@payloadcms/plugin-import-export 4.0.0-internal.cd47d20 → 4.0.0-internal.ce66a41
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/components/ExportPreview/index.css +0 -3
- package/dist/components/FieldsToExport/index.d.ts.map +1 -1
- package/dist/components/FieldsToExport/index.js +18 -15
- package/dist/components/FieldsToExport/index.js.map +1 -1
- package/dist/components/FieldsToExport/reduceFields.d.ts +6 -0
- package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
- package/dist/components/FieldsToExport/reduceFields.js +4 -0
- package/dist/components/FieldsToExport/reduceFields.js.map +1 -1
- package/dist/components/ImportPreview/index.css +0 -3
- package/dist/components/ImportPreview/index.d.ts.map +1 -1
- package/dist/components/ImportPreview/index.js +10 -7
- package/dist/components/ImportPreview/index.js.map +1 -1
- package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts +7 -0
- package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts.map +1 -0
- package/dist/components/RelationshipCell/getRelationshipGroupKey.js +3 -0
- package/dist/components/RelationshipCell/getRelationshipGroupKey.js.map +1 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.d.ts +43 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.d.ts.map +1 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.js +109 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.js.map +1 -0
- package/dist/components/RelationshipCell/index.css +30 -0
- package/dist/components/RelationshipCell/index.d.ts +15 -0
- package/dist/components/RelationshipCell/index.d.ts.map +1 -0
- package/dist/components/RelationshipCell/index.js +57 -0
- package/dist/components/RelationshipCell/index.js.map +1 -0
- package/dist/utilities/getExportFieldFunctions.js +64 -27
- package/dist/utilities/getExportFieldFunctions.js.map +1 -1
- package/package.json +9 -9
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
.export-preview__export-count {
|
|
17
17
|
color: var(--color-text-secondary);
|
|
18
|
-
font-family: var(--text-body-medium-font-family);
|
|
19
18
|
font-size: var(--text-body-medium-font-size);
|
|
20
19
|
font-weight: var(--text-body-medium-font-weight);
|
|
21
20
|
line-height: var(--text-body-medium-line-height);
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
|
|
24
23
|
.export-preview__limit-capped {
|
|
25
24
|
color: var(--color-text-warning);
|
|
26
|
-
font-family: var(--text-body-medium-font-family);
|
|
27
25
|
font-size: var(--text-body-medium-font-size);
|
|
28
26
|
font-weight: var(--text-body-medium-font-weight);
|
|
29
27
|
line-height: var(--text-body-medium-line-height);
|
|
@@ -46,7 +44,6 @@
|
|
|
46
44
|
|
|
47
45
|
.export-preview__page-info {
|
|
48
46
|
color: var(--color-text-secondary);
|
|
49
|
-
font-family: var(--text-body-medium-font-family);
|
|
50
47
|
font-size: var(--text-body-medium-font-size);
|
|
51
48
|
font-weight: var(--text-body-medium-font-weight);
|
|
52
49
|
line-height: var(--text-body-medium-line-height);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FieldsToExport/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAWrD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FieldsToExport/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAWrD,OAAO,KAA6B,MAAM,OAAO,CAAA;AAOjD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA+E3D,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { FieldLabel, ReactSelect, useConfig, useDocumentInfo, useField, useListQuery } from '@payloadcms/ui';
|
|
4
|
-
import React, { useEffect } from 'react';
|
|
4
|
+
import React, { useEffect, useMemo } from 'react';
|
|
5
5
|
import { useImportExport } from '../ImportExportProvider/index.js';
|
|
6
|
-
import { reduceFields } from './reduceFields.js';
|
|
6
|
+
import { filterSelectableFieldValues, reduceFields } from './reduceFields.js';
|
|
7
7
|
const baseClass = 'field-type fields-to-export';
|
|
8
8
|
export const FieldsToExport = (props)=>{
|
|
9
9
|
const { id } = useDocumentInfo();
|
|
@@ -17,29 +17,32 @@ export const FieldsToExport = (props)=>{
|
|
|
17
17
|
const collectionConfig = getEntityConfig({
|
|
18
18
|
collectionSlug: collectionSlug ?? collection
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const fieldOptions = useMemo(()=>{
|
|
21
|
+
const disabledFields = collectionConfig?.admin?.custom?.['plugin-import-export']?.disabledFields ?? [];
|
|
22
|
+
return reduceFields({
|
|
23
|
+
disabledFields,
|
|
24
|
+
fields: collectionConfig?.fields
|
|
25
|
+
});
|
|
26
|
+
}, [
|
|
27
|
+
collectionConfig?.admin?.custom,
|
|
28
|
+
collectionConfig?.fields
|
|
29
|
+
]);
|
|
25
30
|
useEffect(()=>{
|
|
26
31
|
if (id || !collectionSlug) {
|
|
27
32
|
return;
|
|
28
33
|
}
|
|
29
34
|
const queryColumns = query?.columns;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
// Fallback if no columns in query
|
|
36
|
-
setValue(collectionConfig?.admin?.defaultColumns ?? []);
|
|
37
|
-
}
|
|
35
|
+
const initialColumns = Array.isArray(queryColumns) ? queryColumns.filter((column)=>typeof column === 'string' && !column.startsWith('-')) : collectionConfig?.admin?.defaultColumns ?? [];
|
|
36
|
+
setValue(filterSelectableFieldValues({
|
|
37
|
+
fieldOptions,
|
|
38
|
+
values: initialColumns
|
|
39
|
+
}));
|
|
38
40
|
}, [
|
|
39
41
|
id,
|
|
40
42
|
collectionSlug,
|
|
41
43
|
query?.columns,
|
|
42
44
|
collectionConfig?.admin?.defaultColumns,
|
|
45
|
+
fieldOptions,
|
|
43
46
|
setValue
|
|
44
47
|
]);
|
|
45
48
|
const onChange = (options)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/FieldsToExport/index.tsx"],"sourcesContent":["'use client'\n\nimport type { SelectFieldClientProps } from 'payload'\nimport type { ReactNode } from 'react'\n\nimport {\n FieldLabel,\n ReactSelect,\n useConfig,\n useDocumentInfo,\n useField,\n useListQuery,\n} from '@payloadcms/ui'\nimport React, { useEffect } from 'react'\n\nimport { useImportExport } from '../ImportExportProvider/index.js'\nimport { reduceFields } from './reduceFields.js'\n\nconst baseClass = 'field-type fields-to-export'\n\nexport const FieldsToExport: React.FC<SelectFieldClientProps> = (props) => {\n const { id } = useDocumentInfo()\n const { setValue, value } = useField<string[]>()\n const { value: collectionSlug } = useField<string>({ path: 'collectionSlug' })\n const { getEntityConfig } = useConfig()\n const { collection } = useImportExport()\n const { query } = useListQuery()\n\n const collectionConfig = getEntityConfig({ collectionSlug: collectionSlug ?? collection })\n\n const disabledFields =\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/FieldsToExport/index.tsx"],"sourcesContent":["'use client'\n\nimport type { SelectFieldClientProps } from 'payload'\nimport type { ReactNode } from 'react'\n\nimport {\n FieldLabel,\n ReactSelect,\n useConfig,\n useDocumentInfo,\n useField,\n useListQuery,\n} from '@payloadcms/ui'\nimport React, { useEffect, useMemo } from 'react'\n\nimport { useImportExport } from '../ImportExportProvider/index.js'\nimport { filterSelectableFieldValues, reduceFields } from './reduceFields.js'\n\nconst baseClass = 'field-type fields-to-export'\n\nexport const FieldsToExport: React.FC<SelectFieldClientProps> = (props) => {\n const { id } = useDocumentInfo()\n const { setValue, value } = useField<string[]>()\n const { value: collectionSlug } = useField<string>({ path: 'collectionSlug' })\n const { getEntityConfig } = useConfig()\n const { collection } = useImportExport()\n const { query } = useListQuery()\n\n const collectionConfig = getEntityConfig({ collectionSlug: collectionSlug ?? collection })\n\n const fieldOptions = useMemo(() => {\n const disabledFields =\n collectionConfig?.admin?.custom?.['plugin-import-export']?.disabledFields ?? []\n\n return reduceFields({\n disabledFields,\n fields: collectionConfig?.fields,\n })\n }, [collectionConfig?.admin?.custom, collectionConfig?.fields])\n useEffect(() => {\n if (id || !collectionSlug) {\n return\n }\n\n const queryColumns = query?.columns\n const initialColumns = Array.isArray(queryColumns)\n ? queryColumns.filter(\n (column): column is string => typeof column === 'string' && !column.startsWith('-'),\n )\n : (collectionConfig?.admin?.defaultColumns ?? [])\n\n setValue(filterSelectableFieldValues({ fieldOptions, values: initialColumns }))\n }, [\n id,\n collectionSlug,\n query?.columns,\n collectionConfig?.admin?.defaultColumns,\n fieldOptions,\n setValue,\n ])\n\n const onChange = (options: { id: string; label: ReactNode; value: string }[]) => {\n if (!options) {\n setValue([])\n return\n }\n\n const updatedValue = options.map((option) =>\n typeof option === 'object' ? option.value : option,\n )\n\n setValue(updatedValue)\n }\n\n return (\n <div className={baseClass}>\n <FieldLabel label={props.field.label} path={props.path} />\n <ReactSelect\n className={baseClass}\n disabled={props.readOnly}\n getOptionValue={(option) => String(option.value)}\n inputId={`field-${props.path.replace(/\\./g, '__')}`}\n isClearable={true}\n isMulti={true}\n isSortable={true}\n // @ts-expect-error react select option\n onChange={onChange}\n options={fieldOptions}\n value={\n Array.isArray(value)\n ? value.map((val) => {\n const match = fieldOptions.find((opt) => opt.value === val)\n return match ? { ...match, id: val } : { id: val, label: val, value: val }\n })\n : []\n }\n />\n </div>\n )\n}\n"],"names":["FieldLabel","ReactSelect","useConfig","useDocumentInfo","useField","useListQuery","React","useEffect","useMemo","useImportExport","filterSelectableFieldValues","reduceFields","baseClass","FieldsToExport","props","id","setValue","value","collectionSlug","path","getEntityConfig","collection","query","collectionConfig","fieldOptions","disabledFields","admin","custom","fields","queryColumns","columns","initialColumns","Array","isArray","filter","column","startsWith","defaultColumns","values","onChange","options","updatedValue","map","option","div","className","label","field","disabled","readOnly","getOptionValue","String","inputId","replace","isClearable","isMulti","isSortable","val","match","find","opt"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,YAAY,QACP,iBAAgB;AACvB,OAAOC,SAASC,SAAS,EAAEC,OAAO,QAAQ,QAAO;AAEjD,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,2BAA2B,EAAEC,YAAY,QAAQ,oBAAmB;AAE7E,MAAMC,YAAY;AAElB,OAAO,MAAMC,iBAAmD,CAACC;IAC/D,MAAM,EAAEC,EAAE,EAAE,GAAGZ;IACf,MAAM,EAAEa,QAAQ,EAAEC,KAAK,EAAE,GAAGb;IAC5B,MAAM,EAAEa,OAAOC,cAAc,EAAE,GAAGd,SAAiB;QAAEe,MAAM;IAAiB;IAC5E,MAAM,EAAEC,eAAe,EAAE,GAAGlB;IAC5B,MAAM,EAAEmB,UAAU,EAAE,GAAGZ;IACvB,MAAM,EAAEa,KAAK,EAAE,GAAGjB;IAElB,MAAMkB,mBAAmBH,gBAAgB;QAAEF,gBAAgBA,kBAAkBG;IAAW;IAExF,MAAMG,eAAehB,QAAQ;QAC3B,MAAMiB,iBACJF,kBAAkBG,OAAOC,QAAQ,CAAC,uBAAuB,EAAEF,kBAAkB,EAAE;QAEjF,OAAOd,aAAa;YAClBc;YACAG,QAAQL,kBAAkBK;QAC5B;IACF,GAAG;QAACL,kBAAkBG,OAAOC;QAAQJ,kBAAkBK;KAAO;IAC9DrB,UAAU;QACR,IAAIQ,MAAM,CAACG,gBAAgB;YACzB;QACF;QAEA,MAAMW,eAAeP,OAAOQ;QAC5B,MAAMC,iBAAiBC,MAAMC,OAAO,CAACJ,gBACjCA,aAAaK,MAAM,CACjB,CAACC,SAA6B,OAAOA,WAAW,YAAY,CAACA,OAAOC,UAAU,CAAC,QAEhFb,kBAAkBG,OAAOW,kBAAkB,EAAE;QAElDrB,SAASN,4BAA4B;YAAEc;YAAcc,QAAQP;QAAe;IAC9E,GAAG;QACDhB;QACAG;QACAI,OAAOQ;QACPP,kBAAkBG,OAAOW;QACzBb;QACAR;KACD;IAED,MAAMuB,WAAW,CAACC;QAChB,IAAI,CAACA,SAAS;YACZxB,SAAS,EAAE;YACX;QACF;QAEA,MAAMyB,eAAeD,QAAQE,GAAG,CAAC,CAACC,SAChC,OAAOA,WAAW,WAAWA,OAAO1B,KAAK,GAAG0B;QAG9C3B,SAASyB;IACX;IAEA,qBACE,MAACG;QAAIC,WAAWjC;;0BACd,KAACZ;gBAAW8C,OAAOhC,MAAMiC,KAAK,CAACD,KAAK;gBAAE3B,MAAML,MAAMK,IAAI;;0BACtD,KAAClB;gBACC4C,WAAWjC;gBACXoC,UAAUlC,MAAMmC,QAAQ;gBACxBC,gBAAgB,CAACP,SAAWQ,OAAOR,OAAO1B,KAAK;gBAC/CmC,SAAS,CAAC,MAAM,EAAEtC,MAAMK,IAAI,CAACkC,OAAO,CAAC,OAAO,OAAO;gBACnDC,aAAa;gBACbC,SAAS;gBACTC,YAAY;gBACZ,uCAAuC;gBACvCjB,UAAUA;gBACVC,SAAShB;gBACTP,OACEe,MAAMC,OAAO,CAAChB,SACVA,MAAMyB,GAAG,CAAC,CAACe;oBACT,MAAMC,QAAQlC,aAAamC,IAAI,CAAC,CAACC,MAAQA,IAAI3C,KAAK,KAAKwC;oBACvD,OAAOC,QAAQ;wBAAE,GAAGA,KAAK;wBAAE3C,IAAI0C;oBAAI,IAAI;wBAAE1C,IAAI0C;wBAAKX,OAAOW;wBAAKxC,OAAOwC;oBAAI;gBAC3E,KACA,EAAE;;;;AAKhB,EAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { ClientField } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
export declare const filterSelectableFieldValues: ({ fieldOptions, values, }: {
|
|
4
|
+
fieldOptions: {
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
7
|
+
values: string[];
|
|
8
|
+
}) => string[];
|
|
3
9
|
export declare const reduceFields: ({ disabledFields, excludeUnsortable, fields, labelPrefix, path, }: {
|
|
4
10
|
disabledFields?: string[];
|
|
5
11
|
excludeUnsortable?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduceFields.d.ts","sourceRoot":"","sources":["../../../src/components/FieldsToExport/reduceFields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"reduceFields.d.ts","sourceRoot":"","sources":["../../../src/components/FieldsToExport/reduceFields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,eAAO,MAAM,2BAA2B,8BAGrC;IACD,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACjC,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,KAAG,MAAM,EAIT,CAAA;AAyCD,eAAO,MAAM,YAAY,sEAMtB;IACD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,KAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAoFxD,CAAA"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { fieldAffectsData, fieldHasSubFields } from 'payload/shared';
|
|
3
3
|
import React, { Fragment } from 'react';
|
|
4
|
+
export const filterSelectableFieldValues = ({ fieldOptions, values })=>{
|
|
5
|
+
const selectableValues = new Set(fieldOptions.map((field)=>field.value));
|
|
6
|
+
return values.filter((value)=>selectableValues.has(value));
|
|
7
|
+
};
|
|
4
8
|
const createNestedClientFieldPath = (parentPath, field)=>{
|
|
5
9
|
if (parentPath) {
|
|
6
10
|
if (fieldAffectsData(field)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/FieldsToExport/reduceFields.tsx"],"sourcesContent":["import type { ClientField } from 'payload'\n\nimport { fieldAffectsData, fieldHasSubFields } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nconst createNestedClientFieldPath = (parentPath: string, field: ClientField): string => {\n if (parentPath) {\n if (fieldAffectsData(field)) {\n return `${parentPath}.${field.name}`\n }\n return parentPath\n }\n\n if (fieldAffectsData(field)) {\n return field.name\n }\n\n return ''\n}\n\nconst combineLabel = ({\n field,\n prefix,\n}: {\n field: ClientField\n prefix?: React.ReactNode\n}): React.ReactNode => {\n return (\n <Fragment>\n {prefix ? (\n <Fragment>\n <span style={{ display: 'inline-block' }}>{prefix}</span>\n {' > '}\n </Fragment>\n ) : null}\n <span style={{ display: 'inline-block' }}>\n {'label' in field && typeof field.label === 'string'\n ? field.label\n : (('name' in field && field.name) ?? 'unnamed field')}\n </span>\n </Fragment>\n )\n}\n\nexport const reduceFields = ({\n disabledFields = [],\n excludeUnsortable = false,\n fields,\n labelPrefix = null,\n path = '',\n}: {\n disabledFields?: string[]\n excludeUnsortable?: boolean\n fields: ClientField[]\n labelPrefix?: React.ReactNode\n path?: string\n}): { id: string; label: React.ReactNode; value: string }[] => {\n if (!fields) {\n return []\n }\n\n return fields.reduce<{ id: string; label: React.ReactNode; value: string }[]>(\n (fieldsToUse, field) => {\n const isArrayOrBlocks = field.type === 'array' || field.type === 'blocks'\n\n // escape for a variety of reasons, include ui fields as they have `name`.\n if (field.type === 'ui' || (excludeUnsortable && isArrayOrBlocks)) {\n return fieldsToUse\n }\n\n if (!isArrayOrBlocks && fieldHasSubFields(field)) {\n return [\n ...fieldsToUse,\n ...reduceFields({\n disabledFields,\n excludeUnsortable,\n fields: field.fields,\n labelPrefix: combineLabel({ field, prefix: labelPrefix }),\n path: createNestedClientFieldPath(path, field),\n }),\n ]\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n return [\n ...fieldsToUse,\n ...field.tabs.reduce<{ id: string; label: React.ReactNode; value: string }[]>(\n (tabFields, tab) => {\n if ('fields' in tab) {\n const isNamedTab = 'name' in tab && tab.name\n\n const newPath = isNamedTab ? `${path}${path ? '.' : ''}${tab.name}` : path\n\n return [\n ...tabFields,\n ...reduceFields({\n disabledFields,\n excludeUnsortable,\n fields: tab.fields,\n labelPrefix: isNamedTab\n ? combineLabel({\n field: {\n name: tab.name,\n label: tab.label ?? tab.name,\n } as any,\n prefix: labelPrefix,\n })\n : labelPrefix,\n path: newPath,\n }),\n ]\n }\n return tabFields\n },\n [],\n ),\n ]\n }\n\n const val = createNestedClientFieldPath(path, field)\n\n // If the field is disabled, skip it\n if (\n disabledFields.some(\n (disabledField) => val === disabledField || val.startsWith(`${disabledField}.`),\n )\n ) {\n return fieldsToUse\n }\n\n const formattedField = {\n id: val,\n label: combineLabel({ field, prefix: labelPrefix }),\n value: val,\n }\n\n return [...fieldsToUse, formattedField]\n },\n [],\n )\n}\n"],"names":["fieldAffectsData","fieldHasSubFields","React","Fragment","
|
|
1
|
+
{"version":3,"sources":["../../../src/components/FieldsToExport/reduceFields.tsx"],"sourcesContent":["import type { ClientField } from 'payload'\n\nimport { fieldAffectsData, fieldHasSubFields } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nexport const filterSelectableFieldValues = ({\n fieldOptions,\n values,\n}: {\n fieldOptions: { value: string }[]\n values: string[]\n}): string[] => {\n const selectableValues = new Set(fieldOptions.map((field) => field.value))\n\n return values.filter((value) => selectableValues.has(value))\n}\n\nconst createNestedClientFieldPath = (parentPath: string, field: ClientField): string => {\n if (parentPath) {\n if (fieldAffectsData(field)) {\n return `${parentPath}.${field.name}`\n }\n return parentPath\n }\n\n if (fieldAffectsData(field)) {\n return field.name\n }\n\n return ''\n}\n\nconst combineLabel = ({\n field,\n prefix,\n}: {\n field: ClientField\n prefix?: React.ReactNode\n}): React.ReactNode => {\n return (\n <Fragment>\n {prefix ? (\n <Fragment>\n <span style={{ display: 'inline-block' }}>{prefix}</span>\n {' > '}\n </Fragment>\n ) : null}\n <span style={{ display: 'inline-block' }}>\n {'label' in field && typeof field.label === 'string'\n ? field.label\n : (('name' in field && field.name) ?? 'unnamed field')}\n </span>\n </Fragment>\n )\n}\n\nexport const reduceFields = ({\n disabledFields = [],\n excludeUnsortable = false,\n fields,\n labelPrefix = null,\n path = '',\n}: {\n disabledFields?: string[]\n excludeUnsortable?: boolean\n fields: ClientField[]\n labelPrefix?: React.ReactNode\n path?: string\n}): { id: string; label: React.ReactNode; value: string }[] => {\n if (!fields) {\n return []\n }\n\n return fields.reduce<{ id: string; label: React.ReactNode; value: string }[]>(\n (fieldsToUse, field) => {\n const isArrayOrBlocks = field.type === 'array' || field.type === 'blocks'\n\n // escape for a variety of reasons, include ui fields as they have `name`.\n if (field.type === 'ui' || (excludeUnsortable && isArrayOrBlocks)) {\n return fieldsToUse\n }\n\n if (!isArrayOrBlocks && fieldHasSubFields(field)) {\n return [\n ...fieldsToUse,\n ...reduceFields({\n disabledFields,\n excludeUnsortable,\n fields: field.fields,\n labelPrefix: combineLabel({ field, prefix: labelPrefix }),\n path: createNestedClientFieldPath(path, field),\n }),\n ]\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n return [\n ...fieldsToUse,\n ...field.tabs.reduce<{ id: string; label: React.ReactNode; value: string }[]>(\n (tabFields, tab) => {\n if ('fields' in tab) {\n const isNamedTab = 'name' in tab && tab.name\n\n const newPath = isNamedTab ? `${path}${path ? '.' : ''}${tab.name}` : path\n\n return [\n ...tabFields,\n ...reduceFields({\n disabledFields,\n excludeUnsortable,\n fields: tab.fields,\n labelPrefix: isNamedTab\n ? combineLabel({\n field: {\n name: tab.name,\n label: tab.label ?? tab.name,\n } as any,\n prefix: labelPrefix,\n })\n : labelPrefix,\n path: newPath,\n }),\n ]\n }\n return tabFields\n },\n [],\n ),\n ]\n }\n\n const val = createNestedClientFieldPath(path, field)\n\n // If the field is disabled, skip it\n if (\n disabledFields.some(\n (disabledField) => val === disabledField || val.startsWith(`${disabledField}.`),\n )\n ) {\n return fieldsToUse\n }\n\n const formattedField = {\n id: val,\n label: combineLabel({ field, prefix: labelPrefix }),\n value: val,\n }\n\n return [...fieldsToUse, formattedField]\n },\n [],\n )\n}\n"],"names":["fieldAffectsData","fieldHasSubFields","React","Fragment","filterSelectableFieldValues","fieldOptions","values","selectableValues","Set","map","field","value","filter","has","createNestedClientFieldPath","parentPath","name","combineLabel","prefix","span","style","display","label","reduceFields","disabledFields","excludeUnsortable","fields","labelPrefix","path","reduce","fieldsToUse","isArrayOrBlocks","type","tabs","tabFields","tab","isNamedTab","newPath","val","some","disabledField","startsWith","formattedField","id"],"mappings":";AAEA,SAASA,gBAAgB,EAAEC,iBAAiB,QAAQ,iBAAgB;AACpE,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,OAAO,MAAMC,8BAA8B,CAAC,EAC1CC,YAAY,EACZC,MAAM,EAIP;IACC,MAAMC,mBAAmB,IAAIC,IAAIH,aAAaI,GAAG,CAAC,CAACC,QAAUA,MAAMC,KAAK;IAExE,OAAOL,OAAOM,MAAM,CAAC,CAACD,QAAUJ,iBAAiBM,GAAG,CAACF;AACvD,EAAC;AAED,MAAMG,8BAA8B,CAACC,YAAoBL;IACvD,IAAIK,YAAY;QACd,IAAIf,iBAAiBU,QAAQ;YAC3B,OAAO,GAAGK,WAAW,CAAC,EAAEL,MAAMM,IAAI,EAAE;QACtC;QACA,OAAOD;IACT;IAEA,IAAIf,iBAAi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InB,IAAI;wBAE5C,MAAMqB,UAAUD,aAAa,GAAGR,OAAOA,OAAO,MAAM,KAAKO,IAAInB,IAAI,EAAE,GAAGY;wBAEtE,OAAO;+BACFM;+BACAX,aAAa;gCACdC;gCACAC;gCACAC,QAAQS,IAAIT,MAAM;gCAClBC,aAAaS,aACTnB,aAAa;oCACXP,OAAO;wCACLM,MAAMmB,IAAInB,IAAI;wCACdM,OAAOa,IAAIb,KAAK,IAAIa,IAAInB,IAAI;oCAC9B;oCACAE,QAAQS;gCACV,KACAA;gCACJC,MAAMS;4BACR;yBACD;oBACH;oBACA,OAAOH;gBACT,GACA,EAAE;aAEL;QACH;QAEA,MAAMI,MAAMxB,4BAA4Bc,MAAMlB;QAE9C,oCAAoC;QACpC,IACEc,eAAee,IAAI,CACjB,CAACC,gBAAkBF,QAAQE,iBAAiBF,IAAIG,UAAU,CAAC,GAAGD,cAAc,CAAC,CAAC,IAEhF;YACA,OAAOV;QACT;QAEA,MAAMY,iBAAiB;YACrBC,IAAIL;YACJhB,OAAOL,aAAa;gBAAEP;gBAAOQ,QAAQS;YAAY;YACjDhB,OAAO2B;QACT;QAEA,OAAO;eAAIR;YAAaY;SAAe;IACzC,GACA,EAAE;AAEN,EAAC"}
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
.import-preview__info {
|
|
10
10
|
color: var(--color-text-secondary);
|
|
11
|
-
font-family: var(--text-body-medium-font-family);
|
|
12
11
|
font-size: var(--text-body-medium-font-size);
|
|
13
12
|
font-weight: var(--text-body-medium-font-weight);
|
|
14
13
|
line-height: var(--text-body-medium-line-height);
|
|
@@ -16,7 +15,6 @@
|
|
|
16
15
|
|
|
17
16
|
.import-preview__import-count {
|
|
18
17
|
color: var(--color-text-secondary);
|
|
19
|
-
font-family: var(--text-body-medium-font-family);
|
|
20
18
|
font-size: var(--text-body-medium-font-size);
|
|
21
19
|
font-weight: var(--text-body-medium-font-weight);
|
|
22
20
|
line-height: var(--text-body-medium-line-height);
|
|
@@ -39,7 +37,6 @@
|
|
|
39
37
|
|
|
40
38
|
.import-preview__page-info {
|
|
41
39
|
color: var(--color-text-secondary);
|
|
42
|
-
font-family: var(--text-body-medium-font-family);
|
|
43
40
|
font-size: var(--text-body-medium-font-size);
|
|
44
41
|
font-weight: var(--text-body-medium-font-weight);
|
|
45
42
|
line-height: var(--text-body-medium-line-height);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ImportPreview/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAkC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ImportPreview/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAkC,MAAM,OAAO,CAAA;AActD,OAAO,aAAa,CAAA;AAuBpB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EA+nBjC,CAAA"}
|
|
@@ -7,6 +7,7 @@ import { fieldAffectsData, getObjectDotNotation } from 'payload/shared';
|
|
|
7
7
|
import React, { useState, useTransition } from 'react';
|
|
8
8
|
import { DEFAULT_PREVIEW_LIMIT, PREVIEW_LIMIT_OPTIONS } from '../../constants.js';
|
|
9
9
|
import { getFormStateSignature, getSubmittedFormValues } from '../../utilities/getSubmittedFormValues.js';
|
|
10
|
+
import { RelationshipCell } from '../RelationshipCell/index.js';
|
|
10
11
|
import './index.css';
|
|
11
12
|
const baseClass = 'import-preview';
|
|
12
13
|
// The file contents are sent separately as `fileData`.
|
|
@@ -201,16 +202,21 @@ export const ImportPreview = ()=>{
|
|
|
201
202
|
active: true,
|
|
202
203
|
field,
|
|
203
204
|
Heading: label,
|
|
204
|
-
renderedCells: docs.map((doc)=>{
|
|
205
|
+
renderedCells: docs.map((doc, rowIndex)=>{
|
|
205
206
|
const value = getObjectDotNotation(doc, fieldPath);
|
|
206
207
|
if (value === undefined || value === null) {
|
|
207
208
|
return null;
|
|
208
209
|
}
|
|
209
210
|
// Format based on field type
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
const shouldRenderGroupedRelationship = format === 'json' && field.type === 'relationship' && Array.isArray(field.relationTo);
|
|
212
|
+
if (shouldRenderGroupedRelationship) {
|
|
213
|
+
return /*#__PURE__*/ _jsx(RelationshipCell, {
|
|
214
|
+
fieldPath: fieldPath,
|
|
215
|
+
relationTo: field.relationTo,
|
|
216
|
+
value: value
|
|
217
|
+
}, `${fieldPath}-${rowIndex}`);
|
|
218
|
+
} else if (field.type === 'relationship' || field.type === 'upload') {
|
|
212
219
|
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
213
|
-
// Single relationship
|
|
214
220
|
const relationTo = Array.isArray(field.relationTo) ? value.relationTo : field.relationTo;
|
|
215
221
|
const relatedConfig = config.collections.find((c)=>c.slug === relationTo);
|
|
216
222
|
if (relatedConfig && relatedConfig.admin?.useAsTitle) {
|
|
@@ -224,11 +230,9 @@ export const ImportPreview = ()=>{
|
|
|
224
230
|
});
|
|
225
231
|
}
|
|
226
232
|
}
|
|
227
|
-
// Fallback to ID
|
|
228
233
|
const id = value.id || value;
|
|
229
234
|
return `${getTranslation(relatedConfig?.labels?.singular || relationTo, i18n)}: ${id}`;
|
|
230
235
|
} else if (Array.isArray(value)) {
|
|
231
|
-
// Multiple relationships
|
|
232
236
|
return value.map((item)=>{
|
|
233
237
|
if (typeof item === 'object') {
|
|
234
238
|
const relationTo = Array.isArray(field.relationTo) ? item.relationTo : field.relationTo;
|
|
@@ -249,7 +253,6 @@ export const ImportPreview = ()=>{
|
|
|
249
253
|
return item;
|
|
250
254
|
}).join(', ');
|
|
251
255
|
}
|
|
252
|
-
// Just an ID
|
|
253
256
|
return String(value);
|
|
254
257
|
} else if (field.type === 'date') {
|
|
255
258
|
// Display date as string to avoid wrong locale/timezone conversion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ImportPreview/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, Column, PaginatedDocs } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Pagination,\n PerPage,\n Table,\n Translation,\n useConfig,\n useDebouncedEffect,\n useDocumentInfo,\n useField,\n useForm,\n useFormFields,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatDocTitle } from '@payloadcms/ui/shared'\nimport { fieldAffectsData, getObjectDotNotation } from 'payload/shared'\nimport React, { useState, useTransition } from 'react'\n\nimport type {\n PluginImportExportTranslationKeys,\n PluginImportExportTranslations,\n} from '../../translations/index.js'\nimport type { ImportPreviewResponse } from '../../types.js'\n\nimport { DEFAULT_PREVIEW_LIMIT, PREVIEW_LIMIT_OPTIONS } from '../../constants.js'\nimport {\n getFormStateSignature,\n getSubmittedFormValues,\n} from '../../utilities/getSubmittedFormValues.js'\nimport './index.css'\n\nconst baseClass = 'import-preview'\n\n// The file contents are sent separately as `fileData`.\nconst nonSerializableFormKeys = ['file']\n\n/**\n * Browser-native ArrayBuffer → base64. Avoids Node's `Buffer`, which is not\n * available in the browser under bundlers that don't polyfill it (e.g. Vite),\n * unlike Next's webpack build. Chunked to stay under `String.fromCharCode`'s\n * argument-count limit for large files.\n */\nconst arrayBufferToBase64 = (arrayBuffer: ArrayBuffer): string => {\n const bytes = new Uint8Array(arrayBuffer)\n const chunkSize = 0x8000\n let binary = ''\n for (let i = 0; i < bytes.length; i += chunkSize) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize))\n }\n return btoa(binary)\n}\n\nexport const ImportPreview: React.FC = () => {\n const [isPending, startTransition] = useTransition()\n const {\n config,\n config: { routes },\n } = useConfig()\n const { collectionSlug } = useDocumentInfo()\n const { i18n, t } = useTranslation<\n PluginImportExportTranslations,\n PluginImportExportTranslationKeys\n >()\n\n const { value: targetCollectionSlug } = useField<string>({ path: 'collectionSlug' })\n const { value: importMode } = useField<string>({ path: 'importMode' })\n const { value: matchField } = useField<string>({ path: 'matchField' })\n const { value: filename } = useField<string>({ path: 'filename' })\n const { value: url } = useField<string>({ path: 'url' })\n const { value: mimeType } = useField<string>({ path: 'mimeType' })\n const { value: status } = useField<string>({ path: 'status' })\n const { value: summary } = useField<any>({ path: 'summary' })\n\n // Access the file field directly from form fields\n const fileField = useFormFields(([fields]) => fields?.file || null)\n\n const { getData } = useForm()\n const formStateSignature = useFormFields(([fields]) =>\n getFormStateSignature({ fields, omit: nonSerializableFormKeys }),\n )\n\n const [dataToRender, setDataToRender] = useState<Record<string, unknown>[]>([])\n const [columns, setColumns] = useState<Column[]>([])\n const [totalDocs, setTotalDocs] = useState<number>(0)\n const [error, setError] = useState<null | string>(null)\n\n // Preview pagination state\n const [previewPage, setPreviewPage] = useState(1)\n const [previewLimit, setPreviewLimit] = useState(DEFAULT_PREVIEW_LIMIT)\n const [paginationData, setPaginationData] = useState<null | Pick<\n PaginatedDocs,\n 'hasNextPage' | 'hasPrevPage' | 'limit' | 'nextPage' | 'page' | 'prevPage' | 'totalPages'\n >>(null)\n\n const collectionConfig = React.useMemo(\n () => config.collections.find((c) => c.slug === targetCollectionSlug),\n [targetCollectionSlug, config.collections],\n )\n\n useDebouncedEffect(\n () => {\n if (!collectionSlug || !targetCollectionSlug) {\n return\n }\n\n if (!targetCollectionSlug || (!url && !fileField?.value)) {\n setDataToRender([])\n setColumns([])\n setTotalDocs(0)\n setPaginationData(null)\n return\n }\n\n if (!collectionConfig) {\n setDataToRender([])\n setColumns([])\n setTotalDocs(0)\n setPaginationData(null)\n return\n }\n\n const abortController = new AbortController()\n\n const processFileData = async () => {\n setError(null)\n\n try {\n // Determine format from file\n let format: 'csv' | 'json' = 'json'\n if (fileField?.value && fileField.value instanceof File) {\n const file = fileField.value\n format = file.type === 'text/csv' || file.name?.endsWith('.csv') ? 'csv' : 'json'\n } else if (mimeType === 'text/csv' || filename?.endsWith('.csv')) {\n format = 'csv'\n }\n\n // Get file data as base64\n let fileData: string | undefined\n\n if (fileField?.value && fileField.value instanceof File) {\n // File is being uploaded, read its contents\n const arrayBuffer = await fileField.value.arrayBuffer()\n const base64 = arrayBufferToBase64(arrayBuffer)\n fileData = base64\n } else if (url) {\n // File has been saved, fetch from URL\n const response = await fetch(url, { signal: abortController.signal })\n if (!response.ok) {\n throw new Error('Failed to fetch file')\n }\n const arrayBuffer = await response.arrayBuffer()\n const base64 = arrayBufferToBase64(arrayBuffer)\n fileData = base64\n }\n\n if (!fileData) {\n setDataToRender([])\n setColumns([])\n setTotalDocs(0)\n setPaginationData(null)\n return\n }\n\n // Fetch transformed data from the server\n const res = await fetch(`${routes.api}/${collectionSlug}/preview-data`, {\n body: JSON.stringify({\n collectionSlug: targetCollectionSlug,\n fileData,\n format,\n formData: getSubmittedFormValues({\n formData: getData(),\n omit: nonSerializableFormKeys,\n }),\n previewLimit,\n previewPage,\n }),\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n signal: abortController.signal,\n })\n\n if (!res.ok) {\n throw new Error('Failed to process file')\n }\n\n const {\n docs,\n hasNextPage,\n hasPrevPage,\n limit: responseLimit,\n page: responsePage,\n totalDocs: serverTotalDocs,\n totalPages,\n }: ImportPreviewResponse = await res.json()\n\n setTotalDocs(serverTotalDocs)\n setPaginationData({\n hasNextPage,\n hasPrevPage,\n limit: responseLimit,\n nextPage: responsePage + 1,\n page: responsePage,\n prevPage: responsePage - 1,\n totalPages,\n })\n\n if (!Array.isArray(docs) || docs.length === 0) {\n setDataToRender([])\n setColumns([])\n return\n }\n\n // Build columns from collection fields without traverseFields\n const buildColumnsFromFields = (\n fields: ClientField[],\n parentPath = '',\n parentLabel = '',\n ): Column[] => {\n const cols: Column[] = []\n\n fields.forEach((field) => {\n if (!fieldAffectsData(field) || field.admin?.disabled) {\n return\n }\n\n // Build the field path\n const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name\n\n // Get the field label\n let label = field.name\n if ('label' in field && field.label) {\n label = getTranslation(field.label, i18n)\n }\n\n // Add parent label prefix if in a group\n if (parentLabel) {\n label = `${parentLabel} > ${label}`\n }\n\n // Skip if this field doesn't exist in any document\n const hasData = docs.some((doc) => {\n const value = getObjectDotNotation(doc, fieldPath)\n return value !== undefined && value !== null\n })\n\n if (!hasData && field.type !== 'relationship') {\n return\n }\n\n cols.push({\n accessor: fieldPath,\n active: true,\n field,\n Heading: label,\n renderedCells: docs.map((doc) => {\n const value = getObjectDotNotation(doc, fieldPath)\n\n if (value === undefined || value === null) {\n return null\n }\n\n // Format based on field type\n if (field.type === 'relationship' || field.type === 'upload') {\n // Handle relationships\n if (typeof value === 'object' && !Array.isArray(value)) {\n // Single relationship\n const relationTo = Array.isArray(field.relationTo)\n ? (value as any).relationTo\n : field.relationTo\n\n const relatedConfig = config.collections.find((c) => c.slug === relationTo)\n if (relatedConfig && relatedConfig.admin?.useAsTitle) {\n const titleValue = (value as any)[relatedConfig.admin.useAsTitle]\n if (titleValue) {\n return formatDocTitle({\n collectionConfig: relatedConfig,\n data: value as any,\n dateFormat: config.admin.dateFormat,\n i18n,\n })\n }\n }\n\n // Fallback to ID\n const id = (value as any).id || value\n return `${getTranslation(relatedConfig?.labels?.singular || relationTo, i18n)}: ${id}`\n } else if (Array.isArray(value)) {\n // Multiple relationships\n return value\n .map((item) => {\n if (typeof item === 'object') {\n const relationTo = Array.isArray(field.relationTo)\n ? item.relationTo\n : field.relationTo\n const relatedConfig = config.collections.find(\n (c) => c.slug === relationTo,\n )\n\n if (relatedConfig && relatedConfig.admin?.useAsTitle) {\n const titleValue = item[relatedConfig.admin.useAsTitle]\n if (titleValue) {\n return formatDocTitle({\n collectionConfig: relatedConfig,\n data: item,\n dateFormat: config.admin.dateFormat,\n i18n,\n })\n }\n }\n\n return item.id || item\n }\n return item\n })\n .join(', ')\n }\n\n // Just an ID\n return String(value)\n } else if (field.type === 'date') {\n // Display date as string to avoid wrong locale/timezone conversion\n return String(value)\n } else if (field.type === 'checkbox') {\n return value ? '✓' : '✗'\n } else if (field.type === 'select' || field.type === 'radio') {\n // Show the label for select/radio options\n const option = field.options?.find((opt) => {\n if (typeof opt === 'string') {\n return opt === value\n }\n return opt.value === value\n })\n\n if (option && typeof option === 'object') {\n return getTranslation(option.label, i18n)\n }\n return String(value)\n } else if (field.type === 'number') {\n return String(value)\n } else if (Array.isArray(value)) {\n // Handle arrays\n if (field.type === 'blocks') {\n return value.map((block: any) => `${block.blockType || 'Block'}`).join(', ')\n }\n return `[${value.length} items]`\n } else if (typeof value === 'object') {\n // Handle objects\n if (field.type === 'group') {\n return '{...}'\n }\n return JSON.stringify(value)\n }\n\n return String(value)\n }),\n })\n\n // For groups, add nested fields with parent label\n if (field.type === 'group' && 'fields' in field) {\n const groupLabel =\n 'label' in field && field.label ? getTranslation(field.label, i18n) : field.name\n\n const nestedCols = buildColumnsFromFields(\n field.fields,\n fieldPath,\n parentLabel ? `${parentLabel} > ${groupLabel}` : groupLabel,\n )\n cols.push(...nestedCols)\n }\n\n // For tabs, process the fields within\n if ('tabs' in field && Array.isArray(field.tabs)) {\n field.tabs.forEach((tab) => {\n if ('name' in tab && tab.name) {\n // Named tab\n const tabPath = parentPath ? `${parentPath}.${tab.name}` : tab.name\n const tabLabel =\n 'label' in tab && tab.label ? getTranslation(tab.label, i18n) : tab.name\n\n const tabCols = buildColumnsFromFields(\n tab.fields,\n tabPath,\n parentLabel ? `${parentLabel} > ${tabLabel}` : tabLabel,\n )\n cols.push(...tabCols)\n } else {\n // Unnamed tab - fields go directly under parent\n const tabLabel =\n 'label' in tab && tab.label ? getTranslation(tab.label, i18n) : ''\n\n const tabCols = buildColumnsFromFields(\n tab.fields,\n parentPath,\n tabLabel && typeof tabLabel === 'string' && parentLabel\n ? `${parentLabel} > ${tabLabel}`\n : typeof tabLabel === 'string'\n ? tabLabel\n : parentLabel,\n )\n cols.push(...tabCols)\n }\n })\n }\n })\n\n return cols\n }\n\n const fieldColumns = buildColumnsFromFields(collectionConfig.fields)\n\n const existingAccessors = new Set(fieldColumns.map((column) => column.accessor))\n\n // Discover all fields from document data to determine column order\n // Respect the order fields appear in the data (e.g., CSV column order)\n const dataFieldOrder: string[] = []\n const dataFieldsSet = new Set<string>()\n\n // Collect all fields from all docs to get comprehensive field list\n docs.forEach((doc) => {\n Object.keys(doc).forEach((key) => {\n if (!dataFieldsSet.has(key) && doc[key] !== undefined && doc[key] !== null) {\n dataFieldsSet.add(key)\n dataFieldOrder.push(key)\n }\n })\n })\n\n // Helper to create a column for a field\n const createColumnForField = (fieldName: string): Column => ({\n accessor: fieldName,\n active: true,\n field: { name: fieldName } as ClientField,\n Heading: getTranslation(fieldName, i18n),\n renderedCells: docs.map((doc) => {\n const value = doc[fieldName]\n if (value === undefined || value === null) {\n return null\n }\n\n return String(value)\n }),\n })\n\n // Build columns respecting data order for fields not in config\n // For fields in config, use their natural order from fieldColumns\n const finalColumns: Column[] = []\n const addedAccessors = new Set<string>()\n\n // Process fields in the order they appear in the data\n dataFieldOrder.forEach((fieldName) => {\n if (existingAccessors.has(fieldName)) {\n // This field is from the collection config\n const configColumn = fieldColumns.find((col) => col.accessor === fieldName)\n if (configColumn && !addedAccessors.has(fieldName)) {\n finalColumns.push(configColumn)\n addedAccessors.add(fieldName)\n }\n } else {\n // This is an additional field (system field or extra data field)\n if (!addedAccessors.has(fieldName)) {\n finalColumns.push(createColumnForField(fieldName))\n addedAccessors.add(fieldName)\n }\n }\n })\n\n // Add any remaining config fields that weren't in the data\n fieldColumns.forEach((col) => {\n if (!addedAccessors.has(col.accessor)) {\n finalColumns.push(col)\n addedAccessors.add(col.accessor)\n }\n })\n\n setColumns(finalColumns)\n setDataToRender(docs)\n } catch (err) {\n console.error('Error processing file data:', err)\n setError(err instanceof Error ? err.message : 'Failed to load preview')\n setDataToRender([])\n setColumns([])\n setTotalDocs(0)\n setPaginationData(null)\n }\n }\n\n startTransition(async () => await processFileData())\n\n return () => {\n if (!abortController.signal.aborted) {\n abortController.abort('Component unmounted')\n }\n }\n },\n [\n collectionSlug,\n targetCollectionSlug,\n url,\n filename,\n mimeType,\n fileField?.value,\n formStateSignature,\n getData,\n collectionConfig,\n config,\n i18n,\n previewLimit,\n previewPage,\n routes.api,\n ],\n 500,\n )\n\n // If import has been processed, show results instead of preview\n if (status !== 'pending' && summary) {\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__header`}>\n <h3>\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:importResults\" t={t} />\n </h3>\n </div>\n <div className={`${baseClass}__results`}>\n <p>\n <strong>Status:</strong> {status}\n </p>\n <p>\n <strong>Imported:</strong> {summary.imported || 0}\n </p>\n <p>\n <strong>Updated:</strong> {summary.updated || 0}\n </p>\n <p>\n <strong>Total:</strong> {summary.total || 0}\n </p>\n {summary.issues > 0 && (\n <p>\n <strong>Issues:</strong> {summary.issues}\n </p>\n )}\n {summary.issueDetails && summary.issueDetails.length > 0 && (\n <div style={{ marginTop: '1rem' }}>\n <strong>Issue Details:</strong>\n <ul style={{ marginTop: '0.5rem' }}>\n {summary.issueDetails.slice(0, 10).map((issue: any, index: number) => (\n <li key={index}>\n Row {issue.row}: {issue.error}\n </li>\n ))}\n {summary.issueDetails.length > 10 && (\n <li>... and {summary.issueDetails.length - 10} more issues</li>\n )}\n </ul>\n </div>\n )}\n </div>\n </div>\n )\n }\n\n if (!targetCollectionSlug) {\n return (\n <div className={baseClass}>\n <p style={{ opacity: 0.6 }}>\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:collectionRequired\" t={t} />\n </p>\n </div>\n )\n }\n\n if (error) {\n return (\n <div className={baseClass}>\n <p style={{ color: 'red' }}>\n <Translation i18nKey=\"general:error\" t={t} />: {error}\n </p>\n </div>\n )\n }\n\n if (!url && !fileField?.value) {\n return (\n <div className={baseClass}>\n <p style={{ opacity: 0.6 }}>\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:uploadFileToSeePreview\" t={t} />\n </p>\n </div>\n )\n }\n\n const handlePageChange = (page: number) => {\n setPreviewPage(page)\n }\n\n const handlePerPageChange = (newLimit: number) => {\n setPreviewLimit(newLimit)\n setPreviewPage(1)\n }\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__header`}>\n <h3>\n <Translation i18nKey=\"version:preview\" t={t} />\n </h3>\n {totalDocs > 0 && !isPending && (\n <div className={`${baseClass}__info`}>\n <span className={`${baseClass}__import-count`}>\n <Translation\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n i18nKey=\"plugin-import-export:documentsToImport\"\n t={t}\n variables={{\n count: totalDocs,\n }}\n />\n </span>\n {' | '}\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:mode\" t={t} />: {importMode || 'create'}\n {importMode !== 'create' && (\n <>\n {' | '}\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:matchBy\" t={t} />: {matchField || 'id'}\n </>\n )}\n </div>\n )}\n </div>\n {isPending && !dataToRender.length && (\n <div className={`${baseClass}__loading`}>\n <Translation i18nKey=\"general:loading\" t={t} />\n </div>\n )}\n {dataToRender.length > 0 && <Table columns={columns} data={dataToRender} />}\n {!isPending && dataToRender.length === 0 && targetCollectionSlug && (\n <p>\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:noDataToPreview\" t={t} />\n </p>\n )}\n {paginationData && totalDocs > 0 && (\n <div className={`${baseClass}__pagination`}>\n {paginationData.totalPages > 1 && (\n <Pagination\n hasNextPage={paginationData.hasNextPage}\n hasPrevPage={paginationData.hasPrevPage}\n nextPage={paginationData.nextPage ?? undefined}\n numberOfNeighbors={1}\n onChange={handlePageChange}\n page={paginationData.page}\n prevPage={paginationData.prevPage ?? undefined}\n totalPages={paginationData.totalPages}\n />\n )}\n <span className={`${baseClass}__page-info`}>\n <Translation\n // @ts-expect-error - plugin translations not typed\n i18nKey=\"plugin-import-export:previewPageInfo\"\n t={t}\n variables={{\n end: Math.min((paginationData.page ?? 1) * previewLimit, totalDocs),\n start: ((paginationData.page ?? 1) - 1) * previewLimit + 1,\n total: totalDocs,\n }}\n />\n </span>\n <PerPage\n handleChange={handlePerPageChange}\n limit={previewLimit}\n limits={PREVIEW_LIMIT_OPTIONS}\n />\n </div>\n )}\n </div>\n )\n}\n"],"names":["getTranslation","Pagination","PerPage","Table","Translation","useConfig","useDebouncedEffect","useDocumentInfo","useField","useForm","useFormFields","useTranslation","formatDocTitle","fieldAffectsData","getObjectDotNotation","React","useState","useTransition","DEFAULT_PREVIEW_LIMIT","PREVIEW_LIMIT_OPTIONS","getFormStateSignature","getSubmittedFormValues","baseClass","nonSerializableFormKeys","arrayBufferToBase64","arrayBuffer","bytes","Uint8Array","chunkSize","binary","i","length","String","fromCharCode","subarray","btoa","ImportPreview","isPending","startTransition","config","routes","collectionSlug","i18n","t","value","targetCollectionSlug","path","importMode","matchField","filename","url","mimeType","status","summary","fileField","fields","file","getData","formStateSignature","omit","dataToRender","setDataToRender","columns","setColumns","totalDocs","setTotalDocs","error","setError","previewPage","setPreviewPage","previewLimit","setPreviewLimit","paginationData","setPaginationData","collectionConfig","useMemo","collections","find","c","slug","abortController","AbortController","processFileData","format","File","type","name","endsWith","fileData","base64","response","fetch","signal","ok","Error","res","api","body","JSON","stringify","formData","credentials","headers","method","docs","hasNextPage","hasPrevPage","limit","responseLimit","page","responsePage","serverTotalDocs","totalPages","json","nextPage","prevPage","Array","isArray","buildColumnsFromFields","parentPath","parentLabel","cols","forEach","field","admin","disabled","fieldPath","label","hasData","some","doc","undefined","push","accessor","active","Heading","renderedCells","map","relationTo","relatedConfig","useAsTitle","titleValue","data","dateFormat","id","labels","singular","item","join","option","options","opt","block","blockType","groupLabel","nestedCols","tabs","tab","tabPath","tabLabel","tabCols","fieldColumns","existingAccessors","Set","column","dataFieldOrder","dataFieldsSet","Object","keys","key","has","add","createColumnForField","fieldName","finalColumns","addedAccessors","configColumn","col","err","console","message","aborted","abort","div","className","h3","i18nKey","p","strong","imported","updated","total","issues","issueDetails","style","marginTop","ul","slice","issue","index","li","row","opacity","color","handlePageChange","handlePerPageChange","newLimit","span","variables","count","numberOfNeighbors","onChange","end","Math","min","start","handleChange","limits"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,UAAU,EACVC,OAAO,EACPC,KAAK,EACLC,WAAW,EACXC,SAAS,EACTC,kBAAkB,EAClBC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,gBAAgB,EAAEC,oBAAoB,QAAQ,iBAAgB;AACvE,OAAOC,SAASC,QAAQ,EAAEC,aAAa,QAAQ,QAAO;AAQtD,SAASC,qBAAqB,EAAEC,qBAAqB,QAAQ,qBAAoB;AACjF,SACEC,qBAAqB,EACrBC,sBAAsB,QACjB,4CAA2C;AAClD,OAAO,cAAa;AAEpB,MAAMC,YAAY;AAElB,uDAAuD;AACvD,MAAMC,0BAA0B;IAAC;CAAO;AAExC;;;;;CAKC,GACD,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,QAAQ,IAAIC,WAAWF;IAC7B,MAAMG,YAAY;IAClB,IAAIC,SAAS;IACb,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,MAAMK,MAAM,EAAED,KAAKF,UAAW;QAChDC,UAAUG,OAAOC,YAAY,IAAIP,MAAMQ,QAAQ,CAACJ,GAAGA,IAAIF;IACzD;IACA,OAAOO,KAAKN;AACd;AAEA,OAAO,MAAMO,gBAA0B;IACrC,MAAM,CAACC,WAAWC,gBAAgB,GAAGrB;IACrC,MAAM,EACJsB,MAAM,EACNA,QAAQ,EAAEC,MAAM,EAAE,EACnB,GAAGnC;IACJ,MAAM,EAAEoC,cAAc,EAAE,GAAGlC;IAC3B,MAAM,EAAEmC,IAAI,EAAEC,CAAC,EAAE,GAAGhC;IAKpB,MAAM,EAAEiC,OAAOC,oBAAoB,EAAE,GAAGrC,SAAiB;QAAEsC,MAAM;IAAiB;IA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wBACCwG,aAAajC,eAAeiC,WAAW;wBACvCC,aAAalC,eAAekC,WAAW;wBACvCQ,UAAU1C,eAAe0C,QAAQ,IAAIiB;wBACrC+E,mBAAmB;wBACnBC,UAAUP;wBACV/F,MAAMrC,eAAeqC,IAAI;wBACzBM,UAAU3C,eAAe2C,QAAQ,IAAIgB;wBACrCnB,YAAYxC,eAAewC,UAAU;;kCAGzC,KAAC+F;wBAAKvB,WAAW,GAAGlK,UAAU,WAAW,CAAC;kCACxC,cAAA,KAAClB;4BACC,mDAAmD;4BACnDsL,SAAQ;4BACR/I,GAAGA;4BACHqK,WAAW;gCACTI,KAAKC,KAAKC,GAAG,CAAC,AAAC9I,CAAAA,eAAeqC,IAAI,IAAI,CAAA,IAAKvC,cAAcN;gCACzDuJ,OAAO,AAAC,CAAA,AAAC/I,CAAAA,eAAeqC,IAAI,IAAI,CAAA,IAAK,CAAA,IAAKvC,eAAe;gCACzDyH,OAAO/H;4BACT;;;kCAGJ,KAAC9D;wBACCsN,cAAcX;wBACdlG,OAAOrC;wBACPmJ,QAAQtM;;;;;;AAMpB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ImportPreview/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, Column, PaginatedDocs } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Pagination,\n PerPage,\n Table,\n Translation,\n useConfig,\n useDebouncedEffect,\n useDocumentInfo,\n useField,\n useForm,\n useFormFields,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatDocTitle } from '@payloadcms/ui/shared'\nimport { fieldAffectsData, getObjectDotNotation } from 'payload/shared'\nimport React, { useState, useTransition } from 'react'\n\nimport type {\n PluginImportExportTranslationKeys,\n PluginImportExportTranslations,\n} from '../../translations/index.js'\nimport type { ImportPreviewResponse } from '../../types.js'\n\nimport { DEFAULT_PREVIEW_LIMIT, PREVIEW_LIMIT_OPTIONS } from '../../constants.js'\nimport {\n getFormStateSignature,\n getSubmittedFormValues,\n} from '../../utilities/getSubmittedFormValues.js'\nimport { RelationshipCell } from '../RelationshipCell/index.js'\nimport './index.css'\n\nconst baseClass = 'import-preview'\n\n// The file contents are sent separately as `fileData`.\nconst nonSerializableFormKeys = ['file']\n\n/**\n * Browser-native ArrayBuffer → base64. Avoids Node's `Buffer`, which is not\n * available in the browser under bundlers that don't polyfill it (e.g. Vite),\n * unlike Next's webpack build. Chunked to stay under `String.fromCharCode`'s\n * argument-count limit for large files.\n */\nconst arrayBufferToBase64 = (arrayBuffer: ArrayBuffer): string => {\n const bytes = new Uint8Array(arrayBuffer)\n const chunkSize = 0x8000\n let binary = ''\n for (let i = 0; i < bytes.length; i += chunkSize) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize))\n }\n return btoa(binary)\n}\n\nexport const ImportPreview: React.FC = () => {\n const [isPending, startTransition] = useTransition()\n const {\n config,\n config: { routes },\n } = useConfig()\n const { collectionSlug } = useDocumentInfo()\n const { i18n, t } = useTranslation<\n PluginImportExportTranslations,\n PluginImportExportTranslationKeys\n >()\n\n const { value: targetCollectionSlug } = useField<string>({ path: 'collectionSlug' })\n const { value: importMode } = useField<string>({ path: 'importMode' })\n const { value: matchField } = useField<string>({ path: 'matchField' })\n const { value: filename } = useField<string>({ path: 'filename' })\n const { value: url } = useField<string>({ path: 'url' })\n const { value: mimeType } = useField<string>({ path: 'mimeType' })\n const { value: status } = useField<string>({ path: 'status' })\n const { value: summary } = useField<any>({ path: 'summary' })\n\n // Access the file field directly from form fields\n const fileField = useFormFields(([fields]) => fields?.file || null)\n\n const { getData } = useForm()\n const formStateSignature = useFormFields(([fields]) =>\n getFormStateSignature({ fields, omit: nonSerializableFormKeys }),\n )\n\n const [dataToRender, setDataToRender] = useState<Record<string, unknown>[]>([])\n const [columns, setColumns] = useState<Column[]>([])\n const [totalDocs, setTotalDocs] = useState<number>(0)\n const [error, setError] = useState<null | string>(null)\n\n // Preview pagination state\n const [previewPage, setPreviewPage] = useState(1)\n const [previewLimit, setPreviewLimit] = useState(DEFAULT_PREVIEW_LIMIT)\n const [paginationData, setPaginationData] = useState<null | Pick<\n PaginatedDocs,\n 'hasNextPage' | 'hasPrevPage' | 'limit' | 'nextPage' | 'page' | 'prevPage' | 'totalPages'\n >>(null)\n\n const collectionConfig = React.useMemo(\n () => config.collections.find((c) => c.slug === targetCollectionSlug),\n [targetCollectionSlug, config.collections],\n )\n\n useDebouncedEffect(\n () => {\n if (!collectionSlug || !targetCollectionSlug) {\n return\n }\n\n if (!targetCollectionSlug || (!url && !fileField?.value)) {\n setDataToRender([])\n setColumns([])\n setTotalDocs(0)\n setPaginationData(null)\n return\n }\n\n if (!collectionConfig) {\n setDataToRender([])\n setColumns([])\n setTotalDocs(0)\n setPaginationData(null)\n return\n }\n\n const abortController = new AbortController()\n\n const processFileData = async () => {\n setError(null)\n\n try {\n // Determine format from file\n let format: 'csv' | 'json' = 'json'\n if (fileField?.value && fileField.value instanceof File) {\n const file = fileField.value\n format = file.type === 'text/csv' || file.name?.endsWith('.csv') ? 'csv' : 'json'\n } else if (mimeType === 'text/csv' || filename?.endsWith('.csv')) {\n format = 'csv'\n }\n\n // Get file data as base64\n let fileData: string | undefined\n\n if (fileField?.value && fileField.value instanceof File) {\n // File is being uploaded, read its contents\n const arrayBuffer = await fileField.value.arrayBuffer()\n const base64 = arrayBufferToBase64(arrayBuffer)\n fileData = base64\n } else if (url) {\n // File has been saved, fetch from URL\n const response = await fetch(url, { signal: abortController.signal })\n if (!response.ok) {\n throw new Error('Failed to fetch file')\n }\n const arrayBuffer = await response.arrayBuffer()\n const base64 = arrayBufferToBase64(arrayBuffer)\n fileData = base64\n }\n\n if (!fileData) {\n setDataToRender([])\n setColumns([])\n setTotalDocs(0)\n setPaginationData(null)\n return\n }\n\n // Fetch transformed data from the server\n const res = await fetch(`${routes.api}/${collectionSlug}/preview-data`, {\n body: JSON.stringify({\n collectionSlug: targetCollectionSlug,\n fileData,\n format,\n formData: getSubmittedFormValues({\n formData: getData(),\n omit: nonSerializableFormKeys,\n }),\n previewLimit,\n previewPage,\n }),\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n signal: abortController.signal,\n })\n\n if (!res.ok) {\n throw new Error('Failed to process file')\n }\n\n const {\n docs,\n hasNextPage,\n hasPrevPage,\n limit: responseLimit,\n page: responsePage,\n totalDocs: serverTotalDocs,\n totalPages,\n }: ImportPreviewResponse = await res.json()\n\n setTotalDocs(serverTotalDocs)\n setPaginationData({\n hasNextPage,\n hasPrevPage,\n limit: responseLimit,\n nextPage: responsePage + 1,\n page: responsePage,\n prevPage: responsePage - 1,\n totalPages,\n })\n\n if (!Array.isArray(docs) || docs.length === 0) {\n setDataToRender([])\n setColumns([])\n return\n }\n\n // Build columns from collection fields without traverseFields\n const buildColumnsFromFields = (\n fields: ClientField[],\n parentPath = '',\n parentLabel = '',\n ): Column[] => {\n const cols: Column[] = []\n\n fields.forEach((field) => {\n if (!fieldAffectsData(field) || field.admin?.disabled) {\n return\n }\n\n // Build the field path\n const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name\n\n // Get the field label\n let label = field.name\n if ('label' in field && field.label) {\n label = getTranslation(field.label, i18n)\n }\n\n // Add parent label prefix if in a group\n if (parentLabel) {\n label = `${parentLabel} > ${label}`\n }\n\n // Skip if this field doesn't exist in any document\n const hasData = docs.some((doc) => {\n const value = getObjectDotNotation(doc, fieldPath)\n return value !== undefined && value !== null\n })\n\n if (!hasData && field.type !== 'relationship') {\n return\n }\n\n cols.push({\n accessor: fieldPath,\n active: true,\n field,\n Heading: label,\n renderedCells: docs.map((doc, rowIndex) => {\n const value = getObjectDotNotation(doc, fieldPath)\n\n if (value === undefined || value === null) {\n return null\n }\n\n // Format based on field type\n const shouldRenderGroupedRelationship =\n format === 'json' &&\n field.type === 'relationship' &&\n Array.isArray(field.relationTo)\n\n if (shouldRenderGroupedRelationship) {\n return (\n <RelationshipCell\n fieldPath={fieldPath}\n key={`${fieldPath}-${rowIndex}`}\n relationTo={field.relationTo}\n value={value}\n />\n )\n } else if (field.type === 'relationship' || field.type === 'upload') {\n if (typeof value === 'object' && !Array.isArray(value)) {\n const relationTo = Array.isArray(field.relationTo)\n ? (value as any).relationTo\n : field.relationTo\n\n const relatedConfig = config.collections.find((c) => c.slug === relationTo)\n if (relatedConfig && relatedConfig.admin?.useAsTitle) {\n const titleValue = (value as any)[relatedConfig.admin.useAsTitle]\n if (titleValue) {\n return formatDocTitle({\n collectionConfig: relatedConfig,\n data: value as any,\n dateFormat: config.admin.dateFormat,\n i18n,\n })\n }\n }\n\n const id = (value as any).id || value\n return `${getTranslation(relatedConfig?.labels?.singular || relationTo, i18n)}: ${id}`\n } else if (Array.isArray(value)) {\n return value\n .map((item) => {\n if (typeof item === 'object') {\n const relationTo = Array.isArray(field.relationTo)\n ? item.relationTo\n : field.relationTo\n const relatedConfig = config.collections.find(\n (c) => c.slug === relationTo,\n )\n\n if (relatedConfig && relatedConfig.admin?.useAsTitle) {\n const titleValue = item[relatedConfig.admin.useAsTitle]\n if (titleValue) {\n return formatDocTitle({\n collectionConfig: relatedConfig,\n data: item,\n dateFormat: config.admin.dateFormat,\n i18n,\n })\n }\n }\n\n return item.id || item\n }\n return item\n })\n .join(', ')\n }\n\n return String(value)\n } else if (field.type === 'date') {\n // Display date as string to avoid wrong locale/timezone conversion\n return String(value)\n } else if (field.type === 'checkbox') {\n return value ? '✓' : '✗'\n } else if (field.type === 'select' || field.type === 'radio') {\n // Show the label for select/radio options\n const option = field.options?.find((opt) => {\n if (typeof opt === 'string') {\n return opt === value\n }\n return opt.value === value\n })\n\n if (option && typeof option === 'object') {\n return getTranslation(option.label, i18n)\n }\n return String(value)\n } else if (field.type === 'number') {\n return String(value)\n } else if (Array.isArray(value)) {\n // Handle arrays\n if (field.type === 'blocks') {\n return value.map((block: any) => `${block.blockType || 'Block'}`).join(', ')\n }\n return `[${value.length} items]`\n } else if (typeof value === 'object') {\n // Handle objects\n if (field.type === 'group') {\n return '{...}'\n }\n return JSON.stringify(value)\n }\n\n return String(value)\n }),\n })\n\n // For groups, add nested fields with parent label\n if (field.type === 'group' && 'fields' in field) {\n const groupLabel =\n 'label' in field && field.label ? getTranslation(field.label, i18n) : field.name\n\n const nestedCols = buildColumnsFromFields(\n field.fields,\n fieldPath,\n parentLabel ? `${parentLabel} > ${groupLabel}` : groupLabel,\n )\n cols.push(...nestedCols)\n }\n\n // For tabs, process the fields within\n if ('tabs' in field && Array.isArray(field.tabs)) {\n field.tabs.forEach((tab) => {\n if ('name' in tab && tab.name) {\n // Named tab\n const tabPath = parentPath ? `${parentPath}.${tab.name}` : tab.name\n const tabLabel =\n 'label' in tab && tab.label ? getTranslation(tab.label, i18n) : tab.name\n\n const tabCols = buildColumnsFromFields(\n tab.fields,\n tabPath,\n parentLabel ? `${parentLabel} > ${tabLabel}` : tabLabel,\n )\n cols.push(...tabCols)\n } else {\n // Unnamed tab - fields go directly under parent\n const tabLabel =\n 'label' in tab && tab.label ? getTranslation(tab.label, i18n) : ''\n\n const tabCols = buildColumnsFromFields(\n tab.fields,\n parentPath,\n tabLabel && typeof tabLabel === 'string' && parentLabel\n ? `${parentLabel} > ${tabLabel}`\n : typeof tabLabel === 'string'\n ? tabLabel\n : parentLabel,\n )\n cols.push(...tabCols)\n }\n })\n }\n })\n\n return cols\n }\n\n const fieldColumns = buildColumnsFromFields(collectionConfig.fields)\n\n const existingAccessors = new Set(fieldColumns.map((column) => column.accessor))\n\n // Discover all fields from document data to determine column order\n // Respect the order fields appear in the data (e.g., CSV column order)\n const dataFieldOrder: string[] = []\n const dataFieldsSet = new Set<string>()\n\n // Collect all fields from all docs to get comprehensive field list\n docs.forEach((doc) => {\n Object.keys(doc).forEach((key) => {\n if (!dataFieldsSet.has(key) && doc[key] !== undefined && doc[key] !== null) {\n dataFieldsSet.add(key)\n dataFieldOrder.push(key)\n }\n })\n })\n\n // Helper to create a column for a field\n const createColumnForField = (fieldName: string): Column => ({\n accessor: fieldName,\n active: true,\n field: { name: fieldName } as ClientField,\n Heading: getTranslation(fieldName, i18n),\n renderedCells: docs.map((doc) => {\n const value = doc[fieldName]\n if (value === undefined || value === null) {\n return null\n }\n\n return String(value)\n }),\n })\n\n // Build columns respecting data order for fields not in config\n // For fields in config, use their natural order from fieldColumns\n const finalColumns: Column[] = []\n const addedAccessors = new Set<string>()\n\n // Process fields in the order they appear in the data\n dataFieldOrder.forEach((fieldName) => {\n if (existingAccessors.has(fieldName)) {\n // This field is from the collection config\n const configColumn = fieldColumns.find((col) => col.accessor === fieldName)\n if (configColumn && !addedAccessors.has(fieldName)) {\n finalColumns.push(configColumn)\n addedAccessors.add(fieldName)\n }\n } else {\n // This is an additional field (system field or extra data field)\n if (!addedAccessors.has(fieldName)) {\n finalColumns.push(createColumnForField(fieldName))\n addedAccessors.add(fieldName)\n }\n }\n })\n\n // Add any remaining config fields that weren't in the data\n fieldColumns.forEach((col) => {\n if (!addedAccessors.has(col.accessor)) {\n finalColumns.push(col)\n addedAccessors.add(col.accessor)\n }\n })\n\n setColumns(finalColumns)\n setDataToRender(docs)\n } catch (err) {\n console.error('Error processing file data:', err)\n setError(err instanceof Error ? err.message : 'Failed to load preview')\n setDataToRender([])\n setColumns([])\n setTotalDocs(0)\n setPaginationData(null)\n }\n }\n\n startTransition(async () => await processFileData())\n\n return () => {\n if (!abortController.signal.aborted) {\n abortController.abort('Component unmounted')\n }\n }\n },\n [\n collectionSlug,\n targetCollectionSlug,\n url,\n filename,\n mimeType,\n fileField?.value,\n formStateSignature,\n getData,\n collectionConfig,\n config,\n i18n,\n previewLimit,\n previewPage,\n routes.api,\n ],\n 500,\n )\n\n // If import has been processed, show results instead of preview\n if (status !== 'pending' && summary) {\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__header`}>\n <h3>\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:importResults\" t={t} />\n </h3>\n </div>\n <div className={`${baseClass}__results`}>\n <p>\n <strong>Status:</strong> {status}\n </p>\n <p>\n <strong>Imported:</strong> {summary.imported || 0}\n </p>\n <p>\n <strong>Updated:</strong> {summary.updated || 0}\n </p>\n <p>\n <strong>Total:</strong> {summary.total || 0}\n </p>\n {summary.issues > 0 && (\n <p>\n <strong>Issues:</strong> {summary.issues}\n </p>\n )}\n {summary.issueDetails && summary.issueDetails.length > 0 && (\n <div style={{ marginTop: '1rem' }}>\n <strong>Issue Details:</strong>\n <ul style={{ marginTop: '0.5rem' }}>\n {summary.issueDetails.slice(0, 10).map((issue: any, index: number) => (\n <li key={index}>\n Row {issue.row}: {issue.error}\n </li>\n ))}\n {summary.issueDetails.length > 10 && (\n <li>... and {summary.issueDetails.length - 10} more issues</li>\n )}\n </ul>\n </div>\n )}\n </div>\n </div>\n )\n }\n\n if (!targetCollectionSlug) {\n return (\n <div className={baseClass}>\n <p style={{ opacity: 0.6 }}>\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:collectionRequired\" t={t} />\n </p>\n </div>\n )\n }\n\n if (error) {\n return (\n <div className={baseClass}>\n <p style={{ color: 'red' }}>\n <Translation i18nKey=\"general:error\" t={t} />: {error}\n </p>\n </div>\n )\n }\n\n if (!url && !fileField?.value) {\n return (\n <div className={baseClass}>\n <p style={{ opacity: 0.6 }}>\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:uploadFileToSeePreview\" t={t} />\n </p>\n </div>\n )\n }\n\n const handlePageChange = (page: number) => {\n setPreviewPage(page)\n }\n\n const handlePerPageChange = (newLimit: number) => {\n setPreviewLimit(newLimit)\n setPreviewPage(1)\n }\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__header`}>\n <h3>\n <Translation i18nKey=\"version:preview\" t={t} />\n </h3>\n {totalDocs > 0 && !isPending && (\n <div className={`${baseClass}__info`}>\n <span className={`${baseClass}__import-count`}>\n <Translation\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n i18nKey=\"plugin-import-export:documentsToImport\"\n t={t}\n variables={{\n count: totalDocs,\n }}\n />\n </span>\n {' | '}\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:mode\" t={t} />: {importMode || 'create'}\n {importMode !== 'create' && (\n <>\n {' | '}\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:matchBy\" t={t} />: {matchField || 'id'}\n </>\n )}\n </div>\n )}\n </div>\n {isPending && !dataToRender.length && (\n <div className={`${baseClass}__loading`}>\n <Translation i18nKey=\"general:loading\" t={t} />\n </div>\n )}\n {dataToRender.length > 0 && <Table columns={columns} data={dataToRender} />}\n {!isPending && dataToRender.length === 0 && targetCollectionSlug && (\n <p>\n {/* @ts-expect-error - translations are not typed in plugins */}\n <Translation i18nKey=\"plugin-import-export:noDataToPreview\" t={t} />\n </p>\n )}\n {paginationData && totalDocs > 0 && (\n <div className={`${baseClass}__pagination`}>\n {paginationData.totalPages > 1 && (\n <Pagination\n hasNextPage={paginationData.hasNextPage}\n hasPrevPage={paginationData.hasPrevPage}\n nextPage={paginationData.nextPage ?? undefined}\n numberOfNeighbors={1}\n onChange={handlePageChange}\n page={paginationData.page}\n prevPage={paginationData.prevPage ?? undefined}\n totalPages={paginationData.totalPages}\n />\n )}\n <span className={`${baseClass}__page-info`}>\n <Translation\n // @ts-expect-error - plugin translations not typed\n i18nKey=\"plugin-import-export:previewPageInfo\"\n t={t}\n variables={{\n end: Math.min((paginationData.page ?? 1) * previewLimit, totalDocs),\n start: ((paginationData.page ?? 1) - 1) * previewLimit + 1,\n total: totalDocs,\n }}\n />\n </span>\n <PerPage\n handleChange={handlePerPageChange}\n limit={previewLimit}\n limits={PREVIEW_LIMIT_OPTIONS}\n />\n </div>\n )}\n </div>\n )\n}\n"],"names":["getTranslation","Pagination","PerPage","Table","Translation","useConfig","useDebouncedEffect","useDocumentInfo","useField","useForm","useFormFields","useTranslation","formatDocTitle","fieldAffectsData","getObjectDotNotation","React","useState","useTransition","DEFAULT_PREVIEW_LIMIT","PREVIEW_LIMIT_OPTIONS","getFormStateSignature","getSubmittedFormValues","RelationshipCell","baseClass","nonSerializableFormKeys","arrayBufferToBase64","arrayBuffer","bytes","Uint8Array","chunkSize","binary","i","length","String","fromCharCode","subarray","btoa","ImportPreview","isPending","startTransition","config","routes","collectionSlug","i18n","t","value","targetCollectionSlug","path","importMode","matchField","filename","url","mimeType","status","summary","fileField","fields","file","getData","formStateSignature","omit","dataToRender","setDataToRender","columns","setColumns","totalDocs","setTotalDocs","error","setError","previewPage","setPreviewPage","previewLimit","setPreviewLimit","paginationData","setPaginationData","collectionConfig","useMemo","collections","find","c","slug","abortController","AbortController","processFileData","format","File","type","name","endsWith","fileData","base64","response","fetch","signal","ok","Error","res","api","body","JSON","stringify","formData","credentials","headers","method","docs","hasNextPage","hasPrevPage","limit","responseLimit","page","responsePage","serverTotalDocs","totalPages","json","nextPage","prevPage","Array","isArray","buildColumnsFromFields","parentPath","parentLabel","cols","forEach","field","admin","disabled","fieldPath","label","hasData","some","doc","undefined","push","accessor","active","Heading","renderedCells","map","rowIndex","shouldRenderGroupedRelationship","relationTo","relatedConfig","useAsTitle","titleValue","data","dateFormat","id","labels","singular","item","join","option","options","opt","block","blockType","groupLabel","nestedCols","tabs","tab","tabPath","tabLabel","tabCols","fieldColumns","existingAccessors","Set","column","dataFieldOrder","dataFieldsSet","Object","keys","key","has","add","createColumnForField","fieldName","finalColumns","addedAccessors","configColumn","col","err","console","message","aborted","abort","div","className","h3","i18nKey","p","strong","imported","updated","total","issues","issueDetails","style","marginTop","ul","slice","issue","index","li","row","opacity","color","handlePageChange","handlePerPageChange","newLimit","span","variables","count","numberOfNeighbors","onChange","end","Math","min","start","handleChange","limits"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,UAAU,EACVC,OAAO,EACPC,KAAK,EACLC,WAAW,EACXC,SAAS,EACTC,kBAAkB,EAClBC,eAAe,EACfC,QAAQ,EACRC,OAAO,E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H;wBACCyG,aAAajC,eAAeiC,WAAW;wBACvCC,aAAalC,eAAekC,WAAW;wBACvCQ,UAAU1C,eAAe0C,QAAQ,IAAIiB;wBACrCiF,mBAAmB;wBACnBC,UAAUP;wBACVjG,MAAMrC,eAAeqC,IAAI;wBACzBM,UAAU3C,eAAe2C,QAAQ,IAAIgB;wBACrCnB,YAAYxC,eAAewC,UAAU;;kCAGzC,KAACiG;wBAAKvB,WAAW,GAAGpK,UAAU,WAAW,CAAC;kCACxC,cAAA,KAACnB;4BACC,mDAAmD;4BACnDyL,SAAQ;4BACRjJ,GAAGA;4BACHuK,WAAW;gCACTI,KAAKC,KAAKC,GAAG,CAAC,AAAChJ,CAAAA,eAAeqC,IAAI,IAAI,CAAA,IAAKvC,cAAcN;gCACzDyJ,OAAO,AAAC,CAAA,AAACjJ,CAAAA,eAAeqC,IAAI,IAAI,CAAA,IAAK,CAAA,IAAKvC,eAAe;gCACzD2H,OAAOjI;4BACT;;;kCAGJ,KAAC/D;wBACCyN,cAAcX;wBACdpG,OAAOrC;wBACPqJ,QAAQzM;;;;;;AAMpB,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRelationshipGroupKey.d.ts","sourceRoot":"","sources":["../../../src/components/RelationshipCell/getRelationshipGroupKey.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,uBAAuB,wBAAyB,IAAI,KAAG,MACzB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/RelationshipCell/getRelationshipGroupKey.ts"],"sourcesContent":["type Args = {\n fieldPath: string\n slug?: string\n}\n\nexport const getRelationshipGroupKey = ({ slug, fieldPath }: Args): string =>\n slug ? `${fieldPath}-${slug}` : fieldPath\n"],"names":["getRelationshipGroupKey","slug","fieldPath"],"mappings":"AAKA,OAAO,MAAMA,0BAA0B,CAAC,EAAEC,IAAI,EAAEC,SAAS,EAAQ,GAC/DD,OAAO,GAAGC,UAAU,CAAC,EAAED,MAAM,GAAGC,UAAS"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { I18n } from '@payloadcms/translations';
|
|
2
|
+
import type { ClientCollectionConfig, SanitizedConfig } from 'payload';
|
|
3
|
+
/**
|
|
4
|
+
* Labels rendered per collection before the rest collapse into `and N more`,
|
|
5
|
+
* matching `totalToShow` in the list view's relationship cell.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TOTAL_TO_SHOW = 3;
|
|
8
|
+
type Args = {
|
|
9
|
+
collections: ClientCollectionConfig[];
|
|
10
|
+
dateFormat: SanitizedConfig['admin']['dateFormat'];
|
|
11
|
+
i18n: I18n<any, any>;
|
|
12
|
+
/** `field.relationTo` — an array when the field is polymorphic. */
|
|
13
|
+
relationTo: string | string[];
|
|
14
|
+
value: unknown;
|
|
15
|
+
};
|
|
16
|
+
export type RelationshipGroup = {
|
|
17
|
+
/** Plural label of the target collection, empty when it cannot be determined. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** One rendered label per document, capped at `TOTAL_TO_SHOW`. */
|
|
20
|
+
options: string[];
|
|
21
|
+
/** Options past `TOTAL_TO_SHOW` dropped from this group, to render as `and N more`. */
|
|
22
|
+
remaining: number;
|
|
23
|
+
/** Slug of the target collection, undefined when it cannot be determined. */
|
|
24
|
+
slug?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Groups a relationship or upload value by target collection — one group per
|
|
28
|
+
* collection, labeled with its plural label, holding one label per document.
|
|
29
|
+
*
|
|
30
|
+
* Import files carry relationships in whichever shape produced them, so every
|
|
31
|
+
* entry is one of: a bare ID, a populated document, or the polymorphic
|
|
32
|
+
* `{ relationTo, value }` pair — whose `value` is itself an ID or a document.
|
|
33
|
+
*
|
|
34
|
+
* Each group caps at `TOTAL_TO_SHOW` options and counts the rest into `remaining`,
|
|
35
|
+
* so a polymorphic field shows the same depth per collection rather than spending
|
|
36
|
+
* one cell's worth of rows on whichever collection happens to come first. Groups are
|
|
37
|
+
* returned in the order their collection first appears, and entries whose collection
|
|
38
|
+
* cannot be determined collect into a single unlabeled group. Options keep their order
|
|
39
|
+
* in the file rather than being sorted, so the preview reflects what will be imported.
|
|
40
|
+
*/
|
|
41
|
+
export declare const getRelationshipGroups: ({ collections, dateFormat, i18n, relationTo, value, }: Args) => RelationshipGroup[];
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=getRelationshipGroups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRelationshipGroups.d.ts","sourceRoot":"","sources":["../../../src/components/RelationshipCell/getRelationshipGroups.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAKtE;;;GAGG;AACH,eAAO,MAAM,aAAa,IAAI,CAAA;AAE9B,KAAK,IAAI,GAAG;IACV,WAAW,EAAE,sBAAsB,EAAE,CAAA;IACrC,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;IAClD,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACpB,mEAAmE;IACnE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC7B,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAA;IACb,kEAAkE;IAClE,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,uFAAuF;IACvF,SAAS,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,0DAM/B,IAAI,KAAG,iBAAiB,EAyC1B,CAAA"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
2
|
+
import { formatDocTitle } from '@payloadcms/ui/shared';
|
|
3
|
+
/**
|
|
4
|
+
* Labels rendered per collection before the rest collapse into `and N more`,
|
|
5
|
+
* matching `totalToShow` in the list view's relationship cell.
|
|
6
|
+
*/ export const TOTAL_TO_SHOW = 3;
|
|
7
|
+
/**
|
|
8
|
+
* Groups a relationship or upload value by target collection — one group per
|
|
9
|
+
* collection, labeled with its plural label, holding one label per document.
|
|
10
|
+
*
|
|
11
|
+
* Import files carry relationships in whichever shape produced them, so every
|
|
12
|
+
* entry is one of: a bare ID, a populated document, or the polymorphic
|
|
13
|
+
* `{ relationTo, value }` pair — whose `value` is itself an ID or a document.
|
|
14
|
+
*
|
|
15
|
+
* Each group caps at `TOTAL_TO_SHOW` options and counts the rest into `remaining`,
|
|
16
|
+
* so a polymorphic field shows the same depth per collection rather than spending
|
|
17
|
+
* one cell's worth of rows on whichever collection happens to come first. Groups are
|
|
18
|
+
* returned in the order their collection first appears, and entries whose collection
|
|
19
|
+
* cannot be determined collect into a single unlabeled group. Options keep their order
|
|
20
|
+
* in the file rather than being sorted, so the preview reflects what will be imported.
|
|
21
|
+
*/ export const getRelationshipGroups = ({ collections, dateFormat, i18n, relationTo, value })=>{
|
|
22
|
+
const entries = Array.isArray(value) ? value : [
|
|
23
|
+
value
|
|
24
|
+
];
|
|
25
|
+
const configsBySlug = new Map(collections.map((collection)=>[
|
|
26
|
+
collection.slug,
|
|
27
|
+
collection
|
|
28
|
+
]));
|
|
29
|
+
// Insertion order is the order each collection first appears, which is the order to render.
|
|
30
|
+
const groupsBySlug = new Map();
|
|
31
|
+
entries.forEach((entry)=>{
|
|
32
|
+
const { slug, target } = resolveEntry({
|
|
33
|
+
entry,
|
|
34
|
+
relationTo
|
|
35
|
+
});
|
|
36
|
+
const key = slug ?? '';
|
|
37
|
+
let group = groupsBySlug.get(key);
|
|
38
|
+
if (!group) {
|
|
39
|
+
group = {
|
|
40
|
+
slug,
|
|
41
|
+
label: slug ? getTranslation(configsBySlug.get(slug)?.labels?.plural || slug, i18n) : '',
|
|
42
|
+
options: [],
|
|
43
|
+
remaining: 0
|
|
44
|
+
};
|
|
45
|
+
groupsBySlug.set(key, group);
|
|
46
|
+
}
|
|
47
|
+
// Past the cap only the count matters, so skip the cost of titling the document.
|
|
48
|
+
if (group.options.length < TOTAL_TO_SHOW) {
|
|
49
|
+
group.options.push(getOptionLabel({
|
|
50
|
+
collectionConfig: slug ? configsBySlug.get(slug) : undefined,
|
|
51
|
+
dateFormat,
|
|
52
|
+
entry,
|
|
53
|
+
i18n,
|
|
54
|
+
target
|
|
55
|
+
}));
|
|
56
|
+
} else {
|
|
57
|
+
group.remaining++;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return [
|
|
61
|
+
...groupsBySlug.values()
|
|
62
|
+
];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Splits an entry into the collection it targets — `undefined` when that cannot be
|
|
66
|
+
* determined — and the ID or document it points at.
|
|
67
|
+
*/ const resolveEntry = ({ entry, relationTo })=>{
|
|
68
|
+
const entryArgs = {
|
|
69
|
+
value: entry
|
|
70
|
+
};
|
|
71
|
+
if (isPolymorphicRelationship(entryArgs)) {
|
|
72
|
+
return {
|
|
73
|
+
slug: entryArgs.value.relationTo,
|
|
74
|
+
target: entryArgs.value.value
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
slug: Array.isArray(relationTo) ? undefined : relationTo,
|
|
79
|
+
target: entry
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const getOptionLabel = ({ collectionConfig, dateFormat, entry, i18n, target })=>{
|
|
83
|
+
const targetArgs = {
|
|
84
|
+
value: target
|
|
85
|
+
};
|
|
86
|
+
const doc = isRecord(targetArgs) ? targetArgs.value : undefined;
|
|
87
|
+
const id = doc ? doc.id : target;
|
|
88
|
+
// Fall back to JSON for anything that did not resolve to a usable ID. Interpolating an
|
|
89
|
+
// object into a template is the `[object Object]` this function exists to avoid.
|
|
90
|
+
if (typeof id !== 'string' && typeof id !== 'number') {
|
|
91
|
+
return JSON.stringify(entry) ?? '';
|
|
92
|
+
}
|
|
93
|
+
if (!doc) {
|
|
94
|
+
// A bare ID carries no document to title. Showing the ID alone is more honest than
|
|
95
|
+
// the field's `Untitled` fallback, which would assert the document has no title.
|
|
96
|
+
return `${id}`;
|
|
97
|
+
}
|
|
98
|
+
return formatDocTitle({
|
|
99
|
+
collectionConfig,
|
|
100
|
+
data: doc,
|
|
101
|
+
dateFormat,
|
|
102
|
+
fallback: `${i18n.t('general:untitled')} - ID: ${id}`,
|
|
103
|
+
i18n
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const isRecord = (args)=>typeof args.value === 'object' && args.value !== null && !Array.isArray(args.value);
|
|
107
|
+
const isPolymorphicRelationship = (args)=>isRecord(args) && typeof args.value.relationTo === 'string' && 'value' in args.value;
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=getRelationshipGroups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/RelationshipCell/getRelationshipGroups.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { ClientCollectionConfig, SanitizedConfig } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatDocTitle } from '@payloadcms/ui/shared'\n\n/**\n * Labels rendered per collection before the rest collapse into `and N more`,\n * matching `totalToShow` in the list view's relationship cell.\n */\nexport const TOTAL_TO_SHOW = 3\n\ntype Args = {\n collections: ClientCollectionConfig[]\n dateFormat: SanitizedConfig['admin']['dateFormat']\n i18n: I18n<any, any>\n /** `field.relationTo` — an array when the field is polymorphic. */\n relationTo: string | string[]\n value: unknown\n}\n\nexport type RelationshipGroup = {\n /** Plural label of the target collection, empty when it cannot be determined. */\n label: string\n /** One rendered label per document, capped at `TOTAL_TO_SHOW`. */\n options: string[]\n /** Options past `TOTAL_TO_SHOW` dropped from this group, to render as `and N more`. */\n remaining: number\n /** Slug of the target collection, undefined when it cannot be determined. */\n slug?: string\n}\n\n/**\n * Groups a relationship or upload value by target collection — one group per\n * collection, labeled with its plural label, holding one label per document.\n *\n * Import files carry relationships in whichever shape produced them, so every\n * entry is one of: a bare ID, a populated document, or the polymorphic\n * `{ relationTo, value }` pair — whose `value` is itself an ID or a document.\n *\n * Each group caps at `TOTAL_TO_SHOW` options and counts the rest into `remaining`,\n * so a polymorphic field shows the same depth per collection rather than spending\n * one cell's worth of rows on whichever collection happens to come first. Groups are\n * returned in the order their collection first appears, and entries whose collection\n * cannot be determined collect into a single unlabeled group. Options keep their order\n * in the file rather than being sorted, so the preview reflects what will be imported.\n */\nexport const getRelationshipGroups = ({\n collections,\n dateFormat,\n i18n,\n relationTo,\n value,\n}: Args): RelationshipGroup[] => {\n const entries = Array.isArray(value) ? value : [value]\n const configsBySlug = new Map(collections.map((collection) => [collection.slug, collection]))\n\n // Insertion order is the order each collection first appears, which is the order to render.\n const groupsBySlug = new Map<string, RelationshipGroup>()\n\n entries.forEach((entry) => {\n const { slug, target } = resolveEntry({ entry, relationTo })\n\n const key = slug ?? ''\n let group = groupsBySlug.get(key)\n\n if (!group) {\n group = {\n slug,\n label: slug ? getTranslation(configsBySlug.get(slug)?.labels?.plural || slug, i18n) : '',\n options: [],\n remaining: 0,\n }\n\n groupsBySlug.set(key, group)\n }\n\n // Past the cap only the count matters, so skip the cost of titling the document.\n if (group.options.length < TOTAL_TO_SHOW) {\n group.options.push(\n getOptionLabel({\n collectionConfig: slug ? configsBySlug.get(slug) : undefined,\n dateFormat,\n entry,\n i18n,\n target,\n }),\n )\n } else {\n group.remaining++\n }\n })\n\n return [...groupsBySlug.values()]\n}\n\n/**\n * Splits an entry into the collection it targets — `undefined` when that cannot be\n * determined — and the ID or document it points at.\n */\nconst resolveEntry = ({\n entry,\n relationTo,\n}: { entry: unknown } & Pick<Args, 'relationTo'>): { slug?: string; target: unknown } => {\n const entryArgs = { value: entry }\n\n if (isPolymorphicRelationship(entryArgs)) {\n return { slug: entryArgs.value.relationTo, target: entryArgs.value.value }\n }\n\n return { slug: Array.isArray(relationTo) ? undefined : relationTo, target: entry }\n}\n\ntype GetOptionLabelArgs = {\n collectionConfig?: ClientCollectionConfig\n /** The original entry, kept for the JSON fallback when `target` holds no usable ID. */\n entry: unknown\n target: unknown\n} & Pick<Args, 'dateFormat' | 'i18n'>\n\nconst getOptionLabel = ({\n collectionConfig,\n dateFormat,\n entry,\n i18n,\n target,\n}: GetOptionLabelArgs): string => {\n const targetArgs = { value: target }\n const doc = isRecord(targetArgs) ? targetArgs.value : undefined\n const id = doc ? doc.id : target\n\n // Fall back to JSON for anything that did not resolve to a usable ID. Interpolating an\n // object into a template is the `[object Object]` this function exists to avoid.\n if (typeof id !== 'string' && typeof id !== 'number') {\n return JSON.stringify(entry) ?? ''\n }\n\n if (!doc) {\n // A bare ID carries no document to title. Showing the ID alone is more honest than\n // the field's `Untitled` fallback, which would assert the document has no title.\n return `${id}`\n }\n\n return formatDocTitle({\n collectionConfig,\n data: doc as Parameters<typeof formatDocTitle>[0]['data'],\n dateFormat,\n fallback: `${i18n.t('general:untitled')} - ID: ${id}`,\n i18n,\n })\n}\n\ntype ValueArgs = { value: unknown }\n\nconst isRecord = (args: ValueArgs): args is { value: Record<string, unknown> } =>\n typeof args.value === 'object' && args.value !== null && !Array.isArray(args.value)\n\nconst isPolymorphicRelationship = (\n args: ValueArgs,\n): args is { value: { relationTo: string; value: unknown } } =>\n isRecord(args) && typeof args.value.relationTo === 'string' && 'value' in args.value\n"],"names":["getTranslation","formatDocTitle","TOTAL_TO_SHOW","getRelationshipGroups","collections","dateFormat","i18n","relationTo","value","entries","Array","isArray","configsBySlug","Map","map","collection","slug","groupsBySlug","forEach","entry","target","resolveEntry","key","group","get","label","labels","plural","options","remaining","set","length","push","getOptionLabel","collectionConfig","undefined","values","entryArgs","isPolymorphicRelationship","targetArgs","doc","isRecord","id","JSON","stringify","data","fallback","t","args"],"mappings":"AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,cAAc,QAAQ,wBAAuB;AAEtD;;;CAGC,GACD,OAAO,MAAMC,gBAAgB,EAAC;AAsB9B;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMC,wBAAwB,CAAC,EACpCC,WAAW,EACXC,UAAU,EACVC,IAAI,EACJC,UAAU,EACVC,KAAK,EACA;IACL,MAAMC,UAAUC,MAAMC,OAAO,CAACH,SAASA,QAAQ;QAACA;KAAM;IACtD,MAAMI,gBAAgB,IAAIC,IAAIT,YAAYU,GAAG,CAAC,CAACC,aAAe;YAACA,WAAWC,IAAI;YAAED;SAAW;IAE3F,4FAA4F;IAC5F,MAAME,eAAe,IAAIJ;IAEzBJ,QAAQS,OAAO,CAAC,CAACC;QACf,MAAM,EAAEH,IAAI,EAAEI,MAAM,EAAE,GAAGC,aAAa;YAAEF;YAAOZ;QAAW;QAE1D,MAAMe,MAAMN,QAAQ;QACpB,IAAIO,QAAQN,aAAaO,GAAG,CAACF;QAE7B,IAAI,CAACC,OAAO;YACVA,QAAQ;gBACNP;gBACAS,OAAOT,OAAOhB,eAAeY,cAAcY,GAAG,CAACR,OAAOU,QAAQC,UAAUX,MAAMV,QAAQ;gBACtFsB,SAAS,EAAE;gBACXC,WAAW;YACb;YAEAZ,aAAaa,GAAG,CAACR,KAAKC;QACxB;QAEA,iFAAiF;QACjF,IAAIA,MAAMK,OAAO,CAACG,MAAM,GAAG7B,eAAe;YACxCqB,MAAMK,OAAO,CAACI,IAAI,CAChBC,eAAe;gBACbC,kBAAkBlB,OAAOJ,cAAcY,GAAG,CAACR,QAAQmB;gBACnD9B;gBACAc;gBACAb;gBACAc;YACF;QAEJ,OAAO;YACLG,MAAMM,SAAS;QACjB;IACF;IAEA,OAAO;WAAIZ,aAAamB,MAA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+1,30 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.import-preview-relationship {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--spacer-2);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.import-preview-relationship__group {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
align-items: flex-start;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.import-preview-relationship__collection {
|
|
15
|
+
color: var(--color-text-secondary);
|
|
16
|
+
font-size: var(--text-body-medium-bold-font-size);
|
|
17
|
+
font-weight: var(--text-body-large-font-weight);
|
|
18
|
+
letter-spacing: var(--text-body-small-bold-letter-spacing);
|
|
19
|
+
line-height: var(--text-body-small-bold-line-height);
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.import-preview-relationship__more {
|
|
24
|
+
display: block;
|
|
25
|
+
color: var(--color-text-secondary);
|
|
26
|
+
font-size: var(--text-body-small-font-size);
|
|
27
|
+
font-weight: var(--text-body-small-font-weight);
|
|
28
|
+
line-height: var(--text-body-small-line-height);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.css';
|
|
3
|
+
type Props = {
|
|
4
|
+
fieldPath: string;
|
|
5
|
+
/** `field.relationTo` — an array when the field is polymorphic. */
|
|
6
|
+
relationTo: string | string[];
|
|
7
|
+
value: unknown;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Renders a relationship or upload value for the import preview table, stacking
|
|
11
|
+
* one row per target collection.
|
|
12
|
+
*/
|
|
13
|
+
export declare const RelationshipCell: React.FC<Props>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RelationshipCell/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,aAAa,CAAA;AAIpB,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,mEAAmE;IACnE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC7B,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAuC5C,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useConfig, useTranslation } from '@payloadcms/ui';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { getRelationshipGroupKey } from './getRelationshipGroupKey.js';
|
|
6
|
+
import { getRelationshipGroups } from './getRelationshipGroups.js';
|
|
7
|
+
import './index.css';
|
|
8
|
+
const baseClass = 'import-preview-relationship';
|
|
9
|
+
/**
|
|
10
|
+
* Renders a relationship or upload value for the import preview table, stacking
|
|
11
|
+
* one row per target collection.
|
|
12
|
+
*/ export const RelationshipCell = ({ fieldPath, relationTo, value })=>{
|
|
13
|
+
const { config } = useConfig();
|
|
14
|
+
const { i18n } = useTranslation();
|
|
15
|
+
const groups = getRelationshipGroups({
|
|
16
|
+
collections: config.collections,
|
|
17
|
+
dateFormat: config.admin.dateFormat,
|
|
18
|
+
i18n,
|
|
19
|
+
relationTo,
|
|
20
|
+
value
|
|
21
|
+
});
|
|
22
|
+
// The column heading already names a monomorphic field, whose collection never varies.
|
|
23
|
+
const shouldShowCollectionLabels = Array.isArray(relationTo);
|
|
24
|
+
if (!groups.length) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
28
|
+
className: baseClass,
|
|
29
|
+
children: groups.map(({ slug, label, options, remaining })=>/*#__PURE__*/ _jsxs("div", {
|
|
30
|
+
className: `${baseClass}__group`,
|
|
31
|
+
children: [
|
|
32
|
+
shouldShowCollectionLabels && label && /*#__PURE__*/ _jsx("span", {
|
|
33
|
+
className: `${baseClass}__collection`,
|
|
34
|
+
children: label
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
37
|
+
className: `${baseClass}__values`,
|
|
38
|
+
children: [
|
|
39
|
+
options.join(', '),
|
|
40
|
+
remaining > 0 && /*#__PURE__*/ _jsx("span", {
|
|
41
|
+
className: `${baseClass}__more`,
|
|
42
|
+
children: i18n.t('fields:itemsAndMore', {
|
|
43
|
+
count: remaining,
|
|
44
|
+
items: ''
|
|
45
|
+
}).trim()
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
})
|
|
49
|
+
]
|
|
50
|
+
}, getRelationshipGroupKey({
|
|
51
|
+
slug,
|
|
52
|
+
fieldPath
|
|
53
|
+
})))
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/RelationshipCell/index.tsx"],"sourcesContent":["'use client'\nimport { useConfig, useTranslation } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { getRelationshipGroupKey } from './getRelationshipGroupKey.js'\nimport { getRelationshipGroups } from './getRelationshipGroups.js'\nimport './index.css'\n\nconst baseClass = 'import-preview-relationship'\n\ntype Props = {\n fieldPath: string\n /** `field.relationTo` — an array when the field is polymorphic. */\n relationTo: string | string[]\n value: unknown\n}\n\n/**\n * Renders a relationship or upload value for the import preview table, stacking\n * one row per target collection.\n */\nexport const RelationshipCell: React.FC<Props> = ({ fieldPath, relationTo, value }) => {\n const { config } = useConfig()\n const { i18n } = useTranslation()\n\n const groups = getRelationshipGroups({\n collections: config.collections,\n dateFormat: config.admin.dateFormat,\n i18n,\n relationTo,\n value,\n })\n\n // The column heading already names a monomorphic field, whose collection never varies.\n const shouldShowCollectionLabels = Array.isArray(relationTo)\n\n if (!groups.length) {\n return null\n }\n\n return (\n <div className={baseClass}>\n {groups.map(({ slug, label, options, remaining }) => (\n <div className={`${baseClass}__group`} key={getRelationshipGroupKey({ slug, fieldPath })}>\n {/* A `label` element would be unassociated here — the cell holds no control */}\n {shouldShowCollectionLabels && label && (\n <span className={`${baseClass}__collection`}>{label}</span>\n )}\n <div className={`${baseClass}__values`}>\n {options.join(', ')}\n {remaining > 0 && (\n <span className={`${baseClass}__more`}>\n {i18n.t('fields:itemsAndMore', { count: remaining, items: '' }).trim()}\n </span>\n )}\n </div>\n </div>\n ))}\n </div>\n )\n}\n"],"names":["useConfig","useTranslation","React","getRelationshipGroupKey","getRelationshipGroups","baseClass","RelationshipCell","fieldPath","relationTo","value","config","i18n","groups","collections","dateFormat","admin","shouldShowCollectionLabels","Array","isArray","length","div","className","map","slug","label","options","remaining","span","join","t","count","items","trim"],"mappings":"AAAA;;AACA,SAASA,SAAS,EAAEC,cAAc,QAAQ,iBAAgB;AAC1D,OAAOC,WAAW,QAAO;AAEzB,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,qBAAqB,QAAQ,6BAA4B;AAClE,OAAO,cAAa;AAEpB,MAAMC,YAAY;AASlB;;;CAGC,GACD,OAAO,MAAMC,mBAAoC,CAAC,EAAEC,SAAS,EAAEC,UAAU,EAAEC,KAAK,EAAE;IAChF,MAAM,EAAEC,MAAM,EAAE,GAAGV;IACnB,MAAM,EAAEW,IAAI,EAAE,GAAGV;IAEjB,MAAMW,SAASR,sBAAsB;QACnCS,aAAaH,OAAOG,WAAW;QAC/BC,YAAYJ,OAAOK,KAAK,CAACD,UAAU;QACnCH;QACAH;QACAC;IACF;IAEA,uFAAuF;IACvF,MAAMO,6BAA6BC,MAAMC,OAAO,CAACV;IAEjD,IAAI,CAACI,OAAOO,MAAM,EAAE;QAClB,OAAO;IACT;IAEA,qBACE,KAACC;QAAIC,WAAWhB;kBACbO,OAAOU,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAEC,SAAS,EAAE,iBAC9C,MAACN;gBAAIC,WAAW,GAAGhB,UAAU,OAAO,CAAC;;oBAElCW,8BAA8BQ,uBAC7B,KAACG;wBAAKN,WAAW,GAAGhB,UAAU,YAAY,CAAC;kCAAGmB;;kCAEhD,MAACJ;wBAAIC,WAAW,GAAGhB,UAAU,QAAQ,CAAC;;4BACnCoB,QAAQG,IAAI,CAAC;4BACbF,YAAY,mBACX,KAACC;gCAAKN,WAAW,GAAGhB,UAAU,MAAM,CAAC;0CAClCM,KAAKkB,CAAC,CAAC,uBAAuB;oCAAEC,OAAOJ;oCAAWK,OAAO;gCAAG,GAAGC,IAAI;;;;;eAThC7B,wBAAwB;gBAAEoB;gBAAMhB;YAAU;;AAiB9F,EAAC"}
|
|
@@ -50,45 +50,82 @@ const registerExportHandler = (field, fullKey, result)=>{
|
|
|
50
50
|
registerHandler(({ value })=>typeof value === 'object' && value && 'id' in value ? value.id : value);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
registerHandler(({ siblingData, value })=>{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
registerHandler(({ format, siblingData, value })=>{
|
|
54
|
+
// A shape this handler does not recognize is left untouched for JSON, which holds the
|
|
55
|
+
// source value verbatim. CSV still clears it, since its id/relationTo would otherwise
|
|
56
|
+
// land in sibling columns.
|
|
57
|
+
if (!isPolymorphicRelValue(value)) {
|
|
58
|
+
return format === 'json' ? undefined : null;
|
|
59
|
+
}
|
|
60
|
+
// A recognized reference that resolves to no id is dangling, and a dangling reference
|
|
61
|
+
// cannot be imported back — clear it for both formats.
|
|
62
|
+
const id = getPolymorphicRelId(value);
|
|
63
|
+
if (id === undefined) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (format === 'json') {
|
|
67
|
+
return {
|
|
68
|
+
relationTo: value.relationTo,
|
|
69
|
+
value: id
|
|
70
|
+
};
|
|
60
71
|
}
|
|
72
|
+
siblingData[`${fullKey}_id`] = id;
|
|
73
|
+
siblingData[`${fullKey}_relationTo`] = value.relationTo;
|
|
61
74
|
return null;
|
|
62
75
|
});
|
|
63
76
|
return;
|
|
64
77
|
}
|
|
65
78
|
if (!Array.isArray(field.relationTo)) {
|
|
66
|
-
registerHandler(({ siblingData, value })=>{
|
|
67
|
-
if (Array.isArray(value)) {
|
|
68
|
-
|
|
69
|
-
const id = typeof val === 'object' && val ? val.id : val;
|
|
70
|
-
siblingData[`${fullKey}_${i}_id`] = id;
|
|
71
|
-
});
|
|
72
|
-
return null;
|
|
79
|
+
registerHandler(({ format, siblingData, value })=>{
|
|
80
|
+
if (!Array.isArray(value)) {
|
|
81
|
+
return undefined;
|
|
73
82
|
}
|
|
74
|
-
|
|
83
|
+
const ids = value.map((val)=>typeof val === 'object' && val ? val.id : val);
|
|
84
|
+
// Bare null entries fail relationship validation when the JSON is imported, so drop
|
|
85
|
+
// references that could not be resolved. CSV keeps source indexes in its column names;
|
|
86
|
+
// unflattening those columns collapses any gaps on import.
|
|
87
|
+
if (format === 'json') {
|
|
88
|
+
return ids.filter((id)=>id !== null && id !== undefined);
|
|
89
|
+
}
|
|
90
|
+
ids.forEach((id, i)=>{
|
|
91
|
+
siblingData[`${fullKey}_${i}_id`] = id;
|
|
92
|
+
});
|
|
93
|
+
return null;
|
|
75
94
|
});
|
|
76
95
|
return;
|
|
77
96
|
}
|
|
78
|
-
registerHandler(({ siblingData, value })=>{
|
|
79
|
-
if (Array.isArray(value)) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
97
|
+
registerHandler(({ format, siblingData, value })=>{
|
|
98
|
+
if (!Array.isArray(value)) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
// `index` is carried so CSV columns stay pinned to the source position: an entry
|
|
102
|
+
// that cannot be resolved to an id leaves a gap rather than shifting its siblings.
|
|
103
|
+
const rels = value.flatMap((val, index)=>{
|
|
104
|
+
if (!isPolymorphicRelValue(val)) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
const id = getPolymorphicRelId(val);
|
|
108
|
+
return id === undefined ? [] : [
|
|
109
|
+
{
|
|
110
|
+
id,
|
|
111
|
+
index,
|
|
112
|
+
relationTo: val.relationTo
|
|
87
113
|
}
|
|
88
|
-
|
|
89
|
-
|
|
114
|
+
];
|
|
115
|
+
});
|
|
116
|
+
if (format === 'json') {
|
|
117
|
+
// Bare null entries fail relationship validation when the JSON is imported, so return
|
|
118
|
+
// only references that resolved to an id.
|
|
119
|
+
return rels.map(({ id, relationTo })=>({
|
|
120
|
+
relationTo,
|
|
121
|
+
value: id
|
|
122
|
+
}));
|
|
90
123
|
}
|
|
91
|
-
|
|
124
|
+
rels.forEach(({ id, index, relationTo })=>{
|
|
125
|
+
siblingData[`${fullKey}_${index}_id`] = id;
|
|
126
|
+
siblingData[`${fullKey}_${index}_relationTo`] = relationTo;
|
|
127
|
+
});
|
|
128
|
+
return null;
|
|
92
129
|
});
|
|
93
130
|
};
|
|
94
131
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getExportFieldFunctions.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { ExportFieldHookEntry, FieldBeforeExportHook } from '../types.js'\n\nimport { registerFieldHooks } from './flattenedFields.js'\nimport { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'\n\ntype Args = {\n fields: FlattenedField[]\n}\n\n/**\n * Builds a map from logical field path (e.g. `content_textBlock_body`) to\n * the export hook entry. Paths include block slugs but never array indices.\n */\nexport const getExportFieldFunctions = ({ fields }: Args): Record<string, ExportFieldHookEntry> => {\n const result: Record<string, ExportFieldHookEntry> = {}\n registerFieldHooks(fields, '', result, registerExportHandler)\n return result\n}\n\nconst registerExportHandler = (\n field: FlattenedField,\n fullKey: string,\n result: Record<string, ExportFieldHookEntry>,\n): void => {\n const beforeExport = field.custom?.['plugin-import-export']?.hooks?.beforeExport\n\n if (typeof beforeExport === 'function') {\n result[fullKey] = { type: 'beforeExport', fn: beforeExport }\n return\n }\n\n const registerHandler = (handler: FieldBeforeExportHook) => {\n result[fullKey] = { type: 'beforeExport', fn: handler }\n }\n\n if (field.type === 'json' || field.type === 'richText') {\n registerHandler(({ format, value }) => {\n if (format === 'json') {\n return value\n }\n if (value === null || value === undefined) {\n return value\n }\n if (typeof value === 'object') {\n return JSON.stringify(value)\n }\n return value\n })\n return\n }\n\n if (field.type === 'date') {\n registerHandler(({ value }) => value)\n return\n }\n\n if (field.type !== 'relationship' && field.type !== 'upload') {\n return\n }\n\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ value }) =>\n typeof value === 'object' && value && 'id' in value ? value.id : value,\n )\n return\n }\n\n registerHandler(({ siblingData, value }) => {\n if (isPolymorphicRelValue(value)) {\n const id = getPolymorphicRelId(value)\n
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getExportFieldFunctions.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { ExportFieldHookEntry, FieldBeforeExportHook } from '../types.js'\n\nimport { registerFieldHooks } from './flattenedFields.js'\nimport { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'\n\ntype Args = {\n fields: FlattenedField[]\n}\n\n/**\n * Builds a map from logical field path (e.g. `content_textBlock_body`) to\n * the export hook entry. Paths include block slugs but never array indices.\n */\nexport const getExportFieldFunctions = ({ fields }: Args): Record<string, ExportFieldHookEntry> => {\n const result: Record<string, ExportFieldHookEntry> = {}\n registerFieldHooks(fields, '', result, registerExportHandler)\n return result\n}\n\nconst registerExportHandler = (\n field: FlattenedField,\n fullKey: string,\n result: Record<string, ExportFieldHookEntry>,\n): void => {\n const beforeExport = field.custom?.['plugin-import-export']?.hooks?.beforeExport\n\n if (typeof beforeExport === 'function') {\n result[fullKey] = { type: 'beforeExport', fn: beforeExport }\n return\n }\n\n const registerHandler = (handler: FieldBeforeExportHook) => {\n result[fullKey] = { type: 'beforeExport', fn: handler }\n }\n\n if (field.type === 'json' || field.type === 'richText') {\n registerHandler(({ format, value }) => {\n if (format === 'json') {\n return value\n }\n if (value === null || value === undefined) {\n return value\n }\n if (typeof value === 'object') {\n return JSON.stringify(value)\n }\n return value\n })\n return\n }\n\n if (field.type === 'date') {\n registerHandler(({ value }) => value)\n return\n }\n\n if (field.type !== 'relationship' && field.type !== 'upload') {\n return\n }\n\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ value }) =>\n typeof value === 'object' && value && 'id' in value ? value.id : value,\n )\n return\n }\n\n registerHandler(({ format, siblingData, value }) => {\n // A shape this handler does not recognize is left untouched for JSON, which holds the\n // source value verbatim. CSV still clears it, since its id/relationTo would otherwise\n // land in sibling columns.\n if (!isPolymorphicRelValue(value)) {\n return format === 'json' ? undefined : null\n }\n\n // A recognized reference that resolves to no id is dangling, and a dangling reference\n // cannot be imported back — clear it for both formats.\n const id = getPolymorphicRelId(value)\n if (id === undefined) {\n return null\n }\n\n if (format === 'json') {\n return { relationTo: value.relationTo, value: id }\n }\n siblingData[`${fullKey}_id`] = id\n siblingData[`${fullKey}_relationTo`] = value.relationTo\n return null\n })\n return\n }\n\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ format, siblingData, value }) => {\n if (!Array.isArray(value)) {\n return undefined\n }\n const ids = value.map((val) =>\n typeof val === 'object' && val ? (val as { id: unknown }).id : val,\n )\n // Bare null entries fail relationship validation when the JSON is imported, so drop\n // references that could not be resolved. CSV keeps source indexes in its column names;\n // unflattening those columns collapses any gaps on import.\n if (format === 'json') {\n return ids.filter((id) => id !== null && id !== undefined)\n }\n ids.forEach((id, i) => {\n siblingData[`${fullKey}_${i}_id`] = id\n })\n return null\n })\n return\n }\n\n registerHandler(({ format, siblingData, value }) => {\n if (!Array.isArray(value)) {\n return undefined\n }\n // `index` is carried so CSV columns stay pinned to the source position: an entry\n // that cannot be resolved to an id leaves a gap rather than shifting its siblings.\n const rels = value.flatMap((val, index) => {\n if (!isPolymorphicRelValue(val)) {\n return []\n }\n const id = getPolymorphicRelId(val)\n return id === undefined ? [] : [{ id, index, relationTo: val.relationTo }]\n })\n\n if (format === 'json') {\n // Bare null entries fail relationship validation when the JSON is imported, so return\n // only references that resolved to an id.\n return rels.map(({ id, relationTo }) => ({ relationTo, value: id }))\n }\n rels.forEach(({ id, index, relationTo }) => {\n siblingData[`${fullKey}_${index}_id`] = id\n siblingData[`${fullKey}_${index}_relationTo`] = relationTo\n })\n return null\n })\n}\n"],"names":["registerFieldHooks","getPolymorphicRelId","isPolymorphicRelValue","getExportFieldFunctions","fields","result","registerExportHandler","field","fullKey","beforeExport","custom","hooks","type","fn","registerHandler","handler","format","value","undefined","JSON","stringify","hasMany","Array","isArray","relationTo","id","siblingData","ids","map","val","filter","forEach","i","rels","flatMap","index"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,uBAAsB;AACzD,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAMhF;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CAAC,EAAEC,MAAM,EAAQ;IACtD,MAAMC,SAA+C,CAAC;IACtDL,mBAAmBI,QAAQ,IAAIC,QAAQC;IACvC,OAAOD;AACT,EAAC;AAED,MAAMC,wBAAwB,CAC5BC,OACAC,SACAH;IAEA,MAAMI,eAAeF,MAAMG,MAAM,EAAE,CAAC,uBAAuB,EAAEC,OAAOF;IAEpE,IAAI,OAAOA,iBAAiB,YAAY;QACtCJ,MAAM,CAACG,QAAQ,GAAG;YAAEI,MAAM;YAAgBC,IAAIJ;QAAa;QAC3D;IACF;IAEA,MAAMK,kBAAkB,CAACC;QACvBV,MAAM,CAACG,QAAQ,GAAG;YAAEI,MAAM;YAAgBC,IAAIE;QAAQ;IACxD;IA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ACnE;QACAQ,KAAKF,OAAO,CAAC,CAAC,EAAEN,EAAE,EAAEU,KAAK,EAAEX,UAAU,EAAE;YACrCE,WAAW,CAAC,GAAGlB,QAAQ,CAAC,EAAE2B,MAAM,GAAG,CAAC,CAAC,GAAGV;YACxCC,WAAW,CAAC,GAAGlB,QAAQ,CAAC,EAAE2B,MAAM,WAAW,CAAC,CAAC,GAAGX;QAClD;QACA,OAAO;IACT;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-import-export",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.ce66a41",
|
|
4
4
|
"description": "Import-Export plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -60,21 +60,21 @@
|
|
|
60
60
|
"dist"
|
|
61
61
|
],
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@faceless-ui/modal": "3.0.
|
|
63
|
+
"@faceless-ui/modal": "3.0.2",
|
|
64
64
|
"csv-parse": "5.6.0",
|
|
65
65
|
"csv-stringify": "6.5.2",
|
|
66
66
|
"qs-esm": "8.0.1",
|
|
67
|
-
"@payloadcms/translations": "4.0.0-internal.
|
|
68
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
67
|
+
"@payloadcms/translations": "4.0.0-internal.ce66a41",
|
|
68
|
+
"@payloadcms/ui": "4.0.0-internal.ce66a41"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@payloadcms/
|
|
72
|
-
"
|
|
73
|
-
"
|
|
71
|
+
"@payloadcms/ui": "4.0.0-internal.ce66a41",
|
|
72
|
+
"payload": "4.0.0-internal.ce66a41",
|
|
73
|
+
"@payloadcms/eslint-config": "3.28.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"
|
|
77
|
-
"
|
|
76
|
+
"payload": "4.0.0-internal.ce66a41",
|
|
77
|
+
"@payloadcms/ui": "4.0.0-internal.ce66a41"
|
|
78
78
|
},
|
|
79
79
|
"homepage:": "https://payloadcms.com",
|
|
80
80
|
"scripts": {
|