@firecms/data_import_export 3.0.0-beta.2-pre.1 → 3.0.0-beta.2-pre.3

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 CHANGED
@@ -1,7 +1,7 @@
1
- import C, { useState as j, useRef as Ie, useEffect as ce, useCallback as b, useMemo as Oe } from "react";
1
+ import C, { useState as j, useRef as Ie, useEffect as ce, useCallback as x, useMemo as Ae } from "react";
2
2
  import { jsxs as p, Fragment as $, jsx as s } from "react/jsx-runtime";
3
- import { getPropertyInPath as L, EntityReference as de, useCustomizationController as z, getFieldConfig as pe, ErrorBoundary as Ae, PropertyConfigBadge as fe, useDataSource as me, useSnackbarController as Ee, resolveCollection as ue, getPropertiesWithPropertiesOrder as Te, useSelectionController as je, EntityCollectionTable as Fe, getArrayValuesCount as ke, getValueInPath as Pe, useFireCMSContext as Me, useNavigationController as $e } from "@firecms/core";
4
- import { Table as Le, TableHeader as _e, TableCell as M, TableBody as Be, TableRow as Re, Typography as u, ChevronRightIcon as He, Select as he, SelectItem as R, FileUpload as Je, UploadIcon as Ue, TextField as Ve, IconButton as ee, EditIcon as We, CenteredView as ze, CircularProgress as ge, Tooltip as te, FileUploadIcon as Ge, Dialog as ye, DialogContent as xe, DialogActions as be, Button as F, cn as B, defaultBorderMixin as Xe, GetAppIcon as qe, Alert as Qe, focusedMixin as U, BooleanSwitchWithLabel as Ye } from "@firecms/ui";
3
+ import { getPropertyInPath as L, EntityReference as de, useSnackbarController as pe, useCustomizationController as z, getFieldConfig as fe, ErrorBoundary as Ee, PropertyConfigBadge as me, useDataSource as ue, resolveCollection as he, 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 Le, TableHeader as _e, TableCell as M, TableBody as Be, TableRow as Je, Typography as u, ChevronRightIcon as Re, Select as ge, SelectItem as J, FileUpload as He, UploadIcon as Ue, TextField as Ve, IconButton as ee, EditIcon as We, CenteredView as ze, CircularProgress as ye, Tooltip as te, FileUploadIcon as Ge, Dialog as be, DialogContent as xe, DialogActions as ve, Button as k, cn as B, 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 = () => {
@@ -24,12 +24,14 @@ const Ke = () => {
24
24
  function et(e) {
25
25
  return new Promise((r, n) => {
26
26
  if (e.type === "application/json") {
27
+ console.debug("Converting JSON file to JSON", e.name);
27
28
  const t = new FileReader();
28
29
  t.onload = function(a) {
29
30
  const i = a.target?.result, o = JSON.parse(i);
30
- r(o);
31
+ Array.isArray(o) || n(new Error("JSON file should contain an array of objects")), r(o);
31
32
  }, t.readAsText(e);
32
33
  } else {
34
+ console.debug("Converting Excel file to JSON", e.name);
33
35
  const t = new FileReader();
34
36
  t.onload = function(a) {
35
37
  const i = new Uint8Array(a.target?.result), o = ie.read(
@@ -39,7 +41,7 @@ function et(e) {
39
41
  codepage: 65001,
40
42
  cellDates: !0
41
43
  }
42
- ), l = o.SheetNames[0], d = o.Sheets[l], m = ie.utils.sheet_to_json(d).map(tt).map(ve);
44
+ ), l = o.SheetNames[0], d = o.Sheets[l], m = ie.utils.sheet_to_json(d).map(tt).map(Ce);
43
45
  r(m);
44
46
  }, t.readAsArrayBuffer(e);
45
47
  }
@@ -55,7 +57,7 @@ function tt(e) {
55
57
  return r;
56
58
  }, {});
57
59
  }
58
- function ve(e) {
60
+ function Ce(e) {
59
61
  return Object.keys(e).reduce((r, n) => {
60
62
  let t = r;
61
63
  const a = n.split(".");
@@ -69,7 +71,7 @@ function ve(e) {
69
71
  }, {});
70
72
  }
71
73
  function rt(e, r, n, t, a, i) {
72
- const o = Ce(e);
74
+ const o = we(e);
73
75
  r && delete o[r];
74
76
  const l = Object.entries(o).map(([c, f]) => {
75
77
  const m = n[c] ?? c;
@@ -80,17 +82,17 @@ function rt(e, r, n, t, a, i) {
80
82
  return h && (S = Z(f, h)), {
81
83
  [m]: S
82
84
  };
83
- }).reduce((c, f) => ({ ...c, ...f }), {}), d = ve(l);
85
+ }).reduce((c, f) => ({ ...c, ...f }), {}), d = Ce(l);
84
86
  return {
85
87
  id: r ? e[r] : void 0,
86
88
  values: d,
87
89
  path: i
88
90
  };
89
91
  }
90
- function Ce(e, r = "") {
92
+ function we(e, r = "") {
91
93
  return Object.keys(e).reduce((n, t) => {
92
94
  const a = r ? `${r}.${t}` : t;
93
- return typeof e[t] == "object" && e[t] !== null && !Array.isArray(e[t]) ? Object.assign(n, Ce(e[t], a)) : n[a] = e[t], n;
95
+ return typeof e[t] == "object" && e[t] !== null && !Array.isArray(e[t]) ? Object.assign(n, we(e[t], a)) : n[a] = e[t], n;
94
96
  }, {});
95
97
  }
96
98
  function Z(e, r) {
@@ -210,7 +212,7 @@ function it({
210
212
  /* @__PURE__ */ s(Be, { children: t && Object.entries(r).map(
211
213
  ([o, l]) => {
212
214
  const d = r[o], c = l ? L(t, l) : null, f = L(n, o), m = f ? f.dataType === "array" && typeof f.of == "object" ? `${f.dataType} - ${f.of.dataType}` : f.dataType : void 0;
213
- return /* @__PURE__ */ p(Re, { style: { height: "90px" }, children: [
215
+ return /* @__PURE__ */ p(Je, { style: { height: "90px" }, children: [
214
216
  /* @__PURE__ */ p(M, { style: { width: "20%" }, children: [
215
217
  /* @__PURE__ */ s(u, { variant: "body2", children: o }),
216
218
  f && /* @__PURE__ */ s(
@@ -222,7 +224,7 @@ function it({
222
224
  }
223
225
  )
224
226
  ] }),
225
- /* @__PURE__ */ s(M, { children: /* @__PURE__ */ s(He, {}) }),
227
+ /* @__PURE__ */ s(M, { children: /* @__PURE__ */ s(Re, {}) }),
226
228
  /* @__PURE__ */ s(
227
229
  M,
228
230
  {
@@ -248,7 +250,7 @@ function st({
248
250
  onChange: n
249
251
  }) {
250
252
  return /* @__PURE__ */ s("div", { children: /* @__PURE__ */ p(
251
- he,
253
+ ge,
252
254
  {
253
255
  size: "small",
254
256
  value: e ?? "",
@@ -258,15 +260,16 @@ function st({
258
260
  renderValue: (t) => /* @__PURE__ */ s(u, { variant: "body2", children: t !== "" ? t : "Autogenerate ID" }),
259
261
  label: "Column that will be used as ID for each document",
260
262
  children: [
261
- /* @__PURE__ */ s(R, { value: "", children: "Autogenerate ID" }),
262
- Object.entries(r).map(([t, a]) => /* @__PURE__ */ s(R, { value: t, children: t }, t))
263
+ /* @__PURE__ */ s(J, { value: "", children: "Autogenerate ID" }),
264
+ Object.entries(r).map(([t, a]) => /* @__PURE__ */ s(J, { value: t, children: t }, t))
263
265
  ]
264
266
  }
265
267
  ) });
266
268
  }
267
269
  function ot({ onDataAdded: e }) {
270
+ const r = pe();
268
271
  return /* @__PURE__ */ s(
269
- Je,
272
+ He,
270
273
  {
271
274
  accept: {
272
275
  "text/*": [".csv", ".xls", ".xlsx"],
@@ -285,9 +288,11 @@ function ot({ onDataAdded: e }) {
285
288
  /* @__PURE__ */ s(Ue, {}),
286
289
  "Drag and drop a file here or click to upload"
287
290
  ] }),
288
- onFilesAdded: (r) => {
289
- r.length > 0 && et(r[0]).then((n) => {
290
- e(n);
291
+ onFilesAdded: (n) => {
292
+ n.length > 0 && et(n[0]).then((t) => {
293
+ e(t);
294
+ }).catch((t) => {
295
+ console.error("Error parsing file", t), r.open({ type: "error", message: t.message });
291
296
  });
292
297
  }
293
298
  }
@@ -301,13 +306,13 @@ function Dt({
301
306
  onPropertyNameChanged: a,
302
307
  propertyTypeView: i
303
308
  }) {
304
- const { propertyConfigs: o } = z(), l = r ? pe(r, o) : null;
305
- return /* @__PURE__ */ s(Ae, { children: /* @__PURE__ */ p(
309
+ const { propertyConfigs: o } = z(), l = r ? fe(r, o) : null;
310
+ return /* @__PURE__ */ s(Ee, { children: /* @__PURE__ */ p(
306
311
  "div",
307
312
  {
308
313
  className: "flex flex-row w-full items-center",
309
314
  children: [
310
- /* @__PURE__ */ s("div", { className: "mx-4", children: i ?? /* @__PURE__ */ s(fe, { propertyConfig: l ?? void 0 }) }),
315
+ /* @__PURE__ */ s("div", { className: "mx-4", children: i ?? /* @__PURE__ */ s(me, { propertyConfig: l ?? void 0 }) }),
311
316
  /* @__PURE__ */ s("div", { className: "w-full flex flex-col grow", children: /* @__PURE__ */ p("div", { className: "flex flex-row items-center gap-2", children: [
312
317
  t && /* @__PURE__ */ s(
313
318
  Ve,
@@ -331,9 +336,9 @@ function lt({
331
336
  collection: r,
332
337
  onImportSuccess: n
333
338
  }) {
334
- const t = me(), a = Ie(!1), [i, o] = j(0);
339
+ const t = ue(), a = Ie(!1), [i, o] = j(0);
335
340
  function l() {
336
- a.current || (a.current = !0, we(
341
+ a.current || (a.current = !0, De(
337
342
  t,
338
343
  r,
339
344
  e.entities,
@@ -347,7 +352,7 @@ function lt({
347
352
  return ce(() => {
348
353
  l();
349
354
  }, []), /* @__PURE__ */ p(ze, { className: "flex flex-col gap-4 items-center", children: [
350
- /* @__PURE__ */ s(ge, {}),
355
+ /* @__PURE__ */ s(ye, {}),
351
356
  /* @__PURE__ */ s(u, { variant: "h6", children: "Saving data" }),
352
357
  /* @__PURE__ */ p(u, { variant: "body2", children: [
353
358
  i,
@@ -358,7 +363,7 @@ function lt({
358
363
  /* @__PURE__ */ s(u, { variant: "caption", children: "Do not close this tab or the import will be interrupted." })
359
364
  ] });
360
365
  }
361
- function we(e, r, n, t = 0, a = 25, i) {
366
+ function De(e, r, n, t = 0, a = 25, i) {
362
367
  console.debug("Saving imported data", t, a);
363
368
  const o = n.slice(t, t + a);
364
369
  return Promise.all(o.map((l) => e.saveEntity({
@@ -368,26 +373,26 @@ function we(e, r, n, t = 0, a = 25, i) {
368
373
  entityId: l.id,
369
374
  collection: r,
370
375
  status: "new"
371
- }))).then(() => t + a < n.length ? (i(t + a), we(e, r, n, t + a, a, i)) : (i(n.length), Promise.resolve()));
376
+ }))).then(() => t + a < n.length ? (i(t + a), De(e, r, n, t + a, a, i)) : (i(n.length), Promise.resolve()));
372
377
  }
373
378
  function ct({
374
379
  collection: e,
375
380
  path: r,
376
381
  collectionEntitiesCount: n
377
382
  }) {
378
- const t = z(), a = Ee(), [i, o] = C.useState(!1), [l, d] = C.useState("initial"), c = Ke(), f = b(() => {
383
+ const t = z(), a = pe(), [i, o] = C.useState(!1), [l, d] = C.useState("initial"), c = Ke(), f = x(() => {
379
384
  o(!0), d("initial");
380
- }, [o]), m = b(() => {
385
+ }, [o]), m = x(() => {
381
386
  o(!1);
382
- }, [o]), y = b(() => {
387
+ }, [o]), y = x(() => {
383
388
  d("preview");
384
- }, []), h = b(() => {
389
+ }, []), h = x(() => {
385
390
  d("import_data_saving");
386
391
  }, []), S = async (g) => {
387
392
  if (c.setImportData(g), g.length > 0) {
388
- const O = await Ze(g, nt);
389
- c.setOriginProperties(O);
390
- const A = Se(g);
393
+ const I = await Ze(g, nt);
394
+ c.setOriginProperties(I);
395
+ const A = Ne(g);
391
396
  c.setHeadersMapping(A);
392
397
  const E = Object.keys(A)?.[0];
393
398
  if (E?.includes("id") || E?.includes("key")) {
@@ -398,15 +403,15 @@ function ct({
398
403
  setTimeout(() => {
399
404
  d("mapping");
400
405
  }, 100);
401
- }, N = ue({
406
+ }, N = he({
402
407
  collection: e,
403
408
  path: r,
404
409
  fields: t.propertyConfigs
405
- }), _ = Te(N.properties, N.propertiesOrder), I = Object.entries(_).flatMap(([g, O]) => De(g, O, 0)), H = N.propertiesOrder ?? Object.keys(N.properties);
410
+ }), _ = Te(N.properties, N.propertiesOrder), O = Object.entries(_).flatMap(([g, I]) => Se(g, I, 0)), R = N.propertiesOrder ?? Object.keys(N.properties);
406
411
  return e.collectionGroup ? null : /* @__PURE__ */ p($, { children: [
407
412
  /* @__PURE__ */ s(te, { title: "Import", children: /* @__PURE__ */ s(ee, { color: "primary", onClick: f, children: /* @__PURE__ */ s(Ge, {}) }) }),
408
413
  /* @__PURE__ */ p(
409
- ye,
414
+ be,
410
415
  {
411
416
  open: i,
412
417
  fullWidth: l === "preview",
@@ -431,7 +436,7 @@ function ct({
431
436
  onIdPropertyChanged: (g) => c.setIdColumn(g),
432
437
  buildPropertyView: ({
433
438
  isIdColumn: g,
434
- property: O,
439
+ property: I,
435
440
  propertyKey: A,
436
441
  importKey: E
437
442
  }) => /* @__PURE__ */ s(
@@ -439,13 +444,13 @@ function ct({
439
444
  {
440
445
  selectedPropertyKey: A ?? "",
441
446
  properties: _,
442
- propertiesAndLevel: I,
447
+ propertiesAndLevel: O,
443
448
  isIdColumn: g,
444
449
  onIdSelected: () => {
445
450
  c.setIdColumn(E);
446
451
  },
447
452
  onPropertySelected: (w) => {
448
- const G = Object.entries(c.headersMapping).map(([x, k]) => k === w ? { [x]: null } : x === E ? { [x]: w } : { [x]: k }).reduce((x, k) => ({ ...x, ...k }), {});
453
+ const G = Object.entries(c.headersMapping).map(([b, F]) => F === w ? { [b]: null } : b === E ? { [b]: w } : { [b]: F }).reduce((b, F) => ({ ...b, ...F }), {});
449
454
  c.setHeadersMapping(G), w === c.idColumn && c.setIdColumn(void 0);
450
455
  }
451
456
  }
@@ -458,7 +463,7 @@ function ct({
458
463
  {
459
464
  importConfig: c,
460
465
  properties: _,
461
- propertiesOrder: H
466
+ propertiesOrder: R
462
467
  }
463
468
  ),
464
469
  l === "import_data_saving" && c && /* @__PURE__ */ s(
@@ -475,9 +480,9 @@ function ct({
475
480
  }
476
481
  )
477
482
  ] }),
478
- /* @__PURE__ */ p(be, { children: [
483
+ /* @__PURE__ */ p(ve, { children: [
479
484
  l === "mapping" && /* @__PURE__ */ s(
480
- F,
485
+ k,
481
486
  {
482
487
  onClick: () => d("initial"),
483
488
  variant: "text",
@@ -485,7 +490,7 @@ function ct({
485
490
  }
486
491
  ),
487
492
  l === "preview" && /* @__PURE__ */ s(
488
- F,
493
+ k,
489
494
  {
490
495
  onClick: () => d("mapping"),
491
496
  variant: "text",
@@ -493,7 +498,7 @@ function ct({
493
498
  }
494
499
  ),
495
500
  /* @__PURE__ */ s(
496
- F,
501
+ k,
497
502
  {
498
503
  onClick: m,
499
504
  variant: "text",
@@ -501,7 +506,7 @@ function ct({
501
506
  }
502
507
  ),
503
508
  l === "mapping" && /* @__PURE__ */ s(
504
- F,
509
+ k,
505
510
  {
506
511
  variant: "filled",
507
512
  onClick: y,
@@ -509,7 +514,7 @@ function ct({
509
514
  }
510
515
  ),
511
516
  l === "preview" && /* @__PURE__ */ s(
512
- F,
517
+ k,
513
518
  {
514
519
  variant: "filled",
515
520
  onClick: h,
@@ -531,30 +536,30 @@ function dt({
531
536
  propertiesAndLevel: a,
532
537
  isIdColumn: i
533
538
  }) {
534
- const o = e ? L(r, e) : null, l = b((c) => c === V ? /* @__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(
539
+ const o = e ? L(r, e) : null, l = x((c) => c === V ? /* @__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(
535
540
  se,
536
541
  {
537
542
  propertyKey: c,
538
543
  property: o
539
544
  }
540
- ), [o]), d = b((c) => {
545
+ ), [o]), d = x((c) => {
541
546
  c === V ? (t(), n(null)) : n(c === "" ? null : c);
542
547
  }, []);
543
548
  return /* @__PURE__ */ p(
544
- he,
549
+ ge,
545
550
  {
546
551
  value: i ? V : e ?? void 0,
547
552
  onValueChange: d,
548
553
  renderValue: l,
549
554
  children: [
550
- /* @__PURE__ */ s(R, { value: "", children: /* @__PURE__ */ s(u, { variant: "body2", className: "p-4", children: "Do not import this property" }) }),
551
- /* @__PURE__ */ s(R, { value: V, children: /* @__PURE__ */ s(u, { variant: "body2", className: "p-4", children: "Use this column as ID" }) }),
555
+ /* @__PURE__ */ s(J, { value: "", children: /* @__PURE__ */ s(u, { variant: "body2", className: "p-4", children: "Do not import this property" }) }),
556
+ /* @__PURE__ */ s(J, { value: V, children: /* @__PURE__ */ s(u, { variant: "body2", className: "p-4", children: "Use this column as ID" }) }),
552
557
  a.map(({
553
558
  property: c,
554
559
  level: f,
555
560
  propertyKey: m
556
561
  }) => /* @__PURE__ */ s(
557
- R,
562
+ J,
558
563
  {
559
564
  value: m,
560
565
  disabled: c.dataType === "map",
@@ -573,14 +578,14 @@ function dt({
573
578
  }
574
579
  );
575
580
  }
576
- function De(e, r, n) {
581
+ function Se(e, r, n) {
577
582
  const t = [];
578
583
  return t.push({
579
584
  property: r,
580
585
  level: n,
581
586
  propertyKey: e
582
587
  }), r.dataType === "map" && r.properties && Object.entries(r.properties).forEach(([a, i]) => {
583
- t.push(...De(`${e}.${a}`, i, n + 1));
588
+ t.push(...Se(`${e}.${a}`, i, n + 1));
584
589
  }), t;
585
590
  }
586
591
  function se({
@@ -588,14 +593,14 @@ function se({
588
593
  property: r,
589
594
  level: n = 0
590
595
  }) {
591
- const { propertyConfigs: t } = z(), a = pe(r, t);
596
+ const { propertyConfigs: t } = z(), a = fe(r, t);
592
597
  return /* @__PURE__ */ p(
593
598
  "div",
594
599
  {
595
600
  className: "flex flex-row w-full text-start items-center h-full",
596
601
  children: [
597
602
  new Array(n).fill(0).map((i, o) => /* @__PURE__ */ s("div", { className: B(Xe, "ml-8 border-l h-12") }, o)),
598
- /* @__PURE__ */ s("div", { className: "m-4", children: /* @__PURE__ */ s(te, { title: a?.name, children: /* @__PURE__ */ s(fe, { propertyConfig: a }) }) }),
603
+ /* @__PURE__ */ s("div", { className: "m-4", children: /* @__PURE__ */ s(te, { title: a?.name, children: /* @__PURE__ */ s(me, { propertyConfig: a }) }) }),
599
604
  /* @__PURE__ */ p("div", { className: "flex flex-col flex-grow p-2 pl-2", children: [
600
605
  /* @__PURE__ */ s(
601
606
  u,
@@ -632,7 +637,7 @@ function pt({
632
637
  }, []);
633
638
  const t = je();
634
639
  return /* @__PURE__ */ s(
635
- Fe,
640
+ ke,
636
641
  {
637
642
  title: /* @__PURE__ */ p("div", { children: [
638
643
  /* @__PURE__ */ s(u, { variant: "subtitle2", children: "Imported data preview" }),
@@ -655,12 +660,12 @@ function pt({
655
660
  }
656
661
  );
657
662
  }
658
- function Se(e) {
663
+ function Ne(e) {
659
664
  const r = {};
660
665
  return e.filter(Boolean).forEach((n) => {
661
666
  Object.keys(n).forEach((t) => {
662
667
  const a = n[t];
663
- typeof a == "object" && !Array.isArray(a) && Object.entries(Se([a])).forEach(([i, o]) => {
668
+ typeof a == "object" && !Array.isArray(a) && Object.entries(Ne([a])).forEach(([i, o]) => {
664
669
  r[`${t}.${i}`] = `${t}.${o}`;
665
670
  }), r[t] = t;
666
671
  });
@@ -670,7 +675,7 @@ function ft(e, r, n, t, a, i, o) {
670
675
  console.debug("Downloading export", { dataLength: e.length, collection: n, exportType: i, dateExportType: o });
671
676
  const l = n.properties;
672
677
  if (i === "csv") {
673
- const d = t ? ke(e.map((h) => h.values)) : {}, c = ht(l, a, d), f = mt(e, r, l, c, o), m = oe(c.map((h) => h.label)), y = f.map((h) => oe(h));
678
+ const d = t ? Fe(e.map((h) => h.values)) : {}, c = ht(l, a, d), f = mt(e, r, l, c, o), m = oe(c.map((h) => h.label)), y = f.map((h) => oe(h));
674
679
  le([m, ...y], `${n.name}.csv`, "text/csv");
675
680
  } else {
676
681
  const d = ut(e, r, l, o), c = JSON.stringify(d, null, 2);
@@ -745,20 +750,20 @@ function yt({
745
750
  exportAllowed: t,
746
751
  notAllowedView: a
747
752
  }) {
748
- const i = z(), 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(), I = $e().resolveAliasesFrom(r), H = !t || t({
753
+ const i = z(), 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 = ue(), O = $e().resolveAliasesFrom(r), R = !t || t({
749
754
  collectionEntitiesCount: n,
750
- path: I,
755
+ path: O,
751
756
  collection: e
752
- }), g = C.useMemo(() => ue({
757
+ }), g = C.useMemo(() => he({
753
758
  collection: e,
754
- path: I,
759
+ path: O,
755
760
  fields: i.propertyConfigs
756
- }), [e, I]), [O, A] = C.useState(!1), [E, w] = C.useState(), [G, x] = C.useState(!1), k = b(() => {
757
- x(!0);
758
- }, [x]), X = b(() => {
759
- x(!1);
760
- }, [x]), ne = b(async (P) => {
761
- const J = o?.additionalFields, D = g.additionalFields, q = J ? await Promise.all(P.map(async (T) => (await Promise.all(J.map(async (v) => ({
761
+ }), [e, O]), [I, A] = C.useState(!1), [E, w] = C.useState(), [G, b] = C.useState(!1), F = x(() => {
762
+ b(!0);
763
+ }, [b]), X = x(() => {
764
+ b(!1);
765
+ }, [b]), ne = x(async (P) => {
766
+ const H = o?.additionalFields, D = g.additionalFields, q = H ? await Promise.all(P.map(async (T) => (await Promise.all(H.map(async (v) => ({
762
767
  [v.key]: await v.builder({
763
768
  entity: T,
764
769
  context: S
@@ -770,30 +775,30 @@ function yt({
770
775
  })
771
776
  } : {}))).reduce((v, Y) => ({ ...v, ...Y }), {}))) : [];
772
777
  return [...q, ...Q];
773
- }, [o?.additionalFields]), ae = b(async (P, J) => {
778
+ }, [o?.additionalFields]), ae = x(async (P, H) => {
774
779
  A(!0), N.fetchCollection({
775
- path: I,
780
+ path: O,
776
781
  collection: P
777
782
  }).then(async (D) => {
778
783
  w(void 0);
779
784
  const q = await ne(D), Q = [
780
- ...J?.additionalFields?.map((T) => T.key) ?? [],
785
+ ...H?.additionalFields?.map((T) => T.key) ?? [],
781
786
  ...P.additionalFields?.map((T) => T.key) ?? []
782
787
  ];
783
788
  ft(D, q, P, d, Q, f, y);
784
789
  }).catch((D) => {
785
790
  console.error("Error loading export data", D), w(D);
786
791
  }).finally(() => A(!1));
787
- }, [N, I, ne, d, f, y]), Ne = b(() => {
792
+ }, [N, O, ne, d, f, y]), Oe = x(() => {
788
793
  ae(g, o), X();
789
794
  }, [ae, g, o, X]);
790
795
  return /* @__PURE__ */ p($, { children: [
791
- /* @__PURE__ */ s(te, { title: "Export", children: /* @__PURE__ */ s(ee, { color: "primary", onClick: k, children: /* @__PURE__ */ s(qe, {}) }) }),
796
+ /* @__PURE__ */ s(te, { title: "Export", children: /* @__PURE__ */ s(ee, { color: "primary", onClick: F, children: /* @__PURE__ */ s(qe, {}) }) }),
792
797
  /* @__PURE__ */ p(
793
- ye,
798
+ be,
794
799
  {
795
800
  open: G,
796
- onOpenChange: x,
801
+ onOpenChange: b,
797
802
  maxWidth: "xl",
798
803
  children: [
799
804
  /* @__PURE__ */ p(xe, { className: "flex flex-col gap-4 my-4", children: [
@@ -916,12 +921,12 @@ function yt({
916
921
  label: "Flatten arrays"
917
922
  }
918
923
  ),
919
- !H && a
924
+ !R && a
920
925
  ] }),
921
- /* @__PURE__ */ p(be, { children: [
922
- O && /* @__PURE__ */ s(ge, { size: "small" }),
926
+ /* @__PURE__ */ p(ve, { children: [
927
+ I && /* @__PURE__ */ s(ye, { size: "small" }),
923
928
  /* @__PURE__ */ s(
924
- F,
929
+ k,
925
930
  {
926
931
  onClick: X,
927
932
  variant: "text",
@@ -929,11 +934,11 @@ function yt({
929
934
  }
930
935
  ),
931
936
  /* @__PURE__ */ s(
932
- F,
937
+ k,
933
938
  {
934
939
  variant: "filled",
935
- onClick: Ne,
936
- disabled: O || !H,
940
+ onClick: Oe,
941
+ disabled: I || !R,
937
942
  children: "Download"
938
943
  }
939
944
  )
@@ -944,7 +949,7 @@ function yt({
944
949
  ] });
945
950
  }
946
951
  function St(e) {
947
- return Oe(() => ({
952
+ return Ae(() => ({
948
953
  name: "Import/Export",
949
954
  collections: {
950
955
  CollectionActions: [ct, yt],
@@ -959,11 +964,11 @@ export {
959
964
  lt as ImportSaveInProgress,
960
965
  rt as convertDataToEntity,
961
966
  et as convertFileToJson,
962
- Ce as flattenEntry,
967
+ we as flattenEntry,
963
968
  nt as getInferenceType,
964
969
  at as getPropertiesMapping,
965
970
  Z as processValueMapping,
966
- ve as unflattenObject,
971
+ Ce as unflattenObject,
967
972
  Ke as useImportConfig,
968
973
  St as useImportExportPlugin
969
974
  };