@payloadcms/ui 3.57.0-internal.98b3a35 → 3.57.0-internal.d2ddce7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/elements/BulkUpload/FileSidebar/index.d.ts.map +1 -1
  2. package/dist/elements/BulkUpload/FileSidebar/index.js +38 -74
  3. package/dist/elements/BulkUpload/FileSidebar/index.js.map +1 -1
  4. package/dist/elements/BulkUpload/FileSidebar/index.scss +1 -14
  5. package/dist/elements/BulkUpload/FormsManager/index.d.ts +1 -6
  6. package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
  7. package/dist/elements/BulkUpload/FormsManager/index.js +14 -52
  8. package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
  9. package/dist/elements/BulkUpload/FormsManager/reducer.d.ts +2 -2
  10. package/dist/elements/BulkUpload/FormsManager/reducer.d.ts.map +1 -1
  11. package/dist/elements/BulkUpload/FormsManager/reducer.js +5 -5
  12. package/dist/elements/BulkUpload/FormsManager/reducer.js.map +1 -1
  13. package/dist/elements/BulkUpload/index.d.ts +5 -30
  14. package/dist/elements/BulkUpload/index.d.ts.map +1 -1
  15. package/dist/elements/BulkUpload/index.js +28 -130
  16. package/dist/elements/BulkUpload/index.js.map +1 -1
  17. package/dist/elements/Status/index.d.ts.map +1 -1
  18. package/dist/elements/Status/index.js +1 -1
  19. package/dist/elements/Status/index.js.map +1 -1
  20. package/dist/exports/client/index.js +24 -24
  21. package/dist/exports/client/index.js.map +3 -3
  22. package/dist/fields/Upload/Input.js +20 -20
  23. package/dist/fields/Upload/Input.js.map +1 -1
  24. package/dist/forms/Form/index.js +2 -1
  25. package/dist/forms/Form/index.js.map +1 -1
  26. package/dist/forms/RenderFields/RenderField.js +236 -223
  27. package/dist/forms/RenderFields/RenderField.js.map +1 -1
  28. package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
  29. package/dist/forms/fieldSchemasToFormState/renderField.js +1 -2
  30. package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
  31. package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.d.ts.map +1 -1
  32. package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js +0 -2
  33. package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js.map +1 -1
  34. package/dist/forms/fieldSchemasToFormState/types.d.ts +0 -6
  35. package/dist/forms/fieldSchemasToFormState/types.d.ts.map +1 -1
  36. package/dist/forms/fieldSchemasToFormState/types.js.map +1 -1
  37. package/dist/styles.css +1 -1
  38. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"renderField.js","names":["getTranslation","createClientField","MissingEditorProp","fieldIsHiddenOrDisabled","RenderServerComponent","FieldDescription","WatchCondition","defaultUIFieldComponentKeys","renderField","id","clientFieldSchemaMap","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","forceCreateClientField","formState","indexPath","lastRenderedPath","mockRSCs","operation","parentPath","parentSchemaPath","path","permissions","preferences","readOnly","readOnlyFromProps","renderAllFields","req","schemaPath","siblingData","requiresRender","type","clientField","get","defaultIDType","payload","config","db","field","i18n","importMap","clientProps","customComponents","includes","serverProps","user","value","name","rows","forEach","row","rowIndex","rowLastRenderedPath","rowPath","rowRequiresRender","admin","components","RowLabel","Component","key","rowLabel","labels","singular","String","padStart","rowNumber","blockTypeToMatch","blockType","blockConfig","blocks","blockReferences","find","block","slug","Label","Object","keys","length","description","editor","Error","Field","_jsx","FieldComponent","Description","t","AfterInput","afterInput","BeforeInput","beforeInput"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\n FlattenedBlock,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, MissingEditorProp } from 'payload'\nimport { fieldIsHiddenOrDisabled } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\nimport { FieldDescription, WatchCondition } from '../../exports/client/index.js'\n\nconst defaultUIFieldComponentKeys: Array<'Cell' | 'Description' | 'Field' | 'Filter'> = [\n 'Cell',\n 'Description',\n 'Field',\n 'Filter',\n]\n\nexport const renderField: RenderFieldMethod = ({\n id,\n clientFieldSchemaMap,\n collectionSlug,\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n forceCreateClientField,\n formState,\n indexPath,\n lastRenderedPath,\n mockRSCs,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions,\n preferences,\n readOnly: readOnlyFromProps,\n renderAllFields,\n req,\n schemaPath,\n siblingData,\n}) => {\n const requiresRender = renderAllFields || !lastRenderedPath || lastRenderedPath !== path\n\n if (!requiresRender && fieldConfig.type !== 'array' && fieldConfig.type !== 'blocks') {\n return\n }\n\n const clientField =\n clientFieldSchemaMap && !forceCreateClientField\n ? (clientFieldSchemaMap.get(schemaPath) as ClientField)\n : createClientField({\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n })\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n field: clientField,\n path,\n permissions,\n readOnly:\n readOnlyFromProps === true\n ? true\n : typeof permissions === 'boolean'\n ? !permissions\n : !permissions?.[operation],\n schemaPath,\n }\n\n if (fieldState?.customComponents) {\n clientProps.customComponents = fieldState.customComponents\n }\n\n // fields with subfields\n if (['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'].includes(fieldConfig.type)) {\n clientProps.indexPath = indexPath\n clientProps.parentPath = parentPath\n clientProps.parentSchemaPath = parentSchemaPath\n }\n\n const serverProps: ServerComponentProps = {\n id,\n clientField,\n clientFieldSchemaMap,\n data,\n field: fieldConfig,\n fieldSchemaMap,\n permissions,\n // TODO: Should we pass explicit values? initialValue, value, valid\n // value and initialValue should be typed\n collectionSlug,\n formState,\n i18n: req.i18n,\n operation,\n payload: req.payload,\n preferences,\n req,\n siblingData,\n user: req.user,\n value: 'name' in fieldConfig && data?.[fieldConfig.name],\n }\n\n switch (fieldConfig.type) {\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n const rowLastRenderedPath = row.lastRenderedPath\n\n const rowPath = `${path}.${rowIndex}`\n\n const rowRequiresRender =\n renderAllFields || !rowLastRenderedPath || rowLastRenderedPath !== rowPath\n\n if (!rowRequiresRender) {\n return\n }\n\n row.lastRenderedPath = rowPath\n\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!row.customComponents) {\n row.customComponents = {}\n }\n\n row.customComponents.RowLabel = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.RowLabel,\n importMap: req.payload.importMap,\n key: `${rowIndex}`,\n serverProps: {\n ...serverProps,\n rowLabel: `${getTranslation(fieldConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n },\n })\n : 'Mock'\n }\n })\n\n break\n }\n\n case 'blocks': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n const rowLastRenderedPath = row.lastRenderedPath\n\n const rowPath = `${path}.${rowIndex}`\n\n const rowRequiresRender =\n renderAllFields || !rowLastRenderedPath || rowLastRenderedPath !== rowPath\n\n if (!rowRequiresRender) {\n return\n }\n\n row.lastRenderedPath = rowPath\n\n const blockTypeToMatch: string = row.blockType\n\n const blockConfig =\n req.payload.blocks[blockTypeToMatch] ??\n ((fieldConfig.blockReferences ?? fieldConfig.blocks).find(\n (block) => typeof block !== 'string' && block.slug === blockTypeToMatch,\n ) as FlattenedBlock | undefined)\n\n if (blockConfig.admin?.components && 'Label' in blockConfig.admin.components) {\n if (!fieldState.rows[rowIndex]?.customComponents) {\n fieldState.rows[rowIndex].customComponents = {}\n }\n\n fieldState.rows[rowIndex].customComponents.RowLabel = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: blockConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: `${rowIndex}`,\n serverProps: {\n ...serverProps,\n blockType: row.blockType,\n rowLabel: `${getTranslation(blockConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n },\n })\n : 'Mock'\n }\n })\n\n break\n }\n }\n\n if (!requiresRender) {\n return\n }\n\n /**\n * Set the `lastRenderedPath` equal to the new path of the field, this will prevent it from being rendered again\n */\n fieldState.lastRenderedPath = path\n\n if (fieldIsHiddenOrDisabled(clientField)) {\n return\n }\n\n /**\n * Only create the `customComponents` object if needed.\n * This will prevent unnecessary data from being transferred to the client.\n */\n if (fieldConfig.admin) {\n if (\n (Object.keys(fieldConfig.admin.components || {}).length > 0 ||\n fieldConfig.type === 'richText' ||\n ('description' in fieldConfig.admin &&\n typeof fieldConfig.admin.description === 'function')) &&\n !fieldState?.customComponents\n ) {\n fieldState.customComponents = {}\n }\n }\n\n switch (fieldConfig.type) {\n case 'richText': {\n if (!fieldConfig?.editor) {\n throw new MissingEditorProp(fieldConfig) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof fieldConfig?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!fieldConfig.admin) {\n fieldConfig.admin = {}\n }\n\n if (!fieldConfig.admin.components) {\n fieldConfig.admin.components = {}\n }\n\n fieldState.customComponents.Field = !mockRSCs ? (\n <WatchCondition path={path}>\n {RenderServerComponent({\n clientProps,\n Component: fieldConfig.editor.FieldComponent,\n importMap: req.payload.importMap,\n serverProps,\n })}\n </WatchCondition>\n ) : (\n 'Mock'\n )\n\n break\n }\n\n case 'ui': {\n if (fieldConfig?.admin?.components) {\n // Render any extra, untyped components\n for (const key in fieldConfig.admin.components) {\n if (key in defaultUIFieldComponentKeys) {\n continue\n }\n\n const Component = fieldConfig.admin.components[key]\n\n fieldState.customComponents[key] = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component,\n importMap: req.payload.importMap,\n key: `field.admin.components.${key}`,\n serverProps,\n })\n : 'Mock'\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if (\n 'description' in fieldConfig.admin &&\n typeof fieldConfig.admin?.description === 'function'\n ) {\n fieldState.customComponents.Description = !mockRSCs ? (\n <FieldDescription\n description={fieldConfig.admin?.description({\n i18n: req.i18n,\n t: req.i18n.t,\n })}\n path={path}\n />\n ) : (\n 'Mock'\n )\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.afterInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.afterInput',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.beforeInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.beforeInput',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Description,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Description',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Error,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Error',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Label',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = !mockRSCs ? (\n <WatchCondition path={path}>\n {RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Field,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Field',\n serverProps,\n })}\n </WatchCondition>\n ) : (\n 'Mock'\n )\n }\n }\n }\n}\n"],"mappings":";AAQA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,iBAAiB,QAAQ;AACrD,SAASC,uBAAuB,QAAQ;AAIxC,SAASC,qBAAqB,QAAQ;AAEtC;AACA,SAASC,gBAAgB,EAAEC,cAAc,QAAQ;AAEjD,MAAMC,2BAAA,GAAkF,CACtF,QACA,eACA,SACA,SACD;AAED,OAAO,MAAMC,WAAA,GAAiCA,CAAC;EAC7CC,EAAE;EACFC,oBAAoB;EACpBC,cAAc;EACdC,IAAI;EACJC,WAAW;EACXC,cAAc;EACdC,UAAU;EACVC,sBAAsB;EACtBC,SAAS;EACTC,SAAS;EACTC,gBAAgB;EAChBC,QAAQ;EACRC,SAAS;EACTC,UAAU;EACVC,gBAAgB;EAChBC,IAAI;EACJC,WAAW;EACXC,WAAW;EACXC,QAAA,EAAUC,iBAAiB;EAC3BC,eAAe;EACfC,GAAG;EACHC,UAAU;EACVC;AAAW,CACZ;EACC,MAAMC,cAAA,GAAiBJ,eAAA,IAAmB,CAACV,gBAAA,IAAoBA,gBAAA,KAAqBK,IAAA;EAEpF,IAAI,CAACS,cAAA,IAAkBpB,WAAA,CAAYqB,IAAI,KAAK,WAAWrB,WAAA,CAAYqB,IAAI,KAAK,UAAU;IACpF;EACF;EAEA,MAAMC,WAAA,GACJzB,oBAAA,IAAwB,CAACM,sBAAA,GACpBN,oBAAA,CAAqB0B,GAAG,CAACL,UAAA,IAC1B9B,iBAAA,CAAkB;IAChBoC,aAAA,EAAeP,GAAA,CAAIQ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K;UAC7CxC,SAAA,EAAWb,GAAA,CAAIQ,OAAO,CAACK,SAAS;UAChCmB,GAAA,EAAK;UACLf;QACF,KACA;MACN;MAEA,IAAI,WAAWlC,WAAA,CAAY6C,KAAK,CAACC,UAAU,EAAE;QAC3C5C,UAAA,CAAW8B,gBAAgB,CAACgC,KAAK,GAAG,CAACzD,QAAA,GACjChB,qBAAA,CAAsB;UACpBwC,WAAA;UACAiB,SAAA,EAAWhD,WAAA,CAAY6C,KAAK,CAACC,UAAU,CAACkB,KAAK;UAC7ClC,SAAA,EAAWb,GAAA,CAAIQ,OAAO,CAACK,SAAS;UAChCmB,GAAA,EAAK;UACLf;QACF,KACA;MACN;MAEA,IAAI,WAAWlC,WAAA,CAAY6C,KAAK,CAACC,UAAU,EAAE;QAC3C5C,UAAA,CAAW8B,gBAAgB,CAACuC,KAAK,GAAG,CAAChE,QAAA,gBACnCiE,IAAA,CAAC/E,cAAA;UAAekB,IAAA,EAAMA,IAAA;oBACnBpB,qBAAA,CAAsB;YACrBwC,WAAA;YACAiB,SAAA,EAAWhD,WAAA,CAAY6C,KAAK,CAACC,UAAU,CAACyB,KAAK;YAC7CzC,SAAA,EAAWb,GAAA,CAAIQ,OAAO,CAACK,SAAS;YAChCmB,GAAA,EAAK;YACLf;UACF;aAGF;MAEJ;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"renderField.js","names":["getTranslation","createClientField","MissingEditorProp","fieldIsHiddenOrDisabled","RenderServerComponent","FieldDescription","WatchCondition","defaultUIFieldComponentKeys","renderField","id","clientFieldSchemaMap","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","lastRenderedPath","mockRSCs","operation","parentPath","parentSchemaPath","path","permissions","preferences","readOnly","readOnlyFromProps","renderAllFields","req","schemaPath","siblingData","requiresRender","type","clientField","get","defaultIDType","payload","config","db","field","i18n","importMap","clientProps","customComponents","includes","serverProps","user","value","name","rows","forEach","row","rowIndex","rowLastRenderedPath","rowPath","rowRequiresRender","admin","components","RowLabel","Component","key","rowLabel","labels","singular","String","padStart","rowNumber","blockTypeToMatch","blockType","blockConfig","blocks","blockReferences","find","block","slug","Label","Object","keys","length","description","editor","Error","Field","_jsx","FieldComponent","Description","t","AfterInput","afterInput","BeforeInput","beforeInput"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\n FlattenedBlock,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, MissingEditorProp } from 'payload'\nimport { fieldIsHiddenOrDisabled } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\nimport { FieldDescription, WatchCondition } from '../../exports/client/index.js'\n\nconst defaultUIFieldComponentKeys: Array<'Cell' | 'Description' | 'Field' | 'Filter'> = [\n 'Cell',\n 'Description',\n 'Field',\n 'Filter',\n]\n\nexport const renderField: RenderFieldMethod = ({\n id,\n clientFieldSchemaMap,\n collectionSlug,\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n formState,\n indexPath,\n lastRenderedPath,\n mockRSCs,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions,\n preferences,\n readOnly: readOnlyFromProps,\n renderAllFields,\n req,\n schemaPath,\n siblingData,\n}) => {\n const requiresRender = renderAllFields || !lastRenderedPath || lastRenderedPath !== path\n\n if (!requiresRender && fieldConfig.type !== 'array' && fieldConfig.type !== 'blocks') {\n return\n }\n\n const clientField = clientFieldSchemaMap\n ? (clientFieldSchemaMap.get(schemaPath) as ClientField)\n : createClientField({\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n })\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n field: clientField,\n path,\n permissions,\n readOnly:\n readOnlyFromProps === true\n ? true\n : typeof permissions === 'boolean'\n ? !permissions\n : !permissions?.[operation],\n schemaPath,\n }\n\n if (fieldState?.customComponents) {\n clientProps.customComponents = fieldState.customComponents\n }\n\n // fields with subfields\n if (['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'].includes(fieldConfig.type)) {\n clientProps.indexPath = indexPath\n clientProps.parentPath = parentPath\n clientProps.parentSchemaPath = parentSchemaPath\n }\n\n const serverProps: ServerComponentProps = {\n id,\n clientField,\n clientFieldSchemaMap,\n data,\n field: fieldConfig,\n fieldSchemaMap,\n permissions,\n // TODO: Should we pass explicit values? initialValue, value, valid\n // value and initialValue should be typed\n collectionSlug,\n formState,\n i18n: req.i18n,\n operation,\n payload: req.payload,\n preferences,\n req,\n siblingData,\n user: req.user,\n value: 'name' in fieldConfig && data?.[fieldConfig.name],\n }\n\n switch (fieldConfig.type) {\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n const rowLastRenderedPath = row.lastRenderedPath\n\n const rowPath = `${path}.${rowIndex}`\n\n const rowRequiresRender =\n renderAllFields || !rowLastRenderedPath || rowLastRenderedPath !== rowPath\n\n if (!rowRequiresRender) {\n return\n }\n\n row.lastRenderedPath = rowPath\n\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!row.customComponents) {\n row.customComponents = {}\n }\n\n row.customComponents.RowLabel = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.RowLabel,\n importMap: req.payload.importMap,\n key: `${rowIndex}`,\n serverProps: {\n ...serverProps,\n rowLabel: `${getTranslation(fieldConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n },\n })\n : 'Mock'\n }\n })\n\n break\n }\n\n case 'blocks': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n const rowLastRenderedPath = row.lastRenderedPath\n\n const rowPath = `${path}.${rowIndex}`\n\n const rowRequiresRender =\n renderAllFields || !rowLastRenderedPath || rowLastRenderedPath !== rowPath\n\n if (!rowRequiresRender) {\n return\n }\n\n row.lastRenderedPath = rowPath\n\n const blockTypeToMatch: string = row.blockType\n\n const blockConfig =\n req.payload.blocks[blockTypeToMatch] ??\n ((fieldConfig.blockReferences ?? fieldConfig.blocks).find(\n (block) => typeof block !== 'string' && block.slug === blockTypeToMatch,\n ) as FlattenedBlock | undefined)\n\n if (blockConfig.admin?.components && 'Label' in blockConfig.admin.components) {\n if (!fieldState.rows[rowIndex]?.customComponents) {\n fieldState.rows[rowIndex].customComponents = {}\n }\n\n fieldState.rows[rowIndex].customComponents.RowLabel = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: blockConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: `${rowIndex}`,\n serverProps: {\n ...serverProps,\n blockType: row.blockType,\n rowLabel: `${getTranslation(blockConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n },\n })\n : 'Mock'\n }\n })\n\n break\n }\n }\n\n if (!requiresRender) {\n return\n }\n\n /**\n * Set the `lastRenderedPath` equal to the new path of the field, this will prevent it from being rendered again\n */\n fieldState.lastRenderedPath = path\n\n if (fieldIsHiddenOrDisabled(clientField)) {\n return\n }\n\n /**\n * Only create the `customComponents` object if needed.\n * This will prevent unnecessary data from being transferred to the client.\n */\n if (fieldConfig.admin) {\n if (\n (Object.keys(fieldConfig.admin.components || {}).length > 0 ||\n fieldConfig.type === 'richText' ||\n ('description' in fieldConfig.admin &&\n typeof fieldConfig.admin.description === 'function')) &&\n !fieldState?.customComponents\n ) {\n fieldState.customComponents = {}\n }\n }\n\n switch (fieldConfig.type) {\n case 'richText': {\n if (!fieldConfig?.editor) {\n throw new MissingEditorProp(fieldConfig) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof fieldConfig?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!fieldConfig.admin) {\n fieldConfig.admin = {}\n }\n\n if (!fieldConfig.admin.components) {\n fieldConfig.admin.components = {}\n }\n\n fieldState.customComponents.Field = !mockRSCs ? (\n <WatchCondition path={path}>\n {RenderServerComponent({\n clientProps,\n Component: fieldConfig.editor.FieldComponent,\n importMap: req.payload.importMap,\n serverProps,\n })}\n </WatchCondition>\n ) : (\n 'Mock'\n )\n\n break\n }\n\n case 'ui': {\n if (fieldConfig?.admin?.components) {\n // Render any extra, untyped components\n for (const key in fieldConfig.admin.components) {\n if (key in defaultUIFieldComponentKeys) {\n continue\n }\n\n const Component = fieldConfig.admin.components[key]\n\n fieldState.customComponents[key] = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component,\n importMap: req.payload.importMap,\n key: `field.admin.components.${key}`,\n serverProps,\n })\n : 'Mock'\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if (\n 'description' in fieldConfig.admin &&\n typeof fieldConfig.admin?.description === 'function'\n ) {\n fieldState.customComponents.Description = !mockRSCs ? (\n <FieldDescription\n description={fieldConfig.admin?.description({\n i18n: req.i18n,\n t: req.i18n.t,\n })}\n path={path}\n />\n ) : (\n 'Mock'\n )\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.afterInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.afterInput',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.beforeInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.beforeInput',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Description,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Description',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Error,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Error',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Label',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = !mockRSCs ? (\n <WatchCondition path={path}>\n {RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Field,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Field',\n serverProps,\n })}\n </WatchCondition>\n ) : (\n 'Mock'\n )\n }\n }\n }\n}\n"],"mappings":";AAQA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,iBAAiB,QAAQ;AACrD,SAASC,uBAAuB,QAAQ;AAIxC,SAASC,qBAAqB,QAAQ;AAEtC;AACA,SAASC,gBAAgB,EAAEC,cAAc,QAAQ;AAEjD,MAAMC,2BAAA,GAAkF,CACtF,QACA,eACA,SACA,SACD;AAED,OAAO,MAAMC,WAAA,GAAiCA,CAAC;EAC7CC,EAAE;EACFC,oBAAoB;EACpBC,cAAc;EACdC,IAAI;EACJC,WAAW;EACXC,cAAc;EACdC,UAAU;EACVC,SAAS;EACTC,SAAS;EACTC,gBAAgB;EAChBC,QAAQ;EACRC,SAAS;EACTC,UAAU;EACVC,gBAAgB;EAChBC,IAAI;EACJC,WAAW;EACXC,WAAW;EACXC,QAAA,EAAUC,iBAAiB;EAC3BC,eAAe;EACfC,GAAG;EACHC,UAAU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ts","sourceRoot":"","sources":["../../../../src/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAOrF,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;;;OASG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,6BAA6B,GAAG,EAAE,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAA;AAE/E;;GAEG;AACH,eAAO,MAAM,4BAA4B,EAAE,cAAc,CACvD,uBAAuB,EACvB,OAAO,CAAC,6BAA6B,CAAC,CA8EvC,CAAA"}
1
+ {"version":3,"file":"renderFieldServerFn.d.ts","sourceRoot":"","sources":["../../../../src/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAOrF,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;;;OASG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,6BAA6B,GAAG,EAAE,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAA;AAE/E;;GAEG;AACH,eAAO,MAAM,4BAA4B,EAAE,cAAc,CACvD,uBAAuB,EACvB,OAAO,CAAC,6BAA6B,CAAC,CA4EvC,CAAA"}
@@ -72,8 +72,6 @@ export const _internal_renderFieldHandler = async ({
72
72
  preferences: {
73
73
  fields: {}
74
74
  },
75
- // If we are passed a field override, we want to ensure we create a new client field based on that override
76
- forceCreateClientField: fieldArg ? true : false,
77
75
  previousFieldState: undefined,
78
76
  renderAllFields: true,
79
77
  req,
@@ -1 +1 @@
1
- {"version":3,"file":"renderFieldServerFn.js","names":["deepMerge","getClientConfig","getClientSchemaMap","getSchemaMap","renderField","_internal_renderFieldHandler","field","fieldArg","initialValue","path","req","schemaPath","user","Error","entityType","entitySlug","fieldPath","split","schemaMap","collectionSlug","undefined","config","payload","globalSlug","i18n","clientSchemaMap","importMap","targetField","get","join","clone","data","name","fieldState","clientFieldSchemaMap","fieldConfig","fieldSchemaMap","formState","indexPath","lastRenderedPath","operation","parentPath","parentSchemaPath","permissions","preferences","fields","forceCreateClientField","previousFieldState","renderAllFields","siblingData","customComponents"],"sources":["../../../../src/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.ts"],"sourcesContent":["import { deepMerge, type Field, type FieldState, type ServerFunction } from 'payload'\n\nimport { getClientConfig } from '../../../utilities/getClientConfig.js'\nimport { getClientSchemaMap } from '../../../utilities/getClientSchemaMap.js'\nimport { getSchemaMap } from '../../../utilities/getSchemaMap.js'\nimport { renderField } from '../renderField.js'\n\nexport type RenderFieldServerFnArgs = {\n /**\n * Override field config pulled from schemaPath lookup\n */\n field?: Partial<Field>\n /**\n * Pass the value this field will receive when rendering it on the server.\n * For richText, this helps provide initial state for sub-fields that are immediately rendered (like blocks)\n * so that we can avoid multiple waterfall requests for each block that renders on the client.\n */\n initialValue?: unknown\n /**\n * Path to the field to render\n * @default field name\n */\n path?: string\n /**\n * Dot schema path to a richText field declared in your config.\n * Format:\n * \"collection.<collectionSlug>.<fieldPath>\"\n * \"global.<globalSlug>.<fieldPath>\"\n *\n * Examples:\n * \"collection.posts.richText\"\n * \"global.siteSettings.content\"\n */\n schemaPath: string\n}\nexport type RenderFieldServerFnReturnType = {} & FieldState['customComponents']\n\n/**\n * @experimental - may break in minor releases\n */\nexport const _internal_renderFieldHandler: ServerFunction<\n RenderFieldServerFnArgs,\n Promise<RenderFieldServerFnReturnType>\n // eslint-disable-next-line @typescript-eslint/require-await\n> = async ({ field: fieldArg, initialValue, path, req, schemaPath }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const [entityType, entitySlug, ...fieldPath] = schemaPath.split('.')\n\n const schemaMap = getSchemaMap({\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n config: req.payload.config,\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n i18n: req.i18n,\n })\n\n // Provide client schema map as it would have been provided if the target editor field would have been rendered.\n // For lexical, only then will it contain all the lexical-internal entries\n const clientSchemaMap = getClientSchemaMap({\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n config: getClientConfig({\n config: req.payload.config,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n user: req.user,\n }),\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n i18n: req.i18n,\n payload: req.payload,\n schemaMap,\n })\n\n const targetField = schemaMap.get(`${entitySlug}.${fieldPath.join('.')}`) as Field | undefined\n\n if (!targetField) {\n throw new Error(`Could not find target field at schemaPath: ${schemaPath}`)\n }\n\n const field: Field = fieldArg ? deepMerge(targetField, fieldArg, { clone: false }) : targetField\n\n let data = {}\n if (typeof initialValue !== 'undefined') {\n if ('name' in field) {\n data[field.name] = initialValue\n } else {\n data = initialValue\n }\n }\n\n const fieldState: FieldState = {}\n renderField({\n clientFieldSchemaMap: clientSchemaMap,\n collectionSlug: entityType === 'collection' && entitySlug ? entitySlug : '-',\n data,\n fieldConfig: field,\n fieldSchemaMap: schemaMap,\n fieldState, // TODO,\n formState: {}, // TODO,\n indexPath: '',\n lastRenderedPath: '',\n operation: 'create',\n parentPath: '',\n parentSchemaPath: '',\n path: path ?? ('name' in field ? field.name : ''),\n permissions: true,\n preferences: {\n fields: {},\n },\n // If we are passed a field override, we want to ensure we create a new client field based on that override\n forceCreateClientField: fieldArg ? true : false,\n previousFieldState: undefined,\n renderAllFields: true,\n req,\n schemaPath: `${entitySlug}.${fieldPath.join('.')}`,\n siblingData: data,\n })\n\n return fieldState.customComponents ?? {}\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAA0D;AAE5E,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,QAAQ;AAC7B,SAASC,WAAW,QAAQ;AAgC5B;;;AAGA,OAAO,MAAMC,4BAAA,GAIT,MAAAA,CAAO;EAAEC,KAAA,EAAOC,QAAQ;EAAEC,YAAY;EAAEC,IAAI;EAAEC,GAAG;EAAEC;AAAU,CAAE;EACjE,IAAI,CAACD,GAAA,CAAIE,IAAI,EAAE;IACb,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAM,CAACC,UAAA,EAAYC,UAAA,EAAY,GAAGC,SAAA,CAAU,GAAGL,UAAA,CAAWM,KAAK,CAAC;EAEhE,MAAMC,SAAA,GAAYf,YAAA,CAAa;IAC7BgB,cAAA,EAAgBL,UAAA,KAAe,eAAeC,UAAA,GAAaK,SAAA;IAC3DC,MAAA,EAAQX,GAAA,CAAIY,OAAO,CAACD,MAAM;IAC1BE,UAAA,EAAYT,UAAA,KAAe,WAAWC,UAAA,GAAaK,SAAA;IACnDI,IAAA,EAAMd,GAAA,CAAIc;EACZ;EAEA;EACA;EACA,MAAMC,eAAA,GAAkBvB,kBAAA,CAAmB;IACzCiB,cAAA,EAAgBL,UAAA,KAAe,eAAeC,UAAA,GAAaK,SAAA;IAC3DC,MAAA,EAAQpB,eAAA,CAAgB;MACtBoB,MAAA,EAAQX,GAAA,CAAIY,OAAO,CAACD,MAAM;MAC1BG,IAAA,EAAMd,GAAA,CAAIc,IAAI;MACdE,SAAA,EAAWhB,GAAA,CAAIY,OAAO,CAACI,SAAS;MAChCd,IAAA,EAAMF,GAAA,C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,OAAO;IAC1CwC,kBAAA,EAAoB3B,SAAA;IACpB4B,eAAA,EAAiB;IACjBtC,GAAA;IACAC,UAAA,EAAY,GAAGI,UAAA,IAAcC,SAAA,CAAUa,IAAI,CAAC,MAAM;IAClDoB,WAAA,EAAalB;EACf;EAEA,OAAOE,UAAA,CAAWiB,gBAAgB,IAAI,CAAC;AACzC","ignoreList":[]}
1
+ {"version":3,"file":"renderFieldServerFn.js","names":["deepMerge","getClientConfig","getClientSchemaMap","getSchemaMap","renderField","_internal_renderFieldHandler","field","fieldArg","initialValue","path","req","schemaPath","user","Error","entityType","entitySlug","fieldPath","split","schemaMap","collectionSlug","undefined","config","payload","globalSlug","i18n","clientSchemaMap","importMap","targetField","get","join","clone","data","name","fieldState","clientFieldSchemaMap","fieldConfig","fieldSchemaMap","formState","indexPath","lastRenderedPath","operation","parentPath","parentSchemaPath","permissions","preferences","fields","previousFieldState","renderAllFields","siblingData","customComponents"],"sources":["../../../../src/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.ts"],"sourcesContent":["import { deepMerge, type Field, type FieldState, type ServerFunction } from 'payload'\n\nimport { getClientConfig } from '../../../utilities/getClientConfig.js'\nimport { getClientSchemaMap } from '../../../utilities/getClientSchemaMap.js'\nimport { getSchemaMap } from '../../../utilities/getSchemaMap.js'\nimport { renderField } from '../renderField.js'\n\nexport type RenderFieldServerFnArgs = {\n /**\n * Override field config pulled from schemaPath lookup\n */\n field?: Partial<Field>\n /**\n * Pass the value this field will receive when rendering it on the server.\n * For richText, this helps provide initial state for sub-fields that are immediately rendered (like blocks)\n * so that we can avoid multiple waterfall requests for each block that renders on the client.\n */\n initialValue?: unknown\n /**\n * Path to the field to render\n * @default field name\n */\n path?: string\n /**\n * Dot schema path to a richText field declared in your config.\n * Format:\n * \"collection.<collectionSlug>.<fieldPath>\"\n * \"global.<globalSlug>.<fieldPath>\"\n *\n * Examples:\n * \"collection.posts.richText\"\n * \"global.siteSettings.content\"\n */\n schemaPath: string\n}\nexport type RenderFieldServerFnReturnType = {} & FieldState['customComponents']\n\n/**\n * @experimental - may break in minor releases\n */\nexport const _internal_renderFieldHandler: ServerFunction<\n RenderFieldServerFnArgs,\n Promise<RenderFieldServerFnReturnType>\n // eslint-disable-next-line @typescript-eslint/require-await\n> = async ({ field: fieldArg, initialValue, path, req, schemaPath }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const [entityType, entitySlug, ...fieldPath] = schemaPath.split('.')\n\n const schemaMap = getSchemaMap({\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n config: req.payload.config,\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n i18n: req.i18n,\n })\n\n // Provide client schema map as it would have been provided if the target editor field would have been rendered.\n // For lexical, only then will it contain all the lexical-internal entries\n const clientSchemaMap = getClientSchemaMap({\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n config: getClientConfig({\n config: req.payload.config,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n user: req.user,\n }),\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n i18n: req.i18n,\n payload: req.payload,\n schemaMap,\n })\n\n const targetField = schemaMap.get(`${entitySlug}.${fieldPath.join('.')}`) as Field | undefined\n\n if (!targetField) {\n throw new Error(`Could not find target field at schemaPath: ${schemaPath}`)\n }\n\n const field: Field = fieldArg ? deepMerge(targetField, fieldArg, { clone: false }) : targetField\n\n let data = {}\n if (typeof initialValue !== 'undefined') {\n if ('name' in field) {\n data[field.name] = initialValue\n } else {\n data = initialValue\n }\n }\n\n const fieldState: FieldState = {}\n renderField({\n clientFieldSchemaMap: clientSchemaMap,\n collectionSlug: entityType === 'collection' && entitySlug ? entitySlug : '-',\n data,\n fieldConfig: field,\n fieldSchemaMap: schemaMap,\n fieldState, // TODO,\n formState: {}, // TODO,\n indexPath: '',\n lastRenderedPath: '',\n operation: 'create',\n parentPath: '',\n parentSchemaPath: '',\n path: path ?? ('name' in field ? field.name : ''),\n permissions: true,\n preferences: {\n fields: {},\n },\n previousFieldState: undefined,\n renderAllFields: true,\n req,\n schemaPath: `${entitySlug}.${fieldPath.join('.')}`,\n siblingData: data,\n })\n\n return fieldState.customComponents ?? {}\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAA0D;AAE5E,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,QAAQ;AAC7B,SAASC,WAAW,QAAQ;AAgC5B;;;AAGA,OAAO,MAAMC,4BAAA,GAIT,MAAAA,CAAO;EAAEC,KAAA,EAAOC,QAAQ;EAAEC,YAAY;EAAEC,IAAI;EAAEC,GAAG;EAAEC;AAAU,CAAE;EACjE,IAAI,CAACD,GAAA,CAAIE,IAAI,EAAE;IACb,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAM,CAACC,UAAA,EAAYC,UAAA,EAAY,GAAGC,SAAA,CAAU,GAAGL,UAAA,CAAWM,KAAK,CAAC;EAEhE,MAAMC,SAAA,GAAYf,YAAA,CAAa;IAC7BgB,cAAA,EAAgBL,UAAA,KAAe,eAAeC,UAAA,GAAaK,SAAA;IAC3DC,MAAA,EAAQX,GAAA,CAAIY,OAAO,CAACD,MAAM;IAC1BE,UAAA,EAAYT,UAAA,KAAe,WAAWC,UAAA,GAAaK,SAAA;IACnDI,IAAA,EAAMd,GAAA,CAAIc;EACZ;EAEA;EACA;EACA,MAAMC,eAAA,GAAkBvB,kBAAA,CAAmB;IACzCiB,cAAA,EAAgBL,UAAA,KAAe,eAAeC,UAAA,GAAaK,SAAA;IAC3DC,MAAA,EAAQpB,eAAA,CAAgB;MACtBoB,MAAA,EAAQX,GAAA,CAAIY,OAAO,CAACD,MAAM;MAC1BG,IAAA,EAAMd,GAAA,CAAIc,IAAI;MACdE,SAAA,EAAWhB,GAAA,CAAIY,OAAO,CAACI,SAAS;MAChCd,IAAA,EAAMF,GAAA,CAAIE;IACZ;IACAW,UAAA,EAAYT,UAAA,KAAe,WAAWC,UAAA,GAAaK,SAAA;IACnDI,IAAA,E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CAAC,MAAM;IAClDmB,WAAA,EAAajB;EACf;EAEA,OAAOE,UAAA,CAAWgB,gBAAgB,IAAI,CAAC;AACzC","ignoreList":[]}
@@ -6,12 +6,6 @@ export type RenderFieldArgs = {
6
6
  fieldConfig: Field;
7
7
  fieldSchemaMap: FieldSchemaMap;
8
8
  fieldState: FieldState;
9
- /**
10
- * If set to true, it will force creating a clientField based on the passed fieldConfig instead of pulling
11
- * the client field from the clientFieldSchemaMap. This is useful if the passed fieldConfig differs from the one in the schema map,
12
- * e.g. when calling the render-field server function and passing a field config override.
13
- */
14
- forceCreateClientField?: boolean;
15
9
  formState: FormState;
16
10
  id?: number | string;
17
11
  indexPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,IAAI,EACJ,mBAAmB,EACnB,KAAK,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,SAAS,EACT,cAAc,EACd,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAEhB,MAAM,MAAM,eAAe,GAAG;IAC5B,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;IAC3C,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,IAAI,CAAA;IACV,WAAW,EAAE,KAAK,CAAA;IAClB,cAAc,EAAE,cAAc,CAAA;IAC9B,UAAU,EAAE,UAAU,CAAA;IACtB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,SAAS,EAAE,SAAS,CAAA;IACpB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,SAAS,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA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E,UAAU,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,IAAI,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/forms/fieldSchemasToFormState/types.ts"],"sourcesContent":["import type {\n ClientFieldSchemaMap,\n Data,\n DocumentPreferences,\n Field,\n FieldSchemaMap,\n FieldState,\n FormState,\n Operation,\n PayloadRequest,\n SanitizedFieldPermissions,\n} from 'payload'\n\nexport type RenderFieldArgs = {\n clientFieldSchemaMap?: ClientFieldSchemaMap\n collectionSlug: string\n data: Data\n fieldConfig: Field\n fieldSchemaMap: FieldSchemaMap\n fieldState: FieldState\n /**\n * If set to true, it will force creating a clientField based on the passed fieldConfig instead of pulling\n * the client field from the clientFieldSchemaMap. This is useful if the passed fieldConfig differs from the one in the schema map,\n * e.g. when calling the render-field server function and passing a field config override.\n */\n forceCreateClientField?: boolean\n formState: FormState\n id?: number | string\n indexPath: string\n lastRenderedPath: string\n mockRSCs?: boolean\n operation: Operation\n parentPath: string\n parentSchemaPath: string\n path: string\n permissions: SanitizedFieldPermissions\n preferences: DocumentPreferences\n previousFieldState: FieldState\n readOnly?: boolean\n renderAllFields: boolean\n req: PayloadRequest\n schemaPath: string\n siblingData: Data\n}\n\nexport type RenderFieldMethod = (args: RenderFieldArgs) => void\n"],"mappings":"AA6CA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/forms/fieldSchemasToFormState/types.ts"],"sourcesContent":["import type {\n ClientFieldSchemaMap,\n Data,\n DocumentPreferences,\n Field,\n FieldSchemaMap,\n FieldState,\n FormState,\n Operation,\n PayloadRequest,\n SanitizedFieldPermissions,\n} from 'payload'\n\nexport type RenderFieldArgs = {\n clientFieldSchemaMap?: ClientFieldSchemaMap\n collectionSlug: string\n data: Data\n fieldConfig: Field\n fieldSchemaMap: FieldSchemaMap\n fieldState: FieldState\n formState: FormState\n id?: number | string\n indexPath: string\n lastRenderedPath: string\n mockRSCs?: boolean\n operation: Operation\n parentPath: string\n parentSchemaPath: string\n path: string\n permissions: SanitizedFieldPermissions\n preferences: DocumentPreferences\n previousFieldState: FieldState\n readOnly?: boolean\n renderAllFields: boolean\n req: PayloadRequest\n schemaPath: string\n siblingData: Data\n}\n\nexport type RenderFieldMethod = (args: RenderFieldArgs) => void\n"],"mappings":"AAuCA","ignoreList":[]}