@payloadcms/next 3.48.0-canary.5 → 3.48.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"buildView.d.ts","sourceRoot":"","sources":["../../../src/views/BrowseByFolder/buildView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAI/B,SAAS,EACV,MAAM,SAAS,CAAA;AAShB,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;CACjB,GAAG,oBAAoB,CAAA;AAExB,eAAO,MAAM,uBAAuB,SAC5B,mBAAmB,KACxB,OAAO,CAAC,+BAA+B,CAuJzC,CAAA"}
1
+ {"version":3,"file":"buildView.d.ts","sourceRoot":"","sources":["../../../src/views/BrowseByFolder/buildView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAI/B,SAAS,EACV,MAAM,SAAS,CAAA;AAShB,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;CACjB,GAAG,oBAAoB,CAAA;AAExB,eAAO,MAAM,uBAAuB,SAC5B,mBAAmB,KACxB,OAAO,CAAC,+BAA+B,CAyMzC,CAAA"}
@@ -35,9 +35,29 @@ export const buildBrowseByFolderView = async args => {
35
35
  if (config.folders === false || config.folders.browseByFolder === false) {
36
36
  throw new Error('not-found');
37
37
  }
38
- const browseByFolderSlugs = browseByFolderSlugsFromArgs.filter(collectionSlug => permissions?.collections?.[collectionSlug]?.read && visibleEntities.collections.includes(collectionSlug));
39
- const query = queryFromArgs || queryFromReq;
40
- const activeCollectionFolderSlugs = Array.isArray(query?.relationTo) && query.relationTo.length ? query.relationTo.filter(slug => browseByFolderSlugs.includes(slug) || config.folders && slug === config.folders.slug) : [...browseByFolderSlugs, config.folders.slug];
38
+ const foldersSlug = config.folders.slug;
39
+ /**
40
+ * All visiible folder enabled collection slugs that the user has read permissions for.
41
+ */
42
+ const allowReadCollectionSlugs = browseByFolderSlugsFromArgs.filter(collectionSlug => permissions?.collections?.[collectionSlug]?.read && visibleEntities.collections.includes(collectionSlug));
43
+ const query = queryFromArgs || (queryFromReq ? {
44
+ ...queryFromReq,
45
+ relationTo: typeof queryFromReq?.relationTo === 'string' ? JSON.parse(queryFromReq.relationTo) : undefined
46
+ } : {});
47
+ /**
48
+ * If a folderID is provided and the relationTo query param exists,
49
+ * we filter the collection slugs to only those that are allowed to be read.
50
+ *
51
+ * If no folderID is provided, only folders should be active and displayed (the root view).
52
+ */
53
+ let collectionsToDisplay = [];
54
+ if (folderID && Array.isArray(query?.relationTo)) {
55
+ collectionsToDisplay = query.relationTo.filter(slug => allowReadCollectionSlugs.includes(slug) || slug === foldersSlug);
56
+ } else if (folderID) {
57
+ collectionsToDisplay = [...allowReadCollectionSlugs, foldersSlug];
58
+ } else {
59
+ collectionsToDisplay = [foldersSlug];
60
+ }
41
61
  const {
42
62
  routes: {
43
63
  admin: adminRoute
@@ -55,17 +75,19 @@ export const buildBrowseByFolderView = async args => {
55
75
  sort: query?.sort
56
76
  }
57
77
  });
58
- const sortPreference = browseByFolderPreferences?.sort || '_folderOrDocumentTitle';
78
+ const sortPreference = browseByFolderPreferences?.sort || 'name';
59
79
  const viewPreference = browseByFolderPreferences?.viewPreference || 'grid';
60
80
  const {
61
81
  breadcrumbs,
62
82
  documents,
83
+ folderAssignedCollections,
63
84
  FolderResultsComponent,
64
85
  subfolders
65
86
  } = await getFolderResultsComponentAndData({
66
- activeCollectionSlugs: activeCollectionFolderSlugs,
67
- browseByFolder: false,
87
+ browseByFolder: true,
88
+ collectionsToDisplay,
68
89
  displayAs: viewPreference,
90
+ folderAssignedCollections: collectionsToDisplay.filter(slug => slug !== foldersSlug) || [],
69
91
  folderID,
70
92
  req: initPageResult.req,
71
93
  sort: sortPreference
@@ -96,8 +118,23 @@ export const buildBrowseByFolderView = async args => {
96
118
  // payload,
97
119
  // serverProps,
98
120
  // })
99
- // documents cannot be created without a parent folder in this view
100
- const allowCreateCollectionSlugs = resolvedFolderID ? [config.folders.slug, ...browseByFolderSlugs] : [config.folders.slug];
121
+ // Filter down allCollectionFolderSlugs by the ones the current folder is assingned to
122
+ const allAvailableCollectionSlugs = folderID && Array.isArray(folderAssignedCollections) && folderAssignedCollections.length ? allowReadCollectionSlugs.filter(slug => folderAssignedCollections.includes(slug)) : allowReadCollectionSlugs;
123
+ // Filter down activeCollectionFolderSlugs by the ones the current folder is assingned to
124
+ const availableActiveCollectionFolderSlugs = collectionsToDisplay.filter(slug => {
125
+ if (slug === foldersSlug) {
126
+ return permissions?.collections?.[foldersSlug]?.read;
127
+ } else {
128
+ return !folderAssignedCollections || folderAssignedCollections.includes(slug);
129
+ }
130
+ });
131
+ // Documents cannot be created without a parent folder in this view
132
+ const allowCreateCollectionSlugs = (resolvedFolderID ? [foldersSlug, ...allAvailableCollectionSlugs] : [foldersSlug]).filter(collectionSlug => {
133
+ if (collectionSlug === foldersSlug) {
134
+ return permissions?.collections?.[foldersSlug]?.create;
135
+ }
136
+ return permissions?.collections?.[collectionSlug]?.create && visibleEntities.collections.includes(collectionSlug);
137
+ });
101
138
  return {
102
139
  View: /*#__PURE__*/_jsxs(_Fragment, {
103
140
  children: [/*#__PURE__*/_jsx(HydrateAuthProvider, {
@@ -105,8 +142,8 @@ export const buildBrowseByFolderView = async args => {
105
142
  }), RenderServerComponent({
106
143
  clientProps: {
107
144
  // ...folderViewSlots,
108
- activeCollectionFolderSlugs,
109
- allCollectionFolderSlugs: browseByFolderSlugs,
145
+ activeCollectionFolderSlugs: availableActiveCollectionFolderSlugs,
146
+ allCollectionFolderSlugs: allAvailableCollectionSlugs,
110
147
  allowCreateCollectionSlugs,
111
148
  baseFolderPath: `/browse-by-folder`,
112
149
  breadcrumbs,
@@ -114,6 +151,7 @@ export const buildBrowseByFolderView = async args => {
114
151
  disableBulkEdit,
115
152
  documents,
116
153
  enableRowSelections,
154
+ folderAssignedCollections,
117
155
  folderFieldName: config.folders.fieldName,
118
156
  folderID: resolvedFolderID || null,
119
157
  FolderResultsComponent,
@@ -1 +1 @@
1
- {"version":3,"file":"buildView.js","names":["DefaultBrowseByFolderView","HydrateAuthProvider","RenderServerComponent","getFolderResultsComponentAndData","upsertPreferences","formatAdminURL","redirect","React","buildBrowseByFolderView","args","browseByFolderSlugs","browseByFolderSlugsFromArgs","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","params","query","queryFromArgs","searchParams","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","folders","browseByFolder","Error","filter","collectionSlug","collections","read","includes","activeCollectionFolderSlugs","Array","isArray","relationTo","length","slug","routes","admin","adminRoute","browseByFolderPreferences","key","value","sort","sortPreference","viewPreference","breadcrumbs","documents","FolderResultsComponent","subfolders","activeCollectionSlugs","displayAs","resolvedFolderID","id","path","serverURL","serverProps","allowCreateCollectionSlugs","View","_jsxs","_Fragment","_jsx","clientProps","allCollectionFolderSlugs","baseFolderPath","folderFieldName","fieldName","Fallback","importMap"],"sources":["../../../src/views/BrowseByFolder/buildView.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n BuildCollectionFolderViewResult,\n FolderListViewClientProps,\n FolderListViewServerPropsOnly,\n FolderSortKeys,\n ListQuery,\n} from 'payload'\n\nimport { DefaultBrowseByFolderView, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getFolderResultsComponentAndData, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport React from 'react'\n\nexport type BuildFolderViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n folderID?: number | string\n isInDrawer?: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewServerProps\n\nexport const buildBrowseByFolderView = async (\n args: BuildFolderViewArgs,\n): Promise<BuildCollectionFolderViewResult> => {\n const {\n browseByFolderSlugs: browseByFolderSlugsFromArgs = [],\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n folderID,\n initPageResult,\n isInDrawer,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n locale: fullLocale,\n permissions,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (config.folders === false || config.folders.browseByFolder === false) {\n throw new Error('not-found')\n }\n\n const browseByFolderSlugs = browseByFolderSlugsFromArgs.filter(\n (collectionSlug) =>\n permissions?.collections?.[collectionSlug]?.read &&\n visibleEntities.collections.includes(collectionSlug),\n )\n\n const query = queryFromArgs || queryFromReq\n const activeCollectionFolderSlugs: string[] =\n Array.isArray(query?.relationTo) && query.relationTo.length\n ? query.relationTo.filter(\n (slug) =>\n browseByFolderSlugs.includes(slug) || (config.folders && slug === config.folders.slug),\n )\n : [...browseByFolderSlugs, config.folders.slug]\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n /**\n * @todo: find a pattern to avoid setting preferences on hard navigation, i.e. direct links, page refresh, etc.\n * This will ensure that prefs are only updated when explicitly set by the user\n * This could potentially be done by injecting a `sessionID` into the params and comparing it against a session cookie\n */\n const browseByFolderPreferences = await upsertPreferences<{\n sort?: FolderSortKeys\n viewPreference?: 'grid' | 'list'\n }>({\n key: 'browse-by-folder',\n req: initPageResult.req,\n value: {\n sort: query?.sort as FolderSortKeys,\n },\n })\n\n const sortPreference: FolderSortKeys = browseByFolderPreferences?.sort || '_folderOrDocumentTitle'\n const viewPreference = browseByFolderPreferences?.viewPreference || 'grid'\n\n const { breadcrumbs, documents, FolderResultsComponent, subfolders } =\n await getFolderResultsComponentAndData({\n activeCollectionSlugs: activeCollectionFolderSlugs,\n browseByFolder: false,\n displayAs: viewPreference,\n folderID,\n req: initPageResult.req,\n sort: sortPreference,\n })\n\n const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id\n\n if (\n !isInDrawer &&\n ((resolvedFolderID && folderID && folderID !== resolvedFolderID) ||\n (folderID && !resolvedFolderID))\n ) {\n redirect(\n formatAdminURL({\n adminRoute,\n path: config.admin.routes.browseByFolder,\n serverURL: config.serverURL,\n }),\n )\n }\n\n const serverProps: Omit<FolderListViewServerPropsOnly, 'collectionConfig' | 'listPreferences'> = {\n documents,\n i18n,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n subfolders,\n user,\n }\n\n // const folderViewSlots = renderFolderViewSlots({\n // clientProps: {\n // },\n // description: staticDescription,\n // payload,\n // serverProps,\n // })\n\n // documents cannot be created without a parent folder in this view\n const allowCreateCollectionSlugs = resolvedFolderID\n ? [config.folders.slug, ...browseByFolderSlugs]\n : [config.folders.slug]\n\n return {\n View: (\n <>\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n activeCollectionFolderSlugs,\n allCollectionFolderSlugs: browseByFolderSlugs,\n allowCreateCollectionSlugs,\n baseFolderPath: `/browse-by-folder`,\n breadcrumbs,\n disableBulkDelete,\n disableBulkEdit,\n documents,\n enableRowSelections,\n folderFieldName: config.folders.fieldName,\n folderID: resolvedFolderID || null,\n FolderResultsComponent,\n sort: sortPreference,\n subfolders,\n viewPreference,\n } satisfies FolderListViewClientProps,\n // Component:config.folders?.components?.views?.BrowseByFolders?.Component,\n Fallback: DefaultBrowseByFolderView,\n importMap: payload.importMap,\n serverProps,\n })}\n </>\n ),\n }\n}\n"],"mappings":";AASA,SAASA,yBAAyB,EAAEC,mBAAmB,QAAQ;AAC/D,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gCAAgC,EAAEC,iBAAiB,QAAQ;AACpE,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,MAAW;AAalB,OAAO,MAAMC,uBAAA,GAA0B,MACrCC,IAAA;EAEA,MAAM;IACJC,mBAAA,EAAqBC,2BAAA,GAA8B,EAAE;IACrDC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,MAAM;IACNC,KAAA,EAAOC,aAAa;IACpBC;EAAY,CACb,GAAGZ,IAAA;EAEJ,MAAM;IACJa,MAAA,EAAQC,UAAU;IAClBC,WAAW;IACXC,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBT,KAAA,EAAOU,YAAY;MACnBC;IAAI,CACL;IACDC;EAAe,CAChB,GAAGf,cAAA;EAEJ,IAAIY,MAAA,CAAOI,OAAO,KAAK,SAASJ,MAAA,CAAOI,OAAO,CAACC,cAAc,KAAK,OAAO;IACvE,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAMxB,mBAAA,GAAsBC,2BAAA,CAA4BwB,MAAM,CAC3DC,cAAA,IACCZ,WAAA,EAAaa,W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}
1
+ {"version":3,"file":"buildView.js","names":["DefaultBrowseByFolderView","HydrateAuthProvider","RenderServerComponent","getFolderResultsComponentAndData","upsertPreferences","formatAdminURL","redirect","React","buildBrowseByFolderView","args","browseByFolderSlugs","browseByFolderSlugsFromArgs","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","params","query","queryFromArgs","searchParams","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","folders","browseByFolder","Error","foldersSlug","slug","allowReadCollectionSlugs","filter","collectionSlug","collections","read","includes","relationTo","JSON","parse","undefined","collectionsToDisplay","Array","isArray","routes","admin","adminRoute","browseByFolderPreferences","key","value","sort","sortPreference","viewPreference","breadcrumbs","documents","folderAssignedCollections","FolderResultsComponent","subfolders","displayAs","resolvedFolderID","length","id","path","serverURL","serverProps","allAvailableCollectionSlugs","availableActiveCollectionFolderSlugs","allowCreateCollectionSlugs","create","View","_jsxs","_Fragment","_jsx","clientProps","activeCollectionFolderSlugs","allCollectionFolderSlugs","baseFolderPath","folderFieldName","fieldName","Fallback","importMap"],"sources":["../../../src/views/BrowseByFolder/buildView.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n BuildCollectionFolderViewResult,\n FolderListViewClientProps,\n FolderListViewServerPropsOnly,\n FolderSortKeys,\n ListQuery,\n} from 'payload'\n\nimport { DefaultBrowseByFolderView, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getFolderResultsComponentAndData, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport React from 'react'\n\nexport type BuildFolderViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n folderID?: number | string\n isInDrawer?: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewServerProps\n\nexport const buildBrowseByFolderView = async (\n args: BuildFolderViewArgs,\n): Promise<BuildCollectionFolderViewResult> => {\n const {\n browseByFolderSlugs: browseByFolderSlugsFromArgs = [],\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n folderID,\n initPageResult,\n isInDrawer,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n locale: fullLocale,\n permissions,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (config.folders === false || config.folders.browseByFolder === false) {\n throw new Error('not-found')\n }\n\n const foldersSlug = config.folders.slug\n\n /**\n * All visiible folder enabled collection slugs that the user has read permissions for.\n */\n const allowReadCollectionSlugs = browseByFolderSlugsFromArgs.filter(\n (collectionSlug) =>\n permissions?.collections?.[collectionSlug]?.read &&\n visibleEntities.collections.includes(collectionSlug),\n )\n\n const query =\n queryFromArgs ||\n ((queryFromReq\n ? {\n ...queryFromReq,\n relationTo:\n typeof queryFromReq?.relationTo === 'string'\n ? JSON.parse(queryFromReq.relationTo)\n : undefined,\n }\n : {}) as ListQuery)\n\n /**\n * If a folderID is provided and the relationTo query param exists,\n * we filter the collection slugs to only those that are allowed to be read.\n *\n * If no folderID is provided, only folders should be active and displayed (the root view).\n */\n let collectionsToDisplay: string[] = []\n if (folderID && Array.isArray(query?.relationTo)) {\n collectionsToDisplay = query.relationTo.filter(\n (slug) => allowReadCollectionSlugs.includes(slug) || slug === foldersSlug,\n )\n } else if (folderID) {\n collectionsToDisplay = [...allowReadCollectionSlugs, foldersSlug]\n } else {\n collectionsToDisplay = [foldersSlug]\n }\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n /**\n * @todo: find a pattern to avoid setting preferences on hard navigation, i.e. direct links, page refresh, etc.\n * This will ensure that prefs are only updated when explicitly set by the user\n * This could potentially be done by injecting a `sessionID` into the params and comparing it against a session cookie\n */\n const browseByFolderPreferences = await upsertPreferences<{\n sort?: FolderSortKeys\n viewPreference?: 'grid' | 'list'\n }>({\n key: 'browse-by-folder',\n req: initPageResult.req,\n value: {\n sort: query?.sort as FolderSortKeys,\n },\n })\n\n const sortPreference: FolderSortKeys = browseByFolderPreferences?.sort || 'name'\n const viewPreference = browseByFolderPreferences?.viewPreference || 'grid'\n\n const { breadcrumbs, documents, folderAssignedCollections, FolderResultsComponent, subfolders } =\n await getFolderResultsComponentAndData({\n browseByFolder: true,\n collectionsToDisplay,\n displayAs: viewPreference,\n folderAssignedCollections: collectionsToDisplay.filter((slug) => slug !== foldersSlug) || [],\n folderID,\n req: initPageResult.req,\n sort: sortPreference,\n })\n\n const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id\n\n if (\n !isInDrawer &&\n ((resolvedFolderID && folderID && folderID !== resolvedFolderID) ||\n (folderID && !resolvedFolderID))\n ) {\n redirect(\n formatAdminURL({\n adminRoute,\n path: config.admin.routes.browseByFolder,\n serverURL: config.serverURL,\n }),\n )\n }\n\n const serverProps: Omit<FolderListViewServerPropsOnly, 'collectionConfig' | 'listPreferences'> = {\n documents,\n i18n,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n subfolders,\n user,\n }\n\n // const folderViewSlots = renderFolderViewSlots({\n // clientProps: {\n // },\n // description: staticDescription,\n // payload,\n // serverProps,\n // })\n\n // Filter down allCollectionFolderSlugs by the ones the current folder is assingned to\n const allAvailableCollectionSlugs =\n folderID && Array.isArray(folderAssignedCollections) && folderAssignedCollections.length\n ? allowReadCollectionSlugs.filter((slug) => folderAssignedCollections.includes(slug))\n : allowReadCollectionSlugs\n\n // Filter down activeCollectionFolderSlugs by the ones the current folder is assingned to\n const availableActiveCollectionFolderSlugs = collectionsToDisplay.filter((slug) => {\n if (slug === foldersSlug) {\n return permissions?.collections?.[foldersSlug]?.read\n } else {\n return !folderAssignedCollections || folderAssignedCollections.includes(slug)\n }\n })\n\n // Documents cannot be created without a parent folder in this view\n const allowCreateCollectionSlugs = (\n resolvedFolderID ? [foldersSlug, ...allAvailableCollectionSlugs] : [foldersSlug]\n ).filter((collectionSlug) => {\n if (collectionSlug === foldersSlug) {\n return permissions?.collections?.[foldersSlug]?.create\n }\n return (\n permissions?.collections?.[collectionSlug]?.create &&\n visibleEntities.collections.includes(collectionSlug)\n )\n })\n\n return {\n View: (\n <>\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n activeCollectionFolderSlugs: availableActiveCollectionFolderSlugs,\n allCollectionFolderSlugs: allAvailableCollectionSlugs,\n allowCreateCollectionSlugs,\n baseFolderPath: `/browse-by-folder`,\n breadcrumbs,\n disableBulkDelete,\n disableBulkEdit,\n documents,\n enableRowSelections,\n folderAssignedCollections,\n folderFieldName: config.folders.fieldName,\n folderID: resolvedFolderID || null,\n FolderResultsComponent,\n sort: sortPreference,\n subfolders,\n viewPreference,\n } satisfies FolderListViewClientProps,\n // Component:config.folders?.components?.views?.BrowseByFolders?.Component,\n Fallback: DefaultBrowseByFolderView,\n importMap: payload.importMap,\n serverProps,\n })}\n </>\n ),\n }\n}\n"],"mappings":";AASA,SAASA,yBAAyB,EAAEC,mBAAmB,QAAQ;AAC/D,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gCAAgC,EAAEC,iBAAiB,QAAQ;AACpE,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,MAAW;AAalB,OAAO,MAAMC,uBAAA,GAA0B,MACrCC,IAAA;EAEA,MAAM;IACJC,mBAAA,EAAqBC,2BAAA,GAA8B,EAAE;IACrDC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,MAAM;IACNC,KAAA,EAAOC,aAAa;IACpBC;EAAY,CACb,GAAGZ,IAAA;EAEJ,MAAM;IACJa,MAAA,EAAQC,UAAU;IAClBC,WAAW;IACXC,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;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AAA;UACNM,UAAA;UACAL;QACF;QACA;QACA2B,QAAA,EAAUrF,yBAAA;QACVsF,SAAA,EAAW3D,OAAA,CAAQ2D,SAAS;QAC5BhB;MACF;;EAGN;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"buildView.d.ts","sourceRoot":"","sources":["../../../src/views/CollectionFolders/buildView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAI/B,SAAS,EACV,MAAM,SAAS,CAAA;AAWhB,MAAM,MAAM,kCAAkC,GAAG;IAC/C,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;CACjB,GAAG,oBAAoB,CAAA;AAExB;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAC9B,kCAAkC,KACvC,OAAO,CAAC,+BAA+B,CA0KzC,CAAA"}
1
+ {"version":3,"file":"buildView.d.ts","sourceRoot":"","sources":["../../../src/views/CollectionFolders/buildView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAI/B,SAAS,EACV,MAAM,SAAS,CAAA;AAWhB,MAAM,MAAM,kCAAkC,GAAG;IAC/C,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;CACjB,GAAG,oBAAoB,CAAA;AAExB;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAC9B,kCAAkC,KACvC,OAAO,CAAC,+BAA+B,CAgLzC,CAAA"}
@@ -62,7 +62,7 @@ export const buildCollectionFolderView = async args => {
62
62
  sort: query?.sort
63
63
  }
64
64
  });
65
- const sortPreference = collectionFolderPreferences?.sort || '_folderOrDocumentTitle';
65
+ const sortPreference = collectionFolderPreferences?.sort || 'name';
66
66
  const viewPreference = collectionFolderPreferences?.viewPreference || 'grid';
67
67
  const {
68
68
  routes: {
@@ -72,12 +72,14 @@ export const buildCollectionFolderView = async args => {
72
72
  const {
73
73
  breadcrumbs,
74
74
  documents,
75
+ folderAssignedCollections,
75
76
  FolderResultsComponent,
76
77
  subfolders
77
78
  } = await getFolderResultsComponentAndData({
78
- activeCollectionSlugs: [config.folders.slug, collectionSlug],
79
79
  browseByFolder: false,
80
+ collectionsToDisplay: [config.folders.slug, collectionSlug],
80
81
  displayAs: viewPreference,
82
+ folderAssignedCollections: [collectionSlug],
81
83
  folderID,
82
84
  req: initPageResult.req,
83
85
  sort: sortPreference
@@ -133,6 +135,7 @@ export const buildCollectionFolderView = async args => {
133
135
  disableBulkEdit,
134
136
  documents,
135
137
  enableRowSelections,
138
+ folderAssignedCollections,
136
139
  folderFieldName: config.folders.fieldName,
137
140
  folderID: resolvedFolderID || null,
138
141
  FolderResultsComponent,
@@ -1 +1 @@
1
- {"version":3,"file":"buildView.js","names":["DefaultCollectionFolderView","HydrateAuthProvider","RenderServerComponent","getFolderResultsComponentAndData","upsertPreferences","formatAdminURL","redirect","React","buildCollectionFolderView","args","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","overrideEntityVisibility","params","query","queryFromArgs","searchParams","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","folders","Error","collections","read","includes","collectionFolderPreferences","key","value","sort","sortPreference","viewPreference","routes","admin","adminRoute","breadcrumbs","documents","FolderResultsComponent","subfolders","activeCollectionSlugs","browseByFolder","displayAs","resolvedFolderID","length","id","path","serverURL","serverProps","search","View","_jsxs","_Fragment","_jsx","clientProps","allCollectionFolderSlugs","allowCreateCollectionSlugs","create","filter","Boolean","baseFolderPath","folderFieldName","fieldName","Fallback","importMap"],"sources":["../../../src/views/CollectionFolders/buildView.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n BuildCollectionFolderViewResult,\n FolderListViewClientProps,\n FolderListViewServerPropsOnly,\n FolderSortKeys,\n ListQuery,\n} from 'payload'\n\nimport { DefaultCollectionFolderView, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getFolderResultsComponentAndData, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport React from 'react'\n\n// import { renderFolderViewSlots } from './renderFolderViewSlots.js'\n\nexport type BuildCollectionFolderViewStateArgs = {\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n folderID?: number | string\n isInDrawer?: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewServerProps\n\n/**\n * Builds the entire view for collection-folder views on the server\n */\nexport const buildCollectionFolderView = async (\n args: BuildCollectionFolderViewStateArgs,\n): Promise<BuildCollectionFolderViewResult> => {\n const {\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n folderID,\n initPageResult,\n isInDrawer,\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 i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!config.folders) {\n throw new Error('not-found')\n }\n\n if (\n !permissions?.collections?.[collectionSlug]?.read ||\n !permissions?.collections?.[config.folders.slug].read\n ) {\n throw new Error('not-found')\n }\n\n if (collectionConfig) {\n if (\n (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) ||\n !config.folders\n ) {\n throw new Error('not-found')\n }\n\n const query = queryFromArgs || queryFromReq\n\n /**\n * @todo: find a pattern to avoid setting preferences on hard navigation, i.e. direct links, page refresh, etc.\n * This will ensure that prefs are only updated when explicitly set by the user\n * This could potentially be done by injecting a `sessionID` into the params and comparing it against a session cookie\n */\n const collectionFolderPreferences = await upsertPreferences<{\n sort?: FolderSortKeys\n viewPreference?: 'grid' | 'list'\n }>({\n key: `${collectionSlug}-collection-folder`,\n req: initPageResult.req,\n value: {\n sort: query?.sort as FolderSortKeys,\n },\n })\n\n const sortPreference: FolderSortKeys =\n collectionFolderPreferences?.sort || '_folderOrDocumentTitle'\n const viewPreference = collectionFolderPreferences?.viewPreference || 'grid'\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n const { breadcrumbs, documents, FolderResultsComponent, subfolders } =\n await getFolderResultsComponentAndData({\n activeCollectionSlugs: [config.folders.slug, collectionSlug],\n browseByFolder: false,\n displayAs: viewPreference,\n folderID,\n req: initPageResult.req,\n sort: sortPreference,\n })\n\n const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id\n\n if (\n !isInDrawer &&\n ((resolvedFolderID && folderID && folderID !== resolvedFolderID) ||\n (folderID && !resolvedFolderID))\n ) {\n redirect(\n formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${config.folders.slug}`,\n serverURL: config.serverURL,\n }),\n )\n }\n\n const serverProps: FolderListViewServerPropsOnly = {\n collectionConfig,\n documents,\n i18n,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n subfolders,\n user,\n }\n\n // We could support slots in the folder view in the future\n // const folderViewSlots = renderFolderViewSlots({\n // clientProps: {\n // collectionSlug,\n // hasCreatePermission,\n // newDocumentURL,\n // },\n // collectionConfig,\n // description: typeof collectionConfig.admin.description === 'function'\n // ? collectionConfig.admin.description({ t: i18n.t })\n // : collectionConfig.admin.description,\n // payload,\n // serverProps,\n // })\n\n const search = query?.search as string\n\n return {\n View: (\n <>\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n allCollectionFolderSlugs: [config.folders.slug, collectionSlug],\n allowCreateCollectionSlugs: [\n permissions?.collections?.[config.folders.slug]?.create\n ? config.folders.slug\n : null,\n permissions?.collections?.[collectionSlug]?.create ? collectionSlug : null,\n ].filter(Boolean),\n baseFolderPath: `/collections/${collectionSlug}/${config.folders.slug}`,\n breadcrumbs,\n collectionSlug,\n disableBulkDelete,\n disableBulkEdit,\n documents,\n enableRowSelections,\n folderFieldName: config.folders.fieldName,\n folderID: resolvedFolderID || null,\n FolderResultsComponent,\n search,\n sort: sortPreference,\n subfolders,\n viewPreference,\n } satisfies FolderListViewClientProps,\n // Component: collectionConfig?.admin?.components?.views?.Folders?.Component,\n Fallback: DefaultCollectionFolderView,\n importMap: payload.importMap,\n serverProps,\n })}\n </>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n"],"mappings":";AASA,SAASA,2BAA2B,EAAEC,mBAAmB,QAAQ;AACjE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gCAAgC,EAAEC,iBAAiB,QAAQ;AACpE,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,MAAW;AAclB;;;AAGA,OAAO,MAAMC,yBAAA,GAA4B,MACvCC,IAAA;EAEA,MAAM;IACJC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,wBAAwB;IACxBC,MAAM;IACNC,KAAA,EAAOC,aAAa;IACpBC;EAAY,CACb,GAAGX,IAAA;EAEJ,MAAM;IACJY,gBAAgB;IAChBA,gBAAA,EAAkB;MAAEC,IAAA,EAAMC;IAAc,CAAE;IAC1CC,MAAA,EAAQC,UAAU;IAClBC,WAAW;IACXC,GAAA,EAAK;MACHC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Acb,cAAA,CAAe,EAAE8C,MAAA,GAAS9C,cAAA,GAAiB,KACvE,CAAC+C,MAAM,CAACC,OAAA;YACTC,cAAA,EAAgB,gBAAgBjD,cAAA,IAAkBO,MAAA,CAAOI,OAAO,CAACZ,IAAI,EAAE;YACvE0B,WAAA;YACAzB,cAAA;YACAb,iBAAA;YACAC,eAAA;YACAsC,SAAA;YACArC,mBAAA;YACA6D,eAAA,EAAiB3C,MAAA,CAAOI,OAAO,CAACwC,SAAS;YACzC7D,QAAA,EAAU0C,gBAAA,IAAoB;YAC9BL,sBAAA;YACAW,MAAA;YACAnB,IAAA,EAAMC,cAAA;YACNQ,UAAA;YACAP;UACF;UACA;UACA+B,QAAA,EAAU3E,2BAAA;UACV4E,SAAA,EAAW/C,OAAA,CAAQ+C,SAAS;UAC5BhB;QACF;;IAGN;EACF;EAEA,MAAM,IAAIzB,KAAA,CAAM;AAClB","ignoreList":[]}
1
+ {"version":3,"file":"buildView.js","names":["DefaultCollectionFolderView","HydrateAuthProvider","RenderServerComponent","getFolderResultsComponentAndData","upsertPreferences","formatAdminURL","redirect","React","buildCollectionFolderView","args","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","overrideEntityVisibility","params","query","queryFromArgs","searchParams","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","folders","Error","collections","read","includes","collectionFolderPreferences","key","value","sort","sortPreference","viewPreference","routes","admin","adminRoute","breadcrumbs","documents","folderAssignedCollections","FolderResultsComponent","subfolders","browseByFolder","collectionsToDisplay","displayAs","resolvedFolderID","length","id","path","serverURL","serverProps","search","View","_jsxs","_Fragment","_jsx","clientProps","allCollectionFolderSlugs","allowCreateCollectionSlugs","create","filter","Boolean","baseFolderPath","folderFieldName","fieldName","Fallback","importMap"],"sources":["../../../src/views/CollectionFolders/buildView.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n BuildCollectionFolderViewResult,\n FolderListViewClientProps,\n FolderListViewServerPropsOnly,\n FolderSortKeys,\n ListQuery,\n} from 'payload'\n\nimport { DefaultCollectionFolderView, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getFolderResultsComponentAndData, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport React from 'react'\n\n// import { renderFolderViewSlots } from './renderFolderViewSlots.js'\n\nexport type BuildCollectionFolderViewStateArgs = {\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n folderID?: number | string\n isInDrawer?: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewServerProps\n\n/**\n * Builds the entire view for collection-folder views on the server\n */\nexport const buildCollectionFolderView = async (\n args: BuildCollectionFolderViewStateArgs,\n): Promise<BuildCollectionFolderViewResult> => {\n const {\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n folderID,\n initPageResult,\n isInDrawer,\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 i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!config.folders) {\n throw new Error('not-found')\n }\n\n if (\n !permissions?.collections?.[collectionSlug]?.read ||\n !permissions?.collections?.[config.folders.slug].read\n ) {\n throw new Error('not-found')\n }\n\n if (collectionConfig) {\n if (\n (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) ||\n !config.folders\n ) {\n throw new Error('not-found')\n }\n\n const query = queryFromArgs || queryFromReq\n\n /**\n * @todo: find a pattern to avoid setting preferences on hard navigation, i.e. direct links, page refresh, etc.\n * This will ensure that prefs are only updated when explicitly set by the user\n * This could potentially be done by injecting a `sessionID` into the params and comparing it against a session cookie\n */\n const collectionFolderPreferences = await upsertPreferences<{\n sort?: FolderSortKeys\n viewPreference?: 'grid' | 'list'\n }>({\n key: `${collectionSlug}-collection-folder`,\n req: initPageResult.req,\n value: {\n sort: query?.sort as FolderSortKeys,\n },\n })\n\n const sortPreference: FolderSortKeys = collectionFolderPreferences?.sort || 'name'\n const viewPreference = collectionFolderPreferences?.viewPreference || 'grid'\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n const {\n breadcrumbs,\n documents,\n folderAssignedCollections,\n FolderResultsComponent,\n subfolders,\n } = await getFolderResultsComponentAndData({\n browseByFolder: false,\n collectionsToDisplay: [config.folders.slug, collectionSlug],\n displayAs: viewPreference,\n folderAssignedCollections: [collectionSlug],\n folderID,\n req: initPageResult.req,\n sort: sortPreference,\n })\n\n const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id\n\n if (\n !isInDrawer &&\n ((resolvedFolderID && folderID && folderID !== resolvedFolderID) ||\n (folderID && !resolvedFolderID))\n ) {\n redirect(\n formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${config.folders.slug}`,\n serverURL: config.serverURL,\n }),\n )\n }\n\n const serverProps: FolderListViewServerPropsOnly = {\n collectionConfig,\n documents,\n i18n,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n subfolders,\n user,\n }\n\n // We could support slots in the folder view in the future\n // const folderViewSlots = renderFolderViewSlots({\n // clientProps: {\n // collectionSlug,\n // hasCreatePermission,\n // newDocumentURL,\n // },\n // collectionConfig,\n // description: typeof collectionConfig.admin.description === 'function'\n // ? collectionConfig.admin.description({ t: i18n.t })\n // : collectionConfig.admin.description,\n // payload,\n // serverProps,\n // })\n\n const search = query?.search as string\n\n return {\n View: (\n <>\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n allCollectionFolderSlugs: [config.folders.slug, collectionSlug],\n allowCreateCollectionSlugs: [\n permissions?.collections?.[config.folders.slug]?.create\n ? config.folders.slug\n : null,\n permissions?.collections?.[collectionSlug]?.create ? collectionSlug : null,\n ].filter(Boolean),\n baseFolderPath: `/collections/${collectionSlug}/${config.folders.slug}`,\n breadcrumbs,\n collectionSlug,\n disableBulkDelete,\n disableBulkEdit,\n documents,\n enableRowSelections,\n folderAssignedCollections,\n folderFieldName: config.folders.fieldName,\n folderID: resolvedFolderID || null,\n FolderResultsComponent,\n search,\n sort: sortPreference,\n subfolders,\n viewPreference,\n } satisfies FolderListViewClientProps,\n // Component: collectionConfig?.admin?.components?.views?.Folders?.Component,\n Fallback: DefaultCollectionFolderView,\n importMap: payload.importMap,\n serverProps,\n })}\n </>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n"],"mappings":";AASA,SAASA,2BAA2B,EAAEC,mBAAmB,QAAQ;AACjE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gCAAgC,EAAEC,iBAAiB,QAAQ;AACpE,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,MAAW;AAclB;;;AAGA,OAAO,MAAMC,yBAAA,GAA4B,MACvCC,IAAA;EAEA,MAAM;IACJC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,wBAAwB;IACxBC,MAAM;IACNC,KAAA,EAAOC,aAAa;IACpBC;EAAY,CACb,GAAGX,IAAA;EAEJ,MAAM;IACJY,gBAAgB;IAChBA,gBAAA,EAAkB;MAAEC,IAAA,EAAMC;IAAc,CAAE;IAC1CC,MAAA,EAAQC,UAAU;IAClBC,WAAW;IACXC,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBZ,KAAA,EAAOa,YAAY;MACnBC;IAAI,CACL;IACDC;EAAe,CAChB,GAAGnB,cAAA;EAEJ,IAAI,CAACgB,MAAA,CAAOI,OAAO,EAAE;IACnB,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,IACE,CAACT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A;YACAzB,cAAA;YACAb,iBAAA;YACAC,eAAA;YACAsC,SAAA;YACArC,mBAAA;YACAsC,yBAAA;YACAwB,eAAA,EAAiB5C,MAAA,CAAOI,OAAO,CAACyC,SAAS;YACzC9D,QAAA,EAAU2C,gBAAA,IAAoB;YAC9BL,sBAAA;YACAW,MAAA;YACApB,IAAA,EAAMC,cAAA;YACNS,UAAA;YACAR;UACF;UACA;UACAgC,QAAA,EAAU5E,2BAAA;UACV6E,SAAA,EAAWhD,OAAA,CAAQgD,SAAS;UAC5BhB;QACF;;IAGN;EACF;EAEA,MAAM,IAAI1B,KAAA,CAAM;AAClB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "3.48.0-canary.5",
3
+ "version": "3.48.0",
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.48.0-canary.5",
91
- "@payloadcms/translations": "3.48.0-canary.5",
92
- "@payloadcms/ui": "3.48.0-canary.5"
90
+ "@payloadcms/ui": "3.48.0",
91
+ "@payloadcms/translations": "3.48.0",
92
+ "@payloadcms/graphql": "3.48.0"
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.48.0-canary.5"
110
+ "payload": "3.48.0"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "graphql": "^16.8.1",
114
114
  "next": "^15.2.3",
115
- "payload": "3.48.0-canary.5"
115
+ "payload": "3.48.0"
116
116
  },
117
117
  "engines": {
118
118
  "node": "^18.20.2 || >=20.9.0"