@payloadcms/ui 4.0.0-internal.a7ca468 → 4.0.0-internal.af6aad0
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/AddNewRelation/index.css +0 -4
- package/dist/elements/AddNewRelation/index.js +2 -2
- package/dist/elements/AddNewRelation/index.js.map +1 -1
- package/dist/elements/AppHeader/index.css +5 -0
- package/dist/elements/AppHeader/index.d.ts +1 -8
- package/dist/elements/AppHeader/index.d.ts.map +1 -1
- package/dist/elements/AppHeader/index.js +4 -13
- package/dist/elements/AppHeader/index.js.map +1 -1
- package/dist/elements/ArrayAction/index.d.ts +1 -0
- package/dist/elements/ArrayAction/index.d.ts.map +1 -1
- package/dist/elements/ArrayAction/index.js +45 -32
- package/dist/elements/ArrayAction/index.js.map +1 -1
- package/dist/elements/BulkUpload/AddFilesView/index.css +10 -4
- package/dist/elements/BulkUpload/AddFilesView/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/AddFilesView/index.js +71 -51
- package/dist/elements/BulkUpload/AddFilesView/index.js.map +1 -1
- package/dist/elements/Button/index.css +25 -2
- package/dist/elements/Button/index.d.ts.map +1 -1
- package/dist/elements/Button/index.js +2 -0
- package/dist/elements/Button/index.js.map +1 -1
- package/dist/elements/Button/types.d.ts +1 -1
- package/dist/elements/Button/types.d.ts.map +1 -1
- package/dist/elements/Button/types.js.map +1 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts +10 -0
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts.map +1 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js +65 -3
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js.map +1 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js +345 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js.map +1 -1
- package/dist/elements/DefaultListViewTabs/index.css +1 -0
- package/dist/elements/DefaultListViewTabs/index.d.ts.map +1 -1
- package/dist/elements/DefaultListViewTabs/index.js +84 -62
- package/dist/elements/DefaultListViewTabs/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/types.d.ts +1 -1
- package/dist/elements/DocumentDrawer/types.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/types.js.map +1 -1
- package/dist/elements/Drawer/index.css +10 -4
- package/dist/elements/Drawer/types.d.ts +2 -2
- package/dist/elements/Drawer/types.d.ts.map +1 -1
- package/dist/elements/Drawer/types.js.map +1 -1
- package/dist/elements/Dropzone/index.css +10 -4
- package/dist/elements/DuplicateDocument/SelectLocalesDrawer/index.js +3 -2
- package/dist/elements/DuplicateDocument/SelectLocalesDrawer/index.js.map +1 -1
- package/dist/elements/FileManager/index.css +0 -30
- package/dist/elements/FileManager/index.d.ts.map +1 -1
- package/dist/elements/FileManager/index.js +379 -287
- package/dist/elements/FileManager/index.js.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/Column/index.css +22 -4
- package/dist/elements/Hierarchy/ColumnBrowser/Column/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/Column/index.js +68 -49
- package/dist/elements/Hierarchy/ColumnBrowser/Column/index.js.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.css +100 -15
- package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.js +97 -137
- package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.js.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/index.d.ts +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/index.js +51 -23
- package/dist/elements/Hierarchy/ColumnBrowser/index.js.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/types.d.ts +26 -3
- package/dist/elements/Hierarchy/ColumnBrowser/types.d.ts.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/types.js.map +1 -1
- package/dist/elements/Hierarchy/CreateNewButton/index.css +9 -0
- package/dist/elements/Hierarchy/CreateNewButton/index.d.ts +9 -0
- package/dist/elements/Hierarchy/CreateNewButton/index.d.ts.map +1 -0
- package/dist/elements/Hierarchy/CreateNewButton/index.js +111 -0
- package/dist/elements/Hierarchy/CreateNewButton/index.js.map +1 -0
- package/dist/elements/Hierarchy/DocHeaderButton/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/DocHeaderButton/index.js +6 -1
- package/dist/elements/Hierarchy/DocHeaderButton/index.js.map +1 -1
- package/dist/elements/Hierarchy/DocHeaderButton/index.server.js +1 -3
- package/dist/elements/Hierarchy/DocHeaderButton/index.server.js.map +1 -1
- package/dist/elements/Hierarchy/Field/index.client.d.ts +5 -0
- package/dist/elements/Hierarchy/Field/index.client.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Field/index.client.js +120 -95
- package/dist/elements/Hierarchy/Field/index.client.js.map +1 -1
- package/dist/elements/Hierarchy/Field/index.css +3 -34
- package/dist/elements/Hierarchy/Modal/Footer/index.css +45 -0
- package/dist/elements/Hierarchy/Modal/Footer/index.d.ts +28 -0
- package/dist/elements/Hierarchy/Modal/Footer/index.d.ts.map +1 -0
- package/dist/elements/Hierarchy/Modal/Footer/index.js +166 -0
- package/dist/elements/Hierarchy/Modal/Footer/index.js.map +1 -0
- package/dist/elements/Hierarchy/Modal/fetchAncestorPath.d.ts +18 -4
- package/dist/elements/Hierarchy/Modal/fetchAncestorPath.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Modal/fetchAncestorPath.js +88 -24
- package/dist/elements/Hierarchy/Modal/fetchAncestorPath.js.map +1 -1
- package/dist/elements/Hierarchy/Modal/index.css +4 -53
- package/dist/elements/Hierarchy/Modal/index.d.ts +5 -2
- package/dist/elements/Hierarchy/Modal/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Modal/index.js +136 -99
- package/dist/elements/Hierarchy/Modal/index.js.map +1 -1
- package/dist/elements/Hierarchy/Modal/types.d.ts +15 -0
- package/dist/elements/Hierarchy/Modal/types.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Modal/types.js.map +1 -1
- package/dist/elements/Hierarchy/MoveMany/index.d.ts +7 -3
- package/dist/elements/Hierarchy/MoveMany/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/MoveMany/index.js +43 -170
- package/dist/elements/Hierarchy/MoveMany/index.js.map +1 -1
- package/dist/elements/Hierarchy/Search/index.css +2 -9
- package/dist/elements/Hierarchy/Search/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Search/index.js +6 -73
- package/dist/elements/Hierarchy/Search/index.js.map +1 -1
- package/dist/elements/Hierarchy/Search/types.d.ts +2 -6
- package/dist/elements/Hierarchy/Search/types.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Search/types.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.d.ts +0 -4
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.js +101 -186
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.js +1 -21
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.css +3 -3
- package/dist/elements/Hierarchy/Tree/TreeNode/index.css +59 -29
- package/dist/elements/Hierarchy/Tree/TreeNode/index.d.ts +1 -1
- package/dist/elements/Hierarchy/Tree/TreeNode/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeNode/index.js +54 -10
- package/dist/elements/Hierarchy/Tree/TreeNode/index.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/index.css +8 -9
- package/dist/elements/Hierarchy/Tree/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/index.js +29 -47
- package/dist/elements/Hierarchy/Tree/index.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/types.d.ts +9 -1
- package/dist/elements/Hierarchy/Tree/types.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/types.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/useChildren.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/useChildren.js +11 -1
- package/dist/elements/Hierarchy/Tree/useChildren.js.map +1 -1
- package/dist/elements/Hierarchy/getFolderHierarchySlug.d.ts +22 -0
- package/dist/elements/Hierarchy/getFolderHierarchySlug.d.ts.map +1 -0
- package/dist/elements/Hierarchy/getFolderHierarchySlug.js +17 -0
- package/dist/elements/Hierarchy/getFolderHierarchySlug.js.map +1 -0
- package/dist/elements/Hierarchy/move/moveDocuments.d.ts +34 -0
- package/dist/elements/Hierarchy/move/moveDocuments.d.ts.map +1 -0
- package/dist/elements/Hierarchy/move/moveDocuments.js +94 -0
- package/dist/elements/Hierarchy/move/moveDocuments.js.map +1 -0
- package/dist/elements/IDLabel/index.css +6 -0
- package/dist/elements/IDLabel/index.d.ts +1 -1
- package/dist/elements/IDLabel/index.d.ts.map +1 -1
- package/dist/elements/IDLabel/index.js +16 -21
- package/dist/elements/IDLabel/index.js.map +1 -1
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +3 -2
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListControls/types.d.ts +4 -0
- package/dist/elements/ListControls/types.d.ts.map +1 -1
- package/dist/elements/ListControls/types.js.map +1 -1
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.d.ts +1 -7
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.d.ts.map +1 -1
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.js +26 -32
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.js.map +1 -1
- package/dist/elements/Nav/NavSidebarToggle/index.js +1 -1
- package/dist/elements/Nav/NavSidebarToggle/index.js.map +1 -1
- package/dist/elements/Nav/NavWrapper/index.d.ts +1 -0
- package/dist/elements/Nav/NavWrapper/index.d.ts.map +1 -1
- package/dist/elements/Nav/NavWrapper/index.js +12 -18
- package/dist/elements/Nav/NavWrapper/index.js.map +1 -1
- package/dist/elements/Nav/SidebarTabs/index.css +1 -2
- package/dist/elements/Nav/context.d.ts +0 -1
- package/dist/elements/Nav/context.d.ts.map +1 -1
- package/dist/elements/Nav/context.js +92 -67
- package/dist/elements/Nav/context.js.map +1 -1
- package/dist/elements/Nav/index.css +47 -42
- package/dist/elements/Nav/index.d.ts +4 -0
- package/dist/elements/Nav/index.d.ts.map +1 -1
- package/dist/elements/Nav/index.js +16 -1
- package/dist/elements/Nav/index.js.map +1 -1
- package/dist/elements/NavGroup/index.css +29 -15
- package/dist/elements/Popup/PopupButtonList/index.css +33 -17
- package/dist/elements/Popup/index.css +6 -0
- package/dist/elements/Popup/index.d.ts +10 -0
- package/dist/elements/Popup/index.d.ts.map +1 -1
- package/dist/elements/Popup/index.js +13 -6
- package/dist/elements/Popup/index.js.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.js +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.js.map +1 -1
- package/dist/elements/QueryPresets/QueryPresetBar/index.js +1 -3
- package/dist/elements/QueryPresets/QueryPresetBar/index.js.map +1 -1
- package/dist/elements/ReactSelect/types.d.ts +5 -0
- package/dist/elements/ReactSelect/types.d.ts.map +1 -1
- package/dist/elements/ReactSelect/types.js.map +1 -1
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +5 -2
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/SegmentedControl/index.css +58 -0
- package/dist/elements/SegmentedControl/index.d.ts +19 -0
- package/dist/elements/SegmentedControl/index.d.ts.map +1 -0
- package/dist/elements/SegmentedControl/index.js +104 -0
- package/dist/elements/SegmentedControl/index.js.map +1 -0
- package/dist/elements/SelectAll/index.d.ts.map +1 -1
- package/dist/elements/SelectAll/index.js +1 -2
- package/dist/elements/SelectAll/index.js.map +1 -1
- package/dist/elements/SelectRow/index.d.ts.map +1 -1
- package/dist/elements/SelectRow/index.js +1 -2
- package/dist/elements/SelectRow/index.js.map +1 -1
- package/dist/elements/SidebarRow/index.css +1 -5
- package/dist/elements/SidebarToggle/index.css +3 -1
- package/dist/elements/SortHeader/index.d.ts.map +1 -1
- package/dist/elements/SortHeader/index.js +29 -26
- package/dist/elements/SortHeader/index.js.map +1 -1
- package/dist/elements/StepNav/DropTarget/index.css +20 -0
- package/dist/elements/StepNav/DropTarget/index.d.ts +16 -0
- package/dist/elements/StepNav/DropTarget/index.d.ts.map +1 -0
- package/dist/elements/StepNav/DropTarget/index.js +71 -0
- package/dist/elements/StepNav/DropTarget/index.js.map +1 -0
- package/dist/elements/StepNav/index.css +64 -14
- package/dist/elements/StepNav/index.d.ts.map +1 -1
- package/dist/elements/StepNav/index.js +147 -69
- package/dist/elements/StepNav/index.js.map +1 -1
- package/dist/elements/StepNav/types.d.ts +6 -0
- package/dist/elements/StepNav/types.d.ts.map +1 -1
- package/dist/elements/StepNav/types.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Hierarchy/index.css +5 -7
- package/dist/elements/Table/DefaultCell/fields/Hierarchy/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Hierarchy/index.js +14 -3
- package/dist/elements/Table/DefaultCell/fields/Hierarchy/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js +3 -11
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/Upload/UploadFromURLModal/index.d.ts +1 -1
- package/dist/elements/Upload/UploadFromURLModal/index.d.ts.map +1 -1
- package/dist/elements/Upload/UploadFromURLModal/index.js.map +1 -1
- package/dist/elements/Upload/index.css +39 -32
- package/dist/elements/Upload/index.d.ts.map +1 -1
- package/dist/elements/Upload/index.js +37 -99
- package/dist/elements/Upload/index.js.map +1 -1
- package/dist/elements/Upload/usePasteFromClipboard.d.ts +14 -0
- package/dist/elements/Upload/usePasteFromClipboard.d.ts.map +1 -0
- package/dist/elements/Upload/usePasteFromClipboard.js +93 -0
- package/dist/elements/Upload/usePasteFromClipboard.js.map +1 -0
- package/dist/elements/Upload/useUploadFromUrl.d.ts +20 -0
- package/dist/elements/Upload/useUploadFromUrl.d.ts.map +1 -0
- package/dist/elements/Upload/useUploadFromUrl.js +201 -0
- package/dist/elements/Upload/useUploadFromUrl.js.map +1 -0
- package/dist/elements/UploadDropzoneContent/index.css +31 -0
- package/dist/elements/UploadDropzoneContent/index.d.ts +17 -0
- package/dist/elements/UploadDropzoneContent/index.d.ts.map +1 -0
- package/dist/elements/UploadDropzoneContent/index.js +62 -0
- package/dist/elements/UploadDropzoneContent/index.js.map +1 -0
- package/dist/elements/UserMenu/HoverSubmenuGroup.d.ts +18 -0
- package/dist/elements/UserMenu/HoverSubmenuGroup.d.ts.map +1 -0
- package/dist/elements/UserMenu/HoverSubmenuGroup.js +38 -0
- package/dist/elements/UserMenu/HoverSubmenuGroup.js.map +1 -0
- package/dist/elements/UserMenu/LanguageMenu/index.d.ts.map +1 -1
- package/dist/elements/UserMenu/LanguageMenu/index.js +83 -39
- package/dist/elements/UserMenu/LanguageMenu/index.js.map +1 -1
- package/dist/elements/UserMenu/SettingsMenu/index.d.ts.map +1 -1
- package/dist/elements/UserMenu/SettingsMenu/index.js +57 -21
- package/dist/elements/UserMenu/SettingsMenu/index.js.map +1 -1
- package/dist/elements/UserMenu/ThemeMenu/index.d.ts.map +1 -1
- package/dist/elements/UserMenu/ThemeMenu/index.js +83 -39
- package/dist/elements/UserMenu/ThemeMenu/index.js.map +1 -1
- package/dist/elements/UserMenu/index.css +32 -2
- package/dist/elements/UserMenu/index.d.ts +1 -0
- package/dist/elements/UserMenu/index.d.ts.map +1 -1
- package/dist/elements/UserMenu/index.js +77 -51
- package/dist/elements/UserMenu/index.js.map +1 -1
- package/dist/elements/UserMenu/useHoverSubmenu.d.ts +21 -0
- package/dist/elements/UserMenu/useHoverSubmenu.d.ts.map +1 -0
- package/dist/elements/UserMenu/useHoverSubmenu.js +260 -0
- package/dist/elements/UserMenu/useHoverSubmenu.js.map +1 -0
- package/dist/elements/ViewModeToggle/index.d.ts +8 -0
- package/dist/elements/ViewModeToggle/index.d.ts.map +1 -0
- package/dist/elements/ViewModeToggle/index.js +29 -0
- package/dist/elements/ViewModeToggle/index.js.map +1 -0
- package/dist/elements/WhereBuilder/conditionValue.d.ts +32 -0
- package/dist/elements/WhereBuilder/conditionValue.d.ts.map +1 -0
- package/dist/elements/WhereBuilder/conditionValue.js +32 -0
- package/dist/elements/WhereBuilder/conditionValue.js.map +1 -0
- package/dist/elements/WhereBuilder/conditionValue.spec.js +65 -0
- package/dist/elements/WhereBuilder/conditionValue.spec.js.map +1 -0
- package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/index.js +15 -4
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +6 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +1 -1
- package/dist/exports/client/index.js.map +3 -3
- package/dist/fields/Array/ArrayRow.d.ts +1 -0
- package/dist/fields/Array/ArrayRow.d.ts.map +1 -1
- package/dist/fields/Array/ArrayRow.js +2 -0
- package/dist/fields/Array/ArrayRow.js.map +1 -1
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +38 -10
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/BlockRow.d.ts +1 -0
- package/dist/fields/Blocks/BlockRow.d.ts.map +1 -1
- package/dist/fields/Blocks/BlockRow.js +2 -0
- package/dist/fields/Blocks/BlockRow.js.map +1 -1
- package/dist/fields/Blocks/RowActions.d.ts +1 -0
- package/dist/fields/Blocks/RowActions.d.ts.map +1 -1
- package/dist/fields/Blocks/RowActions.js +22 -19
- package/dist/fields/Blocks/RowActions.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +35 -7
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Checkbox/Input.d.ts +2 -2
- package/dist/fields/Checkbox/Input.d.ts.map +1 -1
- package/dist/fields/Checkbox/Input.js +134 -152
- package/dist/fields/Checkbox/Input.js.map +1 -1
- package/dist/fields/Checkbox/index.css +168 -155
- package/dist/fields/Relationship/Input.d.ts.map +1 -1
- package/dist/fields/Relationship/Input.js +24 -6
- package/dist/fields/Relationship/Input.js.map +1 -1
- package/dist/fields/Relationship/optionsReducer.d.ts.map +1 -1
- package/dist/fields/Relationship/optionsReducer.js +2 -0
- package/dist/fields/Relationship/optionsReducer.js.map +1 -1
- package/dist/fields/Relationship/types.d.ts +24 -0
- package/dist/fields/Relationship/types.d.ts.map +1 -1
- package/dist/fields/Relationship/types.js.map +1 -1
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js +44 -16
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/fields/Upload/Input.spec.js +241 -0
- package/dist/fields/Upload/Input.spec.js.map +1 -0
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +4 -1
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +1 -0
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/icons/CollapseLayers/index.css +5 -0
- package/dist/icons/CollapseLayers/index.d.ts +7 -0
- package/dist/icons/CollapseLayers/index.d.ts.map +1 -0
- package/dist/icons/CollapseLayers/index.js +23 -0
- package/dist/icons/CollapseLayers/index.js.map +1 -0
- package/dist/icons/Edit/index.d.ts +0 -1
- package/dist/icons/Edit/index.d.ts.map +1 -1
- package/dist/icons/Edit/index.js +4 -4
- package/dist/icons/Edit/index.js.map +1 -1
- package/dist/icons/Table/index.css +5 -0
- package/dist/icons/Table/index.d.ts +7 -0
- package/dist/icons/Table/index.d.ts.map +1 -0
- package/dist/icons/Table/index.js +25 -0
- package/dist/icons/Table/index.js.map +1 -0
- package/dist/providers/Actions/index.d.ts +1 -0
- package/dist/providers/Actions/index.d.ts.map +1 -1
- package/dist/providers/Actions/index.js +43 -11
- package/dist/providers/Actions/index.js.map +1 -1
- package/dist/providers/Auth/AuthSessionDebug/index.css +48 -0
- package/dist/providers/Auth/AuthSessionDebug/index.d.ts +13 -0
- package/dist/providers/Auth/AuthSessionDebug/index.d.ts.map +1 -0
- package/dist/providers/Auth/AuthSessionDebug/index.js +93 -0
- package/dist/providers/Auth/AuthSessionDebug/index.js.map +1 -0
- package/dist/providers/Auth/AuthSessionDebug/utilities.d.ts +21 -0
- package/dist/providers/Auth/AuthSessionDebug/utilities.d.ts.map +1 -0
- package/dist/providers/Auth/AuthSessionDebug/utilities.js +53 -0
- package/dist/providers/Auth/AuthSessionDebug/utilities.js.map +1 -0
- package/dist/providers/Auth/authSessionRequests.d.ts +27 -0
- package/dist/providers/Auth/authSessionRequests.d.ts.map +1 -0
- package/dist/providers/Auth/authSessionRequests.js +119 -0
- package/dist/providers/Auth/authSessionRequests.js.map +1 -0
- package/dist/providers/Auth/authSessionRequests.spec.js +121 -0
- package/dist/providers/Auth/authSessionRequests.spec.js.map +1 -0
- package/dist/providers/Auth/index.d.ts +2 -56
- package/dist/providers/Auth/index.d.ts.map +1 -1
- package/dist/providers/Auth/index.js +283 -135
- package/dist/providers/Auth/index.js.map +1 -1
- package/dist/providers/Auth/sessionActivity.d.ts +23 -0
- package/dist/providers/Auth/sessionActivity.d.ts.map +1 -0
- package/dist/providers/Auth/sessionActivity.js +49 -0
- package/dist/providers/Auth/sessionActivity.js.map +1 -0
- package/dist/providers/Auth/sessionActivity.spec.js +44 -0
- package/dist/providers/Auth/sessionActivity.spec.js.map +1 -0
- package/dist/providers/Auth/sessionTiming.d.ts +11 -0
- package/dist/providers/Auth/sessionTiming.d.ts.map +1 -0
- package/dist/providers/Auth/sessionTiming.js +18 -0
- package/dist/providers/Auth/sessionTiming.js.map +1 -0
- package/dist/providers/Auth/tabSessionSync/index.d.ts +17 -0
- package/dist/providers/Auth/tabSessionSync/index.d.ts.map +1 -0
- package/dist/providers/Auth/tabSessionSync/index.js +263 -0
- package/dist/providers/Auth/tabSessionSync/index.js.map +1 -0
- package/dist/providers/Auth/tabSessionSync/index.spec.js +463 -0
- package/dist/providers/Auth/tabSessionSync/index.spec.js.map +1 -0
- package/dist/providers/Auth/tabSessionSync/types.d.ts +107 -0
- package/dist/providers/Auth/tabSessionSync/types.d.ts.map +1 -0
- package/dist/providers/Auth/tabSessionSync/types.js +6 -0
- package/dist/providers/Auth/tabSessionSync/types.js.map +1 -0
- package/dist/providers/Auth/tabSessionSync/useTabSessionSync.d.ts +11 -0
- package/dist/providers/Auth/tabSessionSync/useTabSessionSync.d.ts.map +1 -0
- package/dist/providers/Auth/tabSessionSync/useTabSessionSync.js +90 -0
- package/dist/providers/Auth/tabSessionSync/useTabSessionSync.js.map +1 -0
- package/dist/providers/Auth/tabSessionSync/utilities.d.ts +26 -0
- package/dist/providers/Auth/tabSessionSync/utilities.d.ts.map +1 -0
- package/dist/providers/Auth/tabSessionSync/utilities.js +159 -0
- package/dist/providers/Auth/tabSessionSync/utilities.js.map +1 -0
- package/dist/providers/Auth/types.d.ts +65 -0
- package/dist/providers/Auth/types.d.ts.map +1 -0
- package/dist/providers/Auth/types.js +2 -0
- package/dist/providers/Auth/types.js.map +1 -0
- package/dist/providers/Auth/useAuthSessionTimers.d.ts +26 -0
- package/dist/providers/Auth/useAuthSessionTimers.d.ts.map +1 -0
- package/dist/providers/Auth/useAuthSessionTimers.js +203 -0
- package/dist/providers/Auth/useAuthSessionTimers.js.map +1 -0
- package/dist/providers/Auth/useAuthSessionTimers.spec.js +311 -0
- package/dist/providers/Auth/useAuthSessionTimers.spec.js.map +1 -0
- package/dist/providers/FormErrorHandler/index.d.ts +5 -1
- package/dist/providers/FormErrorHandler/index.d.ts.map +1 -1
- package/dist/providers/FormErrorHandler/index.js.map +1 -1
- package/dist/providers/Hierarchy/index.d.ts.map +1 -1
- package/dist/providers/Hierarchy/index.js +53 -24
- package/dist/providers/Hierarchy/index.js.map +1 -1
- package/dist/providers/Hierarchy/types.d.ts +2 -0
- package/dist/providers/Hierarchy/types.d.ts.map +1 -1
- package/dist/providers/Hierarchy/types.js.map +1 -1
- package/dist/providers/HierarchyDnd/index.css +51 -0
- package/dist/providers/HierarchyDnd/index.d.ts +21 -0
- package/dist/providers/HierarchyDnd/index.d.ts.map +1 -0
- package/dist/providers/HierarchyDnd/index.js +163 -0
- package/dist/providers/HierarchyDnd/index.js.map +1 -0
- package/dist/providers/HierarchyDnd/types.d.ts +56 -0
- package/dist/providers/HierarchyDnd/types.d.ts.map +1 -0
- package/dist/providers/HierarchyDnd/types.js +21 -0
- package/dist/providers/HierarchyDnd/types.js.map +1 -0
- package/dist/providers/Locale/index.d.ts.map +1 -1
- package/dist/providers/Locale/index.js +41 -36
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/providers/Root/index.js +4 -4
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/RouteTransition/ProgressBar/index.js +4 -1
- package/dist/providers/RouteTransition/ProgressBar/index.js.map +1 -1
- package/dist/providers/RouteTransition/ProgressBar/index.spec.js +44 -0
- package/dist/providers/RouteTransition/ProgressBar/index.spec.js.map +1 -0
- package/dist/providers/RouteTransition/index.d.ts +2 -0
- package/dist/providers/RouteTransition/index.d.ts.map +1 -1
- package/dist/providers/RouteTransition/index.js +42 -14
- package/dist/providers/RouteTransition/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/templates/Default/Wrapper/index.css +2 -1
- package/dist/templates/Default/Wrapper/index.d.ts +2 -0
- package/dist/templates/Default/Wrapper/index.d.ts.map +1 -1
- package/dist/templates/Default/Wrapper/index.js +12 -6
- package/dist/templates/Default/Wrapper/index.js.map +1 -1
- package/dist/templates/Default/index.css +3 -1
- package/dist/templates/Default/index.d.ts +1 -0
- package/dist/templates/Default/index.d.ts.map +1 -1
- package/dist/templates/Default/index.js +19 -15
- package/dist/templates/Default/index.js.map +1 -1
- package/dist/utilities/formatMetadata.d.ts.map +1 -1
- package/dist/utilities/formatMetadata.js +0 -5
- package/dist/utilities/formatMetadata.js.map +1 -1
- package/dist/utilities/getFilesFromClipboard.d.ts +10 -0
- package/dist/utilities/getFilesFromClipboard.d.ts.map +1 -0
- package/dist/utilities/getFilesFromClipboard.js +49 -0
- package/dist/utilities/getFilesFromClipboard.js.map +1 -0
- package/dist/utilities/slugify.d.ts.map +1 -1
- package/dist/utilities/slugify.js +1 -0
- package/dist/utilities/slugify.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js +3 -2
- package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.js +7 -7
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.client.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.client.js +104 -66
- package/dist/views/Dashboard/Default/ModularDashboard/index.client.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.css +33 -140
- package/dist/views/Edit/SetDocumentTitle/index.d.ts.map +1 -1
- package/dist/views/Edit/SetDocumentTitle/index.js +4 -1
- package/dist/views/Edit/SetDocumentTitle/index.js.map +1 -1
- package/dist/views/Edit/index.d.ts.map +1 -1
- package/dist/views/Edit/index.js +3 -2
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/views/HierarchyList/DocumentListSelection/index.d.ts.map +1 -1
- package/dist/views/HierarchyList/DocumentListSelection/index.js +100 -105
- package/dist/views/HierarchyList/DocumentListSelection/index.js.map +1 -1
- package/dist/views/HierarchyList/HierarchyCards/DocumentCard/index.css +216 -0
- package/dist/views/HierarchyList/HierarchyCards/DocumentCard/index.d.ts +20 -0
- package/dist/views/HierarchyList/HierarchyCards/DocumentCard/index.d.ts.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/DocumentCard/index.js +182 -0
- package/dist/views/HierarchyList/HierarchyCards/DocumentCard/index.js.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/DragPreviewItem/index.css +38 -0
- package/dist/views/HierarchyList/HierarchyCards/DragPreviewItem/index.d.ts +15 -0
- package/dist/views/HierarchyList/HierarchyCards/DragPreviewItem/index.d.ts.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/DragPreviewItem/index.js +85 -0
- package/dist/views/HierarchyList/HierarchyCards/DragPreviewItem/index.js.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/FolderCard/index.css +98 -0
- package/dist/views/HierarchyList/HierarchyCards/FolderCard/index.d.ts +27 -0
- package/dist/views/HierarchyList/HierarchyCards/FolderCard/index.d.ts.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/FolderCard/index.js +84 -0
- package/dist/views/HierarchyList/HierarchyCards/FolderCard/index.js.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/HierarchyCard/index.d.ts +19 -0
- package/dist/views/HierarchyList/HierarchyCards/HierarchyCard/index.d.ts.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/HierarchyCard/index.js +100 -0
- package/dist/views/HierarchyList/HierarchyCards/HierarchyCard/index.js.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/PlaneItem/index.d.ts +53 -0
- package/dist/views/HierarchyList/HierarchyCards/PlaneItem/index.d.ts.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/PlaneItem/index.js +145 -0
- package/dist/views/HierarchyList/HierarchyCards/PlaneItem/index.js.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/getThumbnailSrc.d.ts +8 -0
- package/dist/views/HierarchyList/HierarchyCards/getThumbnailSrc.d.ts.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/getThumbnailSrc.js +21 -0
- package/dist/views/HierarchyList/HierarchyCards/getThumbnailSrc.js.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/index.css +115 -0
- package/dist/views/HierarchyList/HierarchyCards/index.d.ts +80 -0
- package/dist/views/HierarchyList/HierarchyCards/index.d.ts.map +1 -0
- package/dist/views/HierarchyList/HierarchyCards/index.js +457 -0
- package/dist/views/HierarchyList/HierarchyCards/index.js.map +1 -0
- package/dist/views/HierarchyList/HierarchyListHeader/index.d.ts +6 -1
- package/dist/views/HierarchyList/HierarchyListHeader/index.d.ts.map +1 -1
- package/dist/views/HierarchyList/HierarchyListHeader/index.js +10 -8
- package/dist/views/HierarchyList/HierarchyListHeader/index.js.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/ChildNameCell.d.ts.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/ChildNameCell.js +11 -10
- package/dist/views/HierarchyList/HierarchyTable/ChildNameCell.js.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/SlotTable.d.ts.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/SlotTable.js +3 -6
- package/dist/views/HierarchyList/HierarchyTable/SlotTable.js.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/index.css +51 -0
- package/dist/views/HierarchyList/HierarchyTable/index.d.ts +13 -1
- package/dist/views/HierarchyList/HierarchyTable/index.d.ts.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/index.js +156 -38
- package/dist/views/HierarchyList/HierarchyTable/index.js.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/types.d.ts +6 -0
- package/dist/views/HierarchyList/HierarchyTable/types.d.ts.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/types.js.map +1 -1
- package/dist/views/HierarchyList/index.d.ts.map +1 -1
- package/dist/views/HierarchyList/index.js +103 -20
- package/dist/views/HierarchyList/index.js.map +1 -1
- package/dist/views/List/ListHeader/index.d.ts +1 -10
- package/dist/views/List/ListHeader/index.d.ts.map +1 -1
- package/dist/views/List/ListHeader/index.js +1 -3
- package/dist/views/List/ListHeader/index.js.map +1 -1
- package/dist/views/List/ListSelection/index.d.ts.map +1 -1
- package/dist/views/List/ListSelection/index.js +138 -122
- package/dist/views/List/ListSelection/index.js.map +1 -1
- package/dist/views/List/handleHierarchy.d.ts +6 -1
- package/dist/views/List/handleHierarchy.d.ts.map +1 -1
- package/dist/views/List/handleHierarchy.js +34 -3
- package/dist/views/List/handleHierarchy.js.map +1 -1
- package/dist/views/List/index.client.d.ts.map +1 -1
- package/dist/views/List/index.client.js +128 -18
- package/dist/views/List/index.client.js.map +1 -1
- package/dist/views/List/index.css +5 -0
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +27 -16
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/Root/getCustomCollectionViewByRoute.d.ts.map +1 -1
- package/dist/views/Root/getCustomCollectionViewByRoute.js.map +1 -1
- package/dist/views/Root/getCustomGlobalViewByRoute.d.ts.map +1 -1
- package/dist/views/Root/getCustomGlobalViewByRoute.js.map +1 -1
- package/dist/views/Root/getCustomViewByKey.d.ts.map +1 -1
- package/dist/views/Root/getCustomViewByKey.js.map +1 -1
- package/dist/views/Root/getRouteData.d.ts.map +1 -1
- package/dist/views/Root/getRouteData.js +8 -2
- package/dist/views/Root/getRouteData.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +1 -0
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Version/generateVersionViewMetadata.js.map +1 -1
- package/dist/views/Versions/generateVersionsViewMetadata.js.map +1 -1
- package/package.json +4 -4
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.css +0 -36
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.d.ts +0 -13
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.d.ts.map +0 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.js +0 -141
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.js.map +0 -1
|
@@ -6,6 +6,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
6
6
|
import { useForm, useFormFields } from '../../../forms/Form/context.js';
|
|
7
7
|
import { useConfig } from '../../../providers/Config/index.js';
|
|
8
8
|
import { useDocumentInfo } from '../../../providers/DocumentInfo/index.js';
|
|
9
|
+
import { useDocumentTitle } from '../../../providers/DocumentTitle/index.js';
|
|
9
10
|
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
10
11
|
import { Button } from '../../Button/index.js';
|
|
11
12
|
import { useHierarchyModal } from '../Modal/useHierarchyModal.js';
|
|
@@ -29,6 +30,9 @@ export const HierarchyButtonClient = ({
|
|
|
29
30
|
const {
|
|
30
31
|
collectionSlug: documentCollectionSlug
|
|
31
32
|
} = useDocumentInfo();
|
|
33
|
+
const {
|
|
34
|
+
title: documentTitle
|
|
35
|
+
} = useDocumentTitle();
|
|
32
36
|
const {
|
|
33
37
|
disabled: formDisabled,
|
|
34
38
|
setModified
|
|
@@ -122,7 +126,8 @@ export const HierarchyButtonClient = ({
|
|
|
122
126
|
}), /*#__PURE__*/_jsx(HierarchyModal, {
|
|
123
127
|
hasMany: hasMany,
|
|
124
128
|
initialSelections: currentId ? [currentId] : undefined,
|
|
125
|
-
onSave: handleModalSave
|
|
129
|
+
onSave: handleModalSave,
|
|
130
|
+
title: !hasMany && documentTitle ? `${t('general:move')} "${documentTitle}"` : undefined
|
|
126
131
|
})]
|
|
127
132
|
});
|
|
128
133
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["formatAdminURL","React","useCallback","useEffect","useMemo","useState","useForm","useFormFields","useConfig","useDocumentInfo","useTranslation","Button","useHierarchyModal","baseClass","HierarchyButtonClient","fieldName","hasMany","hierarchyCollectionSlug","Icon","readOnly","readOnlyFromProps","SmallIcon","t","config","getEntityConfig","collectionSlug","documentCollectionSlug","disabled","formDisabled","setModified","dispatchField","_","dispatch","currentFieldValue","fields","currentId","value","displayName","setDisplayName","isLoading","setIsLoading","collectionConfig","useAsTitle","admin","isHierarchyCollection","filterByCollection","undefined","HierarchyModal","openModal","fetchItemName","response","fetch","apiRoute","routes","api","path","serverURL","credentials","ok","itemData","json","title","name","id","String","handleModalSave","closeModal","selections","ids","Array","from","keys","newValue","type","handleClick","label","_jsxs","_Fragment","_jsx","buttonStyle","className","filter","Boolean","join","icon","iconPosition","margin","onClick","initialSelections","onSave"],"sources":["../../../../src/elements/Hierarchy/DocHeaderButton/index.tsx"],"sourcesContent":["'use client'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport type { SelectionWithPath } from '../Modal/types.js'\n\nimport { useForm, useFormFields } from '../../../forms/Form/context.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { useHierarchyModal } from '../Modal/useHierarchyModal.js'\nimport './index.css'\n\nconst baseClass = 'hierarchy-button'\n\nexport type HierarchyButtonClientProps = {\n fieldName: string\n hasMany?: boolean\n hierarchyCollectionSlug: string\n Icon?: React.ReactNode\n readOnly?: boolean\n SmallIcon?: React.ReactNode\n}\n\nexport const HierarchyButtonClient: React.FC<HierarchyButtonClientProps> = ({\n fieldName,\n hasMany = false,\n hierarchyCollectionSlug,\n Icon,\n readOnly: readOnlyFromProps,\n SmallIcon,\n}) => {\n const { t } = useTranslation()\n const { config, getEntityConfig } = useConfig()\n const { collectionSlug: documentCollectionSlug } = useDocumentInfo()\n const { disabled: formDisabled, setModified } = useForm()\n const readOnly = readOnlyFromProps || formDisabled\n const dispatchField = useFormFields(([_, dispatch]) => dispatch)\n\n const currentFieldValue = useFormFields(([fields]) => (fields && fields?.[fieldName]) || null)\n const currentId = currentFieldValue?.value as null | number | string\n\n const [displayName, setDisplayName] = useState<string>('')\n const [isLoading, setIsLoading] = useState(true)\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchyCollectionSlug })\n const useAsTitle = collectionConfig?.admin?.useAsTitle || 'name'\n\n const isHierarchyCollection = documentCollectionSlug === hierarchyCollectionSlug\n\n // When in hierarchy collection, let the modal use allowedCollections from context\n // When in other collections, filter by that collection's slug\n // Memoize to prevent new array references on every render\n const filterByCollection = useMemo(\n () => (isHierarchyCollection || !documentCollectionSlug ? undefined : [documentCollectionSlug]),\n [isHierarchyCollection, documentCollectionSlug],\n )\n\n const [HierarchyModal, , { openModal }] = useHierarchyModal({\n filterByCollection,\n hierarchyCollectionSlug,\n Icon,\n })\n\n // Fetch item name when currentId changes\n useEffect(() => {\n const fetchItemName = async () => {\n if (currentId && (typeof currentId === 'string' || typeof currentId === 'number')) {\n setIsLoading(true)\n try {\n const response = await fetch(\n formatAdminURL({\n apiRoute: config.routes.api,\n path: `/${hierarchyCollectionSlug}/${currentId}`,\n serverURL: config.serverURL,\n }),\n { credentials: 'include' },\n )\n\n if (response.ok) {\n const itemData = await response.json()\n const title = itemData?.[useAsTitle] || itemData?.name || itemData?.id\n\n setDisplayName(String(title))\n } else {\n setDisplayName(t('general:none'))\n }\n } catch {\n setDisplayName(t('general:none'))\n } finally {\n setIsLoading(false)\n }\n } else {\n setDisplayName(t('general:none'))\n setIsLoading(false)\n }\n }\n\n void fetchItemName()\n }, [currentId, hierarchyCollectionSlug, config.routes.api, config.serverURL, useAsTitle, t])\n\n const handleModalSave = useCallback(\n ({\n closeModal,\n selections,\n }: {\n closeModal: () => void\n selections: Map<number | string, SelectionWithPath>\n }) => {\n const ids = Array.from(selections.keys())\n const newValue = hasMany ? ids : (ids[0] ?? null)\n\n if (currentFieldValue?.value !== newValue) {\n dispatchField({\n type: 'UPDATE',\n path: fieldName,\n value: newValue,\n })\n setModified(true)\n }\n closeModal()\n },\n [currentFieldValue?.value, dispatchField, fieldName, hasMany, setModified],\n )\n\n const handleClick = useCallback(() => {\n if (!readOnly) {\n openModal()\n }\n }, [openModal, readOnly])\n\n const label = isLoading ? `${t('general:loading')}...` : displayName\n\n return (\n <>\n <Button\n buttonStyle=\"secondary\"\n className={[baseClass, readOnly && `${baseClass}--read-only`].filter(Boolean).join(' ')}\n disabled={readOnly}\n icon={SmallIcon ?? Icon}\n iconPosition=\"left\"\n margin={false}\n onClick={handleClick}\n >\n {label}\n </Button>\n <HierarchyModal\n hasMany={hasMany}\n initialSelections={currentId ? [currentId] : undefined}\n onSave={handleModalSave}\n />\n </>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAIjE,SAASC,OAAO,EAAEC,aAAa,QAAQ;AACvC,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,iBAAiB,QAAQ;AAClC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAWlB,OAAO,MAAMC,qBAAA,GAA8DA,CAAC;EAC1EC,SAAS;EACTC,OAAA,GAAU,KAAK;EACfC,uBAAuB;EACvBC,IAAI;EACJC,QAAA,EAAUC,iBAAiB;EAC3BC;AAAS,CACV;EACC,MAAM;IAAEC;EAAC,CAAE,GAAGZ,cAAA;EACd,MAAM;IAAEa,MAAM;IAAEC;EAAe,CAAE,GAAGhB,SAAA;EACpC,MAAM;IAAEiB,cAAA,EAAgBC;EAAsB,CAAE,GAAGjB,eAAA;EACnD,MAAM;IAAEkB,QAAA,EAAUC,YAAY;IAAEC;EAAW,CAAE,GAAGvB,OAAA;EAChD,MAAMa,QAAA,GAAW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E,MAAM6C,WAAA,GAAcxE,WAAA,CAAY;IAC9B,IAAI,CAACiB,QAAA,EAAU;MACb6B,SAAA;IACF;EACF,GAAG,CAACA,SAAA,EAAW7B,QAAA,CAAS;EAExB,MAAMwD,KAAA,GAAQpC,SAAA,GAAY,GAAGjB,CAAA,CAAE,uBAAuB,GAAGe,WAAA;EAEzD,oBACEuC,KAAA,CAAAC,SAAA;4BACEC,IAAA,CAACnE,MAAA;MACCoE,WAAA,EAAY;MACZC,SAAA,EAAW,CAACnE,SAAA,EAAWM,QAAA,IAAY,GAAGN,SAAA,aAAsB,CAAC,CAACoE,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;MACnFxD,QAAA,EAAUR,QAAA;MACViE,IAAA,EAAM/D,SAAA,IAAaH,IAAA;MACnBmE,YAAA,EAAa;MACbC,MAAA,EAAQ;MACRC,OAAA,EAASb,WAAA;gBAERC;qBAEHG,IAAA,CAAC/B,cAAA;MACC/B,OAAA,EAASA,OAAA;MACTwE,iBAAA,EAAmBrD,SAAA,GAAY,CAACA,SAAA,CAAU,GAAGW,SAAA;MAC7C2C,MAAA,EAAQxB;;;AAIhB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["formatAdminURL","React","useCallback","useEffect","useMemo","useState","useForm","useFormFields","useConfig","useDocumentInfo","useDocumentTitle","useTranslation","Button","useHierarchyModal","baseClass","HierarchyButtonClient","fieldName","hasMany","hierarchyCollectionSlug","Icon","readOnly","readOnlyFromProps","SmallIcon","t","config","getEntityConfig","collectionSlug","documentCollectionSlug","title","documentTitle","disabled","formDisabled","setModified","dispatchField","_","dispatch","currentFieldValue","fields","currentId","value","displayName","setDisplayName","isLoading","setIsLoading","collectionConfig","useAsTitle","admin","isHierarchyCollection","filterByCollection","undefined","HierarchyModal","openModal","fetchItemName","response","fetch","apiRoute","routes","api","path","serverURL","credentials","ok","itemData","json","name","id","String","handleModalSave","closeModal","selections","ids","Array","from","keys","newValue","type","handleClick","label","_jsxs","_Fragment","_jsx","buttonStyle","className","filter","Boolean","join","icon","iconPosition","margin","onClick","initialSelections","onSave"],"sources":["../../../../src/elements/Hierarchy/DocHeaderButton/index.tsx"],"sourcesContent":["'use client'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport type { SelectionWithPath } from '../Modal/types.js'\n\nimport { useForm, useFormFields } from '../../../forms/Form/context.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useDocumentTitle } from '../../../providers/DocumentTitle/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { useHierarchyModal } from '../Modal/useHierarchyModal.js'\nimport './index.css'\n\nconst baseClass = 'hierarchy-button'\n\nexport type HierarchyButtonClientProps = {\n fieldName: string\n hasMany?: boolean\n hierarchyCollectionSlug: string\n Icon?: React.ReactNode\n readOnly?: boolean\n SmallIcon?: React.ReactNode\n}\n\nexport const HierarchyButtonClient: React.FC<HierarchyButtonClientProps> = ({\n fieldName,\n hasMany = false,\n hierarchyCollectionSlug,\n Icon,\n readOnly: readOnlyFromProps,\n SmallIcon,\n}) => {\n const { t } = useTranslation()\n const { config, getEntityConfig } = useConfig()\n const { collectionSlug: documentCollectionSlug } = useDocumentInfo()\n const { title: documentTitle } = useDocumentTitle()\n const { disabled: formDisabled, setModified } = useForm()\n const readOnly = readOnlyFromProps || formDisabled\n const dispatchField = useFormFields(([_, dispatch]) => dispatch)\n\n const currentFieldValue = useFormFields(([fields]) => (fields && fields?.[fieldName]) || null)\n const currentId = currentFieldValue?.value as null | number | string\n\n const [displayName, setDisplayName] = useState<string>('')\n const [isLoading, setIsLoading] = useState(true)\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchyCollectionSlug })\n const useAsTitle = collectionConfig?.admin?.useAsTitle || 'name'\n\n const isHierarchyCollection = documentCollectionSlug === hierarchyCollectionSlug\n\n // When in hierarchy collection, let the modal use allowedCollections from context\n // When in other collections, filter by that collection's slug\n // Memoize to prevent new array references on every render\n const filterByCollection = useMemo(\n () => (isHierarchyCollection || !documentCollectionSlug ? undefined : [documentCollectionSlug]),\n [isHierarchyCollection, documentCollectionSlug],\n )\n\n const [HierarchyModal, , { openModal }] = useHierarchyModal({\n filterByCollection,\n hierarchyCollectionSlug,\n Icon,\n })\n\n // Fetch item name when currentId changes\n useEffect(() => {\n const fetchItemName = async () => {\n if (currentId && (typeof currentId === 'string' || typeof currentId === 'number')) {\n setIsLoading(true)\n try {\n const response = await fetch(\n formatAdminURL({\n apiRoute: config.routes.api,\n path: `/${hierarchyCollectionSlug}/${currentId}`,\n serverURL: config.serverURL,\n }),\n { credentials: 'include' },\n )\n\n if (response.ok) {\n const itemData = await response.json()\n const title = itemData?.[useAsTitle] || itemData?.name || itemData?.id\n\n setDisplayName(String(title))\n } else {\n setDisplayName(t('general:none'))\n }\n } catch {\n setDisplayName(t('general:none'))\n } finally {\n setIsLoading(false)\n }\n } else {\n setDisplayName(t('general:none'))\n setIsLoading(false)\n }\n }\n\n void fetchItemName()\n }, [currentId, hierarchyCollectionSlug, config.routes.api, config.serverURL, useAsTitle, t])\n\n const handleModalSave = useCallback(\n ({\n closeModal,\n selections,\n }: {\n closeModal: () => void\n selections: Map<number | string, SelectionWithPath>\n }) => {\n const ids = Array.from(selections.keys())\n const newValue = hasMany ? ids : (ids[0] ?? null)\n\n if (currentFieldValue?.value !== newValue) {\n dispatchField({\n type: 'UPDATE',\n path: fieldName,\n value: newValue,\n })\n setModified(true)\n }\n closeModal()\n },\n [currentFieldValue?.value, dispatchField, fieldName, hasMany, setModified],\n )\n\n const handleClick = useCallback(() => {\n if (!readOnly) {\n openModal()\n }\n }, [openModal, readOnly])\n\n const label = isLoading ? `${t('general:loading')}...` : displayName\n\n return (\n <>\n <Button\n buttonStyle=\"secondary\"\n className={[baseClass, readOnly && `${baseClass}--read-only`].filter(Boolean).join(' ')}\n disabled={readOnly}\n icon={SmallIcon ?? Icon}\n iconPosition=\"left\"\n margin={false}\n onClick={handleClick}\n >\n {label}\n </Button>\n <HierarchyModal\n hasMany={hasMany}\n initialSelections={currentId ? [currentId] : undefined}\n onSave={handleModalSave}\n title={!hasMany && documentTitle ? `${t('general:move')} \"${documentTitle}\"` : undefined}\n />\n </>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAIjE,SAASC,OAAO,EAAEC,aAAa,QAAQ;AACvC,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,iBAAiB,QAAQ;AAClC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAWlB,OAAO,MAAMC,qBAAA,GAA8DA,CAAC;EAC1EC,SAAS;EACTC,OAAA,GAAU,KAAK;EACfC,uBAAuB;EACvBC,IAAI;EACJC,QAAA,EAAUC,iBAAiB;EAC3BC;AAAS,CACV;EACC,MAAM;IAAEC;EAAC,CAAE,GAAGZ,cAAA;EACd,MAAM;IAAEa,MAAM;IAAEC;EAAe,CAAE,GAAGjB,SAAA;EACpC,MAAM;IAAEkB,cAAA,EAAgBC;EAAsB,CAAE,GAAGlB,eAAA;EACnD,MAAM;IAAEmB,KAAA,EAAOC;EAAa,CAAE,GAAGnB,gBAAA;EACjC,MAAM;IAAEoB,QAAA,EAAUC,YAAY;IAAEC;EAAW,CAAE,GAAG1B,OAAA;EAChD,MAAMc,QAAA,GAAWC,iBAAA,IAAqBU,YAAA;EACtC,MAAME,aAAA,GAAgB1B,aAAA,CAAc,CAAC,CAAC2B,CAAA,EAAGC,QAAA,CAAS,KAAKA,QAAA;EAEvD,MAAMC,iBAAA,GAAoB7B,aAAA,CAAc,CAAC,CAAC8B,MAAA,CAA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nB,CAAA,CAAE,uBAAuB,GAAGiB,WAAA;EAEzD,oBACEsC,KAAA,CAAAC,SAAA;4BACEC,IAAA,CAACpE,MAAA;MACCqE,WAAA,EAAY;MACZC,SAAA,EAAW,CAACpE,SAAA,EAAWM,QAAA,IAAY,GAAGN,SAAA,aAAsB,CAAC,CAACqE,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;MACnFvD,QAAA,EAAUV,QAAA;MACVkE,IAAA,EAAMhE,SAAA,IAAaH,IAAA;MACnBoE,YAAA,EAAa;MACbC,MAAA,EAAQ;MACRC,OAAA,EAASb,WAAA;gBAERC;qBAEHG,IAAA,CAAC9B,cAAA;MACCjC,OAAA,EAASA,OAAA;MACTyE,iBAAA,EAAmBpD,SAAA,GAAY,CAACA,SAAA,CAAU,GAAGW,SAAA;MAC7C0C,MAAA,EAAQxB,eAAA;MACRvC,KAAA,EAAO,CAACX,OAAA,IAAWY,aAAA,GAAgB,GAAGN,CAAA,CAAE,oBAAoBM,aAAA,GAAgB,GAAGoB;;;AAIvF","ignoreList":[]}
|
|
@@ -18,9 +18,7 @@ export const HierarchyButton = ({
|
|
|
18
18
|
// Important: Must render the icon here on server to avoid hydration mismatch
|
|
19
19
|
// For default FolderIcon path, render directly to avoid import map requirement
|
|
20
20
|
const isDefaultFolderIcon = !IconComponent || IconComponent === '@payloadcms/ui#FolderIcon';
|
|
21
|
-
const renderedIcon = isDefaultFolderIcon ? /*#__PURE__*/_jsx(FolderIcon, {
|
|
22
|
-
size: 16
|
|
23
|
-
}) : RenderServerComponent({
|
|
21
|
+
const renderedIcon = isDefaultFolderIcon ? /*#__PURE__*/_jsx(FolderIcon, {}) : RenderServerComponent({
|
|
24
22
|
Component: IconComponent,
|
|
25
23
|
importMap: payload.importMap,
|
|
26
24
|
key: `hierarchy-button-icon-${hierarchyCollectionSlug}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.js","names":["React","FolderIcon","RenderServerComponent","HierarchyButtonClient","HierarchyButton","fieldName","hasMany","hierarchyCollectionSlug","payload","hierarchyCollectionConfig","config","collections","find","c","slug","hierarchyConfig","hierarchy","undefined","IconComponent","admin","components","Icon","SmallIconComponent","SmallIcon","isDefaultFolderIcon","renderedIcon","_jsx","
|
|
1
|
+
{"version":3,"file":"index.server.js","names":["React","FolderIcon","RenderServerComponent","HierarchyButtonClient","HierarchyButton","fieldName","hasMany","hierarchyCollectionSlug","payload","hierarchyCollectionConfig","config","collections","find","c","slug","hierarchyConfig","hierarchy","undefined","IconComponent","admin","components","Icon","SmallIconComponent","SmallIcon","isDefaultFolderIcon","renderedIcon","_jsx","Component","importMap","key","isDefaultSmallIcon","renderedSmallIcon"],"sources":["../../../../src/elements/Hierarchy/DocHeaderButton/index.server.tsx"],"sourcesContent":["import type { Payload } from 'payload'\n\nimport React from 'react'\n\nimport { FolderIcon } from '../../../icons/Folder/index.js'\nimport { RenderServerComponent } from '../../RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports dir for proper client boundary\nimport { HierarchyButtonClient } from '../../../exports/client/index.js'\n\nexport type HierarchyButtonServerProps = {\n fieldName: string\n hasMany?: boolean\n hierarchyCollectionSlug: string\n payload: Payload\n}\n\nexport const HierarchyButton: React.FC<HierarchyButtonServerProps> = ({\n fieldName,\n hasMany,\n hierarchyCollectionSlug,\n payload,\n}) => {\n const hierarchyCollectionConfig = payload.config.collections.find(\n (c) => c.slug === hierarchyCollectionSlug,\n )\n const hierarchyConfig =\n hierarchyCollectionConfig?.hierarchy && typeof hierarchyCollectionConfig.hierarchy === 'object'\n ? hierarchyCollectionConfig.hierarchy\n : undefined\n const IconComponent = hierarchyConfig?.admin.components.Icon\n const SmallIconComponent = hierarchyConfig?.admin.components.SmallIcon\n\n // Render the custom icon if provided, otherwise use FolderIcon directly\n // Important: Must render the icon here on server to avoid hydration mismatch\n // For default FolderIcon path, render directly to avoid import map requirement\n const isDefaultFolderIcon = !IconComponent || IconComponent === '@payloadcms/ui#FolderIcon'\n const renderedIcon = isDefaultFolderIcon ? (\n <FolderIcon />\n ) : (\n RenderServerComponent({\n Component: IconComponent,\n importMap: payload.importMap,\n key: `hierarchy-button-icon-${hierarchyCollectionSlug}`,\n })\n )\n\n // Render the small icon for compact display (pill button)\n // Reuse the full icon if SmallIcon is the same component\n const isDefaultSmallIcon =\n !SmallIconComponent || SmallIconComponent === '@payloadcms/ui#FolderIcon'\n const renderedSmallIcon =\n SmallIconComponent === IconComponent ? (\n renderedIcon\n ) : isDefaultSmallIcon ? (\n <FolderIcon />\n ) : (\n RenderServerComponent({\n Component: SmallIconComponent,\n importMap: payload.importMap,\n key: `hierarchy-button-small-icon-${hierarchyCollectionSlug}`,\n })\n )\n\n return (\n <HierarchyButtonClient\n fieldName={fieldName}\n hasMany={hasMany}\n hierarchyCollectionSlug={hierarchyCollectionSlug}\n Icon={renderedIcon}\n SmallIcon={renderedSmallIcon}\n />\n )\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AAElB,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC;AACA,SAASC,qBAAqB,QAAQ;AAStC,OAAO,MAAMC,eAAA,GAAwDA,CAAC;EACpEC,SAAS;EACTC,OAAO;EACPC,uBAAuB;EACvBC;AAAO,CACR;EACC,MAAMC,yBAAA,GAA4BD,OAAA,CAAQE,MAAM,CAACC,WAAW,CAACC,IAAI,CAC9DC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAKP,uBAAA;EAEpB,MAAMQ,eAAA,GACJN,yBAAA,EAA2BO,SAAA,IAAa,OAAOP,yBAAA,CAA0BO,SAAS,KAAK,WACnFP,yBAAA,CAA0BO,SAAS,GACnCC,SAAA;EACN,MAAMC,aAAA,GAAgBH,eAAA,EAAiBI,KAAA,CAAMC,UAAA,CAAWC,IAAA;EACxD,MAAMC,kBAAA,GAAqBP,eAAA,EAAiBI,KAAA,CAAMC,UAAA,CAAWG,SAAA;EAE7D;EACA;EACA;EACA,MAAMC,mBAAA,GAAsB,CAACN,aAAA,IAAiBA,aAAA,KAAkB;EAChE,MAAMO,YAAA,GAAeD,mBAAA,gBACnBE,IAAA,CAACzB,UAAA,QAEDC,qBAAA,CAAsB;IACpByB,SAAA,EAAWT,aAAA;IACXU,SAAA,EAAWpB,OAAA,CAAQoB,SAAS;IAC5BC,GAAA,EAAK,yBAAyBtB,uBAAA;EAChC;EAGF;EACA;EACA,MAAMuB,kBAAA,GACJ,CAACR,kBAAA,IAAsBA,kBAAA,KAAuB;EAChD,MAAMS,iBAAA,GACJT,kBAAA,KAAuBJ,aAAA,GACrBO,YAAA,GACEK,kBAAA,gBACFJ,IAAA,CAACzB,UAAA,QAEDC,qBAAA,CAAsB;IACpByB,SAAA,EAAWL,kBAAA;IACXM,SAAA,EAAWpB,OAAA,CAAQoB,SAAS;IAC5BC,GAAA,EAAK,+BAA+BtB,uBAAA;EACtC;EAGJ,oBACEmB,IAAA,CAACvB,qBAAA;IACCE,SAAA,EAAWA,SAAA;IACXC,OAAA,EAASA,OAAA;IACTC,uBAAA,EAAyBA,uBAAA;IACzBc,IAAA,EAAMI,YAAA;IACNF,SAAA,EAAWQ;;AAGjB","ignoreList":[]}
|
|
@@ -4,5 +4,10 @@ import './index.css';
|
|
|
4
4
|
export type HierarchyFieldClientProps = {
|
|
5
5
|
Icon?: React.ReactNode;
|
|
6
6
|
} & RelationshipFieldClientProps;
|
|
7
|
+
/**
|
|
8
|
+
* Renders a hierarchy relationship (e.g. tags) as a standard relationship input, swapping the
|
|
9
|
+
* "create new document" button for one that opens the hierarchy column browser. Options are
|
|
10
|
+
* labelled with their full ancestor path while browsing so same-named items stay distinguishable.
|
|
11
|
+
*/
|
|
7
12
|
export declare const HierarchyFieldClient: React.FC<HierarchyFieldClientProps>;
|
|
8
13
|
//# sourceMappingURL=index.client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAqB,MAAM,SAAS,CAAA;AAG9E,OAAO,KAAyC,MAAM,OAAO,CAAA;AAc7D,OAAO,aAAa,CAAA;AAUpB,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB,GAAG,4BAA4B,CAAA;AAEhC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAoPpE,CAAA"}
|
|
@@ -2,30 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { getTranslation } from '@payloadcms/translations';
|
|
5
|
-
import React, { useCallback, useMemo } from 'react';
|
|
6
|
-
import { FieldDescription } from '../../../fields/FieldDescription/index.js';
|
|
7
|
-
import { FieldError } from '../../../fields/FieldError/index.js';
|
|
8
|
-
import { FieldLabel } from '../../../fields/FieldLabel/index.js';
|
|
5
|
+
import React, { Fragment, useCallback, useMemo } from 'react';
|
|
9
6
|
import { mergeFieldStyles } from '../../../fields/mergeFieldStyles.js';
|
|
10
|
-
import {
|
|
7
|
+
import { RelationshipInput } from '../../../fields/Relationship/Input.js';
|
|
11
8
|
import { useField } from '../../../forms/useField/index.js';
|
|
12
|
-
import {
|
|
9
|
+
import { TagIcon } from '../../../icons/Tag/index.js';
|
|
13
10
|
import { useConfig } from '../../../providers/Config/index.js';
|
|
14
11
|
import { useDocumentInfo } from '../../../providers/DocumentInfo/index.js';
|
|
15
12
|
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
16
13
|
import { Button } from '../../Button/index.js';
|
|
17
|
-
import { RenderCustomComponent } from '../../RenderCustomComponent/index.js';
|
|
18
14
|
import { useHierarchyModal } from '../Modal/useHierarchyModal.js';
|
|
19
|
-
import { SelectedHierarchies } from './SelectedHierarchies.js';
|
|
20
15
|
import './index.css';
|
|
21
16
|
const baseClass = 'hierarchy-field';
|
|
17
|
+
/** The hierarchy is monomorphic, so the grouped options can be flattened into a single list */
|
|
18
|
+
const flattenOptionGroups = groups => groups.map(group => group.options).flat();
|
|
19
|
+
/**
|
|
20
|
+
* Renders a hierarchy relationship (e.g. tags) as a standard relationship input, swapping the
|
|
21
|
+
* "create new document" button for one that opens the hierarchy column browser. Options are
|
|
22
|
+
* labelled with their full ancestor path while browsing so same-named items stay distinguishable.
|
|
23
|
+
*/
|
|
22
24
|
export const HierarchyFieldClient = props => {
|
|
23
25
|
const {
|
|
24
26
|
field,
|
|
25
27
|
field: {
|
|
26
28
|
admin: {
|
|
27
29
|
className,
|
|
28
|
-
description
|
|
30
|
+
description,
|
|
31
|
+
isSortable = true,
|
|
32
|
+
placeholder
|
|
29
33
|
} = {},
|
|
30
34
|
hasMany,
|
|
31
35
|
label,
|
|
@@ -52,6 +56,8 @@ export const HierarchyFieldClient = props => {
|
|
|
52
56
|
const collectionConfig = getEntityConfig({
|
|
53
57
|
collectionSlug: hierarchySlug
|
|
54
58
|
});
|
|
59
|
+
const hierarchyConfig = collectionConfig?.hierarchy && typeof collectionConfig.hierarchy === 'object' ? collectionConfig.hierarchy : undefined;
|
|
60
|
+
const titlePathFieldName = hierarchyConfig?.titlePathFieldName;
|
|
55
61
|
const memoizedValidate = useCallback((value, validationOptions) => {
|
|
56
62
|
if (typeof validate === 'function') {
|
|
57
63
|
return validate(value, {
|
|
@@ -69,6 +75,8 @@ export const HierarchyFieldClient = props => {
|
|
|
69
75
|
Label
|
|
70
76
|
} = {},
|
|
71
77
|
disabled,
|
|
78
|
+
filterOptions,
|
|
79
|
+
initialValue,
|
|
72
80
|
path,
|
|
73
81
|
setValue,
|
|
74
82
|
showError,
|
|
@@ -77,27 +85,49 @@ export const HierarchyFieldClient = props => {
|
|
|
77
85
|
potentiallyStalePath: pathFromProps,
|
|
78
86
|
validate: memoizedValidate
|
|
79
87
|
});
|
|
88
|
+
const [relationTo] = React.useState(() => [hierarchySlug]);
|
|
80
89
|
const styles = useMemo(() => mergeFieldStyles(field), [field]);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return value_0;
|
|
90
|
+
const toRelationValues = useCallback(ids => {
|
|
91
|
+
if (hasMany) {
|
|
92
|
+
return Array.isArray(ids) ? ids.map(id => ({
|
|
93
|
+
relationTo: hierarchySlug,
|
|
94
|
+
value: id
|
|
95
|
+
})) : null;
|
|
88
96
|
}
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
return ids ? {
|
|
98
|
+
relationTo: hierarchySlug,
|
|
99
|
+
value: ids
|
|
100
|
+
} : null;
|
|
101
|
+
}, [hasMany, hierarchySlug]);
|
|
102
|
+
const memoizedValue = useMemo(() => toRelationValues(value_0), [toRelationValues, value_0]);
|
|
103
|
+
const memoizedInitialValue = useMemo(() => toRelationValues(initialValue), [initialValue, toRelationValues]);
|
|
104
|
+
const handleChangeHasMany = useCallback(newValue => {
|
|
105
|
+
const ids_0 = Array.isArray(newValue) ? newValue.map(relation => relation.value) : [];
|
|
106
|
+
const isUnchanged = Array.isArray(value_0) && value_0.length === ids_0.length && value_0.every((id_0, index) => id_0 === ids_0[index]);
|
|
107
|
+
setValue(ids_0, isUnchanged);
|
|
108
|
+
}, [setValue, value_0]);
|
|
109
|
+
const handleChangeSingle = useCallback(newValue_0 => {
|
|
110
|
+
const id_1 = newValue_0?.value ?? null;
|
|
111
|
+
setValue(id_1, value_0 === id_1);
|
|
112
|
+
}, [setValue, value_0]);
|
|
113
|
+
// Selecting the virtual path field is what triggers the server to compute it
|
|
114
|
+
const selectOptionFields = useMemo(() => titlePathFieldName ? {
|
|
115
|
+
[titlePathFieldName]: true
|
|
116
|
+
} : undefined, [titlePathFieldName]);
|
|
117
|
+
const formatOptionLabel = useCallback(({
|
|
118
|
+
context,
|
|
119
|
+
defaultLabel,
|
|
120
|
+
doc
|
|
121
|
+
}) => {
|
|
122
|
+
if (context !== 'menu' || !titlePathFieldName) {
|
|
123
|
+
return defaultLabel;
|
|
95
124
|
}
|
|
96
|
-
|
|
97
|
-
|
|
125
|
+
const titlePath = doc?.[titlePathFieldName];
|
|
126
|
+
if (typeof titlePath !== 'string' || !titlePath) {
|
|
127
|
+
return defaultLabel;
|
|
98
128
|
}
|
|
99
|
-
return
|
|
100
|
-
}, [
|
|
129
|
+
return titlePath.split('/').map(segment => segment.trim()).join(' / ');
|
|
130
|
+
}, [titlePathFieldName]);
|
|
101
131
|
// Memoize to prevent new array references on every render
|
|
102
132
|
const filterByCollection = useMemo(() => documentCollectionSlug ? [documentCollectionSlug] : undefined, [documentCollectionSlug]);
|
|
103
133
|
const [HierarchyModal,, {
|
|
@@ -107,83 +137,78 @@ export const HierarchyFieldClient = props => {
|
|
|
107
137
|
hierarchyCollectionSlug: hierarchySlug,
|
|
108
138
|
Icon
|
|
109
139
|
});
|
|
140
|
+
// Pass the current value so the browser opens expanded to what is already selected
|
|
141
|
+
const initialSelections = useMemo(() => {
|
|
142
|
+
if (!value_0) {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
return Array.isArray(value_0) ? value_0 : [value_0];
|
|
146
|
+
}, [value_0]);
|
|
110
147
|
const handleModalSave = useCallback(({
|
|
111
148
|
closeModal,
|
|
112
149
|
selections
|
|
113
150
|
}) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
setValue(newValue);
|
|
151
|
+
const ids_1 = Array.from(selections.keys());
|
|
152
|
+
setValue(hasMany ? ids_1 : ids_1[0] ?? null);
|
|
117
153
|
closeModal();
|
|
118
154
|
}, [hasMany, setValue]);
|
|
119
|
-
const handleRemove = useCallback(({
|
|
120
|
-
id: idToRemove
|
|
121
|
-
}) => {
|
|
122
|
-
if (hasMany) {
|
|
123
|
-
const newIds = selectedIds.filter(id => id !== idToRemove);
|
|
124
|
-
setValue(newIds.length > 0 ? newIds : null);
|
|
125
|
-
} else {
|
|
126
|
-
setValue(null);
|
|
127
|
-
}
|
|
128
|
-
}, [hasMany, selectedIds, setValue]);
|
|
129
|
-
const handleOpenModal = useCallback(() => {
|
|
130
|
-
openModal();
|
|
131
|
-
}, [openModal]);
|
|
132
155
|
const hierarchyLabel = getTranslation(hasMany ? collectionConfig?.labels?.plural : collectionConfig?.labels?.singular, i18n) || hierarchySlug;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}), BeforeInput, /*#__PURE__*/_jsxs("div", {
|
|
154
|
-
className: `${baseClass}__content`,
|
|
155
|
-
children: [selectedIds.length > 0 && /*#__PURE__*/_jsx(SelectedHierarchies, {
|
|
156
|
-
hierarchySlug: hierarchySlug,
|
|
157
|
-
onRemove: handleRemove,
|
|
158
|
-
readOnly: readOnly || disabled,
|
|
159
|
-
selectedIds: selectedIds
|
|
160
|
-
}), !readOnly && (hasMany || selectedIds.length === 0) && /*#__PURE__*/_jsx(Button, {
|
|
161
|
-
buttonStyle: "dashed",
|
|
162
|
-
className: `${baseClass}__manage-button`,
|
|
163
|
-
disabled: disabled,
|
|
164
|
-
icon: /*#__PURE__*/_jsx(CirclePlusIcon, {
|
|
165
|
-
size: 24
|
|
166
|
-
}),
|
|
167
|
-
iconPosition: "left",
|
|
168
|
-
margin: false,
|
|
169
|
-
onClick: handleOpenModal,
|
|
170
|
-
size: "medium",
|
|
171
|
-
children: t('general:selectLabel', {
|
|
172
|
-
label: hierarchyLabel
|
|
173
|
-
})
|
|
174
|
-
})]
|
|
175
|
-
}), AfterInput, /*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
176
|
-
CustomComponent: Description,
|
|
177
|
-
Fallback: /*#__PURE__*/_jsx(FieldDescription, {
|
|
178
|
-
description: description,
|
|
179
|
-
path: path
|
|
180
|
-
})
|
|
156
|
+
const selectLabel = t('general:selectLabel', {
|
|
157
|
+
label: hierarchyLabel
|
|
158
|
+
});
|
|
159
|
+
const BrowseButton = useMemo(() => /*#__PURE__*/_jsx(Button, {
|
|
160
|
+
"aria-label": selectLabel,
|
|
161
|
+
buttonStyle: "secondary",
|
|
162
|
+
className: `${baseClass}__browse-button`,
|
|
163
|
+
disabled: disabled,
|
|
164
|
+
icon: Icon ?? /*#__PURE__*/_jsx(TagIcon, {}),
|
|
165
|
+
margin: false,
|
|
166
|
+
onClick: openModal,
|
|
167
|
+
size: "large",
|
|
168
|
+
tooltip: selectLabel
|
|
169
|
+
}), [disabled, Icon, openModal, selectLabel]);
|
|
170
|
+
return /*#__PURE__*/_jsx(RelationshipInput, {
|
|
171
|
+
AfterInput: /*#__PURE__*/_jsxs(Fragment, {
|
|
172
|
+
children: [AfterInput, /*#__PURE__*/_jsx(HierarchyModal, {
|
|
173
|
+
hasMany: hasMany,
|
|
174
|
+
initialSelections: initialSelections,
|
|
175
|
+
onSave: handleModalSave
|
|
181
176
|
})]
|
|
182
|
-
}),
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
}),
|
|
178
|
+
allowEdit: false,
|
|
179
|
+
BeforeInput: BeforeInput,
|
|
180
|
+
className: [baseClass, className].filter(Boolean).join(' '),
|
|
181
|
+
CreateButton: BrowseButton,
|
|
182
|
+
Description: Description,
|
|
183
|
+
description: description,
|
|
184
|
+
Error: Error,
|
|
185
|
+
filterOptions: filterOptions,
|
|
186
|
+
formatDisplayedOptions: flattenOptionGroups,
|
|
187
|
+
formatOptionLabel: formatOptionLabel,
|
|
188
|
+
isSortable: isSortable,
|
|
189
|
+
Label: Label,
|
|
190
|
+
label: label,
|
|
191
|
+
localized: localized,
|
|
192
|
+
maxResultsPerRequest: 10,
|
|
193
|
+
path: path,
|
|
194
|
+
placeholder: placeholder,
|
|
195
|
+
readOnly: readOnly || disabled,
|
|
196
|
+
relationTo: relationTo,
|
|
197
|
+
required: required,
|
|
198
|
+
selectOptionFields: selectOptionFields,
|
|
199
|
+
showError: showError,
|
|
200
|
+
style: styles,
|
|
201
|
+
...(hasMany === true ? {
|
|
202
|
+
hasMany: true,
|
|
203
|
+
initialValue: memoizedInitialValue,
|
|
204
|
+
onChange: handleChangeHasMany,
|
|
205
|
+
value: memoizedValue
|
|
206
|
+
} : {
|
|
207
|
+
hasMany: false,
|
|
208
|
+
initialValue: memoizedInitialValue,
|
|
209
|
+
onChange: handleChangeSingle,
|
|
210
|
+
value: memoizedValue
|
|
211
|
+
})
|
|
187
212
|
});
|
|
188
213
|
};
|
|
189
214
|
//# sourceMappingURL=index.client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.js","names":["getTranslation","React","useCallback","useMemo","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","useField","CirclePlusIcon","useConfig","useDocumentInfo","useTranslation","Button","RenderCustomComponent","useHierarchyModal","SelectedHierarchies","baseClass","HierarchyFieldClient","props","field","admin","className","description","hasMany","label","localized","relationTo","relationToProp","required","Icon","path","pathFromProps","readOnly","validate","hierarchySlug","Array","isArray","getEntityConfig","collectionSlug","documentCollectionSlug","i18n","t","collectionConfig","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","setValue","showError","potentiallyStalePath","styles","selectedIds","initialSelections","filterByCollection","undefined","HierarchyModal","openModal","hierarchyCollectionSlug","handleModalSave","closeModal","selections","ids","from","keys","newValue","handleRemove","id","idToRemove","newIds","filter","length","handleOpenModal","hierarchyLabel","labels","plural","singular","_jsxs","Boolean","join","replace","style","_jsx","CustomComponent","Fallback","onRemove","buttonStyle","icon","size","iconPosition","margin","onClick","onSave"],"sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"sourcesContent":["'use client'\nimport type { RelationshipFieldClientProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useMemo } from 'react'\n\nimport type { SelectionWithPath } from '../Modal/types.js'\n\nimport { FieldDescription } from '../../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../../fields/FieldLabel/index.js'\nimport { mergeFieldStyles } from '../../../fields/mergeFieldStyles.js'\nimport { fieldBaseClass } from '../../../fields/shared/index.js'\nimport { useField } from '../../../forms/useField/index.js'\nimport { CirclePlusIcon } from '../../../icons/CirclePlus/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { RenderCustomComponent } from '../../RenderCustomComponent/index.js'\nimport { useHierarchyModal } from '../Modal/useHierarchyModal.js'\nimport { SelectedHierarchies } from './SelectedHierarchies.js'\nimport './index.css'\n\nconst baseClass = 'hierarchy-field'\n\ntype Value = (number | string)[] | null | (number | string)\n\nexport type HierarchyFieldClientProps = {\n Icon?: React.ReactNode\n} & RelationshipFieldClientProps\n\nexport const HierarchyFieldClient: React.FC<HierarchyFieldClientProps> = (props) => {\n const {\n field,\n field: {\n admin: { className, description } = {},\n hasMany,\n label,\n localized,\n relationTo: relationToProp,\n required,\n },\n Icon,\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const hierarchySlug = Array.isArray(relationToProp) ? relationToProp[0] : relationToProp\n\n const { getEntityConfig } = useConfig()\n const { collectionSlug: documentCollectionSlug } = useDocumentInfo()\n const { i18n, t } = useTranslation()\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchySlug })\n\n const memoizedValidate = useCallback(\n (value: Value, validationOptions: Parameters<typeof validate>[1]) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n path,\n setValue,\n showError,\n value,\n } = useField<Value>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n // Normalize value to array of IDs for display\n const selectedIds = useMemo((): (number | string)[] => {\n if (!value) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value]\n }, [value])\n\n // Initialize selections for the modal - use current value so modal expands to current selection\n const initialSelections = useMemo(() => {\n if (!value) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value] as (number | string)[]\n }, [value])\n\n // Memoize to prevent new array references on every render\n const filterByCollection = useMemo(\n () => (documentCollectionSlug ? [documentCollectionSlug] : undefined),\n [documentCollectionSlug],\n )\n\n const [HierarchyModal, , { openModal }] = useHierarchyModal({\n filterByCollection,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n const handleModalSave = useCallback(\n ({\n closeModal,\n selections,\n }: {\n closeModal: () => void\n selections: Map<number | string, SelectionWithPath>\n }) => {\n const ids = Array.from(selections.keys())\n const newValue = hasMany ? ids : (ids[0] ?? null)\n setValue(newValue)\n closeModal()\n },\n [hasMany, setValue],\n )\n\n const handleRemove = useCallback(\n ({ id: idToRemove }: { id: number | string }) => {\n if (hasMany) {\n const newIds = selectedIds.filter((id) => id !== idToRemove)\n setValue(newIds.length > 0 ? newIds : null)\n } else {\n setValue(null)\n }\n },\n [hasMany, selectedIds, setValue],\n )\n\n const handleOpenModal = useCallback(() => {\n openModal()\n }, [openModal])\n\n const hierarchyLabel =\n getTranslation(\n hasMany ? collectionConfig?.labels?.plural : collectionConfig?.labels?.singular,\n i18n,\n ) || hierarchySlug\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && `${baseClass}--read-only`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <div className={`${baseClass}__content`}>\n {selectedIds.length > 0 && (\n <SelectedHierarchies\n hierarchySlug={hierarchySlug}\n onRemove={handleRemove}\n readOnly={readOnly || disabled}\n selectedIds={selectedIds}\n />\n )}\n {!readOnly && (hasMany || selectedIds.length === 0) && (\n <Button\n buttonStyle=\"dashed\"\n className={`${baseClass}__manage-button`}\n disabled={disabled}\n icon={<CirclePlusIcon size={24} />}\n iconPosition=\"left\"\n margin={false}\n onClick={handleOpenModal}\n size=\"medium\"\n >\n {t('general:selectLabel', { label: hierarchyLabel })}\n </Button>\n )}\n </div>\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n <HierarchyModal\n hasMany={hasMany}\n initialSelections={initialSelections}\n onSave={handleModalSave}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAI5C,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;A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A,eAAUF,IAAA,CAACpF,UAAA;UAAW2B,IAAA,EAAMA,IAAA;UAAMwB,SAAA,EAAWA;;UAE9CN,WAAA,E,aACDkC,KAAA,CAAC;QAAI7D,SAAA,EAAW,GAAGL,SAAA,WAAoB;mBACpCyC,WAAA,CAAYmB,MAAM,GAAG,kBACpBW,IAAA,CAACxE,mBAAA;UACCmB,aAAA,EAAeA,aAAA;UACfwD,QAAA,EAAUnB,YAAA;UACVvC,QAAA,EAAUA,QAAA,IAAYoB,QAAA;UACtBK,WAAA,EAAaA;YAGhB,CAACzB,QAAA,KAAaT,OAAA,IAAWkC,WAAA,CAAYmB,MAAM,KAAK,mBAC/CW,IAAA,CAAC3E,MAAA;UACC+E,WAAA,EAAY;UACZtE,SAAA,EAAW,GAAGL,SAAA,iBAA0B;UACxCoC,QAAA,EAAUA,QAAA;UACVwC,IAAA,eAAML,IAAA,CAAC/E,cAAA;YAAeqF,IAAA,EAAM;;UAC5BC,YAAA,EAAa;UACbC,MAAA,EAAQ;UACRC,OAAA,EAASnB,eAAA;UACTgB,IAAA,EAAK;oBAEJpD,CAAA,CAAE,uBAAuB;YAAEjB,KAAA,EAAOsD;UAAe;;UAIvD/B,UAAA,E,aACDwC,IAAA,CAAC1E,qBAAA;QACC2E,eAAA,EAAiBvC,WAAA;QACjBwC,QAAA,eAAUF,IAAA,CAACrF,gBAAA;UAAiBoB,WAAA,EAAaA,WAAA;UAAaQ,IAAA,EAAMA;;;qBAGhEyD,IAAA,CAAC1B,cAAA;MACCtC,OAAA,EAASA,OAAA;MACTmC,iBAAA,EAAmBA,iBAAA;MACnBuC,MAAA,EAAQjC;;;AAIhB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.client.js","names":["getTranslation","React","Fragment","useCallback","useMemo","mergeFieldStyles","RelationshipInput","useField","TagIcon","useConfig","useDocumentInfo","useTranslation","Button","useHierarchyModal","baseClass","flattenOptionGroups","groups","map","group","options","flat","HierarchyFieldClient","props","field","admin","className","description","isSortable","placeholder","hasMany","label","localized","relationTo","relationToProp","required","Icon","path","pathFromProps","readOnly","validate","hierarchySlug","Array","isArray","getEntityConfig","collectionSlug","documentCollectionSlug","i18n","t","collectionConfig","hierarchyConfig","hierarchy","undefined","titlePathFieldName","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","filterOptions","initialValue","setValue","showError","potentiallyStalePath","useState","styles","toRelationValues","ids","id","memoizedValue","memoizedInitialValue","handleChangeHasMany","newValue","relation","isUnchanged","length","every","index","handleChangeSingle","selectOptionFields","formatOptionLabel","context","defaultLabel","doc","titlePath","split","segment","trim","join","filterByCollection","HierarchyModal","openModal","hierarchyCollectionSlug","initialSelections","handleModalSave","closeModal","selections","from","keys","hierarchyLabel","labels","plural","singular","selectLabel","BrowseButton","_jsx","buttonStyle","icon","margin","onClick","size","tooltip","_jsxs","onSave","allowEdit","filter","Boolean","CreateButton","formatDisplayedOptions","maxResultsPerRequest","style","onChange"],"sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"sourcesContent":["'use client'\nimport type { RelationshipFieldClientProps, ValueWithRelation } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { Fragment, useCallback, useMemo } from 'react'\n\nimport type { Option, OptionGroup } from '../../../fields/Relationship/types.js'\nimport type { SelectionWithPath } from '../Modal/types.js'\n\nimport { mergeFieldStyles } from '../../../fields/mergeFieldStyles.js'\nimport { RelationshipInput } from '../../../fields/Relationship/Input.js'\nimport { useField } from '../../../forms/useField/index.js'\nimport { TagIcon } from '../../../icons/Tag/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { useHierarchyModal } from '../Modal/useHierarchyModal.js'\nimport './index.css'\n\nconst baseClass = 'hierarchy-field'\n\ntype Value = (number | string)[] | null | (number | string)\n\n/** The hierarchy is monomorphic, so the grouped options can be flattened into a single list */\nconst flattenOptionGroups = (groups: OptionGroup[]): Option[] =>\n groups.map((group) => group.options).flat()\n\nexport type HierarchyFieldClientProps = {\n Icon?: React.ReactNode\n} & RelationshipFieldClientProps\n\n/**\n * Renders a hierarchy relationship (e.g. tags) as a standard relationship input, swapping the\n * \"create new document\" button for one that opens the hierarchy column browser. Options are\n * labelled with their full ancestor path while browsing so same-named items stay distinguishable.\n */\nexport const HierarchyFieldClient: React.FC<HierarchyFieldClientProps> = (props) => {\n const {\n field,\n field: {\n admin: { className, description, isSortable = true, placeholder } = {},\n hasMany,\n label,\n localized,\n relationTo: relationToProp,\n required,\n },\n Icon,\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const hierarchySlug = Array.isArray(relationToProp) ? relationToProp[0] : relationToProp\n\n const { getEntityConfig } = useConfig()\n const { collectionSlug: documentCollectionSlug } = useDocumentInfo()\n const { i18n, t } = useTranslation()\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchySlug })\n const hierarchyConfig =\n collectionConfig?.hierarchy && typeof collectionConfig.hierarchy === 'object'\n ? collectionConfig.hierarchy\n : undefined\n const titlePathFieldName = hierarchyConfig?.titlePathFieldName\n\n const memoizedValidate = useCallback(\n (value: Value, validationOptions: Parameters<typeof validate>[1]) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n filterOptions,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<Value>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const [relationTo] = React.useState(() => [hierarchySlug])\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const toRelationValues = useCallback(\n (ids: Value): null | ValueWithRelation | ValueWithRelation[] => {\n if (hasMany) {\n return Array.isArray(ids)\n ? ids.map((id) => ({ relationTo: hierarchySlug, value: id }))\n : null\n }\n\n return ids ? { relationTo: hierarchySlug, value: ids as number | string } : null\n },\n [hasMany, hierarchySlug],\n )\n\n const memoizedValue = useMemo(() => toRelationValues(value), [toRelationValues, value])\n\n const memoizedInitialValue = useMemo(\n () => toRelationValues(initialValue),\n [initialValue, toRelationValues],\n )\n\n const handleChangeHasMany = useCallback(\n (newValue: ValueWithRelation[]) => {\n const ids = Array.isArray(newValue) ? newValue.map((relation) => relation.value) : []\n\n const isUnchanged =\n Array.isArray(value) &&\n value.length === ids.length &&\n value.every((id, index) => id === ids[index])\n\n setValue(ids, isUnchanged)\n },\n [setValue, value],\n )\n\n const handleChangeSingle = useCallback(\n (newValue: ValueWithRelation) => {\n const id = newValue?.value ?? null\n setValue(id, value === id)\n },\n [setValue, value],\n )\n\n // Selecting the virtual path field is what triggers the server to compute it\n const selectOptionFields = useMemo(\n () => (titlePathFieldName ? { [titlePathFieldName]: true } : undefined),\n [titlePathFieldName],\n )\n\n const formatOptionLabel = useCallback(\n ({\n context,\n defaultLabel,\n doc,\n }: {\n context: 'menu' | 'value'\n defaultLabel: string\n doc?: Record<string, unknown>\n }) => {\n if (context !== 'menu' || !titlePathFieldName) {\n return defaultLabel\n }\n\n const titlePath = doc?.[titlePathFieldName]\n\n if (typeof titlePath !== 'string' || !titlePath) {\n return defaultLabel\n }\n\n return titlePath\n .split('/')\n .map((segment) => segment.trim())\n .join(' / ')\n },\n [titlePathFieldName],\n )\n\n // Memoize to prevent new array references on every render\n const filterByCollection = useMemo(\n () => (documentCollectionSlug ? [documentCollectionSlug] : undefined),\n [documentCollectionSlug],\n )\n\n const [HierarchyModal, , { openModal }] = useHierarchyModal({\n filterByCollection,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n // Pass the current value so the browser opens expanded to what is already selected\n const initialSelections = useMemo((): (number | string)[] => {\n if (!value) {\n return []\n }\n\n return Array.isArray(value) ? value : [value]\n }, [value])\n\n const handleModalSave = useCallback(\n ({\n closeModal,\n selections,\n }: {\n closeModal: () => void\n selections: Map<number | string, SelectionWithPath>\n }) => {\n const ids = Array.from(selections.keys())\n setValue(hasMany ? ids : (ids[0] ?? null))\n closeModal()\n },\n [hasMany, setValue],\n )\n\n const hierarchyLabel =\n getTranslation(\n hasMany ? collectionConfig?.labels?.plural : collectionConfig?.labels?.singular,\n i18n,\n ) || hierarchySlug\n\n const selectLabel = t('general:selectLabel', { label: hierarchyLabel })\n\n const BrowseButton = useMemo(\n () => (\n <Button\n aria-label={selectLabel}\n buttonStyle=\"secondary\"\n className={`${baseClass}__browse-button`}\n disabled={disabled}\n icon={Icon ?? <TagIcon />}\n margin={false}\n onClick={openModal}\n size=\"large\"\n tooltip={selectLabel}\n />\n ),\n [disabled, Icon, openModal, selectLabel],\n )\n\n return (\n <RelationshipInput\n AfterInput={\n <Fragment>\n {AfterInput}\n <HierarchyModal\n hasMany={hasMany}\n initialSelections={initialSelections}\n onSave={handleModalSave}\n />\n </Fragment>\n }\n allowEdit={false}\n BeforeInput={BeforeInput}\n className={[baseClass, className].filter(Boolean).join(' ')}\n CreateButton={BrowseButton}\n Description={Description}\n description={description}\n Error={Error}\n filterOptions={filterOptions}\n formatDisplayedOptions={flattenOptionGroups}\n formatOptionLabel={formatOptionLabel}\n isSortable={isSortable}\n Label={Label}\n label={label}\n localized={localized}\n maxResultsPerRequest={10}\n path={path}\n placeholder={placeholder}\n readOnly={readOnly || disabled}\n relationTo={relationTo}\n required={required}\n selectOptionFields={selectOptionFields}\n showError={showError}\n style={styles}\n {...(hasMany === true\n ? {\n hasMany: true,\n initialValue: memoizedInitialValue as ValueWithRelation[],\n onChange: handleChangeHasMany,\n value: memoizedValue as ValueWithRelation[],\n }\n : {\n hasMany: false,\n initialValue: memoizedInitialValue as ValueWithRelation,\n onChange: handleChangeSingle,\n value: memoizedValue as ValueWithRelation,\n })}\n />\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,QAAQ;AAKtD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A,EAAWA,SAAA;IACX0D,KAAA,EAAOvD,MAAA;IACN,IAAIxC,OAAA,KAAY,OACb;MACEA,OAAA,EAAS;MACTmC,YAAA,EAAcU,oBAAA;MACdmD,QAAA,EAAUlD,mBAAA;MACVrB,KAAA,EAAOmB;IACT,IACA;MACE5C,OAAA,EAAS;MACTmC,YAAA,EAAcU,oBAAA;MACdmD,QAAA,EAAU3C,kBAAA;MACV5B,KAAA,EAAOmB;IACT,CAAC;;AAGX","ignoreList":[]}
|
|
@@ -1,37 +1,6 @@
|
|
|
1
1
|
@layer payload-default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
display: flex;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.hierarchy-field .field-label {
|
|
9
|
-
display: flex;
|
|
10
|
-
font-family: var(--text-body-large-font-family);
|
|
11
|
-
font-size: var(--text-body-large-font-size);
|
|
12
|
-
font-weight: var(--text-body-large-font-weight);
|
|
13
|
-
line-height: var(--text-body-large-line-height);
|
|
14
|
-
letter-spacing: var(--text-body-large-letter-spacing);
|
|
15
|
-
margin: unset;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.hierarchy-field__label {
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
gap: var(--spacer-1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.hierarchy-field__content {
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-direction: column;
|
|
27
|
-
gap: var(--spacer-2-5);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.hierarchy-field__manage-button {
|
|
31
|
-
align-self: flex-start;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.hierarchy-field--read-only .hierarchy-field__content {
|
|
35
|
-
opacity: 0.75;
|
|
2
|
+
/* Matches the icon weight of the default relationship "add new" button this stands in for */
|
|
3
|
+
.hierarchy-field__browse-button {
|
|
4
|
+
color: var(--color-icon);
|
|
36
5
|
}
|
|
37
6
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.hierarchy-modal-footer__lead {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--spacer-1);
|
|
6
|
+
min-width: 0;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.hierarchy-modal-footer__trail {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
gap: var(--spacer-2);
|
|
14
|
+
flex-shrink: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.hierarchy-modal-footer__placeholder {
|
|
18
|
+
color: var(--color-text-secondary);
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.hierarchy-modal-footer__arrow {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-shrink: 0;
|
|
25
|
+
color: var(--color-text-secondary);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.hierarchy-modal-footer__chip {
|
|
29
|
+
max-width: 280px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Lets the breadcrumb ellipsize instead of forcing the chip past its max-width */
|
|
33
|
+
.hierarchy-modal-footer__chip .chip__label {
|
|
34
|
+
min-width: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.hierarchy-modal-footer__chip-separator,
|
|
38
|
+
.hierarchy-modal-footer__chip-ellipsis {
|
|
39
|
+
color: var(--color-text-secondary);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.hierarchy-modal-footer__chip-separator {
|
|
43
|
+
padding-inline: calc(var(--spacer-1) / 2);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PathSegment } from '../../ColumnBrowser/types.js';
|
|
3
|
+
import './index.css';
|
|
4
|
+
export type HierarchyModalFooterProps = {
|
|
5
|
+
/** Label for the primary action, e.g. "Move" or "Confirm" */
|
|
6
|
+
readonly confirmLabel: string;
|
|
7
|
+
/** Path of the item the user has picked in this session, root first */
|
|
8
|
+
readonly destinationPath?: PathSegment[];
|
|
9
|
+
/** Leading icon for the breadcrumb chips - falls back to a folder */
|
|
10
|
+
readonly Icon?: React.ReactNode;
|
|
11
|
+
readonly isConfirmDisabled: boolean;
|
|
12
|
+
readonly isMultiSelect: boolean;
|
|
13
|
+
readonly onClear: () => void;
|
|
14
|
+
readonly onConfirm: () => void;
|
|
15
|
+
readonly onMoveToRoot?: () => void;
|
|
16
|
+
/** Called with a chip's path to expand the browser down to that item and focus it */
|
|
17
|
+
readonly onRevealPath: (path: PathSegment[]) => void;
|
|
18
|
+
/** Shown when nothing has been picked yet, e.g. "Select Folder" */
|
|
19
|
+
readonly placeholderLabel: string;
|
|
20
|
+
/** Path the item lived in before the modal was opened, root first */
|
|
21
|
+
readonly previousPath?: PathSegment[];
|
|
22
|
+
readonly selectionCount: number;
|
|
23
|
+
/** Shown in multi-select mode once something is checked, e.g. "3 Tags selected" */
|
|
24
|
+
readonly selectionCountLabel: string;
|
|
25
|
+
readonly showMoveToRoot?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare const HierarchyModalFooter: React.FC<HierarchyModalFooterProps>;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/Hierarchy/Modal/Footer/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAQ/D,OAAO,aAAa,CAAA;AAOpB,MAAM,MAAM,yBAAyB,GAAG;IACtC,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,eAAe,CAAC,EAAE,WA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