@payloadcms/ui 3.0.0-beta.37 → 3.0.0-beta.38
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/DocumentFields/index.d.ts.map +1 -1
- package/dist/elements/DocumentFields/index.js +2 -0
- package/dist/elements/DocumentFields/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.scss +3 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +14 -8
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +1 -1
- package/dist/elements/ReactSelect/Input/index.d.ts +5 -0
- package/dist/elements/ReactSelect/Input/index.d.ts.map +1 -0
- package/dist/elements/ReactSelect/Input/index.js +17 -0
- package/dist/elements/ReactSelect/Input/index.js.map +1 -0
- package/dist/elements/ReactSelect/MultiValue/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/MultiValue/index.js +7 -5
- package/dist/elements/ReactSelect/MultiValue/index.js.map +1 -1
- package/dist/elements/ReactSelect/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/index.js +17 -1
- package/dist/elements/ReactSelect/index.js.map +1 -1
- package/dist/elements/RenderTitle/index.d.ts.map +1 -1
- package/dist/elements/RenderTitle/index.js +12 -7
- package/dist/elements/RenderTitle/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Relationship/index.js +1 -1
- package/dist/elements/Table/DefaultCell/fields/Relationship/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/index.js +104 -72
- package/dist/elements/WhereBuilder/Condition/Relationship/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +3 -3
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/index.js +49 -49
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +6 -6
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +6 -6
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Checkbox/index.d.ts.map +1 -1
- package/dist/fields/Checkbox/index.js +6 -6
- package/dist/fields/Checkbox/index.js.map +1 -1
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +5 -5
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +5 -2
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/DateTime/index.js +5 -5
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Email/index.d.ts.map +1 -1
- package/dist/fields/Email/index.js +4 -4
- package/dist/fields/Email/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +5 -3
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +7 -7
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Number/index.d.ts.map +1 -1
- package/dist/fields/Number/index.js +7 -7
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/index.d.ts.map +1 -1
- package/dist/fields/Password/index.js +6 -4
- package/dist/fields/Password/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js +5 -5
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/findOptionsByValue.js +1 -1
- package/dist/fields/Relationship/findOptionsByValue.js.map +1 -1
- package/dist/fields/Relationship/index.d.ts.map +1 -1
- package/dist/fields/Relationship/index.js +2 -4
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Select/index.d.ts.map +1 -1
- package/dist/fields/Select/index.js +5 -5
- package/dist/fields/Select/index.js.map +1 -1
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Text/index.d.ts.map +1 -1
- package/dist/fields/Text/index.js +5 -5
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Textarea/index.d.ts.map +1 -1
- package/dist/fields/Textarea/index.js +3 -3
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Upload/index.d.ts.map +1 -1
- package/dist/fields/Upload/index.js +3 -3
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/forms/FieldPropsProvider/index.d.ts +1 -0
- package/dist/forms/FieldPropsProvider/index.d.ts.map +1 -1
- package/dist/forms/FieldPropsProvider/index.js.map +1 -1
- package/dist/forms/Form/context.d.ts +3 -1
- package/dist/forms/Form/context.d.ts.map +1 -1
- package/dist/forms/Form/context.js +3 -1
- package/dist/forms/Form/context.js.map +1 -1
- package/dist/forms/Form/getSiblingData.d.ts.map +1 -1
- package/dist/forms/Form/getSiblingData.js +1 -0
- package/dist/forms/Form/getSiblingData.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +28 -11
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/initContextState.d.ts.map +1 -1
- package/dist/forms/Form/initContextState.js +1 -0
- package/dist/forms/Form/initContextState.js.map +1 -1
- package/dist/forms/Form/types.d.ts +2 -0
- package/dist/forms/Form/types.d.ts.map +1 -1
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/forms/RenderFields/index.d.ts.map +1 -1
- package/dist/forms/RenderFields/index.js +6 -2
- package/dist/forms/RenderFields/index.js.map +1 -1
- package/dist/forms/RenderFields/types.d.ts +8 -1
- package/dist/forms/RenderFields/types.d.ts.map +1 -1
- package/dist/forms/RenderFields/types.js.map +1 -1
- package/dist/forms/Submit/index.d.ts.map +1 -1
- package/dist/forms/Submit/index.js +3 -2
- package/dist/forms/Submit/index.js.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.d.ts +5 -3
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.js +4 -3
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.js.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.d.ts +5 -3
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.js +4 -3
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.js.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.d.ts +5 -3
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.js +21 -15
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.js.map +1 -1
- package/dist/forms/buildStateFromSchema/index.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/index.js +3 -2
- package/dist/forms/buildStateFromSchema/index.js.map +1 -1
- package/dist/forms/useField/index.d.ts.map +1 -1
- package/dist/forms/useField/index.js +5 -2
- package/dist/forms/useField/index.js.map +1 -1
- package/dist/forms/useField/types.d.ts +1 -0
- package/dist/forms/useField/types.d.ts.map +1 -1
- package/dist/forms/useField/types.js.map +1 -1
- package/dist/icons/Plus/index.d.ts.map +1 -1
- package/dist/icons/Plus/index.js +1 -0
- package/dist/icons/Plus/index.js.map +1 -1
- package/dist/icons/Plus/index.scss +0 -3
- package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.js +1 -0
- package/dist/providers/ComponentMap/buildComponentMap/fields.js.map +1 -1
- package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/index.js +67 -53
- package/dist/providers/DocumentInfo/index.js.map +1 -1
- package/dist/providers/DocumentInfo/types.d.ts +4 -0
- package/dist/providers/DocumentInfo/types.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/types.js.map +1 -1
- package/dist/providers/Root/index.d.ts +1 -2
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/Translation/index.d.ts +1 -5
- package/dist/providers/Translation/index.d.ts.map +1 -1
- package/dist/providers/Translation/index.js.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/index.d.ts +8 -0
- package/dist/utilities/buildFieldSchemaMap/index.d.ts.map +1 -0
- package/dist/utilities/buildFieldSchemaMap/index.js +29 -0
- package/dist/utilities/buildFieldSchemaMap/index.js.map +1 -0
- package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts +14 -0
- package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts.map +1 -0
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js +75 -0
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -0
- package/dist/utilities/buildFieldSchemaMap/types.d.ts +3 -0
- package/dist/utilities/buildFieldSchemaMap/types.d.ts.map +1 -0
- package/dist/utilities/buildFieldSchemaMap/types.js +3 -0
- package/dist/utilities/buildFieldSchemaMap/types.js.map +1 -0
- package/dist/utilities/buildFormState.d.ts +7 -0
- package/dist/utilities/buildFormState.d.ts.map +1 -0
- package/dist/utilities/buildFormState.js +162 -0
- package/dist/utilities/buildFormState.js.map +1 -0
- package/dist/utilities/getFormState.d.ts +1 -0
- package/dist/utilities/getFormState.d.ts.map +1 -1
- package/dist/utilities/getFormState.js +5 -2
- package/dist/utilities/getFormState.js.map +1 -1
- package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValues.js +1 -0
- package/dist/utilities/reduceFieldsToValues.js.map +1 -1
- package/package.json +5 -5
|
@@ -11,7 +11,7 @@ export const RenderFields = (props)=>{
|
|
|
11
11
|
const [hasRendered, setHasRendered] = React.useState(Boolean(forceRender));
|
|
12
12
|
const [intersectionRef, entry] = useIntersect({
|
|
13
13
|
rootMargin: '1000px'
|
|
14
|
-
}, forceRender);
|
|
14
|
+
}, Boolean(forceRender));
|
|
15
15
|
const isIntersecting = Boolean(entry?.isIntersecting);
|
|
16
16
|
const isAboveViewport = entry?.boundingClientRect?.top < 0;
|
|
17
17
|
const shouldRender = forceRender || isIntersecting || isAboveViewport;
|
|
@@ -41,12 +41,16 @@ export const RenderFields = (props)=>{
|
|
|
41
41
|
ref: intersectionRef,
|
|
42
42
|
children: hasRendered && fieldMap?.map((f, fieldIndex)=>{
|
|
43
43
|
const { type, CustomField, custom, disabled, fieldComponentProps, fieldComponentProps: { readOnly }, isHidden } = f;
|
|
44
|
+
const forceRenderChildren = typeof forceRender === 'number' && fieldIndex <= forceRender || true;
|
|
44
45
|
const name = 'name' in f ? f.name : undefined;
|
|
45
46
|
return /*#__PURE__*/ _jsx(RenderField, {
|
|
46
47
|
CustomField: CustomField,
|
|
47
48
|
custom: custom,
|
|
48
49
|
disabled: disabled,
|
|
49
|
-
fieldComponentProps:
|
|
50
|
+
fieldComponentProps: {
|
|
51
|
+
...fieldComponentProps,
|
|
52
|
+
forceRender: forceRenderChildren
|
|
53
|
+
},
|
|
50
54
|
indexPath: indexPath !== undefined ? `${indexPath}.${fieldIndex}` : `${fieldIndex}`,
|
|
51
55
|
isHidden: isHidden,
|
|
52
56
|
name: name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RenderFields/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { Props } from './types.js'\n\nimport { useIntersect } from '../../hooks/useIntersect.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { RenderField } from './RenderField.js'\nimport './index.scss'\n\nconst baseClass = 'render-fields'\n\nexport { Props }\n\nexport const RenderFields: React.FC<Props> = (props) => {\n const { className, fieldMap, forceRender, indexPath, margins, path, permissions, schemaPath } =\n props\n\n const { i18n } = useTranslation()\n const [hasRendered, setHasRendered] = React.useState(Boolean(forceRender))\n const [intersectionRef, entry] = useIntersect(\n {\n rootMargin: '1000px',\n },\n forceRender,\n )\n const isIntersecting = Boolean(entry?.isIntersecting)\n const isAboveViewport = entry?.boundingClientRect?.top < 0\n const shouldRender = forceRender || isIntersecting || isAboveViewport\n\n React.useEffect(() => {\n if (shouldRender && !hasRendered) {\n setHasRendered(true)\n }\n }, [shouldRender, hasRendered])\n\n if (!fieldMap || (Array.isArray(fieldMap) && fieldMap.length === 0)) {\n return null\n }\n\n if (!i18n) {\n console.error('Need to implement i18n when calling RenderFields') // eslint-disable-line no-console\n }\n\n if (fieldMap) {\n return (\n <div\n className={[\n baseClass,\n className,\n margins && `${baseClass}--margins-${margins}`,\n margins === false && `${baseClass}--margins-none`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={intersectionRef}\n >\n {hasRendered &&\n fieldMap?.map((f, fieldIndex) => {\n const {\n type,\n CustomField,\n custom,\n disabled,\n fieldComponentProps,\n fieldComponentProps: { readOnly },\n isHidden,\n } = f\n\n const name = 'name' in f ? f.name : undefined\n\n return (\n <RenderField\n CustomField={CustomField}\n custom={custom}\n disabled={disabled}\n fieldComponentProps={fieldComponentProps}\n indexPath={indexPath !== undefined ? `${indexPath}.${fieldIndex}` : `${fieldIndex}`}\n isHidden={isHidden}\n key={fieldIndex}\n name={name}\n path={path}\n permissions={permissions?.[name]}\n readOnly={readOnly}\n schemaPath={schemaPath}\n siblingPermissions={permissions}\n type={type}\n />\n )\n })}\n </div>\n )\n }\n\n return null\n}\n"],"names":["React","useIntersect","useTranslation","RenderField","baseClass","RenderFields","props","className","fieldMap","forceRender","indexPath","margins","path","permissions","schemaPath","i18n","hasRendered","setHasRendered","useState","Boolean","intersectionRef","entry","rootMargin","isIntersecting","isAboveViewport","boundingClientRect","top","shouldRender","useEffect","Array","isArray","length","console","error","div","filter","join","ref","map","f","fieldIndex","type","CustomField","custom","disabled","fieldComponentProps","readOnly","isHidden","name","undefined","siblingPermissions"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RenderFields/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { Props } from './types.js'\n\nimport { useIntersect } from '../../hooks/useIntersect.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { RenderField } from './RenderField.js'\nimport './index.scss'\n\nconst baseClass = 'render-fields'\n\nexport { Props }\n\nexport const RenderFields: React.FC<Props> = (props) => {\n const { className, fieldMap, forceRender, indexPath, margins, path, permissions, schemaPath } =\n props\n\n const { i18n } = useTranslation()\n const [hasRendered, setHasRendered] = React.useState(Boolean(forceRender))\n const [intersectionRef, entry] = useIntersect(\n {\n rootMargin: '1000px',\n },\n Boolean(forceRender),\n )\n\n const isIntersecting = Boolean(entry?.isIntersecting)\n const isAboveViewport = entry?.boundingClientRect?.top < 0\n const shouldRender = forceRender || isIntersecting || isAboveViewport\n\n React.useEffect(() => {\n if (shouldRender && !hasRendered) {\n setHasRendered(true)\n }\n }, [shouldRender, hasRendered])\n\n if (!fieldMap || (Array.isArray(fieldMap) && fieldMap.length === 0)) {\n return null\n }\n\n if (!i18n) {\n console.error('Need to implement i18n when calling RenderFields') // eslint-disable-line no-console\n }\n\n if (fieldMap) {\n return (\n <div\n className={[\n baseClass,\n className,\n margins && `${baseClass}--margins-${margins}`,\n margins === false && `${baseClass}--margins-none`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={intersectionRef}\n >\n {hasRendered &&\n fieldMap?.map((f, fieldIndex) => {\n const {\n type,\n CustomField,\n custom,\n disabled,\n fieldComponentProps,\n fieldComponentProps: { readOnly },\n isHidden,\n } = f\n\n const forceRenderChildren =\n (typeof forceRender === 'number' && fieldIndex <= forceRender) || true\n\n const name = 'name' in f ? f.name : undefined\n\n return (\n <RenderField\n CustomField={CustomField}\n custom={custom}\n disabled={disabled}\n fieldComponentProps={{ ...fieldComponentProps, forceRender: forceRenderChildren }}\n indexPath={indexPath !== undefined ? `${indexPath}.${fieldIndex}` : `${fieldIndex}`}\n isHidden={isHidden}\n key={fieldIndex}\n name={name}\n path={path}\n permissions={permissions?.[name]}\n readOnly={readOnly}\n schemaPath={schemaPath}\n siblingPermissions={permissions}\n type={type}\n />\n )\n })}\n </div>\n )\n }\n\n return null\n}\n"],"names":["React","useIntersect","useTranslation","RenderField","baseClass","RenderFields","props","className","fieldMap","forceRender","indexPath","margins","path","permissions","schemaPath","i18n","hasRendered","setHasRendered","useState","Boolean","intersectionRef","entry","rootMargin","isIntersecting","isAboveViewport","boundingClientRect","top","shouldRender","useEffect","Array","isArray","length","console","error","div","filter","join","ref","map","f","fieldIndex","type","CustomField","custom","disabled","fieldComponentProps","readOnly","isHidden","forceRenderChildren","name","undefined","siblingPermissions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AACA,OAAOA,WAAW,QAAO;AAIzB,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,WAAW,QAAQ,mBAAkB;AAG9C,MAAMC,YAAY;AAIlB,OAAO,MAAMC,eAAgC,CAACC;IAC5C,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAEC,UAAU,EAAE,GAC3FR;IAEF,MAAM,EAAES,IAAI,EAAE,GAAGb;IACjB,MAAM,CAACc,aAAaC,eAAe,GAAGjB,MAAMkB,QAAQ,CAACC,QAAQV;IAC7D,MAAM,CAACW,iBAAiBC,MAAM,GAAGpB,aAC/B;QACEqB,YAAY;IACd,GACAH,QAAQV;IAGV,MAAMc,iBAAiBJ,QAAQE,OAAOE;IACtC,MAAMC,kBAAkBH,O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VhC,YAAYA;oBACZqC,oBAAoBtC;oBACpB4B,MAAMA;mBAPDD;YAUX;;IAGR;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -3,7 +3,14 @@ import type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/ty
|
|
|
3
3
|
export type Props = {
|
|
4
4
|
className?: string;
|
|
5
5
|
fieldMap: FieldMap;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Controls the rendering behavior of the fields, i.e. defers rendering until they intersect with the viewport using the Intersection Observer API.
|
|
8
|
+
*
|
|
9
|
+
* If true, the fields will be rendered immediately, rather than waiting for them to intersect with the viewport.
|
|
10
|
+
*
|
|
11
|
+
* If a number is provided, will immediately render fields _up to that index_.
|
|
12
|
+
*/
|
|
13
|
+
forceRender?: boolean | number;
|
|
7
14
|
indexPath?: string;
|
|
8
15
|
margins?: 'small' | false;
|
|
9
16
|
operation?: Operation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AAEvF,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AAEvF,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAA;IAClB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IACzB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE;QACZ,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;KACtC,CAAA;IACD,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RenderFields/types.ts"],"sourcesContent":["import type { FieldPermissions, Operation } from 'payload/types'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nexport type Props = {\n className?: string\n fieldMap: FieldMap\n forceRender?: boolean\n indexPath?: string\n margins?: 'small' | false\n operation?: Operation\n path: string\n permissions?: {\n [fieldName: string]: FieldPermissions\n }\n readOnly: boolean\n schemaPath: string\n}\n"],"names":[],"rangeMappings":"","mappings":"AAIA,
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RenderFields/types.ts"],"sourcesContent":["import type { FieldPermissions, Operation } from 'payload/types'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nexport type Props = {\n className?: string\n fieldMap: FieldMap\n /**\n * Controls the rendering behavior of the fields, i.e. defers rendering until they intersect with the viewport using the Intersection Observer API.\n *\n * If true, the fields will be rendered immediately, rather than waiting for them to intersect with the viewport.\n *\n * If a number is provided, will immediately render fields _up to that index_.\n */\n forceRender?: boolean | number\n indexPath?: string\n margins?: 'small' | false\n operation?: Operation\n path: string\n permissions?: {\n [fieldName: string]: FieldPermissions\n }\n readOnly: boolean\n schemaPath: string\n}\n"],"names":[],"rangeMappings":"","mappings":"AAIA,WAoBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/Submit/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAA;AAI3D,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/Submit/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAA;AAI3D,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,UAAU,iFAerB,CAAA"}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
4
|
import { Button } from '../../elements/Button/index.js';
|
|
5
|
-
import { useForm, useFormProcessing } from '../Form/context.js';
|
|
5
|
+
import { useForm, useFormInitializing, useFormProcessing } from '../Form/context.js';
|
|
6
6
|
const baseClass = 'form-submit';
|
|
7
7
|
export const FormSubmit = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
8
8
|
const { type = 'submit', buttonId: id, children, disabled: disabledFromProps } = props;
|
|
9
9
|
const processing = useFormProcessing();
|
|
10
|
+
const initializing = useFormInitializing();
|
|
10
11
|
const { disabled } = useForm();
|
|
11
|
-
const canSave = !(disabledFromProps || processing || disabled);
|
|
12
|
+
const canSave = !(disabledFromProps || initializing || processing || disabled);
|
|
12
13
|
return /*#__PURE__*/ _jsx("div", {
|
|
13
14
|
className: baseClass,
|
|
14
15
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/Submit/index.tsx"],"sourcesContent":["'use client'\nimport React, { forwardRef } from 'react'\n\nimport type { Props } from '../../elements/Button/types.js'\n\nimport { Button } from '../../elements/Button/index.js'\nimport { useForm, useFormProcessing } from '../Form/context.js'\nimport './index.scss'\n\nconst baseClass = 'form-submit'\n\nexport const FormSubmit = forwardRef<HTMLButtonElement, Props>((props, ref) => {\n const { type = 'submit', buttonId: id, children, disabled: disabledFromProps } = props\n const processing = useFormProcessing()\n const { disabled } = useForm()\n\n const canSave = !(disabledFromProps || processing || disabled)\n\n return (\n <div className={baseClass}>\n <Button ref={ref} {...props} disabled={canSave ? undefined : true} id={id} type={type}>\n {children}\n </Button>\n </div>\n )\n})\n"],"names":["React","forwardRef","Button","useForm","useFormProcessing","baseClass","FormSubmit","props","ref","type","buttonId","id","children","disabled","disabledFromProps","processing","canSave","div","className","undefined"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/Submit/index.tsx"],"sourcesContent":["'use client'\nimport React, { forwardRef } from 'react'\n\nimport type { Props } from '../../elements/Button/types.js'\n\nimport { Button } from '../../elements/Button/index.js'\nimport { useForm, useFormInitializing, useFormProcessing } from '../Form/context.js'\nimport './index.scss'\n\nconst baseClass = 'form-submit'\n\nexport const FormSubmit = forwardRef<HTMLButtonElement, Props>((props, ref) => {\n const { type = 'submit', buttonId: id, children, disabled: disabledFromProps } = props\n const processing = useFormProcessing()\n const initializing = useFormInitializing()\n const { disabled } = useForm()\n\n const canSave = !(disabledFromProps || initializing || processing || disabled)\n\n return (\n <div className={baseClass}>\n <Button ref={ref} {...props} disabled={canSave ? undefined : true} id={id} type={type}>\n {children}\n </Button>\n </div>\n )\n})\n"],"names":["React","forwardRef","Button","useForm","useFormInitializing","useFormProcessing","baseClass","FormSubmit","props","ref","type","buttonId","id","children","disabled","disabledFromProps","processing","initializing","canSave","div","className","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AACA,OAAOA,SAASC,UAAU,QAAQ,QAAO;AAIzC,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,OAAO,EAAEC,mBAAmB,EAAEC,iBAAiB,QAAQ,qBAAoB;AAGpF,MAAMC,YAAY;AAElB,OAAO,MAAMC,2BAAaN,WAAqC,CAACO,OAAOC;IACrE,MAAM,EAAEC,OAAO,QAAQ,EAAEC,UAAUC,EAAE,EAAEC,QAAQ,EAAEC,UAAUC,iBAAiB,EAAE,GAAGP;IACjF,MAAMQ,aAAaX;IACnB,MAAMY,eAAeb;IACrB,MAAM,EAAEU,QAAQ,EAAE,GAAGX;IAErB,MAAMe,UAAU,CAAEH,CAAAA,qBAAqBE,gBAAgBD,cAAcF,QAAO;IAE5E,qBACE,KAACK;QAAIC,WAAWd;kBACd,cAAA,KAACJ;YAAOO,KAAKA;YAAM,GAAGD,KAAK;YAAEM,UAAUI,UAAUG,YAAY;YAAMT,IAAIA;YAAIF,MAAMA;sBAC9EG;;;AAIT,GAAE"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { User } from 'payload/auth';
|
|
2
|
+
import type { Data, Field as FieldSchema } from 'payload/types';
|
|
2
3
|
type Args = {
|
|
3
4
|
data: Data;
|
|
4
5
|
fields: FieldSchema[];
|
|
5
6
|
id?: number | string;
|
|
6
|
-
|
|
7
|
+
locale: string | undefined;
|
|
7
8
|
siblingData: Data;
|
|
9
|
+
user: User;
|
|
8
10
|
};
|
|
9
|
-
export declare const calculateDefaultValues: ({ id, data, fields,
|
|
11
|
+
export declare const calculateDefaultValues: ({ id, data, fields, locale, user, }: Args) => Promise<Data>;
|
|
10
12
|
export {};
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AAI/D,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,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,sBAAsB,wCAMhC,IAAI,KAAG,QAAQ,IAAI,CAWrB,CAAA"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { iterateFields } from './iterateFields.js';
|
|
2
|
-
export const calculateDefaultValues = async ({ id, data, fields,
|
|
2
|
+
export const calculateDefaultValues = async ({ id, data, fields, locale, user })=>{
|
|
3
3
|
await iterateFields({
|
|
4
4
|
id,
|
|
5
5
|
data,
|
|
6
6
|
fields,
|
|
7
|
-
|
|
8
|
-
siblingData: data
|
|
7
|
+
locale,
|
|
8
|
+
siblingData: data,
|
|
9
|
+
user
|
|
9
10
|
});
|
|
10
11
|
return data;
|
|
11
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/index.ts"],"sourcesContent":["import type { Data, Field as FieldSchema
|
|
1
|
+
{"version":3,"sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/index.ts"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { Data, Field as FieldSchema } from 'payload/types'\n\nimport { iterateFields } from './iterateFields.js'\n\ntype Args = {\n data: Data\n fields: FieldSchema[]\n id?: number | string\n locale: string | undefined\n siblingData: Data\n user: User\n}\n\nexport const calculateDefaultValues = async ({\n id,\n data,\n fields,\n locale,\n user,\n}: Args): Promise<Data> => {\n await iterateFields({\n id,\n data,\n fields,\n locale,\n siblingData: data,\n user,\n })\n\n return data\n}\n"],"names":["iterateFields","calculateDefaultValues","id","data","fields","locale","user","siblingData"],"rangeMappings":";;;;;;;;;;;","mappings":"AAGA,SAASA,aAAa,QAAQ,qBAAoB;AAWlD,OAAO,MAAMC,yBAAyB,OAAO,EAC3CC,EAAE,EACFC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,IAAI,EACC;IACL,MAAMN,cAAc;QAClBE;QACAC;QACAC;QACAC;QACAE,aAAaJ;QACbG;IACF;IAEA,OAAOH;AACT,EAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { User } from 'payload/auth';
|
|
2
|
+
import type { Data, Field, TabAsField } from 'payload/types';
|
|
2
3
|
type Args<T> = {
|
|
3
4
|
data: T;
|
|
4
5
|
fields: (Field | TabAsField)[];
|
|
5
6
|
id?: number | string;
|
|
6
|
-
|
|
7
|
+
locale: string | undefined;
|
|
7
8
|
siblingData: Data;
|
|
9
|
+
user: User;
|
|
8
10
|
};
|
|
9
|
-
export declare const iterateFields: <T>({ id, data, fields,
|
|
11
|
+
export declare const iterateFields: <T>({ id, data, fields, locale, siblingData, user, }: Args<T>) => Promise<void>;
|
|
10
12
|
export {};
|
|
11
13
|
//# sourceMappingURL=iterateFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterateFields.d.ts","sourceRoot":"","sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"iterateFields.d.ts","sourceRoot":"","sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAI5D,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,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,aAAa,wDAOvB,KAAK,CAAC,CAAC,KAAG,QAAQ,IAAI,CAexB,CAAA"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { defaultValuePromise } from './promise.js';
|
|
2
|
-
export const iterateFields = async ({ id, data, fields,
|
|
2
|
+
export const iterateFields = async ({ id, data, fields, locale, siblingData, user })=>{
|
|
3
3
|
const promises = [];
|
|
4
4
|
fields.forEach((field)=>{
|
|
5
5
|
promises.push(defaultValuePromise({
|
|
6
6
|
id,
|
|
7
7
|
data,
|
|
8
8
|
field,
|
|
9
|
-
|
|
10
|
-
siblingData
|
|
9
|
+
locale,
|
|
10
|
+
siblingData,
|
|
11
|
+
user
|
|
11
12
|
}));
|
|
12
13
|
});
|
|
13
14
|
await Promise.all(promises);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.ts"],"sourcesContent":["import type { Data, Field,
|
|
1
|
+
{"version":3,"sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.ts"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { Data, Field, TabAsField } from 'payload/types'\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 siblingData: Data\n user: User\n}\n\nexport const iterateFields = async <T>({\n id,\n data,\n fields,\n locale,\n siblingData,\n user,\n}: Args<T>): Promise<void> => {\n const promises = []\n fields.forEach((field) => {\n promises.push(\n defaultValuePromise({\n id,\n data,\n field,\n locale,\n siblingData,\n user,\n }),\n )\n })\n await Promise.all(promises)\n}\n"],"names":["defaultValuePromise","iterateFields","id","data","fields","locale","siblingData","user","promises","forEach","field","push","Promise","all"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAGA,SAASA,mBAAmB,QAAQ,eAAc;AAWlD,OAAO,MAAMC,gBAAgB,OAAU,EACrCC,EAAE,EACFC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,WAAW,EACXC,IAAI,EACI;IACR,MAAMC,WAAW,EAAE;IACnBJ,OAAOK,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXX,oBAAoB;YAClBE;YACAC;YACAO;YACAL;YACAC;YACAC;QACF;IAEJ;IACA,MAAMK,QAAQC,GAAG,CAACL;AACpB,EAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import type { User } from 'payload/auth';
|
|
1
2
|
import type { Data } from 'payload/types';
|
|
2
|
-
import { type Field, type
|
|
3
|
+
import { type Field, type TabAsField } from 'payload/types';
|
|
3
4
|
type Args<T> = {
|
|
4
5
|
data: T;
|
|
5
6
|
field: Field | TabAsField;
|
|
6
7
|
id?: number | string;
|
|
7
|
-
|
|
8
|
+
locale: string | undefined;
|
|
8
9
|
siblingData: Data;
|
|
10
|
+
user: User;
|
|
9
11
|
};
|
|
10
|
-
export declare const defaultValuePromise: <T>({ id, data, field,
|
|
12
|
+
export declare const defaultValuePromise: <T>({ id, data, field, locale, siblingData, user, }: Args<T>) => Promise<void>;
|
|
11
13
|
export {};
|
|
12
14
|
//# sourceMappingURL=promise.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/promise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/promise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAgC,MAAM,eAAe,CAAA;AAKzF,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,WAAW,EAAE,IAAI,CAAA;IACjB,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAGD,eAAO,MAAM,mBAAmB,uDAO7B,KAAK,CAAC,CAAC,KAAG,QAAQ,IAAI,CA2IxB,CAAA"}
|
|
@@ -2,13 +2,13 @@ import { fieldAffectsData, tabHasName } from 'payload/types';
|
|
|
2
2
|
import { getDefaultValue } from 'payload/utilities';
|
|
3
3
|
import { iterateFields } from './iterateFields.js';
|
|
4
4
|
// TODO: Make this works for rich text subfields
|
|
5
|
-
export const defaultValuePromise = async ({ id, data, field,
|
|
5
|
+
export const defaultValuePromise = async ({ id, data, field, locale, siblingData, user })=>{
|
|
6
6
|
if (fieldAffectsData(field)) {
|
|
7
7
|
if (typeof siblingData[field.name] === 'undefined' && typeof field.defaultValue !== 'undefined') {
|
|
8
8
|
siblingData[field.name] = await getDefaultValue({
|
|
9
9
|
defaultValue: field.defaultValue,
|
|
10
|
-
locale
|
|
11
|
-
user
|
|
10
|
+
locale,
|
|
11
|
+
user,
|
|
12
12
|
value: siblingData[field.name]
|
|
13
13
|
});
|
|
14
14
|
}
|
|
@@ -23,8 +23,9 @@ export const defaultValuePromise = async ({ id, data, field, req, siblingData })
|
|
|
23
23
|
id,
|
|
24
24
|
data,
|
|
25
25
|
fields: field.fields,
|
|
26
|
-
|
|
27
|
-
siblingData: groupData
|
|
26
|
+
locale,
|
|
27
|
+
siblingData: groupData,
|
|
28
|
+
user
|
|
28
29
|
});
|
|
29
30
|
break;
|
|
30
31
|
}
|
|
@@ -38,8 +39,9 @@ export const defaultValuePromise = async ({ id, data, field, req, siblingData })
|
|
|
38
39
|
id,
|
|
39
40
|
data,
|
|
40
41
|
fields: field.fields,
|
|
41
|
-
|
|
42
|
-
siblingData: row
|
|
42
|
+
locale,
|
|
43
|
+
siblingData: row,
|
|
44
|
+
user
|
|
43
45
|
}));
|
|
44
46
|
});
|
|
45
47
|
await Promise.all(promises);
|
|
@@ -60,8 +62,9 @@ export const defaultValuePromise = async ({ id, data, field, req, siblingData })
|
|
|
60
62
|
id,
|
|
61
63
|
data,
|
|
62
64
|
fields: block.fields,
|
|
63
|
-
|
|
64
|
-
siblingData: row
|
|
65
|
+
locale,
|
|
66
|
+
siblingData: row,
|
|
67
|
+
user
|
|
65
68
|
}));
|
|
66
69
|
}
|
|
67
70
|
});
|
|
@@ -76,8 +79,9 @@ export const defaultValuePromise = async ({ id, data, field, req, siblingData })
|
|
|
76
79
|
id,
|
|
77
80
|
data,
|
|
78
81
|
fields: field.fields,
|
|
79
|
-
|
|
80
|
-
siblingData
|
|
82
|
+
locale,
|
|
83
|
+
siblingData,
|
|
84
|
+
user
|
|
81
85
|
});
|
|
82
86
|
break;
|
|
83
87
|
}
|
|
@@ -94,8 +98,9 @@ export const defaultValuePromise = async ({ id, data, field, req, siblingData })
|
|
|
94
98
|
id,
|
|
95
99
|
data,
|
|
96
100
|
fields: field.fields,
|
|
97
|
-
|
|
98
|
-
siblingData: tabSiblingData
|
|
101
|
+
locale,
|
|
102
|
+
siblingData: tabSiblingData,
|
|
103
|
+
user
|
|
99
104
|
});
|
|
100
105
|
break;
|
|
101
106
|
}
|
|
@@ -108,8 +113,9 @@ export const defaultValuePromise = async ({ id, data, field, req, siblingData })
|
|
|
108
113
|
...tab,
|
|
109
114
|
type: 'tab'
|
|
110
115
|
})),
|
|
111
|
-
|
|
112
|
-
siblingData
|
|
116
|
+
locale,
|
|
117
|
+
siblingData,
|
|
118
|
+
user
|
|
113
119
|
});
|
|
114
120
|
break;
|
|
115
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/promise.ts"],"sourcesContent":["import type { Data } from 'payload/types'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/forms/buildStateFromSchema/calculateDefaultValues/promise.ts"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { Data } from 'payload/types'\n\nimport { type Field, type TabAsField, fieldAffectsData, tabHasName } from 'payload/types'\nimport { getDefaultValue } from 'payload/utilities'\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 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 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 siblingData[field.name] = await getDefaultValue({\n defaultValue: field.defaultValue,\n locale,\n user,\n value: siblingData[field.name],\n })\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\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 siblingData: groupData,\n user,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row) => {\n promises.push(\n iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n siblingData: row,\n user,\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 = row.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\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 siblingData: row,\n user,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await iterateFields({\n id,\n data,\n fields: field.fields,\n locale,\n siblingData,\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') siblingData[field.name] = {}\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 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 siblingData,\n user,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["fieldAffectsData","tabHasName","getDefaultValue","iterateFields","defaultValuePromise","id","data","field","locale","siblingData","user","name","defaultValue","value","type","groupData","fields","rows","Array","isArray","promises","forEach","row","push","Promise","all","blockTypeToMatch","blockType","block","blocks","find","slug","tabSiblingData","tabs","map","tab"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAAsCA,gBAAgB,EAAEC,UAAU,QAAQ,gBAAe;AAC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@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/buildStateFromSchema/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,mBAAmB,EACnB,KAAK,IAAI,WAAW,EACpB,SAAS,EACT,sBAAsB,EACvB,MAAM,eAAe,CAAA;AAKtB,KAAK,IAAI,GAAG;IACV,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,WAAW,EAAE,WAAW,EAAE,GAAG,SAAS,CAAA;IACtC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,WAAW,EAAE,mBAAmB,CAAA;IAChC,GAAG,EAAE,sBAAsB,CAAA;IAC3B,WAAW,CAAC,EAAE,IAAI,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,cAAc,CAAC,EAAE,mBAAmB,CAAA;IACpC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,oBAAoB,SAAgB,IAAI,KAAG,QAAQ,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/buildStateFromSchema/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,mBAAmB,EACnB,KAAK,IAAI,WAAW,EACpB,SAAS,EACT,sBAAsB,EACvB,MAAM,eAAe,CAAA;AAKtB,KAAK,IAAI,GAAG;IACV,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,WAAW,EAAE,WAAW,EAAE,GAAG,SAAS,CAAA;IACtC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,WAAW,EAAE,mBAAmB,CAAA;IAChC,GAAG,EAAE,sBAAsB,CAAA;IAC3B,WAAW,CAAC,EAAE,IAAI,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,cAAc,CAAC,EAAE,mBAAmB,CAAA;IACpC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,oBAAoB,SAAgB,IAAI,KAAG,QAAQ,SAAS,CAiCxE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/buildStateFromSchema/index.tsx"],"sourcesContent":["import type {\n Data,\n DocumentPreferences,\n Field as FieldSchema,\n FormState,\n PayloadRequestWithData,\n} from 'payload/types'\n\nimport { calculateDefaultValues } from './calculateDefaultValues/index.js'\nimport { iterateFields } from './iterateFields.js'\n\ntype Args = {\n data?: Data\n fieldSchema: FieldSchema[] | undefined\n id?: number | string\n operation?: 'create' | 'update'\n preferences: DocumentPreferences\n req: PayloadRequestWithData\n siblingData?: Data\n}\n\nexport type BuildFormStateArgs = {\n collectionSlug?: string\n data?: Data\n docPreferences?: DocumentPreferences\n formState?: FormState\n globalSlug?: string\n id?: number | string\n locale?: string\n operation?: 'create' | 'update'\n schemaPath: string\n}\n\nexport const buildStateFromSchema = async (args: Args): Promise<FormState> => {\n const { id, data: fullData = {}, fieldSchema, operation, preferences, req } = args\n\n if (fieldSchema) {\n const state: FormState = {}\n\n const dataWithDefaultValues = await calculateDefaultValues({\n id,\n data: fullData,\n fields: fieldSchema,\n req,\n siblingData: fullData,\n })\n\n await iterateFields({\n id,\n addErrorPathToParent: null,\n data: dataWithDefaultValues,\n fields: fieldSchema,\n fullData,\n operation,\n parentPassesCondition: true,\n path: '',\n preferences,\n req,\n state,\n })\n\n return state\n }\n\n return {}\n}\n"],"names":["calculateDefaultValues","iterateFields","buildStateFromSchema","args","id","data","fullData","fieldSchema","operation","preferences","req","state","dataWithDefaultValues","fields","siblingData","addErrorPathToParent","parentPassesCondition","path"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/buildStateFromSchema/index.tsx"],"sourcesContent":["import type {\n Data,\n DocumentPreferences,\n Field as FieldSchema,\n FormState,\n PayloadRequestWithData,\n} from 'payload/types'\n\nimport { calculateDefaultValues } from './calculateDefaultValues/index.js'\nimport { iterateFields } from './iterateFields.js'\n\ntype Args = {\n data?: Data\n fieldSchema: FieldSchema[] | undefined\n id?: number | string\n operation?: 'create' | 'update'\n preferences: DocumentPreferences\n req: PayloadRequestWithData\n siblingData?: Data\n}\n\nexport type BuildFormStateArgs = {\n collectionSlug?: string\n data?: Data\n docPreferences?: DocumentPreferences\n formState?: FormState\n globalSlug?: string\n id?: number | string\n locale?: string\n operation?: 'create' | 'update'\n schemaPath: string\n}\n\nexport const buildStateFromSchema = async (args: Args): Promise<FormState> => {\n const { id, data: fullData = {}, fieldSchema, operation, preferences, req } = args\n\n if (fieldSchema) {\n const state: FormState = {}\n\n const dataWithDefaultValues = await calculateDefaultValues({\n id,\n data: fullData,\n fields: fieldSchema,\n locale: req.locale,\n siblingData: fullData,\n user: req.user,\n })\n\n await iterateFields({\n id,\n addErrorPathToParent: null,\n data: dataWithDefaultValues,\n fields: fieldSchema,\n fullData,\n operation,\n parentPassesCondition: true,\n path: '',\n preferences,\n req,\n state,\n })\n\n return state\n }\n\n return {}\n}\n"],"names":["calculateDefaultValues","iterateFields","buildStateFromSchema","args","id","data","fullData","fieldSchema","operation","preferences","req","state","dataWithDefaultValues","fields","locale","siblingData","user","addErrorPathToParent","parentPassesCondition","path"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAQA,SAASA,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,aAAa,QAAQ,qBAAoB;AAwBlD,OAAO,MAAMC,uBAAuB,OAAOC;IACzC,MAAM,EAAEC,EAAE,EAAEC,MAAMC,WAAW,CAAC,CAAC,EAAEC,WAAW,EAAEC,SAAS,EAAEC,WAAW,EAAEC,GAAG,EAAE,GAAGP;IAE9E,IAAII,aAAa;QACf,MAAMI,QAAmB,CAAC;QAE1B,MAAMC,wBAAwB,MAAMZ,uBAAuB;YACzDI;YACAC,MAAMC;YACNO,QAAQN;YACRO,QAAQJ,IAAII,MAAM;YAClBC,aAAaT;YACbU,MAAMN,IAAIM,IAAI;QAChB;QAEA,MAAMf,cAAc;YAClBG;YACAa,sBAAsB;YACtBZ,MAAMO;YACNC,QAAQN;YACRD;YACAE;YACAU,uBAAuB;YACvBC,MAAM;YACNV;YACAC;YACAC;QACF;QAEA,OAAOA;IACT;IAEA,OAAO,CAAC;AACV,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/useField/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpD,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/useField/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpD,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA;AAkBlC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,eAAiB,OAAO,KAAG,UAAU,CAAC,CAqM1D,CAAA"}
|
|
@@ -7,7 +7,7 @@ import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
|
|
|
7
7
|
import { useOperation } from '../../providers/Operation/index.js';
|
|
8
8
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
9
9
|
import { useFieldProps } from '../FieldPropsProvider/index.js';
|
|
10
|
-
import { useForm, useFormFields, useFormModified, useFormProcessing, useFormSubmitted } from '../Form/context.js';
|
|
10
|
+
import { useForm, useFormFields, useFormInitializing, useFormModified, useFormProcessing, useFormSubmitted } from '../Form/context.js';
|
|
11
11
|
/**
|
|
12
12
|
* Get and set the value of a form field.
|
|
13
13
|
*
|
|
@@ -19,6 +19,7 @@ import { useForm, useFormFields, useFormModified, useFormProcessing, useFormSubm
|
|
|
19
19
|
const path = options.path || pathFromContext;
|
|
20
20
|
const submitted = useFormSubmitted();
|
|
21
21
|
const processing = useFormProcessing();
|
|
22
|
+
const initializing = useFormInitializing();
|
|
22
23
|
const { user } = useAuth();
|
|
23
24
|
const { id } = useDocumentInfo();
|
|
24
25
|
const operation = useOperation();
|
|
@@ -85,6 +86,7 @@ import { useForm, useFormFields, useFormModified, useFormProcessing, useFormSubm
|
|
|
85
86
|
errorMessage: field?.errorMessage,
|
|
86
87
|
errorPaths: field?.errorPaths || [],
|
|
87
88
|
filterOptions,
|
|
89
|
+
formInitializing: initializing,
|
|
88
90
|
formProcessing: processing,
|
|
89
91
|
formSubmitted: submitted,
|
|
90
92
|
initialValue,
|
|
@@ -112,7 +114,8 @@ import { useForm, useFormFields, useFormModified, useFormProcessing, useFormSubm
|
|
|
112
114
|
schemaPath,
|
|
113
115
|
readOnly,
|
|
114
116
|
permissions,
|
|
115
|
-
filterOptions
|
|
117
|
+
filterOptions,
|
|
118
|
+
initializing
|
|
116
119
|
]);
|
|
117
120
|
// Throttle the validate function
|
|
118
121
|
useThrottledEffect(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/useField/index.tsx"],"sourcesContent":["'use client'\nimport { useCallback, useMemo, useRef } from 'react'\n\nimport type { UPDATE } from '../Form/types.js'\nimport type { FieldType, Options } from './types.js'\n\nexport type { FieldType, Options }\n\nimport useThrottledEffect from '../../hooks/useThrottledEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { useFieldProps } from '../FieldPropsProvider/index.js'\nimport {\n useForm,\n useFormFields,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n} from '../Form/context.js'\n\n/**\n * Get and set the value of a form field.\n *\n * @see https://payloadcms.com/docs/admin/hooks#usefield\n */\nexport const useField = <T,>(options: Options): FieldType<T> => {\n const { disableFormData = false, hasRows, validate } = options\n\n const { path: pathFromContext, permissions, readOnly, schemaPath } = useFieldProps()\n\n // Prioritize passed in path over context path. If the context path should be prioritized (which is the case for top-level useField calls in fields), it should be passed in as the options path.\n const path = options.path || pathFromContext\n\n const submitted = useFormSubmitted()\n const processing = useFormProcessing()\n const { user } = useAuth()\n const { id } = useDocumentInfo()\n const operation = useOperation()\n\n const { dispatchField, field } = useFormFields(([fields, dispatch]) => ({\n dispatchField: dispatch,\n field: (fields && fields?.[path]) || null,\n }))\n\n const { t } = useTranslation()\n const config = useConfig()\n\n const { getData, getDataByPath, getSiblingData, setModified } = useForm()\n const modified = useFormModified()\n\n const filterOptions = field?.filterOptions\n const value = field?.value as T\n const initialValue = field?.initialValue as T\n const valid = typeof field?.valid === 'boolean' ? field.valid : true\n const showError = valid === false && submitted\n\n const prevValid = useRef(valid)\n const prevErrorMessage = useRef(field?.errorMessage)\n\n // Method to return from `useField`, used to\n // update field values from field component(s)\n const setValue = useCallback(\n (e, disableModifyingForm = false) => {\n const val = e && e.target ? e.target.value : e\n\n dispatchField({\n type: 'UPDATE',\n disableFormData: disableFormData || (hasRows && val > 0),\n path,\n value: val,\n })\n\n if (!disableModifyingForm) {\n if (typeof setModified === 'function') {\n // Only update setModified to true if the form is not already set to modified. Otherwise the following could happen:\n // 1. Text field: someone types in it in an unmodified form\n // 2. After setTimeout triggers setModified(true): form is set to modified. Save Button becomes available. Good!\n // 3. Type something in text field\n // 4. Click on save button before setTimeout in useField has finished (so setModified(true) has not been run yet)\n // 5. Form is saved, setModified(false) is set in the Form/index.tsx `submit` function, \"saved successfully\" toast appears\n // 6. setModified(true) inside the timeout is run, form is set to modified again, even though it was already saved and thus set to unmodified. Bad! This should have happened before the form is saved. Now the form should be unmodified and stay that way\n // until a NEW change happens. Due to this, the \"Leave without saving\" modal appears even though it should not when leaving the page fast immediately after saving the document.\n // This is only an issue for forms which have already been set to modified true, as that causes the save button to be enabled. If we prevent this setTimeout to be run\n // for already-modified forms first place (which is unnecessary), we can avoid this issue. As for unmodified forms, this race issue will not happen, because you cannot click the save button faster\n // than the timeout in useField is run. That's because the save button won't even be enabled for clicking until the setTimeout in useField has run.\n // This fixes e2e test flakes, as e2e tests were often so fast that they were saving the form before the timeout in useField has run.\n // Specifically, this fixes the 'should not warn about unsaved changes when navigating to lexical editor with blocks node and then leaving the page after making a change and saving' lexical e2e test.\n if (modified === false) {\n // Update modified state after field value comes back\n // to avoid cursor jump caused by state value / DOM mismatch\n setTimeout(() => {\n setModified(true)\n }, 10)\n }\n }\n }\n },\n [setModified, path, dispatchField, disableFormData, hasRows, modified],\n )\n\n // Store result from hook as ref\n // to prevent unnecessary rerenders\n const result: FieldType<T> = useMemo(\n () => ({\n errorMessage: field?.errorMessage,\n errorPaths: field?.errorPaths || [],\n filterOptions,\n formProcessing: processing,\n formSubmitted: submitted,\n initialValue,\n path,\n permissions,\n readOnly: readOnly || false,\n rows: field?.rows,\n schemaPath,\n setValue,\n showError,\n valid: field?.valid,\n value,\n }),\n [\n field?.errorMessage,\n field?.rows,\n field?.valid,\n field?.errorPaths,\n processing,\n setValue,\n showError,\n submitted,\n value,\n initialValue,\n path,\n schemaPath,\n readOnly,\n permissions,\n filterOptions,\n ],\n )\n\n // Throttle the validate function\n useThrottledEffect(\n () => {\n const validateField = async () => {\n let valueToValidate = value\n\n if (field?.rows && Array.isArray(field.rows)) {\n valueToValidate = getDataByPath(path)\n }\n\n let errorMessage: string | undefined\n let valid: boolean | string = prevValid.current\n\n const isValid =\n typeof validate === 'function'\n ? await validate(valueToValidate, {\n id,\n config,\n data: getData(),\n operation,\n siblingData: getSiblingData(path),\n t,\n user,\n })\n : true\n\n if (typeof isValid === 'string') {\n valid = false\n errorMessage = isValid\n } else if (typeof isValid === 'boolean') {\n valid = isValid\n errorMessage = undefined\n }\n\n // Only dispatch if the validation result has changed\n // This will prevent unnecessary rerenders\n if (valid !== prevValid.current || errorMessage !== prevErrorMessage.current) {\n prevValid.current = valid\n prevErrorMessage.current = errorMessage\n\n const update: UPDATE = {\n type: 'UPDATE',\n errorMessage,\n path,\n rows: field?.rows,\n valid,\n // validate,\n value,\n }\n\n if (disableFormData || (hasRows ? typeof value === 'number' && value > 0 : false)) {\n update.disableFormData = true\n }\n\n if (typeof dispatchField === 'function') {\n dispatchField(update)\n }\n }\n }\n\n void validateField()\n },\n 150,\n [\n value,\n disableFormData,\n dispatchField,\n getData,\n getSiblingData,\n getDataByPath,\n id,\n operation,\n path,\n user,\n validate,\n field?.rows,\n ],\n )\n\n return result\n}\n"],"names":["useCallback","useMemo","useRef","useThrottledEffect","useAuth","useConfig","useDocumentInfo","useOperation","useTranslation","useFieldProps","useForm","useFormFields","useFormModified","useFormProcessing","useFormSubmitted","useField","options","disableFormData","hasRows","validate","path","pathFromContext","permissions","readOnly","schemaPath","submitted","processing","user","id","operation","dispatchField","field","fields","dispatch","t","config","getData","getDataByPath","getSiblingData","setModified","modified","filterOptions","value","initialValue","valid","showError","prevValid","prevErrorMessage","errorMessage","setValue","e","disableModifyingForm","val","target","type","setTimeout","result","errorPaths","formProcessing","formSubmitted","rows","validateField","valueToValidate","Array","isArray","current","isValid","data","siblingData","undefined","update"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAO;AAOpD,OAAOC,wBAAwB,oCAAmC;AAClE,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SACEC,OAAO,EACPC,aAAa,EACbC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,QACX,qBAAoB;AAE3B;;;;CAIC,GACD,OAAO,MAAMC,WAAW,CAAKC;IAC3B,MAAM,EAAEC,kBAAkB,KAAK,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGH;IAEvD,MAAM,EAAEI,MAAMC,eAAe,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,UAAU,EAAE,GAAGf;IAErE,iMAAiM;IACjM,MAAMW,OAAOJ,QAAQI,IAAI,IAAIC;IAE7B,MAAMI,YAAYX;IAClB,MAAMY,aAAab;IACnB,MAAM,EAAEc,IAAI,EAAE,GAAGvB;IACjB,MAAM,EAAEwB,EAAE,EAAE,GAAGtB;IACf,MAAMuB,YAAYtB;IAElB,MAAM,EAAEuB,aAAa,EAAEC,KAAK,EAAE,G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N;oBACA5B;oBACAwC,MAAM7B,OAAO6B;oBACbhB;oBACA,YAAY;oBACZF;gBACF;gBAEA,IAAIzB,mBAAoBC,CAAAA,UAAU,OAAOwB,UAAU,YAAYA,QAAQ,IAAI,KAAI,GAAI;oBACjF4B,OAAOrD,eAAe,GAAG;gBAC3B;gBAEA,IAAI,OAAOa,kBAAkB,YAAY;oBACvCA,cAAcwC;gBAChB;YACF;QACF;QAEA,KAAKT;IACP,GACA,KACA;QACEnB;QACAzB;QACAa;QACAM;QACAE;QACAD;QACAT;QACAC;QACAT;QACAO;QACAR;QACAY,OAAO6B;KACR;IAGH,OAAOJ;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/useField/index.tsx"],"sourcesContent":["'use client'\nimport { useCallback, useMemo, useRef } from 'react'\n\nimport type { UPDATE } from '../Form/types.js'\nimport type { FieldType, Options } from './types.js'\n\nexport type { FieldType, Options }\n\nimport useThrottledEffect from '../../hooks/useThrottledEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { useFieldProps } from '../FieldPropsProvider/index.js'\nimport {\n useForm,\n useFormFields,\n useFormInitializing,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n} from '../Form/context.js'\n\n/**\n * Get and set the value of a form field.\n *\n * @see https://payloadcms.com/docs/admin/hooks#usefield\n */\nexport const useField = <T,>(options: Options): FieldType<T> => {\n const { disableFormData = false, hasRows, validate } = options\n\n const { path: pathFromContext, permissions, readOnly, schemaPath } = useFieldProps()\n\n // Prioritize passed in path over context path. If the context path should be prioritized (which is the case for top-level useField calls in fields), it should be passed in as the options path.\n const path = options.path || pathFromContext\n\n const submitted = useFormSubmitted()\n const processing = useFormProcessing()\n const initializing = useFormInitializing()\n const { user } = useAuth()\n const { id } = useDocumentInfo()\n const operation = useOperation()\n\n const { dispatchField, field } = useFormFields(([fields, dispatch]) => ({\n dispatchField: dispatch,\n field: (fields && fields?.[path]) || null,\n }))\n\n const { t } = useTranslation()\n const config = useConfig()\n\n const { getData, getDataByPath, getSiblingData, setModified } = useForm()\n const modified = useFormModified()\n\n const filterOptions = field?.filterOptions\n const value = field?.value as T\n const initialValue = field?.initialValue as T\n const valid = typeof field?.valid === 'boolean' ? field.valid : true\n const showError = valid === false && submitted\n\n const prevValid = useRef(valid)\n const prevErrorMessage = useRef(field?.errorMessage)\n\n // Method to return from `useField`, used to\n // update field values from field component(s)\n const setValue = useCallback(\n (e, disableModifyingForm = false) => {\n const val = e && e.target ? e.target.value : e\n\n dispatchField({\n type: 'UPDATE',\n disableFormData: disableFormData || (hasRows && val > 0),\n path,\n value: val,\n })\n\n if (!disableModifyingForm) {\n if (typeof setModified === 'function') {\n // Only update setModified to true if the form is not already set to modified. Otherwise the following could happen:\n // 1. Text field: someone types in it in an unmodified form\n // 2. After setTimeout triggers setModified(true): form is set to modified. Save Button becomes available. Good!\n // 3. Type something in text field\n // 4. Click on save button before setTimeout in useField has finished (so setModified(true) has not been run yet)\n // 5. Form is saved, setModified(false) is set in the Form/index.tsx `submit` function, \"saved successfully\" toast appears\n // 6. setModified(true) inside the timeout is run, form is set to modified again, even though it was already saved and thus set to unmodified. Bad! This should have happened before the form is saved. Now the form should be unmodified and stay that way\n // until a NEW change happens. Due to this, the \"Leave without saving\" modal appears even though it should not when leaving the page fast immediately after saving the document.\n // This is only an issue for forms which have already been set to modified true, as that causes the save button to be enabled. If we prevent this setTimeout to be run\n // for already-modified forms first place (which is unnecessary), we can avoid this issue. As for unmodified forms, this race issue will not happen, because you cannot click the save button faster\n // than the timeout in useField is run. That's because the save button won't even be enabled for clicking until the setTimeout in useField has run.\n // This fixes e2e test flakes, as e2e tests were often so fast that they were saving the form before the timeout in useField has run.\n // Specifically, this fixes the 'should not warn about unsaved changes when navigating to lexical editor with blocks node and then leaving the page after making a change and saving' lexical e2e test.\n if (modified === false) {\n // Update modified state after field value comes back\n // to avoid cursor jump caused by state value / DOM mismatch\n setTimeout(() => {\n setModified(true)\n }, 10)\n }\n }\n }\n },\n [setModified, path, dispatchField, disableFormData, hasRows, modified],\n )\n\n // Store result from hook as ref\n // to prevent unnecessary rerenders\n const result: FieldType<T> = useMemo(\n () => ({\n errorMessage: field?.errorMessage,\n errorPaths: field?.errorPaths || [],\n filterOptions,\n formInitializing: initializing,\n formProcessing: processing,\n formSubmitted: submitted,\n initialValue,\n path,\n permissions,\n readOnly: readOnly || false,\n rows: field?.rows,\n schemaPath,\n setValue,\n showError,\n valid: field?.valid,\n value,\n }),\n [\n field?.errorMessage,\n field?.rows,\n field?.valid,\n field?.errorPaths,\n processing,\n setValue,\n showError,\n submitted,\n value,\n initialValue,\n path,\n schemaPath,\n readOnly,\n permissions,\n filterOptions,\n initializing,\n ],\n )\n\n // Throttle the validate function\n useThrottledEffect(\n () => {\n const validateField = async () => {\n let valueToValidate = value\n\n if (field?.rows && Array.isArray(field.rows)) {\n valueToValidate = getDataByPath(path)\n }\n\n let errorMessage: string | undefined\n let valid: boolean | string = prevValid.current\n\n const isValid =\n typeof validate === 'function'\n ? await validate(valueToValidate, {\n id,\n config,\n data: getData(),\n operation,\n siblingData: getSiblingData(path),\n t,\n user,\n })\n : true\n\n if (typeof isValid === 'string') {\n valid = false\n errorMessage = isValid\n } else if (typeof isValid === 'boolean') {\n valid = isValid\n errorMessage = undefined\n }\n\n // Only dispatch if the validation result has changed\n // This will prevent unnecessary rerenders\n if (valid !== prevValid.current || errorMessage !== prevErrorMessage.current) {\n prevValid.current = valid\n prevErrorMessage.current = errorMessage\n\n const update: UPDATE = {\n type: 'UPDATE',\n errorMessage,\n path,\n rows: field?.rows,\n valid,\n // validate,\n value,\n }\n\n if (disableFormData || (hasRows ? typeof value === 'number' && value > 0 : false)) {\n update.disableFormData = true\n }\n\n if (typeof dispatchField === 'function') {\n dispatchField(update)\n }\n }\n }\n\n void validateField()\n },\n 150,\n [\n value,\n disableFormData,\n dispatchField,\n getData,\n getSiblingData,\n getDataByPath,\n id,\n operation,\n path,\n user,\n validate,\n field?.rows,\n ],\n )\n\n return result\n}\n"],"names":["useCallback","useMemo","useRef","useThrottledEffect","useAuth","useConfig","useDocumentInfo","useOperation","useTranslation","useFieldProps","useForm","useFormFields","useFormInitializing","useFormModified","useFormProcessing","useFormSubmitted","useField","options","disableFormData","hasRows","validate","path","pathFromContext","permissions","readOnly","schemaPath","submitted","processing","initializing","user","id","operation","dispatchField","field","fields","dispatch","t","config","getData","getDataByPath","getSiblingData","setModified","modified","filterOptions","value","initialValue","valid","showError","prevValid","prevErrorMessage","errorMessage","setValue","e","disableModifyingForm","val","target","type","setTimeout","result","errorPaths","formInitializing","formProcessing","formSubmitted","rows","validateField","valueToValidate","Array","isArray","current","isValid","data","siblingData","undefined","update"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAO;AAOpD,OAAOC,wBAAwB,oCAAmC;AAClE,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SACEC,OAAO,EACPC,aAAa,EACbC,mBAAmB,EACnBC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,QACX,qBAAoB;AAE3B;;;;CAIC,GACD,OAAO,MAAMC,WAAW,CAAK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gBAC9BnC;gBACAO;gBACAiC,MAAMhC;gBACNP;gBACAwC,aAAa/B,eAAenB;gBAC5Be;gBACAP;YACF,KACA;YAEN,IAAI,OAAOwC,YAAY,UAAU;gBAC/BvB,QAAQ;gBACRI,eAAemB;YACjB,OAAO,IAAI,OAAOA,YAAY,WAAW;gBACvCvB,QAAQuB;gBACRnB,eAAesB;YACjB;YAEA,qDAAqD;YACrD,0CAA0C;YAC1C,IAAI1B,UAAUE,UAAUoB,OAAO,IAAIlB,iBAAiBD,iBAAiBmB,OAAO,EAAE;gBAC5EpB,UAAUoB,OAAO,GAAGtB;gBACpBG,iBAAiBmB,OAAO,GAAGlB;gBAE3B,MAAMuB,SAAiB;oBACrBjB,MAAM;oBACNN;oBACA7B;oBACA0C,MAAM9B,OAAO8B;oBACbjB;oBACA,YAAY;oBACZF;gBACF;gBAEA,IAAI1B,mBAAoBC,CAAAA,UAAU,OAAOyB,UAAU,YAAYA,QAAQ,IAAI,KAAI,GAAI;oBACjF6B,OAAOvD,eAAe,GAAG;gBAC3B;gBAEA,IAAI,OAAOc,kBAAkB,YAAY;oBACvCA,cAAcyC;gBAChB;YACF;QACF;QAEA,KAAKT;IACP,GACA,KACA;QACEpB;QACA1B;QACAc;QACAM;QACAE;QACAD;QACAT;QACAC;QACAV;QACAQ;QACAT;QACAa,OAAO8B;KACR;IAGH,OAAOL;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/useField/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAE/F,MAAM,MAAM,OAAO,GAAG;IACpB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;QAEI;IACJ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAA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cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,YAAY,CAAC,EAAE,CAAC,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,gBAAgB,CAAA;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,oBAAoB,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IAChE,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,CAAC,CAAA;CACT,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/useField/types.ts"],"sourcesContent":["import type { ClientValidate, FieldPermissions, FilterOptionsResult, Row } from 'payload/types'\n\nexport type Options = {\n disableFormData?: boolean\n hasRows?: boolean\n /**\n * If you do not provide a `path` or a `name`, this hook will look for one using the `useFieldPath` hook.\n **/\n path?: string\n validate?: ClientValidate\n}\n\nexport type FieldType<T> = {\n errorMessage?: string\n errorPaths?: string[]\n filterOptions?: FilterOptionsResult\n formProcessing: boolean\n formSubmitted: boolean\n initialValue?: T\n path: string\n permissions: FieldPermissions\n readOnly?: boolean\n rows?: Row[]\n schemaPath: string\n setValue: (val: unknown, disableModifyingForm?: boolean) => void\n showError: boolean\n valid?: boolean\n value: T\n}\n"],"names":[],"rangeMappings":"","mappings":"AAYA,
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/useField/types.ts"],"sourcesContent":["import type { ClientValidate, FieldPermissions, FilterOptionsResult, Row } from 'payload/types'\n\nexport type Options = {\n disableFormData?: boolean\n hasRows?: boolean\n /**\n * If you do not provide a `path` or a `name`, this hook will look for one using the `useFieldPath` hook.\n **/\n path?: string\n validate?: ClientValidate\n}\n\nexport type FieldType<T> = {\n errorMessage?: string\n errorPaths?: string[]\n filterOptions?: FilterOptionsResult\n formInitializing: boolean\n formProcessing: boolean\n formSubmitted: boolean\n initialValue?: T\n path: string\n permissions: FieldPermissions\n readOnly?: boolean\n rows?: Row[]\n schemaPath: string\n setValue: (val: unknown, disableModifyingForm?: boolean) => void\n showError: boolean\n valid?: boolean\n value: T\n}\n"],"names":[],"rangeMappings":"","mappings":"AAYA,WAiBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/icons/Plus/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/icons/Plus/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAUxB,CAAA"}
|
package/dist/icons/Plus/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/icons/Plus/index.tsx"],"sourcesContent":["import React from 'react'\n\nimport './index.scss'\n\nexport const Plus: React.FC = () => (\n <svg
|
|
1
|
+
{"version":3,"sources":["../../../src/icons/Plus/index.tsx"],"sourcesContent":["import React from 'react'\n\nimport './index.scss'\n\nexport const Plus: React.FC = () => (\n <svg\n className=\"icon icon--plus\"\n viewBox=\"0 0 25 25\"\n width=\"25\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <line className=\"stroke\" x1=\"12.4589\" x2=\"12.4589\" y1=\"16.9175\" y2=\"8.50115\" />\n <line className=\"stroke\" x1=\"8.05164\" x2=\"16.468\" y1=\"12.594\" y2=\"12.594\" />\n </svg>\n)\n"],"names":["React","Plus","svg","className","viewBox","width","xmlns","line","x1","x2","y1","y2"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,OAAOA,WAAW,QAAO;AAIzB,OAAO,MAAMC,OAAiB,kBAC5B,MAACC;QACCC,WAAU;QACVC,SAAQ;QACRC,OAAM;QACNC,OAAM;;0BAEN,KAACC;gBAAKJ,WAAU;gBAASK,IAAG;gBAAUC,IAAG;gBAAUC,IAAG;gBAAUC,IAAG;;0BACnE,KAACJ;gBAAKJ,WAAU;gBAASK,IAAG;gBAAUC,IAAG;gBAASC,IAAG;gBAASC,IAAG;;;OAEpE"}
|