@payloadcms/ui 3.0.0-beta.133 → 3.0.0-beta.135
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.
- package/dist/assets/payload-favicon-dark.png +0 -0
- package/dist/assets/payload-favicon-light.png +0 -0
- package/dist/assets/payload-favicon.svg +4 -4
- package/dist/assets/payload-logo-dark.svg +1 -23
- package/dist/assets/payload-logo-light.svg +1 -23
- package/dist/assets/static-og-image.png +0 -0
- package/dist/elements/RelationshipTable/index.d.ts +1 -0
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +3 -2
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/RenderServerComponent/index.d.ts +0 -6
- package/dist/elements/RenderServerComponent/index.d.ts.map +1 -1
- package/dist/elements/RenderServerComponent/index.js +1 -24
- package/dist/elements/RenderServerComponent/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.js +1 -1
- package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.js.map +1 -1
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.d.ts +1 -0
- package/dist/exports/shared/index.d.ts.map +1 -1
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +4 -4
- package/dist/fields/Checkbox/index.d.ts.map +1 -1
- package/dist/fields/Checkbox/index.js +71 -183
- package/dist/fields/Checkbox/index.js.map +1 -1
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +68 -170
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +100 -207
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +72 -162
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Email/index.d.ts.map +1 -1
- package/dist/fields/Email/index.js +72 -161
- package/dist/fields/Email/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +64 -152
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +7 -10
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Join/index.d.ts.map +1 -1
- package/dist/fields/Join/index.js +5 -2
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/fields/Number/index.d.ts.map +1 -1
- package/dist/fields/Number/index.js +143 -275
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/index.d.ts.map +1 -1
- package/dist/fields/Password/index.js +79 -166
- package/dist/fields/Password/index.js.map +1 -1
- package/dist/fields/Point/index.d.ts.map +1 -1
- package/dist/fields/Point/index.js +110 -235
- package/dist/fields/Point/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js +93 -209
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/index.d.ts.map +1 -1
- package/dist/fields/Relationship/index.js +7 -10
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Select/Input.d.ts +0 -1
- package/dist/fields/Select/Input.d.ts.map +1 -1
- package/dist/fields/Select/Input.js +45 -50
- package/dist/fields/Select/Input.js.map +1 -1
- package/dist/fields/Select/index.d.ts.map +1 -1
- package/dist/fields/Select/index.js +7 -7
- package/dist/fields/Select/index.js.map +1 -1
- package/dist/fields/Text/Input.d.ts.map +1 -1
- package/dist/fields/Text/Input.js +31 -36
- package/dist/fields/Text/Input.js.map +1 -1
- package/dist/fields/Text/index.d.ts +1 -1
- package/dist/fields/Text/index.d.ts.map +1 -1
- package/dist/fields/Text/index.js +93 -171
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Text/types.d.ts +0 -1
- package/dist/fields/Text/types.d.ts.map +1 -1
- package/dist/fields/Text/types.js.map +1 -1
- package/dist/fields/Textarea/Input.d.ts.map +1 -1
- package/dist/fields/Textarea/Input.js +26 -31
- package/dist/fields/Textarea/Input.js.map +1 -1
- package/dist/fields/Textarea/index.d.ts.map +1 -1
- package/dist/fields/Textarea/index.js +62 -112
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Textarea/types.d.ts +0 -1
- package/dist/fields/Textarea/types.d.ts.map +1 -1
- package/dist/fields/Textarea/types.js.map +1 -1
- package/dist/fields/Upload/Input.d.ts +0 -1
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js +41 -46
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/fields/Upload/index.d.ts.map +1 -1
- package/dist/fields/Upload/index.js +63 -135
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/fields/mergeFieldStyles.d.ts +3 -0
- package/dist/fields/mergeFieldStyles.d.ts.map +1 -0
- package/dist/fields/mergeFieldStyles.js +13 -0
- package/dist/fields/mergeFieldStyles.js.map +1 -0
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +3 -3
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Submit/index.d.ts.map +1 -1
- package/dist/forms/Submit/index.js +7 -2
- package/dist/forms/Submit/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +3 -0
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +40 -9
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.d.ts +4 -1
- package/dist/forms/fieldSchemasToFormState/types.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.js.map +1 -1
- package/dist/graphics/Icon/index.d.ts.map +1 -1
- package/dist/graphics/Icon/index.js +2 -2
- package/dist/graphics/Icon/index.js.map +1 -1
- package/dist/graphics/Logo/index.d.ts.map +1 -1
- package/dist/graphics/Logo/index.js +30 -21
- package/dist/graphics/Logo/index.js.map +1 -1
- package/dist/utilities/buildFormState.d.ts +0 -4
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +1 -15
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/buildTableState.d.ts +2 -1
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +7 -4
- package/dist/utilities/buildTableState.js.map +1 -1
- package/package.json +15 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","deepCopyObjectSimple","MissingEditorProp","fieldAffectsData","RenderServerComponent","FieldDescription","renderField","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","operation","parentPath","parentSchemaPath","path","permissions","incomingPermissions","req","schemaPath","siblingData","clientField","defaultIDType","payload","config","db","field","i18n","name","clientProps","customComponents","readOnly","includes","type","serverProps","user","rows","forEach","row","rowIndex","admin","components","RowLabels","_jsx","Component","RowLabel","importMap","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","FieldComponent","Field","Fallback","undefined","Description","description","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\n PayloadComponent,\n SanitizedFieldPermissions,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, deepCopyObjectSimple, MissingEditorProp } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\n\nexport const renderField: RenderFieldMethod = ({\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n formState,\n indexPath,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions: incomingPermissions,\n req,\n schemaPath,\n siblingData,\n}) => {\n // TODO (ALESSIO): why are we passing the fieldConfig twice?\n // and especially, why are we deepCopyObject -here- instead of inside the createClientField func,\n // so no one screws this up in the future?\n const clientField = createClientField({\n clientField: deepCopyObjectSimple(fieldConfig) as ClientField,\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n })\n\n const permissions =\n incomingPermissions === true\n ? true\n : fieldAffectsData(fieldConfig)\n ? incomingPermissions?.[fieldConfig.name]\n : ({} as SanitizedFieldPermissions)\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n customComponents: fieldState?.customComponents || {},\n field: clientField,\n path,\n readOnly: permissions !== true && !permissions?.[operation],\n schemaPath,\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 clientField,\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 formState,\n i18n: req.i18n,\n payload: req.payload,\n siblingData,\n user: req.user,\n }\n\n if (!fieldState?.customComponents) {\n fieldState.customComponents = {}\n }\n\n switch (fieldConfig.type) {\n // TODO: handle block row labels as well in a similar fashion\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!fieldState.customComponents.RowLabels) {\n fieldState.customComponents.RowLabels = []\n }\n\n fieldState.customComponents.RowLabels[rowIndex] = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.RowLabel}\n importMap={req.payload.importMap}\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 )\n }\n })\n\n break\n }\n\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 /**\n * We have to deep copy all the props we send to the client (= FieldComponent.clientProps).\n * That way, every editor's field / cell props we send to the client have their own object references.\n *\n * If we send the same object reference to the client twice (e.g. through some configurations where 2 or more fields\n * reference the same editor object, like the root editor), the admin panel may hang indefinitely. This has been happening since\n * a newer Next.js update that made it break when sending the same object reference to the client twice.\n *\n * We can use deepCopyObjectSimple as client props should be JSON-serializable.\n */\n const FieldComponent: PayloadComponent = fieldConfig.editor.FieldComponent\n if (typeof FieldComponent === 'object' && FieldComponent.clientProps) {\n FieldComponent.clientProps = deepCopyObjectSimple(FieldComponent.clientProps)\n }\n\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={FieldComponent}\n Fallback={undefined}\n importMap={req.payload.importMap}\n serverProps={serverProps}\n />\n )\n\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if ('description' in fieldConfig.admin) {\n // @TODO move this to client, only render if it is a function\n fieldState.customComponents.Description = (\n <FieldDescription\n description={\n typeof fieldConfig.admin?.description === 'string' ||\n typeof fieldConfig.admin?.description === 'object'\n ? fieldConfig.admin.description\n : typeof fieldConfig.admin?.description === 'function'\n ? fieldConfig.admin?.description({ t: req.i18n.t })\n : ''\n }\n path={path}\n />\n )\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.afterInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.afterInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.beforeInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.beforeInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Description}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Description\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Error}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Error\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Label}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Label\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Field}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Field\"\n serverProps={serverProps}\n />\n )\n }\n }\n }\n}\n"],"mappings":";AASA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,oBAAoB,EAAEC,iBAAiB,QAAQ;AAC3E,SAASC,gBAAgB,QAAQ;AAIjC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AAEjC,OAAO,MAAMC,WAAA,GAAiCA,CAAC;EAC7CC,IAAI;EACJC,WAAW;EACX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AA,CAAIK,OAAO,CAACuB,SAAS;UAEhCZ,WAAA,EAAaA;WADT;MAIV;MAEA,IAAI,WAAW3B,WAAA,CAAYiC,KAAK,CAACC,UAAU,EAAE;QAC3ChC,UAAA,CAAWqB,gBAAgB,CAACoC,KAAK,gBAC/BvB,IAAA,CAACxC,qBAAA;UACC0B,WAAA,EAAaA,WAAA;UACbe,SAAA,EAAWrC,WAAA,CAAYiC,KAAK,CAACC,UAAU,CAACyB,KAAK;UAC7CpB,SAAA,EAAW5B,GAAA,CAAIK,OAAO,CAACuB,SAAS;UAEhCZ,WAAA,EAAaA;WADT;MAIV;MAEA,IAAI,WAAW3B,WAAA,CAAYiC,KAAK,CAACC,UAAU,EAAE;QAC3ChC,UAAA,CAAWqB,gBAAgB,CAAC0B,KAAK,gBAC/Bb,IAAA,CAACxC,qBAAA;UACC0B,WAAA,EAAaA,WAAA;UACbe,SAAA,EAAWrC,WAAA,CAAYiC,KAAK,CAACC,UAAU,CAACe,KAAK;UAC7CV,SAAA,EAAW5B,GAAA,CAAIK,OAAO,CAACuB,SAAS;UAEhCZ,WAAA,EAAaA;WADT;MAIV;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","deepCopyObjectSimple","MissingEditorProp","fieldAffectsData","RenderServerComponent","FieldDescription","defaultUIFieldComponentKeys","renderField","id","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","operation","parentPath","parentSchemaPath","path","permissions","incomingPermissions","preferences","req","schemaPath","siblingData","clientField","defaultIDType","payload","config","db","field","i18n","importMap","name","clientProps","customComponents","readOnly","includes","type","serverProps","user","rows","forEach","row","rowIndex","admin","components","RowLabels","_jsx","Component","RowLabel","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","FieldComponent","Field","Fallback","undefined","key","description","Description","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\n PayloadComponent,\n SanitizedFieldPermissions,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, deepCopyObjectSimple, MissingEditorProp } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- need this to reference already existing bundle. Otherwise, bundle size increases., payload/no-imports-from-exports-dir\nimport { FieldDescription } 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 collectionSlug,\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n formState,\n indexPath,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions: incomingPermissions,\n preferences,\n req,\n schemaPath,\n siblingData,\n}) => {\n // TODO (ALESSIO): why are we passing the fieldConfig twice?\n // and especially, why are we deepCopyObject -here- instead of inside the createClientField func,\n // so no one screws this up in the future?\n const clientField = createClientField({\n clientField: deepCopyObjectSimple(fieldConfig) as ClientField,\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n })\n\n const permissions =\n incomingPermissions === true\n ? true\n : fieldAffectsData(fieldConfig)\n ? incomingPermissions?.[fieldConfig.name]\n : ({} as SanitizedFieldPermissions)\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n customComponents: fieldState?.customComponents || {},\n field: clientField,\n path,\n readOnly: permissions !== true && !permissions?.[operation],\n schemaPath,\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 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 }\n\n if (!fieldState?.customComponents) {\n fieldState.customComponents = {}\n }\n\n switch (fieldConfig.type) {\n // TODO: handle block row labels as well in a similar fashion\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!fieldState.customComponents.RowLabels) {\n fieldState.customComponents.RowLabels = []\n }\n\n fieldState.customComponents.RowLabels[rowIndex] = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.RowLabel}\n importMap={req.payload.importMap}\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 )\n }\n })\n\n break\n }\n\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 /**\n * We have to deep copy all the props we send to the client (= FieldComponent.clientProps).\n * That way, every editor's field / cell props we send to the client have their own object references.\n *\n * If we send the same object reference to the client twice (e.g. through some configurations where 2 or more fields\n * reference the same editor object, like the root editor), the admin panel may hang indefinitely. This has been happening since\n * a newer Next.js update that made it break when sending the same object reference to the client twice.\n *\n * We can use deepCopyObjectSimple as client props should be JSON-serializable.\n */\n const FieldComponent: PayloadComponent = fieldConfig.editor.FieldComponent\n if (typeof FieldComponent === 'object' && FieldComponent.clientProps) {\n FieldComponent.clientProps = deepCopyObjectSimple(FieldComponent.clientProps)\n }\n\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={FieldComponent}\n Fallback={undefined}\n importMap={req.payload.importMap}\n serverProps={serverProps}\n />\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 const Component = fieldConfig.admin.components[key]\n fieldState.customComponents[key] = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={Component}\n importMap={req.payload.importMap}\n key={`field.admin.components.${key}`}\n serverProps={serverProps}\n />\n )\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if ('description' in fieldConfig.admin) {\n if (typeof fieldConfig.admin?.description === 'function') {\n fieldState.customComponents.Description = (\n <FieldDescription\n description={fieldConfig.admin?.description({\n t: req.i18n.t,\n })}\n path={path}\n />\n )\n }\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.afterInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.afterInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.beforeInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.beforeInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Description}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Description\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Error}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Error\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Label}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Label\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Field}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Field\"\n serverProps={serverProps}\n />\n )\n }\n }\n }\n}\n"],"mappings":";AASA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,oBAAoB,EAAEC,iBAAiB,QAAQ;AAC3E,SAASC,gBAAgB,QAAQ;AAIjC,SAASC,qBAAqB,QAAQ;AACtC;AACA,SAASC,gBAAgB,QAAQ;AAEjC,MAAMC,2BAAA,GAAkF,CACtF,QACA,eACA,SACA,SACD;AAED,OAAO,MAAMC,WAAA,GAAiCA,CAAC;EAC7CC,EAAE;EACFC,cAAc;EACdC,IAAI;EACJC,WAAW;EACXC,cAAc;EACdC,UAAU;EACVC,SAAS;EACTC,SAAS;EACTC,SAAS;EACTC,UAAU;EACVC,gBAAgB;EAChBC,IAAI;EACJC,WAAA,EAAaC,mBAAmB;EAChCC,WAAW;EACXC,GAAG;EACHC,UAAU;EACVC;AAAW,CACZ;EACC;EACA;EACA;EACA,MAAMC,WAAA,GAAc1B,iBAAA,CAAkB;IACpC0B,WAAA,EAAazB,oBAAA,CAAqBU,WAAA;IAClCgB,aAAA,EAAeJ,GAAA,CAAIK,OAAO,CAACC,MAAM,CAACC,EAAE,CAACH,aAAa;IAClDI,KAAA,EAAOpB,WAAA;IACPqB,IAAA,EAAMT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A;UACC+B,WAAA,EAAaA,WAAA;UACbe,SAAA,EAAWvC,WAAA,CAAYmC,KAAK,CAACC,UAAU,CAACY,KAAK;UAC7C1B,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAEhCO,WAAA,EAAaA;WADT;MAIV;MAEA,IAAI,WAAW7B,WAAA,CAAYmC,KAAK,CAACC,UAAU,EAAE;QAC3ClC,UAAA,CAAWuB,gBAAgB,CAACoC,KAAK,gBAC/BvB,IAAA,CAAC7C,qBAAA;UACC+B,WAAA,EAAaA,WAAA;UACbe,SAAA,EAAWvC,WAAA,CAAYmC,KAAK,CAACC,UAAU,CAACyB,KAAK;UAC7CvC,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAEhCO,WAAA,EAAaA;WADT;MAIV;MAEA,IAAI,WAAW7B,WAAA,CAAYmC,KAAK,CAACC,UAAU,EAAE;QAC3ClC,UAAA,CAAWuB,gBAAgB,CAACyB,KAAK,gBAC/BZ,IAAA,CAAC7C,qBAAA;UACC+B,WAAA,EAAaA,WAAA;UACbe,SAAA,EAAWvC,WAAA,CAAYmC,KAAK,CAACC,UAAU,CAACc,KAAK;UAC7C5B,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAEhCO,WAAA,EAAaA;WADT;MAIV;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { Data, Field, FieldSchemaMap, FieldState, FormState, Operation, PayloadRequest, SanitizedFieldPermissions } from 'payload';
|
|
1
|
+
import type { Data, DocumentPreferences, Field, FieldSchemaMap, FieldState, FormState, Operation, PayloadRequest, SanitizedFieldPermissions } from 'payload';
|
|
2
2
|
export type RenderFieldArgs = {
|
|
3
|
+
collectionSlug: string;
|
|
3
4
|
data: Data;
|
|
4
5
|
fieldConfig: Field;
|
|
5
6
|
fieldSchemaMap: FieldSchemaMap;
|
|
6
7
|
fieldState: FieldState;
|
|
7
8
|
formState: FormState;
|
|
9
|
+
id?: number | string;
|
|
8
10
|
indexPath: string;
|
|
9
11
|
operation: Operation;
|
|
10
12
|
parentPath: string;
|
|
@@ -13,6 +15,7 @@ export type RenderFieldArgs = {
|
|
|
13
15
|
permissions: {
|
|
14
16
|
[fieldName: string]: SanitizedFieldPermissions;
|
|
15
17
|
} | null | SanitizedFieldPermissions;
|
|
18
|
+
preferences: DocumentPreferences;
|
|
16
19
|
previousFieldState: FieldState;
|
|
17
20
|
req: PayloadRequest;
|
|
18
21
|
schemaPath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,KAAK,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,SAAS,EACT,cAAc,EACd,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAEhB,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,IAAI,CAAA;IACV,WAAW,EAAE,KAAK,CAAA;IAClB,cAAc,EAAE,cAAc,CAAA;IAC9B,UAAU,EAAE,UAAU,CAAA;IACtB,SAAS,EAAE,SAAS,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,SAAS,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EACP;QACE,CAAC,SAAS,EAAE,MAAM,GAAG,yBAAyB,CAAA;KAC/C,GACD,IAAI,GACJ,yBAAyB,CAAA;IAC7B,kBAAkB,EAAE,UAAU,CAAA;IAC9B,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
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,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,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,SAAS,EAAE,SAAS,CAAA;IACpB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,SAAS,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EACP;QACE,CAAC,SAAS,EAAE,MAAM,GAAG,yBAAyB,CAAA;KAC/C,GACD,IAAI,GACJ,yBAAyB,CAAA;IAC7B,WAAW,EAAE,mBAAmB,CAAA;IAChC,kBAAkB,EAAE,UAAU,CAAA;IAC9B,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 Data,\n Field,\n FieldSchemaMap,\n FieldState,\n FormState,\n Operation,\n PayloadRequest,\n SanitizedFieldPermissions,\n} from 'payload'\n\nexport type RenderFieldArgs = {\n data: Data\n fieldConfig: Field\n fieldSchemaMap: FieldSchemaMap\n fieldState: FieldState\n formState: FormState\n indexPath: string\n operation: Operation\n parentPath: string\n parentSchemaPath: string\n path: string\n permissions:\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | null\n | SanitizedFieldPermissions\n previousFieldState: FieldState\n req: PayloadRequest\n schemaPath: string\n siblingData: Data\n}\n\nexport type RenderFieldMethod = (args: RenderFieldArgs) => void\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/forms/fieldSchemasToFormState/types.ts"],"sourcesContent":["import type {\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 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 operation: Operation\n parentPath: string\n parentSchemaPath: string\n path: string\n permissions:\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | null\n | SanitizedFieldPermissions\n preferences: DocumentPreferences\n previousFieldState: FieldState\n req: PayloadRequest\n schemaPath: string\n siblingData: Data\n}\n\nexport type RenderFieldMethod = (args: RenderFieldArgs) => void\n"],"mappings":"AAsCA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/graphics/Icon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/graphics/Icon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAqBA,CAAA"}
|
|
@@ -11,10 +11,10 @@ export const PayloadIcon = ({
|
|
|
11
11
|
width: "100%",
|
|
12
12
|
xmlns: "http://www.w3.org/2000/svg",
|
|
13
13
|
children: [/*#__PURE__*/_jsx("path", {
|
|
14
|
-
d: "M11.
|
|
14
|
+
d: "M11.8673 21.2336L4.40922 16.9845C4.31871 16.9309 4.25837 16.8355 4.25837 16.7282V10.1609C4.25837 10.0477 4.38508 9.97616 4.48162 10.0298L13.1404 14.9642C13.2611 15.0358 13.412 14.9464 13.412 14.8093V11.6091C13.412 11.4839 13.3456 11.3647 13.2309 11.2992L2.81624 5.36353C2.72573 5.30989 2.60505 5.30989 2.51454 5.36353L1.15085 6.14422C1.06034 6.19786 1 6.29321 1 6.40048V18.5995C1 18.7068 1.06034 18.8021 1.15085 18.8558L11.8491 24.9583C11.9397 25.0119 12.0603 25.0119 12.1509 24.9583L21.1355 19.8331C21.2562 19.7616 21.2562 19.5948 21.1355 19.5232L18.3357 17.9261C18.2211 17.8605 18.0883 17.8605 17.9737 17.9261L12.175 21.2336C12.0845 21.2872 11.9638 21.2872 11.8733 21.2336H11.8673Z",
|
|
15
15
|
fill: fill
|
|
16
16
|
}), /*#__PURE__*/_jsx("path", {
|
|
17
|
-
d: "
|
|
17
|
+
d: "M22.8491 6.13827L12.1508 0.0417218C12.0603 -0.0119135 11.9397 -0.0119135 11.8491 0.0417218L6.19528 3.2658C6.0746 3.33731 6.0746 3.50418 6.19528 3.57569L8.97092 5.16091C9.08557 5.22647 9.21832 5.22647 9.33296 5.16091L11.8672 3.71872C11.9578 3.66508 12.0784 3.66508 12.1689 3.71872L19.627 7.96782C19.7175 8.02146 19.7778 8.11681 19.7778 8.22408V14.8212C19.7778 14.9464 19.8442 15.0656 19.9589 15.1311L22.7345 16.7104C22.8552 16.7819 23.006 16.6925 23.006 16.5554V6.40048C23.006 6.29321 22.9457 6.19786 22.8552 6.14423L22.8491 6.13827Z",
|
|
18
18
|
fill: fill
|
|
19
19
|
})]
|
|
20
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","PayloadIcon","fill","fillFromProps","_jsxs","className","height","viewBox","width","xmlns","_jsx","d"],"sources":["../../../src/graphics/Icon/index.tsx"],"sourcesContent":["import React from 'react'\n\nexport const PayloadIcon: React.FC<{\n fill?: string\n}> = ({ fill: fillFromProps }) => {\n const fill = fillFromProps || 'var(--theme-elevation-1000)'\n\n return (\n <svg\n className=\"graphic-icon\"\n height=\"100%\"\n viewBox=\"0 0 25 25\"\n width=\"100%\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M11.
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PayloadIcon","fill","fillFromProps","_jsxs","className","height","viewBox","width","xmlns","_jsx","d"],"sources":["../../../src/graphics/Icon/index.tsx"],"sourcesContent":["import React from 'react'\n\nexport const PayloadIcon: React.FC<{\n fill?: string\n}> = ({ fill: fillFromProps }) => {\n const fill = fillFromProps || 'var(--theme-elevation-1000)'\n\n return (\n <svg\n className=\"graphic-icon\"\n height=\"100%\"\n viewBox=\"0 0 25 25\"\n width=\"100%\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M11.8673 21.2336L4.40922 16.9845C4.31871 16.9309 4.25837 16.8355 4.25837 16.7282V10.1609C4.25837 10.0477 4.38508 9.97616 4.48162 10.0298L13.1404 14.9642C13.2611 15.0358 13.412 14.9464 13.412 14.8093V11.6091C13.412 11.4839 13.3456 11.3647 13.2309 11.2992L2.81624 5.36353C2.72573 5.30989 2.60505 5.30989 2.51454 5.36353L1.15085 6.14422C1.06034 6.19786 1 6.29321 1 6.40048V18.5995C1 18.7068 1.06034 18.8021 1.15085 18.8558L11.8491 24.9583C11.9397 25.0119 12.0603 25.0119 12.1509 24.9583L21.1355 19.8331C21.2562 19.7616 21.2562 19.5948 21.1355 19.5232L18.3357 17.9261C18.2211 17.8605 18.0883 17.8605 17.9737 17.9261L12.175 21.2336C12.0845 21.2872 11.9638 21.2872 11.8733 21.2336H11.8673Z\"\n fill={fill}\n />\n <path\n d=\"M22.8491 6.13827L12.1508 0.0417218C12.0603 -0.0119135 11.9397 -0.0119135 11.8491 0.0417218L6.19528 3.2658C6.0746 3.33731 6.0746 3.50418 6.19528 3.57569L8.97092 5.16091C9.08557 5.22647 9.21832 5.22647 9.33296 5.16091L11.8672 3.71872C11.9578 3.66508 12.0784 3.66508 12.1689 3.71872L19.627 7.96782C19.7175 8.02146 19.7778 8.11681 19.7778 8.22408V14.8212C19.7778 14.9464 19.8442 15.0656 19.9589 15.1311L22.7345 16.7104C22.8552 16.7819 23.006 16.6925 23.006 16.5554V6.40048C23.006 6.29321 22.9457 6.19786 22.8552 6.14423L22.8491 6.13827Z\"\n fill={fill}\n />\n </svg>\n )\n}\n"],"mappings":";AAAA,OAAOA,KAAA,MAAW;AAElB,OAAO,MAAMC,WAAA,GAERA,CAAC;EAAEC,IAAA,EAAMC;AAAa,CAAE;EAC3B,MAAMD,IAAA,GAAOC,aAAA,IAAiB;EAE9B,oBACEC,KAAA,CAAC;IACCC,SAAA,EAAU;IACVC,MAAA,EAAO;IACPC,OAAA,EAAQ;IACRC,KAAA,EAAM;IACNC,KAAA,EAAM;4BAENC,IAAA,CAAC;MACCC,CAAA,EAAE;MACFT,IAAA,EAAMA;qBAERQ,IAAA,CAAC;MACCC,CAAA,EAAE;MACFT,IAAA,EAAMA;;;AAId","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/graphics/Logo/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/graphics/Logo/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EA0B/B,CAAA"}
|
|
@@ -8,30 +8,39 @@ const css = `
|
|
|
8
8
|
export const PayloadLogo = () => /*#__PURE__*/_jsxs("svg", {
|
|
9
9
|
className: "graphic-logo",
|
|
10
10
|
fill: "none",
|
|
11
|
-
height: "
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
height: "43.5",
|
|
12
|
+
id: "b",
|
|
13
|
+
viewBox: "0 0 193.38 43.5",
|
|
14
|
+
width: "193.38",
|
|
14
15
|
xmlns: "http://www.w3.org/2000/svg",
|
|
15
16
|
children: [/*#__PURE__*/_jsx("style", {
|
|
16
17
|
children: css
|
|
17
|
-
}), /*#__PURE__*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
}), /*#__PURE__*/_jsxs("g", {
|
|
19
|
+
id: "c",
|
|
20
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
21
|
+
d: "M18.01,35.63l-12.36-7.13c-.15-.09-.25-.25-.25-.43v-11.02c0-.19.21-.31.37-.22l14.35,8.28c.2.12.45-.03.45-.26v-5.37c0-.21-.11-.41-.3-.52L3.01,9c-.15-.09-.35-.09-.5,0l-2.26,1.31c-.15.09-.25.25-.25.43v20.47c0,.18.1.34.25.43l17.73,10.24c.15.09.35.09.5,0l14.89-8.6c.2-.12.2-.4,0-.52l-4.64-2.68c-.19-.11-.41-.11-.6,0l-9.61,5.55c-.15.09-.35.09-.5,0Z"
|
|
22
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
23
|
+
d: "M36.21,10.3L18.48.07c-.15-.09-.35-.09-.5,0l-9.37,5.41c-.2.12-.2.4,0,.52l4.6,2.66c.19.11.41.11.6,0l4.2-2.42c.15-.09.35-.09.5,0l12.36,7.13c.15.09.25.25.25.43v11.07c0,.21.11.41.3.52l4.6,2.65c.2.12.45-.03.45-.26V10.74c0-.18-.1-.34-.25-.43Z"
|
|
24
|
+
}), /*#__PURE__*/_jsxs("g", {
|
|
25
|
+
id: "d",
|
|
26
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
27
|
+
d: "M193.38,9.47c0,1.94-1.48,3.32-3.3,3.32s-3.31-1.39-3.31-3.32,1.49-3.31,3.31-3.31,3.3,1.39,3.3,3.31ZM192.92,9.47c0-1.68-1.26-2.88-2.84-2.88s-2.84,1.2-2.84,2.88,1.26,2.89,2.84,2.89,2.84-1.2,2.84-2.89ZM188.69,11.17v-3.51h1.61c.85,0,1.35.39,1.35,1.15,0,.53-.3.86-.67,1.02l.79,1.35h-.89l-.72-1.22h-.64v1.22h-.82ZM190.18,9.31c.46,0,.64-.16.64-.5s-.19-.49-.64-.49h-.67v.99h.67Z"
|
|
28
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
29
|
+
d: "M54.72,24.84v10.93h-5.4V6.1h12.26c7.02,0,11.1,3.2,11.1,9.39s-4.07,9.35-11.06,9.35h-6.9,0ZM61.12,20.52c4.07,0,6.11-1.66,6.11-5.03s-2.04-5.03-6.11-5.03h-6.4v10.06h6.4Z"
|
|
30
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
31
|
+
d: "M85.94,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.18-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM85.73,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z"
|
|
32
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
33
|
+
d: "M90.39,14.66h5.4l5.86,15.92h.08l5.57-15.92h5.28l-8.23,21.49c-2,5.28-4.45,7.32-8.89,7.36-.71,0-1.7-.08-2.45-.21v-4.03c.62.13.96.13,1.41.13,2.16,0,3.07-.75,4.2-3.66l-8.23-21.07h0Z"
|
|
34
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
35
|
+
d: "M113.46,35.77V6.1h5.32v29.67h-5.32Z"
|
|
36
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
37
|
+
d: "M130.79,36.27c-6.23,0-10.68-4.2-10.68-11.05s4.45-11.05,10.68-11.05,10.68,4.24,10.68,11.05-4.45,11.05-10.68,11.05ZM130.79,32.32c3.41,0,5.36-2.66,5.36-7.11s-1.95-7.11-5.36-7.11-5.36,2.7-5.36,7.11,1.91,7.11,5.36,7.11Z"
|
|
38
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
39
|
+
d: "M156.19,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.19-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM155.98,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z"
|
|
40
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
41
|
+
d: "M178.5,32.41c-1.04,2.12-3.58,3.87-6.78,3.87-5.53,0-9.31-4.49-9.31-11.05s3.78-11.05,9.31-11.05c3.28,0,5.69,1.83,6.69,3.95V6.1h5.32v29.67h-5.24v-3.37h0ZM178.55,24.84c0-4.11-1.95-6.78-5.32-6.78s-5.45,2.83-5.45,7.15,2,7.15,5.45,7.15,5.32-2.66,5.32-6.78v-.75h0Z"
|
|
42
|
+
})]
|
|
43
|
+
})]
|
|
35
44
|
})]
|
|
36
45
|
});
|
|
37
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","css","PayloadLogo","_jsxs","className","fill","height","viewBox","width","xmlns","_jsx","d"],"sources":["../../../src/graphics/Logo/index.tsx"],"sourcesContent":["import React from 'react'\n\nconst css = `\n .graphic-logo path {\n fill: var(--theme-elevation-1000);\n }\n`\n\nexport const PayloadLogo: React.FC = () => (\n <svg\n className=\"graphic-logo\"\n fill=\"none\"\n height=\"
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","css","PayloadLogo","_jsxs","className","fill","height","id","viewBox","width","xmlns","_jsx","d"],"sources":["../../../src/graphics/Logo/index.tsx"],"sourcesContent":["import React from 'react'\n\nconst css = `\n .graphic-logo path {\n fill: var(--theme-elevation-1000);\n }\n`\n\nexport const PayloadLogo: React.FC = () => (\n <svg\n className=\"graphic-logo\"\n fill=\"none\"\n height=\"43.5\"\n id=\"b\"\n viewBox=\"0 0 193.38 43.5\"\n width=\"193.38\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <style>{css}</style>\n <g id=\"c\">\n <path d=\"M18.01,35.63l-12.36-7.13c-.15-.09-.25-.25-.25-.43v-11.02c0-.19.21-.31.37-.22l14.35,8.28c.2.12.45-.03.45-.26v-5.37c0-.21-.11-.41-.3-.52L3.01,9c-.15-.09-.35-.09-.5,0l-2.26,1.31c-.15.09-.25.25-.25.43v20.47c0,.18.1.34.25.43l17.73,10.24c.15.09.35.09.5,0l14.89-8.6c.2-.12.2-.4,0-.52l-4.64-2.68c-.19-.11-.41-.11-.6,0l-9.61,5.55c-.15.09-.35.09-.5,0Z\" />\n <path d=\"M36.21,10.3L18.48.07c-.15-.09-.35-.09-.5,0l-9.37,5.41c-.2.12-.2.4,0,.52l4.6,2.66c.19.11.41.11.6,0l4.2-2.42c.15-.09.35-.09.5,0l12.36,7.13c.15.09.25.25.25.43v11.07c0,.21.11.41.3.52l4.6,2.65c.2.12.45-.03.45-.26V10.74c0-.18-.1-.34-.25-.43Z\" />\n <g id=\"d\">\n <path d=\"M193.38,9.47c0,1.94-1.48,3.32-3.3,3.32s-3.31-1.39-3.31-3.32,1.49-3.31,3.31-3.31,3.3,1.39,3.3,3.31ZM192.92,9.47c0-1.68-1.26-2.88-2.84-2.88s-2.84,1.2-2.84,2.88,1.26,2.89,2.84,2.89,2.84-1.2,2.84-2.89ZM188.69,11.17v-3.51h1.61c.85,0,1.35.39,1.35,1.15,0,.53-.3.86-.67,1.02l.79,1.35h-.89l-.72-1.22h-.64v1.22h-.82ZM190.18,9.31c.46,0,.64-.16.64-.5s-.19-.49-.64-.49h-.67v.99h.67Z\" />\n <path d=\"M54.72,24.84v10.93h-5.4V6.1h12.26c7.02,0,11.1,3.2,11.1,9.39s-4.07,9.35-11.06,9.35h-6.9,0ZM61.12,20.52c4.07,0,6.11-1.66,6.11-5.03s-2.04-5.03-6.11-5.03h-6.4v10.06h6.4Z\" />\n <path d=\"M85.94,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.18-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM85.73,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M90.39,14.66h5.4l5.86,15.92h.08l5.57-15.92h5.28l-8.23,21.49c-2,5.28-4.45,7.32-8.89,7.36-.71,0-1.7-.08-2.45-.21v-4.03c.62.13.96.13,1.41.13,2.16,0,3.07-.75,4.2-3.66l-8.23-21.07h0Z\" />\n <path d=\"M113.46,35.77V6.1h5.32v29.67h-5.32Z\" />\n <path d=\"M130.79,36.27c-6.23,0-10.68-4.2-10.68-11.05s4.45-11.05,10.68-11.05,10.68,4.24,10.68,11.05-4.45,11.05-10.68,11.05ZM130.79,32.32c3.41,0,5.36-2.66,5.36-7.11s-1.95-7.11-5.36-7.11-5.36,2.7-5.36,7.11,1.91,7.11,5.36,7.11Z\" />\n <path d=\"M156.19,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.19-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM155.98,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M178.5,32.41c-1.04,2.12-3.58,3.87-6.78,3.87-5.53,0-9.31-4.49-9.31-11.05s3.78-11.05,9.31-11.05c3.28,0,5.69,1.83,6.69,3.95V6.1h5.32v29.67h-5.24v-3.37h0ZM178.55,24.84c0-4.11-1.95-6.78-5.32-6.78s-5.45,2.83-5.45,7.15,2,7.15,5.45,7.15,5.32-2.66,5.32-6.78v-.75h0Z\" />\n </g>\n </g>\n </svg>\n)\n"],"mappings":";AAAA,OAAOA,KAAA,MAAW;AAElB,MAAMC,GAAA,GAAM;;;;AAIZ,CAAC;AAED,OAAO,MAAMC,WAAA,GAAwBA,CAAA,kBACnCC,KAAA,CAAC;EACCC,SAAA,EAAU;EACVC,IAAA,EAAK;EACLC,MAAA,EAAO;EACPC,EAAA,EAAG;EACHC,OAAA,EAAQ;EACRC,KAAA,EAAM;EACNC,KAAA,EAAM;0BAENC,IAAA,CAAC;cAAOV;mBACRE,KAAA,CAAC;IAAEI,EAAA,EAAG;4BACJI,IAAA,CAAC;MAAKC,CAAA,EAAE;qBACRD,IAAA,CAAC;MAAKC,CAAA,EAAE;qBACRT,KAAA,CAAC;MAAEI,EAAA,EAAG;8BACJI,IAAA,CAAC;QAAKC,CAAA,EAAE;uBACRD,IAAA,CAAC;QAAKC,CAAA,EAAE;uBACRD,IAAA,CAAC;QAAKC,CAAA,EAAE;uBACRD,IAAA,CAAC;QAAKC,CAAA,EAAE;uBACRD,IAAA,CAAC;QAAKC,CAAA,EAAE;uBACRD,IAAA,CAAC;QAAKC,CAAA,EAAE;uBACRD,IAAA,CAAC;QAAKC,CAAA,EAAE;uBACRD,IAAA,CAAC;QAAKC,CAAA,EAAE","ignoreList":[]}
|
|
@@ -6,10 +6,6 @@ export declare const getFieldSchemaMap: (args: {
|
|
|
6
6
|
globalSlug?: string;
|
|
7
7
|
i18n: I18nClient;
|
|
8
8
|
}) => FieldSchemaMap;
|
|
9
|
-
export declare const getClientConfig: (args: {
|
|
10
|
-
config: SanitizedConfig;
|
|
11
|
-
i18n: I18nClient;
|
|
12
|
-
}) => ClientConfig;
|
|
13
9
|
type BuildFormStateSuccessResult = {
|
|
14
10
|
clientConfig?: ClientConfig;
|
|
15
11
|
errors?: never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildFormState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACT,eAAe,EAChB,MAAM,SAAS,CAAA;AAqBhB,eAAO,MAAM,iBAAiB,SAAU;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,OAAO,CAAC,oBAAoB,CAqD9B,CAAA;AAED,eAAO,MAAM,cAAc,SACnB,kBAAkB,KACvB,OAAO,CAAC,2BAA2B,CAkHrC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatErrors } from 'payload';
|
|
2
2
|
import { reduceFieldsToValues } from 'payload/shared';
|
|
3
3
|
import { fieldSchemasToFormState } from '../forms/fieldSchemasToFormState/index.js';
|
|
4
4
|
import { renderField } from '../forms/fieldSchemasToFormState/renderField.js';
|
|
@@ -41,20 +41,6 @@ export const getFieldSchemaMap = args => {
|
|
|
41
41
|
}
|
|
42
42
|
return entityFieldMap;
|
|
43
43
|
};
|
|
44
|
-
export const getClientConfig = args => {
|
|
45
|
-
const {
|
|
46
|
-
config,
|
|
47
|
-
i18n
|
|
48
|
-
} = args;
|
|
49
|
-
if (cachedClientConfig && process.env.NODE_ENV !== 'development') {
|
|
50
|
-
return cachedClientConfig;
|
|
51
|
-
}
|
|
52
|
-
cachedClientConfig = createClientConfig({
|
|
53
|
-
config,
|
|
54
|
-
i18n
|
|
55
|
-
});
|
|
56
|
-
return cachedClientConfig;
|
|
57
|
-
};
|
|
58
44
|
export const buildFormStateHandler = async args => {
|
|
59
45
|
const {
|
|
60
46
|
req
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFormState.js","names":["createClientConfig","formatErrors","reduceFieldsToValues","fieldSchemasToFormState","renderField","buildFieldSchemaMap","handleFormStateLocking","cachedFieldMap","global","_payload_fieldMap","cachedClientConfig","_payload_clientConfig","getFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","process","env","NODE_ENV","Map","cachedEntityFieldMap","get","fieldSchemaMap","entityFieldMap","set","getClientConfig","buildFormStateHandler","req","incomingUserSlug","user","collection","adminUserSlug","payload","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","res","buildFormState","err","logger","error","msg","message","id","idFromArgs","data","incomingData","docPermissions","docPreferences","formState","operation","renderAllFields","returnLockStatus","schemaPath","updateLastEdited","undefined","fieldOrEntityConfig","fields","type","Array","isArray","formStateResult","permissions","preferences","previousFormState","renderFieldFn","upload","file","lockedStateResult","lockedState","state"],"sources":["../../src/utilities/buildFormState.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type {\n BuildFormStateArgs,\n ClientConfig,\n ClientUser,\n ErrorResult,\n FieldSchemaMap,\n FormState,\n SanitizedConfig,\n} from 'payload'\n\nimport { createClientConfig, formatErrors } from 'payload'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport { fieldSchemasToFormState } from '../forms/fieldSchemasToFormState/index.js'\nimport { renderField } from '../forms/fieldSchemasToFormState/renderField.js'\nimport { buildFieldSchemaMap } from './buildFieldSchemaMap/index.js'\nimport { handleFormStateLocking } from './handleFormStateLocking.js'\n\nlet cachedFieldMap = global._payload_fieldMap\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedFieldMap) {\n cachedFieldMap = global._payload_fieldMap = null\n}\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getFieldSchemaMap = (args: {\n collectionSlug?: string\n config: SanitizedConfig\n globalSlug?: string\n i18n: I18nClient\n}): FieldSchemaMap => {\n const { collectionSlug, config, globalSlug, i18n } = args\n\n if (process.env.NODE_ENV !== 'development') {\n if (!cachedFieldMap) {\n cachedFieldMap = new Map()\n }\n const cachedEntityFieldMap = cachedFieldMap.get(collectionSlug || globalSlug)\n if (cachedEntityFieldMap) {\n return cachedEntityFieldMap\n }\n }\n\n const { fieldSchemaMap: entityFieldMap } = buildFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n: i18n as I18n,\n })\n\n if (process.env.NODE_ENV !== 'development') {\n cachedFieldMap.set(collectionSlug || globalSlug, entityFieldMap)\n }\n\n return entityFieldMap\n}\n\nexport const getClientConfig = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n}): ClientConfig => {\n const { config, i18n } = args\n\n if (cachedClientConfig && process.env.NODE_ENV !== 'development') {\n return cachedClientConfig\n }\n\n cachedClientConfig = createClientConfig({\n config,\n i18n,\n })\n\n return cachedClientConfig\n}\n\ntype BuildFormStateSuccessResult = {\n clientConfig?: ClientConfig\n errors?: never\n indexPath?: string\n lockedState?: { isLocked: boolean; lastEditedAt: string; user: ClientUser | number | string }\n state: FormState\n}\n\ntype BuildFormStateErrorResult = {\n lockedState?: never\n state?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildFormStateResult = BuildFormStateErrorResult | BuildFormStateSuccessResult\n\nexport const buildFormStateHandler = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateResult> => {\n const { req } = args\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n try {\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const res = await buildFormState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildFormState = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateSuccessResult> => {\n const {\n id: idFromArgs,\n collectionSlug,\n data: incomingData,\n docPermissions,\n docPreferences,\n formState,\n globalSlug,\n operation,\n renderAllFields,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n },\n returnLockStatus,\n schemaPath = collectionSlug || globalSlug,\n updateLastEdited,\n } = args\n\n let data = incomingData\n\n if (!collectionSlug && !globalSlug) {\n throw new Error('Either collectionSlug or globalSlug must be provided')\n }\n\n const fieldSchemaMap = getFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n,\n })\n\n const id = collectionSlug ? idFromArgs : undefined\n const fieldOrEntityConfig = fieldSchemaMap.get(schemaPath)\n\n if (!fieldOrEntityConfig) {\n throw new Error(`Could not find \"${schemaPath}\" in the fieldSchemaMap`)\n }\n\n if (\n (!('fields' in fieldOrEntityConfig) ||\n !fieldOrEntityConfig.fields ||\n !fieldOrEntityConfig.fields.length) &&\n 'type' in fieldOrEntityConfig &&\n fieldOrEntityConfig.type !== 'blocks'\n ) {\n throw new Error(\n `The field found in fieldSchemaMap for \"${schemaPath}\" does not contain any subfields.`,\n )\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) {\n data = reduceFieldsToValues(formState, true)\n }\n\n /**\n * When building state for sub schemas we need to adjust:\n * - `fields`\n * - `parentSchemaPath`\n * - `parentPath`\n *\n * Type assertion is fine because we wrap sub schemas in an array\n * so we can safely map over them within `fieldSchemasToFormState`\n */\n const fields = Array.isArray(fieldOrEntityConfig)\n ? fieldOrEntityConfig\n : 'fields' in fieldOrEntityConfig\n ? fieldOrEntityConfig.fields\n : [fieldOrEntityConfig]\n\n const formStateResult = await fieldSchemasToFormState({\n id,\n collectionSlug,\n data,\n fields,\n fieldSchemaMap,\n operation,\n permissions: docPermissions?.fields || {},\n preferences: docPreferences || { fields: {} },\n previousFormState: formState,\n renderAllFields,\n renderFieldFn: renderField,\n req,\n schemaPath,\n })\n\n // Maintain form state of auth / upload fields\n if (collectionSlug && formState) {\n if (payload.collections[collectionSlug]?.config?.upload && formState.file) {\n formStateResult.file = formState.file\n }\n }\n\n let lockedStateResult\n\n if (returnLockStatus) {\n lockedStateResult = await handleFormStateLocking({\n id,\n collectionSlug,\n globalSlug,\n req,\n updateLastEdited,\n })\n }\n\n return {\n lockedState: lockedStateResult,\n state: formStateResult,\n }\n}\n"],"mappings":"AAWA,SAASA,kBAAkB,EAAEC,YAAY,QAAQ;AACjD,SAASC,oBAAoB,QAAQ;AAErC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,WAAW,QAAQ;AAC5B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,sBAAsB,QAAQ;AAEvC,IAAIC,cAAA,GAAiBC,MAAA,CAAOC,iBAAiB;AAC7C,IAAIC,kBAAA,GAAqBF,MAAA,CAAOG,qBAAqB;AAErD,IAAI,CAACJ,cAAA,EAAgB;EACnBA,cAAA,GAAiBC,MAAA,CAAOC,iBAAiB,GAAG;AAC9C;AAEA,IAAI,CAACC,kBAAA,EAAoB;EACvBA,kBAAA,GAAqBF,MAAA,CAAOG,qBAAqB,GAAG;AACtD;AAEA,OAAO,MAAMC,iBAAA,GAAqBC,IAAA;EAMhC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAI,CAAE,GAAGJ,IAAA;EAErD,IAAIK,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;IAC1C,IAAI,CAACb,cAAA,EAAgB;MACnBA,cAAA,GAAiB,IAAIc,GAAA;IACvB;IACA,MAAMC,oBAAA,GAAuBf,cAAA,CAAegB,GAAG,CAACT,cAAA,IAAkBE,UAAA;IAClE,IAAIM,oBAAA,EAAsB;MACxB,OAAOA,oBAAA;IACT;EACF;EAEA,MAAM;IAAEE,cAAA,EAAgBC;EAAc,CAAE,GAAGpB,mBAAA,CAAoB;IAC7DS,cAAA;IACAC,MAAA;IACAC,UAAA;IACAC,IAAA,EAAMA;EACR;EAEA,IAAIC,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;IAC1Cb,cAAA,CAAemB,GAAG,CAACZ,cAAA,IAAkBE,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AA;MACAzC,cAAA;MACAE,UAAA;MACAa,GAAA;MACAqC;IACF;EACF;EAEA,OAAO;IACLe,WAAA,EAAaD,iBAAA;IACbE,KAAA,EAAOT;EACT;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildFormState.js","names":["formatErrors","reduceFieldsToValues","fieldSchemasToFormState","renderField","buildFieldSchemaMap","handleFormStateLocking","cachedFieldMap","global","_payload_fieldMap","cachedClientConfig","_payload_clientConfig","getFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","process","env","NODE_ENV","Map","cachedEntityFieldMap","get","fieldSchemaMap","entityFieldMap","set","buildFormStateHandler","req","incomingUserSlug","user","collection","adminUserSlug","payload","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","res","buildFormState","err","logger","error","msg","message","id","idFromArgs","data","incomingData","docPermissions","docPreferences","formState","operation","renderAllFields","returnLockStatus","schemaPath","updateLastEdited","undefined","fieldOrEntityConfig","fields","type","Array","isArray","formStateResult","permissions","preferences","previousFormState","renderFieldFn","upload","file","lockedStateResult","lockedState","state"],"sources":["../../src/utilities/buildFormState.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type {\n BuildFormStateArgs,\n ClientConfig,\n ClientUser,\n ErrorResult,\n FieldSchemaMap,\n FormState,\n SanitizedConfig,\n} from 'payload'\n\nimport { formatErrors } from 'payload'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport { fieldSchemasToFormState } from '../forms/fieldSchemasToFormState/index.js'\nimport { renderField } from '../forms/fieldSchemasToFormState/renderField.js'\nimport { buildFieldSchemaMap } from './buildFieldSchemaMap/index.js'\nimport { handleFormStateLocking } from './handleFormStateLocking.js'\n\nlet cachedFieldMap = global._payload_fieldMap\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedFieldMap) {\n cachedFieldMap = global._payload_fieldMap = null\n}\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getFieldSchemaMap = (args: {\n collectionSlug?: string\n config: SanitizedConfig\n globalSlug?: string\n i18n: I18nClient\n}): FieldSchemaMap => {\n const { collectionSlug, config, globalSlug, i18n } = args\n\n if (process.env.NODE_ENV !== 'development') {\n if (!cachedFieldMap) {\n cachedFieldMap = new Map()\n }\n const cachedEntityFieldMap = cachedFieldMap.get(collectionSlug || globalSlug)\n if (cachedEntityFieldMap) {\n return cachedEntityFieldMap\n }\n }\n\n const { fieldSchemaMap: entityFieldMap } = buildFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n: i18n as I18n,\n })\n\n if (process.env.NODE_ENV !== 'development') {\n cachedFieldMap.set(collectionSlug || globalSlug, entityFieldMap)\n }\n\n return entityFieldMap\n}\n\ntype BuildFormStateSuccessResult = {\n clientConfig?: ClientConfig\n errors?: never\n indexPath?: string\n lockedState?: { isLocked: boolean; lastEditedAt: string; user: ClientUser | number | string }\n state: FormState\n}\n\ntype BuildFormStateErrorResult = {\n lockedState?: never\n state?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildFormStateResult = BuildFormStateErrorResult | BuildFormStateSuccessResult\n\nexport const buildFormStateHandler = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateResult> => {\n const { req } = args\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n try {\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const res = await buildFormState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildFormState = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateSuccessResult> => {\n const {\n id: idFromArgs,\n collectionSlug,\n data: incomingData,\n docPermissions,\n docPreferences,\n formState,\n globalSlug,\n operation,\n renderAllFields,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n },\n returnLockStatus,\n schemaPath = collectionSlug || globalSlug,\n updateLastEdited,\n } = args\n\n let data = incomingData\n\n if (!collectionSlug && !globalSlug) {\n throw new Error('Either collectionSlug or globalSlug must be provided')\n }\n\n const fieldSchemaMap = getFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n,\n })\n\n const id = collectionSlug ? idFromArgs : undefined\n const fieldOrEntityConfig = fieldSchemaMap.get(schemaPath)\n\n if (!fieldOrEntityConfig) {\n throw new Error(`Could not find \"${schemaPath}\" in the fieldSchemaMap`)\n }\n\n if (\n (!('fields' in fieldOrEntityConfig) ||\n !fieldOrEntityConfig.fields ||\n !fieldOrEntityConfig.fields.length) &&\n 'type' in fieldOrEntityConfig &&\n fieldOrEntityConfig.type !== 'blocks'\n ) {\n throw new Error(\n `The field found in fieldSchemaMap for \"${schemaPath}\" does not contain any subfields.`,\n )\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) {\n data = reduceFieldsToValues(formState, true)\n }\n\n /**\n * When building state for sub schemas we need to adjust:\n * - `fields`\n * - `parentSchemaPath`\n * - `parentPath`\n *\n * Type assertion is fine because we wrap sub schemas in an array\n * so we can safely map over them within `fieldSchemasToFormState`\n */\n const fields = Array.isArray(fieldOrEntityConfig)\n ? fieldOrEntityConfig\n : 'fields' in fieldOrEntityConfig\n ? fieldOrEntityConfig.fields\n : [fieldOrEntityConfig]\n\n const formStateResult = await fieldSchemasToFormState({\n id,\n collectionSlug,\n data,\n fields,\n fieldSchemaMap,\n operation,\n permissions: docPermissions?.fields || {},\n preferences: docPreferences || { fields: {} },\n previousFormState: formState,\n renderAllFields,\n renderFieldFn: renderField,\n req,\n schemaPath,\n })\n\n // Maintain form state of auth / upload fields\n if (collectionSlug && formState) {\n if (payload.collections[collectionSlug]?.config?.upload && formState.file) {\n formStateResult.file = formState.file\n }\n }\n\n let lockedStateResult\n\n if (returnLockStatus) {\n lockedStateResult = await handleFormStateLocking({\n id,\n collectionSlug,\n globalSlug,\n req,\n updateLastEdited,\n })\n }\n\n return {\n lockedState: lockedStateResult,\n state: formStateResult,\n }\n}\n"],"mappings":"AAWA,SAASA,YAAY,QAAQ;AAC7B,SAASC,oBAAoB,QAAQ;AAErC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,WAAW,QAAQ;AAC5B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,sBAAsB,QAAQ;AAEvC,IAAIC,cAAA,GAAiBC,MAAA,CAAOC,iBAAiB;AAC7C,IAAIC,kBAAA,GAAqBF,MAAA,CAAOG,qBAAqB;AAErD,IAAI,CAACJ,cAAA,EAAgB;EACnBA,cAAA,GAAiBC,MAAA,CAAOC,iBAAiB,GAAG;AAC9C;AAEA,IAAI,CAACC,kBAAA,EAAoB;EACvBA,kBAAA,GAAqBF,MAAA,CAAOG,qBAAqB,GAAG;AACtD;AAEA,OAAO,MAAMC,iBAAA,GAAqBC,IAAA;EAMhC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAI,CAAE,GAAGJ,IAAA;EAErD,IAAIK,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;IAC1C,IAAI,CAACb,cAAA,EAAgB;MACnBA,cAAA,GAAiB,IAAIc,GAAA;IACvB;IACA,MAAMC,oBAAA,GAAuBf,cAAA,CAAegB,GAAG,CAACT,c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AAuB;MAC/CgD,EAAA;MACAxC,cAAA;MACAE,UAAA;MACAY,GAAA;MACAqC;IACF;EACF;EAEA,OAAO;IACLe,WAAA,EAAaD,iBAAA;IACbE,KAAA,EAAOT;EACT;AACF","ignoreList":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
-
import type { BuildTableStateArgs, ClientConfig, ErrorResult, PaginatedDocs, SanitizedConfig } from 'payload';
|
|
2
|
+
import type { BuildTableStateArgs, ClientConfig, ErrorResult, ImportMap, PaginatedDocs, SanitizedConfig } from 'payload';
|
|
3
3
|
import type { Column } from '../elements/Table/index.js';
|
|
4
4
|
import type { ListPreferences } from '../elements/TableColumns/index.js';
|
|
5
5
|
export declare const getClientConfig: (args: {
|
|
6
6
|
config: SanitizedConfig;
|
|
7
7
|
i18n: I18nClient;
|
|
8
|
+
importMap: ImportMap;
|
|
8
9
|
}) => ClientConfig;
|
|
9
10
|
type BuildTableStateSuccessResult = {
|
|
10
11
|
clientConfig?: ClientConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTableState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildTableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,mBAAmB,EAEnB,YAAY,EACZ,WAAW,EACX,aAAa,EAEb,eAAe,EAChB,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAUxE,eAAO,MAAM,eAAe,SAAU;IACpC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"buildTableState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildTableState.ts"],"names":[],"mappings":"AAAA,OAAO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
|
|
1
|
-
import { dequal } from 'dequal';
|
|
1
|
+
import { dequal } from 'dequal'; // TODO: Can we change this to dequal/lite ? If not, please add comment explaining why
|
|
2
2
|
import { createClientConfig, formatErrors } from 'payload';
|
|
3
3
|
import { renderFilters, renderTable } from './renderTable.js';
|
|
4
4
|
let cachedClientConfig = global._payload_clientConfig;
|
|
@@ -8,14 +8,16 @@ if (!cachedClientConfig) {
|
|
|
8
8
|
export const getClientConfig = args => {
|
|
9
9
|
const {
|
|
10
10
|
config,
|
|
11
|
-
i18n
|
|
11
|
+
i18n,
|
|
12
|
+
importMap
|
|
12
13
|
} = args;
|
|
13
14
|
if (cachedClientConfig && process.env.NODE_ENV !== 'development') {
|
|
14
15
|
return cachedClientConfig;
|
|
15
16
|
}
|
|
16
17
|
cachedClientConfig = createClientConfig({
|
|
17
18
|
config,
|
|
18
|
-
i18n
|
|
19
|
+
i18n,
|
|
20
|
+
importMap
|
|
19
21
|
});
|
|
20
22
|
return cachedClientConfig;
|
|
21
23
|
};
|
|
@@ -92,7 +94,8 @@ export const buildTableState = async args => {
|
|
|
92
94
|
}
|
|
93
95
|
const clientConfig = getClientConfig({
|
|
94
96
|
config,
|
|
95
|
-
i18n
|
|
97
|
+
i18n,
|
|
98
|
+
importMap: payload.importMap
|
|
96
99
|
});
|
|
97
100
|
let collectionConfig;
|
|
98
101
|
let clientCollectionConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTableState.js","names":["dequal","createClientConfig","formatErrors","renderFilters","renderTable","cachedClientConfig","global","_payload_clientConfig","getClientConfig","args","config","i18n","process","env","NODE_ENV","buildTableStateHandler","req","res","buildTableState","err","payload","logger","error","msg","message","collectionSlug","columns","docs","docsFromArgs","enableRowSelections","query","renderRowTypes","user","tableAppearance","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","length","clientConfig","collectionConfig","clientCollectionConfig","slug","preferencesKey","preferencesResult","where","and","key","equals","id","then","value","newPrefs","mergedPrefs","preferencesArgs","data","update","create","fields","parseInt","undefined","page","sort","columnState","Table","columnPreferences","useAsTitle","renderedFilters","importMap","preferences","state"],"sources":["../../src/utilities/buildTableState.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n BuildTableStateArgs,\n ClientCollectionConfig,\n ClientConfig,\n ErrorResult,\n PaginatedDocs,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport { dequal } from 'dequal'\nimport { createClientConfig, formatErrors } from 'payload'\n\nimport type { Column } from '../elements/Table/index.js'\nimport type { ListPreferences } from '../elements/TableColumns/index.js'\n\nimport { renderFilters, renderTable } from './renderTable.js'\n\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getClientConfig = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n}): ClientConfig => {\n const { config, i18n } = args\n\n if (cachedClientConfig && process.env.NODE_ENV !== 'development') {\n return cachedClientConfig\n }\n\n cachedClientConfig = createClientConfig({\n config,\n i18n,\n })\n\n return cachedClientConfig\n}\n\ntype BuildTableStateSuccessResult = {\n clientConfig?: ClientConfig\n data: PaginatedDocs\n errors?: never\n preferences: ListPreferences\n renderedFilters: Map<string, React.ReactNode>\n state: Column[]\n Table: React.ReactNode\n}\n\ntype BuildTableStateErrorResult = {\n data?: any\n renderedFilters?: never\n state?: never\n Table?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildTableStateResult = BuildTableStateErrorResult | BuildTableStateSuccessResult\n\nexport const buildTableStateHandler = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateResult> => {\n const { req } = args\n\n try {\n const res = await buildTableState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildTableState = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateSuccessResult> => {\n const {\n collectionSlug,\n columns,\n docs: docsFromArgs,\n enableRowSelections,\n query,\n renderRowTypes,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n tableAppearance,\n } = args\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n })\n\n let collectionConfig: SanitizedCollectionConfig\n let clientCollectionConfig: ClientCollectionConfig\n\n if (req.payload.collections[collectionSlug]) {\n collectionConfig = req.payload.collections[collectionSlug].config\n clientCollectionConfig = clientConfig.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n }\n\n // get prefs, then set update them using the columns that we just received\n const preferencesKey = `${collectionSlug}-list`\n\n const preferencesResult = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n pagination: false,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0] ?? { id: null, value: {} })\n\n let newPrefs = preferencesResult.value\n\n if (!preferencesResult.id || !dequal(columns, preferencesResult?.columns)) {\n const mergedPrefs = {\n ...(preferencesResult || {}),\n columns,\n }\n const preferencesArgs = {\n collection: 'payload-preferences',\n data: {\n key: preferencesKey,\n user: {\n collection: user.collection,\n value: user.id,\n },\n value: mergedPrefs,\n },\n depth: 0,\n req,\n }\n\n if (preferencesResult.id) {\n newPrefs = await payload\n .update({\n ...preferencesArgs,\n id: preferencesResult.id,\n })\n ?.then((res) => res.value as ListPreferences)\n } else {\n newPrefs = await payload.create(preferencesArgs)?.then((res) => res.value as ListPreferences)\n }\n }\n\n const fields = collectionConfig.fields\n\n let docs = docsFromArgs\n let data: PaginatedDocs\n\n // lookup docs, if desired, i.e. within `join` field which initialize with `depth: 0`\n\n if (!docs || query) {\n data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: query?.limit ? parseInt(query.limit, 10) : undefined,\n page: query?.page ? parseInt(query.page, 10) : undefined,\n sort: query?.sort,\n where: query?.where,\n })\n\n docs = data.docs\n }\n\n const { columnState, Table } = renderTable({\n collectionConfig: clientCollectionConfig,\n columnPreferences: undefined, // TODO, might not be needed\n columns,\n docs,\n enableRowSelections,\n fields,\n i18n: req.i18n,\n payload,\n renderRowTypes,\n tableAppearance,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(fields, req.payload.importMap)\n\n return {\n data,\n preferences: newPrefs,\n renderedFilters,\n state: columnState,\n Table,\n }\n}\n"],"mappings":"AAWA,SAASA,MAAM,QAAQ;AACvB,SAASC,kBAAkB,EAAEC,YAAY,QAAQ;AAKjD,SAASC,aAAa,EAAEC,WAAW,QAAQ;AAE3C,IAAIC,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB;AAErD,IAAI,CAACF,kBAAA,EAAoB;EACvBA,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB,GAAG;AACtD;AAEA,OAAO,MAAMC,eAAA,GAAmBC,IAAA;EAI9B,MAAM;IAAEC,MAAM;IAAEC;EAAI,CAAE,GAAGF,IAAA;EAEzB,IAAIJ,kBAA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7C,OAAA,CAAQwB,IAAI,CAAC;MACxBT,UAAA,EAAYV,cAAA;MACZoB,KAAA,EAAO;MACPC,KAAA,EAAOhB,KAAA,EAAOgB,KAAA,GAAQuB,QAAA,CAASvC,KAAA,CAAMgB,KAAK,EAAE,MAAMwB,SAAA;MAClDC,IAAA,EAAMzC,KAAA,EAAOyC,IAAA,GAAOF,QAAA,CAASvC,KAAA,CAAMyC,IAAI,EAAE,MAAMD,SAAA;MAC/CE,IAAA,EAAM1C,KAAA,EAAO0C,IAAA;MACbjB,KAAA,EAAOzB,KAAA,EAAOyB;IAChB;IAEA5B,IAAA,GAAOsC,IAAA,CAAKtC,IAAI;EAClB;EAEA,MAAM;IAAE8C,WAAW;IAAEC;EAAK,CAAE,GAAGtE,WAAA,CAAY;IACzC8C,gBAAA,EAAkBC,sBAAA;IAClBwB,iBAAA,EAAmBL,SAAA;IACnB5C,OAAA;IACAC,IAAA;IACAE,mBAAA;IACAuC,MAAA;IACAzD,IAAA,EAAMK,GAAA,CAAIL,IAAI;IACdS,OAAA;IACAW,cAAA;IACAE,eAAA;IACA2C,UAAA,EAAY1B,gBAAA,CAAiBb,KAAK,CAACuC;EACrC;EAEA,MAAMC,eAAA,GAAkB1E,aAAA,CAAciE,MAAA,EAAQpD,GAAA,CAAII,OAAO,CAAC0D,SAAS;EAEnE,OAAO;IACLb,IAAA;IACAc,WAAA,EAAajB,QAAA;IACbe,eAAA;IACAG,KAAA,EAAOP,WAAA;IACPC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildTableState.js","names":["dequal","createClientConfig","formatErrors","renderFilters","renderTable","cachedClientConfig","global","_payload_clientConfig","getClientConfig","args","config","i18n","importMap","process","env","NODE_ENV","buildTableStateHandler","req","res","buildTableState","err","payload","logger","error","msg","message","collectionSlug","columns","docs","docsFromArgs","enableRowSelections","query","renderRowTypes","user","tableAppearance","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","length","clientConfig","collectionConfig","clientCollectionConfig","slug","preferencesKey","preferencesResult","where","and","key","equals","id","then","value","newPrefs","mergedPrefs","preferencesArgs","data","update","create","fields","parseInt","undefined","page","sort","columnState","Table","columnPreferences","useAsTitle","renderedFilters","preferences","state"],"sources":["../../src/utilities/buildTableState.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n BuildTableStateArgs,\n ClientCollectionConfig,\n ClientConfig,\n ErrorResult,\n ImportMap,\n PaginatedDocs,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport { dequal } from 'dequal' // TODO: Can we change this to dequal/lite ? If not, please add comment explaining why\nimport { createClientConfig, formatErrors } from 'payload'\n\nimport type { Column } from '../elements/Table/index.js'\nimport type { ListPreferences } from '../elements/TableColumns/index.js'\n\nimport { renderFilters, renderTable } from './renderTable.js'\n\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getClientConfig = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n}): ClientConfig => {\n const { config, i18n, importMap } = args\n\n if (cachedClientConfig && process.env.NODE_ENV !== 'development') {\n return cachedClientConfig\n }\n\n cachedClientConfig = createClientConfig({\n config,\n i18n,\n importMap,\n })\n\n return cachedClientConfig\n}\n\ntype BuildTableStateSuccessResult = {\n clientConfig?: ClientConfig\n data: PaginatedDocs\n errors?: never\n preferences: ListPreferences\n renderedFilters: Map<string, React.ReactNode>\n state: Column[]\n Table: React.ReactNode\n}\n\ntype BuildTableStateErrorResult = {\n data?: any\n renderedFilters?: never\n state?: never\n Table?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildTableStateResult = BuildTableStateErrorResult | BuildTableStateSuccessResult\n\nexport const buildTableStateHandler = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateResult> => {\n const { req } = args\n\n try {\n const res = await buildTableState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildTableState = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateSuccessResult> => {\n const {\n collectionSlug,\n columns,\n docs: docsFromArgs,\n enableRowSelections,\n query,\n renderRowTypes,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n tableAppearance,\n } = args\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n })\n\n let collectionConfig: SanitizedCollectionConfig\n let clientCollectionConfig: ClientCollectionConfig\n\n if (req.payload.collections[collectionSlug]) {\n collectionConfig = req.payload.collections[collectionSlug].config\n clientCollectionConfig = clientConfig.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n }\n\n // get prefs, then set update them using the columns that we just received\n const preferencesKey = `${collectionSlug}-list`\n\n const preferencesResult = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n pagination: false,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0] ?? { id: null, value: {} })\n\n let newPrefs = preferencesResult.value\n\n if (!preferencesResult.id || !dequal(columns, preferencesResult?.columns)) {\n const mergedPrefs = {\n ...(preferencesResult || {}),\n columns,\n }\n const preferencesArgs = {\n collection: 'payload-preferences',\n data: {\n key: preferencesKey,\n user: {\n collection: user.collection,\n value: user.id,\n },\n value: mergedPrefs,\n },\n depth: 0,\n req,\n }\n\n if (preferencesResult.id) {\n newPrefs = await payload\n .update({\n ...preferencesArgs,\n id: preferencesResult.id,\n })\n ?.then((res) => res.value as ListPreferences)\n } else {\n newPrefs = await payload.create(preferencesArgs)?.then((res) => res.value as ListPreferences)\n }\n }\n\n const fields = collectionConfig.fields\n\n let docs = docsFromArgs\n let data: PaginatedDocs\n\n // lookup docs, if desired, i.e. within `join` field which initialize with `depth: 0`\n\n if (!docs || query) {\n data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: query?.limit ? parseInt(query.limit, 10) : undefined,\n page: query?.page ? parseInt(query.page, 10) : undefined,\n sort: query?.sort,\n where: query?.where,\n })\n\n docs = data.docs\n }\n\n const { columnState, Table } = renderTable({\n collectionConfig: clientCollectionConfig,\n columnPreferences: undefined, // TODO, might not be needed\n columns,\n docs,\n enableRowSelections,\n fields,\n i18n: req.i18n,\n payload,\n renderRowTypes,\n tableAppearance,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(fields, req.payload.importMap)\n\n return {\n data,\n preferences: newPrefs,\n renderedFilters,\n state: columnState,\n Table,\n }\n}\n"],"mappings":"AAYA,SAASA,MAAM,QAAQ,SAAQ,CAAC;AAChC,SAASC,kBAAkB,EAAEC,YAAY,QAAQ;AAKjD,SAASC,aAAa,EAAEC,WAAW,QAAQ;AAE3C,IAAIC,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB;AAErD,IAAI,CAACF,kBAAA,EAAoB;EACvBA,kBAAA,GA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loadcms/ui",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.135",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,6 +64,16 @@
|
|
|
64
64
|
"types": "./dist/fields/*/index.d.ts",
|
|
65
65
|
"default": "./dist/fields/*/index.js"
|
|
66
66
|
},
|
|
67
|
+
"./forms/fieldSchemasToFormState": {
|
|
68
|
+
"import": "./dist/forms/fieldSchemasToFormState/index.js",
|
|
69
|
+
"types": "./dist/forms/fieldSchemasToFormState/index.d.ts",
|
|
70
|
+
"default": "./dist/forms/fieldSchemasToFormState/index.js"
|
|
71
|
+
},
|
|
72
|
+
"./forms/renderField": {
|
|
73
|
+
"import": "./dist/forms/fieldSchemasToFormState/renderField.js",
|
|
74
|
+
"types": "./dist/forms/fieldSchemasToFormState/renderField.d.ts",
|
|
75
|
+
"default": "./dist/forms/fieldSchemasToFormState/renderField.js"
|
|
76
|
+
},
|
|
67
77
|
"./forms/*": {
|
|
68
78
|
"import": "./dist/forms/*/index.js",
|
|
69
79
|
"types": "./dist/forms/*/index.d.ts",
|
|
@@ -123,7 +133,7 @@
|
|
|
123
133
|
"ts-essentials": "10.0.3",
|
|
124
134
|
"use-context-selector": "2.0.0",
|
|
125
135
|
"uuid": "10.0.0",
|
|
126
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
136
|
+
"@payloadcms/translations": "3.0.0-beta.135"
|
|
127
137
|
},
|
|
128
138
|
"devDependencies": {
|
|
129
139
|
"@babel/cli": "^7.24.5",
|
|
@@ -141,14 +151,14 @@
|
|
|
141
151
|
"esbuild": "0.23.1",
|
|
142
152
|
"esbuild-sass-plugin": "3.3.1",
|
|
143
153
|
"eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
|
|
144
|
-
"
|
|
145
|
-
"
|
|
154
|
+
"@payloadcms/eslint-config": "3.0.0-beta.112",
|
|
155
|
+
"payload": "3.0.0-beta.135"
|
|
146
156
|
},
|
|
147
157
|
"peerDependencies": {
|
|
148
158
|
"next": "^15.0.0",
|
|
149
159
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
150
160
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
151
|
-
"payload": "3.0.0-beta.
|
|
161
|
+
"payload": "3.0.0-beta.135"
|
|
152
162
|
},
|
|
153
163
|
"engines": {
|
|
154
164
|
"node": "^18.20.2 || >=20.9.0"
|