@payloadcms/ui 3.29.0-canary.2 → 3.29.0-canary.3

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 (46) hide show
  1. package/dist/elements/Table/DefaultCell/index.d.ts.map +1 -1
  2. package/dist/elements/Table/DefaultCell/index.js +32 -25
  3. package/dist/elements/Table/DefaultCell/index.js.map +1 -1
  4. package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
  5. package/dist/elements/TableColumns/buildColumnState.js +8 -1
  6. package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
  7. package/dist/exports/client/index.js +11 -11
  8. package/dist/exports/client/index.js.map +4 -4
  9. package/dist/forms/Form/index.d.ts.map +1 -1
  10. package/dist/forms/Form/index.js.map +1 -1
  11. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts +3 -1
  12. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
  13. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +28 -0
  14. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
  15. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.d.ts +4 -2
  16. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.d.ts.map +1 -1
  17. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.js +4 -0
  18. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.js.map +1 -1
  19. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.d.ts +4 -2
  20. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.d.ts.map +1 -1
  21. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.js +4 -0
  22. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.js.map +1 -1
  23. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.d.ts +4 -2
  24. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.d.ts.map +1 -1
  25. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.js +41 -2
  26. package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.js.map +1 -1
  27. package/dist/forms/fieldSchemasToFormState/index.d.ts +4 -2
  28. package/dist/forms/fieldSchemasToFormState/index.d.ts.map +1 -1
  29. package/dist/forms/fieldSchemasToFormState/index.js +6 -0
  30. package/dist/forms/fieldSchemasToFormState/index.js.map +1 -1
  31. package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts +4 -2
  32. package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts.map +1 -1
  33. package/dist/forms/fieldSchemasToFormState/iterateFields.js +16 -0
  34. package/dist/forms/fieldSchemasToFormState/iterateFields.js.map +1 -1
  35. package/dist/utilities/buildFormState.d.ts.map +1 -1
  36. package/dist/utilities/buildFormState.js +5 -1
  37. package/dist/utilities/buildFormState.js.map +1 -1
  38. package/dist/utilities/getDisplayedFieldValue.d.ts +13 -0
  39. package/dist/utilities/getDisplayedFieldValue.d.ts.map +1 -0
  40. package/dist/utilities/getDisplayedFieldValue.js +28 -0
  41. package/dist/utilities/getDisplayedFieldValue.js.map +1 -0
  42. package/dist/utilities/hasOptionLabelJSXElement.d.ts +3 -0
  43. package/dist/utilities/hasOptionLabelJSXElement.d.ts.map +1 -0
  44. package/dist/utilities/hasOptionLabelJSXElement.js +15 -0
  45. package/dist/utilities/hasOptionLabelJSXElement.js.map +1 -0
  46. package/package.json +4 -4
@@ -1,13 +1,15 @@
1
- import type { Data, Field as FieldSchema, PayloadRequest, User } from 'payload';
1
+ import type { Data, Field as FieldSchema, PayloadRequest, SelectMode, SelectType, User } from 'payload';
2
2
  type Args = {
3
3
  data: Data;
4
4
  fields: FieldSchema[];
5
5
  id?: number | string;
6
6
  locale: string | undefined;
7
7
  req: PayloadRequest;
8
+ select?: SelectType;
9
+ selectMode?: SelectMode;
8
10
  siblingData: Data;
9
11
  user: User;
10
12
  };
11
- export declare const calculateDefaultValues: ({ id, data, fields, locale, req, user, }: Args) => Promise<Data>;
13
+ export declare const calculateDefaultValues: ({ id, data, fields, locale, req, select, selectMode, user, }: Args) => Promise<Data>;
12
14
  export {};
13
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,WAAW,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAI/E,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,sBAAsB,6CAOhC,IAAI,KAAG,OAAO,CAAC,IAAI,CAYrB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,KAAK,IAAI,WAAW,EACpB,cAAc,EACd,UAAU,EACV,UAAU,EACV,IAAI,EACL,MAAM,SAAS,CAAA;AAIhB,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,sBAAsB,iEAShC,IAAI,KAAG,OAAO,CAAC,IAAI,CAcrB,CAAA"}
@@ -5,6 +5,8 @@ export const calculateDefaultValues = async ({
5
5
  fields,
6
6
  locale,
7
7
  req,
8
+ select,
9
+ selectMode,
8
10
  user
9
11
  }) => {
10
12
  await iterateFields({
@@ -13,6 +15,8 @@ export const calculateDefaultValues = async ({
13
15
  fields,
14
16
  locale,
15
17
  req,
18
+ select,
19
+ selectMode,
16
20
  siblingData: data,
17
21
  user
18
22
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["iterateFields","calculateDefaultValues","id","data","fields","locale","req","user","siblingData"],"sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/index.ts"],"sourcesContent":["import type { Data, Field as FieldSchema, PayloadRequest, User } from 'payload'\n\nimport { iterateFields } from './iterateFields.js'\n\ntype Args = {\n data: Data\n fields: FieldSchema[]\n id?: number | string\n locale: string | undefined\n req: PayloadRequest\n siblingData: Data\n user: User\n}\n\nexport const calculateDefaultValues = async ({\n id,\n data,\n fields,\n locale,\n req,\n user,\n}: Args): Promise<Data> => {\n await iterateFields({\n id,\n data,\n fields,\n locale,\n req,\n siblingData: data,\n user,\n })\n\n return data\n}\n"],"mappings":"AAEA,SAASA,aAAa,QAAQ;AAY9B,OAAO,MAAMC,sBAAA,GAAyB,MAAAA,CAAO;EAC3CC,EAAE;EACFC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,GAAG;EACHC;AAAI,CACC;EACL,MAAMP,aAAA,CAAc;IAClBE,EAAA;IACAC,IAAA;IACAC,MAAA;IACAC,MAAA;IACAC,GAAA;IACAE,WAAA,EAAaL,IAAA;IACbI;EACF;EAEA,OAAOJ,IAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["iterateFields","calculateDefaultValues","id","data","fields","locale","req","select","selectMode","user","siblingData"],"sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/index.ts"],"sourcesContent":["import type {\n Data,\n Field as FieldSchema,\n PayloadRequest,\n SelectMode,\n SelectType,\n User,\n} from 'payload'\n\nimport { iterateFields } from './iterateFields.js'\n\ntype Args = {\n data: Data\n fields: FieldSchema[]\n id?: number | string\n locale: string | undefined\n req: PayloadRequest\n select?: SelectType\n selectMode?: SelectMode\n siblingData: Data\n user: User\n}\n\nexport const calculateDefaultValues = async ({\n id,\n data,\n fields,\n locale,\n req,\n select,\n selectMode,\n user,\n}: Args): Promise<Data> => {\n await iterateFields({\n id,\n data,\n fields,\n locale,\n req,\n select,\n selectMode,\n siblingData: data,\n user,\n })\n\n return data\n}\n"],"mappings":"AASA,SAASA,aAAa,QAAQ;AAc9B,OAAO,MAAMC,sBAAA,GAAyB,MAAAA,CAAO;EAC3CC,EAAE;EACFC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,GAAG;EACHC,MAAM;EACNC,UAAU;EACVC;AAAI,CACC;EACL,MAAMT,aAAA,CAAc;IAClBE,EAAA;IACAC,IAAA;IACAC,MAAA;IACAC,MAAA;IACAC,GAAA;IACAC,MAAA;IACAC,UAAA;IACAE,WAAA,EAAaP,IAAA;IACbM;EACF;EAEA,OAAON,IAAA;AACT","ignoreList":[]}
@@ -1,13 +1,15 @@
1
- import type { Data, Field, PayloadRequest, TabAsField, User } from 'payload';
1
+ import type { Data, Field, PayloadRequest, SelectMode, SelectType, TabAsField, User } from 'payload';
2
2
  type Args<T> = {
3
3
  data: T;
4
4
  fields: (Field | TabAsField)[];
5
5
  id?: number | string;
6
6
  locale: string | undefined;
7
7
  req: PayloadRequest;
8
+ select?: SelectType;
9
+ selectMode?: SelectMode;
8
10
  siblingData: Data;
9
11
  user: User;
10
12
  };
11
- export declare const iterateFields: <T>({ id, data, fields, locale, req, siblingData, user, }: Args<T>) => Promise<void>;
13
+ export declare const iterateFields: <T>({ id, data, fields, locale, req, select, selectMode, siblingData, user, }: Args<T>) => Promise<void>;
12
14
  export {};
13
15
  //# sourceMappingURL=iterateFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"iterateFields.d.ts","sourceRoot":"","sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAI5E,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,IAAI,EAAE,CAAC,CAAA;IACP,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,aAAa,GAAU,CAAC,yDAQlC,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CAkBxB,CAAA"}
1
+ {"version":3,"file":"iterateFields.d.ts","sourceRoot":"","sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAIpG,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,IAAI,EAAE,CAAC,CAAA;IACP,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,aAAa,GAAU,CAAC,6EAUlC,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CAoBxB,CAAA"}
@@ -5,6 +5,8 @@ export const iterateFields = async ({
5
5
  fields,
6
6
  locale,
7
7
  req,
8
+ select,
9
+ selectMode,
8
10
  siblingData,
9
11
  user
10
12
  }) => {
@@ -16,6 +18,8 @@ export const iterateFields = async ({
16
18
  field,
17
19
  locale,
18
20
  req,
21
+ select,
22
+ selectMode,
19
23
  siblingData,
20
24
  user
21
25
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"iterateFields.js","names":["defaultValuePromise","iterateFields","id","data","fields","locale","req","siblingData","user","promises","forEach","field","push","Promise","all"],"sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.ts"],"sourcesContent":["import type { Data, Field, PayloadRequest, TabAsField, User } from 'payload'\n\nimport { defaultValuePromise } from './promise.js'\n\ntype Args<T> = {\n data: T\n fields: (Field | TabAsField)[]\n id?: number | string\n locale: string | undefined\n req: PayloadRequest\n siblingData: Data\n user: User\n}\n\nexport const iterateFields = async <T>({\n id,\n data,\n fields,\n locale,\n req,\n siblingData,\n user,\n}: Args<T>): Promise<void> => {\n const promises = []\n\n fields.forEach((field) => {\n promises.push(\n defaultValuePromise({\n id,\n data,\n field,\n locale,\n req,\n siblingData,\n user,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ;AAYpC,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAU;EACrCC,EAAE;EACFC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,GAAG;EACHC,WAAW;EACXC;AAAI,CACI;EACR,MAAMC,QAAA,GAAW,EAAE;EAEnBL,MAAA,CAAOM,OAAO,CAAEC,KAAA;IACdF,QAAA,CAASG,IAAI,CACXZ,mBAAA,CAAoB;MAClBE,EAAA;MACAC,IAAA;MACAQ,KAAA;MACAN,MAAA;MACAC,GAAA;MACAC,WAAA;MACAC;IACF;EAEJ;EAEA,MAAMK,OAAA,CAAQC,GAAG,CAACL,QAAA;AACpB","ignoreList":[]}
1
+ {"version":3,"file":"iterateFields.js","names":["defaultValuePromise","iterateFields","id","data","fields","locale","req","select","selectMode","siblingData","user","promises","forEach","field","push","Promise","all"],"sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.ts"],"sourcesContent":["import type { Data, Field, PayloadRequest, SelectMode, SelectType, TabAsField, User } from 'payload'\n\nimport { defaultValuePromise } from './promise.js'\n\ntype Args<T> = {\n data: T\n fields: (Field | TabAsField)[]\n id?: number | string\n locale: string | undefined\n req: PayloadRequest\n select?: SelectType\n selectMode?: SelectMode\n siblingData: Data\n user: User\n}\n\nexport const iterateFields = async <T>({\n id,\n data,\n fields,\n locale,\n req,\n select,\n selectMode,\n siblingData,\n user,\n}: Args<T>): Promise<void> => {\n const promises = []\n\n fields.forEach((field) => {\n promises.push(\n defaultValuePromise({\n id,\n data,\n field,\n locale,\n req,\n select,\n selectMode,\n siblingData,\n user,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ;AAcpC,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAU;EACrCC,EAAE;EACFC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,GAAG;EACHC,MAAM;EACNC,UAAU;EACVC,WAAW;EACXC;AAAI,CACI;EACR,MAAMC,QAAA,GAAW,EAAE;EAEnBP,MAAA,CAAOQ,OAAO,CAAEC,KAAA;IACdF,QAAA,CAASG,IAAI,CACXd,mBAAA,CAAoB;MAClBE,EAAA;MACAC,IAAA;MACAU,KAAA;MACAR,MAAA;MACAC,GAAA;MACAC,MAAA;MACAC,UAAA;MACAC,WAAA;MACAC;IACF;EAEJ;EAEA,MAAMK,OAAA,CAAQC,GAAG,CAACL,QAAA;AACpB","ignoreList":[]}
@@ -1,13 +1,15 @@
1
- import type { Data, Field, PayloadRequest, TabAsField, User } from 'payload';
1
+ import type { Data, Field, PayloadRequest, SelectMode, SelectType, TabAsField, User } from 'payload';
2
2
  type Args<T> = {
3
3
  data: T;
4
4
  field: Field | TabAsField;
5
5
  id?: number | string;
6
6
  locale: string | undefined;
7
7
  req: PayloadRequest;
8
+ select?: SelectType;
9
+ selectMode?: SelectMode;
8
10
  siblingData: Data;
9
11
  user: User;
10
12
  };
11
- export declare const defaultValuePromise: <T>({ id, data, field, locale, req, siblingData, user, }: Args<T>) => Promise<void>;
13
+ export declare const defaultValuePromise: <T>({ id, data, field, locale, req, select, selectMode, siblingData, user, }: Args<T>) => Promise<void>;
12
14
  export {};
13
15
  //# sourceMappingURL=promise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/promise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAkB,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAO5F,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAGD,eAAO,MAAM,mBAAmB,GAAU,CAAC,wDAQxC,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CAkKxB,CAAA"}
1
+ {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/promise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,KAAK,EAEL,cAAc,EACd,UAAU,EACV,UAAU,EACV,UAAU,EACV,IAAI,EACL,MAAM,SAAS,CAAA;AAOhB,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAGD,eAAO,MAAM,mBAAmB,GAAU,CAAC,4EAUxC,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CA8MxB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { getDefaultValue } from 'payload';
1
+ import { getBlockSelect, getDefaultValue, stripUnselectedFields } from 'payload';
2
2
  import { fieldAffectsData, tabHasName } from 'payload/shared';
3
3
  import { iterateFields } from './iterateFields.js';
4
4
  // TODO: Make this works for rich text subfields
@@ -8,9 +8,20 @@ export const defaultValuePromise = async ({
8
8
  field,
9
9
  locale,
10
10
  req,
11
+ select,
12
+ selectMode,
11
13
  siblingData,
12
14
  user
13
15
  }) => {
16
+ const shouldContinue = stripUnselectedFields({
17
+ field,
18
+ select,
19
+ selectMode,
20
+ siblingDoc: siblingData
21
+ });
22
+ if (!shouldContinue) {
23
+ return;
24
+ }
14
25
  if (fieldAffectsData(field)) {
15
26
  if (typeof siblingData[field.name] === 'undefined' && typeof field.defaultValue !== 'undefined') {
16
27
  try {
@@ -36,6 +47,7 @@ export const defaultValuePromise = async ({
36
47
  const rows = siblingData[field.name];
37
48
  if (Array.isArray(rows)) {
38
49
  const promises = [];
50
+ const arraySelect = select?.[field.name];
39
51
  rows.forEach(row => {
40
52
  promises.push(iterateFields({
41
53
  id,
@@ -43,6 +55,8 @@ export const defaultValuePromise = async ({
43
55
  fields: field.fields,
44
56
  locale,
45
57
  req,
58
+ select: typeof arraySelect === 'object' ? arraySelect : undefined,
59
+ selectMode,
46
60
  siblingData: row,
47
61
  user
48
62
  }));
@@ -59,6 +73,14 @@ export const defaultValuePromise = async ({
59
73
  rows.forEach(row => {
60
74
  const blockTypeToMatch = row.blockType;
61
75
  const block = req.payload.blocks[blockTypeToMatch] ?? (field.blockReferences ?? field.blocks).find(blockType => typeof blockType !== 'string' && blockType.slug === blockTypeToMatch);
76
+ const {
77
+ blockSelect,
78
+ blockSelectMode
79
+ } = getBlockSelect({
80
+ block,
81
+ select: select?.[field.name],
82
+ selectMode
83
+ });
62
84
  if (block) {
63
85
  row.blockType = blockTypeToMatch;
64
86
  promises.push(iterateFields({
@@ -67,6 +89,8 @@ export const defaultValuePromise = async ({
67
89
  fields: block.fields,
68
90
  locale,
69
91
  req,
92
+ select: typeof blockSelect === 'object' ? blockSelect : undefined,
93
+ selectMode: blockSelectMode,
70
94
  siblingData: row,
71
95
  user
72
96
  }));
@@ -85,6 +109,8 @@ export const defaultValuePromise = async ({
85
109
  fields: field.fields,
86
110
  locale,
87
111
  req,
112
+ select,
113
+ selectMode,
88
114
  siblingData,
89
115
  user
90
116
  });
@@ -96,12 +122,15 @@ export const defaultValuePromise = async ({
96
122
  siblingData[field.name] = {};
97
123
  }
98
124
  const groupData = siblingData[field.name];
125
+ const groupSelect = select?.[field.name];
99
126
  await iterateFields({
100
127
  id,
101
128
  data,
102
129
  fields: field.fields,
103
130
  locale,
104
131
  req,
132
+ select: typeof groupSelect === 'object' ? groupSelect : undefined,
133
+ selectMode,
105
134
  siblingData: groupData,
106
135
  user
107
136
  });
@@ -110,13 +139,19 @@ export const defaultValuePromise = async ({
110
139
  case 'tab':
111
140
  {
112
141
  let tabSiblingData;
113
- if (tabHasName(field)) {
142
+ const isNamedTab = tabHasName(field);
143
+ let tabSelect;
144
+ if (isNamedTab) {
114
145
  if (typeof siblingData[field.name] !== 'object') {
115
146
  siblingData[field.name] = {};
116
147
  }
117
148
  tabSiblingData = siblingData[field.name];
149
+ if (typeof select?.[field.name] === 'object') {
150
+ tabSelect = select?.[field.name];
151
+ }
118
152
  } else {
119
153
  tabSiblingData = siblingData;
154
+ tabSelect = select;
120
155
  }
121
156
  await iterateFields({
122
157
  id,
@@ -124,6 +159,8 @@ export const defaultValuePromise = async ({
124
159
  fields: field.fields,
125
160
  locale,
126
161
  req,
162
+ select: tabSelect,
163
+ selectMode,
127
164
  siblingData: tabSiblingData,
128
165
  user
129
166
  });
@@ -140,6 +177,8 @@ export const defaultValuePromise = async ({
140
177
  })),
141
178
  locale,
142
179
  req,
180
+ select,
181
+ selectMode,
143
182
  siblingData,
144
183
  user
145
184
  });
@@ -1 +1 @@
1
- {"version":3,"file":"promise.js","names":["getDefaultValue","fieldAffectsData","tabHasName","iterateFields","defaultValuePromise","id","data","field","locale","req","siblingData","user","name","defaultValue","value","err","payload","logger","error","msg","type","rows","Array","isArray","promises","forEach","row","push","fields","Promise","all","blockTypeToMatch","blockType","block","blocks","blockReferences","find","slug","groupData","tabSiblingData","tabs","map","tab"],"sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/promise.ts"],"sourcesContent":["import type { Data, Field, FlattenedBlock, PayloadRequest, TabAsField, User } from 'payload'\n\nimport { getDefaultValue } from 'payload'\nimport { fieldAffectsData, tabHasName } from 'payload/shared'\n\nimport { iterateFields } from './iterateFields.js'\n\ntype Args<T> = {\n data: T\n field: Field | TabAsField\n id?: number | string\n locale: string | undefined\n req: PayloadRequest\n siblingData: Data\n user: User\n}\n\n// TODO: Make this works for rich text subfields\nexport const defaultValuePromise = async <T>({\n id,\n data,\n field,\n locale,\n req,\n siblingData,\n user,\n}: Args<T>): Promise<void> => {\n if (fieldAffectsData(field)) {\n if (\n typeof siblingData[field.name] === 'undefined' &&\n typeof field.defaultValue !== 'undefined'\n ) {\n try {\n siblingData[field.name] = await getDefaultValue({\n defaultValue: field.defaultValue,\n locale,\n req,\n user,\n value: siblingData[field.name],\n })\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `Error calculating default value for field: ${field.name}`,\n })\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n\n rows.forEach((row) => {\n promises.push(\n iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n req,\n siblingData: row,\n user,\n }),\n )\n })\n\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row) => {\n const blockTypeToMatch: string = row.blockType\n const block =\n req.payload.blocks[blockTypeToMatch] ??\n ((field.blockReferences ?? field.blocks).find(\n (blockType) => typeof blockType !== 'string' && blockType.slug === blockTypeToMatch,\n ) as FlattenedBlock | undefined)\n\n if (block) {\n row.blockType = blockTypeToMatch\n\n promises.push(\n iterateFields({\n id,\n data,\n fields: block.fields,\n locale,\n req,\n siblingData: row,\n user,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n req,\n siblingData,\n user,\n })\n\n break\n }\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n\n await iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n req,\n siblingData: groupData,\n user,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n if (tabHasName(field)) {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n } else {\n tabSiblingData = siblingData\n }\n\n await iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n req,\n siblingData: tabSiblingData,\n user,\n })\n\n break\n }\n\n case 'tabs': {\n await iterateFields({\n id,\n data,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n locale,\n req,\n siblingData,\n user,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ;AAChC,SAASC,gBAAgB,EAAEC,UAAU,QAAQ;AAE7C,SAASC,aAAa,QAAQ;AAY9B;AACA,OAAO,MAAMC,mBAAA,GAAsB,MAAAA,CAAU;EAC3CC,EAAE;EACFC,IAAI;EACJC,KAAK;EACLC,MAAM;EACNC,GAAG;EACHC,WAAW;EACXC;AAAI,CACI;EACR,IAAIV,gBAAA,CAAiBM,KAAA,GAAQ;IAC3B,IACE,OAAOG,WAAW,CAACH,KAAA,CAAMK,IAAI,CAAC,KAAK,eACnC,OAAOL,KAAA,CAAMM,YAAY,KAAK,aAC9B;MACA,IAAI;QACFH,WAAW,CAACH,KAAA,CAAMK,IAAI,CAAC,GAAG,MAAMZ,eAAA,CAAgB;UAC9Ca,YAAA,EAAcN,KAAA,CAAMM,YAAY;UAChCL,MAAA;UACAC,GAAA;UACAE,IAAA;UACAG,KAAA,EAAOJ,WAAW,CAACH,KAAA,CAAMK,IAAI;QAC/B;MACF,EAAE,OAAOG,GAAA,EAAK;QACZN,GAAA,CAAIO,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;UACvBH,GAAA;UACAI,GAAA,EAAK,8CAA8CZ,KAAA,CAAMK,IAAI;QAC/D;MACF;IACF;EACF;EAEA;EACA,QAAQL,KAAA,CAAMa,IAAI;IAChB,KAAK;MAAS;QACZ,MAAMC,IAAA,GAAOX,WAAW,CAACH,KAAA,CAAMK,IAAI,CAAC;QAEpC,IAAIU,KAAA,CAAMC,OAAO,CAACF,IAAA,GAAO;UACvB,MAAMG,QAAA,GAAW,EAAE;UAEnBH,IAAA,C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ultValue","stripUnselectedFields","fieldAffectsData","tabHasName","iterateFields","defaultValuePromise","id","data","field","locale","req","select","selectMode","siblingData","user","shouldContinue","siblingDoc","name","defaultValue","value","err","payload","logger","error","msg","type","rows","Array","isArray","promises","arraySelect","forEach","row","push","fields","undefined","Promise","all","blockTypeToMatch","blockType","block","blocks","blockReferences","find","slug","blockSelect","blockSelectMode","groupData","groupSelect","tabSiblingData","isNamedTab","tabSelect","tabs","map","tab"],"sources":["../../../../src/forms/fieldSchemasToFormState/calculateDefaultValues/promise.ts"],"sourcesContent":["import type {\n Data,\n Field,\n FlattenedBlock,\n PayloadRequest,\n SelectMode,\n SelectType,\n TabAsField,\n User,\n} from 'payload'\n\nimport { getBlockSelect, getDefaultValue, stripUnselectedFields } from 'payload'\nimport { fieldAffectsData, tabHasName } from 'payload/shared'\n\nimport { iterateFields } from './iterateFields.js'\n\ntype Args<T> = {\n data: T\n field: Field | TabAsField\n id?: number | string\n locale: string | undefined\n req: PayloadRequest\n select?: SelectType\n selectMode?: SelectMode\n siblingData: Data\n user: User\n}\n\n// TODO: Make this works for rich text subfields\nexport const defaultValuePromise = async <T>({\n id,\n data,\n field,\n locale,\n req,\n select,\n selectMode,\n siblingData,\n user,\n}: Args<T>): Promise<void> => {\n const shouldContinue = stripUnselectedFields({\n field,\n select,\n selectMode,\n siblingDoc: siblingData,\n })\n\n if (!shouldContinue) {\n return\n }\n\n if (fieldAffectsData(field)) {\n if (\n typeof siblingData[field.name] === 'undefined' &&\n typeof field.defaultValue !== 'undefined'\n ) {\n try {\n siblingData[field.name] = await getDefaultValue({\n defaultValue: field.defaultValue,\n locale,\n req,\n user,\n value: siblingData[field.name],\n })\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `Error calculating default value for field: ${field.name}`,\n })\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n const arraySelect = select?.[field.name]\n\n rows.forEach((row) => {\n promises.push(\n iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n req,\n select: typeof arraySelect === 'object' ? arraySelect : undefined,\n selectMode,\n siblingData: row,\n user,\n }),\n )\n })\n\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n\n rows.forEach((row) => {\n const blockTypeToMatch: string = row.blockType\n\n const block =\n req.payload.blocks[blockTypeToMatch] ??\n ((field.blockReferences ?? field.blocks).find(\n (blockType) => typeof blockType !== 'string' && blockType.slug === blockTypeToMatch,\n ) as FlattenedBlock | undefined)\n\n const { blockSelect, blockSelectMode } = getBlockSelect({\n block,\n select: select?.[field.name],\n selectMode,\n })\n\n if (block) {\n row.blockType = blockTypeToMatch\n\n promises.push(\n iterateFields({\n id,\n data,\n fields: block.fields,\n locale,\n req,\n select: typeof blockSelect === 'object' ? blockSelect : undefined,\n selectMode: blockSelectMode,\n siblingData: row,\n user,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n req,\n select,\n selectMode,\n siblingData,\n user,\n })\n\n break\n }\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n\n const groupSelect = select?.[field.name]\n\n await iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n req,\n select: typeof groupSelect === 'object' ? groupSelect : undefined,\n selectMode,\n siblingData: groupData,\n user,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n\n const isNamedTab = tabHasName(field)\n\n let tabSelect: SelectType | undefined\n\n if (isNamedTab) {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n\n if (typeof select?.[field.name] === 'object') {\n tabSelect = select?.[field.name] as SelectType\n }\n } else {\n tabSiblingData = siblingData\n tabSelect = select\n }\n\n await iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n req,\n select: tabSelect,\n selectMode,\n siblingData: tabSiblingData,\n user,\n })\n\n break\n }\n\n case 'tabs': {\n await iterateFields({\n id,\n data,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n locale,\n req,\n select,\n selectMode,\n siblingData,\n user,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"mappings":"AAWA,SAASA,cAAc,EAAEC,eAAe,EAAEC,qBAAqB,QAAQ;AACvE,SAASC,gBAAgB,EAAEC,UAAU,QAAQ;AAE7C,SAASC,aAAa,QAAQ;AAc9B;AACA,OAAO,MAAMC,mBAAA,GAAsB,MAAAA,CAAU;EAC3CC,EAAE;EACFC,IAAI;EACJC,KAAK;EACLC,MAAM;EACNC,GAAG;EACHC,MAAM;EACNC,UAAU;EACVC,WAAW;EACXC;AAAI,CACI;EACR,MAAMC,cAAA,GAAiBd,qBAAA,CAAsB;IAC3CO,KAAA;IACAG,MAAA;IACAC,UAAA;IACAI,UAAA,EAAYH;EACd;EAEA,IAAI,CAACE,cAAA,EAAgB;IACnB;EACF;EAEA,IAAIb,gBAAA,CAAiBM,KAAA,GAAQ;IAC3B,IACE,OAAOK,WAAW,CAACL,KAAA,CAAMS,IAAI,CAAC,KAAK,eACnC,OAAOT,KAAA,CAAMU,YAAY,KAAK,aAC9B;MACA,IAAI;QACFL,WAAW,CAACL,KAAA,CAAMS,IAAI,CAAC,GAAG,MAAMjB,eAAA,CAAgB;UAC9CkB,YAAA,EAAcV,KAAA,CAAMU,YAAY;UAChCT,MAAA;UACAC,GAAA;UACAI,IAAA;UACAK,KAAA,EAAON,WAAW,CAACL,KAAA,CAAMS,IAAI;QAC/B;MACF,EAAE,OAAOG,GAAA,EAAK;QACZV,GAAA,CAAIW,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;UACvBH,GAAA;UACAI,GAAA,EAAK,8CAA8ChB,KAAA,CAAMS,IA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IAEA,KAAK;MAAO;QACV,IAAImC,cAAA;QAEJ,MAAMC,UAAA,GAAa/C,UAAA,CAAWK,KAAA;QAE9B,IAAI2C,SAAA;QAEJ,IAAID,UAAA,EAAY;UACd,IAAI,OAAOrC,WAAW,CAACL,KAAA,CAAMS,IAAI,CAAC,KAAK,UAAU;YAC/CJ,WAAW,CAACL,KAAA,CAAMS,IAAI,CAAC,GAAG,CAAC;UAC7B;UAEAgC,cAAA,GAAiBpC,WAAW,CAACL,KAAA,CAAMS,IAAI,CAAC;UAExC,IAAI,OAAON,MAAA,GAASH,KAAA,CAAMS,IAAI,CAAC,KAAK,UAAU;YAC5CkC,SAAA,GAAYxC,MAAA,GAASH,KAAA,CAAMS,IAAI,CAAC;UAClC;QACF,OAAO;UACLgC,cAAA,GAAiBpC,WAAA;UACjBsC,SAAA,GAAYxC,MAAA;QACd;QAEA,MAAMP,aAAA,CAAc;UAClBE,EAAA;UACAC,IAAA;UACA2B,MAAA,EAAQ1B,KAAA,CAAM0B,MAAM;UACpBzB,MAAA;UACAC,GAAA;UACAC,MAAA,EAAQwC,SAAA;UACRvC,UAAA;UACAC,WAAA,EAAaoC,cAAA;UACbnC;QACF;QAEA;MACF;IAEA,KAAK;MAAQ;QACX,MAAMV,aAAA,CAAc;UAClBE,EAAA;UACAC,IAAA;UACA2B,MAAA,EAAQ1B,KAAA,CAAM4C,IAAI,CAACC,GAAG,CAAEC,GAAA,KAAS;YAAE,GAAGA,GAAG;YAAE7B,IAAA,EAAM;UAAM;UACvDhB,MAAA;UACAC,GAAA;UACAC,MAAA;UACAC,UAAA;UACAC,WAAA;UACAC;QACF;QAEA;MACF;IAEA;MAAS;QACP;MACF;EACF;AACF","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ClientFieldSchemaMap, Data, DocumentPreferences, Field, FieldSchemaMap, FormState, PayloadRequest, SanitizedFieldsPermissions } from 'payload';
1
+ import type { ClientFieldSchemaMap, Data, DocumentPreferences, Field, FieldSchemaMap, FormState, PayloadRequest, SanitizedFieldsPermissions, SelectMode, SelectType } from 'payload';
2
2
  import type { RenderFieldMethod } from './types.js';
3
3
  import { iterateFields } from './iterateFields.js';
4
4
  type Args = {
@@ -56,8 +56,10 @@ type Args = {
56
56
  renderFieldFn?: RenderFieldMethod;
57
57
  req: PayloadRequest;
58
58
  schemaPath: string;
59
+ select?: SelectType;
60
+ selectMode?: SelectMode;
59
61
  skipValidation?: boolean;
60
62
  };
61
- export declare const fieldSchemasToFormState: ({ id, clientFieldSchemaMap, collectionSlug, data, documentData, fields, fieldSchemaMap, initialBlockData, operation, permissions, preferences, previousFormState, renderAllFields, renderFieldFn, req, schemaPath, skipValidation, }: Args) => Promise<FormState>;
63
+ export declare const fieldSchemasToFormState: ({ id, clientFieldSchemaMap, collectionSlug, data, documentData, fields, fieldSchemaMap, initialBlockData, operation, permissions, preferences, previousFormState, renderAllFields, renderFieldFn, req, schemaPath, select, selectMode, skipValidation, }: Args) => Promise<FormState>;
62
64
  export { iterateFields };
63
65
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,IAAI,EACJ,mBAAmB,EACnB,KAAK,EACL,cAAc,EACd,SAAS,EAET,cAAc,EACd,0BAA0B,EAC3B,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;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,EAAE,IAAI,CAAA;IACnB,MAAM,EAAE,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CAAA;IACnB,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;;;OAGG;IACH,gBAAgB,CAAC,EAAE,IAAI,CAAA;IACvB,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,WAAW,EAAE,0BAA0B,CAAA;IACvC,WAAW,EAAE,mBAAmB,CAAA;IAChC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,SAAS,CAAA;IAC7B;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,iBAAiB,CAAA;IACjC,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,uBAAuB,6PAoBjC,IAAI,KAAG,OAAO,CAAC,SAAS,CA+D1B,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -17,6 +17,8 @@ export const fieldSchemasToFormState = async ({
17
17
  renderFieldFn,
18
18
  req,
19
19
  schemaPath,
20
+ select,
21
+ selectMode,
20
22
  skipValidation
21
23
  }) => {
22
24
  if (!clientFieldSchemaMap && renderFieldFn) {
@@ -33,6 +35,8 @@ export const fieldSchemasToFormState = async ({
33
35
  fields,
34
36
  locale: req.locale,
35
37
  req,
38
+ select,
39
+ selectMode,
36
40
  siblingData: dataWithDefaultValues,
37
41
  user: req.user
38
42
  });
@@ -63,6 +67,8 @@ export const fieldSchemasToFormState = async ({
63
67
  renderAllFields,
64
68
  renderFieldFn,
65
69
  req,
70
+ select,
71
+ selectMode,
66
72
  skipValidation,
67
73
  state
68
74
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["calculateDefaultValues","iterateFields","fieldSchemasToFormState","id","clientFieldSchemaMap","collectionSlug","data","documentData","fields","fieldSchemaMap","initialBlockData","operation","permissions","preferences","previousFormState","renderAllFields","renderFieldFn","req","schemaPath","skipValidation","console","warn","length","state","dataWithDefaultValues","locale","siblingData","user","fullData","addErrorPathToParent","blockData","parentIndexPath","parentPassesCondition","parentPath","parentSchemaPath"],"sources":["../../../src/forms/fieldSchemasToFormState/index.tsx"],"sourcesContent":["import type {\n ClientFieldSchemaMap,\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 /**\n * The client field schema map is required for field rendering.\n * If fields should not be rendered (=> `renderFieldFn` is not provided),\n * then the client field schema map is not required.\n */\n clientFieldSchemaMap?: ClientFieldSchemaMap\n collectionSlug?: string\n data?: Data\n /**\n * If this is undefined, the `data` passed to this function will serve as `fullData` and `data` when iterating over\n * the top-level-fields to generate form state.\n * For sub fields, the `data` will be narrowed down to the sub fields, while `fullData` remains the same.\n *\n * Usually, the `data` passed to this function will be the document data. This means that running validation, read access control\n * or executing filterOptions here will have access to the full document through the passed `fullData` parameter, and that `fullData` and `data` will be identical.\n *\n * In some cases however, this function is used to generate form state solely for sub fields - independent from the parent form state.\n * This means that `data` will be the form state of the sub fields - the document data won't be available here.\n *\n * In these cases, you can pass `documentData` which will be used as `fullData` instead of `data`.\n *\n * This is useful for lexical blocks, as lexical block fields there are not part of the parent form state, yet we still want\n * document data to be available for validation and filterOptions, under the `data` key.\n */\n documentData?: 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 /**\n * Validation, filterOptions and read access control will receive the `blockData`, which is the data of the nearest parent block. You can pass in\n * the initial block data here, which will be used as `blockData` for the top-level fields, until the first block is encountered.\n */\n initialBlockData?: Data\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 skipValidation?: boolean\n}\n\nexport const fieldSchemasToFormState = async ({\n id,\n clientFieldSchemaMap,\n collectionSlug,\n data = {},\n documentData,\n fields,\n fieldSchemaMap,\n initialBlockData,\n operation,\n permissions,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n schemaPath,\n skipValidation,\n}: Args): Promise<FormState> => {\n if (!clientFieldSchemaMap && renderFieldFn) {\n console.warn(\n 'clientFieldSchemaMap is not passed to fieldSchemasToFormState - this will reduce performance',\n )\n }\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 req,\n siblingData: dataWithDefaultValues,\n user: req.user,\n })\n\n let fullData = dataWithDefaultValues\n\n if (documentData) {\n // By the time this function is used to get form state for nested forms, their default values should have already been calculated\n // => no need to run calculateDefaultValues here\n fullData = documentData\n }\n\n await iterateFields({\n id,\n addErrorPathToParent: null,\n blockData: initialBlockData,\n clientFieldSchemaMap,\n collectionSlug,\n data: dataWithDefaultValues,\n fields,\n fieldSchemaMap,\n fullData,\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 skipValidation,\n state,\n })\n\n return state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A;MACAC,eAAA;MACAC,aAAA;MACAC,GAAA;MACAE,cAAA;MACAI;IACF;IAEA,OAAOA,KAAA;EACT;EAEA,OAAO,CAAC;AACV;AAEA,SAAStB,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["calculateDefaultValues","iterateFields","fieldSchemasToFormState","id","clientFieldSchemaMap","collectionSlug","data","documentData","fields","fieldSchemaMap","initialBlockData","operation","permissions","preferences","previousFormState","renderAllFields","renderFieldFn","req","schemaPath","select","selectMode","skipValidation","console","warn","length","state","dataWithDefaultValues","locale","siblingData","user","fullData","addErrorPathToParent","blockData","parentIndexPath","parentPassesCondition","parentPath","parentSchemaPath"],"sources":["../../../src/forms/fieldSchemasToFormState/index.tsx"],"sourcesContent":["import type {\n ClientFieldSchemaMap,\n Data,\n DocumentPreferences,\n Field,\n FieldSchemaMap,\n FormState,\n FormStateWithoutComponents,\n PayloadRequest,\n SanitizedFieldsPermissions,\n SelectMode,\n SelectType,\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 /**\n * The client field schema map is required for field rendering.\n * If fields should not be rendered (=> `renderFieldFn` is not provided),\n * then the client field schema map is not required.\n */\n clientFieldSchemaMap?: ClientFieldSchemaMap\n collectionSlug?: string\n data?: Data\n /**\n * If this is undefined, the `data` passed to this function will serve as `fullData` and `data` when iterating over\n * the top-level-fields to generate form state.\n * For sub fields, the `data` will be narrowed down to the sub fields, while `fullData` remains the same.\n *\n * Usually, the `data` passed to this function will be the document data. This means that running validation, read access control\n * or executing filterOptions here will have access to the full document through the passed `fullData` parameter, and that `fullData` and `data` will be identical.\n *\n * In some cases however, this function is used to generate form state solely for sub fields - independent from the parent form state.\n * This means that `data` will be the form state of the sub fields - the document data won't be available here.\n *\n * In these cases, you can pass `documentData` which will be used as `fullData` instead of `data`.\n *\n * This is useful for lexical blocks, as lexical block fields there are not part of the parent form state, yet we still want\n * document data to be available for validation and filterOptions, under the `data` key.\n */\n documentData?: 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 /**\n * Validation, filterOptions and read access control will receive the `blockData`, which is the data of the nearest parent block. You can pass in\n * the initial block data here, which will be used as `blockData` for the top-level fields, until the first block is encountered.\n */\n initialBlockData?: Data\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 select?: SelectType\n selectMode?: SelectMode\n skipValidation?: boolean\n}\n\nexport const fieldSchemasToFormState = async ({\n id,\n clientFieldSchemaMap,\n collectionSlug,\n data = {},\n documentData,\n fields,\n fieldSchemaMap,\n initialBlockData,\n operation,\n permissions,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n schemaPath,\n select,\n selectMode,\n skipValidation,\n}: Args): Promise<FormState> => {\n if (!clientFieldSchemaMap && renderFieldFn) {\n console.warn(\n 'clientFieldSchemaMap is not passed to fieldSchemasToFormState - this will reduce performance',\n )\n }\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 req,\n select,\n selectMode,\n siblingData: dataWithDefaultValues,\n user: req.user,\n })\n\n let fullData = dataWithDefaultValues\n\n if (documentData) {\n // By the time this function is used to get form state for nested forms, their default values should have already been calculated\n // => no need to run calculateDefaultValues here\n fullData = documentData\n }\n\n await iterateFields({\n id,\n addErrorPathToParent: null,\n blockData: initialBlockData,\n clientFieldSchemaMap,\n collectionSlug,\n data: dataWithDefaultValues,\n fields,\n fieldSchemaMap,\n fullData,\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 select,\n selectMode,\n skipValidation,\n state,\n })\n\n return state\n }\n\n return {}\n}\n\nexport { iterateFields }\n"],"mappings":"AAgBA,SAASA,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AA8D9B,OAAO,MAAMC,uBAAA,GAA0B,MAAAA,CAAO;EAC5CC,EAAE;EACFC,oBAAoB;EACpBC,cAAc;EACdC,IAAA,GAAO,CAAC,CAAC;EACTC,YAAY;EACZC,MAAM;EACNC,cAAc;EACdC,gBAAgB;EAChBC,SAAS;EACTC,WAAW;EACXC,WAAW;EACXC,iBAAiB;EACjBC,eAAe;EACfC,aAAa;EACbC,GAAG;EACHC,UAAU;EACVC,MAAM;EACNC,UAAU;EACVC;AAAc,CACT;EACL,IAAI,CAACjB,oBAAA,IAAwBY,aAAA,EAAe;IAC1CM,OAAA,CAAQC,IAAI,CACV;EAEJ;EAEA,IAAIf,MAAA,IAAUA,MAAA,CAAOgB,MAAM,EAAE;IAC3B,MAAMC,KAAA,GAAoC,CAAC;IAE3C,MAAMC,qBAAA,GAAwB;MAAE,GAAGpB;IAAK;IAExC,MAAMN,sBAAA,CAAuB;MAC3BG,EAAA;MACAG,IAAA,EAAMoB,qBAAA;MACNlB,MAAA;MACAmB,MAAA,EAAQV,GAAA,CAAIU,MAAM;MAClBV,GAAA;MACAE,MAAA;MACAC,UAAA;MACAQ,WAAA,EAAaF,qBAAA;MACbG,IAAA,EAAMZ,GAAA,CAAIY;IACZ;IAEA,IAAIC,QAAA,GAAWJ,qBAAA;IAEf,IAAInB,YAAA,EAAc;MAChB;MACA;MACAuB,QAAA,GAAWvB,YAAA;IACb;IAEA,MAAMN,aAAA,CAAc;MAClBE,EAAA;MACA4B,oBAAA,EAAsB;MACtBC,SAAA,EAAWtB,gBAAA;MACXN,oBAAA;MACAC,cAAA;MACAC,IAAA,EAAMoB,qBAAA;MACNlB,MAAA;MACAC,cAAA;MACAqB,QAAA;MACAnB,SAAA;MACAsB,eAAA,EAAiB;MACjBC,qBAAA,EAAuB;MACvBC,UAAA,EAAY;MACZC,gBAAA,EAAkBlB,UAAA;MAClBN,WAAA;MACAC,WAAA;MACAC,iBAAA;MACAC,eAAA;MACAC,aAAA;MACAC,GAAA;MACAE,MAAA;MACAC,UAAA;MACAC,cAAA;MACAI;IACF;IAEA,OAAOA,KAAA;EACT;EAEA,OAAO,CAAC;AACV;AAEA,SAASxB,aAAa","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ClientFieldSchemaMap, Data, DocumentPreferences, Field as FieldSchema, FieldSchemaMap, FormState, FormStateWithoutComponents, PayloadRequest, SanitizedFieldsPermissions } from 'payload';
1
+ import type { ClientFieldSchemaMap, Data, DocumentPreferences, Field as FieldSchema, FieldSchemaMap, FormState, FormStateWithoutComponents, PayloadRequest, SanitizedFieldsPermissions, SelectMode, SelectType } from 'payload';
2
2
  import type { AddFieldStatePromiseArgs } from './addFieldStatePromise.js';
3
3
  import type { RenderFieldMethod } from './types.js';
4
4
  type Args = {
@@ -45,6 +45,8 @@ type Args = {
45
45
  renderAllFields: boolean;
46
46
  renderFieldFn: RenderFieldMethod;
47
47
  req: PayloadRequest;
48
+ select?: SelectType;
49
+ selectMode?: SelectMode;
48
50
  /**
49
51
  * Whether to skip checking the field's condition. @default false
50
52
  */
@@ -58,6 +60,6 @@ type Args = {
58
60
  /**
59
61
  * Flattens the fields schema and fields data
60
62
  */
61
- export declare const iterateFields: ({ id, addErrorPathToParent: addErrorPathToParentArg, anyParentLocalized, blockData, clientFieldSchemaMap, collectionSlug, data, fields, fieldSchemaMap, filter, forceFullValue, fullData, includeSchema, omitParents, operation, parentIndexPath, parentPassesCondition, parentPath, parentSchemaPath, permissions, preferences, previousFormState, renderAllFields, renderFieldFn: renderFieldFn, req, skipConditionChecks, skipValidation, state, }: Args) => Promise<void>;
63
+ export declare const iterateFields: ({ id, addErrorPathToParent: addErrorPathToParentArg, anyParentLocalized, blockData, clientFieldSchemaMap, collectionSlug, data, fields, fieldSchemaMap, filter, forceFullValue, fullData, includeSchema, omitParents, operation, parentIndexPath, parentPassesCondition, parentPath, parentSchemaPath, permissions, preferences, previousFormState, renderAllFields, renderFieldFn: renderFieldFn, req, select, selectMode, skipConditionChecks, skipValidation, state, }: Args) => Promise<void>;
62
64
  export {};
63
65
  //# sourceMappingURL=iterateFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"iterateFields.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/iterateFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,IAAI,EACJ,mBAAmB,EACnB,KAAK,IAAI,WAAW,EACpB,cAAc,EACd,SAAS,EACT,0BAA0B,EAC1B,cAAc,EACd,0BAA0B,EAC3B,MAAM,SAAS,CAAA;AAIhB,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,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,SAAS,EAAE,IAAI,GAAG,SAAS,CAAA;IAC3B,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,cAAc,EAAE,cAAc,CAAA;IAC9B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,OAAO,CAAA;IACpD;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,IAAI,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,eAAe,EAAE,MAAM,CAAA;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,0BAA0B,CAAA;IACvC,WAAW,CAAC,EAAE,mBAAmB,CAAA;IACjC,iBAAiB,EAAE,SAAS,CAAA;IAC5B,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,EAAE,iBAAiB,CAAA;IAChC,GAAG,EAAE,cAAc,CAAA;IACnB;;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,0bA6BvB,IAAI,KAAG,OAAO,CAAC,IAAI,CA8ErB,CAAA"}
1
+ {"version":3,"file":"iterateFields.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/iterateFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,IAAI,EACJ,mBAAmB,EACnB,KAAK,IAAI,WAAW,EACpB,cAAc,EACd,SAAS,EACT,0BAA0B,EAC1B,cAAc,EACd,0BAA0B,EAC1B,UAAU,EACV,UAAU,EACX,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACzE,OAAO,KAAK,EAAE,iBAAiB,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AO,CAAA;IACxB,KAAK,CAAC,EAAE,0BAA0B,CAAA;CACnC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,8cA+BvB,IAAI,KAAG,OAAO,CAAC,IAAI,CA6FrB,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { stripUnselectedFields } from 'payload';
1
2
  import { getFieldPaths } from 'payload/shared';
2
3
  import { addFieldStatePromise } from './addFieldStatePromise.js';
3
4
  /**
@@ -29,6 +30,8 @@ export const iterateFields = async ({
29
30
  renderAllFields,
30
31
  renderFieldFn: renderFieldFn,
31
32
  req,
33
+ select,
34
+ selectMode,
32
35
  skipConditionChecks = false,
33
36
  skipValidation = false,
34
37
  state = {}
@@ -47,6 +50,17 @@ export const iterateFields = async ({
47
50
  parentPath,
48
51
  parentSchemaPath
49
52
  });
53
+ if (path !== 'id') {
54
+ const shouldContinue = stripUnselectedFields({
55
+ field,
56
+ select,
57
+ selectMode,
58
+ siblingDoc: data
59
+ });
60
+ if (!shouldContinue) {
61
+ return;
62
+ }
63
+ }
50
64
  const pathSegments = path ? path.split('.') : [];
51
65
  if (!skipConditionChecks) {
52
66
  try {
@@ -93,6 +107,8 @@ export const iterateFields = async ({
93
107
  renderFieldFn,
94
108
  req,
95
109
  schemaPath,
110
+ select,
111
+ selectMode,
96
112
  skipConditionChecks,
97
113
  skipValidation,
98
114
  state
@@ -1 +1 @@
1
- {"version":3,"file":"iterateFields.js","names":["getFieldPaths","addFieldStatePromise","iterateFields","id","addErrorPathToParent","addErrorPathToParentArg","anyParentLocalized","blockData","clientFieldSchemaMap","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","indexPath","path","schemaPath","index","pathSegments","split","Boolean","admin","condition","user","err","payload","logger","error","msg","push","parentPermissions","Promise","all"],"sources":["../../../src/forms/fieldSchemasToFormState/iterateFields.ts"],"sourcesContent":["import type {\n ClientFieldSchemaMap,\n Data,\n DocumentPreferences,\n Field as FieldSchema,\n FieldSchemaMap,\n FormState,\n FormStateWithoutComponents,\n PayloadRequest,\n SanitizedFieldsPermissions,\n} from 'payload'\n\nimport { getFieldPaths } from 'payload/shared'\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 /**\n * Data of the nearest parent block, or undefined\n */\n blockData: Data | undefined\n clientFieldSchemaMap?: ClientFieldSchemaMap\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 blockData,\n clientFieldSchemaMap,\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\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath: 'name' in field ? '' : parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const pathSegments = path ? path.split('.') : []\n\n if (!skipConditionChecks) {\n try {\n passesCondition = Boolean(\n (field?.admin?.condition\n ? Boolean(\n field.admin.condition(fullData || {}, data || {}, {\n blockData,\n path: pathSegments,\n user: req.user,\n }),\n )\n : true) && parentPassesCondition,\n )\n } catch (err) {\n passesCondition = false\n\n req.payload.logger.error({\n err,\n msg: `Error evaluating field condition at path: ${path}`,\n })\n }\n }\n\n promises.push(\n addFieldStatePromise({\n id,\n addErrorPathToParent: addErrorPathToParentArg,\n anyParentLocalized,\n blockData,\n clientFieldSchemaMap,\n collectionSlug,\n data,\n field,\n fieldIndex,\n fieldSchemaMap,\n filter,\n forceFullValue,\n fullData,\n includeSchema,\n indexPath,\n omitParents,\n operation,\n parentIndexPath,\n parentPath,\n parentPermissions: permissions,\n parentSchemaPath,\n passesCondition,\n path,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n schemaPath,\n skipConditionChecks,\n skipValidation,\n state,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"mappings":"AAYA,SAASA,aAAa,QAAQ;AAK9B,SAASC,oBAAoB,QAAQ;AAyDrC;;;AAGA,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAO;EAClCC,EAAE;EACFC,oBAAA,EAAsBC,uBAAuB;EAC7CC,kBAAA,GAAqB,KAAK;EAC1BC,SAAS;E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AO,CAACC,MAAM,CAACC,KAAK,CAAC;UACvBH,GAAA;UACAI,GAAA,EAAK,6CAA6Cb,IAAA;QACpD;MACF;IACF;IAEAN,QAAA,CAASoB,IAAI,CACXnD,oBAAA,CAAqB;MACnBE,EAAA;MACAC,oBAAA,EAAsBC,uBAAA;MACtBC,kBAAA;MACAC,SAAA;MACAC,oBAAA;MACAC,cAAA;MACAC,IAAA;MACAwB,KAAA;MACAC,UAAA;MACAvB,cAAA;MACAC,MAAA;MACAC,cAAA;MACAC,QAAA;MACAC,aAAA;MACAqB,SAAA;MACApB,WAAA;MACAC,SAAA;MACAC,eAAA;MACAE,UAAA;MACAgC,iBAAA,EAAmB9B,WAAA;MACnBD,gBAAA;MACAc,eAAA;MACAE,IAAA;MACAd,WAAA;MACAC,iBAAA;MACAC,eAAA;MACAC,aAAA;MACAC,GAAA;MACAW,UAAA;MACAV,mBAAA;MACAC,cAAA;MACAC;IACF;EAEJ;EAEA,MAAMuB,OAAA,CAAQC,GAAG,CAACvB,QAAA;AACpB","ignoreList":[]}
1
+ {"version":3,"file":"iterateFields.js","names":["stripUnselectedFields","getFieldPaths","addFieldStatePromise","iterateFields","id","addErrorPathToParent","addErrorPathToParentArg","anyParentLocalized","blockData","clientFieldSchemaMap","collectionSlug","data","fields","fieldSchemaMap","filter","forceFullValue","fullData","includeSchema","omitParents","operation","parentIndexPath","parentPassesCondition","parentPath","parentSchemaPath","permissions","preferences","previousFormState","renderAllFields","renderFieldFn","req","select","selectMode","skipConditionChecks","skipValidation","state","promises","forEach","field","fieldIndex","passesCondition","indexPath","path","schemaPath","index","shouldContinue","siblingDoc","pathSegments","split","Boolean","admin","condition","user","err","payload","logger","error","msg","push","parentPermissions","Promise","all"],"sources":["../../../src/forms/fieldSchemasToFormState/iterateFields.ts"],"sourcesContent":["import type {\n ClientFieldSchemaMap,\n Data,\n DocumentPreferences,\n Field as FieldSchema,\n FieldSchemaMap,\n FormState,\n FormStateWithoutComponents,\n PayloadRequest,\n SanitizedFieldsPermissions,\n SelectMode,\n SelectType,\n} from 'payload'\n\nimport { stripUnselectedFields } from 'payload'\nimport { getFieldPaths } from 'payload/shared'\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 /**\n * Data of the nearest parent block, or undefined\n */\n blockData: Data | undefined\n clientFieldSchemaMap?: ClientFieldSchemaMap\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 select?: SelectType\n selectMode?: SelectMode\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 blockData,\n clientFieldSchemaMap,\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 select,\n selectMode,\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\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath: 'name' in field ? '' : parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n if (path !== 'id') {\n const shouldContinue = stripUnselectedFields({\n field,\n select,\n selectMode,\n siblingDoc: data,\n })\n\n if (!shouldContinue) {\n return\n }\n }\n\n const pathSegments = path ? path.split('.') : []\n\n if (!skipConditionChecks) {\n try {\n passesCondition = Boolean(\n (field?.admin?.condition\n ? Boolean(\n field.admin.condition(fullData || {}, data || {}, {\n blockData,\n path: pathSegments,\n user: req.user,\n }),\n )\n : true) && parentPassesCondition,\n )\n } catch (err) {\n passesCondition = false\n\n req.payload.logger.error({\n err,\n msg: `Error evaluating field condition at path: ${path}`,\n })\n }\n }\n\n promises.push(\n addFieldStatePromise({\n id,\n addErrorPathToParent: addErrorPathToParentArg,\n anyParentLocalized,\n blockData,\n clientFieldSchemaMap,\n collectionSlug,\n data,\n field,\n fieldIndex,\n fieldSchemaMap,\n filter,\n forceFullValue,\n fullData,\n includeSchema,\n indexPath,\n omitParents,\n operation,\n parentIndexPath,\n parentPath,\n parentPermissions: permissions,\n parentSchemaPath,\n passesCondition,\n path,\n preferences,\n previousFormState,\n renderAllFields,\n renderFieldFn,\n req,\n schemaPath,\n select,\n selectMode,\n skipConditionChecks,\n skipValidation,\n state,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"mappings":"AAcA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,aAAa,QAAQ;AAK9B,SAASC,oBAAoB,QAAQ;AA2DrC;;;AAGA,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAO;EAClCC,EAAE;EACFC,oBAAA,E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AAA,CAAMY,KAAK,CAACC,SAAS,CAAClC,QAAA,IAAY,CAAC,GAAGL,IAAA,IAAQ,CAAC,GAAG;UAChDH,SAAA;UACAiC,IAAA,EAAMK,YAAA;UACNK,IAAA,EAAMtB,GAAA,CAAIsB;QACZ,MAEF,IAAG,KAAM9B,qBAAA;MAEjB,EAAE,OAAO+B,GAAA,EAAK;QACZb,eAAA,GAAkB;QAElBV,GAAA,CAAIwB,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;UACvBH,GAAA;UACAI,GAAA,EAAK,6CAA6Cf,IAAA;QACpD;MACF;IACF;IAEAN,QAAA,CAASsB,IAAI,CACXvD,oBAAA,CAAqB;MACnBE,EAAA;MACAC,oBAAA,EAAsBC,uBAAA;MACtBC,kBAAA;MACAC,SAAA;MACAC,oBAAA;MACAC,cAAA;MACAC,IAAA;MACA0B,KAAA;MACAC,UAAA;MACAzB,cAAA;MACAC,MAAA;MACAC,cAAA;MACAC,QAAA;MACAC,aAAA;MACAuB,SAAA;MACAtB,WAAA;MACAC,SAAA;MACAC,eAAA;MACAE,UAAA;MACAoC,iBAAA,EAAmBlC,WAAA;MACnBD,gBAAA;MACAgB,eAAA;MACAE,IAAA;MACAhB,WAAA;MACAC,iBAAA;MACAC,eAAA;MACAC,aAAA;MACAC,GAAA;MACAa,UAAA;MACAZ,MAAA;MACAC,UAAA;MACAC,mBAAA;MACAC,cAAA;MACAC;IACF;EAEJ;EAEA,MAAMyB,OAAA,CAAQC,GAAG,CAACzB,QAAA;AACpB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildFormState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAYnG,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,EAAE,M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B,CAAA;AAED,KAAK,yBAAyB,GAAG;IAC/B,WAAW,CAAC,EAAE,KAAK,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,CACA;IACE,OAAO,EAAE,MAAM,CAAA;CAChB,GACD,WAAW,CACd,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,GAAG,2BAA2B,CAAA;AAE1F,eAAO,MAAM,qBAAqB,SAC1B,kBAAkB,KACvB,OAAO,CAAC,oBAAoB,CAqD9B,CAAA;AAED,eAAO,MAAM,cAAc,SACnB,kBAAkB,KACvB,OAAO,CAAC,2BAA2B,CAkJrC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { formatErrors } from 'payload';
2
- import { reduceFieldsToValues } from 'payload/shared';
2
+ import { getSelectMode, reduceFieldsToValues } from 'payload/shared';
3
3
  import { fieldSchemasToFormState } from '../forms/fieldSchemasToFormState/index.js';
4
4
  import { renderField } from '../forms/fieldSchemasToFormState/renderField.js';
5
5
  import { getClientConfig } from './getClientConfig.js';
@@ -82,9 +82,11 @@ export const buildFormState = async args => {
82
82
  },
83
83
  returnLockStatus,
84
84
  schemaPath = collectionSlug || globalSlug,
85
+ select,
85
86
  skipValidation,
86
87
  updateLastEdited
87
88
  } = args;
89
+ const selectMode = select ? getSelectMode(select) : undefined;
88
90
  let data = incomingData;
89
91
  if (!collectionSlug && !globalSlug) {
90
92
  throw new Error('Either collectionSlug or globalSlug must be provided');
@@ -157,6 +159,8 @@ export const buildFormState = async args => {
157
159
  renderFieldFn: renderField,
158
160
  req,
159
161
  schemaPath,
162
+ select,
163
+ selectMode,
160
164
  skipValidation
161
165
  });
162
166
  // Maintain form state of auth / upload fields