@payloadcms/ui 4.0.0-internal.40de3ec → 4.0.0-internal.4cbdd50
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/css/colors.css +3 -0
- package/dist/css/design-tokens.css +5 -0
- package/dist/css/elevations.css +4 -0
- package/dist/css/radius.css +1 -3
- package/dist/css/theme.css +4 -0
- package/dist/css/utilities.css +5 -0
- package/dist/elements/APIKeyInput/index.css +92 -0
- package/dist/elements/APIKeyInput/index.d.ts +14 -0
- package/dist/elements/APIKeyInput/index.d.ts.map +1 -0
- package/dist/elements/APIKeyInput/index.js +86 -0
- package/dist/elements/APIKeyInput/index.js.map +1 -0
- package/dist/elements/AddNewRelation/index.d.ts.map +1 -1
- package/dist/elements/AddNewRelation/index.js +85 -103
- package/dist/elements/AddNewRelation/index.js.map +1 -1
- package/dist/elements/AppHeader/index.d.ts +3 -1
- package/dist/elements/AppHeader/index.d.ts.map +1 -1
- package/dist/elements/AppHeader/index.js +7 -27
- package/dist/elements/AppHeader/index.js.map +1 -1
- package/dist/elements/BulkUpload/ActionsBar/index.css +10 -4
- package/dist/elements/BulkUpload/ActionsBar/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/ActionsBar/index.js +43 -40
- package/dist/elements/BulkUpload/ActionsBar/index.js.map +1 -1
- package/dist/elements/BulkUpload/AddFilesView/index.js +1 -1
- package/dist/elements/BulkUpload/AddFilesView/index.js.map +1 -1
- package/dist/elements/BulkUpload/AddingFilesView/index.css +25 -0
- package/dist/elements/BulkUpload/AddingFilesView/index.d.ts +1 -1
- package/dist/elements/BulkUpload/AddingFilesView/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/AddingFilesView/index.js +1 -1
- package/dist/elements/BulkUpload/AddingFilesView/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditForm/index.css +9 -0
- package/dist/elements/BulkUpload/EditForm/index.d.ts +1 -1
- package/dist/elements/BulkUpload/EditForm/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditForm/index.js +1 -1
- package/dist/elements/BulkUpload/EditForm/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.d.ts +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js +59 -55
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/BulkUpload/EditMany/index.css +71 -0
- package/dist/elements/BulkUpload/EditMany/index.d.ts +1 -1
- package/dist/elements/BulkUpload/EditMany/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditMany/index.js +1 -1
- package/dist/elements/BulkUpload/EditMany/index.js.map +1 -1
- package/dist/elements/BulkUpload/FileSidebar/index.css +54 -75
- package/dist/elements/BulkUpload/FileSidebar/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FileSidebar/index.js +60 -50
- package/dist/elements/BulkUpload/FileSidebar/index.js.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +13 -0
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/Button/index.css +8 -0
- package/dist/elements/Card/index.css +1 -1
- package/dist/elements/CodeEditor/CodeEditor.d.ts.map +1 -1
- package/dist/elements/CodeEditor/CodeEditor.js +19 -0
- package/dist/elements/CodeEditor/CodeEditor.js.map +1 -1
- package/dist/elements/ColumnSelection/Popup.d.ts +12 -0
- package/dist/elements/ColumnSelection/Popup.d.ts.map +1 -0
- package/dist/elements/{ColumnSelector/index.js → ColumnSelection/Popup.js} +24 -13
- package/dist/elements/ColumnSelection/Popup.js.map +1 -0
- package/dist/elements/ColumnSelection/index.d.ts +10 -0
- package/dist/elements/ColumnSelection/index.d.ts.map +1 -0
- package/dist/elements/{ColumnsButton → ColumnSelection}/index.js +23 -17
- package/dist/elements/ColumnSelection/index.js.map +1 -0
- package/dist/elements/Combobox/index.css +1 -0
- package/dist/elements/ConfirmationModal/index.css +7 -0
- package/dist/elements/ConfirmationModal/index.d.ts +1 -0
- package/dist/elements/ConfirmationModal/index.d.ts.map +1 -1
- package/dist/elements/ConfirmationModal/index.js +7 -3
- package/dist/elements/ConfirmationModal/index.js.map +1 -1
- package/dist/elements/DeleteMany/index.d.ts +3 -26
- package/dist/elements/DeleteMany/index.d.ts.map +1 -1
- package/dist/elements/DeleteMany/index.js +1 -95
- package/dist/elements/DeleteMany/index.js.map +1 -1
- package/dist/elements/Dialog/DialogModal/index.d.ts +1 -1
- package/dist/elements/Dialog/DialogModal/index.d.ts.map +1 -1
- package/dist/elements/Dialog/DialogModal/index.js.map +1 -1
- package/dist/elements/Dialog/index.css +4 -0
- package/dist/elements/DocumentControls/index.css +17 -1
- package/dist/elements/DocumentControls/index.d.ts +6 -0
- package/dist/elements/DocumentControls/index.d.ts.map +1 -1
- package/dist/elements/DocumentControls/index.js +9 -8
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerContent.js +10 -6
- package/dist/elements/DocumentDrawer/DrawerContent.js.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerHeader/index.css +76 -4
- package/dist/elements/DocumentDrawer/DrawerHeader/index.d.ts +7 -1
- package/dist/elements/DocumentDrawer/DrawerHeader/index.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js +150 -87
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/types.d.ts +1 -0
- package/dist/elements/DocumentDrawer/types.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/types.js.map +1 -1
- package/dist/elements/DocumentFields/index.css +61 -2
- package/dist/elements/DraggableSortable/index.js.map +1 -1
- package/dist/elements/Drawer/index.css +57 -26
- package/dist/elements/Drawer/index.d.ts +25 -0
- package/dist/elements/Drawer/index.d.ts.map +1 -1
- package/dist/elements/Drawer/index.js +133 -54
- package/dist/elements/Drawer/index.js.map +1 -1
- package/dist/elements/Drawer/types.d.ts +1 -0
- package/dist/elements/Drawer/types.d.ts.map +1 -1
- package/dist/elements/Drawer/types.js.map +1 -1
- package/dist/elements/EditMany/DrawerContent.d.ts +1 -1
- package/dist/elements/EditMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/EditMany/DrawerContent.js +76 -71
- package/dist/elements/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/EditMany/index.css +71 -0
- package/dist/elements/EditMany/index.d.ts +9 -11
- package/dist/elements/EditMany/index.d.ts.map +1 -1
- package/dist/elements/EditMany/index.js +2 -40
- package/dist/elements/EditMany/index.js.map +1 -1
- package/dist/elements/FieldSelect/index.css +3 -0
- package/dist/elements/FileDetails/DraggableFileDetails/index.css +32 -0
- package/dist/elements/FileDetails/DraggableFileDetails/index.d.ts +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.d.ts.map +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.js +19 -18
- package/dist/elements/FileDetails/DraggableFileDetails/index.js.map +1 -1
- package/dist/elements/GroupBy/Popup.d.ts +21 -0
- package/dist/elements/GroupBy/Popup.d.ts.map +1 -0
- package/dist/elements/GroupBy/Popup.js +269 -0
- package/dist/elements/GroupBy/Popup.js.map +1 -0
- package/dist/elements/GroupBy/index.d.ts +12 -0
- package/dist/elements/GroupBy/index.d.ts.map +1 -0
- package/dist/elements/GroupBy/index.js +91 -0
- package/dist/elements/GroupBy/index.js.map +1 -0
- package/dist/elements/Hierarchy/Drawer/index.css +3 -21
- package/dist/elements/Hierarchy/Drawer/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Drawer/index.js +5 -3
- package/dist/elements/Hierarchy/Drawer/index.js.map +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.css +36 -0
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.d.ts +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.js +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.js.map +1 -1
- package/dist/elements/Hierarchy/Field/index.client.d.ts +1 -1
- package/dist/elements/Hierarchy/Field/index.client.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Field/index.client.js +5 -2
- package/dist/elements/Hierarchy/Field/index.client.js.map +1 -1
- package/dist/elements/Hierarchy/Field/index.css +37 -0
- package/dist/elements/Hierarchy/MoveMany/index.d.ts +0 -1
- package/dist/elements/Hierarchy/MoveMany/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/MoveMany/index.js +0 -1
- package/dist/elements/Hierarchy/MoveMany/index.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.css +27 -0
- package/dist/elements/Hierarchy/Tree/LoadMore/index.d.ts +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.js +1 -1
- package/dist/elements/Hierarchy/Tree/LoadMore/index.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeFocusContext.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeFocusContext.js +36 -16
- package/dist/elements/Hierarchy/Tree/TreeFocusContext.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeNode/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeNode/index.js +20 -15
- package/dist/elements/Hierarchy/Tree/TreeNode/index.js.map +1 -1
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.js.map +1 -1
- package/dist/elements/ListColumnSelectionButton/index.d.ts +11 -0
- package/dist/elements/ListColumnSelectionButton/index.d.ts.map +1 -0
- package/dist/elements/ListColumnSelectionButton/index.js +37 -0
- package/dist/elements/ListColumnSelectionButton/index.js.map +1 -0
- package/dist/elements/ListControls/index.css +5 -0
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +7 -7
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/elements/ListDrawer/DrawerContent.js +12 -6
- package/dist/elements/ListDrawer/DrawerContent.js.map +1 -1
- package/dist/elements/ListGroupByButton/index.d.ts +12 -0
- package/dist/elements/ListGroupByButton/index.d.ts.map +1 -0
- package/dist/elements/ListGroupByButton/index.js +55 -0
- package/dist/elements/ListGroupByButton/index.js.map +1 -0
- package/dist/elements/ListWhereBuilder/index.d.ts +16 -0
- package/dist/elements/ListWhereBuilder/index.d.ts.map +1 -0
- package/dist/elements/ListWhereBuilder/index.js +62 -0
- package/dist/elements/ListWhereBuilder/index.js.map +1 -0
- package/dist/elements/LoadMoreRow/index.css +34 -0
- package/dist/elements/LoadMoreRow/index.d.ts +1 -1
- package/dist/elements/LoadMoreRow/index.d.ts.map +1 -1
- package/dist/elements/LoadMoreRow/index.js +4 -8
- package/dist/elements/LoadMoreRow/index.js.map +1 -1
- package/dist/elements/Loading/index.css +28 -74
- package/dist/elements/Loading/index.d.ts.map +1 -1
- package/dist/elements/Loading/index.js +16 -60
- package/dist/elements/Loading/index.js.map +1 -1
- package/dist/elements/Localizer/index.d.ts.map +1 -1
- package/dist/elements/Localizer/index.js +3 -4
- package/dist/elements/Localizer/index.js.map +1 -1
- package/dist/elements/MenuSeparator/index.d.ts +4 -0
- package/dist/elements/MenuSeparator/index.d.ts.map +1 -0
- package/dist/elements/MenuSeparator/index.js +10 -0
- package/dist/elements/MenuSeparator/index.js.map +1 -0
- package/dist/elements/Nav/index.d.ts.map +1 -1
- package/dist/elements/Nav/index.js +4 -23
- package/dist/elements/Nav/index.js.map +1 -1
- package/dist/elements/Popup/PopupButtonList/index.css +48 -4
- package/dist/elements/Popup/PopupButtonList/index.d.ts.map +1 -1
- package/dist/elements/Popup/PopupButtonList/index.js +1 -0
- package/dist/elements/Popup/PopupButtonList/index.js.map +1 -1
- package/dist/elements/Popup/PopupGroupLabel/index.css +19 -4
- package/dist/elements/Popup/index.d.ts +7 -0
- package/dist/elements/Popup/index.d.ts.map +1 -1
- package/dist/elements/Popup/index.js +143 -63
- package/dist/elements/Popup/index.js.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.d.ts +13 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.d.ts.map +1 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js +41 -0
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js.map +1 -0
- package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts +1 -0
- package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.js +9 -31
- package/dist/elements/PublishButton/ScheduleDrawer/index.js.map +1 -1
- package/dist/elements/PublishButton/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/index.js +4 -5
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/PublishMany/DrawerContent.d.ts +2 -1
- package/dist/elements/PublishMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/PublishMany/DrawerContent.js.map +1 -1
- package/dist/elements/PublishMany/index.d.ts +2 -6
- package/dist/elements/PublishMany/index.d.ts.map +1 -1
- package/dist/elements/PublishMany/index.js +0 -38
- package/dist/elements/PublishMany/index.js.map +1 -1
- package/dist/elements/QueryPresets/cells/ColumnsCell/{index.scss → index.css} +1 -3
- package/dist/elements/QueryPresets/cells/ColumnsCell/index.d.ts +1 -1
- package/dist/elements/QueryPresets/cells/ColumnsCell/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/cells/ColumnsCell/index.js +1 -1
- package/dist/elements/QueryPresets/cells/ColumnsCell/index.js.map +1 -1
- package/dist/elements/QueryPresets/fields/ColumnsField/index.d.ts +1 -1
- package/dist/elements/QueryPresets/fields/ColumnsField/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/fields/ColumnsField/index.js +77 -48
- package/dist/elements/QueryPresets/fields/ColumnsField/index.js.map +1 -1
- package/dist/elements/QueryPresets/fields/GroupByField/index.d.ts +1 -1
- package/dist/elements/QueryPresets/fields/GroupByField/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/fields/GroupByField/index.js +12 -21
- package/dist/elements/QueryPresets/fields/GroupByField/index.js.map +1 -1
- package/dist/elements/QueryPresets/fields/Heading/index.css +52 -0
- package/dist/elements/QueryPresets/fields/Heading/index.d.ts +7 -0
- package/dist/elements/QueryPresets/fields/Heading/index.d.ts.map +1 -0
- package/dist/elements/QueryPresets/fields/Heading/index.js +31 -0
- package/dist/elements/QueryPresets/fields/Heading/index.js.map +1 -0
- package/dist/elements/QueryPresets/fields/WhereField/index.d.ts +1 -1
- package/dist/elements/QueryPresets/fields/WhereField/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/fields/WhereField/index.js +24 -23
- package/dist/elements/QueryPresets/fields/WhereField/index.js.map +1 -1
- package/dist/elements/QueryPresets/fields/fields.css +23 -0
- package/dist/elements/ReactSelect/MultiValue/index.css +1 -1
- package/dist/elements/ReactSelect/getCaptureMenuScroll.d.ts +5 -0
- package/dist/elements/ReactSelect/getCaptureMenuScroll.d.ts.map +1 -0
- package/dist/elements/ReactSelect/getCaptureMenuScroll.js +10 -0
- package/dist/elements/ReactSelect/getCaptureMenuScroll.js.map +1 -0
- package/dist/elements/ReactSelect/getMenuListStyles.d.ts +6 -0
- package/dist/elements/ReactSelect/getMenuListStyles.d.ts.map +1 -0
- package/dist/elements/ReactSelect/getMenuListStyles.js +7 -0
- package/dist/elements/ReactSelect/getMenuListStyles.js.map +1 -0
- package/dist/elements/ReactSelect/index.css +0 -1
- package/dist/elements/ReactSelect/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/index.js +176 -139
- package/dist/elements/ReactSelect/index.js.map +1 -1
- package/dist/elements/ReactSelect/types.d.ts +1 -0
- package/dist/elements/ReactSelect/types.d.ts.map +1 -1
- package/dist/elements/ReactSelect/types.js.map +1 -1
- package/dist/elements/RelationshipTable/index.js +2 -2
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/RenderTitle/index.css +10 -0
- package/dist/elements/RenderTitle/index.d.ts +5 -0
- package/dist/elements/RenderTitle/index.d.ts.map +1 -1
- package/dist/elements/RenderTitle/index.js +52 -27
- package/dist/elements/RenderTitle/index.js.map +1 -1
- package/dist/elements/SchedulePublishButton/index.d.ts.map +1 -1
- package/dist/elements/SchedulePublishButton/index.js +6 -1
- package/dist/elements/SchedulePublishButton/index.js.map +1 -1
- package/dist/elements/SelectMany/index.js +1 -1
- package/dist/elements/SelectMany/index.js.map +1 -1
- package/dist/elements/SortColumn/index.css +1 -1
- package/dist/elements/Spinner/index.css +16 -0
- package/dist/elements/Table/DefaultCell/fields/Blocks/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Blocks/index.js.map +1 -1
- package/dist/elements/Table/OrderableRow.d.ts.map +1 -1
- package/dist/elements/Table/OrderableRow.js +1 -1
- package/dist/elements/Table/OrderableRow.js.map +1 -1
- package/dist/elements/Table/RelationshipProvider/index.d.ts.map +1 -1
- package/dist/elements/Table/RelationshipProvider/index.js +1 -0
- package/dist/elements/Table/RelationshipProvider/index.js.map +1 -1
- package/dist/elements/Table/index.css +39 -10
- package/dist/elements/Tabs/index.css +100 -0
- package/dist/elements/Tabs/index.d.ts +32 -0
- package/dist/elements/Tabs/index.d.ts.map +1 -0
- package/dist/elements/Tabs/index.js +62 -0
- package/dist/elements/Tabs/index.js.map +1 -0
- package/dist/elements/TimezonePicker/index.css +0 -15
- package/dist/elements/Toasts/fieldErrors.d.ts +1 -0
- package/dist/elements/Toasts/fieldErrors.d.ts.map +1 -1
- package/dist/elements/Toasts/fieldErrors.js +25 -9
- package/dist/elements/Toasts/fieldErrors.js.map +1 -1
- package/dist/elements/Toasts/index.css +5 -0
- package/dist/elements/Tooltip/index.css +20 -4
- package/dist/elements/Tooltip/index.d.ts.map +1 -1
- package/dist/elements/Tooltip/index.js +71 -3
- package/dist/elements/Tooltip/index.js.map +1 -1
- package/dist/elements/UnpublishButton/index.d.ts.map +1 -1
- package/dist/elements/UnpublishButton/index.js +5 -13
- package/dist/elements/UnpublishButton/index.js.map +1 -1
- package/dist/elements/UnpublishMany/DrawerContent.d.ts +2 -1
- package/dist/elements/UnpublishMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/UnpublishMany/DrawerContent.js.map +1 -1
- package/dist/elements/UnpublishMany/index.d.ts +2 -4
- package/dist/elements/UnpublishMany/index.d.ts.map +1 -1
- package/dist/elements/UnpublishMany/index.js +0 -38
- package/dist/elements/UnpublishMany/index.js.map +1 -1
- package/dist/elements/UserMenu/LanguageMenu/index.d.ts +6 -0
- package/dist/elements/UserMenu/LanguageMenu/index.d.ts.map +1 -0
- package/dist/elements/UserMenu/LanguageMenu/index.js +133 -0
- package/dist/elements/UserMenu/LanguageMenu/index.js.map +1 -0
- package/dist/elements/UserMenu/SettingsMenu/index.d.ts +15 -0
- package/dist/elements/UserMenu/SettingsMenu/index.d.ts.map +1 -0
- package/dist/elements/UserMenu/SettingsMenu/index.js +119 -0
- package/dist/elements/UserMenu/SettingsMenu/index.js.map +1 -0
- package/dist/elements/UserMenu/SubMenuHeader/index.d.ts +6 -0
- package/dist/elements/UserMenu/SubMenuHeader/index.d.ts.map +1 -0
- package/dist/elements/UserMenu/SubMenuHeader/index.js +34 -0
- package/dist/elements/UserMenu/SubMenuHeader/index.js.map +1 -0
- package/dist/elements/UserMenu/ThemeMenu/index.d.ts +6 -0
- package/dist/elements/UserMenu/ThemeMenu/index.d.ts.map +1 -0
- package/dist/elements/UserMenu/ThemeMenu/index.js +145 -0
- package/dist/elements/UserMenu/ThemeMenu/index.js.map +1 -0
- package/dist/elements/UserMenu/index.css +80 -0
- package/dist/elements/UserMenu/index.d.ts +10 -0
- package/dist/elements/UserMenu/index.d.ts.map +1 -0
- package/dist/elements/UserMenu/index.js +204 -0
- package/dist/elements/UserMenu/index.js.map +1 -0
- package/dist/elements/WhereBuilder/Condition/index.d.ts +1 -0
- package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +17 -2
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/index.d.ts +4 -3
- package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/index.js +71 -62
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/elements/WhereBuilder/types.d.ts +6 -5
- package/dist/elements/WhereBuilder/types.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/types.js.map +1 -1
- package/dist/exports/client/index.d.ts +13 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +2 -2
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/shared/index.js +1 -1
- package/dist/exports/shared/index.js.map +1 -1
- package/dist/fields/Blocks/BlockSelector/BlockSearch/index.css +1 -49
- package/dist/fields/Blocks/BlockSelector/BlockSearch/index.d.ts.map +1 -1
- package/dist/fields/Blocks/BlockSelector/BlockSearch/index.js +27 -20
- package/dist/fields/Blocks/BlockSelector/BlockSearch/index.js.map +1 -1
- package/dist/fields/Blocks/BlockSelector/index.css +17 -3
- package/dist/fields/Blocks/BlockSelector/index.js +1 -1
- package/dist/fields/Blocks/BlockSelector/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.css +6 -0
- package/dist/fields/Row/index.d.ts +1 -1
- package/dist/fields/Tabs/Tab/index.d.ts +0 -1
- package/dist/fields/Tabs/Tab/index.d.ts.map +1 -1
- package/dist/fields/Tabs/Tab/index.js +12 -23
- package/dist/fields/Tabs/Tab/index.js.map +1 -1
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js +37 -37
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Upload/HasMany/index.css +4 -0
- package/dist/forms/RenderFields/RenderField.d.ts +1 -1
- package/dist/forms/RenderFields/RenderField.js +2 -1
- package/dist/forms/RenderFields/RenderField.js.map +1 -1
- package/dist/forms/useField/index.js.map +1 -1
- package/dist/icons/Check/index.css +1 -2
- package/dist/icons/Check/index.js +1 -1
- package/dist/icons/Check/index.js.map +1 -1
- package/dist/icons/Gear/index.d.ts.map +1 -1
- package/dist/icons/Gear/index.js +8 -1
- package/dist/icons/Gear/index.js.map +1 -1
- package/dist/icons/InteractionEnter/index.css +5 -0
- package/dist/icons/InteractionEnter/index.d.ts +11 -0
- package/dist/icons/InteractionEnter/index.d.ts.map +1 -0
- package/dist/icons/InteractionEnter/index.js +25 -0
- package/dist/icons/InteractionEnter/index.js.map +1 -0
- package/dist/icons/{Write → Key}/index.css +1 -1
- package/dist/icons/Key/index.d.ts +7 -0
- package/dist/icons/Key/index.d.ts.map +1 -0
- package/dist/icons/Key/index.js +24 -0
- package/dist/icons/Key/index.js.map +1 -0
- package/dist/icons/LogOut/index.js +2 -2
- package/dist/icons/LogOut/index.js.map +1 -1
- package/dist/icons/Schedule/index.d.ts.map +1 -1
- package/dist/icons/Schedule/index.js +38 -39
- package/dist/icons/Schedule/index.js.map +1 -1
- package/dist/icons/VariableColor/index.css +5 -0
- package/dist/icons/VariableColor/index.d.ts +7 -0
- package/dist/icons/VariableColor/index.d.ts.map +1 -0
- package/dist/icons/VariableColor/index.js +23 -0
- package/dist/icons/VariableColor/index.js.map +1 -0
- package/dist/icons/Warning/index.css +1 -7
- package/dist/icons/Warning/index.d.ts +1 -1
- package/dist/icons/Warning/index.d.ts.map +1 -1
- package/dist/icons/Warning/index.js +11 -16
- package/dist/icons/Warning/index.js.map +1 -1
- package/dist/icons/WarningTriangle/index.css +5 -0
- package/dist/icons/WarningTriangle/index.d.ts +6 -0
- package/dist/icons/WarningTriangle/index.d.ts.map +1 -0
- package/dist/icons/WarningTriangle/index.js +21 -0
- package/dist/icons/WarningTriangle/index.js.map +1 -0
- package/dist/icons/Write/index.d.ts +0 -1
- package/dist/icons/Write/index.d.ts.map +1 -1
- package/dist/icons/Write/index.js +1 -2
- package/dist/icons/Write/index.js.map +1 -1
- package/dist/providers/Auth/index.d.ts +3 -1
- package/dist/providers/Auth/index.d.ts.map +1 -1
- package/dist/providers/Auth/index.js +8 -3
- package/dist/providers/Auth/index.js.map +1 -1
- package/dist/providers/Config/index.js.map +1 -1
- package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/index.js +4 -0
- package/dist/providers/DocumentInfo/index.js.map +1 -1
- package/dist/providers/DocumentInfo/types.d.ts +4 -0
- package/dist/providers/DocumentInfo/types.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/types.js.map +1 -1
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js +27 -24
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/TableColumns/RenderDefaultCell/index.css +1 -0
- package/dist/providers/Theme/index.d.ts.map +1 -1
- package/dist/providers/Theme/index.js +16 -14
- package/dist/providers/Theme/index.js.map +1 -1
- package/dist/providers/ToastContainer/index.css +208 -0
- package/dist/providers/ToastContainer/index.d.ts +1 -0
- package/dist/providers/ToastContainer/index.d.ts.map +1 -1
- package/dist/providers/ToastContainer/index.js +19 -6
- package/dist/providers/ToastContainer/index.js.map +1 -1
- package/dist/scss/app.scss +7 -2
- package/dist/styles.css +1361 -1
- package/dist/templates/Default/index.d.ts.map +1 -1
- package/dist/templates/Default/index.js +52 -2
- package/dist/templates/Default/index.js.map +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js +0 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js +0 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/formatDocTitle/formatDateTitle.d.ts.map +1 -1
- package/dist/utilities/formatDocTitle/formatDateTitle.js +1 -1
- package/dist/utilities/formatDocTitle/formatDateTitle.js.map +1 -1
- package/dist/utilities/getHasScheduledPublish.d.ts +12 -0
- package/dist/utilities/getHasScheduledPublish.d.ts.map +1 -0
- package/dist/utilities/getHasScheduledPublish.js +38 -0
- package/dist/utilities/getHasScheduledPublish.js.map +1 -0
- package/dist/utilities/getVersions.d.ts.map +1 -1
- package/dist/utilities/getVersions.js +1 -21
- package/dist/utilities/getVersions.js.map +1 -1
- package/dist/utilities/reduceFieldsToOptions.js +1 -1
- package/dist/utilities/reduceFieldsToOptions.js.map +1 -1
- package/dist/views/Account/ResetPreferences/index.js +1 -0
- package/dist/views/Account/ResetPreferences/index.js.map +1 -1
- package/dist/views/Account/Settings/index.css +30 -13
- package/dist/views/Account/ToggleTheme/index.d.ts.map +1 -1
- package/dist/views/Account/ToggleTheme/index.js +31 -47
- package/dist/views/Account/ToggleTheme/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.client.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +10 -1
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Edit/Auth/APIKey.d.ts.map +1 -1
- package/dist/views/Edit/Auth/APIKey.js +10 -32
- package/dist/views/Edit/Auth/APIKey.js.map +1 -1
- package/dist/views/Edit/Auth/index.css +0 -67
- package/dist/views/Edit/index.d.ts.map +1 -1
- package/dist/views/Edit/index.js +62 -48
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/views/HierarchyList/DocumentListSelection/index.js +8 -8
- package/dist/views/HierarchyList/DocumentListSelection/index.js.map +1 -1
- package/dist/views/List/ListHeader/index.css +23 -1
- package/dist/views/List/ListHeader/index.d.ts.map +1 -1
- package/dist/views/List/ListHeader/index.js +0 -1
- package/dist/views/List/ListHeader/index.js.map +1 -1
- package/dist/views/List/ListSelection/index.d.ts.map +1 -1
- package/dist/views/List/ListSelection/index.js +84 -33
- package/dist/views/List/ListSelection/index.js.map +1 -1
- package/dist/views/List/handleGroupBy.d.ts.map +1 -1
- package/dist/views/List/handleGroupBy.js +9 -0
- package/dist/views/List/handleGroupBy.js.map +1 -1
- package/dist/views/List/index.client.d.ts.map +1 -1
- package/dist/views/List/index.client.js +7 -6
- package/dist/views/List/index.client.js.map +1 -1
- package/dist/views/List/index.css +15 -0
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +9 -2
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/renderListViewSlots.d.ts.map +1 -1
- package/dist/views/List/renderListViewSlots.js +11 -0
- package/dist/views/List/renderListViewSlots.js.map +1 -1
- package/dist/views/Logout/LogoutClient.d.ts +14 -0
- package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
- package/dist/views/Logout/LogoutClient.js +39 -33
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/Logout/index.d.ts.map +1 -1
- package/dist/views/Logout/index.js +7 -2
- package/dist/views/Logout/index.js.map +1 -1
- package/dist/views/Version/Default/index.css +3 -5
- package/dist/views/Version/Default/index.d.ts.map +1 -1
- package/dist/views/Version/Default/index.js +7 -28
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Checkbox/index.js.map +1 -1
- package/dist/views/Version/Restore/index.css +2 -2
- package/dist/views/Version/SelectComparison/VersionDrawer/index.css +5 -0
- package/dist/views/Version/SelectComparison/VersionDrawer/index.d.ts +1 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/index.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/index.js +1 -2
- package/dist/views/Version/SelectComparison/VersionDrawer/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/index.css +5 -0
- package/dist/views/Version/SelectComparison/index.d.ts +1 -1
- package/dist/views/Version/SelectComparison/index.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/index.js +1 -1
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/views/Version/SelectLocales/index.d.ts +1 -2
- package/dist/views/Version/SelectLocales/index.d.ts.map +1 -1
- package/dist/views/Version/SelectLocales/index.js +83 -32
- package/dist/views/Version/SelectLocales/index.js.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
- package/dist/views/Versions/index.css +19 -16
- package/dist/views/Versions/index.d.ts +1 -1
- package/dist/views/Versions/index.d.ts.map +1 -1
- package/dist/views/Versions/index.js +3 -26
- package/dist/views/Versions/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/elements/BulkUpload/AddingFilesView/index.scss +0 -25
- package/dist/elements/BulkUpload/EditForm/index.scss +0 -11
- package/dist/elements/BulkUpload/EditMany/index.scss +0 -171
- package/dist/elements/ColumnSelector/index.d.ts +0 -9
- package/dist/elements/ColumnSelector/index.d.ts.map +0 -1
- package/dist/elements/ColumnSelector/index.js.map +0 -1
- package/dist/elements/ColumnsButton/index.d.ts +0 -7
- package/dist/elements/ColumnsButton/index.d.ts.map +0 -1
- package/dist/elements/ColumnsButton/index.js.map +0 -1
- package/dist/elements/EditMany/index.scss +0 -182
- package/dist/elements/FileDetails/DraggableFileDetails/index.scss +0 -35
- package/dist/elements/GroupByBuilder/index.d.ts +0 -12
- package/dist/elements/GroupByBuilder/index.d.ts.map +0 -1
- package/dist/elements/GroupByBuilder/index.js +0 -164
- package/dist/elements/GroupByBuilder/index.js.map +0 -1
- package/dist/elements/GroupByBuilder/index.scss +0 -39
- package/dist/elements/GroupByControl/index.d.ts +0 -9
- package/dist/elements/GroupByControl/index.d.ts.map +0 -1
- package/dist/elements/GroupByControl/index.js +0 -258
- package/dist/elements/GroupByControl/index.js.map +0 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.scss +0 -78
- package/dist/elements/Hierarchy/Field/index.scss +0 -41
- package/dist/elements/Hierarchy/MoveMany/index.scss +0 -7
- package/dist/elements/Hierarchy/Tree/LoadMore/index.scss +0 -26
- package/dist/elements/Hierarchy/Tree/TreeConnector.d.ts +0 -7
- package/dist/elements/Hierarchy/Tree/TreeConnector.d.ts.map +0 -1
- package/dist/elements/Hierarchy/Tree/TreeConnector.js +0 -23
- package/dist/elements/Hierarchy/Tree/TreeConnector.js.map +0 -1
- package/dist/elements/LoadMoreRow/index.scss +0 -45
- package/dist/elements/QueryPresets/fields/ColumnsField/index.scss +0 -17
- package/dist/elements/QueryPresets/fields/GroupByField/index.scss +0 -17
- package/dist/elements/QueryPresets/fields/WhereField/index.scss +0 -23
- package/dist/fields/Tabs/Tab/index.css +0 -82
- package/dist/scss/toasts.scss +0 -146
- package/dist/views/Version/SelectComparison/VersionDrawer/index.scss +0 -18
- package/dist/views/Version/SelectComparison/index.scss +0 -9
- /package/dist/elements/{ColumnSelector/index.css → ColumnSelection/Popup.css} +0 -0
- /package/dist/elements/{GroupByControl/index.css → GroupBy/Popup.css} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getTranslation","React","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","useEffectEvent","TagIcon","useConfig","useHierarchy","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","onClick","type","_Fragment","onSelect","HierarchyDrawer","props","drawerSlug","refreshTree","createParentId","setCreateParentId","drawerContentRef","documentDrawerKey","setDocumentDrawerKey","documentDrawerSlug","DocumentDrawer","closeDocumentDrawer","openDrawer","openDocumentDrawer","handleCreateNew","parentId","setTimeout","handleDocumentSave","doc","undefined","refreshColumn","drawerContent","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 { useHierarchy } from '../../../providers/Hierarchy/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.css'\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 />}\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 const { refreshTree } = useHierarchy()\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 refreshTree(hierarchyCollectionSlug)\n closeDocumentDrawer()\n },\n [closeDocumentDrawer, createParentId, hierarchyCollectionSlug, refreshTree],\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} 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,YAAY,QAAQ;AAC7B,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,UAA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AAO,CAACsD,aAAa,CAAChB,cAAA;IAC9C;IACA,IAAIE,gBAAA,CAAiBxC,OAAO,IAAIoD,GAAA,EAAK/C,EAAA,EAAI;MACvCmC,gBAAA,CAAiBxC,OAAO,CAACoB,UAAU,CAACgC,GAAA,CAAI/C,EAAE;IAC5C;IACAgC,WAAA,CAAYxE,uBAAA;IACZgF,mBAAA;EACF,GACA,CAACA,mBAAA,EAAqBP,cAAA,EAAgBzE,uBAAA,EAAyBwE,WAAA,CAAY;EAG7E;EACA,MAAMkB,aAAA,GAAgBhH,OAAA,CACpB,mBACEkF,IAAA,CAACnE,sBAAA;IACE,GAAG6E,KAAK;IACT1E,gBAAA,EAAkBA,gBAAA;IAClBO,WAAA,EAAagF,eAAA;IACb5E,GAAA,EAAKoE;MAGT,CAACQ,eAAA,EAAiBb,KAAA,CAAM;EAG1B,oBACEZ,KAAA,CAAAS,SAAA;4BACEP,IAAA,CAACzE,MAAA;MAAOwE,SAAA,EAAWnE,SAAA;MAAWmG,MAAA,EAAQ;MAAMC,IAAA,EAAMrB,UAAA;gBAC/CmB;qBAEH9B,IAAA,CAACxE,mBAAA;gBACC,aAAAwE,IAAA,CAACmB,cAAA;QACCc,WAAA,EACEpB,cAAA,KAAmB,OAAO;UAAE,CAACnD,wBAAA,GAA2BmD;QAAe,IAAIe,SAAA;QAG7EnF,MAAA,EAAQiF;SADHV,iBAAA;;;AAMf","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","React","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","useEffectEvent","TagIcon","useConfig","useHierarchy","useTranslation","DialogModal","useDocumentDrawer","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","onClick","type","_Fragment","onSelect","HierarchyDrawer","props","drawerSlug","refreshTree","createParentId","setCreateParentId","drawerContentRef","documentDrawerKey","setDocumentDrawerKey","documentDrawerSlug","DocumentDrawer","closeDocumentDrawer","openDrawer","openDocumentDrawer","handleCreateNew","parentId","setTimeout","handleDocumentSave","doc","undefined","refreshColumn","drawerContent","closeOnBlur","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 { useHierarchy } from '../../../providers/Hierarchy/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { DialogModal } from '../../Dialog/index.js'\nimport { useDocumentDrawer } from '../../DocumentDrawer/index.js'\nimport { DrawerDepthProvider } from '../../Drawer/index.js'\nimport { DrawerActionHeader } from '../../DrawerActionHeader/index.js'\nimport { HierarchyColumnBrowser } from '../ColumnBrowser/index.js'\nimport { fetchAncestorPath } from './fetchAncestorPath.js'\nimport './index.css'\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 />}\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 const { refreshTree } = useHierarchy()\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 refreshTree(hierarchyCollectionSlug)\n closeDocumentDrawer()\n },\n [closeDocumentDrawer, createParentId, hierarchyCollectionSlug, refreshTree],\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 <DialogModal className={baseClass} closeOnBlur size=\"large\" slug={drawerSlug}>\n {drawerContent}\n </DialogModal>\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,EAC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AA,GAA2BmD;QAAe,IAAIe,SAAA;QAG7EnF,MAAA,EAAQiF;SADHV,iBAAA;;;AAMf","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.selected-hierarchies__pills {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
gap: var(--spacer-1);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.selected-hierarchies__pill .chip__label {
|
|
9
|
+
max-width: 200px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.selected-hierarchies__pill.chip--size-medium {
|
|
13
|
+
height: 1.25rem;
|
|
14
|
+
padding-inline-start: var(--spacer-1);
|
|
15
|
+
border-radius: var(--radius-chip);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.selected-hierarchies__pill .chip__remove {
|
|
19
|
+
color: var(--color-icon-secondary);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.selected-hierarchies__pill .chip__remove:hover {
|
|
23
|
+
color: var(--color-text);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.selected-hierarchies__empty {
|
|
27
|
+
color: var(--color-text-secondary);
|
|
28
|
+
font-style: italic;
|
|
29
|
+
padding: var(--spacer-1) 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.selected-hierarchies__loading {
|
|
33
|
+
color: var(--color-text-secondary);
|
|
34
|
+
padding: var(--spacer-1) 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1 +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;AAMnE,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectedHierarchies.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/SelectedHierarchies.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA+C,MAAM,OAAO,CAAA;AAMnE,OAAO,2BAA2B,CAAA;AASlC,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"}
|
|
@@ -8,7 +8,7 @@ import { useConfig } from '../../../providers/Config/index.js';
|
|
|
8
8
|
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
9
9
|
import { Chip } from '../../Chip/index.js';
|
|
10
10
|
import { Spinner } from '../../Spinner/index.js';
|
|
11
|
-
import './SelectedHierarchies.
|
|
11
|
+
import './SelectedHierarchies.css';
|
|
12
12
|
const baseClass = 'selected-hierarchies';
|
|
13
13
|
export const SelectedHierarchies = ({
|
|
14
14
|
hierarchySlug,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectedHierarchies.js","names":["formatAdminURL","qs","React","useEffect","useMemo","useRef","useState","useConfig","useTranslation","Chip","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","disabled","icon"],"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 { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Chip } from '../../Chip/index.js'\nimport { Spinner } from '../../Spinner/index.js'\nimport './SelectedHierarchies.
|
|
1
|
+
{"version":3,"file":"SelectedHierarchies.js","names":["formatAdminURL","qs","React","useEffect","useMemo","useRef","useState","useConfig","useTranslation","Chip","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","disabled","icon"],"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 { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Chip } from '../../Chip/index.js'\nimport { Spinner } from '../../Spinner/index.js'\nimport './SelectedHierarchies.css'\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=\"sm\" />\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 return (\n <Chip\n className={`${baseClass}__pill`}\n disabled={readOnly}\n icon={Icon}\n onRemove={() => onRemove({ id: item.id })}\n size=\"medium\"\n >\n {item.title}\n </Chip>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAE5D,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,IAAI,QAAQ;AACrB,SAASC,OAAO,QAAQ;AACxB,OAAO;AAEP,MAAMC,SAAA,GAAY;AAelB,OAAO,MAAMC,mBAAA,GAA0DA,CAAC;EACtEC,aAAa;EACbC,IAAI;EACJC,QAAQ;EACRC,QAAA,GAAW,KAAK;EAChBC;AAAW,CACZ;EACC,MAAM;IAAEC,MAAM;IAAEC;EAAe,CAAE,GAAGZ,SAAA;EACpC,MAAM;IAAEa;EAAI,CAAE,GAAGZ,cAAA;EACjB,MAAM,CAACa,KAAA,EAAOC,QAAA,CAAS,GAAGhB,QAAA,CAA0B,EAAE;EACtD,MAAM,CAACiB,aAAA,EAAeC,gBAAA,CAAiB,GAAGlB,QAAA,CAAS;EAEnD,MA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SAAkB;gBAClCU,KAAA,CAAMyC,GAAG,CAAEQ,MAAA,iBACVG,IAAA,CAACG,YAAA;QACC9D,IAAA,EAAMA,IAAA;QACNwD,IAAA,EAAMA,MAAA;QAENvD,QAAA,EAAUA,QAAA;QACVC,QAAA,EAAUA;SAFLsD,MAAA,CAAKzB,EAAE;;;AAQxB;AASA,MAAM+B,YAAA,GAA4CA,CAAC;EAAE9D,IAAI;EAAEwD,IAAI;EAAEvD,QAAQ;EAAEC;AAAQ,CAAE;EACnF,oBACEyD,IAAA,CAAChE,IAAA;IACCiE,SAAA,EAAW,GAAG/D,SAAA,QAAiB;IAC/BkE,QAAA,EAAU7D,QAAA;IACV8D,IAAA,EAAMhE,IAAA;IACNC,QAAA,EAAUA,CAAA,KAAMA,QAAA,CAAS;MAAE8B,EAAA,EAAIyB,IAAA,CAAKzB;IAAG;IACvC8B,IAAA,EAAK;cAEJL,IAAA,CAAKJ;;AAGZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAG3D,OAAO,KAA+B,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAG3D,OAAO,KAA+B,MAAM,OAAO,CAAA;AAkBnD,OAAO,aAAa,CAAA;AAMpB,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"}
|
|
@@ -9,6 +9,7 @@ import { FieldLabel } from '../../../fields/FieldLabel/index.js';
|
|
|
9
9
|
import { mergeFieldStyles } from '../../../fields/mergeFieldStyles.js';
|
|
10
10
|
import { fieldBaseClass } from '../../../fields/shared/index.js';
|
|
11
11
|
import { useField } from '../../../forms/useField/index.js';
|
|
12
|
+
import { CirclePlusIcon } from '../../../icons/CirclePlus/index.js';
|
|
12
13
|
import { useConfig } from '../../../providers/Config/index.js';
|
|
13
14
|
import { useDocumentInfo } from '../../../providers/DocumentInfo/index.js';
|
|
14
15
|
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
@@ -16,7 +17,7 @@ import { Button } from '../../Button/index.js';
|
|
|
16
17
|
import { RenderCustomComponent } from '../../RenderCustomComponent/index.js';
|
|
17
18
|
import { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js';
|
|
18
19
|
import { SelectedHierarchies } from './SelectedHierarchies.js';
|
|
19
|
-
import './index.
|
|
20
|
+
import './index.css';
|
|
20
21
|
const baseClass = 'hierarchy-field';
|
|
21
22
|
export const HierarchyFieldClient = props => {
|
|
22
23
|
const {
|
|
@@ -160,7 +161,9 @@ export const HierarchyFieldClient = props => {
|
|
|
160
161
|
buttonStyle: "dashed",
|
|
161
162
|
className: `${baseClass}__manage-button`,
|
|
162
163
|
disabled: disabled,
|
|
163
|
-
icon:
|
|
164
|
+
icon: /*#__PURE__*/_jsx(CirclePlusIcon, {
|
|
165
|
+
size: 24
|
|
166
|
+
}),
|
|
164
167
|
iconPosition: "left",
|
|
165
168
|
margin: false,
|
|
166
169
|
onClick: handleOpenDrawer,
|
|
@@ -1 +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=\"medium\"\n >\n {t('general:selectLabel', { label: hierarchyLabel })}\n </Button>\n )}\n </div>\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n <HierarchyDrawer\n hasMany={hasMany}\n initialSelections={initialSelections}\n onSave={handleDrawerSave}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ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AAQjC;;;AAIhB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.client.js","names":["getTranslation","React","useCallback","useMemo","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","useField","CirclePlusIcon","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","size","iconPosition","margin","onClick","onSave"],"sources":["../../../../src/elements/Hierarchy/Field/index.client.tsx"],"sourcesContent":["'use client'\nimport type { RelationshipFieldClientProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useMemo } from 'react'\n\nimport type { SelectionWithPath } from '../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 { CirclePlusIcon } from '../../../icons/CirclePlus/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { RenderCustomComponent } from '../../RenderCustomComponent/index.js'\nimport { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js'\nimport { SelectedHierarchies } from './SelectedHierarchies.js'\nimport './index.css'\n\nconst baseClass = 'hierarchy-field'\n\ntype Value = (number | string)[] | null | (number | string)\n\nexport type HierarchyFieldClientProps = {\n Icon?: React.ReactNode\n} & RelationshipFieldClientProps\n\nexport const HierarchyFieldClient: React.FC<HierarchyFieldClientProps> = (props) => {\n const {\n field,\n field: {\n admin: { className, description } = {},\n hasMany,\n label,\n localized,\n relationTo: relationToProp,\n required,\n },\n Icon,\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const hierarchySlug = Array.isArray(relationToProp) ? relationToProp[0] : relationToProp\n\n const { getEntityConfig } = useConfig()\n const { collectionSlug: documentCollectionSlug } = useDocumentInfo()\n const { i18n, t } = useTranslation()\n\n const collectionConfig = getEntityConfig({ collectionSlug: hierarchySlug })\n\n const memoizedValidate = useCallback(\n (value: Value, validationOptions: Parameters<typeof validate>[1]) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n path,\n setValue,\n showError,\n value,\n } = useField<Value>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n // Normalize value to array of IDs for display\n const selectedIds = useMemo((): (number | string)[] => {\n if (!value) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value]\n }, [value])\n\n // Initialize selections for the 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={<CirclePlusIcon size={24} />}\n iconPosition=\"left\"\n margin={false}\n onClick={handleOpenDrawer}\n size=\"medium\"\n >\n {t('general:selectLabel', { label: hierarchyLabel })}\n </Button>\n )}\n </div>\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n <HierarchyDrawer\n hasMany={hasMany}\n initialSelections={initialSelections}\n onSave={handleDrawerSave}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAI5C,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,mBAAmB,QAAQ;AACpC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAQlB,OAAO,MAAMC,oBAAA,GAA6DC,KAAA;EACxE,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC;MAAW,CAAE,GAAG,CAAC,CAAC;MACtCC,OAAO;MACPC,KAAK;MACLC,SAAS;MACTC,UAAA,EAAYC,cAAc;MAC1BC;IAAQ,CACT;IACDC,IAAI;IACJC,IAAA,EAAMC,aAAa;IACnBC,QAAQ;IACRC;EAAQ,CACT,GAAGf,KAAA;EAEJ,MAAMgB,aAAA,GAAgBC,KAAA,CAAMC,OAAO,CAACT,cAAA,IAAkBA,cAAc,CAAC,EAAE,GAAGA,cAAA;EAE1E,MAAM;IAAEU;EAAe,CAAE,GAAG5B,SAAA;EAC5B,MAAM;IAAE6B,cAAA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,MAAA,EAAQ;UACRC,OAAA,EAASnB,gBAAA;UACTgB,IAAA,EAAK;oBAEJpD,CAAA,CAAE,uBAAuB;YAAEjB,KAAA,EAAOsD;UAAe;;UAIvD/B,UAAA,E,aACDwC,IAAA,CAAC1E,qBAAA;QACC2E,eAAA,EAAiBvC,WAAA;QACjBwC,QAAA,eAAUF,IAAA,CAACrF,gBAAA;UAAiBoB,WAAA,EAAaA,WAAA;UAAaQ,IAAA,EAAMA;;;qBAGhEyD,IAAA,CAAC1B,eAAA;MACCtC,OAAA,EAASA,OAAA;MACTmC,iBAAA,EAAmBA,iBAAA;MACnBuC,MAAA,EAAQjC;;;AAIhB","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.hierarchy-field .field-type__wrap {
|
|
3
|
+
gap: var(--spacer-2);
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
display: flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.hierarchy-field .field-label {
|
|
9
|
+
display: flex;
|
|
10
|
+
font-family: var(--text-body-large-font-family);
|
|
11
|
+
font-size: var(--text-body-large-font-size);
|
|
12
|
+
font-weight: var(--text-body-large-font-weight);
|
|
13
|
+
line-height: var(--text-body-large-line-height);
|
|
14
|
+
letter-spacing: var(--text-body-large-letter-spacing);
|
|
15
|
+
margin: unset;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.hierarchy-field__label {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: var(--spacer-1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.hierarchy-field__content {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
gap: var(--spacer-2-5);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.hierarchy-field__manage-button {
|
|
31
|
+
align-self: flex-start;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.hierarchy-field--read-only .hierarchy-field__content {
|
|
35
|
+
opacity: 0.75;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/MoveMany/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAyC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/MoveMany/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAe7D,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,EACf,aAAa,EACb,IAAI,EACJ,WAAW,EACX,SAAS,EACT,UAAU,GACX,EAAE,aAAa,qBA4Qf"}
|
|
@@ -16,7 +16,6 @@ import { ConfirmationModal } from '../../ConfirmationModal/index.js';
|
|
|
16
16
|
import { ListSelectionButton } from '../../ListSelection/index.js';
|
|
17
17
|
import { Translation } from '../../Translation/index.js';
|
|
18
18
|
import { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js';
|
|
19
|
-
import './index.scss';
|
|
20
19
|
export const baseClass = 'move-many';
|
|
21
20
|
/**
|
|
22
21
|
* Gets the parent field name from the hierarchy config.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useModal","getTranslation","formatAdminURL","qs","React","useCallback","useMemo","useState","toast","useConfig","useDocumentSelection","useLocale","useTranslation","requests","ConfirmationModal","ListSelectionButton","Translation","useHierarchyDrawer","baseClass","getParentFieldName","hierarchyConfig","config","hierarchy","undefined","parentFieldName","MoveMany","currentParentID","hierarchySlug","Icon","modalPrefix","onSuccess","selections","i18n","t","code","locale","openModal","collections","routes","api","getSelectionsWithMetadata","destination","setDestination","confirmMoveDrawerSlug","requiredCollections","selectionsWithMeta","required","Set","collectionSlug","items","Object","entries","metadata","allowedCollections","slug","add","size","Array","from","disabledIds","parentIds","ids","length","HierarchyDrawer","closeDrawer","openDrawer","filterByCollection","hierarchyCollectionSlug","count","label","totalCount","labels","find","c","collectionLabel","plural","singular","push","join","hierarchyCollectionConfig","canMove","handleDrawerSave","selectionsMap","firstSelection","values","next","value","destinationId","id","destinationTitle","path","title","String","handleMoveToRoot","handleConfirmMove","totalMoved","hasErrors","queryString","stringify","where","in","addQueryPrefix","url","apiRoute","response","patch","body","JSON","headers","language","credentials","json","status","errors","error","message","description","map","movedCount","docs","successKey","success","_err","_jsxs","Fragment","_jsx","className","onClick","hasMany","initialSelections","onMoveToRoot","onSave","showMoveToRoot","elements","1","children","i18nKey","variables","confirmingLabel","heading","modalSlug","onConfirm"],"sources":["../../../../src/elements/Hierarchy/MoveMany/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useMemo, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type { SelectionWithPath } from '../Drawer/types.js'\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentSelection } from '../../../providers/DocumentSelection/index.js'\nimport { useLocale } from '../../../providers/Locale/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { requests } from '../../../utilities/api.js'\nimport { ConfirmationModal } from '../../ConfirmationModal/index.js'\nimport { ListSelectionButton } from '../../ListSelection/index.js'\nimport { Translation } from '../../Translation/index.js'\nimport { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js'\nimport './index.scss'\n\nexport const baseClass = 'move-many'\n\ntype MoveManyProps = {\n /** Current parent ID - drawer will open expanded to this location */\n currentParentID?: null | number | string\n /** The hierarchy collection slug (e.g., 'folders') */\n hierarchySlug: string\n /** Icon to display in the hierarchy drawer */\n Icon?: React.ReactNode\n /** When multiple MoveMany components are rendered on the page, this will differentiate them */\n modalPrefix?: string\n /** Callback after successful move */\n onSuccess?: () => void\n /** Selections grouped by collection slug */\n selections: Record<string, { ids: (number | string)[] }>\n}\n\n/**\n * Gets the parent field name from the hierarchy config.\n */\nfunction getParentFieldName(\n hierarchyConfig: ClientCollectionConfig | undefined,\n): string | undefined {\n const config =\n hierarchyConfig?.hierarchy && typeof hierarchyConfig.hierarchy === 'object'\n ? hierarchyConfig.hierarchy\n : undefined\n return config?.parentFieldName\n}\n\nexport function MoveMany({\n currentParentID,\n hierarchySlug,\n Icon,\n modalPrefix,\n onSuccess,\n selections,\n}: MoveManyProps) {\n const { i18n, t } = useTranslation()\n const { code: locale } = useLocale()\n const { openModal } = useModal()\n const {\n config: {\n collections,\n routes: { api },\n },\n } = useConfig()\n\n const { getSelectionsWithMetadata } = useDocumentSelection()\n\n const [destination, setDestination] = useState<{\n id: null | number | string\n title: string\n } | null>(null)\n\n const confirmMoveDrawerSlug = `${modalPrefix ? `${modalPrefix}-` : ''}confirm-move-many`\n\n // Compute required collections from selection metadata\n // For related items: add their collection slug\n // For folders: add their allowedCollections values\n const requiredCollections = useMemo(() => {\n const selectionsWithMeta = getSelectionsWithMetadata()\n const required = new Set<string>()\n\n for (const [collectionSlug, { selections: items }] of Object.entries(selectionsWithMeta)) {\n if (collectionSlug === hierarchySlug) {\n // For folders, add their allowedCollections to required set\n for (const { metadata } of items) {\n if (metadata.allowedCollections) {\n for (const slug of metadata.allowedCollections) {\n required.add(slug)\n }\n }\n }\n } else {\n // For related items, add their collection slug\n required.add(collectionSlug)\n }\n }\n\n return required.size > 0 ? Array.from(required) : undefined\n }, [getSelectionsWithMetadata, hierarchySlug])\n\n // Folders being moved cannot be selected as destination (can't move into themselves)\n const disabledIds = useMemo(() => {\n const parentIds = selections[hierarchySlug]?.ids\n return parentIds?.length ? new Set(parentIds) : undefined\n }, [selections, hierarchySlug])\n\n const [HierarchyDrawer, , { closeDrawer, openDrawer }] = useHierarchyDrawer({\n disabledIds,\n filterByCollection: requiredCollections,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n // Calculate total count and label\n const { count, label } = useMemo(() => {\n let totalCount = 0\n const labels: string[] = []\n\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n const config = collections.find((c) => c.slug === collectionSlug)\n\n if (config && ids.length > 0) {\n totalCount += ids.length\n const collectionLabel = getTranslation(\n ids.length > 1 ? config.labels.plural : config.labels.singular,\n i18n,\n )\n labels.push(collectionLabel)\n }\n }\n\n return {\n count: totalCount,\n label: labels.join(', '),\n }\n }, [selections, collections, i18n])\n\n const hierarchyCollectionConfig = collections.find((c) => c.slug === hierarchySlug)\n const parentFieldName = getParentFieldName(hierarchyCollectionConfig)\n\n // Check if hierarchy has a valid parentFieldName\n const canMove = parentFieldName !== undefined\n\n const handleDrawerSave = useCallback(\n ({ selections: selectionsMap }: { selections: Map<number | string, SelectionWithPath> }) => {\n if (selectionsMap.size === 0) {\n return\n }\n\n const firstSelection = selectionsMap.values().next().value\n const destinationId = firstSelection?.id\n const destinationTitle =\n firstSelection?.path?.[firstSelection.path.length - 1]?.title || String(destinationId)\n\n setDestination({ id: destinationId, title: destinationTitle })\n openModal(confirmMoveDrawerSlug)\n },\n [openModal, confirmMoveDrawerSlug],\n )\n\n const handleMoveToRoot = useCallback(() => {\n setDestination({ id: null, title: t('hierarchy:noParent') })\n openModal(confirmMoveDrawerSlug)\n }, [openModal, confirmMoveDrawerSlug, t])\n\n const handleConfirmMove = useCallback(async () => {\n if (destination === null) {\n return\n }\n\n let totalMoved = 0\n let hasErrors = false\n\n try {\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n if (ids.length === 0) {\n continue\n }\n\n const queryString = qs.stringify(\n {\n locale,\n where: { id: { in: ids } },\n },\n { addQueryPrefix: true },\n )\n\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n })\n\n const response = await requests.patch(url, {\n body: JSON.stringify({ [parentFieldName]: destination.id }),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n credentials: 'include',\n },\n })\n\n const json = await response.json()\n\n if (response.status >= 400) {\n hasErrors = true\n\n if (json?.errors?.length > 0) {\n toast.error(json.message || t('error:unknown'), {\n description: json.errors\n .map((error: { message: string }) => error.message)\n .join('\\n'),\n })\n } else {\n toast.error(json?.message || t('error:unknown'))\n }\n\n continue\n }\n\n const movedCount = json?.docs?.length || 0\n totalMoved += movedCount\n\n if (json?.errors?.length > 0) {\n hasErrors = true\n toast.error(json.message, {\n description: json.errors.map((error: { message: string }) => error.message).join('\\n'),\n })\n }\n }\n\n if (totalMoved > 0) {\n const successKey =\n destination.id === null ? 'hierarchy:itemsMovedToRoot' : 'hierarchy:itemsMovedTo'\n\n toast.success(\n t(successKey, {\n destination: destination.title,\n title: label,\n }),\n )\n }\n\n if (!hasErrors || totalMoved > 0) {\n closeDrawer()\n onSuccess?.()\n }\n } catch (_err) {\n toast.error(t('error:unknown'))\n } finally {\n setDestination(null)\n }\n }, [\n closeDrawer,\n destination,\n selections,\n parentFieldName,\n locale,\n api,\n i18n,\n t,\n label,\n onSuccess,\n ])\n\n if (count === 0 || !canMove) {\n return null\n }\n\n return (\n <React.Fragment>\n <ListSelectionButton\n aria-label={t('general:move')}\n className={`${baseClass}__toggle`}\n onClick={openDrawer}\n >\n {t('general:move')}\n </ListSelectionButton>\n <HierarchyDrawer\n hasMany={false}\n initialSelections={currentParentID ? [currentParentID] : null}\n onMoveToRoot={handleMoveToRoot}\n onSave={handleDrawerSave}\n showMoveToRoot\n />\n <ConfirmationModal\n body={\n <p>\n {destination?.id === null ? (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"hierarchy:moveItemsToRootConfirmation\"\n t={t}\n variables={{\n count,\n label,\n }}\n />\n ) : (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"general:moveConfirm\"\n t={t}\n variables={{\n count,\n destination: destination?.title || '',\n label,\n }}\n />\n )}\n </p>\n }\n confirmingLabel={t('general:moving')}\n heading={t('general:confirmMove')}\n modalSlug={confirmMoveDrawerSlug}\n onConfirm={handleConfirmMove}\n />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACtD,SAASC,KAAK,QAAQ;AAItB,SAASC,SAAS,QAAQ;AAC1B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,WAAW,QAAQ;AAC5B,SAASC,kBAAkB,QAAQ;AACnC,OAAO;AAEP,OAAO,MAAMC,SAAA,GAAY;AAiBzB;;;AAGA,SAASC,mBACPC,eAAmD;EAEnD,MAAMC,MAAA,GACJD,eAAA,EAAiBE,SAAA,IAAa,OAAOF,eAAA,CAAgBE,SAAS,KAAK,WAC/DF,eAAA,CAAgBE,SA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C,CAAA,CAAE;qBAEL4F,IAAA,CAAC9D,eAAA;MACCiE,OAAA,EAAS;MACTC,iBAAA,EAAmBvG,eAAA,GAAkB,CAACA,eAAA,CAAgB,GAAG;MACzDwG,YAAA,EAAcrC,gBAAA;MACdsC,MAAA,EAAQlD,gBAAA;MACRmD,cAAc;qBAEhBP,IAAA,CAAC/G,iBAAA;MACC4F,IAAA,eACEmB,IAAA,CAAC;kBACEpF,WAAA,EAAa+C,EAAA,KAAO,oBACnBqC,IAAA,CAAC7G,WAAA;UACCqH,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC;YAAQ,CAAE,kBAAKV,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACAC;UACF;0BAGFwD,IAAA,CAAC7G,WAAA;UACCqH,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC,QAAQ,EAARA;YAAQ,CAAE,kBAAKV,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACA3B,WAAA,EAAaA,WAAA,EAAakD,KAAA,IAAS;YACnCtB;UACF;;;MAKRqE,eAAA,EAAiBzG,CAAA,CAAE;MACnB0G,OAAA,EAAS1G,CAAA,CAAE;MACX2G,SAAA,EAAWjG,qBAAA;MACXkG,SAAA,EAAW/C;;;AAInB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useModal","getTranslation","formatAdminURL","qs","React","useCallback","useMemo","useState","toast","useConfig","useDocumentSelection","useLocale","useTranslation","requests","ConfirmationModal","ListSelectionButton","Translation","useHierarchyDrawer","baseClass","getParentFieldName","hierarchyConfig","config","hierarchy","undefined","parentFieldName","MoveMany","currentParentID","hierarchySlug","Icon","modalPrefix","onSuccess","selections","i18n","t","code","locale","openModal","collections","routes","api","getSelectionsWithMetadata","destination","setDestination","confirmMoveDrawerSlug","requiredCollections","selectionsWithMeta","required","Set","collectionSlug","items","Object","entries","metadata","allowedCollections","slug","add","size","Array","from","disabledIds","parentIds","ids","length","HierarchyDrawer","closeDrawer","openDrawer","filterByCollection","hierarchyCollectionSlug","count","label","totalCount","labels","find","c","collectionLabel","plural","singular","push","join","hierarchyCollectionConfig","canMove","handleDrawerSave","selectionsMap","firstSelection","values","next","value","destinationId","id","destinationTitle","path","title","String","handleMoveToRoot","handleConfirmMove","totalMoved","hasErrors","queryString","stringify","where","in","addQueryPrefix","url","apiRoute","response","patch","body","JSON","headers","language","credentials","json","status","errors","error","message","description","map","movedCount","docs","successKey","success","_err","_jsxs","Fragment","_jsx","className","onClick","hasMany","initialSelections","onMoveToRoot","onSave","showMoveToRoot","elements","1","children","i18nKey","variables","confirmingLabel","heading","modalSlug","onConfirm"],"sources":["../../../../src/elements/Hierarchy/MoveMany/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useMemo, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type { SelectionWithPath } from '../Drawer/types.js'\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentSelection } from '../../../providers/DocumentSelection/index.js'\nimport { useLocale } from '../../../providers/Locale/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { requests } from '../../../utilities/api.js'\nimport { ConfirmationModal } from '../../ConfirmationModal/index.js'\nimport { ListSelectionButton } from '../../ListSelection/index.js'\nimport { Translation } from '../../Translation/index.js'\nimport { useHierarchyDrawer } from '../Drawer/useHierarchyDrawer.js'\n\nexport const baseClass = 'move-many'\n\ntype MoveManyProps = {\n /** Current parent ID - drawer will open expanded to this location */\n currentParentID?: null | number | string\n /** The hierarchy collection slug (e.g., 'folders') */\n hierarchySlug: string\n /** Icon to display in the hierarchy drawer */\n Icon?: React.ReactNode\n /** When multiple MoveMany components are rendered on the page, this will differentiate them */\n modalPrefix?: string\n /** Callback after successful move */\n onSuccess?: () => void\n /** Selections grouped by collection slug */\n selections: Record<string, { ids: (number | string)[] }>\n}\n\n/**\n * Gets the parent field name from the hierarchy config.\n */\nfunction getParentFieldName(\n hierarchyConfig: ClientCollectionConfig | undefined,\n): string | undefined {\n const config =\n hierarchyConfig?.hierarchy && typeof hierarchyConfig.hierarchy === 'object'\n ? hierarchyConfig.hierarchy\n : undefined\n return config?.parentFieldName\n}\n\nexport function MoveMany({\n currentParentID,\n hierarchySlug,\n Icon,\n modalPrefix,\n onSuccess,\n selections,\n}: MoveManyProps) {\n const { i18n, t } = useTranslation()\n const { code: locale } = useLocale()\n const { openModal } = useModal()\n const {\n config: {\n collections,\n routes: { api },\n },\n } = useConfig()\n\n const { getSelectionsWithMetadata } = useDocumentSelection()\n\n const [destination, setDestination] = useState<{\n id: null | number | string\n title: string\n } | null>(null)\n\n const confirmMoveDrawerSlug = `${modalPrefix ? `${modalPrefix}-` : ''}confirm-move-many`\n\n // Compute required collections from selection metadata\n // For related items: add their collection slug\n // For folders: add their allowedCollections values\n const requiredCollections = useMemo(() => {\n const selectionsWithMeta = getSelectionsWithMetadata()\n const required = new Set<string>()\n\n for (const [collectionSlug, { selections: items }] of Object.entries(selectionsWithMeta)) {\n if (collectionSlug === hierarchySlug) {\n // For folders, add their allowedCollections to required set\n for (const { metadata } of items) {\n if (metadata.allowedCollections) {\n for (const slug of metadata.allowedCollections) {\n required.add(slug)\n }\n }\n }\n } else {\n // For related items, add their collection slug\n required.add(collectionSlug)\n }\n }\n\n return required.size > 0 ? Array.from(required) : undefined\n }, [getSelectionsWithMetadata, hierarchySlug])\n\n // Folders being moved cannot be selected as destination (can't move into themselves)\n const disabledIds = useMemo(() => {\n const parentIds = selections[hierarchySlug]?.ids\n return parentIds?.length ? new Set(parentIds) : undefined\n }, [selections, hierarchySlug])\n\n const [HierarchyDrawer, , { closeDrawer, openDrawer }] = useHierarchyDrawer({\n disabledIds,\n filterByCollection: requiredCollections,\n hierarchyCollectionSlug: hierarchySlug,\n Icon,\n })\n\n // Calculate total count and label\n const { count, label } = useMemo(() => {\n let totalCount = 0\n const labels: string[] = []\n\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n const config = collections.find((c) => c.slug === collectionSlug)\n\n if (config && ids.length > 0) {\n totalCount += ids.length\n const collectionLabel = getTranslation(\n ids.length > 1 ? config.labels.plural : config.labels.singular,\n i18n,\n )\n labels.push(collectionLabel)\n }\n }\n\n return {\n count: totalCount,\n label: labels.join(', '),\n }\n }, [selections, collections, i18n])\n\n const hierarchyCollectionConfig = collections.find((c) => c.slug === hierarchySlug)\n const parentFieldName = getParentFieldName(hierarchyCollectionConfig)\n\n // Check if hierarchy has a valid parentFieldName\n const canMove = parentFieldName !== undefined\n\n const handleDrawerSave = useCallback(\n ({ selections: selectionsMap }: { selections: Map<number | string, SelectionWithPath> }) => {\n if (selectionsMap.size === 0) {\n return\n }\n\n const firstSelection = selectionsMap.values().next().value\n const destinationId = firstSelection?.id\n const destinationTitle =\n firstSelection?.path?.[firstSelection.path.length - 1]?.title || String(destinationId)\n\n setDestination({ id: destinationId, title: destinationTitle })\n openModal(confirmMoveDrawerSlug)\n },\n [openModal, confirmMoveDrawerSlug],\n )\n\n const handleMoveToRoot = useCallback(() => {\n setDestination({ id: null, title: t('hierarchy:noParent') })\n openModal(confirmMoveDrawerSlug)\n }, [openModal, confirmMoveDrawerSlug, t])\n\n const handleConfirmMove = useCallback(async () => {\n if (destination === null) {\n return\n }\n\n let totalMoved = 0\n let hasErrors = false\n\n try {\n for (const [collectionSlug, { ids }] of Object.entries(selections)) {\n if (ids.length === 0) {\n continue\n }\n\n const queryString = qs.stringify(\n {\n locale,\n where: { id: { in: ids } },\n },\n { addQueryPrefix: true },\n )\n\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n })\n\n const response = await requests.patch(url, {\n body: JSON.stringify({ [parentFieldName]: destination.id }),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n credentials: 'include',\n },\n })\n\n const json = await response.json()\n\n if (response.status >= 400) {\n hasErrors = true\n\n if (json?.errors?.length > 0) {\n toast.error(json.message || t('error:unknown'), {\n description: json.errors\n .map((error: { message: string }) => error.message)\n .join('\\n'),\n })\n } else {\n toast.error(json?.message || t('error:unknown'))\n }\n\n continue\n }\n\n const movedCount = json?.docs?.length || 0\n totalMoved += movedCount\n\n if (json?.errors?.length > 0) {\n hasErrors = true\n toast.error(json.message, {\n description: json.errors.map((error: { message: string }) => error.message).join('\\n'),\n })\n }\n }\n\n if (totalMoved > 0) {\n const successKey =\n destination.id === null ? 'hierarchy:itemsMovedToRoot' : 'hierarchy:itemsMovedTo'\n\n toast.success(\n t(successKey, {\n destination: destination.title,\n title: label,\n }),\n )\n }\n\n if (!hasErrors || totalMoved > 0) {\n closeDrawer()\n onSuccess?.()\n }\n } catch (_err) {\n toast.error(t('error:unknown'))\n } finally {\n setDestination(null)\n }\n }, [\n closeDrawer,\n destination,\n selections,\n parentFieldName,\n locale,\n api,\n i18n,\n t,\n label,\n onSuccess,\n ])\n\n if (count === 0 || !canMove) {\n return null\n }\n\n return (\n <React.Fragment>\n <ListSelectionButton\n aria-label={t('general:move')}\n className={`${baseClass}__toggle`}\n onClick={openDrawer}\n >\n {t('general:move')}\n </ListSelectionButton>\n <HierarchyDrawer\n hasMany={false}\n initialSelections={currentParentID ? [currentParentID] : null}\n onMoveToRoot={handleMoveToRoot}\n onSave={handleDrawerSave}\n showMoveToRoot\n />\n <ConfirmationModal\n body={\n <p>\n {destination?.id === null ? (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"hierarchy:moveItemsToRootConfirmation\"\n t={t}\n variables={{\n count,\n label,\n }}\n />\n ) : (\n <Translation\n elements={{\n '1': ({ children }) => <strong>{children}</strong>,\n }}\n i18nKey=\"general:moveConfirm\"\n t={t}\n variables={{\n count,\n destination: destination?.title || '',\n label,\n }}\n />\n )}\n </p>\n }\n confirmingLabel={t('general:moving')}\n heading={t('general:confirmMove')}\n modalSlug={confirmMoveDrawerSlug}\n onConfirm={handleConfirmMove}\n />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACtD,SAASC,KAAK,QAAQ;AAItB,SAASC,SAAS,QAAQ;AAC1B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,WAAW,QAAQ;AAC5B,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,SAAA,GAAY;AAiBzB;;;AAGA,SAASC,mBACPC,eAAmD;EAEnD,MAAMC,MAAA,GACJD,eAAA,EAAiBE,SAAA,IAAa,OAAOF,eAAA,CAAgBE,SAAS,KAAK,WAC/DF,eAAA,CAAgBE,SAAS,GACzBC,SAAA;EACN,OAAOF,MAAA,EAAQG,eAAA;AACjB;AAEA,OAAO,SAASC,SAAS;EACvBC,eAAe;EACfC,aAAa;EACbC,IAAI;EACJC,WAAW;EACXC,SAAS;EACTC;AAAU,CACI;EACd,MAAM;IAAEC,IAAI;IAAEC;EAAC,CAAE,GAAGrB,cAAA;EACpB,MAAM;IAAEsB,IAAA,EAAMC;EAAM,CAAE,GAAGxB,SAAA;EACzB,MAAM;IAAEyB;EAAS,CAAE,GAAGpC,QAAA;EACtB,MAAM;IACJqB,MAAA,EAAQ;MACNgB,WAAW;MACXC,MAAA,EAAQ;QAA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V,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACAC;UACF;0BAGFwD,IAAA,CAAC7G,WAAA;UACCqH,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC,QAAQ,EAARA;YAAQ,CAAE,kBAAKV,IAAA,CAAC;wBAAQU;;UAClC;UACAC,OAAA,EAAQ;UACRvG,CAAA,EAAGA,CAAA;UACHwG,SAAA,EAAW;YACTrE,KAAA;YACA3B,WAAA,EAAaA,WAAA,EAAakD,KAAA,IAAS;YACnCtB;UACF;;;MAKRqE,eAAA,EAAiBzG,CAAA,CAAE;MACnB0G,OAAA,EAAS1G,CAAA,CAAE;MACX2G,SAAA,EAAWjG,qBAAA;MACXkG,SAAA,EAAW/C;;;AAInB","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Tree-specific overrides for the shared LoadMoreRow component */
|
|
2
|
+
|
|
3
|
+
.tree__load-more.load-more-row {
|
|
4
|
+
padding-top: 0;
|
|
5
|
+
padding-left: calc(
|
|
6
|
+
(var(--tree-depth, 0) * var(--tree-indent)) + (var(--spacer-1) * var(--tree-depth)) +
|
|
7
|
+
var(--spacer-2-5) - 2px
|
|
8
|
+
);
|
|
9
|
+
height: var(--tree-node-content-height);
|
|
10
|
+
position: relative;
|
|
11
|
+
margin-block: var(--spacer-1) var(--spacer-2);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Tree-specific button styling (uses native button for focus management) */
|
|
15
|
+
.tree__load-more-button {
|
|
16
|
+
color: var(--color-text);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
text-decoration: underline;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tree__load-more-button:hover {
|
|
22
|
+
color: var(--color-text-secondary);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.tree__load-more-button:active {
|
|
26
|
+
color: var(--color-text);
|
|
27
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/Hierarchy/Tree/LoadMore/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/Hierarchy/Tree/LoadMore/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,aAAa,CAAA;AAEpB,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAA;IAChD,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAiB5C,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { LoadMoreRow } from '../../../LoadMoreRow/index.js';
|
|
6
6
|
import { LoadMoreButton } from './LoadMoreButton.js';
|
|
7
|
-
import './index.
|
|
7
|
+
import './index.css';
|
|
8
8
|
export const LoadMore = ({
|
|
9
9
|
id,
|
|
10
10
|
currentCount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","LoadMoreRow","LoadMoreButton","LoadMore","id","currentCount","depth","onLoadMore","totalDocs","_jsx","className","hasMore","loadMoreButton","style"],"sources":["../../../../../src/elements/Hierarchy/Tree/LoadMore/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { LoadMoreRow } from '../../../LoadMoreRow/index.js'\nimport { LoadMoreButton } from './LoadMoreButton.js'\nimport './index.
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","LoadMoreRow","LoadMoreButton","LoadMore","id","currentCount","depth","onLoadMore","totalDocs","_jsx","className","hasMore","loadMoreButton","style"],"sources":["../../../../../src/elements/Hierarchy/Tree/LoadMore/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { LoadMoreRow } from '../../../LoadMoreRow/index.js'\nimport { LoadMoreButton } from './LoadMoreButton.js'\nimport './index.css'\n\ntype LoadMoreProps = {\n currentCount: number\n depth: number\n id: string\n onLoadMore: (() => Promise<void>) | (() => void)\n totalDocs: number\n}\n\nexport const LoadMore: React.FC<LoadMoreProps> = ({\n id,\n currentCount,\n depth,\n onLoadMore,\n totalDocs,\n}) => {\n return (\n <LoadMoreRow\n className=\"tree__load-more\"\n currentCount={currentCount}\n hasMore={currentCount < totalDocs}\n loadMoreButton={<LoadMoreButton id={id} onLoadMore={onLoadMore} />}\n style={{ '--tree-depth': depth } as React.CSSProperties}\n totalDocs={totalDocs}\n />\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,MAAW;AAElB,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAUP,OAAO,MAAMC,QAAA,GAAoCA,CAAC;EAChDC,EAAE;EACFC,YAAY;EACZC,KAAK;EACLC,UAAU;EACVC;AAAS,CACV;EACC,oBACEC,IAAA,CAACR,WAAA;IACCS,SAAA,EAAU;IACVL,YAAA,EAAcA,YAAA;IACdM,OAAA,EAASN,YAAA,GAAeG,SAAA;IACxBI,cAAA,eAAgBH,IAAA,CAACP,cAAA;MAAeE,EAAA,EAAIA,EAAA;MAAIG,UAAA,EAAYA;;IACpDM,KAAA,EAAO;MAAE,gBAAgBP;IAAM;IAC/BE,SAAA,EAAWA;;AAGjB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeFocusContext.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Tree/TreeFocusContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"TreeFocusContext.d.ts","sourceRoot":"","sources":["../../../../src/elements/Hierarchy/Tree/TreeFocusContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,KAAK,aAAa,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACjC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;CAC3B,CAAA;AAED,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAC7C,YAAY,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAA;IAC3C,YAAY,EAAE,CAAC,EAAE,EAAE,IAAI,GAAG,MAAM,KAAK,IAAI,CAAA;IACzC,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CACrC,CAAA;AAID,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAgFrE,CAAA;AAED,eAAO,MAAM,YAAY,4BAMxB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,oBAI9B;IACD,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACjC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;CAC3B;;;;CAsCA,CAAA"}
|