@payloadcms/next 4.0.0-internal.38b7f1d → 4.0.0-internal.5f0cd13
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/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 +12 -14
- package/dist/cjs/withPayload.cjs.map +2 -2
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +5 -1
- package/dist/layouts/Root/index.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/getNextRequestI18n.d.ts.map +1 -1
- package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
- package/dist/utilities/getRequestHighContrast.d.ts.map +1 -1
- package/dist/utilities/getRequestTheme.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 +1 -2
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js +2 -0
- package/dist/utilities/initReq.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/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/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.map +1 -1
- 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 +69 -42
- 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 +1 -2
- 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/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/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 -2
- 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 +1 -0
- package/dist/views/Document/renderDocumentSlots.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +1 -2
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/index.js +1 -1
- package/dist/views/ForgotPassword/index.js.map +1 -1
- 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.map +1 -1
- package/dist/views/List/handleHierarchy.js +1 -0
- package/dist/views/List/handleHierarchy.js.map +1 -1
- 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 +15 -4
- 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 +3 -4
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/NotFound/metadata.d.ts.map +1 -1
- package/dist/views/ResetPassword/index.d.ts.map +1 -1
- package/dist/views/ResetPassword/index.js +1 -1
- 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.map +1 -1
- 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.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +2 -2
- 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/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 +3 -2
- 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/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 +1 -127
- package/dist/withPayload/withPayload.d.ts.map +1 -1
- package/dist/withPayload/withPayload.js +7 -7
- package/dist/withPayload/withPayload.js.map +1 -1
- package/package.json +8 -23
- 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 -68
- 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/HierarchyTypeField/index.d.ts +0 -9
- package/dist/elements/HierarchyTypeField/index.d.ts.map +0 -1
- package/dist/elements/HierarchyTypeField/index.js +0 -114
- package/dist/elements/HierarchyTypeField/index.js.map +0 -1
- package/dist/elements/HierarchyTypeField/index.server.d.ts +0 -9
- package/dist/elements/HierarchyTypeField/index.server.d.ts.map +0 -1
- package/dist/elements/HierarchyTypeField/index.server.js +0 -32
- package/dist/elements/HierarchyTypeField/index.server.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/SidebarTabs/TabError/index.css +0 -29
- package/dist/elements/Nav/SidebarTabs/TabError/index.d.ts +0 -8
- package/dist/elements/Nav/SidebarTabs/TabError/index.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/TabError/index.js +0 -42
- package/dist/elements/Nav/SidebarTabs/TabError/index.js.map +0 -1
- package/dist/elements/Nav/SidebarTabs/constants.d.ts +0 -2
- package/dist/elements/Nav/SidebarTabs/constants.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/constants.js +0 -2
- package/dist/elements/Nav/SidebarTabs/constants.js.map +0 -1
- package/dist/elements/Nav/SidebarTabs/index.client.d.ts +0 -22
- package/dist/elements/Nav/SidebarTabs/index.client.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/index.client.js +0 -195
- package/dist/elements/Nav/SidebarTabs/index.client.js.map +0 -1
- package/dist/elements/Nav/SidebarTabs/index.css +0 -80
- package/dist/elements/Nav/SidebarTabs/index.d.ts +0 -17
- package/dist/elements/Nav/SidebarTabs/index.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/index.js +0 -85
- package/dist/elements/Nav/SidebarTabs/index.js.map +0 -1
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.d.ts +0 -10
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.d.ts.map +0 -1
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.js +0 -54
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.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 -61
- 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 -118
- package/dist/elements/Nav/index.client.js.map +0 -1
- package/dist/elements/Nav/index.css +0 -155
- 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 -214
- package/dist/elements/Nav/index.js.map +0 -1
- package/dist/exports/client.d.ts +0 -6
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js +0 -8
- package/dist/exports/client.js.map +0 -1
- package/dist/exports/rsc.d.ts +0 -6
- package/dist/exports/rsc.d.ts.map +0 -1
- package/dist/exports/rsc.js +0 -6
- 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/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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","handlePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","isolateObjectProperty","logError","formatAdminURL","hasAutosaveEnabled","hasDraftsEnabled","React","DocumentHeader","getPreferences","NotFoundView","getDocPreferences","getDocumentData","getDocumentPermissions","getDocumentView","getIsLocked","getMetaBySegment","getVersions","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","searchParams","versions","viewType","collectionConfig","docID","idFromArgs","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","Boolean","deletedAt","reqForPermissions","transactionID","reqForLockCheck","docPreferences","docPermissions","hasDeletePermission","hasPublishPermission","hasSavePermission","hasTrashPermission","currentEditor","isLocked","lastUpdateTime","entityPreferences","Promise","all","data","collection","operation","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","readOnly","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","collections","find","visibleSlug","globals","formattedParams","URLSearchParams","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","validateDraftData","drafts","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","isPreviewEnabled","previewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","DocumentView","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n EditViewComponent,\n PayloadComponent,\n RenderDocumentVersionsProperties,\n} from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n LivePreviewProvider,\n} from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { handleLivePreview, handlePreview } from '@payloadcms/ui/rsc'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { isolateObjectProperty, logError } from 'payload'\nimport { formatAdminURL, hasAutosaveEnabled, hasDraftsEnabled } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { getDocPreferences } from './getDocPreferences.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getDocumentView } from './getDocumentView.js'\nimport { getIsLocked } from './getIsLocked.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getVersions } from './getVersions.js'\nimport { renderDocumentSlots } from './renderDocumentSlots.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\nexport type ViewToRender =\n | EditViewComponent\n | PayloadComponent<DocumentViewServerProps>\n | React.FC\n | React.FC<DocumentViewClientProps>\n\n/**\n * This function is responsible for rendering\n * an Edit Document view on the server for both:\n * - default document edit views\n * - on-demand edit views within drawers\n */\nexport const renderDocument = async ({\n disableActions,\n documentSubViewType,\n drawerSlug,\n importMap,\n initialData,\n initPageResult,\n overrideEntityVisibility,\n params,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n redirectAfterRestore,\n searchParams,\n versions,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n readonly redirectAfterRestore?: boolean\n versions?: RenderDocumentVersionsProperties\n} & AdminViewServerProps): Promise<{\n data: Data\n Document: React.ReactNode\n}> => {\n const {\n collectionConfig,\n docID: idFromArgs,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n let isEditing = getIsEditing({ id: idFromArgs, collectionSlug, globalSlug })\n\n // Fetch the doc required for the view\n let doc =\n !idFromArgs && !globalSlug\n ? initialData || null\n : await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n segments,\n user,\n })\n\n if (isEditing && !doc) {\n // If it's a collection document that doesn't exist, redirect to collection list\n if (collectionSlug) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}?notFound=${encodeURIComponent(idFromArgs)}`,\n })\n redirect(redirectURL)\n } else {\n // For globals or other cases, keep the 404 behavior\n throw new Error('not-found')\n }\n }\n\n const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string')\n\n // CRITICAL FIX FOR TRANSACTION RACE CONDITION:\n // When running parallel operations with Promise.all, if they share the same req object\n // and one operation calls initTransaction() which MUTATES req.transactionID, that mutation\n // is visible to all parallel operations. This causes:\n // 1. Operation A (e.g., getDocumentPermissions → docAccessOperation) calls initTransaction()\n // which sets req.transactionID = Promise, then resolves it to a UUID\n // 2. Operation B (e.g., getIsLocked) running in parallel receives the SAME req with the mutated transactionID\n // 3. Operation A (does not even know that Operation B even exists and is stil using the transactionID) commits/ends its transaction\n // 4. Operation B tries to use the now-expired session → MongoExpiredSessionError!\n //\n // Solution: Use isolateObjectProperty to create a Proxy that isolates the 'transactionID' property.\n // This allows each operation to have its own transactionID without affecting the parent req.\n // If parent req already has a transaction, preserve it (don't isolate), since this\n // issue only arises when one of the operations calls initTransaction() themselves -\n // because then, that operation will also try to commit/end the transaction itself.\n\n // If the transactionID is already set, the parallel operations will not try to\n // commit/end the transaction themselves, so we don't need to isolate the\n // transactionID property.\n const reqForPermissions = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n const reqForLockCheck = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n\n const [\n docPreferences,\n {\n docPermissions,\n hasDeletePermission,\n hasPublishPermission,\n hasSavePermission,\n hasTrashPermission,\n },\n { currentEditor, isLocked, lastUpdateTime },\n entityPreferences,\n ] = await Promise.all([\n // Get document preferences\n getDocPreferences({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n payload,\n user,\n }),\n\n // Get permissions - isolated transactionID prevents cross-contamination\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req: reqForPermissions,\n }),\n\n // Fetch document lock state - isolated transactionID prevents cross-contamination\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req: reqForLockCheck,\n }),\n\n // get entity preferences\n getPreferences<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n payload,\n req.user.id,\n req.user.collection,\n ),\n ])\n\n const operation = (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create'\n\n const [\n { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount },\n { state: formState },\n ] = await Promise.all([\n getVersions({\n id: idFromArgs,\n collectionConfig,\n doc,\n docPermissions,\n globalConfig,\n locale: locale?.code,\n payload,\n user,\n }),\n buildFormState({\n id: idFromArgs,\n collectionSlug,\n data: doc,\n docPermissions,\n docPreferences,\n fallbackLocale: false,\n globalSlug,\n locale: locale?.code,\n operation,\n readOnly: isTrashedDoc || isLocked,\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n versions,\n }\n\n if (\n !overrideEntityVisibility &&\n ((collectionSlug &&\n !visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug)) ||\n (globalSlug && !visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)))\n ) {\n throw new Error('not-found')\n }\n\n const formattedParams = new URLSearchParams()\n\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n formattedParams.append('draft', 'true')\n }\n\n if (locale?.code) {\n formattedParams.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${formattedParams.toString()}`\n\n const apiURL = formatAdminURL({\n apiRoute,\n path: collectionSlug\n ? `/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `/${globalSlug}${apiQueryParams}`\n : '',\n })\n\n let View: ViewToRender = null\n\n let showHeader = true\n\n const RootViewOverride =\n collectionConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in collectionConfig.admin.components.views.edit.root\n ? collectionConfig?.admin?.components?.views?.edit?.root?.Component\n : globalConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in globalConfig.admin.components.views.edit.root\n ? globalConfig?.admin?.components?.views?.edit?.root?.Component\n : null\n\n if (RootViewOverride) {\n View = RootViewOverride\n showHeader = false\n } else {\n ;({ View } = getDocumentView({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n }))\n }\n\n if (!View) {\n View = NotFoundView\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave = hasSavePermission && hasAutosaveEnabled(collectionConfig || globalConfig)\n\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n let id = idFromArgs\n\n if (shouldAutosave && !validateDraftData && !idFromArgs && collectionSlug) {\n doc = await payload.create({\n collection: collectionSlug,\n data: initialData || {},\n depth: 0,\n draft: true,\n fallbackLocale: false,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n id = doc.id\n isEditing = getIsEditing({ id: doc.id, collectionSlug, globalSlug })\n\n if (!drawerSlug && redirectAfterCreate !== false) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n id,\n collectionConfig,\n globalConfig,\n hasSavePermission,\n locale,\n permissions,\n req,\n })\n\n // Extract Description from documentSlots to pass to DocumentHeader\n const { Description } = documentSlots\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n const { isLivePreviewEnabled, livePreviewConfig, livePreviewURL } = await handleLivePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n const { isPreviewEnabled, previewURL } = await handlePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n return {\n data: doc,\n Document: (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n currentEditor={currentEditor}\n disableActions={disableActions ?? false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasDeletePermission={hasDeletePermission}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n hasTrashPermission={hasTrashPermission}\n id={id}\n initialData={doc}\n initialState={formState}\n isEditing={isEditing}\n isLocked={isLocked}\n isTrashed={isTrashedDoc}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <LivePreviewProvider\n breakpoints={livePreviewConfig?.breakpoints}\n isLivePreviewEnabled={isLivePreviewEnabled && operation !== 'create'}\n isLivePreviewing={Boolean(\n entityPreferences?.value?.editViewType === 'live-preview' && livePreviewURL,\n )}\n isPreviewEnabled={Boolean(isPreviewEnabled)}\n previewURL={previewURL}\n typeofLivePreviewURL={typeof livePreviewConfig?.url as 'function' | 'string' | undefined}\n url={livePreviewURL}\n >\n {showHeader && !drawerSlug && (\n <DocumentHeader\n AfterHeader={Description}\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n permissions={permissions}\n req={req}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {RenderServerComponent({\n clientProps,\n Component: View,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </LivePreviewProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function DocumentView(props: AdminViewServerProps) {\n try {\n const { Document: RenderedDocument } = await renderDocument(props)\n return RenderedDocument\n } catch (error) {\n if (error?.message === 'NEXT_REDIRECT') {\n throw error\n }\n\n logError({ err: error, payload: props.initPageResult.req.payload })\n\n if (error.message === 'not-found') {\n notFound()\n }\n }\n}\n"],"mappings":";AAYA,SACEA,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,QACd;AACP,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,EAAEC,aAAa,QAAQ;AACjD,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,qBAAqB,EAAEC,QAAQ,QAAQ;AAChD,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ;AACrE,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ;AAClC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,EAAaA;yBAClC8F,IAAA,CAACjJ,iBAAA;oBACEG,qBAAA,CAAsB;YACrBuI,WAAA;YACAV,SAAA,EAAWP,IAAA;YACXvF,SAAA;YACA0H,WAAA,EAAa/C;UACf;;;OArCC3D,MAAA,EAAQqD,IAAA;EA0CnB;AACF;AAEA,OAAO,eAAesD,aAAaC,KAA2B;EAC5D,IAAI;IACF,MAAM;MAAEd,QAAA,EAAUe;IAAgB,CAAE,GAAG,MAAMjI,cAAA,CAAegI,KAAA;IAC5D,OAAOC,gBAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,EAAOC,OAAA,KAAY,iBAAiB;MACtC,MAAMD,KAAA;IACR;IAEApJ,QAAA,CAAS;MAAEsJ,GAAA,EAAKF,KAAA;MAAO1G,OAAA,EAASwG,KAAA,CAAM1H,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAI0G,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCxJ,QAAA;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","DocumentHeader","handleLivePreview","handlePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","isolateObjectProperty","logError","formatAdminURL","hasAutosaveEnabled","hasDraftsEnabled","React","getPreferences","NotFoundView","UnauthorizedViewWithGutter","getDocPreferences","getDocumentData","getDocumentPermissions","getDocumentView","getIsLocked","getMetaBySegment","getVersions","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","searchParams","versions","viewType","collectionConfig","docID","idFromArgs","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","Boolean","deletedAt","reqForPermissions","transactionID","reqForLockCheck","docPreferences","docPermissions","hasDeletePermission","hasPublishPermission","hasSavePermission","hasTrashPermission","currentEditor","isLocked","lastUpdateTime","entityPreferences","Promise","all","data","collection","operation","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","readOnly","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","server","collections","find","visibleSlug","globals","formattedParams","URLSearchParams","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","validateDraftData","drafts","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","isPreviewEnabled","previewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","DocumentView","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n EditViewComponent,\n PayloadComponent,\n RenderDocumentVersionsProperties,\n} from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n LivePreviewProvider,\n} from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { DocumentHeader, handleLivePreview, handlePreview } from '@payloadcms/ui/rsc'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { isolateObjectProperty, logError } from 'payload'\nimport { formatAdminURL, hasAutosaveEnabled, hasDraftsEnabled } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { UnauthorizedViewWithGutter } from '../Unauthorized/index.js'\nimport { getDocPreferences } from './getDocPreferences.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getDocumentView } from './getDocumentView.js'\nimport { getIsLocked } from './getIsLocked.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getVersions } from './getVersions.js'\nimport { renderDocumentSlots } from './renderDocumentSlots.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\nexport type ViewToRender =\n | EditViewComponent\n | PayloadComponent<DocumentViewServerProps>\n | React.FC\n | React.FC<DocumentViewClientProps>\n\n/**\n * This function is responsible for rendering\n * an Edit Document view on the server for both:\n * - default document edit views\n * - on-demand edit views within drawers\n */\nexport const renderDocument = async ({\n disableActions,\n documentSubViewType,\n drawerSlug,\n importMap,\n initialData,\n initPageResult,\n overrideEntityVisibility,\n params,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n redirectAfterRestore,\n searchParams,\n versions,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n readonly redirectAfterRestore?: boolean\n versions?: RenderDocumentVersionsProperties\n} & AdminViewServerProps): Promise<{\n data: Data\n Document: React.ReactNode\n}> => {\n const {\n collectionConfig,\n docID: idFromArgs,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n let isEditing = getIsEditing({ id: idFromArgs, collectionSlug, globalSlug })\n\n // Fetch the doc required for the view\n let doc =\n !idFromArgs && !globalSlug\n ? initialData || null\n : await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n segments,\n user,\n })\n\n if (isEditing && !doc) {\n // If it's a collection document that doesn't exist, redirect to collection list\n if (collectionSlug) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}?notFound=${encodeURIComponent(idFromArgs)}`,\n })\n redirect(redirectURL)\n } else {\n // For globals or other cases, keep the 404 behavior\n throw new Error('not-found')\n }\n }\n\n const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string')\n\n // CRITICAL FIX FOR TRANSACTION RACE CONDITION:\n // When running parallel operations with Promise.all, if they share the same req object\n // and one operation calls initTransaction() which MUTATES req.transactionID, that mutation\n // is visible to all parallel operations. This causes:\n // 1. Operation A (e.g., getDocumentPermissions → docAccessOperation) calls initTransaction()\n // which sets req.transactionID = Promise, then resolves it to a UUID\n // 2. Operation B (e.g., getIsLocked) running in parallel receives the SAME req with the mutated transactionID\n // 3. Operation A (does not even know that Operation B even exists and is stil using the transactionID) commits/ends its transaction\n // 4. Operation B tries to use the now-expired session → MongoExpiredSessionError!\n //\n // Solution: Use isolateObjectProperty to create a Proxy that isolates the 'transactionID' property.\n // This allows each operation to have its own transactionID without affecting the parent req.\n // If parent req already has a transaction, preserve it (don't isolate), since this\n // issue only arises when one of the operations calls initTransaction() themselves -\n // because then, that operation will also try to commit/end the transaction itself.\n\n // If the transactionID is already set, the parallel operations will not try to\n // commit/end the transaction themselves, so we don't need to isolate the\n // transactionID property.\n const reqForPermissions = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n const reqForLockCheck = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n\n const [\n docPreferences,\n {\n docPermissions,\n hasDeletePermission,\n hasPublishPermission,\n hasSavePermission,\n hasTrashPermission,\n },\n { currentEditor, isLocked, lastUpdateTime },\n entityPreferences,\n ] = await Promise.all([\n // Get document preferences\n getDocPreferences({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n payload,\n user,\n }),\n\n // Get permissions - isolated transactionID prevents cross-contamination\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req: reqForPermissions,\n }),\n\n // Fetch document lock state - isolated transactionID prevents cross-contamination\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req: reqForLockCheck,\n }),\n\n // get entity preferences\n getPreferences<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n payload,\n req.user.id,\n req.user.collection,\n ),\n ])\n\n const operation = (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create'\n\n const [\n { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount },\n { state: formState },\n ] = await Promise.all([\n getVersions({\n id: idFromArgs,\n collectionConfig,\n doc,\n docPermissions,\n globalConfig,\n locale: locale?.code,\n payload,\n user,\n }),\n buildFormState({\n id: idFromArgs,\n collectionSlug,\n data: doc,\n docPermissions,\n docPreferences,\n fallbackLocale: false,\n globalSlug,\n locale: locale?.code,\n operation,\n readOnly: isTrashedDoc || isLocked,\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n server: req.server,\n user,\n versions,\n }\n\n if (\n !overrideEntityVisibility &&\n ((collectionSlug &&\n !visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug)) ||\n (globalSlug && !visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)))\n ) {\n throw new Error('not-found')\n }\n\n const formattedParams = new URLSearchParams()\n\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n formattedParams.append('draft', 'true')\n }\n\n if (locale?.code) {\n formattedParams.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${formattedParams.toString()}`\n\n const apiURL = formatAdminURL({\n apiRoute,\n path: collectionSlug\n ? `/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `/${globalSlug}${apiQueryParams}`\n : '',\n })\n\n let View: ViewToRender = null\n\n let showHeader = true\n\n const RootViewOverride =\n collectionConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in collectionConfig.admin.components.views.edit.root\n ? collectionConfig?.admin?.components?.views?.edit?.root?.Component\n : globalConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in globalConfig.admin.components.views.edit.root\n ? globalConfig?.admin?.components?.views?.edit?.root?.Component\n : null\n\n if (RootViewOverride) {\n View = RootViewOverride\n showHeader = false\n } else {\n ;({ View } = getDocumentView({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n }))\n\n if (View === UnauthorizedViewWithGutter) {\n showHeader = false\n }\n }\n\n if (!View) {\n View = NotFoundView\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave = hasSavePermission && hasAutosaveEnabled(collectionConfig || globalConfig)\n\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n let id = idFromArgs\n\n if (shouldAutosave && !validateDraftData && !idFromArgs && collectionSlug) {\n doc = await payload.create({\n collection: collectionSlug,\n data: initialData || {},\n depth: 0,\n draft: true,\n fallbackLocale: false,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n id = doc.id\n isEditing = getIsEditing({ id: doc.id, collectionSlug, globalSlug })\n\n if (!drawerSlug && redirectAfterCreate !== false) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n id,\n collectionConfig,\n globalConfig,\n hasSavePermission,\n locale,\n permissions,\n req,\n })\n\n // Extract Description from documentSlots to pass to DocumentHeader\n const { Description } = documentSlots\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n const { isLivePreviewEnabled, livePreviewConfig, livePreviewURL } = await handleLivePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n const { isPreviewEnabled, previewURL } = await handlePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n return {\n data: doc,\n Document: (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n currentEditor={currentEditor}\n disableActions={disableActions ?? false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasDeletePermission={hasDeletePermission}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n hasTrashPermission={hasTrashPermission}\n id={id}\n initialData={doc}\n initialState={formState}\n isEditing={isEditing}\n isLocked={isLocked}\n isTrashed={isTrashedDoc}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <LivePreviewProvider\n breakpoints={livePreviewConfig?.breakpoints}\n isLivePreviewEnabled={isLivePreviewEnabled && operation !== 'create'}\n isLivePreviewing={Boolean(\n entityPreferences?.value?.editViewType === 'live-preview' && livePreviewURL,\n )}\n isPreviewEnabled={Boolean(isPreviewEnabled)}\n previewURL={previewURL}\n typeofLivePreviewURL={typeof livePreviewConfig?.url as 'function' | 'string' | undefined}\n url={livePreviewURL}\n >\n {showHeader && !drawerSlug && (\n <DocumentHeader\n AfterHeader={Description}\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n permissions={permissions}\n req={req}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {RenderServerComponent({\n clientProps,\n Component: View,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </LivePreviewProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function DocumentView(props: AdminViewServerProps) {\n try {\n const { Document: RenderedDocument } = await renderDocument(props)\n return RenderedDocument\n } catch (error) {\n if (error?.message === 'NEXT_REDIRECT') {\n throw error\n }\n\n logError({ err: error, payload: props.initPageResult.req.payload })\n\n if (error.message === 'not-found') {\n notFound()\n }\n }\n}\n"],"mappings":";AAYA,SACEA,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,QACd;AACP,SAASC,qBAAqB,QAAQ;AACtC,SAASC,cAAc,EAAEC,iBAAiB,EAAEC,aAAa,QAAQ;AACjE,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,qBAAqB,EAAEC,QAAQ,QAAQ;AAChD,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ;AACrE,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,WAAW,QAAQ;AAC5B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,mBAAmB,QAAQ;AAEpC,OAAO,MAAMC,gBAAA,GAA6C,MAAOC,IAAA,IAASJ,gBAAA,CAAiBI,IAAA;AAQ3F;;;;;;AAMA,OAAO,MAAMC,cAAA,GAAiB,MAAAA,CA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AAaC,KAA2B;EAC5D,IAAI;IACF,MAAM;MAAEd,QAAA,EAAUe;IAAgB,CAAE,GAAG,MAAMlI,cAAA,CAAeiI,KAAA;IAC5D,OAAOC,gBAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,EAAOC,OAAA,KAAY,iBAAiB;MACtC,MAAMD,KAAA;IACR;IAEArJ,QAAA,CAAS;MAAEuJ,GAAA,EAAKF,KAAA;MAAO3G,OAAA,EAASyG,KAAA,CAAM3H,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAI2G,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCzJ,QAAA;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderDocumentSlots.d.ts","sourceRoot":"","sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEb,MAAM,EACN,cAAc,EAGd,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EAGpB,cAAc,EAMf,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,mBAAmB,EAAE,CAAC,IAAI,EAAE;IACvC,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,iBAAiB,EAAE,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,oBAAoB,CAAA;IACjC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,
|
|
1
|
+
{"version":3,"file":"renderDocumentSlots.d.ts","sourceRoot":"","sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEb,MAAM,EACN,cAAc,EAGd,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EAGpB,cAAc,EAMf,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,mBAAmB,EAAE,CAAC,IAAI,EAAE;IACvC,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,iBAAiB,EAAE,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,oBAAoB,CAAA;IACjC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,aA6LL,CAAA;AAED,eAAO,MAAM,0BAA0B,EAAE,cAAc,CAAC;IACtD,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAwBA,CAAA"}
|
|
@@ -21,6 +21,7 @@ export const renderDocumentSlots = args => {
|
|
|
21
21
|
locale,
|
|
22
22
|
payload: req.payload,
|
|
23
23
|
permissions,
|
|
24
|
+
server: req.server,
|
|
24
25
|
user: req.user
|
|
25
26
|
};
|
|
26
27
|
const BeforeDocumentControls = collectionConfig?.admin?.components?.edit?.beforeDocumentControls || globalConfig?.admin?.components?.edit?.beforeDocumentControls;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","hasDraftsEnabled","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","locale","permissions","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","user","BeforeDocumentControls","edit","beforeDocumentControls","Component","importMap","BeforeDocumentMeta","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","LivePreview","views","livePreview","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomStatus","Status","CustomPublishButton","PublishButton","CustomUnpublishButton","UnpublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","data"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n Locale,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n UnpublishButtonServerPropsOnly,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport const renderDocumentSlots: (args: {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasSavePermission: boolean\n id?: number | string\n locale: Locale\n permissions: SanitizedPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, locale, permissions, req } = args\n\n const components: DocumentSlots = {} as DocumentSlots\n\n const unsavedDraftWithValidations = undefined\n\n const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview\n\n const serverProps: ServerProps = {\n id,\n i18n: req.i18n,\n locale,\n payload: req.payload,\n permissions,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.edit?.beforeDocumentControls\n\n if (BeforeDocumentControls) {\n components.BeforeDocumentControls = RenderServerComponent({\n Component: BeforeDocumentControls,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies BeforeDocumentControlsServerPropsOnly,\n })\n }\n\n const BeforeDocumentMeta =\n collectionConfig?.admin?.components?.edit?.BeforeDocumentMeta ||\n globalConfig?.admin?.components?.edit?.BeforeDocumentMeta\n\n if (BeforeDocumentMeta) {\n components.BeforeDocumentMeta = RenderServerComponent({\n Component: BeforeDocumentMeta,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const EditMenuItems = collectionConfig?.admin?.components?.edit?.editMenuItems\n\n if (EditMenuItems) {\n components.EditMenuItems = RenderServerComponent({\n Component: EditMenuItems,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies EditMenuItemsServerPropsOnly,\n })\n }\n\n const CustomPreviewButton =\n collectionConfig?.admin?.components?.edit?.PreviewButton ||\n globalConfig?.admin?.components?.edit?.PreviewButton\n\n if (isPreviewEnabled && CustomPreviewButton) {\n components.PreviewButton = RenderServerComponent({\n Component: CustomPreviewButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PreviewButtonServerPropsOnly,\n })\n }\n\n const LivePreview =\n collectionConfig?.admin?.components?.views?.edit?.livePreview ||\n globalConfig?.admin?.components?.views?.edit?.livePreview\n\n if (LivePreview?.Component) {\n components.LivePreview = RenderServerComponent({\n Component: LivePreview.Component,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const descriptionFromConfig =\n collectionConfig?.admin?.description || globalConfig?.admin?.description\n\n const staticDescription: StaticDescription =\n typeof descriptionFromConfig === 'function'\n ? descriptionFromConfig({ t: req.i18n.t })\n : descriptionFromConfig\n\n const CustomDescription =\n collectionConfig?.admin?.components?.Description || globalConfig?.admin?.components?.Description\n\n const hasDescription = CustomDescription || staticDescription\n\n if (hasDescription) {\n components.Description = RenderServerComponent({\n clientProps: {\n collectionSlug: collectionConfig?.slug,\n description: staticDescription,\n } satisfies ViewDescriptionClientProps,\n Component: CustomDescription,\n Fallback: ViewDescription,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies ViewDescriptionServerPropsOnly,\n })\n }\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomStatus =\n collectionConfig?.admin?.components?.edit?.Status ||\n globalConfig?.admin?.components?.edit?.Status\n\n if (CustomStatus) {\n components.Status = RenderServerComponent({\n Component: CustomStatus,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n }\n\n if (hasSavePermission) {\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.edit?.PublishButton\n\n if (CustomPublishButton) {\n components.PublishButton = RenderServerComponent({\n Component: CustomPublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PublishButtonServerPropsOnly,\n })\n }\n\n const CustomUnpublishButton =\n collectionConfig?.admin?.components?.edit?.UnpublishButton ||\n globalConfig?.admin?.components?.edit?.UnpublishButton\n\n if (CustomUnpublishButton) {\n components.UnpublishButton = RenderServerComponent({\n Component: CustomUnpublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies UnpublishButtonServerPropsOnly,\n })\n }\n\n const CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.edit?.SaveDraftButton\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n if ((draftsEnabled || unsavedDraftWithValidations) && CustomSaveDraftButton) {\n components.SaveDraftButton = RenderServerComponent({\n Component: CustomSaveDraftButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveDraftButtonServerPropsOnly,\n })\n }\n } else {\n const CustomSaveButton =\n collectionConfig?.admin?.components?.edit?.SaveButton ||\n globalConfig?.admin?.components?.edit?.SaveButton\n\n if (CustomSaveButton) {\n components.SaveButton = RenderServerComponent({\n Component: CustomSaveButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveButtonServerPropsOnly,\n })\n }\n }\n }\n\n if (collectionConfig?.upload && collectionConfig?.admin?.components?.edit?.Upload) {\n components.Upload = RenderServerComponent({\n Component: collectionConfig.admin.components.edit.Upload,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n if (collectionConfig?.upload && collectionConfig.upload.admin?.components?.controls) {\n components.UploadControls = RenderServerComponent({\n Component: collectionConfig.upload.admin.components.controls,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n return components\n}\n\nexport const renderDocumentSlotsHandler: ServerFunction<{\n collectionSlug: string\n id?: number | string\n}> = async (args) => {\n const { id, collectionSlug, locale, permissions, req } = args\n\n const collectionConfig = req.payload.collections[collectionSlug]?.config\n\n if (!collectionConfig) {\n throw new Error(req.t('error:incorrectCollection'))\n }\n\n const { hasSavePermission } = await getDocumentPermissions({\n id,\n collectionConfig,\n data: {},\n req,\n })\n\n return renderDocumentSlots({\n id,\n collectionConfig,\n hasSavePermission,\n locale,\n permissions,\n req,\n })\n}\n"],"mappings":"AAqBA,SAASA,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,mBAAA,GAQUC,IAAA;EACrB,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,iBAAiB;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGP,IAAA;EAE5F,MAAMQ,UAAA,GAA4B,CAAC;EAEnC,MAAMC,2BAAA,GAA8BC,SAAA;EAEpC,MAAMC,gBAAA,GAAmBT,gBAAA,EAAkBU,KAAA,EAAOC,OAAA,IAAWV,YAAA,EAAcS,KAAA,EAAOC,OAAA;EAElF,MAAMC,WAAA,GAA2B;IAC/Bb,EAAA;IACAc,IAAA,EAAMR,GAAA,CAAIQ,IAAI;IACdV,MAAA;IACAW,OAAA,EAAST,GAAA,CAAIS,OAAO;IACpBV,WAAA;IACAW,IAAA,EAAMV,GAAA,CAAIU;EAEZ;EAEA,MAAMC,sBAAA,GACJhB,gBAAA,EAAkBU,KAAA,EAAOJ,UAAA,EAAYW,IAAA,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A,CAAWkD,cAAc,GAAG9D,qBAAA,CAAsB;MAChDyB,SAAA,EAAWnB,gBAAA,CAAiBqD,MAAM,CAAC3C,KAAK,CAACJ,UAAU,CAACiD,QAAQ;MAC5DnC,SAAA,EAAWf,GAAA,CAAIS,OAAO,CAACM,SAAS;MAChCR;IACF;EACF;EAEA,OAAON,UAAA;AACT;AAEA,OAAO,MAAMmD,0BAAA,GAGR,MAAO3D,IAAA;EACV,MAAM;IAAEC,EAAE;IAAEsC,cAAc;IAAElC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGP,IAAA;EAEzD,MAAME,gBAAA,GAAmBK,GAAA,CAAIS,OAAO,CAAC4C,WAAW,CAACrB,cAAA,CAAe,EAAEsB,MAAA;EAElE,IAAI,CAAC3D,gBAAA,EAAkB;IACrB,MAAM,IAAI4D,KAAA,CAAMvD,GAAA,CAAI2B,CAAC,CAAC;EACxB;EAEA,MAAM;IAAE9B;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzDG,EAAA;IACAC,gBAAA;IACA6D,IAAA,EAAM,CAAC;IACPxD;EACF;EAEA,OAAOR,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACAC,MAAA;IACAC,WAAA;IACAC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","hasDraftsEnabled","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","locale","permissions","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","server","user","BeforeDocumentControls","edit","beforeDocumentControls","Component","importMap","BeforeDocumentMeta","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","LivePreview","views","livePreview","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomStatus","Status","CustomPublishButton","PublishButton","CustomUnpublishButton","UnpublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","data"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n Locale,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n UnpublishButtonServerPropsOnly,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport const renderDocumentSlots: (args: {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasSavePermission: boolean\n id?: number | string\n locale: Locale\n permissions: SanitizedPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, locale, permissions, req } = args\n\n const components: DocumentSlots = {} as DocumentSlots\n\n const unsavedDraftWithValidations = undefined\n\n const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview\n\n const serverProps: ServerProps = {\n id,\n i18n: req.i18n,\n locale,\n payload: req.payload,\n permissions,\n server: req.server,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.edit?.beforeDocumentControls\n\n if (BeforeDocumentControls) {\n components.BeforeDocumentControls = RenderServerComponent({\n Component: BeforeDocumentControls,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies BeforeDocumentControlsServerPropsOnly,\n })\n }\n\n const BeforeDocumentMeta =\n collectionConfig?.admin?.components?.edit?.BeforeDocumentMeta ||\n globalConfig?.admin?.components?.edit?.BeforeDocumentMeta\n\n if (BeforeDocumentMeta) {\n components.BeforeDocumentMeta = RenderServerComponent({\n Component: BeforeDocumentMeta,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const EditMenuItems = collectionConfig?.admin?.components?.edit?.editMenuItems\n\n if (EditMenuItems) {\n components.EditMenuItems = RenderServerComponent({\n Component: EditMenuItems,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies EditMenuItemsServerPropsOnly,\n })\n }\n\n const CustomPreviewButton =\n collectionConfig?.admin?.components?.edit?.PreviewButton ||\n globalConfig?.admin?.components?.edit?.PreviewButton\n\n if (isPreviewEnabled && CustomPreviewButton) {\n components.PreviewButton = RenderServerComponent({\n Component: CustomPreviewButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PreviewButtonServerPropsOnly,\n })\n }\n\n const LivePreview =\n collectionConfig?.admin?.components?.views?.edit?.livePreview ||\n globalConfig?.admin?.components?.views?.edit?.livePreview\n\n if (LivePreview?.Component) {\n components.LivePreview = RenderServerComponent({\n Component: LivePreview.Component,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const descriptionFromConfig =\n collectionConfig?.admin?.description || globalConfig?.admin?.description\n\n const staticDescription: StaticDescription =\n typeof descriptionFromConfig === 'function'\n ? descriptionFromConfig({ t: req.i18n.t })\n : descriptionFromConfig\n\n const CustomDescription =\n collectionConfig?.admin?.components?.Description || globalConfig?.admin?.components?.Description\n\n const hasDescription = CustomDescription || staticDescription\n\n if (hasDescription) {\n components.Description = RenderServerComponent({\n clientProps: {\n collectionSlug: collectionConfig?.slug,\n description: staticDescription,\n } satisfies ViewDescriptionClientProps,\n Component: CustomDescription,\n Fallback: ViewDescription,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies ViewDescriptionServerPropsOnly,\n })\n }\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomStatus =\n collectionConfig?.admin?.components?.edit?.Status ||\n globalConfig?.admin?.components?.edit?.Status\n\n if (CustomStatus) {\n components.Status = RenderServerComponent({\n Component: CustomStatus,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n }\n\n if (hasSavePermission) {\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.edit?.PublishButton\n\n if (CustomPublishButton) {\n components.PublishButton = RenderServerComponent({\n Component: CustomPublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PublishButtonServerPropsOnly,\n })\n }\n\n const CustomUnpublishButton =\n collectionConfig?.admin?.components?.edit?.UnpublishButton ||\n globalConfig?.admin?.components?.edit?.UnpublishButton\n\n if (CustomUnpublishButton) {\n components.UnpublishButton = RenderServerComponent({\n Component: CustomUnpublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies UnpublishButtonServerPropsOnly,\n })\n }\n\n const CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.edit?.SaveDraftButton\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n if ((draftsEnabled || unsavedDraftWithValidations) && CustomSaveDraftButton) {\n components.SaveDraftButton = RenderServerComponent({\n Component: CustomSaveDraftButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveDraftButtonServerPropsOnly,\n })\n }\n } else {\n const CustomSaveButton =\n collectionConfig?.admin?.components?.edit?.SaveButton ||\n globalConfig?.admin?.components?.edit?.SaveButton\n\n if (CustomSaveButton) {\n components.SaveButton = RenderServerComponent({\n Component: CustomSaveButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveButtonServerPropsOnly,\n })\n }\n }\n }\n\n if (collectionConfig?.upload && collectionConfig?.admin?.components?.edit?.Upload) {\n components.Upload = RenderServerComponent({\n Component: collectionConfig.admin.components.edit.Upload,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n if (collectionConfig?.upload && collectionConfig.upload.admin?.components?.controls) {\n components.UploadControls = RenderServerComponent({\n Component: collectionConfig.upload.admin.components.controls,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n return components\n}\n\nexport const renderDocumentSlotsHandler: ServerFunction<{\n collectionSlug: string\n id?: number | string\n}> = async (args) => {\n const { id, collectionSlug, locale, permissions, req } = args\n\n const collectionConfig = req.payload.collections[collectionSlug]?.config\n\n if (!collectionConfig) {\n throw new Error(req.t('error:incorrectCollection'))\n }\n\n const { hasSavePermission } = await getDocumentPermissions({\n id,\n collectionConfig,\n data: {},\n req,\n })\n\n return renderDocumentSlots({\n id,\n collectionConfig,\n hasSavePermission,\n locale,\n permissions,\n req,\n })\n}\n"],"mappings":"AAqBA,SAASA,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,mBAAA,GAQUC,IAAA;EACrB,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,iBAAiB;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGP,IAAA;EAE5F,MAAMQ,UAAA,GAA4B,CAAC;EAEnC,MAAMC,2BAAA,GAA8BC,SAAA;EAEpC,MAAMC,gBAAA,GAAmBT,gBAAA,EAAkBU,KAAA,EAAOC,OAAA,IAAWV,YAAA,EAAcS,KAAA,EAAOC,OAAA;EAElF,MAAMC,WAAA,GAA2B;IAC/Bb,EAAA;IACAc,IAAA,EAAMR,GAAA,CAAIQ,IAAI;IACdV,MAAA;IACAW,OAAA,EAAST,GAAA,CAAIS,OAAO;IACpBV,WAAA;IACAW,MAAA,EAAQV,GAAA,CAAIU,MAAM;IAClBC,IAAA,EAAM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,gBAAA,EAAkBsD,MAAA,IAAUtD,gBAAA,CAAiBsD,MAAM,CAAC5C,KAAK,EAAEJ,UAAA,EAAYkD,QAAA,EAAU;IACnFlD,UAAA,CAAWmD,cAAc,GAAG/D,qBAAA,CAAsB;MAChD0B,SAAA,EAAWpB,gBAAA,CAAiBsD,MAAM,CAAC5C,KAAK,CAACJ,UAAU,CAACkD,QAAQ;MAC5DnC,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChCT;IACF;EACF;EAEA,OAAON,UAAA;AACT;AAEA,OAAO,MAAMoD,0BAAA,GAGR,MAAO5D,IAAA;EACV,MAAM;IAAEC,EAAE;IAAEuC,cAAc;IAAEnC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGP,IAAA;EAEzD,MAAME,gBAAA,GAAmBK,GAAA,CAAIS,OAAO,CAAC6C,WAAW,CAACrB,cAAA,CAAe,EAAEsB,MAAA;EAElE,IAAI,CAAC5D,gBAAA,EAAkB;IACrB,MAAM,IAAI6D,KAAA,CAAMxD,GAAA,CAAI4B,CAAC,CAAC;EACxB;EAEA,MAAM;IAAE/B;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzDG,EAAA;IACAC,gBAAA;IACA8D,IAAA,EAAM,CAAC;IACPzD;EACF;EAEA,OAAOR,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACAC,MAAA;IACAC,WAAA;IACAC;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/ForgotPassword/ForgotPasswordForm/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/ForgotPassword/ForgotPasswordForm/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAmItC,CAAA"}
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { EmailField, Form, FormSubmit, TextField, useConfig, useTranslation } from '@payloadcms/ui';
|
|
5
|
+
import { EmailField, Form, FormHeader, FormSubmit, TextField, useConfig, useTranslation } from '@payloadcms/ui';
|
|
6
6
|
import { email, formatAdminURL, text } from 'payload/shared';
|
|
7
7
|
import React, { useState } from 'react';
|
|
8
|
-
import { FormHeader } from '../../../elements/FormHeader/index.js';
|
|
9
8
|
export const ForgotPasswordForm = () => {
|
|
10
9
|
const $ = _c(17);
|
|
11
10
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","EmailField","Form","FormSubmit","TextField","useConfig","useTranslation","email","formatAdminURL","text","React","useState","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","EmailField","Form","FormHeader","FormSubmit","TextField","useConfig","useTranslation","email","formatAdminURL","text","React","useState","ForgotPasswordForm","$","config","getEntityConfig","admin","t0","routes","t1","user","userSlug","api","apiRoute","t","hasSubmitted","setHasSubmitted","t2","collectionSlug","collectionConfig","loginWithUsername","auth","t3","res","successToast","errorToast","json","then","catch","handleResponse","t4","t5","Symbol","for","initialState","username","initialValue","valid","value","undefined","t6","_jsx","description","heading","_jsxs","action","path","method","children","field","name","label","required","validate","type","blockData","data","event","preferences","fields","req","payload","siblingData","autoComplete","value_0","size"],"sources":["../../../../src/views/ForgotPassword/ForgotPasswordForm/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\nimport type { FormState, PayloadRequest } from 'payload'\n\nimport {\n EmailField,\n Form,\n FormHeader,\n FormSubmit,\n TextField,\n useConfig,\n useTranslation,\n} from '@payloadcms/ui'\nimport { email, formatAdminURL, text } from 'payload/shared'\nimport React, { useState } from 'react'\n\nexport const ForgotPasswordForm: React.FC = () => {\n const { config, getEntityConfig } = useConfig()\n\n const {\n admin: { user: userSlug },\n routes: { api: apiRoute },\n } = config\n\n const { t } = useTranslation()\n const [hasSubmitted, setHasSubmitted] = useState(false)\n const collectionConfig = getEntityConfig({ collectionSlug: userSlug })\n const loginWithUsername = collectionConfig?.auth?.loginWithUsername\n\n const handleResponse: FormProps['handleResponse'] = (res, successToast, errorToast) => {\n res\n .json()\n .then(() => {\n setHasSubmitted(true)\n successToast(t('general:submissionSuccessful'))\n })\n .catch(() => {\n errorToast(\n loginWithUsername\n ? t('authentication:usernameNotValid')\n : t('authentication:emailNotValid'),\n )\n })\n }\n\n const initialState: FormState = loginWithUsername\n ? {\n username: {\n initialValue: '',\n valid: true,\n value: undefined,\n },\n }\n : {\n email: {\n initialValue: '',\n valid: true,\n value: undefined,\n },\n }\n\n if (hasSubmitted) {\n return (\n <FormHeader\n description={t('authentication:checkYourEmailForPasswordReset')}\n heading={t('authentication:emailSent')}\n />\n )\n }\n\n return (\n <Form\n action={formatAdminURL({\n apiRoute,\n path: `/${userSlug}/forgot-password`,\n })}\n handleResponse={handleResponse}\n initialState={initialState}\n method=\"POST\"\n >\n <FormHeader\n description={\n loginWithUsername\n ? t('authentication:forgotPasswordUsernameInstructions')\n : t('authentication:forgotPasswordEmailInstructions')\n }\n heading={t('authentication:forgotPassword')}\n />\n\n {loginWithUsername ? (\n <TextField\n field={{\n name: 'username',\n label: t('authentication:username'),\n required: true,\n }}\n path=\"username\"\n validate={(value) =>\n text(value, {\n name: 'username',\n type: 'text',\n blockData: {},\n data: {},\n event: 'onChange',\n path: ['username'],\n preferences: { fields: {} },\n req: {\n payload: {\n config,\n },\n t,\n } as unknown as PayloadRequest,\n required: true,\n siblingData: {},\n })\n }\n />\n ) : (\n <EmailField\n field={{\n name: 'email',\n admin: {\n autoComplete: 'email',\n },\n label: t('general:email'),\n required: true,\n }}\n path=\"email\"\n validate={(value) =>\n email(value, {\n name: 'email',\n type: 'email',\n blockData: {},\n data: {},\n event: 'onChange',\n path: ['email'],\n preferences: { fields: {} },\n req: { payload: { config }, t } as unknown as PayloadRequest,\n required: true,\n siblingData: {},\n })\n }\n />\n )}\n <FormSubmit size=\"large\">{t('general:submit')}</FormSubmit>\n </Form>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAKA,SACEC,UAAU,EACVC,IAAI,EACJC,UAAU,EACVC,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,cAAc,QACT;AACP,SAASC,KAAK,EAAEC,cAAc,EAAEC,IAAI,QAAQ;AAC5C,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,OAAO,MAAMC,kBAAA,GAA+BA,CAAA;EAAA,MAAAC,CAAA,GAAAd,EAAA;EAC1C;IAAAe,MAAA;IAAAC;EAAA,IAAoCV,SAAA;EAEpC;IAAAW,KAAA,EAAAC,EAAA;IAAAC,MAAA,EAAAC;EAAA,IAGIL,MAAA;EAFK;IAAAM,IAAA,EAAAC;EAAA,IAAAJ,EAAkB;EACjB;IAAAK,GAAA,EAAAC;EAAA,IAAAJ,EAAiB;EAG3B;IAAAK;EAAA,IAAclB,cAAA;EACd,OAAAmB,YAAA,EAAAC,eAAA,IAAwCf,QAAA,MAAS;EAAA,IAAAgB,EAAA;EAAA,IAAAd,CAAA,QAAAE,eAAA,IAAAF,CAAA,QAAAQ,QAAA;IACxBM,EAAA,GAAAZ,eAAA;MAAAa,cAAA,EAAkCP;IAAA,CAAS;IAAAR,CAAA,MAAAE,eAAA;IAAAF,CAAA,MAAAQ,QAAA;IAAAR,CAAA,MAAAc,EAAA;EAAA;IAAAA,EAAA,GAAAd,CAAA;EAAA;EAApE,MAAAgB,gBAAA,GAAyBF,EAA2C;EACpE,MAAAG,iBAAA,GAA0BD,gBAAA,EAAAE,IAAA,EAAAD,iBAAA;EAAwB,IAAAE,EAAA;EAAA,IAAAnB,CAAA,QAAAiB,iBAAA,IAAAjB,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AAA,CAAE;QAAA,C;;;;;;;;;;;;;;;;;;;SAzE9BgB,E;CA4EJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/ForgotPassword/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/ForgotPassword/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAMnD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAIvC,eAAO,MAAM,uBAAuB,oBAAoB,CAAA;AAExD,wBAAgB,kBAAkB,CAAC,EAAE,cAAc,EAAE,EAAE,oBAAoB,qBA8D1E"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Link } from '@payloadcms/ui';
|
|
3
|
+
import { FormHeader } from '@payloadcms/ui/rsc';
|
|
3
4
|
import { Translation } from '@payloadcms/ui/shared';
|
|
4
5
|
import { formatAdminURL } from 'payload/shared';
|
|
5
6
|
import React, { Fragment } from 'react';
|
|
6
|
-
import { FormHeader } from '../../elements/FormHeader/index.js';
|
|
7
7
|
import { ForgotPasswordForm } from './ForgotPasswordForm/index.js';
|
|
8
8
|
export const forgotPasswordBaseClass = 'forgot-password';
|
|
9
9
|
export function ForgotPasswordView({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Button","Link","Translation","formatAdminURL","React","Fragment","
|
|
1
|
+
{"version":3,"file":"index.js","names":["Button","Link","FormHeader","Translation","formatAdminURL","React","Fragment","ForgotPasswordForm","forgotPasswordBaseClass","ForgotPasswordView","initPageResult","req","i18n","payload","config","user","admin","routes","account","accountRoute","login","loginRoute","adminRoute","_jsxs","_jsx","description","elements","0","children","href","path","prefetch","i18nKey","t","heading","buttonStyle","el","size","to"],"sources":["../../../src/views/ForgotPassword/index.tsx"],"sourcesContent":["import type { AdminViewServerProps } from 'payload'\n\nimport { Button, Link } from '@payloadcms/ui'\nimport { FormHeader } from '@payloadcms/ui/rsc'\nimport { Translation } from '@payloadcms/ui/shared'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { ForgotPasswordForm } from './ForgotPasswordForm/index.js'\n\nexport const forgotPasswordBaseClass = 'forgot-password'\n\nexport function ForgotPasswordView({ initPageResult }: AdminViewServerProps) {\n const {\n req: {\n i18n,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: {\n routes: { account: accountRoute, login: loginRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (user) {\n return (\n <Fragment>\n <FormHeader\n description={\n <Translation\n elements={{\n '0': ({ children }) => (\n <Link\n href={formatAdminURL({\n adminRoute,\n path: accountRoute,\n })}\n prefetch={false}\n >\n {children}\n </Link>\n ),\n }}\n i18nKey=\"authentication:loggedInChangePassword\"\n t={i18n.t}\n />\n }\n heading={i18n.t('authentication:alreadyLoggedIn')}\n />\n <Button buttonStyle=\"secondary\" el=\"link\" size=\"large\" to={adminRoute}>\n {i18n.t('general:backToDashboard')}\n </Button>\n </Fragment>\n )\n }\n\n return (\n <Fragment>\n <ForgotPasswordForm />\n <Link\n href={formatAdminURL({\n adminRoute,\n path: loginRoute,\n })}\n prefetch={false}\n >\n {i18n.t('authentication:backToLogin')}\n </Link>\n </Fragment>\n )\n}\n"],"mappings":";AAEA,SAASA,MAAM,EAAEC,IAAI,QAAQ;AAC7B,SAASC,UAAU,QAAQ;AAC3B,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,uBAAA,GAA0B;AAEvC,OAAO,SAASC,mBAAmB;EAAEC;AAAc,CAAwB;EACzE,MAAM;IACJC,GAAA,EAAK;MACHC,IAAI;MACJC,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGL,cAAA;EAEJ,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,OAAA,EAASC,YAAY;QAAEC,KAAA,EAAOC;MAAU;IAAE,CACrD;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGR,MAAA;EAEJ,IAAIC,IAAA,EAAM;IACR,oBACEQ,KAAA,CAACjB,QAAA;8BACCkB,IAAA,CAACtB,UAAA;QACCuB,WAAA,eACED,IAAA,CAACrB,WAAA;UACCuB,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC;YAAQ,CAAE,kBAChBJ,IAAA,CAACvB,IAAA;cACC4B,IAAA,EAAMzB,cAAA,CAAe;gBACnBkB,UAAA;gBACAQ,IAAA,EAAMX;cACR;cACAY,QAAA,EAAU;wBAETH;;UAGP;UACAI,OAAA,EAAQ;UACRC,CAAA,EAAGrB,IAAA,CAAKqB;;QAGZC,OAAA,EAAStB,IAAA,CAAKqB,CAAC,CAAC;uBAElBT,IAAA,CAACxB,MAAA;QAAOmC,WAAA,EAAY;QAAYC,EAAA,EAAG;QAAOC,IAAA,EAAK;QAAQC,EAAA,EAAIhB,UAAA;kBACxDV,IAAA,CAAKqB,CAAC,CAAC;;;EAIhB;EAEA,oBACEV,KAAA,CAACjB,QAAA;4BACCkB,IAAA,CAACjB,kBAAA,O,aACDiB,IAAA,CAACvB,IAAA;MACC4B,IAAA,EAAMzB,cAAA,CAAe;QACnBkB,UAAA;QACAQ,IAAA,EAAMT;MACR;MACAU,QAAA,EAAU;gBAETnB,IAAA,CAAKqB,CAAC,CAAC;;;AAIhB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSerializableValue.d.ts","sourceRoot":"","sources":["../../../src/views/List/createSerializableValue.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"createSerializableValue.d.ts","sourceRoot":"","sources":["../../../src/views/List/createSerializableValue.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,uBAAuB,GAAI,OAAO,GAAG,KAAG,MAWpD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractRelationshipDisplayValue.d.ts","sourceRoot":"","sources":["../../../src/views/List/extractRelationshipDisplayValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAGnE,eAAO,MAAM,+BAA+B,
|
|
1
|
+
{"version":3,"file":"extractRelationshipDisplayValue.d.ts","sourceRoot":"","sources":["../../../src/views/List/extractRelationshipDisplayValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAGnE,eAAO,MAAM,+BAA+B,GAC1C,cAAc,GAAG,EACjB,cAAc,YAAY,EAC1B,qBAAqB,sBAAsB,KAC1C,MAiBF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractValueOrRelationshipID.d.ts","sourceRoot":"","sources":["../../../src/views/List/extractValueOrRelationshipID.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,4BAA4B,
|
|
1
|
+
{"version":3,"file":"extractValueOrRelationshipID.d.ts","sourceRoot":"","sources":["../../../src/views/List/extractValueOrRelationshipID.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,4BAA4B,GAAI,cAAc,GAAG,KAAG,GAmBhE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleGroupBy.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleGroupBy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EACZ,MAAM,EACN,SAA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
+
import { getTranslation } from '@payloadcms/translations';
|
|
1
2
|
import { renderTable } from '@payloadcms/ui/rsc';
|
|
2
3
|
import { formatDate } from '@payloadcms/ui/shared';
|
|
3
4
|
import { flattenAllFields } from 'payload';
|
|
@@ -110,6 +111,13 @@ export const handleGroupBy = async ({
|
|
|
110
111
|
if (valueOrRelationshipID === false) {
|
|
111
112
|
heading = req.i18n.t('general:false');
|
|
112
113
|
}
|
|
114
|
+
} else if (groupByField?.type === 'select' || groupByField?.type === 'radio') {
|
|
115
|
+
const option = groupByField.options?.find(opt => (typeof opt === 'string' ? opt : opt.value) === valueOrRelationshipID);
|
|
116
|
+
if (option && typeof option !== 'string' && typeof option.label === 'string') {
|
|
117
|
+
heading = getTranslation(option.label, req.i18n);
|
|
118
|
+
} else {
|
|
119
|
+
heading = String(valueOrRelationshipID);
|
|
120
|
+
}
|
|
113
121
|
} else {
|
|
114
122
|
heading = String(valueOrRelationshipID);
|
|
115
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleGroupBy.js","names":["renderTable","formatDate","flattenAllFields","createSerializableValue","extractRelationshipDisplayValue","extractValueOrRelationshipID","handleGroupBy","clientCollectionConfig","clientConfig","collectionConfig","collectionSlug","columns","customCellProps","drawerSlug","enableRowSelections","fieldPermissions","query","req","select","trash","user","viewType","where","whereWithMergedSearch","Table","columnState","dataByGroup","flattenedFields","fields","groupByFieldPath","groupBy","replace","groupByField","find","f","name","populate","type","relationTo","Array","isArray","forEach","rel","config","collections","c","slug","admin","useAsTitle","distinct","payload","findDistinct","collection","depth","field","limit","Number","undefined","locale","overrideAccess","page","sort","data","docs","values","map","Promise","all","distinctValue","i","potentiallyPopulatedRelationship","valueOrRelationshipID","groupData","draft","fallbackLocale","includeLockStatus","queryByGroup","equals","heading","i18n","t","relationshipConfig","date","String","pattern","dateFormat","serializableValue","length","newColumnState","NewTable","groupByValue","key","orderableFieldName","orderable"],"sources":["../../../src/views/List/handleGroupBy.ts"],"sourcesContent":["import type {\n ClientCollectionConfig,\n ClientConfig,\n Column,\n ListQuery,\n PaginatedDocs,\n PayloadRequest,\n SanitizedCollectionConfig,\n SanitizedFieldsPermissions,\n SelectType,\n ViewTypes,\n Where,\n} from 'payload'\n\nimport { renderTable } from '@payloadcms/ui/rsc'\nimport { formatDate } from '@payloadcms/ui/shared'\nimport { flattenAllFields } from 'payload'\n\nimport { createSerializableValue } from './createSerializableValue.js'\nimport { extractRelationshipDisplayValue } from './extractRelationshipDisplayValue.js'\nimport { extractValueOrRelationshipID } from './extractValueOrRelationshipID.js'\n\nexport const handleGroupBy = async ({\n clientCollectionConfig,\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n fieldPermissions,\n query,\n req,\n select,\n trash = false,\n user,\n viewType,\n where: whereWithMergedSearch,\n}: {\n clientCollectionConfig: ClientCollectionConfig\n clientConfig: ClientConfig\n collectionConfig: SanitizedCollectionConfig\n collectionSlug: string\n columns: any[]\n customCellProps?: Record<string, any>\n drawerSlug?: string\n enableRowSelections?: boolean\n fieldPermissions?: SanitizedFieldsPermissions\n query?: ListQuery\n req: PayloadRequest\n select?: SelectType\n trash?: boolean\n user: any\n viewType?: ViewTypes\n where: Where\n}): Promise<{\n columnState: Column[]\n data: PaginatedDocs\n Table: null | React.ReactNode | React.ReactNode[]\n}> => {\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[]\n\n const dataByGroup: Record<string, PaginatedDocs> = {}\n\n // NOTE: is there a faster/better way to do this?\n const flattenedFields = flattenAllFields({ fields: collectionConfig.fields })\n\n const groupByFieldPath = query.groupBy.replace(/^-/, '')\n\n const groupByField = flattenedFields.find((f) => f.name === groupByFieldPath)\n\n // Set up population for relationships\n let populate\n\n if (groupByField?.type === 'relationship' && groupByField.relationTo) {\n const relationTo = Array.isArray(groupByField.relationTo)\n ? groupByField.relationTo\n : [groupByField.relationTo]\n\n populate = {}\n relationTo.forEach((rel) => {\n const config = clientConfig.collections.find((c) => c.slug === rel)\n populate[rel] = { [config?.admin?.useAsTitle || 'id']: true }\n })\n }\n\n const distinct = await req.payload.findDistinct({\n collection: collectionSlug,\n depth: 1,\n field: groupByFieldPath,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n populate,\n req,\n sort: query?.groupBy,\n trash,\n where: whereWithMergedSearch,\n })\n\n const data = {\n ...distinct,\n docs: distinct.values?.map(() => ({})) || [],\n values: undefined,\n }\n\n await Promise.all(\n (distinct.values || []).map(async (distinctValue, i) => {\n const potentiallyPopulatedRelationship = distinctValue[groupByFieldPath]\n\n // Extract value or relationship ID for database query\n const valueOrRelationshipID = extractValueOrRelationshipID(potentiallyPopulatedRelationship)\n\n const groupData = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.queryByGroup?.[valueOrRelationshipID]?.limit\n ? Number(query.queryByGroup[valueOrRelationshipID].limit)\n : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.queryByGroup?.[valueOrRelationshipID]?.page\n ? Number(query.queryByGroup[valueOrRelationshipID].page)\n : undefined,\n req,\n // Note: if we wanted to enable table-by-table sorting, we could use this:\n // sort: query?.queryByGroup?.[valueOrRelationshipID]?.sort,\n select,\n sort: query?.sort,\n trash,\n user,\n where: {\n ...(whereWithMergedSearch || {}),\n [groupByFieldPath]: {\n equals: valueOrRelationshipID,\n },\n },\n })\n\n // Extract heading\n let heading: string\n\n if (potentiallyPopulatedRelationship === null) {\n heading = req.i18n.t('general:noValue')\n } else if (groupByField?.type === 'relationship') {\n const relationshipConfig = Array.isArray(groupByField.relationTo)\n ? undefined\n : clientConfig.collections.find((c) => c.slug === groupByField.relationTo)\n heading = extractRelationshipDisplayValue(\n potentiallyPopulatedRelationship,\n clientConfig,\n relationshipConfig,\n )\n } else if (groupByField?.type === 'date') {\n heading = formatDate({\n date: String(valueOrRelationshipID),\n i18n: req.i18n,\n pattern: clientConfig.admin.dateFormat,\n })\n } else if (groupByField?.type === 'checkbox') {\n if (valueOrRelationshipID === true) {\n heading = req.i18n.t('general:true')\n }\n if (valueOrRelationshipID === false) {\n heading = req.i18n.t('general:false')\n }\n } else {\n heading = String(valueOrRelationshipID)\n }\n\n // Create serializable value for client\n const serializableValue = createSerializableValue(valueOrRelationshipID)\n\n if (groupData.docs && groupData.docs.length > 0) {\n const { columnState: newColumnState, Table: NewTable } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columns,\n customCellProps,\n data: groupData,\n drawerSlug,\n enableRowSelections,\n fieldPermissions,\n groupByFieldPath,\n groupByValue: serializableValue,\n heading: heading || req.i18n.t('general:noValue'),\n i18n: req.i18n,\n key: `table-${serializableValue}`,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n })\n\n // Only need to set `columnState` once, using the first table's column state\n // This will avoid needing to generate column state explicitly for root context that wraps all tables\n if (!columnState) {\n columnState = newColumnState\n }\n\n if (!Table) {\n Table = []\n }\n\n dataByGroup[serializableValue] = groupData\n ;(Table as Array<React.ReactNode>)[i] = NewTable\n }\n }),\n )\n\n return {\n columnState,\n data,\n Table,\n }\n}\n"],"mappings":"AAcA,SAASA,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,+BAA+B,QAAQ;AAChD,SAASC,4BAA4B,QAAQ;AAE7C,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAO;EAClCC,sBAAsB;EACtBC,YAAY;EACZC,gBAAgB;EAChBC,cAAc;EACdC,OAAO;EACPC,eAAe;EACfC,UAAU;EACVC,mBAAmB;EACnBC,gBAAgB;EAChBC,KAAK;EACLC,GAAG;EACHC,MAAM;EACNC,KAAA,GAAQ,KAAK;EACbC,IAAI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AUT,IAAI,IAAIS,SAAA,CAAUT,IAAI,CAACwB,MAAM,GAAG,GAAG;MAC/C,MAAM;QAAE9D,WAAA,EAAa+D,cAAc;QAAEhE,KAAA,EAAOiE;MAAQ,CAAE,GAAGzF,WAAA,CAAY;QACnEO,sBAAA;QACAE,gBAAA;QACAE,OAAA;QACAC,eAAA;QACAkD,IAAA,EAAMU,SAAA;QACN3D,UAAA;QACAC,mBAAA;QACAC,gBAAA;QACAc,gBAAA;QACA6D,YAAA,EAAcJ,iBAAA;QACdR,OAAA,EAASA,OAAA,IAAW7D,GAAA,CAAI8D,IAAI,CAACC,CAAC,CAAC;QAC/BD,IAAA,EAAM9D,GAAA,CAAI8D,IAAI;QACdY,GAAA,EAAK,SAASL,iBAAA,EAAmB;QACjCM,kBAAA,EAAoBnF,gBAAA,CAAiBoF,SAAS,KAAK,OAAO,WAAWpC,SAAA;QACrEP,OAAA,EAASjC,GAAA,CAAIiC,OAAO;QACpBlC,KAAA;QACAgC,UAAA,EAAYvC,gBAAA,CAAiBsC,KAAK,CAACC,UAAU;QAC7C3B;MACF;MAEA;MACA;MACA,IAAI,CAACI,WAAA,EAAa;QAChBA,WAAA,GAAc+D,cAAA;MAChB;MAEA,IAAI,CAAChE,KAAA,EAAO;QACVA,KAAA,GAAQ,EAAE;MACZ;MAEAE,WAAW,CAAC4D,iBAAA,CAAkB,GAAGd,SAAA;MAC/BhD,KAAgC,CAAC6C,CAAA,CAAE,GAAGoB,QAAA;IAC1C;EACF;EAGF,OAAO;IACLhE,WAAA;IACAqC,IAAA;IACAtC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"handleGroupBy.js","names":["getTranslation","renderTable","formatDate","flattenAllFields","createSerializableValue","extractRelationshipDisplayValue","extractValueOrRelationshipID","handleGroupBy","clientCollectionConfig","clientConfig","collectionConfig","collectionSlug","columns","customCellProps","drawerSlug","enableRowSelections","fieldPermissions","query","req","select","trash","user","viewType","where","whereWithMergedSearch","Table","columnState","dataByGroup","flattenedFields","fields","groupByFieldPath","groupBy","replace","groupByField","find","f","name","populate","type","relationTo","Array","isArray","forEach","rel","config","collections","c","slug","admin","useAsTitle","distinct","payload","findDistinct","collection","depth","field","limit","Number","undefined","locale","overrideAccess","page","sort","data","docs","values","map","Promise","all","distinctValue","i","potentiallyPopulatedRelationship","valueOrRelationshipID","groupData","draft","fallbackLocale","includeLockStatus","queryByGroup","equals","heading","i18n","t","relationshipConfig","date","String","pattern","dateFormat","option","options","opt","value","label","serializableValue","length","newColumnState","NewTable","groupByValue","key","orderableFieldName","orderable"],"sources":["../../../src/views/List/handleGroupBy.ts"],"sourcesContent":["import type {\n ClientCollectionConfig,\n ClientConfig,\n Column,\n ListQuery,\n PaginatedDocs,\n PayloadRequest,\n SanitizedCollectionConfig,\n SanitizedFieldsPermissions,\n SelectType,\n ViewTypes,\n Where,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { renderTable } from '@payloadcms/ui/rsc'\nimport { formatDate } from '@payloadcms/ui/shared'\nimport { flattenAllFields } from 'payload'\n\nimport { createSerializableValue } from './createSerializableValue.js'\nimport { extractRelationshipDisplayValue } from './extractRelationshipDisplayValue.js'\nimport { extractValueOrRelationshipID } from './extractValueOrRelationshipID.js'\n\nexport const handleGroupBy = async ({\n clientCollectionConfig,\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n fieldPermissions,\n query,\n req,\n select,\n trash = false,\n user,\n viewType,\n where: whereWithMergedSearch,\n}: {\n clientCollectionConfig: ClientCollectionConfig\n clientConfig: ClientConfig\n collectionConfig: SanitizedCollectionConfig\n collectionSlug: string\n columns: any[]\n customCellProps?: Record<string, any>\n drawerSlug?: string\n enableRowSelections?: boolean\n fieldPermissions?: SanitizedFieldsPermissions\n query?: ListQuery\n req: PayloadRequest\n select?: SelectType\n trash?: boolean\n user: any\n viewType?: ViewTypes\n where: Where\n}): Promise<{\n columnState: Column[]\n data: PaginatedDocs\n Table: null | React.ReactNode | React.ReactNode[]\n}> => {\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[]\n\n const dataByGroup: Record<string, PaginatedDocs> = {}\n\n // NOTE: is there a faster/better way to do this?\n const flattenedFields = flattenAllFields({ fields: collectionConfig.fields })\n\n const groupByFieldPath = query.groupBy.replace(/^-/, '')\n\n const groupByField = flattenedFields.find((f) => f.name === groupByFieldPath)\n\n // Set up population for relationships\n let populate\n\n if (groupByField?.type === 'relationship' && groupByField.relationTo) {\n const relationTo = Array.isArray(groupByField.relationTo)\n ? groupByField.relationTo\n : [groupByField.relationTo]\n\n populate = {}\n relationTo.forEach((rel) => {\n const config = clientConfig.collections.find((c) => c.slug === rel)\n populate[rel] = { [config?.admin?.useAsTitle || 'id']: true }\n })\n }\n\n const distinct = await req.payload.findDistinct({\n collection: collectionSlug,\n depth: 1,\n field: groupByFieldPath,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n populate,\n req,\n sort: query?.groupBy,\n trash,\n where: whereWithMergedSearch,\n })\n\n const data = {\n ...distinct,\n docs: distinct.values?.map(() => ({})) || [],\n values: undefined,\n }\n\n await Promise.all(\n (distinct.values || []).map(async (distinctValue, i) => {\n const potentiallyPopulatedRelationship = distinctValue[groupByFieldPath]\n\n // Extract value or relationship ID for database query\n const valueOrRelationshipID = extractValueOrRelationshipID(potentiallyPopulatedRelationship)\n\n const groupData = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.queryByGroup?.[valueOrRelationshipID]?.limit\n ? Number(query.queryByGroup[valueOrRelationshipID].limit)\n : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.queryByGroup?.[valueOrRelationshipID]?.page\n ? Number(query.queryByGroup[valueOrRelationshipID].page)\n : undefined,\n req,\n // Note: if we wanted to enable table-by-table sorting, we could use this:\n // sort: query?.queryByGroup?.[valueOrRelationshipID]?.sort,\n select,\n sort: query?.sort,\n trash,\n user,\n where: {\n ...(whereWithMergedSearch || {}),\n [groupByFieldPath]: {\n equals: valueOrRelationshipID,\n },\n },\n })\n\n // Extract heading\n let heading: string\n\n if (potentiallyPopulatedRelationship === null) {\n heading = req.i18n.t('general:noValue')\n } else if (groupByField?.type === 'relationship') {\n const relationshipConfig = Array.isArray(groupByField.relationTo)\n ? undefined\n : clientConfig.collections.find((c) => c.slug === groupByField.relationTo)\n heading = extractRelationshipDisplayValue(\n potentiallyPopulatedRelationship,\n clientConfig,\n relationshipConfig,\n )\n } else if (groupByField?.type === 'date') {\n heading = formatDate({\n date: String(valueOrRelationshipID),\n i18n: req.i18n,\n pattern: clientConfig.admin.dateFormat,\n })\n } else if (groupByField?.type === 'checkbox') {\n if (valueOrRelationshipID === true) {\n heading = req.i18n.t('general:true')\n }\n if (valueOrRelationshipID === false) {\n heading = req.i18n.t('general:false')\n }\n } else if (groupByField?.type === 'select' || groupByField?.type === 'radio') {\n const option = groupByField.options?.find(\n (opt) => (typeof opt === 'string' ? opt : opt.value) === valueOrRelationshipID,\n )\n if (option && typeof option !== 'string' && typeof option.label === 'string') {\n heading = getTranslation(option.label, req.i18n)\n } else {\n heading = String(valueOrRelationshipID)\n }\n } else {\n heading = String(valueOrRelationshipID)\n }\n\n // Create serializable value for client\n const serializableValue = createSerializableValue(valueOrRelationshipID)\n\n if (groupData.docs && groupData.docs.length > 0) {\n const { columnState: newColumnState, Table: NewTable } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columns,\n customCellProps,\n data: groupData,\n drawerSlug,\n enableRowSelections,\n fieldPermissions,\n groupByFieldPath,\n groupByValue: serializableValue,\n heading: heading || req.i18n.t('general:noValue'),\n i18n: req.i18n,\n key: `table-${serializableValue}`,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n })\n\n // Only need to set `columnState` once, using the first table's column state\n // This will avoid needing to generate column state explicitly for root context that wraps all tables\n if (!columnState) {\n columnState = newColumnState\n }\n\n if (!Table) {\n Table = []\n }\n\n dataByGroup[serializableValue] = groupData\n ;(Table as Array<React.ReactNode>)[i] = NewTable\n }\n }),\n )\n\n return {\n columnState,\n data,\n Table,\n }\n}\n"],"mappings":"AAcA,SAASA,cAAc,QAAQ;AAC/B,SAASC,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,+BAA+B,QAAQ;AAChD,SAASC,4BAA4B,QAAQ;AAE7C,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAO;EAClCC,sBAAsB;EACtBC,YAAY;EACZC,gBAAgB;EAChBC,cAAc;EACdC,OAAO;EACPC,eAAe;EACfC,UAAU;EACVC,mBAAmB;EACnBC,gBAAgB;EAChBC,KAAK;EACLC,GAAG;EACHC,MAAM;EACNC,KAAA,GAAQ,KAAK;EACbC,IAAI;EACJC,QAAQ;EACRC,KAAA,EAAOC;AAAqB,CAkB7B;EAKC,IAAIC,KAAA,GAA6C;EACjD,IAAIC,WAAA;EAEJ,MAAMC,WAAA,GAA6C,CAAC;EAEpD;EACA,MAAMC,eAAA,GAAkBzB,gBAAA,CAAiB;IAAE0B,MAAA,EAAQnB,gBAAA,CAAiBmB;EAAO;EAE3E,MAAMC,gBAAA,GAAmBb,KAAA,CAAMc,OAAO,CAACC,OAAO,CAAC,MAAM;EAErD,MAAMC,YAAA,GAAeL,eAAA,CAAgBM,IAAI,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAKN,gBAAA;EAE5D;EACA,IAAIO,QAAA;EAEJ,IAAIJ,YAAA,EAAcK,IAAA,KAAS,kBAAkBL,YAAA,CAAaM,UAAU,EAAE;IACpE,MAAMA,UAAA,GAAaC,KAAA,CAAMC,OAAO,CAACR,YAAA,CAAaM,UAAU,IACpDN,YAAA,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E,cAAc;QAAErE,KAAA,EAAOsE;MAAQ,CAAE,GAAG9F,WAAA,CAAY;QACnEO,sBAAA;QACAE,gBAAA;QACAE,OAAA;QACAC,eAAA;QACAkD,IAAA,EAAMU,SAAA;QACN3D,UAAA;QACAC,mBAAA;QACAC,gBAAA;QACAc,gBAAA;QACAkE,YAAA,EAAcJ,iBAAA;QACdb,OAAA,EAASA,OAAA,IAAW7D,GAAA,CAAI8D,IAAI,CAACC,CAAC,CAAC;QAC/BD,IAAA,EAAM9D,GAAA,CAAI8D,IAAI;QACdiB,GAAA,EAAK,SAASL,iBAAA,EAAmB;QACjCM,kBAAA,EAAoBxF,gBAAA,CAAiByF,SAAS,KAAK,OAAO,WAAWzC,SAAA;QACrEP,OAAA,EAASjC,GAAA,CAAIiC,OAAO;QACpBlC,KAAA;QACAgC,UAAA,EAAYvC,gBAAA,CAAiBsC,KAAK,CAACC,UAAU;QAC7C3B;MACF;MAEA;MACA;MACA,IAAI,CAACI,WAAA,EAAa;QAChBA,WAAA,GAAcoE,cAAA;MAChB;MAEA,IAAI,CAACrE,KAAA,EAAO;QACVA,KAAA,GAAQ,EAAE;MACZ;MAEAE,WAAW,CAACiE,iBAAA,CAAkB,GAAGnB,SAAA;MAC/BhD,KAAgC,CAAC6C,CAAA,CAAE,GAAGyB,QAAA;IAC1C;EACF;EAGF,OAAO;IACLrE,WAAA;IACAqC,IAAA;IACAtC;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleHierarchy.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleHierarchy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EAEd,yBAAyB,EACzB,oBAAoB,EAEpB,KAAK,EACN,MAAM,SAAS,CAAA;AAMhB;;;GAGG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"handleHierarchy.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleHierarchy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EAEd,yBAAyB,EACzB,oBAAoB,EAEpB,KAAK,EACN,MAAM,SAAS,CAAA;AAMhB;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAU,yGAUnC;IACD,UAAU,CAAC,EAAE,IAAI,GAAG,KAAK,CAAA;IACzB,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;IAChC,WAAW,CAAC,EAAE,oBAAoB,CAAA;IAClC,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;CAC7B,KAAG,OAAO,CAAC,iBAAiB,CAmP5B,CAAA"}
|
|
@@ -1 +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 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,MAAM,IAAIG,KAAA,CAAM;EAClB;EAEA,MAAMC,eAAA,GAAkBJ,eAAA,CAAgB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AAA,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
|
+
{"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,gBA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WAAA;MAC7C;IACF;EACF;EAEA;EACA;EACA;EACA;EACA,IAAIwB,kBAAA;EAEJ,IAAI9E,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"}
|