@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useModal","getTranslation","DEFAULT_HIERARCHY_TREE_LIMIT","React","useCallback","useId","useMemo","useRef","useState","PlusIcon","useAuth","useConfig","useHierarchy","useRouter","useTranslation","Button","CreateDocumentButton","DelayedSpinner","DocumentDrawer","LoadMore","TreeFocusProvider","useTreeFocus","TreeNode","useChildren","baseClass","getDocumentTitle","doc","useAsTitle","docId","id","idStr","String","value","HierarchyTreeInner","baseFilter","collectionSlug","filterByCollections","icon","initialData","initialDataProp","initialExpandedNodes","initialExpandedNodesProp","onNodeClick","selectedNodeId","useAsTitleProp","focusedId","moveFocus","setFocusedId","router","i18n","t","permissions","getEntityConfig","closeModal","openModal","createDrawerSlug","isCreateDrawerOpen","setIsCreateDrawerOpen","getExpandedNodesForCollection","getTreeDataForCollection","toggleNodeForCollection","typeFieldName","collectionConfig","hierarchyConfig","hierarchy","undefined","parentFieldName","treeLimit","admin","canCreate","Boolean","collections","create","allPossibleTypeValues","relatedCollections","Object","keys","contextData","baseFilterKey","JSON","stringify","contextBaseFilterKey","contextSeededRef","lastInitialExpandedRef","current","expandedNodes","contextExpanded","size","Set","handleToggleNode","wasSeeded","length","initialSet","map","isCurrentlyExpanded","has","nodeId","childrenCache","Map","prevBaseFilterKeyRef","clear","docs","docsByParent","parentId","parentKey","set","get","push","filterKey","slice","sort","join","cacheKey","parentMeta","loadedParents","loadedCount","children","hasMore","page","Math","ceil","totalDocs","treeRef","rootNodes","isLoading","loadMore","loadMoreFromHook","refresh","cache","enabled","limit","handleLoadMore","handleNodeClick","rootFocusableIds","node","firstRootFocusableId","lastRootFocusableId","handleTreeKeyDown","e","key","preventDefault","_jsx","className","collectionLabel","buttonStyle","drawerSlug","label","labels","singular","onSave","isAllSelected","handleAllClick","_jsxs","onKeyDown","ref","role","tabIndex","filter","onClick","plural","_Fragment","margin","redirectAfterCreate","nodeIdStr","nodeTitle","depth","hasChildren","title","onSelect","onToggle","selected","currentCount","onLoadMore","HierarchyTree","props"],"sources":["../../../../src/elements/Hierarchy/Tree/index.tsx"],"sourcesContent":["'use client'\n\nimport { useModal } from '@faceless-ui/modal'\nimport { getTranslation } from '@payloadcms/translations'\nimport { DEFAULT_HIERARCHY_TREE_LIMIT } from 'payload/shared'\nimport React, { useCallback, useId, useMemo, useRef, useState } from 'react'\n\nimport type { CachedChildren, HierarchyTreeProps, TreeDocument } from './types.js'\n\nimport { PlusIcon } from '../../../icons/Plus/index.js'\nimport { useAuth } from '../../../providers/Auth/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useHierarchy } from '../../../providers/Hierarchy/index.js'\nimport { useRouter } from '../../../providers/RouterAdapter/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { CreateDocumentButton } from '../../CreateDocumentButton/index.js'\nimport { DelayedSpinner } from '../../DelayedSpinner/index.js'\nimport { DocumentDrawer } from '../../DocumentDrawer/index.js'\nimport { LoadMore } from './LoadMore/index.js'\nimport { TreeFocusProvider, useTreeFocus } from './TreeFocusContext.js'\nimport { TreeNode } from './TreeNode/index.js'\nimport { useChildren } from './useChildren.js'\nimport './index.css'\n\nconst baseClass = 'tree'\n\nconst getDocumentTitle = (doc: TreeDocument, useAsTitle: string | undefined): string => {\n const docId: number | string = doc.id\n const idStr = typeof docId === 'number' ? String(docId) : docId\n\n if (!useAsTitle) {\n return idStr\n }\n\n const value = doc[useAsTitle]\n if (value && (typeof value === 'string' || typeof value === 'number')) {\n return String(value)\n }\n return idStr\n}\n\nconst HierarchyTreeInner: React.FC<HierarchyTreeProps> = ({\n baseFilter,\n collectionSlug,\n filterByCollections,\n icon,\n initialData: initialDataProp,\n initialExpandedNodes: initialExpandedNodesProp,\n onNodeClick,\n selectedNodeId,\n useAsTitle: useAsTitleProp,\n}) => {\n const { focusedId, moveFocus, setFocusedId } = useTreeFocus()\n const router = useRouter()\n const { i18n, t } = useTranslation()\n const { permissions } = useAuth()\n const { getEntityConfig } = useConfig()\n const { closeModal, openModal } = useModal()\n const createDrawerSlug = `tree-create-${useId()}`\n const [isCreateDrawerOpen, setIsCreateDrawerOpen] = useState(false)\n\n const {\n getExpandedNodesForCollection,\n getTreeDataForCollection,\n toggleNodeForCollection,\n typeFieldName,\n } = useHierarchy()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const hierarchyConfig =\n collectionConfig.hierarchy && typeof collectionConfig.hierarchy === 'object'\n ? collectionConfig.hierarchy\n : undefined\n const parentFieldName = hierarchyConfig?.parentFieldName\n const treeLimit = hierarchyConfig?.admin?.treeLimit ?? DEFAULT_HIERARCHY_TREE_LIMIT\n const useAsTitle = useAsTitleProp ?? collectionConfig.admin?.useAsTitle\n const canCreate = Boolean(permissions?.collections?.[collectionSlug]?.create)\n\n const allPossibleTypeValues = useMemo(\n () =>\n hierarchyConfig?.relatedCollections\n ? Object.keys(hierarchyConfig.relatedCollections)\n : undefined,\n [hierarchyConfig?.relatedCollections],\n )\n\n const contextData = getTreeDataForCollection(collectionSlug)\n const baseFilterKey = baseFilter ? JSON.stringify(baseFilter) : ''\n const contextBaseFilterKey = contextData?.baseFilter ? JSON.stringify(contextData.baseFilter) : ''\n const initialData =\n baseFilterKey === contextBaseFilterKey ? (contextData ?? initialDataProp) : initialDataProp\n // Tracks whether context has been seeded at least once since the last navigation.\n // Resets when initialExpandedNodesProp changes (new array reference = navigation).\n // Allows the memo to distinguish \"not yet seeded\" (fall back to prop) from\n // \"user collapsed all nodes\" (trust empty context).\n const contextSeededRef = useRef(false)\n const lastInitialExpandedRef = useRef(initialExpandedNodesProp)\n if (lastInitialExpandedRef.current !== initialExpandedNodesProp) {\n lastInitialExpandedRef.current = initialExpandedNodesProp\n contextSeededRef.current = false\n }\n\n const expandedNodes = useMemo(() => {\n const contextExpanded = getExpandedNodesForCollection(collectionSlug)\n if (contextExpanded.size > 0) {\n contextSeededRef.current = true\n return contextExpanded\n }\n if (contextSeededRef.current) {\n // Context was seeded (had nodes since last navigation) — trust empty set as \"all collapsed\"\n return contextExpanded\n }\n return initialExpandedNodesProp ? new Set(initialExpandedNodesProp) : contextExpanded\n }, [collectionSlug, getExpandedNodesForCollection, initialExpandedNodesProp])\n\n const handleToggleNode = useCallback(\n ({ id }: { id: number | string }) => {\n // Mark context as seeded so the memo never falls back to the prop after this interaction.\n // Capture the previous value first — seeding is only needed on the very first interaction.\n const wasSeeded = contextSeededRef.current\n contextSeededRef.current = true\n const contextExpanded = getExpandedNodesForCollection(collectionSlug)\n if (!wasSeeded && contextExpanded.size === 0 && initialExpandedNodesProp?.length) {\n // Context not yet seeded. Seed it with all initial nodes, applying the toggle correctly:\n // exclude the target if collapsing, include it if expanding.\n const initialSet = new Set(initialExpandedNodesProp.map(String))\n const isCurrentlyExpanded = initialSet.has(String(id))\n for (const nodeId of initialExpandedNodesProp) {\n if (!isCurrentlyExpanded || String(nodeId) !== String(id)) {\n toggleNodeForCollection(collectionSlug, nodeId)\n }\n }\n if (!isCurrentlyExpanded) {\n toggleNodeForCollection(collectionSlug, id)\n }\n return\n }\n toggleNodeForCollection(collectionSlug, id)\n },\n [\n collectionSlug,\n getExpandedNodesForCollection,\n initialExpandedNodesProp,\n toggleNodeForCollection,\n ],\n )\n\n // Pre-populate cache with initialData synchronously before first render\n const childrenCache = useRef<Map<string, CachedChildren>>(new Map())\n\n const prevBaseFilterKeyRef = useRef(baseFilterKey)\n if (prevBaseFilterKeyRef.current !== baseFilterKey) {\n prevBaseFilterKeyRef.current = baseFilterKey\n childrenCache.current.clear()\n }\n\n useMemo(() => {\n if (!initialData || initialData.docs.length === 0) {\n return\n }\n\n const docsByParent = new Map<string, TreeDocument[]>()\n for (const doc of initialData.docs) {\n const parentId = doc[parentFieldName] || 'null'\n const parentKey = String(parentId)\n if (!docsByParent.has(parentKey)) {\n docsByParent.set(parentKey, [])\n }\n docsByParent.get(parentKey).push(doc)\n }\n\n const filterKey = filterByCollections?.length\n ? filterByCollections.slice().sort().join(',')\n : ''\n for (const [parentKey, docs] of docsByParent) {\n const cacheKey = `${collectionSlug}-${parentKey}-${filterKey}-${baseFilterKey}`\n const parentMeta = initialData.loadedParents[parentKey]\n\n if (parentMeta) {\n const loadedCount = parentMeta.loadedCount ?? docs.length\n childrenCache.current.set(cacheKey, {\n children: docs,\n hasMore: parentMeta.hasMore,\n page: Math.ceil(loadedCount / treeLimit) || 1,\n totalDocs: parentMeta.totalDocs,\n })\n } else {\n childrenCache.current.set(cacheKey, {\n children: docs,\n hasMore: false,\n page: 1,\n totalDocs: docs.length,\n })\n }\n }\n }, [initialData, filterByCollections, parentFieldName, collectionSlug, treeLimit, baseFilterKey])\n\n const treeRef = useRef<HTMLDivElement>(null)\n\n const {\n children: rootNodes,\n hasMore,\n isLoading,\n loadMore: loadMoreFromHook,\n refresh,\n totalDocs,\n } = useChildren({\n allPossibleTypeValues,\n baseFilter,\n cache: childrenCache,\n collectionSlug,\n enabled: true,\n filterByCollections,\n initialData,\n limit: treeLimit,\n parentFieldName,\n parentId: 'null',\n typeFieldName,\n useAsTitle,\n })\n\n const handleLoadMore = useCallback(async () => {\n await loadMoreFromHook()\n }, [loadMoreFromHook])\n\n const handleNodeClick = useCallback(\n ({ id }: { id: number | string }) => {\n onNodeClick?.({ id })\n },\n [onNodeClick],\n )\n\n const rootFocusableIds = useMemo(\n () => (rootNodes ? rootNodes.map((node) => `node-${String(node.id)}`) : []),\n [rootNodes],\n )\n\n const firstRootFocusableId = rootFocusableIds[0]\n const lastRootFocusableId = rootFocusableIds[rootFocusableIds.length - 1]\n\n const handleTreeKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown') {\n e.preventDefault()\n\n if (\n focusedId &&\n firstRootFocusableId &&\n lastRootFocusableId &&\n focusedId === lastRootFocusableId\n ) {\n setFocusedId(firstRootFocusableId)\n return\n }\n\n moveFocus('down')\n } else if (e.key === 'ArrowUp') {\n e.preventDefault()\n\n if (\n focusedId &&\n firstRootFocusableId &&\n lastRootFocusableId &&\n focusedId === firstRootFocusableId\n ) {\n setFocusedId(lastRootFocusableId)\n return\n }\n\n moveFocus('up')\n }\n },\n [firstRootFocusableId, focusedId, lastRootFocusableId, moveFocus, setFocusedId],\n )\n\n if (isLoading && !rootNodes) {\n return (\n <div className={baseClass}>\n <DelayedSpinner baseClass={baseClass} isLoading={true} />\n </div>\n )\n }\n\n if (!rootNodes || rootNodes.length === 0) {\n const collectionLabel = getEntityConfig({ collectionSlug })\n return (\n <div className={baseClass}>\n <CreateDocumentButton\n buttonStyle=\"primary\"\n collections={[{ collectionSlug }]}\n drawerSlug={createDrawerSlug}\n label={t('general:createNewLabel', {\n label: getTranslation(collectionLabel.labels.singular, i18n),\n })}\n onSave={async () => {\n await refresh()\n router.refresh()\n }}\n />\n </div>\n )\n }\n\n const isAllSelected = selectedNodeId === null\n const handleAllClick = () => onNodeClick?.({ id: null })\n\n return (\n <div\n className={baseClass}\n onKeyDown={handleTreeKeyDown}\n ref={treeRef}\n role=\"tree\"\n tabIndex={-1}\n >\n <div className={`${baseClass}__all-option-wrapper`}>\n <div\n aria-selected={isAllSelected}\n className={[\n `${baseClass}__all-option`,\n 'sidebar-row',\n isAllSelected && `${baseClass}__all-option--selected`,\n isAllSelected && 'sidebar-row--selected',\n ]\n .filter(Boolean)\n .join(' ')}\n onClick={handleAllClick}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleAllClick()\n }\n }}\n role=\"treeitem\"\n tabIndex={0}\n >\n <span className=\"sidebar-row__title\">\n {t('general:all')}{' '}\n {getTranslation(getEntityConfig({ collectionSlug })?.labels?.plural, i18n)}\n </span>\n </div>\n {canCreate && (\n <>\n <Button\n aria-label={t('general:createNew')}\n buttonStyle=\"ghost\"\n className={`${baseClass}__create-button`}\n margin={false}\n onClick={() => {\n setIsCreateDrawerOpen(true)\n openModal(createDrawerSlug)\n }}\n >\n <PlusIcon size={24} />\n </Button>\n {isCreateDrawerOpen && (\n <DocumentDrawer\n collectionSlug={collectionSlug}\n drawerSlug={createDrawerSlug}\n initialData={parentFieldName ? { [parentFieldName]: null } : undefined}\n onSave={async () => {\n closeModal(createDrawerSlug)\n setIsCreateDrawerOpen(false)\n await refresh()\n router.refresh()\n }}\n redirectAfterCreate={false}\n />\n )}\n </>\n )}\n </div>\n {rootNodes.map((node) => {\n const nodeId: number | string = node.id\n const nodeIdStr = typeof nodeId === 'number' ? String(nodeId) : nodeId\n const nodeTitle = getDocumentTitle(node, useAsTitle)\n\n return (\n <TreeNode\n allPossibleTypeValues={allPossibleTypeValues}\n baseFilter={baseFilter}\n cache={childrenCache}\n collectionSlug={collectionSlug}\n depth={0}\n expandedNodes={expandedNodes}\n filterByCollections={filterByCollections}\n icon={icon}\n key={nodeIdStr}\n limit={treeLimit}\n node={{ id: nodeId, hasChildren: true, title: nodeTitle }}\n onSelect={handleNodeClick}\n onToggle={handleToggleNode}\n parentFieldName={parentFieldName}\n selected={nodeIdStr === String(selectedNodeId)}\n selectedNodeId={selectedNodeId}\n typeFieldName={typeFieldName}\n useAsTitle={useAsTitle}\n />\n )\n })}\n {hasMore && (\n <LoadMore\n currentCount={rootNodes.length}\n depth={0}\n id=\"load-more-root\"\n onLoadMore={handleLoadMore}\n totalDocs={totalDocs}\n />\n )}\n </div>\n )\n}\n\nexport const HierarchyTree: React.FC<HierarchyTreeProps> = (props) => {\n return (\n <TreeFocusProvider>\n <HierarchyTreeInner {...props} />\n </TreeFocusProvider>\n )\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,4BAA4B,QAAQ;AAC7C,OAAOC,KAAA,IAASC,WAAW,EA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ARCHY_TREE_LIMIT","React","useCallback","useId","useMemo","useRef","CollapseLayersIcon","useConfig","useHierarchy","useRouter","useTranslation","Button","CreateDocumentButton","DelayedSpinner","LoadMore","TreeFocusProvider","useTreeFocus","TreeNode","useChildren","baseClass","ROOT_ANCESTOR_IDS","getDocumentTitle","doc","useAsTitle","docId","id","idStr","String","value","HierarchyTreeInner","baseFilter","collectionSlug","filterByCollections","icon","initialData","initialDataProp","initialExpandedNodes","initialExpandedNodesProp","onNodeClick","selectedNodeId","useAsTitleProp","focusedId","moveFocus","setFocusedId","router","i18n","t","getEntityConfig","createDrawerSlug","collapseAllForCollection","getExpandedNodesForCollection","getTreeDataForCollection","toggleNodeForCollection","typeFieldName","collectionConfig","hierarchyConfig","hierarchy","undefined","parentFieldName","treeLimit","admin","allPossibleTypeValues","relatedCollections","Object","keys","contextData","baseFilterKey","JSON","stringify","contextBaseFilterKey","contextSeededRef","lastInitialExpandedRef","current","expandedNodes","contextExpanded","size","Set","handleToggleNode","wasSeeded","length","initialSet","map","isCurrentlyExpanded","has","nodeId","handleCollapseAll","childrenCache","Map","prevBaseFilterKeyRef","clear","docs","docsByParent","parentId","parentKey","set","get","push","filterKey","slice","sort","join","cacheKey","parentMeta","loadedParents","loadedCount","children","hasMore","page","Math","ceil","totalDocs","treeRef","rootNodes","isLoading","loadMore","loadMoreFromHook","refresh","cache","enabled","limit","handleLoadMore","handleNodeClick","rootFocusableIds","node","firstRootFocusableId","lastRootFocusableId","handleTreeKeyDown","e","key","preventDefault","_jsx","className","collectionLabel","buttonStyle","collections","drawerSlug","label","labels","singular","onSave","isAllSelected","handleAllClick","_jsxs","onKeyDown","ref","role","tabIndex","filter","Boolean","onClick","plural","margin","tooltip","nodeIdStr","nodeTitle","ancestorIds","depth","dropParentFieldName","hasChildren","title","onSelect","onToggle","selected","currentCount","onLoadMore","HierarchyTree","props"],"sources":["../../../../src/elements/Hierarchy/Tree/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { DEFAULT_HIERARCHY_TREE_LIMIT } from 'payload/shared'\nimport React, { useCallback, useId, useMemo, useRef } from 'react'\n\nimport type { CachedChildren, HierarchyTreeProps, TreeDocument } from './types.js'\n\nimport { CollapseLayersIcon } from '../../../icons/CollapseLayers/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useHierarchy } from '../../../providers/Hierarchy/index.js'\nimport { useRouter } from '../../../providers/RouterAdapter/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { CreateDocumentButton } from '../../CreateDocumentButton/index.js'\nimport { DelayedSpinner } from '../../DelayedSpinner/index.js'\nimport { LoadMore } from './LoadMore/index.js'\nimport { TreeFocusProvider, useTreeFocus } from './TreeFocusContext.js'\nimport { TreeNode } from './TreeNode/index.js'\nimport { useChildren } from './useChildren.js'\nimport './index.css'\n\nconst baseClass = 'tree'\n\n/** Root nodes have no ancestors; hoisted so the reference stays stable across renders. */\nconst ROOT_ANCESTOR_IDS: (number | string)[] = []\n\nconst getDocumentTitle = (doc: TreeDocument, useAsTitle: string | undefined): string => {\n const docId: number | string = doc.id\n const idStr = typeof docId === 'number' ? String(docId) : docId\n\n if (!useAsTitle) {\n return idStr\n }\n\n const value = doc[useAsTitle]\n if (value && (typeof value === 'string' || typeof value === 'number')) {\n return String(value)\n }\n return idStr\n}\n\nconst HierarchyTreeInner: React.FC<HierarchyTreeProps> = ({\n baseFilter,\n collectionSlug,\n filterByCollections,\n icon,\n initialData: initialDataProp,\n initialExpandedNodes: initialExpandedNodesProp,\n onNodeClick,\n selectedNodeId,\n useAsTitle: useAsTitleProp,\n}) => {\n const { focusedId, moveFocus, setFocusedId } = useTreeFocus()\n const router = useRouter()\n const { i18n, t } = useTranslation()\n const { getEntityConfig } = useConfig()\n const createDrawerSlug = `tree-create-${useId()}`\n\n const {\n collapseAllForCollection,\n getExpandedNodesForCollection,\n getTreeDataForCollection,\n toggleNodeForCollection,\n typeFieldName,\n } = useHierarchy()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const hierarchyConfig =\n collectionConfig.hierarchy && typeof collectionConfig.hierarchy === 'object'\n ? collectionConfig.hierarchy\n : undefined\n const parentFieldName = hierarchyConfig?.parentFieldName\n const treeLimit = hierarchyConfig?.admin?.treeLimit ?? DEFAULT_HIERARCHY_TREE_LIMIT\n const useAsTitle = useAsTitleProp ?? collectionConfig.admin?.useAsTitle\n\n const allPossibleTypeValues = useMemo(\n () =>\n hierarchyConfig?.relatedCollections\n ? Object.keys(hierarchyConfig.relatedCollections)\n : undefined,\n [hierarchyConfig?.relatedCollections],\n )\n\n const contextData = getTreeDataForCollection(collectionSlug)\n const baseFilterKey = baseFilter ? JSON.stringify(baseFilter) : ''\n const contextBaseFilterKey = contextData?.baseFilter ? JSON.stringify(contextData.baseFilter) : ''\n const initialData =\n baseFilterKey === contextBaseFilterKey ? (contextData ?? initialDataProp) : initialDataProp\n // Tracks whether context has been seeded at least once since the last navigation.\n // Resets when initialExpandedNodesProp changes (new array reference = navigation).\n // Allows the memo to distinguish \"not yet seeded\" (fall back to prop) from\n // \"user collapsed all nodes\" (trust empty context).\n const contextSeededRef = useRef(false)\n const lastInitialExpandedRef = useRef(initialExpandedNodesProp)\n if (lastInitialExpandedRef.current !== initialExpandedNodesProp) {\n lastInitialExpandedRef.current = initialExpandedNodesProp\n contextSeededRef.current = false\n }\n\n const expandedNodes = useMemo(() => {\n const contextExpanded = getExpandedNodesForCollection(collectionSlug)\n if (contextExpanded.size > 0) {\n contextSeededRef.current = true\n return contextExpanded\n }\n if (contextSeededRef.current) {\n // Context was seeded (had nodes since last navigation) — trust empty set as \"all collapsed\"\n return contextExpanded\n }\n return initialExpandedNodesProp ? new Set(initialExpandedNodesProp) : contextExpanded\n }, [collectionSlug, getExpandedNodesForCollection, initialExpandedNodesProp])\n\n const handleToggleNode = useCallback(\n ({ id }: { id: number | string }) => {\n // Mark context as seeded so the memo never falls back to the prop after this interaction.\n // Capture the previous value first — seeding is only needed on the very first interaction.\n const wasSeeded = contextSeededRef.current\n contextSeededRef.current = true\n const contextExpanded = getExpandedNodesForCollection(collectionSlug)\n if (!wasSeeded && contextExpanded.size === 0 && initialExpandedNodesProp?.length) {\n // Context not yet seeded. Seed it with all initial nodes, applying the toggle correctly:\n // exclude the target if collapsing, include it if expanding.\n const initialSet = new Set(initialExpandedNodesProp.map(String))\n const isCurrentlyExpanded = initialSet.has(String(id))\n for (const nodeId of initialExpandedNodesProp) {\n if (!isCurrentlyExpanded || String(nodeId) !== String(id)) {\n toggleNodeForCollection(collectionSlug, nodeId)\n }\n }\n if (!isCurrentlyExpanded) {\n toggleNodeForCollection(collectionSlug, id)\n }\n return\n }\n toggleNodeForCollection(collectionSlug, id)\n },\n [\n collectionSlug,\n getExpandedNodesForCollection,\n initialExpandedNodesProp,\n toggleNodeForCollection,\n ],\n )\n\n const handleCollapseAll = useCallback(() => {\n // Mark context as seeded so the expandedNodes memo trusts the now-empty context\n // rather than falling back to the server-provided initial nodes.\n contextSeededRef.current = true\n collapseAllForCollection(collectionSlug)\n }, [collapseAllForCollection, collectionSlug])\n\n // Pre-populate cache with initialData synchronously before first render\n const childrenCache = useRef<Map<string, CachedChildren>>(new Map())\n\n const prevBaseFilterKeyRef = useRef(baseFilterKey)\n if (prevBaseFilterKeyRef.current !== baseFilterKey) {\n prevBaseFilterKeyRef.current = baseFilterKey\n childrenCache.current.clear()\n }\n\n useMemo(() => {\n if (!initialData || initialData.docs.length === 0) {\n return\n }\n\n const docsByParent = new Map<string, TreeDocument[]>()\n for (const doc of initialData.docs) {\n const parentId = doc[parentFieldName] || 'null'\n const parentKey = String(parentId)\n if (!docsByParent.has(parentKey)) {\n docsByParent.set(parentKey, [])\n }\n docsByParent.get(parentKey).push(doc)\n }\n\n const filterKey = filterByCollections?.length\n ? filterByCollections.slice().sort().join(',')\n : ''\n for (const [parentKey, docs] of docsByParent) {\n const cacheKey = `${collectionSlug}-${parentKey}-${filterKey}-${baseFilterKey}`\n const parentMeta = initialData.loadedParents[parentKey]\n\n if (parentMeta) {\n const loadedCount = parentMeta.loadedCount ?? docs.length\n childrenCache.current.set(cacheKey, {\n children: docs,\n hasMore: parentMeta.hasMore,\n page: Math.ceil(loadedCount / treeLimit) || 1,\n totalDocs: parentMeta.totalDocs,\n })\n } else {\n childrenCache.current.set(cacheKey, {\n children: docs,\n hasMore: false,\n page: 1,\n totalDocs: docs.length,\n })\n }\n }\n }, [initialData, filterByCollections, parentFieldName, collectionSlug, treeLimit, baseFilterKey])\n\n const treeRef = useRef<HTMLDivElement>(null)\n\n const {\n children: rootNodes,\n hasMore,\n isLoading,\n loadMore: loadMoreFromHook,\n refresh,\n totalDocs,\n } = useChildren({\n allPossibleTypeValues,\n baseFilter,\n cache: childrenCache,\n collectionSlug,\n enabled: true,\n filterByCollections,\n initialData,\n limit: treeLimit,\n parentFieldName,\n parentId: 'null',\n typeFieldName,\n useAsTitle,\n })\n\n const handleLoadMore = useCallback(async () => {\n await loadMoreFromHook()\n }, [loadMoreFromHook])\n\n const handleNodeClick = useCallback(\n ({ id }: { id: number | string }) => {\n onNodeClick?.({ id })\n },\n [onNodeClick],\n )\n\n const rootFocusableIds = useMemo(\n () => (rootNodes ? rootNodes.map((node) => `node-${String(node.id)}`) : []),\n [rootNodes],\n )\n\n const firstRootFocusableId = rootFocusableIds[0]\n const lastRootFocusableId = rootFocusableIds[rootFocusableIds.length - 1]\n\n const handleTreeKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown') {\n e.preventDefault()\n\n if (\n focusedId &&\n firstRootFocusableId &&\n lastRootFocusableId &&\n focusedId === lastRootFocusableId\n ) {\n setFocusedId(firstRootFocusableId)\n return\n }\n\n moveFocus('down')\n } else if (e.key === 'ArrowUp') {\n e.preventDefault()\n\n if (\n focusedId &&\n firstRootFocusableId &&\n lastRootFocusableId &&\n focusedId === firstRootFocusableId\n ) {\n setFocusedId(lastRootFocusableId)\n return\n }\n\n moveFocus('up')\n }\n },\n [firstRootFocusableId, focusedId, lastRootFocusableId, moveFocus, setFocusedId],\n )\n\n if (isLoading && !rootNodes) {\n return (\n <div className={baseClass}>\n <DelayedSpinner baseClass={baseClass} isLoading={true} />\n </div>\n )\n }\n\n if (!rootNodes || rootNodes.length === 0) {\n const collectionLabel = getEntityConfig({ collectionSlug })\n return (\n <div className={baseClass}>\n <CreateDocumentButton\n buttonStyle=\"primary\"\n collections={[{ collectionSlug }]}\n drawerSlug={createDrawerSlug}\n label={t('general:createNewLabel', {\n label: getTranslation(collectionLabel.labels.singular, i18n),\n })}\n onSave={async () => {\n await refresh()\n router.refresh()\n }}\n />\n </div>\n )\n }\n\n const isAllSelected = selectedNodeId === null\n const handleAllClick = () => onNodeClick?.({ id: null })\n\n return (\n <div\n className={baseClass}\n onKeyDown={handleTreeKeyDown}\n ref={treeRef}\n role=\"tree\"\n tabIndex={-1}\n >\n <div className={`${baseClass}__all-option-wrapper`}>\n <div\n aria-selected={isAllSelected}\n className={[\n `${baseClass}__all-option`,\n 'sidebar-row',\n isAllSelected && `${baseClass}__all-option--selected`,\n isAllSelected && 'sidebar-row--selected',\n ]\n .filter(Boolean)\n .join(' ')}\n onClick={handleAllClick}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleAllClick()\n }\n }}\n role=\"treeitem\"\n tabIndex={0}\n >\n {Boolean(icon) && <span className=\"sidebar-row__icon\">{icon}</span>}\n <span className=\"sidebar-row__title\">\n {getTranslation(getEntityConfig({ collectionSlug })?.labels?.plural, i18n)}\n </span>\n </div>\n {expandedNodes.size > 0 && (\n <Button\n aria-label={t('fields:collapseAll')}\n buttonStyle=\"ghost\"\n className={`${baseClass}__collapse-all-button`}\n margin={false}\n onClick={handleCollapseAll}\n tooltip={t('fields:collapseAll')}\n >\n <CollapseLayersIcon />\n </Button>\n )}\n </div>\n {rootNodes.map((node) => {\n const nodeId: number | string = node.id\n const nodeIdStr = typeof nodeId === 'number' ? String(nodeId) : nodeId\n const nodeTitle = getDocumentTitle(node, useAsTitle)\n\n return (\n <TreeNode\n allPossibleTypeValues={allPossibleTypeValues}\n ancestorIds={ROOT_ANCESTOR_IDS}\n baseFilter={baseFilter}\n cache={childrenCache}\n collectionSlug={collectionSlug}\n depth={0}\n dropParentFieldName={parentFieldName}\n expandedNodes={expandedNodes}\n filterByCollections={filterByCollections}\n key={nodeIdStr}\n limit={treeLimit}\n node={{ id: nodeId, hasChildren: true, title: nodeTitle }}\n onSelect={handleNodeClick}\n onToggle={handleToggleNode}\n parentFieldName={parentFieldName}\n selected={nodeIdStr === String(selectedNodeId)}\n selectedNodeId={selectedNodeId}\n typeFieldName={typeFieldName}\n useAsTitle={useAsTitle}\n />\n )\n })}\n {hasMore && (\n <LoadMore\n currentCount={rootNodes.length}\n depth={0}\n id=\"load-more-root\"\n onLoadMore={handleLoadMore}\n totalDocs={totalDocs}\n />\n )}\n </div>\n )\n}\n\nexport const HierarchyTree: React.FC<HierarchyTreeProps> = (props) => {\n return (\n <TreeFocusProvider>\n <HierarchyTreeInner {...props} />\n </TreeFocusProvider>\n )\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,cAAc,QAAQ;AAC/B,SAASC,4BAA4B,QAAQ;AAC7C,OAAOC,KAAA,IAASC,WAAW,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAI3D,SAASC,kBAAkB,QAAQ;AACnC,SAASC,SAAS,QAAQ;AAC1B,SAASC,YAAY,QAAQ;AAC7B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,EAAEC,YAAY,QAAQ;AAChD,SAASC,QAAQ,QAAQ;AACzB,SAASC,WAAW,QAAQ;AAC5B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB;AACA,M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CwB,IAAA,CAACpH,QAAA;MACCqJ,YAAA,EAAcnD,SAAA,CAAUjC,MAAM;MAC9B6E,KAAA,EAAO;MACPnI,EAAA,EAAG;MACH2I,UAAA,EAAY5C,cAAA;MACZV,SAAA,EAAWA;;;AAKrB;AAEA,OAAO,MAAMuD,aAAA,GAA+CC,KAAA;EAC1D,oBACEpC,IAAA,CAACnH,iBAAA;cACC,aAAAmH,IAAA,CAACrG,kBAAA;MAAoB,GAAGyI;;;AAG9B","ignoreList":[]}
|
|
@@ -53,13 +53,21 @@ export type TreeInitialData = {
|
|
|
53
53
|
};
|
|
54
54
|
export type TreeNodeProps = {
|
|
55
55
|
allPossibleTypeValues?: string[];
|
|
56
|
+
/**
|
|
57
|
+
* Ids of this node's ancestors, so a folder can't be dropped into its own subtree.
|
|
58
|
+
*/
|
|
59
|
+
ancestorIds?: (number | string)[];
|
|
56
60
|
baseFilter?: null | Where;
|
|
57
61
|
cache: TreeCache;
|
|
58
62
|
collectionSlug: string;
|
|
59
63
|
depth: number;
|
|
64
|
+
/**
|
|
65
|
+
* Parent field name to set on documents dropped onto this node. Omit to make the tree inert as a
|
|
66
|
+
* drop target.
|
|
67
|
+
*/
|
|
68
|
+
dropParentFieldName?: string;
|
|
60
69
|
expandedNodes: Set<number | string>;
|
|
61
70
|
filterByCollections?: string[];
|
|
62
|
-
icon?: ReactNode;
|
|
63
71
|
limit: number;
|
|
64
72
|
node: TreeNodeData;
|
|
65
73
|
onSelect?: ({ id }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Tree/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,GAAG,EAAE,MAAM,G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A;CACpB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/elements/Hierarchy/Tree/types.ts"],"sourcesContent":["import type { TypeWithID, Where } from 'payload'\nimport type { ReactNode, RefObject } from 'react'\n\nexport type HierarchyDocument = {\n [key: string]: unknown\n} & TypeWithID\n\nexport type HierarchyInitialData = {\n baseFilter?: null | Where\n docs: HierarchyDocument[]\n // Metadata about what was loaded - keyed by parent ID ('null' for root)\n loadedParents: Record<string, { hasMore: boolean; loadedCount?: number; totalDocs: number }>\n}\n\nexport type HierarchyTreeProps = {\n baseFilter?: null | Where\n collectionSlug: string\n filterByCollections?: string[]\n icon?: ReactNode\n /** Initial data for first render (before context hydration). After hydration, context data takes precedence. */\n initialData?: HierarchyInitialData | null\n /** Initial expanded nodes for first render (before context hydration). After hydration, context takes precedence. */\n initialExpandedNodes?: (number | string)[]\n onNodeClick?: ({ id }: { id: null | number | string }) => void\n selectedNodeId?: null | number | string\n useAsTitle?: string\n}\n\n// Tree primitive types (used by TreeNode, useChildren, HierarchyTree)\n\nexport type TreeDocument = {\n [key: string]: unknown\n id: number | string\n}\n\nexport type TreeNodeData = {\n hasChildren: boolean\n id: number | string\n title: string\n}\n\nexport type CachedChildren = {\n children: TreeDocument[]\n hasMore: boolean\n page: number\n totalDocs: number\n}\n\nexport type TreeCache = RefObject<Map<string, CachedChildren>>\n\nexport type TreeInitialData = {\n docs: TreeDocument[]\n loadedParents: Record<string, { hasMore: boolean; loadedCount?: number; totalDocs: number }>\n}\n\nexport type TreeNodeProps = {\n allPossibleTypeValues?: string[]\n baseFilter?: null | Where\n cache: TreeCache\n collectionSlug: string\n depth: number\n expandedNodes: Set<number | string>\n filterByCollections?: string[]\n
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/elements/Hierarchy/Tree/types.ts"],"sourcesContent":["import type { TypeWithID, Where } from 'payload'\nimport type { ReactNode, RefObject } from 'react'\n\nexport type HierarchyDocument = {\n [key: string]: unknown\n} & TypeWithID\n\nexport type HierarchyInitialData = {\n baseFilter?: null | Where\n docs: HierarchyDocument[]\n // Metadata about what was loaded - keyed by parent ID ('null' for root)\n loadedParents: Record<string, { hasMore: boolean; loadedCount?: number; totalDocs: number }>\n}\n\nexport type HierarchyTreeProps = {\n baseFilter?: null | Where\n collectionSlug: string\n filterByCollections?: string[]\n icon?: ReactNode\n /** Initial data for first render (before context hydration). After hydration, context data takes precedence. */\n initialData?: HierarchyInitialData | null\n /** Initial expanded nodes for first render (before context hydration). After hydration, context takes precedence. */\n initialExpandedNodes?: (number | string)[]\n onNodeClick?: ({ id }: { id: null | number | string }) => void\n selectedNodeId?: null | number | string\n useAsTitle?: string\n}\n\n// Tree primitive types (used by TreeNode, useChildren, HierarchyTree)\n\nexport type TreeDocument = {\n [key: string]: unknown\n id: number | string\n}\n\nexport type TreeNodeData = {\n hasChildren: boolean\n id: number | string\n title: string\n}\n\nexport type CachedChildren = {\n children: TreeDocument[]\n hasMore: boolean\n page: number\n totalDocs: number\n}\n\nexport type TreeCache = RefObject<Map<string, CachedChildren>>\n\nexport type TreeInitialData = {\n docs: TreeDocument[]\n loadedParents: Record<string, { hasMore: boolean; loadedCount?: number; totalDocs: number }>\n}\n\nexport type TreeNodeProps = {\n allPossibleTypeValues?: string[]\n /**\n * Ids of this node's ancestors, so a folder can't be dropped into its own subtree.\n */\n ancestorIds?: (number | string)[]\n baseFilter?: null | Where\n cache: TreeCache\n collectionSlug: string\n depth: number\n /**\n * Parent field name to set on documents dropped onto this node. Omit to make the tree inert as a\n * drop target.\n */\n dropParentFieldName?: string\n expandedNodes: Set<number | string>\n filterByCollections?: string[]\n limit: number\n node: TreeNodeData\n onSelect?: ({ id }: { id: number | string }) => void\n onToggle: ({ id }: { id: number | string }) => void\n parentFieldName: string\n selected?: boolean\n selectedNodeId?: number | string\n typeFieldName?: null | string\n useAsTitle?: string\n}\n"],"mappings":"AAuDA","ignoreList":[]}
|
|
@@ -1 +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,kMAcrB,eAAe,KAAG,iBAmQpB,CAAA"}
|
|
@@ -125,7 +125,17 @@ export const useChildren = ({
|
|
|
125
125
|
// Client-side filter: only show items that are a superset of required collections
|
|
126
126
|
// Server query uses ANY (due to PG limitations), but we want ALL (superset)
|
|
127
127
|
const newDocs = filterByCollections?.length && typeFieldName ? allDocs.filter(doc => isSuperset(doc[typeFieldName], filterByCollections)) : allDocs;
|
|
128
|
-
|
|
128
|
+
let newChildren;
|
|
129
|
+
if (pageToFetch === 1) {
|
|
130
|
+
newChildren = newDocs;
|
|
131
|
+
} else {
|
|
132
|
+
// Dedupe against already-loaded children: page-number math can drift from the
|
|
133
|
+
// actual loaded count (e.g. after a cache merge), causing an overlapping page
|
|
134
|
+
// to be re-fetched here.
|
|
135
|
+
const existingIds = new Set((currentChildren || []).map(doc => doc.id));
|
|
136
|
+
const dedupedNewDocs = newDocs.filter(doc => !existingIds.has(doc.id));
|
|
137
|
+
newChildren = [...(currentChildren || []), ...dedupedNewDocs];
|
|
138
|
+
}
|
|
129
139
|
setChildren(newChildren);
|
|
130
140
|
setTotalDocs(data.totalDocs || 0);
|
|
131
141
|
setHasMore(data.hasNextPage || false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChildren.js","names":["combineWhereConstraints","formatAdminURL","qs","useCallback","useEffect","useRef","useState","useConfig","isSuperset","useChildren","allPossibleTypeValues","baseFilter","cache","cacheKey","cacheKeyProp","collectionSlug","enabled","filterByCollections","initialData","limit","parentFieldName","parentId","typeFieldName","useAsTitle","filterKey","length","slice","sort","join","baseFilterKey","JSON","stringify","String","cachedData","current","get","parentKey","parentMeta","loadedParents","hasInitialData","initialDocsForParent","docs","filter","doc","docParent","children","setChildren","isLoading","setIsLoading","page","setPage","totalDocs","setTotalDocs","hasMore","setHasMore","initializedRef","childrenRef","isLoadingRef","config","routes","api","serverURL","fetchPage","pageToFetch","currentChildren","parentCondition","or","exists","equals","filterCondition","in","not_in","undefined","where","queryParams","queryString","addQueryPrefix","url","apiRoute","path","response","fetch","credentials","ok","Error","data","json","allDocs","newDocs","newChildren","hasNextPage","set","emptyChildren","prevFilterKeyRef","load","currentCachedData","loadMore","shouldRefetchPage1","refresh","delete","effectiveChildren"],"sources":["../../../../src/elements/Hierarchy/Tree/useChildren.tsx"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { combineWhereConstraints, formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type { TreeCache, TreeDocument, TreeInitialData } from './types.js'\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { isSuperset } from '../../../utilities/isSuperset.js'\n\ntype UseChildrenArgs = {\n allPossibleTypeValues?: string[]\n /** Base filter to apply to all queries (e.g., tenant filter) */\n baseFilter?: null | Where\n cache?: TreeCache\n /** Pre-computed cache key to ensure consistency with cache population */\n cacheKey?: string\n collectionSlug: string\n enabled?: boolean\n filterByCollections?: string[]\n initialData?: null | TreeInitialData\n limit?: number\n parentFieldName: string\n parentId: number | string\n typeFieldName?: null | string\n useAsTitle?: string\n}\n\ntype UseChildrenReturn = {\n children: null | TreeDocument[]\n hasMore: boolean\n isLoading: boolean\n /** Explicitly load children. Safe to call multiple times — no-ops if already loaded. */\n load: () => Promise<TreeDocument[]>\n loadMore: () => Promise<TreeDocument[]>\n refresh: () => Promise<TreeDocument[]>\n totalDocs: number\n}\n\nexport const useChildren = ({\n allPossibleTypeValues,\n baseFilter,\n cache,\n cacheKey: cacheKeyProp,\n collectionSlug,\n enabled = true,\n filterByCollections,\n initialData,\n limit = 2,\n parentFieldName,\n parentId,\n typeFieldName,\n useAsTitle,\n}: UseChildrenArgs): UseChildrenReturn => {\n const filterKey = filterByCollections?.length ? filterByCollections.slice().sort().join(',') : ''\n const baseFilterKey = baseFilter ? JSON.stringify(baseFilter) : ''\n // Use provided cacheKey for consistency with cache population, or compute if not provided\n const cacheKey =\n cacheKeyProp ?? `${collectionSlug}-${String(parentId)}-${filterKey}-${baseFilterKey}`\n const cachedData = cache?.current.get(cacheKey)\n\n // Check if we have initial data for this specific parent\n const parentKey = parentId === 'null' ? 'null' : String(parentId)\n const parentMeta = initialData?.loadedParents?.[parentKey]\n const hasInitialData = !!parentMeta\n\n // Extract docs for this parent from initialData if available\n // Apply same superset filter as fetchPage for consistency\n const initialDocsForParent = hasInitialData\n ? initialData.docs.filter((doc) => {\n const docParent = doc[parentFieldName] || 'null'\n if (String(docParent) !== parentKey) {\n return false\n }\n if (filterByCollections?.length && typeFieldName) {\n return isSuperset(doc[typeFieldName] as string[] | undefined, filterByCollections)\n }\n return true\n })\n : null\n\n const [children, setChildren] = useState<null | TreeDocument[]>(\n initialDocsForParent || cachedData?.children || null,\n )\n const [isLoading, setIsLoading] = useState(false)\n const [page, setPage] = useState(cachedData?.page || 1)\n const [totalDocs, setTotalDocs] = useState(parentMeta?.totalDocs || cachedData?.totalDocs || 0)\n const [hasMore, setHasMore] = useState(parentMeta?.hasMore || cachedData?.hasMore || false)\n const initializedRef = useRef(!!hasInitialData)\n // Refs for stable access inside load() without adding state to its dep array\n const childrenRef = useRef(children)\n childrenRef.current = children\n const isLoadingRef = useRef(isLoading)\n isLoadingRef.current = isLoading\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const fetchPage = useCallback(\n async (\n pageToFetch: number,\n currentChildren: null | TreeDocument[],\n ): Promise<TreeDocument[]> => {\n setIsLoading(true)\n\n try {\n const parentCondition =\n parentId === 'null' || parentId === null\n ? {\n or: [\n { [parentFieldName]: { exists: false } },\n { [parentFieldName]: { equals: null } },\n ],\n }\n : { [parentFieldName]: { equals: parentId } }\n\n // Build filter condition for collection type filtering\n // Matches items that:\n // - allow ANY of the selected collections, OR\n // - are unrestricted (type field doesn't exist), OR\n // - have empty allowedTypes array (unrestricted)\n const filterCondition: undefined | Where =\n filterByCollections?.length && typeFieldName\n ? {\n or: [\n { [typeFieldName]: { in: filterByCollections } },\n { [typeFieldName]: { exists: false } },\n // Using not_in with all possible values matches empty arrays in both MongoDB and Postgres\n ...(allPossibleTypeValues?.length\n ? [{ [typeFieldName]: { not_in: allPossibleTypeValues } }]\n : []),\n ],\n }\n : undefined\n\n // Combine conditions: parent + filter + baseFilter\n const where = combineWhereConstraints([parentCondition, filterCondition, baseFilter])\n\n const queryParams: Record<string, unknown> = {\n limit,\n page: pageToFetch,\n sort: useAsTitle ?? 'id',\n where,\n }\n\n const queryString = qs.stringify(queryParams, { addQueryPrefix: true })\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n serverURL,\n })\n const response = await fetch(url, {\n credentials: 'include',\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch children')\n }\n\n const data = await response.json()\n const allDocs: TreeDocument[] = data.docs || []\n\n // Client-side filter: only show items that are a superset of required collections\n // Server query uses ANY (due to PG limitations), but we want ALL (superset)\n const newDocs =\n filterByCollections?.length && typeFieldName\n ? allDocs.filter((doc) =>\n isSuperset(doc[typeFieldName] as string[] | undefined, filterByCollections),\n )\n : allDocs\n\n const newChildren = pageToFetch === 1 ? newDocs : [...(currentChildren || []), ...newDocs]\n\n setChildren(newChildren)\n setTotalDocs(data.totalDocs || 0)\n setHasMore(data.hasNextPage || false)\n setPage(pageToFetch)\n\n if (cache) {\n cache.current.set(cacheKey, {\n children: newChildren,\n hasMore: data.hasNextPage || false,\n page: pageToFetch,\n totalDocs: data.totalDocs || 0,\n })\n }\n\n return newDocs\n } catch {\n if (pageToFetch === 1) {\n const emptyChildren: TreeDocument[] = []\n setChildren(emptyChildren)\n setHasMore(false)\n\n if (cache) {\n cache.current.set(cacheKey, {\n children: emptyChildren,\n hasMore: false,\n page: 1,\n totalDocs: 0,\n })\n }\n }\n\n return []\n } finally {\n setIsLoading(false)\n }\n },\n [\n allPossibleTypeValues,\n baseFilter,\n parentId,\n parentFieldName,\n filterByCollections,\n typeFieldName,\n limit,\n useAsTitle,\n api,\n collectionSlug,\n serverURL,\n cache,\n cacheKey,\n ],\n )\n\n // Reset state and reload when filter changes\n const prevFilterKeyRef = useRef(filterKey)\n useEffect(() => {\n if (prevFilterKeyRef.current !== filterKey) {\n prevFilterKeyRef.current = filterKey\n setChildren(null)\n setPage(1)\n setTotalDocs(0)\n setHasMore(false)\n // If the node is currently expanded, immediately reload with the new filter\n if (enabled) {\n void fetchPage(1, null)\n }\n }\n }, [filterKey, enabled, fetchPage])\n\n // Load children explicitly. Safe to call multiple times — no-ops if already loaded or loading.\n const load = useCallback(async (): Promise<TreeDocument[]> => {\n // Consume initialData on first call without re-fetching\n if (initializedRef.current && childrenRef.current !== null) {\n initializedRef.current = false\n return childrenRef.current\n }\n\n // Already loaded\n if (childrenRef.current !== null) {\n return childrenRef.current\n }\n\n // Guard against concurrent calls\n if (isLoadingRef.current) {\n return []\n }\n\n // Restore from cache when available (e.g., after a filter reset)\n const currentCachedData = cache?.current.get(cacheKey)\n if (currentCachedData) {\n setChildren(currentCachedData.children)\n setPage(currentCachedData.page)\n setTotalDocs(currentCachedData.totalDocs)\n setHasMore(currentCachedData.hasMore)\n return currentCachedData.children\n }\n\n return fetchPage(1, null)\n }, [cache, cacheKey, fetchPage])\n\n const loadMore = useCallback(async (): Promise<TreeDocument[]> => {\n if (isLoading || !hasMore) {\n return []\n }\n\n // If we have fewer items than our limit, the cached data was fetched with a smaller limit\n // We need to re-fetch page 1 with our limit to get the full first page\n const shouldRefetchPage1 = children && children.length < limit\n\n return fetchPage(shouldRefetchPage1 ? 1 : page + 1, children)\n }, [isLoading, hasMore, page, children, fetchPage, limit])\n\n const refresh = useCallback(async (): Promise<TreeDocument[]> => {\n if (cache) {\n cache.current.delete(cacheKey)\n }\n setChildren(null)\n setPage(1)\n return fetchPage(1, null)\n }, [cache, cacheKey, fetchPage])\n // If state hasn't been loaded yet, read directly from cache as a synchronous fallback.\n // Tree's useMemo pre-populates the cache before child TreeNodes render, so this eliminates\n // the brief null-children flash that occurs when a node becomes expanded after context updates.\n const effectiveChildren = children ?? cache?.current.get(cacheKey)?.children ?? null\n\n return { children: effectiveChildren, hasMore, isLoading, load, loadMore, refresh, totalDocs }\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,EAAEC,cAAc,QAAQ;AACxD,YAAYC,EAAA,MAAQ;AACpB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAIzD,SAASC,SAAS,QAAQ;AAC1B,SAASC,UAAU,QAAQ;AA+B3B,OAAO,MAAMC,WAAA,GAAcA,CAAC;EAC1BC,qBAAqB;EACrBC,UAAU;EACVC,KAAK;EACLC,QAAA,EAAUC,YAAY;EACtBC,cAAc;EACdC,OAAA,GAAU,IAAI;EACdC,mBAAmB;EACnBC,WAAW;EACXC,KAAA,GAAQ,CAAC;EACTC,eAAe;EACfC,QAAQ;EACRC,aAAa;EACbC;AAAU,CACM;EAChB,MAAMC,SAAA,GAAYP,mBAAA,EAAqBQ,MAAA,GAASR,mBAAA,CAAoBS,KAAK,GAAGC,IAAI,GAAGC,IAAI,CAAC,OAAO;EAC/F,MAAMC,aAAA,GAAgBlB,UAAA,GAAamB,IAAA,CAAKC,SAAS,CAACpB,UAAA,IAAc;EAChE;EACA,MAAME,QAAA,GACJC,YAAA,IAAgB,GAAGC,cAAA,IAAkBiB,MAAA,CAAOX,QAAA,KAAaG,SAAA,IAAaK,aAAA,EAAe;EACvF,MAAMI,UAAA,GAAarB,KAAA,EAAOsB,OAAA,CAAQC,GAAA,CAAItB,QAAA;EAEtC;EACA,MAAMuB,SAAA,GAAYf,QAAA,KAAa,SAAS,SAASW,MAAA,CAAOX,QAAA;EACxD,MAAMgB,UAAA,GAAanB,WAAA,EAAaoB,aAAA,GAAgBF,SAAA,CAAU;EAC1D,MAAMG,cAAA,GAAiB,CAAC,CAACF,UAAA;EAEzB;EACA;EACA,MAAMG,oBAAA,GAAuBD,cAAA,GACzBrB,WAAA,CAAYuB,IAAI,CAACC,MAAM,CAAEC,GAAA;IACvB,MAAMC,SAAA,GAAYD,GAA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,CAAkB1C,OAAO;MACpC,OAAO0C,iBAAA,CAAkBlD,QAAQ;IACnC;IAEA,OAAOiB,SAAA,CAAU,GAAG;EACtB,GAAG,CAAClD,KAAA,EAAOC,QAAA,EAAUiD,SAAA,CAAU;EAE/B,MAAMkC,QAAA,GAAW7F,WAAA,CAAY;IAC3B,IAAI4C,SAAA,IAAa,CAACM,OAAA,EAAS;MACzB,OAAO,EAAE;IACX;IAEA;IACA;IACA,MAAM4C,kBAAA,GAAqBpD,QAAA,IAAYA,QAAA,CAASpB,MAAM,GAAGN,KAAA;IAEzD,OAAO2C,SAAA,CAAUmC,kBAAA,GAAqB,IAAIhD,IAAA,GAAO,GAAGJ,QAAA;EACtD,GAAG,CAACE,SAAA,EAAWM,OAAA,EAASJ,IAAA,EAAMJ,QAAA,EAAUiB,SAAA,EAAW3C,KAAA,CAAM;EAEzD,MAAM+E,OAAA,GAAU/F,WAAA,CAAY;IAC1B,IAAIS,KAAA,EAAO;MACTA,KAAA,CAAMsB,OAAO,CAACiE,MAAM,CAACtF,QAAA;IACvB;IACAiC,WAAA,CAAY;IACZI,OAAA,CAAQ;IACR,OAAOY,SAAA,CAAU,GAAG;EACtB,GAAG,CAAClD,KAAA,EAAOC,QAAA,EAAUiD,SAAA,CAAU;EAC/B;EACA;EACA;EACA,MAAMsC,iBAAA,GAAoBvD,QAAA,IAAYjC,KAAA,EAAOsB,OAAA,CAAQC,GAAA,CAAItB,QAAA,GAAWgC,QAAA,IAAY;EAEhF,OAAO;IAAEA,QAAA,EAAUuD,iBAAA;IAAmB/C,OAAA;IAASN,SAAA;IAAW+C,IAAA;IAAME,QAAA;IAAUE,OAAA;IAAS/C;EAAU;AAC/F","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useChildren.js","names":["combineWhereConstraints","formatAdminURL","qs","useCallback","useEffect","useRef","useState","useConfig","isSuperset","useChildren","allPossibleTypeValues","baseFilter","cache","cacheKey","cacheKeyProp","collectionSlug","enabled","filterByCollections","initialData","limit","parentFieldName","parentId","typeFieldName","useAsTitle","filterKey","length","slice","sort","join","baseFilterKey","JSON","stringify","String","cachedData","current","get","parentKey","parentMeta","loadedParents","hasInitialData","initialDocsForParent","docs","filter","doc","docParent","children","setChildren","isLoading","setIsLoading","page","setPage","totalDocs","setTotalDocs","hasMore","setHasMore","initializedRef","childrenRef","isLoadingRef","config","routes","api","serverURL","fetchPage","pageToFetch","currentChildren","parentCondition","or","exists","equals","filterCondition","in","not_in","undefined","where","queryParams","queryString","addQueryPrefix","url","apiRoute","path","response","fetch","credentials","ok","Error","data","json","allDocs","newDocs","newChildren","existingIds","Set","map","id","dedupedNewDocs","has","hasNextPage","set","emptyChildren","prevFilterKeyRef","load","currentCachedData","loadMore","shouldRefetchPage1","refresh","delete","effectiveChildren"],"sources":["../../../../src/elements/Hierarchy/Tree/useChildren.tsx"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { combineWhereConstraints, formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type { TreeCache, TreeDocument, TreeInitialData } from './types.js'\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { isSuperset } from '../../../utilities/isSuperset.js'\n\ntype UseChildrenArgs = {\n allPossibleTypeValues?: string[]\n /** Base filter to apply to all queries (e.g., tenant filter) */\n baseFilter?: null | Where\n cache?: TreeCache\n /** Pre-computed cache key to ensure consistency with cache population */\n cacheKey?: string\n collectionSlug: string\n enabled?: boolean\n filterByCollections?: string[]\n initialData?: null | TreeInitialData\n limit?: number\n parentFieldName: string\n parentId: number | string\n typeFieldName?: null | string\n useAsTitle?: string\n}\n\ntype UseChildrenReturn = {\n children: null | TreeDocument[]\n hasMore: boolean\n isLoading: boolean\n /** Explicitly load children. Safe to call multiple times — no-ops if already loaded. */\n load: () => Promise<TreeDocument[]>\n loadMore: () => Promise<TreeDocument[]>\n refresh: () => Promise<TreeDocument[]>\n totalDocs: number\n}\n\nexport const useChildren = ({\n allPossibleTypeValues,\n baseFilter,\n cache,\n cacheKey: cacheKeyProp,\n collectionSlug,\n enabled = true,\n filterByCollections,\n initialData,\n limit = 2,\n parentFieldName,\n parentId,\n typeFieldName,\n useAsTitle,\n}: UseChildrenArgs): UseChildrenReturn => {\n const filterKey = filterByCollections?.length ? filterByCollections.slice().sort().join(',') : ''\n const baseFilterKey = baseFilter ? JSON.stringify(baseFilter) : ''\n // Use provided cacheKey for consistency with cache population, or compute if not provided\n const cacheKey =\n cacheKeyProp ?? `${collectionSlug}-${String(parentId)}-${filterKey}-${baseFilterKey}`\n const cachedData = cache?.current.get(cacheKey)\n\n // Check if we have initial data for this specific parent\n const parentKey = parentId === 'null' ? 'null' : String(parentId)\n const parentMeta = initialData?.loadedParents?.[parentKey]\n const hasInitialData = !!parentMeta\n\n // Extract docs for this parent from initialData if available\n // Apply same superset filter as fetchPage for consistency\n const initialDocsForParent = hasInitialData\n ? initialData.docs.filter((doc) => {\n const docParent = doc[parentFieldName] || 'null'\n if (String(docParent) !== parentKey) {\n return false\n }\n if (filterByCollections?.length && typeFieldName) {\n return isSuperset(doc[typeFieldName] as string[] | undefined, filterByCollections)\n }\n return true\n })\n : null\n\n const [children, setChildren] = useState<null | TreeDocument[]>(\n initialDocsForParent || cachedData?.children || null,\n )\n const [isLoading, setIsLoading] = useState(false)\n const [page, setPage] = useState(cachedData?.page || 1)\n const [totalDocs, setTotalDocs] = useState(parentMeta?.totalDocs || cachedData?.totalDocs || 0)\n const [hasMore, setHasMore] = useState(parentMeta?.hasMore || cachedData?.hasMore || false)\n const initializedRef = useRef(!!hasInitialData)\n // Refs for stable access inside load() without adding state to its dep array\n const childrenRef = useRef(children)\n childrenRef.current = children\n const isLoadingRef = useRef(isLoading)\n isLoadingRef.current = isLoading\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const fetchPage = useCallback(\n async (\n pageToFetch: number,\n currentChildren: null | TreeDocument[],\n ): Promise<TreeDocument[]> => {\n setIsLoading(true)\n\n try {\n const parentCondition =\n parentId === 'null' || parentId === null\n ? {\n or: [\n { [parentFieldName]: { exists: false } },\n { [parentFieldName]: { equals: null } },\n ],\n }\n : { [parentFieldName]: { equals: parentId } }\n\n // Build filter condition for collection type filtering\n // Matches items that:\n // - allow ANY of the selected collections, OR\n // - are unrestricted (type field doesn't exist), OR\n // - have empty allowedTypes array (unrestricted)\n const filterCondition: undefined | Where =\n filterByCollections?.length && typeFieldName\n ? {\n or: [\n { [typeFieldName]: { in: filterByCollections } },\n { [typeFieldName]: { exists: false } },\n // Using not_in with all possible values matches empty arrays in both MongoDB and Postgres\n ...(allPossibleTypeValues?.length\n ? [{ [typeFieldName]: { not_in: allPossibleTypeValues } }]\n : []),\n ],\n }\n : undefined\n\n // Combine conditions: parent + filter + baseFilter\n const where = combineWhereConstraints([parentCondition, filterCondition, baseFilter])\n\n const queryParams: Record<string, unknown> = {\n limit,\n page: pageToFetch,\n sort: useAsTitle ?? 'id',\n where,\n }\n\n const queryString = qs.stringify(queryParams, { addQueryPrefix: true })\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n serverURL,\n })\n const response = await fetch(url, {\n credentials: 'include',\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch children')\n }\n\n const data = await response.json()\n const allDocs: TreeDocument[] = data.docs || []\n\n // Client-side filter: only show items that are a superset of required collections\n // Server query uses ANY (due to PG limitations), but we want ALL (superset)\n const newDocs =\n filterByCollections?.length && typeFieldName\n ? allDocs.filter((doc) =>\n isSuperset(doc[typeFieldName] as string[] | undefined, filterByCollections),\n )\n : allDocs\n\n let newChildren: TreeDocument[]\n if (pageToFetch === 1) {\n newChildren = newDocs\n } else {\n // Dedupe against already-loaded children: page-number math can drift from the\n // actual loaded count (e.g. after a cache merge), causing an overlapping page\n // to be re-fetched here.\n const existingIds = new Set((currentChildren || []).map((doc) => doc.id))\n const dedupedNewDocs = newDocs.filter((doc) => !existingIds.has(doc.id))\n newChildren = [...(currentChildren || []), ...dedupedNewDocs]\n }\n\n setChildren(newChildren)\n setTotalDocs(data.totalDocs || 0)\n setHasMore(data.hasNextPage || false)\n setPage(pageToFetch)\n\n if (cache) {\n cache.current.set(cacheKey, {\n children: newChildren,\n hasMore: data.hasNextPage || false,\n page: pageToFetch,\n totalDocs: data.totalDocs || 0,\n })\n }\n\n return newDocs\n } catch {\n if (pageToFetch === 1) {\n const emptyChildren: TreeDocument[] = []\n setChildren(emptyChildren)\n setHasMore(false)\n\n if (cache) {\n cache.current.set(cacheKey, {\n children: emptyChildren,\n hasMore: false,\n page: 1,\n totalDocs: 0,\n })\n }\n }\n\n return []\n } finally {\n setIsLoading(false)\n }\n },\n [\n allPossibleTypeValues,\n baseFilter,\n parentId,\n parentFieldName,\n filterByCollections,\n typeFieldName,\n limit,\n useAsTitle,\n api,\n collectionSlug,\n serverURL,\n cache,\n cacheKey,\n ],\n )\n\n // Reset state and reload when filter changes\n const prevFilterKeyRef = useRef(filterKey)\n useEffect(() => {\n if (prevFilterKeyRef.current !== filterKey) {\n prevFilterKeyRef.current = filterKey\n setChildren(null)\n setPage(1)\n setTotalDocs(0)\n setHasMore(false)\n // If the node is currently expanded, immediately reload with the new filter\n if (enabled) {\n void fetchPage(1, null)\n }\n }\n }, [filterKey, enabled, fetchPage])\n\n // Load children explicitly. Safe to call multiple times — no-ops if already loaded or loading.\n const load = useCallback(async (): Promise<TreeDocument[]> => {\n // Consume initialData on first call without re-fetching\n if (initializedRef.current && childrenRef.current !== null) {\n initializedRef.current = false\n return childrenRef.current\n }\n\n // Already loaded\n if (childrenRef.current !== null) {\n return childrenRef.current\n }\n\n // Guard against concurrent calls\n if (isLoadingRef.current) {\n return []\n }\n\n // Restore from cache when available (e.g., after a filter reset)\n const currentCachedData = cache?.current.get(cacheKey)\n if (currentCachedData) {\n setChildren(currentCachedData.children)\n setPage(currentCachedData.page)\n setTotalDocs(currentCachedData.totalDocs)\n setHasMore(currentCachedData.hasMore)\n return currentCachedData.children\n }\n\n return fetchPage(1, null)\n }, [cache, cacheKey, fetchPage])\n\n const loadMore = useCallback(async (): Promise<TreeDocument[]> => {\n if (isLoading || !hasMore) {\n return []\n }\n\n // If we have fewer items than our limit, the cached data was fetched with a smaller limit\n // We need to re-fetch page 1 with our limit to get the full first page\n const shouldRefetchPage1 = children && children.length < limit\n\n return fetchPage(shouldRefetchPage1 ? 1 : page + 1, children)\n }, [isLoading, hasMore, page, children, fetchPage, limit])\n\n const refresh = useCallback(async (): Promise<TreeDocument[]> => {\n if (cache) {\n cache.current.delete(cacheKey)\n }\n setChildren(null)\n setPage(1)\n return fetchPage(1, null)\n }, [cache, cacheKey, fetchPage])\n // If state hasn't been loaded yet, read directly from cache as a synchronous fallback.\n // Tree's useMemo pre-populates the cache before child TreeNodes render, so this eliminates\n // the brief null-children flash that occurs when a node becomes expanded after context updates.\n const effectiveChildren = children ?? cache?.current.get(cacheKey)?.children ?? null\n\n return { children: effectiveChildren, hasMore, isLoading, load, loadMore, refresh, totalDocs }\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,EAAEC,cAAc,QAAQ;AACxD,YAAYC,EAAA,MAAQ;AACpB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAIzD,SAASC,SAAS,QAAQ;AAC1B,SAASC,UAAU,QAAQ;AA+B3B,OAAO,MAAMC,WAAA,GAAcA,CAAC;EAC1BC,qBAAqB;EACrBC,UAAU;EACVC,KAAK;EACLC,QAAA,EAAUC,YAAY;EACtBC,cAAc;EACdC,OAAA,GAAU,IAAI;EACdC,mBAAmB;EACnBC,WAAW;EACXC,KAAA,GAAQ,CAAC;EACTC,eAAe;EACfC,QAAQ;EACRC,aAAa;EACbC;AAAU,CACM;EAChB,MAAMC,SAAA,GAAYP,mBAAA,EAAqBQ,MAAA,GAASR,mBAAA,CAAoBS,KAAK,GAAGC,IAAI,GAAGC,IAAI,CAAC,OAAO;EAC/F,MAAMC,aAAA,GAAgBlB,UAAA,GAAamB,IAAA,C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SAAA,CAAUyC,kBAAA,GAAqB,IAAItD,IAAA,GAAO,GAAGJ,QAAA;EACtD,GAAG,CAACE,SAAA,EAAWM,OAAA,EAASJ,IAAA,EAAMJ,QAAA,EAAUiB,SAAA,EAAW3C,KAAA,CAAM;EAEzD,MAAMqF,OAAA,GAAUrG,WAAA,CAAY;IAC1B,IAAIS,KAAA,EAAO;MACTA,KAAA,CAAMsB,OAAO,CAACuE,MAAM,CAAC5F,QAAA;IACvB;IACAiC,WAAA,CAAY;IACZI,OAAA,CAAQ;IACR,OAAOY,SAAA,CAAU,GAAG;EACtB,GAAG,CAAClD,KAAA,EAAOC,QAAA,EAAUiD,SAAA,CAAU;EAC/B;EACA;EACA;EACA,MAAM4C,iBAAA,GAAoB7D,QAAA,IAAYjC,KAAA,EAAOsB,OAAA,CAAQC,GAAA,CAAItB,QAAA,GAAWgC,QAAA,IAAY;EAEhF,OAAO;IAAEA,QAAA,EAAU6D,iBAAA;IAAmBrD,OAAA;IAASN,SAAA;IAAWqD,IAAA;IAAME,QAAA;IAAUE,OAAA;IAASrD;EAAU;AAC/F","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape both `ClientCollectionConfig` and `SanitizedCollectionConfig` satisfy for the purposes
|
|
3
|
+
* of this lookup, so routing (which holds the sanitized config) and client components can share
|
|
4
|
+
* one implementation.
|
|
5
|
+
*/
|
|
6
|
+
type FolderHierarchyCandidate = {
|
|
7
|
+
hierarchy?: {
|
|
8
|
+
relatedCollections?: Record<string, {
|
|
9
|
+
hasMany: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
} | boolean;
|
|
12
|
+
slug: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Finds the slug of the folder-style hierarchy collection (allowHasMany: false) that
|
|
16
|
+
* `collectionSlug` belongs to, by scanning each collection's `hierarchy.relatedCollections`.
|
|
17
|
+
* Returns undefined if the collection has no folder field (e.g. it only has a tags field,
|
|
18
|
+
* or no hierarchy field at all).
|
|
19
|
+
*/
|
|
20
|
+
export declare const getFolderHierarchySlug: (collections: FolderHierarchyCandidate[], collectionSlug: string) => string | undefined;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=getFolderHierarchySlug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFolderHierarchySlug.d.ts","sourceRoot":"","sources":["../../../src/elements/Hierarchy/getFolderHierarchySlug.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,KAAK,wBAAwB,GAAG;IAC9B,SAAS,CAAC,EACN;QACE,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,OAAO,EAAE,OAAO,CAAA;SAAE,CAAC,CAAA;KAC1D,GACD,OAAO,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,gBACpB,wBAAwB,EAAE,kBACvB,MAAM,KACrB,MAAM,GAAG,SASF,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape both `ClientCollectionConfig` and `SanitizedCollectionConfig` satisfy for the purposes
|
|
3
|
+
* of this lookup, so routing (which holds the sanitized config) and client components can share
|
|
4
|
+
* one implementation.
|
|
5
|
+
*/ /**
|
|
6
|
+
* Finds the slug of the folder-style hierarchy collection (allowHasMany: false) that
|
|
7
|
+
* `collectionSlug` belongs to, by scanning each collection's `hierarchy.relatedCollections`.
|
|
8
|
+
* Returns undefined if the collection has no folder field (e.g. it only has a tags field,
|
|
9
|
+
* or no hierarchy field at all).
|
|
10
|
+
*/export const getFolderHierarchySlug = (collections, collectionSlug) => collections.find(collection => {
|
|
11
|
+
if (!collection.hierarchy || typeof collection.hierarchy !== 'object') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const related = collection.hierarchy.relatedCollections?.[collectionSlug];
|
|
15
|
+
return related !== undefined && related.hasMany === false;
|
|
16
|
+
})?.slug;
|
|
17
|
+
//# sourceMappingURL=getFolderHierarchySlug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFolderHierarchySlug.js","names":["getFolderHierarchySlug","collections","collectionSlug","find","collection","hierarchy","related","relatedCollections","undefined","hasMany","slug"],"sources":["../../../src/elements/Hierarchy/getFolderHierarchySlug.ts"],"sourcesContent":["/**\n * The shape both `ClientCollectionConfig` and `SanitizedCollectionConfig` satisfy for the purposes\n * of this lookup, so routing (which holds the sanitized config) and client components can share\n * one implementation.\n */\ntype FolderHierarchyCandidate = {\n hierarchy?:\n | {\n relatedCollections?: Record<string, { hasMany: boolean }>\n }\n | boolean\n slug: string\n}\n\n/**\n * Finds the slug of the folder-style hierarchy collection (allowHasMany: false) that\n * `collectionSlug` belongs to, by scanning each collection's `hierarchy.relatedCollections`.\n * Returns undefined if the collection has no folder field (e.g. it only has a tags field,\n * or no hierarchy field at all).\n */\nexport const getFolderHierarchySlug = (\n collections: FolderHierarchyCandidate[],\n collectionSlug: string,\n): string | undefined =>\n collections.find((collection) => {\n if (!collection.hierarchy || typeof collection.hierarchy !== 'object') {\n return false\n }\n\n const related = collection.hierarchy.relatedCollections?.[collectionSlug]\n\n return related !== undefined && related.hasMany === false\n })?.slug\n"],"mappings":"AAAA;;;;GAAA,CAcA;;;;;MAMA,OAAO,MAAMA,sBAAA,GAAyBA,CACpCC,WAAA,EACAC,cAAA,KAEAD,WAAA,CAAYE,IAAI,CAAEC,UAAA;EAChB,IAAI,CAACA,UAAA,CAAWC,SAAS,IAAI,OAAOD,UAAA,CAAWC,SAAS,KAAK,UAAU;IACrE,OAAO;EACT;EAEA,MAAMC,OAAA,GAAUF,UAAA,CAAWC,SAAS,CAACE,kBAAkB,GAAGL,cAAA,CAAe;EAEzE,OAAOI,OAAA,KAAYE,SAAA,IAAaF,OAAA,CAAQG,OAAO,KAAK;AACtD,IAAIC,IAAA","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
type MoveDocumentsArgs = {
|
|
3
|
+
apiRoute: string;
|
|
4
|
+
/** Destination hierarchy item, or null for root. */
|
|
5
|
+
destination: {
|
|
6
|
+
id: null | number | string;
|
|
7
|
+
title: string;
|
|
8
|
+
};
|
|
9
|
+
i18n: I18nClient;
|
|
10
|
+
/** Human-readable label for what moved, used in the success toast. */
|
|
11
|
+
label: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
/** The hierarchy item's parent/folder field name on each moved document. */
|
|
14
|
+
parentFieldName: string;
|
|
15
|
+
/** Documents to move, grouped by collection slug. */
|
|
16
|
+
selections: Record<string, {
|
|
17
|
+
ids: (number | string)[];
|
|
18
|
+
}>;
|
|
19
|
+
t: (key: string, options?: Record<string, unknown>) => string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Bulk-assigns `parentFieldName` on every selected document, one PATCH per collection.
|
|
23
|
+
*
|
|
24
|
+
* Surfaces per-collection failures as toasts and keeps going, so one rejected collection doesn't
|
|
25
|
+
* strand the rest. Returns how many documents actually moved, leaving it to the caller to decide
|
|
26
|
+
* whether to refresh the view or clear its selection - the same reason it does not take an
|
|
27
|
+
* `onSuccess`: drop and the Move button want different follow-up.
|
|
28
|
+
*/
|
|
29
|
+
export declare const moveDocuments: ({ apiRoute, destination, i18n, label, locale, parentFieldName, selections, t, }: MoveDocumentsArgs) => Promise<{
|
|
30
|
+
hasErrors: boolean;
|
|
31
|
+
totalMoved: number;
|
|
32
|
+
}>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=moveDocuments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moveDocuments.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/move/moveDocuments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAQ1D,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,oDAAoD;IACpD,WAAW,EAAE;QAAE,EAAE,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1D,IAAI,EAAE,UAAU,CAAA;IAChB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4EAA4E;IAC5E,eAAe,EAAE,MAAM,CAAA;IACvB,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;KAAE,CAAC,CAAA;IACxD,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAA;CAC9D,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,oFASvB,iBAAiB,KAAG,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CA6ExE,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { formatAdminURL } from 'payload/shared';
|
|
2
|
+
import * as qs from 'qs-esm';
|
|
3
|
+
import { toast } from 'sonner';
|
|
4
|
+
import { requests } from '../../../utilities/api.js';
|
|
5
|
+
/**
|
|
6
|
+
* Bulk-assigns `parentFieldName` on every selected document, one PATCH per collection.
|
|
7
|
+
*
|
|
8
|
+
* Surfaces per-collection failures as toasts and keeps going, so one rejected collection doesn't
|
|
9
|
+
* strand the rest. Returns how many documents actually moved, leaving it to the caller to decide
|
|
10
|
+
* whether to refresh the view or clear its selection - the same reason it does not take an
|
|
11
|
+
* `onSuccess`: drop and the Move button want different follow-up.
|
|
12
|
+
*/
|
|
13
|
+
export const moveDocuments = async ({
|
|
14
|
+
apiRoute,
|
|
15
|
+
destination,
|
|
16
|
+
i18n,
|
|
17
|
+
label,
|
|
18
|
+
locale,
|
|
19
|
+
parentFieldName,
|
|
20
|
+
selections,
|
|
21
|
+
t
|
|
22
|
+
}) => {
|
|
23
|
+
let totalMoved = 0;
|
|
24
|
+
let hasErrors = false;
|
|
25
|
+
try {
|
|
26
|
+
for (const [collectionSlug, {
|
|
27
|
+
ids
|
|
28
|
+
}] of Object.entries(selections)) {
|
|
29
|
+
if (ids.length === 0) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const queryString = qs.stringify({
|
|
33
|
+
locale,
|
|
34
|
+
where: {
|
|
35
|
+
id: {
|
|
36
|
+
in: ids
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
addQueryPrefix: true
|
|
41
|
+
});
|
|
42
|
+
const url = formatAdminURL({
|
|
43
|
+
apiRoute,
|
|
44
|
+
path: `/${collectionSlug}${queryString}`
|
|
45
|
+
});
|
|
46
|
+
const response = await requests.patch(url, {
|
|
47
|
+
body: JSON.stringify({
|
|
48
|
+
[parentFieldName]: destination.id
|
|
49
|
+
}),
|
|
50
|
+
headers: {
|
|
51
|
+
'Accept-Language': i18n.language,
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
credentials: 'include'
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const json = await response.json();
|
|
57
|
+
if (response.status >= 400) {
|
|
58
|
+
hasErrors = true;
|
|
59
|
+
if (json?.errors?.length > 0) {
|
|
60
|
+
toast.error(json.message || t('error:unknown'), {
|
|
61
|
+
description: json.errors.map(error => error.message).join('\n')
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
toast.error(json?.message || t('error:unknown'));
|
|
65
|
+
}
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const movedCount = json?.docs?.length || 0;
|
|
69
|
+
totalMoved += movedCount;
|
|
70
|
+
if (json?.errors?.length > 0) {
|
|
71
|
+
hasErrors = true;
|
|
72
|
+
toast.error(json.message, {
|
|
73
|
+
description: json.errors.map(error => error.message).join('\n')
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (totalMoved > 0) {
|
|
78
|
+
const successKey = destination.id === null ? 'hierarchy:itemsMovedToRoot' : 'hierarchy:itemsMovedTo';
|
|
79
|
+
toast.success(t(successKey, {
|
|
80
|
+
count: totalMoved,
|
|
81
|
+
destination: destination.title,
|
|
82
|
+
label
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
} catch (_err) {
|
|
86
|
+
hasErrors = true;
|
|
87
|
+
toast.error(t('error:unknown'));
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
hasErrors,
|
|
91
|
+
totalMoved
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=moveDocuments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moveDocuments.js","names":["formatAdminURL","qs","toast","requests","moveDocuments","apiRoute","destination","i18n","label","locale","parentFieldName","selections","t","totalMoved","hasErrors","collectionSlug","ids","Object","entries","length","queryString","stringify","where","id","in","addQueryPrefix","url","path","response","patch","body","JSON","headers","language","credentials","json","status","errors","error","message","description","map","join","movedCount","docs","successKey","success","count","title","_err"],"sources":["../../../../src/elements/Hierarchy/move/moveDocuments.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport { toast } from 'sonner'\n\nimport { requests } from '../../../utilities/api.js'\n\ntype MoveDocumentsArgs = {\n apiRoute: string\n /** Destination hierarchy item, or null for root. */\n destination: { id: null | number | string; title: string }\n i18n: I18nClient\n /** Human-readable label for what moved, used in the success toast. */\n label: string\n locale?: string\n /** The hierarchy item's parent/folder field name on each moved document. */\n parentFieldName: string\n /** Documents to move, grouped by collection slug. */\n selections: Record<string, { ids: (number | string)[] }>\n t: (key: string, options?: Record<string, unknown>) => string\n}\n\n/**\n * Bulk-assigns `parentFieldName` on every selected document, one PATCH per collection.\n *\n * Surfaces per-collection failures as toasts and keeps going, so one rejected collection doesn't\n * strand the rest. Returns how many documents actually moved, leaving it to the caller to decide\n * whether to refresh the view or clear its selection - the same reason it does not take an\n * `onSuccess`: drop and the Move button want different follow-up.\n */\nexport const moveDocuments = async ({\n apiRoute,\n destination,\n i18n,\n label,\n locale,\n parentFieldName,\n selections,\n t,\n}: MoveDocumentsArgs): Promise<{ hasErrors: boolean; totalMoved: number }> => {\n let totalMoved = 0\n let hasErrors = false\n\n try {\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n if (ids.length === 0) {\n continue\n }\n\n const queryString = qs.stringify(\n {\n locale,\n where: { id: { in: ids } },\n },\n { addQueryPrefix: true },\n )\n\n const url = formatAdminURL({\n apiRoute,\n path: `/${collectionSlug}${queryString}`,\n })\n\n const response = await requests.patch(url, {\n body: JSON.stringify({ [parentFieldName]: destination.id }),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n credentials: 'include',\n },\n })\n\n const json = await response.json()\n\n if (response.status >= 400) {\n hasErrors = true\n\n if (json?.errors?.length > 0) {\n toast.error(json.message || t('error:unknown'), {\n description: json.errors.map((error: { message: string }) => error.message).join('\\n'),\n })\n } else {\n toast.error(json?.message || t('error:unknown'))\n }\n\n continue\n }\n\n const movedCount = json?.docs?.length || 0\n totalMoved += movedCount\n\n if (json?.errors?.length > 0) {\n hasErrors = true\n toast.error(json.message, {\n description: json.errors.map((error: { message: string }) => error.message).join('\\n'),\n })\n }\n }\n\n if (totalMoved > 0) {\n const successKey =\n destination.id === null ? 'hierarchy:itemsMovedToRoot' : 'hierarchy:itemsMovedTo'\n\n toast.success(\n t(successKey, {\n count: totalMoved,\n destination: destination.title,\n label,\n }),\n )\n }\n } catch (_err) {\n hasErrors = true\n toast.error(t('error:unknown'))\n }\n\n return { hasErrors, totalMoved }\n}\n"],"m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|
+
button:not(:disabled):hover > .id-label {
|
|
24
|
+
background: var(--color-bg-secondary-hover);
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
.id-label__prefix {
|
|
22
28
|
color: var(--color-text-secondary);
|
|
23
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/IDLabel/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,OAAO,aAAa,CAAA;AAIpB,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/IDLabel/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,OAAO,aAAa,CAAA;AAIpB,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAyCA,CAAA"}
|
|
@@ -12,7 +12,7 @@ import { useDrawerDepth } from '../Drawer/index.js';
|
|
|
12
12
|
import './index.css';
|
|
13
13
|
const baseClass = 'id-label';
|
|
14
14
|
export const IDLabel = t0 => {
|
|
15
|
-
const $ = _c(
|
|
15
|
+
const $ = _c(12);
|
|
16
16
|
const {
|
|
17
17
|
id,
|
|
18
18
|
className,
|
|
@@ -40,22 +40,25 @@ export const IDLabel = t0 => {
|
|
|
40
40
|
bb0: {
|
|
41
41
|
const sanitizedID = sanitizeID(id);
|
|
42
42
|
const shouldRenderLink = drawerDepth > 0 && (collectionSlug || globalSlug);
|
|
43
|
+
const t6 = shouldRenderLink && `${baseClass}--is-link`;
|
|
44
|
+
let t7;
|
|
45
|
+
if ($[9] !== className || $[10] !== t6) {
|
|
46
|
+
t7 = [baseClass, t6, className].filter(Boolean);
|
|
47
|
+
$[9] = className;
|
|
48
|
+
$[10] = t6;
|
|
49
|
+
$[11] = t7;
|
|
50
|
+
} else {
|
|
51
|
+
t7 = $[11];
|
|
52
|
+
}
|
|
53
|
+
const classes = t7.join(" ");
|
|
43
54
|
if (shouldRenderLink) {
|
|
44
55
|
const docPath = formatAdminURL({
|
|
45
56
|
adminRoute,
|
|
46
57
|
path: `/${collectionSlug ? `collections/${collectionSlug}` : `globals/${globalSlug}`}/${id}`
|
|
47
58
|
});
|
|
48
|
-
let t6;
|
|
49
|
-
if ($[9] !== className) {
|
|
50
|
-
t6 = [baseClass, className].filter(Boolean);
|
|
51
|
-
$[9] = className;
|
|
52
|
-
$[10] = t6;
|
|
53
|
-
} else {
|
|
54
|
-
t6 = $[10];
|
|
55
|
-
}
|
|
56
59
|
t5 = _jsxs("div", {
|
|
57
|
-
className:
|
|
58
|
-
title: id,
|
|
60
|
+
className: classes,
|
|
61
|
+
title: String(id),
|
|
59
62
|
children: [_jsx("span", {
|
|
60
63
|
className: `${baseClass}__prefix`,
|
|
61
64
|
children: prefix
|
|
@@ -67,17 +70,9 @@ export const IDLabel = t0 => {
|
|
|
67
70
|
});
|
|
68
71
|
break bb0;
|
|
69
72
|
}
|
|
70
|
-
let t6;
|
|
71
|
-
if ($[11] !== className) {
|
|
72
|
-
t6 = [baseClass, className].filter(Boolean);
|
|
73
|
-
$[11] = className;
|
|
74
|
-
$[12] = t6;
|
|
75
|
-
} else {
|
|
76
|
-
t6 = $[12];
|
|
77
|
-
}
|
|
78
73
|
t4 = _jsxs("div", {
|
|
79
|
-
className:
|
|
80
|
-
title: id,
|
|
74
|
+
className: classes,
|
|
75
|
+
title: String(id),
|
|
81
76
|
children: [_jsx("span", {
|
|
82
77
|
className: `${baseClass}__prefix`,
|
|
83
78
|
children: prefix
|