@payloadcms/ui 3.29.0-canary.1 → 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.
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.d.ts.map +1 -1
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.js +2 -1
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js +32 -25
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js +8 -1
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/exports/client/index.js +11 -11
- package/dist/exports/client/index.js.map +4 -4
- package/dist/fields/Tabs/Tab/index.d.ts +1 -0
- package/dist/fields/Tabs/Tab/index.d.ts.map +1 -1
- package/dist/fields/Tabs/Tab/index.js +29 -25
- package/dist/fields/Tabs/Tab/index.js.map +1 -1
- package/dist/fields/Tabs/Tab/index.scss +4 -0
- package/dist/fields/Tabs/index.d.ts +1 -1
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js +285 -194
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Tabs/index.scss +8 -0
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts +3 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +45 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.d.ts +4 -2
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.js +4 -0
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.d.ts +4 -2
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.js +4 -0
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/iterateFields.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.d.ts +4 -2
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.js +41 -2
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/index.d.ts +4 -2
- package/dist/forms/fieldSchemasToFormState/index.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/index.js +6 -0
- package/dist/forms/fieldSchemasToFormState/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts +4 -2
- package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/iterateFields.js +16 -0
- package/dist/forms/fieldSchemasToFormState/iterateFields.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +5 -1
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/getDisplayedFieldValue.d.ts +13 -0
- package/dist/utilities/getDisplayedFieldValue.d.ts.map +1 -0
- package/dist/utilities/getDisplayedFieldValue.js +28 -0
- package/dist/utilities/getDisplayedFieldValue.js.map +1 -0
- package/dist/utilities/hasOptionLabelJSXElement.d.ts +3 -0
- package/dist/utilities/hasOptionLabelJSXElement.d.ts.map +1 -0
- package/dist/utilities/hasOptionLabelJSXElement.js +15 -0
- package/dist/utilities/hasOptionLabelJSXElement.js.map +1 -0
- package/package.json +4 -4
|
@@ -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\n }\n\n return {}\n}\n\nexport { iterateFields }\n"],"mappings":"
|
|
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,
|
|
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,EAAE,MA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;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":"
|
|
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,EAAsBC,uBAAuB;EAC7CC,kBAAA,GAAqB,KAAK;EAC1BC,SAAS;EACTC,oBAAoB;EACpBC,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,MAAM;EACNC,UAAU;EACVC,mBAAA,GAAsB,KAAK;EAC3BC,cAAA,GAAiB,KAAK;EACtBC,KAAA,GAAQ,CAAC;AAAC,CACL;EACL,MAAMC,QAAA,GAAW,EAAE;EAEnBvB,MAAA,CA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