@payloadcms/ui 4.0.0-internal.6e89a16 → 4.0.0-internal.71538a3
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/ClipboardAction/mergeFormStateFromClipboard.d.ts.map +1 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js +2 -0
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js.map +1 -1
- package/dist/elements/DocumentCard/index.css +1 -1
- package/dist/elements/FileDetails/FileMeta/index.d.ts +1 -1
- package/dist/elements/FileDetails/FileMeta/index.d.ts.map +1 -1
- package/dist/elements/FileDetails/FileMeta/index.js +7 -8
- package/dist/elements/FileDetails/FileMeta/index.js.map +1 -1
- package/dist/elements/FileManager/FilePreview/index.d.ts.map +1 -1
- package/dist/elements/FileManager/FilePreview/index.js +12 -14
- package/dist/elements/FileManager/FilePreview/index.js.map +1 -1
- package/dist/elements/FileManager/index.d.ts.map +1 -1
- package/dist/elements/FileManager/index.js +2 -7
- package/dist/elements/FileManager/index.js.map +1 -1
- package/dist/elements/Table/index.d.ts +2 -0
- package/dist/elements/Table/index.d.ts.map +1 -1
- package/dist/elements/Table/index.js +3 -2
- package/dist/elements/Table/index.js.map +1 -1
- package/dist/elements/Thumbnail/index.d.ts +1 -0
- package/dist/elements/Thumbnail/index.d.ts.map +1 -1
- package/dist/elements/Thumbnail/index.js +2 -1
- package/dist/elements/Thumbnail/index.js.map +1 -1
- package/dist/elements/Upload/index.d.ts.map +1 -1
- package/dist/elements/Upload/index.js +2 -7
- package/dist/elements/Upload/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +27 -27
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/rsc/index.d.ts +1 -0
- package/dist/exports/rsc/index.d.ts.map +1 -1
- package/dist/exports/rsc/index.js +1 -0
- package/dist/exports/rsc/index.js.map +1 -1
- package/dist/forms/Form/fieldReducer.d.ts.map +1 -1
- package/dist/forms/Form/fieldReducer.js +4 -0
- package/dist/forms/Form/fieldReducer.js.map +1 -1
- package/dist/forms/Form/mergeServerFormState.d.ts.map +1 -1
- package/dist/forms/Form/mergeServerFormState.js +6 -7
- package/dist/forms/Form/mergeServerFormState.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +3 -6
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/useField/index.d.ts.map +1 -1
- package/dist/forms/useField/index.js +44 -48
- package/dist/forms/useField/index.js.map +1 -1
- package/dist/forms/useField/types.d.ts +0 -5
- package/dist/forms/useField/types.d.ts.map +1 -1
- package/dist/forms/useField/types.js.map +1 -1
- package/dist/graphics/DocumentPlaceholder/index.d.ts +8 -0
- package/dist/graphics/DocumentPlaceholder/index.d.ts.map +1 -0
- package/dist/graphics/DocumentPlaceholder/index.js +1079 -0
- package/dist/graphics/DocumentPlaceholder/index.js.map +1 -0
- package/dist/icons/Upload/index.d.ts +5 -0
- package/dist/icons/Upload/index.d.ts.map +1 -0
- package/dist/icons/Upload/index.js +21 -0
- package/dist/icons/Upload/index.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/utilities/reduceFieldsToValuesWithValidation.d.ts +1 -1
- package/dist/utilities/reduceFieldsToValuesWithValidation.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValuesWithValidation.js +7 -3
- package/dist/utilities/reduceFieldsToValuesWithValidation.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.js +1 -0
- package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js +1 -0
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +1 -0
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts +2 -0
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +2 -0
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js +27 -5
- package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js.map +1 -1
- package/dist/views/List/index.client.js +1 -1
- package/dist/views/List/index.client.js.map +1 -1
- package/dist/widgets/CollectionPreview/getColumnCount.d.ts +8 -0
- package/dist/widgets/CollectionPreview/getColumnCount.d.ts.map +1 -0
- package/dist/widgets/CollectionPreview/getColumnCount.js +9 -0
- package/dist/widgets/CollectionPreview/getColumnCount.js.map +1 -0
- package/dist/widgets/CollectionPreview/getPreviewThumbnailURLs.d.ts +8 -0
- package/dist/widgets/CollectionPreview/getPreviewThumbnailURLs.d.ts.map +1 -0
- package/dist/widgets/CollectionPreview/getPreviewThumbnailURLs.js +83 -0
- package/dist/widgets/CollectionPreview/getPreviewThumbnailURLs.js.map +1 -0
- package/dist/widgets/CollectionPreview/hasDraggedFiles.d.ts +9 -0
- package/dist/widgets/CollectionPreview/hasDraggedFiles.d.ts.map +1 -0
- package/dist/widgets/CollectionPreview/hasDraggedFiles.js +8 -0
- package/dist/widgets/CollectionPreview/hasDraggedFiles.js.map +1 -0
- package/dist/widgets/CollectionPreview/index.client.d.ts +5 -0
- package/dist/widgets/CollectionPreview/index.client.d.ts.map +1 -0
- package/dist/widgets/CollectionPreview/index.client.js +314 -0
- package/dist/widgets/CollectionPreview/index.client.js.map +1 -0
- package/dist/widgets/CollectionPreview/index.css +333 -0
- package/dist/widgets/CollectionPreview/index.d.ts +10 -0
- package/dist/widgets/CollectionPreview/index.d.ts.map +1 -0
- package/dist/widgets/CollectionPreview/index.js +183 -0
- package/dist/widgets/CollectionPreview/index.js.map +1 -0
- package/dist/widgets/CollectionPreview/preferences.d.ts +12 -0
- package/dist/widgets/CollectionPreview/preferences.d.ts.map +1 -0
- package/dist/widgets/CollectionPreview/preferences.js +16 -0
- package/dist/widgets/CollectionPreview/preferences.js.map +1 -0
- package/dist/widgets/CollectionPreview/renderTable.d.ts +14 -0
- package/dist/widgets/CollectionPreview/renderTable.d.ts.map +1 -0
- package/dist/widgets/CollectionPreview/renderTable.js +160 -0
- package/dist/widgets/CollectionPreview/renderTable.js.map +1 -0
- package/dist/widgets/CollectionPreview/types.d.ts +28 -0
- package/dist/widgets/CollectionPreview/types.d.ts.map +1 -0
- package/dist/widgets/CollectionPreview/types.js +2 -0
- package/dist/widgets/CollectionPreview/types.js.map +1 -0
- package/package.json +4 -4
- package/dist/elements/Upload/getInitialCrop.d.ts +0 -26
- package/dist/elements/Upload/getInitialCrop.d.ts.map +0 -1
- package/dist/elements/Upload/getInitialCrop.js +0 -30
- package/dist/elements/Upload/getInitialCrop.js.map +0 -1
|
@@ -29,6 +29,7 @@ export { resolveFilterOptions } from '../../utilities/resolveFilterOptions.js';
|
|
|
29
29
|
export { upsertPreferences } from '../../utilities/upsertPreferences.js';
|
|
30
30
|
export { ActivityWidget } from '../../widgets/Activity/index.js';
|
|
31
31
|
export { CollectionCards } from '../../widgets/CollectionCards/index.js';
|
|
32
|
+
export { CollectionPreviewWidget } from '../../widgets/CollectionPreview/index.js';
|
|
32
33
|
export { CollectionQueryWidget } from '../../widgets/CollectionQuery/index.js';
|
|
33
34
|
export { UploadDropzoneWidget } from '../../widgets/UploadDropzone/index.js';
|
|
34
35
|
export { WelcomeWidget } from '../../widgets/Welcome/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/rsc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAA;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAA;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6DAA6D,CAAA;AACvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAA;AAC5F,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAA;AACtF,YAAY,EACV,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,qDAAqD,CAAA;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,4EAA4E,CAAA;AACzH,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAA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AAA;AACjG,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAA;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -28,6 +28,7 @@ export { resolveFilterOptions } from '../../utilities/resolveFilterOptions.js';
|
|
|
28
28
|
export { upsertPreferences } from '../../utilities/upsertPreferences.js';
|
|
29
29
|
export { ActivityWidget } from '../../widgets/Activity/index.js';
|
|
30
30
|
export { CollectionCards } from '../../widgets/CollectionCards/index.js';
|
|
31
|
+
export { CollectionPreviewWidget } from '../../widgets/CollectionPreview/index.js';
|
|
31
32
|
export { CollectionQueryWidget } from '../../widgets/CollectionQuery/index.js';
|
|
32
33
|
export { UploadDropzoneWidget } from '../../widgets/UploadDropzone/index.js';
|
|
33
34
|
export { WelcomeWidget } from '../../widgets/Welcome/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DocumentHeader","FieldDiffContainer","FieldDiffLabel","FormHeader","HierarchyButton","HierarchyField","HierarchySidebarTabServer","HierarchyTypeFieldServer","escapeDiffHTML","getHTMLDiffComponents","unescapeDiffHTML","LLMInstructionsCell","Logo","getNavPrefs","DefaultNav","renderTabHandler","_internal_renderFieldHandler","File","CheckIcon","DefaultTemplate","MinimalTemplate","copyDataFromLocaleHandler","getColumns","getPreferences","handleLivePreview","handlePreview","addRecentlyViewedItem","recentlyViewedMaxItems","renderFilters","renderTable","resolveFilterOptions","upsertPreferences","ActivityWidget","CollectionCards","CollectionQueryWidget","UploadDropzoneWidget","WelcomeWidget"],"sources":["../../../src/exports/rsc/index.ts"],"sourcesContent":["export { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nexport { FieldDiffContainer } from '../../elements/FieldDiffContainer/index.js'\nexport { FieldDiffLabel } from '../../elements/FieldDiffLabel/index.js'\nexport { FormHeader } from '../../elements/FormHeader/index.js'\nexport { HierarchyButton } from '../../elements/Hierarchy/DocHeaderButton/index.server.js'\nexport { HierarchyField } from '../../elements/Hierarchy/Field/index.server.js'\nexport { HierarchySidebarTabServer } from '../../elements/Hierarchy/Tree/HierarchySidebarTab.server.js'\nexport { HierarchyTypeFieldServer } from '../../elements/HierarchyTypeField/index.server.js'\nexport {\n escapeDiffHTML,\n getHTMLDiffComponents,\n unescapeDiffHTML,\n} from '../../elements/HTMLDiff/index.js'\nexport { LLMInstructionsCell } from '../../elements/LLMInstructionsCell/index.js'\nexport { Logo } from '../../elements/Logo/index.js'\nexport { getNavPrefs } from '../../elements/Nav/getNavPrefs.js'\nexport { DefaultNav, type NavProps } from '../../elements/Nav/index.js'\nexport { renderTabHandler } from '../../elements/Nav/SidebarTabs/renderTabServerFn.js'\nexport type {\n RenderTabServerFnArgs,\n RenderTabServerFnReturnType,\n} from '../../elements/Nav/SidebarTabs/renderTabServerFn.js'\nexport { _internal_renderFieldHandler } from '../../forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js'\nexport { File } from '../../graphics/File/index.js'\nexport { CheckIcon } from '../../icons/Check/index.js'\nexport { DefaultTemplate, type DefaultTemplateProps } from '../../templates/Default/index.js'\nexport { MinimalTemplate, type MinimalTemplateProps } from '../../templates/Minimal/index.js'\nexport { copyDataFromLocaleHandler } from '../../utilities/copyDataFromLocale.js'\nexport { getColumns } from '../../utilities/getColumns.js'\nexport { getPreferences } from '../../utilities/getPreferences.js'\nexport { handleLivePreview } from '../../utilities/handleLivePreview.js'\nexport { handlePreview } from '../../utilities/handlePreview.js'\nexport { addRecentlyViewedItem, recentlyViewedMaxItems } from '../../utilities/recentlyViewed.js'\nexport { renderFilters, renderTable } from '../../utilities/renderTable.js'\nexport { resolveFilterOptions } from '../../utilities/resolveFilterOptions.js'\nexport { upsertPreferences } from '../../utilities/upsertPreferences.js'\nexport { ActivityWidget } from '../../widgets/Activity/index.js'\nexport { CollectionCards } from '../../widgets/CollectionCards/index.js'\nexport { CollectionQueryWidget } from '../../widgets/CollectionQuery/index.js'\nexport { UploadDropzoneWidget } from '../../widgets/UploadDropzone/index.js'\nexport { WelcomeWidget } from '../../widgets/Welcome/index.js'\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,QAAQ;AACzC,SACEC,cAAc,EACdC,qBAAqB,EACrBC,gBAAgB,QACX;AACP,SAASC,mBAAmB,QAAQ;AACpC,SAASC,IAAI,QAAQ;AACrB,SAASC,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAuB;AAC1C,SAASC,gBAAgB,QAAQ;AAKjC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,IAAI,QAAQ;AACrB,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAmC;AAC3D,SAASC,eAAe,QAAmC;AAC3D,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,aAAa,QAAQ;AAC9B,SAASC,qBAAqB,EAAEC,sBAAsB,QAAQ;AAC9D,SAASC,aAAa,EAAEC,WAAW,QAAQ;AAC3C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DocumentHeader","FieldDiffContainer","FieldDiffLabel","FormHeader","HierarchyButton","HierarchyField","HierarchySidebarTabServer","HierarchyTypeFieldServer","escapeDiffHTML","getHTMLDiffComponents","unescapeDiffHTML","LLMInstructionsCell","Logo","getNavPrefs","DefaultNav","renderTabHandler","_internal_renderFieldHandler","File","CheckIcon","DefaultTemplate","MinimalTemplate","copyDataFromLocaleHandler","getColumns","getPreferences","handleLivePreview","handlePreview","addRecentlyViewedItem","recentlyViewedMaxItems","renderFilters","renderTable","resolveFilterOptions","upsertPreferences","ActivityWidget","CollectionCards","CollectionPreviewWidget","CollectionQueryWidget","UploadDropzoneWidget","WelcomeWidget"],"sources":["../../../src/exports/rsc/index.ts"],"sourcesContent":["export { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nexport { FieldDiffContainer } from '../../elements/FieldDiffContainer/index.js'\nexport { FieldDiffLabel } from '../../elements/FieldDiffLabel/index.js'\nexport { FormHeader } from '../../elements/FormHeader/index.js'\nexport { HierarchyButton } from '../../elements/Hierarchy/DocHeaderButton/index.server.js'\nexport { HierarchyField } from '../../elements/Hierarchy/Field/index.server.js'\nexport { HierarchySidebarTabServer } from '../../elements/Hierarchy/Tree/HierarchySidebarTab.server.js'\nexport { HierarchyTypeFieldServer } from '../../elements/HierarchyTypeField/index.server.js'\nexport {\n escapeDiffHTML,\n getHTMLDiffComponents,\n unescapeDiffHTML,\n} from '../../elements/HTMLDiff/index.js'\nexport { LLMInstructionsCell } from '../../elements/LLMInstructionsCell/index.js'\nexport { Logo } from '../../elements/Logo/index.js'\nexport { getNavPrefs } from '../../elements/Nav/getNavPrefs.js'\nexport { DefaultNav, type NavProps } from '../../elements/Nav/index.js'\nexport { renderTabHandler } from '../../elements/Nav/SidebarTabs/renderTabServerFn.js'\nexport type {\n RenderTabServerFnArgs,\n RenderTabServerFnReturnType,\n} from '../../elements/Nav/SidebarTabs/renderTabServerFn.js'\nexport { _internal_renderFieldHandler } from '../../forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js'\nexport { File } from '../../graphics/File/index.js'\nexport { CheckIcon } from '../../icons/Check/index.js'\nexport { DefaultTemplate, type DefaultTemplateProps } from '../../templates/Default/index.js'\nexport { MinimalTemplate, type MinimalTemplateProps } from '../../templates/Minimal/index.js'\nexport { copyDataFromLocaleHandler } from '../../utilities/copyDataFromLocale.js'\nexport { getColumns } from '../../utilities/getColumns.js'\nexport { getPreferences } from '../../utilities/getPreferences.js'\nexport { handleLivePreview } from '../../utilities/handleLivePreview.js'\nexport { handlePreview } from '../../utilities/handlePreview.js'\nexport { addRecentlyViewedItem, recentlyViewedMaxItems } from '../../utilities/recentlyViewed.js'\nexport { renderFilters, renderTable } from '../../utilities/renderTable.js'\nexport { resolveFilterOptions } from '../../utilities/resolveFilterOptions.js'\nexport { upsertPreferences } from '../../utilities/upsertPreferences.js'\nexport { ActivityWidget } from '../../widgets/Activity/index.js'\nexport { CollectionCards } from '../../widgets/CollectionCards/index.js'\nexport { CollectionPreviewWidget } from '../../widgets/CollectionPreview/index.js'\nexport { CollectionQueryWidget } from '../../widgets/CollectionQuery/index.js'\nexport { UploadDropzoneWidget } from '../../widgets/UploadDropzone/index.js'\nexport { WelcomeWidget } from '../../widgets/Welcome/index.js'\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,QAAQ;AACzC,SACEC,cAAc,EACdC,qBAAqB,EACrBC,gBAAgB,QACX;AACP,SAASC,mBAAmB,QAAQ;AACpC,SAASC,IAAI,QAAQ;AACrB,SAASC,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAuB;AAC1C,SAASC,gBAAgB,QAAQ;AAKjC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,IAAI,QAAQ;AACrB,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAmC;AAC3D,SAASC,eAAe,QAAmC;AAC3D,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,aAAa,QAAQ;AAC9B,SAASC,qBAAqB,EAAEC,sBAAsB,QAAQ;AAC9D,SAASC,aAAa,EAAEC,WAAW,QAAQ;AAC3C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ","ignoreList":[]}
|
|
@@ -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,CAqb7E"}
|
|
@@ -53,6 +53,7 @@ export function fieldReducer(state, action) {
|
|
|
53
53
|
},
|
|
54
54
|
[path]: {
|
|
55
55
|
...state[path],
|
|
56
|
+
disableFormData: true,
|
|
56
57
|
rows: withNewRow,
|
|
57
58
|
value: siblingRows.length
|
|
58
59
|
}
|
|
@@ -187,6 +188,7 @@ export function fieldReducer(state, action) {
|
|
|
187
188
|
...flattenRows(path, rows),
|
|
188
189
|
[path]: {
|
|
189
190
|
...state[path],
|
|
191
|
+
disableFormData: true,
|
|
190
192
|
rows: newRows,
|
|
191
193
|
value: rows.length
|
|
192
194
|
}
|
|
@@ -269,6 +271,7 @@ export function fieldReducer(state, action) {
|
|
|
269
271
|
...remainingFields,
|
|
270
272
|
[path]: {
|
|
271
273
|
...state[path],
|
|
274
|
+
disableFormData: rows.length > 0,
|
|
272
275
|
rows: rowsMetadata,
|
|
273
276
|
value: rows.length
|
|
274
277
|
},
|
|
@@ -309,6 +312,7 @@ export function fieldReducer(state, action) {
|
|
|
309
312
|
...flattenRows(path, siblingRows),
|
|
310
313
|
[path]: {
|
|
311
314
|
...state[path],
|
|
315
|
+
disableFormData: true,
|
|
312
316
|
rows: rowsMetadata,
|
|
313
317
|
value: siblingRows.length
|
|
314
318
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldReducer.js","names":["ObjectIdImport","dequal","deepCopyObjectSimpleWithoutReactComponents","mergeServerFormState","flattenRows","separateRows","ObjectId","default","fieldReducer","state","action","type","blockType","path","rowIndex","rowIndexFromArgs","subFieldState","rows","length","withNewRow","newRow","id","value","toHexString","isLoading","splice","initialValue","valid","remainingFields","siblingRows","newState","passesCondition","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","newRows","newRowID","customComponents","RowLabel","newRowState","key","keys","filter","endsWith","idState","newNestedFieldID","isValid","parseInt","parentFieldPath","parentFieldRows","acceptValues","prevStateRef","serverState","currentState","incomingState","current","moveFromIndex","moveToIndex","topLevelRows","copyOfMovingRow","rowsWithinField","copyOfMovingRow2","rowsMetadata","rowIndexArg","Math","max","min","undefined","collapsed","optimize","newField","oldField","field","values","updatedRows","isModified","_","fieldWithoutIsModified","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 { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\n\nimport type { FieldAction } from './types.js'\n\nimport { mergeServerFormState } from './mergeServerFormState.js'\nimport { flattenRows, separateRows } from './rows.js'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\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 isLoading: true,\n }\n\n if (blockType) {\n newRow.blockType = blockType\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 valid: true,\n value: newRow.id,\n },\n [path]: {\n ...state[path],\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 /**\n * Duplicates a row in an array or blocks field.\n * It needs to manipulate two distinct parts of the form state:\n * - The `rows` property of the parent field, e.g. `array.rows`, `blocks.rows`, etc.\n * - The row's state, e.g. `array.0.id`, `array.0.text`, etc.\n */\n case 'DUPLICATE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n\n // 1. Duplicate the `rows` property of the parent field, e.g. `array.rows`, `blocks.rows`, etc.\n const newRows = [...(state[path].rows || [])]\n\n const newRow = deepCopyObjectSimpleWithoutReactComponents(newRows[rowIndex])\n\n const newRowID = new ObjectId().toHexString()\n\n if (newRow.id) {\n newRow.id = newRowID\n }\n\n if (newRows[rowIndex]?.customComponents?.RowLabel) {\n newRow.customComponents = {\n RowLabel: newRows[rowIndex].customComponents.RowLabel,\n }\n }\n\n // 2. Duplicate the row's state, e.g. `array.0.id`, `array.0.text`, etc.\n const newRowState = deepCopyObjectSimpleWithoutReactComponents(rows[rowIndex])\n\n // Ensure that `id` in form state exactly matches the row id on the parent field\n if (newRowState.id) {\n newRowState.id.value = newRowID\n newRowState.id.initialValue = newRowID\n }\n\n // Generate new ids for all nested id fields, e.g. `array.0.nestedArray.0.id`\n for (const key of Object.keys(newRowState).filter((key) => key.endsWith('.id'))) {\n const idState = newRowState[key]\n\n const newNestedFieldID = new ObjectId().toHexString()\n\n if (idState && typeof idState.value === 'string' && ObjectId.isValid(idState.value)) {\n newRowState[key].value = newNestedFieldID\n newRowState[key].initialValue = newNestedFieldID\n\n // Apply the ID to its corresponding parent field's rows, e.g. `array.0.nestedArray.rows[0].id`\n const segments = key.split('.')\n const rowIndex = parseInt(segments[segments.length - 2], 10)\n const parentFieldPath = segments.slice(0, segments.length - 2).join('.')\n const parentFieldRows = newRowState?.[parentFieldPath]?.rows\n\n if (newRowState[parentFieldPath] && Array.isArray(parentFieldRows)) {\n if (!parentFieldRows[rowIndex]) {\n parentFieldRows[rowIndex] = {\n id: newNestedFieldID,\n }\n } else {\n parentFieldRows[rowIndex].id = newNestedFieldID\n }\n }\n }\n }\n\n // If there are subfields\n if (Object.keys(newRowState).length > 0) {\n // Add new object containing subfield names to unflattenedRows array\n rows.splice(rowIndex + 1, 0, newRowState)\n newRows.splice(rowIndex + 1, 0, newRow)\n }\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n rows: newRows,\n value: rows.length,\n },\n }\n\n return newState\n }\n\n case 'MERGE_SERVER_STATE': {\n const { acceptValues, prevStateRef, serverState } = action\n\n const newState = mergeServerFormState({\n acceptValues,\n currentState: state || {},\n incomingState: serverState,\n })\n\n if (prevStateRef) {\n prevStateRef.current = newState\n }\n\n return newState\n }\n\n case 'MOVE_ROW': {\n const { moveFromIndex, moveToIndex, path } = action\n\n // Handle moving rows on the top-level, i.e. `array.0.text` -> `array.1.text`\n const { remainingFields, rows: topLevelRows } = separateRows(path, state)\n const copyOfMovingRow = topLevelRows[moveFromIndex]\n topLevelRows.splice(moveFromIndex, 1)\n topLevelRows.splice(moveToIndex, 0, copyOfMovingRow)\n\n // modify array/block internal row state (i.e. collapsed, blockType)\n const rowsWithinField = [...(state[path]?.rows || [])]\n const copyOfMovingRow2 = { ...rowsWithinField[moveFromIndex] }\n rowsWithinField.splice(moveFromIndex, 1)\n rowsWithinField.splice(moveToIndex, 0, copyOfMovingRow2)\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, topLevelRows),\n [path]: {\n ...state[path],\n rows: rowsWithinField,\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 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 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 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((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 ...(key === 'value' ? { isModified: true } : {}),\n }\n }\n\n return field\n }, state?.[action.path] || {})\n\n const newState = {\n ...state,\n [action.path]: newField,\n }\n\n // reset `isModified` in all other fields\n // Use destructuring instead of delete to avoid mutating field objects\n // shared with the previous state (shallow copy shares references)\n if ('value' in action) {\n for (const [path, field] of Object.entries(newState)) {\n if (path !== action.path && 'isModified' in field) {\n const { isModified: _, ...fieldWithoutIsModified } = field\n newState[path] = fieldWithoutIsModified\n }\n }\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,0CAA0C,QAAQ;AAI3D,SAASC,oBAAoB,QAAQ;AACrC,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAE1C,MAAMC,QAAA,GAAW,aAAaN,cAAA,GAAiBA,cAAA,CAAeO,OAAO,GAAGP,cAAA;AAExE;;;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;UACtEC,SAAA,EAAW;QACb;QAEA,IAAIZ,SAAA,EAAW;UACbQ,MAAA,CAAOR,SAAS,GAAGA,SAAA;QACrB;QAEAO,UAAA,CAAWM,MAAM,CAACX,QAAA,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,CAAOG,IAAI,CAAC,IAAI,CAAC;QAE5B,MAAMiB,QAAA,GAAW;UACf,GAAGrB,KAAK;UACR,CAACC,MAAA,CAAOG,IAAI,GAAGgF;QACjB;QAEA;QACA;QACA;QACA,IAAI,WAAWnF,MAAA,EAAQ;UACrB,KAAK,MAAM,CAACG,IAAA,EAAMkF,KAAA,CAAM,IAAIlD,MAAA,CAAOC,OAAO,CAAChB,QAAA,GAAW;YACpD,IAAIjB,IAAA,KAASH,MAAA,CAAOG,IAAI,IAAI,gBAAgBkF,KAAA,EAAO;cACjD,MAAM;gBAAEG,UAAA,EAAYC,CAAC;gBAAE,GAAGC;cAAA,CAAwB,GAAGL,KAAA;cACrDjE,QAAQ,CAACjB,IAAA,CAAK,GAAGuF,sBAAA;YACnB;UACF;QACF;QAEA,OAAOtE,QAAA;MACT;IAEA,KAAK;MAAe;QAClB,MAAMA,QAAA,GAAW;UAAE,GAAGrB;QAAM;QAE5BoC,MAAA,CAAOC,OAAO,CAACpC,MAAA,CAAO2F,SAAS,EAAEnE,OAAO,CAAC,CAAC,CAACrB,IAAA,EAAMkF,KAAA,CAAM;UACrDjE,QAAQ,CAACjB,IAAA,CAAK,GAAGkF,KAAA;QACnB;QAEA,OAAOjE,QAAA;MACT;IAEA;MAAS;QACP,OAAOrB,KAAA;MACT;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"fieldReducer.js","names":["ObjectIdImport","dequal","deepCopyObjectSimpleWithoutReactComponents","mergeServerFormState","flattenRows","separateRows","ObjectId","default","fieldReducer","state","action","type","blockType","path","rowIndex","rowIndexFromArgs","subFieldState","rows","length","withNewRow","newRow","id","value","toHexString","isLoading","splice","initialValue","valid","remainingFields","siblingRows","newState","passesCondition","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","newRows","newRowID","customComponents","RowLabel","newRowState","key","keys","filter","endsWith","idState","newNestedFieldID","isValid","parseInt","parentFieldPath","parentFieldRows","acceptValues","prevStateRef","serverState","currentState","incomingState","current","moveFromIndex","moveToIndex","topLevelRows","copyOfMovingRow","rowsWithinField","copyOfMovingRow2","rowsMetadata","rowIndexArg","Math","max","min","undefined","collapsed","optimize","newField","oldField","field","values","updatedRows","isModified","_","fieldWithoutIsModified","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 { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\n\nimport type { FieldAction } from './types.js'\n\nimport { mergeServerFormState } from './mergeServerFormState.js'\nimport { flattenRows, separateRows } from './rows.js'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\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 isLoading: true,\n }\n\n if (blockType) {\n newRow.blockType = blockType\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 valid: true,\n value: newRow.id,\n },\n [path]: {\n ...state[path],\n disableFormData: 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 /**\n * Duplicates a row in an array or blocks field.\n * It needs to manipulate two distinct parts of the form state:\n * - The `rows` property of the parent field, e.g. `array.rows`, `blocks.rows`, etc.\n * - The row's state, e.g. `array.0.id`, `array.0.text`, etc.\n */\n case 'DUPLICATE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n\n // 1. Duplicate the `rows` property of the parent field, e.g. `array.rows`, `blocks.rows`, etc.\n const newRows = [...(state[path].rows || [])]\n\n const newRow = deepCopyObjectSimpleWithoutReactComponents(newRows[rowIndex])\n\n const newRowID = new ObjectId().toHexString()\n\n if (newRow.id) {\n newRow.id = newRowID\n }\n\n if (newRows[rowIndex]?.customComponents?.RowLabel) {\n newRow.customComponents = {\n RowLabel: newRows[rowIndex].customComponents.RowLabel,\n }\n }\n\n // 2. Duplicate the row's state, e.g. `array.0.id`, `array.0.text`, etc.\n const newRowState = deepCopyObjectSimpleWithoutReactComponents(rows[rowIndex])\n\n // Ensure that `id` in form state exactly matches the row id on the parent field\n if (newRowState.id) {\n newRowState.id.value = newRowID\n newRowState.id.initialValue = newRowID\n }\n\n // Generate new ids for all nested id fields, e.g. `array.0.nestedArray.0.id`\n for (const key of Object.keys(newRowState).filter((key) => key.endsWith('.id'))) {\n const idState = newRowState[key]\n\n const newNestedFieldID = new ObjectId().toHexString()\n\n if (idState && typeof idState.value === 'string' && ObjectId.isValid(idState.value)) {\n newRowState[key].value = newNestedFieldID\n newRowState[key].initialValue = newNestedFieldID\n\n // Apply the ID to its corresponding parent field's rows, e.g. `array.0.nestedArray.rows[0].id`\n const segments = key.split('.')\n const rowIndex = parseInt(segments[segments.length - 2], 10)\n const parentFieldPath = segments.slice(0, segments.length - 2).join('.')\n const parentFieldRows = newRowState?.[parentFieldPath]?.rows\n\n if (newRowState[parentFieldPath] && Array.isArray(parentFieldRows)) {\n if (!parentFieldRows[rowIndex]) {\n parentFieldRows[rowIndex] = {\n id: newNestedFieldID,\n }\n } else {\n parentFieldRows[rowIndex].id = newNestedFieldID\n }\n }\n }\n }\n\n // If there are subfields\n if (Object.keys(newRowState).length > 0) {\n // Add new object containing subfield names to unflattenedRows array\n rows.splice(rowIndex + 1, 0, newRowState)\n newRows.splice(rowIndex + 1, 0, newRow)\n }\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n disableFormData: true,\n rows: newRows,\n value: rows.length,\n },\n }\n\n return newState\n }\n\n case 'MERGE_SERVER_STATE': {\n const { acceptValues, prevStateRef, serverState } = action\n\n const newState = mergeServerFormState({\n acceptValues,\n currentState: state || {},\n incomingState: serverState,\n })\n\n if (prevStateRef) {\n prevStateRef.current = newState\n }\n\n return newState\n }\n\n case 'MOVE_ROW': {\n const { moveFromIndex, moveToIndex, path } = action\n\n // Handle moving rows on the top-level, i.e. `array.0.text` -> `array.1.text`\n const { remainingFields, rows: topLevelRows } = separateRows(path, state)\n const copyOfMovingRow = topLevelRows[moveFromIndex]\n topLevelRows.splice(moveFromIndex, 1)\n topLevelRows.splice(moveToIndex, 0, copyOfMovingRow)\n\n // modify array/block internal row state (i.e. collapsed, blockType)\n const rowsWithinField = [...(state[path]?.rows || [])]\n const copyOfMovingRow2 = { ...rowsWithinField[moveFromIndex] }\n rowsWithinField.splice(moveFromIndex, 1)\n rowsWithinField.splice(moveToIndex, 0, copyOfMovingRow2)\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, topLevelRows),\n [path]: {\n ...state[path],\n rows: rowsWithinField,\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 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 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((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 ...(key === 'value' ? { isModified: true } : {}),\n }\n }\n\n return field\n }, state?.[action.path] || {})\n\n const newState = {\n ...state,\n [action.path]: newField,\n }\n\n // reset `isModified` in all other fields\n // Use destructuring instead of delete to avoid mutating field objects\n // shared with the previous state (shallow copy shares references)\n if ('value' in action) {\n for (const [path, field] of Object.entries(newState)) {\n if (path !== action.path && 'isModified' in field) {\n const { isModified: _, ...fieldWithoutIsModified } = field\n newState[path] = fieldWithoutIsModified\n }\n }\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,0CAA0C,QAAQ;AAI3D,SAASC,oBAAoB,QAAQ;AACrC,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAE1C,MAAMC,QAAA,GAAW,aAAaN,cAAA,GAAiBA,cAAA,CAAeO,OAAO,GAAGP,cAAA;AAExE;;;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;UACtEC,SAAA,EAAW;QACb;QAEA,IAAIZ,SAAA,EAAW;UACbQ,MAAA,CAAOR,SAAS,GAAGA,SAAA;QACrB;QAEAO,UAAA,CAAWM,MAAM,CAACX,QAAA,EAAU,GAAGM,M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,UAAA,EAAY;cAAK,IAAI,CAAC,CAAC;YACjD;UACF;UAEA,OAAOH,KAAA;QACT,GAAGvF,KAAA,GAAQC,MAAA,CAAOG,IAAI,CAAC,IAAI,CAAC;QAE5B,MAAMiB,QAAA,GAAW;UACf,GAAGrB,KAAK;UACR,CAACC,MAAA,CAAOG,IAAI,GAAGiF;QACjB;QAEA;QACA;QACA;QACA,IAAI,WAAWpF,MAAA,EAAQ;UACrB,KAAK,MAAM,CAACG,IAAA,EAAMmF,KAAA,CAAM,IAAIlD,MAAA,CAAOC,OAAO,CAACjB,QAAA,GAAW;YACpD,IAAIjB,IAAA,KAASH,MAAA,CAAOG,IAAI,IAAI,gBAAgBmF,KAAA,EAAO;cACjD,MAAM;gBAAEG,UAAA,EAAYC,CAAC;gBAAE,GAAGC;cAAA,CAAwB,GAAGL,KAAA;cACrDlE,QAAQ,CAACjB,IAAA,CAAK,GAAGwF,sBAAA;YACnB;UACF;QACF;QAEA,OAAOvE,QAAA;MACT;IAEA,KAAK;MAAe;QAClB,MAAMA,QAAA,GAAW;UAAE,GAAGrB;QAAM;QAE5BqC,MAAA,CAAOC,OAAO,CAACrC,MAAA,CAAO4F,SAAS,EAAEnE,OAAO,CAAC,CAAC,CAACtB,IAAA,EAAMmF,KAAA,CAAM;UACrDlE,QAAQ,CAACjB,IAAA,CAAK,GAAGmF,KAAA;QACnB;QAEA,OAAOlE,QAAA;MACT;IAEA;MAAS;QACP,OAAOrB,KAAA;MACT;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeServerFormState.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/mergeServerFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxC;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB;IACE;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GACD,OAAO,CAAA;AAEX,KAAK,IAAI,GAAG;IACV,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,aAAa,EAAE,SAAS,CAAA;CACzB,CAAA;AA6CD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,mDAI9B,IAAI,KAAG,
|
|
1
|
+
{"version":3,"file":"mergeServerFormState.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/mergeServerFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxC;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB;IACE;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GACD,OAAO,CAAA;AAEX,KAAK,IAAI,GAAG;IACV,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,aAAa,EAAE,SAAS,CAAA;CACzB,CAAA;AA6CD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,mDAI9B,IAAI,KAAG,SAwJT,CAAA"}
|
|
@@ -155,13 +155,12 @@ export const mergeServerFormState = ({
|
|
|
155
155
|
newState[path].rows.push(newRow);
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
newState[path].value = rowCount === 0 && currentState[path]?.value === null ? null : rowCount;
|
|
158
|
+
/**
|
|
159
|
+
* Sync the value field to match the actual row count after merging.
|
|
160
|
+
* Client is source of truth for row count when rows were added/removed during the request.
|
|
161
|
+
*/
|
|
162
|
+
if ('value' in incomingField && newState[path].rows.length !== incomingField.value) {
|
|
163
|
+
newState[path].value = newState[path].rows.length;
|
|
165
164
|
}
|
|
166
165
|
}
|
|
167
166
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeServerFormState.js","names":["dequal","parseArrayFieldPath","path","segments","split","lastNumericIndex","i","length","test","arrayPath","slice","join","fieldPath","rowIndex","parseInt","mergeServerFormState","acceptValues","currentState","incomingState","newState","incomingField","Object","entries","addedByServer","shouldAcceptValue","overrideLocalChanges","isModified","parsed","clientRowId","rows","id","serverRowId","undefined","sanitizedIncomingField","initialValue","value","rest","errorPaths","Array","isArray","map","serverRow","index","forEach","row","indexInCurrentState","findIndex","existingRow","newRow","push","rowCount","valid","passesCondition","blocksFilterOptions"],"sources":["../../../src/forms/Form/mergeServerFormState.ts"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\n\n/**\n * If true, will accept all values from the server, overriding any current values in local state.\n * Can also provide an options object for more granular control.\n */\nexport type AcceptValues =\n | {\n /**\n * When `false`, will accept the values from the server _UNLESS_ the value has been modified locally since the request was made.\n * This is useful for autosave, for example, where hooks may have modified the field's value on the server while you were still making changes.\n * @default undefined\n */\n overrideLocalChanges?: boolean\n }\n | boolean\n\ntype Args = {\n acceptValues?: AcceptValues\n currentState?: FormState\n incomingState: FormState\n}\n\n/**\n * Parses an array field path to extract the array path, row index, and field path.\n * Handles nested arrays by finding the deepest numeric index.\n *\n * @param path - The field path to parse (e.g., 'array.1.text' or 'blocks.0.items.1.title')\n * @returns Object with arrayPath, rowIndex, and fieldPath, or null if not an array field\n *\n * @example\n * parseArrayFieldPath('array.1.text')\n * // Returns: { arrayPath: 'array', rowIndex: 1, fieldPath: 'text' }\n *\n * @example\n * parseArrayFieldPath('blocks.0.items.1.title')\n * // Returns: { arrayPath: 'blocks.0.items', rowIndex: 1, fieldPath: 'title' }\n */\nfunction parseArrayFieldPath(path: string): {\n arrayPath: string\n fieldPath: string\n rowIndex: number\n} | null {\n const segments = path.split('.')\n\n // Find the last numeric index (indicates array row)\n let lastNumericIndex = -1\n for (let i = segments.length - 1; i >= 0; i--) {\n if (/^\\d+$/.test(segments[i])) {\n lastNumericIndex = i\n break\n }\n }\n\n // Not an array field if no numeric index or nothing after it\n if (lastNumericIndex === -1 || lastNumericIndex === segments.length - 1) {\n return null\n }\n\n return {\n arrayPath: segments.slice(0, lastNumericIndex).join('.'),\n fieldPath: segments.slice(lastNumericIndex + 1).join('.'),\n rowIndex: parseInt(segments[lastNumericIndex], 10),\n }\n}\n\n/**\n * This function receives form state from the server and intelligently merges it into the client state.\n * The server contains extra properties that the client may not have, e.g. custom components and error states.\n * We typically do not want to merge properties that rely on user input, however, such as values, unless explicitly requested.\n * Doing this would cause the client to lose any local changes to those fields.\n *\n * Note: Local state is the source of truth, not the new server state that is getting merged in. This is critical for array row\n * manipulation specifically, where the user may have added, removed, or reordered rows while a request was pending and is now stale.\n *\n * This function applies some defaults, as well as cleans up the server response in preparation for the client.\n * e.g. it will set `valid` and `passesCondition` to true if undefined, and remove `addedByServer` from the response.\n */\nexport const mergeServerFormState = ({\n acceptValues,\n currentState = {},\n incomingState,\n}: Args): FormState => {\n const newState = { ...currentState }\n\n for (const [path, incomingField] of Object.entries(incomingState || {})) {\n if (!(path in currentState) && !incomingField.addedByServer) {\n continue\n }\n\n /**\n * If it's a new field added by the server, always accept the value.\n * Otherwise:\n * a. accept all values when explicitly requested, e.g. on submit\n * b. only accept values for unmodified fields, e.g. on autosave\n */\n let shouldAcceptValue =\n incomingField.addedByServer ||\n acceptValues === true ||\n (typeof acceptValues === 'object' &&\n acceptValues !== null &&\n // Note: Must be explicitly `false`, allow `null` or `undefined` to mean true\n acceptValues.overrideLocalChanges === false &&\n !currentState[path]?.isModified)\n\n /**\n * For array row fields, verify the row IDs match at the given index before accepting\n * server values. If rows were reordered or deleted while the request was in-flight,\n * the same index may refer to different rows, and accepting the server value would\n * overwrite the wrong row's data.\n *\n * This guard only applies during autosave. On explicit save (acceptValues === true),\n * the server response is authoritative and this check is bypassed.\n */\n if (shouldAcceptValue && !incomingField.addedByServer && acceptValues !== true) {\n const parsed = parseArrayFieldPath(path)\n if (parsed) {\n const { arrayPath, rowIndex } = parsed\n const clientRowId = currentState[arrayPath]?.rows?.[rowIndex]?.id\n const serverRowId = incomingState[arrayPath]?.rows?.[rowIndex]?.id\n\n if (clientRowId === undefined || (serverRowId && clientRowId !== serverRowId)) {\n shouldAcceptValue = false\n }\n }\n }\n\n let sanitizedIncomingField = incomingField\n\n if (!shouldAcceptValue) {\n /**\n * Note: do not delete properties off `incomingField` as this will mutate the original object\n * Instead, omit them from the destructured object by excluding specific keys\n * This will also ensure we don't set `undefined` into the result unnecessarily\n */\n const { initialValue, value, ...rest } = incomingField\n sanitizedIncomingField = rest\n }\n\n newState[path] = {\n ...currentState[path],\n ...sanitizedIncomingField,\n }\n\n if (\n currentState[path] &&\n 'errorPaths' in currentState[path] &&\n !('errorPaths' in incomingField)\n ) {\n newState[path].errorPaths = []\n }\n\n /**\n * Deeply merge the rows array to ensure changes to local state are not lost while the request was pending\n * For example, the server response could come back with a row which has been deleted on the client\n * Loop over the incoming rows, if it exists in client side form state, merge in any new properties from the server\n * Note: read `currentState` and not `newState` here, as the `rows` property have already been merged above\n *\n * On explicit save (acceptValues === true), the server is authoritative - accept server row order.\n * On autosave (acceptValues !== true), the client is source of truth - use ID-based matching.\n */\n if (Array.isArray(incomingField.rows) && path in currentState) {\n if (acceptValues === true) {\n // Explicit save: server is authoritative, use index-based merging\n newState[path].rows = incomingField.rows.map((serverRow, index) => ({\n ...(currentState[path]?.rows?.[index] || {}),\n ...serverRow,\n }))\n } else {\n // Autosave: client is source of truth, use ID-based matching\n newState[path].rows = [...(currentState[path]?.rows || [])] // shallow copy to avoid mutating the original array\n\n incomingField.rows.forEach((row) => {\n const indexInCurrentState = currentState[path].rows?.findIndex(\n (existingRow) => existingRow.id === row.id,\n )\n\n if (indexInCurrentState > -1) {\n newState[path].rows[indexInCurrentState] = {\n ...currentState[path].rows[indexInCurrentState],\n ...row,\n }\n } else if (row.addedByServer) {\n /**\n * Note: This is a known limitation of computed array and block rows\n * If a new row was added by the server, we append it to the _end_ of this array\n * This is because the client is the source of truth, and it has arrays ordered in a certain position\n * For example, the user may have re-ordered rows client-side while a long running request is processing\n * This means that we _cannot_ slice a new row into the second position on the server, for example\n * By the time it gets back to the client, its index is stale\n */\n const newRow = { ...row }\n delete newRow.addedByServer\n newState[path].rows.push(newRow)\n }\n })\n }\n\n // Client rows may have changed while the request was pending.\n // Background merges preserve their row count and null/empty distinction; explicit saves accept server values.\n if ('value' in incomingField) {\n const rowCount = newState[path].rows.length\n\n if (acceptValues !== true) {\n newState[path].value =\n rowCount === 0 && currentState[path]?.value === null ? null : rowCount\n }\n }\n }\n\n // If `valid` is `undefined`, mark it as `true`\n if (incomingField.valid !== false) {\n newState[path].valid = true\n }\n\n // If `passesCondition` is `undefined`, mark it as `true`\n if (incomingField.passesCondition !== false) {\n newState[path].passesCondition = true\n }\n\n /**\n * Undefined values for blocksFilterOptions coming back should be treated as \"all blocks allowed\" and\n * should always be merged in.\n * Without this, an undefined value coming back will incorrectly be ignored, and the previous filter will remain.\n */\n if (!incomingField.blocksFilterOptions) {\n delete newState[path].blocksFilterOptions\n }\n\n // Strip away the `addedByServer` property from the client\n // This will prevent it from being passed back to the server\n delete newState[path].addedByServer\n }\n\n // Return the original object reference if the state is unchanged\n // This will avoid unnecessary re-renders and dependency updates\n return dequal(newState, currentState) ? currentState : newState\n}\n"],"mappings":"AAAA;;AAGA,SAASA,MAAM,QAAQ,cAAa,CAAC;AAuBrC;;;;;;;;;;;;;;;AAeA,SAASC,oBAAoBC,IAAY;EAKvC,MAAMC,QAAA,GAAWD,IAAA,CAAKE,KAAK,CAAC;EAE5B;EACA,IAAIC,gBAAA,GAAmB,CAAC;EACxB,KAAK,IAAIC,CAAA,GAAIH,QAAA,CAASI,MAAM,GAAG,GAAGD,CAAA,IAAK,GAAGA,CAAA,IAAK;IAC7C,IAAI,QAAQE,IAAI,CAACL,QAAQ,CAACG,CAAA,CAAE,GAAG;MAC7BD,gBAAA,GAAmBC,CAAA;MACnB;IACF;EACF;EAEA;EACA,IAAID,gB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B,EAAE;MACtC,OAAOlC,QAAQ,CAACjB,IAAA,CAAK,CAACmD,mBAAmB;IAC3C;IAEA;IACA;IACA,OAAOlC,QAAQ,CAACjB,IAAA,CAAK,CAACqB,aAAa;EACrC;EAEA;EACA;EACA,OAAOvB,MAAA,CAAOmB,QAAA,EAAUF,YAAA,IAAgBA,YAAA,GAAeE,QAAA;AACzD","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"mergeServerFormState.js","names":["dequal","parseArrayFieldPath","path","segments","split","lastNumericIndex","i","length","test","arrayPath","slice","join","fieldPath","rowIndex","parseInt","mergeServerFormState","acceptValues","currentState","incomingState","newState","incomingField","Object","entries","addedByServer","shouldAcceptValue","overrideLocalChanges","isModified","parsed","clientRowId","rows","id","serverRowId","undefined","sanitizedIncomingField","initialValue","value","rest","errorPaths","Array","isArray","map","serverRow","index","forEach","row","indexInCurrentState","findIndex","existingRow","newRow","push","valid","passesCondition","blocksFilterOptions"],"sources":["../../../src/forms/Form/mergeServerFormState.ts"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\n\n/**\n * If true, will accept all values from the server, overriding any current values in local state.\n * Can also provide an options object for more granular control.\n */\nexport type AcceptValues =\n | {\n /**\n * When `false`, will accept the values from the server _UNLESS_ the value has been modified locally since the request was made.\n * This is useful for autosave, for example, where hooks may have modified the field's value on the server while you were still making changes.\n * @default undefined\n */\n overrideLocalChanges?: boolean\n }\n | boolean\n\ntype Args = {\n acceptValues?: AcceptValues\n currentState?: FormState\n incomingState: FormState\n}\n\n/**\n * Parses an array field path to extract the array path, row index, and field path.\n * Handles nested arrays by finding the deepest numeric index.\n *\n * @param path - The field path to parse (e.g., 'array.1.text' or 'blocks.0.items.1.title')\n * @returns Object with arrayPath, rowIndex, and fieldPath, or null if not an array field\n *\n * @example\n * parseArrayFieldPath('array.1.text')\n * // Returns: { arrayPath: 'array', rowIndex: 1, fieldPath: 'text' }\n *\n * @example\n * parseArrayFieldPath('blocks.0.items.1.title')\n * // Returns: { arrayPath: 'blocks.0.items', rowIndex: 1, fieldPath: 'title' }\n */\nfunction parseArrayFieldPath(path: string): {\n arrayPath: string\n fieldPath: string\n rowIndex: number\n} | null {\n const segments = path.split('.')\n\n // Find the last numeric index (indicates array row)\n let lastNumericIndex = -1\n for (let i = segments.length - 1; i >= 0; i--) {\n if (/^\\d+$/.test(segments[i])) {\n lastNumericIndex = i\n break\n }\n }\n\n // Not an array field if no numeric index or nothing after it\n if (lastNumericIndex === -1 || lastNumericIndex === segments.length - 1) {\n return null\n }\n\n return {\n arrayPath: segments.slice(0, lastNumericIndex).join('.'),\n fieldPath: segments.slice(lastNumericIndex + 1).join('.'),\n rowIndex: parseInt(segments[lastNumericIndex], 10),\n }\n}\n\n/**\n * This function receives form state from the server and intelligently merges it into the client state.\n * The server contains extra properties that the client may not have, e.g. custom components and error states.\n * We typically do not want to merge properties that rely on user input, however, such as values, unless explicitly requested.\n * Doing this would cause the client to lose any local changes to those fields.\n *\n * Note: Local state is the source of truth, not the new server state that is getting merged in. This is critical for array row\n * manipulation specifically, where the user may have added, removed, or reordered rows while a request was pending and is now stale.\n *\n * This function applies some defaults, as well as cleans up the server response in preparation for the client.\n * e.g. it will set `valid` and `passesCondition` to true if undefined, and remove `addedByServer` from the response.\n */\nexport const mergeServerFormState = ({\n acceptValues,\n currentState = {},\n incomingState,\n}: Args): FormState => {\n const newState = { ...currentState }\n\n for (const [path, incomingField] of Object.entries(incomingState || {})) {\n if (!(path in currentState) && !incomingField.addedByServer) {\n continue\n }\n\n /**\n * If it's a new field added by the server, always accept the value.\n * Otherwise:\n * a. accept all values when explicitly requested, e.g. on submit\n * b. only accept values for unmodified fields, e.g. on autosave\n */\n let shouldAcceptValue =\n incomingField.addedByServer ||\n acceptValues === true ||\n (typeof acceptValues === 'object' &&\n acceptValues !== null &&\n // Note: Must be explicitly `false`, allow `null` or `undefined` to mean true\n acceptValues.overrideLocalChanges === false &&\n !currentState[path]?.isModified)\n\n /**\n * For array row fields, verify the row IDs match at the given index before accepting\n * server values. If rows were reordered or deleted while the request was in-flight,\n * the same index may refer to different rows, and accepting the server value would\n * overwrite the wrong row's data.\n *\n * This guard only applies during autosave. On explicit save (acceptValues === true),\n * the server response is authoritative and this check is bypassed.\n */\n if (shouldAcceptValue && !incomingField.addedByServer && acceptValues !== true) {\n const parsed = parseArrayFieldPath(path)\n if (parsed) {\n const { arrayPath, rowIndex } = parsed\n const clientRowId = currentState[arrayPath]?.rows?.[rowIndex]?.id\n const serverRowId = incomingState[arrayPath]?.rows?.[rowIndex]?.id\n\n if (clientRowId === undefined || (serverRowId && clientRowId !== serverRowId)) {\n shouldAcceptValue = false\n }\n }\n }\n\n let sanitizedIncomingField = incomingField\n\n if (!shouldAcceptValue) {\n /**\n * Note: do not delete properties off `incomingField` as this will mutate the original object\n * Instead, omit them from the destructured object by excluding specific keys\n * This will also ensure we don't set `undefined` into the result unnecessarily\n */\n const { initialValue, value, ...rest } = incomingField\n sanitizedIncomingField = rest\n }\n\n newState[path] = {\n ...currentState[path],\n ...sanitizedIncomingField,\n }\n\n if (\n currentState[path] &&\n 'errorPaths' in currentState[path] &&\n !('errorPaths' in incomingField)\n ) {\n newState[path].errorPaths = []\n }\n\n /**\n * Deeply merge the rows array to ensure changes to local state are not lost while the request was pending\n * For example, the server response could come back with a row which has been deleted on the client\n * Loop over the incoming rows, if it exists in client side form state, merge in any new properties from the server\n * Note: read `currentState` and not `newState` here, as the `rows` property have already been merged above\n *\n * On explicit save (acceptValues === true), the server is authoritative - accept server row order.\n * On autosave (acceptValues !== true), the client is source of truth - use ID-based matching.\n */\n if (Array.isArray(incomingField.rows) && path in currentState) {\n if (acceptValues === true) {\n // Explicit save: server is authoritative, use index-based merging\n newState[path].rows = incomingField.rows.map((serverRow, index) => ({\n ...(currentState[path]?.rows?.[index] || {}),\n ...serverRow,\n }))\n } else {\n // Autosave: client is source of truth, use ID-based matching\n newState[path].rows = [...(currentState[path]?.rows || [])] // shallow copy to avoid mutating the original array\n\n incomingField.rows.forEach((row) => {\n const indexInCurrentState = currentState[path].rows?.findIndex(\n (existingRow) => existingRow.id === row.id,\n )\n\n if (indexInCurrentState > -1) {\n newState[path].rows[indexInCurrentState] = {\n ...currentState[path].rows[indexInCurrentState],\n ...row,\n }\n } else if (row.addedByServer) {\n /**\n * Note: This is a known limitation of computed array and block rows\n * If a new row was added by the server, we append it to the _end_ of this array\n * This is because the client is the source of truth, and it has arrays ordered in a certain position\n * For example, the user may have re-ordered rows client-side while a long running request is processing\n * This means that we _cannot_ slice a new row into the second position on the server, for example\n * By the time it gets back to the client, its index is stale\n */\n const newRow = { ...row }\n delete newRow.addedByServer\n newState[path].rows.push(newRow)\n }\n })\n\n /**\n * Sync the value field to match the actual row count after merging.\n * Client is source of truth for row count when rows were added/removed during the request.\n */\n if ('value' in incomingField && newState[path].rows.length !== incomingField.value) {\n newState[path].value = newState[path].rows.length\n }\n }\n }\n\n // If `valid` is `undefined`, mark it as `true`\n if (incomingField.valid !== false) {\n newState[path].valid = true\n }\n\n // If `passesCondition` is `undefined`, mark it as `true`\n if (incomingField.passesCondition !== false) {\n newState[path].passesCondition = true\n }\n\n /**\n * Undefined values for blocksFilterOptions coming back should be treated as \"all blocks allowed\" and\n * should always be merged in.\n * Without this, an undefined value coming back will incorrectly be ignored, and the previous filter will remain.\n */\n if (!incomingField.blocksFilterOptions) {\n delete newState[path].blocksFilterOptions\n }\n\n // Strip away the `addedByServer` property from the client\n // This will prevent it from being passed back to the server\n delete newState[path].addedByServer\n }\n\n // Return the original object reference if the state is unchanged\n // This will avoid unnecessary re-renders and dependency updates\n return dequal(newState, currentState) ? currentState : newState\n}\n"],"mappings":"AAAA;;AAGA,SAASA,MAAM,QAAQ,cAAa,CAAC;AAuBrC;;;;;;;;;;;;;;;AAeA,SAASC,oBAAoBC,IAAY;EAKvC,MAAMC,QAAA,GAAWD,IAAA,CAAKE,KAAK,CAAC;EAE5B;EACA,IAAIC,gBAAA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,GAAG;IACzB;IAEA;IACA,IAAI9B,aAAA,CAAc+B,eAAe,KAAK,OAAO;MAC3ChC,QAAQ,CAACjB,IAAA,CAAK,CAACiD,eAAe,GAAG;IACnC;IAEA;;;;;IAKA,IAAI,CAAC/B,aAAA,CAAcgC,mBAAmB,EAAE;MACtC,OAAOjC,QAAQ,CAACjB,IAAA,CAAK,CAACkD,mBAAmB;IAC3C;IAEA;IACA;IACA,OAAOjC,QAAQ,CAACjB,IAAA,CAAK,CAACqB,aAAa;EACrC;EAEA;EACA;EACA,OAAOvB,MAAA,CAAOmB,QAAA,EAAUF,YAAA,IAAgBA,YAAA,GAAeE,QAAA;AACzD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addFieldStatePromise.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/addFieldStatePromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,IAAI,EACJ,mBAAmB,EACnB,KAAK,EACL,cAAc,EACd,cAAc,EAGd,SAAS,EACT,0BAA0B,EAC1B,cAAc,EAGd,0BAA0B,EAC1B,UAAU,EACV,UAAU,EACV,UAAU,EAEX,MAAM,SAAS,CAAA;AAchB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAQnD,MAAM,MAAM,wBAAwB,GAAG;IACrC,oBAAoB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IACjD;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,SAAS,EAAE,IAAI,GAAG,SAAS,CAAA;IAC3B,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,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CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,0BAA0B,CAAA;IAC7C,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,OAAO,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,mBAAmB,CAAA;IAChC,iBAAiB,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,EAAE,iBAAiB,CAAA;IAChC;;;OAGG;IACH,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,0BAA0B,CAAA;CAClC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,SAAgB,wBAAwB,KAAG,OAAO,CAAC,IAAI,CAi8BvF,CAAA"}
|
|
@@ -261,13 +261,10 @@ export const addFieldStatePromise = async args => {
|
|
|
261
261
|
fieldState.rows = rows;
|
|
262
262
|
}
|
|
263
263
|
// Add values to field state
|
|
264
|
-
if (data[field.name]
|
|
265
|
-
fieldState.value = null;
|
|
266
|
-
fieldState.initialValue = null;
|
|
267
|
-
} else {
|
|
264
|
+
if (data[field.name] !== null) {
|
|
268
265
|
fieldState.value = forceFullValue ? arrayValue : arrayValue.length;
|
|
269
266
|
fieldState.initialValue = forceFullValue ? arrayValue : arrayValue.length;
|
|
270
|
-
if (
|
|
267
|
+
if (arrayValue.length > 0) {
|
|
271
268
|
fieldState.disableFormData = true;
|
|
272
269
|
}
|
|
273
270
|
}
|
|
@@ -435,7 +432,7 @@ export const addFieldStatePromise = async args => {
|
|
|
435
432
|
} else {
|
|
436
433
|
fieldState.value = forceFullValue ? blocksValue : blocksValue.length;
|
|
437
434
|
fieldState.initialValue = forceFullValue ? blocksValue : blocksValue.length;
|
|
438
|
-
if (
|
|
435
|
+
if (blocksValue.length > 0) {
|
|
439
436
|
fieldState.disableFormData = true;
|
|
440
437
|
}
|
|
441
438
|
}
|