@payloadcms/ui 3.80.0-internal.8d9ec7c → 3.80.0-internal.cdd7ef7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts.map +1 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js +4 -2
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js.map +1 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js +157 -0
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/Column/index.d.ts.map +1 -0
- package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/Column/index.js +5 -5
- package/dist/elements/Hierarchy/ColumnBrowser/Column/index.js.map +1 -0
- package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/Column/index.scss +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.d.ts.map +1 -0
- package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/ColumnItem/index.js +3 -3
- package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.js.map +1 -0
- package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/ColumnItem/index.scss +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/index.d.ts.map +1 -0
- package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/index.js +6 -6
- package/dist/elements/Hierarchy/ColumnBrowser/index.js.map +1 -0
- package/dist/elements/Hierarchy/ColumnBrowser/types.d.ts.map +1 -0
- package/dist/elements/Hierarchy/ColumnBrowser/types.js.map +1 -0
- package/dist/elements/Hierarchy/DocHeaderButton/index.d.ts.map +1 -0
- package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.js +6 -6
- package/dist/elements/Hierarchy/DocHeaderButton/index.js.map +1 -0
- package/dist/elements/Hierarchy/DocHeaderButton/index.server.d.ts.map +1 -0
- package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.server.js +3 -3
- package/dist/elements/Hierarchy/DocHeaderButton/index.server.js.map +1 -0
- package/dist/elements/Hierarchy/Drawer/fetchAncestorPath.d.ts.map +1 -0
- package/dist/elements/Hierarchy/Drawer/fetchAncestorPath.js.map +1 -0
- package/dist/elements/{HierarchyDrawer → Hierarchy}/Drawer/index.d.ts +2 -2
- package/dist/elements/Hierarchy/Drawer/index.d.ts.map +1 -0
- package/dist/elements/{HierarchyDrawer → Hierarchy}/Drawer/index.js +2 -2
- package/dist/elements/Hierarchy/Drawer/index.js.map +1 -0
- package/dist/elements/{HierarchyDrawer → Hierarchy/Drawer}/types.d.ts +1 -1
- package/dist/elements/Hierarchy/Drawer/types.d.ts.map +1 -0
- package/dist/elements/Hierarchy/Drawer/types.js.map +1 -0
- package/dist/elements/{HierarchyDrawer/index.d.ts → Hierarchy/Drawer/useHierarchyDrawer.d.ts} +1 -1
- package/dist/elements/Hierarchy/Drawer/useHierarchyDrawer.d.ts.map +1 -0
- package/dist/elements/{HierarchyDrawer/index.js → Hierarchy/Drawer/useHierarchyDrawer.js} +6 -6
- package/dist/elements/Hierarchy/Drawer/useHierarchyDrawer.js.map +1 -0
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.d.ts.map +1 -0
- package/dist/elements/{HierarchyField → Hierarchy/Field}/SelectedHierarchies.js +7 -16
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.js.map +1 -0
- package/dist/elements/{HierarchyField → Hierarchy/Field}/SelectedHierarchies.scss +1 -1
- package/dist/elements/Hierarchy/Field/index.client.d.ts.map +1 -0
- package/dist/elements/{HierarchyField → Hierarchy/Field}/index.client.js +17 -29
- package/dist/elements/Hierarchy/Field/index.client.js.map +1 -0
- package/dist/elements/{HierarchyField → Hierarchy/Field}/index.scss +1 -1
- package/dist/elements/Hierarchy/Field/index.server.d.ts.map +1 -0
- package/dist/elements/{HierarchyField → Hierarchy/Field}/index.server.js +2 -2
- package/dist/elements/Hierarchy/Field/index.server.js.map +1 -0
- package/dist/elements/Hierarchy/HydrateProvider/index.d.ts +4 -0
- package/dist/elements/Hierarchy/HydrateProvider/index.d.ts.map +1 -0
- package/dist/elements/{HydrateHierarchyProvider → Hierarchy/HydrateProvider}/index.js +1 -1
- package/dist/elements/Hierarchy/HydrateProvider/index.js.map +1 -0
- package/dist/elements/{MoveMany → Hierarchy/MoveMany}/index.d.ts +3 -3
- package/dist/elements/Hierarchy/MoveMany/index.d.ts.map +1 -0
- package/dist/elements/{MoveMany → Hierarchy/MoveMany}/index.js +10 -10
- package/dist/elements/Hierarchy/MoveMany/index.js.map +1 -0
- package/dist/elements/{MoveMany → Hierarchy/MoveMany}/index.scss +1 -1
- package/dist/elements/Hierarchy/Search/HierarchySearchInput.d.ts.map +1 -0
- package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchInput.js +5 -5
- package/dist/elements/Hierarchy/Search/HierarchySearchInput.js.map +1 -0
- package/dist/elements/Hierarchy/Search/HierarchySearchResultItem.d.ts.map +1 -0
- package/dist/elements/Hierarchy/Search/HierarchySearchResultItem.js.map +1 -0
- package/dist/elements/Hierarchy/Search/HierarchySearchResults.d.ts.map +1 -0
- package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchResults.js +2 -2
- package/dist/elements/Hierarchy/Search/HierarchySearchResults.js.map +1 -0
- package/dist/elements/Hierarchy/Search/index.d.ts.map +1 -0
- package/dist/elements/{HierarchySearch → Hierarchy/Search}/index.js +2 -2
- package/dist/elements/Hierarchy/Search/index.js.map +1 -0
- package/dist/elements/{HierarchySearch → Hierarchy/Search}/index.scss +1 -1
- package/dist/elements/Hierarchy/Search/types.d.ts.map +1 -0
- package/dist/elements/Hierarchy/Search/types.js.map +1 -0
- package/dist/elements/Hierarchy/Search/useHierarchySearch.d.ts.map +1 -0
- package/dist/elements/{HierarchySearch → Hierarchy/Search}/useHierarchySearch.js +2 -2
- package/dist/elements/Hierarchy/Search/useHierarchySearch.js.map +1 -0
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.d.ts.map +1 -0
- package/dist/elements/{HierarchyTree → Hierarchy/Tree}/HierarchySidebarTab.js +43 -48
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.js.map +1 -0
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.d.ts.map +1 -0
- package/dist/elements/{HierarchyTree → Hierarchy/Tree}/HierarchySidebarTab.server.js +6 -5
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.js.map +1 -0
- package/dist/elements/Hierarchy/Tree/LoadMore/LoadMoreButton.d.ts.map +1 -0
- package/dist/elements/{Tree → Hierarchy/Tree}/LoadMore/LoadMoreButton.js +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/LoadMoreButton.js.map +1 -0
- package/dist/elements/Hierarchy/Tree/LoadMore/index.d.ts.map +1 -0
- package/dist/elements/{Tree → Hierarchy/Tree}/LoadMore/index.js +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.js.map +1 -0
- package/dist/elements/Hierarchy/Tree/TreeConnector.d.ts.map +1 -0
- package/dist/elements/Hierarchy/Tree/TreeConnector.js.map +1 -0
- package/dist/elements/Hierarchy/Tree/TreeFocusContext.d.ts.map +1 -0
- package/dist/elements/Hierarchy/Tree/TreeFocusContext.js.map +1 -0
- package/dist/elements/Hierarchy/Tree/TreeNode/index.d.ts.map +1 -0
- package/dist/elements/{Tree → Hierarchy/Tree}/TreeNode/index.js +8 -4
- package/dist/elements/Hierarchy/Tree/TreeNode/index.js.map +1 -0
- package/dist/elements/{Tree → Hierarchy/Tree}/TreeNode/index.scss +1 -1
- package/dist/elements/{HierarchyTree → Hierarchy/Tree}/index.d.ts +1 -0
- package/dist/elements/Hierarchy/Tree/index.d.ts.map +1 -0
- package/dist/elements/{Tree → Hierarchy/Tree}/index.js +72 -72
- package/dist/elements/Hierarchy/Tree/index.js.map +1 -0
- package/dist/elements/{Tree → Hierarchy/Tree}/index.scss +2 -5
- package/dist/elements/{Tree → Hierarchy/Tree}/types.d.ts +30 -24
- package/dist/elements/Hierarchy/Tree/types.d.ts.map +1 -0
- package/dist/elements/Hierarchy/Tree/types.js.map +1 -0
- package/dist/elements/{Tree → Hierarchy/Tree}/useChildren.d.ts +5 -1
- package/dist/elements/Hierarchy/Tree/useChildren.d.ts.map +1 -0
- package/dist/elements/{Tree → Hierarchy/Tree}/useChildren.js +41 -25
- package/dist/elements/Hierarchy/Tree/useChildren.js.map +1 -0
- package/dist/elements/LoadMoreRow/index.js +1 -1
- package/dist/elements/LoadMoreRow/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +14 -9
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Hierarchy/index.js +1 -1
- package/dist/elements/Table/DefaultCell/fields/Hierarchy/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +11 -15
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +26 -26
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/rsc/index.d.ts +3 -3
- package/dist/exports/rsc/index.d.ts.map +1 -1
- package/dist/exports/rsc/index.js +3 -3
- package/dist/exports/rsc/index.js.map +1 -1
- package/dist/forms/Form/mergeServerFormState.d.ts.map +1 -1
- package/dist/forms/Form/mergeServerFormState.js +101 -24
- package/dist/forms/Form/mergeServerFormState.js.map +1 -1
- package/dist/icons/TableView/index.d.ts +3 -0
- package/dist/icons/TableView/index.d.ts.map +1 -0
- package/dist/icons/TableView/index.js +16 -0
- package/dist/icons/TableView/index.js.map +1 -0
- package/dist/providers/Hierarchy/index.d.ts.map +1 -1
- package/dist/providers/Hierarchy/index.js +5 -1
- package/dist/providers/Hierarchy/index.js.map +1 -1
- package/dist/providers/Hierarchy/types.d.ts +1 -0
- package/dist/providers/Hierarchy/types.d.ts.map +1 -1
- package/dist/providers/Hierarchy/types.js.map +1 -1
- package/dist/providers/SidebarTabs/index.d.ts +19 -0
- package/dist/providers/SidebarTabs/index.d.ts.map +1 -0
- package/dist/providers/SidebarTabs/index.js +24 -0
- package/dist/providers/SidebarTabs/index.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/views/Edit/index.d.ts.map +1 -1
- package/dist/views/Edit/index.js +11 -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 +145 -86
- package/dist/views/HierarchyList/DocumentListSelection/index.js.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/index.d.ts +1 -1
- package/dist/views/HierarchyList/HierarchyTable/index.d.ts.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/elements/HierarchyButton/index.d.ts.map +0 -1
- package/dist/elements/HierarchyButton/index.js.map +0 -1
- package/dist/elements/HierarchyButton/index.server.d.ts.map +0 -1
- package/dist/elements/HierarchyButton/index.server.js.map +0 -1
- package/dist/elements/HierarchyColumnBrowser/Column/index.d.ts.map +0 -1
- package/dist/elements/HierarchyColumnBrowser/Column/index.js.map +0 -1
- package/dist/elements/HierarchyColumnBrowser/ColumnItem/index.d.ts.map +0 -1
- package/dist/elements/HierarchyColumnBrowser/ColumnItem/index.js.map +0 -1
- package/dist/elements/HierarchyColumnBrowser/index.d.ts.map +0 -1
- package/dist/elements/HierarchyColumnBrowser/index.js.map +0 -1
- package/dist/elements/HierarchyColumnBrowser/types.d.ts.map +0 -1
- package/dist/elements/HierarchyColumnBrowser/types.js.map +0 -1
- package/dist/elements/HierarchyDrawer/Drawer/index.d.ts.map +0 -1
- package/dist/elements/HierarchyDrawer/Drawer/index.js.map +0 -1
- package/dist/elements/HierarchyDrawer/fetchAncestorPath.d.ts.map +0 -1
- package/dist/elements/HierarchyDrawer/fetchAncestorPath.js.map +0 -1
- package/dist/elements/HierarchyDrawer/index.d.ts.map +0 -1
- package/dist/elements/HierarchyDrawer/index.js.map +0 -1
- package/dist/elements/HierarchyDrawer/types.d.ts.map +0 -1
- package/dist/elements/HierarchyDrawer/types.js.map +0 -1
- package/dist/elements/HierarchyField/SelectedHierarchies.d.ts.map +0 -1
- package/dist/elements/HierarchyField/SelectedHierarchies.js.map +0 -1
- package/dist/elements/HierarchyField/index.client.d.ts.map +0 -1
- package/dist/elements/HierarchyField/index.client.js.map +0 -1
- package/dist/elements/HierarchyField/index.server.d.ts.map +0 -1
- package/dist/elements/HierarchyField/index.server.js.map +0 -1
- package/dist/elements/HierarchySearch/HierarchySearchInput.d.ts.map +0 -1
- package/dist/elements/HierarchySearch/HierarchySearchInput.js.map +0 -1
- package/dist/elements/HierarchySearch/HierarchySearchResultItem.d.ts.map +0 -1
- package/dist/elements/HierarchySearch/HierarchySearchResultItem.js.map +0 -1
- package/dist/elements/HierarchySearch/HierarchySearchResults.d.ts.map +0 -1
- package/dist/elements/HierarchySearch/HierarchySearchResults.js.map +0 -1
- package/dist/elements/HierarchySearch/index.d.ts.map +0 -1
- package/dist/elements/HierarchySearch/index.js.map +0 -1
- package/dist/elements/HierarchySearch/types.d.ts.map +0 -1
- package/dist/elements/HierarchySearch/types.js.map +0 -1
- package/dist/elements/HierarchySearch/useHierarchySearch.d.ts.map +0 -1
- package/dist/elements/HierarchySearch/useHierarchySearch.js.map +0 -1
- package/dist/elements/HierarchyTree/HierarchySidebarTab.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/HierarchySidebarTab.js.map +0 -1
- package/dist/elements/HierarchyTree/HierarchySidebarTab.server.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/HierarchySidebarTab.server.js.map +0 -1
- package/dist/elements/HierarchyTree/LoadMore/LoadMoreButton.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/LoadMore/LoadMoreButton.js +0 -36
- package/dist/elements/HierarchyTree/LoadMore/LoadMoreButton.js.map +0 -1
- package/dist/elements/HierarchyTree/LoadMore/index.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/LoadMore/index.js +0 -29
- package/dist/elements/HierarchyTree/LoadMore/index.js.map +0 -1
- package/dist/elements/HierarchyTree/LoadMore/index.scss +0 -26
- package/dist/elements/HierarchyTree/TreeConnector.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/TreeConnector.js.map +0 -1
- package/dist/elements/HierarchyTree/TreeFocusContext.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/TreeFocusContext.js.map +0 -1
- package/dist/elements/HierarchyTree/TreeNode/index.d.ts +0 -5
- package/dist/elements/HierarchyTree/TreeNode/index.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/TreeNode/index.js +0 -201
- package/dist/elements/HierarchyTree/TreeNode/index.js.map +0 -1
- package/dist/elements/HierarchyTree/TreeNode/index.scss +0 -99
- package/dist/elements/HierarchyTree/index.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/index.js +0 -66
- package/dist/elements/HierarchyTree/index.js.map +0 -1
- package/dist/elements/HierarchyTree/index.scss +0 -42
- package/dist/elements/HierarchyTree/types.d.ts +0 -57
- package/dist/elements/HierarchyTree/types.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/types.js.map +0 -1
- package/dist/elements/HierarchyTree/useChildren.d.ts +0 -26
- package/dist/elements/HierarchyTree/useChildren.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/useChildren.js +0 -150
- package/dist/elements/HierarchyTree/useChildren.js.map +0 -1
- package/dist/elements/HierarchyTree/useTreeState.d.ts +0 -9
- package/dist/elements/HierarchyTree/useTreeState.d.ts.map +0 -1
- package/dist/elements/HierarchyTree/useTreeState.js +0 -50
- package/dist/elements/HierarchyTree/useTreeState.js.map +0 -1
- package/dist/elements/HydrateHierarchyProvider/index.d.ts +0 -4
- package/dist/elements/HydrateHierarchyProvider/index.d.ts.map +0 -1
- package/dist/elements/HydrateHierarchyProvider/index.js.map +0 -1
- package/dist/elements/MoveMany/index.d.ts.map +0 -1
- package/dist/elements/MoveMany/index.js.map +0 -1
- package/dist/elements/Tree/LoadMore/LoadMoreButton.d.ts +0 -8
- package/dist/elements/Tree/LoadMore/LoadMoreButton.d.ts.map +0 -1
- package/dist/elements/Tree/LoadMore/LoadMoreButton.js.map +0 -1
- package/dist/elements/Tree/LoadMore/index.d.ts +0 -12
- package/dist/elements/Tree/LoadMore/index.d.ts.map +0 -1
- package/dist/elements/Tree/LoadMore/index.js.map +0 -1
- package/dist/elements/Tree/TreeConnector.d.ts +0 -7
- package/dist/elements/Tree/TreeConnector.d.ts.map +0 -1
- package/dist/elements/Tree/TreeConnector.js +0 -23
- package/dist/elements/Tree/TreeConnector.js.map +0 -1
- package/dist/elements/Tree/TreeFocusContext.d.ts +0 -28
- package/dist/elements/Tree/TreeFocusContext.d.ts.map +0 -1
- package/dist/elements/Tree/TreeFocusContext.js +0 -140
- package/dist/elements/Tree/TreeFocusContext.js.map +0 -1
- package/dist/elements/Tree/TreeNode/index.d.ts.map +0 -1
- package/dist/elements/Tree/TreeNode/index.js.map +0 -1
- package/dist/elements/Tree/index.d.ts +0 -5
- package/dist/elements/Tree/index.d.ts.map +0 -1
- package/dist/elements/Tree/index.js.map +0 -1
- package/dist/elements/Tree/types.d.ts.map +0 -1
- package/dist/elements/Tree/types.js +0 -2
- package/dist/elements/Tree/types.js.map +0 -1
- package/dist/elements/Tree/useChildren.d.ts.map +0 -1
- package/dist/elements/Tree/useChildren.js.map +0 -1
- /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/Column/index.d.ts +0 -0
- /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/ColumnItem/index.d.ts +0 -0
- /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/index.d.ts +0 -0
- /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/index.scss +0 -0
- /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/types.d.ts +0 -0
- /package/dist/elements/{HierarchyColumnBrowser → Hierarchy/ColumnBrowser}/types.js +0 -0
- /package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.d.ts +0 -0
- /package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.scss +0 -0
- /package/dist/elements/{HierarchyButton → Hierarchy/DocHeaderButton}/index.server.d.ts +0 -0
- /package/dist/elements/{HierarchyDrawer → Hierarchy/Drawer}/fetchAncestorPath.d.ts +0 -0
- /package/dist/elements/{HierarchyDrawer → Hierarchy/Drawer}/fetchAncestorPath.js +0 -0
- /package/dist/elements/{HierarchyDrawer → Hierarchy}/Drawer/index.scss +0 -0
- /package/dist/elements/{HierarchyDrawer → Hierarchy/Drawer}/types.js +0 -0
- /package/dist/elements/{HierarchyField → Hierarchy/Field}/SelectedHierarchies.d.ts +0 -0
- /package/dist/elements/{HierarchyField → Hierarchy/Field}/index.client.d.ts +0 -0
- /package/dist/elements/{HierarchyField → Hierarchy/Field}/index.server.d.ts +0 -0
- /package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchInput.d.ts +0 -0
- /package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchResultItem.d.ts +0 -0
- /package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchResultItem.js +0 -0
- /package/dist/elements/{HierarchySearch → Hierarchy/Search}/HierarchySearchResults.d.ts +0 -0
- /package/dist/elements/{HierarchySearch → Hierarchy/Search}/index.d.ts +0 -0
- /package/dist/elements/{HierarchySearch → Hierarchy/Search}/types.d.ts +0 -0
- /package/dist/elements/{HierarchySearch → Hierarchy/Search}/types.js +0 -0
- /package/dist/elements/{HierarchySearch → Hierarchy/Search}/useHierarchySearch.d.ts +0 -0
- /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/HierarchySidebarTab.d.ts +0 -0
- /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/HierarchySidebarTab.server.d.ts +0 -0
- /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/LoadMore/LoadMoreButton.d.ts +0 -0
- /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/LoadMore/index.d.ts +0 -0
- /package/dist/elements/{Tree → Hierarchy/Tree}/LoadMore/index.scss +0 -0
- /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/TreeConnector.d.ts +0 -0
- /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/TreeConnector.js +0 -0
- /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/TreeFocusContext.d.ts +0 -0
- /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/TreeFocusContext.js +0 -0
- /package/dist/elements/{Tree → Hierarchy/Tree}/TreeNode/index.d.ts +0 -0
- /package/dist/elements/{HierarchyTree → Hierarchy/Tree}/types.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/DocHeaderButton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAUxE,OAAO,cAAc,CAAA;AAIrB,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CA+HtE,CAAA"}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
4
|
import { formatAdminURL } from 'payload/shared';
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
-
import { useForm, useFormFields } from '
|
|
7
|
-
import { useConfig } from '
|
|
8
|
-
import { useDocumentInfo } from '
|
|
9
|
-
import { useTranslation } from '
|
|
10
|
-
import { Button } from '
|
|
11
|
-
import { useHierarchyDrawer } from '../
|
|
6
|
+
import { useForm, useFormFields } from '../../../forms/Form/context.js';
|
|
7
|
+
import { useConfig } from '../../../providers/Config/index.js';
|
|
8
|
+
import { useDocumentInfo } from '../../../providers/DocumentInfo/index.js';
|
|
9
|
+
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
10
|
+
import { Button } from '../../Button/index.js';
|
|
11
|
+
import { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js';
|
|
12
12
|
import './index.scss';
|
|
13
13
|
const baseClass = 'hierarchy-button';
|
|
14
14
|
export const HierarchyButtonClient = ({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["formatAdminURL","React","useCallback","useEffect","useMemo","useState","useForm","useFormFields","useConfig","useDocumentInfo","useTranslation","Button","useHierarchyDrawer","baseClass","HierarchyButtonClient","fieldName","hasMany","hierarchyCollectionSlug","Icon","readOnly","t","config","getEntityConfig","collectionSlug","documentCollectionSlug","setModified","dispatchField","_","dispatch","currentFieldValue","fields","currentId","value","displayName","setDisplayName","isLoading","setIsLoading","collectionConfig","useAsTitle","admin","isHierarchyCollection","filterByCollection","undefined","HierarchyDrawer","openDrawer","fetchItemName","response","fetch","apiRoute","routes","api","path","serverURL","credentials","ok","itemData","json","title","name","id","String","handleDrawerSave","closeDrawer","selections","ids","Array","from","keys","newValue","type","handleClick","label","_jsxs","_Fragment","_jsx","buttonStyle","className","filter","Boolean","join","disabled","icon","iconPosition","margin","onClick","initialSelections","onSave"],"sources":["../../../../src/elements/Hierarchy/DocHeaderButton/index.tsx"],"sourcesContent":["'use client'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport type { SelectionWithPath } from '../Drawer/types.js'\n\nimport { useForm, useFormFields } from '../../../forms/Form/context.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js'\nimport './index.scss'\n\nconst baseClass = 'hierarchy-button'\n\nexport type HierarchyButtonClientProps = {\n fieldName: string\n hasMany?: boolean\n hierarchyCollectionSlug: string\n Icon?: React.ReactNode\n readOnly?: boolean\n}\n\nexport const HierarchyButtonClient: React.FC<HierarchyButtonClientProps> = ({\n fieldName,\n hasMany = false,\n hierarchyCollectionSlug,\n Icon,\n readOnly,\n}) => {\n const { t } = useTranslation()\n const { config, getEntityConfig } = useConfig()\n const { collectionSlug: documentCollectionSlug } = useDocumentInfo()\n const { setModified } = useForm()\n const dispatchField = useFormFields(([_, dispatch]) => dispatch)\n\n const currentFieldValue = useFormFields(([fields]) => (fields && fields?.[fieldName]) || null)\n const currentId = currentFieldValue?.value as null | number | string\n\n const [displayName, setDisplayName] = useState<string>('')\n const [isLoading, setIsLoading] = useState(true)\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchyCollectionSlug })\n const useAsTitle = collectionConfig?.admin?.useAsTitle || 'name'\n\n const isHierarchyCollection = documentCollectionSlug === hierarchyCollectionSlug\n\n // When in hierarchy collection, let the drawer use allowedCollections from context\n // When in other collections, filter by that collection's slug\n // Memoize to prevent new array references on every render\n const filterByCollection = useMemo(\n () => (isHierarchyCollection || !documentCollectionSlug ? undefined : [documentCollectionSlug]),\n [isHierarchyCollection, documentCollectionSlug],\n )\n\n const [HierarchyDrawer, , { openDrawer }] = useHierarchyDrawer({\n filterByCollection,\n hierarchyCollectionSlug,\n Icon,\n })\n\n // Fetch item name when currentId changes\n useEffect(() => {\n const fetchItemName = async () => {\n if (currentId && (typeof currentId === 'string' || typeof currentId === 'number')) {\n setIsLoading(true)\n try {\n const response = await fetch(\n formatAdminURL({\n apiRoute: config.routes.api,\n path: `/${hierarchyCollectionSlug}/${currentId}`,\n serverURL: config.serverURL,\n }),\n { credentials: 'include' },\n )\n\n if (response.ok) {\n const itemData = await response.json()\n const title = itemData?.[useAsTitle] || itemData?.name || itemData?.id\n\n setDisplayName(String(title))\n } else {\n setDisplayName(t('general:none'))\n }\n } catch {\n setDisplayName(t('general:none'))\n } finally {\n setIsLoading(false)\n }\n } else {\n setDisplayName(t('general:none'))\n setIsLoading(false)\n }\n }\n\n void fetchItemName()\n }, [currentId, hierarchyCollectionSlug, config.routes.api, config.serverURL, useAsTitle, t])\n\n const handleDrawerSave = useCallback(\n ({\n closeDrawer,\n selections,\n }: {\n closeDrawer: () => void\n selections: Map<number | string, SelectionWithPath>\n }) => {\n const ids = Array.from(selections.keys())\n const newValue = hasMany ? ids : (ids[0] ?? null)\n\n if (currentFieldValue?.value !== newValue) {\n dispatchField({\n type: 'UPDATE',\n path: fieldName,\n value: newValue,\n })\n setModified(true)\n }\n closeDrawer()\n },\n [currentFieldValue?.value, dispatchField, fieldName, hasMany, setModified],\n )\n\n const handleClick = useCallback(() => {\n if (!readOnly) {\n openDrawer()\n }\n }, [openDrawer, readOnly])\n\n const label = isLoading ? `${t('general:loading')}...` : displayName\n\n return (\n <>\n <Button\n buttonStyle=\"subtle\"\n className={[baseClass, readOnly && `${baseClass}--read-only`].filter(Boolean).join(' ')}\n disabled={readOnly}\n icon={Icon}\n iconPosition=\"left\"\n margin={false}\n onClick={handleClick}\n >\n {label}\n </Button>\n <HierarchyDrawer\n hasMany={hasMany}\n initialSelections={currentId ? [currentId] : undefined}\n onSave={handleDrawerSave}\n />\n </>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAIjE,SAASC,OAAO,EAAEC,aAAa,QAAQ;AACvC,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/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CAACH,UAAA,CAAWI,IAAI;IACtC,MAAMC,QAAA,GAAWpD,OAAA,GAAUgD,GAAA,GAAOA,GAAG,CAAC,EAAE,IAAI;IAE5C,IAAInC,iBAAA,EAAmBG,KAAA,KAAUoC,QAAA,EAAU;MACzC1C,aAAA,CAAc;QACZ2C,IAAA,EAAM;QACNlB,IAAA,EAAMpC,SAAA;QACNiB,KAAA,EAAOoC;MACT;MACA3C,WAAA,CAAY;IACd;IACAqC,WAAA;EACF,GACA,CAACjC,iBAAA,EAAmBG,KAAA,EAAON,aAAA,EAAeX,SAAA,EAAWC,OAAA,EAASS,WAAA,CAAY;EAG5E,MAAM6C,WAAA,GAAcpE,WAAA,CAAY;IAC9B,IAAI,CAACiB,QAAA,EAAU;MACbyB,UAAA;IACF;EACF,GAAG,CAACA,UAAA,EAAYzB,QAAA,CAAS;EAEzB,MAAMoD,KAAA,GAAQpC,SAAA,GAAY,GAAGf,CAAA,CAAE,uBAAuB,GAAGa,WAAA;EAEzD,oBACEuC,KAAA,CAAAC,SAAA;4BACEC,IAAA,CAAC/D,MAAA;MACCgE,WAAA,EAAY;MACZC,SAAA,EAAW,CAAC/D,SAAA,EAAWM,QAAA,IAAY,GAAGN,SAAA,aAAsB,CAAC,CAACgE,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;MACnFC,QAAA,EAAU7D,QAAA;MACV8D,IAAA,EAAM/D,IAAA;MACNgE,YAAA,EAAa;MACbC,MAAA,EAAQ;MACRC,OAAA,EAASd,WAAA;gBAERC;qBAEHG,IAAA,CAAC/B,eAAA;MACC3B,OAAA,EAASA,OAAA;MACTqE,iBAAA,EAAmBtD,SAAA,GAAY,CAACA,SAAA,CAAU,GAAGW,SAAA;MAC7C4C,MAAA,EAAQzB;;;AAIhB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.server.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/DocHeaderButton/index.server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAqChE,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { FolderIcon } from '
|
|
4
|
-
import { RenderServerComponent } from '
|
|
3
|
+
import { FolderIcon } from '../../../icons/Folder/index.js';
|
|
4
|
+
import { RenderServerComponent } from '../../RenderServerComponent/index.js';
|
|
5
5
|
// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports dir for proper client boundary
|
|
6
|
-
import { HierarchyButtonClient } from '
|
|
6
|
+
import { HierarchyButtonClient } from '../../../exports/client/index.js';
|
|
7
7
|
export const HierarchyButton = ({
|
|
8
8
|
fieldName,
|
|
9
9
|
hasMany,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.server.js","names":["React","FolderIcon","RenderServerComponent","HierarchyButtonClient","HierarchyButton","fieldName","hasMany","hierarchyCollectionSlug","payload","hierarchyCollectionConfig","config","collections","find","c","slug","hierarchyConfig","hierarchy","undefined","IconComponent","admin","components","Icon","isDefaultFolderIcon","renderedIcon","_jsx","color","Component","importMap","key"],"sources":["../../../../src/elements/Hierarchy/DocHeaderButton/index.server.tsx"],"sourcesContent":["import type { Payload } from 'payload'\n\nimport React from 'react'\n\nimport { FolderIcon } from '../../../icons/Folder/index.js'\nimport { RenderServerComponent } from '../../RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports dir for proper client boundary\nimport { HierarchyButtonClient } from '../../../exports/client/index.js'\n\nexport type HierarchyButtonServerProps = {\n fieldName: string\n hasMany?: boolean\n hierarchyCollectionSlug: string\n payload: Payload\n}\n\nexport const HierarchyButton: React.FC<HierarchyButtonServerProps> = ({\n fieldName,\n hasMany,\n hierarchyCollectionSlug,\n payload,\n}) => {\n const hierarchyCollectionConfig = payload.config.collections.find(\n (c) => c.slug === hierarchyCollectionSlug,\n )\n const hierarchyConfig =\n hierarchyCollectionConfig?.hierarchy && typeof hierarchyCollectionConfig.hierarchy === 'object'\n ? hierarchyCollectionConfig.hierarchy\n : undefined\n const IconComponent = hierarchyConfig?.admin.components.Icon\n\n // Render the custom icon if provided, otherwise use FolderIcon directly\n // Important: Must render the icon here on server to avoid hydration mismatch\n // For default FolderIcon path, render directly to avoid import map requirement\n const isDefaultFolderIcon = !IconComponent || IconComponent === '@payloadcms/ui#FolderIcon'\n const renderedIcon = isDefaultFolderIcon ? (\n <FolderIcon color=\"muted\" />\n ) : (\n RenderServerComponent({\n Component: IconComponent,\n importMap: payload.importMap,\n key: `hierarchy-button-icon-${hierarchyCollectionSlug}`,\n })\n )\n\n return (\n <HierarchyButtonClient\n fieldName={fieldName}\n hasMany={hasMany}\n hierarchyCollectionSlug={hierarchyCollectionSlug}\n Icon={renderedIcon}\n />\n )\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AAElB,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC;AACA,SAASC,qBAAqB,QAAQ;AAStC,OAAO,MAAMC,eAAA,GAAwDA,CAAC;EACpEC,SAAS;EACTC,OAAO;EACPC,uBAAuB;EACvBC;AAAO,CACR;EACC,MAAMC,yBAAA,GAA4BD,OAAA,CAAQE,MAAM,CAACC,WAAW,CAACC,IAAI,CAC9DC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAKP,uBAAA;EAEpB,MAAMQ,eAAA,GACJN,yBAAA,EAA2BO,SAAA,IAAa,OAAOP,yBAAA,CAA0BO,SAAS,KAAK,WACnFP,yBAAA,CAA0BO,SAAS,GACnCC,SAAA;EACN,MAAMC,aAAA,GAAgBH,eAAA,EAAiBI,KAAA,CAAMC,UAAA,CAAWC,IAAA;EAExD;EACA;EACA;EACA,MAAMC,mBAAA,GAAsB,CAACJ,aAAA,IAAiBA,aAAA,KAAkB;EAChE,MAAMK,YAAA,GAAeD,mBAAA,gBACnBE,IAAA,CAACvB,UAAA;IAAWwB,KAAA,EAAM;OAElBvB,qBAAA,CAAsB;IACpBwB,SAAA,EAAWR,aAAA;IACXS,SAAA,EAAWnB,OAAA,CAAQmB,SAAS;IAC5BC,GAAA,EAAK,yBAAyBrB,uBAAA;EAChC;EAGF,oBACEiB,IAAA,CAACrB,qBAAA;IACCE,SAAA,EAAWA,SAAA;IACXC,OAAA,EAASA,OAAA;IACTC,uBAAA,EAAyBA,uBAAA;IACzBc,IAAA,EAAME;;AAGZ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAncestorPath.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Drawer/fetchAncestorPath.ts"],"names":[],"mappings":"AAGA,KAAK,qBAAqB,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAID;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,GAAG,EACH,cAAc,EACd,MAAM,EACN,eAAe,EACf,SAAS,GACV,EAAE,qBAAqB,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CA+CtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAncestorPath.js","names":["formatAdminURL","qs","MAX_HIERARCHY_DEPTH","fetchAncestorPath","api","collectionSlug","itemId","parentFieldName","serverURL","queryString","stringify","depth","limit","select","where","id","equals","addQueryPrefix","url","apiRoute","path","response","fetch","credentials","ok","data","json","doc","docs","current","undefined","parentId","unshift"],"sources":["../../../../src/elements/Hierarchy/Drawer/fetchAncestorPath.ts"],"sourcesContent":["import { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\n\ntype FetchAncestorPathArgs = {\n api: string\n collectionSlug: string\n itemId: number | string\n parentFieldName: string\n serverURL: string\n}\n\nconst MAX_HIERARCHY_DEPTH = 20\n\n/**\n * Fetches the ancestor path for an item using a single API call with depth.\n * Returns array of ancestor IDs from root to item's parent.\n * Example: item at level 3 returns [grandparentId, parentId]\n */\nexport async function fetchAncestorPath({\n api,\n collectionSlug,\n itemId,\n parentFieldName,\n serverURL,\n}: FetchAncestorPathArgs): Promise<(number | string)[]> {\n const queryString = qs.stringify(\n {\n depth: MAX_HIERARCHY_DEPTH,\n limit: 1,\n select: { [parentFieldName]: true },\n where: { id: { equals: itemId } },\n },\n { addQueryPrefix: true },\n )\n\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n serverURL,\n })\n\n const response = await fetch(url, { credentials: 'include' })\n\n if (!response.ok) {\n return []\n }\n\n const data = await response.json()\n const doc = data.docs?.[0]\n\n if (!doc) {\n return []\n }\n\n // Walk the nested parent chain to build path from root to immediate parent\n const path: (number | string)[] = []\n let current = doc[parentFieldName]\n\n while (current !== null && current !== undefined) {\n // Parent could be an ID (number/string) or a populated object\n const parentId = typeof current === 'object' ? current.id : current\n\n if (parentId !== null && parentId !== undefined) {\n path.unshift(parentId)\n }\n\n // Move to next parent (only if current is populated object)\n current = typeof current === 'object' ? current[parentFieldName] : null\n }\n\n return path\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AAUpB,MAAMC,mBAAA,GAAsB;AAE5B;;;;;AAKA,OAAO,eAAeC,k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ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { HierarchyColumnBrowserRef } from '
|
|
3
|
-
import type { HierarchyDrawerInternalProps } from '
|
|
2
|
+
import type { HierarchyColumnBrowserRef } from '../ColumnBrowser/index.js';
|
|
3
|
+
import type { HierarchyDrawerInternalProps } from './types.js';
|
|
4
4
|
import './index.scss';
|
|
5
5
|
export declare const baseClass = "hierarchy-drawer";
|
|
6
6
|
type HierarchyDrawerContentProps = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Drawer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,KAAK,EAAE,4BAA4B,EAAqB,MAAM,YAAY,CAAA;AAWjF,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,SAAS,qBAAqB,CAAA;AAE3C,KAAK,2BAA2B,GAAG;IACjC,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;IACpE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACrE,GAAG,4BAA4B,CAAA;AAEhC,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,sBAAsB,oOAiBhC;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;CAAE,GAAG,2BAA2B,sBAwL3F,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,CA2FlE,CAAA"}
|
|
@@ -10,8 +10,8 @@ import { useTranslation } from '../../../providers/Translation/index.js';
|
|
|
10
10
|
import { useDocumentDrawer } from '../../DocumentDrawer/index.js';
|
|
11
11
|
import { Drawer, DrawerDepthProvider } from '../../Drawer/index.js';
|
|
12
12
|
import { DrawerActionHeader } from '../../DrawerActionHeader/index.js';
|
|
13
|
-
import { HierarchyColumnBrowser } from '
|
|
14
|
-
import { fetchAncestorPath } from '
|
|
13
|
+
import { HierarchyColumnBrowser } from '../ColumnBrowser/index.js';
|
|
14
|
+
import { fetchAncestorPath } from './fetchAncestorPath.js';
|
|
15
15
|
import './index.scss';
|
|
16
16
|
export const baseClass = 'hierarchy-drawer';
|
|
17
17
|
export const HierarchyDrawerContent = function HierarchyDrawerContent({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","React","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","useEffectEvent","TagIcon","useConfig","useTranslation","useDocumentDrawer","Drawer","DrawerDepthProvider","DrawerActionHeader","HierarchyColumnBrowser","fetchAncestorPath","baseClass","HierarchyDrawerContent","baseFilter","closeDrawer","columnBrowserRef","disabledIds","filterByCollection","hasMany","hierarchyCollectionSlug","Icon","initialSelections","onCreateNew","onMoveToRoot","onSave","parentFieldName","ref","showMoveToRoot","useAsTitle","i18n","t","config","routes","api","serverURL","getEntityConfig","collectionConfig","collectionSlug","collectionLabel","labels","plural","parentFieldName_internal","hierarchy","initialExpandedPath","setInitialExpandedPath","isLoadingPath","setIsLoadingPath","Boolean","length","hasLoadedPathRef","firstSelection","loadAncestorPath","itemId","path","current","selections","setSelections","map","Map","id","set","selectedIds","Set","keys","ancestorsWithSelections","handleCancel","handleSave","handleSelect","prev","next","has","delete","clear","handleClearAll","selectItem","selectionCount","size","_jsxs","className","_jsx","onCancel","saveLabel","title","label","color","onClick","type","_Fragment","onSelect","HierarchyDrawer","props","drawerSlug","createParentId","setCreateParentId","drawerContentRef","documentDrawerKey","setDocumentDrawerKey","documentDrawerSlug","DocumentDrawer","closeDocumentDrawer","openDrawer","openDocumentDrawer","handleCreateNew","parentId","setTimeout","handleDocumentSave","doc","undefined","refreshColumn","drawerContent","gutter","Header","slug","initialData"],"sources":["../../../../src/elements/Hierarchy/Drawer/index.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport type { HierarchyColumnBrowserRef } from '../ColumnBrowser/index.js'\nimport type { HierarchyDrawerInternalProps, SelectionWithPath } from './types.js'\n\nimport { useEffectEvent } from '../../../hooks/useEffectEvent.js'\nimport { TagIcon } from '../../../icons/Tag/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { useDocumentDrawer } from '../../DocumentDrawer/index.js'\nimport { Drawer, DrawerDepthProvider } from '../../Drawer/index.js'\nimport { DrawerActionHeader } from '../../DrawerActionHeader/index.js'\nimport { HierarchyColumnBrowser } from '../ColumnBrowser/index.js'\nimport { fetchAncestorPath } from './fetchAncestorPath.js'\nimport './index.scss'\n\nexport const baseClass = 'hierarchy-drawer'\n\ntype HierarchyDrawerContentProps = {\n columnBrowserRef?: React.RefObject<HierarchyColumnBrowserRef | null>\n onCreateNew?: (params: { parentId: null | number | string }) => void\n} & HierarchyDrawerInternalProps\n\nexport type HierarchyDrawerContentRef = {\n selectItem: (id: number | string) => void\n}\n\nexport const HierarchyDrawerContent = function HierarchyDrawerContent({\n baseFilter,\n closeDrawer,\n columnBrowserRef,\n disabledIds,\n filterByCollection,\n hasMany = false,\n hierarchyCollectionSlug,\n Icon,\n initialSelections,\n onCreateNew,\n onMoveToRoot,\n onSave,\n parentFieldName,\n ref,\n showMoveToRoot,\n useAsTitle,\n}: { ref?: React.RefObject<HierarchyDrawerContentRef | null> } & HierarchyDrawerContentProps) {\n const { i18n, t } = useTranslation()\n // NOTE: Do NOT use useModal() here - it causes re-renders when any modal state changes\n // Use closeDrawer prop instead which already handles closing the modal\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchyCollectionSlug })\n const collectionLabel = collectionConfig\n ? getTranslation(collectionConfig.labels?.plural || hierarchyCollectionSlug, i18n)\n : hierarchyCollectionSlug\n\n const parentFieldName_internal =\n collectionConfig?.hierarchy && typeof collectionConfig.hierarchy === 'object'\n ? collectionConfig.hierarchy.parentFieldName\n : parentFieldName\n\n const [initialExpandedPath, setInitialExpandedPath] = useState<(number | string)[] | undefined>()\n const [isLoadingPath, setIsLoadingPath] = useState(Boolean(initialSelections?.length))\n const hasLoadedPathRef = React.useRef(false)\n const firstSelection = initialSelections?.[0]\n\n const loadAncestorPath = useEffectEvent(async (itemId?: number | string) => {\n if (!itemId) {\n setIsLoadingPath(false)\n return\n }\n\n try {\n const path = await fetchAncestorPath({\n api,\n collectionSlug: hierarchyCollectionSlug,\n itemId,\n parentFieldName: parentFieldName_internal,\n serverURL,\n })\n setInitialExpandedPath(path)\n } catch {\n // Silently handle fetch errors - will just start at root\n } finally {\n setIsLoadingPath(false)\n }\n })\n\n // Load ancestor path on mount\n useEffect(() => {\n if (hasLoadedPathRef.current) {\n return\n }\n hasLoadedPathRef.current = true\n void loadAncestorPath(firstSelection)\n }, [firstSelection])\n\n const [selections, setSelections] = useState<Map<number | string, SelectionWithPath>>(() => {\n const map = new Map<number | string, SelectionWithPath>()\n\n if (initialSelections) {\n for (const id of initialSelections) {\n map.set(id, { id, path: [] })\n }\n }\n\n return map\n })\n\n const selectedIds = useMemo(() => new Set(selections.keys()), [selections])\n\n // For now, ancestorsWithSelections is empty - will be computed when we have path tracking\n const ancestorsWithSelections = useMemo(() => new Set<number | string>(), [])\n\n const handleCancel = useCallback(() => {\n closeDrawer()\n }, [closeDrawer])\n\n const handleSave = useCallback(() => {\n onSave({ closeDrawer, selections })\n }, [onSave, selections, closeDrawer])\n\n const handleSelect = useCallback(\n ({\n id,\n path,\n }: {\n id: number | string\n path: Array<{ id: number | string; title: string }>\n }) => {\n setSelections((prev) => {\n const next = new Map(prev)\n\n if (next.has(id)) {\n next.delete(id)\n } else {\n if (!hasMany) {\n // Single select: clear previous selections\n next.clear()\n }\n next.set(id, { id, path })\n }\n\n return next\n })\n },\n [hasMany],\n )\n\n const handleClearAll = useCallback(() => {\n setSelections(new Map())\n }, [])\n\n // Expose selectItem for programmatic selection (e.g., after creating a new item)\n useImperativeHandle(\n ref,\n () => ({\n selectItem: (id: number | string) => {\n setSelections((prev) => {\n const next = new Map(prev)\n if (!hasMany) {\n next.clear()\n }\n // Path will be empty for newly created items - could be enhanced later\n next.set(id, { id, path: [] })\n return next\n })\n },\n }),\n [hasMany],\n )\n\n const selectionCount = selections.size\n\n return (\n <div className={`${baseClass}__content`}>\n <DrawerActionHeader\n onCancel={handleCancel}\n onSave={handleSave}\n saveLabel={t('general:select')}\n title={t('general:selectValue', { label: collectionLabel })}\n />\n <div className={`${baseClass}__subheader`}>\n <div className={`${baseClass}__subheader-left`}>\n {Icon || <TagIcon color=\"muted\" />}\n <h4>{collectionLabel}</h4>\n </div>\n <div className={`${baseClass}__subheader-right`}>\n {showMoveToRoot && onMoveToRoot && (\n <button className={`${baseClass}__move-to-root`} onClick={onMoveToRoot} type=\"button\">\n {t('hierarchy:moveToRoot')}\n </button>\n )}\n {selectionCount > 0 && (\n <>\n <span className={`${baseClass}__selection-info`}>{selectionCount} selected</span>\n <span>—</span>\n <button className={`${baseClass}__clear-all`} onClick={handleClearAll} type=\"button\">\n {t('general:clearAll')}\n </button>\n </>\n )}\n </div>\n </div>\n <div className={`${baseClass}__columns`}>\n <HierarchyColumnBrowser\n ancestorsWithSelections={ancestorsWithSelections}\n baseFilter={baseFilter}\n disabledIds={disabledIds}\n filterByCollection={filterByCollection}\n hierarchyCollectionSlug={hierarchyCollectionSlug}\n initialExpandedPath={initialExpandedPath}\n isLoadingPath={isLoadingPath}\n onCreateNew={onCreateNew}\n onSelect={handleSelect}\n parentFieldName={parentFieldName}\n ref={columnBrowserRef}\n selectedIds={selectedIds}\n useAsTitle={useAsTitle}\n />\n </div>\n </div>\n )\n}\n\nexport const HierarchyDrawer: React.FC<HierarchyDrawerInternalProps> = (props) => {\n const { drawerSlug, hierarchyCollectionSlug, parentFieldName } = props\n\n // Get parentFieldName from hierarchy config\n const { getEntityConfig } = useConfig()\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchyCollectionSlug })\n const parentFieldName_internal =\n collectionConfig?.hierarchy && typeof collectionConfig.hierarchy === 'object'\n ? collectionConfig.hierarchy.parentFieldName\n : parentFieldName\n\n // Track which parentId is being used for the document drawer - use state to trigger re-render\n const [createParentId, setCreateParentId] = useState<null | number | string>(null)\n\n // Ref to access column browser's refresh function\n const columnBrowserRef = useRef<HierarchyColumnBrowserRef | null>(null)\n\n // Ref to access drawer content's selectItem function\n const drawerContentRef = useRef<HierarchyDrawerContentRef | null>(null)\n\n // Key for DocumentDrawer to force remount when parentId changes\n const [documentDrawerKey, setDocumentDrawerKey] = useState(0)\n\n // Stable drawer slug for the document drawer - must not change on remount\n const documentDrawerSlug = `${drawerSlug}-create-doc`\n\n // Document drawer for creating new items - rendered OUTSIDE the Drawer to avoid nested modal issues\n const [DocumentDrawer, , { closeDrawer: closeDocumentDrawer, openDrawer: openDocumentDrawer }] =\n useDocumentDrawer({\n collectionSlug: hierarchyCollectionSlug,\n drawerSlug: documentDrawerSlug,\n })\n\n const handleCreateNew = useCallback(\n ({ parentId }: { parentId: null | number | string }) => {\n // Increment key to force DocumentDrawer remount with new initialData\n setDocumentDrawerKey((prev) => prev + 1)\n setCreateParentId(parentId)\n // Use setTimeout to ensure state update triggers re-render before opening drawer\n setTimeout(() => {\n openDocumentDrawer()\n }, 0)\n },\n [openDocumentDrawer],\n )\n\n // Refresh the column, select the new item, and close the document drawer after creation\n const handleDocumentSave = useCallback<\n NonNullable<React.ComponentProps<typeof DocumentDrawer>['onSave']>\n >(\n ({ doc }) => {\n if (columnBrowserRef.current && createParentId !== undefined) {\n void columnBrowserRef.current.refreshColumn(createParentId)\n }\n if (drawerContentRef.current && doc?.id) {\n drawerContentRef.current.selectItem(doc.id)\n }\n closeDocumentDrawer()\n },\n [closeDocumentDrawer, createParentId],\n )\n\n // Memoize the content - only depends on stable values\n const drawerContent = useMemo(\n () => (\n <HierarchyDrawerContent\n {...props}\n columnBrowserRef={columnBrowserRef}\n onCreateNew={handleCreateNew}\n ref={drawerContentRef}\n />\n ),\n [handleCreateNew, props],\n )\n\n return (\n <>\n <Drawer className={baseClass} gutter={false} Header={null} slug={drawerSlug}>\n {drawerContent}\n </Drawer>\n <DrawerDepthProvider>\n <DocumentDrawer\n initialData={\n createParentId !== null ? { [parentFieldName_internal]: createParentId } : undefined\n }\n key={documentDrawerKey}\n onSave={handleDocumentSave}\n />\n </DrawerDepthProvider>\n </>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IACLC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH;AAKP,SAASC,cAAc,QAAQ;AAC/B,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,MAAM,EAAEC,mBAAmB,QAAQ;AAC5C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,iBAAiB,QAAQ;AAClC,OAAO;AAEP,OAAO,MAAMC,SAAA,GAAY;AAWzB,OAAO,MAAMC,sBAAA,GAAyB,SAASA,uBAAuB;EACpEC,UAAU;EACVC,WAAW;EACXC,gBAAgB;EAChBC,WAAW;EACXC,kBAAkB;EAClBC,OAAA,GAAU,KAAK;EACfC,uBAAuB;EACvBC,IAAI;EAC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CAACoB,UAAU,CAACgC,GAAA,CAAI/C,EAAE;IAC5C;IACAwC,mBAAA;EACF,GACA,CAACA,mBAAA,EAAqBP,cAAA,CAAe;EAGvC;EACA,MAAMiB,aAAA,GAAgB/G,OAAA,CACpB,mBACEiF,IAAA,CAACnE,sBAAA;IACE,GAAG8E,KAAK;IACT3E,gBAAA,EAAkBA,gBAAA;IAClBO,WAAA,EAAagF,eAAA;IACb5E,GAAA,EAAKoE;MAGT,CAACQ,eAAA,EAAiBZ,KAAA,CAAM;EAG1B,oBACEb,KAAA,CAAAU,SAAA;4BACER,IAAA,CAACzE,MAAA;MAAOwE,SAAA,EAAWnE,SAAA;MAAWmG,MAAA,EAAQ;MAAOC,MAAA,EAAQ;MAAMC,IAAA,EAAMrB,UAAA;gBAC9DkB;qBAEH9B,IAAA,CAACxE,mBAAA;gBACC,aAAAwE,IAAA,CAACmB,cAAA;QACCe,WAAA,EACErB,cAAA,KAAmB,OAAO;UAAE,CAACnD,wBAAA,GAA2BmD;QAAe,IAAIe,SAAA;QAG7EnF,MAAA,EAAQiF;SADHV,iBAAA;;;AAMf","ignoreList":[]}
|
|
@@ -64,5 +64,5 @@ export type UseHierarchyDrawer = (args: UseHierarchyDrawerArgs) => [
|
|
|
64
64
|
toggleDrawer: () => void;
|
|
65
65
|
}
|
|
66
66
|
];
|
|
67
|
-
export type { ColumnItemData } from '../
|
|
67
|
+
export type { ColumnItemData } from '../ColumnBrowser/types.js';
|
|
68
68
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Drawer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAE3C,MAAM,MAAM,iBAAiB,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Q,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;IACtC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAA;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC/B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B,GAAG,oBAAoB,CAAA;AAExB,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAA;AAErC,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,sBAAsB,KAAK;IACjE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAAC;IAC9B,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC;IACzD;QACE,WAAW,EAAE,MAAM,IAAI,CAAA;QACvB,WAAW,EAAE,MAAM,CAAA;QACnB,UAAU,EAAE,MAAM,CAAA;QAClB,YAAY,EAAE,OAAO,CAAA;QACrB,UAAU,EAAE,MAAM,IAAI,CAAA;QACtB,YAAY,EAAE,MAAM,IAAI,CAAA;KACzB;CACF,CAAA;AAGD,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/elements/Hierarchy/Drawer/types.ts"],"sourcesContent":["import type { Where } from 'payload'\nimport type React from 'react'\nimport type { HTMLAttributes } from 'react'\n\nexport type SelectionWithPath = {\n id: number | string\n path: Array<{ id: number | string; title: string }>\n}\n\nexport type UseHierarchyDrawerArgs = {\n /** IDs that should be disabled (e.g., items being moved can't be selected as destination) */\n disabledIds?: Set<number | string>\n /**\n * When provided, filters hierarchy items to only show those that accept these collections.\n * Used with collectionSpecific hierarchy config.\n */\n filterByCollection?: string[]\n hierarchyCollectionSlug: string\n Icon?: React.ReactNode\n}\n\nexport type HierarchyDrawerProps = {\n readonly hasMany?: boolean\n readonly initialSelections?: (number | string)[]\n readonly onMoveToRoot?: () => void\n readonly onSave: (params: {\n closeDrawer: () => void\n selections: Map<number | string, SelectionWithPath>\n }) => void\n readonly showMoveToRoot?: boolean\n}\n\nexport type HierarchyDrawerInternalProps = {\n /** Base filter constraint (e.g., tenant filter) to apply to all queries */\n readonly baseFilter?: null | Where\n readonly closeDrawer: () => void\n /** IDs that should be disabled (e.g., items being moved can't be selected as destination) */\n readonly disabledIds?: Set<number | string>\n readonly drawerSlug: string\n /**\n * When provided, filters hierarchy items to only show those that accept these collections.\n * Used with collectionSpecific hierarchy config.\n */\n readonly filterByCollection?: string[]\n readonly hierarchyCollectionSlug: string\n readonly Icon?: React.ReactNode\n readonly parentFieldName: string\n readonly useAsTitle?: string\n} & HierarchyDrawerProps\n\nexport type HierarchyDrawerTogglerProps = {\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n drawerSlug?: string\n} & HTMLAttributes<HTMLButtonElement>\n\nexport type UseHierarchyDrawer = (args: UseHierarchyDrawerArgs) => [\n React.FC<HierarchyDrawerProps>,\n React.FC<Omit<HierarchyDrawerTogglerProps, 'drawerSlug'>>,\n {\n closeDrawer: () => void\n drawerDepth: number\n drawerSlug: string\n isDrawerOpen: boolean\n openDrawer: () => void\n toggleDrawer: () => void\n },\n]\n\n// Re-export column browser types for backwards compatibility\nexport type { ColumnItemData } from '../ColumnBrowser/types.js'\n"],"mappings":"AAsEA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHierarchyDrawer.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Drawer/useHierarchyDrawer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8C,MAAM,OAAO,CAAA;AAElE,OAAO,KAAK,EAEV,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAEnB,cAAc,YAAY,CAAA;AAQ1B,eAAO,MAAM,yBAAyB,qBAGnC;IACD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb,KAAG,MAA6C,CAAA;AAEjD,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAmBxE,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAiHhC,CAAA"}
|
|
@@ -5,11 +5,11 @@ import { createElement as _createElement } from "react";
|
|
|
5
5
|
import { useModal } from '@faceless-ui/modal';
|
|
6
6
|
import React, { useCallback, useId, useMemo, useRef } from 'react';
|
|
7
7
|
export * from './types.js';
|
|
8
|
-
import { useConfig } from '
|
|
9
|
-
import { useEditDepth } from '
|
|
10
|
-
import { useHierarchy } from '
|
|
11
|
-
import { DrawerToggler } from '
|
|
12
|
-
import { baseClass, HierarchyDrawer } from './
|
|
8
|
+
import { useConfig } from '../../../providers/Config/index.js';
|
|
9
|
+
import { useEditDepth } from '../../../providers/EditDepth/index.js';
|
|
10
|
+
import { useHierarchy } from '../../../providers/Hierarchy/index.js';
|
|
11
|
+
import { DrawerToggler } from '../../Drawer/index.js';
|
|
12
|
+
import { baseClass, HierarchyDrawer } from './index.js';
|
|
13
13
|
export const formatHierarchyDrawerSlug = ({
|
|
14
14
|
depth,
|
|
15
15
|
uuid
|
|
@@ -145,4 +145,4 @@ export const useHierarchyDrawer = ({
|
|
|
145
145
|
}), [drawerDepth, drawerSlug, toggleDrawer, closeDrawer, openDrawer]);
|
|
146
146
|
return [MemoizedDrawer, MemoizedDrawerToggler, MemoizedDrawerState];
|
|
147
147
|
};
|
|
148
|
-
//# sourceMappingURL=
|
|
148
|
+
//# sourceMappingURL=useHierarchyDrawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHierarchyDrawer.js","names":["useModal","React","useCallback","useId","useMemo","useRef","useConfig","useEditDepth","useHierarchy","DrawerToggler","baseClass","HierarchyDrawer","formatHierarchyDrawerSlug","depth","uuid","HierarchyDrawerToggler","children","className","disabled","drawerSlug","onClick","rest","_jsx","filter","Boolean","join","slug","useHierarchyDrawer","disabledIds","filterByCollection","filterByCollectionProp","hierarchyCollectionSlug","Icon","getEntityConfig","allowedCollections","baseFilter","collectionConfig","collectionSlug","useAsTitle","admin","hierarchyConfig","hierarchy","undefined","parentFieldName","map","c","drawerDepth","closeModal","openModal","toggleModal","closeModalRef","openModalRef","toggleModalRef","current","toggleDrawer","closeDrawer","openDrawer","MemoizedDrawer","DrawerComponent","props","_createElement","key","MemoizedDrawerToggler","TogglerComponent","MemoizedDrawerState","isDrawerOpen"],"sources":["../../../../src/elements/Hierarchy/Drawer/useHierarchyDrawer.tsx"],"sourcesContent":["'use client'\nimport { useModal } from '@faceless-ui/modal'\nimport React, { useCallback, useId, useMemo, useRef } from 'react'\n\nimport type {\n HierarchyDrawerProps,\n HierarchyDrawerTogglerProps,\n UseHierarchyDrawer,\n} from './types.js'\n\nexport * from './types.js'\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useEditDepth } from '../../../providers/EditDepth/index.js'\nimport { useHierarchy } from '../../../providers/Hierarchy/index.js'\nimport { DrawerToggler } from '../../Drawer/index.js'\nimport { baseClass, HierarchyDrawer } from './index.js'\n\nexport const formatHierarchyDrawerSlug = ({\n depth,\n uuid,\n}: {\n depth: number\n uuid: string\n}): string => `hierarchy-drawer_${depth}_${uuid}`\n\nexport const HierarchyDrawerToggler: React.FC<HierarchyDrawerTogglerProps> = ({\n children,\n className,\n disabled,\n drawerSlug,\n onClick,\n ...rest\n}) => {\n return (\n <DrawerToggler\n className={[className, `${baseClass}__toggler`].filter(Boolean).join(' ')}\n disabled={disabled}\n onClick={onClick}\n slug={drawerSlug}\n {...rest}\n >\n {children}\n </DrawerToggler>\n )\n}\n\n/**\n * Hook for using a hierarchy drawer for selecting hierarchy items.\n *\n * @example\n * ```tsx\n * const [HierarchyDrawer, HierarchyDrawerToggler, { closeDrawer, openDrawer }] = useHierarchyDrawer({\n * collectionSlug: 'categories',\n * })\n *\n * return (\n * <>\n * <HierarchyDrawer\n * onSave={(selections) => console.log(selections)}\n * hasMany={true}\n * />\n * <HierarchyDrawerToggler>Select Categories</HierarchyDrawerToggler>\n * </>\n * )\n * ```\n */\nexport const useHierarchyDrawer: UseHierarchyDrawer = ({\n disabledIds,\n filterByCollection: filterByCollectionProp,\n hierarchyCollectionSlug,\n Icon,\n}) => {\n const { getEntityConfig } = useConfig()\n const { allowedCollections, baseFilter } = useHierarchy()\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchyCollectionSlug })\n\n const useAsTitle = collectionConfig?.admin?.useAsTitle\n const hierarchyConfig =\n collectionConfig?.hierarchy && typeof collectionConfig.hierarchy === 'object'\n ? collectionConfig.hierarchy\n : undefined\n const parentFieldName = hierarchyConfig?.parentFieldName\n\n // Use explicit prop if provided, otherwise fall back to allowedCollections from context\n // - allowedCollections is null/undefined: no filtering (undefined)\n // - allowedCollections is []: folder accepts everything, show only unrestricted destinations ([])\n // - allowedCollections has values: show folders accepting those types\n // Memoize to prevent new array references on every render\n const filterByCollection = useMemo(() => {\n if (filterByCollectionProp !== undefined) {\n return filterByCollectionProp\n }\n return allowedCollections !== null ? allowedCollections.map((c) => c.slug) : undefined\n }, [filterByCollectionProp, allowedCollections])\n\n const drawerDepth = useEditDepth()\n const uuid = useId()\n const { closeModal, openModal, toggleModal } = useModal()\n\n const drawerSlug = formatHierarchyDrawerSlug({\n depth: drawerDepth,\n uuid,\n })\n\n // Store modal functions in refs to ensure stable callbacks\n // This prevents re-renders when other modals (like DocumentDrawer) change state\n const closeModalRef = useRef(closeModal)\n const openModalRef = useRef(openModal)\n const toggleModalRef = useRef(toggleModal)\n closeModalRef.current = closeModal\n openModalRef.current = openModal\n toggleModalRef.current = toggleModal\n\n // Stable callbacks using refs - these will NEVER change\n const toggleDrawer = useCallback(() => {\n toggleModalRef.current(drawerSlug)\n }, [drawerSlug])\n\n const closeDrawer = useCallback(() => {\n closeModalRef.current(drawerSlug)\n }, [drawerSlug])\n\n const openDrawer = useCallback(() => {\n openModalRef.current(drawerSlug)\n }, [drawerSlug])\n\n const MemoizedDrawer = useMemo(() => {\n const DrawerComponent: React.FC<HierarchyDrawerProps> = (props) => (\n <HierarchyDrawer\n {...props}\n baseFilter={baseFilter}\n closeDrawer={closeDrawer}\n disabledIds={disabledIds}\n drawerSlug={drawerSlug}\n filterByCollection={filterByCollection}\n hierarchyCollectionSlug={hierarchyCollectionSlug}\n Icon={Icon}\n key={drawerSlug}\n parentFieldName={parentFieldName}\n useAsTitle={useAsTitle}\n />\n )\n\n return DrawerComponent\n }, [\n baseFilter,\n drawerSlug,\n closeDrawer,\n disabledIds,\n filterByCollection,\n Icon,\n parentFieldName,\n hierarchyCollectionSlug,\n useAsTitle,\n ])\n\n const MemoizedDrawerToggler = useMemo(() => {\n const TogglerComponent: React.FC<Omit<HierarchyDrawerTogglerProps, 'drawerSlug'>> = (props) => (\n <HierarchyDrawerToggler {...props} drawerSlug={drawerSlug} />\n )\n\n return TogglerComponent\n }, [drawerSlug])\n\n const MemoizedDrawerState = useMemo(\n () => ({\n closeDrawer,\n drawerDepth,\n drawerSlug,\n // Note: Not tracking isDrawerOpen to prevent re-renders when other modals change state\n // Consumers needing this can use useModal() directly\n isDrawerOpen: false,\n openDrawer,\n toggleDrawer,\n }),\n [drawerDepth, drawerSlug, toggleDrawer, closeDrawer, openDrawer],\n )\n\n return [MemoizedDrawer, MemoizedDrawerToggler, MemoizedDrawerState]\n}\n"],"mappings":"AAAA;;;;AACA,SAASA,QAAQ,QAAQ;AACzB,OAAOC,KAAA,IAASC,WAAW,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,QAA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AACjD,eAAA;MACE,GAAGgD,KAAK;MACTxB,UAAA,EAAYA,UAAA;MACZoB,WAAA,EAAaA,WAAA;MACb3B,WAAA,EAAaA,WAAA;MACbT,UAAA,EAAYA,UAAA;MACZU,kBAAA,EAAoBA,kBAAA;MACpBE,uBAAA,EAAyBA,uBAAA;MACzBC,IAAA,EAAMA,IAAA;MACN6B,GAAA,EAAK1C,UAAA;MACLwB,eAAA,EAAiBA,eAAA;MACjBL,UAAA,EAAYA;;IAIhB,OAAOoB,eAAA;EACT,GAAG,CACDvB,UAAA,EACAhB,UAAA,EACAoC,WAAA,EACA3B,WAAA,EACAC,kBAAA,EACAG,IAAA,EACAW,eAAA,EACAZ,uBAAA,EACAO,UAAA,CACD;EAED,MAAMwB,qBAAA,GAAwB1D,OAAA,CAAQ;IACpC,MAAM2D,gBAAA,GAA+EJ,OAAA,iBACnFrC,IAAA,CAACP,sBAAA;MAAwB,GAAG4C,OAAK;MAAExC,UAAA,EAAYA;;IAGjD,OAAO4C,gBAAA;EACT,GAAG,CAAC5C,UAAA,CAAW;EAEf,MAAM6C,mBAAA,GAAsB5D,OAAA,CAC1B,OAAO;IACLmD,WAAA;IACAT,WAAA;IACA3B,UAAA;IACA;IACA;IACA8C,YAAA,EAAc;IACdT,UAAA;IACAF;EACF,IACA,CAACR,WAAA,EAAa3B,UAAA,EAAYmC,YAAA,EAAcC,WAAA,EAAaC,UAAA,CAAW;EAGlE,OAAO,CAACC,cAAA,EAAgBK,qBAAA,EAAuBE,mBAAA,CAAoB;AACrE","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectedHierarchies.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/SelectedHierarchies.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA+C,MAAM,OAAO,CAAA;AAOnE,OAAO,4BAA4B,CAAA;AASnC,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA8HlE,CAAA"}
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { getTranslation } from '@payloadcms/translations';
|
|
6
5
|
import { formatAdminURL } from 'payload/shared';
|
|
7
6
|
import * as qs from 'qs-esm';
|
|
8
7
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
9
|
-
import { XIcon } from '
|
|
10
|
-
import { useConfig } from '
|
|
11
|
-
import { useTranslation } from '
|
|
12
|
-
import { Pill } from '
|
|
13
|
-
import { Spinner } from '
|
|
8
|
+
import { XIcon } from '../../../icons/X/index.js';
|
|
9
|
+
import { useConfig } from '../../../providers/Config/index.js';
|
|
10
|
+
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
11
|
+
import { Pill } from '../../Pill/index.js';
|
|
12
|
+
import { Spinner } from '../../Spinner/index.js';
|
|
14
13
|
import './SelectedHierarchies.scss';
|
|
15
14
|
const baseClass = 'selected-hierarchies';
|
|
16
15
|
export const SelectedHierarchies = ({
|
|
@@ -25,8 +24,7 @@ export const SelectedHierarchies = ({
|
|
|
25
24
|
getEntityConfig
|
|
26
25
|
} = useConfig();
|
|
27
26
|
const {
|
|
28
|
-
i18n
|
|
29
|
-
t
|
|
27
|
+
i18n
|
|
30
28
|
} = useTranslation();
|
|
31
29
|
const [items, setItems] = useState([]);
|
|
32
30
|
const [isInitialLoad, setIsInitialLoad] = useState(true);
|
|
@@ -110,14 +108,7 @@ export const SelectedHierarchies = ({
|
|
|
110
108
|
});
|
|
111
109
|
}
|
|
112
110
|
if (items.length === 0) {
|
|
113
|
-
|
|
114
|
-
const translatedLabel = label ? getTranslation(label, i18n) : hierarchySlug;
|
|
115
|
-
return /*#__PURE__*/_jsx("div", {
|
|
116
|
-
className: `${baseClass}__empty`,
|
|
117
|
-
children: t('general:noLabel', {
|
|
118
|
-
label: translatedLabel
|
|
119
|
-
})
|
|
120
|
-
});
|
|
111
|
+
return null;
|
|
121
112
|
}
|
|
122
113
|
return /*#__PURE__*/_jsx("div", {
|
|
123
114
|
className: baseClass,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectedHierarchies.js","names":["c","_c","formatAdminURL","qs","React","useEffect","useMemo","useRef","useState","XIcon","useConfig","useTranslation","Pill","Spinner","baseClass","SelectedHierarchies","hierarchySlug","Icon","onRemove","readOnly","selectedIds","config","getEntityConfig","i18n","items","setItems","isInitialLoad","setIsInitialLoad","prevSelectedIdsRef","routes","api","serverURL","collectionConfig","collectionSlug","selectedIdsKey","slice","sort","join","length","current","fetchItems","useAsTitle","admin","query","depth","limit","select","where","id","in","queryString","stringify","url","apiRoute","path","response","fetch","credentials","headers","language","ok","data","json","fetchedItems","docs","map","doc","docId","titleValue","title","String","orderedItems","find","item","filter","undefined","_jsx","className","size","SelectedPill","t0","$","t","t1","e","preventDefault","stopPropagation","handleRemove","t2","_jsxs","pillStyle","children","Boolean","disabled","onClick","type"],"sources":["../../../../src/elements/Hierarchy/Field/SelectedHierarchies.tsx"],"sourcesContent":["'use client'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useEffect, useMemo, useRef, useState } from 'react'\n\nimport { XIcon } from '../../../icons/X/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Pill } from '../../Pill/index.js'\nimport { Spinner } from '../../Spinner/index.js'\nimport './SelectedHierarchies.scss'\n\nconst baseClass = 'selected-hierarchies'\n\ntype HierarchyItem = {\n id: number | string\n title: string\n}\n\nexport type SelectedHierarchiesProps = {\n hierarchySlug: string\n Icon?: React.ReactNode\n onRemove: ({ id }: { id: number | string }) => void\n readOnly?: boolean\n selectedIds: (number | string)[]\n}\n\nexport const SelectedHierarchies: React.FC<SelectedHierarchiesProps> = ({\n hierarchySlug,\n Icon,\n onRemove,\n readOnly = false,\n selectedIds,\n}) => {\n const { config, getEntityConfig } = useConfig()\n const { i18n } = useTranslation()\n const [items, setItems] = useState<HierarchyItem[]>([])\n const [isInitialLoad, setIsInitialLoad] = useState(true)\n\n const prevSelectedIdsRef = useRef<string>('')\n\n const {\n routes: { api },\n serverURL,\n } = config\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchySlug })\n\n const selectedIdsKey = useMemo(() => selectedIds.slice().sort().join(','), [selectedIds])\n\n useEffect(() => {\n if (!selectedIds || selectedIds.length === 0) {\n setItems([])\n setIsInitialLoad(false)\n return\n }\n\n if (prevSelectedIdsRef.current === selectedIdsKey) {\n return\n }\n prevSelectedIdsRef.current = selectedIdsKey\n\n const fetchItems = async () => {\n const useAsTitle = collectionConfig?.admin?.useAsTitle || 'id'\n\n const query = {\n depth: 0,\n limit: selectedIds.length,\n select: {\n [useAsTitle]: true,\n },\n where: {\n id: {\n in: selectedIds,\n },\n },\n }\n\n const queryString = qs.stringify(query)\n\n try {\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${hierarchySlug}?${queryString}`,\n serverURL,\n })\n\n const response = await fetch(url, {\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n\n if (response.ok) {\n const data = await response.json()\n const fetchedItems: HierarchyItem[] = data.docs.map((doc: Record<string, unknown>) => {\n const docId = doc.id as number | string\n const titleValue = doc[useAsTitle] ?? docId\n const title =\n typeof titleValue === 'string' || typeof titleValue === 'number'\n ? String(titleValue)\n : String(docId)\n return {\n id: docId,\n title,\n }\n })\n\n // Order by selectedIds to preserve selection order\n const orderedItems = selectedIds\n .map((id) => fetchedItems.find((item) => item.id === id))\n .filter((item): item is HierarchyItem => item !== undefined)\n\n setItems(orderedItems)\n }\n } catch {\n // Silently fail - items will remain empty\n } finally {\n setIsInitialLoad(false)\n }\n }\n\n void fetchItems()\n }, [selectedIds, selectedIdsKey, hierarchySlug, collectionConfig, serverURL, api, i18n.language])\n\n if (isInitialLoad) {\n return (\n <div className={`${baseClass}__loading`}>\n <Spinner size=\"small\" />\n </div>\n )\n }\n\n if (items.length === 0) {\n return null\n }\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__pills`}>\n {items.map((item) => (\n <SelectedPill\n Icon={Icon}\n item={item}\n key={item.id}\n onRemove={onRemove}\n readOnly={readOnly}\n />\n ))}\n </div>\n </div>\n )\n}\n\ntype SelectedPillProps = {\n Icon?: React.ReactNode\n item: HierarchyItem\n onRemove: ({ id }: { id: number | string }) => void\n readOnly: boolean\n}\n\nconst SelectedPill: React.FC<SelectedPillProps> = ({ Icon, item, onRemove, readOnly }) => {\n const { t } = useTranslation()\n\n const handleRemove = (e: React.MouseEvent) => {\n e.preventDefault()\n e.stopPropagation()\n onRemove({ id: item.id })\n }\n\n return (\n <Pill className={`${baseClass}__pill`} pillStyle=\"light\" size=\"small\">\n {Boolean(Icon) && <span className={`${baseClass}__pill-icon`}>{Icon}</span>}\n <span className={`${baseClass}__pill-label`}>{item.title}</span>\n <button\n aria-label={t('general:remove')}\n className={`${baseClass}__pill-remove`}\n disabled={readOnly}\n onClick={readOnly ? undefined : handleRemove}\n type=\"button\"\n >\n <XIcon />\n </button>\n </Pill>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,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,CAAA;AAMrB,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB,GAAG,4BAA4B,CAAA;AAEhC,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CA2LpE,CAAA"}
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { getTranslation } from '@payloadcms/translations';
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
|
-
import { FieldDescription } from '
|
|
7
|
-
import { FieldError } from '
|
|
8
|
-
import { FieldLabel } from '
|
|
9
|
-
import { mergeFieldStyles } from '
|
|
10
|
-
import { fieldBaseClass } from '
|
|
11
|
-
import { useField } from '
|
|
12
|
-
import { useConfig } from '
|
|
13
|
-
import { useDocumentInfo } from '
|
|
14
|
-
import { useTranslation } from '
|
|
15
|
-
import { Button } from '
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
6
|
+
import { FieldDescription } from '../../../fields/FieldDescription/index.js';
|
|
7
|
+
import { FieldError } from '../../../fields/FieldError/index.js';
|
|
8
|
+
import { FieldLabel } from '../../../fields/FieldLabel/index.js';
|
|
9
|
+
import { mergeFieldStyles } from '../../../fields/mergeFieldStyles.js';
|
|
10
|
+
import { fieldBaseClass } from '../../../fields/shared/index.js';
|
|
11
|
+
import { useField } from '../../../forms/useField/index.js';
|
|
12
|
+
import { useConfig } from '../../../providers/Config/index.js';
|
|
13
|
+
import { useDocumentInfo } from '../../../providers/DocumentInfo/index.js';
|
|
14
|
+
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
15
|
+
import { Button } from '../../Button/index.js';
|
|
16
|
+
import { RenderCustomComponent } from '../../RenderCustomComponent/index.js';
|
|
17
|
+
import { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js';
|
|
18
18
|
import { SelectedHierarchies } from './SelectedHierarchies.js';
|
|
19
19
|
import './index.scss';
|
|
20
20
|
const baseClass = 'hierarchy-field';
|
|
@@ -135,18 +135,11 @@ export const HierarchyFieldClient = props => {
|
|
|
135
135
|
style: styles,
|
|
136
136
|
children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
137
137
|
CustomComponent: Label,
|
|
138
|
-
Fallback: /*#__PURE__*/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
path: path,
|
|
144
|
-
required: required,
|
|
145
|
-
unstyled: true
|
|
146
|
-
}), Boolean(Icon) && /*#__PURE__*/_jsx("span", {
|
|
147
|
-
className: `${baseClass}__label-icon`,
|
|
148
|
-
children: Icon
|
|
149
|
-
})]
|
|
138
|
+
Fallback: /*#__PURE__*/_jsx(FieldLabel, {
|
|
139
|
+
label: label,
|
|
140
|
+
localized: localized,
|
|
141
|
+
path: path,
|
|
142
|
+
required: required
|
|
150
143
|
})
|
|
151
144
|
}), /*#__PURE__*/_jsxs("div", {
|
|
152
145
|
className: `${fieldBaseClass}__wrap`,
|
|
@@ -163,11 +156,6 @@ export const HierarchyFieldClient = props => {
|
|
|
163
156
|
onRemove: handleRemove,
|
|
164
157
|
readOnly: readOnly || disabled,
|
|
165
158
|
selectedIds: selectedIds
|
|
166
|
-
}), hasMany && selectedIds.length === 0 && /*#__PURE__*/_jsx("span", {
|
|
167
|
-
className: `${baseClass}__placeholder`,
|
|
168
|
-
children: t('general:noLabel', {
|
|
169
|
-
label: hierarchyLabel
|
|
170
|
-
})
|
|
171
159
|
}), !readOnly && (hasMany || selectedIds.length === 0) && /*#__PURE__*/_jsx(Button, {
|
|
172
160
|
buttonStyle: "dashed",
|
|
173
161
|
className: `${baseClass}__manage-button`,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.client.js","names":["getTranslation","React","useCallback","useMemo","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","useField","useConfig","useDocumentInfo","useTranslation","Button","RenderCustomComponent","useHierarchyDrawer","SelectedHierarchies","baseClass","HierarchyFieldClient","props","field","admin","className","description","hasMany","label","localized","relationTo","relationToProp","required","Icon","path","pathFromProps","readOnly","validate","hierarchySlug","Array","isArray","getEntityConfig","collectionSlug","documentCollectionSlug","i18n","t","collectionConfig","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","setValue","showError","potentiallyStalePath","styles","selectedIds","initialSelections","filterByCollection","undefined","HierarchyDrawer","openDrawer","hierarchyCollectionSlug","handleDrawerSave","closeDrawer","selections","ids","from","keys","newValue","handleRemove","id","idToRemove","newIds","filter","length","handleOpenDrawer","hierarchyLabel","labels","plural","singular","_jsxs","Boolean","join","replace","style","_jsx","CustomComponent","Fallback","onRemove","buttonStyle","icon","iconPosition","margin","onClick","size","onSave"],"sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"sourcesContent":["'use client'\nimport type { RelationshipFieldClientProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useMemo } from 'react'\n\nimport type { SelectionWithPath } from '../Drawer/types.js'\n\nimport { FieldDescription } from '../../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../../fields/FieldLabel/index.js'\nimport { mergeFieldStyles } from '../../../fields/mergeFieldStyles.js'\nimport { fieldBaseClass } from '../../../fields/shared/index.js'\nimport { useField } from '../../../forms/useField/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { RenderCustomComponent } from '../../RenderCustomComponent/index.js'\nimport { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js'\nimport { SelectedHierarchies } from './SelectedHierarchies.js'\nimport './index.scss'\n\nconst baseClass = 'hierarchy-field'\n\ntype Value = (number | string)[] | null | (number | string)\n\nexport type HierarchyFieldClientProps = {\n Icon?: React.ReactNode\n} & RelationshipFieldClientProps\n\nexport const HierarchyFieldClient: React.FC<HierarchyFieldClientProps> = (props) => {\n const {\n field,\n field: {\n admin: { className, description } = {},\n hasMany,\n label,\n localized,\n relationTo: relationToProp,\n required,\n },\n Icon,\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const hierarchySlug = Array.isArray(relationToProp) ? relationToProp[0] : relationToProp\n\n const { getEntityConfig } = useConfig()\n const { collectionSlug: documentCollectionSlug } = useDocumentInfo()\n const { i18n, t } = useTranslation()\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchySlug })\n\n const memoizedValidate = useCallback(\n (value: Value, validationOptions: Parameters<typeof validate>[1]) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n path,\n setValue,\n showError,\n value,\n } = useField<Value>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n // Normalize value to array of IDs for display\n const selectedIds = useMemo((): (number | string)[] => {\n if (!value) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value]\n }, [value])\n\n // Initialize selections for the drawer - use current value so drawer expands to current selection\n const initialSelections = useMemo(() => {\n if (!value) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value] as (number | string)[]\n }, [value])\n\n // Memoize to prevent new array references on every render\n const filterByCollection = useMemo(\n () => (documentCollectionSlug ? [documentCollectionSlug] : undefined),\n [documentCollectionSlug],\n )\n\n const [HierarchyDrawer, , { openDrawer }] = useHierarchyDrawer({\n filterByCollection,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n const handleDrawerSave = useCallback(\n ({\n closeDrawer,\n selections,\n }: {\n closeDrawer: () => void\n selections: Map<number | string, SelectionWithPath>\n }) => {\n const ids = Array.from(selections.keys())\n const newValue = hasMany ? ids : (ids[0] ?? null)\n setValue(newValue)\n closeDrawer()\n },\n [hasMany, setValue],\n )\n\n const handleRemove = useCallback(\n ({ id: idToRemove }: { id: number | string }) => {\n if (hasMany) {\n const newIds = selectedIds.filter((id) => id !== idToRemove)\n setValue(newIds.length > 0 ? newIds : null)\n } else {\n setValue(null)\n }\n },\n [hasMany, selectedIds, setValue],\n )\n\n const handleOpenDrawer = useCallback(() => {\n openDrawer()\n }, [openDrawer])\n\n const hierarchyLabel =\n getTranslation(\n hasMany ? collectionConfig?.labels?.plural : collectionConfig?.labels?.singular,\n i18n,\n ) || hierarchySlug\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && `${baseClass}--read-only`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <div className={`${baseClass}__content`}>\n {selectedIds.length > 0 && (\n <SelectedHierarchies\n hierarchySlug={hierarchySlug}\n onRemove={handleRemove}\n readOnly={readOnly || disabled}\n selectedIds={selectedIds}\n />\n )}\n {!readOnly && (hasMany || selectedIds.length === 0) && (\n <Button\n buttonStyle=\"dashed\"\n className={`${baseClass}__manage-button`}\n disabled={disabled}\n icon=\"plus\"\n iconPosition=\"left\"\n margin={false}\n onClick={handleOpenDrawer}\n size=\"small\"\n >\n {t('general:selectLabel', { label: hierarchyLabel })}\n </Button>\n )}\n </div>\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n <HierarchyDrawer\n hasMany={hasMany}\n initialSelections={initialSelections}\n onSave={handleDrawerSave}\n />\n </div>\n )\n}\n"],"mappings":"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AAC1B,eAAA;MACCtC,OAAA,EAASA,OAAA;MACTmC,iBAAA,EAAmBA,iBAAA;MACnBuC,MAAA,EAAQjC;;;AAIhB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.server.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/index.server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAA;AAQ/D,eAAO,MAAM,cAAc,EAAE,gCA2B5B,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { RenderServerComponent } from '
|
|
3
|
+
import { RenderServerComponent } from '../../RenderServerComponent/index.js';
|
|
4
4
|
// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports dir for proper client boundary
|
|
5
|
-
import { HierarchyFieldClient } from '
|
|
5
|
+
import { HierarchyFieldClient } from '../../../exports/client/index.js';
|
|
6
6
|
export const HierarchyField = props => {
|
|
7
7
|
const {
|
|
8
8
|
clientField,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.server.js","names":["React","RenderServerComponent","HierarchyFieldClient","HierarchyField","props","clientField","field","payload","hierarchySlug","Array","isArray","relationTo","hierarchyCollectionConfig","config","collections","find","c","slug","hierarchyConfig","hierarchy","undefined","Icon","admin","components","renderedIcon","Component","importMap","key","_jsx","path","permissions","readOnly","schemaPath"],"sources":["../../../../src/elements/Hierarchy/Field/index.server.tsx"],"sourcesContent":["import type { RelationshipFieldServerComponent } from 'payload'\n\nimport React from 'react'\n\nimport { RenderServerComponent } from '../../RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports dir for proper client boundary\nimport { HierarchyFieldClient } from '../../../exports/client/index.js'\n\nexport const HierarchyField: RelationshipFieldServerComponent = (props) => {\n const { clientField, field, payload } = props\n\n const hierarchySlug = Array.isArray(field.relationTo) ? field.relationTo[0] : field.relationTo\n const hierarchyCollectionConfig = payload.config.collections.find((c) => c.slug === hierarchySlug)\n const hierarchyConfig =\n hierarchyCollectionConfig?.hierarchy && typeof hierarchyCollectionConfig.hierarchy === 'object'\n ? hierarchyCollectionConfig.hierarchy\n : undefined\n const Icon = hierarchyConfig?.admin.components.Icon\n\n const renderedIcon = RenderServerComponent({\n Component: Icon,\n importMap: payload.importMap,\n key: `hierarchy-field-icon-${hierarchySlug}`,\n })\n\n return (\n <HierarchyFieldClient\n field={clientField}\n Icon={renderedIcon}\n path={props.path}\n permissions={props.permissions}\n readOnly={props.readOnly}\n schemaPath={props.schemaPath}\n />\n )\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AAElB,SAASC,qBAAqB,QAAQ;AACtC;AACA,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,cAAA,GAAoDC,KAAA;EAC/D,MAAM;IAAEC,WAAW;IAAEC,KAAK;IAAEC;EAAO,CAAE,GAAGH,KAAA;EAExC,MAAMI,aAAA,GAAgBC,KAAA,CAAMC,OAAO,CAACJ,KAAA,CAAMK,UAAU,IAAIL,KAAA,CAAMK,UAAU,CAAC,EAAE,GAAGL,KAAA,CAAMK,UAAU;EAC9F,MAAMC,yBAAA,GAA4BL,OAAA,CAAQM,MAAM,CAACC,WAAW,CAACC,IAAI,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAKT,aAAA;EACpF,MAAMU,eAAA,GACJN,yBAAA,EAA2BO,SAAA,IAAa,OAAOP,yBAAA,CAA0BO,SAAS,KAAK,WACnFP,yBAAA,CAA0BO,SAAS,GACnCC,SAAA;EACN,MAAMC,IAAA,GAAOH,eAAA,EAAiBI,KAAA,CAAMC,UAAA,CAAWF,IAAA;EAE/C,MAAMG,YAAA,GAAevB,qBAAA,CAAsB;IACzCwB,SAAA,EAAWJ,IAAA;IACXK,SAAA,EAAWnB,OAAA,CAAQmB,SAAS;IAC5BC,GAAA,EAAK,wBAAwBnB,aAAA;EAC/B;EAEA,oBACEoB,IAAA,CAAC1B,oBAAA;IACCI,KAAA,EAAOD,WAAA;IACPgB,IAAA,EAAMG,YAAA;IACNK,IAAA,EAAMzB,KAAA,CAAMyB,IAAI;IAChBC,WAAA,EAAa1B,KAAA,CAAM0B,WAAW;IAC9BC,QAAA,EAAU3B,KAAA,CAAM2B,QAAQ;IACxBC,UAAA,EAAY5B,KAAA,CAAM4B;;AAGxB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/HydrateProvider/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAA;AAI1F,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,6BAA6B,CAmD5E,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
|
-
import { useHierarchy } from '
|
|
5
|
+
import { useHierarchy } from '../../../providers/Hierarchy/index.js';
|
|
6
6
|
export const HydrateHierarchyProvider = t0 => {
|
|
7
7
|
const $ = _c(16);
|
|
8
8
|
const {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useEffect","useHierarchy","HydrateHierarchyProvider","t0","$","allowedCollections","baseFilter","collectionSlug","expandedNodes","parent","parentFieldName","selectedFilters","tableData","treeData","treeLimit","typeFieldName","useAsTitle","viewCollectionSlug","hydrate","t1","t2"],"sources":["../../../../src/elements/Hierarchy/HydrateProvider/index.tsx"],"sourcesContent":["'use client'\n\nimport type React from 'react'\n\nimport { useEffect } from 'react'\n\nimport type { HydrateHierarchyProviderProps } from '../../../providers/Hierarchy/types.js'\n\nimport { useHierarchy } from '../../../providers/Hierarchy/index.js'\n\nexport const HydrateHierarchyProvider: React.FC<HydrateHierarchyProviderProps> = ({\n allowedCollections,\n baseFilter,\n collectionSlug,\n expandedNodes,\n parent,\n parentFieldName,\n selectedFilters,\n tableData,\n treeData,\n treeLimit,\n typeFieldName,\n useAsTitle,\n viewCollectionSlug,\n}) => {\n const { hydrate } = useHierarchy()\n\n useEffect(() => {\n hydrate({\n allowedCollections,\n baseFilter,\n collectionSlug,\n expandedNodes,\n parent,\n parentFieldName,\n selectedFilters,\n tableData,\n treeData,\n treeLimit,\n typeFieldName,\n useAsTitle,\n viewCollectionSlug,\n })\n }, [\n allowedCollections,\n baseFilter,\n collectionSlug,\n expandedNodes,\n hydrate,\n parent,\n parentFieldName,\n selectedFilters,\n tableData,\n treeData,\n treeLimit,\n typeFieldName,\n useAsTitle,\n viewCollectionSlug,\n ])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,SAAS,QAAQ;AAI1B,SAASC,YAAY,QAAQ;AAE7B,OAAO,MAAMC,wBAAA,GAAoEC,EAAA;EAAA,MAAAC,CAAA,GAAAL,EAAA;EAAC;IAAAM,kBAAA;IAAAC,UAAA;IAAAC,cAAA;IAAAC,aAAA;IAAAC,MAAA;IAAAC,eAAA;IAAAC,eAAA;IAAAC,SAAA;IAAAC,QAAA;IAAAC,SAAA;IAAAC,aAAA;IAAAC,UAAA;IAAAC;EAAA,IAAAd,EAcjF;EACC;IAAAe;EAAA,IAAoBjB,YAAA;EAAA,IAAAkB,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAhB,CAAA,QAAAC,kBAAA,IAAAD,CAAA,QAAAE,UAAA,IAAAF,CAAA,QAAAG,cAAA,IAAAH,CAAA,QAAAI,aAAA,IAAAJ,CAAA,QAAAc,OAAA,IAAAd,CAAA,QAAAK,MAAA,IAAAL,CAAA,QAAAM,eAAA,IAAAN,CAAA,QA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"move-many";
|
|
4
4
|
type MoveManyProps = {
|
|
5
|
-
/** Current
|
|
6
|
-
|
|
5
|
+
/** Current parent ID - drawer will open expanded to this location */
|
|
6
|
+
currentParentID?: null | number | string;
|
|
7
7
|
/** The hierarchy collection slug (e.g., 'folders') */
|
|
8
8
|
hierarchySlug: string;
|
|
9
9
|
/** Icon to display in the hierarchy drawer */
|
|
@@ -17,6 +17,6 @@ type MoveManyProps = {
|
|
|
17
17
|
ids: (number | string)[];
|
|
18
18
|
}>;
|
|
19
19
|
};
|
|
20
|
-
export declare function MoveMany({ currentFolderId, hierarchySlug, Icon, modalPrefix, onSuccess, selections, }: MoveManyProps): React.JSX.Element;
|
|
20
|
+
export declare function MoveMany({ currentParentID: currentFolderId, hierarchySlug, Icon, modalPrefix, onSuccess, selections, }: MoveManyProps): React.JSX.Element;
|
|
21
21
|
export {};
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/MoveMany/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAc7D,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,KAAK,aAAa,GAAG;IACnB,qEAAqE;IACrE,eAAe,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;IACxC,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAA;IACrB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;KAAE,CAAC,CAAA;CACzD,CAAA;AAeD,wBAAgB,QAAQ,CAAC,EACvB,eAAe,EAAE,eAAe,EAChC,aAAa,EACb,IAAI,EACJ,WAAW,EACX,SAAS,EACT,UAAU,GACX,EAAE,aAAa,qBA4Qf"}
|
|
@@ -7,15 +7,15 @@ import { formatAdminURL } from 'payload/shared';
|
|
|
7
7
|
import * as qs from 'qs-esm';
|
|
8
8
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
9
9
|
import { toast } from 'sonner';
|
|
10
|
-
import { useConfig } from '
|
|
11
|
-
import { useDocumentSelection } from '
|
|
12
|
-
import { useLocale } from '
|
|
13
|
-
import { useTranslation } from '
|
|
14
|
-
import { requests } from '
|
|
15
|
-
import { ConfirmationModal } from '
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
10
|
+
import { useConfig } from '../../../providers/Config/index.js';
|
|
11
|
+
import { useDocumentSelection } from '../../../providers/DocumentSelection/index.js';
|
|
12
|
+
import { useLocale } from '../../../providers/Locale/index.js';
|
|
13
|
+
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
14
|
+
import { requests } from '../../../utilities/api.js';
|
|
15
|
+
import { ConfirmationModal } from '../../ConfirmationModal/index.js';
|
|
16
|
+
import { ListSelectionButton } from '../../ListSelection/index.js';
|
|
17
|
+
import { Translation } from '../../Translation/index.js';
|
|
18
|
+
import { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js';
|
|
19
19
|
import './index.scss';
|
|
20
20
|
export const baseClass = 'move-many';
|
|
21
21
|
/**
|
|
@@ -26,7 +26,7 @@ function getParentFieldName(hierarchyConfig) {
|
|
|
26
26
|
return config?.parentFieldName;
|
|
27
27
|
}
|
|
28
28
|
export function MoveMany({
|
|
29
|
-
currentFolderId,
|
|
29
|
+
currentParentID: currentFolderId,
|
|
30
30
|
hierarchySlug,
|
|
31
31
|
Icon,
|
|
32
32
|
modalPrefix,
|