@payloadcms/next 3.59.0-internal.5d79493 → 3.59.0-internal.6aee982

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.
@@ -6,7 +6,7 @@ export async function getRequestLocale({
6
6
  }) {
7
7
  if (req.payload.config.localization) {
8
8
  const localeFromParams = req.query.locale;
9
- if (localeFromParams) {
9
+ if (req.user && localeFromParams) {
10
10
  await upsertPreferences({
11
11
  key: 'locale',
12
12
  req,
@@ -1 +1 @@
1
- {"version":3,"file":"getRequestLocale.js","names":["upsertPreferences","findLocaleFromCode","getPreferences","getRequestLocale","req","payload","config","localization","localeFromParams","query","locale","key","value","user","id","collection","defaultLocale","undefined"],"sources":["../../src/utilities/getRequestLocale.ts"],"sourcesContent":["import type { Locale, PayloadRequest } from 'payload'\n\nimport { upsertPreferences } from '@payloadcms/ui/rsc'\nimport { findLocaleFromCode } from '@payloadcms/ui/shared'\n\nimport { getPreferences } from './getPreferences.js'\n\ntype GetRequestLocalesArgs = {\n req: PayloadRequest\n}\n\nexport async function getRequestLocale({ req }: GetRequestLocalesArgs): Promise<Locale> {\n if (req.payload.config.localization) {\n const localeFromParams = req.query.locale as string | undefined\n\n if (localeFromParams) {\n await upsertPreferences<Locale['code']>({ key: 'locale', req, value: localeFromParams })\n }\n\n return (\n (req.user &&\n findLocaleFromCode(\n req.payload.config.localization,\n localeFromParams ||\n (\n await getPreferences<Locale['code']>(\n 'locale',\n req.payload,\n req.user.id,\n req.user.collection,\n )\n )?.value,\n )) ||\n findLocaleFromCode(\n req.payload.config.localization,\n req.payload.config.localization.defaultLocale || 'en',\n )\n )\n }\n\n return undefined\n}\n"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AAEnC,SAASC,cAAc,QAAQ;AAM/B,OAAO,eAAeC,iBAAiB;EAAEC;AAAG,CAAyB;EACnE,IAAIA,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;IACnC,MAAMC,gBAAA,GAAmBJ,GAAA,CAAIK,KAAK,CAACC,MAAM;IAEzC,IAAIF,gBAAA,EAAkB;MACpB,MAAMR,iBAAA,CAAkC;QAAEW,GAAA,EAAK;QAAUP,GAAA;QAAKQ,KAAA,EAAOJ;MAAiB;IACxF;IAEA,OACEJ,GAAC,CAAIS,IAAI,IACPZ,kBAAA,CACEG,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BC,gBAAA,IAEI,OAAMN,cAAA,CACJ,UACAE,GAAA,CAAIC,OAAO,EACXD,GAAA,CAAIS,IAAI,CAACC,EAAE,EACXV,GAAA,CAAIS,IAAI,CAACE,UAAU,CACrB,GACCH,KAAA,KAETX,kBAAA,CACEG,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BH,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,CAACS,aAAa,IAAI;EAGvD;EAEA,OAAOC,SAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"getRequestLocale.js","names":["upsertPreferences","findLocaleFromCode","getPreferences","getRequestLocale","req","payload","config","localization","localeFromParams","query","locale","user","key","value","id","collection","defaultLocale","undefined"],"sources":["../../src/utilities/getRequestLocale.ts"],"sourcesContent":["import type { Locale, PayloadRequest } from 'payload'\n\nimport { upsertPreferences } from '@payloadcms/ui/rsc'\nimport { findLocaleFromCode } from '@payloadcms/ui/shared'\n\nimport { getPreferences } from './getPreferences.js'\n\ntype GetRequestLocalesArgs = {\n req: PayloadRequest\n}\n\nexport async function getRequestLocale({ req }: GetRequestLocalesArgs): Promise<Locale> {\n if (req.payload.config.localization) {\n const localeFromParams = req.query.locale as string | undefined\n\n if (req.user && localeFromParams) {\n await upsertPreferences<Locale['code']>({ key: 'locale', req, value: localeFromParams })\n }\n\n return (\n (req.user &&\n findLocaleFromCode(\n req.payload.config.localization,\n localeFromParams ||\n (\n await getPreferences<Locale['code']>(\n 'locale',\n req.payload,\n req.user.id,\n req.user.collection,\n )\n )?.value,\n )) ||\n findLocaleFromCode(\n req.payload.config.localization,\n req.payload.config.localization.defaultLocale || 'en',\n )\n )\n }\n\n return undefined\n}\n"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AAEnC,SAASC,cAAc,QAAQ;AAM/B,OAAO,eAAeC,iBAAiB;EAAEC;AAAG,CAAyB;EACnE,IAAIA,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;IACnC,MAAMC,gBAAA,GAAmBJ,GAAA,CAAIK,KAAK,CAACC,MAAM;IAEzC,IAAIN,GAAA,CAAIO,IAAI,IAAIH,gBAAA,EAAkB;MAChC,MAAMR,iBAAA,CAAkC;QAAEY,GAAA,EAAK;QAAUR,GAAA;QAAKS,KAAA,EAAOL;MAAiB;IACxF;IAEA,OACEJ,GAAC,CAAIO,IAAI,IACPV,kBAAA,CACEG,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BC,gBAAA,IAEI,OAAMN,cAAA,CACJ,UACAE,GAAA,CAAIC,OAAO,EACXD,GAAA,CAAIO,IAAI,CAACG,EAAE,EACXV,GAAA,CAAIO,IAAI,CAACI,UAAU,CACrB,GACCF,KAAA,KAETZ,kBAAA,CACEG,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,EAC/BH,GAAA,CAAIC,OAAO,CAACC,MAAM,CAACC,YAAY,CAACS,aAAa,IAAI;EAGvD;EAEA,OAAOC,SAAA;AACT","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Document/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,IAAI,EACJ,uBAAuB,EACvB,uBAAuB,EAEvB,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EACjC,MAAM,SAAS,CAAA;AAehB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OA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B,CAAC,GACzC,KAAK,CAAC,EAAE,GACR,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,6PAgBxB;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IACtC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IACtC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;IACzC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IACvC,QAAQ,CAAC,EAAE,gCAAgC,CAAA;CAC5C,GAAG,oBAAoB,KAAG,OAAO,CAAC;IACjC,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAoVA,CAAA;AAED,wBAAsB,QAAQ,CAAC,KAAK,EAAE,oBAAoB,+QAezD"}
@@ -311,7 +311,7 @@ export const renderDocument = async ({
311
311
  children: /*#__PURE__*/_jsxs(LivePreviewProvider, {
312
312
  breakpoints: livePreviewConfig?.breakpoints,
313
313
  isLivePreviewEnabled: isLivePreviewEnabled && operation !== 'create',
314
- isLivePreviewing: entityPreferences?.value?.editViewType === 'live-preview',
314
+ isLivePreviewing: Boolean(entityPreferences?.value?.editViewType === 'live-preview' && livePreviewURL),
315
315
  typeofLivePreviewURL: typeof livePreviewConfig?.url,
316
316
  url: livePreviewURL,
317
317
  children: [showHeader && !drawerSlug && /*#__PURE__*/_jsx(DocumentHeader, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","logError","formatAdminURL","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","serverURL","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","deletedAt","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","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","drafts","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","autosave","validateDraftData","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","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 } 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 { logError } from 'payload'\nimport { formatAdminURL } 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 serverURL,\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 serverURL,\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 = typeof doc?.deletedAt === 'string'\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\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\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req,\n }),\n\n // Fetch document lock state\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req,\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 (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\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 = collectionSlug\n ? `${serverURL}${apiRoute}/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\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 =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\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 serverURL,\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 permissions: docPermissions,\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 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 hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\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={entityPreferences?.value?.editViewType === 'live-preview'}\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 Document(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,QAAQ;AAClC,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;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MAAMD,KAAA;IACR;IAEA3I,QAAA,CAAS;MAAE6I,GAAA,EAAKF,KAAA;MAAOnG,OAAA,EAASiG,KAAA,CAAMnH,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAImG,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjC9I,QAAA;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","logError","formatAdminURL","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","serverURL","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","deletedAt","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","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","drafts","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","autosave","validateDraftData","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","Boolean","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","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 } 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 { logError } from 'payload'\nimport { formatAdminURL } 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 serverURL,\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 serverURL,\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 = typeof doc?.deletedAt === 'string'\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\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\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req,\n }),\n\n // Fetch document lock state\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req,\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 (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\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 = collectionSlug\n ? `${serverURL}${apiRoute}/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\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 =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\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 serverURL,\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 permissions: docPermissions,\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 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 hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\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 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 Document(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,QAAQ;AAClC,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,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,CAAO;EACnCC,cAAc;EACdC,mBAAmB;EACnBC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,cAAc;EACdC,wBAAwB;EACxBC,MAAM;EACNC,mBAAmB;EACnBC,mBAAmB;EACnBC,sBAAsB;EACtBC,oBAAoB;EACpBC,YAAY;EACZC,QAAQ;EACRC;AAAQ,CASc;EAItB,MAAM;IACJC,gBAAgB;IAChBC,KAAA,EAAOC,UAAU;IACjBC,YAAY;IACZC,MAAM;IACNC,WAAW;IACXC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QACPC,MAAM;QACNA,MAAA,E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aA,WAAA;UACbC,GAAA,EAAKA;yBAGTuF,IAAA,CAACtI,mBAAA;UAAoB8C,WAAA,EAAaA;yBAClCwF,IAAA,CAACvI,iBAAA;oBACEG,qBAAA,CAAsB;YACrB+H,WAAA;YACAV,SAAA,EAAWP,IAAA;YACXnF,SAAA;YACAqH,WAAA,EAAa/C;UACf;;;OAnCCtD,MAAA,EAAQgD,IAAA;EAwCnB;AACF;AAEA,OAAO,eAAewC,SAASc,KAA2B;EACxD,IAAI;IACF,MAAM;MAAEd,QAAA,EAAUe;IAAgB,CAAE,GAAG,MAAM3H,cAAA,CAAe0H,KAAA;IAC5D,OAAOC,gBAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,EAAOC,OAAA,KAAY,iBAAiB;MACtC,MAAMD,KAAA;IACR;IAEA5I,QAAA,CAAS;MAAE8I,GAAA,EAAKF,KAAA;MAAOpG,OAAA,EAASkG,KAAA,CAAMpH,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAIoG,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjC/I,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,cAAc,EAGd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EAGrB,cAAc,EAKf,MAAM,SAAS,CAAA;AAOhB,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,WAAW,EAAE,4BAA4B,CAAA;IACzC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,aA2IL,CAAA;AAED,eAAO,MAAM,0BAA0B,EAAE,cAAc,CAAC;IACtD,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAsBA,CAAA"}
1
+ {"version":3,"file":"renderDocumentSlots.d.ts","sourceRoot":"","sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEb,cAAc,EAGd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EAGrB,cAAc,EAKf,MAAM,SAAS,CAAA;AAOhB,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,WAAW,EAAE,4BAA4B,CAAA;IACzC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,aAuJL,CAAA;AAED,eAAO,MAAM,0BAA0B,EAAE,cAAc,CAAC;IACtD,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAsBA,CAAA"}
@@ -42,6 +42,14 @@ export const renderDocumentSlots = args => {
42
42
  serverProps: serverProps
43
43
  });
44
44
  }
45
+ const LivePreview = collectionConfig?.admin?.components?.views?.edit?.livePreview || globalConfig?.admin?.components?.views?.edit?.livePreview;
46
+ if (LivePreview?.Component) {
47
+ components.LivePreview = RenderServerComponent({
48
+ Component: LivePreview.Component,
49
+ importMap: req.payload.importMap,
50
+ serverProps
51
+ });
52
+ }
45
53
  const descriptionFromConfig = collectionConfig?.admin?.description || globalConfig?.admin?.description;
46
54
  const staticDescription = typeof descriptionFromConfig === 'function' ? descriptionFromConfig({
47
55
  t: req.i18n.t
@@ -1 +1 @@
1
- {"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","user","BeforeDocumentControls","edit","beforeDocumentControls","elements","Component","importMap","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomPublishButton","PublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","autosave","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","docPermissions","data","permissions"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\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 permissions: SanitizedDocumentPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, 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 payload: req.payload,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.elements?.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 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?.elements?.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 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 ||\n globalConfig?.admin?.components?.elements?.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 (hasSavePermission) {\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.elements?.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 CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.elements?.SaveDraftButton\n\n const draftsEnabled =\n (collectionConfig?.versions?.drafts && !collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && !globalConfig?.versions?.drafts?.autosave)\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?.elements?.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, 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 { docPermissions, hasSavePermission } = await getDocumentPermissions({\n collectionConfig,\n data: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nD;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzEI,gBAAA;IACAsD,IAAA,EAAM,CAAC;IACPnD;EACF;EAEA,OAAON,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACAqD,WAAA,EAAaF,cAAA;IACblD;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","user","BeforeDocumentControls","edit","beforeDocumentControls","elements","Component","importMap","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","LivePreview","views","livePreview","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomPublishButton","PublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","autosave","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","docPermissions","data","permissions"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\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 permissions: SanitizedDocumentPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, 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 payload: req.payload,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.elements?.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 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?.elements?.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 ||\n globalConfig?.admin?.components?.elements?.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 (hasSavePermission) {\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.elements?.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 CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.elements?.SaveDraftButton\n\n const draftsEnabled =\n (collectionConfig?.versions?.drafts && !collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && !globalConfig?.versions?.drafts?.autosave)\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?.elements?.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, 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 { docPermissions, hasSavePermission } = await getDocumentPermissions({\n collectionConfig,\n data: {},\n req,\n })\n\n return renderDocumentSlots({\n id,\n collectionConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n}\n"],"mappings":"AAmBA,SAASA,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AAEtC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,mBAAA,GAOUC,IAAA;EACrB,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,iBAAiB;IAAEC;EAAG,CAAE,GAAGL,IAAA;EAEvE,MAAMM,UAAA,GAA4B,CAAC;EAEnC,MAAMC,2BAAA,GAA8BC,SAAA;EAEpC,MAAMC,gBAAA,GAAmBP,gBAAA,EAAkBQ,KAAA,EAAOC,OAAA,IAAWR,YAAA,EAAcO,KAAA,EAAOC,OAAA;EAElF,MAAMC,WAAA,GAA2B;IAC/BX,EAAA;IACAY,IAAA,EAAMR,GAAA,CAAIQ,IAAI;IACdC,OAAA,EAAST,GAAA,CAAIS,OAAO;IACpBC,IAAA,EAAMV,GAAA,CAAIU;EAEZ;EAEA,MAAMC,sBAAA,GACJd,gBAAA,EAAkBQ,KAAA,EAAOJ,UAAA,EAAYW,IAAA,EAAMC,sBAAA,IAC3Cf,YAAA,EAAcO,KAAA,EAAOJ,UAAA,EAAYa,QAAA,EAAUD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CAAiBQ,KAAK,CAACJ,UAAU,CAACW,IAAI,CAACkC,MAAM;MACxD9B,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChCT;IACF;EACF;EAEA,IAAIV,gBAAA,EAAkBgD,MAAA,IAAUhD,gBAAA,CAAiBgD,MAAM,CAACxC,KAAK,EAAEJ,UAAA,EAAY8C,QAAA,EAAU;IACnF9C,UAAA,CAAW+C,cAAc,GAAGxD,qBAAA,CAAsB;MAChDuB,SAAA,EAAWlB,gBAAA,CAAiBgD,MAAM,CAACxC,KAAK,CAACJ,UAAU,CAAC8C,QAAQ;MAC5D/B,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChCT;IACF;EACF;EAEA,OAAON,UAAA;AACT;AAEA,OAAO,MAAMgD,0BAAA,GAGR,MAAOtD,IAAA;EACV,MAAM;IAAEC,EAAE;IAAEoC,cAAc;IAAEhC;EAAG,CAAE,GAAGL,IAAA;EAEpC,MAAME,gBAAA,GAAmBG,GAAA,CAAIS,OAAO,CAACyC,WAAW,CAAClB,cAAA,CAAe,EAAEmB,MAAA;EAElE,IAAI,CAACtD,gBAAA,EAAkB;IACrB,MAAM,IAAIuD,KAAA,CAAMpD,GAAA,CAAI2B,CAAC,CAAC;EACxB;EAEA,MAAM;IAAE0B,cAAc;IAAEtD;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzEI,gBAAA;IACAyD,IAAA,EAAM,CAAC;IACPtD;EACF;EAEA,OAAON,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACAwD,WAAA,EAAaF,cAAA;IACbrD;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "3.59.0-internal.5d79493",
3
+ "version": "3.59.0-internal.6aee982",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -87,9 +87,9 @@
87
87
  "qs-esm": "7.0.2",
88
88
  "sass": "1.77.4",
89
89
  "uuid": "10.0.0",
90
- "@payloadcms/graphql": "3.59.0-internal.5d79493",
91
- "@payloadcms/translations": "3.59.0-internal.5d79493",
92
- "@payloadcms/ui": "3.59.0-internal.5d79493"
90
+ "@payloadcms/graphql": "3.59.0-internal.6aee982",
91
+ "@payloadcms/translations": "3.59.0-internal.6aee982",
92
+ "@payloadcms/ui": "3.59.0-internal.6aee982"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@babel/cli": "7.27.2",
@@ -107,12 +107,12 @@
107
107
  "esbuild-sass-plugin": "3.3.1",
108
108
  "swc-plugin-transform-remove-imports": "4.0.4",
109
109
  "@payloadcms/eslint-config": "3.28.0",
110
- "payload": "3.59.0-internal.5d79493"
110
+ "payload": "3.59.0-internal.6aee982"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "graphql": "^16.8.1",
114
114
  "next": "^15.2.3",
115
- "payload": "3.59.0-internal.5d79493"
115
+ "payload": "3.59.0-internal.6aee982"
116
116
  },
117
117
  "engines": {
118
118
  "node": "^18.20.2 || >=20.9.0"