{"version":3,"file":"InputRenderer.mjs","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n  useStrapiApp,\n  useForm,\n  InputRenderer as FormInputRenderer,\n  useField,\n  createRulesEngine,\n  type JsonLogicCondition,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\nimport { useHasInputPopoverParent } from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\nimport {\n  getConditionDependencyPaths,\n  getConditionDependencySubscriptionValue,\n} from '../../../utils/conditionalFields';\nimport { getDirectParent } from '../utils/data';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n  document?: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst BaseInputRenderer = ({\n  visible,\n  hint: providedHint,\n  document: providedDocument,\n  ...inputProps\n}: InputRendererProps) => {\n  const { currentDocument, currentDocumentMeta } = useDocumentContext('DynamicComponent');\n  // Most edit-view fields can read the document from context, which avoids threading a\n  // frequently-changing `document` prop through nested component/DZ trees and reduces churn.\n  // Keep `providedDocument` as an explicit override for callers outside that default flow.\n  const document = providedDocument ?? currentDocument;\n  const localeKey = document?.document?.locale || 'default';\n  const {\n    edit: { components },\n  } = useDocumentLayout(currentDocumentMeta.model);\n\n  const collectionType =\n    document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n  const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n  const isInPreviewPopover = useHasInputPopoverParent();\n  const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;\n\n  const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n  const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n  const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n  const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n  const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n  let idToCheck = document.document?.documentId;\n  if (collectionType === SINGLE_TYPES) {\n    idToCheck = document?.document?.documentId;\n  }\n\n  const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n  const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n  // Everything preview related\n  const previewProps = usePreviewInputManager(inputProps.name, inputProps.attribute);\n  const props = { ...inputProps, ...previewProps };\n\n  /**\n   * Component fields are always readable and editable,\n   * however the fields within them may not be.\n   */\n  const canUserReadField = canUserAction(props.name, readableFields, props.type);\n  const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n  const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n  const { lazyComponentStore } = useLazyComponents(\n    attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n  );\n\n  const hint = useFieldHint(providedHint, props.attribute);\n  const renderComponentInput = React.useCallback(\n    (componentInputProps: InputRendererProps) => (\n      <MemoizedInputRenderer\n        key={`input-${componentInputProps.name}-${localeKey}`}\n        {...componentInputProps}\n      />\n    ),\n    [localeKey]\n  );\n\n  // We pass field in case of Custom Fields to keep backward compatibility\n  const field = useField(props.name);\n\n  if (!visible) {\n    return null;\n  }\n\n  /**\n   * If the user can't read the field then we don't want to ever render it.\n   */\n  if (!canUserReadField && !shouldIgnorePermissions) {\n    return <NotAllowedInput hint={hint} {...props} />;\n  }\n\n  const fieldIsDisabled =\n    (!canUserEditField && !shouldIgnorePermissions) || props.disabled || isFormDisabled;\n\n  /**\n   * Because a custom field has a unique prop but the type could be confused with either\n   * the useField hook or the type of the field we need to handle it separately and first.\n   */\n  if (attributeHasCustomFieldProperty(props.attribute)) {\n    const CustomInput = lazyComponentStore[props.attribute.customField];\n\n    if (CustomInput) {\n      return (\n        <CustomInput\n          {...props}\n          {...field}\n          // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n          hint={hint}\n          disabled={fieldIsDisabled}\n        />\n      );\n    }\n\n    return (\n      <FormInputRenderer\n        key={`input-${props.name}-${localeKey}`}\n        {...props}\n        {...previewProps}\n        hint={hint}\n        // @ts-expect-error – this workaround lets us display that the custom field is missing.\n        type={props.attribute.customField}\n        disabled={fieldIsDisabled}\n      />\n    );\n  }\n\n  /**\n   * This is where we handle ONLY the fields from the `useLibrary` hook.\n   */\n  const addedInputTypes = Object.keys(fields);\n  if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n    const CustomInput = fields[props.type];\n    return (\n      <CustomInput\n        key={`input-${props.name}-${localeKey}`}\n        {...props}\n        // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n        hint={hint}\n        disabled={fieldIsDisabled}\n      />\n    );\n  }\n\n  /**\n   * These include the content-manager specific fields, failing that we fall back\n   * to the more generic form input renderer.\n   */\n  switch (props.type) {\n    case 'blocks':\n      return (\n        <BlocksInput\n          key={`input-${props.name}-${localeKey}`}\n          {...props}\n          hint={hint}\n          type={props.type}\n          disabled={fieldIsDisabled}\n        />\n      );\n    case 'component':\n      // Preview focus/blur handlers are not used for data-structure roots (component/dynamic zone).\n      // Dropping them avoids unstable function props cascading through memoized component trees.\n      const { onBlur: _onComponentBlur, onFocus: _onComponentFocus, ...componentProps } = props;\n\n      return (\n        <ComponentInput\n          key={`input-${props.name}-${localeKey}`}\n          {...componentProps}\n          hint={hint}\n          layout={components[props.attribute.component].layout}\n          disabled={fieldIsDisabled}\n        >\n          {renderComponentInput}\n        </ComponentInput>\n      );\n    case 'dynamiczone':\n      // Same rationale as `component` above: keep data-structure root props stable.\n      const { onBlur: _onDzBlur, onFocus: _onDzFocus, ...dynamicZoneProps } = props;\n\n      return (\n        <DynamicZone\n          key={`input-${props.name}-${localeKey}`}\n          {...dynamicZoneProps}\n          hint={hint}\n          disabled={fieldIsDisabled}\n        />\n      );\n    case 'relation':\n      return (\n        <RelationsInput\n          key={`input-${props.name}-${localeKey}`}\n          {...props}\n          hint={hint}\n          disabled={fieldIsDisabled}\n        />\n      );\n    case 'richtext':\n      return (\n        <Wysiwyg\n          key={`input-${props.name}-${localeKey}`}\n          {...props}\n          hint={hint}\n          type={props.type}\n          disabled={fieldIsDisabled}\n        />\n      );\n    case 'uid':\n      // These props are not needed for the generic form input renderer.\n      const { unique: _uniqueUID, ...restUIDProps } = props;\n      return (\n        <UIDInput\n          key={`input-${props.name}-${localeKey}`}\n          {...restUIDProps}\n          hint={hint}\n          type={props.type}\n          disabled={fieldIsDisabled}\n        />\n      );\n    /**\n     * Enumerations are a special case because they require options.\n     */\n    case 'enumeration':\n      return (\n        <FormInputRenderer\n          key={`input-${props.name}-${localeKey}`}\n          {...props}\n          {...previewProps}\n          hint={hint}\n          options={props.attribute.enum.map((value) => ({ value }))}\n          // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n          type={props.customField ? 'custom-field' : props.type}\n          disabled={fieldIsDisabled}\n        />\n      );\n    default:\n      // These props are not needed for the generic form input renderer.\n      const { unique: _unique, mainField: _mainField, ...restProps } = props;\n      return (\n        <FormInputRenderer\n          key={`input-${props.name}-${localeKey}`}\n          {...restProps}\n          {...previewProps}\n          hint={hint}\n          // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n          type={props.customField ? 'custom-field' : props.type}\n          disabled={fieldIsDisabled}\n        />\n      );\n  }\n};\n\n// Reuse one rules engine instance instead of recreating it for every field render.\nconst rulesEngine = createRulesEngine();\n\n/**\n * A wrapper around BaseInputRenderer that conditionally renders it depending on the attribute's condition.\n */\nconst ConditionAwareInputRenderer = ({\n  condition,\n  ...props\n}: InputRendererProps & { condition: JsonLogicCondition }) => {\n  // Extract only the field paths the visibility rule depends on so unrelated form changes\n  // do not force this conditional field to re-render.\n  const conditionDependencyPaths = React.useMemo(\n    () => getConditionDependencyPaths(condition),\n    [condition]\n  );\n  const getValues = useForm(\n    'ConditionalInputRenderer',\n    (state) => (state as typeof state & { getValues: () => unknown }).getValues\n  );\n  const conditionSubscriptionValue = useForm('ConditionalInputRenderer', (state) => {\n    // Subscribe to a small, comparable snapshot of the parent scope instead of all form values.\n    return getConditionDependencySubscriptionValue(\n      getDirectParent(state.values, props.name),\n      conditionDependencyPaths\n    );\n  });\n\n  // When dependencies are known, read the latest parent scope lazily via getValues() so the\n  // rule still evaluates against fresh data without subscribing to every form change.\n  const targetValues =\n    conditionDependencyPaths === null\n      ? conditionSubscriptionValue\n      : getDirectParent(getValues(), props.name);\n\n  const isVisible = rulesEngine.evaluate(condition, targetValues);\n\n  if (!isVisible) {\n    return null;\n  }\n\n  return <BaseInputRenderer {...props} />;\n};\n\nconst attributeHasCustomFieldProperty = (\n  attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n  'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n  hint: React.ReactNode = undefined,\n  attribute: Schema.Attribute.AnyAttribute\n) => {\n  const { formatMessage } = useIntl();\n\n  const { maximum, minimum } = getMinMax(attribute);\n\n  if (!maximum && !minimum) {\n    return hint;\n  }\n\n  const units = ['string', 'uid', 'richtext', 'email', 'password', 'text'].includes(attribute.type)\n    ? formatMessage(\n        {\n          id: 'content-manager.form.Input.hint.character.unit',\n          defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n        },\n        {\n          maxValue: Math.max(minimum || 0, maximum || 0),\n        }\n      )\n    : null;\n\n  const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n  return formatMessage(\n    {\n      id: 'content-manager.form.Input.hint.text',\n      defaultMessage:\n        '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n    },\n    {\n      min: minimum,\n      max: maximum,\n      description: hint,\n      unit: units,\n      divider: hasMinAndMax\n        ? formatMessage({\n            id: 'content-manager.form.Input.hint.minMaxDivider',\n            defaultMessage: ' / ',\n          })\n        : null,\n      br: <br />,\n    }\n  );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n  if ('min' in attribute || 'max' in attribute) {\n    return {\n      maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n      minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n    };\n  } else if ('maxLength' in attribute || 'minLength' in attribute) {\n    return { maximum: attribute.maxLength, minimum: attribute.minLength };\n  } else {\n    return { maximum: undefined, minimum: undefined };\n  }\n};\n\n/**\n * Conditionally routes the exported InputRender component towards ConditionalInputRenderer\n * (when there's a JSON logic condition on the attribute, or BaseInputRenderer otherwise.\n * We do this because rendering a conditional field requires access to the values of\n * other form fields, which causes many re-renders and performance issues on complex content\n * types. By splitting the component into two, we isolate the performance issue to\n * conditional fields only, not all edit view fields.\n */\nconst MemoizedInputRenderer = React.memo((props: InputRendererProps) => {\n  const condition = props.attribute.conditions?.visible;\n  if (condition) {\n    return <ConditionAwareInputRenderer {...props} condition={condition} />;\n  }\n\n  return <BaseInputRenderer {...props} />;\n});\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["BaseInputRenderer","visible","hint","providedHint","document","providedDocument","inputProps","currentDocument","currentDocumentMeta","useDocumentContext","localeKey","locale","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","shouldIgnorePermissions","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","previewProps","usePreviewInputManager","name","attribute","props","canUserReadField","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","renderComponentInput","React","useCallback","componentInputProps","_jsx","MemoizedInputRenderer","field","useField","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","onBlur","_onComponentBlur","onFocus","_onComponentFocus","componentProps","ComponentInput","layout","component","_onDzBlur","_onDzFocus","dynamicZoneProps","DynamicZone","RelationsInput","Wysiwyg","unique","_uniqueUID","restUIDProps","UIDInput","options","enum","map","value","_unique","mainField","_mainField","restProps","rulesEngine","createRulesEngine","ConditionAwareInputRenderer","condition","conditionDependencyPaths","useMemo","getConditionDependencyPaths","getValues","conditionSubscriptionValue","getConditionDependencySubscriptionValue","getDirectParent","values","targetValues","isVisible","evaluate","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","memo","conditions"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0CA;;;;;;;AAOC,IACD,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,OAAO,EACPC,IAAAA,EAAMC,YAAY,EAClBC,QAAAA,EAAUC,gBAAgB,EAC1B,GAAGC,UAAAA,EACgB,GAAA;AACnB,IA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