@payloadcms/ui 3.55.0-internal.df60e35 → 3.55.0
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/AppHeader/index.scss +1 -0
- package/dist/elements/DefaultListViewTabs/index.d.ts +12 -0
- package/dist/elements/DefaultListViewTabs/index.d.ts.map +1 -0
- package/dist/elements/DefaultListViewTabs/index.js +161 -0
- package/dist/elements/DefaultListViewTabs/index.js.map +1 -0
- package/dist/elements/{ListHeaderTabs → DefaultListViewTabs}/index.scss +1 -1
- package/dist/elements/DocumentDrawer/Provider.d.ts +2 -1
- package/dist/elements/DocumentDrawer/Provider.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/Provider.js.map +1 -1
- package/dist/elements/FieldSelect/reduceFieldOptions.js +1 -1
- package/dist/elements/FieldSelect/reduceFieldOptions.js.map +1 -1
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +69 -78
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListControls/index.scss +2 -82
- package/dist/elements/SearchBar/index.d.ts +2 -3
- package/dist/elements/SearchBar/index.d.ts.map +1 -1
- package/dist/elements/SearchBar/index.js +2 -3
- package/dist/elements/SearchBar/index.js.map +1 -1
- package/dist/elements/SearchBar/index.scss +56 -7
- package/dist/elements/SearchFilter/index.d.ts +2 -33
- package/dist/elements/SearchFilter/index.d.ts.map +1 -1
- package/dist/elements/SearchFilter/index.js +7 -5
- package/dist/elements/SearchFilter/index.js.map +1 -1
- package/dist/elements/SearchFilter/types.d.ts +33 -0
- package/dist/elements/SearchFilter/types.d.ts.map +1 -0
- package/dist/elements/SearchFilter/types.js +2 -0
- package/dist/elements/SearchFilter/types.js.map +1 -0
- package/dist/elements/Status/index.d.ts.map +1 -1
- package/dist/elements/Status/index.js +1 -1
- package/dist/elements/Status/index.js.map +1 -1
- package/dist/exports/client/{CodeEditor-MIIBUJZ4.js → CodeEditor-URFJPG6I.js} +2 -2
- package/dist/exports/client/chunk-KPQQ5IUL.js +26 -0
- package/dist/exports/client/{chunk-Z6O2JA43.js.map → chunk-KPQQ5IUL.js.map} +3 -3
- package/dist/exports/client/index.js +12 -12
- 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/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Join/index.js +1 -1
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/forms/Form/types.d.ts +6 -3
- 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 +1 -1
- package/dist/forms/RenderFields/index.js.map +1 -1
- package/dist/forms/RowLabel/Context/index.d.ts.map +1 -1
- package/dist/forms/RowLabel/Context/index.js +17 -31
- package/dist/forms/RowLabel/Context/index.js.map +1 -1
- package/dist/providers/Auth/index.d.ts +2 -1
- package/dist/providers/Auth/index.d.ts.map +1 -1
- package/dist/providers/Auth/index.js +74 -83
- package/dist/providers/Auth/index.js.map +1 -1
- package/dist/providers/Config/index.d.ts.map +1 -1
- package/dist/providers/Config/index.js +6 -3
- package/dist/providers/Config/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildFormState.js +2 -1
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +12 -4
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/getClientConfig.d.ts +2 -7
- package/dist/utilities/getClientConfig.d.ts.map +1 -1
- package/dist/utilities/getClientConfig.js +19 -8
- package/dist/utilities/getClientConfig.js.map +1 -1
- package/dist/utilities/getColumns.d.ts +10 -0
- package/dist/utilities/getColumns.d.ts.map +1 -0
- package/dist/utilities/getColumns.js +36 -0
- package/dist/utilities/getColumns.js.map +1 -0
- package/dist/utilities/renderTable.d.ts +3 -3
- package/dist/utilities/renderTable.d.ts.map +1 -1
- package/dist/utilities/renderTable.js +2 -11
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/views/BrowseByFolder/index.js +1 -1
- package/dist/views/BrowseByFolder/index.js.map +1 -1
- package/dist/views/CollectionFolder/index.d.ts.map +1 -1
- package/dist/views/CollectionFolder/index.js +5 -15
- package/dist/views/CollectionFolder/index.js.map +1 -1
- package/dist/views/Edit/Auth/index.d.ts.map +1 -1
- package/dist/views/Edit/Auth/index.js +1 -1
- package/dist/views/Edit/Auth/index.js.map +1 -1
- package/dist/views/List/ListHeader/index.d.ts.map +1 -1
- package/dist/views/List/ListHeader/index.js +5 -13
- package/dist/views/List/ListHeader/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/elements/ListHeaderTabs/ByFolderPill.d.ts +0 -10
- package/dist/elements/ListHeaderTabs/ByFolderPill.d.ts.map +0 -1
- package/dist/elements/ListHeaderTabs/ByFolderPill.js +0 -70
- package/dist/elements/ListHeaderTabs/ByFolderPill.js.map +0 -1
- package/dist/elements/ListHeaderTabs/DefaultListPill.d.ts +0 -9
- package/dist/elements/ListHeaderTabs/DefaultListPill.d.ts.map +0 -1
- package/dist/elements/ListHeaderTabs/DefaultListPill.js +0 -68
- package/dist/elements/ListHeaderTabs/DefaultListPill.js.map +0 -1
- package/dist/elements/ListHeaderTabs/TrashPill.d.ts +0 -6
- package/dist/elements/ListHeaderTabs/TrashPill.d.ts.map +0 -1
- package/dist/elements/ListHeaderTabs/TrashPill.js +0 -53
- package/dist/elements/ListHeaderTabs/TrashPill.js.map +0 -1
- package/dist/exports/client/chunk-Z6O2JA43.js +0 -26
- /package/dist/exports/client/{CodeEditor-MIIBUJZ4.js.map → CodeEditor-URFJPG6I.js.map} +0 -0
|
@@ -6,6 +6,7 @@ export { getHTMLDiffComponents } from '../../elements/HTMLDiff/index.js';
|
|
|
6
6
|
export { File } from '../../graphics/File/index.js';
|
|
7
7
|
export { CheckIcon } from '../../icons/Check/index.js';
|
|
8
8
|
export { copyDataFromLocaleHandler } from '../../utilities/copyDataFromLocale.js';
|
|
9
|
+
export { getColumns } from '../../utilities/getColumns.js';
|
|
9
10
|
export { getFolderResultsComponentAndData } from '../../utilities/getFolderResultsComponentAndData.js';
|
|
10
11
|
export { renderFilters, renderTable } from '../../utilities/renderTable.js';
|
|
11
12
|
export { resolveFilterOptions } from '../../utilities/resolveFilterOptions.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/rsc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,uDAAuD,CAAA;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AACjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAA;AACtG,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"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/rsc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,uDAAuD,CAAA;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAC1D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAA;AACtG,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"}
|
|
@@ -6,6 +6,7 @@ export { getHTMLDiffComponents } from '../../elements/HTMLDiff/index.js';
|
|
|
6
6
|
export { File } from '../../graphics/File/index.js';
|
|
7
7
|
export { CheckIcon } from '../../icons/Check/index.js';
|
|
8
8
|
export { copyDataFromLocaleHandler } from '../../utilities/copyDataFromLocale.js';
|
|
9
|
+
export { getColumns } from '../../utilities/getColumns.js';
|
|
9
10
|
export { getFolderResultsComponentAndData } from '../../utilities/getFolderResultsComponentAndData.js';
|
|
10
11
|
export { renderFilters, renderTable } from '../../utilities/renderTable.js';
|
|
11
12
|
export { resolveFilterOptions } from '../../utilities/resolveFilterOptions.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["FieldDiffContainer","FieldDiffLabel","FolderTableCell","FolderField","getHTMLDiffComponents","File","CheckIcon","copyDataFromLocaleHandler","getFolderResultsComponentAndData","renderFilters","renderTable","resolveFilterOptions","upsertPreferences"],"sources":["../../../src/exports/rsc/index.ts"],"sourcesContent":["export { FieldDiffContainer } from '../../elements/FieldDiffContainer/index.js'\nexport { FieldDiffLabel } from '../../elements/FieldDiffLabel/index.js'\nexport { FolderTableCell } from '../../elements/FolderView/Cell/index.server.js'\nexport { FolderField } from '../../elements/FolderView/FolderField/index.server.js'\nexport { getHTMLDiffComponents } from '../../elements/HTMLDiff/index.js'\nexport { File } from '../../graphics/File/index.js'\nexport { CheckIcon } from '../../icons/Check/index.js'\nexport { copyDataFromLocaleHandler } from '../../utilities/copyDataFromLocale.js'\nexport { getFolderResultsComponentAndData } from '../../utilities/getFolderResultsComponentAndData.js'\nexport { renderFilters, renderTable } from '../../utilities/renderTable.js'\nexport { resolveFilterOptions } from '../../utilities/resolveFilterOptions.js'\nexport { upsertPreferences } from '../../utilities/upsertPreferences.js'\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,WAAW,QAAQ;AAC5B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,IAAI,QAAQ;AACrB,SAASC,SAAS,QAAQ;AAC1B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,gCAAgC,QAAQ;AACjD,SAASC,aAAa,EAAEC,WAAW,QAAQ;AAC3C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,iBAAiB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["FieldDiffContainer","FieldDiffLabel","FolderTableCell","FolderField","getHTMLDiffComponents","File","CheckIcon","copyDataFromLocaleHandler","getColumns","getFolderResultsComponentAndData","renderFilters","renderTable","resolveFilterOptions","upsertPreferences"],"sources":["../../../src/exports/rsc/index.ts"],"sourcesContent":["export { FieldDiffContainer } from '../../elements/FieldDiffContainer/index.js'\nexport { FieldDiffLabel } from '../../elements/FieldDiffLabel/index.js'\nexport { FolderTableCell } from '../../elements/FolderView/Cell/index.server.js'\nexport { FolderField } from '../../elements/FolderView/FolderField/index.server.js'\nexport { getHTMLDiffComponents } from '../../elements/HTMLDiff/index.js'\nexport { File } from '../../graphics/File/index.js'\nexport { CheckIcon } from '../../icons/Check/index.js'\nexport { copyDataFromLocaleHandler } from '../../utilities/copyDataFromLocale.js'\nexport { getColumns } from '../../utilities/getColumns.js'\nexport { getFolderResultsComponentAndData } from '../../utilities/getFolderResultsComponentAndData.js'\nexport { renderFilters, renderTable } from '../../utilities/renderTable.js'\nexport { resolveFilterOptions } from '../../utilities/resolveFilterOptions.js'\nexport { upsertPreferences } from '../../utilities/upsertPreferences.js'\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,WAAW,QAAQ;AAC5B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,IAAI,QAAQ;AACrB,SAASC,SAAS,QAAQ;AAC1B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,gCAAgC,QAAQ;AACjD,SAASC,aAAa,EAAEC,WAAW,QAAQ;AAC3C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,iBAAiB,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Blocks/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAyC,MAAM,OAAO,CAAA;AA6B7D,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Blocks/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAyC,MAAM,OAAO,CAAA;AA6B7D,OAAO,cAAc,CAAA;AA+drB,eAAO,MAAM,WAAW;;;;+EAAsC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getTranslation","React","Fragment","useCallback","useMemo","toast","Banner","Button","clipboardCopy","clipboardPaste","ClipboardAction","mergeFormStateFromClipboard","reduceFormStateByPath","DraggableSortableItem","DraggableSortable","DrawerToggler","useDrawerSlug","ErrorPill","RenderCustomComponent","useForm","useFormSubmitted","extractRowsAndCollapsedIDs","toggleAllRows","NullifyLocaleField","useField","withCondition","useConfig","useDocumentInfo","useLocale","useTranslation","scrollToID","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","BlockRow","BlocksDrawer","baseClass","BlocksFieldComponent","props","i18n","t","field","name","type","admin","className","description","isSortable","blockReferences","blocks","label","labels","labelsFromProps","localized","maxRows","minRows","minRowsProp","required","path","pathFromProps","permissions","readOnly","schemaPath","schemaPathFromProps","validate","setDocFieldPreferences","addFieldRow","dispatchFields","getFields","moveFieldRow","removeFieldRow","replaceState","setModified","code","locale","config","localization","drawerSlug","submitted","plural","singular","editingDefaultLocale","fallback","defaultLocale","clientBlocks","resolvedBlocks","blockReference","block","blocksMap","push","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","errorPaths","rows","showError","valid","hasRows","potentiallyStalePath","addRow","rowIndex","blockType","setTimeout","duplicateRow","removeRow","moveRow","moveFromIndex","moveToIndex","toggleCollapseAll","collapsed","collapsedIDs","updatedRows","setCollapse","rowID","copyRow","clipboardResult","getDataToCopy","formState","error","success","pasteRow","pasteArgs","onPaste","dataFromClipboard","newState","schemaBlocks","pasteBlocks","hasMaxRows","length","fieldErrorCount","fieldHasErrors","showMinRows","showRequired","styles","_jsxs","filter","Boolean","join","id","replace","style","_jsx","CustomComponent","Fallback","as","count","withMessage","onClick","allowCopy","allowPaste","fieldValue","ids","map","row","onDragEnd","i","isLoading","blockConfig","find","slug","rowPath","rowErrorCount","errorPath","startsWith","draggableSortableItemProps","errorCount","fields","RowLabel","parentPath","rowCount","buttonStyle","el","icon","iconPosition","iconStyle","addRowIndex","BlocksField"],"sources":["../../../src/fields/Blocks/index.tsx"],"sourcesContent":["'use client'\nimport type { BlocksFieldClientComponent, ClientBlock } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { Fragment, useCallback, useMemo } from 'react'\nimport { toast } from 'sonner'\n\nimport type { ClipboardPasteData } from '../../elements/ClipboardAction/types.js'\n\nimport { Banner } from '../../elements/Banner/index.js'\nimport { Button } from '../../elements/Button/index.js'\nimport { clipboardCopy, clipboardPaste } from '../../elements/ClipboardAction/clipboardUtilities.js'\nimport { ClipboardAction } from '../../elements/ClipboardAction/index.js'\nimport {\n mergeFormStateFromClipboard,\n reduceFormStateByPath,\n} from '../../elements/ClipboardAction/mergeFormStateFromClipboard.js'\nimport { DraggableSortableItem } from '../../elements/DraggableSortable/DraggableSortableItem/index.js'\nimport { DraggableSortable } from '../../elements/DraggableSortable/index.js'\nimport { DrawerToggler } from '../../elements/Drawer/index.js'\nimport { useDrawerSlug } from '../../elements/Drawer/useDrawerSlug.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useForm, useFormSubmitted } from '../../forms/Form/context.js'\nimport { extractRowsAndCollapsedIDs, toggleAllRows } from '../../forms/Form/rowHelpers.js'\nimport { NullifyLocaleField } from '../../forms/NullifyField/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 { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { scrollToID } from '../../utilities/scrollToID.js'\nimport './index.scss'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { BlockRow } from './BlockRow.js'\nimport { BlocksDrawer } from './BlocksDrawer/index.js'\n\nconst baseClass = 'blocks-field'\n\nconst BlocksFieldComponent: BlocksFieldClientComponent = (props) => {\n const { i18n, t } = useTranslation()\n\n const {\n field,\n field: {\n name,\n type,\n admin: { className, description, isSortable = true } = {},\n blockReferences,\n blocks,\n label,\n labels: labelsFromProps,\n localized,\n maxRows,\n minRows: minRowsProp,\n required,\n },\n path: pathFromProps,\n permissions,\n readOnly,\n schemaPath: schemaPathFromProps,\n validate,\n } = props\n\n const schemaPath = schemaPathFromProps ?? name\n\n const minRows = (minRowsProp ?? required) ? 1 : 0\n\n const { setDocFieldPreferences } = useDocumentInfo()\n const {\n addFieldRow,\n dispatchFields,\n getFields,\n moveFieldRow,\n removeFieldRow,\n replaceState,\n setModified,\n } = useForm()\n const { code: locale } = useLocale()\n const {\n config: { localization },\n config,\n } = useConfig()\n const drawerSlug = useDrawerSlug('blocks-drawer')\n const submitted = useFormSubmitted()\n\n const labels = {\n plural: t('fields:blocks'),\n singular: t('fields:block'),\n ...labelsFromProps,\n }\n\n const editingDefaultLocale = (() => {\n if (localization && localization.fallback) {\n const defaultLocale = localization.defaultLocale\n return locale === defaultLocale\n }\n\n return true\n })()\n\n const clientBlocks = useMemo(() => {\n if (!blockReferences) {\n return blocks\n }\n\n const resolvedBlocks: ClientBlock[] = []\n for (const blockReference of blockReferences) {\n const block =\n typeof blockReference === 'string' ? config.blocksMap[blockReference] : blockReference\n if (block) {\n resolvedBlocks.push(block)\n }\n }\n\n return resolvedBlocks\n }, [blockReferences, blocks, config.blocksMap])\n\n const memoizedValidate = useCallback(\n (value, options) => {\n // alternative locales can be null\n if (!editingDefaultLocale && value === null) {\n return true\n }\n if (typeof validate === 'function') {\n return validate(value, { ...options, maxRows, minRows, required })\n }\n },\n [maxRows, minRows, required, validate, editingDefaultLocale],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n errorPaths,\n path,\n rows = [],\n showError,\n valid,\n value,\n } = useField<number>({\n hasRows: true,\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const addRow = useCallback(\n (rowIndex: number, blockType: string) => {\n addFieldRow({\n blockType,\n path,\n rowIndex,\n schemaPath,\n })\n\n setTimeout(() => {\n scrollToID(`${path}-row-${rowIndex + 1}`)\n }, 0)\n },\n [addFieldRow, path, schemaPath],\n )\n\n const duplicateRow = useCallback(\n (rowIndex: number) => {\n dispatchFields({ type: 'DUPLICATE_ROW', path, rowIndex })\n setModified(true)\n\n setTimeout(() => {\n scrollToID(`${path}-row-${rowIndex + 1}`)\n }, 0)\n },\n [dispatchFields, path, setModified],\n )\n\n const removeRow = useCallback(\n (rowIndex: number) => {\n removeFieldRow({\n path,\n rowIndex,\n })\n },\n [path, removeFieldRow],\n )\n\n const moveRow = useCallback(\n (moveFromIndex: number, moveToIndex: number) => {\n moveFieldRow({ moveFromIndex, moveToIndex, path })\n },\n [moveFieldRow, path],\n )\n\n const toggleCollapseAll = useCallback(\n (collapsed: boolean) => {\n const { collapsedIDs, updatedRows } = toggleAllRows({\n collapsed,\n rows,\n })\n\n dispatchFields({ type: 'SET_ALL_ROWS_COLLAPSED', path, updatedRows })\n setDocFieldPreferences(path, { collapsed: collapsedIDs })\n },\n [dispatchFields, path, rows, setDocFieldPreferences],\n )\n\n const setCollapse = useCallback(\n (rowID: string, collapsed: boolean) => {\n const { collapsedIDs, updatedRows } = extractRowsAndCollapsedIDs({\n collapsed,\n rowID,\n rows,\n })\n\n dispatchFields({ type: 'SET_ROW_COLLAPSED', path, updatedRows })\n setDocFieldPreferences(path, { collapsed: collapsedIDs })\n },\n [dispatchFields, path, rows, setDocFieldPreferences],\n )\n\n const copyRow = useCallback(\n (rowIndex: number) => {\n const clipboardResult = clipboardCopy({\n type,\n blocks: clientBlocks,\n getDataToCopy: () =>\n reduceFormStateByPath({\n formState: { ...getFields() },\n path,\n rowIndex,\n }),\n path,\n rowIndex,\n t,\n })\n\n if (typeof clipboardResult === 'string') {\n toast.error(clipboardResult)\n } else {\n toast.success(t('general:copied'))\n }\n },\n [clientBlocks, path, t, type, getFields],\n )\n\n const pasteRow = useCallback(\n (rowIndex: number) => {\n const pasteArgs = {\n onPaste: (dataFromClipboard: ClipboardPasteData) => {\n const formState = { ...getFields() }\n const newState = mergeFormStateFromClipboard({\n dataFromClipboard,\n formState,\n path,\n rowIndex,\n })\n replaceState(newState)\n setModified(true)\n },\n path,\n schemaBlocks: clientBlocks,\n t,\n }\n\n const clipboardResult = clipboardPaste(pasteArgs)\n\n if (typeof clipboardResult === 'string') {\n toast.error(clipboardResult)\n }\n },\n [clientBlocks, getFields, path, replaceState, setModified, t],\n )\n\n const pasteBlocks = useCallback(\n (dataFromClipboard: ClipboardPasteData) => {\n const formState = { ...getFields() }\n const newState = mergeFormStateFromClipboard({\n dataFromClipboard,\n formState,\n path,\n })\n replaceState(newState)\n setModified(true)\n },\n [getFields, path, replaceState, setModified],\n )\n\n const hasMaxRows = maxRows && rows.length >= maxRows\n\n const fieldErrorCount = errorPaths.length\n const fieldHasErrors = submitted && fieldErrorCount + (valid ? 0 : 1) > 0\n\n const showMinRows = rows.length < minRows || (required && rows.length === 0)\n const showRequired = readOnly && rows.length === 0\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n fieldHasErrors ? `${baseClass}--has-error` : `${baseClass}--has-no-error`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={styles}\n >\n {showError && (\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n )}\n <header className={`${baseClass}__header`}>\n <div className={`${baseClass}__header-wrap`}>\n <div className={`${baseClass}__heading-with-error`}>\n <h3>\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel\n as=\"span\"\n label={label}\n localized={localized}\n path={path}\n required={required}\n />\n }\n />\n </h3>\n {fieldHasErrors && fieldErrorCount > 0 && (\n <ErrorPill count={fieldErrorCount} i18n={i18n} withMessage />\n )}\n </div>\n <ul className={`${baseClass}__header-actions`}>\n {rows.length > 0 && (\n <Fragment>\n <li>\n <button\n className={`${baseClass}__header-action`}\n onClick={() => toggleCollapseAll(true)}\n type=\"button\"\n >\n {t('fields:collapseAll')}\n </button>\n </li>\n <li>\n <button\n className={`${baseClass}__header-action`}\n onClick={() => toggleCollapseAll(false)}\n type=\"button\"\n >\n {t('fields:showAll')}\n </button>\n </li>\n </Fragment>\n )}\n <li>\n <ClipboardAction\n allowCopy={rows?.length > 0}\n allowPaste={!readOnly}\n blocks={clientBlocks}\n className={`${baseClass}__header-action`}\n disabled={disabled}\n getDataToCopy={() =>\n reduceFormStateByPath({\n formState: { ...getFields() },\n path,\n })\n }\n onPaste={pasteBlocks}\n path={path}\n type={type}\n />\n </li>\n </ul>\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </header>\n {BeforeInput}\n <NullifyLocaleField\n fieldValue={value}\n localized={localized}\n path={path}\n readOnly={readOnly}\n />\n {(rows.length > 0 || (!valid && (showRequired || showMinRows))) && (\n <DraggableSortable\n className={`${baseClass}__rows`}\n ids={rows.map((row) => row.id)}\n onDragEnd={({ moveFromIndex, moveToIndex }) => moveRow(moveFromIndex, moveToIndex)}\n >\n {rows.map((row, i) => {\n const { blockType, isLoading } = row\n const blockConfig: ClientBlock =\n config.blocksMap[blockType] ??\n ((blockReferences ?? blocks).find(\n (block) => typeof block !== 'string' && block.slug === blockType,\n ) as ClientBlock)\n\n if (blockConfig) {\n const rowPath = `${path}.${i}`\n\n const rowErrorCount = errorPaths.filter((errorPath) =>\n errorPath.startsWith(rowPath + '.'),\n ).length\n\n return (\n <DraggableSortableItem\n disabled={readOnly || disabled || !isSortable}\n id={row.id}\n key={row.id}\n >\n {(draggableSortableItemProps) => (\n <BlockRow\n {...draggableSortableItemProps}\n addRow={addRow}\n block={blockConfig}\n blocks={blockReferences ?? blocks}\n copyRow={copyRow}\n duplicateRow={duplicateRow}\n errorCount={rowErrorCount}\n fields={blockConfig.fields}\n hasMaxRows={hasMaxRows}\n isLoading={isLoading}\n isSortable={isSortable}\n Label={rows?.[i]?.customComponents?.RowLabel}\n labels={labels}\n moveRow={moveRow}\n parentPath={path}\n pasteRow={pasteRow}\n path={rowPath}\n permissions={permissions}\n readOnly={readOnly || disabled}\n removeRow={removeRow}\n row={row}\n rowCount={rows.length}\n rowIndex={i}\n schemaPath={schemaPath + blockConfig.slug}\n setCollapse={setCollapse}\n />\n )}\n </DraggableSortableItem>\n )\n }\n\n return null\n })}\n {!editingDefaultLocale && (\n <React.Fragment>\n {showMinRows && (\n <Banner type=\"error\">\n {t('validation:requiresAtLeast', {\n count: minRows,\n label:\n getTranslation(minRows > 1 ? labels.plural : labels.singular, i18n) ||\n t(minRows > 1 ? 'general:row' : 'general:rows'),\n })}\n </Banner>\n )}\n {showRequired && (\n <Banner>\n {t('validation:fieldHasNo', { label: getTranslation(labels.plural, i18n) })}\n </Banner>\n )}\n </React.Fragment>\n )}\n </DraggableSortable>\n )}\n {!hasMaxRows && (\n <Fragment>\n <DrawerToggler\n className={`${baseClass}__drawer-toggler`}\n disabled={readOnly || disabled}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={readOnly || disabled}\n el=\"span\"\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n >\n {t('fields:addLabel', { label: getTranslation(labels.singular, i18n) })}\n </Button>\n </DrawerToggler>\n <BlocksDrawer\n addRow={addRow}\n addRowIndex={rows?.length || 0}\n blocks={blockReferences ?? blocks}\n drawerSlug={drawerSlug}\n labels={labels}\n />\n </Fragment>\n )}\n {AfterInput}\n </div>\n )\n}\n\nexport const BlocksField = withCondition(BlocksFieldComponent)\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,QAAQ;AACtD,SAASC,KAAK,QAAQ;AAItB,SAASC,MAAM,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MAAA,EAAQA;;QAIb2C,UAAA;;AAGP;AAEA,OAAO,MAAMyF,WAAA,GAAchK,aAAA,CAAcc,oBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","React","Fragment","useCallback","useMemo","toast","Banner","Button","clipboardCopy","clipboardPaste","ClipboardAction","mergeFormStateFromClipboard","reduceFormStateByPath","DraggableSortableItem","DraggableSortable","DrawerToggler","useDrawerSlug","ErrorPill","RenderCustomComponent","useForm","useFormSubmitted","extractRowsAndCollapsedIDs","toggleAllRows","NullifyLocaleField","useField","withCondition","useConfig","useDocumentInfo","useLocale","useTranslation","scrollToID","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","BlockRow","BlocksDrawer","baseClass","BlocksFieldComponent","props","i18n","t","field","name","type","admin","className","description","isSortable","blockReferences","blocks","label","labels","labelsFromProps","localized","maxRows","minRows","minRowsProp","required","path","pathFromProps","permissions","readOnly","schemaPath","schemaPathFromProps","validate","setDocFieldPreferences","addFieldRow","dispatchFields","getFields","moveFieldRow","removeFieldRow","replaceState","setModified","code","locale","config","localization","drawerSlug","submitted","plural","singular","editingDefaultLocale","fallback","defaultLocale","clientBlocks","resolvedBlocks","blockReference","block","blocksMap","push","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","errorPaths","rows","showError","valid","hasRows","potentiallyStalePath","addRow","rowIndex","blockType","setTimeout","duplicateRow","removeRow","moveRow","moveFromIndex","moveToIndex","toggleCollapseAll","collapsed","collapsedIDs","updatedRows","setCollapse","rowID","copyRow","clipboardResult","getDataToCopy","formState","error","success","pasteRow","pasteArgs","onPaste","dataFromClipboard","newState","schemaBlocks","pasteBlocks","hasMaxRows","length","fieldErrorCount","fieldHasErrors","showMinRows","showRequired","styles","_jsxs","filter","Boolean","join","id","replace","style","_jsx","CustomComponent","Fallback","as","count","withMessage","onClick","allowCopy","allowPaste","fieldValue","ids","map","row","onDragEnd","i","isLoading","blockConfig","find","slug","rowPath","rowErrorCount","errorPath","startsWith","draggableSortableItemProps","errorCount","fields","RowLabel","parentPath","rowCount","buttonStyle","el","icon","iconPosition","iconStyle","addRowIndex","BlocksField"],"sources":["../../../src/fields/Blocks/index.tsx"],"sourcesContent":["'use client'\nimport type { BlocksFieldClientComponent, ClientBlock } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { Fragment, useCallback, useMemo } from 'react'\nimport { toast } from 'sonner'\n\nimport type { ClipboardPasteData } from '../../elements/ClipboardAction/types.js'\n\nimport { Banner } from '../../elements/Banner/index.js'\nimport { Button } from '../../elements/Button/index.js'\nimport { clipboardCopy, clipboardPaste } from '../../elements/ClipboardAction/clipboardUtilities.js'\nimport { ClipboardAction } from '../../elements/ClipboardAction/index.js'\nimport {\n mergeFormStateFromClipboard,\n reduceFormStateByPath,\n} from '../../elements/ClipboardAction/mergeFormStateFromClipboard.js'\nimport { DraggableSortableItem } from '../../elements/DraggableSortable/DraggableSortableItem/index.js'\nimport { DraggableSortable } from '../../elements/DraggableSortable/index.js'\nimport { DrawerToggler } from '../../elements/Drawer/index.js'\nimport { useDrawerSlug } from '../../elements/Drawer/useDrawerSlug.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useForm, useFormSubmitted } from '../../forms/Form/context.js'\nimport { extractRowsAndCollapsedIDs, toggleAllRows } from '../../forms/Form/rowHelpers.js'\nimport { NullifyLocaleField } from '../../forms/NullifyField/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 { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { scrollToID } from '../../utilities/scrollToID.js'\nimport './index.scss'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { BlockRow } from './BlockRow.js'\nimport { BlocksDrawer } from './BlocksDrawer/index.js'\n\nconst baseClass = 'blocks-field'\n\nconst BlocksFieldComponent: BlocksFieldClientComponent = (props) => {\n const { i18n, t } = useTranslation()\n\n const {\n field,\n field: {\n name,\n type,\n admin: { className, description, isSortable = true } = {},\n blockReferences,\n blocks,\n label,\n labels: labelsFromProps,\n localized,\n maxRows,\n minRows: minRowsProp,\n required,\n },\n path: pathFromProps,\n permissions,\n readOnly,\n schemaPath: schemaPathFromProps,\n validate,\n } = props\n\n const schemaPath = schemaPathFromProps ?? name\n\n const minRows = (minRowsProp ?? required) ? 1 : 0\n\n const { setDocFieldPreferences } = useDocumentInfo()\n const {\n addFieldRow,\n dispatchFields,\n getFields,\n moveFieldRow,\n removeFieldRow,\n replaceState,\n setModified,\n } = useForm()\n const { code: locale } = useLocale()\n const {\n config: { localization },\n config,\n } = useConfig()\n const drawerSlug = useDrawerSlug('blocks-drawer')\n const submitted = useFormSubmitted()\n\n const labels = {\n plural: t('fields:blocks'),\n singular: t('fields:block'),\n ...labelsFromProps,\n }\n\n const editingDefaultLocale = (() => {\n if (localization && localization.fallback) {\n const defaultLocale = localization.defaultLocale\n return locale === defaultLocale\n }\n\n return true\n })()\n\n const clientBlocks = useMemo(() => {\n if (!blockReferences) {\n return blocks\n }\n\n const resolvedBlocks: ClientBlock[] = []\n\n for (const blockReference of blockReferences) {\n const block =\n typeof blockReference === 'string' ? config.blocksMap[blockReference] : blockReference\n if (block) {\n resolvedBlocks.push(block)\n }\n }\n\n return resolvedBlocks\n }, [blockReferences, blocks, config.blocksMap])\n\n const memoizedValidate = useCallback(\n (value, options) => {\n // alternative locales can be null\n if (!editingDefaultLocale && value === null) {\n return true\n }\n if (typeof validate === 'function') {\n return validate(value, { ...options, maxRows, minRows, required })\n }\n },\n [maxRows, minRows, required, validate, editingDefaultLocale],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n errorPaths,\n path,\n rows = [],\n showError,\n valid,\n value,\n } = useField<number>({\n hasRows: true,\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const addRow = useCallback(\n (rowIndex: number, blockType: string) => {\n addFieldRow({\n blockType,\n path,\n rowIndex,\n schemaPath,\n })\n\n setTimeout(() => {\n scrollToID(`${path}-row-${rowIndex + 1}`)\n }, 0)\n },\n [addFieldRow, path, schemaPath],\n )\n\n const duplicateRow = useCallback(\n (rowIndex: number) => {\n dispatchFields({ type: 'DUPLICATE_ROW', path, rowIndex })\n setModified(true)\n\n setTimeout(() => {\n scrollToID(`${path}-row-${rowIndex + 1}`)\n }, 0)\n },\n [dispatchFields, path, setModified],\n )\n\n const removeRow = useCallback(\n (rowIndex: number) => {\n removeFieldRow({\n path,\n rowIndex,\n })\n },\n [path, removeFieldRow],\n )\n\n const moveRow = useCallback(\n (moveFromIndex: number, moveToIndex: number) => {\n moveFieldRow({ moveFromIndex, moveToIndex, path })\n },\n [moveFieldRow, path],\n )\n\n const toggleCollapseAll = useCallback(\n (collapsed: boolean) => {\n const { collapsedIDs, updatedRows } = toggleAllRows({\n collapsed,\n rows,\n })\n\n dispatchFields({ type: 'SET_ALL_ROWS_COLLAPSED', path, updatedRows })\n setDocFieldPreferences(path, { collapsed: collapsedIDs })\n },\n [dispatchFields, path, rows, setDocFieldPreferences],\n )\n\n const setCollapse = useCallback(\n (rowID: string, collapsed: boolean) => {\n const { collapsedIDs, updatedRows } = extractRowsAndCollapsedIDs({\n collapsed,\n rowID,\n rows,\n })\n\n dispatchFields({ type: 'SET_ROW_COLLAPSED', path, updatedRows })\n setDocFieldPreferences(path, { collapsed: collapsedIDs })\n },\n [dispatchFields, path, rows, setDocFieldPreferences],\n )\n\n const copyRow = useCallback(\n (rowIndex: number) => {\n const clipboardResult = clipboardCopy({\n type,\n blocks: clientBlocks,\n getDataToCopy: () =>\n reduceFormStateByPath({\n formState: { ...getFields() },\n path,\n rowIndex,\n }),\n path,\n rowIndex,\n t,\n })\n\n if (typeof clipboardResult === 'string') {\n toast.error(clipboardResult)\n } else {\n toast.success(t('general:copied'))\n }\n },\n [clientBlocks, path, t, type, getFields],\n )\n\n const pasteRow = useCallback(\n (rowIndex: number) => {\n const pasteArgs = {\n onPaste: (dataFromClipboard: ClipboardPasteData) => {\n const formState = { ...getFields() }\n const newState = mergeFormStateFromClipboard({\n dataFromClipboard,\n formState,\n path,\n rowIndex,\n })\n replaceState(newState)\n setModified(true)\n },\n path,\n schemaBlocks: clientBlocks,\n t,\n }\n\n const clipboardResult = clipboardPaste(pasteArgs)\n\n if (typeof clipboardResult === 'string') {\n toast.error(clipboardResult)\n }\n },\n [clientBlocks, getFields, path, replaceState, setModified, t],\n )\n\n const pasteBlocks = useCallback(\n (dataFromClipboard: ClipboardPasteData) => {\n const formState = { ...getFields() }\n const newState = mergeFormStateFromClipboard({\n dataFromClipboard,\n formState,\n path,\n })\n replaceState(newState)\n setModified(true)\n },\n [getFields, path, replaceState, setModified],\n )\n\n const hasMaxRows = maxRows && rows.length >= maxRows\n\n const fieldErrorCount = errorPaths.length\n const fieldHasErrors = submitted && fieldErrorCount + (valid ? 0 : 1) > 0\n\n const showMinRows = rows.length < minRows || (required && rows.length === 0)\n const showRequired = readOnly && rows.length === 0\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n fieldHasErrors ? `${baseClass}--has-error` : `${baseClass}--has-no-error`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={styles}\n >\n {showError && (\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n )}\n <header className={`${baseClass}__header`}>\n <div className={`${baseClass}__header-wrap`}>\n <div className={`${baseClass}__heading-with-error`}>\n <h3>\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel\n as=\"span\"\n label={label}\n localized={localized}\n path={path}\n required={required}\n />\n }\n />\n </h3>\n {fieldHasErrors && fieldErrorCount > 0 && (\n <ErrorPill count={fieldErrorCount} i18n={i18n} withMessage />\n )}\n </div>\n <ul className={`${baseClass}__header-actions`}>\n {rows.length > 0 && (\n <Fragment>\n <li>\n <button\n className={`${baseClass}__header-action`}\n onClick={() => toggleCollapseAll(true)}\n type=\"button\"\n >\n {t('fields:collapseAll')}\n </button>\n </li>\n <li>\n <button\n className={`${baseClass}__header-action`}\n onClick={() => toggleCollapseAll(false)}\n type=\"button\"\n >\n {t('fields:showAll')}\n </button>\n </li>\n </Fragment>\n )}\n <li>\n <ClipboardAction\n allowCopy={rows?.length > 0}\n allowPaste={!readOnly}\n blocks={clientBlocks}\n className={`${baseClass}__header-action`}\n disabled={disabled}\n getDataToCopy={() =>\n reduceFormStateByPath({\n formState: { ...getFields() },\n path,\n })\n }\n onPaste={pasteBlocks}\n path={path}\n type={type}\n />\n </li>\n </ul>\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </header>\n {BeforeInput}\n <NullifyLocaleField\n fieldValue={value}\n localized={localized}\n path={path}\n readOnly={readOnly}\n />\n {(rows.length > 0 || (!valid && (showRequired || showMinRows))) && (\n <DraggableSortable\n className={`${baseClass}__rows`}\n ids={rows.map((row) => row.id)}\n onDragEnd={({ moveFromIndex, moveToIndex }) => moveRow(moveFromIndex, moveToIndex)}\n >\n {rows.map((row, i) => {\n const { blockType, isLoading } = row\n\n const blockConfig: ClientBlock =\n config.blocksMap[blockType] ??\n ((blockReferences ?? blocks).find(\n (block) => typeof block !== 'string' && block.slug === blockType,\n ) as ClientBlock)\n\n if (blockConfig) {\n const rowPath = `${path}.${i}`\n\n const rowErrorCount = errorPaths.filter((errorPath) =>\n errorPath.startsWith(rowPath + '.'),\n ).length\n\n return (\n <DraggableSortableItem\n disabled={readOnly || disabled || !isSortable}\n id={row.id}\n key={row.id}\n >\n {(draggableSortableItemProps) => (\n <BlockRow\n {...draggableSortableItemProps}\n addRow={addRow}\n block={blockConfig}\n blocks={blockReferences ?? blocks}\n copyRow={copyRow}\n duplicateRow={duplicateRow}\n errorCount={rowErrorCount}\n fields={blockConfig.fields}\n hasMaxRows={hasMaxRows}\n isLoading={isLoading}\n isSortable={isSortable}\n Label={rows?.[i]?.customComponents?.RowLabel}\n labels={labels}\n moveRow={moveRow}\n parentPath={path}\n pasteRow={pasteRow}\n path={rowPath}\n permissions={permissions}\n readOnly={readOnly || disabled}\n removeRow={removeRow}\n row={row}\n rowCount={rows.length}\n rowIndex={i}\n schemaPath={schemaPath + blockConfig.slug}\n setCollapse={setCollapse}\n />\n )}\n </DraggableSortableItem>\n )\n }\n\n return null\n })}\n {!editingDefaultLocale && (\n <React.Fragment>\n {showMinRows && (\n <Banner type=\"error\">\n {t('validation:requiresAtLeast', {\n count: minRows,\n label:\n getTranslation(minRows > 1 ? labels.plural : labels.singular, i18n) ||\n t(minRows > 1 ? 'general:row' : 'general:rows'),\n })}\n </Banner>\n )}\n {showRequired && (\n <Banner>\n {t('validation:fieldHasNo', { label: getTranslation(labels.plural, i18n) })}\n </Banner>\n )}\n </React.Fragment>\n )}\n </DraggableSortable>\n )}\n {!hasMaxRows && (\n <Fragment>\n <DrawerToggler\n className={`${baseClass}__drawer-toggler`}\n disabled={readOnly || disabled}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={readOnly || disabled}\n el=\"span\"\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n >\n {t('fields:addLabel', { label: getTranslation(labels.singular, i18n) })}\n </Button>\n </DrawerToggler>\n <BlocksDrawer\n addRow={addRow}\n addRowIndex={rows?.length || 0}\n blocks={blockReferences ?? blocks}\n drawerSlug={drawerSlug}\n labels={labels}\n />\n </Fragment>\n )}\n {AfterInput}\n </div>\n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IAAA;UAAM;;uBAGzE6G,IAAA,CAACjH,YAAA;QACCuE,MAAA,EAAQA,MAAA;QACR4E,WAAA,EAAajF,IAAA,EAAMkC,MAAA,IAAU;QAC7BtF,MAAA,EAAQD,eAAA,IAAmBC,MAAA;QAC3B4B,UAAA,EAAYA,UAAA;QACZ1B,MAAA,EAAQA;;QAIb2C,UAAA;;AAGP;AAEA,OAAO,MAAMyF,WAAA,GAAchK,aAAA,CAAcc,oBAAA","ignoreList":[]}
|
|
@@ -159,7 +159,7 @@ const JoinFieldComponent = props => {
|
|
|
159
159
|
collectionSlug: docConfig?.slug,
|
|
160
160
|
config,
|
|
161
161
|
docID,
|
|
162
|
-
fields: relatedCollection
|
|
162
|
+
fields: relatedCollection?.fields,
|
|
163
163
|
segments: field.on.split('.')
|
|
164
164
|
});
|
|
165
165
|
}, [getEntityConfig, field.collection, field.on, docConfig?.slug, docID, config]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ObjectIdImport","fieldAffectsData","flattenTopLevelFields","React","useMemo","RelationshipTable","RenderCustomComponent","useField","withCondition","useConfig","useDocumentInfo","FieldDescription","FieldError","FieldLabel","fieldBaseClass","ObjectId","default","getInitialDrawerData","collectionSlug","config","docID","fields","segments","flattenedFields","keepPresentationalFields","path","field","find","name","type","value","Array","isArray","relationTo","hasMany","nextSegments","slice","length","initialData","id","toHexString","_block","blockReferences","blocks","block","blocksMap","blockInitialData","blockType","slug","JoinFieldComponent","props","admin","allowCreate","description","collection","label","localized","on","required","pathFromProps","docConfig","getEntityConfig","customComponents","AfterInput","BeforeInput","Description","Error","Label","showError","potentiallyStalePath","filterOptions","targetField","where","equals","and","initialDrawerData","relatedCollection","split","_jsxs","className","filter","Boolean","join","replace","_jsx","CustomComponent","Fallback","disableTable","fieldPath","docs","style","margin","parent","joinPath","undefined","JoinField"],"sources":["../../../src/fields/Join/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n ClientConfig,\n ClientField,\n JoinFieldClient,\n JoinFieldClientComponent,\n PaginatedDocs,\n Where,\n} from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { fieldAffectsData, 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 { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../index.js'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\n\n/**\n * Recursively builds the default data for joined collection\n */\nconst getInitialDrawerData = ({\n collectionSlug,\n config,\n docID,\n fields,\n segments,\n}: {\n collectionSlug: string\n config: ClientConfig\n docID: number | string\n fields: ClientField[]\n segments: string[]\n}) => {\n const flattenedFields = flattenTopLevelFields(fields, {\n keepPresentationalFields: true,\n })\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' && fieldAffectsData(field))) {\n return {\n [field.name]: getInitialDrawerData({\n collectionSlug,\n config,\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 config,\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.blockReferences ?? field.blocks) {\n const block = typeof _block === 'string' ? config.blocksMap[_block] : _block\n\n const blockInitialData = getInitialDrawerData({\n collectionSlug,\n config,\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: pathFromProps,\n } = props\n\n const { id: docID, docConfig } = useDocumentInfo()\n\n const { config, getEntityConfig } = useConfig()\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n path,\n showError,\n value,\n } = useField<PaginatedDocs>({\n potentiallyStalePath: pathFromProps,\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 = Array.isArray(collection)\n ? {}\n : {\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, collection, field.targetField.relationTo, field.where, on, docConfig?.slug])\n\n const initialDrawerData = useMemo(() => {\n const relatedCollection = getEntityConfig({\n collectionSlug: Array.isArray(field.collection) ? field.collection[0] : field.collection,\n })\n\n return getInitialDrawerData({\n collectionSlug: docConfig?.slug,\n config,\n docID,\n fields: relatedCollection.fields,\n segments: field.on.split('.'),\n })\n }, [getEntityConfig, field.collection, field.on, docConfig?.slug, docID, config])\n\n if (!docConfig) {\n return null\n }\n\n return (\n <div\n className={[fieldBaseClass, showError && 'error', 'join'].filter(Boolean).join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n >\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\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 fieldPath={path}\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 parent={\n Array.isArray(collection)\n ? {\n id: docID,\n collectionSlug: docConfig.slug,\n joinPath: path,\n }\n : undefined\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;;;AAWA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,gBAAgB,EAAEC,qBAAqB,QAAQ;AACxD,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,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAE/B,MAAMC,QAAA,GAAW,aAAaf,cAAA,GAAiBA,cAAA,CAAegB,OAAO,GAAGhB,cAAA;AAExE;;;AAGA,MAAMiB,oBAAA,GAAuBA,CAAC;EAC5BC,cAAc;EACdC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC;AAAQ,CAOT;EACC,MAAMC,eAAA,GAAkBrB,qBAAA,CAAsBmB,MAAA,EAAQ;IACpDG,wBAAA,EAA0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pE;MACZ,IACAqE,SAAA;MAEN7D,UAAA,EAAYqB;qBAEd8B,IAAA,CAAC9E,qBAAA;MACC+E,eAAA,EAAiBpB,WAAA;MACjBqB,QAAA,eAAUF,IAAA,CAACzE,gBAAA;QAAiB0C,WAAA,EAAaA,WAAA;QAAa5B,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAMsE,SAAA,GAAYvF,aAAA,CAAcyC,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ObjectIdImport","fieldAffectsData","flattenTopLevelFields","React","useMemo","RelationshipTable","RenderCustomComponent","useField","withCondition","useConfig","useDocumentInfo","FieldDescription","FieldError","FieldLabel","fieldBaseClass","ObjectId","default","getInitialDrawerData","collectionSlug","config","docID","fields","segments","flattenedFields","keepPresentationalFields","path","field","find","name","type","value","Array","isArray","relationTo","hasMany","nextSegments","slice","length","initialData","id","toHexString","_block","blockReferences","blocks","block","blocksMap","blockInitialData","blockType","slug","JoinFieldComponent","props","admin","allowCreate","description","collection","label","localized","on","required","pathFromProps","docConfig","getEntityConfig","customComponents","AfterInput","BeforeInput","Description","Error","Label","showError","potentiallyStalePath","filterOptions","targetField","where","equals","and","initialDrawerData","relatedCollection","split","_jsxs","className","filter","Boolean","join","replace","_jsx","CustomComponent","Fallback","disableTable","fieldPath","docs","style","margin","parent","joinPath","undefined","JoinField"],"sources":["../../../src/fields/Join/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n ClientConfig,\n ClientField,\n JoinFieldClient,\n JoinFieldClientComponent,\n PaginatedDocs,\n Where,\n} from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { fieldAffectsData, 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 { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../index.js'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\n\n/**\n * Recursively builds the default data for joined collection\n */\nconst getInitialDrawerData = ({\n collectionSlug,\n config,\n docID,\n fields,\n segments,\n}: {\n collectionSlug: string\n config: ClientConfig\n docID: number | string\n fields: ClientField[]\n segments: string[]\n}) => {\n const flattenedFields = flattenTopLevelFields(fields, {\n keepPresentationalFields: true,\n })\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' && fieldAffectsData(field))) {\n return {\n [field.name]: getInitialDrawerData({\n collectionSlug,\n config,\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 config,\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.blockReferences ?? field.blocks) {\n const block = typeof _block === 'string' ? config.blocksMap[_block] : _block\n\n const blockInitialData = getInitialDrawerData({\n collectionSlug,\n config,\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: pathFromProps,\n } = props\n\n const { id: docID, docConfig } = useDocumentInfo()\n\n const { config, getEntityConfig } = useConfig()\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n path,\n showError,\n value,\n } = useField<PaginatedDocs>({\n potentiallyStalePath: pathFromProps,\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 = Array.isArray(collection)\n ? {}\n : {\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, collection, field.targetField.relationTo, field.where, on, docConfig?.slug])\n\n const initialDrawerData = useMemo(() => {\n const relatedCollection = getEntityConfig({\n collectionSlug: Array.isArray(field.collection) ? field.collection[0] : field.collection,\n })\n\n return getInitialDrawerData({\n collectionSlug: docConfig?.slug,\n config,\n docID,\n fields: relatedCollection?.fields,\n segments: field.on.split('.'),\n })\n }, [getEntityConfig, field.collection, field.on, docConfig?.slug, docID, config])\n\n if (!docConfig) {\n return null\n }\n\n return (\n <div\n className={[fieldBaseClass, showError && 'error', 'join'].filter(Boolean).join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n >\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\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 fieldPath={path}\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 parent={\n Array.isArray(collection)\n ? {\n id: docID,\n collectionSlug: docConfig.slug,\n joinPath: path,\n }\n : undefined\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;;;AAWA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,gBAAgB,EAAEC,qBAAqB,QAAQ;AACxD,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,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAE/B,MAAMC,QAAA,GAAW,aAAaf,cAAA,GAAiBA,cAAA,CAAegB,OAAO,GAAGhB,cAAA;AAExE;;;AAGA,MAAMiB,oBAAA,GAAuBA,CAAC;EAC5BC,cAAc;EACdC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC;AAAQ,CAOT;EACC,MAAMC,eAAA,GAAkBrB,qBAAA,CAAsBmB,MAAA,EAAQ;IACpDG,wBAAA,EAA0B;EAC5B;EAEA,MAAMC,IAAA,GAAOH,QAAQ,CAAC,EAAE;EAExB,MAAMI,KAAA,GAAQH,eAAA,CAAgBI,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,GA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 export type SubmitOptions<C = Record<string, unknown>> = {
|
|
|
70
70
|
acceptValues?: AcceptValues;
|
|
71
71
|
action?: string;
|
|
72
72
|
/**
|
|
73
|
-
* @experimental - Note: this property is experimental and may change in the future. Use at your own discretion.
|
|
74
73
|
* If you want to pass additional data to the onSuccess callback, you can use this context object.
|
|
74
|
+
*
|
|
75
|
+
* @experimental This property is experimental and may change in the future.
|
|
75
76
|
*/
|
|
76
77
|
context?: C;
|
|
77
78
|
/**
|
|
@@ -94,11 +95,13 @@ export type SubmitOptions<C = Record<string, unknown>> = {
|
|
|
94
95
|
};
|
|
95
96
|
export type DispatchFields = React.Dispatch<any>;
|
|
96
97
|
export type Submit = <T extends Response, C extends Record<string, unknown>>(options?: SubmitOptions<C>, e?: React.FormEvent<HTMLFormElement>) => Promise</**
|
|
97
|
-
* @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own discretion.
|
|
98
98
|
* Returns the form state and the response from the server.
|
|
99
|
-
|
|
99
|
+
*
|
|
100
100
|
* @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own discretion.
|
|
101
|
+
*/ /**
|
|
101
102
|
* Returns the form state and the response from the server.
|
|
103
|
+
*
|
|
104
|
+
* @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own discretion.
|
|
102
105
|
*/ {
|
|
103
106
|
formState?: FormState;
|
|
104
107
|
res: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,IAAI,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EACH,SAAS,EACT,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2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AAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAChF,eAAe,EAAE,CAAC,EAChB,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,aAAa,GACd,EAAE;QACD,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,MAAM,CAAA;QAClB,aAAa,CAAC,EAAE,SAAS,CAAA;KAC1B,KAAK,IAAI,CAAA;IACV,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAA;IACxC,KAAK,EAAE,KAAK,CAAA;IACZ;;;OAGG;IACH,uBAAuB,EAAE,aAAa,CAAA;IACtC,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;IACxC,UAAU,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAA;IACzC,WAAW,EAAE,WAAW,CAAA;IACxB,aAAa,EAAE,aAAa,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type {\n ClientField,\n Data,\n FormField,\n FormState,\n Row,\n TypedUser,\n ValidationFieldError,\n} from 'payload'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nimport type { AcceptValues } from './mergeServerFormState.js'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormOnSuccess<T = unknown, C = Record<string, unknown>> = (\n json: T,\n options?: {\n /**\n * Arbitrary context passed to the onSuccess callback.\n */\n context?: C\n /**\n * Form state at the time of the request used to retrieve the JSON response.\n */\n formState?: FormState\n },\n) => Promise<FormState | void> | void\n\nexport type FormProps = {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n /**\n * If you don't want the form to be a <form> element, you can pass a string here to use as the wrapper element.\n */\n el?: string\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: ClientField[]\n handleResponse?: (\n res: Response,\n successToast: (value: string) => void,\n errorToast: (value: string) => void,\n ) => void\n initialState?: FormState\n /**\n * Determines if this Form is the main, top-level Form of a document. If set to true, the\n * Form's children will be wrapped in a DocumentFormContext, which lets you access this document\n * Form's data and fields from any child component - even if that child component is wrapped in a child\n * Form (e.g. a lexical block).\n */\n isDocumentForm?: boolean\n isInitializing?: boolean\n log?: boolean\n onChange?: ((args: { formState: FormState; submitted?: boolean }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: FormOnSuccess\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n} & (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n)\n\nexport type SubmitOptions<C = Record<string, unknown>> = {\n acceptValues?: AcceptValues\n action?: string\n /**\n *
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type {\n ClientField,\n Data,\n FormField,\n FormState,\n Row,\n TypedUser,\n ValidationFieldError,\n} from 'payload'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nimport type { AcceptValues } from './mergeServerFormState.js'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormOnSuccess<T = unknown, C = Record<string, unknown>> = (\n json: T,\n options?: {\n /**\n * Arbitrary context passed to the onSuccess callback.\n */\n context?: C\n /**\n * Form state at the time of the request used to retrieve the JSON response.\n */\n formState?: FormState\n },\n) => Promise<FormState | void> | void\n\nexport type FormProps = {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n /**\n * If you don't want the form to be a <form> element, you can pass a string here to use as the wrapper element.\n */\n el?: string\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: ClientField[]\n handleResponse?: (\n res: Response,\n successToast: (value: string) => void,\n errorToast: (value: string) => void,\n ) => void\n initialState?: FormState\n /**\n * Determines if this Form is the main, top-level Form of a document. If set to true, the\n * Form's children will be wrapped in a DocumentFormContext, which lets you access this document\n * Form's data and fields from any child component - even if that child component is wrapped in a child\n * Form (e.g. a lexical block).\n */\n isDocumentForm?: boolean\n isInitializing?: boolean\n log?: boolean\n onChange?: ((args: { formState: FormState; submitted?: boolean }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: FormOnSuccess\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n} & (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n)\n\nexport type SubmitOptions<C = Record<string, unknown>> = {\n acceptValues?: AcceptValues\n action?: string\n /**\n * If you want to pass additional data to the onSuccess callback, you can use this context object.\n *\n * @experimental This property is experimental and may change in the future.\n */\n context?: C\n /**\n * When true, will disable the form while it is processing.\n * @default true\n */\n disableFormWhileProcessing?: boolean\n /**\n * When true, will disable the success toast after form submission.\n * @default false\n */\n disableSuccessStatus?: boolean\n method?: string\n overrides?: ((formState) => FormData) | Record<string, unknown>\n /**\n * When true, will skip validation before submitting the form.\n * @default false\n */\n skipValidation?: boolean\n}\n\nexport type DispatchFields = React.Dispatch<any>\n\nexport type Submit = <T extends Response, C extends Record<string, unknown>>(\n options?: SubmitOptions<C>,\n e?: React.FormEvent<HTMLFormElement>,\n) => Promise</**\n * Returns the form state and the response from the server.\n *\n * @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own discretion.\n */\n{ formState?: FormState; res: T } | void>\n\nexport type ValidateForm = () => Promise<boolean>\n\nexport type CreateFormData = (\n overrides?: Record<string, unknown>,\n /**\n * If mergeOverrideData true, the data will be merged with the existing data in the form state.\n * @default true\n */\n options?: {\n /**\n * If provided, will use this instead of of derived data from the current form state.\n */\n data?: Data\n mergeOverrideData?: boolean\n },\n) => FormData | Promise<FormData>\n\nexport type GetFields = () => FormState\nexport type GetField = (path: string) => FormField\nexport type GetData = () => Data\nexport type GetSiblingData = (path: string) => Data\nexport type GetDataByPath = <T = unknown>(path: string) => T\nexport type SetModified = (modified: boolean) => void\nexport type SetSubmitted = (submitted: boolean) => void\nexport type SetProcessing = (processing: boolean) => void\n\nexport type Reset = (data: unknown) => Promise<void>\n\nexport type REPLACE_STATE = {\n optimize?: boolean\n /**\n * If `sanitize` is true, default values will be set for form field properties that are not present in the incoming state.\n * For example, `valid` will be set to true if it is not present in the incoming state.\n */\n sanitize?: boolean\n state: FormState\n type: 'REPLACE_STATE'\n}\n\nexport type REMOVE = {\n path: string\n type: 'REMOVE'\n}\n\nexport type MODIFY_CONDITION = {\n path: string\n result: boolean\n type: 'MODIFY_CONDITION'\n user: TypedUser\n}\n\nexport type UPDATE = {\n path: string\n type: 'UPDATE'\n} & Partial<FormField>\n\nexport type UPDATE_MANY = {\n formState: FormState\n type: 'UPDATE_MANY'\n}\n\nexport type REMOVE_ROW = {\n path: string\n rowIndex: number\n type: 'REMOVE_ROW'\n}\n\nexport type ADD_ROW = {\n blockType?: string\n path: string\n rowIndex?: number\n subFieldState?: FormState\n type: 'ADD_ROW'\n}\n\nexport type MERGE_SERVER_STATE = {\n acceptValues?: AcceptValues\n prevStateRef: React.RefObject<FormState>\n serverState: FormState\n type: 'MERGE_SERVER_STATE'\n}\n\nexport type REPLACE_ROW = {\n blockType?: string\n path: string\n rowIndex: number\n subFieldState?: FormState\n type: 'REPLACE_ROW'\n}\n\nexport type DUPLICATE_ROW = {\n path: string\n rowIndex: number\n type: 'DUPLICATE_ROW'\n}\n\nexport type MOVE_ROW = {\n moveFromIndex: number\n moveToIndex: number\n path: string\n type: 'MOVE_ROW'\n}\n\nexport type ADD_SERVER_ERRORS = {\n errors: ValidationFieldError[]\n type: 'ADD_SERVER_ERRORS'\n}\n\nexport type SET_ROW_COLLAPSED = {\n path: string\n type: 'SET_ROW_COLLAPSED'\n updatedRows: Row[]\n}\n\nexport type SET_ALL_ROWS_COLLAPSED = {\n path: string\n type: 'SET_ALL_ROWS_COLLAPSED'\n updatedRows: Row[]\n}\n\nexport type FieldAction =\n | ADD_ROW\n | ADD_SERVER_ERRORS\n | DUPLICATE_ROW\n | MERGE_SERVER_STATE\n | MODIFY_CONDITION\n | MOVE_ROW\n | REMOVE\n | REMOVE_ROW\n | REPLACE_ROW\n | REPLACE_STATE\n | SET_ALL_ROWS_COLLAPSED\n | SET_ROW_COLLAPSED\n | UPDATE\n | UPDATE_MANY\n\nexport type FormFieldsContext = [FormState, Dispatch<FieldAction>]\n\nexport type Context = {\n addFieldRow: ({\n blockType,\n path,\n rowIndex,\n schemaPath,\n subFieldState,\n }: {\n blockType?: string\n path: string\n rowIndex?: number\n schemaPath: string\n subFieldState?: FormState\n }) => void\n buildRowErrors: () => void\n createFormData: CreateFormData\n disabled: boolean\n dispatchFields: Dispatch<FieldAction>\n /**\n * Form context fields may be outdated and should not be relied on. Instead, prefer `useFormFields`.\n */\n fields: FormState\n formRef: React.RefObject<HTMLFormElement>\n getData: GetData\n getDataByPath: GetDataByPath\n getField: GetField\n getFields: GetFields\n getSiblingData: GetSiblingData\n initializing: boolean\n /**\n * Tracks wether the form state passes validation.\n * For example the state could be submitted but invalid as field errors have been returned.\n */\n isValid: boolean\n moveFieldRow: ({\n moveFromIndex,\n moveToIndex,\n path,\n }: {\n moveFromIndex: number\n moveToIndex: number\n path: string\n }) => void\n removeFieldRow: ({ path, rowIndex }: { path: string; rowIndex: number }) => void\n replaceFieldRow: ({\n blockType,\n path,\n rowIndex,\n schemaPath,\n subFieldState,\n }: {\n blockType?: string\n path: string\n rowIndex: number\n schemaPath: string\n subFieldState?: FormState\n }) => void\n replaceState: (state: FormState) => void\n reset: Reset\n /**\n * If the form has started processing in the background (e.g.\n * if autosave is running), this will be true.\n */\n setBackgroundProcessing: SetProcessing\n setDisabled: (disabled: boolean) => void\n setIsValid: (processing: boolean) => void\n setModified: SetModified\n setProcessing: SetProcessing\n setSubmitted: SetSubmitted\n submit: Submit\n uuid?: string\n validateForm: ValidateForm\n}\n"],"mappings":"AAwQA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAInD,OAAO,cAAc,CAAA;AAMrB,OAAO,EAAE,iBAAiB,IAAI,KAAK,EAAE,CAAA;AAErC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgGpD,CAAA"}
|
|
@@ -6,8 +6,8 @@ import { fieldIsHiddenOrDisabled, getFieldPaths, getFieldPermissions } from 'pay
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { RenderIfInViewport } from '../../elements/RenderIfInViewport/index.js';
|
|
8
8
|
import { useOperation } from '../../providers/Operation/index.js';
|
|
9
|
-
import { FieldPathContext } from './context.js';
|
|
10
9
|
import './index.scss';
|
|
10
|
+
import { FieldPathContext } from './context.js';
|
|
11
11
|
import { RenderField } from './RenderField.js';
|
|
12
12
|
const baseClass = 'render-fields';
|
|
13
13
|
export const RenderFields = props => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","fieldIsHiddenOrDisabled","getFieldPaths","getFieldPermissions","React","RenderIfInViewport","useOperation","FieldPathContext","RenderField","baseClass","RenderFields","props","$","className","fields","forceRender","margins","parentIndexPath","parentPath","parentSchemaPath","permissions","readOnly","readOnlyFromParent","operation","length","t0","t1","t2","filter","Boolean","t3","join","t4","t5","field","i","hasOperationPermission","fieldPermissions","read","hasReadPermission","parentName","includes","split","isReadOnly","admin","indexPath","path","schemaPath","index","_jsx","value","children","clientFieldConfig","map"],"sources":["../../../src/forms/RenderFields/index.tsx"],"sourcesContent":["'use client'\n\nimport { fieldIsHiddenOrDisabled, getFieldPaths, getFieldPermissions } from 'payload/shared'\nimport React from 'react'\n\nimport type { RenderFieldsProps } from './types.js'\n\nimport { RenderIfInViewport } from '../../elements/RenderIfInViewport/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { FieldPathContext } from './context.js'\nimport
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","fieldIsHiddenOrDisabled","getFieldPaths","getFieldPermissions","React","RenderIfInViewport","useOperation","FieldPathContext","RenderField","baseClass","RenderFields","props","$","className","fields","forceRender","margins","parentIndexPath","parentPath","parentSchemaPath","permissions","readOnly","readOnlyFromParent","operation","length","t0","t1","t2","filter","Boolean","t3","join","t4","t5","field","i","hasOperationPermission","fieldPermissions","read","hasReadPermission","parentName","includes","split","isReadOnly","admin","indexPath","path","schemaPath","index","_jsx","value","children","clientFieldConfig","map"],"sources":["../../../src/forms/RenderFields/index.tsx"],"sourcesContent":["'use client'\n\nimport type { SanitizedFieldPermissions } from 'payload'\n\nimport { fieldIsHiddenOrDisabled, getFieldPaths, getFieldPermissions } from 'payload/shared'\nimport React from 'react'\n\nimport type { RenderFieldsProps } from './types.js'\n\nimport { RenderIfInViewport } from '../../elements/RenderIfInViewport/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport './index.scss'\nimport { FieldPathContext } from './context.js'\nimport { RenderField } from './RenderField.js'\n\nconst baseClass = 'render-fields'\n\nexport { RenderFieldsProps as Props }\n\nexport const RenderFields: React.FC<RenderFieldsProps> = (props) => {\n const {\n className,\n fields,\n forceRender,\n margins,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n permissions,\n readOnly: readOnlyFromParent,\n } = props\n\n const operation = useOperation()\n\n if (fields && fields.length > 0) {\n return (\n <RenderIfInViewport\n className={[\n baseClass,\n className,\n margins && `${baseClass}--margins-${margins}`,\n margins === false && `${baseClass}--margins-none`,\n ]\n .filter(Boolean)\n .join(' ')}\n forceRender={forceRender}\n >\n {fields.map((field, i) => {\n // For sidebar fields in the main fields array, `field` will be `null`, and visa versa\n // This is to keep the order of the fields consistent and maintain the correct index paths for the main fields (i)\n if (!field || fieldIsHiddenOrDisabled(field)) {\n return null\n }\n\n const {\n operation: hasOperationPermission,\n permissions: fieldPermissions,\n read: hasReadPermission,\n } = getFieldPermissions({\n field,\n operation,\n parentName: parentPath?.includes('.')\n ? parentPath.split('.')[parentPath.split('.').length - 1]\n : parentPath,\n permissions,\n })\n\n // If the user cannot read the field, then filter it out\n // This is different from `admin.readOnly` which is executed based on `operation`\n if ('name' in field && !hasReadPermission) {\n return null\n }\n\n // `admin.readOnly` displays the value but prevents the field from being edited\n let isReadOnly = readOnlyFromParent || field?.admin?.readOnly\n\n // If parent field is `readOnly: true`, but this field is `readOnly: false`, the field should still be editable\n if (isReadOnly && field.admin?.readOnly === false) {\n isReadOnly = false\n }\n\n // If the user does not have access at the operation level, to begin with, force it to be read-only\n if ('name' in field && !hasOperationPermission) {\n isReadOnly = true\n }\n\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: i,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n return (\n <FieldPathContext key={`${path}-${i}`} value={path}>\n <RenderField\n clientFieldConfig={field}\n forceRender={forceRender}\n indexPath={indexPath}\n parentPath={parentPath}\n parentSchemaPath={parentSchemaPath}\n path={path}\n permissions={fieldPermissions as SanitizedFieldPermissions}\n readOnly={isReadOnly}\n schemaPath={schemaPath}\n />\n </FieldPathContext>\n )\n })}\n </RenderIfInViewport>\n )\n }\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,uBAAuB,EAAEC,aAAa,EAAEC,mBAAmB,QAAQ;AAC5E,OAAOC,KAAA,MAAW;AAIlB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,QAAQ;AAC7B,OAAO;AACP,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAE5B,MAAMC,SAAA,GAAY;AAIlB,OAAO,MAAMC,YAAA,GAA4CC,KAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EACvD;IAAAa,SAAA;IAAAC,MAAA;IAAAC,WAAA;IAAAC,OAAA;IAAAC,eAAA;IAAAC,UAAA;IAAAC,gBAAA;IAAAC,WAAA;IAAAC,QAAA,EAAAC;EAAA,IAUIX,KAAA;EAEJ,MAAAY,SAAA,GAAkBjB,YAAA;EAAA,IAEdQ,MAAA,IAAUA,MAAA,CAAAU,MAAA,IAAgB;IAMtB,MAAAC,EAAA,GAAAT,OAAA,IAAW,GAAAP,SAAA,aAAyBO,OAAA,EAAS;IAC7C,MAAAU,EAAA,GAAAV,OAAA,UAAY,IAAS,GAAAP,SAAA,gBAA4B;IAAA,IAAAkB,EAAA;IAAA,IAAAf,CAAA,Q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AA,CAAWpB,EA8DZ;MAAA,C;;;;;;;;;;;;;;WAzEFD,E;;;CA+EN","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/forms/RowLabel/Context/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,KAAK,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;IAC/B,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAQD,KAAK,KAAK,CAAC,CAAC,IAAI;IACd,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACnC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAEjC,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/forms/RowLabel/Context/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,KAAK,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;IAC/B,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAQD,KAAK,KAAK,CAAC,CAAC,IAAI;IACd,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACnC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAEjC,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAUrD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,CAAC,OACG,YAAY,CAAC,CAAC,CAC7C,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { c as _c } from "react/compiler-runtime";
|
|
4
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
4
|
import React from 'react';
|
|
6
5
|
import { useWatchForm } from '../../Form/context.js';
|
|
@@ -9,40 +8,27 @@ const RowLabel = /*#__PURE__*/React.createContext({
|
|
|
9
8
|
path: '',
|
|
10
9
|
rowNumber: undefined
|
|
11
10
|
});
|
|
12
|
-
export const RowLabelProvider =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
rowNumber
|
|
18
|
-
} = t0;
|
|
11
|
+
export const RowLabelProvider = ({
|
|
12
|
+
children,
|
|
13
|
+
path,
|
|
14
|
+
rowNumber
|
|
15
|
+
}) => {
|
|
19
16
|
const {
|
|
20
17
|
getDataByPath,
|
|
21
18
|
getSiblingData
|
|
22
19
|
} = useWatchForm();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
$[0] = children;
|
|
37
|
-
$[1] = getDataByPath;
|
|
38
|
-
$[2] = getSiblingData;
|
|
39
|
-
$[3] = path;
|
|
40
|
-
$[4] = rowNumber;
|
|
41
|
-
$[5] = t1;
|
|
42
|
-
} else {
|
|
43
|
-
t1 = $[5];
|
|
44
|
-
}
|
|
45
|
-
return t1;
|
|
20
|
+
const collapsibleData = getSiblingData(path);
|
|
21
|
+
const arrayData = getDataByPath(path);
|
|
22
|
+
const data = arrayData || collapsibleData;
|
|
23
|
+
const contextValue = React.useMemo(() => ({
|
|
24
|
+
data,
|
|
25
|
+
path,
|
|
26
|
+
rowNumber
|
|
27
|
+
}), [data, path, rowNumber]);
|
|
28
|
+
return /*#__PURE__*/_jsx(RowLabel, {
|
|
29
|
+
value: contextValue,
|
|
30
|
+
children: children
|
|
31
|
+
});
|
|
46
32
|
};
|
|
47
33
|
export const useRowLabel = () => {
|
|
48
34
|
return React.use(RowLabel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useWatchForm","RowLabel","createContext","data","path","rowNumber","undefined","RowLabelProvider","children","getDataByPath","getSiblingData","collapsibleData","arrayData","contextValue","useMemo","_jsx","value","useRowLabel","use"],"sources":["../../../../src/forms/RowLabel/Context/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { useWatchForm } from '../../Form/context.js'\n\ntype RowLabelType<T = unknown> = {\n readonly data: T\n readonly path: string\n readonly rowNumber?: number\n}\n\nconst RowLabel = React.createContext<RowLabelType>({\n data: {},\n path: '',\n rowNumber: undefined,\n})\n\ntype Props<T> = {\n readonly children: React.ReactNode\n} & Omit<RowLabelType<T>, 'data'>\n\nexport const RowLabelProvider: React.FC<Props<unknown>> = ({ children, path, rowNumber }) => {\n const { getDataByPath, getSiblingData } = useWatchForm()\n const collapsibleData = getSiblingData(path)\n const arrayData = getDataByPath(path)\n\n const data = arrayData || collapsibleData\n\n const contextValue = React.useMemo(() => ({ data, path, rowNumber }), [data, path, rowNumber])\n\n return <RowLabel value={contextValue}>{children}</RowLabel>\n}\n\nexport const useRowLabel = <T,>() => {\n return React.use(RowLabel) as RowLabelType<T>\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,MAAW;AAElB,SAASC,YAAY,QAAQ;AAQ7B,MAAMC,QAAA,gBAAWF,KAAA,CAAMG,aAAa,CAAe;EACjDC,IAAA,EAAM,CAAC;EACPC,IAAA,EAAM;EACNC,SAAA,EAAWC;AACb;AAMA,OAAO,MAAMC,gBAAA,GAA6CA,CAAC;EAAEC,QAAQ;EAAEJ,IAAI;EAAEC;AAAS,CAAE;EACtF,MAAM;IAAEI,aAAa;IAAEC;EAAc,CAAE,GAAGV,YAAA;EAC1C,MAAMW,eAAA,GAAkBD,cAAA,CAAeN,IAAA;EACvC,MAAMQ,SAAA,GAAYH,aAAA,CAAcL,IAAA;EAEhC,MAAMD,IAAA,GAAOS,SAAA,IAAaD,eAAA;EAE1B,MAAME,YAAA,GAAed,KAAA,CAAMe,OAAO,CAAC,OAAO;IAAEX,IAAA;IAAMC,IAAA;IAAMC;EAAU,IAAI,CAACF,IAAA,EAAMC,IAAA,EAAMC,SAAA,CAAU;EAE7F,oBAAOU,IAAA,CAACd,QAAA;IAASe,KAAA,EAAOH,YAAA;cAAeL;;AACzC;AAEA,OAAO,MAAMS,WAAA,GAAcA,CAAA;EACzB,OAAOlB,KAAA,CAAMmB,GAAG,CAACjB,QAAA;AACnB","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ClientUser, SanitizedPermissions, TypedUser } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export type UserWithToken<T = ClientUser> = {
|
|
4
|
+
/** seconds until expiration */
|
|
4
5
|
exp: number;
|
|
5
6
|
token: string;
|
|
6
7
|
user: T;
|
|
@@ -16,7 +17,7 @@ export type AuthContext<T = ClientUser> = {
|
|
|
16
17
|
setUser: (user: null | UserWithToken<T>) => void;
|
|
17
18
|
strategy?: string;
|
|
18
19
|
token?: string;
|
|
19
|
-
|
|
20
|
+
tokenExpirationMs?: number;
|
|
20
21
|
user?: null | T;
|
|
21
22
|
};
|
|
22
23
|
type Props = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Auth/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAM1E,OAAO,KAA+D,MAAM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