@payloadcms/ui 4.0.0-internal.f05c47f → 4.0.0-internal.f715c6e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/AppHeader/index.css +0 -1
- package/dist/elements/ArrayAction/index.d.ts +0 -1
- package/dist/elements/ArrayAction/index.d.ts.map +1 -1
- package/dist/elements/ArrayAction/index.js +32 -45
- package/dist/elements/ArrayAction/index.js.map +1 -1
- package/dist/elements/Autosave/index.d.ts.map +1 -1
- package/dist/elements/Autosave/index.js +0 -3
- package/dist/elements/Autosave/index.js.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +2 -6
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/Button/index.css +2 -2
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts +0 -10
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts.map +1 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js +0 -55
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js.map +1 -1
- package/dist/elements/ColumnSelection/Popup.d.ts.map +1 -1
- package/dist/elements/ColumnSelection/Popup.js +3 -3
- package/dist/elements/ColumnSelection/Popup.js.map +1 -1
- package/dist/elements/ColumnSelection/matchesColumnSearch.d.ts +10 -0
- package/dist/elements/ColumnSelection/matchesColumnSearch.d.ts.map +1 -0
- package/dist/elements/ColumnSelection/matchesColumnSearch.js +21 -0
- package/dist/elements/ColumnSelection/matchesColumnSearch.js.map +1 -0
- package/dist/{utilities/matchesSearchQuery.spec.js → elements/ColumnSelection/matchesColumnSearch.spec.js} +29 -29
- package/dist/elements/ColumnSelection/matchesColumnSearch.spec.js.map +1 -0
- package/dist/elements/Combobox/index.css +23 -76
- package/dist/elements/Combobox/index.d.ts +0 -7
- package/dist/elements/Combobox/index.d.ts.map +1 -1
- package/dist/elements/Combobox/index.js +20 -58
- package/dist/elements/Combobox/index.js.map +1 -1
- package/dist/elements/CopyToClipboard/index.d.ts +0 -1
- package/dist/elements/CopyToClipboard/index.d.ts.map +1 -1
- package/dist/elements/CopyToClipboard/index.js +8 -10
- package/dist/elements/CopyToClipboard/index.js.map +1 -1
- package/dist/elements/DeleteDocument/index.d.ts.map +1 -1
- package/dist/elements/DeleteDocument/index.js +2 -9
- package/dist/elements/DeleteDocument/index.js.map +1 -1
- package/dist/elements/DeleteMany/index.d.ts.map +1 -1
- package/dist/elements/DeleteMany/index.js +1 -4
- package/dist/elements/DeleteMany/index.js.map +1 -1
- package/dist/elements/Drawer/index.css +4 -10
- package/dist/elements/DuplicateDocument/SelectLocalesDrawer/index.js +2 -3
- package/dist/elements/DuplicateDocument/SelectLocalesDrawer/index.js.map +1 -1
- package/dist/elements/DuplicateDocument/index.d.ts.map +1 -1
- package/dist/elements/DuplicateDocument/index.js +1 -6
- package/dist/elements/DuplicateDocument/index.js.map +1 -1
- package/dist/elements/EditMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/EditMany/DrawerContent.js +1 -4
- package/dist/elements/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/FileManager/FileToolbar/index.d.ts.map +1 -1
- package/dist/elements/FileManager/FileToolbar/index.js +0 -3
- package/dist/elements/FileManager/FileToolbar/index.js.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/index.js +1 -4
- package/dist/elements/Hierarchy/ColumnBrowser/index.js.map +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.js +1 -4
- package/dist/elements/Hierarchy/Field/SelectedHierarchies.js.map +1 -1
- package/dist/elements/Hierarchy/Modal/fetchAncestorPath.d.ts +1 -2
- package/dist/elements/Hierarchy/Modal/fetchAncestorPath.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Modal/fetchAncestorPath.js +0 -2
- package/dist/elements/Hierarchy/Modal/fetchAncestorPath.js.map +1 -1
- package/dist/elements/Hierarchy/Modal/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Modal/index.js +0 -3
- package/dist/elements/Hierarchy/Modal/index.js.map +1 -1
- package/dist/elements/Hierarchy/MoveMany/index.d.ts.map +1 -1
- package/dist/elements/Hierarchy/MoveMany/index.js +1 -4
- package/dist/elements/Hierarchy/MoveMany/index.js.map +1 -1
- package/dist/elements/Hierarchy/Search/useHierarchySearch.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Search/useHierarchySearch.js +0 -3
- package/dist/elements/Hierarchy/Search/useHierarchySearch.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/useChildren.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/useChildren.js +1 -4
- package/dist/elements/Hierarchy/Tree/useChildren.js.map +1 -1
- package/dist/elements/IDLabel/index.css +0 -6
- package/dist/elements/IDLabel/index.d.ts +1 -1
- package/dist/elements/IDLabel/index.d.ts.map +1 -1
- package/dist/elements/IDLabel/index.js +21 -16
- package/dist/elements/IDLabel/index.js.map +1 -1
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.d.ts +7 -1
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.d.ts.map +1 -1
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.js +32 -26
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.js.map +1 -1
- package/dist/elements/ListHeader/TitleActions/ListEmptyTrashButton.d.ts.map +1 -1
- package/dist/elements/ListHeader/TitleActions/ListEmptyTrashButton.js +2 -6
- package/dist/elements/ListHeader/TitleActions/ListEmptyTrashButton.js.map +1 -1
- package/dist/elements/PermanentlyDeleteButton/index.d.ts.map +1 -1
- package/dist/elements/PermanentlyDeleteButton/index.js +1 -4
- package/dist/elements/PermanentlyDeleteButton/index.js.map +1 -1
- package/dist/elements/Popup/PopupButtonList/index.css +1 -1
- package/dist/elements/Popup/index.js +1 -1
- package/dist/elements/Popup/index.js.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.js +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.js.map +1 -1
- package/dist/elements/PublishButton/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/index.js +2 -6
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/PublishMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/PublishMany/DrawerContent.js +1 -4
- package/dist/elements/PublishMany/DrawerContent.js.map +1 -1
- package/dist/elements/QueryPresets/QueryPresetBar/index.js +3 -1
- package/dist/elements/QueryPresets/QueryPresetBar/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +2 -5
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/RestoreButton/index.d.ts.map +1 -1
- package/dist/elements/RestoreButton/index.js +1 -4
- package/dist/elements/RestoreButton/index.js.map +1 -1
- package/dist/elements/RestoreMany/index.d.ts.map +1 -1
- package/dist/elements/RestoreMany/index.js +0 -3
- package/dist/elements/RestoreMany/index.js.map +1 -1
- package/dist/elements/SortHeader/index.d.ts.map +1 -1
- package/dist/elements/SortHeader/index.js +26 -29
- package/dist/elements/SortHeader/index.js.map +1 -1
- package/dist/elements/StepNav/index.css +14 -64
- package/dist/elements/StepNav/index.d.ts.map +1 -1
- package/dist/elements/StepNav/index.js +69 -145
- package/dist/elements/StepNav/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js +11 -3
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/Table/OrderableTable.d.ts.map +1 -1
- package/dist/elements/Table/OrderableTable.js +1 -3
- package/dist/elements/Table/OrderableTable.js.map +1 -1
- package/dist/elements/Table/RelationshipProvider/index.d.ts.map +1 -1
- package/dist/elements/Table/RelationshipProvider/index.js +23 -29
- package/dist/elements/Table/RelationshipProvider/index.js.map +1 -1
- package/dist/elements/UnpublishButton/index.d.ts.map +1 -1
- package/dist/elements/UnpublishButton/index.js +1 -4
- package/dist/elements/UnpublishButton/index.js.map +1 -1
- package/dist/elements/UnpublishMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/UnpublishMany/DrawerContent.js +1 -4
- package/dist/elements/UnpublishMany/DrawerContent.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/index.js +0 -3
- package/dist/elements/WhereBuilder/Condition/Relationship/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -5
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +1 -1
- package/dist/exports/client/index.js.map +3 -3
- package/dist/fields/Array/ArrayRow.d.ts +0 -1
- package/dist/fields/Array/ArrayRow.d.ts.map +1 -1
- package/dist/fields/Array/ArrayRow.js +0 -2
- package/dist/fields/Array/ArrayRow.js.map +1 -1
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +10 -38
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/BlockRow.d.ts +0 -1
- package/dist/fields/Blocks/BlockRow.d.ts.map +1 -1
- package/dist/fields/Blocks/BlockRow.js +0 -2
- package/dist/fields/Blocks/BlockRow.js.map +1 -1
- package/dist/fields/Blocks/RowActions.d.ts +0 -1
- package/dist/fields/Blocks/RowActions.d.ts.map +1 -1
- package/dist/fields/Blocks/RowActions.js +19 -22
- package/dist/fields/Blocks/RowActions.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +7 -35
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Relationship/Input.d.ts.map +1 -1
- package/dist/fields/Relationship/Input.js +1 -5
- package/dist/fields/Relationship/Input.js.map +1 -1
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js +1 -4
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +1 -4
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/hooks/usePayloadAPI.d.ts.map +1 -1
- package/dist/hooks/usePayloadAPI.js +40 -44
- package/dist/hooks/usePayloadAPI.js.map +1 -1
- package/dist/icons/Edit/index.d.ts +1 -0
- package/dist/icons/Edit/index.d.ts.map +1 -1
- package/dist/icons/Edit/index.js +4 -4
- package/dist/icons/Edit/index.js.map +1 -1
- package/dist/providers/Actions/index.d.ts +0 -1
- package/dist/providers/Actions/index.d.ts.map +1 -1
- package/dist/providers/Actions/index.js +11 -43
- package/dist/providers/Actions/index.js.map +1 -1
- package/dist/providers/Auth/index.d.ts +56 -2
- package/dist/providers/Auth/index.d.ts.map +1 -1
- package/dist/providers/Auth/index.js +135 -283
- package/dist/providers/Auth/index.js.map +1 -1
- package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/index.js +1 -5
- package/dist/providers/DocumentInfo/index.js.map +1 -1
- package/dist/providers/DocumentInfo/useGetDocPermissions.d.ts +1 -2
- package/dist/providers/DocumentInfo/useGetDocPermissions.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/useGetDocPermissions.js +1 -3
- package/dist/providers/DocumentInfo/useGetDocPermissions.js.map +1 -1
- package/dist/providers/FormErrorHandler/index.d.ts +1 -5
- package/dist/providers/FormErrorHandler/index.d.ts.map +1 -1
- package/dist/providers/FormErrorHandler/index.js.map +1 -1
- package/dist/providers/Hierarchy/index.d.ts.map +1 -1
- package/dist/providers/Hierarchy/index.js +1 -4
- package/dist/providers/Hierarchy/index.js.map +1 -1
- package/dist/providers/Locale/index.d.ts.map +1 -1
- package/dist/providers/Locale/index.js +36 -41
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/providers/Root/index.js +4 -4
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/RouteTransition/ProgressBar/index.js +1 -4
- package/dist/providers/RouteTransition/ProgressBar/index.js.map +1 -1
- package/dist/providers/RouteTransition/index.d.ts +0 -2
- package/dist/providers/RouteTransition/index.d.ts.map +1 -1
- package/dist/providers/RouteTransition/index.js +14 -42
- package/dist/providers/RouteTransition/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/templates/Default/index.d.ts +0 -1
- package/dist/templates/Default/index.d.ts.map +1 -1
- package/dist/templates/Default/index.js +39 -45
- package/dist/templates/Default/index.js.map +1 -1
- package/dist/utilities/filterOutUploadFields.d.ts.map +1 -1
- package/dist/utilities/filterOutUploadFields.js +1 -1
- package/dist/utilities/filterOutUploadFields.js.map +1 -1
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js +0 -8
- package/dist/utilities/initReq.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js +2 -3
- package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.js +7 -7
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.client.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.client.js +66 -104
- package/dist/views/Dashboard/Default/ModularDashboard/index.client.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.css +140 -33
- package/dist/views/HierarchyList/HierarchyTable/index.d.ts.map +1 -1
- package/dist/views/HierarchyList/HierarchyTable/index.js +2 -6
- package/dist/views/HierarchyList/HierarchyTable/index.js.map +1 -1
- package/dist/views/List/ListHeader/index.d.ts +10 -1
- package/dist/views/List/ListHeader/index.d.ts.map +1 -1
- package/dist/views/List/ListHeader/index.js +3 -1
- package/dist/views/List/ListHeader/index.js.map +1 -1
- package/dist/views/List/index.client.d.ts.map +1 -1
- package/dist/views/List/index.client.js +14 -0
- package/dist/views/List/index.client.js.map +1 -1
- package/dist/views/List/index.css +0 -5
- package/dist/views/Root/getCustomCollectionViewByRoute.d.ts.map +1 -1
- package/dist/views/Root/getCustomCollectionViewByRoute.js.map +1 -1
- package/dist/views/Root/getCustomGlobalViewByRoute.d.ts.map +1 -1
- package/dist/views/Root/getCustomGlobalViewByRoute.js.map +1 -1
- package/dist/views/Root/getCustomViewByKey.d.ts.map +1 -1
- package/dist/views/Root/getCustomViewByKey.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +0 -1
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Version/Restore/index.d.ts.map +1 -1
- package/dist/views/Version/Restore/index.js +3 -6
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/elements/BranchSelector/index.css +0 -83
- package/dist/elements/BranchSelector/index.d.ts +0 -12
- package/dist/elements/BranchSelector/index.d.ts.map +0 -1
- package/dist/elements/BranchSelector/index.js +0 -160
- package/dist/elements/BranchSelector/index.js.map +0 -1
- package/dist/providers/Auth/AuthSessionDebug/index.css +0 -48
- package/dist/providers/Auth/AuthSessionDebug/index.d.ts +0 -13
- package/dist/providers/Auth/AuthSessionDebug/index.d.ts.map +0 -1
- package/dist/providers/Auth/AuthSessionDebug/index.js +0 -93
- package/dist/providers/Auth/AuthSessionDebug/index.js.map +0 -1
- package/dist/providers/Auth/AuthSessionDebug/utilities.d.ts +0 -21
- package/dist/providers/Auth/AuthSessionDebug/utilities.d.ts.map +0 -1
- package/dist/providers/Auth/AuthSessionDebug/utilities.js +0 -53
- package/dist/providers/Auth/AuthSessionDebug/utilities.js.map +0 -1
- package/dist/providers/Auth/authSessionRequests.d.ts +0 -27
- package/dist/providers/Auth/authSessionRequests.d.ts.map +0 -1
- package/dist/providers/Auth/authSessionRequests.js +0 -119
- package/dist/providers/Auth/authSessionRequests.js.map +0 -1
- package/dist/providers/Auth/authSessionRequests.spec.js +0 -121
- package/dist/providers/Auth/authSessionRequests.spec.js.map +0 -1
- package/dist/providers/Auth/sessionActivity.d.ts +0 -23
- package/dist/providers/Auth/sessionActivity.d.ts.map +0 -1
- package/dist/providers/Auth/sessionActivity.js +0 -49
- package/dist/providers/Auth/sessionActivity.js.map +0 -1
- package/dist/providers/Auth/sessionActivity.spec.js +0 -44
- package/dist/providers/Auth/sessionActivity.spec.js.map +0 -1
- package/dist/providers/Auth/sessionTiming.d.ts +0 -11
- package/dist/providers/Auth/sessionTiming.d.ts.map +0 -1
- package/dist/providers/Auth/sessionTiming.js +0 -18
- package/dist/providers/Auth/sessionTiming.js.map +0 -1
- package/dist/providers/Auth/tabSessionSync/index.d.ts +0 -17
- package/dist/providers/Auth/tabSessionSync/index.d.ts.map +0 -1
- package/dist/providers/Auth/tabSessionSync/index.js +0 -263
- package/dist/providers/Auth/tabSessionSync/index.js.map +0 -1
- package/dist/providers/Auth/tabSessionSync/index.spec.js +0 -463
- package/dist/providers/Auth/tabSessionSync/index.spec.js.map +0 -1
- package/dist/providers/Auth/tabSessionSync/types.d.ts +0 -107
- package/dist/providers/Auth/tabSessionSync/types.d.ts.map +0 -1
- package/dist/providers/Auth/tabSessionSync/types.js +0 -6
- package/dist/providers/Auth/tabSessionSync/types.js.map +0 -1
- package/dist/providers/Auth/tabSessionSync/useTabSessionSync.d.ts +0 -11
- package/dist/providers/Auth/tabSessionSync/useTabSessionSync.d.ts.map +0 -1
- package/dist/providers/Auth/tabSessionSync/useTabSessionSync.js +0 -90
- package/dist/providers/Auth/tabSessionSync/useTabSessionSync.js.map +0 -1
- package/dist/providers/Auth/tabSessionSync/utilities.d.ts +0 -26
- package/dist/providers/Auth/tabSessionSync/utilities.d.ts.map +0 -1
- package/dist/providers/Auth/tabSessionSync/utilities.js +0 -159
- package/dist/providers/Auth/tabSessionSync/utilities.js.map +0 -1
- package/dist/providers/Auth/types.d.ts +0 -65
- package/dist/providers/Auth/types.d.ts.map +0 -1
- package/dist/providers/Auth/types.js +0 -2
- package/dist/providers/Auth/types.js.map +0 -1
- package/dist/providers/Auth/useAuthSessionTimers.d.ts +0 -26
- package/dist/providers/Auth/useAuthSessionTimers.d.ts.map +0 -1
- package/dist/providers/Auth/useAuthSessionTimers.js +0 -203
- package/dist/providers/Auth/useAuthSessionTimers.js.map +0 -1
- package/dist/providers/Auth/useAuthSessionTimers.spec.js +0 -311
- package/dist/providers/Auth/useAuthSessionTimers.spec.js.map +0 -1
- package/dist/providers/Branch/index.d.ts +0 -62
- package/dist/providers/Branch/index.d.ts.map +0 -1
- package/dist/providers/Branch/index.js +0 -192
- package/dist/providers/Branch/index.js.map +0 -1
- package/dist/providers/Branch/index.server.d.ts +0 -14
- package/dist/providers/Branch/index.server.d.ts.map +0 -1
- package/dist/providers/Branch/index.server.js +0 -80
- package/dist/providers/Branch/index.server.js.map +0 -1
- package/dist/providers/RouteTransition/ProgressBar/index.spec.js +0 -44
- package/dist/providers/RouteTransition/ProgressBar/index.spec.js.map +0 -1
- package/dist/utilities/getRequestBranch.d.ts +0 -18
- package/dist/utilities/getRequestBranch.d.ts.map +0 -1
- package/dist/utilities/getRequestBranch.js +0 -32
- package/dist/utilities/getRequestBranch.js.map +0 -1
- package/dist/utilities/matchesSearchQuery.d.ts +0 -12
- package/dist/utilities/matchesSearchQuery.d.ts.map +0 -1
- package/dist/utilities/matchesSearchQuery.js +0 -23
- package/dist/utilities/matchesSearchQuery.js.map +0 -1
- package/dist/utilities/matchesSearchQuery.spec.js.map +0 -1
|
@@ -7,7 +7,6 @@ import React, { createContext, use, useCallback, useEffect, useMemo, useRef, use
|
|
|
7
7
|
import { useControllableState } from '../../hooks/useControllableState.js';
|
|
8
8
|
import { useAuth } from '../../providers/Auth/index.js';
|
|
9
9
|
import { requests } from '../../utilities/api.js';
|
|
10
|
-
import { useBranchParam } from '../Branch/index.js';
|
|
11
10
|
import { useConfig } from '../Config/index.js';
|
|
12
11
|
import { DocumentTitleProvider } from '../DocumentTitle/index.js';
|
|
13
12
|
import { useLocale, useLocaleLoading } from '../Locale/index.js';
|
|
@@ -98,7 +97,6 @@ const DocumentInfo = ({
|
|
|
98
97
|
const {
|
|
99
98
|
code: locale
|
|
100
99
|
} = useLocale();
|
|
101
|
-
const branch = useBranchParam();
|
|
102
100
|
const {
|
|
103
101
|
localeIsLoading
|
|
104
102
|
} = useLocaleLoading();
|
|
@@ -204,7 +202,6 @@ const DocumentInfo = ({
|
|
|
204
202
|
const getDocPermissions = useGetDocPermissions({
|
|
205
203
|
id: id,
|
|
206
204
|
api,
|
|
207
|
-
branch,
|
|
208
205
|
collectionSlug,
|
|
209
206
|
globalSlug,
|
|
210
207
|
i18n,
|
|
@@ -268,7 +265,6 @@ const DocumentInfo = ({
|
|
|
268
265
|
const action = React.useMemo(() => {
|
|
269
266
|
const docPath = `${pluralType === 'globals' ? `/globals` : ''}/${slug}${id ? `/${id}` : ''}`;
|
|
270
267
|
return `${baseAPIPath}${docPath}${qs.stringify({
|
|
271
|
-
branch,
|
|
272
268
|
depth: 0,
|
|
273
269
|
'fallback-locale': 'null',
|
|
274
270
|
locale,
|
|
@@ -276,7 +272,7 @@ const DocumentInfo = ({
|
|
|
276
272
|
}, {
|
|
277
273
|
addQueryPrefix: true
|
|
278
274
|
})}`;
|
|
279
|
-
}, [baseAPIPath,
|
|
275
|
+
}, [baseAPIPath, locale, pluralType, id, slug, uploadEdits]);
|
|
280
276
|
const value = {
|
|
281
277
|
...props,
|
|
282
278
|
action,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["formatAdminURL","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","useControllableState","useAuth","requests","useBranchParam","useConfig","DocumentTitleProvider","useLocale","useLocaleLoading","usePreferences","useTranslation","UploadEditsProvider","useUploadEdits","useGetDocPermissions","Context","useDocumentInfo","DocumentInfo","children","props","id","collectionSlug","currentEditor","currentEditorFromProps","docPermissions","docPermissionsFromProps","globalSlug","hasPublishedDoc","hasPublishedDocFromProps","hasPublishPermission","hasPublishPermissionFromProps","hasSavePermission","hasSavePermissionFromProps","hasScheduledPublish","hasScheduledPublishFromProps","initialData","initialState","isLocked","isLockedFromProps","lastUpdateTime","lastUpdateTimeFromProps","mostRecentVersionIsAutosaved","mostRecentVersionIsAutosavedFromProps","unpublishedVersionCount","unpublishedVersionCountFromProps","versionCount","versionCountFromProps","setDocPermissions","setHasSavePermission","setHasPublishPermission","permissions","config","admin","dateFormat","collections","routes","api","getEntityConfig","collectionConfig","globalConfig","hasLockedDocumentsCollection","some","collection","slug","abortControllerRef","AbortController","docConfig","i18n","uploadEdits","setMostRecentVersionIsAutosaved","setVersionCount","setHasPublishedDoc","setUnpublishedVersionCount","setHasScheduledPublish","Boolean","documentIsLocked","setDocumentIsLocked","setCurrentEditor","setLastUpdateTime","data","setData","uploadStatus","setUploadStatus","documentLockState","hasShownLockedModal","user","updateUploadStatus","status","getPreference","setPreference","code","locale","branch","localeIsLoading","isInitializing","undefined","baseAPIPath","apiRoute","path","pluralType","preferencesKey","unlockDocument","docID","isGlobal","request","get","credentials","params","docs","json","length","lockID","delete","headers","error","console","updateDocumentEditor","userData","relationTo","value","patch","body","JSON","stringify","getDocPermissions","getDocPreferences","setDocFieldPreferences","fieldPreferences","allPreferences","fields","e","incrementVersionCount","newCount","versions","maxPerDoc","Math","min","max","re1","current","abort","_err","action","docPath","depth","addQueryPrefix","savedDocumentData","updateSavedDocumentData","_jsx","DocumentInfoProvider"],"sources":["../../../src/providers/DocumentInfo/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, User } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { DocumentInfoContext, DocumentInfoProps } from './types.js'\n\nimport { useControllableState } from '../../hooks/useControllableState.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { useBranchParam } from '../Branch/index.js'\nimport { useConfig } from '../Config/index.js'\nimport { DocumentTitleProvider } from '../DocumentTitle/index.js'\nimport { useLocale, useLocaleLoading } from '../Locale/index.js'\nimport { usePreferences } from '../Preferences/index.js'\nimport { useTranslation } from '../Translation/index.js'\nimport { UploadEditsProvider, useUploadEdits } from '../UploadEdits/index.js'\nimport { useGetDocPermissions } from './useGetDocPermissions.js'\n\nconst Context = createContext({} as DocumentInfoContext)\n\nexport type * from './types.js'\n\nexport const useDocumentInfo = (): DocumentInfoContext => use(Context)\n\nconst DocumentInfo: React.FC<\n {\n readonly children: React.ReactNode\n } & DocumentInfoProps\n> = ({ children, ...props }) => {\n const {\n id,\n collectionSlug,\n currentEditor: currentEditorFromProps,\n docPermissions: docPermissionsFromProps,\n globalSlug,\n hasPublishedDoc: hasPublishedDocFromProps,\n hasPublishPermission: hasPublishPermissionFromProps,\n hasSavePermission: hasSavePermissionFromProps,\n hasScheduledPublish: hasScheduledPublishFromProps,\n initialData,\n initialState,\n isLocked: isLockedFromProps,\n lastUpdateTime: lastUpdateTimeFromProps,\n mostRecentVersionIsAutosaved: mostRecentVersionIsAutosavedFromProps,\n unpublishedVersionCount: unpublishedVersionCountFromProps,\n versionCount: versionCountFromProps,\n } = props\n\n const [docPermissions, setDocPermissions] = useControllableState(docPermissionsFromProps)\n\n const [hasSavePermission, setHasSavePermission] = useControllableState(hasSavePermissionFromProps)\n\n const [hasPublishPermission, setHasPublishPermission] = useControllableState(\n hasPublishPermissionFromProps,\n )\n\n const { permissions } = useAuth()\n\n const {\n config: {\n admin: { dateFormat },\n collections,\n routes: { api },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n // Check if the locked-documents collection exists in the config\n const hasLockedDocumentsCollection = collections.some(\n (collection) => collection.slug === 'payload-locked-documents',\n )\n\n const abortControllerRef = useRef(new AbortController())\n const docConfig = collectionConfig || globalConfig\n\n const { i18n } = useTranslation()\n\n const { uploadEdits } = useUploadEdits()\n\n const [mostRecentVersionIsAutosaved, setMostRecentVersionIsAutosaved] = useState(\n mostRecentVersionIsAutosavedFromProps,\n )\n\n const [versionCount, setVersionCount] = useState(versionCountFromProps)\n\n const [hasPublishedDoc, setHasPublishedDoc] = useState(hasPublishedDocFromProps)\n\n const [unpublishedVersionCount, setUnpublishedVersionCount] = useState(\n unpublishedVersionCountFromProps,\n )\n\n const [hasScheduledPublish, setHasScheduledPublish] = useState(\n Boolean(hasScheduledPublishFromProps),\n )\n\n const [documentIsLocked, setDocumentIsLocked] = useControllableState<boolean | undefined>(\n isLockedFromProps,\n )\n\n const [currentEditor, setCurrentEditor] = useControllableState<null | User>(\n currentEditorFromProps,\n )\n const [lastUpdateTime, setLastUpdateTime] = useControllableState<number>(lastUpdateTimeFromProps)\n\n const [data, setData] = useControllableState(initialData)\n\n const [uploadStatus, setUploadStatus] = useControllableState<'failed' | 'idle' | 'uploading'>(\n 'idle',\n )\n\n const documentLockState = useRef<{\n hasShownLockedModal: boolean\n isLocked: boolean\n user: number | string | User\n } | null>({\n hasShownLockedModal: false,\n isLocked: false,\n user: null,\n })\n\n const updateUploadStatus = useCallback(\n (status: 'failed' | 'idle' | 'uploading') => {\n setUploadStatus(status)\n },\n [setUploadStatus],\n )\n\n const { getPreference, setPreference } = usePreferences()\n const { code: locale } = useLocale()\n const branch = useBranchParam()\n const { localeIsLoading } = useLocaleLoading()\n\n const isInitializing = useMemo(\n () => initialState === undefined || initialData === undefined || localeIsLoading,\n [initialData, initialState, localeIsLoading],\n )\n\n const baseAPIPath = formatAdminURL({\n apiRoute: api,\n path: '',\n })\n\n let slug: string\n let pluralType: 'collections' | 'globals'\n let preferencesKey: string\n\n if (globalSlug) {\n slug = globalSlug\n pluralType = 'globals'\n preferencesKey = `global-${slug}`\n }\n\n if (collectionSlug) {\n slug = collectionSlug\n pluralType = 'collections'\n\n if (id) {\n preferencesKey = `collection-${slug}-${id}`\n }\n }\n\n const unlockDocument = useCallback(\n async (docID: number | string, slug: string) => {\n // Check if the locked-documents collection exists before making API calls\n if (!hasLockedDocumentsCollection) {\n return\n }\n\n try {\n const isGlobal = slug === globalSlug\n\n const request = await requests.get(`${baseAPIPath}/payload-locked-documents`, {\n credentials: 'include',\n params: isGlobal\n ? {\n 'where[globalSlug][equals]': slug,\n }\n : {\n 'where[document.relationTo][equals]': slug,\n 'where[document.value][equals]': docID,\n },\n })\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n await requests.delete(`${baseAPIPath}/payload-locked-documents/${lockID}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n setDocumentIsLocked(false)\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to unlock the document', error)\n }\n },\n [baseAPIPath, globalSlug, setDocumentIsLocked, hasLockedDocumentsCollection],\n )\n\n const updateDocumentEditor = useCallback(\n async (docID: number | string, slug: string, user: number | string | User) => {\n // Check if the locked-documents collection exists before making API calls\n if (!hasLockedDocumentsCollection) {\n return\n }\n\n try {\n const isGlobal = slug === globalSlug\n\n // Check if the document is already locked\n const request = await requests.get(`${baseAPIPath}/payload-locked-documents`, {\n credentials: 'include',\n params: isGlobal\n ? {\n 'where[globalSlug][equals]': slug,\n }\n : {\n 'where[document.relationTo][equals]': slug,\n 'where[document.value][equals]': docID,\n },\n })\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n\n const userData =\n typeof user === 'object'\n ? { relationTo: user.collection, value: user.id }\n : { relationTo: 'users', value: user }\n\n // Send a patch request to update the _lastEdited info\n await requests.patch(`${baseAPIPath}/payload-locked-documents/${lockID}`, {\n body: JSON.stringify({\n user: userData,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to update the document editor', error)\n }\n },\n [baseAPIPath, globalSlug, hasLockedDocumentsCollection],\n )\n\n const getDocPermissions = useGetDocPermissions({\n id: id as string,\n api,\n branch,\n collectionSlug,\n globalSlug,\n i18n,\n locale,\n permissions,\n setDocPermissions,\n setHasPublishPermission,\n setHasSavePermission,\n })\n\n const getDocPreferences = useCallback(() => {\n return getPreference<DocumentPreferences>(preferencesKey)\n }, [getPreference, preferencesKey])\n\n const setDocFieldPreferences = useCallback<DocumentInfoContext['setDocFieldPreferences']>(\n async (path, fieldPreferences) => {\n const allPreferences = await getDocPreferences()\n\n if (preferencesKey) {\n try {\n await setPreference(preferencesKey, {\n ...allPreferences,\n fields: {\n ...(allPreferences?.fields || {}),\n [path]: {\n ...allPreferences?.fields?.[path],\n ...fieldPreferences,\n },\n },\n })\n } catch (e) {\n console.error(e) // eslint-disable-line no-console\n }\n }\n },\n [setPreference, preferencesKey, getDocPreferences],\n )\n\n const incrementVersionCount = useCallback(() => {\n const newCount = versionCount + 1\n if (collectionConfig && collectionConfig.versions) {\n if (collectionConfig.versions.maxPerDoc > 0) {\n setVersionCount(Math.min(newCount, collectionConfig.versions.maxPerDoc))\n } else {\n setVersionCount(newCount)\n }\n } else if (globalConfig && globalConfig.versions) {\n if (globalConfig.versions.max > 0) {\n setVersionCount(Math.min(newCount, globalConfig.versions.max))\n } else {\n setVersionCount(newCount)\n }\n }\n }, [collectionConfig, globalConfig, versionCount])\n\n // clean on unmount\n useEffect(() => {\n const re1 = abortControllerRef.current\n\n return () => {\n if (re1) {\n try {\n re1.abort()\n } catch (_err) {\n // swallow error\n }\n }\n }\n }, [])\n\n const action: string = React.useMemo(() => {\n const docPath = `${pluralType === 'globals' ? `/globals` : ''}/${slug}${id ? `/${id}` : ''}`\n\n return `${baseAPIPath}${docPath}${qs.stringify(\n {\n branch,\n depth: 0,\n 'fallback-locale': 'null',\n locale,\n uploadEdits: uploadEdits || undefined,\n },\n {\n addQueryPrefix: true,\n },\n )}`\n }, [baseAPIPath, branch, locale, pluralType, id, slug, uploadEdits])\n\n const value: DocumentInfoContext = {\n ...props,\n action,\n currentEditor,\n data,\n docConfig,\n docPermissions,\n documentIsLocked,\n documentLockState,\n getDocPermissions,\n getDocPreferences,\n hasPublishedDoc,\n hasPublishPermission,\n hasSavePermission,\n hasScheduledPublish,\n incrementVersionCount,\n initialData,\n initialState,\n isInitializing,\n lastUpdateTime,\n mostRecentVersionIsAutosaved,\n preferencesKey,\n savedDocumentData: data,\n setCurrentEditor,\n setData,\n setDocFieldPreferences,\n setDocumentIsLocked,\n setHasPublishedDoc,\n setHasScheduledPublish,\n setLastUpdateTime,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n setUploadStatus: updateUploadStatus,\n unlockDocument,\n unpublishedVersionCount,\n updateDocumentEditor,\n updateSavedDocumentData: setData,\n uploadStatus,\n versionCount,\n }\n\n return (\n <Context value={value}>\n <DocumentTitleProvider>{children}</DocumentTitleProvider>\n </Context>\n )\n}\n\nexport const DocumentInfoProvider: React.FC<\n {\n readonly children: React.ReactNode\n } & DocumentInfoProps\n> = (props) => {\n return (\n <UploadEditsProvider>\n <DocumentInfo {...props} />\n </UploadEditsProvider>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAI7F,SAASC,oBAAoB,QAAQ;AACrC,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,SAAS,EAAEC,gBAAgB,QAAQ;AAC5C,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,mBAAmB,EAAEC,cAAc,QAAQ;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AAO,GAAG4E,WAAA,GAAc+C,OAAA,GAAUtJ,EAAA,CAAGkI,SAAS,CAC5C;MACE/B,MAAA;MACAoD,KAAA,EAAO;MACP,mBAAmB;MACnBrD,MAAA;MACAvB,WAAA,EAAaA,WAAA,IAAe2B;IAC9B,GACA;MACEkD,cAAA,EAAgB;IAClB,IACC;EACL,GAAG,CAACjD,WAAA,EAAaJ,MAAA,EAAQD,MAAA,EAAQQ,UAAA,EAAY/E,EAAA,EAAI2C,IAAA,EAAMK,WAAA,CAAY;EAEnE,MAAMmD,KAAA,GAA6B;IACjC,GAAGpG,KAAK;IACR2H,MAAA;IACAxH,aAAA;IACAyD,IAAA;IACAb,SAAA;IACA1C,cAAA;IACAmD,gBAAA;IACAQ,iBAAA;IACAyC,iBAAA;IACAC,iBAAA;IACAlG,eAAA;IACAE,oBAAA;IACAE,iBAAA;IACAE,mBAAA;IACAkG,qBAAA;IACAhG,WAAA;IACAC,YAAA;IACA0D,cAAA;IACAvD,cAAA;IACAE,4BAAA;IACA2D,cAAA;IACA8C,iBAAA,EAAmBnE,IAAA;IACnBF,gBAAA;IACAG,OAAA;IACA8C,sBAAA;IACAlD,mBAAA;IACAL,kBAAA;IACAE,sBAAA;IACAK,iBAAA;IACAT,+BAAA;IACAG,0BAAA;IACAU,eAAA,EAAiBI,kBAAA;IACjBe,cAAA;IACA1D,uBAAA;IACAyE,oBAAA;IACA+B,uBAAA,EAAyBnE,OAAA;IACzBC,YAAA;IACApC;EACF;EAEA,oBACEuG,IAAA,CAACrI,OAAA;IAAQwG,KAAA,EAAOA,KAAA;cACd,aAAA6B,IAAA,CAAC7I,qBAAA;gBAAuBW;;;AAG9B;AAEA,OAAO,MAAMmI,oBAAA,GAIRlI,KAAA;EACH,oBACEiI,IAAA,CAACxI,mBAAA;cACC,aAAAwI,IAAA,CAACnI,YAAA;MAAc,GAAGE;;;AAGxB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["formatAdminURL","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","useControllableState","useAuth","requests","useConfig","DocumentTitleProvider","useLocale","useLocaleLoading","usePreferences","useTranslation","UploadEditsProvider","useUploadEdits","useGetDocPermissions","Context","useDocumentInfo","DocumentInfo","children","props","id","collectionSlug","currentEditor","currentEditorFromProps","docPermissions","docPermissionsFromProps","globalSlug","hasPublishedDoc","hasPublishedDocFromProps","hasPublishPermission","hasPublishPermissionFromProps","hasSavePermission","hasSavePermissionFromProps","hasScheduledPublish","hasScheduledPublishFromProps","initialData","initialState","isLocked","isLockedFromProps","lastUpdateTime","lastUpdateTimeFromProps","mostRecentVersionIsAutosaved","mostRecentVersionIsAutosavedFromProps","unpublishedVersionCount","unpublishedVersionCountFromProps","versionCount","versionCountFromProps","setDocPermissions","setHasSavePermission","setHasPublishPermission","permissions","config","admin","dateFormat","collections","routes","api","getEntityConfig","collectionConfig","globalConfig","hasLockedDocumentsCollection","some","collection","slug","abortControllerRef","AbortController","docConfig","i18n","uploadEdits","setMostRecentVersionIsAutosaved","setVersionCount","setHasPublishedDoc","setUnpublishedVersionCount","setHasScheduledPublish","Boolean","documentIsLocked","setDocumentIsLocked","setCurrentEditor","setLastUpdateTime","data","setData","uploadStatus","setUploadStatus","documentLockState","hasShownLockedModal","user","updateUploadStatus","status","getPreference","setPreference","code","locale","localeIsLoading","isInitializing","undefined","baseAPIPath","apiRoute","path","pluralType","preferencesKey","unlockDocument","docID","isGlobal","request","get","credentials","params","docs","json","length","lockID","delete","headers","error","console","updateDocumentEditor","userData","relationTo","value","patch","body","JSON","stringify","getDocPermissions","getDocPreferences","setDocFieldPreferences","fieldPreferences","allPreferences","fields","e","incrementVersionCount","newCount","versions","maxPerDoc","Math","min","max","re1","current","abort","_err","action","docPath","depth","addQueryPrefix","savedDocumentData","updateSavedDocumentData","_jsx","DocumentInfoProvider"],"sources":["../../../src/providers/DocumentInfo/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, User } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { DocumentInfoContext, DocumentInfoProps } from './types.js'\n\nimport { useControllableState } from '../../hooks/useControllableState.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { useConfig } from '../Config/index.js'\nimport { DocumentTitleProvider } from '../DocumentTitle/index.js'\nimport { useLocale, useLocaleLoading } from '../Locale/index.js'\nimport { usePreferences } from '../Preferences/index.js'\nimport { useTranslation } from '../Translation/index.js'\nimport { UploadEditsProvider, useUploadEdits } from '../UploadEdits/index.js'\nimport { useGetDocPermissions } from './useGetDocPermissions.js'\n\nconst Context = createContext({} as DocumentInfoContext)\n\nexport type * from './types.js'\n\nexport const useDocumentInfo = (): DocumentInfoContext => use(Context)\n\nconst DocumentInfo: React.FC<\n {\n readonly children: React.ReactNode\n } & DocumentInfoProps\n> = ({ children, ...props }) => {\n const {\n id,\n collectionSlug,\n currentEditor: currentEditorFromProps,\n docPermissions: docPermissionsFromProps,\n globalSlug,\n hasPublishedDoc: hasPublishedDocFromProps,\n hasPublishPermission: hasPublishPermissionFromProps,\n hasSavePermission: hasSavePermissionFromProps,\n hasScheduledPublish: hasScheduledPublishFromProps,\n initialData,\n initialState,\n isLocked: isLockedFromProps,\n lastUpdateTime: lastUpdateTimeFromProps,\n mostRecentVersionIsAutosaved: mostRecentVersionIsAutosavedFromProps,\n unpublishedVersionCount: unpublishedVersionCountFromProps,\n versionCount: versionCountFromProps,\n } = props\n\n const [docPermissions, setDocPermissions] = useControllableState(docPermissionsFromProps)\n\n const [hasSavePermission, setHasSavePermission] = useControllableState(hasSavePermissionFromProps)\n\n const [hasPublishPermission, setHasPublishPermission] = useControllableState(\n hasPublishPermissionFromProps,\n )\n\n const { permissions } = useAuth()\n\n const {\n config: {\n admin: { dateFormat },\n collections,\n routes: { api },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n // Check if the locked-documents collection exists in the config\n const hasLockedDocumentsCollection = collections.some(\n (collection) => collection.slug === 'payload-locked-documents',\n )\n\n const abortControllerRef = useRef(new AbortController())\n const docConfig = collectionConfig || globalConfig\n\n const { i18n } = useTranslation()\n\n const { uploadEdits } = useUploadEdits()\n\n const [mostRecentVersionIsAutosaved, setMostRecentVersionIsAutosaved] = useState(\n mostRecentVersionIsAutosavedFromProps,\n )\n\n const [versionCount, setVersionCount] = useState(versionCountFromProps)\n\n const [hasPublishedDoc, setHasPublishedDoc] = useState(hasPublishedDocFromProps)\n\n const [unpublishedVersionCount, setUnpublishedVersionCount] = useState(\n unpublishedVersionCountFromProps,\n )\n\n const [hasScheduledPublish, setHasScheduledPublish] = useState(\n Boolean(hasScheduledPublishFromProps),\n )\n\n const [documentIsLocked, setDocumentIsLocked] = useControllableState<boolean | undefined>(\n isLockedFromProps,\n )\n\n const [currentEditor, setCurrentEditor] = useControllableState<null | User>(\n currentEditorFromProps,\n )\n const [lastUpdateTime, setLastUpdateTime] = useControllableState<number>(lastUpdateTimeFromProps)\n\n const [data, setData] = useControllableState(initialData)\n\n const [uploadStatus, setUploadStatus] = useControllableState<'failed' | 'idle' | 'uploading'>(\n 'idle',\n )\n\n const documentLockState = useRef<{\n hasShownLockedModal: boolean\n isLocked: boolean\n user: number | string | User\n } | null>({\n hasShownLockedModal: false,\n isLocked: false,\n user: null,\n })\n\n const updateUploadStatus = useCallback(\n (status: 'failed' | 'idle' | 'uploading') => {\n setUploadStatus(status)\n },\n [setUploadStatus],\n )\n\n const { getPreference, setPreference } = usePreferences()\n const { code: locale } = useLocale()\n const { localeIsLoading } = useLocaleLoading()\n\n const isInitializing = useMemo(\n () => initialState === undefined || initialData === undefined || localeIsLoading,\n [initialData, initialState, localeIsLoading],\n )\n\n const baseAPIPath = formatAdminURL({\n apiRoute: api,\n path: '',\n })\n\n let slug: string\n let pluralType: 'collections' | 'globals'\n let preferencesKey: string\n\n if (globalSlug) {\n slug = globalSlug\n pluralType = 'globals'\n preferencesKey = `global-${slug}`\n }\n\n if (collectionSlug) {\n slug = collectionSlug\n pluralType = 'collections'\n\n if (id) {\n preferencesKey = `collection-${slug}-${id}`\n }\n }\n\n const unlockDocument = useCallback(\n async (docID: number | string, slug: string) => {\n // Check if the locked-documents collection exists before making API calls\n if (!hasLockedDocumentsCollection) {\n return\n }\n\n try {\n const isGlobal = slug === globalSlug\n\n const request = await requests.get(`${baseAPIPath}/payload-locked-documents`, {\n credentials: 'include',\n params: isGlobal\n ? {\n 'where[globalSlug][equals]': slug,\n }\n : {\n 'where[document.relationTo][equals]': slug,\n 'where[document.value][equals]': docID,\n },\n })\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n await requests.delete(`${baseAPIPath}/payload-locked-documents/${lockID}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n setDocumentIsLocked(false)\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to unlock the document', error)\n }\n },\n [baseAPIPath, globalSlug, setDocumentIsLocked, hasLockedDocumentsCollection],\n )\n\n const updateDocumentEditor = useCallback(\n async (docID: number | string, slug: string, user: number | string | User) => {\n // Check if the locked-documents collection exists before making API calls\n if (!hasLockedDocumentsCollection) {\n return\n }\n\n try {\n const isGlobal = slug === globalSlug\n\n // Check if the document is already locked\n const request = await requests.get(`${baseAPIPath}/payload-locked-documents`, {\n credentials: 'include',\n params: isGlobal\n ? {\n 'where[globalSlug][equals]': slug,\n }\n : {\n 'where[document.relationTo][equals]': slug,\n 'where[document.value][equals]': docID,\n },\n })\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n\n const userData =\n typeof user === 'object'\n ? { relationTo: user.collection, value: user.id }\n : { relationTo: 'users', value: user }\n\n // Send a patch request to update the _lastEdited info\n await requests.patch(`${baseAPIPath}/payload-locked-documents/${lockID}`, {\n body: JSON.stringify({\n user: userData,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to update the document editor', error)\n }\n },\n [baseAPIPath, globalSlug, hasLockedDocumentsCollection],\n )\n\n const getDocPermissions = useGetDocPermissions({\n id: id as string,\n api,\n collectionSlug,\n globalSlug,\n i18n,\n locale,\n permissions,\n setDocPermissions,\n setHasPublishPermission,\n setHasSavePermission,\n })\n\n const getDocPreferences = useCallback(() => {\n return getPreference<DocumentPreferences>(preferencesKey)\n }, [getPreference, preferencesKey])\n\n const setDocFieldPreferences = useCallback<DocumentInfoContext['setDocFieldPreferences']>(\n async (path, fieldPreferences) => {\n const allPreferences = await getDocPreferences()\n\n if (preferencesKey) {\n try {\n await setPreference(preferencesKey, {\n ...allPreferences,\n fields: {\n ...(allPreferences?.fields || {}),\n [path]: {\n ...allPreferences?.fields?.[path],\n ...fieldPreferences,\n },\n },\n })\n } catch (e) {\n console.error(e) // eslint-disable-line no-console\n }\n }\n },\n [setPreference, preferencesKey, getDocPreferences],\n )\n\n const incrementVersionCount = useCallback(() => {\n const newCount = versionCount + 1\n if (collectionConfig && collectionConfig.versions) {\n if (collectionConfig.versions.maxPerDoc > 0) {\n setVersionCount(Math.min(newCount, collectionConfig.versions.maxPerDoc))\n } else {\n setVersionCount(newCount)\n }\n } else if (globalConfig && globalConfig.versions) {\n if (globalConfig.versions.max > 0) {\n setVersionCount(Math.min(newCount, globalConfig.versions.max))\n } else {\n setVersionCount(newCount)\n }\n }\n }, [collectionConfig, globalConfig, versionCount])\n\n // clean on unmount\n useEffect(() => {\n const re1 = abortControllerRef.current\n\n return () => {\n if (re1) {\n try {\n re1.abort()\n } catch (_err) {\n // swallow error\n }\n }\n }\n }, [])\n\n const action: string = React.useMemo(() => {\n const docPath = `${pluralType === 'globals' ? `/globals` : ''}/${slug}${id ? `/${id}` : ''}`\n\n return `${baseAPIPath}${docPath}${qs.stringify(\n {\n depth: 0,\n 'fallback-locale': 'null',\n locale,\n uploadEdits: uploadEdits || undefined,\n },\n {\n addQueryPrefix: true,\n },\n )}`\n }, [baseAPIPath, locale, pluralType, id, slug, uploadEdits])\n\n const value: DocumentInfoContext = {\n ...props,\n action,\n currentEditor,\n data,\n docConfig,\n docPermissions,\n documentIsLocked,\n documentLockState,\n getDocPermissions,\n getDocPreferences,\n hasPublishedDoc,\n hasPublishPermission,\n hasSavePermission,\n hasScheduledPublish,\n incrementVersionCount,\n initialData,\n initialState,\n isInitializing,\n lastUpdateTime,\n mostRecentVersionIsAutosaved,\n preferencesKey,\n savedDocumentData: data,\n setCurrentEditor,\n setData,\n setDocFieldPreferences,\n setDocumentIsLocked,\n setHasPublishedDoc,\n setHasScheduledPublish,\n setLastUpdateTime,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n setUploadStatus: updateUploadStatus,\n unlockDocument,\n unpublishedVersionCount,\n updateDocumentEditor,\n updateSavedDocumentData: setData,\n uploadStatus,\n versionCount,\n }\n\n return (\n <Context value={value}>\n <DocumentTitleProvider>{children}</DocumentTitleProvider>\n </Context>\n )\n}\n\nexport const DocumentInfoProvider: React.FC<\n {\n readonly children: React.ReactNode\n } & DocumentInfoProps\n> = (props) => {\n return (\n <UploadEditsProvider>\n <DocumentInfo {...props} />\n </UploadEditsProvider>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAI7F,SAASC,oBAAoB,QAAQ;AACrC,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,SAASC,SAAS,QAAQ;AAC1B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,SAAS,EAAEC,gBAAgB,QAAQ;AAC5C,SAASC,cAAc,QAAQ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ions } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export type GetDocPermissions = (data?: Data) => Promise<void>;
|
|
4
|
-
export declare const useGetDocPermissions: ({ id, api,
|
|
4
|
+
export declare const useGetDocPermissions: ({ id, api, collectionSlug, globalSlug, i18n, locale, permissions, setDocPermissions, setHasPublishPermission, setHasSavePermission, }: {
|
|
5
5
|
api: string;
|
|
6
|
-
branch: string | undefined;
|
|
7
6
|
collectionSlug: string;
|
|
8
7
|
globalSlug: string;
|
|
9
8
|
i18n: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetDocPermissions.d.ts","sourceRoot":"","sources":["../../../src/providers/DocumentInfo/useGetDocPermissions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAIvF,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAE9D,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"useGetDocPermissions.d.ts","sourceRoot":"","sources":["../../../src/providers/DocumentInfo/useGetDocPermissions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAIvF,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAE9D,eAAO,MAAM,oBAAoB,0IAW9B;IACD,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,GAAG,CAAA;IACT,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,oBAAoB,CAAA;IACjC,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC,CAAA;IACrF,uBAAuB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;IACtE,oBAAoB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;CACpE,KAAG,iBAuGD,CAAA"}
|
|
@@ -6,7 +6,6 @@ import { isEditing as getIsEditing } from '../../utilities/isEditing.js';
|
|
|
6
6
|
export const useGetDocPermissions = ({
|
|
7
7
|
id,
|
|
8
8
|
api,
|
|
9
|
-
branch,
|
|
10
9
|
collectionSlug,
|
|
11
10
|
globalSlug,
|
|
12
11
|
i18n,
|
|
@@ -17,7 +16,6 @@ export const useGetDocPermissions = ({
|
|
|
17
16
|
setHasSavePermission
|
|
18
17
|
}) => React.useCallback(async data => {
|
|
19
18
|
const params = {
|
|
20
|
-
branch,
|
|
21
19
|
locale: locale || undefined
|
|
22
20
|
};
|
|
23
21
|
const idToUse = data?.id || id;
|
|
@@ -85,5 +83,5 @@ export const useGetDocPermissions = ({
|
|
|
85
83
|
isEditing: newIsEditing
|
|
86
84
|
}));
|
|
87
85
|
}
|
|
88
|
-
}, [
|
|
86
|
+
}, [locale, id, collectionSlug, globalSlug, api, i18n.language, setDocPermissions, setHasSavePermission, setHasPublishPermission, permissions?.collections, permissions?.globals]);
|
|
89
87
|
//# sourceMappingURL=useGetDocPermissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetDocPermissions.js","names":["formatAdminURL","qs","React","hasSavePermission","getHasSavePermission","isEditing","getIsEditing","useGetDocPermissions","id","api","
|
|
1
|
+
{"version":3,"file":"useGetDocPermissions.js","names":["formatAdminURL","qs","React","hasSavePermission","getHasSavePermission","isEditing","getIsEditing","useGetDocPermissions","id","api","collectionSlug","globalSlug","i18n","locale","permissions","setDocPermissions","setHasPublishPermission","setHasSavePermission","useCallback","data","params","undefined","idToUse","newIsEditing","docAccessPath","res","fetch","apiRoute","path","stringify","addQueryPrefix","body","JSON","doc","_status","credentials","headers","language","method","json","publishedAccessJSON","then","docPermissions","update","newDocPermissions","collections","globals"],"sources":["../../../src/providers/DocumentInfo/useGetDocPermissions.tsx"],"sourcesContent":["import type { Data, SanitizedDocumentPermissions, SanitizedPermissions } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React from 'react'\n\nimport { hasSavePermission as getHasSavePermission } from '../../utilities/hasSavePermission.js'\nimport { isEditing as getIsEditing } from '../../utilities/isEditing.js'\n\nexport type GetDocPermissions = (data?: Data) => Promise<void>\n\nexport const useGetDocPermissions = ({\n id,\n api,\n collectionSlug,\n globalSlug,\n i18n,\n locale,\n permissions,\n setDocPermissions,\n setHasPublishPermission,\n setHasSavePermission,\n}: {\n api: string\n collectionSlug: string\n globalSlug: string\n i18n: any\n id: string\n locale: string\n permissions: SanitizedPermissions\n setDocPermissions: React.Dispatch<React.SetStateAction<SanitizedDocumentPermissions>>\n setHasPublishPermission: React.Dispatch<React.SetStateAction<boolean>>\n setHasSavePermission: React.Dispatch<React.SetStateAction<boolean>>\n}): GetDocPermissions =>\n React.useCallback(\n async (data: Data) => {\n const params = {\n locale: locale || undefined,\n }\n\n const idToUse = data?.id || id\n const newIsEditing = getIsEditing({ id: idToUse, collectionSlug, globalSlug })\n\n if (newIsEditing) {\n const docAccessPath: `/${string}` = collectionSlug\n ? `/${collectionSlug}/access/${idToUse}`\n : globalSlug\n ? `/globals/${globalSlug}/access`\n : null\n\n if (docAccessPath) {\n const res = await fetch(\n formatAdminURL({\n apiRoute: api,\n path: `${docAccessPath}${qs.stringify(params, { addQueryPrefix: true })}`,\n }),\n {\n body: JSON.stringify({\n ...(data?.doc || data || {}),\n _status: 'draft',\n }),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n },\n method: 'post',\n },\n )\n\n const json: SanitizedDocumentPermissions = await res.json()\n\n const publishedAccessJSON = await fetch(\n formatAdminURL({\n apiRoute: api,\n path: `${docAccessPath}${qs.stringify(params, { addQueryPrefix: true })}`,\n }),\n {\n body: JSON.stringify({\n ...(data?.doc || data || {}),\n _status: 'published',\n }),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n },\n ).then((res) => res.json())\n\n setDocPermissions(json)\n\n setHasSavePermission(\n getHasSavePermission({\n collectionSlug,\n docPermissions: json,\n globalSlug,\n isEditing: newIsEditing,\n }),\n )\n\n setHasPublishPermission(publishedAccessJSON?.update)\n }\n } else {\n // when creating new documents, there is no permissions saved for this document yet\n // use the generic entity permissions instead\n const newDocPermissions = collectionSlug\n ? permissions?.collections?.[collectionSlug]\n : permissions?.globals?.[globalSlug]\n\n setDocPermissions(newDocPermissions)\n\n setHasSavePermission(\n getHasSavePermission({\n collectionSlug,\n docPermissions: newDocPermissions,\n globalSlug,\n isEditing: newIsEditing,\n }),\n )\n }\n },\n [\n locale,\n id,\n collectionSlug,\n globalSlug,\n api,\n i18n.language,\n setDocPermissions,\n setHasSavePermission,\n setHasPublishPermission,\n permissions?.collections,\n permissions?.globals,\n ],\n )\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,MAAW;AAElB,SAASC,iBAAA,IAAqBC,oBAAoB,QAAQ;AAC1D,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAI1C,OAAO,MAAMC,oBAAA,GAAuBA,CAAC;EACnCC,EAAE;EACFC,GAAG;EACHC,cAAc;EACdC,UAAU;EACVC,IAAI;EACJC,MAAM;EACNC,WAAW;EACXC,iBAAiB;EACjBC,uBAAuB;EACvBC;AAAoB,CAYrB,KACCf,KAAA,C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,IAAQ,CAAC,CAAC;UAC3Be,OAAA,EAAS;QACX;QACAC,WAAA,EAAa;QACbC,OAAA,EAAS;UACP,mBAAmBxB,IAAA,CAAKyB,QAAQ;UAChC,gBAAgB;QAClB;QACAC,MAAA,EAAQ;MACV,GACAG,IAAI,CAAEhB,GAAA,IAAQA,GAAA,CAAIc,IAAI;MAExBxB,iBAAA,CAAkBwB,IAAA;MAElBtB,oBAAA,CACEb,oBAAA,CAAqB;QACnBM,cAAA;QACAgC,cAAA,EAAgBH,IAAA;QAChB5B,UAAA;QACAN,SAAA,EAAWkB;MACb;MAGFP,uBAAA,CAAwBwB,mBAAA,EAAqBG,MAAA;IAC/C;EACF,OAAO;IACL;IACA;IACA,MAAMC,iBAAA,GAAoBlC,cAAA,GACtBI,WAAA,EAAa+B,WAAA,GAAcnC,cAAA,CAAe,GAC1CI,WAAA,EAAagC,OAAA,GAAUnC,UAAA,CAAW;IAEtCI,iBAAA,CAAkB6B,iBAAA;IAElB3B,oBAAA,CACEb,oBAAA,CAAqB;MACnBM,cAAA;MACAgC,cAAA,EAAgBE,iBAAA;MAChBjC,UAAA;MACAN,SAAA,EAAWkB;IACb;EAEJ;AACF,GACA,CACEV,MAAA,EACAL,EAAA,EACAE,cAAA,EACAC,UAAA,EACAF,GAAA,EACAG,IAAA,CAAKyB,QAAQ,EACbtB,iBAAA,EACAE,oBAAA,EACAD,uBAAA,EACAF,WAAA,EAAa+B,WAAA,EACb/B,WAAA,EAAagC,OAAA,CACd","ignoreList":[]}
|
|
@@ -13,12 +13,8 @@ export type NonFieldError = {
|
|
|
13
13
|
*
|
|
14
14
|
* Multiple handlers can be chained by composing providers; the first one to
|
|
15
15
|
* return `true` wins.
|
|
16
|
-
*
|
|
17
|
-
* `retry` re-submits the form that produced the error, allowing the user to
|
|
18
|
-
* retry after resolving the underlying issue (e.g. deleting documents to free
|
|
19
|
-
* up quota).
|
|
20
16
|
*/
|
|
21
|
-
export type FormErrorHandler = (err: NonFieldError
|
|
17
|
+
export type FormErrorHandler = (err: NonFieldError) => boolean;
|
|
22
18
|
export declare const FormErrorHandlerContext: import("react").Context<FormErrorHandler>;
|
|
23
19
|
export declare const useFormErrorHandler: () => FormErrorHandler | undefined;
|
|
24
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/FormErrorHandler/index.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/FormErrorHandler/index.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,CAAA;AAE9D,eAAO,MAAM,uBAAuB,2CAAyD,CAAA;AAE7F,eAAO,MAAM,mBAAmB,QAAO,gBAAgB,GAAG,SAAyC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createContext","use","FormErrorHandlerContext","undefined","useFormErrorHandler"],"sources":["../../../src/providers/FormErrorHandler/index.tsx"],"sourcesContent":["'use client'\nimport { createContext, use } from 'react'\n\nexport type NonFieldError = {\n data?: unknown\n message: string\n}\n\n/**\n * A callback that a plugin can provide to intercept non-field form errors before\n * Payload shows its default error toast. Return `true` to claim the error (the\n * default toast is suppressed). Return `false` to let Payload handle it normally.\n *\n * Set via `<FormErrorHandlerContext value={handler}>` inside an\n * `admin.components.providers` entry. The Form reads this automatically — no\n * changes to collection config or the edit view are required.\n *\n * Multiple handlers can be chained by composing providers; the first one to\n * return `true` wins.\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["createContext","use","FormErrorHandlerContext","undefined","useFormErrorHandler"],"sources":["../../../src/providers/FormErrorHandler/index.tsx"],"sourcesContent":["'use client'\nimport { createContext, use } from 'react'\n\nexport type NonFieldError = {\n data?: unknown\n message: string\n}\n\n/**\n * A callback that a plugin can provide to intercept non-field form errors before\n * Payload shows its default error toast. Return `true` to claim the error (the\n * default toast is suppressed). Return `false` to let Payload handle it normally.\n *\n * Set via `<FormErrorHandlerContext value={handler}>` inside an\n * `admin.components.providers` entry. The Form reads this automatically — no\n * changes to collection config or the edit view are required.\n *\n * Multiple handlers can be chained by composing providers; the first one to\n * return `true` wins.\n */\nexport type FormErrorHandler = (err: NonFieldError) => boolean\n\nexport const FormErrorHandlerContext = createContext<FormErrorHandler | undefined>(undefined)\n\nexport const useFormErrorHandler = (): FormErrorHandler | undefined => use(FormErrorHandlerContext)\n"],"mappings":"AAAA;;AACA,SAASA,aAAa,EAAEC,GAAG,QAAQ;AAqBnC,OAAO,MAAMC,uBAAA,gBAA0BF,aAAA,CAA4CG,SAAA;AAEnF,OAAO,MAAMC,mBAAA,GAAsBA,CAAA,KAAoCH,GAAA,CAAIC,uBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Hierarchy/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,KAAK,EAEV,qBAAqB,EAGrB,sBAAsB,EAEvB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Hierarchy/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,KAAK,EAEV,qBAAqB,EAGrB,sBAAsB,EAEvB,MAAM,YAAY,CAAA;AASnB,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAmZ9D,CAAA;AAED,eAAO,MAAM,YAAY,QAAO,qBAM/B,CAAA"}
|
|
@@ -5,7 +5,6 @@ import { DEFAULT_HIERARCHY_TREE_LIMIT, formatAdminURL, PREFERENCE_KEYS } from 'p
|
|
|
5
5
|
import * as qs from 'qs-esm';
|
|
6
6
|
import React, { createContext, use, useCallback, useState } from 'react';
|
|
7
7
|
import { useDebouncedCallback } from '../../hooks/useDebouncedCallback.js';
|
|
8
|
-
import { useBranchParam } from '../Branch/index.js';
|
|
9
8
|
import { useConfig } from '../Config/index.js';
|
|
10
9
|
import { usePreferences } from '../Preferences/index.js';
|
|
11
10
|
import { useRouter } from '../RouterAdapter/index.js';
|
|
@@ -26,7 +25,6 @@ export const HierarchyProvider = ({
|
|
|
26
25
|
serverURL
|
|
27
26
|
}
|
|
28
27
|
} = useConfig();
|
|
29
|
-
const branch = useBranchParam();
|
|
30
28
|
const [baseFilter, setBaseFilter] = useState(null);
|
|
31
29
|
const [collectionSlug, setCollectionSlug] = useState(null);
|
|
32
30
|
const [parent, setParent] = useState(null);
|
|
@@ -239,7 +237,6 @@ export const HierarchyProvider = ({
|
|
|
239
237
|
}
|
|
240
238
|
};
|
|
241
239
|
const queryString = qs.stringify({
|
|
242
|
-
branch,
|
|
243
240
|
limit: treeLimit,
|
|
244
241
|
page: nextPage,
|
|
245
242
|
sort: useAsTitle ?? 'id',
|
|
@@ -285,7 +282,7 @@ export const HierarchyProvider = ({
|
|
|
285
282
|
setIsLoadingMore(false);
|
|
286
283
|
setLoadingNodeId(null);
|
|
287
284
|
}
|
|
288
|
-
}, [
|
|
285
|
+
}, [api, collectionSlug, isLoadingMore, parentFieldName, serverURL, treeCache, treeLimit, useAsTitle]);
|
|
289
286
|
const reset = useCallback(() => {
|
|
290
287
|
setBaseFilter(null);
|
|
291
288
|
setCollectionSlug(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DEFAULT_HIERARCHY_TREE_LIMIT","formatAdminURL","PREFERENCE_KEYS","qs","React","createContext","use","useCallback","useState","useDebouncedCallback","useBranchParam","useConfig","usePreferences","useRouter","HierarchyContext","undefined","HierarchyProvider","children","setPreference","router","config","routes","admin","adminRoute","api","serverURL","branch","baseFilter","setBaseFilter","collectionSlug","setCollectionSlug","parent","setParent","parentFieldName","setParentFieldName","treeLimit","setTreeLimit","typeFieldName","setTypeFieldName","useAsTitle","setUseAsTitle","allowedCollections","setAllowedCollections","treeCache","setTreeCache","Map","expandedNodesByCollection","setExpandedNodesByCollection","selectedFiltersByCollection","setSelectedFiltersByCollection","isLoadingMore","setIsLoadingMore","loadingNodeId","setLoadingNodeId","treeRefreshKeys","setTreeRefreshKeys","getNodeChildren","parentId","cache","get","docs","filter","doc","docParentId","String","hydrate","data","newAllowedCollections","newBaseFilter","slug","expandedNodes","newExpandedNodes","newParent","newParentFieldName","selectedFilters","newSelectedFilters","treeData","newTreeLimit","newTypeFieldName","newUseAsTitle","prev","newCache","existingEntry","set","existingDocIds","Set","map","id","newDocs","has","loadedParents","length","newMap","existingExpanded","mergedExpanded","savePreferencesDebounced","preferenceKey","HIERARCHY_TREE","currentExpanded","currentFilters","Array","from","expanded","filters","toggleNodeForCollection","newExpanded","delete","add","toggleNode","getExpandedNodesForCollection","getTreeDataForCollection","setSelectedFilters","selectParent","queryParam","url","path","push","refresh","loadMoreChildren","parentKey","parentMeta","hasMore","currentChildren","nextPage","Math","floor","where","or","exists","equals","queryString","stringify","limit","page","sort","addQueryPrefix","apiRoute","response","fetch","credentials","ok","Error","json","uniqueNewDocs","hasNextPage","totalDocs","reset","refreshTree","next","value","_jsx","useHierarchy","context"],"sources":["../../../src/providers/Hierarchy/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TypeWithID, Where } from 'payload'\n\nimport { DEFAULT_HIERARCHY_TREE_LIMIT, formatAdminURL, PREFERENCE_KEYS } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useState } from 'react'\n\nimport type {\n AllowedCollection,\n HierarchyContextValue,\n HierarchyDocument,\n HierarchyHydrateData,\n HierarchyProviderProps,\n HierarchyTreeCacheEntry,\n} from './types.js'\n\nimport { useDebouncedCallback } from '../../hooks/useDebouncedCallback.js'\nimport { useBranchParam } from '../Branch/index.js'\nimport { useConfig } from '../Config/index.js'\nimport { usePreferences } from '../Preferences/index.js'\nimport { useRouter } from '../RouterAdapter/index.js'\n\nconst HierarchyContext = createContext<HierarchyContextValue | undefined>(undefined)\n\nexport const HierarchyProvider: React.FC<HierarchyProviderProps> = ({ children }) => {\n const { setPreference } = usePreferences()\n const router = useRouter()\n const {\n config: {\n routes: { admin: adminRoute, api },\n serverURL,\n },\n } = useConfig()\n\n const branch = useBranchParam()\n\n const [baseFilter, setBaseFilter] = useState<null | Where>(null)\n const [collectionSlug, setCollectionSlug] = useState<null | string>(null)\n const [parent, setParent] = useState<null | (Record<string, unknown> & TypeWithID)>(null)\n const [parentFieldName, setParentFieldName] = useState<string>('')\n const [treeLimit, setTreeLimit] = useState<number>(DEFAULT_HIERARCHY_TREE_LIMIT)\n const [typeFieldName, setTypeFieldName] = useState<null | string>(null)\n const [useAsTitle, setUseAsTitle] = useState<null | string>(null)\n const [allowedCollections, setAllowedCollections] = useState<AllowedCollection[] | null>(null)\n\n const [treeCache, setTreeCache] = useState<Map<string, HierarchyTreeCacheEntry>>(() => new Map())\n const [expandedNodesByCollection, setExpandedNodesByCollection] = useState<\n Map<string, Set<number | string>>\n >(() => new Map())\n const [selectedFiltersByCollection, setSelectedFiltersByCollection] = useState<\n Map<string, string[]>\n >(() => new Map())\n const [isLoadingMore, setIsLoadingMore] = useState<boolean>(false)\n const [loadingNodeId, setLoadingNodeId] = useState<null | number | string>(null)\n const [treeRefreshKeys, setTreeRefreshKeys] = useState<Map<string, number>>(() => new Map())\n\n const getNodeChildren = useCallback(\n (parentId: null | number | string): HierarchyDocument[] => {\n if (!collectionSlug) {\n return []\n }\n\n const cache = treeCache.get(collectionSlug)\n if (!cache) {\n return []\n }\n\n return cache.docs.filter((doc) => {\n const docParentId = doc[parentFieldName]\n if (parentId === null) {\n return docParentId === null || docParentId === undefined\n }\n return docParentId !== null && String(docParentId) === String(parentId)\n })\n },\n [collectionSlug, parentFieldName, treeCache],\n )\n\n const hydrate = useCallback((data: HierarchyHydrateData) => {\n const {\n allowedCollections: newAllowedCollections,\n baseFilter: newBaseFilter,\n collectionSlug: slug,\n expandedNodes: newExpandedNodes,\n parent: newParent,\n parentFieldName: newParentFieldName,\n selectedFilters: newSelectedFilters,\n treeData,\n treeLimit: newTreeLimit,\n typeFieldName: newTypeFieldName,\n useAsTitle: newUseAsTitle,\n } = data\n\n setCollectionSlug(slug)\n\n if (newBaseFilter !== undefined) {\n setBaseFilter(newBaseFilter ?? null)\n }\n\n if (newAllowedCollections) {\n setAllowedCollections(newAllowedCollections)\n }\n\n if (newParentFieldName) {\n setParentFieldName(newParentFieldName)\n }\n\n if (newTreeLimit !== undefined) {\n setTreeLimit(newTreeLimit)\n }\n\n if (newTypeFieldName !== undefined) {\n setTypeFieldName(newTypeFieldName)\n }\n\n if (newParent !== undefined) {\n setParent(newParent)\n }\n\n if (newUseAsTitle !== undefined) {\n setUseAsTitle(newUseAsTitle)\n }\n\n if (treeData) {\n setTreeCache((prev) => {\n const newCache = new Map(prev)\n const existingEntry = newCache.get(slug)\n\n // If baseFilter is provided, replace cache entirely (tenant changed)\n // Otherwise merge to support incremental loading\n if (newBaseFilter !== undefined || !existingEntry) {\n newCache.set(slug, { ...treeData, baseFilter: newBaseFilter ?? null })\n } else {\n const existingDocIds = new Set(existingEntry.docs.map((doc) => doc.id))\n const newDocs = treeData.docs.filter((doc) => !existingDocIds.has(doc.id))\n\n newCache.set(slug, {\n baseFilter: existingEntry.baseFilter,\n docs: [...existingEntry.docs, ...newDocs],\n loadedParents: {\n ...existingEntry.loadedParents,\n ...treeData.loadedParents,\n },\n })\n }\n\n return newCache\n })\n }\n\n if (newExpandedNodes && newExpandedNodes.length > 0) {\n setExpandedNodesByCollection((prev) => {\n const newMap = new Map(prev)\n const existingExpanded = newMap.get(slug) || new Set()\n const mergedExpanded = new Set([...existingExpanded, ...newExpandedNodes])\n newMap.set(slug, mergedExpanded)\n return newMap\n })\n }\n\n if (newSelectedFilters) {\n setSelectedFiltersByCollection((prev) => {\n const newMap = new Map(prev)\n newMap.set(slug, newSelectedFilters)\n return newMap\n })\n }\n }, [])\n\n const savePreferencesDebounced = useDebouncedCallback(\n async (slug: string, data: { expanded?: Set<number | string>; filters?: string[] }) => {\n const preferenceKey = `${PREFERENCE_KEYS.HIERARCHY_TREE}-${slug}`\n const currentExpanded = expandedNodesByCollection.get(slug) || new Set()\n const currentFilters = selectedFiltersByCollection.get(slug) || []\n\n await setPreference(preferenceKey, {\n expandedNodes: Array.from(data.expanded ?? currentExpanded),\n selectedFilters: data.filters ?? currentFilters,\n })\n },\n 500,\n )\n\n const toggleNodeForCollection = useCallback(\n (slug: string, id: number | string) => {\n setExpandedNodesByCollection((prev) => {\n const newMap = new Map(prev)\n const currentExpanded = newMap.get(slug) || new Set()\n const newExpanded = new Set(currentExpanded)\n\n if (newExpanded.has(id)) {\n newExpanded.delete(id)\n } else {\n newExpanded.add(id)\n }\n\n newMap.set(slug, newExpanded)\n savePreferencesDebounced(slug, { expanded: newExpanded })\n return newMap\n })\n },\n [savePreferencesDebounced],\n )\n\n const toggleNode = useCallback(\n (id: number | string) => {\n if (!collectionSlug) {\n return\n }\n toggleNodeForCollection(collectionSlug, id)\n },\n [collectionSlug, toggleNodeForCollection],\n )\n\n const getExpandedNodesForCollection = useCallback(\n (slug: string): Set<number | string> => {\n return expandedNodesByCollection.get(slug) || new Set()\n },\n [expandedNodesByCollection],\n )\n\n const getTreeDataForCollection = useCallback(\n (slug: string) => {\n return treeCache.get(slug) || null\n },\n [treeCache],\n )\n\n const setSelectedFilters = useCallback(\n (filters: string[]) => {\n if (!collectionSlug) {\n return\n }\n\n setSelectedFiltersByCollection((prev) => {\n const newMap = new Map(prev)\n newMap.set(collectionSlug, filters)\n savePreferencesDebounced(collectionSlug, { filters })\n return newMap\n })\n },\n [collectionSlug, savePreferencesDebounced],\n )\n\n const selectParent = useCallback(\n (id: null | number | string) => {\n if (!collectionSlug) {\n return\n }\n\n const queryParam = parentFieldName || 'parent'\n const url = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}${id !== null ? `?${queryParam}=${id}` : ''}`,\n })\n router.push(url)\n router.refresh()\n },\n [adminRoute, collectionSlug, parentFieldName, router],\n )\n\n const loadMoreChildren = useCallback(\n async (parentId: null | number | string): Promise<void> => {\n if (!collectionSlug || isLoadingMore) {\n return\n }\n\n const cache = treeCache.get(collectionSlug)\n if (!cache) {\n return\n }\n\n const parentKey = parentId === null ? 'root' : String(parentId)\n const parentMeta = cache.loadedParents[parentKey]\n if (!parentMeta || !parentMeta.hasMore) {\n return\n }\n\n setIsLoadingMore(true)\n setLoadingNodeId(parentId)\n\n try {\n const currentChildren = cache.docs.filter((doc) => {\n const docParentId = doc[parentFieldName]\n if (parentId === null) {\n return docParentId === null || docParentId === undefined\n }\n return docParentId !== null && String(docParentId) === String(parentId)\n })\n\n const nextPage = Math.floor(currentChildren.length / treeLimit) + 1\n\n const where =\n parentId === null\n ? {\n or: [\n { [parentFieldName]: { exists: false } },\n { [parentFieldName]: { equals: null } },\n ],\n }\n : { [parentFieldName]: { equals: parentId } }\n\n const queryString = qs.stringify(\n { branch, limit: treeLimit, page: nextPage, sort: useAsTitle ?? 'id', where },\n { addQueryPrefix: true },\n )\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n serverURL,\n })\n const response = await fetch(url, {\n credentials: 'include',\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch more children')\n }\n\n const data = await response.json()\n const newDocs = data.docs || []\n\n setTreeCache((prev) => {\n const newCache = new Map(prev)\n const existingEntry = newCache.get(collectionSlug)\n\n if (existingEntry) {\n const existingDocIds = new Set(existingEntry.docs.map((doc) => doc.id))\n const uniqueNewDocs = newDocs.filter((doc) => !existingDocIds.has(doc.id))\n\n newCache.set(collectionSlug, {\n docs: [...existingEntry.docs, ...uniqueNewDocs],\n loadedParents: {\n ...existingEntry.loadedParents,\n [parentKey]: {\n hasMore: data.hasNextPage || false,\n totalDocs: data.totalDocs || 0,\n },\n },\n })\n }\n\n return newCache\n })\n } catch {\n // Failed to load more children - silently fail\n } finally {\n setIsLoadingMore(false)\n setLoadingNodeId(null)\n }\n },\n [\n branch,\n api,\n collectionSlug,\n isLoadingMore,\n parentFieldName,\n serverURL,\n treeCache,\n treeLimit,\n useAsTitle,\n ],\n )\n\n const reset = useCallback(() => {\n setBaseFilter(null)\n setCollectionSlug(null)\n setParent(null)\n setParentFieldName('')\n setTreeLimit(DEFAULT_HIERARCHY_TREE_LIMIT)\n setTypeFieldName(null)\n setUseAsTitle(null)\n setTreeCache(new Map())\n setExpandedNodesByCollection(new Map())\n setSelectedFiltersByCollection(new Map())\n setIsLoadingMore(false)\n setLoadingNodeId(null)\n }, [])\n\n const refreshTree = useCallback((slug: string) => {\n setTreeCache((prev) => {\n const next = new Map(prev)\n next.delete(slug)\n return next\n })\n setTreeRefreshKeys((prev) => {\n const next = new Map(prev)\n next.set(slug, (next.get(slug) ?? 0) + 1)\n return next\n })\n }, [])\n\n const expandedNodes =\n collectionSlug && expandedNodesByCollection.has(collectionSlug)\n ? expandedNodesByCollection.get(collectionSlug)\n : new Set<number | string>()\n\n const selectedFilters =\n collectionSlug && selectedFiltersByCollection.has(collectionSlug)\n ? selectedFiltersByCollection.get(collectionSlug)\n : []\n\n const value: HierarchyContextValue = {\n allowedCollections,\n baseFilter,\n collectionSlug,\n expandedNodes,\n getExpandedNodesForCollection,\n getNodeChildren,\n getTreeDataForCollection,\n hydrate,\n isLoadingMore,\n loadingNodeId,\n loadMoreChildren,\n parent,\n parentFieldName,\n refreshTree,\n reset,\n selectedFilters,\n selectParent,\n setSelectedFilters,\n toggleNode,\n toggleNodeForCollection,\n treeLimit,\n treeRefreshKeys,\n typeFieldName,\n useAsTitle,\n }\n\n return <HierarchyContext value={value}>{children}</HierarchyContext>\n}\n\nexport const useHierarchy = (): HierarchyContextValue => {\n const context = use(HierarchyContext)\n if (!context) {\n throw new Error('useHierarchy must be used within HierarchyProvider')\n }\n return context\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,4BAA4B,EAAEC,cAAc,EAAEC,eAAe,QAAQ;AAC9E,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAWjE,SAASC,oBAAoB,QAAQ;AACrC,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAE1B,MAAMC,gBAAA,gBAAmBT,aAAA,CAAiDU,SAAA;AAE1E,OAAO,MAAMC,iBAAA,GAAsDA,CAAC;EAAEC;AAAQ,CAAE;EAC9E,MAAM;IAAEC;EAAa,CAAE,GAAGN,cAAA;EAC1B,MAAMO,MAAA,GAASN,SAAA;EACf,MAAM;IACJO,MAAA,EAAQ;MACNC,MAAA,EAAQ;QAAEC,KAAA,EAAOC,UAAU;QAAEC;MAAG,CAAE;MAClCC;IAAS;EACV,CACF,GAAGd,SAAA;EAEJ,MAAMe,MAAA,GAAShB,cAAA;EAEf,MAAM,CAACiB,UAAA,EAAYC,aAAA,CAAc,GAAGpB,QAAA,CAAuB;EAC3D,MAAM,CAACqB,cAAA,EAAgBC,iBAAA,CAAkB,GAAGtB,QAAA,CAAwB;EACpE,MAAM,CAACuB,MAAA,EAAQC,SAAA,CAAU,GAAGxB,QAAA,CAAwD;EACpF,MAAM,CAACyB,eAAA,EAAiBC,kBAAA,CAAmB,GAAG1B,QAAA,CAAiB;EAC/D,MAAM,CAAC2B,SAAA,EAAWC,YAAA,CAAa,GAAG5B,QAAA,CAAiBR,4BAAA;EACnD,MAAM,CAACqC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7C,cAAA,IAAkBmB,2BAAA,CAA4ByC,GAAG,CAAC5D,cAAA,IAC9CmB,2BAAA,CAA4BW,GAAG,CAAC9B,cAAA,IAChC,EAAE;EAER,MAAMwH,KAAA,GAA+B;IACnC5G,kBAAA;IACAd,UAAA;IACAE,cAAA;IACAyC,aAAA;IACAuC,6BAAA;IACArD,eAAA;IACAsD,wBAAA;IACA7C,OAAA;IACAf,aAAA;IACAE,aAAA;IACAkE,gBAAA;IACAvF,MAAA;IACAE,eAAA;IACAkH,WAAA;IACAD,KAAA;IACAxE,eAAA;IACAsC,YAAA;IACAD,kBAAA;IACAH,UAAA;IACAJ,uBAAA;IACArE,SAAA;IACAmB,eAAA;IACAjB,aAAA;IACAE;EACF;EAEA,oBAAO+G,IAAA,CAACxI,gBAAA;IAAiBuI,KAAA,EAAOA,KAAA;cAAQpI;;AAC1C;AAEA,OAAO,MAAMsI,YAAA,GAAeA,CAAA;EAC1B,MAAMC,OAAA,GAAUlJ,GAAA,CAAIQ,gBAAA;EACpB,IAAI,CAAC0I,OAAA,EAAS;IACZ,MAAM,IAAIX,KAAA,CAAM;EAClB;EACA,OAAOW,OAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DEFAULT_HIERARCHY_TREE_LIMIT","formatAdminURL","PREFERENCE_KEYS","qs","React","createContext","use","useCallback","useState","useDebouncedCallback","useConfig","usePreferences","useRouter","HierarchyContext","undefined","HierarchyProvider","children","setPreference","router","config","routes","admin","adminRoute","api","serverURL","baseFilter","setBaseFilter","collectionSlug","setCollectionSlug","parent","setParent","parentFieldName","setParentFieldName","treeLimit","setTreeLimit","typeFieldName","setTypeFieldName","useAsTitle","setUseAsTitle","allowedCollections","setAllowedCollections","treeCache","setTreeCache","Map","expandedNodesByCollection","setExpandedNodesByCollection","selectedFiltersByCollection","setSelectedFiltersByCollection","isLoadingMore","setIsLoadingMore","loadingNodeId","setLoadingNodeId","treeRefreshKeys","setTreeRefreshKeys","getNodeChildren","parentId","cache","get","docs","filter","doc","docParentId","String","hydrate","data","newAllowedCollections","newBaseFilter","slug","expandedNodes","newExpandedNodes","newParent","newParentFieldName","selectedFilters","newSelectedFilters","treeData","newTreeLimit","newTypeFieldName","newUseAsTitle","prev","newCache","existingEntry","set","existingDocIds","Set","map","id","newDocs","has","loadedParents","length","newMap","existingExpanded","mergedExpanded","savePreferencesDebounced","preferenceKey","HIERARCHY_TREE","currentExpanded","currentFilters","Array","from","expanded","filters","toggleNodeForCollection","newExpanded","delete","add","toggleNode","getExpandedNodesForCollection","getTreeDataForCollection","setSelectedFilters","selectParent","queryParam","url","path","push","refresh","loadMoreChildren","parentKey","parentMeta","hasMore","currentChildren","nextPage","Math","floor","where","or","exists","equals","queryString","stringify","limit","page","sort","addQueryPrefix","apiRoute","response","fetch","credentials","ok","Error","json","uniqueNewDocs","hasNextPage","totalDocs","reset","refreshTree","next","value","_jsx","useHierarchy","context"],"sources":["../../../src/providers/Hierarchy/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TypeWithID, Where } from 'payload'\n\nimport { DEFAULT_HIERARCHY_TREE_LIMIT, formatAdminURL, PREFERENCE_KEYS } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useState } from 'react'\n\nimport type {\n AllowedCollection,\n HierarchyContextValue,\n HierarchyDocument,\n HierarchyHydrateData,\n HierarchyProviderProps,\n HierarchyTreeCacheEntry,\n} from './types.js'\n\nimport { useDebouncedCallback } from '../../hooks/useDebouncedCallback.js'\nimport { useConfig } from '../Config/index.js'\nimport { usePreferences } from '../Preferences/index.js'\nimport { useRouter } from '../RouterAdapter/index.js'\n\nconst HierarchyContext = createContext<HierarchyContextValue | undefined>(undefined)\n\nexport const HierarchyProvider: React.FC<HierarchyProviderProps> = ({ children }) => {\n const { setPreference } = usePreferences()\n const router = useRouter()\n const {\n config: {\n routes: { admin: adminRoute, api },\n serverURL,\n },\n } = useConfig()\n\n const [baseFilter, setBaseFilter] = useState<null | Where>(null)\n const [collectionSlug, setCollectionSlug] = useState<null | string>(null)\n const [parent, setParent] = useState<null | (Record<string, unknown> & TypeWithID)>(null)\n const [parentFieldName, setParentFieldName] = useState<string>('')\n const [treeLimit, setTreeLimit] = useState<number>(DEFAULT_HIERARCHY_TREE_LIMIT)\n const [typeFieldName, setTypeFieldName] = useState<null | string>(null)\n const [useAsTitle, setUseAsTitle] = useState<null | string>(null)\n const [allowedCollections, setAllowedCollections] = useState<AllowedCollection[] | null>(null)\n\n const [treeCache, setTreeCache] = useState<Map<string, HierarchyTreeCacheEntry>>(() => new Map())\n const [expandedNodesByCollection, setExpandedNodesByCollection] = useState<\n Map<string, Set<number | string>>\n >(() => new Map())\n const [selectedFiltersByCollection, setSelectedFiltersByCollection] = useState<\n Map<string, string[]>\n >(() => new Map())\n const [isLoadingMore, setIsLoadingMore] = useState<boolean>(false)\n const [loadingNodeId, setLoadingNodeId] = useState<null | number | string>(null)\n const [treeRefreshKeys, setTreeRefreshKeys] = useState<Map<string, number>>(() => new Map())\n\n const getNodeChildren = useCallback(\n (parentId: null | number | string): HierarchyDocument[] => {\n if (!collectionSlug) {\n return []\n }\n\n const cache = treeCache.get(collectionSlug)\n if (!cache) {\n return []\n }\n\n return cache.docs.filter((doc) => {\n const docParentId = doc[parentFieldName]\n if (parentId === null) {\n return docParentId === null || docParentId === undefined\n }\n return docParentId !== null && String(docParentId) === String(parentId)\n })\n },\n [collectionSlug, parentFieldName, treeCache],\n )\n\n const hydrate = useCallback((data: HierarchyHydrateData) => {\n const {\n allowedCollections: newAllowedCollections,\n baseFilter: newBaseFilter,\n collectionSlug: slug,\n expandedNodes: newExpandedNodes,\n parent: newParent,\n parentFieldName: newParentFieldName,\n selectedFilters: newSelectedFilters,\n treeData,\n treeLimit: newTreeLimit,\n typeFieldName: newTypeFieldName,\n useAsTitle: newUseAsTitle,\n } = data\n\n setCollectionSlug(slug)\n\n if (newBaseFilter !== undefined) {\n setBaseFilter(newBaseFilter ?? null)\n }\n\n if (newAllowedCollections) {\n setAllowedCollections(newAllowedCollections)\n }\n\n if (newParentFieldName) {\n setParentFieldName(newParentFieldName)\n }\n\n if (newTreeLimit !== undefined) {\n setTreeLimit(newTreeLimit)\n }\n\n if (newTypeFieldName !== undefined) {\n setTypeFieldName(newTypeFieldName)\n }\n\n if (newParent !== undefined) {\n setParent(newParent)\n }\n\n if (newUseAsTitle !== undefined) {\n setUseAsTitle(newUseAsTitle)\n }\n\n if (treeData) {\n setTreeCache((prev) => {\n const newCache = new Map(prev)\n const existingEntry = newCache.get(slug)\n\n // If baseFilter is provided, replace cache entirely (tenant changed)\n // Otherwise merge to support incremental loading\n if (newBaseFilter !== undefined || !existingEntry) {\n newCache.set(slug, { ...treeData, baseFilter: newBaseFilter ?? null })\n } else {\n const existingDocIds = new Set(existingEntry.docs.map((doc) => doc.id))\n const newDocs = treeData.docs.filter((doc) => !existingDocIds.has(doc.id))\n\n newCache.set(slug, {\n baseFilter: existingEntry.baseFilter,\n docs: [...existingEntry.docs, ...newDocs],\n loadedParents: {\n ...existingEntry.loadedParents,\n ...treeData.loadedParents,\n },\n })\n }\n\n return newCache\n })\n }\n\n if (newExpandedNodes && newExpandedNodes.length > 0) {\n setExpandedNodesByCollection((prev) => {\n const newMap = new Map(prev)\n const existingExpanded = newMap.get(slug) || new Set()\n const mergedExpanded = new Set([...existingExpanded, ...newExpandedNodes])\n newMap.set(slug, mergedExpanded)\n return newMap\n })\n }\n\n if (newSelectedFilters) {\n setSelectedFiltersByCollection((prev) => {\n const newMap = new Map(prev)\n newMap.set(slug, newSelectedFilters)\n return newMap\n })\n }\n }, [])\n\n const savePreferencesDebounced = useDebouncedCallback(\n async (slug: string, data: { expanded?: Set<number | string>; filters?: string[] }) => {\n const preferenceKey = `${PREFERENCE_KEYS.HIERARCHY_TREE}-${slug}`\n const currentExpanded = expandedNodesByCollection.get(slug) || new Set()\n const currentFilters = selectedFiltersByCollection.get(slug) || []\n\n await setPreference(preferenceKey, {\n expandedNodes: Array.from(data.expanded ?? currentExpanded),\n selectedFilters: data.filters ?? currentFilters,\n })\n },\n 500,\n )\n\n const toggleNodeForCollection = useCallback(\n (slug: string, id: number | string) => {\n setExpandedNodesByCollection((prev) => {\n const newMap = new Map(prev)\n const currentExpanded = newMap.get(slug) || new Set()\n const newExpanded = new Set(currentExpanded)\n\n if (newExpanded.has(id)) {\n newExpanded.delete(id)\n } else {\n newExpanded.add(id)\n }\n\n newMap.set(slug, newExpanded)\n savePreferencesDebounced(slug, { expanded: newExpanded })\n return newMap\n })\n },\n [savePreferencesDebounced],\n )\n\n const toggleNode = useCallback(\n (id: number | string) => {\n if (!collectionSlug) {\n return\n }\n toggleNodeForCollection(collectionSlug, id)\n },\n [collectionSlug, toggleNodeForCollection],\n )\n\n const getExpandedNodesForCollection = useCallback(\n (slug: string): Set<number | string> => {\n return expandedNodesByCollection.get(slug) || new Set()\n },\n [expandedNodesByCollection],\n )\n\n const getTreeDataForCollection = useCallback(\n (slug: string) => {\n return treeCache.get(slug) || null\n },\n [treeCache],\n )\n\n const setSelectedFilters = useCallback(\n (filters: string[]) => {\n if (!collectionSlug) {\n return\n }\n\n setSelectedFiltersByCollection((prev) => {\n const newMap = new Map(prev)\n newMap.set(collectionSlug, filters)\n savePreferencesDebounced(collectionSlug, { filters })\n return newMap\n })\n },\n [collectionSlug, savePreferencesDebounced],\n )\n\n const selectParent = useCallback(\n (id: null | number | string) => {\n if (!collectionSlug) {\n return\n }\n\n const queryParam = parentFieldName || 'parent'\n const url = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}${id !== null ? `?${queryParam}=${id}` : ''}`,\n })\n router.push(url)\n router.refresh()\n },\n [adminRoute, collectionSlug, parentFieldName, router],\n )\n\n const loadMoreChildren = useCallback(\n async (parentId: null | number | string): Promise<void> => {\n if (!collectionSlug || isLoadingMore) {\n return\n }\n\n const cache = treeCache.get(collectionSlug)\n if (!cache) {\n return\n }\n\n const parentKey = parentId === null ? 'root' : String(parentId)\n const parentMeta = cache.loadedParents[parentKey]\n if (!parentMeta || !parentMeta.hasMore) {\n return\n }\n\n setIsLoadingMore(true)\n setLoadingNodeId(parentId)\n\n try {\n const currentChildren = cache.docs.filter((doc) => {\n const docParentId = doc[parentFieldName]\n if (parentId === null) {\n return docParentId === null || docParentId === undefined\n }\n return docParentId !== null && String(docParentId) === String(parentId)\n })\n\n const nextPage = Math.floor(currentChildren.length / treeLimit) + 1\n\n const where =\n parentId === null\n ? {\n or: [\n { [parentFieldName]: { exists: false } },\n { [parentFieldName]: { equals: null } },\n ],\n }\n : { [parentFieldName]: { equals: parentId } }\n\n const queryString = qs.stringify(\n { limit: treeLimit, page: nextPage, sort: useAsTitle ?? 'id', where },\n { addQueryPrefix: true },\n )\n const url = formatAdminURL({\n apiRoute: api,\n path: `/${collectionSlug}${queryString}`,\n serverURL,\n })\n const response = await fetch(url, {\n credentials: 'include',\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch more children')\n }\n\n const data = await response.json()\n const newDocs = data.docs || []\n\n setTreeCache((prev) => {\n const newCache = new Map(prev)\n const existingEntry = newCache.get(collectionSlug)\n\n if (existingEntry) {\n const existingDocIds = new Set(existingEntry.docs.map((doc) => doc.id))\n const uniqueNewDocs = newDocs.filter((doc) => !existingDocIds.has(doc.id))\n\n newCache.set(collectionSlug, {\n docs: [...existingEntry.docs, ...uniqueNewDocs],\n loadedParents: {\n ...existingEntry.loadedParents,\n [parentKey]: {\n hasMore: data.hasNextPage || false,\n totalDocs: data.totalDocs || 0,\n },\n },\n })\n }\n\n return newCache\n })\n } catch {\n // Failed to load more children - silently fail\n } finally {\n setIsLoadingMore(false)\n setLoadingNodeId(null)\n }\n },\n [\n api,\n collectionSlug,\n isLoadingMore,\n parentFieldName,\n serverURL,\n treeCache,\n treeLimit,\n useAsTitle,\n ],\n )\n\n const reset = useCallback(() => {\n setBaseFilter(null)\n setCollectionSlug(null)\n setParent(null)\n setParentFieldName('')\n setTreeLimit(DEFAULT_HIERARCHY_TREE_LIMIT)\n setTypeFieldName(null)\n setUseAsTitle(null)\n setTreeCache(new Map())\n setExpandedNodesByCollection(new Map())\n setSelectedFiltersByCollection(new Map())\n setIsLoadingMore(false)\n setLoadingNodeId(null)\n }, [])\n\n const refreshTree = useCallback((slug: string) => {\n setTreeCache((prev) => {\n const next = new Map(prev)\n next.delete(slug)\n return next\n })\n setTreeRefreshKeys((prev) => {\n const next = new Map(prev)\n next.set(slug, (next.get(slug) ?? 0) + 1)\n return next\n })\n }, [])\n\n const expandedNodes =\n collectionSlug && expandedNodesByCollection.has(collectionSlug)\n ? expandedNodesByCollection.get(collectionSlug)\n : new Set<number | string>()\n\n const selectedFilters =\n collectionSlug && selectedFiltersByCollection.has(collectionSlug)\n ? selectedFiltersByCollection.get(collectionSlug)\n : []\n\n const value: HierarchyContextValue = {\n allowedCollections,\n baseFilter,\n collectionSlug,\n expandedNodes,\n getExpandedNodesForCollection,\n getNodeChildren,\n getTreeDataForCollection,\n hydrate,\n isLoadingMore,\n loadingNodeId,\n loadMoreChildren,\n parent,\n parentFieldName,\n refreshTree,\n reset,\n selectedFilters,\n selectParent,\n setSelectedFilters,\n toggleNode,\n toggleNodeForCollection,\n treeLimit,\n treeRefreshKeys,\n typeFieldName,\n useAsTitle,\n }\n\n return <HierarchyContext value={value}>{children}</HierarchyContext>\n}\n\nexport const useHierarchy = (): HierarchyContextValue => {\n const context = use(HierarchyContext)\n if (!context) {\n throw new Error('useHierarchy must be used within HierarchyProvider')\n }\n return context\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,4BAA4B,EAAEC,cAAc,EAAEC,eAAe,QAAQ;AAC9E,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAWjE,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAE1B,MAAMC,gBAAA,gBAAmBR,a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,CAAIO,gBAAA;EACpB,IAAI,CAACyI,OAAA,EAAS;IACZ,MAAM,IAAIX,KAAA,CAAM;EAClB;EACA,OAAOW,OAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Locale/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,OAAO,KAA0D,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Locale/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,OAAO,KAA0D,MAAM,OAAO,CAAA;AAS9E,eAAO,MAAM,oBAAoB;;4BAEP,OAAO;EAC/B,CAAA;AAcF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;CAAE,CA4F5F,CAAA;AAED,eAAO,MAAM,gBAAgB;;4BA7GH,OAAO;CA6G8B,CAAA;AAE/D;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAO,MAA4B,CAAA"}
|
|
@@ -8,7 +8,6 @@ import { findLocaleFromCode } from '../../utilities/findLocaleFromCode.js';
|
|
|
8
8
|
import { useAuth } from '../Auth/index.js';
|
|
9
9
|
import { useConfig } from '../Config/index.js';
|
|
10
10
|
import { useSearchParams } from '../RouterAdapter/index.js';
|
|
11
|
-
import { useRouteTransition } from '../RouteTransition/index.js';
|
|
12
11
|
const LocaleContext = /*#__PURE__*/createContext({});
|
|
13
12
|
export const LocaleLoadingContext = /*#__PURE__*/createContext({
|
|
14
13
|
localeIsLoading: false,
|
|
@@ -22,7 +21,7 @@ const fetchPreferences = async (key, baseURL) => await fetch(`${baseURL}/payload
|
|
|
22
21
|
method: 'GET'
|
|
23
22
|
})?.then(res => res.json());
|
|
24
23
|
export const LocaleProvider = t0 => {
|
|
25
|
-
const $ = _c(
|
|
24
|
+
const $ = _c(28);
|
|
26
25
|
const {
|
|
27
26
|
children,
|
|
28
27
|
locale: initialLocaleFromPrefs
|
|
@@ -41,9 +40,6 @@ export const LocaleProvider = t0 => {
|
|
|
41
40
|
const {
|
|
42
41
|
user
|
|
43
42
|
} = useAuth();
|
|
44
|
-
const {
|
|
45
|
-
isTransitioning
|
|
46
|
-
} = useRouteTransition();
|
|
47
43
|
const defaultLocale = localization ? localization.defaultLocale : "en";
|
|
48
44
|
const t4 = useSearchParams();
|
|
49
45
|
let t5;
|
|
@@ -76,37 +72,36 @@ export const LocaleProvider = t0 => {
|
|
|
76
72
|
const prevLocale = useRef(locale);
|
|
77
73
|
let t7;
|
|
78
74
|
let t8;
|
|
79
|
-
if ($[7] !==
|
|
75
|
+
if ($[7] !== locale) {
|
|
80
76
|
t7 = () => {
|
|
81
|
-
if (locale.code !== prevLocale.current.code
|
|
77
|
+
if (locale.code !== prevLocale.current.code) {
|
|
82
78
|
setLocaleIsLoading(false);
|
|
83
|
-
prevLocale.current = locale;
|
|
84
79
|
}
|
|
80
|
+
prevLocale.current = locale;
|
|
85
81
|
};
|
|
86
|
-
t8 = [
|
|
87
|
-
$[7] =
|
|
88
|
-
$[8] =
|
|
89
|
-
$[9] =
|
|
90
|
-
$[10] = t8;
|
|
82
|
+
t8 = [locale];
|
|
83
|
+
$[7] = locale;
|
|
84
|
+
$[8] = t7;
|
|
85
|
+
$[9] = t8;
|
|
91
86
|
} else {
|
|
92
|
-
t7 = $[
|
|
93
|
-
t8 = $[
|
|
87
|
+
t7 = $[8];
|
|
88
|
+
t8 = $[9];
|
|
94
89
|
}
|
|
95
90
|
useEffect(t7, t8);
|
|
96
91
|
let t9;
|
|
97
|
-
if ($[
|
|
92
|
+
if ($[10] !== apiRoute) {
|
|
98
93
|
t9 = formatAdminURL({
|
|
99
94
|
apiRoute,
|
|
100
95
|
path: ""
|
|
101
96
|
});
|
|
102
|
-
$[
|
|
103
|
-
$[
|
|
97
|
+
$[10] = apiRoute;
|
|
98
|
+
$[11] = t9;
|
|
104
99
|
} else {
|
|
105
|
-
t9 = $[
|
|
100
|
+
t9 = $[11];
|
|
106
101
|
}
|
|
107
102
|
const fetchURL = t9;
|
|
108
103
|
let t10;
|
|
109
|
-
if ($[
|
|
104
|
+
if ($[12] !== defaultLocale || $[13] !== fetchURL || $[14] !== localeFromParams || $[15] !== localization || $[16] !== user?.id) {
|
|
110
105
|
t10 = () => {
|
|
111
106
|
const resetLocale = async function resetLocale() {
|
|
112
107
|
if (localization && user?.id) {
|
|
@@ -119,31 +114,31 @@ export const LocaleProvider = t0 => {
|
|
|
119
114
|
};
|
|
120
115
|
resetLocale();
|
|
121
116
|
};
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
117
|
+
$[12] = defaultLocale;
|
|
118
|
+
$[13] = fetchURL;
|
|
119
|
+
$[14] = localeFromParams;
|
|
120
|
+
$[15] = localization;
|
|
121
|
+
$[16] = user?.id;
|
|
122
|
+
$[17] = t10;
|
|
128
123
|
} else {
|
|
129
|
-
t10 = $[
|
|
124
|
+
t10 = $[17];
|
|
130
125
|
}
|
|
131
126
|
const t11 = user?.id;
|
|
132
127
|
let t12;
|
|
133
|
-
if ($[
|
|
128
|
+
if ($[18] !== defaultLocale || $[19] !== fetchURL || $[20] !== localeFromParams || $[21] !== localization || $[22] !== t11) {
|
|
134
129
|
t12 = [defaultLocale, localization, fetchURL, localeFromParams, t11];
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
130
|
+
$[18] = defaultLocale;
|
|
131
|
+
$[19] = fetchURL;
|
|
132
|
+
$[20] = localeFromParams;
|
|
133
|
+
$[21] = localization;
|
|
134
|
+
$[22] = t11;
|
|
135
|
+
$[23] = t12;
|
|
141
136
|
} else {
|
|
142
|
-
t12 = $[
|
|
137
|
+
t12 = $[23];
|
|
143
138
|
}
|
|
144
139
|
useEffect(t10, t12);
|
|
145
140
|
let t13;
|
|
146
|
-
if ($[
|
|
141
|
+
if ($[24] !== children || $[25] !== isLoading || $[26] !== locale) {
|
|
147
142
|
t13 = _jsx(LocaleContext, {
|
|
148
143
|
value: locale,
|
|
149
144
|
children: _jsx(LocaleLoadingContext, {
|
|
@@ -154,12 +149,12 @@ export const LocaleProvider = t0 => {
|
|
|
154
149
|
children
|
|
155
150
|
})
|
|
156
151
|
});
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
152
|
+
$[24] = children;
|
|
153
|
+
$[25] = isLoading;
|
|
154
|
+
$[26] = locale;
|
|
155
|
+
$[27] = t13;
|
|
161
156
|
} else {
|
|
162
|
-
t13 = $[
|
|
157
|
+
t13 = $[27];
|
|
163
158
|
}
|
|
164
159
|
return t13;
|
|
165
160
|
};
|