@payloadcms/next 3.55.0-canary.11 → 3.55.0-canary.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/views/List/handleGroupBy.d.ts +4 -2
- package/dist/views/List/handleGroupBy.d.ts.map +1 -1
- package/dist/views/List/handleGroupBy.js +3 -1
- package/dist/views/List/handleGroupBy.js.map +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +17 -4
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/transformColumnsToSelect.d.ts +3 -0
- package/dist/views/List/transformColumnsToSelect.d.ts.map +1 -0
- package/dist/views/List/transformColumnsToSelect.js +7 -0
- package/dist/views/List/transformColumnsToSelect.js.map +1 -0
- package/package.json +6 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ClientConfig, Column, ListQuery, PaginatedDocs, PayloadRequest, SanitizedCollectionConfig, ViewTypes, Where } from 'payload';
|
|
2
|
-
export declare const handleGroupBy: ({ clientConfig, collectionConfig, collectionSlug, columns, customCellProps, drawerSlug, enableRowSelections, query, req, trash, user, viewType, where: whereWithMergedSearch, }: {
|
|
1
|
+
import type { ClientCollectionConfig, ClientConfig, Column, ListQuery, PaginatedDocs, PayloadRequest, SanitizedCollectionConfig, SelectType, ViewTypes, Where } from 'payload';
|
|
2
|
+
export declare const handleGroupBy: ({ clientCollectionConfig, clientConfig, collectionConfig, collectionSlug, columns, customCellProps, drawerSlug, enableRowSelections, query, req, select, trash, user, viewType, where: whereWithMergedSearch, }: {
|
|
3
|
+
clientCollectionConfig: ClientCollectionConfig;
|
|
3
4
|
clientConfig: ClientConfig;
|
|
4
5
|
collectionConfig: SanitizedCollectionConfig;
|
|
5
6
|
collectionSlug: string;
|
|
@@ -9,6 +10,7 @@ export declare const handleGroupBy: ({ clientConfig, collectionConfig, collectio
|
|
|
9
10
|
enableRowSelections?: boolean;
|
|
10
11
|
query?: ListQuery;
|
|
11
12
|
req: PayloadRequest;
|
|
13
|
+
select?: SelectType;
|
|
12
14
|
trash?: boolean;
|
|
13
15
|
user: any;
|
|
14
16
|
viewType?: ViewTypes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleGroupBy.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleGroupBy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,SAAS,EACT,aAAa,EACb,cAAc,EACd,yBAAyB,EACzB,SAAS,EACT,KAAK,EACN,MAAM,SAAS,CAAA;AAMhB,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"handleGroupBy.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleGroupBy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EACZ,MAAM,EACN,SAAS,EACT,aAAa,EACb,cAAc,EACd,yBAAyB,EACzB,UAAU,EACV,SAAS,EACT,KAAK,EACN,MAAM,SAAS,CAAA;AAMhB,eAAO,MAAM,aAAa,oNAgBvB;IACD,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,YAAY,EAAE,YAAY,CAAA;IAC1B,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,GAAG,EAAE,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,GAAG,CAAA;IACT,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,EAAE,KAAK,CAAA;CACb,KAAG,OAAO,CAAC;IACV,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,EAAE,IAAI,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;CAClD,CA0KA,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { renderTable } from '@payloadcms/ui/rsc';
|
|
|
2
2
|
import { formatDate } from '@payloadcms/ui/shared';
|
|
3
3
|
import { flattenAllFields } from 'payload';
|
|
4
4
|
export const handleGroupBy = async ({
|
|
5
|
+
clientCollectionConfig,
|
|
5
6
|
clientConfig,
|
|
6
7
|
collectionConfig,
|
|
7
8
|
collectionSlug,
|
|
@@ -11,6 +12,7 @@ export const handleGroupBy = async ({
|
|
|
11
12
|
enableRowSelections,
|
|
12
13
|
query,
|
|
13
14
|
req,
|
|
15
|
+
select,
|
|
14
16
|
trash = false,
|
|
15
17
|
user,
|
|
16
18
|
viewType,
|
|
@@ -19,7 +21,6 @@ export const handleGroupBy = async ({
|
|
|
19
21
|
let Table = null;
|
|
20
22
|
let columnState;
|
|
21
23
|
const dataByGroup = {};
|
|
22
|
-
const clientCollectionConfig = clientConfig.collections.find(c => c.slug === collectionSlug);
|
|
23
24
|
// NOTE: is there a faster/better way to do this?
|
|
24
25
|
const flattenedFields = flattenAllFields({
|
|
25
26
|
fields: collectionConfig.fields
|
|
@@ -76,6 +77,7 @@ export const handleGroupBy = async ({
|
|
|
76
77
|
req,
|
|
77
78
|
// Note: if we wanted to enable table-by-table sorting, we could use this:
|
|
78
79
|
// sort: query?.queryByGroup?.[valueOrRelationshipID]?.sort,
|
|
80
|
+
select,
|
|
79
81
|
sort: query?.sort,
|
|
80
82
|
trash,
|
|
81
83
|
user,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleGroupBy.js","names":["renderTable","formatDate","flattenAllFields","handleGroupBy","clientConfig","collectionConfig","collectionSlug","columns","customCellProps","drawerSlug","enableRowSelections","query","req","trash","user","viewType","where","whereWithMergedSearch","Table","columnState","dataByGroup","clientCollectionConfig","collections","find","c","slug","flattenedFields","fields","groupByFieldPath","groupBy","replace","groupByField","f","name","relationshipConfig","type","relationTo","undefined","populate","Array","isArray","forEach","rel","admin","useAsTitle","distinct","payload","findDistinct","collection","depth","field","limit","Number","locale","overrideAccess","page","sort","data","docs","values","map","Promise","all","distinctValue","i","potentiallyPopulatedRelationship","valueOrRelationshipID","id","groupData","draft","fallbackLocale","includeLockStatus","queryByGroup","equals","heading","date","String","i18n","pattern","dateFormat","t","length","newColumnState","NewTable","groupByValue","key","orderableFieldName","orderable"],"sources":["../../../src/views/List/handleGroupBy.ts"],"sourcesContent":["import type {\n ClientConfig,\n Column,\n ListQuery,\n PaginatedDocs,\n PayloadRequest,\n SanitizedCollectionConfig,\n ViewTypes,\n Where,\n} from 'payload'\n\nimport { renderTable } from '@payloadcms/ui/rsc'\nimport { formatDate } from '@payloadcms/ui/shared'\nimport { flattenAllFields } from 'payload'\n\nexport const handleGroupBy = async ({\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n query,\n req,\n trash = false,\n user,\n viewType,\n where: whereWithMergedSearch,\n}: {\n clientConfig: ClientConfig\n collectionConfig: SanitizedCollectionConfig\n collectionSlug: string\n columns: any[]\n customCellProps?: Record<string, any>\n drawerSlug?: string\n enableRowSelections?: boolean\n query?: ListQuery\n req: PayloadRequest\n trash?: boolean\n user: any\n viewType?: ViewTypes\n where: Where\n}): Promise<{\n columnState: Column[]\n data: PaginatedDocs\n Table: null | React.ReactNode | React.ReactNode[]\n}> => {\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[]\n\n const dataByGroup: Record<string, PaginatedDocs> = {}\n const clientCollectionConfig = clientConfig.collections.find((c) => c.slug === collectionSlug)\n\n // NOTE: is there a faster/better way to do this?\n const flattenedFields = flattenAllFields({ fields: collectionConfig.fields })\n\n const groupByFieldPath = query.groupBy.replace(/^-/, '')\n\n const groupByField = flattenedFields.find((f) => f.name === groupByFieldPath)\n\n const relationshipConfig =\n groupByField?.type === 'relationship'\n ? clientConfig.collections.find((c) => c.slug === groupByField.relationTo)\n : undefined\n\n let populate\n\n if (groupByField?.type === 'relationship' && groupByField.relationTo) {\n const relationTo =\n typeof groupByField.relationTo === 'string'\n ? [groupByField.relationTo]\n : groupByField.relationTo\n\n if (Array.isArray(relationTo)) {\n relationTo.forEach((rel) => {\n if (!populate) {\n populate = {}\n }\n populate[rel] = { [relationshipConfig?.admin.useAsTitle || 'id']: true }\n })\n }\n }\n\n const distinct = await req.payload.findDistinct({\n collection: collectionSlug,\n depth: 1,\n field: groupByFieldPath,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n populate,\n req,\n sort: query?.groupBy,\n trash,\n where: whereWithMergedSearch,\n })\n\n const data = {\n ...distinct,\n docs: distinct.values?.map(() => ({})) || [],\n values: undefined,\n }\n\n await Promise.all(\n distinct.values.map(async (distinctValue, i) => {\n const potentiallyPopulatedRelationship = distinctValue[groupByFieldPath]\n\n const valueOrRelationshipID =\n groupByField?.type === 'relationship' &&\n potentiallyPopulatedRelationship &&\n typeof potentiallyPopulatedRelationship === 'object' &&\n 'id' in potentiallyPopulatedRelationship\n ? potentiallyPopulatedRelationship.id\n : potentiallyPopulatedRelationship\n\n const groupData = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.queryByGroup?.[valueOrRelationshipID]?.limit\n ? Number(query.queryByGroup[valueOrRelationshipID].limit)\n : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.queryByGroup?.[valueOrRelationshipID]?.page\n ? Number(query.queryByGroup[valueOrRelationshipID].page)\n : undefined,\n req,\n // Note: if we wanted to enable table-by-table sorting, we could use this:\n // sort: query?.queryByGroup?.[valueOrRelationshipID]?.sort,\n sort: query?.sort,\n trash,\n user,\n where: {\n ...(whereWithMergedSearch || {}),\n [groupByFieldPath]: {\n equals: valueOrRelationshipID,\n },\n },\n })\n\n let heading = valueOrRelationshipID\n\n if (\n groupByField?.type === 'relationship' &&\n potentiallyPopulatedRelationship &&\n typeof potentiallyPopulatedRelationship === 'object'\n ) {\n heading =\n potentiallyPopulatedRelationship[relationshipConfig.admin.useAsTitle || 'id'] ||\n valueOrRelationshipID\n }\n\n if (groupByField.type === 'date' && valueOrRelationshipID) {\n heading = formatDate({\n date: String(valueOrRelationshipID),\n i18n: req.i18n,\n pattern: clientConfig.admin.dateFormat,\n })\n }\n\n if (groupByField.type === 'checkbox') {\n if (valueOrRelationshipID === true) {\n heading = req.i18n.t('general:true')\n }\n\n if (valueOrRelationshipID === false) {\n heading = req.i18n.t('general:false')\n }\n }\n\n if (groupData.docs && groupData.docs.length > 0) {\n const { columnState: newColumnState, Table: NewTable } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columns,\n customCellProps,\n data: groupData,\n drawerSlug,\n enableRowSelections,\n groupByFieldPath,\n groupByValue: valueOrRelationshipID,\n heading: heading || req.i18n.t('general:noValue'),\n i18n: req.i18n,\n key: `table-${valueOrRelationshipID}`,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n })\n\n // Only need to set `columnState` once, using the first table's column state\n // This will avoid needing to generate column state explicitly for root context that wraps all tables\n if (!columnState) {\n columnState = newColumnState\n }\n\n if (!Table) {\n Table = []\n }\n\n dataByGroup[valueOrRelationshipID] = groupData\n ;(Table as Array<React.ReactNode>)[i] = NewTable\n }\n }),\n )\n\n return {\n columnState,\n data,\n Table,\n }\n}\n"],"mappings":"AAWA,SAASA,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AAEjC,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAO;EAClCC,YAAY;EACZC,gBAAgB;EAChBC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AAId,qBAAA,KAA0B,OAAO;QACnCQ,OAAA,GAAU9D,GAAA,CAAIiE,IAAI,CAACG,CAAC,CAAC;MACvB;IACF;IAEA,IAAIZ,SAAA,CAAUV,IAAI,IAAIU,SAAA,CAAUV,IAAI,CAACuB,MAAM,GAAG,GAAG;MAC/C,MAAM;QAAE9D,WAAA,EAAa+D,cAAc;QAAEhE,KAAA,EAAOiE;MAAQ,CAAE,GAAGnF,WAAA,CAAY;QACnEqB,sBAAA;QACAhB,gBAAA;QACAE,OAAA;QACAC,eAAA;QACAiD,IAAA,EAAMW,SAAA;QACN3D,UAAA;QACAC,mBAAA;QACAkB,gBAAA;QACAwD,YAAA,EAAclB,qBAAA;QACdQ,OAAA,EAASA,OAAA,IAAW9D,GAAA,CAAIiE,IAAI,CAACG,CAAC,CAAC;QAC/BH,IAAA,EAAMjE,GAAA,CAAIiE,IAAI;QACdQ,GAAA,EAAK,SAASnB,qBAAA,EAAuB;QACrCoB,kBAAA,EAAoBjF,gBAAA,CAAiBkF,SAAS,KAAK,OAAO,WAAWlD,SAAA;QACrES,OAAA,EAASlC,GAAA,CAAIkC,OAAO;QACpBnC,KAAA;QACAiC,UAAA,EAAYvC,gBAAA,CAAiBsC,KAAK,CAACC,UAAU;QAC7C7B;MACF;MAEA;MACA;MACA,IAAI,CAACI,WAAA,EAAa;QAChBA,WAAA,GAAc+D,cAAA;MAChB;MAEA,IAAI,CAAChE,KAAA,EAAO;QACVA,KAAA,GAAQ,EAAE;MACZ;MAEAE,WAAW,CAAC8C,qBAAA,CAAsB,GAAGE,SAAA;MACnClD,KAAgC,CAAC8C,CAAA,CAAE,GAAGmB,QAAA;IAC1C;EACF;EAGF,OAAO;IACLhE,WAAA;IACAsC,IAAA;IACAvC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"handleGroupBy.js","names":["renderTable","formatDate","flattenAllFields","handleGroupBy","clientCollectionConfig","clientConfig","collectionConfig","collectionSlug","columns","customCellProps","drawerSlug","enableRowSelections","query","req","select","trash","user","viewType","where","whereWithMergedSearch","Table","columnState","dataByGroup","flattenedFields","fields","groupByFieldPath","groupBy","replace","groupByField","find","f","name","relationshipConfig","type","collections","c","slug","relationTo","undefined","populate","Array","isArray","forEach","rel","admin","useAsTitle","distinct","payload","findDistinct","collection","depth","field","limit","Number","locale","overrideAccess","page","sort","data","docs","values","map","Promise","all","distinctValue","i","potentiallyPopulatedRelationship","valueOrRelationshipID","id","groupData","draft","fallbackLocale","includeLockStatus","queryByGroup","equals","heading","date","String","i18n","pattern","dateFormat","t","length","newColumnState","NewTable","groupByValue","key","orderableFieldName","orderable"],"sources":["../../../src/views/List/handleGroupBy.ts"],"sourcesContent":["import type {\n ClientCollectionConfig,\n ClientConfig,\n Column,\n ListQuery,\n PaginatedDocs,\n PayloadRequest,\n SanitizedCollectionConfig,\n SelectType,\n ViewTypes,\n Where,\n} from 'payload'\n\nimport { renderTable } from '@payloadcms/ui/rsc'\nimport { formatDate } from '@payloadcms/ui/shared'\nimport { flattenAllFields } from 'payload'\n\nexport const handleGroupBy = async ({\n clientCollectionConfig,\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n query,\n req,\n select,\n trash = false,\n user,\n viewType,\n where: whereWithMergedSearch,\n}: {\n clientCollectionConfig: ClientCollectionConfig\n clientConfig: ClientConfig\n collectionConfig: SanitizedCollectionConfig\n collectionSlug: string\n columns: any[]\n customCellProps?: Record<string, any>\n drawerSlug?: string\n enableRowSelections?: boolean\n query?: ListQuery\n req: PayloadRequest\n select?: SelectType\n trash?: boolean\n user: any\n viewType?: ViewTypes\n where: Where\n}): Promise<{\n columnState: Column[]\n data: PaginatedDocs\n Table: null | React.ReactNode | React.ReactNode[]\n}> => {\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[]\n\n const dataByGroup: Record<string, PaginatedDocs> = {}\n\n // NOTE: is there a faster/better way to do this?\n const flattenedFields = flattenAllFields({ fields: collectionConfig.fields })\n\n const groupByFieldPath = query.groupBy.replace(/^-/, '')\n\n const groupByField = flattenedFields.find((f) => f.name === groupByFieldPath)\n\n const relationshipConfig =\n groupByField?.type === 'relationship'\n ? clientConfig.collections.find((c) => c.slug === groupByField.relationTo)\n : undefined\n\n let populate\n\n if (groupByField?.type === 'relationship' && groupByField.relationTo) {\n const relationTo =\n typeof groupByField.relationTo === 'string'\n ? [groupByField.relationTo]\n : groupByField.relationTo\n\n if (Array.isArray(relationTo)) {\n relationTo.forEach((rel) => {\n if (!populate) {\n populate = {}\n }\n populate[rel] = { [relationshipConfig?.admin.useAsTitle || 'id']: true }\n })\n }\n }\n\n const distinct = await req.payload.findDistinct({\n collection: collectionSlug,\n depth: 1,\n field: groupByFieldPath,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n populate,\n req,\n sort: query?.groupBy,\n trash,\n where: whereWithMergedSearch,\n })\n\n const data = {\n ...distinct,\n docs: distinct.values?.map(() => ({})) || [],\n values: undefined,\n }\n\n await Promise.all(\n distinct.values.map(async (distinctValue, i) => {\n const potentiallyPopulatedRelationship = distinctValue[groupByFieldPath]\n\n const valueOrRelationshipID =\n groupByField?.type === 'relationship' &&\n potentiallyPopulatedRelationship &&\n typeof potentiallyPopulatedRelationship === 'object' &&\n 'id' in potentiallyPopulatedRelationship\n ? potentiallyPopulatedRelationship.id\n : potentiallyPopulatedRelationship\n\n const groupData = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.queryByGroup?.[valueOrRelationshipID]?.limit\n ? Number(query.queryByGroup[valueOrRelationshipID].limit)\n : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.queryByGroup?.[valueOrRelationshipID]?.page\n ? Number(query.queryByGroup[valueOrRelationshipID].page)\n : undefined,\n req,\n // Note: if we wanted to enable table-by-table sorting, we could use this:\n // sort: query?.queryByGroup?.[valueOrRelationshipID]?.sort,\n select,\n sort: query?.sort,\n trash,\n user,\n where: {\n ...(whereWithMergedSearch || {}),\n [groupByFieldPath]: {\n equals: valueOrRelationshipID,\n },\n },\n })\n\n let heading = valueOrRelationshipID\n\n if (\n groupByField?.type === 'relationship' &&\n potentiallyPopulatedRelationship &&\n typeof potentiallyPopulatedRelationship === 'object'\n ) {\n heading =\n potentiallyPopulatedRelationship[relationshipConfig.admin.useAsTitle || 'id'] ||\n valueOrRelationshipID\n }\n\n if (groupByField.type === 'date' && valueOrRelationshipID) {\n heading = formatDate({\n date: String(valueOrRelationshipID),\n i18n: req.i18n,\n pattern: clientConfig.admin.dateFormat,\n })\n }\n\n if (groupByField.type === 'checkbox') {\n if (valueOrRelationshipID === true) {\n heading = req.i18n.t('general:true')\n }\n\n if (valueOrRelationshipID === false) {\n heading = req.i18n.t('general:false')\n }\n }\n\n if (groupData.docs && groupData.docs.length > 0) {\n const { columnState: newColumnState, Table: NewTable } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columns,\n customCellProps,\n data: groupData,\n drawerSlug,\n enableRowSelections,\n groupByFieldPath,\n groupByValue: valueOrRelationshipID,\n heading: heading || req.i18n.t('general:noValue'),\n i18n: req.i18n,\n key: `table-${valueOrRelationshipID}`,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n })\n\n // Only need to set `columnState` once, using the first table's column state\n // This will avoid needing to generate column state explicitly for root context that wraps all tables\n if (!columnState) {\n columnState = newColumnState\n }\n\n if (!Table) {\n Table = []\n }\n\n dataByGroup[valueOrRelationshipID] = groupData\n ;(Table as Array<React.ReactNode>)[i] = NewTable\n }\n }),\n )\n\n return {\n columnState,\n data,\n Table,\n }\n}\n"],"mappings":"AAaA,SAASA,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AAEjC,OAAO,MAAMC,aAAA,G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QACnCQ,OAAA,GAAU9D,GAAA,CAAIiE,IAAI,CAACG,CAAC,CAAC;MACvB;IACF;IAEA,IAAIZ,SAAA,CAAUV,IAAI,IAAIU,SAAA,CAAUV,IAAI,CAACuB,MAAM,GAAG,GAAG;MAC/C,MAAM;QAAE7D,WAAA,EAAa8D,cAAc;QAAE/D,KAAA,EAAOgE;MAAQ,CAAE,GAAGpF,WAAA,CAAY;QACnEI,sBAAA;QACAE,gBAAA;QACAE,OAAA;QACAC,eAAA;QACAiD,IAAA,EAAMW,SAAA;QACN3D,UAAA;QACAC,mBAAA;QACAc,gBAAA;QACA4D,YAAA,EAAclB,qBAAA;QACdQ,OAAA,EAASA,OAAA,IAAW9D,GAAA,CAAIiE,IAAI,CAACG,CAAC,CAAC;QAC/BH,IAAA,EAAMjE,GAAA,CAAIiE,IAAI;QACdQ,GAAA,EAAK,SAASnB,qBAAA,EAAuB;QACrCoB,kBAAA,EAAoBjF,gBAAA,CAAiBkF,SAAS,KAAK,OAAO,WAAWlD,SAAA;QACrES,OAAA,EAASlC,GAAA,CAAIkC,OAAO;QACpBnC,KAAA;QACAiC,UAAA,EAAYvC,gBAAA,CAAiBsC,KAAK,CAACC,UAAU;QAC7C5B;MACF;MAEA;MACA;MACA,IAAI,CAACI,WAAA,EAAa;QAChBA,WAAA,GAAc8D,cAAA;MAChB;MAEA,IAAI,CAAC/D,KAAA,EAAO;QACVA,KAAA,GAAQ,EAAE;MACZ;MAEAE,WAAW,CAAC6C,qBAAA,CAAsB,GAAGE,SAAA;MACnCjD,KAAgC,CAAC6C,CAAA,CAAE,GAAGmB,QAAA;IAC1C;EACF;EAGF,OAAO;IACL/D,WAAA;IACAqC,IAAA;IACAtC;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,oBAAoB,EAIzB,KAAK,SAAS,EAMf,MAAM,SAAS,CAAA;AAShB,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,oBAAoB,EAIzB,KAAK,SAAS,EAMf,MAAM,SAAS,CAAA;AAShB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAQvC,KAAK,kBAAkB,GAAG;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;IAChB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,GAAG,oBAAoB,CAAA;AAExB;;;;;GAKG;AACH,eAAO,MAAM,cAAc,SACnB,kBAAkB,KACvB,OAAO,CAAC;IACT,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CACtB,CA2UA,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAWjD,CAAA"}
|
package/dist/views/List/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui';
|
|
3
3
|
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
4
|
-
import { renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc';
|
|
4
|
+
import { getColumns, renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc';
|
|
5
5
|
import { notFound } from 'next/navigation.js';
|
|
6
6
|
import { combineWhereConstraints, formatAdminURL, isNumber, mergeListSearchAndWhere, transformColumnsToPreferences, transformColumnsToSearchParams } from 'payload/shared';
|
|
7
7
|
import React, { Fragment } from 'react';
|
|
@@ -9,6 +9,7 @@ import { getDocumentPermissions } from '../Document/getDocumentPermissions.js';
|
|
|
9
9
|
import { handleGroupBy } from './handleGroupBy.js';
|
|
10
10
|
import { renderListViewSlots } from './renderListViewSlots.js';
|
|
11
11
|
import { resolveAllFilterOptions } from './resolveAllFilterOptions.js';
|
|
12
|
+
import { transformColumnsToSelect } from './transformColumnsToSelect.js';
|
|
12
13
|
/**
|
|
13
14
|
* This function is responsible for rendering
|
|
14
15
|
* the list view on the server for both:
|
|
@@ -143,6 +144,15 @@ export const renderListView = async args => {
|
|
|
143
144
|
totalDocs: 0,
|
|
144
145
|
totalPages: 0
|
|
145
146
|
};
|
|
147
|
+
const clientCollectionConfig = clientConfig.collections.find(c => c.slug === collectionSlug);
|
|
148
|
+
const columns = getColumns({
|
|
149
|
+
clientConfig,
|
|
150
|
+
collectionConfig: clientCollectionConfig,
|
|
151
|
+
collectionSlug,
|
|
152
|
+
columns: collectionPreferences?.columns,
|
|
153
|
+
i18n
|
|
154
|
+
});
|
|
155
|
+
const select = collectionConfig.admin.enableListViewSelectAPI ? transformColumnsToSelect(columns) : undefined;
|
|
146
156
|
try {
|
|
147
157
|
if (collectionConfig.admin.groupBy && query.groupBy) {
|
|
148
158
|
({
|
|
@@ -150,15 +160,17 @@ export const renderListView = async args => {
|
|
|
150
160
|
data,
|
|
151
161
|
Table
|
|
152
162
|
} = await handleGroupBy({
|
|
163
|
+
clientCollectionConfig,
|
|
153
164
|
clientConfig,
|
|
154
165
|
collectionConfig,
|
|
155
166
|
collectionSlug,
|
|
156
|
-
columns
|
|
167
|
+
columns,
|
|
157
168
|
customCellProps,
|
|
158
169
|
drawerSlug,
|
|
159
170
|
enableRowSelections,
|
|
160
171
|
query,
|
|
161
172
|
req,
|
|
173
|
+
select,
|
|
162
174
|
trash,
|
|
163
175
|
user,
|
|
164
176
|
viewType,
|
|
@@ -176,6 +188,7 @@ export const renderListView = async args => {
|
|
|
176
188
|
overrideAccess: false,
|
|
177
189
|
page: query?.page ? Number(query.page) : undefined,
|
|
178
190
|
req,
|
|
191
|
+
select,
|
|
179
192
|
sort: query?.sort,
|
|
180
193
|
trash,
|
|
181
194
|
user,
|
|
@@ -185,9 +198,9 @@ export const renderListView = async args => {
|
|
|
185
198
|
columnState,
|
|
186
199
|
Table
|
|
187
200
|
} = renderTable({
|
|
188
|
-
clientCollectionConfig
|
|
201
|
+
clientCollectionConfig,
|
|
189
202
|
collectionConfig,
|
|
190
|
-
columns
|
|
203
|
+
columns,
|
|
191
204
|
customCellProps,
|
|
192
205
|
data,
|
|
193
206
|
drawerSlug,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DefaultListView","HydrateAuthProvider","ListQueryProvider","RenderServerComponent","renderFilters","renderTable","upsertPreferences","notFound","combineWhereConstraints","formatAdminURL","isNumber","mergeListSearchAndWhere","transformColumnsToPreferences","transformColumnsToSearchParams","React","Fragment","getDocumentPermissions","handleGroupBy","renderListViewSlots","resolveAllFilterOptions","renderListView","args","clientConfig","customCellProps","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","initPageResult","overrideEntityVisibility","params","query","queryFromArgs","searchParams","trash","viewType","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","collections","read","Error","columnsFromQuery","columns","queryByGroup","JSON","parse","collectionPreferences","key","value","groupBy","limit","Number","undefined","preset","sort","page","admin","pagination","defaultLimit","defaultSort","routes","adminRoute","includes","baseFilterConstraint","baseFilter","baseListFilter","queryPreset","queryPresetPermissions","whereWithMergedSearch","search","where","and","deletedAt","exists","findByID","id","collection","depth","overrideAccess","find","c","data","then","docPermissions","err","logger","error","Table","columnState","docs","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","totalDocs","totalPages","draft","fallbackLocale","includeLockStatus","clientCollectionConfig","orderableFieldName","orderable","useAsTitle","name","msg","renderedFilters","fields","importMap","resolvedFilterOptions","staticDescription","description","t","newDocumentURL","path","hasCreatePermission","create","hasDeletePermission","delete","notFoundDocId","serverProps","listPreferences","listSearchableFields","listViewSlots","clientProps","isInDrawer","Boolean","stringify","List","_jsxs","_jsx","modifySearchParams","Component","components","views","list","Fallback","ListView","RenderedList","message","console"],"sources":["../../../src/views/List/index.tsx"],"sourcesContent":["import { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { notFound } from 'next/navigation.js'\nimport {\n type AdminViewServerProps,\n type CollectionPreferences,\n type Column,\n type ColumnPreference,\n type ListQuery,\n type ListViewClientProps,\n type ListViewServerPropsOnly,\n type PaginatedDocs,\n type QueryPreset,\n type SanitizedCollectionPermission,\n} from 'payload'\nimport {\n combineWhereConstraints,\n formatAdminURL,\n isNumber,\n mergeListSearchAndWhere,\n transformColumnsToPreferences,\n transformColumnsToSearchParams,\n} from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { handleGroupBy } from './handleGroupBy.js'\nimport { renderListViewSlots } from './renderListViewSlots.js'\nimport { resolveAllFilterOptions } from './resolveAllFilterOptions.js'\n\ntype RenderListViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n disableQueryPresets?: boolean\n drawerSlug?: string\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n redirectAfterDelete?: boolean\n redirectAfterDuplicate?: boolean\n /**\n * @experimental This prop is subject to change in future releases.\n */\n trash?: boolean\n} & AdminViewServerProps\n\n/**\n * This function is responsible for rendering\n * the list view on the server for both:\n * - default list view\n * - list view within drawers\n */\nexport const renderListView = async (\n args: RenderListViewArgs,\n): Promise<{\n List: React.ReactNode\n}> => {\n const {\n clientConfig,\n customCellProps,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n initPageResult,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n trash,\n viewType,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!permissions?.collections?.[collectionSlug]?.read) {\n throw new Error('not-found')\n }\n\n const query: ListQuery = queryFromArgs || queryFromReq\n\n const columnsFromQuery: ColumnPreference[] = transformColumnsToPreferences(query?.columns)\n\n query.queryByGroup =\n query?.queryByGroup && typeof query.queryByGroup === 'string'\n ? JSON.parse(query.queryByGroup)\n : query?.queryByGroup\n\n const collectionPreferences = await upsertPreferences<CollectionPreferences>({\n key: `collection-${collectionSlug}`,\n req,\n value: {\n columns: columnsFromQuery,\n groupBy: query?.groupBy,\n limit: isNumber(query?.limit) ? Number(query.limit) : undefined,\n preset: query?.preset,\n sort: query?.sort as string,\n },\n })\n\n query.preset = collectionPreferences?.preset\n\n query.page = isNumber(query?.page) ? Number(query.page) : 0\n\n query.limit = collectionPreferences?.limit || collectionConfig.admin.pagination.defaultLimit\n\n query.sort =\n collectionPreferences?.sort ||\n (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : undefined)\n\n query.groupBy = collectionPreferences?.groupBy\n\n query.columns = transformColumnsToSearchParams(collectionPreferences?.columns || [])\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n if (collectionConfig) {\n if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) {\n throw new Error('not-found')\n }\n\n const baseFilterConstraint = await (\n collectionConfig.admin?.baseFilter ?? collectionConfig.admin?.baseListFilter\n )?.({\n limit: query.limit,\n page: query.page,\n req,\n sort: query.sort,\n })\n\n let queryPreset: QueryPreset | undefined\n let queryPresetPermissions: SanitizedCollectionPermission | undefined\n\n let whereWithMergedSearch = mergeListSearchAndWhere({\n collectionConfig,\n search: typeof query?.search === 'string' ? query.search : undefined,\n where: combineWhereConstraints([query?.where, baseFilterConstraint]),\n })\n\n if (trash === true) {\n whereWithMergedSearch = {\n and: [\n whereWithMergedSearch,\n {\n deletedAt: {\n exists: true,\n },\n },\n ],\n }\n }\n\n if (collectionPreferences?.preset) {\n try {\n queryPreset = (await payload.findByID({\n id: collectionPreferences?.preset,\n collection: 'payload-query-presets',\n depth: 0,\n overrideAccess: false,\n user,\n })) as QueryPreset\n\n if (queryPreset) {\n queryPresetPermissions = await getDocumentPermissions({\n id: queryPreset.id,\n collectionConfig: config.collections.find((c) => c.slug === 'payload-query-presets'),\n data: queryPreset,\n req,\n })?.then(({ docPermissions }) => docPermissions)\n }\n } catch (err) {\n req.payload.logger.error(`Error fetching query preset or preset permissions: ${err}`)\n }\n }\n\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[] = []\n let data: PaginatedDocs = {\n // no results default\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit: query.limit,\n nextPage: null,\n page: 1,\n pagingCounter: 0,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n }\n\n try {\n if (collectionConfig.admin.groupBy && query.groupBy) {\n ;({ columnState, data, Table } = await handleGroupBy({\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns: collectionPreferences?.columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n query,\n req,\n trash,\n user,\n viewType,\n where: whereWithMergedSearch,\n }))\n } else {\n data = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n req,\n sort: query?.sort,\n trash,\n user,\n where: whereWithMergedSearch,\n })\n ;({ columnState, Table } = renderTable({\n clientCollectionConfig: clientConfig.collections.find((c) => c.slug === collectionSlug),\n collectionConfig,\n columns: collectionPreferences?.columns,\n customCellProps,\n data,\n drawerSlug,\n enableRowSelections,\n i18n: req.i18n,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n }))\n }\n } catch (err) {\n if (err.name !== 'QueryError') {\n // QueryErrors are expected when a user filters by a field they do not have access to\n req.payload.logger.error({\n err,\n msg: `There was an error fetching the list view data for collection ${collectionSlug}`,\n })\n throw err\n }\n }\n\n const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap)\n\n const resolvedFilterOptions = await resolveAllFilterOptions({\n fields: collectionConfig.fields,\n req,\n })\n\n const staticDescription =\n typeof collectionConfig.admin.description === 'function'\n ? collectionConfig.admin.description({ t: i18n.t })\n : collectionConfig.admin.description\n\n const newDocumentURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/create`,\n })\n\n const hasCreatePermission = permissions?.collections?.[collectionSlug]?.create\n const hasDeletePermission = permissions?.collections?.[collectionSlug]?.delete\n\n // Check if there's a notFound query parameter (document ID that wasn't found)\n const notFoundDocId = typeof searchParams?.notFound === 'string' ? searchParams.notFound : null\n\n const serverProps: ListViewServerPropsOnly = {\n collectionConfig,\n data,\n i18n,\n limit: query.limit,\n listPreferences: collectionPreferences,\n listSearchableFields: collectionConfig.admin.listSearchableFields,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const listViewSlots = renderListViewSlots({\n clientProps: {\n collectionSlug,\n hasCreatePermission,\n hasDeletePermission,\n newDocumentURL,\n },\n collectionConfig,\n description: staticDescription,\n notFoundDocId,\n payload,\n serverProps,\n })\n\n const isInDrawer = Boolean(drawerSlug)\n\n // Needed to prevent: Only plain objects can be passed to Client Components from Server Components. Objects with toJSON methods are not supported. Convert it manually to a simple value before passing it to props.\n // Is there a way to avoid this? The `where` object is already seemingly plain, but is not bc it originates from the params.\n query.where = query?.where ? JSON.parse(JSON.stringify(query?.where || {})) : undefined\n\n return {\n List: (\n <Fragment>\n <HydrateAuthProvider permissions={permissions} />\n <ListQueryProvider\n collectionSlug={collectionSlug}\n data={data}\n modifySearchParams={!isInDrawer}\n orderableFieldName={collectionConfig.orderable === true ? '_order' : undefined}\n query={query}\n >\n {RenderServerComponent({\n clientProps: {\n ...listViewSlots,\n collectionSlug,\n columnState,\n disableBulkDelete,\n disableBulkEdit: collectionConfig.disableBulkEdit ?? disableBulkEdit,\n disableQueryPresets,\n enableRowSelections,\n hasCreatePermission,\n hasDeletePermission,\n listPreferences: collectionPreferences,\n newDocumentURL,\n queryPreset,\n queryPresetPermissions,\n renderedFilters,\n resolvedFilterOptions,\n Table,\n viewType,\n } satisfies ListViewClientProps,\n Component: collectionConfig?.admin?.components?.views?.list?.Component,\n Fallback: DefaultListView,\n importMap: payload.importMap,\n serverProps,\n })}\n </ListQueryProvider>\n </Fragment>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n\nexport const ListView: React.FC<RenderListViewArgs> = async (args) => {\n try {\n const { List: RenderedList } = await renderListView({ ...args, enableRowSelections: true })\n return RenderedList\n } catch (error) {\n if (error.message === 'not-found') {\n notFound()\n } else {\n console.error(error) // eslint-disable-line no-console\n }\n }\n}\n"],"mappings":";AAAA,SAASA,eAAe,EAAEC,mBAAmB,EAAEC,iBAAiB,QAAQ;AACxE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,aAAa,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ;AAC9D,SAASC,QAAQ,QAAQ;AAazB,SACEC,uBAAuB,EACvBC,cAAc,EACdC,QAAQ,EACRC,uBAAuB,EACvBC,6BAA6B,EAC7BC,8BAA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DefaultListView","HydrateAuthProvider","ListQueryProvider","RenderServerComponent","getColumns","renderFilters","renderTable","upsertPreferences","notFound","combineWhereConstraints","formatAdminURL","isNumber","mergeListSearchAndWhere","transformColumnsToPreferences","transformColumnsToSearchParams","React","Fragment","getDocumentPermissions","handleGroupBy","renderListViewSlots","resolveAllFilterOptions","transformColumnsToSelect","renderListView","args","clientConfig","customCellProps","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","initPageResult","overrideEntityVisibility","params","query","queryFromArgs","searchParams","trash","viewType","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","collections","read","Error","columnsFromQuery","columns","queryByGroup","JSON","parse","collectionPreferences","key","value","groupBy","limit","Number","undefined","preset","sort","page","admin","pagination","defaultLimit","defaultSort","routes","adminRoute","includes","baseFilterConstraint","baseFilter","baseListFilter","queryPreset","queryPresetPermissions","whereWithMergedSearch","search","where","and","deletedAt","exists","findByID","id","collection","depth","overrideAccess","find","c","data","then","docPermissions","err","logger","error","Table","columnState","docs","hasNextPage","hasPrevPage","nextPage","pagingCounter","prevPage","totalDocs","totalPages","clientCollectionConfig","select","enableListViewSelectAPI","draft","fallbackLocale","includeLockStatus","orderableFieldName","orderable","useAsTitle","name","msg","renderedFilters","fields","importMap","resolvedFilterOptions","staticDescription","description","t","newDocumentURL","path","hasCreatePermission","create","hasDeletePermission","delete","notFoundDocId","serverProps","listPreferences","listSearchableFields","listViewSlots","clientProps","isInDrawer","Boolean","stringify","List","_jsxs","_jsx","modifySearchParams","Component","components","views","list","Fallback","ListView","RenderedList","message","console"],"sources":["../../../src/views/List/index.tsx"],"sourcesContent":["import { DefaultListView, HydrateAuthProvider, ListQueryProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getColumns, renderFilters, renderTable, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { notFound } from 'next/navigation.js'\nimport {\n type AdminViewServerProps,\n type CollectionPreferences,\n type Column,\n type ColumnPreference,\n type ListQuery,\n type ListViewClientProps,\n type ListViewServerPropsOnly,\n type PaginatedDocs,\n type QueryPreset,\n type SanitizedCollectionPermission,\n} from 'payload'\nimport {\n combineWhereConstraints,\n formatAdminURL,\n isNumber,\n mergeListSearchAndWhere,\n transformColumnsToPreferences,\n transformColumnsToSearchParams,\n} from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { handleGroupBy } from './handleGroupBy.js'\nimport { renderListViewSlots } from './renderListViewSlots.js'\nimport { resolveAllFilterOptions } from './resolveAllFilterOptions.js'\nimport { transformColumnsToSelect } from './transformColumnsToSelect.js'\n\ntype RenderListViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n disableQueryPresets?: boolean\n drawerSlug?: string\n enableRowSelections: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n redirectAfterDelete?: boolean\n redirectAfterDuplicate?: boolean\n /**\n * @experimental This prop is subject to change in future releases.\n */\n trash?: boolean\n} & AdminViewServerProps\n\n/**\n * This function is responsible for rendering\n * the list view on the server for both:\n * - default list view\n * - list view within drawers\n */\nexport const renderListView = async (\n args: RenderListViewArgs,\n): Promise<{\n List: React.ReactNode\n}> => {\n const {\n clientConfig,\n customCellProps,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n initPageResult,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n trash,\n viewType,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!permissions?.collections?.[collectionSlug]?.read) {\n throw new Error('not-found')\n }\n\n const query: ListQuery = queryFromArgs || queryFromReq\n\n const columnsFromQuery: ColumnPreference[] = transformColumnsToPreferences(query?.columns)\n\n query.queryByGroup =\n query?.queryByGroup && typeof query.queryByGroup === 'string'\n ? JSON.parse(query.queryByGroup)\n : query?.queryByGroup\n\n const collectionPreferences = await upsertPreferences<CollectionPreferences>({\n key: `collection-${collectionSlug}`,\n req,\n value: {\n columns: columnsFromQuery,\n groupBy: query?.groupBy,\n limit: isNumber(query?.limit) ? Number(query.limit) : undefined,\n preset: query?.preset,\n sort: query?.sort as string,\n },\n })\n\n query.preset = collectionPreferences?.preset\n\n query.page = isNumber(query?.page) ? Number(query.page) : 0\n\n query.limit = collectionPreferences?.limit || collectionConfig.admin.pagination.defaultLimit\n\n query.sort =\n collectionPreferences?.sort ||\n (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : undefined)\n\n query.groupBy = collectionPreferences?.groupBy\n\n query.columns = transformColumnsToSearchParams(collectionPreferences?.columns || [])\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n if (collectionConfig) {\n if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) {\n throw new Error('not-found')\n }\n\n const baseFilterConstraint = await (\n collectionConfig.admin?.baseFilter ?? collectionConfig.admin?.baseListFilter\n )?.({\n limit: query.limit,\n page: query.page,\n req,\n sort: query.sort,\n })\n\n let queryPreset: QueryPreset | undefined\n let queryPresetPermissions: SanitizedCollectionPermission | undefined\n\n let whereWithMergedSearch = mergeListSearchAndWhere({\n collectionConfig,\n search: typeof query?.search === 'string' ? query.search : undefined,\n where: combineWhereConstraints([query?.where, baseFilterConstraint]),\n })\n\n if (trash === true) {\n whereWithMergedSearch = {\n and: [\n whereWithMergedSearch,\n {\n deletedAt: {\n exists: true,\n },\n },\n ],\n }\n }\n\n if (collectionPreferences?.preset) {\n try {\n queryPreset = (await payload.findByID({\n id: collectionPreferences?.preset,\n collection: 'payload-query-presets',\n depth: 0,\n overrideAccess: false,\n user,\n })) as QueryPreset\n\n if (queryPreset) {\n queryPresetPermissions = await getDocumentPermissions({\n id: queryPreset.id,\n collectionConfig: config.collections.find((c) => c.slug === 'payload-query-presets'),\n data: queryPreset,\n req,\n })?.then(({ docPermissions }) => docPermissions)\n }\n } catch (err) {\n req.payload.logger.error(`Error fetching query preset or preset permissions: ${err}`)\n }\n }\n\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[] = []\n let data: PaginatedDocs = {\n // no results default\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit: query.limit,\n nextPage: null,\n page: 1,\n pagingCounter: 0,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n }\n\n const clientCollectionConfig = clientConfig.collections.find((c) => c.slug === collectionSlug)\n\n const columns = getColumns({\n clientConfig,\n collectionConfig: clientCollectionConfig,\n collectionSlug,\n columns: collectionPreferences?.columns,\n i18n,\n })\n\n const select = collectionConfig.admin.enableListViewSelectAPI\n ? transformColumnsToSelect(columns)\n : undefined\n\n try {\n if (collectionConfig.admin.groupBy && query.groupBy) {\n ;({ columnState, data, Table } = await handleGroupBy({\n clientCollectionConfig,\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n query,\n req,\n select,\n trash,\n user,\n viewType,\n where: whereWithMergedSearch,\n }))\n } else {\n data = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n req,\n select,\n sort: query?.sort,\n trash,\n user,\n where: whereWithMergedSearch,\n })\n ;({ columnState, Table } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columns,\n customCellProps,\n data,\n drawerSlug,\n enableRowSelections,\n i18n: req.i18n,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n }))\n }\n } catch (err) {\n if (err.name !== 'QueryError') {\n // QueryErrors are expected when a user filters by a field they do not have access to\n req.payload.logger.error({\n err,\n msg: `There was an error fetching the list view data for collection ${collectionSlug}`,\n })\n throw err\n }\n }\n\n const renderedFilters = renderFilters(collectionConfig.fields, req.payload.importMap)\n\n const resolvedFilterOptions = await resolveAllFilterOptions({\n fields: collectionConfig.fields,\n req,\n })\n\n const staticDescription =\n typeof collectionConfig.admin.description === 'function'\n ? collectionConfig.admin.description({ t: i18n.t })\n : collectionConfig.admin.description\n\n const newDocumentURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/create`,\n })\n\n const hasCreatePermission = permissions?.collections?.[collectionSlug]?.create\n const hasDeletePermission = permissions?.collections?.[collectionSlug]?.delete\n\n // Check if there's a notFound query parameter (document ID that wasn't found)\n const notFoundDocId = typeof searchParams?.notFound === 'string' ? searchParams.notFound : null\n\n const serverProps: ListViewServerPropsOnly = {\n collectionConfig,\n data,\n i18n,\n limit: query.limit,\n listPreferences: collectionPreferences,\n listSearchableFields: collectionConfig.admin.listSearchableFields,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const listViewSlots = renderListViewSlots({\n clientProps: {\n collectionSlug,\n hasCreatePermission,\n hasDeletePermission,\n newDocumentURL,\n },\n collectionConfig,\n description: staticDescription,\n notFoundDocId,\n payload,\n serverProps,\n })\n\n const isInDrawer = Boolean(drawerSlug)\n\n // Needed to prevent: Only plain objects can be passed to Client Components from Server Components. Objects with toJSON methods are not supported. Convert it manually to a simple value before passing it to props.\n // Is there a way to avoid this? The `where` object is already seemingly plain, but is not bc it originates from the params.\n query.where = query?.where ? JSON.parse(JSON.stringify(query?.where || {})) : undefined\n\n return {\n List: (\n <Fragment>\n <HydrateAuthProvider permissions={permissions} />\n <ListQueryProvider\n collectionSlug={collectionSlug}\n data={data}\n modifySearchParams={!isInDrawer}\n orderableFieldName={collectionConfig.orderable === true ? '_order' : undefined}\n query={query}\n >\n {RenderServerComponent({\n clientProps: {\n ...listViewSlots,\n collectionSlug,\n columnState,\n disableBulkDelete,\n disableBulkEdit: collectionConfig.disableBulkEdit ?? disableBulkEdit,\n disableQueryPresets,\n enableRowSelections,\n hasCreatePermission,\n hasDeletePermission,\n listPreferences: collectionPreferences,\n newDocumentURL,\n queryPreset,\n queryPresetPermissions,\n renderedFilters,\n resolvedFilterOptions,\n Table,\n viewType,\n } satisfies ListViewClientProps,\n Component: collectionConfig?.admin?.components?.views?.list?.Component,\n Fallback: DefaultListView,\n importMap: payload.importMap,\n serverProps,\n })}\n </ListQueryProvider>\n </Fragment>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n\nexport const ListView: React.FC<RenderListViewArgs> = async (args) => {\n try {\n const { List: RenderedList } = await renderListView({ ...args, enableRowSelections: true })\n return RenderedList\n } catch (error) {\n if (error.message === 'not-found') {\n notFound()\n } else {\n console.error(error) // eslint-disable-line no-console\n }\n }\n}\n"],"mappings":";AAAA,SAASA,eAAe,EAAEC,mBAAmB,EAAEC,iBAAiB,QAAQ;AACxE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,UAAU,EAAEC,aAAa,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ;AAC1E,SAASC,QAAQ,QAAQ;AAazB,SACEC,uBAAuB,EACvBC,cAAc,EACdC,QAAQ,EACRC,uBAAuB,EACvBC,6BAA6B,EAC7BC,8BAA8B,QACzB;AACP,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,wBAAwB,QAAQ;AAmBzC;;;;;;AAMA,OAAO,MAAMC,cAAA,GAAiB,MAC5BC,IAAA;EAIA,MAAM;IACJC,YAAY;IACZC,eAAe;IACfC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,UAAU;IACVC,mBAAmB;IACnBC,cAAc;IACdC,wBAAwB;IACxBC,MAAM;IACNC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UACNoD,kBAAA,EAAoB,CAACN,UAAA;UACrBxB,kBAAA,EAAoB9E,gBAAA,CAAiB+E,SAAS,KAAK,OAAO,WAAWpD,SAAA;UACrEhC,KAAA,EAAOA,KAAA;oBAEN/B,qBAAA,CAAsB;YACrByI,WAAA,EAAa;cACX,GAAGD,aAAa;cAChBlG,cAAA;cACA6D,WAAA;cACA5E,iBAAA;cACAC,eAAA,EAAiBY,gBAAA,CAAiBZ,eAAe,IAAIA,eAAA;cACrDC,mBAAA;cACAE,mBAAA;cACAqG,mBAAA;cACAE,mBAAA;cACAI,eAAA,EAAiB7E,qBAAA;cACjBqE,cAAA;cACAjD,WAAA;cACAC,sBAAA;cACAyC,eAAA;cACAG,qBAAA;cACAxB,KAAA;cACA/D;YACF;YACA8G,SAAA,EAAW7G,gBAAA,EAAkB+B,KAAA,EAAO+E,UAAA,EAAYC,KAAA,EAAOC,IAAA,EAAMH,SAAA;YAC7DI,QAAA,EAAUxJ,eAAA;YACV4H,SAAA,EAAW7E,OAAA,CAAQ6E,SAAS;YAC5BY;UACF;;;IAIR;EACF;EAEA,MAAM,IAAIlF,KAAA,CAAM;AAClB;AAEA,OAAO,MAAMmG,QAAA,GAAyC,MAAOlI,IAAA;EAC3D,IAAI;IACF,MAAM;MAAEyH,IAAA,EAAMU;IAAY,CAAE,GAAG,MAAMpI,cAAA,CAAe;MAAE,GAAGC,IAAI;MAAEO,mBAAA,EAAqB;IAAK;IACzF,OAAO4H,YAAA;EACT,EAAE,OAAOtD,KAAA,EAAO;IACd,IAAIA,KAAA,CAAMuD,OAAO,KAAK,aAAa;MACjCnJ,QAAA;IACF,OAAO;MACLoJ,OAAA,CAAQxD,KAAK,CAACA,KAAA,EAAO;MAAA;IACvB;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformColumnsToSelect.d.ts","sourceRoot":"","sources":["../../../src/views/List/transformColumnsToSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAE3D,eAAO,MAAM,wBAAwB,YAAa,gBAAgB,EAAE,KAAG,UAMjD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformColumnsToSelect.js","names":["transformColumnsToSelect","columns","reduce","acc","column","active","accessor"],"sources":["../../../src/views/List/transformColumnsToSelect.ts"],"sourcesContent":["import type { ColumnPreference, SelectType } from 'payload'\n\nexport const transformColumnsToSelect = (columns: ColumnPreference[]): SelectType =>\n columns.reduce((acc, column) => {\n if (column.active) {\n acc[column.accessor] = true\n }\n return acc\n }, {} as SelectType)\n"],"mappings":"AAEA,OAAO,MAAMA,wBAAA,GAA4BC,OAAA,IACvCA,OAAA,CAAQC,MAAM,CAAC,CAACC,GAAA,EAAKC,MAAA;EACnB,IAAIA,MAAA,CAAOC,MAAM,EAAE;IACjBF,GAAG,CAACC,MAAA,CAAOE,QAAQ,CAAC,GAAG;EACzB;EACA,OAAOH,GAAA;AACT,GAAG,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.55.0-canary.
|
|
3
|
+
"version": "3.55.0-canary.12",
|
|
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.55.0-canary.
|
|
91
|
-
"@payloadcms/
|
|
92
|
-
"@payloadcms/
|
|
90
|
+
"@payloadcms/graphql": "3.55.0-canary.12",
|
|
91
|
+
"@payloadcms/ui": "3.55.0-canary.12",
|
|
92
|
+
"@payloadcms/translations": "3.55.0-canary.12"
|
|
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.55.0-canary.
|
|
110
|
+
"payload": "3.55.0-canary.12"
|
|
111
111
|
},
|
|
112
112
|
"peerDependencies": {
|
|
113
113
|
"graphql": "^16.8.1",
|
|
114
114
|
"next": "^15.2.3",
|
|
115
|
-
"payload": "3.55.0-canary.
|
|
115
|
+
"payload": "3.55.0-canary.12"
|
|
116
116
|
},
|
|
117
117
|
"engines": {
|
|
118
118
|
"node": "^18.20.2 || >=20.9.0"
|