@payloadcms/ui 3.20.0 → 3.21.0-canary.0a1cc6a
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/Nav/context.d.ts.map +1 -1
- package/dist/elements/Nav/context.js +3 -4
- package/dist/elements/Nav/context.js.map +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/fields/Join/index.d.ts.map +1 -1
- package/dist/fields/Join/index.js +6 -3
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/fields/Textarea/Input.d.ts.map +1 -1
- package/dist/fields/Textarea/Input.js +9 -16
- package/dist/fields/Textarea/Input.js.map +1 -1
- package/dist/fields/Textarea/index.scss +6 -78
- package/dist/forms/Form/fieldReducer.d.ts.map +1 -1
- package/dist/forms/Form/fieldReducer.js +19 -3
- package/dist/forms/Form/fieldReducer.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +1 -0
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/mergeServerFormState.d.ts.map +1 -1
- package/dist/forms/Form/mergeServerFormState.js +20 -11
- package/dist/forms/Form/mergeServerFormState.js.map +1 -1
- package/dist/forms/Form/types.d.ts +5 -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 +2 -2
- package/dist/forms/RenderFields/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +13 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Join/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAkB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Join/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAkB,MAAM,OAAO,CAAA;AAuMtC,eAAO,MAAM,SAAS;;;;+EAAoC,CAAA"}
|
|
@@ -138,18 +138,21 @@ const JoinFieldComponent = props => {
|
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
return where;
|
|
141
|
-
}, [docID, field.targetField.relationTo, field.where, on, docConfig
|
|
141
|
+
}, [docID, field.targetField.relationTo, field.where, on, docConfig?.slug]);
|
|
142
142
|
const initialDrawerData = useMemo(() => {
|
|
143
143
|
const relatedCollection = getEntityConfig({
|
|
144
144
|
collectionSlug: field.collection
|
|
145
145
|
});
|
|
146
146
|
return getInitialDrawerData({
|
|
147
|
-
collectionSlug: docConfig
|
|
147
|
+
collectionSlug: docConfig?.slug,
|
|
148
148
|
docID,
|
|
149
149
|
fields: relatedCollection.fields,
|
|
150
150
|
segments: field.on.split('.')
|
|
151
151
|
});
|
|
152
|
-
}, [getEntityConfig, field.collection, field.on, docConfig
|
|
152
|
+
}, [getEntityConfig, field.collection, field.on, docConfig?.slug, docID]);
|
|
153
|
+
if (!docConfig) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
153
156
|
return /*#__PURE__*/_jsxs("div", {
|
|
154
157
|
className: [fieldBaseClass, 'join'].filter(Boolean).join(' '),
|
|
155
158
|
id: `field-${path?.replace(/\./g, '__')}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ObjectIdImport","flattenTopLevelFields","React","useMemo","RelationshipTable","RenderCustomComponent","useField","withCondition","useConfig","useDocumentInfo","FieldDescription","FieldLabel","fieldBaseClass","ObjectId","default","getInitialDrawerData","collectionSlug","docID","fields","segments","flattenedFields","path","field","find","name","type","value","Array","isArray","relationTo","hasMany","nextSegments","slice","length","initialData","id","toHexString","block","blocks","blockInitialData","blockType","slug","JoinFieldComponent","props","admin","allowCreate","description","collection","label","localized","on","required","docConfig","getEntityConfig","customComponents","AfterInput","BeforeInput","Description","Label","filterOptions","targetField","where","equals","and","initialDrawerData","relatedCollection","split","_jsxs","className","filter","Boolean","join","replace","_jsx","disableTable","docs","style","margin","CustomComponent","Fallback","JoinField"],"sources":["../../../src/fields/Join/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n ClientField,\n JoinFieldClient,\n JoinFieldClientComponent,\n PaginatedDocs,\n Where,\n} from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { flattenTopLevelFields } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport { RelationshipTable } from '../../elements/RelationshipTable/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../index.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\n/**\n * Recursively builds the default data for joined collection\n */\nconst getInitialDrawerData = ({\n collectionSlug,\n docID,\n fields,\n segments,\n}: {\n collectionSlug: string\n docID: number | string\n fields: ClientField[]\n segments: string[]\n}) => {\n const flattenedFields = flattenTopLevelFields(fields)\n\n const path = segments[0]\n\n const field = flattenedFields.find((field) => field.name === path)\n\n if (!field) {\n return null\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n let value: { relationTo: string; value: number | string } | number | string = docID\n if (Array.isArray(field.relationTo)) {\n value = {\n relationTo: collectionSlug,\n value: docID,\n }\n }\n return {\n [field.name]: field.hasMany ? [value] : value,\n }\n }\n\n const nextSegments = segments.slice(1, segments.length)\n\n if (field.type === 'tab' || field.type === 'group') {\n return {\n [field.name]: getInitialDrawerData({\n collectionSlug,\n docID,\n fields: field.fields,\n segments: nextSegments,\n }),\n }\n }\n\n if (field.type === 'array') {\n const initialData = getInitialDrawerData({\n collectionSlug,\n docID,\n fields: field.fields,\n segments: nextSegments,\n })\n\n initialData.id = ObjectId().toHexString()\n\n return {\n [field.name]: [initialData],\n }\n }\n\n if (field.type === 'blocks') {\n for (const block of field.blocks) {\n const blockInitialData = getInitialDrawerData({\n collectionSlug,\n docID,\n fields: block.fields,\n segments: nextSegments,\n })\n\n if (blockInitialData) {\n blockInitialData.id = ObjectId().toHexString()\n blockInitialData.blockType = block.slug\n\n return {\n [field.name]: [blockInitialData],\n }\n }\n }\n }\n}\n\nconst JoinFieldComponent: JoinFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { allowCreate, description },\n collection,\n label,\n localized,\n on,\n required,\n },\n path,\n } = props\n\n const { id: docID, docConfig } = useDocumentInfo()\n\n const { getEntityConfig } = useConfig()\n\n const { customComponents: { AfterInput, BeforeInput, Description, Label } = {}, value } =\n useField<PaginatedDocs>({\n path,\n })\n\n const filterOptions: null | Where = useMemo(() => {\n if (!docID) {\n return null\n }\n\n let value: { relationTo: string; value: number | string } | number | string = docID\n\n if (Array.isArray(field.targetField.relationTo)) {\n value = {\n relationTo: docConfig.slug,\n value,\n }\n }\n\n const where = {\n [on]: {\n equals: value,\n },\n }\n\n if (field.where) {\n return {\n and: [where, field.where],\n }\n }\n\n return where\n }, [docID, field.targetField.relationTo, field.where, on, docConfig.slug])\n\n const initialDrawerData = useMemo(() => {\n const relatedCollection = getEntityConfig({ collectionSlug: field.collection })\n\n return getInitialDrawerData({\n collectionSlug: docConfig.slug,\n docID,\n fields: relatedCollection.fields,\n segments: field.on.split('.'),\n })\n }, [getEntityConfig, field.collection, field.on, docConfig.slug, docID])\n\n return (\n <div\n className={[fieldBaseClass, 'join'].filter(Boolean).join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n >\n <RelationshipTable\n AfterInput={AfterInput}\n allowCreate={typeof docID !== 'undefined' && allowCreate}\n BeforeInput={BeforeInput}\n disableTable={filterOptions === null}\n field={field as JoinFieldClient}\n filterOptions={filterOptions}\n initialData={docID && value ? value : ({ docs: [] } as PaginatedDocs)}\n initialDrawerData={initialDrawerData}\n Label={\n <h4 style={{ margin: 0 }}>\n {Label || (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n </h4>\n }\n relationTo={collection}\n />\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const JoinField = withCondition(JoinFieldComponent)\n"],"mappings":"AAAA;;;AAUA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAE/B,MAAMC,QAAA,GAAYb,cAAA,CAAec,OAAO,IACtCd,cAAA;AAEF;;;AAGA,MAAMe,oBAAA,GAAuBA,CAAC;EAC5BC,cAAc;EACdC,KAAK;EACLC,MAAM;EACNC;AAAQ,CAMT;EACC,MAAMC,eAAA,GAAkBnB,qBAAA,CAAsBiB,MAAA;EAE9C,MAAMG,IAAA,GAAOF,QAAQ,CAAC,EAAE;EAExB,MAAMG,KAAA,GAAQF,eAAA,CAAgBG,IAAI,CAAED,KAAA,IAAUA,KAAA,CAAME,IAAI,KAAKH,IAAA;EAE7D,IAAI,CAACC,KAAA,EAAO;IACV,OAAO;EACT;EAEA,IAAIA,KAAA,CAAMG,IAAI,KAAK,kBAAkBH,KAAA,CAAMG,IAAI,KAAK,UAAU;IAC5D,IAAIC,KAAA,GAA0ET,KAAA;IA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AAA,EAAMA,IAAA;UAAM8B,QAAA,EAAUA;;;MAI5EtB,UAAA,EAAYkB;qBAEd0B,IAAA,CAACpE,qBAAA;MACCyE,eAAA,EAAiBrB,WAAA;MACjBsB,QAAA,eAAUN,IAAA,CAAC/D,gBAAA;QAAiBoC,WAAA,EAAaA,WAAA;QAAazB,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAM2D,SAAA,GAAYzE,aAAA,CAAcmC,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ObjectIdImport","flattenTopLevelFields","React","useMemo","RelationshipTable","RenderCustomComponent","useField","withCondition","useConfig","useDocumentInfo","FieldDescription","FieldLabel","fieldBaseClass","ObjectId","default","getInitialDrawerData","collectionSlug","docID","fields","segments","flattenedFields","path","field","find","name","type","value","Array","isArray","relationTo","hasMany","nextSegments","slice","length","initialData","id","toHexString","block","blocks","blockInitialData","blockType","slug","JoinFieldComponent","props","admin","allowCreate","description","collection","label","localized","on","required","docConfig","getEntityConfig","customComponents","AfterInput","BeforeInput","Description","Label","filterOptions","targetField","where","equals","and","initialDrawerData","relatedCollection","split","_jsxs","className","filter","Boolean","join","replace","_jsx","disableTable","docs","style","margin","CustomComponent","Fallback","JoinField"],"sources":["../../../src/fields/Join/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n ClientField,\n JoinFieldClient,\n JoinFieldClientComponent,\n PaginatedDocs,\n Where,\n} from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { flattenTopLevelFields } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport { RelationshipTable } from '../../elements/RelationshipTable/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../index.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\n/**\n * Recursively builds the default data for joined collection\n */\nconst getInitialDrawerData = ({\n collectionSlug,\n docID,\n fields,\n segments,\n}: {\n collectionSlug: string\n docID: number | string\n fields: ClientField[]\n segments: string[]\n}) => {\n const flattenedFields = flattenTopLevelFields(fields)\n\n const path = segments[0]\n\n const field = flattenedFields.find((field) => field.name === path)\n\n if (!field) {\n return null\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n let value: { relationTo: string; value: number | string } | number | string = docID\n if (Array.isArray(field.relationTo)) {\n value = {\n relationTo: collectionSlug,\n value: docID,\n }\n }\n return {\n [field.name]: field.hasMany ? [value] : value,\n }\n }\n\n const nextSegments = segments.slice(1, segments.length)\n\n if (field.type === 'tab' || field.type === 'group') {\n return {\n [field.name]: getInitialDrawerData({\n collectionSlug,\n docID,\n fields: field.fields,\n segments: nextSegments,\n }),\n }\n }\n\n if (field.type === 'array') {\n const initialData = getInitialDrawerData({\n collectionSlug,\n docID,\n fields: field.fields,\n segments: nextSegments,\n })\n\n initialData.id = ObjectId().toHexString()\n\n return {\n [field.name]: [initialData],\n }\n }\n\n if (field.type === 'blocks') {\n for (const block of field.blocks) {\n const blockInitialData = getInitialDrawerData({\n collectionSlug,\n docID,\n fields: block.fields,\n segments: nextSegments,\n })\n\n if (blockInitialData) {\n blockInitialData.id = ObjectId().toHexString()\n blockInitialData.blockType = block.slug\n\n return {\n [field.name]: [blockInitialData],\n }\n }\n }\n }\n}\n\nconst JoinFieldComponent: JoinFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { allowCreate, description },\n collection,\n label,\n localized,\n on,\n required,\n },\n path,\n } = props\n\n const { id: docID, docConfig } = useDocumentInfo()\n\n const { getEntityConfig } = useConfig()\n\n const { customComponents: { AfterInput, BeforeInput, Description, Label } = {}, value } =\n useField<PaginatedDocs>({\n path,\n })\n\n const filterOptions: null | Where = useMemo(() => {\n if (!docID) {\n return null\n }\n\n let value: { relationTo: string; value: number | string } | number | string = docID\n\n if (Array.isArray(field.targetField.relationTo)) {\n value = {\n relationTo: docConfig.slug,\n value,\n }\n }\n\n const where = {\n [on]: {\n equals: value,\n },\n }\n\n if (field.where) {\n return {\n and: [where, field.where],\n }\n }\n\n return where\n }, [docID, field.targetField.relationTo, field.where, on, docConfig?.slug])\n\n const initialDrawerData = useMemo(() => {\n const relatedCollection = getEntityConfig({ collectionSlug: field.collection })\n\n return getInitialDrawerData({\n collectionSlug: docConfig?.slug,\n docID,\n fields: relatedCollection.fields,\n segments: field.on.split('.'),\n })\n }, [getEntityConfig, field.collection, field.on, docConfig?.slug, docID])\n\n if (!docConfig) {\n return null\n }\n\n return (\n <div\n className={[fieldBaseClass, 'join'].filter(Boolean).join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n >\n <RelationshipTable\n AfterInput={AfterInput}\n allowCreate={typeof docID !== 'undefined' && allowCreate}\n BeforeInput={BeforeInput}\n disableTable={filterOptions === null}\n field={field as JoinFieldClient}\n filterOptions={filterOptions}\n initialData={docID && value ? value : ({ docs: [] } as PaginatedDocs)}\n initialDrawerData={initialDrawerData}\n Label={\n <h4 style={{ margin: 0 }}>\n {Label || (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n </h4>\n }\n relationTo={collection}\n />\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const JoinField = withCondition(JoinFieldComponent)\n"],"mappings":"AAAA;;;AAUA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,S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AE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQpD,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsEtD,CAAA"}
|
|
@@ -74,22 +74,15 @@ export const TextareaInput = props => {
|
|
|
74
74
|
}), BeforeInput, _jsx("label", {
|
|
75
75
|
className: "textarea-outer",
|
|
76
76
|
htmlFor: `field-${path.replace(/\./g, "__")}`,
|
|
77
|
-
children:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
id: `field-${path.replace(/\./g, "__")}`,
|
|
87
|
-
name: path,
|
|
88
|
-
onChange,
|
|
89
|
-
placeholder: getTranslation(placeholder, i18n),
|
|
90
|
-
rows,
|
|
91
|
-
value: value || ""
|
|
92
|
-
})]
|
|
77
|
+
children: _jsx("textarea", {
|
|
78
|
+
"data-rtl": rtl,
|
|
79
|
+
disabled: readOnly,
|
|
80
|
+
id: `field-${path.replace(/\./g, "__")}`,
|
|
81
|
+
name: path,
|
|
82
|
+
onChange,
|
|
83
|
+
placeholder: getTranslation(placeholder, i18n),
|
|
84
|
+
rows,
|
|
85
|
+
value: value || ""
|
|
93
86
|
})
|
|
94
87
|
}), AfterInput, _jsx(RenderCustomComponent, {
|
|
95
88
|
CustomComponent: Description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","names":["c","_c","getTranslation","React","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useTranslation","fieldBaseClass","TextareaInput","props","$","AfterInput","BeforeInput","className","Description","description","Error","Label","label","localized","onChange","path","placeholder","readOnly","required","rows","rtl","showError","style","value","i18n","t0","t1","t2","filter","Boolean","t3","join","t4","_jsxs","children","_jsx","CustomComponent","Fallback","htmlFor","replace","disabled","id","name"],"sources":["../../../src/fields/Textarea/Input.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport const TextareaInput: React.FC<TextAreaInputProps> = (props) => {\n const {\n AfterInput,\n BeforeInput,\n className,\n Description,\n description,\n Error,\n Label,\n label,\n localized,\n onChange,\n path,\n placeholder,\n readOnly,\n required,\n rows,\n rtl,\n showError,\n style,\n value,\n } = props\n\n const { i18n } = useTranslation()\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'textarea',\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <label className=\"textarea-outer\" htmlFor={`field-${path.replace(/\\./g, '__')}`}>\n <
|
|
1
|
+
{"version":3,"file":"Input.js","names":["c","_c","getTranslation","React","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useTranslation","fieldBaseClass","TextareaInput","props","$","AfterInput","BeforeInput","className","Description","description","Error","Label","label","localized","onChange","path","placeholder","readOnly","required","rows","rtl","showError","style","value","i18n","t0","t1","t2","filter","Boolean","t3","join","t4","_jsxs","children","_jsx","CustomComponent","Fallback","htmlFor","replace","disabled","id","name"],"sources":["../../../src/fields/Textarea/Input.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport const TextareaInput: React.FC<TextAreaInputProps> = (props) => {\n const {\n AfterInput,\n BeforeInput,\n className,\n Description,\n description,\n Error,\n Label,\n label,\n localized,\n onChange,\n path,\n placeholder,\n readOnly,\n required,\n rows,\n rtl,\n showError,\n style,\n value,\n } = props\n\n const { i18n } = useTranslation()\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'textarea',\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <label className=\"textarea-outer\" htmlFor={`field-${path.replace(/\\./g, '__')}`}>\n <textarea\n data-rtl={rtl}\n disabled={readOnly}\n id={`field-${path.replace(/\\./g, '__')}`}\n name={path}\n onChange={onChange}\n placeholder={getTranslation(placeholder, i18n)}\n rows={rows}\n value={value || ''}\n />\n </label>\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,cAAc,QAAQ;AAC/B,OA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A,IAAS;UAAA,C;YAGnBlB,UAAA,EACD8B,IAAA,CAAAvC,qBAAA;UAAAwC,eAAA,EACmB5B,WAAA;UAAA6B,QAAA,EACPF,IAAA,CAAAtC,gBAAA;YAAAY,WAAA;YAAAM;UAAA,C;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAvChBiB,E;CA4CJ","ignoreList":[]}
|
|
@@ -6,20 +6,14 @@
|
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
textarea {
|
|
10
10
|
@include formInput();
|
|
11
|
-
|
|
11
|
+
field-sizing: content;
|
|
12
|
+
overflow-y: auto;
|
|
12
13
|
resize: vertical;
|
|
13
14
|
min-height: base(3);
|
|
14
15
|
height: 100%;
|
|
15
|
-
|
|
16
|
-
// Scrollbar for giant content
|
|
17
|
-
max-height: calc(100vh - $top-header-offset - calc(#{base(5)}));
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
|
|
20
|
-
@include mid-break {
|
|
21
|
-
max-height: 60vh;
|
|
22
|
-
}
|
|
16
|
+
display: flex;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
&.read-only {
|
|
@@ -28,78 +22,12 @@
|
|
|
28
22
|
}
|
|
29
23
|
}
|
|
30
24
|
|
|
31
|
-
// This element takes exactly the same dimensions as the clone
|
|
32
|
-
.textarea-inner {
|
|
33
|
-
display: block;
|
|
34
|
-
position: relative;
|
|
35
|
-
line-height: inherit;
|
|
36
|
-
flex-grow: 1;
|
|
37
|
-
background: none;
|
|
38
|
-
outline: none;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Unstyle the textarea, the border is rendered on .textarea-outer
|
|
42
|
-
.textarea-element {
|
|
43
|
-
position: relative;
|
|
44
|
-
z-index: 1;
|
|
45
|
-
width: 100%;
|
|
46
|
-
height: 100%;
|
|
47
|
-
border: inherit;
|
|
48
|
-
padding: inherit;
|
|
49
|
-
font: inherit;
|
|
50
|
-
line-height: inherit;
|
|
51
|
-
color: inherit;
|
|
52
|
-
background: none;
|
|
53
|
-
overflow: auto;
|
|
54
|
-
resize: none;
|
|
55
|
-
outline: none;
|
|
56
|
-
text-transform: inherit;
|
|
57
|
-
|
|
58
|
-
&::-webkit-scrollbar {
|
|
59
|
-
display: none;
|
|
60
|
-
}
|
|
61
|
-
&[data-rtl='true'] {
|
|
62
|
-
direction: rtl;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Clone of textarea with same height
|
|
67
|
-
.textarea-clone {
|
|
68
|
-
position: absolute;
|
|
69
|
-
top: 0;
|
|
70
|
-
left: 0;
|
|
71
|
-
right: 0;
|
|
72
|
-
bottom: 0;
|
|
73
|
-
pointer-events: none;
|
|
74
|
-
white-space: pre-wrap;
|
|
75
|
-
overflow-wrap: break-word;
|
|
76
|
-
visibility: hidden;
|
|
77
|
-
z-index: 0;
|
|
78
|
-
line-height: inherit;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.textarea-clone::before {
|
|
82
|
-
content: attr(data-value) ' ';
|
|
83
|
-
visibility: hidden;
|
|
84
|
-
opacity: 0;
|
|
85
|
-
white-space: pre-wrap;
|
|
86
|
-
overflow-wrap: break-word;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.textarea-clone::after {
|
|
90
|
-
content: attr(data-after);
|
|
91
|
-
opacity: 0.5;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
@include mid-break {
|
|
95
|
-
padding: 0;
|
|
96
|
-
}
|
|
97
25
|
}
|
|
98
26
|
|
|
99
27
|
html[data-theme='light'] {
|
|
100
28
|
.field-type.textarea {
|
|
101
29
|
&.error {
|
|
102
|
-
|
|
30
|
+
textarea {
|
|
103
31
|
@include lightInputError;
|
|
104
32
|
}
|
|
105
33
|
}
|
|
@@ -109,7 +37,7 @@
|
|
|
109
37
|
html[data-theme='dark'] {
|
|
110
38
|
.field-type.textarea {
|
|
111
39
|
&.error {
|
|
112
|
-
|
|
40
|
+
textarea {
|
|
113
41
|
@include darkInputError;
|
|
114
42
|
}
|
|
115
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldReducer.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/fieldReducer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,SAAS,EAAO,MAAM,SAAS,CAAA;AAMxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAO7C;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"fieldReducer.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/fieldReducer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,SAAS,EAAO,MAAM,SAAS,CAAA;AAMxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAO7C;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,CA2X7E"}
|
|
@@ -285,17 +285,33 @@ export function fieldReducer(state, action) {
|
|
|
285
285
|
// This is a performance enhancement for saving
|
|
286
286
|
// large documents with hundreds of fields
|
|
287
287
|
const newState = {};
|
|
288
|
-
Object.entries(action.state)
|
|
288
|
+
for (const [path, newField] of Object.entries(action.state)) {
|
|
289
289
|
const oldField = state[path];
|
|
290
|
-
|
|
290
|
+
if (newField.valid !== false) {
|
|
291
|
+
newField.valid = true;
|
|
292
|
+
}
|
|
293
|
+
if (newField.passesCondition !== false) {
|
|
294
|
+
newField.passesCondition = true;
|
|
295
|
+
}
|
|
291
296
|
if (!dequal(oldField, newField)) {
|
|
292
297
|
newState[path] = newField;
|
|
293
298
|
} else if (oldField) {
|
|
294
299
|
newState[path] = oldField;
|
|
295
300
|
}
|
|
296
|
-
}
|
|
301
|
+
}
|
|
297
302
|
return newState;
|
|
298
303
|
}
|
|
304
|
+
//TODO: Remove this in 4.0 - this is a temporary fix to prevent a breaking change
|
|
305
|
+
if (action.sanitize) {
|
|
306
|
+
for (const field of Object.values(action.state)) {
|
|
307
|
+
if (field.valid !== false) {
|
|
308
|
+
field.valid = true;
|
|
309
|
+
}
|
|
310
|
+
if (field.passesCondition !== false) {
|
|
311
|
+
field.passesCondition = true;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
299
315
|
// If we're not optimizing, just set the state to the new state
|
|
300
316
|
return action.state;
|
|
301
317
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldReducer.js","names":["ObjectIdImport","dequal","deepCopyObjectSimple","deepCopyObjectSimpleWithoutReactComponents","flattenRows","separateRows","ObjectId","default","fieldReducer","state","action","type","blockType","path","rowIndex","rowIndexFromArgs","subFieldState","rows","length","withNewRow","newRow","id","value","toHexString","undefined","collapsed","isLoading","splice","initialValue","valid","remainingFields","siblingRows","newState","passesCondition","requiresRender","disableFormData","errorPaths","errors","forEach","message","fieldPath","errorMessage","segments","split","push","fieldErrorPath","parentPath","slice","join","Object","entries","reduce","acc","fieldState","fieldErrorPaths","errorACC","startsWith","changed","newErrorPaths","Array","isArray","includes","rowsMetadata","duplicateRowMetadata","duplicateRowState","key","keys","filter","endsWith","idState","isValid","moveFromIndex","moveToIndex","copyOfMovingRow","rowStateCopy","movingRowState","rowIndexArg","Math","max","min","optimize","field","oldField","newField","updatedRows","formState"],"sources":["../../../src/forms/Form/fieldReducer.ts"],"sourcesContent":["'use client'\nimport type { FormField, FormState, Row } from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { deepCopyObjectSimple, deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\n\nimport type { FieldAction } from './types.js'\n\nimport { flattenRows, separateRows } from './rows.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\n/**\n * Reducer which modifies the form field state (all the current data of the fields in the form). When called using dispatch, it will return a new state object.\n */\nexport function fieldReducer(state: FormState, action: FieldAction): FormState {\n switch (action.type) {\n case 'ADD_ROW': {\n const { blockType, path, rowIndex: rowIndexFromArgs, subFieldState = {} } = action\n\n const rowIndex =\n typeof rowIndexFromArgs === 'number' ? rowIndexFromArgs : state[path]?.rows?.length || 0\n\n const withNewRow = [...(state[path]?.rows || [])]\n\n const newRow: Row = {\n id: (subFieldState?.id?.value as string) || new ObjectId().toHexString(),\n blockType: blockType || undefined,\n collapsed: false,\n isLoading: true,\n }\n\n withNewRow.splice(rowIndex, 0, newRow)\n\n if (blockType) {\n subFieldState.blockType = {\n initialValue: blockType,\n valid: true,\n value: blockType,\n }\n }\n\n // add new row to array _field state_\n const { remainingFields, rows: siblingRows } = separateRows(path, state)\n\n siblingRows.splice(rowIndex, 0, subFieldState)\n\n const newState: FormState = {\n ...remainingFields,\n ...flattenRows(path, siblingRows),\n [`${path}.${rowIndex}.id`]: {\n initialValue: newRow.id,\n passesCondition: true,\n requiresRender: true,\n valid: true,\n value: newRow.id,\n },\n [path]: {\n ...state[path],\n disableFormData: true,\n requiresRender: true,\n rows: withNewRow,\n value: siblingRows.length,\n },\n }\n\n return newState\n }\n\n case 'ADD_SERVER_ERRORS': {\n let newState = { ...state }\n\n const errorPaths: { fieldErrorPath: string; parentPath: string }[] = []\n\n action.errors.forEach(({ message, path: fieldPath }) => {\n newState[fieldPath] = {\n ...(newState[fieldPath] || {\n initialValue: null,\n value: null,\n }),\n errorMessage: message,\n valid: false,\n }\n\n const segments = fieldPath.split('.')\n if (segments.length > 1) {\n errorPaths.push({\n fieldErrorPath: fieldPath,\n parentPath: segments.slice(0, segments.length - 1).join('.'),\n })\n }\n })\n\n newState = Object.entries(newState).reduce((acc, [path, fieldState]) => {\n const fieldErrorPaths = errorPaths.reduce((errorACC, { fieldErrorPath, parentPath }) => {\n if (parentPath.startsWith(path)) {\n errorACC.push(fieldErrorPath)\n }\n return errorACC\n }, [])\n\n let changed = false\n\n if (fieldErrorPaths.length > 0) {\n const newErrorPaths = Array.isArray(fieldState.errorPaths) ? fieldState.errorPaths : []\n\n fieldErrorPaths.forEach((fieldErrorPath) => {\n if (!newErrorPaths.includes(fieldErrorPath)) {\n newErrorPaths.push(fieldErrorPath)\n changed = true\n }\n })\n\n if (changed) {\n acc[path] = {\n ...fieldState,\n errorPaths: newErrorPaths,\n }\n }\n }\n\n if (!changed) {\n acc[path] = fieldState\n }\n\n return acc\n }, {})\n\n return newState\n }\n\n case 'DUPLICATE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n const rowsMetadata = [...(state[path].rows || [])]\n\n const duplicateRowMetadata = deepCopyObjectSimple(rowsMetadata[rowIndex])\n if (duplicateRowMetadata.id) {\n duplicateRowMetadata.id = new ObjectId().toHexString()\n }\n\n const duplicateRowState = deepCopyObjectSimpleWithoutReactComponents(rows[rowIndex])\n if (duplicateRowState.id) {\n duplicateRowState.id.value = new ObjectId().toHexString()\n duplicateRowState.id.initialValue = new ObjectId().toHexString()\n }\n\n for (const key of Object.keys(duplicateRowState).filter((key) => key.endsWith('.id'))) {\n const idState = duplicateRowState[key]\n\n if (idState && typeof idState.value === 'string' && ObjectId.isValid(idState.value)) {\n duplicateRowState[key].value = new ObjectId().toHexString()\n duplicateRowState[key].initialValue = new ObjectId().toHexString()\n }\n }\n\n // If there are subfields\n if (Object.keys(duplicateRowState).length > 0) {\n // Add new object containing subfield names to unflattenedRows array\n rows.splice(rowIndex + 1, 0, duplicateRowState)\n rowsMetadata.splice(rowIndex + 1, 0, duplicateRowMetadata)\n }\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n disableFormData: true,\n requiresRender: true,\n rows: rowsMetadata,\n value: rows.length,\n },\n }\n\n return newState\n }\n\n case 'MOVE_ROW': {\n const { moveFromIndex, moveToIndex, path } = action\n const { remainingFields, rows } = separateRows(path, state)\n\n // copy the row to move\n const copyOfMovingRow = rows[moveFromIndex]\n // delete the row by index\n rows.splice(moveFromIndex, 1)\n // insert row copyOfMovingRow back in\n rows.splice(moveToIndex, 0, copyOfMovingRow)\n\n // modify array/block internal row state (i.e. collapsed, blockType)\n const rowStateCopy = [...(state[path]?.rows || [])]\n const movingRowState = { ...rowStateCopy[moveFromIndex] }\n rowStateCopy.splice(moveFromIndex, 1)\n rowStateCopy.splice(moveToIndex, 0, movingRowState)\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n requiresRender: true,\n rows: rowStateCopy,\n },\n }\n\n return newState\n }\n\n case 'REMOVE': {\n const newState = { ...state }\n if (newState[action.path]) {\n delete newState[action.path]\n }\n return newState\n }\n\n case 'REMOVE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n const rowsMetadata = [...(state[path]?.rows || [])]\n\n rows.splice(rowIndex, 1)\n rowsMetadata.splice(rowIndex, 1)\n\n const newState: FormState = {\n ...remainingFields,\n [path]: {\n ...state[path],\n disableFormData: rows.length > 0,\n requiresRender: true,\n rows: rowsMetadata,\n value: rows.length,\n },\n ...flattenRows(path, rows),\n }\n\n return newState\n }\n\n case 'REPLACE_ROW': {\n const { blockType, path, rowIndex: rowIndexArg, subFieldState = {} } = action\n\n const { remainingFields, rows: siblingRows } = separateRows(path, state)\n const rowIndex = Math.max(0, Math.min(rowIndexArg, siblingRows?.length - 1 || 0))\n\n const rowsMetadata = [...(state[path]?.rows || [])]\n rowsMetadata[rowIndex] = {\n id: new ObjectId().toHexString(),\n blockType: blockType || undefined,\n collapsed: false,\n }\n\n if (blockType) {\n subFieldState.blockType = {\n initialValue: blockType,\n valid: true,\n value: blockType,\n }\n }\n\n // replace form _field state_\n siblingRows[rowIndex] = subFieldState\n\n const newState: FormState = {\n ...remainingFields,\n ...flattenRows(path, siblingRows),\n [path]: {\n ...state[path],\n disableFormData: true,\n rows: rowsMetadata,\n value: siblingRows.length,\n },\n }\n\n return newState\n }\n\n case 'REPLACE_STATE': {\n if (action.optimize !== false) {\n // Only update fields that have changed\n // by comparing old value / initialValue to new\n // ..\n // This is a performance enhancement for saving\n // large documents with hundreds of fields\n const newState = {}\n\n Object.entries(action.state).forEach(([path, field]) => {\n const oldField = state[path]\n const newField = field\n\n if (!dequal(oldField, newField)) {\n newState[path] = newField\n } else if (oldField) {\n newState[path] = oldField\n }\n })\n return newState\n }\n // If we're not optimizing, just set the state to the new state\n return action.state\n }\n\n case 'SET_ALL_ROWS_COLLAPSED': {\n const { path, updatedRows } = action\n\n return {\n ...state,\n [path]: {\n ...state[path],\n rows: updatedRows,\n },\n }\n }\n\n case 'SET_ROW_COLLAPSED': {\n const { path, updatedRows } = action\n\n const newState = {\n ...state,\n [path]: {\n ...state[path],\n rows: updatedRows,\n },\n }\n\n return newState\n }\n\n case 'UPDATE': {\n const newField = Object.entries(action).reduce(\n (field, [key, value]) => {\n if (\n [\n 'disableFormData',\n 'errorMessage',\n 'initialValue',\n 'rows',\n 'valid',\n 'validate',\n 'value',\n ].includes(key)\n ) {\n return {\n ...field,\n [key]: value,\n }\n }\n\n return field\n },\n state[action.path] || ({} as FormField),\n )\n\n const newState = {\n ...state,\n [action.path]: newField,\n }\n\n return newState\n }\n\n case 'UPDATE_MANY': {\n const newState = { ...state }\n\n Object.entries(action.formState).forEach(([path, field]) => {\n newState[path] = field\n })\n\n return newState\n }\n\n default: {\n return state\n }\n }\n}\n"],"mappings":"AAAA;;AAGA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,MAAM,QAAQ,cAAa,CAAC;AACrC,SAASC,oBAAoB,EAAEC,0CAA0C,QAAQ;AAIjF,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAE1C,MAAMC,QAAA,GAAYN,cAAA,CAAeO,OAAO,IACtCP,cAAA;AAEF;;;AAGA,OAAO,SAASQ,aAAaC,KAAgB,EAAEC,MAAmB;EAChE,QAAQA,MAAA,CAAOC,IAAI;I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IAAA,CAAK;YACdI,IAAA,EAAMmE;UACR;QACF;QAEA,OAAOpD,QAAA;MACT;IAEA,KAAK;MAAU;QACb,MAAMmD,QAAA,GAAWlC,MAAA,CAAOC,OAAO,CAACxC,MAAA,EAAQyC,MAAM,CAC5C,CAAC8B,KAAA,EAAO,CAAChB,GAAA,EAAK3C,KAAA,CAAM;UAClB,IACE,CACE,mBACA,gBACA,gBACA,QACA,SACA,YACA,QACD,CAACuC,QAAQ,CAACI,GAAA,GACX;YACA,OAAO;cACL,GAAGgB,KAAK;cACR,CAAChB,GAAA,GAAM3C;YACT;UACF;UAEA,OAAO2D,KAAA;QACT,GACAxE,KAAK,CAACC,MAAA,CAAOG,IAAI,CAAC,IAAK,CAAC;QAG1B,MAAMmB,QAAA,GAAW;UACf,GAAGvB,KAAK;UACR,CAACC,MAAA,CAAOG,IAAI,GAAGsE;QACjB;QAEA,OAAOnD,QAAA;MACT;IAEA,KAAK;MAAe;QAClB,MAAMA,QAAA,GAAW;UAAE,GAAGvB;QAAM;QAE5BwC,MAAA,CAAOC,OAAO,CAACxC,MAAA,CAAO2E,SAAS,EAAE/C,OAAO,CAAC,CAAC,CAACzB,IAAA,EAAMoE,KAAA,CAAM;UACrDjD,QAAQ,CAACnB,IAAA,CAAK,GAAGoE,KAAA;QACnB;QAEA,OAAOjD,QAAA;MACT;IAEA;MAAS;QACP,OAAOvB,KAAA;MACT;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"fieldReducer.js","names":["ObjectIdImport","dequal","deepCopyObjectSimple","deepCopyObjectSimpleWithoutReactComponents","flattenRows","separateRows","ObjectId","default","fieldReducer","state","action","type","blockType","path","rowIndex","rowIndexFromArgs","subFieldState","rows","length","withNewRow","newRow","id","value","toHexString","undefined","collapsed","isLoading","splice","initialValue","valid","remainingFields","siblingRows","newState","passesCondition","requiresRender","disableFormData","errorPaths","errors","forEach","message","fieldPath","errorMessage","segments","split","push","fieldErrorPath","parentPath","slice","join","Object","entries","reduce","acc","fieldState","fieldErrorPaths","errorACC","startsWith","changed","newErrorPaths","Array","isArray","includes","rowsMetadata","duplicateRowMetadata","duplicateRowState","key","keys","filter","endsWith","idState","isValid","moveFromIndex","moveToIndex","copyOfMovingRow","rowStateCopy","movingRowState","rowIndexArg","Math","max","min","optimize","newField","oldField","sanitize","field","values","updatedRows","formState"],"sources":["../../../src/forms/Form/fieldReducer.ts"],"sourcesContent":["'use client'\nimport type { FormField, FormState, Row } from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { deepCopyObjectSimple, deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\n\nimport type { FieldAction } from './types.js'\n\nimport { flattenRows, separateRows } from './rows.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\n/**\n * Reducer which modifies the form field state (all the current data of the fields in the form). When called using dispatch, it will return a new state object.\n */\nexport function fieldReducer(state: FormState, action: FieldAction): FormState {\n switch (action.type) {\n case 'ADD_ROW': {\n const { blockType, path, rowIndex: rowIndexFromArgs, subFieldState = {} } = action\n\n const rowIndex =\n typeof rowIndexFromArgs === 'number' ? rowIndexFromArgs : state[path]?.rows?.length || 0\n\n const withNewRow = [...(state[path]?.rows || [])]\n\n const newRow: Row = {\n id: (subFieldState?.id?.value as string) || new ObjectId().toHexString(),\n blockType: blockType || undefined,\n collapsed: false,\n isLoading: true,\n }\n\n withNewRow.splice(rowIndex, 0, newRow)\n\n if (blockType) {\n subFieldState.blockType = {\n initialValue: blockType,\n valid: true,\n value: blockType,\n }\n }\n\n // add new row to array _field state_\n const { remainingFields, rows: siblingRows } = separateRows(path, state)\n\n siblingRows.splice(rowIndex, 0, subFieldState)\n\n const newState: FormState = {\n ...remainingFields,\n ...flattenRows(path, siblingRows),\n [`${path}.${rowIndex}.id`]: {\n initialValue: newRow.id,\n passesCondition: true,\n requiresRender: true,\n valid: true,\n value: newRow.id,\n },\n [path]: {\n ...state[path],\n disableFormData: true,\n requiresRender: true,\n rows: withNewRow,\n value: siblingRows.length,\n },\n }\n\n return newState\n }\n\n case 'ADD_SERVER_ERRORS': {\n let newState = { ...state }\n\n const errorPaths: { fieldErrorPath: string; parentPath: string }[] = []\n\n action.errors.forEach(({ message, path: fieldPath }) => {\n newState[fieldPath] = {\n ...(newState[fieldPath] || {\n initialValue: null,\n value: null,\n }),\n errorMessage: message,\n valid: false,\n }\n\n const segments = fieldPath.split('.')\n if (segments.length > 1) {\n errorPaths.push({\n fieldErrorPath: fieldPath,\n parentPath: segments.slice(0, segments.length - 1).join('.'),\n })\n }\n })\n\n newState = Object.entries(newState).reduce((acc, [path, fieldState]) => {\n const fieldErrorPaths = errorPaths.reduce((errorACC, { fieldErrorPath, parentPath }) => {\n if (parentPath.startsWith(path)) {\n errorACC.push(fieldErrorPath)\n }\n return errorACC\n }, [])\n\n let changed = false\n\n if (fieldErrorPaths.length > 0) {\n const newErrorPaths = Array.isArray(fieldState.errorPaths) ? fieldState.errorPaths : []\n\n fieldErrorPaths.forEach((fieldErrorPath) => {\n if (!newErrorPaths.includes(fieldErrorPath)) {\n newErrorPaths.push(fieldErrorPath)\n changed = true\n }\n })\n\n if (changed) {\n acc[path] = {\n ...fieldState,\n errorPaths: newErrorPaths,\n }\n }\n }\n\n if (!changed) {\n acc[path] = fieldState\n }\n\n return acc\n }, {})\n\n return newState\n }\n\n case 'DUPLICATE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n const rowsMetadata = [...(state[path].rows || [])]\n\n const duplicateRowMetadata = deepCopyObjectSimple(rowsMetadata[rowIndex])\n if (duplicateRowMetadata.id) {\n duplicateRowMetadata.id = new ObjectId().toHexString()\n }\n\n const duplicateRowState = deepCopyObjectSimpleWithoutReactComponents(rows[rowIndex])\n if (duplicateRowState.id) {\n duplicateRowState.id.value = new ObjectId().toHexString()\n duplicateRowState.id.initialValue = new ObjectId().toHexString()\n }\n\n for (const key of Object.keys(duplicateRowState).filter((key) => key.endsWith('.id'))) {\n const idState = duplicateRowState[key]\n\n if (idState && typeof idState.value === 'string' && ObjectId.isValid(idState.value)) {\n duplicateRowState[key].value = new ObjectId().toHexString()\n duplicateRowState[key].initialValue = new ObjectId().toHexString()\n }\n }\n\n // If there are subfields\n if (Object.keys(duplicateRowState).length > 0) {\n // Add new object containing subfield names to unflattenedRows array\n rows.splice(rowIndex + 1, 0, duplicateRowState)\n rowsMetadata.splice(rowIndex + 1, 0, duplicateRowMetadata)\n }\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n disableFormData: true,\n requiresRender: true,\n rows: rowsMetadata,\n value: rows.length,\n },\n }\n\n return newState\n }\n\n case 'MOVE_ROW': {\n const { moveFromIndex, moveToIndex, path } = action\n const { remainingFields, rows } = separateRows(path, state)\n\n // copy the row to move\n const copyOfMovingRow = rows[moveFromIndex]\n // delete the row by index\n rows.splice(moveFromIndex, 1)\n // insert row copyOfMovingRow back in\n rows.splice(moveToIndex, 0, copyOfMovingRow)\n\n // modify array/block internal row state (i.e. collapsed, blockType)\n const rowStateCopy = [...(state[path]?.rows || [])]\n const movingRowState = { ...rowStateCopy[moveFromIndex] }\n rowStateCopy.splice(moveFromIndex, 1)\n rowStateCopy.splice(moveToIndex, 0, movingRowState)\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n requiresRender: true,\n rows: rowStateCopy,\n },\n }\n\n return newState\n }\n\n case 'REMOVE': {\n const newState = { ...state }\n if (newState[action.path]) {\n delete newState[action.path]\n }\n return newState\n }\n\n case 'REMOVE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n const rowsMetadata = [...(state[path]?.rows || [])]\n\n rows.splice(rowIndex, 1)\n rowsMetadata.splice(rowIndex, 1)\n\n const newState: FormState = {\n ...remainingFields,\n [path]: {\n ...state[path],\n disableFormData: rows.length > 0,\n requiresRender: true,\n rows: rowsMetadata,\n value: rows.length,\n },\n ...flattenRows(path, rows),\n }\n\n return newState\n }\n\n case 'REPLACE_ROW': {\n const { blockType, path, rowIndex: rowIndexArg, subFieldState = {} } = action\n\n const { remainingFields, rows: siblingRows } = separateRows(path, state)\n const rowIndex = Math.max(0, Math.min(rowIndexArg, siblingRows?.length - 1 || 0))\n\n const rowsMetadata = [...(state[path]?.rows || [])]\n rowsMetadata[rowIndex] = {\n id: new ObjectId().toHexString(),\n blockType: blockType || undefined,\n collapsed: false,\n }\n\n if (blockType) {\n subFieldState.blockType = {\n initialValue: blockType,\n valid: true,\n value: blockType,\n }\n }\n\n // replace form _field state_\n siblingRows[rowIndex] = subFieldState\n\n const newState: FormState = {\n ...remainingFields,\n ...flattenRows(path, siblingRows),\n [path]: {\n ...state[path],\n disableFormData: true,\n rows: rowsMetadata,\n value: siblingRows.length,\n },\n }\n\n return newState\n }\n\n case 'REPLACE_STATE': {\n if (action.optimize !== false) {\n // Only update fields that have changed\n // by comparing old value / initialValue to new\n // ..\n // This is a performance enhancement for saving\n // large documents with hundreds of fields\n const newState: FormState = {}\n\n for (const [path, newField] of Object.entries(action.state)) {\n const oldField = state[path]\n\n if (newField.valid !== false) {\n newField.valid = true\n }\n if (newField.passesCondition !== false) {\n newField.passesCondition = true\n }\n\n if (!dequal(oldField, newField)) {\n newState[path] = newField\n } else if (oldField) {\n newState[path] = oldField\n }\n }\n\n return newState\n }\n\n //TODO: Remove this in 4.0 - this is a temporary fix to prevent a breaking change\n if (action.sanitize) {\n for (const field of Object.values(action.state)) {\n if (field.valid !== false) {\n field.valid = true\n }\n if (field.passesCondition !== false) {\n field.passesCondition = true\n }\n }\n }\n // If we're not optimizing, just set the state to the new state\n return action.state\n }\n\n case 'SET_ALL_ROWS_COLLAPSED': {\n const { path, updatedRows } = action\n\n return {\n ...state,\n [path]: {\n ...state[path],\n rows: updatedRows,\n },\n }\n }\n\n case 'SET_ROW_COLLAPSED': {\n const { path, updatedRows } = action\n\n const newState = {\n ...state,\n [path]: {\n ...state[path],\n rows: updatedRows,\n },\n }\n\n return newState\n }\n\n case 'UPDATE': {\n const newField = Object.entries(action).reduce(\n (field, [key, value]) => {\n if (\n [\n 'disableFormData',\n 'errorMessage',\n 'initialValue',\n 'rows',\n 'valid',\n 'validate',\n 'value',\n ].includes(key)\n ) {\n return {\n ...field,\n [key]: value,\n }\n }\n\n return field\n },\n state[action.path] || ({} as FormField),\n )\n\n const newState = {\n ...state,\n [action.path]: newField,\n }\n\n return newState\n }\n\n case 'UPDATE_MANY': {\n const newState = { ...state }\n\n Object.entries(action.formState).forEach(([path, field]) => {\n newState[path] = field\n })\n\n return newState\n }\n\n default: {\n return state\n }\n }\n}\n"],"mappings":"AAAA;;AAGA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,MAAM,QAAQ,cAAa,CAAC;AACrC,SAASC,oBAAoB,EAAEC,0CAA0C,QAAQ;AAIjF,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAE1C,MAAMC,QAAA,GAAYN,cAAA,CAAeO,OAAO,IACtCP,cAAA;AAEF;;;AAGA,OAAO,SAASQ,aAAaC,KAAgB,EAAEC,MAAmB;EAChE,QAAQA,MAAA,CAAOC,IAAI;IACjB,KAAK;MAAW;QACd,MAAM;UAAEC,SAAS;UAAEC,IAAI;UAAEC,QAAA,EAAUC,gBAAgB;UAAEC,aAAA,GAAgB,CAAC;QAAC,CAAE,GAAGN,MAAA;QAE5E,MAAMI,QAAA,GACJ,OAAOC,gBAAA,KAAqB,WAAWA,gBAAA,GAAmBN,KAAK,CAACI,IAAA,CAAK,EAAEI,IAAA,EAAMC,MAAA,IAAU;QAEzF,MAAMC,UAAA,GAAa,C,IAAKV,KAAK,CAACI,IAAA,CAAK,EAAEI,IAAA,IAAQ,EAAE,EAAE;QAEjD,MAAMG,MAAA,GAAc;UAClBC,EAAA,EAAIL,aAAC,EAAeK,EAAA,EAAIC,KAAA,IAAoB,IAAIhB,QAAA,GAAWiB,WAAW;UACtEX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I,IAAA,EAAMqE;UACR;QACF;QAEA,OAAOtD,QAAA;MACT;IAEA,KAAK;MAAU;QACb,MAAMiD,QAAA,GAAWhC,MAAA,CAAOC,OAAO,CAACxC,MAAA,EAAQyC,MAAM,CAC5C,CAACiC,KAAA,EAAO,CAACnB,GAAA,EAAK3C,KAAA,CAAM;UAClB,IACE,CACE,mBACA,gBACA,gBACA,QACA,SACA,YACA,QACD,CAACuC,QAAQ,CAACI,GAAA,GACX;YACA,OAAO;cACL,GAAGmB,KAAK;cACR,CAACnB,GAAA,GAAM3C;YACT;UACF;UAEA,OAAO8D,KAAA;QACT,GACA3E,KAAK,CAACC,MAAA,CAAOG,IAAI,CAAC,IAAK,CAAC;QAG1B,MAAMmB,QAAA,GAAW;UACf,GAAGvB,KAAK;UACR,CAACC,MAAA,CAAOG,IAAI,GAAGoE;QACjB;QAEA,OAAOjD,QAAA;MACT;IAEA,KAAK;MAAe;QAClB,MAAMA,QAAA,GAAW;UAAE,GAAGvB;QAAM;QAE5BwC,MAAA,CAAOC,OAAO,CAACxC,MAAA,CAAO6E,SAAS,EAAEjD,OAAO,CAAC,CAAC,CAACzB,IAAA,EAAMuE,KAAA,CAAM;UACrDpD,QAAQ,CAACnB,IAAA,CAAK,GAAGuE,KAAA;QACnB;QAEA,OAAOpD,QAAA;MACT;IAEA;MAAS;QACP,OAAOvB,KAAA;MACT;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAA+D,MAAM,OAAO,CAAA;AAGnF,OAAO,KAAK,EAGV,SAAS,EAGV,MAAM,YAAY,CAAA;AA6BnB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAA+D,MAAM,OAAO,CAAA;AAGnF,OAAO,KAAK,EAGV,SAAS,EAGV,MAAM,YAAY,CAAA;AA6BnB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAwrBpC,CAAA;AAED,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,SAAS,EAAE,CAAA"}
|