@payloadcms/ui 3.0.2-canary.03cffa2 → 3.0.2-canary.260eb1c

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 (37) hide show
  1. package/dist/elements/DocumentDrawer/DrawerContent.d.ts.map +1 -1
  2. package/dist/elements/DocumentDrawer/DrawerContent.js +2 -4
  3. package/dist/elements/DocumentDrawer/DrawerContent.js.map +1 -1
  4. package/dist/exports/client/index.js +9 -9
  5. package/dist/exports/client/index.js.map +3 -3
  6. package/dist/fields/Blocks/BlockRow.d.ts.map +1 -1
  7. package/dist/fields/Blocks/BlockRow.js +16 -5
  8. package/dist/fields/Blocks/BlockRow.js.map +1 -1
  9. package/dist/forms/RenderFields/index.d.ts +3 -3
  10. package/dist/forms/RenderFields/index.d.ts.map +1 -1
  11. package/dist/forms/RenderFields/index.js +16 -15
  12. package/dist/forms/RenderFields/index.js.map +1 -1
  13. package/dist/forms/RenderFields/types.d.ts +1 -1
  14. package/dist/forms/RenderFields/types.d.ts.map +1 -1
  15. package/dist/forms/RenderFields/types.js.map +1 -1
  16. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts +2 -4
  17. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
  18. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +25 -9
  19. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
  20. package/dist/forms/fieldSchemasToFormState/index.d.ts +2 -2
  21. package/dist/forms/fieldSchemasToFormState/index.d.ts.map +1 -1
  22. package/dist/forms/fieldSchemasToFormState/index.js.map +1 -1
  23. package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts +2 -4
  24. package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts.map +1 -1
  25. package/dist/forms/fieldSchemasToFormState/iterateFields.js +1 -1
  26. package/dist/forms/fieldSchemasToFormState/iterateFields.js.map +1 -1
  27. package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
  28. package/dist/forms/fieldSchemasToFormState/renderField.js +2 -7
  29. package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
  30. package/dist/forms/fieldSchemasToFormState/types.d.ts +1 -3
  31. package/dist/forms/fieldSchemasToFormState/types.d.ts.map +1 -1
  32. package/dist/forms/fieldSchemasToFormState/types.js.map +1 -1
  33. package/dist/providers/ServerFunctions/index.d.ts +1 -1
  34. package/dist/providers/ServerFunctions/index.d.ts.map +1 -1
  35. package/dist/providers/ServerFunctions/index.js +11 -7
  36. package/dist/providers/ServerFunctions/index.js.map +1 -1
  37. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,mBAAmB,EACnB,KAAK,EACL,cAAc,EACd,SAAS,EAET,cAAc,EACd,4BAA4B,EAC7B,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAGnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,KAAK,IAAI,GAAG;IACV,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAA;IAC3B;;;;OAIG;IACH,cAAc,EAAE,cAAc,GAAG,SAAS,CAAA;IAC1C,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,WAAW,EAAE,4BAA4B,CAAC,QAAQ,CAAC,CAAA;IACnD,WAAW,EAAE,mBAAmB,CAAA;IAChC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,SAAS,CAAA;IAC7B;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,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
- {"version":3,"file":"index.js","names":["calculateDefaultValues","iterateFields","fieldSchemasToFormState","args","id","collectionSlug","data","fields","fieldSchemaMap","operation","permissions","preferences","previousFormState","renderAllFields","renderFieldFn","req","schemaPath","length","state","dataWithDefaultValues","locale","siblingData","user","addErrorPathToParent","fullData","parentIndexPath","parentPassesCondition","parentPath","parentSchemaPath"],"sources":["../../../src/forms/fieldSchemasToFormState/index.tsx"],"sourcesContent":["import type {\n Data,\n DocumentPreferences,\n Field,\n FieldSchemaMap,\n FormState,\n FormStateWithoutComponents,\n PayloadRequest,\n SanitizedDocumentPermissions,\n} from 'payload'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { calculateDefaultValues } from './calculateDefaultValues/index.js'\nimport { iterateFields } from './iterateFields.js'\n\ntype Args = {\n collectionSlug?: string\n data?: Data\n fields: Field[] | undefined\n /**\n * The field schema map is required for field rendering.\n * If fields should not be rendered (=> `renderFieldFn` is not provided),\n * then the field schema map is not required.\n */\n fieldSchemaMap: FieldSchemaMap | undefined\n id?: number | string\n operation?: 'create' | 'update'\n permissions: SanitizedDocumentPermissions['fields']\n preferences: DocumentPreferences\n /**\n * Optionally accept the previous form state,\n * to be able to determine if custom fields need to be re-rendered.\n */\n previousFormState?: FormState\n /**\n * If renderAllFields is true, then no matter what is in previous form state,\n * all custom fields will be re-rendered.\n */\n renderAllFields: boolean\n renderFieldFn?: RenderFieldMethod\n req: PayloadRequest\n schemaPath: string\n}\n\nexport const fieldSchemasToFormState = async (args: Args): Promise<FormState> => {\n const {\n id,\n collectionSlug,\n data = {},\n fields,\n fieldSchemaMap,\n operation,\n permissions,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n schemaPath,\n } = args\n\n if (fields && fields.length) {\n const state: FormStateWithoutComponents = {}\n\n const dataWithDefaultValues = { ...data }\n\n await calculateDefaultValues({\n id,\n data: dataWithDefaultValues,\n fields,\n locale: req.locale,\n siblingData: dataWithDefaultValues,\n user: req.user,\n })\n\n await iterateFields({\n id,\n addErrorPathToParent: null,\n collectionSlug,\n data: dataWithDefaultValues,\n fields,\n fieldSchemaMap,\n fullData: dataWithDefaultValues,\n operation,\n parentIndexPath: '',\n parentPassesCondition: true,\n parentPath: '',\n parentSchemaPath: schemaPath,\n permissions,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n state,\n })\n\n return state\n }\n\n return {}\n}\n\nexport { iterateFields }\n"],"mappings":"AAaA,SAASA,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AA+B9B,OAAO,MAAMC,uBAAA,GAA0B,MAAOC,IAAA;EAC5C,MAAM;IACJC,EAAE;IACFC,cAAc;IACdC,IAAA,GAAO,CAAC,CAAC;IACTC,MAAM;IACNC,cAAc;IACdC,SAAS;IACTC,WAAW;IACXC,WAAW;IACXC,iBAAiB;IACjBC,eAAe;IACfC,aAAa;IACbC,GAAG;IACHC;EAAU,CACX,GAAGb,IAAA;EAEJ,IAAII,MAAA,IAAUA,MAAA,CAAOU,MAAM,EAAE;IAC3B,MAAMC,KAAA,GAAoC,CAAC;IAE3C,MAAMC,qBAAA,GAAwB;MAAE,GAAGb;IAAK;IAExC,MAAMN,sBAAA,CAAuB;MAC3BI,EAAA;MACAE,IAAA,EAAMa,qBAAA;MACNZ,MAAA;MACAa,MAAA,EAAQL,GAAA,CAAIK,MAAM;MAClBC,WAAA,EAAaF,qBAAA;MACbG,IAAA,EAAMP,GAAA,CAAIO;IACZ;IAEA,MAAMrB,aAAA,CAAc;MAClBG,EAAA;MACAmB,oBAAA,EAAsB;MACtBlB,cAAA;MACAC,IAAA,EAAMa,qBAAA;MACNZ,MAAA;MACAC,cAAA;MACAgB,QAAA,EAAUL,qBAAA;MACVV,SAAA;MACAgB,eAAA,EAAiB;MACjBC,qBAAA,EAAuB;MACvBC,UAAA,EAAY;MACZC,gBAAA,EAAkBZ,UAAA;MAClBN,WAAA;MACAC,WAAA;MACAC,iBAAA;MACAC,eAAA;MACAC,aAAA;MACAC,GAAA;MACAG;IACF;IAEA,OAAOA,KAAA;EACT;EAEA,OAAO,CAAC;AACV;AAEA,SAASjB,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["calculateDefaultValues","iterateFields","fieldSchemasToFormState","args","id","collectionSlug","data","fields","fieldSchemaMap","operation","permissions","preferences","previousFormState","renderAllFields","renderFieldFn","req","schemaPath","length","state","dataWithDefaultValues","locale","siblingData","user","addErrorPathToParent","fullData","parentIndexPath","parentPassesCondition","parentPath","parentSchemaPath"],"sources":["../../../src/forms/fieldSchemasToFormState/index.tsx"],"sourcesContent":["import type {\n Data,\n DocumentPreferences,\n Field,\n FieldSchemaMap,\n FormState,\n FormStateWithoutComponents,\n PayloadRequest,\n SanitizedFieldsPermissions,\n} from 'payload'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { calculateDefaultValues } from './calculateDefaultValues/index.js'\nimport { iterateFields } from './iterateFields.js'\n\ntype Args = {\n collectionSlug?: string\n data?: Data\n fields: Field[] | undefined\n /**\n * The field schema map is required for field rendering.\n * If fields should not be rendered (=> `renderFieldFn` is not provided),\n * then the field schema map is not required.\n */\n fieldSchemaMap: FieldSchemaMap | undefined\n id?: number | string\n operation?: 'create' | 'update'\n permissions: SanitizedFieldsPermissions\n preferences: DocumentPreferences\n /**\n * Optionally accept the previous form state,\n * to be able to determine if custom fields need to be re-rendered.\n */\n previousFormState?: FormState\n /**\n * If renderAllFields is true, then no matter what is in previous form state,\n * all custom fields will be re-rendered.\n */\n renderAllFields: boolean\n renderFieldFn?: RenderFieldMethod\n req: PayloadRequest\n schemaPath: string\n}\n\nexport const fieldSchemasToFormState = async (args: Args): Promise<FormState> => {\n const {\n id,\n collectionSlug,\n data = {},\n fields,\n fieldSchemaMap,\n operation,\n permissions,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n schemaPath,\n } = args\n\n if (fields && fields.length) {\n const state: FormStateWithoutComponents = {}\n\n const dataWithDefaultValues = { ...data }\n\n await calculateDefaultValues({\n id,\n data: dataWithDefaultValues,\n fields,\n locale: req.locale,\n siblingData: dataWithDefaultValues,\n user: req.user,\n })\n\n await iterateFields({\n id,\n addErrorPathToParent: null,\n collectionSlug,\n data: dataWithDefaultValues,\n fields,\n fieldSchemaMap,\n fullData: dataWithDefaultValues,\n operation,\n parentIndexPath: '',\n parentPassesCondition: true,\n parentPath: '',\n parentSchemaPath: schemaPath,\n permissions,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n state,\n })\n\n return state\n }\n\n return {}\n}\n\nexport { iterateFields }\n"],"mappings":"AAaA,SAASA,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AA+B9B,OAAO,MAAMC,uBAAA,GAA0B,MAAOC,IAAA;EAC5C,MAAM;IACJC,EAAE;IACFC,cAAc;IACdC,IAAA,GAAO,CAAC,CAAC;IACTC,MAAM;IACNC,cAAc;IACdC,SAAS;IACTC,WAAW;IACXC,WAAW;IACXC,iBAAiB;IACjBC,eAAe;IACfC,aAAa;IACbC,GAAG;IACHC;EAAU,CACX,GAAGb,IAAA;EAEJ,IAAII,MAAA,IAAUA,MAAA,CAAOU,MAAM,EAAE;IAC3B,MAAMC,KAAA,GAAoC,CAAC;IAE3C,MAAMC,qBAAA,GAAwB;MAAE,GAAGb;IAAK;IAExC,MAAMN,sBAAA,CAAuB;MAC3BI,EAAA;MACAE,IAAA,EAAMa,qBAAA;MACNZ,MAAA;MACAa,MAAA,EAAQL,GAAA,CAAIK,MAAM;MAClBC,WAAA,EAAaF,qBAAA;MACbG,IAAA,EAAMP,GAAA,CAAIO;IACZ;IAEA,MAAMrB,aAAA,CAAc;MAClBG,EAAA;MACAmB,oBAAA,EAAsB;MACtBlB,cAAA;MACAC,IAAA,EAAMa,qBAAA;MACNZ,MAAA;MACAC,cAAA;MACAgB,QAAA,EAAUL,qBAAA;MACVV,SAAA;MACAgB,eAAA,EAAiB;MACjBC,qBAAA,EAAuB;MACvBC,UAAA,EAAY;MACZC,gBAAA,EAAkBZ,UAAA;MAClBN,WAAA;MACAC,WAAA;MACAC,iBAAA;MACAC,eAAA;MACAC,aAAA;MACAC,GAAA;MACAG;IACF;IAEA,OAAOA,KAAA;EACT;EAEA,OAAO,CAAC;AACV;AAEA,SAASjB,aAAa","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { Data, DocumentPreferences, Field as FieldSchema, FieldSchemaMap, FormState, FormStateWithoutComponents, PayloadRequest, SanitizedFieldPermissions } from 'payload';
1
+ import type { Data, DocumentPreferences, Field as FieldSchema, FieldSchemaMap, FormState, FormStateWithoutComponents, PayloadRequest, SanitizedFieldsPermissions } from 'payload';
2
2
  import type { AddFieldStatePromiseArgs } from './addFieldStatePromise.js';
3
3
  import type { RenderFieldMethod } from './types.js';
4
4
  type Args = {
@@ -34,9 +34,7 @@ type Args = {
34
34
  parentPassesCondition?: boolean;
35
35
  parentPath: string;
36
36
  parentSchemaPath: string;
37
- permissions: {
38
- [fieldName: string]: SanitizedFieldPermissions;
39
- } | null | SanitizedFieldPermissions;
37
+ permissions: SanitizedFieldsPermissions;
40
38
  preferences?: DocumentPreferences;
41
39
  previousFormState: FormState;
42
40
  renderAllFields: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"iterateFields.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/iterateFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,mBAAmB,EACnB,KAAK,IAAI,WAAW,EACpB,cAAc,EACd,SAAS,EACT,0BAA0B,EAC1B,cAAc,EACd,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAInD,KAAK,IAAI,GAAG;IACV,oBAAoB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IACjD;;OAEG;IACH,kBAAkB,CAA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ACnB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,0BAA0B,CAAA;CACnC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,yZA2BvB,IAAI,KAAG,OAAO,CAAC,IAAI,CA+CrB,CAAA"}
@@ -55,9 +55,9 @@ export const iterateFields = async ({
55
55
  operation,
56
56
  parentIndexPath,
57
57
  parentPath,
58
+ parentPermissions: permissions,
58
59
  parentSchemaPath,
59
60
  passesCondition,
60
- permissions,
61
61
  preferences,
62
62
  previousFormState,
63
63
  renderAllFields,
@@ -1 +1 @@
1
- {"version":3,"file":"iterateFields.js","names":["addFieldStatePromise","iterateFields","id","addErrorPathToParent","addErrorPathToParentArg","anyParentLocalized","collectionSlug","data","fields","fieldSchemaMap","filter","forceFullValue","fullData","includeSchema","omitParents","operation","parentIndexPath","parentPassesCondition","parentPath","parentSchemaPath","permissions","preferences","previousFormState","renderAllFields","renderFieldFn","req","skipConditionChecks","skipValidation","state","promises","forEach","field","fieldIndex","passesCondition","Boolean","admin","condition","user","push","Promise","all"],"sources":["../../../src/forms/fieldSchemasToFormState/iterateFields.ts"],"sourcesContent":["import type {\n Data,\n DocumentPreferences,\n Field as FieldSchema,\n FieldSchemaMap,\n FormState,\n FormStateWithoutComponents,\n PayloadRequest,\n SanitizedFieldPermissions,\n} from 'payload'\n\nimport type { AddFieldStatePromiseArgs } from './addFieldStatePromise.js'\nimport type { RenderFieldMethod } from './types.js'\n\nimport { addFieldStatePromise } from './addFieldStatePromise.js'\n\ntype Args = {\n addErrorPathToParent: (fieldPath: string) => void\n /**\n * if any parents is localized, then the field is localized. @default false\n */\n anyParentLocalized?: boolean\n collectionSlug?: string\n data: Data\n fields: FieldSchema[]\n fieldSchemaMap: FieldSchemaMap\n filter?: (args: AddFieldStatePromiseArgs) => boolean\n /**\n * Force the value of fields like arrays or blocks to be the full value instead of the length @default false\n */\n forceFullValue?: boolean\n fullData: Data\n id?: number | string\n /**\n * Whether the field schema should be included in the state. @default false\n */\n includeSchema?: boolean\n /**\n * Whether to omit parent fields in the state. @default false\n */\n omitParents?: boolean\n /**\n * operation is only needed for validation\n */\n operation: 'create' | 'update'\n parentIndexPath: string\n parentPassesCondition?: boolean\n parentPath: string\n parentSchemaPath: string\n permissions:\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | null\n | SanitizedFieldPermissions\n preferences?: DocumentPreferences\n previousFormState: FormState\n renderAllFields: boolean\n renderFieldFn: RenderFieldMethod\n req: PayloadRequest\n /**\n * Whether to skip checking the field's condition. @default false\n */\n skipConditionChecks?: boolean\n /**\n * Whether to skip validating the field. @default false\n */\n skipValidation?: boolean\n state?: FormStateWithoutComponents\n}\n\n/**\n * Flattens the fields schema and fields data\n */\nexport const iterateFields = async ({\n id,\n addErrorPathToParent: addErrorPathToParentArg,\n anyParentLocalized = false,\n collectionSlug,\n data,\n fields,\n fieldSchemaMap,\n filter,\n forceFullValue = false,\n fullData,\n includeSchema = false,\n omitParents = false,\n operation,\n parentIndexPath,\n parentPassesCondition = true,\n parentPath,\n parentSchemaPath,\n permissions,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn: renderFieldFn,\n req,\n skipConditionChecks = false,\n skipValidation = false,\n state = {},\n}: Args): Promise<void> => {\n const promises = []\n\n fields.forEach((field, fieldIndex) => {\n let passesCondition = true\n if (!skipConditionChecks) {\n passesCondition = Boolean(\n (field?.admin?.condition\n ? Boolean(field.admin.condition(fullData || {}, data || {}, { user: req.user }))\n : true) && parentPassesCondition,\n )\n }\n\n promises.push(\n addFieldStatePromise({\n id,\n addErrorPathToParent: addErrorPathToParentArg,\n anyParentLocalized,\n collectionSlug,\n data,\n field,\n fieldIndex,\n fieldSchemaMap,\n filter,\n forceFullValue,\n fullData,\n includeSchema,\n omitParents,\n operation,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n passesCondition,\n permissions,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n skipConditionChecks,\n skipValidation,\n state,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"mappings":"AAcA,SAASA,oBAAoB,QAAQ;AAyDrC;;;AAGA,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAO;EAClCC,EAAE;EACFC,oBAAA,EAAsBC,uBAAuB;EAC7CC,kBAAA,GAAqB,KAAK;EAC1BC,cAAc;EACdC,IAAI;EACJC,MAAM;EACNC,cAAc;EACdC,MAAM;EACNC,cAAA,GAAiB,KAAK;EACtBC,QAAQ;EACRC,aAAA,GAAgB,KAAK;EACrBC,WAAA,GAAc,KAAK;EACnBC,SAAS;EACTC,eAAe;EACfC,qBAAA,GAAwB,IAAI;EAC5BC,UAAU;EACVC,gBAAgB;EAChBC,WAAW;EACXC,WAAW;EACXC,iBAAiB;EACjBC,eAAe;EACfC,aAAA,EAAeA,aAAa;EAC5BC,GAAG;EACHC,mBAAA,GAAsB,KAAK;EAC3BC,cAAA,GAAiB,KAAK;EACtBC,KAAA,GAAQ,CAAC;AAAC,CACL;EACL,MAAMC,QAAA,GAAW,EAAE;EAEnBrB,MAAA,CAAOsB,OAAO,CAAC,CAACC,KAAA,EAAOC,UAAA;IACrB,IAAIC,eAAA,GAAkB;IACtB,IAAI,CAACP,mBAAA,EAAqB;MACxBO,eAAA,GAAkBC,OAAA,CAChB,CAACH,KAAA,EAAOI,KAAA,EAAOC,SAAA,GACXF,OAAA,CAAQH,KAAA,CAAMI,KAAK,CAACC,SAAS,CAACxB,QAAA,IAAY,CAAC,GAAGL,IAAA,IAAQ,CAAC,GAAG;QAAE8B,IAAA,EAAMZ,GAAA,CAAIY;MAAK,MAC3E,IAAG,KAAMpB,qBAAA;IAEjB;IAEAY,QAAA,CAASS,IAAI,CACXtC,oBAAA,CAAqB;MACnBE,EAAA;MACAC,oBAAA,EAAsBC,uBAAA;MACtBC,kBAAA;MACAC,cAAA;MACAC,IAAA;MACAwB,KAAA;MACAC,UAAA;MACAvB,cAAA;MACAC,MAAA;MACAC,cAAA;MACAC,QAAA;MACAC,aAAA;MACAC,WAAA;MACAC,SAAA;MACAC,eAAA;MACAE,UAAA;MACAC,gBAAA;MACAc,eAAA;MACAb,WAAA;MACAC,WAAA;MACAC,iBAAA;MACAC,eAAA;MACAC,aAAA;MACAC,GAAA;MACAC,mBAAA;MACAC,cAAA;MACAC;IACF;EAEJ;EAEA,MAAMW,OAAA,CAAQC,GAAG,CAACX,QAAA;AACpB","ignoreList":[]}
1
+ {"version":3,"file":"iterateFields.js","names":["addFieldStatePromise","iterateFields","id","addErrorPathToParent","addErrorPathToParentArg","anyParentLocalized","collectionSlug","data","fields","fieldSchemaMap","filter","forceFullValue","fullData","includeSchema","omitParents","operation","parentIndexPath","parentPassesCondition","parentPath","parentSchemaPath","permissions","preferences","previousFormState","renderAllFields","renderFieldFn","req","skipConditionChecks","skipValidation","state","promises","forEach","field","fieldIndex","passesCondition","Boolean","admin","condition","user","push","parentPermissions","Promise","all"],"sources":["../../../src/forms/fieldSchemasToFormState/iterateFields.ts"],"sourcesContent":["import type {\n Data,\n DocumentPreferences,\n Field as FieldSchema,\n FieldSchemaMap,\n FormState,\n FormStateWithoutComponents,\n PayloadRequest,\n SanitizedFieldsPermissions,\n} from 'payload'\n\nimport type { AddFieldStatePromiseArgs } from './addFieldStatePromise.js'\nimport type { RenderFieldMethod } from './types.js'\n\nimport { addFieldStatePromise } from './addFieldStatePromise.js'\n\ntype Args = {\n addErrorPathToParent: (fieldPath: string) => void\n /**\n * if any parents is localized, then the field is localized. @default false\n */\n anyParentLocalized?: boolean\n collectionSlug?: string\n data: Data\n fields: FieldSchema[]\n fieldSchemaMap: FieldSchemaMap\n filter?: (args: AddFieldStatePromiseArgs) => boolean\n /**\n * Force the value of fields like arrays or blocks to be the full value instead of the length @default false\n */\n forceFullValue?: boolean\n fullData: Data\n id?: number | string\n /**\n * Whether the field schema should be included in the state. @default false\n */\n includeSchema?: boolean\n /**\n * Whether to omit parent fields in the state. @default false\n */\n omitParents?: boolean\n /**\n * operation is only needed for validation\n */\n operation: 'create' | 'update'\n parentIndexPath: string\n parentPassesCondition?: boolean\n parentPath: string\n parentSchemaPath: string\n permissions: SanitizedFieldsPermissions\n preferences?: DocumentPreferences\n previousFormState: FormState\n renderAllFields: boolean\n renderFieldFn: RenderFieldMethod\n req: PayloadRequest\n /**\n * Whether to skip checking the field's condition. @default false\n */\n skipConditionChecks?: boolean\n /**\n * Whether to skip validating the field. @default false\n */\n skipValidation?: boolean\n state?: FormStateWithoutComponents\n}\n\n/**\n * Flattens the fields schema and fields data\n */\nexport const iterateFields = async ({\n id,\n addErrorPathToParent: addErrorPathToParentArg,\n anyParentLocalized = false,\n collectionSlug,\n data,\n fields,\n fieldSchemaMap,\n filter,\n forceFullValue = false,\n fullData,\n includeSchema = false,\n omitParents = false,\n operation,\n parentIndexPath,\n parentPassesCondition = true,\n parentPath,\n parentSchemaPath,\n permissions,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn: renderFieldFn,\n req,\n skipConditionChecks = false,\n skipValidation = false,\n state = {},\n}: Args): Promise<void> => {\n const promises = []\n\n fields.forEach((field, fieldIndex) => {\n let passesCondition = true\n if (!skipConditionChecks) {\n passesCondition = Boolean(\n (field?.admin?.condition\n ? Boolean(field.admin.condition(fullData || {}, data || {}, { user: req.user }))\n : true) && parentPassesCondition,\n )\n }\n\n promises.push(\n addFieldStatePromise({\n id,\n addErrorPathToParent: addErrorPathToParentArg,\n anyParentLocalized,\n collectionSlug,\n data,\n field,\n fieldIndex,\n fieldSchemaMap,\n filter,\n forceFullValue,\n fullData,\n includeSchema,\n omitParents,\n operation,\n parentIndexPath,\n parentPath,\n parentPermissions: permissions,\n parentSchemaPath,\n passesCondition,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n skipConditionChecks,\n skipValidation,\n state,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"mappings":"AAcA,SAASA,oBA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AqB,iBAAA,EAAmBnB,WAAA;MACnBD,gBAAA;MACAc,eAAA;MACAZ,WAAA;MACAC,iBAAA;MACAC,eAAA;MACAC,aAAA;MACAC,GAAA;MACAC,mBAAA;MACAC,cAAA;MACAC;IACF;EAEJ;EAEA,MAAMY,OAAA,CAAQC,GAAG,CAACZ,QAAA;AACpB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"renderField.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAanD,eAAO,MAAM,WAAW,EAAE,iBAuOzB,CAAA"}
1
+ {"version":3,"file":"renderField.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAanD,eAAO,MAAM,WAAW,EAAE,iBA6NzB,CAAA"}
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { getTranslation } from '@payloadcms/translations';
3
3
  import { createClientField, deepCopyObjectSimple, MissingEditorProp } from 'payload';
4
- import { fieldAffectsData } from 'payload/shared';
5
4
  import { RenderServerComponent } from '../../elements/RenderServerComponent/index.js';
6
5
  // 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
7
6
  import { FieldDescription } from '../../exports/client/index.js';
@@ -19,15 +18,12 @@ export const renderField = ({
19
18
  parentPath,
20
19
  parentSchemaPath,
21
20
  path,
22
- permissions: incomingPermissions,
21
+ permissions,
23
22
  preferences,
24
23
  req,
25
24
  schemaPath,
26
25
  siblingData
27
26
  }) => {
28
- // TODO (ALESSIO): why are we passing the fieldConfig twice?
29
- // and especially, why are we deepCopyObject -here- instead of inside the createClientField func,
30
- // so no one screws this up in the future?
31
27
  const clientField = createClientField({
32
28
  clientField: deepCopyObjectSimple(fieldConfig),
33
29
  defaultIDType: req.payload.config.db.defaultIDType,
@@ -35,12 +31,11 @@ export const renderField = ({
35
31
  i18n: req.i18n,
36
32
  importMap: req.payload.importMap
37
33
  });
38
- const permissions = incomingPermissions === true ? true : fieldAffectsData(fieldConfig) ? incomingPermissions?.[fieldConfig.name] : {};
39
34
  const clientProps = {
40
35
  customComponents: fieldState?.customComponents || {},
41
36
  field: clientField,
42
37
  path,
43
- readOnly: permissions !== true && !permissions?.[operation],
38
+ readOnly: typeof permissions === 'boolean' ? !permissions : !permissions?.[operation],
44
39
  schemaPath
45
40
  };
46
41
  // fields with subfields
@@ -1 +1 @@
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","Component","RowLabel","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","Field","FieldComponent","key","description","Description","_jsx","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\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] = RenderServerComponent({\n 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 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 fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.editor.FieldComponent,\n importMap: req.payload.importMap,\n serverProps,\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] = RenderServerComponent({\n clientProps,\n Component,\n importMap: req.payload.importMap,\n key: `field.admin.components.${key}`,\n 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 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 = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.afterInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.afterInput',\n serverProps,\n })\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.beforeInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.beforeInput',\n serverProps,\n })\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Description,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Description',\n serverProps,\n })\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Error,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Error',\n serverProps,\n })\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Label',\n serverProps,\n })\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Field,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Field',\n serverProps,\n })\n }\n }\n }\n}\n"],"mappings":";AAQA,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,SA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B,WAAA;UACAc,SAAA,EAAWtC,WAAA,CAAYmC,KAAK,CAACC,UAAU,CAACW,KAAK;UAC7CzB,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC4B,GAAA,EAAK;UACLrB;QACF;MACF;MAEA,IAAI,WAAW7B,WAAA,CAAYmC,KAAK,CAACC,UAAU,EAAE;QAC3ClC,UAAA,CAAWuB,gBAAgB,CAACkC,KAAK,GAAGlE,qBAAA,CAAsB;UACxD+B,WAAA;UACAc,SAAA,EAAWtC,WAAA,CAAYmC,KAAK,CAACC,UAAU,CAACuB,KAAK;UAC7CrC,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC4B,GAAA,EAAK;UACLrB;QACF;MACF;MAEA,IAAI,WAAW7B,WAAA,CAAYmC,KAAK,CAACC,UAAU,EAAE;QAC3ClC,UAAA,CAAWuB,gBAAgB,CAACuB,KAAK,GAAGvD,qBAAA,CAAsB;UACxD+B,WAAA;UACAc,SAAA,EAAWtC,WAAA,CAAYmC,KAAK,CAACC,UAAU,CAACY,KAAK;UAC7C1B,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC4B,GAAA,EAAK;UACLrB;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"renderField.js","names":["getTranslation","createClientField","deepCopyObjectSimple","MissingEditorProp","RenderServerComponent","FieldDescription","defaultUIFieldComponentKeys","renderField","id","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","operation","parentPath","parentSchemaPath","path","permissions","preferences","req","schemaPath","siblingData","clientField","defaultIDType","payload","config","db","field","i18n","importMap","clientProps","customComponents","readOnly","includes","type","serverProps","user","rows","forEach","row","rowIndex","admin","components","RowLabels","Component","RowLabel","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","Field","FieldComponent","key","description","Description","_jsx","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type { ClientComponentProps, ClientField, FieldPaths, ServerComponentProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, deepCopyObjectSimple, MissingEditorProp } from 'payload'\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,\n preferences,\n req,\n schemaPath,\n siblingData,\n}) => {\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 clientProps: ClientComponentProps & Partial<FieldPaths> = {\n customComponents: fieldState?.customComponents || {},\n field: clientField,\n path,\n readOnly: typeof permissions === 'boolean' ? !permissions : !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] = RenderServerComponent({\n 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 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 fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.editor.FieldComponent,\n importMap: req.payload.importMap,\n serverProps,\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] = RenderServerComponent({\n clientProps,\n Component,\n importMap: req.payload.importMap,\n key: `field.admin.components.${key}`,\n 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 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 = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.afterInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.afterInput',\n serverProps,\n })\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.beforeInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.beforeInput',\n serverProps,\n })\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Description,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Description',\n serverProps,\n })\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Error,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Error',\n serverProps,\n })\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Label',\n serverProps,\n })\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Field,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Field',\n serverProps,\n })\n }\n }\n }\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,oBAAoB,EAAEC,iBAAiB,QAAQ;AAI3E,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,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V,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC2B,GAAA,EAAK;UACLrB;QACF;MACF;MAEA,IAAI,WAAW3B,WAAA,CAAYiC,KAAK,CAACC,UAAU,EAAE;QAC3ChC,UAAA,CAAWqB,gBAAgB,CAACkC,KAAK,GAAGhE,qBAAA,CAAsB;UACxD6B,WAAA;UACAc,SAAA,EAAWpC,WAAA,CAAYiC,KAAK,CAACC,UAAU,CAACuB,KAAK;UAC7CpC,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC2B,GAAA,EAAK;UACLrB;QACF;MACF;MAEA,IAAI,WAAW3B,WAAA,CAAYiC,KAAK,CAACC,UAAU,EAAE;QAC3ChC,UAAA,CAAWqB,gBAAgB,CAACuB,KAAK,GAAGrD,qBAAA,CAAsB;UACxD6B,WAAA;UACAc,SAAA,EAAWpC,WAAA,CAAYiC,KAAK,CAACC,UAAU,CAACY,KAAK;UAC7CzB,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC2B,GAAA,EAAK;UACLrB;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
@@ -12,9 +12,7 @@ export type RenderFieldArgs = {
12
12
  parentPath: string;
13
13
  parentSchemaPath: string;
14
14
  path: string;
15
- permissions: {
16
- [fieldName: string]: SanitizedFieldPermissions;
17
- } | null | SanitizedFieldPermissions;
15
+ permissions: SanitizedFieldPermissions;
18
16
  preferences: DocumentPreferences;
19
17
  previousFieldState: FieldState;
20
18
  req: PayloadRequest;
@@ -1 +1 @@
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
+ {"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,EAAE,yBAAyB,CAAA;IACtC,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 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
+ {"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: 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":"AAiCA","ignoreList":[]}
@@ -18,7 +18,7 @@ type RenderDocument = (args: {
18
18
  redirectAfterDuplicate?: boolean;
19
19
  signal?: AbortSignal;
20
20
  }) => Promise<{
21
- data: Data;
21
+ docID: string;
22
22
  Document: React.ReactNode;
23
23
  }>;
24
24
  type GetDocumentSlots = (args: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/ServerFunctions/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,IAAI,EACJ,aAAa,EACb,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAqC,MAAM,OAAO,CAAA;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAEhF,KAAK,kBAAkB,GAAG,CACxB,IAAI,EAAE;IACJ,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GAAG,IAAI,CAAC,kBAAkB,EAAE,cAAc,GAAG,KAAK,CAAC,KACjD,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAE7C,KAAK,mBAAmB,GAAG,CACzB,IAAI,EAAE;IACJ,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GAAG,IAAI,CAAC,mBAAmB,EAAE,cAAc,GAAG,KAAK,CAAC,KAClD,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE9C,KAAK,cAAc,GAAG,CAAC,IAAI,EAAE;IAC3B,cAAc,EAAE,MAAM,C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AE,cAAc,CAAA;IAC9B,cAAc,EAAE,oBAAoB,CAAA;CACrC,CAAA;AAED,eAAO,MAAM,sBAAsB,2CAElC,CAAA;AAED,eAAO,MAAM,kBAAkB,kCAM9B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,cAAc,EAAE,oBAAoB,CAAA;CACrC,CAiGA,CAAA"}
@@ -77,14 +77,18 @@ export const ServerFunctionsProvider = ({
77
77
  ...rest
78
78
  } = args || {};
79
79
  try {
80
- const result = await serverFunction({
81
- name: 'render-document',
82
- args: {
83
- fallbackLocale: false,
84
- ...rest
80
+ if (!remoteSignal?.aborted) {
81
+ const result = await serverFunction({
82
+ name: 'render-document',
83
+ args: {
84
+ fallbackLocale: false,
85
+ ...rest
86
+ }
87
+ });
88
+ if (!remoteSignal?.aborted) {
89
+ return result;
85
90
  }
86
- });
87
- return result;
91
+ }
88
92
  } catch (_err) {
89
93
  console.error(_err) // eslint-disable-line no-console
90
94
  ;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","createContext","useCallback","ServerFunctionsContext","undefined","useServerFunctions","context","useContext","Error","ServerFunctionsProvider","children","serverFunction","getDocumentSlots","args","name","getFormState","signal","remoteSignal","rest","aborted","result","fallbackLocale","_err","console","error","state","getTableState","renderDocument","_jsx","Provider","value"],"sources":["../../../src/providers/ServerFunctions/index.tsx"],"sourcesContent":["import type {\n BuildFormStateArgs,\n BuildTableStateArgs,\n Data,\n DocumentSlots,\n ServerFunctionClient,\n} from 'payload'\n\nimport React, { createContext, useCallback } from 'react'\n\nimport type { buildFormStateHandler } from '../../utilities/buildFormState.js'\nimport type { buildTableStateHandler } from '../../utilities/buildTableState.js'\n\ntype GetFormStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildFormStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildFormStateHandler>\n\ntype GetTableStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildTableStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildTableStateHandler>\n\ntype RenderDocument = (args: {\n collectionSlug: string\n disableActions?: boolean\n docID?: number | string\n drawerSlug?: string\n initialData?: Data\n redirectAfterDelete?: boolean\n redirectAfterDuplicate?: boolean\n signal?: AbortSignal\n}) => Promise<{ data: Data; Document: React.ReactNode }>\n\ntype GetDocumentSlots = (args: {\n collectionSlug: string\n signal?: AbortSignal\n}) => Promise<DocumentSlots>\n\ntype ServerFunctionsContextType = {\n getDocumentSlots: GetDocumentSlots\n getFormState: GetFormStateClient\n getTableState: GetTableStateClient\n renderDocument: RenderDocument\n serverFunction: ServerFunctionClient\n}\n\nexport const ServerFunctionsContext = createContext<ServerFunctionsContextType | undefined>(\n undefined,\n)\n\nexport const useServerFunctions = () => {\n const context = React.useContext(ServerFunctionsContext)\n if (context === undefined) {\n throw new Error('useServerFunctions must be used within a ServerFunctionsProvider')\n }\n return context\n}\n\nexport const ServerFunctionsProvider: React.FC<{\n children: React.ReactNode\n serverFunction: ServerFunctionClient\n}> = ({ children, serverFunction }) => {\n if (!serverFunction) {\n throw new Error('ServerFunctionsProvider requires a serverFunction prop')\n }\n\n const getDocumentSlots = useCallback<GetDocumentSlots>(\n async (args) =>\n await serverFunction({\n name: 'render-document-slots',\n args,\n }),\n [serverFunction],\n )\n\n const getFormState = useCallback<GetFormStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'form-state',\n args: { fallbackLocale: false, ...rest },\n })) as ReturnType<typeof buildFormStateHandler> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n return { state: null }\n },\n [serverFunction],\n )\n\n const getTableState = useCallback<GetTableStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'table-state',\n args: { fallbackLocale: false, ...rest },\n })) as ReturnType<typeof buildTableStateHandler> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n // return { state: args.formState }\n },\n [serverFunction],\n )\n\n const renderDocument = useCallback<RenderDocument>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n const result = (await serverFunction({\n name: 'render-document',\n args: { fallbackLocale: false, ...rest },\n })) as { data: Data; Document: React.ReactNode }\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n return (\n <ServerFunctionsContext.Provider\n value={{\n getDocumentSlots,\n getFormState,\n getTableState,\n renderDocument,\n serverFunction,\n }}\n >\n {children}\n </ServerFunctionsContext.Provider>\n )\n}\n"],"mappings":";AAQA,OAAOA,KAAA,IAASC,aAAa,EAAEC,WAAW,QAAQ;AAyClD,OAAO,MAAMC,sBAAA,gBAAyBF,aAAA,CACpCG,SAAA;AAGF,OAAO,MAAMC,kBAAA,GAAqBA,CAAA;EAChC,MAAMC,OAAA,GAAUN,KAAA,CAAMO,UAAU,CAACJ,sBAAA;EACjC,IAAIG,OAAA,KAAYF,SAAA,EAAW;IACzB,MAAM,IAAII,KAAA,CAAM;EAClB;EACA,OAAOF,OAAA;AACT;AAEA,OAAO,MAAMG,uBAAA,GAGRA,CAAC;EAAEC,QAAQ;EAAEC;AAAc,CAAE;EAChC,IAAI,CAACA,cAAA,EAAgB;IACnB,MAAM,IAAIH,KAAA,CAAM;EAClB;EAEA,MAAMI,gBAAA,GAAmBV,WAAA,CACvB,MAAOW,IAAA,IACL,MAAMF,cAAA,CAAe;IACnBG,IAAA,EAAM;IACND;EACF,IACF,CAACF,cAAA,CAAe;EAGlB,MAAMI,YAAA,GAAeb,WAAA,CAC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AU,MAAMT,cAAA,CAAe;QACnCG,IAAA,EAAM;QACND,IAAA,EAAM;UAAEQ,cAAA,EAAgB;UAAO,GAAGH;QAAK;MACzC;MAEA,OAAOE,MAAA;IACT,EAAE,OAAOE,IAAA,EAAM;MACbC,OAAA,CAAQC,KAAK,CAACF,IAAA,EAAM;MAAA;IACtB;EACF,GACA,CAACX,cAAA,CAAe;EAGlB,oBACEiB,IAAA,CAACzB,sBAAA,CAAuB0B,QAAQ;IAC9BC,KAAA,EAAO;MACLlB,gBAAA;MACAG,YAAA;MACAW,aAAA;MACAC,cAAA;MACAhB;IACF;cAECD;;AAGP","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","createContext","useCallback","ServerFunctionsContext","undefined","useServerFunctions","context","useContext","Error","ServerFunctionsProvider","children","serverFunction","getDocumentSlots","args","name","getFormState","signal","remoteSignal","rest","aborted","result","fallbackLocale","_err","console","error","state","getTableState","renderDocument","_jsx","Provider","value"],"sources":["../../../src/providers/ServerFunctions/index.tsx"],"sourcesContent":["import type {\n BuildFormStateArgs,\n BuildTableStateArgs,\n Data,\n DocumentSlots,\n ServerFunctionClient,\n} from 'payload'\n\nimport React, { createContext, useCallback } from 'react'\n\nimport type { buildFormStateHandler } from '../../utilities/buildFormState.js'\nimport type { buildTableStateHandler } from '../../utilities/buildTableState.js'\n\ntype GetFormStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildFormStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildFormStateHandler>\n\ntype GetTableStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildTableStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildTableStateHandler>\n\ntype RenderDocument = (args: {\n collectionSlug: string\n disableActions?: boolean\n docID?: number | string\n drawerSlug?: string\n initialData?: Data\n redirectAfterDelete?: boolean\n redirectAfterDuplicate?: boolean\n signal?: AbortSignal\n}) => Promise<{ docID: string; Document: React.ReactNode }>\n\ntype GetDocumentSlots = (args: {\n collectionSlug: string\n signal?: AbortSignal\n}) => Promise<DocumentSlots>\n\ntype ServerFunctionsContextType = {\n getDocumentSlots: GetDocumentSlots\n getFormState: GetFormStateClient\n getTableState: GetTableStateClient\n renderDocument: RenderDocument\n serverFunction: ServerFunctionClient\n}\n\nexport const ServerFunctionsContext = createContext<ServerFunctionsContextType | undefined>(\n undefined,\n)\n\nexport const useServerFunctions = () => {\n const context = React.useContext(ServerFunctionsContext)\n if (context === undefined) {\n throw new Error('useServerFunctions must be used within a ServerFunctionsProvider')\n }\n return context\n}\n\nexport const ServerFunctionsProvider: React.FC<{\n children: React.ReactNode\n serverFunction: ServerFunctionClient\n}> = ({ children, serverFunction }) => {\n if (!serverFunction) {\n throw new Error('ServerFunctionsProvider requires a serverFunction prop')\n }\n\n const getDocumentSlots = useCallback<GetDocumentSlots>(\n async (args) =>\n await serverFunction({\n name: 'render-document-slots',\n args,\n }),\n [serverFunction],\n )\n\n const getFormState = useCallback<GetFormStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'form-state',\n args: { fallbackLocale: false, ...rest },\n })) as ReturnType<typeof buildFormStateHandler> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n return { state: null }\n },\n [serverFunction],\n )\n\n const getTableState = useCallback<GetTableStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'table-state',\n args: { fallbackLocale: false, ...rest },\n })) as ReturnType<typeof buildTableStateHandler> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n // return { state: args.formState }\n },\n [serverFunction],\n )\n\n const renderDocument = useCallback<RenderDocument>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'render-document',\n args: { fallbackLocale: false, ...rest },\n })) as { docID: string; Document: React.ReactNode }\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n return (\n <ServerFunctionsContext.Provider\n value={{\n getDocumentSlots,\n getFormState,\n getTableState,\n renderDocument,\n serverFunction,\n }}\n >\n {children}\n </ServerFunctionsContext.Provider>\n )\n}\n"],"mappings":";AAQA,OAAOA,KAAA,IAASC,aAAa,EAAEC,WAAW,QAAQ;AAyClD,OAAO,MAAMC,sBAAA,gBAAyBF,aAAA,CACpCG,SAAA;AAGF,OAAO,MAAMC,kBAAA,GAAqBA,CAAA;EAChC,MAAMC,OAAA,GAAUN,KAAA,CAAMO,UAAU,CAACJ,sBAAA;EACjC,IAAIG,OAAA,KAAYF,SAAA,EAAW;IACzB,MAAM,IAAII,KAAA,CAAM;EAClB;EACA,OAAOF,OAAA;AACT;AAEA,OAAO,MAAMG,uBAAA,GAGRA,CAAC;EAAEC,QAAQ;EAAEC;AAAc,CAAE;EAChC,IAAI,CAACA,cAAA,EAAgB;IACnB,MAAM,IAAIH,KAAA,CAAM;EAClB;EAEA,MAAMI,gBAAA,GAAmBV,WAAA,CACvB,MAAOW,IAAA,IACL,MAAMF,cAAA,CAAe;IACnBG,IAAA,EAAM;IACND;EACF,IACF,CAACF,cAAA,CAAe;EAGlB,MAAMI,YAAA,GAAeb,WAAA,CACnB,MAAOW,IAAA;IACL,MAAM;MAAEG,MAAA,EAAQC,YAAY;MAAE,GAAGC;IAAA,CAAM,GAAGL,IAAA,IAAQ,CAAC;IAEnD,IAAI;MACF,IAAI,CAACI,YAAA,EAAcE,OAAA,EAAS;QAC1B,MAAMC,MAAA,GAAU,MAAMT,cAAA,CAAe;UACnCG,IAAA,EAAM;UACND,I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E,OAAOE,IAAA,EAAM;MACbC,OAAA,CAAQC,KAAK,CAACF,IAAA,EAAM;MAAA;IACtB;EACF,GACA,CAACX,cAAA,CAAe;EAGlB,oBACEiB,IAAA,CAACzB,sBAAA,CAAuB0B,QAAQ;IAC9BC,KAAA,EAAO;MACLlB,gBAAA;MACAG,YAAA;MACAW,aAAA;MACAC,cAAA;MACAhB;IACF;cAECD;;AAGP","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/ui",
3
- "version": "3.0.2-canary.03cffa2",
3
+ "version": "3.0.2-canary.260eb1c",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -133,7 +133,7 @@
133
133
  "ts-essentials": "10.0.3",
134
134
  "use-context-selector": "2.0.0",
135
135
  "uuid": "10.0.0",
136
- "@payloadcms/translations": "3.0.2-canary.03cffa2"
136
+ "@payloadcms/translations": "3.0.2-canary.260eb1c"
137
137
  },
138
138
  "devDependencies": {
139
139
  "@babel/cli": "^7.24.5",
@@ -152,13 +152,13 @@
152
152
  "esbuild-sass-plugin": "3.3.1",
153
153
  "eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
154
154
  "@payloadcms/eslint-config": "3.0.0",
155
- "payload": "3.0.2-canary.03cffa2"
155
+ "payload": "3.0.2-canary.260eb1c"
156
156
  },
157
157
  "peerDependencies": {
158
158
  "next": "^15.0.0",
159
159
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
160
160
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
161
- "payload": "3.0.2-canary.03cffa2"
161
+ "payload": "3.0.2-canary.260eb1c"
162
162
  },
163
163
  "engines": {
164
164
  "node": "^18.20.2 || >=20.9.0"