@payloadcms/ui 3.1.0 → 3.1.1-canary.c40ff01
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/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 +1 -2
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/providers/Locale/index.js +30 -29
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/utilities/buildTableState.d.ts +1 -7
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +2 -21
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/getClientConfig.d.ts +8 -0
- package/dist/utilities/getClientConfig.d.ts.map +1 -0
- package/dist/utilities/getClientConfig.js +25 -0
- package/dist/utilities/getClientConfig.js.map +1 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderField.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAanD,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"renderField.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAanD,eAAO,MAAM,WAAW,EAAE,iBA4NzB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getTranslation } from '@payloadcms/translations';
|
|
3
|
-
import { createClientField,
|
|
3
|
+
import { createClientField, MissingEditorProp } from 'payload';
|
|
4
4
|
import { RenderServerComponent } from '../../elements/RenderServerComponent/index.js';
|
|
5
5
|
// eslint-disable-next-line payload/no-imports-from-exports-dir -- need this to reference already existing bundle. Otherwise, bundle size increases., payload/no-imports-from-exports-dir
|
|
6
6
|
import { FieldDescription } from '../../exports/client/index.js';
|
|
@@ -25,7 +25,6 @@ export const renderField = ({
|
|
|
25
25
|
siblingData
|
|
26
26
|
}) => {
|
|
27
27
|
const clientField = createClientField({
|
|
28
|
-
clientField: deepCopyObjectSimple(fieldConfig),
|
|
29
28
|
defaultIDType: req.payload.config.db.defaultIDType,
|
|
30
29
|
field: fieldConfig,
|
|
31
30
|
i18n: req.i18n,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","deepCopyObjectSimple","MissingEditorProp","RenderServerComponent","FieldDescription","defaultUIFieldComponentKeys","renderField","id","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","operation","parentPath","parentSchemaPath","path","permissions","preferences","req","schemaPath","siblingData","clientField","defaultIDType","payload","config","db","field","i18n","importMap","clientProps","customComponents","readOnly","includes","type","serverProps","user","rows","forEach","row","rowIndex","admin","components","RowLabels","Component","RowLabel","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","Field","FieldComponent","key","description","Description","_jsx","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type { ClientComponentProps, ClientField, FieldPaths, ServerComponentProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, deepCopyObjectSimple, MissingEditorProp } from 'payload'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- need this to reference already existing bundle. Otherwise, bundle size increases., payload/no-imports-from-exports-dir\nimport { FieldDescription } from '../../exports/client/index.js'\n\nconst defaultUIFieldComponentKeys: Array<'Cell' | 'Description' | 'Field' | 'Filter'> = [\n 'Cell',\n 'Description',\n 'Field',\n 'Filter',\n]\n\nexport const renderField: RenderFieldMethod = ({\n id,\n collectionSlug,\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n formState,\n indexPath,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions,\n preferences,\n req,\n schemaPath,\n siblingData,\n}) => {\n const clientField = createClientField({\n clientField: deepCopyObjectSimple(fieldConfig) as ClientField,\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n })\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n customComponents: fieldState?.customComponents || {},\n field: clientField,\n path,\n readOnly: typeof permissions === 'boolean' ? !permissions : !permissions?.[operation],\n schemaPath,\n }\n\n // fields with subfields\n if (['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'].includes(fieldConfig.type)) {\n clientProps.indexPath = indexPath\n clientProps.parentPath = parentPath\n clientProps.parentSchemaPath = parentSchemaPath\n }\n\n const serverProps: ServerComponentProps = {\n id,\n clientField,\n data,\n field: fieldConfig,\n fieldSchemaMap,\n permissions,\n // TODO: Should we pass explicit values? initialValue, value, valid\n // value and initialValue should be typed\n collectionSlug,\n formState,\n i18n: req.i18n,\n operation,\n payload: req.payload,\n preferences,\n req,\n siblingData,\n user: req.user,\n }\n\n if (!fieldState?.customComponents) {\n fieldState.customComponents = {}\n }\n\n switch (fieldConfig.type) {\n // TODO: handle block row labels as well in a similar fashion\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!fieldState.customComponents.RowLabels) {\n fieldState.customComponents.RowLabels = []\n }\n\n fieldState.customComponents.RowLabels[rowIndex] = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.RowLabel,\n importMap: req.payload.importMap,\n serverProps: {\n ...serverProps,\n rowLabel: `${getTranslation(fieldConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n },\n })\n }\n })\n\n break\n }\n\n case 'richText': {\n if (!fieldConfig?.editor) {\n throw new MissingEditorProp(fieldConfig) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof fieldConfig?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!fieldConfig.admin) {\n fieldConfig.admin = {}\n }\n\n if (!fieldConfig.admin.components) {\n fieldConfig.admin.components = {}\n }\n\n fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.editor.FieldComponent,\n importMap: req.payload.importMap,\n serverProps,\n })\n\n break\n }\n\n case 'ui': {\n if (fieldConfig?.admin?.components) {\n // Render any extra, untyped components\n for (const key in fieldConfig.admin.components) {\n if (key in defaultUIFieldComponentKeys) {\n continue\n }\n const Component = fieldConfig.admin.components[key]\n fieldState.customComponents[key] = RenderServerComponent({\n clientProps,\n Component,\n importMap: req.payload.importMap,\n key: `field.admin.components.${key}`,\n serverProps,\n })\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if ('description' in fieldConfig.admin) {\n if (typeof fieldConfig.admin?.description === 'function') {\n fieldState.customComponents.Description = (\n <FieldDescription\n description={fieldConfig.admin?.description({\n t: req.i18n.t,\n })}\n path={path}\n />\n )\n }\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.afterInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.afterInput',\n serverProps,\n })\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.beforeInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.beforeInput',\n serverProps,\n })\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Description,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Description',\n serverProps,\n })\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Error,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Error',\n serverProps,\n })\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Label',\n serverProps,\n })\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Field,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Field',\n serverProps,\n })\n }\n }\n }\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,oBAAoB,EAAEC,iBAAiB,QAAQ;AAI3E,SAASC,qBAAqB,QAAQ;AACtC;AACA,SAASC,gBAAgB,QAAQ;AAEjC,MAAMC,2BAAA,GAAkF,CACtF,QACA,eACA,SACA,SACD;AAED,OAAO,MAAMC,WAAA,GAAiCA,CAAC;EAC7CC,EAAE;EACFC,cAAc;EACdC,IAAI;EACJC,WAAW;EACXC,cAAc;EACdC,UAAU;EACVC,SAAS;EACTC,SAAS;EACTC,SAAS;EACTC,UAAU;EACVC,gBAAgB;EAChBC,IAAI;EACJC,WAAW;EACXC,WAAW;EACXC,GAAG;EACHC,UAAU;EACVC;AAAW,CACZ;EACC,MAAMC,WAAA,GAAcxB,iBAAA,CAAkB;IACpCwB,WAAA,EAAavB,oBAAA,CAAqBS,WAAA;IAClCe,aAAA,EAAeJ,GAAA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7CpC,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC2B,GAAA,EAAK;UACLrB;QACF;MACF;MAEA,IAAI,WAAW3B,WAAA,CAAYiC,KAAK,CAACC,UAAU,EAAE;QAC3ChC,UAAA,CAAWqB,gBAAgB,CAACuB,KAAK,GAAGrD,qBAAA,CAAsB;UACxD6B,WAAA;UACAc,SAAA,EAAWpC,WAAA,CAAYiC,KAAK,CAACC,UAAU,CAACY,KAAK;UAC7CzB,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC2B,GAAA,EAAK;UACLrB;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","MissingEditorProp","RenderServerComponent","FieldDescription","defaultUIFieldComponentKeys","renderField","id","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","operation","parentPath","parentSchemaPath","path","permissions","preferences","req","schemaPath","siblingData","clientField","defaultIDType","payload","config","db","field","i18n","importMap","clientProps","customComponents","readOnly","includes","type","serverProps","user","rows","forEach","row","rowIndex","admin","components","RowLabels","Component","RowLabel","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","Field","FieldComponent","key","description","Description","_jsx","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type { ClientComponentProps, FieldPaths, ServerComponentProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, MissingEditorProp } from 'payload'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- need this to reference already existing bundle. Otherwise, bundle size increases., payload/no-imports-from-exports-dir\nimport { FieldDescription } from '../../exports/client/index.js'\n\nconst defaultUIFieldComponentKeys: Array<'Cell' | 'Description' | 'Field' | 'Filter'> = [\n 'Cell',\n 'Description',\n 'Field',\n 'Filter',\n]\n\nexport const renderField: RenderFieldMethod = ({\n id,\n collectionSlug,\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n formState,\n indexPath,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions,\n preferences,\n req,\n schemaPath,\n siblingData,\n}) => {\n const clientField = createClientField({\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n })\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n customComponents: fieldState?.customComponents || {},\n field: clientField,\n path,\n readOnly: typeof permissions === 'boolean' ? !permissions : !permissions?.[operation],\n schemaPath,\n }\n\n // fields with subfields\n if (['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'].includes(fieldConfig.type)) {\n clientProps.indexPath = indexPath\n clientProps.parentPath = parentPath\n clientProps.parentSchemaPath = parentSchemaPath\n }\n\n const serverProps: ServerComponentProps = {\n id,\n clientField,\n data,\n field: fieldConfig,\n fieldSchemaMap,\n permissions,\n // TODO: Should we pass explicit values? initialValue, value, valid\n // value and initialValue should be typed\n collectionSlug,\n formState,\n i18n: req.i18n,\n operation,\n payload: req.payload,\n preferences,\n req,\n siblingData,\n user: req.user,\n }\n\n if (!fieldState?.customComponents) {\n fieldState.customComponents = {}\n }\n\n switch (fieldConfig.type) {\n // TODO: handle block row labels as well in a similar fashion\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!fieldState.customComponents.RowLabels) {\n fieldState.customComponents.RowLabels = []\n }\n\n fieldState.customComponents.RowLabels[rowIndex] = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.RowLabel,\n importMap: req.payload.importMap,\n serverProps: {\n ...serverProps,\n rowLabel: `${getTranslation(fieldConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n },\n })\n }\n })\n\n break\n }\n\n case 'richText': {\n if (!fieldConfig?.editor) {\n throw new MissingEditorProp(fieldConfig) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof fieldConfig?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!fieldConfig.admin) {\n fieldConfig.admin = {}\n }\n\n if (!fieldConfig.admin.components) {\n fieldConfig.admin.components = {}\n }\n\n fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.editor.FieldComponent,\n importMap: req.payload.importMap,\n serverProps,\n })\n\n break\n }\n\n case 'ui': {\n if (fieldConfig?.admin?.components) {\n // Render any extra, untyped components\n for (const key in fieldConfig.admin.components) {\n if (key in defaultUIFieldComponentKeys) {\n continue\n }\n const Component = fieldConfig.admin.components[key]\n fieldState.customComponents[key] = RenderServerComponent({\n clientProps,\n Component,\n importMap: req.payload.importMap,\n key: `field.admin.components.${key}`,\n serverProps,\n })\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if ('description' in fieldConfig.admin) {\n if (typeof fieldConfig.admin?.description === 'function') {\n fieldState.customComponents.Description = (\n <FieldDescription\n description={fieldConfig.admin?.description({\n t: req.i18n.t,\n })}\n path={path}\n />\n )\n }\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.afterInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.afterInput',\n serverProps,\n })\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.beforeInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.beforeInput',\n serverProps,\n })\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Description,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Description',\n serverProps,\n })\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Error,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Error',\n serverProps,\n })\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Label',\n serverProps,\n })\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Field,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Field',\n serverProps,\n })\n }\n }\n }\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,iBAAiB,QAAQ;AAIrD,SAASC,qBAAqB,QAAQ;AACtC;AACA,SAASC,gBAAgB,QAAQ;AAEjC,MAAMC,2BAAA,GAAkF,CACtF,QACA,eACA,SACA,SACD;AAED,OAAO,MAAMC,WAAA,GAAiCA,CAAC;EAC7CC,EAAE;EACFC,cAAc;EACdC,IAAI;EACJC,WAAW;EACXC,cAAc;EACdC,UAAU;EACVC,SAAS;EACTC,SAAS;EACTC,SAAS;EACTC,UAAU;EACVC,gBAAgB;EAChBC,IAAI;EACJC,WAAW;EACXC,WAAW;EACXC,GAAG;EACHC,UAAU;EACVC;AAAW,CACZ;EACC,MAAMC,WAAA,GAAcvB,iBAAA,CAAkB;IACpCwB,aAAA,EAAeJ,GAAA,CAAIK,OAAO,CAACC,MAAM,CAACC,EAAE,CAACH,aAAa;IAClDI,KAAA,EAAOnB,WAAA;IACPoB,IAAA,EAAMT,GAAA,CAAIS,IAAI;IACdC,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK;EACzB;EAEA,MAAMC,WAAA,GAA0D;IAC9DC,gBAAA,EAAkB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ACxD6B,WAAA;UACAc,SAAA,EAAWpC,WAAA,CAAYiC,KAAK,CAACC,UAAU,CAACY,KAAK;UAC7CzB,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC2B,GAAA,EAAK;UACLrB;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -18,8 +18,9 @@ export const LocaleProvider = t0 => {
|
|
|
18
18
|
config: t1
|
|
19
19
|
} = useConfig();
|
|
20
20
|
const {
|
|
21
|
-
localization
|
|
21
|
+
localization: t2
|
|
22
22
|
} = t1;
|
|
23
|
+
const localization = t2 === undefined ? false : t2;
|
|
23
24
|
const {
|
|
24
25
|
user
|
|
25
26
|
} = useAuth();
|
|
@@ -29,23 +30,23 @@ export const LocaleProvider = t0 => {
|
|
|
29
30
|
} = useSearchParams();
|
|
30
31
|
const localeFromParams = searchParams?.locale;
|
|
31
32
|
const [localeCode, setLocaleCode] = useState(localeFromParams || defaultLocale);
|
|
32
|
-
let
|
|
33
|
+
let t3;
|
|
33
34
|
if ($[0] !== localization || $[1] !== localeCode) {
|
|
34
|
-
|
|
35
|
+
t3 = localization && findLocaleFromCode(localization, localeCode);
|
|
35
36
|
$[0] = localization;
|
|
36
37
|
$[1] = localeCode;
|
|
37
|
-
$[2] =
|
|
38
|
+
$[2] = t3;
|
|
38
39
|
} else {
|
|
39
|
-
|
|
40
|
+
t3 = $[2];
|
|
40
41
|
}
|
|
41
|
-
const [locale, setLocale] = useState(
|
|
42
|
+
const [locale, setLocale] = useState(t3);
|
|
42
43
|
const {
|
|
43
44
|
getPreference,
|
|
44
45
|
setPreference
|
|
45
46
|
} = usePreferences();
|
|
46
|
-
let
|
|
47
|
+
let t4;
|
|
47
48
|
if ($[3] !== localization || $[4] !== defaultLocale || $[5] !== localeCode || $[6] !== user || $[7] !== setPreference) {
|
|
48
|
-
|
|
49
|
+
t4 = async newLocale => {
|
|
49
50
|
if (!localization) {
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
@@ -58,8 +59,8 @@ export const LocaleProvider = t0 => {
|
|
|
58
59
|
if (user) {
|
|
59
60
|
await setPreference("locale", localeToSet);
|
|
60
61
|
}
|
|
61
|
-
} catch (
|
|
62
|
-
const error =
|
|
62
|
+
} catch (t5) {
|
|
63
|
+
const error = t5;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
};
|
|
@@ -68,14 +69,14 @@ export const LocaleProvider = t0 => {
|
|
|
68
69
|
$[5] = localeCode;
|
|
69
70
|
$[6] = user;
|
|
70
71
|
$[7] = setPreference;
|
|
71
|
-
$[8] =
|
|
72
|
+
$[8] = t4;
|
|
72
73
|
} else {
|
|
73
|
-
|
|
74
|
+
t4 = $[8];
|
|
74
75
|
}
|
|
75
|
-
const switchLocale =
|
|
76
|
-
let
|
|
76
|
+
const switchLocale = t4;
|
|
77
|
+
let t5;
|
|
77
78
|
if ($[9] !== defaultLocale || $[10] !== localeFromParams || $[11] !== user || $[12] !== getPreference || $[13] !== switchLocale) {
|
|
78
|
-
|
|
79
|
+
t5 = () => {
|
|
79
80
|
const setInitialLocale = async function setInitialLocale() {
|
|
80
81
|
let localeToSet_0 = defaultLocale;
|
|
81
82
|
if (typeof localeFromParams === "string") {
|
|
@@ -85,8 +86,8 @@ export const LocaleProvider = t0 => {
|
|
|
85
86
|
;
|
|
86
87
|
try {
|
|
87
88
|
localeToSet_0 = await getPreference("locale");
|
|
88
|
-
} catch (
|
|
89
|
-
const error_0 =
|
|
89
|
+
} catch (t6) {
|
|
90
|
+
const error_0 = t6;
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -99,13 +100,13 @@ export const LocaleProvider = t0 => {
|
|
|
99
100
|
$[11] = user;
|
|
100
101
|
$[12] = getPreference;
|
|
101
102
|
$[13] = switchLocale;
|
|
102
|
-
$[14] =
|
|
103
|
+
$[14] = t5;
|
|
103
104
|
} else {
|
|
104
|
-
|
|
105
|
+
t5 = $[14];
|
|
105
106
|
}
|
|
106
|
-
let
|
|
107
|
+
let t6;
|
|
107
108
|
if ($[15] !== defaultLocale || $[16] !== getPreference || $[17] !== localization || $[18] !== localeFromParams || $[19] !== setPreference || $[20] !== user || $[21] !== switchLocale) {
|
|
108
|
-
|
|
109
|
+
t6 = [defaultLocale, getPreference, localization, localeFromParams, setPreference, user, switchLocale];
|
|
109
110
|
$[15] = defaultLocale;
|
|
110
111
|
$[16] = getPreference;
|
|
111
112
|
$[17] = localization;
|
|
@@ -113,24 +114,24 @@ export const LocaleProvider = t0 => {
|
|
|
113
114
|
$[19] = setPreference;
|
|
114
115
|
$[20] = user;
|
|
115
116
|
$[21] = switchLocale;
|
|
116
|
-
$[22] =
|
|
117
|
+
$[22] = t6;
|
|
117
118
|
} else {
|
|
118
|
-
|
|
119
|
+
t6 = $[22];
|
|
119
120
|
}
|
|
120
|
-
useEffect(
|
|
121
|
-
let
|
|
121
|
+
useEffect(t5, t6);
|
|
122
|
+
let t7;
|
|
122
123
|
if ($[23] !== locale || $[24] !== children) {
|
|
123
|
-
|
|
124
|
+
t7 = _jsx(LocaleContext.Provider, {
|
|
124
125
|
value: locale,
|
|
125
126
|
children
|
|
126
127
|
});
|
|
127
128
|
$[23] = locale;
|
|
128
129
|
$[24] = children;
|
|
129
|
-
$[25] =
|
|
130
|
+
$[25] = t7;
|
|
130
131
|
} else {
|
|
131
|
-
|
|
132
|
+
t7 = $[25];
|
|
132
133
|
}
|
|
133
|
-
return
|
|
134
|
+
return t7;
|
|
134
135
|
};
|
|
135
136
|
/**
|
|
136
137
|
* A hook that returns the current locale object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","createContext","useContext","useEffect","useState","findLocaleFromCode","useAuth","useConfig","usePreferences","useSearchParams","LocaleContext","LocaleProvider","t0","$","children","config","t1","localization","user","defaultLocale","searchParams","localeFromParams","locale","localeCode","setLocaleCode","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","createContext","useContext","useEffect","useState","findLocaleFromCode","useAuth","useConfig","usePreferences","useSearchParams","LocaleContext","LocaleProvider","t0","$","children","config","t1","localization","t2","undefined","user","defaultLocale","searchParams","localeFromParams","locale","localeCode","setLocaleCode","t3","setLocale","getPreference","setPreference","t4","newLocale","localeToSet","localeCodes","indexOf","t5","error","switchLocale","setInitialLocale","localeToSet_0","t6","t7","_jsx","Provider","value","useLocale"],"sources":["../../../src/providers/Locale/index.tsx"],"sourcesContent":["'use client'\n\nimport type { Locale } from 'payload'\n\nimport React, { createContext, useContext, useEffect, useState } from 'react'\n\nimport { findLocaleFromCode } from '../../utilities/findLocaleFromCode.js'\nimport { useAuth } from '../Auth/index.js'\nimport { useConfig } from '../Config/index.js'\nimport { usePreferences } from '../Preferences/index.js'\nimport { useSearchParams } from '../SearchParams/index.js'\n\nconst LocaleContext = createContext({} as Locale)\n\nexport const LocaleProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => {\n const {\n config: { localization = false },\n } = useConfig()\n\n const { user } = useAuth()\n const defaultLocale =\n localization && localization.defaultLocale ? localization.defaultLocale : 'en'\n\n const { searchParams } = useSearchParams()\n const localeFromParams = searchParams?.locale\n\n const [localeCode, setLocaleCode] = useState<string>(\n (localeFromParams as string) || defaultLocale,\n )\n\n const [locale, setLocale] = useState<Locale | null>(\n localization && findLocaleFromCode(localization, localeCode),\n )\n\n const { getPreference, setPreference } = usePreferences()\n\n const switchLocale = React.useCallback(\n async (newLocale: string) => {\n if (!localization) {\n return\n }\n\n const localeToSet =\n localization.localeCodes.indexOf(newLocale) > -1 ? newLocale : defaultLocale\n\n if (localeToSet !== localeCode) {\n setLocaleCode(localeToSet)\n setLocale(findLocaleFromCode(localization, localeToSet))\n try {\n if (user) {\n await setPreference('locale', localeToSet)\n }\n } catch (error) {\n // swallow error\n }\n }\n },\n [localization, setPreference, user, defaultLocale, localeCode],\n )\n\n useEffect(() => {\n async function setInitialLocale() {\n let localeToSet = defaultLocale\n\n if (typeof localeFromParams === 'string') {\n localeToSet = localeFromParams\n } else if (user) {\n try {\n localeToSet = await getPreference<string>('locale')\n } catch (error) {\n // swallow error\n }\n }\n\n await switchLocale(localeToSet)\n }\n\n void setInitialLocale()\n }, [\n defaultLocale,\n getPreference,\n localization,\n localeFromParams,\n setPreference,\n user,\n switchLocale,\n ])\n\n return <LocaleContext.Provider value={locale}>{children}</LocaleContext.Provider>\n}\n\n/**\n * A hook that returns the current locale object.\n */\nexport const useLocale = (): Locale => useContext(LocaleContext)\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,OAAOC,KAAA,IAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAEtE,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAEhC,MAAMC,aAAA,gBAAgBT,aAAA,CAAc,CAAC;AAErC,OAAO,MAAMU,cAAA,GAA2DC,EAAA;EAAA,MAAAC,CAAA,GAAAd,EAAA;EAAC;IAAAe;EAAA,IAAAF,EAAY;EACnF;IAAAG,MAAA,EAAAC;EAAA,IAEIT,SAAA;EADM;IAAAU,YAAA,EAAAC;EAAA,IAAAF,EAAwB;EAAtB,MAAAC,YAAA,GAAAC,EAAoB,KAAAC,SAAA,WAApBD,EAAoB;EAGhC;IAAAE;EAAA,IAAiBd,OAAA;EACjB,MAAAe,aAAA,GACEJ,YAAA,IAAgBA,YAAA,CAAAI,aAA0B,GAAGJ,YAAA,CAAAI,aAAA,GAA6B;EAE5E;IAAAC;EAAA,IAAyBb,eAAA;EACzB,MAAAc,gBAAA,GAAyBD,YAAA,EAAAE,MAAA;EAEzB,OAAAC,UAAA,EAAAC,aAAA,IAAoCtB,QAAA,CAClCmB,gBAAC,IAA+BF,aAAA;EAAA,IAAAM,EAAA;EAAA,IAAAd,CAAA,QAAAI,YAAA,IAAAJ,CAAA,QAAAY,UAAA;IAI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,OAAAyB,YAAA;IAAAzB,CAAA,OAAA4B,EAAA;EAAA;IAAAA,EAAA,GAAA5B,CAAA;EAAA;EA1BDV,SAAA,CAAUiC,EAkBV,EAAGK,EAQF;EAAA,IAAAC,EAAA;EAAA,IAAA7B,CAAA,SAAAW,MAAA,IAAAX,CAAA,SAAAC,QAAA;IAEM4B,EAAA,GAAAC,IAAA,CAAAjC,aAAA,CAAAkC,QAAA;MAAAC,KAAA,EAA+BrB,MAAA;MAAAV;IAAA,C;;;;;;;SAA/B4B,E;CACT;AAEA;;;AAGA,OAAO,MAAMI,SAAA,GAAYA,CAAA;EAAA,OAAc5C,UAAA,CAAAQ,aAAW;AAAA","ignoreList":[]}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BuildTableStateArgs, ClientConfig, ErrorResult, ImportMap, PaginatedDocs, SanitizedConfig } from 'payload';
|
|
1
|
+
import type { BuildTableStateArgs, ClientConfig, ErrorResult, PaginatedDocs } from 'payload';
|
|
3
2
|
import type { Column } from '../elements/Table/index.js';
|
|
4
3
|
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;
|
|
10
4
|
type BuildTableStateSuccessResult = {
|
|
11
5
|
clientConfig?: ClientConfig;
|
|
12
6
|
data: PaginatedDocs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTableState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildTableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
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,EAEd,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAKxE,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,CA8KtC,CAAA"}
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
import { dequal } from 'dequal'; // TODO: Can we change this to dequal/lite ? If not, please add comment explaining why
|
|
2
|
-
import {
|
|
2
|
+
import { formatErrors } from 'payload';
|
|
3
|
+
import { getClientConfig } from './getClientConfig.js';
|
|
3
4
|
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
|
-
};
|
|
24
5
|
export const buildTableStateHandler = async args => {
|
|
25
6
|
const {
|
|
26
7
|
req
|
|
@@ -1 +1 @@
|
|
|
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","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 { 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' // TODO: Can we change this to dequal/lite ? If not, please add comment explaining why\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 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":"AAYA,SAASA,MAAM,QAAQ,SAAQ,CAAC;AAChC,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,CAAg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AAA;MAC/CE,IAAA,EAAM1C,KAAA,EAAO0C,IAAA;MACbjB,KAAA,EAAOzB,KAAA,EAAOyB;IAChB;IAEA5B,IAAA,GAAOsC,IAAA,CAAKtC,IAAI;EAClB;EAEA,MAAM;IAAE8C,WAAW;IAAEC;EAAK,CAAE,GAAGvE,WAAA,CAAY;IACzC+C,gBAAA,EAAkBC,sBAAA;IAClBwB,iBAAA,EAAmBL,SAAA;IACnB5C,OAAA;IACAC,IAAA;IACAE,mBAAA;IACAuC,MAAA;IACA1D,IAAA,EAAMM,GAAA,CAAIN,IAAI;IACdU,OAAA;IACAW,cAAA;IACAE,eAAA;IACA2C,UAAA,EAAY1B,gBAAA,CAAiBb,KAAK,CAACuC;EACrC;EAEA,MAAMC,eAAA,GAAkB3E,aAAA,CAAckE,MAAA,EAAQpD,GAAA,CAAII,OAAO,CAACT,SAAS;EAEnE,OAAO;IACLsD,IAAA;IACAa,WAAA,EAAahB,QAAA;IACbe,eAAA;IACAE,KAAA,EAAON,WAAA;IACPC;EACF;AACF","ignoreList":[]}
|
|
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;IACF;IAEA,IAAIL,GAAA,CAAIK,OAAO,KAAK,gBAAgB;MAClC,OAAO;IACT;IAEA,OAAOd,YAAA,CAAaS,GAAA;EACtB;AACF;AAEA,OAAO,MAAMD,eAAA,GAAkB,MAC7BH,IAAA;EAEA,MAAM;IACJU,cAAc;IACdC,OAAO;IACPC,IAAA,EAAMC,YAAY;IAClBC,mBAAmB;IACnBC,KAAK;IACLC,cAAc;IACdf,GAAG;IACHA,GAAA,EAAK;MACHgB,IAAI;MACJZ,OAAO;MACPA,OAAA,EAAS;QAAEa;MAAM,CAAE;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AA;IACAE,KAAA,EAAON,WAAA;IACPC;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SanitizedCollectionConfig
|
|
1
|
+
import type { SanitizedCollectionConfig } 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;
|
|
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,
|
|
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;AAExD,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,CAAA;CACjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/views/Edit/Auth/types.ts"],"sourcesContent":["import type { SanitizedCollectionConfig
|
|
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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1-canary.c40ff01",
|
|
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.
|
|
136
|
+
"@payloadcms/translations": "3.1.1-canary.c40ff01"
|
|
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.
|
|
155
|
+
"payload": "3.1.1-canary.c40ff01"
|
|
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.
|
|
161
|
+
"payload": "3.1.1-canary.c40ff01"
|
|
162
162
|
},
|
|
163
163
|
"engines": {
|
|
164
164
|
"node": "^18.20.2 || >=20.9.0"
|