@firecms/data_import_export 3.0.0-alpha.44 → 3.0.0-alpha.46
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 +93 -93
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/useImportExportPlugin.d.ts +6 -5
- package/package.json +4 -4
- package/src/export_import/ExportCollectionAction.tsx +3 -3
- package/src/useImportExportPlugin.tsx +5 -4
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import w, { useState as T, useRef as Ne, useEffect as le, useCallback as b, useMemo as Ie } from "react";
|
|
1
2
|
import { jsxs as p, Fragment as P, jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { buildEntityPropertiesFromData as qe } from "@firecms/schema_inference";
|
|
3
|
+
import { getPropertyInPath as M, EntityReference as ce, Table as Oe, TableHeader as Ae, TableCell as k, TableBody as Ee, TableRow as Te, Typography as h, ChevronRightIcon as je, Select as de, SelectItem as H, FileUpload as Fe, UploadIcon as ke, useFireCMSContext as G, getFieldConfig as pe, ErrorBoundary as Pe, FieldConfigBadge as fe, TextField as Me, IconButton as K, EditIcon as $e, useDataSource as me, CenteredView as _e, CircularProgress as ue, useSnackbarController as Le, resolveCollection as he, getPropertiesWithPropertiesOrder as Re, Tooltip as ee, FileUploadIcon as Be, Dialog as ge, DialogContent as ye, DialogActions as be, Button as j, cn as B, defaultBorderMixin as He, useSelectionController as Je, EntityCollectionTable as Ue, getArrayValuesCount as Ve, getValueInPath as We, useNavigationController as ze, GetAppIcon as Ge, Alert as Xe, focusedMixin as V, BooleanSwitchWithLabel as qe } from "@firecms/core";
|
|
4
|
+
import { buildEntityPropertiesFromData as Qe } from "@firecms/schema_inference";
|
|
5
5
|
import * as ae from "xlsx";
|
|
6
|
-
const
|
|
6
|
+
const Ye = () => {
|
|
7
7
|
const [e, r] = T(!1), [n, t] = T(), [a, i] = T([]), [o, l] = T([]), [d, c] = T({}), [f, m] = T({});
|
|
8
8
|
return {
|
|
9
9
|
inUse: e,
|
|
@@ -20,7 +20,7 @@ const Qe = () => {
|
|
|
20
20
|
setOriginProperties: m
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
function
|
|
23
|
+
function Ze(e) {
|
|
24
24
|
return new Promise((r, n) => {
|
|
25
25
|
if (e.type === "application/json") {
|
|
26
26
|
const t = new FileReader();
|
|
@@ -38,13 +38,13 @@ function Ye(e) {
|
|
|
38
38
|
codepage: 65001,
|
|
39
39
|
cellDates: !0
|
|
40
40
|
}
|
|
41
|
-
), l = o.SheetNames[0], d = o.Sheets[l], m = ae.utils.sheet_to_json(d).map(
|
|
41
|
+
), l = o.SheetNames[0], d = o.Sheets[l], m = ae.utils.sheet_to_json(d).map(Ke).map(xe);
|
|
42
42
|
r(m);
|
|
43
43
|
}, t.readAsArrayBuffer(e);
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Ke(e) {
|
|
48
48
|
return Object.keys(e).reduce((r, n) => {
|
|
49
49
|
try {
|
|
50
50
|
r[n] = JSON.parse(e[n]);
|
|
@@ -54,7 +54,7 @@ function Ze(e) {
|
|
|
54
54
|
return r;
|
|
55
55
|
}, {});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function xe(e) {
|
|
58
58
|
return Object.keys(e).reduce((r, n) => {
|
|
59
59
|
let t = r;
|
|
60
60
|
const a = n.split(".");
|
|
@@ -67,7 +67,7 @@ function be(e) {
|
|
|
67
67
|
}), r;
|
|
68
68
|
}, {});
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function et(e, r, n, t, a, i) {
|
|
71
71
|
const o = ve(e);
|
|
72
72
|
r && delete o[r];
|
|
73
73
|
const l = Object.entries(o).map(([c, f]) => {
|
|
@@ -79,7 +79,7 @@ function Ke(e, r, n, t, a, i) {
|
|
|
79
79
|
return u && (N = Y(f, u)), {
|
|
80
80
|
[m]: N
|
|
81
81
|
};
|
|
82
|
-
}).reduce((c, f) => ({ ...c, ...f }), {}), d =
|
|
82
|
+
}).reduce((c, f) => ({ ...c, ...f }), {}), d = xe(l);
|
|
83
83
|
return {
|
|
84
84
|
id: r ? e[r] : void 0,
|
|
85
85
|
values: d,
|
|
@@ -150,10 +150,10 @@ function Y(e, r) {
|
|
|
150
150
|
}
|
|
151
151
|
return e;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function tt(e) {
|
|
154
154
|
return typeof e == "number" ? "number" : typeof e == "string" ? "string" : typeof e == "boolean" ? "boolean" : e instanceof Date ? "date" : Array.isArray(e) ? "array" : "map";
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function rt(e, r) {
|
|
157
157
|
function n(t, a) {
|
|
158
158
|
const i = {};
|
|
159
159
|
return Object.keys(t).forEach((o) => {
|
|
@@ -181,7 +181,7 @@ function tt(e, r) {
|
|
|
181
181
|
}
|
|
182
182
|
return n(r);
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function nt({
|
|
185
185
|
idColumn: e,
|
|
186
186
|
headersMapping: r,
|
|
187
187
|
originProperties: n,
|
|
@@ -191,25 +191,25 @@ function rt({
|
|
|
191
191
|
}) {
|
|
192
192
|
return /* @__PURE__ */ p(P, { children: [
|
|
193
193
|
/* @__PURE__ */ s(
|
|
194
|
-
|
|
194
|
+
at,
|
|
195
195
|
{
|
|
196
196
|
idColumn: e,
|
|
197
197
|
headersMapping: r,
|
|
198
198
|
onChange: a
|
|
199
199
|
}
|
|
200
200
|
),
|
|
201
|
-
/* @__PURE__ */ p(
|
|
201
|
+
/* @__PURE__ */ p(Oe, { style: {
|
|
202
202
|
tableLayout: "fixed"
|
|
203
203
|
}, children: [
|
|
204
|
-
/* @__PURE__ */ p(
|
|
204
|
+
/* @__PURE__ */ p(Ae, { children: [
|
|
205
205
|
/* @__PURE__ */ s(k, { header: !0, style: { width: "20%" }, children: "Column in file" }),
|
|
206
206
|
/* @__PURE__ */ s(k, { header: !0 }),
|
|
207
207
|
/* @__PURE__ */ s(k, { header: !0, style: { width: "75%" }, children: "Property" })
|
|
208
208
|
] }),
|
|
209
|
-
/* @__PURE__ */ s(
|
|
209
|
+
/* @__PURE__ */ s(Ee, { children: t && Object.entries(r).map(
|
|
210
210
|
([o, l]) => {
|
|
211
211
|
const d = r[o], c = l ? M(t, l) : null, f = M(n, o), m = f ? f.dataType === "array" && typeof f.of == "object" ? `${f.dataType} - ${f.of.dataType}` : f.dataType : void 0;
|
|
212
|
-
return /* @__PURE__ */ p(
|
|
212
|
+
return /* @__PURE__ */ p(Te, { style: { height: "90px" }, children: [
|
|
213
213
|
/* @__PURE__ */ p(k, { style: { width: "20%" }, children: [
|
|
214
214
|
/* @__PURE__ */ s(h, { variant: "body2", children: o }),
|
|
215
215
|
f && /* @__PURE__ */ s(
|
|
@@ -221,7 +221,7 @@ function rt({
|
|
|
221
221
|
}
|
|
222
222
|
)
|
|
223
223
|
] }),
|
|
224
|
-
/* @__PURE__ */ s(k, { children: /* @__PURE__ */ s(
|
|
224
|
+
/* @__PURE__ */ s(k, { children: /* @__PURE__ */ s(je, {}) }),
|
|
225
225
|
/* @__PURE__ */ s(
|
|
226
226
|
k,
|
|
227
227
|
{
|
|
@@ -241,7 +241,7 @@ function rt({
|
|
|
241
241
|
] })
|
|
242
242
|
] });
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function at({
|
|
245
245
|
idColumn: e,
|
|
246
246
|
headersMapping: r,
|
|
247
247
|
onChange: n
|
|
@@ -263,9 +263,9 @@ function nt({
|
|
|
263
263
|
}
|
|
264
264
|
) });
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function it({ onDataAdded: e }) {
|
|
267
267
|
return /* @__PURE__ */ s(
|
|
268
|
-
|
|
268
|
+
Fe,
|
|
269
269
|
{
|
|
270
270
|
accept: {
|
|
271
271
|
"text/*": [".csv", ".xls", ".xlsx"],
|
|
@@ -281,18 +281,18 @@ function at({ onDataAdded: e }) {
|
|
|
281
281
|
size: "small",
|
|
282
282
|
maxFiles: 1,
|
|
283
283
|
uploadDescription: /* @__PURE__ */ p(P, { children: [
|
|
284
|
-
/* @__PURE__ */ s(
|
|
284
|
+
/* @__PURE__ */ s(ke, {}),
|
|
285
285
|
"Drag and drop a file here or click to upload"
|
|
286
286
|
] }),
|
|
287
287
|
onFilesAdded: (r) => {
|
|
288
|
-
r.length > 0 &&
|
|
288
|
+
r.length > 0 && Ze(r[0]).then((n) => {
|
|
289
289
|
e(n);
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
);
|
|
294
294
|
}
|
|
295
|
-
function
|
|
295
|
+
function vt({
|
|
296
296
|
propertyKey: e,
|
|
297
297
|
property: r,
|
|
298
298
|
onEditClick: n,
|
|
@@ -301,7 +301,7 @@ function bt({
|
|
|
301
301
|
propertyTypeView: i
|
|
302
302
|
}) {
|
|
303
303
|
const { propertyConfigs: o } = G(), l = r ? pe(r, o) : null;
|
|
304
|
-
return /* @__PURE__ */ s(
|
|
304
|
+
return /* @__PURE__ */ s(Pe, { children: /* @__PURE__ */ p(
|
|
305
305
|
"div",
|
|
306
306
|
{
|
|
307
307
|
className: "flex flex-row w-full items-center",
|
|
@@ -309,7 +309,7 @@ function bt({
|
|
|
309
309
|
/* @__PURE__ */ s("div", { className: "mx-4", children: i ?? /* @__PURE__ */ s(fe, { propertyConfig: l ?? void 0 }) }),
|
|
310
310
|
/* @__PURE__ */ s("div", { className: "w-full flex flex-col grow", children: /* @__PURE__ */ p("div", { className: "flex flex-row items-center gap-2", children: [
|
|
311
311
|
t && /* @__PURE__ */ s(
|
|
312
|
-
|
|
312
|
+
Me,
|
|
313
313
|
{
|
|
314
314
|
size: "small",
|
|
315
315
|
className: "text-base grow",
|
|
@@ -319,13 +319,13 @@ function bt({
|
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
),
|
|
322
|
-
/* @__PURE__ */ s(K, { onClick: n, size: "small", children: /* @__PURE__ */ s(
|
|
322
|
+
/* @__PURE__ */ s(K, { onClick: n, size: "small", children: /* @__PURE__ */ s($e, { size: "small" }) })
|
|
323
323
|
] }) })
|
|
324
324
|
]
|
|
325
325
|
}
|
|
326
326
|
) });
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function st({
|
|
329
329
|
importConfig: e,
|
|
330
330
|
collection: r,
|
|
331
331
|
onImportSuccess: n
|
|
@@ -345,7 +345,7 @@ function it({
|
|
|
345
345
|
}
|
|
346
346
|
return le(() => {
|
|
347
347
|
l();
|
|
348
|
-
}, []), /* @__PURE__ */ p(
|
|
348
|
+
}, []), /* @__PURE__ */ p(_e, { className: "flex flex-col gap-4 items-center", children: [
|
|
349
349
|
/* @__PURE__ */ s(ue, {}),
|
|
350
350
|
/* @__PURE__ */ s(h, { variant: "h6", children: "Saving data" }),
|
|
351
351
|
/* @__PURE__ */ p(h, { variant: "body2", children: [
|
|
@@ -369,22 +369,22 @@ function we(e, r, n, t = 0, a = 25, i) {
|
|
|
369
369
|
status: "new"
|
|
370
370
|
}))).then(() => t + a < n.length ? (i(t + a), we(e, r, n, t + a, a, i)) : (i(n.length), Promise.resolve()));
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function ot({
|
|
373
373
|
collection: e,
|
|
374
374
|
path: r,
|
|
375
375
|
collectionEntitiesCount: n
|
|
376
376
|
}) {
|
|
377
|
-
const t = G(), a =
|
|
377
|
+
const t = G(), a = Le(), [i, o] = w.useState(!1), [l, d] = w.useState("initial"), c = Ye(), f = b(() => {
|
|
378
378
|
o(!0), d("initial");
|
|
379
|
-
}, [o]), m =
|
|
379
|
+
}, [o]), m = b(() => {
|
|
380
380
|
o(!1);
|
|
381
|
-
}, [o]), y =
|
|
381
|
+
}, [o]), y = b(() => {
|
|
382
382
|
d("preview");
|
|
383
|
-
}, []), u =
|
|
383
|
+
}, []), u = b(() => {
|
|
384
384
|
d("import_data_saving");
|
|
385
385
|
}, []), N = async (g) => {
|
|
386
386
|
if (c.setImportData(g), g.length > 0) {
|
|
387
|
-
const I = await
|
|
387
|
+
const I = await Qe(g, tt);
|
|
388
388
|
c.setOriginProperties(I);
|
|
389
389
|
const L = De(g);
|
|
390
390
|
c.setHeadersMapping(L);
|
|
@@ -401,9 +401,9 @@ function st({
|
|
|
401
401
|
collection: e,
|
|
402
402
|
path: r,
|
|
403
403
|
fields: t.propertyConfigs
|
|
404
|
-
}),
|
|
404
|
+
}), x = Re($.properties, $.propertiesOrder), J = Object.entries(x).flatMap(([g, I]) => Ce(g, I, 0)), _ = $.propertiesOrder ?? Object.keys($.properties);
|
|
405
405
|
return e.collectionGroup ? null : /* @__PURE__ */ p(P, { children: [
|
|
406
|
-
/* @__PURE__ */ s(ee, { title: "Import", children: /* @__PURE__ */ s(K, { color: "primary", onClick: f, children: /* @__PURE__ */ s(
|
|
406
|
+
/* @__PURE__ */ s(ee, { title: "Import", children: /* @__PURE__ */ s(K, { color: "primary", onClick: f, children: /* @__PURE__ */ s(Be, {}) }) }),
|
|
407
407
|
/* @__PURE__ */ p(
|
|
408
408
|
ge,
|
|
409
409
|
{
|
|
@@ -416,17 +416,17 @@ function st({
|
|
|
416
416
|
l === "initial" && /* @__PURE__ */ p(P, { children: [
|
|
417
417
|
/* @__PURE__ */ s(h, { variant: "h6", children: "Import data" }),
|
|
418
418
|
/* @__PURE__ */ s(h, { variant: "body2", children: "Upload a CSV, Excel or JSON file and map it to your existing schema" }),
|
|
419
|
-
/* @__PURE__ */ s(
|
|
419
|
+
/* @__PURE__ */ s(it, { onDataAdded: N })
|
|
420
420
|
] }),
|
|
421
421
|
l === "mapping" && /* @__PURE__ */ p(P, { children: [
|
|
422
422
|
/* @__PURE__ */ s(h, { variant: "h6", children: "Map fields" }),
|
|
423
423
|
/* @__PURE__ */ s(
|
|
424
|
-
|
|
424
|
+
nt,
|
|
425
425
|
{
|
|
426
426
|
headersMapping: c.headersMapping,
|
|
427
427
|
idColumn: c.idColumn,
|
|
428
428
|
originProperties: c.originProperties,
|
|
429
|
-
destinationProperties:
|
|
429
|
+
destinationProperties: x,
|
|
430
430
|
onIdPropertyChanged: (g) => c.setIdColumn(g),
|
|
431
431
|
buildPropertyView: ({
|
|
432
432
|
isIdColumn: g,
|
|
@@ -434,10 +434,10 @@ function st({
|
|
|
434
434
|
propertyKey: L,
|
|
435
435
|
importKey: C
|
|
436
436
|
}) => /* @__PURE__ */ s(
|
|
437
|
-
|
|
437
|
+
lt,
|
|
438
438
|
{
|
|
439
439
|
selectedPropertyKey: L ?? "",
|
|
440
|
-
properties:
|
|
440
|
+
properties: x,
|
|
441
441
|
propertiesAndLevel: J,
|
|
442
442
|
isIdColumn: g,
|
|
443
443
|
onIdSelected: () => {
|
|
@@ -453,15 +453,15 @@ function st({
|
|
|
453
453
|
)
|
|
454
454
|
] }),
|
|
455
455
|
l === "preview" && /* @__PURE__ */ s(
|
|
456
|
-
|
|
456
|
+
ct,
|
|
457
457
|
{
|
|
458
458
|
importConfig: c,
|
|
459
|
-
properties:
|
|
459
|
+
properties: x,
|
|
460
460
|
propertiesOrder: _
|
|
461
461
|
}
|
|
462
462
|
),
|
|
463
463
|
l === "import_data_saving" && c && /* @__PURE__ */ s(
|
|
464
|
-
|
|
464
|
+
st,
|
|
465
465
|
{
|
|
466
466
|
importConfig: c,
|
|
467
467
|
collection: e,
|
|
@@ -474,7 +474,7 @@ function st({
|
|
|
474
474
|
}
|
|
475
475
|
)
|
|
476
476
|
] }),
|
|
477
|
-
/* @__PURE__ */ p(
|
|
477
|
+
/* @__PURE__ */ p(be, { children: [
|
|
478
478
|
l === "mapping" && /* @__PURE__ */ s(
|
|
479
479
|
j,
|
|
480
480
|
{
|
|
@@ -522,7 +522,7 @@ function st({
|
|
|
522
522
|
] });
|
|
523
523
|
}
|
|
524
524
|
const W = "__internal_id__";
|
|
525
|
-
function
|
|
525
|
+
function lt({
|
|
526
526
|
selectedPropertyKey: e,
|
|
527
527
|
properties: r,
|
|
528
528
|
onPropertySelected: n,
|
|
@@ -530,13 +530,13 @@ function ot({
|
|
|
530
530
|
propertiesAndLevel: a,
|
|
531
531
|
isIdColumn: i
|
|
532
532
|
}) {
|
|
533
|
-
const o = e ? M(r, e) : null, l =
|
|
533
|
+
const o = e ? M(r, e) : null, l = b((c) => c === W ? /* @__PURE__ */ s(h, { variant: "body2", className: "p-4", children: "Use this column as ID" }) : !c || !o ? /* @__PURE__ */ s(h, { variant: "body2", className: "p-4", children: "Do not import this property" }) : /* @__PURE__ */ s(
|
|
534
534
|
ie,
|
|
535
535
|
{
|
|
536
536
|
propertyKey: c,
|
|
537
537
|
property: o
|
|
538
538
|
}
|
|
539
|
-
), [o]), d =
|
|
539
|
+
), [o]), d = b((c) => {
|
|
540
540
|
c === W ? (t(), n(null)) : n(c === "" ? null : c);
|
|
541
541
|
}, []);
|
|
542
542
|
return /* @__PURE__ */ p(
|
|
@@ -593,7 +593,7 @@ function ie({
|
|
|
593
593
|
{
|
|
594
594
|
className: "flex flex-row w-full text-start items-center h-full",
|
|
595
595
|
children: [
|
|
596
|
-
new Array(n).fill(0).map((i, o) => /* @__PURE__ */ s("div", { className: B(
|
|
596
|
+
new Array(n).fill(0).map((i, o) => /* @__PURE__ */ s("div", { className: B(He, "ml-8 border-l h-12") }, o)),
|
|
597
597
|
/* @__PURE__ */ s("div", { className: "m-4", children: /* @__PURE__ */ s(ee, { title: a?.name, children: /* @__PURE__ */ s(fe, { propertyConfig: a }) }) }),
|
|
598
598
|
/* @__PURE__ */ p("div", { className: "flex flex-col flex-grow p-2 pl-2", children: [
|
|
599
599
|
/* @__PURE__ */ s(
|
|
@@ -620,18 +620,18 @@ function ie({
|
|
|
620
620
|
}
|
|
621
621
|
);
|
|
622
622
|
}
|
|
623
|
-
function
|
|
623
|
+
function ct({
|
|
624
624
|
importConfig: e,
|
|
625
625
|
properties: r,
|
|
626
626
|
propertiesOrder: n
|
|
627
627
|
}) {
|
|
628
628
|
le(() => {
|
|
629
|
-
const a =
|
|
629
|
+
const a = rt(e.originProperties, r), i = e.importData.map((o) => et(o, e.idColumn, e.headersMapping, r, a, "TEMP_PATH"));
|
|
630
630
|
e.setEntities(i);
|
|
631
631
|
}, []);
|
|
632
|
-
const t =
|
|
632
|
+
const t = Je();
|
|
633
633
|
return /* @__PURE__ */ s(
|
|
634
|
-
|
|
634
|
+
Ue,
|
|
635
635
|
{
|
|
636
636
|
title: /* @__PURE__ */ p("div", { children: [
|
|
637
637
|
/* @__PURE__ */ s(h, { variant: "subtitle2", children: "Imported data preview" }),
|
|
@@ -665,26 +665,26 @@ function De(e) {
|
|
|
665
665
|
});
|
|
666
666
|
}), r;
|
|
667
667
|
}
|
|
668
|
-
function
|
|
668
|
+
function dt(e, r, n, t, a, i, o) {
|
|
669
669
|
const l = n.properties;
|
|
670
670
|
if (i === "csv") {
|
|
671
|
-
const d = t ?
|
|
671
|
+
const d = t ? Ve(e.map((u) => u.values)) : {}, c = mt(l, a, d), f = pt(e, r, l, c, o), m = se(c.map((u) => u.label)), y = f.map((u) => se(u));
|
|
672
672
|
oe([m, ...y], `${n.name}.csv`, "text/csv");
|
|
673
673
|
} else {
|
|
674
|
-
const d =
|
|
674
|
+
const d = ft(e, r, l, o), c = JSON.stringify(d, null, 2);
|
|
675
675
|
oe([c], `${n.name}.json`, "application/json");
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function pt(e, r, n, t, a) {
|
|
679
679
|
const i = e.map((o) => ({
|
|
680
680
|
id: o.id,
|
|
681
681
|
...te(o.values, n, "csv", a)
|
|
682
682
|
}));
|
|
683
683
|
return r && r.forEach((o, l) => {
|
|
684
684
|
i[l] = { ...i[l], ...o };
|
|
685
|
-
}), i && i.map((o) => t.map((l) =>
|
|
685
|
+
}), i && i.map((o) => t.map((l) => We(o, l.key)));
|
|
686
686
|
}
|
|
687
|
-
function
|
|
687
|
+
function ft(e, r, n, t) {
|
|
688
688
|
const a = e.map((i) => ({
|
|
689
689
|
id: i.id,
|
|
690
690
|
...te(i.values, n, "json", t)
|
|
@@ -693,7 +693,7 @@ function pt(e, r, n, t) {
|
|
|
693
693
|
a[o] = { ...a[o], ...i };
|
|
694
694
|
}), a;
|
|
695
695
|
}
|
|
696
|
-
function
|
|
696
|
+
function mt(e, r, n) {
|
|
697
697
|
const t = [
|
|
698
698
|
{ label: "id", key: "id" },
|
|
699
699
|
...Object.entries(e).flatMap(([a, i]) => n && n[a] > 1 ? Array.from(
|
|
@@ -735,27 +735,27 @@ function oe(e, r, n) {
|
|
|
735
735
|
const t = new Blob(e, { type: n }), a = URL.createObjectURL(t), i = document.createElement("a");
|
|
736
736
|
i.href = a, i.setAttribute("download", r), i.click();
|
|
737
737
|
}
|
|
738
|
-
const
|
|
739
|
-
function
|
|
738
|
+
const ut = 500;
|
|
739
|
+
function ht({
|
|
740
740
|
collection: e,
|
|
741
741
|
path: r,
|
|
742
742
|
collectionEntitiesCount: n,
|
|
743
743
|
exportAllowed: t,
|
|
744
744
|
notAllowedView: a
|
|
745
745
|
}) {
|
|
746
|
-
const i = typeof e.exportable == "object" ? e.exportable : void 0, o = w.useRef(/* @__PURE__ */ new Date()), [l, d] = w.useState(!0), [c, f] = w.useState("csv"), [m, y] = w.useState("string"), u = G(), N = me(),
|
|
746
|
+
const i = typeof e.exportable == "object" ? e.exportable : void 0, o = w.useRef(/* @__PURE__ */ new Date()), [l, d] = w.useState(!0), [c, f] = w.useState("csv"), [m, y] = w.useState("string"), u = G(), N = me(), x = ze().resolveAliasesFrom(r), J = !t || t({
|
|
747
747
|
collectionEntitiesCount: n,
|
|
748
|
-
path:
|
|
748
|
+
path: x,
|
|
749
749
|
collection: e
|
|
750
750
|
}), _ = w.useMemo(() => he({
|
|
751
751
|
collection: e,
|
|
752
|
-
path:
|
|
752
|
+
path: x,
|
|
753
753
|
fields: u.propertyConfigs
|
|
754
|
-
}), [e,
|
|
754
|
+
}), [e, x]), [g, I] = w.useState(!1), [L, C] = w.useState(), [O, A] = w.useState(!1), D = b(() => {
|
|
755
755
|
A(!0);
|
|
756
|
-
}, [A]), S =
|
|
756
|
+
}, [A]), S = b(() => {
|
|
757
757
|
A(!1);
|
|
758
|
-
}, [A]), re =
|
|
758
|
+
}, [A]), re = b(async (F) => {
|
|
759
759
|
const U = i?.additionalFields, R = _.additionalFields, X = U ? await Promise.all(F.map(async (E) => (await Promise.all(U.map(async (v) => ({
|
|
760
760
|
[v.key]: await v.builder({
|
|
761
761
|
entity: E,
|
|
@@ -768,9 +768,9 @@ function ut({
|
|
|
768
768
|
})
|
|
769
769
|
} : {}))).reduce((v, Q) => ({ ...v, ...Q }), {}))) : [];
|
|
770
770
|
return [...X, ...q];
|
|
771
|
-
}, [i?.additionalFields]), ne =
|
|
771
|
+
}, [i?.additionalFields]), ne = b(async (F, U) => {
|
|
772
772
|
I(!0), N.fetchCollection({
|
|
773
|
-
path:
|
|
773
|
+
path: x,
|
|
774
774
|
collection: F
|
|
775
775
|
}).then(async (R) => {
|
|
776
776
|
C(void 0);
|
|
@@ -778,13 +778,13 @@ function ut({
|
|
|
778
778
|
...U?.additionalFields?.map((E) => E.key) ?? [],
|
|
779
779
|
...F.additionalFields?.map((E) => E.key) ?? []
|
|
780
780
|
];
|
|
781
|
-
|
|
781
|
+
dt(R, X, F, l, q, c, m);
|
|
782
782
|
}).catch(C).finally(() => I(!1));
|
|
783
|
-
}, [N,
|
|
783
|
+
}, [N, x, re, l, c, m]), Se = b(() => {
|
|
784
784
|
ne(_, i), S();
|
|
785
785
|
}, [ne, _, i, S]);
|
|
786
786
|
return /* @__PURE__ */ p(P, { children: [
|
|
787
|
-
/* @__PURE__ */ s(ee, { title: "Export", children: /* @__PURE__ */ s(K, { color: "primary", onClick: D, children: /* @__PURE__ */ s(
|
|
787
|
+
/* @__PURE__ */ s(ee, { title: "Export", children: /* @__PURE__ */ s(K, { color: "primary", onClick: D, children: /* @__PURE__ */ s(Ge, {}) }) }),
|
|
788
788
|
/* @__PURE__ */ p(
|
|
789
789
|
ge,
|
|
790
790
|
{
|
|
@@ -795,7 +795,7 @@ function ut({
|
|
|
795
795
|
/* @__PURE__ */ p(ye, { className: "flex flex-col gap-4 my-4", children: [
|
|
796
796
|
/* @__PURE__ */ s(h, { variant: "h6", children: "Export data" }),
|
|
797
797
|
/* @__PURE__ */ s("div", { children: "Download the the content of this table as a CSV" }),
|
|
798
|
-
n >
|
|
798
|
+
n > ut && /* @__PURE__ */ s(Xe, { color: "warning", children: /* @__PURE__ */ p("div", { children: [
|
|
799
799
|
"This collections has a large number of documents (",
|
|
800
800
|
n,
|
|
801
801
|
")."
|
|
@@ -903,7 +903,7 @@ function ut({
|
|
|
903
903
|
] })
|
|
904
904
|
] }),
|
|
905
905
|
/* @__PURE__ */ s(
|
|
906
|
-
|
|
906
|
+
qe,
|
|
907
907
|
{
|
|
908
908
|
size: "small",
|
|
909
909
|
disabled: c !== "csv",
|
|
@@ -914,7 +914,7 @@ function ut({
|
|
|
914
914
|
),
|
|
915
915
|
!J && a
|
|
916
916
|
] }),
|
|
917
|
-
/* @__PURE__ */ p(
|
|
917
|
+
/* @__PURE__ */ p(be, { children: [
|
|
918
918
|
g && /* @__PURE__ */ s(ue, { size: "small" }),
|
|
919
919
|
/* @__PURE__ */ s(
|
|
920
920
|
j,
|
|
@@ -939,28 +939,28 @@ function ut({
|
|
|
939
939
|
)
|
|
940
940
|
] });
|
|
941
941
|
}
|
|
942
|
-
function
|
|
943
|
-
return {
|
|
942
|
+
function wt(e) {
|
|
943
|
+
return Ie(() => ({
|
|
944
944
|
name: "Import/Export",
|
|
945
945
|
collections: {
|
|
946
|
-
CollectionActions: [
|
|
946
|
+
CollectionActions: [ot, ht],
|
|
947
947
|
collectionActionsProps: e
|
|
948
948
|
}
|
|
949
|
-
};
|
|
949
|
+
}), [e]);
|
|
950
950
|
}
|
|
951
951
|
export {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
952
|
+
nt as DataNewPropertiesMapping,
|
|
953
|
+
it as ImportFileUpload,
|
|
954
|
+
vt as ImportNewPropertyFieldPreview,
|
|
955
|
+
st as ImportSaveInProgress,
|
|
956
|
+
et as convertDataToEntity,
|
|
957
|
+
Ze as convertFileToJson,
|
|
958
958
|
ve as flattenEntry,
|
|
959
|
-
|
|
960
|
-
|
|
959
|
+
tt as getInferenceType,
|
|
960
|
+
rt as getPropertiesMapping,
|
|
961
961
|
Y as processValueMapping,
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
962
|
+
xe as unflattenObject,
|
|
963
|
+
Ye as useImportConfig,
|
|
964
|
+
wt as useImportExportPlugin
|
|
965
965
|
};
|
|
966
966
|
//# sourceMappingURL=index.es.js.map
|