@payloadcms/next 3.23.0 → 3.24.0-canary.05013b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +1 -2
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts +2 -2
- package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/index.js +2 -0
- package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
- package/dist/elements/DocumentHeader/index.scss +0 -2
- package/dist/elements/Nav/index.client.d.ts.map +1 -1
- package/dist/elements/Nav/index.client.js +1 -3
- package/dist/elements/Nav/index.client.js.map +1 -1
- package/dist/elements/Nav/index.d.ts.map +1 -1
- package/dist/elements/Nav/index.js.map +1 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +4 -4
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/routes/rest/index.js +1 -1
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/views/API/index.d.ts +3 -2
- package/dist/views/API/index.d.ts.map +1 -1
- package/dist/views/API/index.js +2 -2
- package/dist/views/API/index.js.map +1 -1
- package/dist/views/Account/index.d.ts +2 -2
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +4 -3
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/CreateFirstUser/index.d.ts +2 -2
- package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.js +3 -3
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/Dashboard/Default/index.d.ts +13 -6
- package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/index.js +2 -5
- package/dist/views/Dashboard/Default/index.js.map +1 -1
- package/dist/views/Dashboard/index.d.ts +2 -2
- package/dist/views/Dashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/index.js +3 -7
- package/dist/views/Dashboard/index.js.map +1 -1
- package/dist/views/Document/getViewsFromConfig.d.ts +4 -4
- package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -1
- package/dist/views/Document/getViewsFromConfig.js.map +1 -1
- package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
- package/dist/views/Document/handleServerFunction.js +2 -0
- package/dist/views/Document/handleServerFunction.js.map +1 -1
- package/dist/views/Document/index.d.ts +4 -3
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +7 -7
- 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 +6 -5
- package/dist/views/Document/renderDocumentSlots.js.map +1 -1
- package/dist/views/Edit/index.d.ts +2 -2
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.d.ts +2 -2
- package/dist/views/ForgotPassword/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/index.js +4 -7
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js +2 -0
- package/dist/views/List/handleServerFunction.js.map +1 -1
- package/dist/views/List/index.d.ts +6 -5
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +35 -29
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/renderListViewSlots.d.ts +3 -4
- package/dist/views/List/renderListViewSlots.d.ts.map +1 -1
- package/dist/views/List/renderListViewSlots.js +11 -11
- package/dist/views/List/renderListViewSlots.js.map +1 -1
- package/dist/views/List/resolveAllFilterOptions.d.ts +6 -0
- package/dist/views/List/resolveAllFilterOptions.d.ts.map +1 -0
- package/dist/views/List/resolveAllFilterOptions.js +27 -0
- package/dist/views/List/resolveAllFilterOptions.js.map +1 -0
- package/dist/views/LivePreview/Context/index.d.ts.map +1 -1
- package/dist/views/LivePreview/Context/index.js +5 -1
- package/dist/views/LivePreview/Context/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.d.ts.map +1 -1
- package/dist/views/LivePreview/index.client.js +6 -3
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/LivePreview/index.d.ts +3 -2
- package/dist/views/LivePreview/index.d.ts.map +1 -1
- package/dist/views/LivePreview/index.js +2 -2
- package/dist/views/LivePreview/index.js.map +1 -1
- package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
- package/dist/views/Login/LoginForm/index.js +1 -3
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Login/index.d.ts +2 -2
- package/dist/views/Login/index.d.ts.map +1 -1
- package/dist/views/Login/index.js +3 -4
- package/dist/views/Login/index.js.map +1 -1
- package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
- package/dist/views/Logout/LogoutClient.js +32 -30
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/Logout/index.d.ts +3 -3
- package/dist/views/Logout/index.d.ts.map +1 -1
- package/dist/views/Logout/index.js +2 -2
- package/dist/views/Logout/index.js.map +1 -1
- package/dist/views/NotFound/index.client.d.ts.map +1 -1
- package/dist/views/NotFound/index.client.js +0 -3
- package/dist/views/NotFound/index.client.js.map +1 -1
- package/dist/views/NotFound/index.d.ts +2 -2
- package/dist/views/NotFound/index.d.ts.map +1 -1
- package/dist/views/NotFound/index.js +2 -2
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/ResetPassword/index.d.ts +2 -2
- package/dist/views/ResetPassword/index.d.ts.map +1 -1
- package/dist/views/ResetPassword/index.js +4 -7
- package/dist/views/ResetPassword/index.js.map +1 -1
- package/dist/views/Root/getViewFromConfig.d.ts +3 -3
- package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
- package/dist/views/Root/getViewFromConfig.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Unauthorized/index.d.ts +3 -2
- package/dist/views/Unauthorized/index.d.ts.map +1 -1
- package/dist/views/Unauthorized/index.js +3 -6
- package/dist/views/Unauthorized/index.js.map +1 -1
- package/dist/views/Verify/index.client.d.ts.map +1 -1
- package/dist/views/Verify/index.client.js +13 -9
- package/dist/views/Verify/index.client.js.map +1 -1
- package/dist/views/Verify/index.d.ts +2 -2
- package/dist/views/Verify/index.d.ts.map +1 -1
- package/dist/views/Verify/index.js +4 -4
- package/dist/views/Verify/index.js.map +1 -1
- package/dist/views/Version/Default/index.d.ts.map +1 -1
- package/dist/views/Version/Default/index.js +9 -5
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.d.ts +2 -0
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js +126 -59
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts +2 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +18 -4
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js +12 -8
- package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js +12 -8
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +20 -11
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +30 -21
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +13 -9
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.d.ts +7 -3
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js +36 -3
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.d.ts +3 -2
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js +7 -6
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js.map +1 -1
- package/dist/views/Version/Restore/index.d.ts.map +1 -1
- package/dist/views/Version/Restore/index.js +6 -3
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Version/index.d.ts +3 -2
- package/dist/views/Version/index.d.ts.map +1 -1
- package/dist/views/Version/index.js +3 -2
- package/dist/views/Version/index.js.map +1 -1
- package/dist/views/Versions/buildColumns.d.ts +1 -2
- package/dist/views/Versions/buildColumns.d.ts.map +1 -1
- package/dist/views/Versions/buildColumns.js.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.d.ts.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.js +1 -3
- package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
- package/dist/views/Versions/index.client.d.ts +1 -2
- package/dist/views/Versions/index.client.d.ts.map +1 -1
- package/dist/views/Versions/index.client.js.map +1 -1
- package/dist/views/Versions/index.d.ts +3 -2
- package/dist/views/Versions/index.d.ts.map +1 -1
- package/dist/views/Versions/index.js +2 -2
- package/dist/views/Versions/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","getAccessResults","isEntityHidden","parseCookies","renderListView","renderListHandler","args","collectionSlug","disableActions","disableBulkDelete","disableBulkEdit","drawerSlug","enableRowSelections","overrideEntityVisibility","query","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","cookies","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","clientConfig","importMap","preferencesKey","preferences","where","and","key","equals","id","then","res","value","visibleEntities","map","slug","hidden","filter","Boolean","globals","permissions","List","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams","viewType"],"sources":["../../../src/views/List/handleServerFunction.tsx"],"sourcesContent":["import type { ListPreferences, ListQuery, PayloadRequest, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { headers as getHeaders } from 'next/headers.js'\nimport { getAccessResults, isEntityHidden, parseCookies } from 'payload'\n\nimport { renderListView } from './index.js'\n\ntype RenderListResult = {\n List: React.ReactNode\n preferences: ListPreferences\n}\n\nexport const renderListHandler = async (args: {\n collectionSlug: string\n disableActions?: boolean\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n documentDrawerSlug: string\n drawerSlug?: string\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n redirectAfterDelete: boolean\n redirectAfterDuplicate: boolean\n req: PayloadRequest\n}): Promise<RenderListResult> => {\n const {\n collectionSlug,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n drawerSlug,\n enableRowSelections,\n overrideEntityVisibility,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = args\n\n const headers = await getHeaders()\n\n const cookies = parseCookies(headers)\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n })\n\n const preferencesKey = `${collectionSlug}-list`\n\n const preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as ListPreferences)\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const permissions = await getAccessResults({\n req,\n })\n\n const { List } = await renderListView({\n clientConfig,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n drawerSlug,\n enableRowSelections,\n importMap: payload.importMap,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug],\n },\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n viewType: 'list',\n })\n\n return {\n List,\n preferences,\n }\n}\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ;AAChC,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,YAAY,QAAQ;AAE/D,SAASC,cAAc,QAAQ;AAO/B,OAAO,MAAMC,iBAAA,GAAoB,MAAOC,IAAA;EActC,MAAM;IACJC,cAAc;IACdC,cAAc;IACdC,iBAAiB;IACjBC,eAAe;IACfC,UAAU;IACVC,mBAAmB;IACnBC,wBAAwB;IACxBC,KAAK;IACLC,mBAAmB;IACnBC,sBAAsB;IACtBC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGf,IAAA;EAEJ,MAAMP,OAAA,GAAU,MAAMC,UAAA;EAEtB,MAAMsB,OAAA,GAAUnB,YAAA,CAAaJ,OAAA;EAE7B,MAAMwB,gBAAA,GAAmBF,IAAA,EAAMG,UAAA;EAE/B,MAAMC,aAAA,GAAgBL,MAAA,CAAOM,KAAK,CAACL,IAAI;EAEvC;EACA,IAAIE,gBAAA,EAAkB;IACpB,MAAMI,mBAAA,GAAsBR,OAAA,CAAQS,WAAW,CAACL,gBAAA,CAAiB,CAACH,MAAM,CAACS,M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AAA,EAAO;QAAE4B;MAAM;IAAE,CAAE,KAAM,CAACpD,cAAA,CAAe;MAAEoD,MAAA;MAAQjC;IAAK,KAAKgC,IAAA,GAAO,MACjFE,MAAM,CAACC,OAAA;IACVC,OAAA,EAAStC,OAAA,CAAQC,MAAM,CAACqC,OAAO,CAC5BL,GAAG,CAAC,CAAC;MAAEC,IAAI;MAAE3B,KAAA,EAAO;QAAE4B;MAAM;IAAE,CAAE,KAAM,CAACpD,cAAA,CAAe;MAAEoD,MAAA;MAAQjC;IAAK,KAAKgC,IAAA,GAAO,MACjFE,MAAM,CAACC,OAAA;EACZ;EAEA,MAAME,WAAA,GAAc,MAAMzD,gBAAA,CAAiB;IACzCgB;EACF;EAEA,MAAM;IAAE0C;EAAI,CAAE,GAAG,MAAMvD,cAAA,CAAe;IACpCmC,YAAA;IACA/B,cAAA;IACAC,iBAAA;IACAC,eAAA;IACAC,UAAA;IACAC,mBAAA;
|
|
1
|
+
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","getAccessResults","isEntityHidden","parseCookies","renderListView","renderListHandler","args","collectionSlug","disableActions","disableBulkDelete","disableBulkEdit","drawerSlug","enableRowSelections","overrideEntityVisibility","query","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","cookies","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","clientConfig","importMap","preferencesKey","preferences","where","and","key","equals","id","then","res","value","visibleEntities","map","slug","hidden","filter","Boolean","globals","permissions","List","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams","viewType"],"sources":["../../../src/views/List/handleServerFunction.tsx"],"sourcesContent":["import type { ListPreferences, ListQuery, PayloadRequest, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { headers as getHeaders } from 'next/headers.js'\nimport { getAccessResults, isEntityHidden, parseCookies } from 'payload'\n\nimport { renderListView } from './index.js'\n\ntype RenderListResult = {\n List: React.ReactNode\n preferences: ListPreferences\n}\n\nexport const renderListHandler = async (args: {\n collectionSlug: string\n disableActions?: boolean\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n documentDrawerSlug: string\n drawerSlug?: string\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n redirectAfterDelete: boolean\n redirectAfterDuplicate: boolean\n req: PayloadRequest\n}): Promise<RenderListResult> => {\n const {\n collectionSlug,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n drawerSlug,\n enableRowSelections,\n overrideEntityVisibility,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = args\n\n const headers = await getHeaders()\n\n const cookies = parseCookies(headers)\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n })\n\n const preferencesKey = `${collectionSlug}-list`\n\n const preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as ListPreferences)\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const permissions = await getAccessResults({\n req,\n })\n\n const { List } = await renderListView({\n clientConfig,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n drawerSlug,\n enableRowSelections,\n i18n,\n importMap: payload.importMap,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug],\n },\n payload,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n viewType: 'list',\n })\n\n return {\n List,\n preferences,\n }\n}\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ;AAChC,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,YAAY,QAAQ;AAE/D,SAASC,cAAc,QAAQ;AAO/B,OAAO,MAAMC,iBAAA,GAAoB,MAAOC,IAAA;EActC,MAAM;IACJC,cAAc;IACdC,cAAc;IACdC,iBAAiB;IACjBC,eAAe;IACfC,UAAU;IACVC,mBAAmB;IACnBC,wBAAwB;IACxBC,KAAK;IACLC,mBAAmB;IACnBC,sBAAsB;IACtBC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGf,IAAA;EAEJ,MAAMP,OAAA,GAAU,MAAMC,UAAA;EAEtB,MAAMsB,OAAA,GAAUnB,YAAA,CAAaJ,OAAA;EAE7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A,EAAU,CAAC,eAAe7D,cAAA;IAC5B;IACAY,OAAA;IACAL,KAAA;IACAC,mBAAA;IACAC,sBAAA;IACAqD,YAAA,EAAc,CAAC;IACfC,QAAA,EAAU;EACZ;EAEA,OAAO;IACLX,IAAA;IACAjB;EACF;AACF","ignoreList":[]}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AdminViewServerProps, ListQuery } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export { generateListMetadata } from './meta.js';
|
|
4
|
-
type
|
|
4
|
+
type RenderListViewArgs = {
|
|
5
5
|
customCellProps?: Record<string, any>;
|
|
6
6
|
disableBulkDelete?: boolean;
|
|
7
7
|
disableBulkEdit?: boolean;
|
|
8
|
+
drawerSlug?: string;
|
|
8
9
|
enableRowSelections: boolean;
|
|
9
10
|
overrideEntityVisibility?: boolean;
|
|
10
11
|
query: ListQuery;
|
|
11
|
-
} &
|
|
12
|
-
export declare const renderListView: (args:
|
|
12
|
+
} & AdminViewServerProps;
|
|
13
|
+
export declare const renderListView: (args: RenderListViewArgs) => Promise<{
|
|
13
14
|
List: React.ReactNode;
|
|
14
15
|
}>;
|
|
15
|
-
export declare const ListView: React.FC<
|
|
16
|
+
export declare const ListView: React.FC<RenderListViewArgs>;
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,SAAS,EAIV,MAAM,SAAS,CAAA;AAQhB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,KAAK,kBAAkB,GAAG;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;CACjB,GAAG,oBAAoB,CAAA;AAExB,eAAO,MAAM,cAAc,SACnB,kBAAkB,KACvB,OAAO,CAAC;IACT,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CACtB,CAyMA,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAWjD,CAAA"}
|
package/dist/views/List/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { notFound } from 'next/navigation.js';
|
|
|
7
7
|
import { isNumber } from 'payload/shared';
|
|
8
8
|
import React, { Fragment } from 'react';
|
|
9
9
|
import { renderListViewSlots } from './renderListViewSlots.js';
|
|
10
|
+
import { resolveAllFilterOptions } from './resolveAllFilterOptions.js';
|
|
10
11
|
export { generateListMetadata } from './meta.js';
|
|
11
12
|
export const renderListView = async args => {
|
|
12
13
|
const {
|
|
@@ -116,21 +117,25 @@ export const renderListView = async args => {
|
|
|
116
117
|
useAsTitle: collectionConfig.admin.useAsTitle
|
|
117
118
|
});
|
|
118
119
|
const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap);
|
|
120
|
+
const resolvedFilterOptions = await resolveAllFilterOptions({
|
|
121
|
+
collectionConfig,
|
|
122
|
+
req
|
|
123
|
+
});
|
|
119
124
|
const staticDescription = typeof collectionConfig.admin.description === 'function' ? collectionConfig.admin.description({
|
|
120
125
|
t: i18n.t
|
|
121
126
|
}) : collectionConfig.admin.description;
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
};
|
|
130
|
-
const sharedServerProps = {
|
|
127
|
+
const newDocumentURL = formatAdminURL({
|
|
128
|
+
adminRoute,
|
|
129
|
+
path: `/collections/${collectionSlug}/create`
|
|
130
|
+
});
|
|
131
|
+
const hasCreatePermission = permissions?.collections?.[collectionSlug]?.create;
|
|
132
|
+
const serverProps = {
|
|
131
133
|
collectionConfig,
|
|
134
|
+
data,
|
|
132
135
|
i18n,
|
|
133
136
|
limit,
|
|
137
|
+
listPreferences,
|
|
138
|
+
listSearchableFields: collectionConfig.admin.listSearchableFields,
|
|
134
139
|
locale: fullLocale,
|
|
135
140
|
params,
|
|
136
141
|
payload,
|
|
@@ -139,23 +144,16 @@ export const renderListView = async args => {
|
|
|
139
144
|
user
|
|
140
145
|
};
|
|
141
146
|
const listViewSlots = renderListViewSlots({
|
|
142
|
-
clientProps:
|
|
147
|
+
clientProps: {
|
|
148
|
+
collectionSlug,
|
|
149
|
+
hasCreatePermission,
|
|
150
|
+
newDocumentURL
|
|
151
|
+
},
|
|
143
152
|
collectionConfig,
|
|
144
153
|
description: staticDescription,
|
|
145
154
|
payload,
|
|
146
|
-
serverProps
|
|
155
|
+
serverProps
|
|
147
156
|
});
|
|
148
|
-
const clientProps = {
|
|
149
|
-
...listViewSlots,
|
|
150
|
-
...sharedClientProps,
|
|
151
|
-
columnState,
|
|
152
|
-
disableBulkDelete,
|
|
153
|
-
disableBulkEdit,
|
|
154
|
-
enableRowSelections,
|
|
155
|
-
listPreferences,
|
|
156
|
-
renderedFilters,
|
|
157
|
-
Table
|
|
158
|
-
};
|
|
159
157
|
const isInDrawer = Boolean(drawerSlug);
|
|
160
158
|
return {
|
|
161
159
|
List: /*#__PURE__*/_jsxs(Fragment, {
|
|
@@ -167,16 +165,24 @@ export const renderListView = async args => {
|
|
|
167
165
|
defaultSort: sort,
|
|
168
166
|
modifySearchParams: !isInDrawer,
|
|
169
167
|
children: RenderServerComponent({
|
|
170
|
-
clientProps
|
|
168
|
+
clientProps: {
|
|
169
|
+
...listViewSlots,
|
|
170
|
+
collectionSlug,
|
|
171
|
+
columnState,
|
|
172
|
+
disableBulkDelete,
|
|
173
|
+
disableBulkEdit,
|
|
174
|
+
enableRowSelections,
|
|
175
|
+
hasCreatePermission,
|
|
176
|
+
listPreferences,
|
|
177
|
+
newDocumentURL,
|
|
178
|
+
renderedFilters,
|
|
179
|
+
resolvedFilterOptions,
|
|
180
|
+
Table
|
|
181
|
+
},
|
|
171
182
|
Component: collectionConfig?.admin?.components?.views?.list?.Component,
|
|
172
183
|
Fallback: DefaultListView,
|
|
173
184
|
importMap: payload.importMap,
|
|
174
|
-
serverProps
|
|
175
|
-
...sharedServerProps,
|
|
176
|
-
data,
|
|
177
|
-
listPreferences,
|
|
178
|
-
listSearchableFields: collectionConfig.admin.listSearchableFields
|
|
179
|
-
}
|
|
185
|
+
serverProps
|
|
180
186
|
})
|
|
181
187
|
})]
|
|
182
188
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DefaultListView","HydrateAuthProvider","ListQueryProvider","RenderServerComponent","renderFilters","renderTable","upsertPreferences","formatAdminURL","mergeListSearchAndWhere","notFound","isNumber","React","Fragment","renderListViewSlots","generateListMetadata","renderListView","args","clientConfig","customCellProps","disableBulkDelete","disableBulkEdit","drawerSlug","enableRowSelections","initPageResult","overrideEntityVisibility","params","query","queryFromArgs","searchParams","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","collections","read","Error","listPreferences","key","value","limit","Number","undefined","sort","routes","admin","adminRoute","includes","page","pagination","defaultLimit","defaultSort","where","search","baseListFilter","and","filter","Boolean","data","find","collection","depth","draft","fallbackLocale","includeLockStatus","overrideAccess","clientCollectionConfig","c","columnState","Table","columnPreferences","columns","docs","useAsTitle","renderedFilters","fields","importMap","staticDescription","description","t","sharedClientProps","hasCreatePermission","create","newDocumentURL","path","sharedServerProps","listViewSlots","clientProps","serverProps","isInDrawer","List","_jsxs","_jsx","modifySearchParams","Component","components","views","list","Fallback","listSearchableFields","ListView","RenderedList","error","message","console"],"sources":["../../../src/views/List/index.tsx"],"sourcesContent":["import type {\n ListComponentClientProps,\n ListComponentServerProps,\n ListPreferences,\n ListViewClientProps,\n} from '@payloadcms/ui'\nimport type { AdminViewProps, ListQuery, Where } from 'payload'\n\nimport { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL, mergeListSearchAndWhere } from '@payloadcms/ui/shared'\nimport { notFound } from 'next/navigation.js'\nimport { isNumber } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { renderListViewSlots } from './renderListViewSlots.js'\n\nexport { generateListMetadata } from './meta.js'\n\ntype ListViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewProps\n\nexport const renderListView = async (\n args: ListViewArgs,\n): Promise<{\n List: React.ReactNode\n}> => {\n const {\n clientConfig,\n customCellProps,\n disableBulkDelete,\n disableBulkEdit,\n drawerSlug,\n enableRowSelections,\n initPageResult,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req,\n req: {\n i18n,\n locale,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!permissions?.collections?.[collectionSlug]?.read) {\n throw new Error('not-found')\n }\n\n const query = queryFromArgs || queryFromReq\n\n const listPreferences = await upsertPreferences<ListPreferences>({\n key: `${collectionSlug}-list`,\n req,\n value: {\n limit: isNumber(query?.limit) ? Number(query.limit) : undefined,\n sort: query?.sort as string,\n },\n })\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n if (collectionConfig) {\n if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) {\n throw new Error('not-found')\n }\n\n const page = isNumber(query?.page) ? Number(query.page) : 0\n\n const limit = listPreferences?.limit || collectionConfig.admin.pagination.defaultLimit\n\n const sort =\n listPreferences?.sort ||\n (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : undefined)\n\n let where = mergeListSearchAndWhere({\n collectionConfig,\n search: typeof query?.search === 'string' ? query.search : undefined,\n where: (query?.where as Where) || undefined,\n })\n\n if (typeof collectionConfig.admin?.baseListFilter === 'function') {\n const baseListFilter = await collectionConfig.admin.baseListFilter({\n limit,\n page,\n req,\n sort,\n })\n\n if (baseListFilter) {\n where = {\n and: [where, baseListFilter].filter(Boolean),\n }\n }\n }\n\n const data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit,\n locale,\n overrideAccess: false,\n page,\n req,\n sort,\n user,\n where: where || {},\n })\n\n const clientCollectionConfig = clientConfig.collections.find((c) => c.slug === collectionSlug)\n\n const { columnState, Table } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columnPreferences: listPreferences?.columns,\n customCellProps,\n docs: data.docs,\n drawerSlug,\n enableRowSelections,\n i18n: req.i18n,\n payload,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap)\n\n const staticDescription =\n typeof collectionConfig.admin.description === 'function'\n ? collectionConfig.admin.description({ t: i18n.t })\n : collectionConfig.admin.description\n\n const sharedClientProps: ListComponentClientProps = {\n collectionSlug,\n hasCreatePermission: permissions?.collections?.[collectionSlug]?.create,\n newDocumentURL: formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/create`,\n }),\n }\n\n const sharedServerProps: ListComponentServerProps = {\n collectionConfig,\n i18n,\n limit,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const listViewSlots = renderListViewSlots({\n clientProps: sharedClientProps,\n collectionConfig,\n description: staticDescription,\n payload,\n serverProps: sharedServerProps,\n })\n\n const clientProps: ListViewClientProps = {\n ...listViewSlots,\n ...sharedClientProps,\n columnState,\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n listPreferences,\n renderedFilters,\n Table,\n }\n\n const isInDrawer = Boolean(drawerSlug)\n\n return {\n List: (\n <Fragment>\n <HydrateAuthProvider permissions={permissions} />\n <ListQueryProvider\n data={data}\n defaultLimit={limit}\n defaultSort={sort}\n modifySearchParams={!isInDrawer}\n >\n {RenderServerComponent({\n clientProps,\n Component: collectionConfig?.admin?.components?.views?.list?.Component,\n Fallback: DefaultListView,\n importMap: payload.importMap,\n serverProps: {\n ...sharedServerProps,\n data,\n listPreferences,\n listSearchableFields: collectionConfig.admin.listSearchableFields,\n },\n })}\n </ListQueryProvider>\n </Fragment>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n\nexport const ListView: React.FC<ListViewArgs> = async (args) => {\n try {\n const { List: RenderedList } = await renderListView({ ...args, enableRowSelections: true })\n return RenderedList\n } catch (error) {\n if (error.message === 'not-found') {\n notFound()\n } else {\n console.error(error) // eslint-disable-line no-console\n }\n }\n}\n"],"mappings":";AAQA,SAASA,eAAe,EAAEC,mBAAmB,EAAEC,iBAAiB,QAAQ;AACxE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,aAAa,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ;AAC9D,SAASC,cAAc,EAAEC,uBAAuB,QAAQ;AACxD,SAASC,QAAQ,QAAQ;AACzB,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,mBAAmB,QAAQ;AAEpC,SAASC,oBAAoB,QAAQ;AAWrC,OAAO,MAAMC,cAAA,GAAiB,MAC5BC,IAAA;EAIA,MAAM;IACJC,YAAY;IACZC,eAAe;IACfC,iBAAiB;IACjBC,eAAe;IACfC,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AAA;MACAzD,iBAAA;MACAC,eAAA;MACAE,mBAAA;MACAuB,eAAA;MACAqC,eAAA;MACAL;IACF;IAEA,MAAMoB,UAAA,GAAahC,OAAA,CAAQ5C,UAAA;IAE3B,OAAO;MACL6E,IAAA,eACEC,KAAA,CAACvF,QAAA;gCACCwF,IAAA,CAACnG,mBAAA;UAAoBiC,WAAA,EAAaA;yBAClCkE,IAAA,CAAClG,iBAAA;UACCgE,IAAA,EAAMA,IAAA;UACNR,YAAA,EAAcV,KAAA;UACdW,WAAA,EAAaR,IAAA;UACbkD,kBAAA,EAAoB,CAACJ,UAAA;oBAEpB9F,qBAAA,CAAsB;YACrB4F,WAAA;YACAO,SAAA,EAAWzE,gBAAA,EAAkBwB,KAAA,EAAOkD,UAAA,EAAYC,KAAA,EAAOC,IAAA,EAAMH,SAAA;YAC7DI,QAAA,EAAU1G,eAAA;YACVoF,SAAA,EAAW/C,OAAA,CAAQ+C,SAAS;YAC5BY,WAAA,EAAa;cACX,GAAGH,iBAAiB;cACpB3B,IAAA;cACArB,eAAA;cACA8D,oBAAA,EAAsB9E,gBAAA,CAAiBwB,KAAK,CAACsD;YAC/C;UACF;;;IAIR;EACF;EAEA,MAAM,IAAI/D,KAAA,CAAM;AAClB;AAEA,OAAO,MAAMgE,QAAA,GAAmC,MAAO5F,IAAA;EACrD,IAAI;IACF,MAAM;MAAEkF,IAAA,EAAMW;IAAY,CAAE,GAAG,MAAM9F,cAAA,CAAe;MAAE,GAAGC,IAAI;MAAEM,mBAAA,EAAqB;IAAK;IACzF,OAAOuF,YAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCtG,QAAA;IACF,OAAO;MACLuG,OAAA,CAAQF,KAAK,CAACA,KAAA,EAAO;MAAA;IACvB;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DefaultListView","HydrateAuthProvider","ListQueryProvider","RenderServerComponent","renderFilters","renderTable","upsertPreferences","formatAdminURL","mergeListSearchAndWhere","notFound","isNumber","React","Fragment","renderListViewSlots","resolveAllFilterOptions","generateListMetadata","renderListView","args","clientConfig","customCellProps","disableBulkDelete","disableBulkEdit","drawerSlug","enableRowSelections","initPageResult","overrideEntityVisibility","params","query","queryFromArgs","searchParams","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","collections","read","Error","listPreferences","key","value","limit","Number","undefined","sort","routes","admin","adminRoute","includes","page","pagination","defaultLimit","defaultSort","where","search","baseListFilter","and","filter","Boolean","data","find","collection","depth","draft","fallbackLocale","includeLockStatus","overrideAccess","clientCollectionConfig","c","columnState","Table","columnPreferences","columns","docs","useAsTitle","renderedFilters","fields","importMap","resolvedFilterOptions","staticDescription","description","t","newDocumentURL","path","hasCreatePermission","create","serverProps","listSearchableFields","listViewSlots","clientProps","isInDrawer","List","_jsxs","_jsx","modifySearchParams","Component","components","views","list","Fallback","ListView","RenderedList","error","message","console"],"sources":["../../../src/views/List/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n ListPreferences,\n ListQuery,\n ListViewClientProps,\n ListViewServerPropsOnly,\n Where,\n} from 'payload'\n\nimport { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL, mergeListSearchAndWhere } from '@payloadcms/ui/shared'\nimport { notFound } from 'next/navigation.js'\nimport { isNumber } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { renderListViewSlots } from './renderListViewSlots.js'\nimport { resolveAllFilterOptions } from './resolveAllFilterOptions.js'\n\nexport { generateListMetadata } from './meta.js'\n\ntype RenderListViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n drawerSlug?: string\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewServerProps\n\nexport const renderListView = async (\n args: RenderListViewArgs,\n): Promise<{\n List: React.ReactNode\n}> => {\n const {\n clientConfig,\n customCellProps,\n disableBulkDelete,\n disableBulkEdit,\n drawerSlug,\n enableRowSelections,\n initPageResult,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req,\n req: {\n i18n,\n locale,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!permissions?.collections?.[collectionSlug]?.read) {\n throw new Error('not-found')\n }\n\n const query = queryFromArgs || queryFromReq\n\n const listPreferences = await upsertPreferences<ListPreferences>({\n key: `${collectionSlug}-list`,\n req,\n value: {\n limit: isNumber(query?.limit) ? Number(query.limit) : undefined,\n sort: query?.sort as string,\n },\n })\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n if (collectionConfig) {\n if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) {\n throw new Error('not-found')\n }\n\n const page = isNumber(query?.page) ? Number(query.page) : 0\n\n const limit = listPreferences?.limit || collectionConfig.admin.pagination.defaultLimit\n\n const sort =\n listPreferences?.sort ||\n (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : undefined)\n\n let where = mergeListSearchAndWhere({\n collectionConfig,\n search: typeof query?.search === 'string' ? query.search : undefined,\n where: (query?.where as Where) || undefined,\n })\n\n if (typeof collectionConfig.admin?.baseListFilter === 'function') {\n const baseListFilter = await collectionConfig.admin.baseListFilter({\n limit,\n page,\n req,\n sort,\n })\n\n if (baseListFilter) {\n where = {\n and: [where, baseListFilter].filter(Boolean),\n }\n }\n }\n\n const data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit,\n locale,\n overrideAccess: false,\n page,\n req,\n sort,\n user,\n where: where || {},\n })\n\n const clientCollectionConfig = clientConfig.collections.find((c) => c.slug === collectionSlug)\n\n const { columnState, Table } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columnPreferences: listPreferences?.columns,\n customCellProps,\n docs: data.docs,\n drawerSlug,\n enableRowSelections,\n i18n: req.i18n,\n payload,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap)\n\n const resolvedFilterOptions = await resolveAllFilterOptions({\n collectionConfig,\n req,\n })\n\n const staticDescription =\n typeof collectionConfig.admin.description === 'function'\n ? collectionConfig.admin.description({ t: i18n.t })\n : collectionConfig.admin.description\n\n const newDocumentURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/create`,\n })\n\n const hasCreatePermission = permissions?.collections?.[collectionSlug]?.create\n\n const serverProps: ListViewServerPropsOnly = {\n collectionConfig,\n data,\n i18n,\n limit,\n listPreferences,\n listSearchableFields: collectionConfig.admin.listSearchableFields,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const listViewSlots = renderListViewSlots({\n clientProps: {\n collectionSlug,\n hasCreatePermission,\n newDocumentURL,\n },\n collectionConfig,\n description: staticDescription,\n payload,\n serverProps,\n })\n\n const isInDrawer = Boolean(drawerSlug)\n\n return {\n List: (\n <Fragment>\n <HydrateAuthProvider permissions={permissions} />\n <ListQueryProvider\n data={data}\n defaultLimit={limit}\n defaultSort={sort}\n modifySearchParams={!isInDrawer}\n >\n {RenderServerComponent({\n clientProps: {\n ...listViewSlots,\n collectionSlug,\n columnState,\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n hasCreatePermission,\n listPreferences,\n newDocumentURL,\n renderedFilters,\n resolvedFilterOptions,\n Table,\n } satisfies ListViewClientProps,\n Component: collectionConfig?.admin?.components?.views?.list?.Component,\n Fallback: DefaultListView,\n importMap: payload.importMap,\n serverProps,\n })}\n </ListQueryProvider>\n </Fragment>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n\nexport const ListView: React.FC<RenderListViewArgs> = async (args) => {\n try {\n const { List: RenderedList } = await renderListView({ ...args, enableRowSelections: true })\n return RenderedList\n } catch (error) {\n if (error.message === 'not-found') {\n notFound()\n } else {\n console.error(error) // eslint-disable-line no-console\n }\n }\n}\n"],"mappings":";AASA,SAASA,eAAe,EAAEC,mBAAmB,EAAEC,iBAAiB,QAAQ;AACxE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,aAAa,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ;AAC9D,SAASC,cAAc,EAAEC,uBAAuB,QAAQ;AACxD,SAASC,QAAQ,QAAQ;AACzB,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,uBAAuB,QAAQ;AAExC,SAASC,oBAAoB,QAAQ;AAYrC,OAAO,MAAMC,cAAA,GAAiB,MAC5BC,IAAA;EAIA,MAAM;IACJC,YAAY;IACZC,eAAe;IACfC,iBAAiB;IACjBC,eAAe;IACfC,UAAU;IACVC,mBAAmB;IACnBC,cAAc;IACdC,wBAAwB;IACxBC,MAAM;IACNC,KAAA,EAAOC,aAAa;IACpBC;EAAY,CACb,GAAGZ,IAAA;EAEJ,MAAM;IACJa,gBAAgB;IAChBA,gBAAA,EAAkB;MAAEC,IAAA,EAAMC;IAAc,CAAE;IAC1CC,MAAA,EAAQC,UAAU;IAClBC,WAAW;IACXC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJJ,MAAM;MACNK,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBZ,KAAA,EAAOa,YAAY;MACnBC;IAAI,CACL;IACDC;EAAe,CAChB,GAAGlB,cAAA;EAEJ,IAAI,CAACW,WAAA,EAAaQ,WAAA,GAAcX,cAAA,CAAe,EAAEY,IAAA,EAAM;IACrD,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAMlB,KAAA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BAAA;cACAR;YACF;YACAyB,SAAA,EAAWzE,gBAAA,EAAkBwB,KAAA,EAAOkD,UAAA,EAAYC,KAAA,EAAOC,IAAA,EAAMH,SAAA;YAC7DI,QAAA,EAAU3G,eAAA;YACVqF,SAAA,EAAW/C,OAAA,CAAQ+C,SAAS;YAC5BS;UACF;;;IAIR;EACF;EAEA,MAAM,IAAIjD,KAAA,CAAM;AAClB;AAEA,OAAO,MAAM+D,QAAA,GAAyC,MAAO3F,IAAA;EAC3D,IAAI;IACF,MAAM;MAAEkF,IAAA,EAAMU;IAAY,CAAE,GAAG,MAAM7F,cAAA,CAAe;MAAE,GAAGC,IAAI;MAAEM,mBAAA,EAAqB;IAAK;IACzF,OAAOsF,YAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCtG,QAAA;IACF,OAAO;MACLuG,OAAA,CAAQF,KAAK,CAACA,KAAA,EAAO;MAAA;IACvB;EACF;AACF","ignoreList":[]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Payload, SanitizedCollectionConfig, StaticDescription } from 'payload';
|
|
1
|
+
import type { ListViewServerPropsOnly, ListViewSlots, ListViewSlotSharedClientProps, Payload, SanitizedCollectionConfig, StaticDescription } from 'payload';
|
|
3
2
|
type Args = {
|
|
4
|
-
clientProps:
|
|
3
|
+
clientProps: ListViewSlotSharedClientProps;
|
|
5
4
|
collectionConfig: SanitizedCollectionConfig;
|
|
6
5
|
description?: StaticDescription;
|
|
7
6
|
payload: Payload;
|
|
8
|
-
serverProps:
|
|
7
|
+
serverProps: ListViewServerPropsOnly;
|
|
9
8
|
};
|
|
10
9
|
export declare const renderListViewSlots: ({ clientProps, collectionConfig, description, payload, serverProps, }: Args) => ListViewSlots;
|
|
11
10
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderListViewSlots.d.ts","sourceRoot":"","sources":["../../../src/views/List/renderListViewSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"renderListViewSlots.d.ts","sourceRoot":"","sources":["../../../src/views/List/renderListViewSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAQV,uBAAuB,EACvB,aAAa,EACb,6BAA6B,EAC7B,OAAO,EACP,yBAAyB,EACzB,iBAAiB,EAGlB,MAAM,SAAS,CAAA;AAIhB,KAAK,IAAI,GAAG;IACV,WAAW,EAAE,6BAA6B,CAAA;IAC1C,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,uBAAuB,CAAA;CACrC,CAAA;AAED,eAAO,MAAM,mBAAmB,0EAM7B,IAAI,KAAG,aAoDT,CAAA"}
|
|
@@ -9,45 +9,45 @@ export const renderListViewSlots = ({
|
|
|
9
9
|
const result = {};
|
|
10
10
|
if (collectionConfig.admin.components?.afterList) {
|
|
11
11
|
result.AfterList = RenderServerComponent({
|
|
12
|
-
clientProps,
|
|
12
|
+
clientProps: clientProps,
|
|
13
13
|
Component: collectionConfig.admin.components.afterList,
|
|
14
14
|
importMap: payload.importMap,
|
|
15
|
-
serverProps
|
|
15
|
+
serverProps: serverProps
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
if (collectionConfig.admin.components?.afterListTable) {
|
|
19
19
|
result.AfterListTable = RenderServerComponent({
|
|
20
|
-
clientProps,
|
|
20
|
+
clientProps: clientProps,
|
|
21
21
|
Component: collectionConfig.admin.components.afterListTable,
|
|
22
22
|
importMap: payload.importMap,
|
|
23
|
-
serverProps
|
|
23
|
+
serverProps: serverProps
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
if (collectionConfig.admin.components?.beforeList) {
|
|
27
27
|
result.BeforeList = RenderServerComponent({
|
|
28
|
-
clientProps,
|
|
28
|
+
clientProps: clientProps,
|
|
29
29
|
Component: collectionConfig.admin.components.beforeList,
|
|
30
30
|
importMap: payload.importMap,
|
|
31
|
-
serverProps
|
|
31
|
+
serverProps: serverProps
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
if (collectionConfig.admin.components?.beforeListTable) {
|
|
35
35
|
result.BeforeListTable = RenderServerComponent({
|
|
36
|
-
clientProps,
|
|
36
|
+
clientProps: clientProps,
|
|
37
37
|
Component: collectionConfig.admin.components.beforeListTable,
|
|
38
38
|
importMap: payload.importMap,
|
|
39
|
-
serverProps
|
|
39
|
+
serverProps: serverProps
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
if (collectionConfig.admin.components?.Description) {
|
|
43
43
|
result.Description = RenderServerComponent({
|
|
44
44
|
clientProps: {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
collectionSlug: collectionConfig.slug,
|
|
46
|
+
description
|
|
47
47
|
},
|
|
48
48
|
Component: collectionConfig.admin.components.Description,
|
|
49
49
|
importMap: payload.importMap,
|
|
50
|
-
serverProps
|
|
50
|
+
serverProps: serverProps
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderListViewSlots.js","names":["RenderServerComponent","renderListViewSlots","clientProps","collectionConfig","description","payload","serverProps","result","admin","components","afterList","AfterList","Component","importMap","afterListTable","AfterListTable","beforeList","BeforeList","beforeListTable","BeforeListTable","Description"],"sources":["../../../src/views/List/renderListViewSlots.tsx"],"sourcesContent":["import type {\n
|
|
1
|
+
{"version":3,"file":"renderListViewSlots.js","names":["RenderServerComponent","renderListViewSlots","clientProps","collectionConfig","description","payload","serverProps","result","admin","components","afterList","AfterList","Component","importMap","afterListTable","AfterListTable","beforeList","BeforeList","beforeListTable","BeforeListTable","Description","collectionSlug","slug"],"sources":["../../../src/views/List/renderListViewSlots.tsx"],"sourcesContent":["import type {\n AfterListClientProps,\n AfterListTableClientProps,\n AfterListTableServerPropsOnly,\n BeforeListClientProps,\n BeforeListServerPropsOnly,\n BeforeListTableClientProps,\n BeforeListTableServerPropsOnly,\n ListViewServerPropsOnly,\n ListViewSlots,\n ListViewSlotSharedClientProps,\n Payload,\n SanitizedCollectionConfig,\n StaticDescription,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\n\ntype Args = {\n clientProps: ListViewSlotSharedClientProps\n collectionConfig: SanitizedCollectionConfig\n description?: StaticDescription\n payload: Payload\n serverProps: ListViewServerPropsOnly\n}\n\nexport const renderListViewSlots = ({\n clientProps,\n collectionConfig,\n description,\n payload,\n serverProps,\n}: Args): ListViewSlots => {\n const result: ListViewSlots = {} as ListViewSlots\n\n if (collectionConfig.admin.components?.afterList) {\n result.AfterList = RenderServerComponent({\n clientProps: clientProps satisfies AfterListClientProps,\n Component: collectionConfig.admin.components.afterList,\n importMap: payload.importMap,\n serverProps: serverProps satisfies AfterListTableServerPropsOnly,\n })\n }\n\n if (collectionConfig.admin.components?.afterListTable) {\n result.AfterListTable = RenderServerComponent({\n clientProps: clientProps satisfies AfterListTableClientProps,\n Component: collectionConfig.admin.components.afterListTable,\n importMap: payload.importMap,\n serverProps: serverProps satisfies AfterListTableServerPropsOnly,\n })\n }\n\n if (collectionConfig.admin.components?.beforeList) {\n result.BeforeList = RenderServerComponent({\n clientProps: clientProps satisfies BeforeListClientProps,\n Component: collectionConfig.admin.components.beforeList,\n importMap: payload.importMap,\n serverProps: serverProps satisfies BeforeListServerPropsOnly,\n })\n }\n\n if (collectionConfig.admin.components?.beforeListTable) {\n result.BeforeListTable = RenderServerComponent({\n clientProps: clientProps satisfies BeforeListTableClientProps,\n Component: collectionConfig.admin.components.beforeListTable,\n importMap: payload.importMap,\n serverProps: serverProps satisfies BeforeListTableServerPropsOnly,\n })\n }\n\n if (collectionConfig.admin.components?.Description) {\n result.Description = RenderServerComponent({\n clientProps: {\n collectionSlug: collectionConfig.slug,\n description,\n } satisfies ViewDescriptionClientProps,\n Component: collectionConfig.admin.components.Description,\n importMap: payload.importMap,\n serverProps: serverProps satisfies ViewDescriptionServerPropsOnly,\n })\n }\n\n return result\n}\n"],"mappings":"AAkBA,SAASA,qBAAqB,QAAQ;AAUtC,OAAO,MAAMC,mBAAA,GAAsBA,CAAC;EAClCC,WAAW;EACXC,gBAAgB;EAChBC,WAAW;EACXC,OAAO;EACPC;AAAW,CACN;EACL,MAAMC,MAAA,GAAwB,CAAC;EAE/B,IAAIJ,gBAAA,CAAiBK,KAAK,CAACC,UAAU,EAAEC,SAAA,EAAW;IAChDH,MAAA,CAAOI,SAAS,GAAGX,qBAAA,CAAsB;MACvCE,WAAA,EAAaA,WAAA;MACbU,SAAA,EAAWT,gBAAA,CAAiBK,KAAK,CAACC,UAAU,CAACC,SAAS;MACtDG,SAAA,EAAWR,OAAA,CAAQQ,SAAS;MAC5BP,WAAA,EAAaA;IACf;EACF;EAEA,IAAIH,gBAAA,CAAiBK,KAAK,CAACC,UAAU,EAAEK,cAAA,EAAgB;IACrDP,MAAA,CAAOQ,cAAc,GAAGf,qBAAA,CAAsB;MAC5CE,WAAA,EAAaA,WAAA;MACbU,SAAA,EAAWT,gBAAA,CAAiBK,KAAK,CAACC,UAAU,CAACK,cAAc;MAC3DD,SAAA,EAAWR,OAAA,CAAQQ,SAAS;MAC5BP,WAAA,EAAaA;IACf;EACF;EAEA,IAAIH,gBAAA,CAAiBK,KAAK,CAACC,UAAU,EAAEO,UAAA,EAAY;IACjDT,MAAA,CAAOU,UAAU,GAAGjB,qBAAA,CAAsB;MACxCE,WAAA,EAAaA,WAAA;MACbU,SAAA,EAAWT,gBAAA,CAAiBK,KAAK,CAACC,UAAU,CAACO,UAAU;MACvDH,SAAA,EAAWR,OAAA,CAAQQ,SAAS;MAC5BP,WAAA,EAAaA;IACf;EACF;EAEA,IAAIH,gBAAA,CAAiBK,KAAK,CAACC,UAAU,EAAES,eAAA,EAAiB;IACtDX,MAAA,CAAOY,eAAe,GAAGnB,qBAAA,CAAsB;MAC7CE,WAAA,EAAaA,WAAA;MACbU,SAAA,EAAWT,gBAAA,CAAiBK,KAAK,CAACC,UAAU,CAACS,eAAe;MAC5DL,SAAA,EAAWR,OAAA,CAAQQ,SAAS;MAC5BP,WAAA,EAAaA;IACf;EACF;EAEA,IAAIH,gBAAA,CAAiBK,KAAK,CAACC,UAAU,EAAEW,WAAA,EAAa;IAClDb,MAAA,CAAOa,WAAW,GAAGpB,qBAAA,CAAsB;MACzCE,WAAA,EAAa;QACXmB,cAAA,EAAgBlB,gBAAA,CAAiBmB,IAAI;QACrClB;MACF;MACAQ,SAAA,EAAWT,gBAAA,CAAiBK,KAAK,CAACC,UAAU,CAACW,WAAW;MACxDP,SAAA,EAAWR,OAAA,CAAQQ,SAAS;MAC5BP,WAAA,EAAaA;IACf;EACF;EAEA,OAAOC,MAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CollectionConfig, PayloadRequest, ResolvedFilterOptions } from 'payload';
|
|
2
|
+
export declare const resolveAllFilterOptions: ({ collectionConfig, req, }: {
|
|
3
|
+
collectionConfig: CollectionConfig;
|
|
4
|
+
req: PayloadRequest;
|
|
5
|
+
}) => Promise<Map<string, ResolvedFilterOptions>>;
|
|
6
|
+
//# sourceMappingURL=resolveAllFilterOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveAllFilterOptions.d.ts","sourceRoot":"","sources":["../../../src/views/List/resolveAllFilterOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAKtF,eAAO,MAAM,uBAAuB,+BAGjC;IACD,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAyB7C,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { resolveFilterOptions } from '@payloadcms/ui/rsc';
|
|
2
|
+
import { fieldIsHiddenOrDisabled } from 'payload/shared';
|
|
3
|
+
export const resolveAllFilterOptions = async ({
|
|
4
|
+
collectionConfig,
|
|
5
|
+
req
|
|
6
|
+
}) => {
|
|
7
|
+
const resolvedFilterOptions = new Map();
|
|
8
|
+
await Promise.all(collectionConfig.fields.map(async field => {
|
|
9
|
+
if (fieldIsHiddenOrDisabled(field)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if ('name' in field && 'filterOptions' in field && field.filterOptions) {
|
|
13
|
+
const options = await resolveFilterOptions(field.filterOptions, {
|
|
14
|
+
id: undefined,
|
|
15
|
+
blockData: undefined,
|
|
16
|
+
data: {},
|
|
17
|
+
relationTo: field.relationTo,
|
|
18
|
+
req,
|
|
19
|
+
siblingData: {},
|
|
20
|
+
user: req.user
|
|
21
|
+
});
|
|
22
|
+
resolvedFilterOptions.set(field.name, options);
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
return resolvedFilterOptions;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=resolveAllFilterOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveAllFilterOptions.js","names":["resolveFilterOptions","fieldIsHiddenOrDisabled","resolveAllFilterOptions","collectionConfig","req","resolvedFilterOptions","Map","Promise","all","fields","map","field","filterOptions","options","id","undefined","blockData","data","relationTo","siblingData","user","set","name"],"sources":["../../../src/views/List/resolveAllFilterOptions.ts"],"sourcesContent":["import type { CollectionConfig, PayloadRequest, ResolvedFilterOptions } from 'payload'\n\nimport { resolveFilterOptions } from '@payloadcms/ui/rsc'\nimport { fieldIsHiddenOrDisabled } from 'payload/shared'\n\nexport const resolveAllFilterOptions = async ({\n collectionConfig,\n req,\n}: {\n collectionConfig: CollectionConfig\n req: PayloadRequest\n}): Promise<Map<string, ResolvedFilterOptions>> => {\n const resolvedFilterOptions = new Map<string, ResolvedFilterOptions>()\n\n await Promise.all(\n collectionConfig.fields.map(async (field) => {\n if (fieldIsHiddenOrDisabled(field)) {\n return\n }\n\n if ('name' in field && 'filterOptions' in field && field.filterOptions) {\n const options = await resolveFilterOptions(field.filterOptions, {\n id: undefined,\n blockData: undefined,\n data: {}, // use empty object to prevent breaking queries when accessing properties of data\n relationTo: field.relationTo,\n req,\n siblingData: {}, // use empty object to prevent breaking queries when accessing properties of data\n user: req.user,\n })\n resolvedFilterOptions.set(field.name, options)\n }\n }),\n )\n\n return resolvedFilterOptions\n}\n"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,uBAAuB,QAAQ;AAExC,OAAO,MAAMC,uBAAA,GAA0B,MAAAA,CAAO;EAC5CC,gBAAgB;EAChBC;AAAG,CAIJ;EACC,MAAMC,qBAAA,GAAwB,IAAIC,GAAA;EAElC,MAAMC,OAAA,CAAQC,GAAG,CACfL,gBAAA,CAAiBM,MAAM,CAACC,GAAG,CAAC,MAAOC,KAAA;IACjC,IAAIV,uBAAA,CAAwBU,KAAA,GAAQ;MAClC;IACF;IAEA,IAAI,UAAUA,KAAA,IAAS,mBAAmBA,KAAA,IAASA,KAAA,CAAMC,aAAa,EAAE;MACtE,MAAMC,OAAA,GAAU,MAAMb,oBAAA,CAAqBW,KAAA,CAAMC,aAAa,EAAE;QAC9DE,EAAA,EAAIC,SAAA;QACJC,SAAA,EAAWD,SAAA;QACXE,IAAA,EAAM,CAAC;QACPC,UAAA,EAAYP,KAAA,CAAMO,UAAU;QAC5Bd,GAAA;QACAe,WAAA,EAAa,CAAC;QACdC,IAAA,EAAMhB,GAAA,CAAIgB;MACZ;MACAf,qBAAA,CAAsBgB,GAAG,CAACV,KAAA,CAAMW,IAAI,EAAET,OAAA;IACxC;EACF;EAGF,OAAOR,qBAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/LivePreview/Context/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/LivePreview/Context/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAK7D,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAM1D,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAA;IAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,UAAU,CAAC,EAAE;QACX,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,WAAW,EAAE,WAAW,EAAE,CAAA;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,eAAe,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,iBAAiB,CAAC,CAAA;IACtE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAClC,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA6KlE,CAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
import { DndContext } from '@dnd-kit/core';
|
|
5
|
+
import { useConfig } from '@payloadcms/ui';
|
|
5
6
|
import { fieldSchemaToJSON } from 'payload/shared';
|
|
6
7
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
7
8
|
import { customCollisionDetection } from './collisionDetection.js';
|
|
@@ -21,6 +22,9 @@ export const LivePreviewProvider = ({
|
|
|
21
22
|
const [listeningForMessages, setListeningForMessages] = useState(false);
|
|
22
23
|
const iframeRef = React.useRef(null);
|
|
23
24
|
const [iframeHasLoaded, setIframeHasLoaded] = useState(false);
|
|
25
|
+
const {
|
|
26
|
+
config
|
|
27
|
+
} = useConfig();
|
|
24
28
|
const [zoom, setZoom] = useState(1);
|
|
25
29
|
const [position, setPosition] = useState({
|
|
26
30
|
x: 0,
|
|
@@ -36,7 +40,7 @@ export const LivePreviewProvider = ({
|
|
|
36
40
|
});
|
|
37
41
|
const [breakpoint, setBreakpoint] = React.useState('responsive');
|
|
38
42
|
const [fieldSchemaJSON] = useState(() => {
|
|
39
|
-
return fieldSchemaToJSON(fieldSchema);
|
|
43
|
+
return fieldSchemaToJSON(fieldSchema, config);
|
|
40
44
|
});
|
|
41
45
|
// The toolbar needs to freely drag and drop around the page
|
|
42
46
|
const handleDragEnd = ev => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DndContext","fieldSchemaToJSON","React","useCallback","useEffect","useState","customCollisionDetection","LivePreviewContext","sizeReducer","LivePreviewProvider","breakpoints","children","fieldSchema","isPopupOpen","openPopupWindow","popupRef","url","previewWindowType","setPreviewWindowType","appIsReady","setAppIsReady","listeningForMessages","setListeningForMessages","iframeRef","useRef","iframeHasLoaded","setIframeHasLoaded","zoom","setZoom","position","setPosition","x","y","size","setSize","useReducer","height","width","measuredDeviceSize","setMeasuredDeviceSize","breakpoint","setBreakpoint","fieldSchemaJSON","handleDragEnd","ev","over","id","newPos","delta","setWidth","type","value","setHeight","foundBreakpoint","find","bp","name","handleMessage","event","startsWith","origin","data","ready","window","addEventListener","removeEventListener","handleWindowChange","newPreviewWindowType","_jsx","Provider","setToolbarPosition","toolbarPosition","collisionDetection","onDragEnd"],"sources":["../../../../src/views/LivePreview/Context/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, LivePreviewConfig } from 'payload'\n\nimport { DndContext } from '@dnd-kit/core'\nimport { fieldSchemaToJSON } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { usePopupWindow } from '../usePopupWindow.js'\n\nimport { customCollisionDetection } from './collisionDetection.js'\nimport { LivePreviewContext } from './context.js'\nimport { sizeReducer } from './sizeReducer.js'\n\nexport type LivePreviewProviderProps = {\n appIsReady?: boolean\n breakpoints?: LivePreviewConfig['breakpoints']\n children: React.ReactNode\n deviceSize?: {\n height: number\n width: number\n }\n fieldSchema: ClientField[]\n isPopupOpen?: boolean\n openPopupWindow?: ReturnType<typeof usePopupWindow>['openPopupWindow']\n popupRef?: React.RefObject<Window>\n url?: string\n}\n\nexport const LivePreviewProvider: React.FC<LivePreviewProviderProps> = ({\n breakpoints,\n children,\n fieldSchema,\n isPopupOpen,\n openPopupWindow,\n popupRef,\n url,\n}) => {\n const [previewWindowType, setPreviewWindowType] = useState<'iframe' | 'popup'>('iframe')\n\n const [appIsReady, setAppIsReady] = useState(false)\n const [listeningForMessages, setListeningForMessages] = useState(false)\n\n const iframeRef = React.useRef<HTMLIFrameElement>(null)\n\n const [iframeHasLoaded, setIframeHasLoaded] = useState(false)\n\n const [zoom, setZoom] = useState(1)\n\n const [position, setPosition] = useState({ x: 0, y: 0 })\n\n const [size, setSize] = React.useReducer(sizeReducer, { height: 0, width: 0 })\n\n const [measuredDeviceSize, setMeasuredDeviceSize] = useState({\n height: 0,\n width: 0,\n })\n\n const [breakpoint, setBreakpoint] =\n React.useState<LivePreviewConfig['breakpoints'][0]['name']>('responsive')\n\n const [fieldSchemaJSON] = useState(() => {\n return fieldSchemaToJSON(fieldSchema)\n })\n\n // The toolbar needs to freely drag and drop around the page\n const handleDragEnd = (ev) => {\n // only update position if the toolbar is completely within the preview area\n // otherwise reset it back to the previous position\n // TODO: reset to the nearest edge of the preview area\n if (ev.over && ev.over.id === 'live-preview-area') {\n const newPos = {\n x: position.x + ev.delta.x,\n y: position.y + ev.delta.y,\n }\n\n setPosition(newPos)\n } else {\n // reset\n }\n }\n\n const setWidth = useCallback(\n (width) => {\n setSize({ type: 'width', value: width })\n },\n [setSize],\n )\n\n const setHeight = useCallback(\n (height) => {\n setSize({ type: 'height', value: height })\n },\n [setSize],\n )\n\n // explicitly set new width and height when as new breakpoints are selected\n // exclude `custom` breakpoint as it is handled by the `setWidth` and `setHeight` directly\n useEffect(() => {\n const foundBreakpoint = breakpoints?.find((bp) => bp.name === breakpoint)\n\n if (\n foundBreakpoint &&\n breakpoint !== 'responsive' &&\n breakpoint !== 'custom' &&\n typeof foundBreakpoint?.width === 'number' &&\n typeof foundBreakpoint?.height === 'number'\n ) {\n setSize({\n type: 'reset',\n value: {\n height: foundBreakpoint.height,\n width: foundBreakpoint.width,\n },\n })\n }\n }, [breakpoint, breakpoints])\n\n // Receive the `ready` message from the popup window\n // This indicates that the app is ready to receive `window.postMessage` events\n // This is also the only cross-origin way of detecting when a popup window has loaded\n // Unlike iframe elements which have an `onLoad` handler, there is no way to access `window.open` on popups\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n if (\n url?.startsWith(event.origin) &&\n event.data &&\n typeof event.data === 'object' &&\n event.data.type === 'payload-live-preview'\n ) {\n if (event.data.ready) {\n setAppIsReady(true)\n }\n }\n }\n\n window.addEventListener('message', handleMessage)\n\n setListeningForMessages(true)\n\n return () => {\n window.removeEventListener('message', handleMessage)\n }\n }, [url, listeningForMessages])\n\n const handleWindowChange = useCallback(\n (type: 'iframe' | 'popup') => {\n setAppIsReady(false)\n setPreviewWindowType(type)\n if (type === 'popup') {\n openPopupWindow()\n }\n },\n [openPopupWindow],\n )\n\n // when the user closes the popup window, switch back to the iframe\n // the `usePopupWindow` reports the `isPopupOpen` state for us to use here\n useEffect(() => {\n const newPreviewWindowType = isPopupOpen ? 'popup' : 'iframe'\n\n if (newPreviewWindowType !== previewWindowType) {\n handleWindowChange('iframe')\n }\n }, [previewWindowType, isPopupOpen, handleWindowChange])\n\n return (\n <LivePreviewContext.Provider\n value={{\n appIsReady,\n breakpoint,\n breakpoints,\n fieldSchemaJSON,\n iframeHasLoaded,\n iframeRef,\n isPopupOpen,\n measuredDeviceSize,\n openPopupWindow,\n popupRef,\n previewWindowType,\n setAppIsReady,\n setBreakpoint,\n setHeight,\n setIframeHasLoaded,\n setMeasuredDeviceSize,\n setPreviewWindowType: handleWindowChange,\n setSize,\n setToolbarPosition: setPosition,\n setWidth,\n setZoom,\n size,\n toolbarPosition: position,\n url,\n zoom,\n }}\n >\n <DndContext collisionDetection={customCollisionDetection} onDragEnd={handleDragEnd}>\n {listeningForMessages && children}\n </DndContext>\n </LivePreviewContext.Provider>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,UAAU,QAAQ;AAC3B,SAASC,iBAAiB,QAAQ;AAClC,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAIxD,SAASC,wBAAwB,QAAQ;AACzC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,WAAW,QAAQ;AAiB5B,OAAO,MAAMC,mBAAA,GAA0DA,CAAC;EACtEC,WAAW;EACXC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,eAAe;EACfC,QAAQ;EACRC;AAAG,CACJ;EACC,MAAM,CAACC,iBAAA,EAAmBC,oBAAA,CAAqB,GAAGb,QAAA,CAA6B;EAE/E,MAAM,CAACc,UAAA,EAAYC,aAAA,CAAc,GAAGf,QAAA,CAAS;EAC7C,MAAM,CAACgB,oBAAA,EAAsBC,uBAAA,CAAwB,GAAGjB,QAAA,CAAS;EAEjE,MAAMkB,SAAA,GAAYrB,KAAA,CAAMsB,MAAM,CAAoB;EAElD,MAAM,CAACC,eAAA,EAAiBC,kBAAA,CAAmB,GAAGrB,QAAA,CAAS;EAEvD,MAAM,CAACsB,IAAA,EAAMC,OAAA,CAAQ,GAAGvB,QAAA,CAAS;EAEjC,MAAM,CAACwB,QAAA,EAAU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D,iBAAA,EAAmB;MAC9CiD,kBAAA,CAAmB;IACrB;EACF,GAAG,CAACjD,iBAAA,EAAmBJ,WAAA,EAAaqD,kBAAA,CAAmB;EAEvD,oBACEE,IAAA,CAAC7D,kBAAA,CAAmB8D,QAAQ;IAC1BlB,KAAA,EAAO;MACLhC,UAAA;MACAqB,UAAA;MACA9B,WAAA;MACAgC,eAAA;MACAjB,eAAA;MACAF,SAAA;MACAV,WAAA;MACAyB,kBAAA;MACAxB,eAAA;MACAC,QAAA;MACAE,iBAAA;MACAG,aAAA;MACAqB,aAAA;MACAW,SAAA;MACA1B,kBAAA;MACAa,qBAAA;MACArB,oBAAA,EAAsBgD,kBAAA;MACtBhC,OAAA;MACAoC,kBAAA,EAAoBxC,WAAA;MACpBmB,QAAA;MACArB,OAAA;MACAK,IAAA;MACAsC,eAAA,EAAiB1C,QAAA;MACjBb,GAAA;MACAW;IACF;cAEA,aAAAyC,IAAA,CAACpE,UAAA;MAAWwE,kBAAA,EAAoBlE,wBAAA;MAA0BmE,SAAA,EAAW9B,aAAA;gBAClEtB,oBAAA,IAAwBV;;;AAIjC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DndContext","useConfig","fieldSchemaToJSON","React","useCallback","useEffect","useState","customCollisionDetection","LivePreviewContext","sizeReducer","LivePreviewProvider","breakpoints","children","fieldSchema","isPopupOpen","openPopupWindow","popupRef","url","previewWindowType","setPreviewWindowType","appIsReady","setAppIsReady","listeningForMessages","setListeningForMessages","iframeRef","useRef","iframeHasLoaded","setIframeHasLoaded","config","zoom","setZoom","position","setPosition","x","y","size","setSize","useReducer","height","width","measuredDeviceSize","setMeasuredDeviceSize","breakpoint","setBreakpoint","fieldSchemaJSON","handleDragEnd","ev","over","id","newPos","delta","setWidth","type","value","setHeight","foundBreakpoint","find","bp","name","handleMessage","event","startsWith","origin","data","ready","window","addEventListener","removeEventListener","handleWindowChange","newPreviewWindowType","_jsx","Provider","setToolbarPosition","toolbarPosition","collisionDetection","onDragEnd"],"sources":["../../../../src/views/LivePreview/Context/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, LivePreviewConfig } from 'payload'\n\nimport { DndContext } from '@dnd-kit/core'\nimport { useConfig } from '@payloadcms/ui'\nimport { fieldSchemaToJSON } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { usePopupWindow } from '../usePopupWindow.js'\n\nimport { customCollisionDetection } from './collisionDetection.js'\nimport { LivePreviewContext } from './context.js'\nimport { sizeReducer } from './sizeReducer.js'\n\nexport type LivePreviewProviderProps = {\n appIsReady?: boolean\n breakpoints?: LivePreviewConfig['breakpoints']\n children: React.ReactNode\n deviceSize?: {\n height: number\n width: number\n }\n fieldSchema: ClientField[]\n isPopupOpen?: boolean\n openPopupWindow?: ReturnType<typeof usePopupWindow>['openPopupWindow']\n popupRef?: React.RefObject<Window>\n url?: string\n}\n\nexport const LivePreviewProvider: React.FC<LivePreviewProviderProps> = ({\n breakpoints,\n children,\n fieldSchema,\n isPopupOpen,\n openPopupWindow,\n popupRef,\n url,\n}) => {\n const [previewWindowType, setPreviewWindowType] = useState<'iframe' | 'popup'>('iframe')\n\n const [appIsReady, setAppIsReady] = useState(false)\n const [listeningForMessages, setListeningForMessages] = useState(false)\n\n const iframeRef = React.useRef<HTMLIFrameElement>(null)\n\n const [iframeHasLoaded, setIframeHasLoaded] = useState(false)\n const { config } = useConfig()\n\n const [zoom, setZoom] = useState(1)\n\n const [position, setPosition] = useState({ x: 0, y: 0 })\n\n const [size, setSize] = React.useReducer(sizeReducer, { height: 0, width: 0 })\n\n const [measuredDeviceSize, setMeasuredDeviceSize] = useState({\n height: 0,\n width: 0,\n })\n\n const [breakpoint, setBreakpoint] =\n React.useState<LivePreviewConfig['breakpoints'][0]['name']>('responsive')\n\n const [fieldSchemaJSON] = useState(() => {\n return fieldSchemaToJSON(fieldSchema, config)\n })\n\n // The toolbar needs to freely drag and drop around the page\n const handleDragEnd = (ev) => {\n // only update position if the toolbar is completely within the preview area\n // otherwise reset it back to the previous position\n // TODO: reset to the nearest edge of the preview area\n if (ev.over && ev.over.id === 'live-preview-area') {\n const newPos = {\n x: position.x + ev.delta.x,\n y: position.y + ev.delta.y,\n }\n\n setPosition(newPos)\n } else {\n // reset\n }\n }\n\n const setWidth = useCallback(\n (width) => {\n setSize({ type: 'width', value: width })\n },\n [setSize],\n )\n\n const setHeight = useCallback(\n (height) => {\n setSize({ type: 'height', value: height })\n },\n [setSize],\n )\n\n // explicitly set new width and height when as new breakpoints are selected\n // exclude `custom` breakpoint as it is handled by the `setWidth` and `setHeight` directly\n useEffect(() => {\n const foundBreakpoint = breakpoints?.find((bp) => bp.name === breakpoint)\n\n if (\n foundBreakpoint &&\n breakpoint !== 'responsive' &&\n breakpoint !== 'custom' &&\n typeof foundBreakpoint?.width === 'number' &&\n typeof foundBreakpoint?.height === 'number'\n ) {\n setSize({\n type: 'reset',\n value: {\n height: foundBreakpoint.height,\n width: foundBreakpoint.width,\n },\n })\n }\n }, [breakpoint, breakpoints])\n\n // Receive the `ready` message from the popup window\n // This indicates that the app is ready to receive `window.postMessage` events\n // This is also the only cross-origin way of detecting when a popup window has loaded\n // Unlike iframe elements which have an `onLoad` handler, there is no way to access `window.open` on popups\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n if (\n url?.startsWith(event.origin) &&\n event.data &&\n typeof event.data === 'object' &&\n event.data.type === 'payload-live-preview'\n ) {\n if (event.data.ready) {\n setAppIsReady(true)\n }\n }\n }\n\n window.addEventListener('message', handleMessage)\n\n setListeningForMessages(true)\n\n return () => {\n window.removeEventListener('message', handleMessage)\n }\n }, [url, listeningForMessages])\n\n const handleWindowChange = useCallback(\n (type: 'iframe' | 'popup') => {\n setAppIsReady(false)\n setPreviewWindowType(type)\n if (type === 'popup') {\n openPopupWindow()\n }\n },\n [openPopupWindow],\n )\n\n // when the user closes the popup window, switch back to the iframe\n // the `usePopupWindow` reports the `isPopupOpen` state for us to use here\n useEffect(() => {\n const newPreviewWindowType = isPopupOpen ? 'popup' : 'iframe'\n\n if (newPreviewWindowType !== previewWindowType) {\n handleWindowChange('iframe')\n }\n }, [previewWindowType, isPopupOpen, handleWindowChange])\n\n return (\n <LivePreviewContext.Provider\n value={{\n appIsReady,\n breakpoint,\n breakpoints,\n fieldSchemaJSON,\n iframeHasLoaded,\n iframeRef,\n isPopupOpen,\n measuredDeviceSize,\n openPopupWindow,\n popupRef,\n previewWindowType,\n setAppIsReady,\n setBreakpoint,\n setHeight,\n setIframeHasLoaded,\n setMeasuredDeviceSize,\n setPreviewWindowType: handleWindowChange,\n setSize,\n setToolbarPosition: setPosition,\n setWidth,\n setZoom,\n size,\n toolbarPosition: position,\n url,\n zoom,\n }}\n >\n <DndContext collisionDetection={customCollisionDetection} onDragEnd={handleDragEnd}>\n {listeningForMessages && children}\n </DndContext>\n </LivePreviewContext.Provider>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,UAAU,QAAQ;AAC3B,SAASC,SAAS,QAAQ;AAC1B,SAASC,iBAAiB,QAAQ;AAClC,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAIxD,SAASC,wBAAwB,QAAQ;AACzC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,WAAW,QAAQ;AAiB5B,OAAO,MAAMC,mBAAA,GAA0DA,CAAC;EACtEC,WAAW;EACXC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,eAAe;EACfC,QAAQ;EACRC;AAAG,CACJ;EACC,MAAM,CAACC,iBAAA,EAAmBC,oBAAA,CAAqB,GAAGb,QAAA,CAA6B;EAE/E,MAAM,CAACc,UAAA,EAAYC,aAAA,CAAc,GAAGf,QAAA,CAAS;EAC7C,MAAM,CAACgB,oBAAA,EAAsBC,uBAAA,CAAwB,GAAGjB,QAAA,CAAS;EAEjE,MAAMkB,SAAA,GAAYrB,KAAA,CAAMsB,MAAM,CAAoB;EAElD,MAAM,CAACC,eAAA,EAAiBC,kBAAA,C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ACrB,IAAIA,IAAA,KAAS,SAAS;MACpBrC,eAAA;IACF;EACF,GACA,CAACA,eAAA,CAAgB;EAGnB;EACA;EACAV,SAAA,CAAU;IACR,MAAMgE,oBAAA,GAAuBvD,WAAA,GAAc,UAAU;IAErD,IAAIuD,oBAAA,KAAyBnD,iBAAA,EAAmB;MAC9CkD,kBAAA,CAAmB;IACrB;EACF,GAAG,CAAClD,iBAAA,EAAmBJ,WAAA,EAAasD,kBAAA,CAAmB;EAEvD,oBACEE,IAAA,CAAC9D,kBAAA,CAAmB+D,QAAQ;IAC1BlB,KAAA,EAAO;MACLjC,UAAA;MACAsB,UAAA;MACA/B,WAAA;MACAiC,eAAA;MACAlB,eAAA;MACAF,SAAA;MACAV,WAAA;MACA0B,kBAAA;MACAzB,eAAA;MACAC,QAAA;MACAE,iBAAA;MACAG,aAAA;MACAsB,aAAA;MACAW,SAAA;MACA3B,kBAAA;MACAc,qBAAA;MACAtB,oBAAA,EAAsBiD,kBAAA;MACtBhC,OAAA;MACAoC,kBAAA,EAAoBxC,WAAA;MACpBmB,QAAA;MACArB,OAAA;MACAK,IAAA;MACAsC,eAAA,EAAiB1C,QAAA;MACjBd,GAAA;MACAY;IACF;cAEA,aAAAyC,IAAA,CAACtE,UAAA;MAAW0E,kBAAA,EAAoBnE,wBAAA;MAA0BoE,SAAA,EAAW9B,aAAA;gBAClEvB,oBAAA,IAAwBV;;;AAIjC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/views/LivePreview/index.client.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAMV,IAAI,EACJ,aAAa,EAEb,iBAAiB,EAClB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/views/LivePreview/index.client.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAMV,IAAI,EACJ,aAAa,EAEb,iBAAiB,EAClB,MAAM,SAAS,CAAA;AAgChB,OAAO,KAA6D,MAAM,OAAO,CAAA;AAGjF,OAAO,cAAc,CAAA;AAggBrB,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CACtC;IACE,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAA;IACtD,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAA;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB,GAAG,aAAa,CA0DlB,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
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 { DocumentControls, DocumentFields, DocumentLocked, DocumentTakeOver, Form, LeaveWithoutSaving, OperationProvider, SetDocumentStepNav, SetDocumentTitle, useAuth, useConfig, useDocumentDrawerContext, useDocumentEvents, useDocumentInfo, useEditDepth, useServerFunctions, useTranslation, useUploadEdits } from '@payloadcms/ui';
|
|
5
|
+
import { DocumentControls, DocumentFields, DocumentLocked, DocumentTakeOver, Form, LeaveWithoutSaving, OperationProvider, SetDocumentStepNav, SetDocumentTitle, useAuth, useConfig, useDocumentDrawerContext, useDocumentEvents, useDocumentInfo, useEditDepth, useRouteTransition, useServerFunctions, useTranslation, useUploadEdits } from '@payloadcms/ui';
|
|
6
6
|
import { abortAndIgnore, formatAdminURL, handleAbortRef, handleBackToDashboard, handleGoBack, handleTakeOver } from '@payloadcms/ui/shared';
|
|
7
7
|
import { useRouter, useSearchParams } from 'next/navigation.js';
|
|
8
8
|
import React, { Fragment, useCallback, useEffect, useRef, useState } from 'react';
|
|
@@ -96,6 +96,9 @@ const PreviewView = ({
|
|
|
96
96
|
const {
|
|
97
97
|
getFormState
|
|
98
98
|
} = useServerFunctions();
|
|
99
|
+
const {
|
|
100
|
+
startRouteTransition
|
|
101
|
+
} = useRouteTransition();
|
|
99
102
|
const docConfig = collectionConfig || globalConfig;
|
|
100
103
|
const entitySlug = collectionConfig?.slug || globalConfig?.slug;
|
|
101
104
|
const depth = useEditDepth();
|
|
@@ -147,7 +150,7 @@ const PreviewView = ({
|
|
|
147
150
|
adminRoute,
|
|
148
151
|
path: `/collections/${collectionSlug}/${json?.doc?.id}${locale ? `?locale=${locale}` : ''}`
|
|
149
152
|
});
|
|
150
|
-
router.push(redirectRoute);
|
|
153
|
+
startRouteTransition(() => router.push(redirectRoute));
|
|
151
154
|
} else {
|
|
152
155
|
resetUploadEdits();
|
|
153
156
|
}
|
|
@@ -177,7 +180,7 @@ const PreviewView = ({
|
|
|
177
180
|
abortOnSaveRef.current = null;
|
|
178
181
|
return state;
|
|
179
182
|
}
|
|
180
|
-
}, [adminRoute, collectionSlug, depth, docPermissions, entitySlug, getDocPermissions, getDocPreferences, getFormState, globalSlug, id, incrementVersionCount, isEditing, isLockingEnabled, locale, onSaveFromContext, operation, refreshCookieAsync, reportUpdate, resetUploadEdits, router, setDocumentIsLocked, updateSavedDocumentData, user, userSlug, autosaveEnabled]);
|
|
183
|
+
}, [adminRoute, collectionSlug, depth, docPermissions, entitySlug, getDocPermissions, getDocPreferences, getFormState, globalSlug, id, incrementVersionCount, isEditing, isLockingEnabled, locale, onSaveFromContext, operation, refreshCookieAsync, reportUpdate, resetUploadEdits, router, setDocumentIsLocked, updateSavedDocumentData, startRouteTransition, user, userSlug, autosaveEnabled]);
|
|
181
184
|
const onChange = useCallback(async ({
|
|
182
185
|
formState: prevFormState,
|
|
183
186
|
submitted
|