@payloadcms/ui 3.1.1-canary.c40ff01 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js +44 -27
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DatePicker/index.scss +1 -1
- package/dist/elements/ReactSelect/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/index.js +11 -0
- package/dist/elements/ReactSelect/index.js.map +1 -1
- package/dist/elements/ReactSelect/index.scss +0 -3
- package/dist/elements/TableColumns/index.d.ts.map +1 -1
- package/dist/elements/TableColumns/index.js +1 -1
- package/dist/elements/TableColumns/index.js.map +1 -1
- package/dist/exports/client/{DatePicker-23XPGPYP.js → DatePicker-QST7QHAX.js} +2 -2
- package/dist/exports/client/{chunk-PELL3UMP.js → chunk-5LUHGAPX.js} +3 -3
- package/dist/exports/client/{chunk-PELL3UMP.js.map → chunk-5LUHGAPX.js.map} +3 -3
- package/dist/exports/client/index.js +9 -9
- package/dist/exports/client/index.js.map +3 -3
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +2 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/providers/ListQuery/index.d.ts.map +1 -1
- package/dist/providers/ListQuery/index.js +1 -1
- package/dist/providers/ListQuery/index.js.map +1 -1
- package/dist/providers/Locale/index.js +29 -30
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildTableState.d.ts +7 -1
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +26 -8
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/views/Edit/Auth/types.d.ts +2 -2
- package/dist/views/Edit/Auth/types.d.ts.map +1 -1
- package/dist/views/Edit/Auth/types.js.map +1 -1
- package/package.json +4 -4
- package/dist/utilities/getClientConfig.d.ts +0 -8
- package/dist/utilities/getClientConfig.d.ts.map +0 -1
- package/dist/utilities/getClientConfig.js +0 -25
- package/dist/utilities/getClientConfig.js.map +0 -1
- /package/dist/exports/client/{DatePicker-23XPGPYP.js.map → DatePicker-QST7QHAX.js.map} +0 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
import type { BuildTableStateArgs, ClientConfig, ErrorResult, ImportMap, PaginatedDocs, SanitizedConfig } from 'payload';
|
|
2
3
|
import type { Column } from '../elements/Table/index.js';
|
|
3
4
|
import type { ListPreferences } from '../elements/TableColumns/index.js';
|
|
5
|
+
export declare const getClientConfig: (args: {
|
|
6
|
+
config: SanitizedConfig;
|
|
7
|
+
i18n: I18nClient;
|
|
8
|
+
importMap: ImportMap;
|
|
9
|
+
}) => ClientConfig;
|
|
4
10
|
type BuildTableStateSuccessResult = {
|
|
5
11
|
clientConfig?: ClientConfig;
|
|
6
12
|
data: PaginatedDocs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTableState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildTableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,YAAY,EACZ,WAAW,EACX,aAAa,
|
|
1
|
+
{"version":3,"file":"buildTableState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildTableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,mBAAmB,EAEnB,YAAY,EACZ,WAAW,EACX,SAAS,EACT,aAAa,EAEb,eAAe,EAChB,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAUxE,eAAO,MAAM,eAAe,SAAU;IACpC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;CACrB,KAAG,YAcH,CAAA;AAED,KAAK,4BAA4B,GAAG;IAClC,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,IAAI,EAAE,aAAa,CAAA;IACnB,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,WAAW,EAAE,eAAe,CAAA;IAC5B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;IAC7C,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,eAAe,CAAC,EAAE,KAAK,CAAA;IACvB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,CACA;IACE,OAAO,EAAE,MAAM,CAAA;CAChB,GACD,WAAW,CACd,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,0BAA0B,GAAG,4BAA4B,CAAA;AAE7F,eAAO,MAAM,sBAAsB,SAC3B,mBAAmB,KACxB,OAAO,CAAC,qBAAqB,CAqB/B,CAAA;AAED,eAAO,MAAM,eAAe,SACpB,mBAAmB,KACxB,OAAO,CAAC,4BAA4B,CA6KtC,CAAA"}
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
-
import { dequal } from 'dequal';
|
|
2
|
-
import { formatErrors } from 'payload';
|
|
3
|
-
import { getClientConfig } from './getClientConfig.js';
|
|
1
|
+
import { dequal } from 'dequal/lite';
|
|
2
|
+
import { createClientConfig, formatErrors } from 'payload';
|
|
4
3
|
import { renderFilters, renderTable } from './renderTable.js';
|
|
4
|
+
let cachedClientConfig = global._payload_clientConfig;
|
|
5
|
+
if (!cachedClientConfig) {
|
|
6
|
+
cachedClientConfig = global._payload_clientConfig = null;
|
|
7
|
+
}
|
|
8
|
+
export const getClientConfig = args => {
|
|
9
|
+
const {
|
|
10
|
+
config,
|
|
11
|
+
i18n,
|
|
12
|
+
importMap
|
|
13
|
+
} = args;
|
|
14
|
+
if (cachedClientConfig && process.env.NODE_ENV !== 'development') {
|
|
15
|
+
return cachedClientConfig;
|
|
16
|
+
}
|
|
17
|
+
cachedClientConfig = createClientConfig({
|
|
18
|
+
config,
|
|
19
|
+
i18n,
|
|
20
|
+
importMap
|
|
21
|
+
});
|
|
22
|
+
return cachedClientConfig;
|
|
23
|
+
};
|
|
5
24
|
export const buildTableStateHandler = async args => {
|
|
6
25
|
const {
|
|
7
26
|
req
|
|
@@ -112,10 +131,6 @@ export const buildTableState = async args => {
|
|
|
112
131
|
});
|
|
113
132
|
let newPrefs = preferencesResult.value;
|
|
114
133
|
if (!preferencesResult.id || !dequal(columns, preferencesResult?.columns)) {
|
|
115
|
-
const mergedPrefs = {
|
|
116
|
-
...(preferencesResult || {}),
|
|
117
|
-
columns
|
|
118
|
-
};
|
|
119
134
|
const preferencesArgs = {
|
|
120
135
|
collection: 'payload-preferences',
|
|
121
136
|
data: {
|
|
@@ -124,7 +139,10 @@ export const buildTableState = async args => {
|
|
|
124
139
|
collection: user.collection,
|
|
125
140
|
value: user.id
|
|
126
141
|
},
|
|
127
|
-
value:
|
|
142
|
+
value: {
|
|
143
|
+
...(preferencesResult?.value || {}),
|
|
144
|
+
columns
|
|
145
|
+
}
|
|
128
146
|
},
|
|
129
147
|
depth: 0,
|
|
130
148
|
req
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTableState.js","names":["dequal","formatErrors","getClientConfig","renderFilters","renderTable","buildTableStateHandler","args","req","res","buildTableState","err","payload","logger","error","msg","message","collectionSlug","columns","docs","docsFromArgs","enableRowSelections","query","renderRowTypes","i18n","config","user","tableAppearance","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","length","clientConfig","importMap","collectionConfig","clientCollectionConfig","slug","preferencesKey","preferencesResult","where","and","key","equals","id","then","value","newPrefs","mergedPrefs","preferencesArgs","data","update","create","fields","parseInt","undefined","page","sort","columnState","Table","columnPreferences","useAsTitle","renderedFilters","preferences","state"],"sources":["../../src/utilities/buildTableState.ts"],"sourcesContent":["import type {\n BuildTableStateArgs,\n ClientCollectionConfig,\n ClientConfig,\n ErrorResult,\n PaginatedDocs,\n SanitizedCollectionConfig,\n} from 'payload'\n\nimport { dequal } from 'dequal' // TODO: Can we change this to dequal/lite ? If not, please add comment explaining why\nimport { formatErrors } from 'payload'\n\nimport type { Column } from '../elements/Table/index.js'\nimport type { ListPreferences } from '../elements/TableColumns/index.js'\n\nimport { getClientConfig } from './getClientConfig.js'\nimport { renderFilters, renderTable } from './renderTable.js'\n\ntype BuildTableStateSuccessResult = {\n clientConfig?: ClientConfig\n data: PaginatedDocs\n errors?: never\n preferences: ListPreferences\n renderedFilters: Map<string, React.ReactNode>\n state: Column[]\n Table: React.ReactNode\n}\n\ntype BuildTableStateErrorResult = {\n data?: any\n renderedFilters?: never\n state?: never\n Table?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildTableStateResult = BuildTableStateErrorResult | BuildTableStateSuccessResult\n\nexport const buildTableStateHandler = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateResult> => {\n const { req } = args\n\n try {\n const res = await buildTableState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildTableState = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateSuccessResult> => {\n const {\n collectionSlug,\n columns,\n docs: docsFromArgs,\n enableRowSelections,\n query,\n renderRowTypes,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n tableAppearance,\n } = args\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n })\n\n let collectionConfig: SanitizedCollectionConfig\n let clientCollectionConfig: ClientCollectionConfig\n\n if (req.payload.collections[collectionSlug]) {\n collectionConfig = req.payload.collections[collectionSlug].config\n clientCollectionConfig = clientConfig.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n }\n\n // get prefs, then set update them using the columns that we just received\n const preferencesKey = `${collectionSlug}-list`\n\n const preferencesResult = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n pagination: false,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0] ?? { id: null, value: {} })\n\n let newPrefs = preferencesResult.value\n\n if (!preferencesResult.id || !dequal(columns, preferencesResult?.columns)) {\n const mergedPrefs = {\n ...(preferencesResult || {}),\n columns,\n }\n const preferencesArgs = {\n collection: 'payload-preferences',\n data: {\n key: preferencesKey,\n user: {\n collection: user.collection,\n value: user.id,\n },\n value: mergedPrefs,\n },\n depth: 0,\n req,\n }\n\n if (preferencesResult.id) {\n newPrefs = await payload\n .update({\n ...preferencesArgs,\n id: preferencesResult.id,\n })\n ?.then((res) => res.value as ListPreferences)\n } else {\n newPrefs = await payload.create(preferencesArgs)?.then((res) => res.value as ListPreferences)\n }\n }\n\n const fields = collectionConfig.fields\n\n let docs = docsFromArgs\n let data: PaginatedDocs\n\n // lookup docs, if desired, i.e. within `join` field which initialize with `depth: 0`\n\n if (!docs || query) {\n data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: query?.limit ? parseInt(query.limit, 10) : undefined,\n page: query?.page ? parseInt(query.page, 10) : undefined,\n sort: query?.sort,\n where: query?.where,\n })\n\n docs = data.docs\n }\n\n const { columnState, Table } = renderTable({\n collectionConfig: clientCollectionConfig,\n columnPreferences: undefined, // TODO, might not be needed\n columns,\n docs,\n enableRowSelections,\n fields,\n i18n: req.i18n,\n payload,\n renderRowTypes,\n tableAppearance,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(fields, req.payload.importMap)\n\n return {\n data,\n preferences: newPrefs,\n renderedFilters,\n state: columnState,\n Table,\n }\n}\n"],"mappings":"AASA,SAASA,MAAM,QAAQ,SAAQ,CAAC;AAChC,SAASC,YAAY,QAAQ;AAK7B,SAASC,eAAe,QAAQ;AAChC,SAASC,aAAa,EAAEC,WAAW,QAAQ;AA0B3C,OAAO,MAAMC,sBAAA,GAAyB,MACpCC,IAAA;EAEA,MAAM;IAAEC;EAAG,CAAE,GAAGD,IAAA;EAEhB,IAAI;IACF,MAAME,GAAA,GAAM,MAAMC,eAAA,CAAgBH,IAAA;IAClC,OAAOE,GAAA;EACT,EAAE,OAAOE,GAAA,EAAK;IACZH,GAAA,CAAII,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;MAAEH,GAAA;MAAKI,GAAA,EAAK;IAAyC;IAE9E,IAAIJ,GAAA,CAAIK,OAAO,KAAK,8CAA8C;MAChE,OAAO;QACLA,OAAA,EAASL,GAAA,CAAIK;MACf;I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,EAAmBL,SAAA;IACnB/C,OAAA;IACAC,IAAA;IACAE,mBAAA;IACA0C,MAAA;IACAvC,IAAA,EAAMhB,GAAA,CAAIgB,IAAI;IACdZ,OAAA;IACAW,cAAA;IACAI,eAAA;IACA4C,UAAA,EAAY1B,gBAAA,CAAiBd,KAAK,CAACwC;EACrC;EAEA,MAAMC,eAAA,GAAkBpE,aAAA,CAAc2D,MAAA,EAAQvD,GAAA,CAAII,OAAO,CAACgC,SAAS;EAEnE,OAAO;IACLgB,IAAA;IACAa,WAAA,EAAahB,QAAA;IACbe,eAAA;IACAE,KAAA,EAAON,WAAA;IACPC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildTableState.js","names":["dequal","createClientConfig","formatErrors","renderFilters","renderTable","cachedClientConfig","global","_payload_clientConfig","getClientConfig","args","config","i18n","importMap","process","env","NODE_ENV","buildTableStateHandler","req","res","buildTableState","err","payload","logger","error","msg","message","collectionSlug","columns","docs","docsFromArgs","enableRowSelections","query","renderRowTypes","user","tableAppearance","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","length","clientConfig","collectionConfig","clientCollectionConfig","slug","preferencesKey","preferencesResult","where","and","key","equals","id","then","value","newPrefs","preferencesArgs","data","update","create","fields","parseInt","undefined","page","sort","columnState","Table","columnPreferences","useAsTitle","renderedFilters","preferences","state"],"sources":["../../src/utilities/buildTableState.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n BuildTableStateArgs,\n ClientCollectionConfig,\n ClientConfig,\n ErrorResult,\n ImportMap,\n PaginatedDocs,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport { dequal } from 'dequal/lite'\nimport { createClientConfig, formatErrors } from 'payload'\n\nimport type { Column } from '../elements/Table/index.js'\nimport type { ListPreferences } from '../elements/TableColumns/index.js'\n\nimport { renderFilters, renderTable } from './renderTable.js'\n\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getClientConfig = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n}): ClientConfig => {\n const { config, i18n, importMap } = args\n\n if (cachedClientConfig && process.env.NODE_ENV !== 'development') {\n return cachedClientConfig\n }\n\n cachedClientConfig = createClientConfig({\n config,\n i18n,\n importMap,\n })\n\n return cachedClientConfig\n}\n\ntype BuildTableStateSuccessResult = {\n clientConfig?: ClientConfig\n data: PaginatedDocs\n errors?: never\n preferences: ListPreferences\n renderedFilters: Map<string, React.ReactNode>\n state: Column[]\n Table: React.ReactNode\n}\n\ntype BuildTableStateErrorResult = {\n data?: any\n renderedFilters?: never\n state?: never\n Table?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildTableStateResult = BuildTableStateErrorResult | BuildTableStateSuccessResult\n\nexport const buildTableStateHandler = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateResult> => {\n const { req } = args\n\n try {\n const res = await buildTableState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildTableState = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateSuccessResult> => {\n const {\n collectionSlug,\n columns,\n docs: docsFromArgs,\n enableRowSelections,\n query,\n renderRowTypes,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n tableAppearance,\n } = args\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n })\n\n let collectionConfig: SanitizedCollectionConfig\n let clientCollectionConfig: ClientCollectionConfig\n\n if (req.payload.collections[collectionSlug]) {\n collectionConfig = req.payload.collections[collectionSlug].config\n clientCollectionConfig = clientConfig.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n }\n\n // get prefs, then set update them using the columns that we just received\n const preferencesKey = `${collectionSlug}-list`\n\n const preferencesResult = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n pagination: false,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0] ?? { id: null, value: {} })\n\n let newPrefs = preferencesResult.value\n\n if (!preferencesResult.id || !dequal(columns, preferencesResult?.columns)) {\n const preferencesArgs = {\n collection: 'payload-preferences',\n data: {\n key: preferencesKey,\n user: {\n collection: user.collection,\n value: user.id,\n },\n value: {\n ...(preferencesResult?.value || {}),\n columns,\n },\n },\n depth: 0,\n req,\n }\n\n if (preferencesResult.id) {\n newPrefs = await payload\n .update({\n ...preferencesArgs,\n id: preferencesResult.id,\n })\n ?.then((res) => res.value as ListPreferences)\n } else {\n newPrefs = await payload.create(preferencesArgs)?.then((res) => res.value as ListPreferences)\n }\n }\n\n const fields = collectionConfig.fields\n\n let docs = docsFromArgs\n let data: PaginatedDocs\n\n // lookup docs, if desired, i.e. within `join` field which initialize with `depth: 0`\n\n if (!docs || query) {\n data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: query?.limit ? parseInt(query.limit, 10) : undefined,\n page: query?.page ? parseInt(query.page, 10) : undefined,\n sort: query?.sort,\n where: query?.where,\n })\n\n docs = data.docs\n }\n\n const { columnState, Table } = renderTable({\n collectionConfig: clientCollectionConfig,\n columnPreferences: undefined, // TODO, might not be needed\n columns,\n docs,\n enableRowSelections,\n fields,\n i18n: req.i18n,\n payload,\n renderRowTypes,\n tableAppearance,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(fields, req.payload.importMap)\n\n return {\n data,\n preferences: newPrefs,\n renderedFilters,\n state: columnState,\n Table,\n }\n}\n"],"mappings":"AAYA,SAASA,MAAM,QAAQ;AACvB,SAASC,kBAAkB,EAAEC,YAAY,QAAQ;AAKjD,SAASC,aAAa,EAAEC,WAAW,QAAQ;AAE3C,IAAIC,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB;AAErD,IAAI,CAACF,kBAAA,EAAoB;EACvBA,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB,GAAG;AACtD;AAEA,OAAO,MAAMC,eAAA,GAAmBC,IAAA;EAK9B,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAS,CAAE,GAAGH,IAAA;EAEpC,IAAIJ,kBAAA,IAAsBQ,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;IAChE,OAAOV,kBAAA;EACT;EAEAA,kBAAA,GAAqBJ,kBAAA,CAAmB;IACtCS,MAAA;IACAC,IAAA;IACAC;EACF;EAEA,OAAOP,kBAAA;AACT;AA0BA,OAAO,MAAMW,sBAAA,GAAyB,MACpCP,IAAA;EAEA,MAAM;IAAEQ;EAAG,CAAE,GAAGR,IAAA;EAEhB,IAAI;IACF,MAAMS,GAAA,GAAM,MAAMC,eAAA,CAAgBV,IAAA;IAClC,OAAOS,GAAA;EACT,EAAE,OAAOE,GAAA,EAAK;IACZH,GAAA,CAAII,OAAO,CAACC,MAAM,C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,IAAA,CAAKrC,IAAI;EAClB;EAEA,MAAM;IAAE6C,WAAW;IAAEC;EAAK,CAAE,GAAGtE,WAAA,CAAY;IACzC+C,gBAAA,EAAkBC,sBAAA;IAClBuB,iBAAA,EAAmBL,SAAA;IACnB3C,OAAA;IACAC,IAAA;IACAE,mBAAA;IACAsC,MAAA;IACAzD,IAAA,EAAMM,GAAA,CAAIN,IAAI;IACdU,OAAA;IACAW,cAAA;IACAE,eAAA;IACA0C,UAAA,EAAYzB,gBAAA,CAAiBb,KAAK,CAACsC;EACrC;EAEA,MAAMC,eAAA,GAAkB1E,aAAA,CAAciE,MAAA,EAAQnD,GAAA,CAAII,OAAO,CAACT,SAAS;EAEnE,OAAO;IACLqD,IAAA;IACAa,WAAA,EAAaf,QAAA;IACbc,eAAA;IACAE,KAAA,EAAON,WAAA;IACPC;EACF;AACF","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SanitizedCollectionConfig } from 'payload';
|
|
1
|
+
import type { SanitizedCollectionConfig, VerifyConfig } from 'payload';
|
|
2
2
|
export type Props = {
|
|
3
3
|
className?: string;
|
|
4
4
|
collectionSlug: SanitizedCollectionConfig['slug'];
|
|
@@ -12,6 +12,6 @@ export type Props = {
|
|
|
12
12
|
setValidateBeforeSubmit: (validate: boolean) => void;
|
|
13
13
|
useAPIKey?: boolean;
|
|
14
14
|
username: string;
|
|
15
|
-
verify?: boolean;
|
|
15
|
+
verify?: boolean | VerifyConfig;
|
|
16
16
|
};
|
|
17
17
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtE,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACjD,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAA;IACzE,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC/C,uBAAuB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;IACpD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,GAAG,YAAY,CAAA;CAChC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/views/Edit/Auth/types.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from 'payload'\n\nexport type Props = {\n className?: string\n collectionSlug: SanitizedCollectionConfig['slug']\n disableLocalStrategy?: boolean\n email: string\n loginWithUsername: SanitizedCollectionConfig['auth']['loginWithUsername']\n operation: 'create' | 'update'\n readOnly: boolean\n requirePassword?: boolean\n setSchemaPathSegments: (path: string[]) => void\n setValidateBeforeSubmit: (validate: boolean) => void\n useAPIKey?: boolean\n username: string\n verify?: boolean\n}\n"],"mappings":"AAEA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/views/Edit/Auth/types.ts"],"sourcesContent":["import type { SanitizedCollectionConfig, VerifyConfig } from 'payload'\n\nexport type Props = {\n className?: string\n collectionSlug: SanitizedCollectionConfig['slug']\n disableLocalStrategy?: boolean\n email: string\n loginWithUsername: SanitizedCollectionConfig['auth']['loginWithUsername']\n operation: 'create' | 'update'\n readOnly: boolean\n requirePassword?: boolean\n setSchemaPathSegments: (path: string[]) => void\n setValidateBeforeSubmit: (validate: boolean) => void\n useAPIKey?: boolean\n username: string\n verify?: boolean | VerifyConfig\n}\n"],"mappings":"AAEA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.1.1
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"ts-essentials": "10.0.3",
|
|
134
134
|
"use-context-selector": "2.0.0",
|
|
135
135
|
"uuid": "10.0.0",
|
|
136
|
-
"@payloadcms/translations": "3.1.1
|
|
136
|
+
"@payloadcms/translations": "3.1.1"
|
|
137
137
|
},
|
|
138
138
|
"devDependencies": {
|
|
139
139
|
"@babel/cli": "^7.24.5",
|
|
@@ -152,13 +152,13 @@
|
|
|
152
152
|
"esbuild-sass-plugin": "3.3.1",
|
|
153
153
|
"eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
|
|
154
154
|
"@payloadcms/eslint-config": "3.0.0",
|
|
155
|
-
"payload": "3.1.1
|
|
155
|
+
"payload": "3.1.1"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"next": "^15.0.0",
|
|
159
159
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
160
160
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
161
|
-
"payload": "3.1.1
|
|
161
|
+
"payload": "3.1.1"
|
|
162
162
|
},
|
|
163
163
|
"engines": {
|
|
164
164
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
-
import type { ClientConfig, ImportMap, SanitizedConfig } from 'payload';
|
|
3
|
-
export declare const getClientConfig: (args: {
|
|
4
|
-
config: SanitizedConfig;
|
|
5
|
-
i18n: I18nClient;
|
|
6
|
-
importMap: ImportMap;
|
|
7
|
-
}) => ClientConfig;
|
|
8
|
-
//# sourceMappingURL=getClientConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getClientConfig.d.ts","sourceRoot":"","sources":["../../src/utilities/getClientConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAWvE,eAAO,MAAM,eAAe,SACnB;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,KAAG,YAiB9E,CAAA"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createClientConfig } from 'payload';
|
|
2
|
-
import { cache } from 'react';
|
|
3
|
-
let cachedClientConfig = global._payload_clientConfig;
|
|
4
|
-
if (!cachedClientConfig) {
|
|
5
|
-
cachedClientConfig = global._payload_clientConfig = null;
|
|
6
|
-
}
|
|
7
|
-
export const getClientConfig = cache(args => {
|
|
8
|
-
if (cachedClientConfig && !global._payload_doNotCacheClientConfig) {
|
|
9
|
-
return cachedClientConfig;
|
|
10
|
-
}
|
|
11
|
-
const {
|
|
12
|
-
config,
|
|
13
|
-
i18n,
|
|
14
|
-
importMap
|
|
15
|
-
} = args;
|
|
16
|
-
cachedClientConfig = createClientConfig({
|
|
17
|
-
config,
|
|
18
|
-
i18n,
|
|
19
|
-
importMap
|
|
20
|
-
});
|
|
21
|
-
global._payload_clientConfig = cachedClientConfig;
|
|
22
|
-
global._payload_doNotCacheClientConfig = false;
|
|
23
|
-
return cachedClientConfig;
|
|
24
|
-
});
|
|
25
|
-
//# sourceMappingURL=getClientConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getClientConfig.js","names":["createClientConfig","cache","cachedClientConfig","global","_payload_clientConfig","getClientConfig","args","_payload_doNotCacheClientConfig","config","i18n","importMap"],"sources":["../../src/utilities/getClientConfig.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { ClientConfig, ImportMap, SanitizedConfig } from 'payload'\n\nimport { createClientConfig } from 'payload'\nimport { cache } from 'react'\n\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getClientConfig = cache(\n (args: { config: SanitizedConfig; i18n: I18nClient; importMap: ImportMap }): ClientConfig => {\n if (cachedClientConfig && !global._payload_doNotCacheClientConfig) {\n return cachedClientConfig\n }\n const { config, i18n, importMap } = args\n\n cachedClientConfig = createClientConfig({\n config,\n i18n,\n importMap,\n })\n global._payload_clientConfig = cachedClientConfig\n\n global._payload_doNotCacheClientConfig = false\n\n return cachedClientConfig\n },\n)\n"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,KAAK,QAAQ;AAEtB,IAAIC,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB;AAErD,IAAI,CAACF,kBAAA,EAAoB;EACvBA,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB,GAAG;AACtD;AAEA,OAAO,MAAMC,eAAA,GAAkBJ,KAAA,CAC5BK,IAAA;EACC,IAAIJ,kBAAA,IAAsB,CAACC,MAAA,CAAOI,+BAA+B,EAAE;IACjE,OAAOL,kBAAA;EACT;EACA,MAAM;IAAEM,MAAM;IAAEC,IAAI;IAAEC;EAAS,CAAE,GAAGJ,IAAA;EAEpCJ,kBAAA,GAAqBF,kBAAA,CAAmB;IACtCQ,MAAA;IACAC,IAAA;IACAC;EACF;EACAP,MAAA,CAAOC,qBAAqB,GAAGF,kBAAA;EAE/BC,MAAA,CAAOI,+BAA+B,GAAG;EAEzC,OAAOL,kBAAA;AACT","ignoreList":[]}
|
|
File without changes
|