@firecms/data_import_export 3.0.0-canary.49 → 3.0.0-canary.50

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,17 +1,17 @@
1
1
  import y, { useState as S, useRef as Je, useEffect as De, useCallback as v, useMemo as He } from "react";
2
2
  import { jsxs as p, Fragment as M, jsx as i } from "react/jsx-runtime";
3
3
  import { getPropertyInPath as J, mergeDeep as Ve, resolveProperty as ze, isPropertyBuilder as ue, EntityReference as Ue, useSnackbarController as Ne, useCustomizationController as G, getFieldConfig as Se, ErrorBoundary as We, PropertyConfigBadge as Oe, useDataSource as ke, resolveCollection as Ie, getPropertiesWithPropertiesOrder as Xe, useSelectionController as Ge, EntityCollectionTable as Ye, slugify as qe, getArrayValuesCount as Qe, getValueInPath as Ze, useFireCMSContext as Ke, useNavigationController as et } from "@firecms/core";
4
- import { Table as me, TableHeader as fe, TableCell as w, TableBody as he, TableRow as ge, Typography as f, ChevronRightIcon as xe, ExpandablePanel as tt, Select as _e, SelectItem as H, TextField as re, BooleanSwitchWithLabel as se, DateTimeField as rt, FileUpload as at, UploadIcon as nt, IconButton as Y, EditIcon as st, CenteredView as ye, Button as O, CircularProgress as Ae, Tooltip as q, FileUploadIcon as it, Dialog as ie, DialogContent as le, DialogActions as oe, cn as k, defaultBorderMixin as lt, GetAppIcon as Ee, Alert as ot, focusedMixin as _ } from "@firecms/ui";
4
+ import { Table as me, TableHeader as fe, TableCell as w, TableBody as he, TableRow as ge, Typography as f, ChevronRightIcon as xe, ExpandablePanel as tt, Select as _e, SelectItem as H, TextField as re, BooleanSwitchWithLabel as se, DateTimeField as rt, FileUpload as nt, UploadIcon as at, IconButton as Y, EditIcon as st, CenteredView as ye, Button as O, CircularProgress as Ae, Tooltip as q, FileUploadIcon as it, Dialog as ie, DialogContent as le, DialogActions as oe, cn as k, defaultBorderMixin as lt, GetAppIcon as Ee, Alert as ot, focusedMixin as _ } from "@firecms/ui";
5
5
  import { inferTypeFromValue as ct, buildEntityPropertiesFromData as dt } from "@firecms/schema_inference";
6
6
  import * as V from "xlsx";
7
7
  import { getIn as Te, setIn as pt } from "@firecms/formex";
8
8
  const ut = () => {
9
- const [e, a] = S(!1), [s, t] = S({}), [r, n] = S(), [l, o] = S([]), [c, d] = S([]), [u, m] = S({}), [h, g] = S([]), [x, R] = S({});
9
+ const [e, n] = S(!1), [s, t] = S({}), [r, a] = S(), [l, o] = S([]), [c, d] = S([]), [u, m] = S({}), [h, g] = S([]), [x, R] = S({});
10
10
  return {
11
11
  inUse: e,
12
- setInUse: a,
12
+ setInUse: n,
13
13
  idColumn: r,
14
- setIdColumn: n,
14
+ setIdColumn: a,
15
15
  entities: c,
16
16
  setEntities: d,
17
17
  importData: l,
@@ -27,27 +27,27 @@ const ut = () => {
27
27
  };
28
28
  };
29
29
  function mt(e) {
30
- let a = 0;
30
+ let n = 0;
31
31
  const s = [], t = {};
32
32
  if (e == null || e["!ref"] == null)
33
33
  return [];
34
34
  const r = t.range !== void 0 ? t.range : e["!ref"];
35
- let n;
36
- switch (t.header === 1 ? a = 1 : t.header === "A" ? a = 2 : Array.isArray(t.header) && (a = 3), typeof r) {
35
+ let a;
36
+ switch (t.header === 1 ? n = 1 : t.header === "A" ? n = 2 : Array.isArray(t.header) && (n = 3), typeof r) {
37
37
  case "string":
38
- n = be(r);
38
+ a = be(r);
39
39
  break;
40
40
  case "number":
41
- n = be(e["!ref"]), n.s.r = r;
41
+ a = be(e["!ref"]), a.s.r = r;
42
42
  break;
43
43
  default:
44
- n = r;
44
+ a = r;
45
45
  }
46
- const l = V.utils.encode_row(n.s.r), o = new Array(n.e.c - n.s.c + 1);
47
- for (let c = n.s.c; c <= n.e.c; ++c) {
46
+ const l = V.utils.encode_row(a.s.r), o = new Array(a.e.c - a.s.c + 1);
47
+ for (let c = a.s.c; c <= a.e.c; ++c) {
48
48
  o[c] = V.utils.encode_col(c);
49
49
  const d = e[o[c] + l];
50
- switch (a) {
50
+ switch (n) {
51
51
  case 1:
52
52
  s.push(c);
53
53
  break;
@@ -55,7 +55,7 @@ function mt(e) {
55
55
  s.push(o[c]);
56
56
  break;
57
57
  case 3:
58
- s.push(t.header[c - n.s.c]);
58
+ s.push(t.header[c - a.s.c]);
59
59
  break;
60
60
  default:
61
61
  if (d === void 0)
@@ -66,7 +66,7 @@ function mt(e) {
66
66
  return s;
67
67
  }
68
68
  function be(e) {
69
- const a = {
69
+ const n = {
70
70
  s: {
71
71
  c: 0,
72
72
  r: 0
@@ -77,50 +77,50 @@ function be(e) {
77
77
  }
78
78
  };
79
79
  let s = 0, t = 0, r = 0;
80
- const n = e.length;
81
- for (s = 0; t < n && !((r = e.charCodeAt(t) - 64) < 1 || r > 26); ++t)
80
+ const a = e.length;
81
+ for (s = 0; t < a && !((r = e.charCodeAt(t) - 64) < 1 || r > 26); ++t)
82
82
  s = 26 * s + r;
83
- for (a.s.c = --s, s = 0; t < n && !((r = e.charCodeAt(t) - 48) < 0 || r > 9); ++t)
83
+ for (n.s.c = --s, s = 0; t < a && !((r = e.charCodeAt(t) - 48) < 0 || r > 9); ++t)
84
84
  s = 10 * s + r;
85
- if (a.s.r = --s, t === n || e.charCodeAt(++t) === 58)
86
- return a.e.c = a.s.c, a.e.r = a.s.r, a;
87
- for (s = 0; t !== n && !((r = e.charCodeAt(t) - 64) < 1 || r > 26); ++t)
85
+ if (n.s.r = --s, t === a || e.charCodeAt(++t) === 58)
86
+ return n.e.c = n.s.c, n.e.r = n.s.r, n;
87
+ for (s = 0; t !== a && !((r = e.charCodeAt(t) - 64) < 1 || r > 26); ++t)
88
88
  s = 26 * s + r;
89
- for (a.e.c = --s, s = 0; t !== n && !((r = e.charCodeAt(t) - 48) < 0 || r > 9); ++t)
89
+ for (n.e.c = --s, s = 0; t !== a && !((r = e.charCodeAt(t) - 48) < 0 || r > 9); ++t)
90
90
  s = 10 * s + r;
91
- return a.e.r = --s, a;
91
+ return n.e.r = --s, n;
92
92
  }
93
93
  function ft(e) {
94
- return new Promise((a, s) => {
94
+ return new Promise((n, s) => {
95
95
  if (e.type === "application/json") {
96
96
  console.debug("Converting JSON file to JSON", e.name);
97
97
  const t = new FileReader();
98
98
  t.onload = function(r) {
99
99
  try {
100
- const n = r.target?.result, l = JSON.parse(n);
100
+ const a = r.target?.result, l = JSON.parse(a);
101
101
  if (!Array.isArray(l))
102
102
  s(new Error("JSON file should contain an array of objects"));
103
103
  else {
104
104
  const o = l.length > 0 ? Object.keys(l[0]) : [];
105
- a({
105
+ n({
106
106
  data: l,
107
107
  propertiesOrder: o
108
108
  });
109
109
  }
110
- } catch (n) {
111
- console.error("Error parsing JSON file", n), s(n);
110
+ } catch (a) {
111
+ console.error("Error parsing JSON file", a), s(a);
112
112
  }
113
113
  }, t.readAsText(e);
114
114
  } else {
115
115
  console.debug("Converting Excel file to JSON", e.name);
116
116
  const t = new FileReader();
117
117
  t.onload = function(r) {
118
- const n = new Uint8Array(r.target?.result), l = V.read(n, {
118
+ const a = new Uint8Array(r.target?.result), l = V.read(a, {
119
119
  type: "array",
120
120
  codepage: 65001,
121
121
  cellDates: !0
122
122
  }), o = l.SheetNames[0], c = l.Sheets[o], d = V.utils.sheet_to_json(c), u = mt(c), h = d.map(ht).map(je);
123
- a({
123
+ n({
124
124
  data: h,
125
125
  propertiesOrder: u
126
126
  });
@@ -129,70 +129,70 @@ function ft(e) {
129
129
  });
130
130
  }
131
131
  function ht(e) {
132
- return Object.keys(e).reduce((a, s) => {
132
+ return Object.keys(e).reduce((n, s) => {
133
133
  try {
134
- a[s] = JSON.parse(e[s]);
134
+ n[s] = JSON.parse(e[s]);
135
135
  } catch {
136
- a[s] = e[s];
136
+ n[s] = e[s];
137
137
  }
138
- return a;
138
+ return n;
139
139
  }, {});
140
140
  }
141
141
  function je(e) {
142
- return Object.keys(e).reduce((a, s) => {
143
- let t = a;
142
+ return Object.keys(e).reduce((n, s) => {
143
+ let t = n;
144
144
  const r = s.split(".");
145
- return r.forEach((n, l) => {
146
- if (/^[\w]+\[\d+\]$/.test(n)) {
147
- const o = n.slice(0, n.indexOf("[")), c = parseInt(n.slice(n.indexOf("[") + 1, n.indexOf("]")));
145
+ return r.forEach((a, l) => {
146
+ if (/^[\w]+\[\d+\]$/.test(a)) {
147
+ const o = a.slice(0, a.indexOf("[")), c = parseInt(a.slice(a.indexOf("[") + 1, a.indexOf("]")));
148
148
  t[o] || (t[o] = []), l !== r.length - 1 ? (t[o][c] = t[o][c] || {}, t = t[o][c]) : t[o][c] = e[s];
149
149
  } else
150
- l !== r.length - 1 ? (t[n] = t[n] || {}, t = t[n]) : t[n] = e[s];
151
- }), a;
150
+ l !== r.length - 1 ? (t[a] = t[a] || {}, t = t[a]) : t[a] = e[s];
151
+ }), n;
152
152
  }, {});
153
153
  }
154
- function gt(e, a, s, t, r, n) {
154
+ function gt(e, n, s, t, r, a) {
155
155
  const l = Fe(e);
156
- a && delete l[a];
156
+ n && delete l[n];
157
157
  const o = Object.entries(l).map(([u, m]) => {
158
158
  const h = Te(s, u) ?? u, g = J(t, h);
159
159
  if (!g)
160
160
  return {};
161
- const x = ae(m, g);
161
+ const x = ne(m, g);
162
162
  return {
163
163
  [h]: x
164
164
  };
165
- }).reduce((u, m) => ({ ...u, ...m }), {}), c = Ve(n ?? {}, je(o));
166
- let d = a ? e[a] : void 0;
165
+ }).reduce((u, m) => ({ ...u, ...m }), {}), c = Ve(a ?? {}, je(o));
166
+ let d = n ? e[n] : void 0;
167
167
  return typeof d == "string" ? d = d.trim() : typeof d == "number" || typeof d == "boolean" ? d = d.toString() : d instanceof Date ? d = d.toISOString() : d && "toString" in d && (d = d.toString()), {
168
168
  id: d,
169
169
  values: c,
170
170
  path: r
171
171
  };
172
172
  }
173
- function Fe(e, a = "") {
173
+ function Fe(e, n = "") {
174
174
  return Object.keys(e).reduce((s, t) => {
175
- const r = a ? `${a}.${t}` : t;
175
+ const r = n ? `${n}.${t}` : t;
176
176
  return typeof e[t] == "object" && !(e[t] instanceof Date) && e[t] !== null && !Array.isArray(e[t]) ? Object.assign(s, Fe(e[t], r)) : s[r] = e[t], s;
177
177
  }, {});
178
178
  }
179
- function ae(e, a) {
179
+ function ne(e, n) {
180
180
  if (e === null)
181
181
  return null;
182
- if (a === void 0)
182
+ if (n === void 0)
183
183
  return e;
184
184
  const s = ze({
185
- propertyOrBuilder: a
185
+ propertyOrBuilder: n
186
186
  });
187
187
  if (s === null)
188
188
  return e;
189
189
  const t = ct(e), r = s.dataType;
190
190
  if (t === "array" && r === "array" && Array.isArray(e) && s.of && !ue(s.of))
191
- return e.map((n) => ae(n, s.of));
191
+ return e.map((a) => ne(a, s.of));
192
192
  if (t === "string" && r === "number" && typeof e == "string")
193
193
  return Number(e);
194
194
  if (t === "string" && r === "array" && typeof e == "string" && s.of && !ue(s.of))
195
- return e.split(",").map((n) => ae(n, s.of));
195
+ return e.split(",").map((a) => ne(a, s.of));
196
196
  if (t === "string" && r === "boolean")
197
197
  return e === "true";
198
198
  if (t === "number" && r === "boolean")
@@ -204,7 +204,7 @@ function ae(e, a) {
204
204
  if (t === "number" && r === "string" && typeof e == "number")
205
205
  return e.toString();
206
206
  if (t === "string" && r === "array" && typeof e == "string")
207
- return e.split(",").map((n) => n.trim());
207
+ return e.split(",").map((a) => a.trim());
208
208
  if (t === "string" && r === "date" && typeof e == "string")
209
209
  try {
210
210
  return new Date(e);
@@ -221,8 +221,8 @@ function ae(e, a) {
221
221
  return e;
222
222
  }
223
223
  else if (t === "string" && r === "reference" && typeof e == "string") {
224
- const n = e.split("/").slice(0, -1).join("/"), l = e.split("/").slice(-1)[0];
225
- return new Ue(l, n);
224
+ const a = e.split("/").slice(0, -1).join("/"), l = e.split("/").slice(-1)[0];
225
+ return new Ue(l, a);
226
226
  } else {
227
227
  if (t === r)
228
228
  return e;
@@ -237,15 +237,15 @@ function xt(e) {
237
237
  }
238
238
  function yt({
239
239
  importConfig: e,
240
- destinationProperties: a,
240
+ destinationProperties: n,
241
241
  buildPropertyView: s
242
242
  }) {
243
- const t = e.headersMapping, r = e.headingsOrder, n = e.idColumn, l = e.originProperties;
243
+ const t = e.headersMapping, r = e.headingsOrder, a = e.idColumn, l = e.originProperties;
244
244
  return /* @__PURE__ */ p(M, { children: [
245
245
  /* @__PURE__ */ i(
246
246
  bt,
247
247
  {
248
- idColumn: n,
248
+ idColumn: a,
249
249
  headersMapping: t,
250
250
  onChange: (o) => e.setIdColumn(o ?? void 0)
251
251
  }
@@ -259,9 +259,9 @@ function yt({
259
259
  /* @__PURE__ */ i(w, { header: !0 }),
260
260
  /* @__PURE__ */ i(w, { header: !0, style: { width: "75%" }, children: "Map to Property" })
261
261
  ] }),
262
- /* @__PURE__ */ i(he, { children: a && r.map(
262
+ /* @__PURE__ */ i(he, { children: n && r.map(
263
263
  (o) => {
264
- const c = t[o], d = t[o], u = c ? J(a, c) : null, m = J(l, o), h = m ? m.dataType === "array" && typeof m.of == "object" ? `${m.dataType} - ${m.of.dataType}` : m.dataType : void 0;
264
+ const c = t[o], d = t[o], u = c ? J(n, c) : null, m = J(l, o), h = m ? m.dataType === "array" && typeof m.of == "object" ? `${m.dataType} - ${m.of.dataType}` : m.dataType : void 0;
265
265
  return /* @__PURE__ */ p(ge, { style: { height: "90px" }, children: [
266
266
  /* @__PURE__ */ p(w, { style: { width: "20%" }, children: [
267
267
  /* @__PURE__ */ i(f, { variant: "body2", children: o }),
@@ -278,10 +278,10 @@ function yt({
278
278
  /* @__PURE__ */ i(
279
279
  w,
280
280
  {
281
- className: o === n ? "text-center" : void 0,
281
+ className: o === a ? "text-center" : void 0,
282
282
  style: { width: "75%" },
283
283
  children: s?.({
284
- isIdColumn: o === n,
284
+ isIdColumn: o === a,
285
285
  property: u,
286
286
  propertyKey: d,
287
287
  importKey: o
@@ -302,16 +302,16 @@ function yt({
302
302
  /* @__PURE__ */ i(w, { header: !0 }),
303
303
  /* @__PURE__ */ i(w, { header: !0, style: { width: "65%" }, children: "Default value" })
304
304
  ] }),
305
- /* @__PURE__ */ i(he, { children: a && Pe(a).map(
305
+ /* @__PURE__ */ i(he, { children: n && Pe(n).map(
306
306
  (o) => {
307
- const c = J(a, o);
307
+ const c = J(n, o);
308
308
  return typeof c != "object" || c === null || !["number", "string", "boolean", "map"].includes(c.dataType) ? null : /* @__PURE__ */ p(ge, { style: { height: "70px" }, children: [
309
309
  /* @__PURE__ */ i(w, { style: { width: "20%" }, children: /* @__PURE__ */ i(f, { variant: "body2", children: o }) }),
310
310
  /* @__PURE__ */ i(w, { children: /* @__PURE__ */ i(xe, {}) }),
311
311
  /* @__PURE__ */ i(
312
312
  w,
313
313
  {
314
- className: o === n ? "text-center" : void 0,
314
+ className: o === a ? "text-center" : void 0,
315
315
  style: { width: "75%" },
316
316
  children: /* @__PURE__ */ i(
317
317
  vt,
@@ -333,19 +333,19 @@ function yt({
333
333
  ] })
334
334
  ] });
335
335
  }
336
- function Pe(e, a) {
336
+ function Pe(e, n) {
337
337
  return Object.entries(e).reduce((s, [t, r]) => {
338
- const n = a ? `${a}.${t}` : t;
338
+ const a = n ? `${n}.${t}` : t;
339
339
  if (typeof r != "function" && r.dataType === "map" && r.properties) {
340
- const l = Pe(r.properties, n);
340
+ const l = Pe(r.properties, a);
341
341
  return [...s, ...l];
342
342
  }
343
- return [...s, n];
343
+ return [...s, a];
344
344
  }, []);
345
345
  }
346
346
  function bt({
347
347
  idColumn: e,
348
- headersMapping: a,
348
+ headersMapping: n,
349
349
  onChange: s
350
350
  }) {
351
351
  return /* @__PURE__ */ i("div", { children: /* @__PURE__ */ p(
@@ -362,14 +362,14 @@ function bt({
362
362
  label: "Column that will be used as ID for each document",
363
363
  children: [
364
364
  /* @__PURE__ */ i(H, { value: "__none__", children: "Autogenerate ID" }),
365
- Object.entries(a).map(([t, r]) => /* @__PURE__ */ i(H, { value: t, children: t }, t))
365
+ Object.entries(n).map(([t, r]) => /* @__PURE__ */ i(H, { value: t, children: t }, t))
366
366
  ]
367
367
  }
368
368
  ) });
369
369
  }
370
370
  function vt({
371
371
  property: e,
372
- onValueChange: a,
372
+ onValueChange: n,
373
373
  defaultValue: s
374
374
  }) {
375
375
  return e.dataType === "string" ? /* @__PURE__ */ i(
@@ -378,7 +378,7 @@ function vt({
378
378
  size: "small",
379
379
  placeholder: "Default value",
380
380
  value: s ?? "",
381
- onChange: (t) => a(t.target.value)
381
+ onChange: (t) => n(t.target.value)
382
382
  }
383
383
  ) : e.dataType === "number" ? /* @__PURE__ */ i(
384
384
  re,
@@ -387,7 +387,7 @@ function vt({
387
387
  type: "number",
388
388
  value: s ?? "",
389
389
  placeholder: "Default value",
390
- onChange: (t) => a(t.target.value)
390
+ onChange: (t) => n(t.target.value)
391
391
  }
392
392
  ) : e.dataType === "boolean" ? /* @__PURE__ */ i(
393
393
  se,
@@ -395,7 +395,7 @@ function vt({
395
395
  value: s ?? null,
396
396
  allowIndeterminate: !0,
397
397
  size: "small",
398
- onValueChange: (t) => a(t === null ? void 0 : t),
398
+ onValueChange: (t) => n(t === null ? void 0 : t),
399
399
  label: s === void 0 ? "Do not set value" : s === !0 ? "Set value to true" : "Set value to false"
400
400
  }
401
401
  ) : e.dataType === "date" ? /* @__PURE__ */ i(
@@ -405,16 +405,16 @@ function vt({
405
405
  size: "small",
406
406
  value: s ?? void 0,
407
407
  onChange: (t) => {
408
- a(t);
408
+ n(t);
409
409
  },
410
410
  clearable: !0
411
411
  }
412
412
  ) : null;
413
413
  }
414
414
  function Ct({ onDataAdded: e }) {
415
- const a = Ne();
415
+ const n = Ne();
416
416
  return /* @__PURE__ */ i(
417
- at,
417
+ nt,
418
418
  {
419
419
  accept: {
420
420
  "text/*": [".csv", ".xls", ".xlsx"],
@@ -430,7 +430,7 @@ function Ct({ onDataAdded: e }) {
430
430
  size: "small",
431
431
  maxFiles: 1,
432
432
  uploadDescription: /* @__PURE__ */ p(M, { children: [
433
- /* @__PURE__ */ i(nt, {}),
433
+ /* @__PURE__ */ i(at, {}),
434
434
  "Drag and drop a file here or click to upload"
435
435
  ] }),
436
436
  onFilesAdded: (s) => {
@@ -440,7 +440,7 @@ function Ct({ onDataAdded: e }) {
440
440
  }) => {
441
441
  e(t, r);
442
442
  }).catch((t) => {
443
- console.error("Error parsing file", t), a.open({
443
+ console.error("Error parsing file", t), n.open({
444
444
  type: "error",
445
445
  message: t.message
446
446
  });
@@ -451,26 +451,26 @@ function Ct({ onDataAdded: e }) {
451
451
  }
452
452
  function Rt({
453
453
  propertyKey: e,
454
- property: a,
454
+ property: n,
455
455
  onEditClick: s,
456
456
  includeName: t = !0,
457
457
  onPropertyNameChanged: r,
458
- propertyTypeView: n
458
+ propertyTypeView: a
459
459
  }) {
460
- const { propertyConfigs: l } = G(), o = a ? Se(a, l) : null;
460
+ const { propertyConfigs: l } = G(), o = n ? Se(n, l) : null;
461
461
  return /* @__PURE__ */ i(We, { children: /* @__PURE__ */ p(
462
462
  "div",
463
463
  {
464
464
  className: "flex flex-row w-full items-center",
465
465
  children: [
466
- /* @__PURE__ */ i("div", { className: "mx-4", children: n ?? /* @__PURE__ */ i(Oe, { propertyConfig: o ?? void 0 }) }),
466
+ /* @__PURE__ */ i("div", { className: "mx-4", children: a ?? /* @__PURE__ */ i(Oe, { propertyConfig: o ?? void 0 }) }),
467
467
  /* @__PURE__ */ i("div", { className: "w-full flex flex-col grow", children: /* @__PURE__ */ p("div", { className: "flex flex-row items-center gap-2", children: [
468
468
  t && /* @__PURE__ */ i(
469
469
  re,
470
470
  {
471
471
  size: "small",
472
472
  className: "text-base grow",
473
- value: a?.name ?? "",
473
+ value: n?.name ?? "",
474
474
  onChange: (c) => {
475
475
  r && e && r(e, c.target.value);
476
476
  }
@@ -484,24 +484,24 @@ function Rt({
484
484
  }
485
485
  function wt({
486
486
  path: e,
487
- importConfig: a,
487
+ importConfig: n,
488
488
  collection: s,
489
489
  onImportSuccess: t
490
490
  }) {
491
- const [r, n] = S(void 0), l = ke(), o = Je(!1), [c, d] = S(0);
491
+ const [r, a] = S(void 0), l = ke(), o = Je(!1), [c, d] = S(0);
492
492
  function u() {
493
493
  o.current || (o.current = !0, Me(
494
494
  l,
495
495
  s,
496
496
  e,
497
- a.entities,
497
+ n.entities,
498
498
  0,
499
499
  25,
500
500
  d
501
501
  ).then(() => {
502
502
  t(s), o.current = !1;
503
503
  }).catch((m) => {
504
- n(m), o.current = !1;
504
+ a(m), o.current = !1;
505
505
  }));
506
506
  }
507
507
  return De(() => {
@@ -523,30 +523,30 @@ function wt({
523
523
  /* @__PURE__ */ p(f, { variant: "body2", children: [
524
524
  c,
525
525
  "/",
526
- a.entities.length,
526
+ n.entities.length,
527
527
  " entities saved"
528
528
  ] }),
529
529
  /* @__PURE__ */ i(f, { variant: "caption", children: "Do not close this tab or the import will be interrupted." })
530
530
  ] });
531
531
  }
532
- function Me(e, a, s, t, r = 0, n = 25, l) {
533
- console.debug("Saving imported data", r, n);
534
- const o = t.slice(r, r + n);
532
+ function Me(e, n, s, t, r = 0, a = 25, l) {
533
+ console.debug("Saving imported data", r, a);
534
+ const o = t.slice(r, r + a);
535
535
  return Promise.all(o.map((c) => e.saveEntity({
536
536
  path: s,
537
537
  values: c.values,
538
538
  entityId: c.id,
539
- collection: a,
539
+ collection: n,
540
540
  status: "new"
541
- }))).then(() => r + n < t.length ? (l(r + n), Me(e, a, s, t, r + n, n, l)) : (l(t.length), Promise.resolve()));
541
+ }))).then(() => r + a < t.length ? (l(r + a), Me(e, n, s, t, r + a, a, l)) : (l(t.length), Promise.resolve()));
542
542
  }
543
543
  function Dt({
544
544
  collection: e,
545
- path: a,
545
+ path: n,
546
546
  collectionEntitiesCount: s,
547
547
  onAnalyticsEvent: t
548
548
  }) {
549
- const r = G(), n = Ne(), [l, o] = y.useState(!1), [c, d] = y.useState("initial"), u = ut(), m = v(() => {
549
+ const r = G(), a = Ne(), [l, o] = y.useState(!1), [c, d] = y.useState("initial"), u = ut(), m = v(() => {
550
550
  o(!0), t?.("import_open"), d("initial");
551
551
  }, [t]), h = v(() => {
552
552
  o(!1);
@@ -568,7 +568,7 @@ function Dt({
568
568
  }, 100);
569
569
  }, A = Ie({
570
570
  collection: e,
571
- path: a,
571
+ path: n,
572
572
  fields: r.propertyConfigs
573
573
  }), L = Xe(A.properties, A.propertiesOrder), E = Object.entries(L).flatMap(([b, T]) => Re(b, T, 0)), z = A.propertiesOrder ?? Object.keys(A.properties);
574
574
  return e.collectionGroup ? null : /* @__PURE__ */ p(M, { children: [
@@ -632,9 +632,9 @@ function Dt({
632
632
  {
633
633
  importConfig: u,
634
634
  collection: e,
635
- path: a,
635
+ path: n,
636
636
  onImportSuccess: (b) => {
637
- h(), n.open({
637
+ h(), a.open({
638
638
  type: "info",
639
639
  message: "Data imported successfully"
640
640
  });
@@ -692,13 +692,13 @@ function Dt({
692
692
  const W = "__internal_id__";
693
693
  function Nt({
694
694
  selectedPropertyKey: e,
695
- properties: a,
695
+ properties: n,
696
696
  onPropertySelected: s,
697
697
  onIdSelected: t,
698
698
  propertiesAndLevel: r,
699
- isIdColumn: n
699
+ isIdColumn: a
700
700
  }) {
701
- const l = e ? J(a, e) : null, o = v((d) => d === W ? /* @__PURE__ */ i(f, { variant: "body2", className: "p-4", children: "Use this column as ID" }) : !d || !l ? /* @__PURE__ */ i(f, { variant: "body2", color: "disabled", className: "p-4", children: "Do not import this property" }) : /* @__PURE__ */ i(
701
+ const l = e ? J(n, e) : null, o = v((d) => d === W ? /* @__PURE__ */ i(f, { variant: "body2", className: "p-4", children: "Use this column as ID" }) : !d || !l ? /* @__PURE__ */ i(f, { variant: "body2", color: "disabled", className: "p-4", children: "Do not import this property" }) : /* @__PURE__ */ i(
702
702
  ve,
703
703
  {
704
704
  propertyKey: d,
@@ -708,7 +708,7 @@ function Nt({
708
708
  return /* @__PURE__ */ p(
709
709
  _e,
710
710
  {
711
- value: n ? W : e ?? void 0,
711
+ value: a ? W : e ?? void 0,
712
712
  onValueChange: (d) => {
713
713
  d === W ? (t(), s(null)) : s(d === "__do_not_import" ? null : d);
714
714
  },
@@ -740,28 +740,28 @@ function Nt({
740
740
  }
741
741
  );
742
742
  }
743
- function Re(e, a, s) {
743
+ function Re(e, n, s) {
744
744
  const t = [];
745
745
  return t.push({
746
- property: a,
746
+ property: n,
747
747
  level: s,
748
748
  propertyKey: e
749
- }), a.dataType === "map" && a.properties && Object.entries(a.properties).forEach(([r, n]) => {
750
- t.push(...Re(`${e}.${r}`, n, s + 1));
749
+ }), n.dataType === "map" && n.properties && Object.entries(n.properties).forEach(([r, a]) => {
750
+ t.push(...Re(`${e}.${r}`, a, s + 1));
751
751
  }), t;
752
752
  }
753
753
  function ve({
754
754
  propertyKey: e,
755
- property: a,
755
+ property: n,
756
756
  level: s = 0
757
757
  }) {
758
- const { propertyConfigs: t } = G(), r = Se(a, t);
758
+ const { propertyConfigs: t } = G(), r = Se(n, t);
759
759
  return /* @__PURE__ */ p(
760
760
  "div",
761
761
  {
762
762
  className: "flex flex-row w-full text-start items-center h-full",
763
763
  children: [
764
- new Array(s).fill(0).map((n, l) => /* @__PURE__ */ i("div", { className: k(lt, "ml-8 border-l h-12") }, l)),
764
+ new Array(s).fill(0).map((a, l) => /* @__PURE__ */ i("div", { className: k(lt, "ml-8 border-l h-12") }, l)),
765
765
  /* @__PURE__ */ i("div", { className: "m-4", children: /* @__PURE__ */ i(q, { title: r?.name, children: /* @__PURE__ */ i(Oe, { propertyConfig: r }) }) }),
766
766
  /* @__PURE__ */ p("div", { className: "flex flex-col flex-grow p-2 pl-2", children: [
767
767
  /* @__PURE__ */ i(
@@ -770,7 +770,7 @@ function ve({
770
770
  variant: "body1",
771
771
  component: "span",
772
772
  className: "flex-grow pr-2",
773
- children: a.name ? a.name : " "
773
+ children: n.name ? n.name : " "
774
774
  }
775
775
  ),
776
776
  /* @__PURE__ */ i(
@@ -790,15 +790,12 @@ function ve({
790
790
  }
791
791
  function St({
792
792
  importConfig: e,
793
- properties: a,
793
+ properties: n,
794
794
  propertiesOrder: s
795
795
  }) {
796
796
  De(() => {
797
- const r = e.importData.map((n) => gt(n, e.idColumn, e.headersMapping, a, "TEMP_PATH", e.defaultValues));
798
- console.log("Mapped data", {
799
- importConfig: e,
800
- mappedData: r
801
- }), e.setEntities(r);
797
+ const r = e.importData.map((a) => gt(a, e.idColumn, e.headersMapping, n, "TEMP_PATH", e.defaultValues));
798
+ e.setEntities(r);
802
799
  }, []);
803
800
  const t = Ge();
804
801
  return /* @__PURE__ */ i(
@@ -818,128 +815,128 @@ function St({
818
815
  filterable: !1,
819
816
  sortable: !1,
820
817
  selectionController: t,
821
- properties: a
818
+ properties: n
822
819
  }
823
820
  );
824
821
  }
825
- function $e(e, a) {
822
+ function $e(e, n) {
826
823
  const s = {};
827
824
  return e.filter(Boolean).forEach((t) => {
828
825
  Object.keys(t).forEach((r) => {
829
- const n = t[r];
830
- if (typeof n == "object" && !Array.isArray(n)) {
831
- const l = a?.[r], o = l && "properties" in l ? l.properties : void 0, c = $e([n], o);
826
+ const a = t[r];
827
+ if (typeof a == "object" && !Array.isArray(a)) {
828
+ const l = n?.[r], o = l && "properties" in l ? l.properties : void 0, c = $e([a], o);
832
829
  Object.entries(c).forEach(([d, u]) => {
833
830
  s[`${r}.${d}`] = `${r}.${u}`;
834
831
  });
835
832
  }
836
- if (!a)
833
+ if (!n)
837
834
  s[r] = r;
838
- else if (r in a)
835
+ else if (r in n)
839
836
  s[r] = r;
840
837
  else {
841
838
  const l = qe(r);
842
- l in a ? s[r] = l : s[r] = r;
839
+ l in n ? s[r] = l : s[r] = r;
843
840
  }
844
841
  });
845
842
  }), s;
846
843
  }
847
- function Be(e, a, s, t, r, n, l, o, c) {
844
+ function Be(e, n, s, t, r, a, l, o, c) {
848
845
  if (console.debug("Downloading export", {
849
846
  dataLength: e.length,
850
847
  properties: s,
851
848
  exportType: o,
852
849
  dateExportType: c
853
850
  }), o === "csv") {
854
- const d = n ? Qe(e.map((x) => x.values)) : {}, u = It(s, t, l, d), m = Ot(e, a, s, u, c), h = Ce(u.map((x) => x.label)), g = m.map((x) => Ce(x));
851
+ const d = a ? Qe(e.map((x) => x.values)) : {}, u = It(s, t, l, d), m = Ot(e, n, s, u, c), h = Ce(u.map((x) => x.label)), g = m.map((x) => Ce(x));
855
852
  we([h, ...g], `${r}.csv`, "text/csv");
856
853
  } else {
857
- const d = kt(e, a, s, c), u = JSON.stringify(d, null, 2);
854
+ const d = kt(e, n, s, c), u = JSON.stringify(d, null, 2);
858
855
  we([u], `${r}.json`, "application/json");
859
856
  }
860
857
  }
861
- function Ot(e, a, s, t, r) {
862
- const n = e.map((l) => ({
858
+ function Ot(e, n, s, t, r) {
859
+ const a = e.map((l) => ({
863
860
  id: l.id,
864
861
  ...ce(l.values, s, "csv", r)
865
862
  }));
866
- return a && a.forEach((l, o) => {
867
- n[o] = { ...n[o], ...l };
868
- }), n && n.map((l) => t.map((o) => Ze(l, o.key)));
863
+ return n && n.forEach((l, o) => {
864
+ a[o] = { ...a[o], ...l };
865
+ }), a && a.map((l) => t.map((o) => Ze(l, o.key)));
869
866
  }
870
- function kt(e, a, s, t) {
871
- const r = e.map((n) => ({
872
- id: n.id,
873
- ...ce(n.values, s, "json", t)
867
+ function kt(e, n, s, t) {
868
+ const r = e.map((a) => ({
869
+ id: a.id,
870
+ ...ce(a.values, s, "json", t)
874
871
  }));
875
- return a && a.forEach((n, l) => {
876
- r[l] = { ...r[l], ...n };
872
+ return n && n.forEach((a, l) => {
873
+ r[l] = { ...r[l], ...a };
877
874
  }), r;
878
875
  }
879
- function It(e, a, s, t) {
876
+ function It(e, n, s, t) {
880
877
  const r = [
881
878
  {
882
879
  label: "id",
883
880
  key: "id"
884
881
  },
885
- ...(a ?? Object.keys(e)).flatMap((n) => {
886
- const l = e[n];
887
- return t && t[n] > 1 ? Array.from(
888
- { length: t[n] },
889
- (o, c) => ne(l, `${n}[${c}]`, "")
890
- ).flat() : ne(l, n, "");
882
+ ...(n ?? Object.keys(e)).flatMap((a) => {
883
+ const l = e[a];
884
+ return l ? t && t[a] > 1 ? Array.from(
885
+ { length: t[a] },
886
+ (o, c) => ae(l, `${a}[${c}]`, "")
887
+ ).flat() : ae(l, a, "") : (console.warn("Property not found", a, e), []);
891
888
  })
892
889
  ];
893
- return s && r.push(...s.map((n) => ({
894
- label: n,
895
- key: n
890
+ return s && r.push(...s.map((a) => ({
891
+ label: a,
892
+ key: a
896
893
  }))), r;
897
894
  }
898
- function ne(e, a, s = "") {
899
- const t = s ? `${s}.${a}` : a;
900
- return e.dataType === "map" && e.properties ? Object.entries(e.properties).map(([r, n]) => ne(n, r, t)).flat() : [{
895
+ function ae(e, n, s = "") {
896
+ const t = s ? `${s}.${n}` : n;
897
+ return e.dataType === "map" && e.properties ? Object.entries(e.properties).map(([r, a]) => ae(a, r, t)).flat() : [{
901
898
  label: t,
902
899
  key: t
903
900
  }];
904
901
  }
905
- function X(e, a, s, t) {
902
+ function X(e, n, s, t) {
906
903
  let r;
907
- if (a.dataType === "map" && a.properties)
908
- r = ce(e, a.properties, s, t);
909
- else if (a.dataType === "array")
910
- a.of && Array.isArray(e) ? Array.isArray(a.of) ? r = a.of.map((n, l) => X(e[l], n, s, t)) : a.of.dataType === "map" ? r = s === "csv" ? e.map((n) => JSON.stringify(n)) : e.map((n) => X(n, a.of, s, t)) : r = e.map((n) => X(n, a.of, s, t)) : r = e;
911
- else if (a.dataType === "reference" && e && e.isEntityReference && e.isEntityReference()) {
912
- const n = e || void 0;
913
- r = n ? n.pathWithId : null;
904
+ if (n.dataType === "map" && n.properties)
905
+ r = ce(e, n.properties, s, t);
906
+ else if (n.dataType === "array")
907
+ n.of && Array.isArray(e) ? Array.isArray(n.of) ? r = n.of.map((a, l) => X(e[l], a, s, t)) : n.of.dataType === "map" ? r = s === "csv" ? e.map((a) => JSON.stringify(a)) : e.map((a) => X(a, n.of, s, t)) : r = e.map((a) => X(a, n.of, s, t)) : r = e;
908
+ else if (n.dataType === "reference" && e && e.isEntityReference && e.isEntityReference()) {
909
+ const a = e || void 0;
910
+ r = a ? a.pathWithId : null;
914
911
  } else
915
- a.dataType === "date" && e instanceof Date ? r = e ? t === "timestamp" ? e.getTime() : e.toISOString() : null : r = e;
912
+ n.dataType === "date" && e instanceof Date ? r = e ? t === "timestamp" ? e.getTime() : e.toISOString() : null : r = e;
916
913
  return r;
917
914
  }
918
- function ce(e, a, s, t) {
919
- const r = Object.entries(a).map(([n, l]) => {
920
- const o = e && e[n], c = X(o, l, s, t);
921
- return c === void 0 ? {} : { [n]: c };
922
- }).reduce((n, l) => ({ ...n, ...l }), {});
915
+ function ce(e, n, s, t) {
916
+ const r = Object.entries(n).map(([a, l]) => {
917
+ const o = e && e[a], c = X(o, l, s, t);
918
+ return c === void 0 ? {} : { [a]: c };
919
+ }).reduce((a, l) => ({ ...a, ...l }), {});
923
920
  return { ...e, ...r };
924
921
  }
925
922
  function Ce(e) {
926
- return e.map((a) => a == null ? "" : Array.isArray(a) ? '"' + JSON.stringify(a).replaceAll('"', '\\"') + '"' : '"' + String(a).replaceAll('"', '""') + '"').join(",") + `\r
923
+ return e.map((n) => n == null ? "" : Array.isArray(n) ? '"' + JSON.stringify(n).replaceAll('"', '\\"') + '"' : '"' + String(n).replaceAll('"', '""') + '"').join(",") + `\r
927
924
  `;
928
925
  }
929
- function we(e, a, s) {
930
- const t = new Blob(e, { type: s }), r = URL.createObjectURL(t), n = document.createElement("a");
931
- n.href = r, n.setAttribute("download", a), n.click();
926
+ function we(e, n, s) {
927
+ const t = new Blob(e, { type: s }), r = URL.createObjectURL(t), a = document.createElement("a");
928
+ a.href = r, a.setAttribute("download", n), a.click();
932
929
  }
933
930
  const _t = 500;
934
931
  function At({
935
932
  collection: e,
936
- path: a,
933
+ path: n,
937
934
  collectionEntitiesCount: s,
938
935
  onAnalyticsEvent: t,
939
936
  exportAllowed: r,
940
- notAllowedView: n
937
+ notAllowedView: a
941
938
  }) {
942
- const l = G(), o = typeof e.exportable == "object" ? e.exportable : void 0, c = y.useRef(/* @__PURE__ */ new Date()), [d, u] = y.useState(!0), [m, h] = y.useState("csv"), [g, x] = y.useState("string"), R = Ke(), A = ke(), E = et().resolveAliasesFrom(a), z = !r || r({
939
+ const l = G(), o = typeof e.exportable == "object" ? e.exportable : void 0, c = y.useRef(/* @__PURE__ */ new Date()), [d, u] = y.useState(!0), [m, h] = y.useState("csv"), [g, x] = y.useState("string"), R = Ke(), A = ke(), E = et().resolveAliasesFrom(n), z = !r || r({
943
940
  collectionEntitiesCount: s,
944
941
  path: E,
945
942
  collection: e
@@ -1114,7 +1111,7 @@ function At({
1114
1111
  label: "Flatten arrays"
1115
1112
  }
1116
1113
  ),
1117
- !z && n
1114
+ !z && a
1118
1115
  ] }),
1119
1116
  /* @__PURE__ */ p(oe, { children: [
1120
1117
  T && /* @__PURE__ */ i(Ae, { size: "small" }),
@@ -1152,15 +1149,15 @@ function $t(e) {
1152
1149
  }
1153
1150
  function Bt({
1154
1151
  data: e,
1155
- properties: a,
1152
+ properties: n,
1156
1153
  propertiesOrder: s
1157
1154
  }) {
1158
- const t = y.useRef(/* @__PURE__ */ new Date()), [r, n] = y.useState(!0), [l, o] = y.useState("csv"), [c, d] = y.useState("string"), [u, m] = y.useState(!1), h = v(() => {
1155
+ const t = y.useRef(/* @__PURE__ */ new Date()), [r, a] = y.useState(!0), [l, o] = y.useState("csv"), [c, d] = y.useState("string"), [u, m] = y.useState(!1), h = v(() => {
1159
1156
  m(!0);
1160
1157
  }, [m]), g = v(() => {
1161
1158
  m(!1);
1162
1159
  }, [m]), x = v(() => {
1163
- Be(e, [], a, s, "export.csv", r, [], l, c), g();
1160
+ Be(e, [], n, s, "export.csv", r, [], l, c), g();
1164
1161
  }, []);
1165
1162
  return /* @__PURE__ */ p(M, { children: [
1166
1163
  /* @__PURE__ */ i(q, { title: "Export", children: /* @__PURE__ */ i(Y, { color: "primary", onClick: h, children: /* @__PURE__ */ i(Ee, {}) }) }),
@@ -1282,7 +1279,7 @@ function Bt({
1282
1279
  size: "small",
1283
1280
  disabled: l !== "csv",
1284
1281
  value: r,
1285
- onValueChange: n,
1282
+ onValueChange: a,
1286
1283
  label: "Flatten arrays"
1287
1284
  }
1288
1285
  )
@@ -1328,7 +1325,7 @@ export {
1328
1325
  Ot as getEntityCSVExportableData,
1329
1326
  kt as getEntityJsonExportableData,
1330
1327
  xt as getInferenceType,
1331
- ae as processValueMapping,
1328
+ ne as processValueMapping,
1332
1329
  je as unflattenObject,
1333
1330
  ut as useImportConfig,
1334
1331
  $t as useImportExportPlugin