@firecms/data_import_export 3.0.0-canary.2 → 3.0.0-canary.4
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/index.es.js +92 -92
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/export_import/export.ts +1 -1
package/dist/index.es.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import C, { useState as j, useRef as
|
1
|
+
import C, { useState as j, useRef as Oe, useEffect as ce, useCallback as x, useMemo as Ie } from "react";
|
2
2
|
import { jsxs as p, Fragment as $, jsx as s } from "react/jsx-runtime";
|
3
|
-
import { getPropertyInPath as
|
4
|
-
import { Table as
|
3
|
+
import { getPropertyInPath as R, EntityReference as Ee, useSnackbarController as de, useCustomizationController as V, getFieldConfig as pe, ErrorBoundary as Ae, PropertyConfigBadge as fe, useDataSource as me, resolveCollection as ue, getPropertiesWithPropertiesOrder as Te, useSelectionController as je, EntityCollectionTable as ke, getArrayValuesCount as Fe, getValueInPath as Pe, useFireCMSContext as Me, useNavigationController as $e } from "@firecms/core";
|
4
|
+
import { Table as Re, TableHeader as Le, TableCell as M, TableBody as _e, TableRow as Be, Typography as u, ChevronRightIcon as Je, Select as he, SelectItem as B, FileUpload as He, UploadIcon as Ue, TextField as We, IconButton as ee, EditIcon as ze, CenteredView as Ve, CircularProgress as ge, Tooltip as te, FileUploadIcon as Ge, Dialog as ye, DialogContent as be, DialogActions as xe, Button as k, cn as _, defaultBorderMixin as Xe, GetAppIcon as qe, Alert as Qe, focusedMixin as U, BooleanSwitchWithLabel as Ye } from "@firecms/ui";
|
5
5
|
import { buildEntityPropertiesFromData as Ze } from "@firecms/schema_inference";
|
6
6
|
import * as ie from "xlsx";
|
7
7
|
const Ke = () => {
|
@@ -41,7 +41,7 @@ function et(e) {
|
|
41
41
|
codepage: 65001,
|
42
42
|
cellDates: !0
|
43
43
|
}
|
44
|
-
), l = o.SheetNames[0], d = o.Sheets[l], m = ie.utils.sheet_to_json(d).map(tt).map(
|
44
|
+
), l = o.SheetNames[0], d = o.Sheets[l], m = ie.utils.sheet_to_json(d).map(tt).map(ve);
|
45
45
|
r(m);
|
46
46
|
}, t.readAsArrayBuffer(e);
|
47
47
|
}
|
@@ -57,7 +57,7 @@ function tt(e) {
|
|
57
57
|
return r;
|
58
58
|
}, {});
|
59
59
|
}
|
60
|
-
function
|
60
|
+
function ve(e) {
|
61
61
|
return Object.keys(e).reduce((r, n) => {
|
62
62
|
let t = r;
|
63
63
|
const a = n.split(".");
|
@@ -71,28 +71,28 @@ function Ce(e) {
|
|
71
71
|
}, {});
|
72
72
|
}
|
73
73
|
function rt(e, r, n, t, a, i) {
|
74
|
-
const o =
|
74
|
+
const o = Ce(e);
|
75
75
|
r && delete o[r];
|
76
76
|
const l = Object.entries(o).map(([c, f]) => {
|
77
77
|
const m = n[c] ?? c;
|
78
|
-
if (!
|
78
|
+
if (!R(t, m))
|
79
79
|
return {};
|
80
80
|
const h = a[m];
|
81
81
|
let S = f;
|
82
82
|
return h && (S = Z(f, h)), {
|
83
83
|
[m]: S
|
84
84
|
};
|
85
|
-
}).reduce((c, f) => ({ ...c, ...f }), {}), d =
|
85
|
+
}).reduce((c, f) => ({ ...c, ...f }), {}), d = ve(l);
|
86
86
|
return {
|
87
87
|
id: r ? e[r] : void 0,
|
88
88
|
values: d,
|
89
89
|
path: i
|
90
90
|
};
|
91
91
|
}
|
92
|
-
function
|
92
|
+
function Ce(e, r = "") {
|
93
93
|
return Object.keys(e).reduce((n, t) => {
|
94
94
|
const a = r ? `${r}.${t}` : t;
|
95
|
-
return typeof e[t] == "object" && e[t] !== null && !Array.isArray(e[t]) ? Object.assign(n,
|
95
|
+
return typeof e[t] == "object" && e[t] !== null && !Array.isArray(e[t]) ? Object.assign(n, Ce(e[t], a)) : n[a] = e[t], n;
|
96
96
|
}, {});
|
97
97
|
}
|
98
98
|
function Z(e, r) {
|
@@ -143,7 +143,7 @@ function Z(e, r) {
|
|
143
143
|
}
|
144
144
|
else if (n === "string" && t === "reference" && typeof e == "string") {
|
145
145
|
const a = e.split("/").slice(0, -1).join("/"), i = e.split("/").slice(-1)[0];
|
146
|
-
return new
|
146
|
+
return new Ee(i, a);
|
147
147
|
} else {
|
148
148
|
if (n === t)
|
149
149
|
return e;
|
@@ -160,7 +160,7 @@ function at(e, r) {
|
|
160
160
|
function n(t, a) {
|
161
161
|
const i = {};
|
162
162
|
return Object.keys(t).forEach((o) => {
|
163
|
-
const l = a ? `${a}.${o}` : o, d =
|
163
|
+
const l = a ? `${a}.${o}` : o, d = R(t, o), c = R(e, l);
|
164
164
|
if (d) {
|
165
165
|
if (d.dataType === "map" && d.properties) {
|
166
166
|
const f = n(d.properties, l);
|
@@ -201,18 +201,18 @@ function it({
|
|
201
201
|
onChange: a
|
202
202
|
}
|
203
203
|
),
|
204
|
-
/* @__PURE__ */ p(
|
204
|
+
/* @__PURE__ */ p(Re, { style: {
|
205
205
|
tableLayout: "fixed"
|
206
206
|
}, children: [
|
207
|
-
/* @__PURE__ */ p(
|
207
|
+
/* @__PURE__ */ p(Le, { children: [
|
208
208
|
/* @__PURE__ */ s(M, { header: !0, style: { width: "20%" }, children: "Column in file" }),
|
209
209
|
/* @__PURE__ */ s(M, { header: !0 }),
|
210
210
|
/* @__PURE__ */ s(M, { header: !0, style: { width: "75%" }, children: "Property" })
|
211
211
|
] }),
|
212
|
-
/* @__PURE__ */ s(
|
212
|
+
/* @__PURE__ */ s(_e, { children: t && Object.entries(r).map(
|
213
213
|
([o, l]) => {
|
214
|
-
const d = r[o], c = l ?
|
215
|
-
return /* @__PURE__ */ p(
|
214
|
+
const d = r[o], c = l ? R(t, l) : null, f = R(n, o), m = f ? f.dataType === "array" && typeof f.of == "object" ? `${f.dataType} - ${f.of.dataType}` : f.dataType : void 0;
|
215
|
+
return /* @__PURE__ */ p(Be, { style: { height: "90px" }, children: [
|
216
216
|
/* @__PURE__ */ p(M, { style: { width: "20%" }, children: [
|
217
217
|
/* @__PURE__ */ s(u, { variant: "body2", children: o }),
|
218
218
|
f && /* @__PURE__ */ s(
|
@@ -224,7 +224,7 @@ function it({
|
|
224
224
|
}
|
225
225
|
)
|
226
226
|
] }),
|
227
|
-
/* @__PURE__ */ s(M, { children: /* @__PURE__ */ s(
|
227
|
+
/* @__PURE__ */ s(M, { children: /* @__PURE__ */ s(Je, {}) }),
|
228
228
|
/* @__PURE__ */ s(
|
229
229
|
M,
|
230
230
|
{
|
@@ -250,7 +250,7 @@ function st({
|
|
250
250
|
onChange: n
|
251
251
|
}) {
|
252
252
|
return /* @__PURE__ */ s("div", { children: /* @__PURE__ */ p(
|
253
|
-
|
253
|
+
he,
|
254
254
|
{
|
255
255
|
size: "small",
|
256
256
|
value: e ?? "",
|
@@ -260,14 +260,14 @@ function st({
|
|
260
260
|
renderValue: (t) => /* @__PURE__ */ s(u, { variant: "body2", children: t !== "" ? t : "Autogenerate ID" }),
|
261
261
|
label: "Column that will be used as ID for each document",
|
262
262
|
children: [
|
263
|
-
/* @__PURE__ */ s(
|
264
|
-
Object.entries(r).map(([t, a]) => /* @__PURE__ */ s(
|
263
|
+
/* @__PURE__ */ s(B, { value: "", children: "Autogenerate ID" }),
|
264
|
+
Object.entries(r).map(([t, a]) => /* @__PURE__ */ s(B, { value: t, children: t }, t))
|
265
265
|
]
|
266
266
|
}
|
267
267
|
) });
|
268
268
|
}
|
269
269
|
function ot({ onDataAdded: e }) {
|
270
|
-
const r =
|
270
|
+
const r = de();
|
271
271
|
return /* @__PURE__ */ s(
|
272
272
|
He,
|
273
273
|
{
|
@@ -306,16 +306,16 @@ function Dt({
|
|
306
306
|
onPropertyNameChanged: a,
|
307
307
|
propertyTypeView: i
|
308
308
|
}) {
|
309
|
-
const { propertyConfigs: o } =
|
310
|
-
return /* @__PURE__ */ s(
|
309
|
+
const { propertyConfigs: o } = V(), l = r ? pe(r, o) : null;
|
310
|
+
return /* @__PURE__ */ s(Ae, { children: /* @__PURE__ */ p(
|
311
311
|
"div",
|
312
312
|
{
|
313
313
|
className: "flex flex-row w-full items-center",
|
314
314
|
children: [
|
315
|
-
/* @__PURE__ */ s("div", { className: "mx-4", children: i ?? /* @__PURE__ */ s(
|
315
|
+
/* @__PURE__ */ s("div", { className: "mx-4", children: i ?? /* @__PURE__ */ s(fe, { propertyConfig: l ?? void 0 }) }),
|
316
316
|
/* @__PURE__ */ s("div", { className: "w-full flex flex-col grow", children: /* @__PURE__ */ p("div", { className: "flex flex-row items-center gap-2", children: [
|
317
317
|
t && /* @__PURE__ */ s(
|
318
|
-
|
318
|
+
We,
|
319
319
|
{
|
320
320
|
size: "small",
|
321
321
|
className: "text-base grow",
|
@@ -325,7 +325,7 @@ function Dt({
|
|
325
325
|
}
|
326
326
|
}
|
327
327
|
),
|
328
|
-
/* @__PURE__ */ s(ee, { onClick: n, size: "small", children: /* @__PURE__ */ s(
|
328
|
+
/* @__PURE__ */ s(ee, { onClick: n, size: "small", children: /* @__PURE__ */ s(ze, { size: "small" }) })
|
329
329
|
] }) })
|
330
330
|
]
|
331
331
|
}
|
@@ -336,9 +336,9 @@ function lt({
|
|
336
336
|
collection: r,
|
337
337
|
onImportSuccess: n
|
338
338
|
}) {
|
339
|
-
const t =
|
339
|
+
const t = me(), a = Oe(!1), [i, o] = j(0);
|
340
340
|
function l() {
|
341
|
-
a.current || (a.current = !0,
|
341
|
+
a.current || (a.current = !0, we(
|
342
342
|
t,
|
343
343
|
r,
|
344
344
|
e.entities,
|
@@ -351,8 +351,8 @@ function lt({
|
|
351
351
|
}
|
352
352
|
return ce(() => {
|
353
353
|
l();
|
354
|
-
}, []), /* @__PURE__ */ p(
|
355
|
-
/* @__PURE__ */ s(
|
354
|
+
}, []), /* @__PURE__ */ p(Ve, { className: "flex flex-col gap-4 items-center", children: [
|
355
|
+
/* @__PURE__ */ s(ge, {}),
|
356
356
|
/* @__PURE__ */ s(u, { variant: "h6", children: "Saving data" }),
|
357
357
|
/* @__PURE__ */ p(u, { variant: "body2", children: [
|
358
358
|
i,
|
@@ -363,7 +363,7 @@ function lt({
|
|
363
363
|
/* @__PURE__ */ s(u, { variant: "caption", children: "Do not close this tab or the import will be interrupted." })
|
364
364
|
] });
|
365
365
|
}
|
366
|
-
function
|
366
|
+
function we(e, r, n, t = 0, a = 25, i) {
|
367
367
|
console.debug("Saving imported data", t, a);
|
368
368
|
const o = n.slice(t, t + a);
|
369
369
|
return Promise.all(o.map((l) => e.saveEntity({
|
@@ -373,14 +373,14 @@ function De(e, r, n, t = 0, a = 25, i) {
|
|
373
373
|
entityId: l.id,
|
374
374
|
collection: r,
|
375
375
|
status: "new"
|
376
|
-
}))).then(() => t + a < n.length ? (i(t + a),
|
376
|
+
}))).then(() => t + a < n.length ? (i(t + a), we(e, r, n, t + a, a, i)) : (i(n.length), Promise.resolve()));
|
377
377
|
}
|
378
378
|
function ct({
|
379
379
|
collection: e,
|
380
380
|
path: r,
|
381
381
|
collectionEntitiesCount: n
|
382
382
|
}) {
|
383
|
-
const t =
|
383
|
+
const t = V(), a = de(), [i, o] = C.useState(!1), [l, d] = C.useState("initial"), c = Ke(), f = x(() => {
|
384
384
|
o(!0), d("initial");
|
385
385
|
}, [o]), m = x(() => {
|
386
386
|
o(!1);
|
@@ -392,33 +392,33 @@ function ct({
|
|
392
392
|
if (c.setImportData(g), g.length > 0) {
|
393
393
|
const I = await Ze(g, nt);
|
394
394
|
c.setOriginProperties(I);
|
395
|
-
const
|
396
|
-
c.setHeadersMapping(
|
397
|
-
const
|
398
|
-
if (
|
399
|
-
const w =
|
395
|
+
const E = Se(g);
|
396
|
+
c.setHeadersMapping(E);
|
397
|
+
const A = Object.keys(E)?.[0];
|
398
|
+
if (A?.includes("id") || A?.includes("key")) {
|
399
|
+
const w = A;
|
400
400
|
c.setIdColumn(w);
|
401
401
|
}
|
402
402
|
}
|
403
403
|
setTimeout(() => {
|
404
404
|
d("mapping");
|
405
405
|
}, 100);
|
406
|
-
}, N =
|
406
|
+
}, N = ue({
|
407
407
|
collection: e,
|
408
408
|
path: r,
|
409
409
|
fields: t.propertyConfigs
|
410
|
-
}),
|
410
|
+
}), L = Te(N.properties, N.propertiesOrder), O = Object.entries(L).flatMap(([g, I]) => De(g, I, 0)), J = N.propertiesOrder ?? Object.keys(N.properties);
|
411
411
|
return e.collectionGroup ? null : /* @__PURE__ */ p($, { children: [
|
412
412
|
/* @__PURE__ */ s(te, { title: "Import", children: /* @__PURE__ */ s(ee, { color: "primary", onClick: f, children: /* @__PURE__ */ s(Ge, {}) }) }),
|
413
413
|
/* @__PURE__ */ p(
|
414
|
-
|
414
|
+
ye,
|
415
415
|
{
|
416
416
|
open: i,
|
417
417
|
fullWidth: l === "preview",
|
418
418
|
fullHeight: l === "preview",
|
419
419
|
maxWidth: l === "initial" ? "lg" : "7xl",
|
420
420
|
children: [
|
421
|
-
/* @__PURE__ */ p(
|
421
|
+
/* @__PURE__ */ p(be, { className: "flex flex-col gap-4 my-4", fullHeight: l === "preview", children: [
|
422
422
|
l === "initial" && /* @__PURE__ */ p($, { children: [
|
423
423
|
/* @__PURE__ */ s(u, { variant: "h6", children: "Import data" }),
|
424
424
|
/* @__PURE__ */ s(u, { variant: "body2", children: "Upload a CSV, Excel or JSON file and map it to your existing schema" }),
|
@@ -432,25 +432,25 @@ function ct({
|
|
432
432
|
headersMapping: c.headersMapping,
|
433
433
|
idColumn: c.idColumn,
|
434
434
|
originProperties: c.originProperties,
|
435
|
-
destinationProperties:
|
435
|
+
destinationProperties: L,
|
436
436
|
onIdPropertyChanged: (g) => c.setIdColumn(g),
|
437
437
|
buildPropertyView: ({
|
438
438
|
isIdColumn: g,
|
439
439
|
property: I,
|
440
|
-
propertyKey:
|
441
|
-
importKey:
|
440
|
+
propertyKey: E,
|
441
|
+
importKey: A
|
442
442
|
}) => /* @__PURE__ */ s(
|
443
443
|
dt,
|
444
444
|
{
|
445
|
-
selectedPropertyKey:
|
446
|
-
properties:
|
445
|
+
selectedPropertyKey: E ?? "",
|
446
|
+
properties: L,
|
447
447
|
propertiesAndLevel: O,
|
448
448
|
isIdColumn: g,
|
449
449
|
onIdSelected: () => {
|
450
|
-
c.setIdColumn(
|
450
|
+
c.setIdColumn(A);
|
451
451
|
},
|
452
452
|
onPropertySelected: (w) => {
|
453
|
-
const G = Object.entries(c.headersMapping).map(([b, F]) => F === w ? { [b]: null } : b ===
|
453
|
+
const G = Object.entries(c.headersMapping).map(([b, F]) => F === w ? { [b]: null } : b === A ? { [b]: w } : { [b]: F }).reduce((b, F) => ({ ...b, ...F }), {});
|
454
454
|
c.setHeadersMapping(G), w === c.idColumn && c.setIdColumn(void 0);
|
455
455
|
}
|
456
456
|
}
|
@@ -462,8 +462,8 @@ function ct({
|
|
462
462
|
pt,
|
463
463
|
{
|
464
464
|
importConfig: c,
|
465
|
-
properties:
|
466
|
-
propertiesOrder:
|
465
|
+
properties: L,
|
466
|
+
propertiesOrder: J
|
467
467
|
}
|
468
468
|
),
|
469
469
|
l === "import_data_saving" && c && /* @__PURE__ */ s(
|
@@ -480,7 +480,7 @@ function ct({
|
|
480
480
|
}
|
481
481
|
)
|
482
482
|
] }),
|
483
|
-
/* @__PURE__ */ p(
|
483
|
+
/* @__PURE__ */ p(xe, { children: [
|
484
484
|
l === "mapping" && /* @__PURE__ */ s(
|
485
485
|
k,
|
486
486
|
{
|
@@ -527,7 +527,7 @@ function ct({
|
|
527
527
|
)
|
528
528
|
] });
|
529
529
|
}
|
530
|
-
const
|
530
|
+
const W = "__internal_id__";
|
531
531
|
function dt({
|
532
532
|
selectedPropertyKey: e,
|
533
533
|
properties: r,
|
@@ -536,30 +536,30 @@ function dt({
|
|
536
536
|
propertiesAndLevel: a,
|
537
537
|
isIdColumn: i
|
538
538
|
}) {
|
539
|
-
const o = e ?
|
539
|
+
const o = e ? R(r, e) : null, l = x((c) => c === W ? /* @__PURE__ */ s(u, { variant: "body2", className: "p-4", children: "Use this column as ID" }) : !c || !o ? /* @__PURE__ */ s(u, { variant: "body2", className: "p-4", children: "Do not import this property" }) : /* @__PURE__ */ s(
|
540
540
|
se,
|
541
541
|
{
|
542
542
|
propertyKey: c,
|
543
543
|
property: o
|
544
544
|
}
|
545
545
|
), [o]), d = x((c) => {
|
546
|
-
c ===
|
546
|
+
c === W ? (t(), n(null)) : n(c === "" ? null : c);
|
547
547
|
}, []);
|
548
548
|
return /* @__PURE__ */ p(
|
549
|
-
|
549
|
+
he,
|
550
550
|
{
|
551
|
-
value: i ?
|
551
|
+
value: i ? W : e ?? void 0,
|
552
552
|
onValueChange: d,
|
553
553
|
renderValue: l,
|
554
554
|
children: [
|
555
|
-
/* @__PURE__ */ s(
|
556
|
-
/* @__PURE__ */ s(
|
555
|
+
/* @__PURE__ */ s(B, { value: "", children: /* @__PURE__ */ s(u, { variant: "body2", className: "p-4", children: "Do not import this property" }) }),
|
556
|
+
/* @__PURE__ */ s(B, { value: W, children: /* @__PURE__ */ s(u, { variant: "body2", className: "p-4", children: "Use this column as ID" }) }),
|
557
557
|
a.map(({
|
558
558
|
property: c,
|
559
559
|
level: f,
|
560
560
|
propertyKey: m
|
561
561
|
}) => /* @__PURE__ */ s(
|
562
|
-
|
562
|
+
B,
|
563
563
|
{
|
564
564
|
value: m,
|
565
565
|
disabled: c.dataType === "map",
|
@@ -578,14 +578,14 @@ function dt({
|
|
578
578
|
}
|
579
579
|
);
|
580
580
|
}
|
581
|
-
function
|
581
|
+
function De(e, r, n) {
|
582
582
|
const t = [];
|
583
583
|
return t.push({
|
584
584
|
property: r,
|
585
585
|
level: n,
|
586
586
|
propertyKey: e
|
587
587
|
}), r.dataType === "map" && r.properties && Object.entries(r.properties).forEach(([a, i]) => {
|
588
|
-
t.push(...
|
588
|
+
t.push(...De(`${e}.${a}`, i, n + 1));
|
589
589
|
}), t;
|
590
590
|
}
|
591
591
|
function se({
|
@@ -593,14 +593,14 @@ function se({
|
|
593
593
|
property: r,
|
594
594
|
level: n = 0
|
595
595
|
}) {
|
596
|
-
const { propertyConfigs: t } =
|
596
|
+
const { propertyConfigs: t } = V(), a = pe(r, t);
|
597
597
|
return /* @__PURE__ */ p(
|
598
598
|
"div",
|
599
599
|
{
|
600
600
|
className: "flex flex-row w-full text-start items-center h-full",
|
601
601
|
children: [
|
602
|
-
new Array(n).fill(0).map((i, o) => /* @__PURE__ */ s("div", { className:
|
603
|
-
/* @__PURE__ */ s("div", { className: "m-4", children: /* @__PURE__ */ s(te, { title: a?.name, children: /* @__PURE__ */ s(
|
602
|
+
new Array(n).fill(0).map((i, o) => /* @__PURE__ */ s("div", { className: _(Xe, "ml-8 border-l h-12") }, o)),
|
603
|
+
/* @__PURE__ */ s("div", { className: "m-4", children: /* @__PURE__ */ s(te, { title: a?.name, children: /* @__PURE__ */ s(fe, { propertyConfig: a }) }) }),
|
604
604
|
/* @__PURE__ */ p("div", { className: "flex flex-col flex-grow p-2 pl-2", children: [
|
605
605
|
/* @__PURE__ */ s(
|
606
606
|
u,
|
@@ -660,12 +660,12 @@ function pt({
|
|
660
660
|
}
|
661
661
|
);
|
662
662
|
}
|
663
|
-
function
|
663
|
+
function Se(e) {
|
664
664
|
const r = {};
|
665
665
|
return e.filter(Boolean).forEach((n) => {
|
666
666
|
Object.keys(n).forEach((t) => {
|
667
667
|
const a = n[t];
|
668
|
-
typeof a == "object" && !Array.isArray(a) && Object.entries(
|
668
|
+
typeof a == "object" && !Array.isArray(a) && Object.entries(Se([a])).forEach(([i, o]) => {
|
669
669
|
r[`${t}.${i}`] = `${t}.${o}`;
|
670
670
|
}), r[t] = t;
|
671
671
|
});
|
@@ -714,13 +714,13 @@ function K(e, r, n = "") {
|
|
714
714
|
const t = n ? `${n}.${r}` : r;
|
715
715
|
return e.dataType === "map" && e.properties ? Object.entries(e.properties).map(([a, i]) => K(i, a, t)).flat() : [{ label: t, key: t }];
|
716
716
|
}
|
717
|
-
function
|
717
|
+
function z(e, r, n, t) {
|
718
718
|
let a;
|
719
719
|
if (r.dataType === "map" && r.properties)
|
720
720
|
a = re(e, r.properties, n, t);
|
721
721
|
else if (r.dataType === "array")
|
722
|
-
r.of && Array.isArray(e) ? Array.isArray(r.of) ? a = r.of.map((i, o) =>
|
723
|
-
else if (r.dataType === "reference" && e
|
722
|
+
r.of && Array.isArray(e) ? Array.isArray(r.of) ? a = r.of.map((i, o) => z(e[o], i, n, t)) : r.of.dataType === "map" ? a = n === "csv" ? e.map((i) => JSON.stringify(i)) : e.map((i) => z(i, r.of, n, t)) : a = e.map((i) => z(i, r.of, n, t)) : a = e;
|
723
|
+
else if (r.dataType === "reference" && e.isEntityReference && e.isEntityReference()) {
|
724
724
|
const i = e || void 0;
|
725
725
|
a = i ? i.pathWithId : null;
|
726
726
|
} else
|
@@ -729,7 +729,7 @@ function W(e, r, n, t) {
|
|
729
729
|
}
|
730
730
|
function re(e, r, n, t) {
|
731
731
|
const a = Object.entries(r).map(([i, o]) => {
|
732
|
-
const l = e && e[i], d =
|
732
|
+
const l = e && e[i], d = z(l, o, n, t);
|
733
733
|
return d === void 0 ? {} : { [i]: d };
|
734
734
|
}).reduce((i, o) => ({ ...i, ...o }), {});
|
735
735
|
return { ...e, ...a };
|
@@ -750,15 +750,15 @@ function yt({
|
|
750
750
|
exportAllowed: t,
|
751
751
|
notAllowedView: a
|
752
752
|
}) {
|
753
|
-
const i =
|
753
|
+
const i = V(), o = typeof e.exportable == "object" ? e.exportable : void 0, l = C.useRef(/* @__PURE__ */ new Date()), [d, c] = C.useState(!0), [f, m] = C.useState("csv"), [y, h] = C.useState("string"), S = Me(), N = me(), O = $e().resolveAliasesFrom(r), J = !t || t({
|
754
754
|
collectionEntitiesCount: n,
|
755
755
|
path: O,
|
756
756
|
collection: e
|
757
|
-
}), g = C.useMemo(() =>
|
757
|
+
}), g = C.useMemo(() => ue({
|
758
758
|
collection: e,
|
759
759
|
path: O,
|
760
760
|
fields: i.propertyConfigs
|
761
|
-
}), [e, O]), [I,
|
761
|
+
}), [e, O]), [I, E] = C.useState(!1), [A, w] = C.useState(), [G, b] = C.useState(!1), F = x(() => {
|
762
762
|
b(!0);
|
763
763
|
}, [b]), X = x(() => {
|
764
764
|
b(!1);
|
@@ -776,7 +776,7 @@ function yt({
|
|
776
776
|
} : {}))).reduce((v, Y) => ({ ...v, ...Y }), {}))) : [];
|
777
777
|
return [...q, ...Q];
|
778
778
|
}, [o?.additionalFields]), ae = x(async (P, H) => {
|
779
|
-
|
779
|
+
E(!0), N.fetchCollection({
|
780
780
|
path: O,
|
781
781
|
collection: P
|
782
782
|
}).then(async (D) => {
|
@@ -788,20 +788,20 @@ function yt({
|
|
788
788
|
ft(D, q, P, d, Q, f, y);
|
789
789
|
}).catch((D) => {
|
790
790
|
console.error("Error loading export data", D), w(D);
|
791
|
-
}).finally(() =>
|
792
|
-
}, [N, O, ne, d, f, y]),
|
791
|
+
}).finally(() => E(!1));
|
792
|
+
}, [N, O, ne, d, f, y]), Ne = x(() => {
|
793
793
|
ae(g, o), X();
|
794
794
|
}, [ae, g, o, X]);
|
795
795
|
return /* @__PURE__ */ p($, { children: [
|
796
796
|
/* @__PURE__ */ s(te, { title: "Export", children: /* @__PURE__ */ s(ee, { color: "primary", onClick: F, children: /* @__PURE__ */ s(qe, {}) }) }),
|
797
797
|
/* @__PURE__ */ p(
|
798
|
-
|
798
|
+
ye,
|
799
799
|
{
|
800
800
|
open: G,
|
801
801
|
onOpenChange: b,
|
802
802
|
maxWidth: "xl",
|
803
803
|
children: [
|
804
|
-
/* @__PURE__ */ p(
|
804
|
+
/* @__PURE__ */ p(be, { className: "flex flex-col gap-4 my-4", children: [
|
805
805
|
/* @__PURE__ */ s(u, { variant: "h6", children: "Export data" }),
|
806
806
|
/* @__PURE__ */ s("div", { children: "Download the the content of this table as a CSV" }),
|
807
807
|
n > gt && /* @__PURE__ */ s(Qe, { color: "warning", children: /* @__PURE__ */ p("div", { children: [
|
@@ -821,7 +821,7 @@ function yt({
|
|
821
821
|
name: "exportType",
|
822
822
|
checked: f === "csv",
|
823
823
|
onChange: () => m("csv"),
|
824
|
-
className:
|
824
|
+
className: _(U, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
825
825
|
}
|
826
826
|
),
|
827
827
|
/* @__PURE__ */ s(
|
@@ -843,7 +843,7 @@ function yt({
|
|
843
843
|
name: "exportType",
|
844
844
|
checked: f === "json",
|
845
845
|
onChange: () => m("json"),
|
846
|
-
className:
|
846
|
+
className: _(U, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
847
847
|
}
|
848
848
|
),
|
849
849
|
/* @__PURE__ */ s(
|
@@ -867,7 +867,7 @@ function yt({
|
|
867
867
|
name: "dateExportType",
|
868
868
|
checked: y === "timestamp",
|
869
869
|
onChange: () => h("timestamp"),
|
870
|
-
className:
|
870
|
+
className: _(U, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
871
871
|
}
|
872
872
|
),
|
873
873
|
/* @__PURE__ */ p(
|
@@ -893,7 +893,7 @@ function yt({
|
|
893
893
|
name: "dateExportType",
|
894
894
|
checked: y === "string",
|
895
895
|
onChange: () => h("string"),
|
896
|
-
className:
|
896
|
+
className: _(U, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
897
897
|
}
|
898
898
|
),
|
899
899
|
/* @__PURE__ */ p(
|
@@ -921,10 +921,10 @@ function yt({
|
|
921
921
|
label: "Flatten arrays"
|
922
922
|
}
|
923
923
|
),
|
924
|
-
!
|
924
|
+
!J && a
|
925
925
|
] }),
|
926
|
-
/* @__PURE__ */ p(
|
927
|
-
I && /* @__PURE__ */ s(
|
926
|
+
/* @__PURE__ */ p(xe, { children: [
|
927
|
+
I && /* @__PURE__ */ s(ge, { size: "small" }),
|
928
928
|
/* @__PURE__ */ s(
|
929
929
|
k,
|
930
930
|
{
|
@@ -937,8 +937,8 @@ function yt({
|
|
937
937
|
k,
|
938
938
|
{
|
939
939
|
variant: "filled",
|
940
|
-
onClick:
|
941
|
-
disabled: I || !
|
940
|
+
onClick: Ne,
|
941
|
+
disabled: I || !J,
|
942
942
|
children: "Download"
|
943
943
|
}
|
944
944
|
)
|
@@ -949,7 +949,7 @@ function yt({
|
|
949
949
|
] });
|
950
950
|
}
|
951
951
|
function St(e) {
|
952
|
-
return
|
952
|
+
return Ie(() => ({
|
953
953
|
name: "Import/Export",
|
954
954
|
collections: {
|
955
955
|
CollectionActions: [ct, yt],
|
@@ -964,11 +964,11 @@ export {
|
|
964
964
|
lt as ImportSaveInProgress,
|
965
965
|
rt as convertDataToEntity,
|
966
966
|
et as convertFileToJson,
|
967
|
-
|
967
|
+
Ce as flattenEntry,
|
968
968
|
nt as getInferenceType,
|
969
969
|
at as getPropertiesMapping,
|
970
970
|
Z as processValueMapping,
|
971
|
-
|
971
|
+
ve as unflattenObject,
|
972
972
|
Ke as useImportConfig,
|
973
973
|
St as useImportExportPlugin
|
974
974
|
};
|