@payloadcms/next 3.85.0 → 4.0.0-internal.1f9ae9a
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/adapters/layout.d.ts +7 -0
- package/dist/adapters/layout.d.ts.map +1 -0
- package/dist/adapters/layout.js +38 -0
- package/dist/adapters/layout.js.map +1 -0
- package/dist/adapters/router.d.ts +5 -0
- package/dist/adapters/router.d.ts.map +1 -0
- package/dist/adapters/router.js +53 -0
- package/dist/adapters/router.js.map +1 -0
- package/dist/adapters/server.d.ts +7 -0
- package/dist/adapters/server.d.ts.map +1 -0
- package/dist/adapters/server.js +39 -0
- package/dist/adapters/server.js.map +1 -0
- package/dist/cjs/withPayload.cjs +13 -176
- package/dist/cjs/withPayload.cjs.map +4 -4
- package/dist/exports/layouts.d.ts +1 -1
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +1 -1
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/utilities.d.ts +2 -67
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/exports/utilities.js +1 -49
- package/dist/exports/utilities.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/routes/graphql/handler.d.ts.map +1 -1
- package/dist/routes/graphql/playground.d.ts.map +1 -1
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/utilities/getHierarchyAncestry.d.ts +24 -0
- package/dist/utilities/getHierarchyAncestry.d.ts.map +1 -0
- package/dist/utilities/getHierarchyAncestry.js +103 -0
- package/dist/utilities/getHierarchyAncestry.js.map +1 -0
- package/dist/utilities/getNextRequestI18n.d.ts.map +1 -1
- package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
- package/dist/utilities/getRouteWithoutAdmin.d.ts.map +1 -1
- package/dist/utilities/handleAuthRedirect.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +8 -5
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/isCustomAdminView.d.ts.map +1 -1
- package/dist/utilities/isPublicAdminRoute.d.ts.map +1 -1
- package/dist/utilities/meta.d.ts.map +1 -1
- package/dist/utilities/switchLanguageHandler.d.ts +13 -0
- package/dist/utilities/switchLanguageHandler.d.ts.map +1 -0
- package/dist/utilities/switchLanguageHandler.js +16 -0
- package/dist/utilities/switchLanguageHandler.js.map +1 -0
- package/dist/utilities/timestamp.d.ts.map +1 -1
- package/dist/views/API/index.client.d.ts +1 -1
- package/dist/views/API/index.client.d.ts.map +1 -1
- package/dist/views/API/index.client.js +111 -78
- package/dist/views/API/index.client.js.map +1 -1
- package/dist/views/API/index.css +205 -0
- package/dist/views/Account/ResetPreferences/index.js.map +1 -1
- package/dist/views/Account/Settings/index.css +26 -0
- package/dist/views/Account/Settings/index.d.ts +1 -1
- package/dist/views/Account/Settings/index.d.ts.map +1 -1
- package/dist/views/Account/Settings/index.js +2 -1
- package/dist/views/Account/Settings/index.js.map +1 -1
- package/dist/views/Account/ToggleHighContrast/index.d.ts +3 -0
- package/dist/views/Account/ToggleHighContrast/index.d.ts.map +1 -0
- package/dist/views/Account/ToggleHighContrast/index.js +45 -0
- package/dist/views/Account/ToggleHighContrast/index.js.map +1 -0
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +2 -1
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/CollectionTrash/metadata.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +32 -25
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.css +69 -0
- package/dist/views/CreateFirstUser/index.d.ts +1 -1
- package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.js +9 -5
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js +72 -45
- package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.js +25 -22
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.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 +2 -3
- package/dist/views/Dashboard/Default/ModularDashboard/index.client.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.css +299 -0
- package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.js +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.js.map +1 -1
- package/dist/views/Dashboard/Default/index.d.ts +0 -6
- package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/index.js +3 -0
- package/dist/views/Dashboard/Default/index.js.map +1 -1
- package/dist/views/Dashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/index.js +1 -0
- package/dist/views/Dashboard/index.js.map +1 -1
- package/dist/views/Document/getCustomDocumentViewByKey.d.ts.map +1 -1
- package/dist/views/Document/getCustomViewByRoute.d.ts.map +1 -1
- package/dist/views/Document/getDocPreferences.d.ts.map +1 -1
- package/dist/views/Document/getDocumentData.d.ts.map +1 -1
- package/dist/views/Document/getDocumentPermissions.d.ts.map +1 -1
- package/dist/views/Document/getDocumentView.d.ts.map +1 -1
- package/dist/views/Document/getDocumentView.js +3 -9
- package/dist/views/Document/getDocumentView.js.map +1 -1
- package/dist/views/Document/getIsLocked.d.ts.map +1 -1
- package/dist/views/Document/getVersions.d.ts.map +1 -1
- package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
- package/dist/views/Document/handleServerFunction.js +1 -0
- package/dist/views/Document/handleServerFunction.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +6 -3
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -1
- package/dist/views/Document/renderDocumentSlots.js +17 -8
- package/dist/views/Document/renderDocumentSlots.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.css +36 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts +1 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +62 -55
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.css +21 -0
- package/dist/views/ForgotPassword/index.d.ts +1 -0
- package/dist/views/ForgotPassword/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/index.js +11 -8
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/Hierarchy/index.d.ts +18 -0
- package/dist/views/Hierarchy/index.d.ts.map +1 -0
- package/dist/views/Hierarchy/index.js +20 -0
- package/dist/views/Hierarchy/index.js.map +1 -0
- package/dist/views/List/createSerializableValue.d.ts.map +1 -1
- package/dist/views/List/extractRelationshipDisplayValue.d.ts.map +1 -1
- package/dist/views/List/extractValueOrRelationshipID.d.ts.map +1 -1
- package/dist/views/List/handleGroupBy.d.ts.map +1 -1
- package/dist/views/List/handleGroupBy.js +8 -0
- package/dist/views/List/handleGroupBy.js.map +1 -1
- package/dist/views/List/handleHierarchy.d.ts +18 -0
- package/dist/views/List/handleHierarchy.d.ts.map +1 -0
- package/dist/views/List/handleHierarchy.js +259 -0
- package/dist/views/List/handleHierarchy.js.map +1 -0
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js +1 -0
- package/dist/views/List/handleServerFunction.js.map +1 -1
- package/dist/views/List/index.css +3 -0
- package/dist/views/List/index.d.ts +1 -0
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +113 -31
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/metadata.d.ts.map +1 -1
- package/dist/views/List/renderListViewSlots.d.ts.map +1 -1
- package/dist/views/List/renderListViewSlots.js +2 -1
- package/dist/views/List/renderListViewSlots.js.map +1 -1
- package/dist/views/List/resolveAllFilterOptions.d.ts.map +1 -1
- package/dist/views/List/transformColumnsToSelect.d.ts.map +1 -1
- package/dist/views/Login/LoginForm/index.css +48 -0
- package/dist/views/Login/LoginForm/index.d.ts +1 -1
- package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
- package/dist/views/Login/LoginForm/index.js +33 -26
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Login/index.css +8 -0
- package/dist/views/Login/index.d.ts +1 -1
- package/dist/views/Login/index.d.ts.map +1 -1
- package/dist/views/Login/index.js +4 -1
- package/dist/views/Login/index.js.map +1 -1
- package/dist/views/NotFound/index.client.d.ts +2 -4
- package/dist/views/NotFound/index.client.d.ts.map +1 -1
- package/dist/views/NotFound/index.client.js +25 -42
- package/dist/views/NotFound/index.client.js.map +1 -1
- package/dist/views/NotFound/index.css +47 -0
- package/dist/views/NotFound/index.d.ts.map +1 -1
- package/dist/views/NotFound/index.js +7 -6
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/NotFound/metadata.d.ts.map +1 -1
- package/dist/views/ResetPassword/ResetPasswordForm/index.css +36 -0
- package/dist/views/ResetPassword/ResetPasswordForm/index.d.ts +1 -0
- package/dist/views/ResetPassword/ResetPasswordForm/index.d.ts.map +1 -1
- package/dist/views/ResetPassword/ResetPasswordForm/index.js +13 -6
- package/dist/views/ResetPassword/ResetPasswordForm/index.js.map +1 -1
- package/dist/views/ResetPassword/index.css +27 -0
- package/dist/views/ResetPassword/index.d.ts +1 -1
- package/dist/views/ResetPassword/index.d.ts.map +1 -1
- package/dist/views/ResetPassword/index.js +12 -11
- package/dist/views/ResetPassword/index.js.map +1 -1
- package/dist/views/Root/generateCustomViewMetadata.d.ts.map +1 -1
- package/dist/views/Root/getCustomCollectionViewByRoute.d.ts.map +1 -1
- package/dist/views/Root/getCustomGlobalViewByRoute.d.ts +12 -0
- package/dist/views/Root/getCustomGlobalViewByRoute.d.ts.map +1 -0
- package/dist/views/Root/getCustomGlobalViewByRoute.js +46 -0
- package/dist/views/Root/getCustomGlobalViewByRoute.js.map +1 -0
- package/dist/views/Root/getCustomViewByKey.d.ts.map +1 -1
- package/dist/views/Root/getCustomViewByRoute.d.ts.map +1 -1
- package/dist/views/Root/getRouteData.d.ts +1 -4
- package/dist/views/Root/getRouteData.d.ts.map +1 -1
- package/dist/views/Root/getRouteData.js +83 -110
- package/dist/views/Root/getRouteData.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +11 -17
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Root/isPathMatchingRoute.d.ts.map +1 -1
- package/dist/views/Root/metadata.d.ts.map +1 -1
- package/dist/views/Root/metadata.js +1 -37
- package/dist/views/Root/metadata.js.map +1 -1
- package/dist/views/Unauthorized/index.css +44 -0
- package/dist/views/Unauthorized/index.d.ts +1 -1
- package/dist/views/Unauthorized/index.d.ts.map +1 -1
- package/dist/views/Unauthorized/index.js +12 -33
- package/dist/views/Unauthorized/index.js.map +1 -1
- package/dist/views/Verify/index.d.ts.map +1 -1
- package/dist/views/Verify/index.js +2 -1
- package/dist/views/Verify/index.js.map +1 -1
- package/dist/views/Version/Default/index.css +227 -0
- package/dist/views/Version/Default/index.d.ts +1 -1
- package/dist/views/Version/Default/index.d.ts.map +1 -1
- package/dist/views/Version/Default/index.js +13 -11
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.css +64 -0
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.d.ts +2 -1
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js +54 -48
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +3 -3
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Checkbox/index.css +97 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Checkbox/index.d.ts +4 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Checkbox/index.d.ts.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Checkbox/index.js +91 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Checkbox/index.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.css +29 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.js +37 -32
- package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.css +5 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.css +40 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +3 -6
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.css +213 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +47 -25
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.css +4 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +28 -22
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.css +6 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.css +4 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +23 -15
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.css +188 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js +91 -51
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/index.js +2 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/index.css +24 -0
- package/dist/views/Version/RenderFieldsToDiff/index.d.ts.map +1 -1
- package/dist/views/Version/Restore/index.css +26 -0
- package/dist/views/Version/Restore/index.d.ts +1 -1
- package/dist/views/Version/Restore/index.d.ts.map +1 -1
- package/dist/views/Version/Restore/index.js +4 -3
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/index.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/index.js +0 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/index.js.map +1 -1
- package/dist/views/Version/VersionPillLabel/VersionPillLabel.d.ts +1 -1
- package/dist/views/Version/VersionPillLabel/VersionPillLabel.d.ts.map +1 -1
- package/dist/views/Version/VersionPillLabel/VersionPillLabel.js +15 -8
- package/dist/views/Version/VersionPillLabel/VersionPillLabel.js.map +1 -1
- package/dist/views/Version/VersionPillLabel/index.css +31 -0
- package/dist/views/Version/fetchVersions.d.ts.map +1 -1
- package/dist/views/Versions/buildColumns.d.ts.map +1 -1
- package/dist/views/Versions/buildColumns.js +18 -18
- package/dist/views/Versions/buildColumns.js.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.css +7 -0
- package/dist/views/Versions/cells/AutosaveCell/index.d.ts +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.d.ts.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
- package/dist/views/Versions/index.client.d.ts.map +1 -1
- package/dist/views/Versions/index.client.js +7 -23
- package/dist/views/Versions/index.client.js.map +1 -1
- package/dist/views/Versions/index.css +85 -0
- package/dist/views/Versions/index.d.ts +1 -1
- package/dist/views/Versions/index.d.ts.map +1 -1
- package/dist/views/Versions/index.js +1 -1
- package/dist/views/Versions/index.js.map +1 -1
- package/dist/withPayload/withPayload.d.ts.map +1 -1
- package/dist/withPayload/withPayload.js +9 -23
- package/dist/withPayload/withPayload.js.map +1 -1
- package/dist/withPayload/withPayload.utils.d.ts +0 -14
- package/dist/withPayload/withPayload.utils.d.ts.map +1 -1
- package/dist/withPayload/withPayload.utils.js +0 -73
- package/dist/withPayload/withPayload.utils.js.map +1 -1
- package/package.json +12 -27
- package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.d.ts +0 -5
- package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.d.ts.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.js +0 -19
- package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.js.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.d.ts +0 -12
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.d.ts.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +0 -81
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts +0 -16
- package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js +0 -66
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/index.d.ts +0 -10
- package/dist/elements/DocumentHeader/Tabs/index.d.ts.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/index.js +0 -78
- package/dist/elements/DocumentHeader/Tabs/index.js.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.d.ts +0 -4
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.d.ts.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +0 -29
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts +0 -11
- package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts.map +0 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js +0 -72
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +0 -1
- package/dist/elements/DocumentHeader/index.d.ts +0 -15
- package/dist/elements/DocumentHeader/index.d.ts.map +0 -1
- package/dist/elements/DocumentHeader/index.js +0 -36
- package/dist/elements/DocumentHeader/index.js.map +0 -1
- package/dist/elements/FormHeader/index.d.ts +0 -9
- package/dist/elements/FormHeader/index.d.ts.map +0 -1
- package/dist/elements/FormHeader/index.js +0 -20
- package/dist/elements/FormHeader/index.js.map +0 -1
- package/dist/elements/Logo/index.d.ts +0 -4
- package/dist/elements/Logo/index.d.ts.map +0 -1
- package/dist/elements/Logo/index.js +0 -39
- package/dist/elements/Logo/index.js.map +0 -1
- package/dist/elements/Nav/NavHamburger/index.d.ts +0 -8
- package/dist/elements/Nav/NavHamburger/index.d.ts.map +0 -1
- package/dist/elements/Nav/NavHamburger/index.js +0 -51
- package/dist/elements/Nav/NavHamburger/index.js.map +0 -1
- package/dist/elements/Nav/NavWrapper/index.d.ts +0 -10
- package/dist/elements/Nav/NavWrapper/index.d.ts.map +0 -1
- package/dist/elements/Nav/NavWrapper/index.js +0 -61
- package/dist/elements/Nav/NavWrapper/index.js.map +0 -1
- package/dist/elements/Nav/SettingsMenuButton/index.d.ts +0 -7
- package/dist/elements/Nav/SettingsMenuButton/index.d.ts.map +0 -1
- package/dist/elements/Nav/SettingsMenuButton/index.js +0 -45
- package/dist/elements/Nav/SettingsMenuButton/index.js.map +0 -1
- package/dist/elements/Nav/getNavPrefs.d.ts +0 -3
- package/dist/elements/Nav/getNavPrefs.d.ts.map +0 -1
- package/dist/elements/Nav/getNavPrefs.js +0 -27
- package/dist/elements/Nav/getNavPrefs.js.map +0 -1
- package/dist/elements/Nav/index.client.d.ts +0 -11
- package/dist/elements/Nav/index.client.d.ts.map +0 -1
- package/dist/elements/Nav/index.client.js +0 -133
- package/dist/elements/Nav/index.client.js.map +0 -1
- package/dist/elements/Nav/index.d.ts +0 -8
- package/dist/elements/Nav/index.d.ts.map +0 -1
- package/dist/elements/Nav/index.js +0 -183
- package/dist/elements/Nav/index.js.map +0 -1
- package/dist/exports/client.d.ts +0 -5
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js +0 -7
- package/dist/exports/client.js.map +0 -1
- package/dist/exports/rsc.d.ts +0 -5
- package/dist/exports/rsc.d.ts.map +0 -1
- package/dist/exports/rsc.js +0 -5
- package/dist/exports/rsc.js.map +0 -1
- package/dist/exports/templates.d.ts +0 -3
- package/dist/exports/templates.d.ts.map +0 -1
- package/dist/exports/templates.js +0 -3
- package/dist/exports/templates.js.map +0 -1
- package/dist/layouts/Root/NestProviders.d.ts +0 -12
- package/dist/layouts/Root/NestProviders.d.ts.map +0 -1
- package/dist/layouts/Root/NestProviders.js +0 -24
- package/dist/layouts/Root/NestProviders.js.map +0 -1
- package/dist/layouts/Root/checkDependencies.d.ts +0 -2
- package/dist/layouts/Root/checkDependencies.d.ts.map +0 -1
- package/dist/layouts/Root/checkDependencies.js +0 -49
- package/dist/layouts/Root/checkDependencies.js.map +0 -1
- package/dist/layouts/Root/index.d.ts +0 -17
- package/dist/layouts/Root/index.d.ts.map +0 -1
- package/dist/layouts/Root/index.js +0 -143
- package/dist/layouts/Root/index.js.map +0 -1
- package/dist/templates/Default/NavHamburger/index.d.ts +0 -3
- package/dist/templates/Default/NavHamburger/index.d.ts.map +0 -1
- package/dist/templates/Default/NavHamburger/index.js +0 -25
- package/dist/templates/Default/NavHamburger/index.js.map +0 -1
- package/dist/templates/Default/Wrapper/index.d.ts +0 -8
- package/dist/templates/Default/Wrapper/index.d.ts.map +0 -1
- package/dist/templates/Default/Wrapper/index.js +0 -49
- package/dist/templates/Default/Wrapper/index.js.map +0 -1
- package/dist/templates/Default/index.d.ts +0 -17
- package/dist/templates/Default/index.d.ts.map +0 -1
- package/dist/templates/Default/index.js +0 -129
- package/dist/templates/Default/index.js.map +0 -1
- package/dist/templates/Minimal/index.d.ts +0 -10
- package/dist/templates/Minimal/index.d.ts.map +0 -1
- package/dist/templates/Minimal/index.js +0 -21
- package/dist/templates/Minimal/index.js.map +0 -1
- package/dist/utilities/getPreferences.d.ts +0 -6
- package/dist/utilities/getPreferences.d.ts.map +0 -1
- package/dist/utilities/getPreferences.js +0 -26
- package/dist/utilities/getPreferences.js.map +0 -1
- package/dist/utilities/getRequestLocale.d.ts +0 -7
- package/dist/utilities/getRequestLocale.d.ts.map +0 -1
- package/dist/utilities/getRequestLocale.js +0 -20
- package/dist/utilities/getRequestLocale.js.map +0 -1
- package/dist/utilities/getRequestTheme.d.ts +0 -11
- package/dist/utilities/getRequestTheme.d.ts.map +0 -1
- package/dist/utilities/getRequestTheme.js +0 -22
- package/dist/utilities/getRequestTheme.js.map +0 -1
- package/dist/utilities/initReq.d.ts +0 -14
- package/dist/utilities/initReq.d.ts.map +0 -1
- package/dist/utilities/initReq.js +0 -110
- package/dist/utilities/initReq.js.map +0 -1
- package/dist/utilities/selectiveCache.d.ts +0 -12
- package/dist/utilities/selectiveCache.d.ts.map +0 -1
- package/dist/utilities/selectiveCache.js +0 -38
- package/dist/utilities/selectiveCache.js.map +0 -1
- package/dist/views/API/RenderJSON/index.d.ts +0 -12
- package/dist/views/API/RenderJSON/index.d.ts.map +0 -1
- package/dist/views/API/RenderJSON/index.js +0 -135
- package/dist/views/API/RenderJSON/index.js.map +0 -1
- package/dist/views/BrowseByFolder/buildView.d.ts +0 -13
- package/dist/views/BrowseByFolder/buildView.d.ts.map +0 -1
- package/dist/views/BrowseByFolder/buildView.js +0 -170
- package/dist/views/BrowseByFolder/buildView.js.map +0 -1
- package/dist/views/BrowseByFolder/index.d.ts +0 -4
- package/dist/views/BrowseByFolder/index.d.ts.map +0 -1
- package/dist/views/BrowseByFolder/index.js +0 -20
- package/dist/views/BrowseByFolder/index.js.map +0 -1
- package/dist/views/BrowseByFolder/metadata.d.ts +0 -4
- package/dist/views/BrowseByFolder/metadata.d.ts.map +0 -1
- package/dist/views/BrowseByFolder/metadata.js +0 -18
- package/dist/views/BrowseByFolder/metadata.js.map +0 -1
- package/dist/views/CollectionFolders/buildView.d.ts +0 -15
- package/dist/views/CollectionFolders/buildView.d.ts.map +0 -1
- package/dist/views/CollectionFolders/buildView.js +0 -156
- package/dist/views/CollectionFolders/buildView.js.map +0 -1
- package/dist/views/CollectionFolders/index.d.ts +0 -4
- package/dist/views/CollectionFolders/index.d.ts.map +0 -1
- package/dist/views/CollectionFolders/index.js +0 -20
- package/dist/views/CollectionFolders/index.js.map +0 -1
- package/dist/views/CollectionFolders/metadata.d.ts +0 -7
- package/dist/views/CollectionFolders/metadata.d.ts.map +0 -1
- package/dist/views/CollectionFolders/metadata.js +0 -25
- package/dist/views/CollectionFolders/metadata.js.map +0 -1
- package/dist/views/CollectionFolders/renderFolderViewSlots.d.ts +0 -11
- package/dist/views/CollectionFolders/renderFolderViewSlots.d.ts.map +0 -1
- package/dist/views/CollectionFolders/renderFolderViewSlots.js +0 -64
- package/dist/views/CollectionFolders/renderFolderViewSlots.js.map +0 -1
- package/dist/withPayload/withPayloadLegacy.d.ts +0 -2
- package/dist/withPayload/withPayloadLegacy.d.ts.map +0 -1
- package/dist/withPayload/withPayloadLegacy.js +0 -47
- package/dist/withPayload/withPayloadLegacy.js.map +0 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
2
|
+
import { getAncestors } from 'payload';
|
|
3
|
+
import { combineWhereConstraints, DEFAULT_HIERARCHY_LIST_LIMIT } from 'payload/shared';
|
|
4
|
+
/**
|
|
5
|
+
* Fetches hierarchy data for a collection with a selected parent.
|
|
6
|
+
* Returns data that can be rendered client-side by HierarchyTable.
|
|
7
|
+
*/
|
|
8
|
+
export const handleHierarchy = async ({
|
|
9
|
+
baseFilter,
|
|
10
|
+
collectionConfig,
|
|
11
|
+
collectionSlug,
|
|
12
|
+
parentId,
|
|
13
|
+
permissions,
|
|
14
|
+
req,
|
|
15
|
+
search,
|
|
16
|
+
typeFilter,
|
|
17
|
+
user
|
|
18
|
+
}) => {
|
|
19
|
+
const hierarchyConfig = collectionConfig.hierarchy && typeof collectionConfig.hierarchy === 'object' ? collectionConfig.hierarchy : undefined;
|
|
20
|
+
if (!hierarchyConfig) {
|
|
21
|
+
throw new Error('Collection is not a hierarchy');
|
|
22
|
+
}
|
|
23
|
+
const parentFieldName = hierarchyConfig.parentFieldName;
|
|
24
|
+
const useAsTitle = collectionConfig.admin?.useAsTitle || 'id';
|
|
25
|
+
// Fetch the parent item and breadcrumbs (skip for root level)
|
|
26
|
+
let parent = null;
|
|
27
|
+
let breadcrumbs = [];
|
|
28
|
+
if (parentId !== null) {
|
|
29
|
+
try {
|
|
30
|
+
const [item, ancestors] = await Promise.all([req.payload.findByID({
|
|
31
|
+
id: parentId,
|
|
32
|
+
collection: collectionSlug,
|
|
33
|
+
depth: 0,
|
|
34
|
+
overrideAccess: false,
|
|
35
|
+
req,
|
|
36
|
+
user
|
|
37
|
+
}), getAncestors({
|
|
38
|
+
id: parentId,
|
|
39
|
+
collectionSlug,
|
|
40
|
+
req
|
|
41
|
+
})]);
|
|
42
|
+
parent = item;
|
|
43
|
+
breadcrumbs = ancestors;
|
|
44
|
+
} catch (_error) {
|
|
45
|
+
req.payload.logger.warn({
|
|
46
|
+
msg: `Hierarchy item not found: ${parentId}`
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Build children where clause
|
|
51
|
+
// For root level (parentId is null), find items without a parent
|
|
52
|
+
// For nested level, find items with this specific parent
|
|
53
|
+
const parentCondition = parentId === null ? {
|
|
54
|
+
or: [{
|
|
55
|
+
[parentFieldName]: {
|
|
56
|
+
exists: false
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
[parentFieldName]: {
|
|
60
|
+
equals: null
|
|
61
|
+
}
|
|
62
|
+
}]
|
|
63
|
+
} : {
|
|
64
|
+
[parentFieldName]: {
|
|
65
|
+
equals: parentId
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// Build type filter condition if typeFilter is provided and collectionSpecific is configured
|
|
69
|
+
// Filter to folders that allow ANY of the selected types OR are unrestricted
|
|
70
|
+
let typeCondition;
|
|
71
|
+
if (typeFilter && typeFilter.length > 0 && hierarchyConfig.collectionSpecific && typeof hierarchyConfig.collectionSpecific === 'object') {
|
|
72
|
+
const typeFieldName = hierarchyConfig.collectionSpecific.fieldName;
|
|
73
|
+
// Exclude the hierarchy collection itself from the filter (folders always show folders)
|
|
74
|
+
const filteredTypes = typeFilter.filter(t => t !== collectionSlug);
|
|
75
|
+
if (filteredTypes.length > 0) {
|
|
76
|
+
typeCondition = {
|
|
77
|
+
or: [{
|
|
78
|
+
[typeFieldName]: {
|
|
79
|
+
in: filteredTypes
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
[typeFieldName]: {
|
|
83
|
+
exists: false
|
|
84
|
+
}
|
|
85
|
+
}]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Combine conditions: parent + search + typeFilter
|
|
90
|
+
const conditions = [parentCondition];
|
|
91
|
+
if (search) {
|
|
92
|
+
conditions.push({
|
|
93
|
+
[useAsTitle]: {
|
|
94
|
+
like: search
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (typeCondition) {
|
|
99
|
+
conditions.push(typeCondition);
|
|
100
|
+
}
|
|
101
|
+
const childrenWhere = conditions.length > 1 ? {
|
|
102
|
+
and: conditions
|
|
103
|
+
} : parentCondition;
|
|
104
|
+
// Fetch children (hierarchy items with this parent, or root items if parentId is null)
|
|
105
|
+
const childrenData = await req.payload.find({
|
|
106
|
+
collection: collectionSlug,
|
|
107
|
+
depth: 0,
|
|
108
|
+
draft: true,
|
|
109
|
+
fallbackLocale: false,
|
|
110
|
+
includeLockStatus: true,
|
|
111
|
+
limit: DEFAULT_HIERARCHY_LIST_LIMIT,
|
|
112
|
+
locale: req.locale,
|
|
113
|
+
overrideAccess: false,
|
|
114
|
+
page: 1,
|
|
115
|
+
req,
|
|
116
|
+
user,
|
|
117
|
+
where: combineWhereConstraints([childrenWhere, baseFilter])
|
|
118
|
+
});
|
|
119
|
+
// Fetch related documents from other collections
|
|
120
|
+
// At root level: show unassigned documents (where hierarchy field doesn't exist)
|
|
121
|
+
// At nested level: show documents assigned to the selected hierarchy item
|
|
122
|
+
const relatedDocumentsByCollection = {};
|
|
123
|
+
const relatedBaseFilters = {};
|
|
124
|
+
// Use pre-computed relatedCollections from sanitized hierarchy config
|
|
125
|
+
const relatedCollectionsConfig = hierarchyConfig.relatedCollections || {};
|
|
126
|
+
for (const [relatedSlug, fieldInfo] of Object.entries(relatedCollectionsConfig)) {
|
|
127
|
+
if (relatedSlug === collectionSlug) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const relatedCollectionConfig = req.payload.collections[relatedSlug]?.config;
|
|
131
|
+
if (!relatedCollectionConfig) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
// Check if user has read permission for this collection
|
|
135
|
+
if (!permissions?.collections?.[relatedSlug]?.read) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const {
|
|
139
|
+
fieldName,
|
|
140
|
+
hasMany
|
|
141
|
+
} = fieldInfo;
|
|
142
|
+
// Get baseFilter for this related collection
|
|
143
|
+
const relatedBaseFilter = await (relatedCollectionConfig.admin?.baseFilter ?? relatedCollectionConfig.admin?.baseListFilter)?.({
|
|
144
|
+
limit: DEFAULT_HIERARCHY_LIST_LIMIT,
|
|
145
|
+
page: 1,
|
|
146
|
+
req,
|
|
147
|
+
sort: undefined
|
|
148
|
+
});
|
|
149
|
+
if (relatedBaseFilter) {
|
|
150
|
+
relatedBaseFilters[relatedSlug] = relatedBaseFilter;
|
|
151
|
+
}
|
|
152
|
+
// Build where clause based on whether we're at root or nested level
|
|
153
|
+
let relationshipWhere;
|
|
154
|
+
if (parentId === null) {
|
|
155
|
+
// Root level: find documents where hierarchy field doesn't exist, is null, or is empty array
|
|
156
|
+
const conditions = [{
|
|
157
|
+
[fieldName]: {
|
|
158
|
+
exists: false
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
[fieldName]: {
|
|
162
|
+
equals: null
|
|
163
|
+
}
|
|
164
|
+
}];
|
|
165
|
+
if (hasMany) {
|
|
166
|
+
// hasMany fields store cleared values as empty arrays
|
|
167
|
+
conditions.push({
|
|
168
|
+
[fieldName]: {
|
|
169
|
+
equals: []
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
relationshipWhere = {
|
|
174
|
+
or: conditions
|
|
175
|
+
};
|
|
176
|
+
} else {
|
|
177
|
+
// Nested level: find documents assigned to this hierarchy item
|
|
178
|
+
// "in" operator works for both hasMany and single relationship fields
|
|
179
|
+
relationshipWhere = {
|
|
180
|
+
[fieldName]: {
|
|
181
|
+
in: [parentId]
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
// Add search filter if provided
|
|
186
|
+
const relatedUseAsTitle = relatedCollectionConfig.admin?.useAsTitle || 'id';
|
|
187
|
+
const whereWithSearch = search ? {
|
|
188
|
+
and: [relationshipWhere, {
|
|
189
|
+
[relatedUseAsTitle]: {
|
|
190
|
+
like: search
|
|
191
|
+
}
|
|
192
|
+
}]
|
|
193
|
+
} : relationshipWhere;
|
|
194
|
+
// Combine relationship where with related collection's baseFilter
|
|
195
|
+
const where = combineWhereConstraints([whereWithSearch, relatedBaseFilter]);
|
|
196
|
+
try {
|
|
197
|
+
const data = await req.payload.find({
|
|
198
|
+
collection: relatedSlug,
|
|
199
|
+
depth: 0,
|
|
200
|
+
draft: true,
|
|
201
|
+
fallbackLocale: false,
|
|
202
|
+
includeLockStatus: true,
|
|
203
|
+
limit: DEFAULT_HIERARCHY_LIST_LIMIT,
|
|
204
|
+
locale: req.locale,
|
|
205
|
+
overrideAccess: false,
|
|
206
|
+
page: 1,
|
|
207
|
+
req,
|
|
208
|
+
user,
|
|
209
|
+
where
|
|
210
|
+
});
|
|
211
|
+
if (data.totalDocs > 0) {
|
|
212
|
+
relatedDocumentsByCollection[relatedSlug] = {
|
|
213
|
+
fieldName,
|
|
214
|
+
hasMany,
|
|
215
|
+
label: getTranslation(relatedCollectionConfig.labels?.plural, req.i18n),
|
|
216
|
+
result: data
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
} catch (error) {
|
|
220
|
+
req.payload.logger.warn({
|
|
221
|
+
err: error,
|
|
222
|
+
msg: `Failed to query related collection ${relatedSlug}`
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Extract allowed collections from parent's collectionSpecific field
|
|
227
|
+
// - undefined: collectionSpecific not configured, no filtering needed
|
|
228
|
+
// - []: parent folder accepts everything, can only move to unrestricted destinations
|
|
229
|
+
// - [{ slug, label }, ...]: parent folder has restrictions
|
|
230
|
+
let allowedCollections;
|
|
231
|
+
if (hierarchyConfig.collectionSpecific && parent) {
|
|
232
|
+
const typeFieldName = hierarchyConfig.collectionSpecific.fieldName;
|
|
233
|
+
const typeValues = parent[typeFieldName];
|
|
234
|
+
if (typeValues && typeValues.length > 0) {
|
|
235
|
+
allowedCollections = typeValues.map(slug => {
|
|
236
|
+
const config = req.payload.collections[slug]?.config;
|
|
237
|
+
const label = config ? getTranslation(config.labels?.plural, req.i18n) : slug;
|
|
238
|
+
return {
|
|
239
|
+
slug,
|
|
240
|
+
label
|
|
241
|
+
};
|
|
242
|
+
});
|
|
243
|
+
} else {
|
|
244
|
+
// Parent folder accepts everything (type is null or empty)
|
|
245
|
+
allowedCollections = [];
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
allowedCollections,
|
|
250
|
+
breadcrumbs,
|
|
251
|
+
childrenData,
|
|
252
|
+
parent,
|
|
253
|
+
parentFieldName,
|
|
254
|
+
parentId,
|
|
255
|
+
relatedBaseFilters: Object.keys(relatedBaseFilters).length > 0 ? relatedBaseFilters : undefined,
|
|
256
|
+
relatedDocumentsByCollection
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
//# sourceMappingURL=handleHierarchy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleHierarchy.js","names":["getTranslation","getAncestors","combineWhereConstraints","DEFAULT_HIERARCHY_LIST_LIMIT","handleHierarchy","baseFilter","collectionConfig","collectionSlug","parentId","permissions","req","search","typeFilter","user","hierarchyConfig","hierarchy","undefined","Error","parentFieldName","useAsTitle","admin","parent","breadcrumbs","item","ancestors","Promise","all","payload","findByID","id","collection","depth","overrideAccess","_error","logger","warn","msg","parentCondition","or","exists","equals","typeCondition","length","collectionSpecific","typeFieldName","fieldName","filteredTypes","filter","t","in","conditions","push","like","childrenWhere","and","childrenData","find","draft","fallbackLocale","includeLockStatus","limit","locale","page","where","relatedDocumentsByCollection","relatedBaseFilters","relatedCollectionsConfig","relatedCollections","relatedSlug","fieldInfo","Object","entries","relatedCollectionConfig","collections","config","read","hasMany","relatedBaseFilter","baseListFilter","sort","relationshipWhere","relatedUseAsTitle","whereWithSearch","data","totalDocs","label","labels","plural","i18n","result","error","err","allowedCollections","typeValues","map","slug","keys"],"sources":["../../../src/views/List/handleHierarchy.ts"],"sourcesContent":["import type {\n HierarchyViewData,\n PayloadRequest,\n RelatedDocumentsGrouped,\n SanitizedCollectionConfig,\n SanitizedPermissions,\n TypeWithID,\n Where,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getAncestors } from 'payload'\nimport { combineWhereConstraints, DEFAULT_HIERARCHY_LIST_LIMIT } from 'payload/shared'\n\n/**\n * Fetches hierarchy data for a collection with a selected parent.\n * Returns data that can be rendered client-side by HierarchyTable.\n */\nexport const handleHierarchy = async ({\n baseFilter,\n collectionConfig,\n collectionSlug,\n parentId,\n permissions,\n req,\n search,\n typeFilter,\n user,\n}: {\n baseFilter?: null | Where\n collectionConfig: SanitizedCollectionConfig\n collectionSlug: string\n parentId: null | number | string\n permissions?: SanitizedPermissions\n req: PayloadRequest\n search?: string\n /** Filter hierarchy items by their collectionSpecific type field */\n typeFilter?: string[]\n user: PayloadRequest['user']\n}): Promise<HierarchyViewData> => {\n const hierarchyConfig =\n collectionConfig.hierarchy && typeof collectionConfig.hierarchy === 'object'\n ? collectionConfig.hierarchy\n : undefined\n\n if (!hierarchyConfig) {\n throw new Error('Collection is not a hierarchy')\n }\n\n const parentFieldName = hierarchyConfig.parentFieldName\n\n const useAsTitle = collectionConfig.admin?.useAsTitle || 'id'\n\n // Fetch the parent item and breadcrumbs (skip for root level)\n let parent: null | (Record<string, unknown> & TypeWithID) = null\n let breadcrumbs: Array<{ id: number | string; title: string }> = []\n\n if (parentId !== null) {\n try {\n const [item, ancestors] = await Promise.all([\n req.payload.findByID({\n id: parentId,\n collection: collectionSlug,\n depth: 0,\n overrideAccess: false,\n req,\n user,\n }),\n getAncestors({\n id: parentId,\n collectionSlug,\n req,\n }),\n ])\n\n parent = item\n breadcrumbs = ancestors\n } catch (_error) {\n req.payload.logger.warn({\n msg: `Hierarchy item not found: ${parentId}`,\n })\n }\n }\n\n // Build children where clause\n // For root level (parentId is null), find items without a parent\n // For nested level, find items with this specific parent\n const parentCondition =\n parentId === null\n ? {\n or: [{ [parentFieldName]: { exists: false } }, { [parentFieldName]: { equals: null } }],\n }\n : { [parentFieldName]: { equals: parentId } }\n\n // Build type filter condition if typeFilter is provided and collectionSpecific is configured\n // Filter to folders that allow ANY of the selected types OR are unrestricted\n let typeCondition: Record<string, unknown> | undefined\n\n if (\n typeFilter &&\n typeFilter.length > 0 &&\n hierarchyConfig.collectionSpecific &&\n typeof hierarchyConfig.collectionSpecific === 'object'\n ) {\n const typeFieldName = hierarchyConfig.collectionSpecific.fieldName\n // Exclude the hierarchy collection itself from the filter (folders always show folders)\n const filteredTypes = typeFilter.filter((t) => t !== collectionSlug)\n\n if (filteredTypes.length > 0) {\n typeCondition = {\n or: [\n { [typeFieldName]: { in: filteredTypes } },\n { [typeFieldName]: { exists: false } }, // Include unrestricted folders\n ],\n }\n }\n }\n\n // Combine conditions: parent + search + typeFilter\n const conditions: Record<string, unknown>[] = [parentCondition]\n\n if (search) {\n conditions.push({ [useAsTitle]: { like: search } })\n }\n\n if (typeCondition) {\n conditions.push(typeCondition)\n }\n\n const childrenWhere = conditions.length > 1 ? { and: conditions } : parentCondition\n\n // Fetch children (hierarchy items with this parent, or root items if parentId is null)\n const childrenData = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: DEFAULT_HIERARCHY_LIST_LIMIT,\n locale: req.locale,\n overrideAccess: false,\n page: 1,\n req,\n user,\n where: combineWhereConstraints([childrenWhere, baseFilter]),\n })\n\n // Fetch related documents from other collections\n // At root level: show unassigned documents (where hierarchy field doesn't exist)\n // At nested level: show documents assigned to the selected hierarchy item\n const relatedDocumentsByCollection: RelatedDocumentsGrouped = {}\n const relatedBaseFilters: Record<string, Where> = {}\n\n // Use pre-computed relatedCollections from sanitized hierarchy config\n const relatedCollectionsConfig = hierarchyConfig.relatedCollections || {}\n\n for (const [relatedSlug, fieldInfo] of Object.entries(relatedCollectionsConfig)) {\n if (relatedSlug === collectionSlug) {\n continue\n }\n\n const relatedCollectionConfig = req.payload.collections[relatedSlug]?.config\n if (!relatedCollectionConfig) {\n continue\n }\n\n // Check if user has read permission for this collection\n if (!permissions?.collections?.[relatedSlug]?.read) {\n continue\n }\n\n const { fieldName, hasMany } = fieldInfo\n\n // Get baseFilter for this related collection\n const relatedBaseFilter = await (\n relatedCollectionConfig.admin?.baseFilter ?? relatedCollectionConfig.admin?.baseListFilter\n )?.({\n limit: DEFAULT_HIERARCHY_LIST_LIMIT,\n page: 1,\n req,\n sort: undefined,\n })\n\n if (relatedBaseFilter) {\n relatedBaseFilters[relatedSlug] = relatedBaseFilter\n }\n\n // Build where clause based on whether we're at root or nested level\n let relationshipWhere: Record<string, unknown>\n\n if (parentId === null) {\n // Root level: find documents where hierarchy field doesn't exist, is null, or is empty array\n const conditions: Record<string, unknown>[] = [\n { [fieldName]: { exists: false } },\n { [fieldName]: { equals: null } },\n ]\n if (hasMany) {\n // hasMany fields store cleared values as empty arrays\n conditions.push({ [fieldName]: { equals: [] } })\n }\n relationshipWhere = { or: conditions }\n } else {\n // Nested level: find documents assigned to this hierarchy item\n // \"in\" operator works for both hasMany and single relationship fields\n relationshipWhere = {\n [fieldName]: { in: [parentId] },\n }\n }\n\n // Add search filter if provided\n const relatedUseAsTitle = relatedCollectionConfig.admin?.useAsTitle || 'id'\n const whereWithSearch = search\n ? { and: [relationshipWhere, { [relatedUseAsTitle]: { like: search } }] }\n : relationshipWhere\n\n // Combine relationship where with related collection's baseFilter\n const where = combineWhereConstraints([whereWithSearch, relatedBaseFilter])\n\n try {\n const data = await req.payload.find({\n collection: relatedSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: DEFAULT_HIERARCHY_LIST_LIMIT,\n locale: req.locale,\n overrideAccess: false,\n page: 1,\n req,\n user,\n where,\n })\n\n if (data.totalDocs > 0) {\n relatedDocumentsByCollection[relatedSlug] = {\n fieldName,\n hasMany,\n label: getTranslation(relatedCollectionConfig.labels?.plural, req.i18n),\n result: data,\n }\n }\n } catch (error) {\n req.payload.logger.warn({\n err: error,\n msg: `Failed to query related collection ${relatedSlug}`,\n })\n }\n }\n\n // Extract allowed collections from parent's collectionSpecific field\n // - undefined: collectionSpecific not configured, no filtering needed\n // - []: parent folder accepts everything, can only move to unrestricted destinations\n // - [{ slug, label }, ...]: parent folder has restrictions\n let allowedCollections: Array<{ label: string; slug: string }> | undefined\n\n if (hierarchyConfig.collectionSpecific && parent) {\n const typeFieldName = hierarchyConfig.collectionSpecific.fieldName\n const typeValues = parent[typeFieldName] as null | string[] | undefined\n\n if (typeValues && typeValues.length > 0) {\n allowedCollections = typeValues.map((slug) => {\n const config = req.payload.collections[slug]?.config\n const label = config ? getTranslation(config.labels?.plural, req.i18n) : slug\n return { slug, label }\n })\n } else {\n // Parent folder accepts everything (type is null or empty)\n allowedCollections = []\n }\n }\n\n return {\n allowedCollections,\n breadcrumbs,\n childrenData,\n parent,\n parentFieldName,\n parentId,\n relatedBaseFilters: Object.keys(relatedBaseFilters).length > 0 ? relatedBaseFilters : undefined,\n relatedDocumentsByCollection,\n }\n}\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,uBAAuB,EAAEC,4BAA4B,QAAQ;AAEtE;;;;AAIA,OAAO,MAAMC,eAAA,GAAkB,MAAAA,CAAO;EACpCC,UAAU;EACVC,gBAAgB;EAChBC,cAAc;EACdC,QAAQ;EACRC,WAAW;EACXC,GAAG;EACHC,MAAM;EACNC,UAAU;EACVC;AAAI,CAYL;EACC,MAAMC,eAAA,GACJR,gBAAA,CAAiBS,SAAS,IAAI,OAAOT,gBAAA,CAAiBS,SAAS,KAAK,WAChET,gBAAA,CAAiBS,SAAS,GAC1BC,SAAA;EAEN,IAAI,CAACF,eAAA,EAAiB;IACpB,MA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AAI9E,eAAA,CAAgB6B,kBAAkB,IAAItB,MAAA,EAAQ;IAChD,MAAMuB,aAAA,GAAgB9B,eAAA,CAAgB6B,kBAAkB,CAACE,SAAS;IAClE,MAAMgD,UAAA,GAAaxE,MAAM,CAACuB,aAAA,CAAc;IAExC,IAAIiD,UAAA,IAAcA,UAAA,CAAWnD,MAAM,GAAG,GAAG;MACvCkD,kBAAA,GAAqBC,UAAA,CAAWC,GAAG,CAAEC,IAAA;QACnC,MAAMrB,MAAA,GAAShE,GAAA,CAAIiB,OAAO,CAAC8C,WAAW,CAACsB,IAAA,CAAK,EAAErB,MAAA;QAC9C,MAAMW,KAAA,GAAQX,MAAA,GAAS1E,cAAA,CAAe0E,MAAA,CAAOY,MAAM,EAAEC,MAAA,EAAQ7E,GAAA,CAAI8E,IAAI,IAAIO,IAAA;QACzE,OAAO;UAAEA,IAAA;UAAMV;QAAM;MACvB;IACF,OAAO;MACL;MACAO,kBAAA,GAAqB,EAAE;IACzB;EACF;EAEA,OAAO;IACLA,kBAAA;IACAtE,WAAA;IACAiC,YAAA;IACAlC,MAAA;IACAH,eAAA;IACAV,QAAA;IACAyD,kBAAA,EAAoBK,MAAA,CAAO0B,IAAI,CAAC/B,kBAAA,EAAoBvB,MAAM,GAAG,IAAIuB,kBAAA,GAAqBjD,SAAA;IACtFgD;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAC1F,OAAO,KAAK,EAAyB,cAAc,EAAmB,MAAM,SAAS,CAAA;AAQrF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,sBAAsB,EACtB,OAAO,CAAC,4BAA4B,CAAC,
|
|
1
|
+
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAC1F,OAAO,KAAK,EAAyB,cAAc,EAAmB,MAAM,SAAS,CAAA;AAQrF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,sBAAsB,EACtB,OAAO,CAAC,4BAA4B,CAAC,CAsHtC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","canAccessAdmin","isEntityHidden","UnauthorizedError","applyLocaleFiltering","renderListView","renderListHandler","args","collectionSlug","cookies","disableActions","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","locale","overrideEntityVisibility","permissions","query","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","clientConfig","importMap","preferencesKey","preferences","find","collection","depth","limit","where","and","key","equals","id","then","res","docs","value","visibleEntities","collections","map","slug","admin","hidden","filter","Boolean","globals","List","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams","viewType"],"sources":["../../../src/views/List/handleServerFunction.tsx"],"sourcesContent":["import type { RenderListServerFnArgs, RenderListServerFnReturnType } from '@payloadcms/ui'\nimport type { CollectionPreferences, ServerFunction, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { canAccessAdmin, isEntityHidden, UnauthorizedError } from 'payload'\nimport { applyLocaleFiltering } from 'payload/shared'\n\nimport { renderListView } from './index.js'\n\nexport const renderListHandler: ServerFunction<\n RenderListServerFnArgs,\n Promise<RenderListServerFnReturnType>\n> = async (args) => {\n const {\n collectionSlug,\n cookies,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n locale,\n overrideEntityVisibility,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = args\n\n if (!req.user) {\n throw new UnauthorizedError()\n }\n\n await canAccessAdmin({ req })\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const preferencesKey = `collection-${collectionSlug}`\n\n const preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as CollectionPreferences)\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const { List } = await renderListView({\n clientConfig,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n i18n,\n importMap: payload.importMap,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n locale,\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n locale,\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug],\n },\n payload,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n viewType: 'list',\n })\n\n return {\n List,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ;AAClE,SAASC,oBAAoB,QAAQ;AAErC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,iBAAA,GA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MAAEC,KAAA,EAAO;QAAEC;MAAM;IAAE,CAAE,KAAM,CAAC/C,cAAA,CAAe;MAAE+C,MAAA;MAAQvB;IAAK,KAAKqB,IAAA,GAAO,MACjFG,MAAM,CAACC,OAAA;IACVC,OAAA,EAAS5B,OAAA,CAAQC,MAAM,CAAC2B,OAAO,CAC5BN,GAAG,CAAC,CAAC;MAAEC,IAAI;MAAEC,KAAA,EAAO;QAAEC;MAAM;IAAE,CAAE,KAAM,CAAC/C,cAAA,CAAe;MAAE+C,MAAA;MAAQvB;IAAK,KAAKqB,IAAA,GAAO,MACjFG,MAAM,CAACC,OAAA;EACZ;EAEA,MAAM;IAAEE;EAAI,CAAE,GAAG,MAAMhD,cAAA,CAAe;IACpCsB,YAAA;IACAjB,cAAA;IACAC,iBAAA;IACAC,eAAA;IACAC,mBAAA;IACAC,UAAA;IACAC,mBAAA;IACAQ,IAAA;IACAK,SAAA,EAAWJ,OAAA,CAAQI,SAAS;IAC5B0B,cAAA,EAAgB;MACdC,gBAAA,EAAkB/B,OAAA,EAASqB,WAAA,GAAcrC,cAAA,CAAe,EAAEiB,MAAA;MAC1DhB,OAAA;MACA+C,YAAA,EAAchC,OAAA,CAAQC,MAAM,CAAC2B,OAAO,CAACrB,IAAI,CAAE0B,MAAA,IAAWA,MAAA,CAAOV,IAAI,KAAKvC,cAAA;MACtEkD,eAAA,EAAiBC,SAAA;MACjB3C,MAAA;MACAE,WAAA;MACAI,GAAA;MACAsC,YAAA,EAAcD,SAAA;MACdf;IACF;IACA5B,MAAA;IACAC,wBAAA;IACA4C,MAAA,EAAQ;MACNC,QAAA,EAAU,CAAC,eAAetD,cAAA;IAC5B;IACAgB,OAAA;IACAN,WAAA;IACAC,KAAA;IACAC,mBAAA;IACAC,sBAAA;IACA0C,YAAA,EAAc,CAAC;IACfC,QAAA,EAAU;EACZ;EAEA,OAAO;
|
|
1
|
+
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","canAccessAdmin","isEntityHidden","UnauthorizedError","applyLocaleFiltering","renderListView","renderListHandler","args","collectionSlug","cookies","disableActions","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","locale","overrideEntityVisibility","permissions","query","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","clientConfig","importMap","preferencesKey","preferences","find","collection","depth","limit","where","and","key","equals","id","then","res","docs","value","visibleEntities","collections","map","slug","admin","hidden","filter","Boolean","globals","List","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams","server","viewType"],"sources":["../../../src/views/List/handleServerFunction.tsx"],"sourcesContent":["import type { RenderListServerFnArgs, RenderListServerFnReturnType } from '@payloadcms/ui'\nimport type { CollectionPreferences, ServerFunction, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { canAccessAdmin, isEntityHidden, UnauthorizedError } from 'payload'\nimport { applyLocaleFiltering } from 'payload/shared'\n\nimport { renderListView } from './index.js'\n\nexport const renderListHandler: ServerFunction<\n RenderListServerFnArgs,\n Promise<RenderListServerFnReturnType>\n> = async (args) => {\n const {\n collectionSlug,\n cookies,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n locale,\n overrideEntityVisibility,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = args\n\n if (!req.user) {\n throw new UnauthorizedError()\n }\n\n await canAccessAdmin({ req })\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const preferencesKey = `collection-${collectionSlug}`\n\n const preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as CollectionPreferences)\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const { List } = await renderListView({\n clientConfig,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n i18n,\n importMap: payload.importMap,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n locale,\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n locale,\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug],\n },\n payload,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n server: req.server,\n viewType: 'list',\n })\n\n return {\n List,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ;AAClE,SAASC,oBAAoB,QAAQ;AAErC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,iBAAA,GAGT,MAAOC,IAAA;EACT,MAAM;IACJC,cAAc;IACdC,OAAO;IACPC,cAAc;IACdC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,UAAU;IACVC,mBAAmB;IACnBC,MAAM;IACNC,wBAAwB;IACxBC,WAAW;IACXC,KAAK;IACLC,mBAAmB;IACnBC,sBAAsB;IACtBC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGnB,IAAA;EAEJ,IAAI,CAACe,GA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AAM,CAACC,OAAA;EACZ;EAEA,MAAM;IAAEE;EAAI,CAAE,GAAG,MAAMhD,cAAA,CAAe;IACpCsB,YAAA;IACAjB,cAAA;IACAC,iBAAA;IACAC,eAAA;IACAC,mBAAA;IACAC,UAAA;IACAC,mBAAA;IACAQ,IAAA;IACAK,SAAA,EAAWJ,OAAA,CAAQI,SAAS;IAC5B0B,cAAA,EAAgB;MACdC,gBAAA,EAAkB/B,OAAA,EAASqB,WAAA,GAAcrC,cAAA,CAAe,EAAEiB,MAAA;MAC1DhB,OAAA;MACA+C,YAAA,EAAchC,OAAA,CAAQC,MAAM,CAAC2B,OAAO,CAACrB,IAAI,CAAE0B,MAAA,IAAWA,MAAA,CAAOV,IAAI,KAAKvC,cAAA;MACtEkD,eAAA,EAAiBC,SAAA;MACjB3C,MAAA;MACAE,WAAA;MACAI,GAAA;MACAsC,YAAA,EAAcD,SAAA;MACdf;IACF;IACA5B,MAAA;IACAC,wBAAA;IACA4C,MAAA,EAAQ;MACNC,QAAA,EAAU,CAAC,eAAetD,cAAA;IAC5B;IACAgB,OAAA;IACAN,WAAA;IACAC,KAAA;IACAC,mBAAA;IACAC,sBAAA;IACA0C,YAAA,EAAc,CAAC;IACfC,MAAA,EAAQ1C,GAAA,CAAI0C,MAAM;IAClBC,QAAA,EAAU;EACZ;EAEA,OAAO;IACLZ,IAAA;IACAvB;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAKpB,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EAEvB,gBAAgB,EAGjB,MAAM,SAAS,CAAA;AAsBhB,OAAO,KAAmB,MAAM,OAAO,CAAA;AASvC,OAAO,aAAa,CAAA;AAEpB;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,iBAAiB,CAAC,EACd,gBAAgB,GAChB,KAAK,CAAC,aAAa,CAAC,mBAAmB,GAAG,CAAC,mBAAmB,GAAG,uBAAuB,CAAC,CAAC,CAAA;IAC9F,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,GAAG,oBAAoB,CAAA;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,kBAAkB,KACvB,OAAO,CAAC;IACT,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CACtB,CA4eA,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAYjD,CAAA"}
|
package/dist/views/List/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui';
|
|
2
|
+
import { DefaultListView, HierarchyListView, HydrateAuthProvider, HydrateHierarchyProvider, ListQueryProvider } from '@payloadcms/ui';
|
|
3
3
|
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
4
4
|
import { getColumns, renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc';
|
|
5
5
|
import { notFound } from 'next/navigation.js';
|
|
6
|
-
import { appendUploadSelectFields, combineWhereConstraints, formatAdminURL, isNumber, mergeListSearchAndWhere, transformColumnsToPreferences, transformColumnsToSearchParams } from 'payload/shared';
|
|
6
|
+
import { appendDateTimezoneSelectFields, appendUploadSelectFields, combineWhereConstraints, formatAdminURL, isNumber, mergeListSearchAndWhere, transformColumnsToPreferences, transformColumnsToSearchParams } from 'payload/shared';
|
|
7
7
|
import React, { Fragment } from 'react';
|
|
8
8
|
import { getDocumentPermissions } from '../Document/getDocumentPermissions.js';
|
|
9
9
|
import { enrichDocsWithVersionStatus } from './enrichDocsWithVersionStatus.js';
|
|
10
10
|
import { handleGroupBy } from './handleGroupBy.js';
|
|
11
|
+
import { handleHierarchy } from './handleHierarchy.js';
|
|
11
12
|
import { renderListViewSlots } from './renderListViewSlots.js';
|
|
12
13
|
import { resolveAllFilterOptions } from './resolveAllFilterOptions.js';
|
|
13
14
|
import { transformColumnsToSelect } from './transformColumnsToSelect.js';
|
|
@@ -79,7 +80,7 @@ export const renderListView = async args => {
|
|
|
79
80
|
}
|
|
80
81
|
});
|
|
81
82
|
let queryPreset;
|
|
82
|
-
let queryPresetPermissions;
|
|
83
|
+
let queryPresetPermissions = permissions?.collections?.['payload-query-presets'];
|
|
83
84
|
if (collectionPreferences?.preset) {
|
|
84
85
|
try {
|
|
85
86
|
queryPreset = await payload.findByID({
|
|
@@ -155,12 +156,40 @@ export const renderListView = async args => {
|
|
|
155
156
|
i18n,
|
|
156
157
|
permissions
|
|
157
158
|
});
|
|
158
|
-
|
|
159
|
+
/** Automatically force select active columns. */
|
|
160
|
+
const select = transformColumnsToSelect(columns);
|
|
159
161
|
/** Force select image fields for list view thumbnails */
|
|
160
162
|
appendUploadSelectFields({
|
|
161
163
|
collectionConfig,
|
|
162
164
|
select
|
|
163
165
|
});
|
|
166
|
+
/** Force select `_tz` siblings for any timezone-enabled date fields in select */
|
|
167
|
+
appendDateTimezoneSelectFields({
|
|
168
|
+
fields: collectionConfig.flattenedFields,
|
|
169
|
+
select
|
|
170
|
+
});
|
|
171
|
+
/** Force select `_order` for orderable collections — OrderableTable needs it to compute reorder targets */
|
|
172
|
+
if (collectionConfig.orderable === true) {
|
|
173
|
+
select._order = true;
|
|
174
|
+
}
|
|
175
|
+
/** Force select `_status` for drafts-enabled collections — needed by `enrichDocsWithVersionStatus` and `formatDocURL` */
|
|
176
|
+
if (collectionConfig.versions?.drafts) {
|
|
177
|
+
select._status = true;
|
|
178
|
+
}
|
|
179
|
+
// Check for hierarchy parent param
|
|
180
|
+
const isHierarchyCollection = Boolean(collectionConfig.hierarchy);
|
|
181
|
+
const hierarchyParentFieldName = typeof collectionConfig.hierarchy === 'object' ? collectionConfig.hierarchy.parentFieldName ?? 'parent' : 'parent';
|
|
182
|
+
let hierarchyParentId = null;
|
|
183
|
+
if (isHierarchyCollection) {
|
|
184
|
+
const parentParam = searchParams?.[hierarchyParentFieldName];
|
|
185
|
+
if (parentParam === 'null' || parentParam === undefined) {
|
|
186
|
+
hierarchyParentId = null;
|
|
187
|
+
} else if (typeof parentParam === 'string') {
|
|
188
|
+
hierarchyParentId = payload.db.defaultIDType === 'number' && isNumber(parentParam) ? Number(parentParam) : parentParam;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Hierarchy data for client-side rendering
|
|
192
|
+
let hierarchyData;
|
|
164
193
|
try {
|
|
165
194
|
if (collectionConfig.admin.groupBy && query.groupBy) {
|
|
166
195
|
({
|
|
@@ -246,6 +275,40 @@ export const renderListView = async args => {
|
|
|
246
275
|
throw err;
|
|
247
276
|
}
|
|
248
277
|
}
|
|
278
|
+
// Fetch hierarchy data only for hierarchy view
|
|
279
|
+
let HierarchyIcon;
|
|
280
|
+
let HierarchySmallIcon;
|
|
281
|
+
const isHierarchyView = viewType === 'hierarchy';
|
|
282
|
+
if (isHierarchyCollection && isHierarchyView) {
|
|
283
|
+
// Extract typeFilter from searchParams (comma-separated list of collection slugs)
|
|
284
|
+
const typeFilterParam = searchParams?.typeFilter;
|
|
285
|
+
const typeFilter = typeof typeFilterParam === 'string' && typeFilterParam.length > 0 ? typeFilterParam.split(',') : undefined;
|
|
286
|
+
hierarchyData = await handleHierarchy({
|
|
287
|
+
baseFilter: baseFilterConstraint,
|
|
288
|
+
collectionConfig,
|
|
289
|
+
collectionSlug,
|
|
290
|
+
parentId: hierarchyParentId,
|
|
291
|
+
permissions,
|
|
292
|
+
req,
|
|
293
|
+
search: typeof query?.search === 'string' ? query.search : undefined,
|
|
294
|
+
typeFilter,
|
|
295
|
+
user
|
|
296
|
+
});
|
|
297
|
+
data = hierarchyData.childrenData;
|
|
298
|
+
// Resolve hierarchy icon from collection config
|
|
299
|
+
const hierarchyConfig = typeof collectionConfig.hierarchy === 'object' ? collectionConfig.hierarchy : undefined;
|
|
300
|
+
HierarchyIcon = RenderServerComponent({
|
|
301
|
+
Component: hierarchyConfig?.admin?.components?.Icon,
|
|
302
|
+
importMap: payload.importMap,
|
|
303
|
+
key: `hierarchy-icon-${collectionSlug}`
|
|
304
|
+
});
|
|
305
|
+
const smallIconComponent = hierarchyConfig?.admin?.components?.SmallIcon;
|
|
306
|
+
HierarchySmallIcon = smallIconComponent === hierarchyConfig?.admin?.components?.Icon ? HierarchyIcon : RenderServerComponent({
|
|
307
|
+
Component: smallIconComponent,
|
|
308
|
+
importMap: payload.importMap,
|
|
309
|
+
key: `hierarchy-small-icon-${collectionSlug}`
|
|
310
|
+
});
|
|
311
|
+
}
|
|
249
312
|
const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap);
|
|
250
313
|
const resolvedFilterOptions = await resolveAllFilterOptions({
|
|
251
314
|
fields: collectionConfig.fields,
|
|
@@ -282,6 +345,7 @@ export const renderListView = async args => {
|
|
|
282
345
|
payload,
|
|
283
346
|
permissions,
|
|
284
347
|
searchParams,
|
|
348
|
+
server: req.server,
|
|
285
349
|
user
|
|
286
350
|
};
|
|
287
351
|
const listViewSlots = renderListViewSlots({
|
|
@@ -302,42 +366,60 @@ export const renderListView = async args => {
|
|
|
302
366
|
// Needed to prevent: Only plain objects can be passed to Client Components from Server Components. Objects with toJSON methods are not supported. Convert it manually to a simple value before passing it to props.
|
|
303
367
|
// Is there a way to avoid this? The `where` object is already seemingly plain, but is not bc it originates from the params.
|
|
304
368
|
query.where = query?.where ? JSON.parse(JSON.stringify(query?.where || {})) : undefined;
|
|
369
|
+
const RenderedListViewComponent = RenderServerComponent({
|
|
370
|
+
clientProps: {
|
|
371
|
+
...listViewSlots,
|
|
372
|
+
baseFilter: baseFilterConstraint,
|
|
373
|
+
collectionSlug,
|
|
374
|
+
columnState,
|
|
375
|
+
disableBulkDelete,
|
|
376
|
+
disableBulkEdit: collectionConfig.disableBulkEdit ?? disableBulkEdit,
|
|
377
|
+
disableQueryPresets,
|
|
378
|
+
enableRowSelections,
|
|
379
|
+
hasCreatePermission,
|
|
380
|
+
hasDeletePermission,
|
|
381
|
+
hasTrashPermission,
|
|
382
|
+
hierarchyData,
|
|
383
|
+
HierarchyIcon,
|
|
384
|
+
HierarchySmallIcon,
|
|
385
|
+
listPreferences: collectionPreferences,
|
|
386
|
+
newDocumentURL,
|
|
387
|
+
queryPreset,
|
|
388
|
+
queryPresetPermissions,
|
|
389
|
+
renderedFilters,
|
|
390
|
+
resolvedFilterOptions,
|
|
391
|
+
Table,
|
|
392
|
+
viewType
|
|
393
|
+
},
|
|
394
|
+
Component: ComponentOverride ?? collectionConfig?.admin?.components?.views?.list?.Component,
|
|
395
|
+
Fallback: viewType === 'hierarchy' ? HierarchyListView : DefaultListView,
|
|
396
|
+
importMap: payload.importMap,
|
|
397
|
+
key: `list-view-${collectionSlug}-${viewType}`,
|
|
398
|
+
serverProps
|
|
399
|
+
});
|
|
305
400
|
return {
|
|
306
401
|
List: /*#__PURE__*/_jsxs(Fragment, {
|
|
307
402
|
children: [/*#__PURE__*/_jsx(HydrateAuthProvider, {
|
|
308
403
|
permissions: permissions
|
|
309
|
-
}), /*#__PURE__*/
|
|
404
|
+
}), isHierarchyView ? /*#__PURE__*/_jsxs(Fragment, {
|
|
405
|
+
children: [/*#__PURE__*/_jsx(HydrateHierarchyProvider, {
|
|
406
|
+
allowedCollections: hierarchyData?.allowedCollections,
|
|
407
|
+
baseFilter: baseFilterConstraint,
|
|
408
|
+
collectionSlug: collectionSlug,
|
|
409
|
+
expandedNodes: hierarchyData?.breadcrumbs?.slice(0, -1).map(b => b.id),
|
|
410
|
+
parent: hierarchyData?.parent,
|
|
411
|
+
parentFieldName: typeof collectionConfig.hierarchy === 'object' ? collectionConfig.hierarchy?.parentFieldName : undefined,
|
|
412
|
+
tableData: data,
|
|
413
|
+
treeLimit: typeof collectionConfig.hierarchy === 'object' ? collectionConfig.hierarchy?.admin?.treeLimit : undefined,
|
|
414
|
+
typeFieldName: typeof collectionConfig.hierarchy === 'object' && collectionConfig.hierarchy?.collectionSpecific && typeof collectionConfig.hierarchy.collectionSpecific === 'object' ? collectionConfig.hierarchy.collectionSpecific.fieldName : undefined
|
|
415
|
+
}), RenderedListViewComponent]
|
|
416
|
+
}) : /*#__PURE__*/_jsx(ListQueryProvider, {
|
|
310
417
|
collectionSlug: collectionSlug,
|
|
311
418
|
data: data,
|
|
312
419
|
modifySearchParams: !isInDrawer,
|
|
313
420
|
orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,
|
|
314
421
|
query: query,
|
|
315
|
-
children:
|
|
316
|
-
clientProps: {
|
|
317
|
-
...listViewSlots,
|
|
318
|
-
collectionSlug,
|
|
319
|
-
columnState,
|
|
320
|
-
disableBulkDelete,
|
|
321
|
-
disableBulkEdit: collectionConfig.disableBulkEdit ?? disableBulkEdit,
|
|
322
|
-
disableQueryPresets,
|
|
323
|
-
enableRowSelections,
|
|
324
|
-
hasCreatePermission,
|
|
325
|
-
hasDeletePermission,
|
|
326
|
-
hasTrashPermission,
|
|
327
|
-
listPreferences: collectionPreferences,
|
|
328
|
-
newDocumentURL,
|
|
329
|
-
queryPreset,
|
|
330
|
-
queryPresetPermissions,
|
|
331
|
-
renderedFilters,
|
|
332
|
-
resolvedFilterOptions,
|
|
333
|
-
Table,
|
|
334
|
-
viewType
|
|
335
|
-
},
|
|
336
|
-
Component: ComponentOverride ?? collectionConfig?.admin?.components?.views?.list?.Component,
|
|
337
|
-
Fallback: DefaultListView,
|
|
338
|
-
importMap: payload.importMap,
|
|
339
|
-
serverProps
|
|
340
|
-
})
|
|
422
|
+
children: RenderedListViewComponent
|
|
341
423
|
})]
|
|
342
424
|
})
|
|
343
425
|
};
|