@firecms/data_import_export 3.0.0-canary.43 → 3.0.0-canary.45

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
- import w, { useState as C, useRef as Re, useEffect as ye, useCallback as D, useMemo as Be } from "react";
2
- import { jsxs as p, Fragment as $, jsx as i } from "react/jsx-runtime";
3
- import { getPropertyInPath as B, mergeDeep as Je, resolveProperty as He, isPropertyBuilder as le, EntityReference as Ve, useSnackbarController as ve, useCustomizationController as G, getFieldConfig as we, ErrorBoundary as Ue, PropertyConfigBadge as Ce, useDataSource as De, resolveCollection as Oe, getPropertiesWithPropertiesOrder as ze, useSelectionController as We, EntityCollectionTable as Xe, slugify as Ge, getArrayValuesCount as Ye, getValueInPath as qe, useFireCMSContext as Qe, useNavigationController as Ze } from "@firecms/core";
4
- import { Table as ce, TableHeader as de, TableCell as y, TableBody as pe, TableRow as ue, Typography as m, ChevronRightIcon as fe, ExpandablePanel as Ke, Select as Se, SelectItem as J, TextField as ee, BooleanSwitchWithLabel as Ne, DateTimeField as et, FileUpload as tt, UploadIcon as rt, IconButton as ne, EditIcon as nt, CenteredView as me, Button as _, CircularProgress as _e, Tooltip as ae, FileUploadIcon as at, Dialog as Ie, DialogContent as Ae, DialogActions as Te, cn as R, defaultBorderMixin as st, GetAppIcon as it, Alert as ot, focusedMixin as z } from "@firecms/ui";
5
- import { inferTypeFromValue as lt, buildEntityPropertiesFromData as ct } from "@firecms/schema_inference";
1
+ import y, { useState as S, useRef as Je, useEffect as De, useCallback as v, useMemo as Ve } from "react";
2
+ import { jsxs as p, Fragment as M, jsx as i } from "react/jsx-runtime";
3
+ import { getPropertyInPath as J, mergeDeep as He, 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 V, 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";
5
+ import { inferTypeFromValue as ct, buildEntityPropertiesFromData as dt } from "@firecms/schema_inference";
6
6
  import * as H from "xlsx";
7
- import { getIn as Ee, setIn as dt } from "@firecms/formex";
8
- const pt = () => {
9
- const [e, n] = C(!1), [a, t] = C({}), [r, s] = C(), [l, o] = C([]), [c, d] = C([]), [u, f] = C({}), [h, g] = C([]), [O, k] = C({});
7
+ import { getIn as Te, setIn as pt } from "@firecms/formex";
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({});
10
10
  return {
11
11
  inUse: e,
12
- setInUse: n,
12
+ setInUse: a,
13
13
  idColumn: r,
14
- setIdColumn: s,
14
+ setIdColumn: n,
15
15
  entities: c,
16
16
  setEntities: d,
17
17
  importData: l,
@@ -19,54 +19,54 @@ const pt = () => {
19
19
  headingsOrder: (h ?? []).length > 0 ? h : Object.keys(u),
20
20
  setHeadingsOrder: g,
21
21
  headersMapping: u,
22
- setHeadersMapping: f,
23
- originProperties: O,
24
- setOriginProperties: k,
25
- defaultValues: a,
22
+ setHeadersMapping: m,
23
+ originProperties: x,
24
+ setOriginProperties: R,
25
+ defaultValues: s,
26
26
  setDefaultValues: t
27
27
  };
28
28
  };
29
- function ut(e) {
30
- let n = 0;
31
- const a = [], t = {};
29
+ function mt(e) {
30
+ let a = 0;
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 s;
36
- switch (t.header === 1 ? n = 1 : t.header === "A" ? n = 2 : Array.isArray(t.header) && (n = 3), typeof r) {
35
+ let n;
36
+ switch (t.header === 1 ? a = 1 : t.header === "A" ? a = 2 : Array.isArray(t.header) && (a = 3), typeof r) {
37
37
  case "string":
38
- s = he(r);
38
+ n = be(r);
39
39
  break;
40
40
  case "number":
41
- s = he(e["!ref"]), s.s.r = r;
41
+ n = be(e["!ref"]), n.s.r = r;
42
42
  break;
43
43
  default:
44
- s = r;
44
+ n = r;
45
45
  }
46
- const l = H.utils.encode_row(s.s.r), o = new Array(s.e.c - s.s.c + 1);
47
- for (let c = s.s.c; c <= s.e.c; ++c) {
46
+ const l = H.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) {
48
48
  o[c] = H.utils.encode_col(c);
49
49
  const d = e[o[c] + l];
50
- switch (n) {
50
+ switch (a) {
51
51
  case 1:
52
- a.push(c);
52
+ s.push(c);
53
53
  break;
54
54
  case 2:
55
- a.push(o[c]);
55
+ s.push(o[c]);
56
56
  break;
57
57
  case 3:
58
- a.push(t.header[c - s.s.c]);
58
+ s.push(t.header[c - n.s.c]);
59
59
  break;
60
60
  default:
61
61
  if (d === void 0)
62
62
  continue;
63
- a.push(H.utils.format_cell(d));
63
+ s.push(H.utils.format_cell(d));
64
64
  }
65
65
  }
66
- return a;
66
+ return s;
67
67
  }
68
- function he(e) {
69
- const n = {
68
+ function be(e) {
69
+ const a = {
70
70
  s: {
71
71
  c: 0,
72
72
  r: 0
@@ -76,51 +76,51 @@ function he(e) {
76
76
  r: 0
77
77
  }
78
78
  };
79
- let a = 0, t = 0, r = 0;
80
- const s = e.length;
81
- for (a = 0; t < s && !((r = e.charCodeAt(t) - 64) < 1 || r > 26); ++t)
82
- a = 26 * a + r;
83
- for (n.s.c = --a, a = 0; t < s && !((r = e.charCodeAt(t) - 48) < 0 || r > 9); ++t)
84
- a = 10 * a + r;
85
- if (n.s.r = --a, t === s || e.charCodeAt(++t) === 58)
86
- return n.e.c = n.s.c, n.e.r = n.s.r, n;
87
- for (a = 0; t !== s && !((r = e.charCodeAt(t) - 64) < 1 || r > 26); ++t)
88
- a = 26 * a + r;
89
- for (n.e.c = --a, a = 0; t !== s && !((r = e.charCodeAt(t) - 48) < 0 || r > 9); ++t)
90
- a = 10 * a + r;
91
- return n.e.r = --a, n;
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)
82
+ s = 26 * s + r;
83
+ for (a.s.c = --s, s = 0; t < n && !((r = e.charCodeAt(t) - 48) < 0 || r > 9); ++t)
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)
88
+ s = 26 * s + r;
89
+ for (a.e.c = --s, s = 0; t !== n && !((r = e.charCodeAt(t) - 48) < 0 || r > 9); ++t)
90
+ s = 10 * s + r;
91
+ return a.e.r = --s, a;
92
92
  }
93
93
  function ft(e) {
94
- return new Promise((n, a) => {
94
+ return new Promise((a, 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 s = r.target?.result, l = JSON.parse(s);
100
+ const n = r.target?.result, l = JSON.parse(n);
101
101
  if (!Array.isArray(l))
102
- a(new Error("JSON file should contain an array of objects"));
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
- n({
105
+ a({
106
106
  data: l,
107
107
  propertiesOrder: o
108
108
  });
109
109
  }
110
- } catch (s) {
111
- console.error("Error parsing JSON file", s), a(s);
110
+ } catch (n) {
111
+ console.error("Error parsing JSON file", n), s(n);
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 s = new Uint8Array(r.target?.result), l = H.read(s, {
118
+ const n = new Uint8Array(r.target?.result), l = H.read(n, {
119
119
  type: "array",
120
120
  codepage: 65001,
121
121
  cellDates: !0
122
- }), o = l.SheetNames[0], c = l.Sheets[o], d = H.utils.sheet_to_json(c), u = ut(c), h = d.map(mt).map(je);
123
- n({
122
+ }), o = l.SheetNames[0], c = l.Sheets[o], d = H.utils.sheet_to_json(c), u = mt(c), h = d.map(ht).map(je);
123
+ a({
124
124
  data: h,
125
125
  propertiesOrder: u
126
126
  });
@@ -128,72 +128,72 @@ function ft(e) {
128
128
  }
129
129
  });
130
130
  }
131
- function mt(e) {
132
- return Object.keys(e).reduce((n, a) => {
131
+ function ht(e) {
132
+ return Object.keys(e).reduce((a, s) => {
133
133
  try {
134
- n[a] = JSON.parse(e[a]);
134
+ a[s] = JSON.parse(e[s]);
135
135
  } catch {
136
- n[a] = e[a];
136
+ a[s] = e[s];
137
137
  }
138
- return n;
138
+ return a;
139
139
  }, {});
140
140
  }
141
141
  function je(e) {
142
- return Object.keys(e).reduce((n, a) => {
143
- let t = n;
144
- const r = a.split(".");
145
- return r.forEach((s, l) => {
146
- if (/^[\w]+\[\d+\]$/.test(s)) {
147
- const o = s.slice(0, s.indexOf("[")), c = parseInt(s.slice(s.indexOf("[") + 1, s.indexOf("]")));
148
- t[o] || (t[o] = []), l !== r.length - 1 ? (t[o][c] = t[o][c] || {}, t = t[o][c]) : t[o][c] = e[a];
142
+ return Object.keys(e).reduce((a, s) => {
143
+ let t = a;
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("]")));
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[s] = t[s] || {}, t = t[s]) : t[s] = e[a];
151
- }), n;
150
+ l !== r.length - 1 ? (t[n] = t[n] || {}, t = t[n]) : t[n] = e[s];
151
+ }), a;
152
152
  }, {});
153
153
  }
154
- function ht(e, n, a, t, r, s) {
154
+ function gt(e, a, s, t, r, n) {
155
155
  const l = Fe(e);
156
- n && delete l[n];
157
- const o = Object.entries(l).map(([u, f]) => {
158
- const h = Ee(a, u) ?? u, g = B(t, h);
156
+ a && delete l[a];
157
+ const o = Object.entries(l).map(([u, m]) => {
158
+ const h = Te(s, u) ?? u, g = J(t, h);
159
159
  if (!g)
160
160
  return {};
161
- const O = te(f, g);
161
+ const x = ae(m, g);
162
162
  return {
163
- [h]: O
163
+ [h]: x
164
164
  };
165
- }).reduce((u, f) => ({ ...u, ...f }), {}), c = Je(s ?? {}, je(o));
166
- let d = n ? e[n] : void 0;
165
+ }).reduce((u, m) => ({ ...u, ...m }), {}), c = He(n ?? {}, je(o));
166
+ let d = a ? e[a] : 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, n = "") {
174
- return Object.keys(e).reduce((a, t) => {
175
- const r = n ? `${n}.${t}` : t;
176
- return typeof e[t] == "object" && !(e[t] instanceof Date) && e[t] !== null && !Array.isArray(e[t]) ? Object.assign(a, Fe(e[t], r)) : a[r] = e[t], a;
173
+ function Fe(e, a = "") {
174
+ return Object.keys(e).reduce((s, t) => {
175
+ const r = a ? `${a}.${t}` : t;
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 te(e, n) {
179
+ function ae(e, a) {
180
180
  if (e === null)
181
181
  return null;
182
- if (n === void 0)
182
+ if (a === void 0)
183
183
  return e;
184
- const a = He({
185
- propertyOrBuilder: n,
184
+ const s = ze({
185
+ propertyOrBuilder: a,
186
186
  propertyValue: e
187
187
  });
188
- if (a === null)
188
+ if (s === null)
189
189
  return e;
190
- const t = lt(e), r = a.dataType;
191
- if (t === "array" && r === "array" && Array.isArray(e) && a.of && !le(a.of))
192
- return e.map((s) => te(s, a.of));
190
+ const t = ct(e), r = s.dataType;
191
+ if (t === "array" && r === "array" && Array.isArray(e) && s.of && !ue(s.of))
192
+ return e.map((n) => ae(n, s.of));
193
193
  if (t === "string" && r === "number" && typeof e == "string")
194
194
  return Number(e);
195
- if (t === "string" && r === "array" && typeof e == "string" && a.of && !le(a.of))
196
- return e.split(",").map((s) => te(s, a.of));
195
+ if (t === "string" && r === "array" && typeof e == "string" && s.of && !ue(s.of))
196
+ return e.split(",").map((n) => ae(n, s.of));
197
197
  if (t === "string" && r === "boolean")
198
198
  return e === "true";
199
199
  if (t === "number" && r === "boolean")
@@ -205,7 +205,7 @@ function te(e, n) {
205
205
  if (t === "number" && r === "string" && typeof e == "number")
206
206
  return e.toString();
207
207
  if (t === "string" && r === "array" && typeof e == "string")
208
- return e.split(",").map((s) => s.trim());
208
+ return e.split(",").map((n) => n.trim());
209
209
  if (t === "string" && r === "date" && typeof e == "string")
210
210
  try {
211
211
  return new Date(e);
@@ -222,8 +222,8 @@ function te(e, n) {
222
222
  return e;
223
223
  }
224
224
  else if (t === "string" && r === "reference" && typeof e == "string") {
225
- const s = e.split("/").slice(0, -1).join("/"), l = e.split("/").slice(-1)[0];
226
- return new Ve(l, s);
225
+ const n = e.split("/").slice(0, -1).join("/"), l = e.split("/").slice(-1)[0];
226
+ return new Ue(l, n);
227
227
  } else {
228
228
  if (t === r)
229
229
  return e;
@@ -233,41 +233,41 @@ function te(e, n) {
233
233
  }
234
234
  return e;
235
235
  }
236
- function gt(e) {
236
+ function xt(e) {
237
237
  return typeof e == "number" ? "number" : typeof e == "string" ? "string" : typeof e == "boolean" ? "boolean" : e instanceof Date ? "date" : Array.isArray(e) ? "array" : "map";
238
238
  }
239
- function bt({
239
+ function yt({
240
240
  importConfig: e,
241
- destinationProperties: n,
242
- buildPropertyView: a
241
+ destinationProperties: a,
242
+ buildPropertyView: s
243
243
  }) {
244
- const t = e.headersMapping, r = e.headingsOrder, s = e.idColumn, l = e.originProperties;
245
- return /* @__PURE__ */ p($, { children: [
244
+ const t = e.headersMapping, r = e.headingsOrder, n = e.idColumn, l = e.originProperties;
245
+ return /* @__PURE__ */ p(M, { children: [
246
246
  /* @__PURE__ */ i(
247
- xt,
247
+ bt,
248
248
  {
249
- idColumn: s,
249
+ idColumn: n,
250
250
  headersMapping: t,
251
251
  onChange: (o) => e.setIdColumn(o ?? void 0)
252
252
  }
253
253
  ),
254
254
  /* @__PURE__ */ i("div", { className: "h-4" }),
255
- /* @__PURE__ */ p(ce, { style: {
255
+ /* @__PURE__ */ p(me, { style: {
256
256
  tableLayout: "fixed"
257
257
  }, children: [
258
- /* @__PURE__ */ p(de, { children: [
259
- /* @__PURE__ */ i(y, { header: !0, style: { width: "20%" }, children: "Column in file" }),
260
- /* @__PURE__ */ i(y, { header: !0 }),
261
- /* @__PURE__ */ i(y, { header: !0, style: { width: "75%" }, children: "Map to Property" })
258
+ /* @__PURE__ */ p(fe, { children: [
259
+ /* @__PURE__ */ i(w, { header: !0, style: { width: "20%" }, children: "Column in file" }),
260
+ /* @__PURE__ */ i(w, { header: !0 }),
261
+ /* @__PURE__ */ i(w, { header: !0, style: { width: "75%" }, children: "Map to Property" })
262
262
  ] }),
263
- /* @__PURE__ */ i(pe, { children: n && r.map(
263
+ /* @__PURE__ */ i(he, { children: a && r.map(
264
264
  (o) => {
265
- const c = t[o], d = t[o], u = c ? B(n, c) : null, f = B(l, o), h = f ? f.dataType === "array" && typeof f.of == "object" ? `${f.dataType} - ${f.of.dataType}` : f.dataType : void 0;
266
- return /* @__PURE__ */ p(ue, { style: { height: "90px" }, children: [
267
- /* @__PURE__ */ p(y, { style: { width: "20%" }, children: [
268
- /* @__PURE__ */ i(m, { variant: "body2", children: o }),
269
- f && /* @__PURE__ */ i(
270
- m,
265
+ 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;
266
+ return /* @__PURE__ */ p(ge, { style: { height: "90px" }, children: [
267
+ /* @__PURE__ */ p(w, { style: { width: "20%" }, children: [
268
+ /* @__PURE__ */ i(f, { variant: "body2", children: o }),
269
+ m && /* @__PURE__ */ i(
270
+ f,
271
271
  {
272
272
  variant: "caption",
273
273
  color: "secondary",
@@ -275,14 +275,14 @@ function bt({
275
275
  }
276
276
  )
277
277
  ] }),
278
- /* @__PURE__ */ i(y, { children: /* @__PURE__ */ i(fe, {}) }),
278
+ /* @__PURE__ */ i(w, { children: /* @__PURE__ */ i(xe, {}) }),
279
279
  /* @__PURE__ */ i(
280
- y,
280
+ w,
281
281
  {
282
- className: o === s ? "text-center" : void 0,
282
+ className: o === n ? "text-center" : void 0,
283
283
  style: { width: "75%" },
284
- children: a?.({
285
- isIdColumn: o === s,
284
+ children: s?.({
285
+ isIdColumn: o === n,
286
286
  property: u,
287
287
  propertyKey: d,
288
288
  importKey: o
@@ -293,34 +293,34 @@ function bt({
293
293
  }
294
294
  ) })
295
295
  ] }),
296
- /* @__PURE__ */ p(Ke, { title: "Default values", initiallyExpanded: !1, className: "p-4 mt-4", children: [
296
+ /* @__PURE__ */ p(tt, { title: "Default values", initiallyExpanded: !1, className: "p-4 mt-4", children: [
297
297
  /* @__PURE__ */ i("div", { className: "text-sm text-slate-500 dark:text-slate-300 font-medium ml-3.5 mb-1", children: "You can select a default value for unmapped columns and empty values:" }),
298
- /* @__PURE__ */ p(ce, { style: {
298
+ /* @__PURE__ */ p(me, { style: {
299
299
  tableLayout: "fixed"
300
300
  }, children: [
301
- /* @__PURE__ */ p(de, { children: [
302
- /* @__PURE__ */ i(y, { header: !0, style: { width: "30%" }, children: "Property" }),
303
- /* @__PURE__ */ i(y, { header: !0 }),
304
- /* @__PURE__ */ i(y, { header: !0, style: { width: "65%" }, children: "Default value" })
301
+ /* @__PURE__ */ p(fe, { children: [
302
+ /* @__PURE__ */ i(w, { header: !0, style: { width: "30%" }, children: "Property" }),
303
+ /* @__PURE__ */ i(w, { header: !0 }),
304
+ /* @__PURE__ */ i(w, { header: !0, style: { width: "65%" }, children: "Default value" })
305
305
  ] }),
306
- /* @__PURE__ */ i(pe, { children: n && ke(n).map(
306
+ /* @__PURE__ */ i(he, { children: a && Pe(a).map(
307
307
  (o) => {
308
- const c = B(n, o);
309
- return typeof c != "object" || c === null || !["number", "string", "boolean", "map"].includes(c.dataType) ? null : /* @__PURE__ */ p(ue, { style: { height: "70px" }, children: [
310
- /* @__PURE__ */ i(y, { style: { width: "20%" }, children: /* @__PURE__ */ i(m, { variant: "body2", children: o }) }),
311
- /* @__PURE__ */ i(y, { children: /* @__PURE__ */ i(fe, {}) }),
308
+ const c = J(a, o);
309
+ return typeof c != "object" || c === null || !["number", "string", "boolean", "map"].includes(c.dataType) ? null : /* @__PURE__ */ p(ge, { style: { height: "70px" }, children: [
310
+ /* @__PURE__ */ i(w, { style: { width: "20%" }, children: /* @__PURE__ */ i(f, { variant: "body2", children: o }) }),
311
+ /* @__PURE__ */ i(w, { children: /* @__PURE__ */ i(xe, {}) }),
312
312
  /* @__PURE__ */ i(
313
- y,
313
+ w,
314
314
  {
315
- className: o === s ? "text-center" : void 0,
315
+ className: o === n ? "text-center" : void 0,
316
316
  style: { width: "75%" },
317
317
  children: /* @__PURE__ */ i(
318
- yt,
318
+ vt,
319
319
  {
320
320
  property: c,
321
- defaultValue: Ee(e.defaultValues, o),
321
+ defaultValue: Te(e.defaultValues, o),
322
322
  onValueChange: (d) => {
323
- const u = dt(e.defaultValues, o, d);
323
+ const u = pt(e.defaultValues, o, d);
324
324
  e.setDefaultValues(u);
325
325
  }
326
326
  }
@@ -334,88 +334,88 @@ function bt({
334
334
  ] })
335
335
  ] });
336
336
  }
337
- function ke(e, n) {
338
- return Object.entries(e).reduce((a, [t, r]) => {
339
- const s = n ? `${n}.${t}` : t;
337
+ function Pe(e, a) {
338
+ return Object.entries(e).reduce((s, [t, r]) => {
339
+ const n = a ? `${a}.${t}` : t;
340
340
  if (typeof r != "function" && r.dataType === "map" && r.properties) {
341
- const l = ke(r.properties, s);
342
- return [...a, ...l];
341
+ const l = Pe(r.properties, n);
342
+ return [...s, ...l];
343
343
  }
344
- return [...a, s];
344
+ return [...s, n];
345
345
  }, []);
346
346
  }
347
- function xt({
347
+ function bt({
348
348
  idColumn: e,
349
- headersMapping: n,
350
- onChange: a
349
+ headersMapping: a,
350
+ onChange: s
351
351
  }) {
352
352
  return /* @__PURE__ */ i("div", { children: /* @__PURE__ */ p(
353
- Se,
353
+ _e,
354
354
  {
355
355
  size: "small",
356
356
  value: e ?? "",
357
357
  onChange: (t) => {
358
358
  const r = t.target.value;
359
- a(r === "__none__" ? null : r);
359
+ s(r === "__none__" ? null : r);
360
360
  },
361
361
  placeholder: "Autogenerate ID",
362
- renderValue: (t) => /* @__PURE__ */ i(m, { variant: "body2", children: t !== "__none__" ? t : "Autogenerate ID" }),
362
+ renderValue: (t) => /* @__PURE__ */ i(f, { variant: "body2", children: t !== "__none__" ? t : "Autogenerate ID" }),
363
363
  label: "Column that will be used as ID for each document",
364
364
  children: [
365
- /* @__PURE__ */ i(J, { value: "__none__", children: "Autogenerate ID" }),
366
- Object.entries(n).map(([t, r]) => /* @__PURE__ */ i(J, { value: t, children: t }, t))
365
+ /* @__PURE__ */ i(V, { value: "__none__", children: "Autogenerate ID" }),
366
+ Object.entries(a).map(([t, r]) => /* @__PURE__ */ i(V, { value: t, children: t }, t))
367
367
  ]
368
368
  }
369
369
  ) });
370
370
  }
371
- function yt({
371
+ function vt({
372
372
  property: e,
373
- onValueChange: n,
374
- defaultValue: a
373
+ onValueChange: a,
374
+ defaultValue: s
375
375
  }) {
376
376
  return e.dataType === "string" ? /* @__PURE__ */ i(
377
- ee,
377
+ re,
378
378
  {
379
379
  size: "small",
380
380
  placeholder: "Default value",
381
- value: a ?? "",
382
- onChange: (t) => n(t.target.value)
381
+ value: s ?? "",
382
+ onChange: (t) => a(t.target.value)
383
383
  }
384
384
  ) : e.dataType === "number" ? /* @__PURE__ */ i(
385
- ee,
385
+ re,
386
386
  {
387
387
  size: "small",
388
388
  type: "number",
389
- value: a ?? "",
389
+ value: s ?? "",
390
390
  placeholder: "Default value",
391
- onChange: (t) => n(t.target.value)
391
+ onChange: (t) => a(t.target.value)
392
392
  }
393
393
  ) : e.dataType === "boolean" ? /* @__PURE__ */ i(
394
- Ne,
394
+ se,
395
395
  {
396
- value: a ?? null,
396
+ value: s ?? null,
397
397
  allowIndeterminate: !0,
398
398
  size: "small",
399
- onValueChange: (t) => n(t === null ? void 0 : t),
400
- label: a === void 0 ? "Do not set value" : a === !0 ? "Set value to true" : "Set value to false"
399
+ onValueChange: (t) => a(t === null ? void 0 : t),
400
+ label: s === void 0 ? "Do not set value" : s === !0 ? "Set value to true" : "Set value to false"
401
401
  }
402
402
  ) : e.dataType === "date" ? /* @__PURE__ */ i(
403
- et,
403
+ rt,
404
404
  {
405
405
  mode: e.mode ?? "date",
406
406
  size: "small",
407
- value: a ?? void 0,
407
+ value: s ?? void 0,
408
408
  onChange: (t) => {
409
- n(t);
409
+ a(t);
410
410
  },
411
411
  clearable: !0
412
412
  }
413
413
  ) : null;
414
414
  }
415
- function vt({ onDataAdded: e }) {
416
- const n = ve();
415
+ function Ct({ onDataAdded: e }) {
416
+ const a = Ne();
417
417
  return /* @__PURE__ */ i(
418
- tt,
418
+ at,
419
419
  {
420
420
  accept: {
421
421
  "text/*": [".csv", ".xls", ".xlsx"],
@@ -430,18 +430,18 @@ function vt({ onDataAdded: e }) {
430
430
  preventDropOnDocument: !0,
431
431
  size: "small",
432
432
  maxFiles: 1,
433
- uploadDescription: /* @__PURE__ */ p($, { children: [
434
- /* @__PURE__ */ i(rt, {}),
433
+ uploadDescription: /* @__PURE__ */ p(M, { children: [
434
+ /* @__PURE__ */ i(nt, {}),
435
435
  "Drag and drop a file here or click to upload"
436
436
  ] }),
437
- onFilesAdded: (a) => {
438
- a.length > 0 && ft(a[0]).then(({
437
+ onFilesAdded: (s) => {
438
+ s.length > 0 && ft(s[0]).then(({
439
439
  data: t,
440
440
  propertiesOrder: r
441
441
  }) => {
442
442
  e(t, r);
443
443
  }).catch((t) => {
444
- console.error("Error parsing file", t), n.open({
444
+ console.error("Error parsing file", t), a.open({
445
445
  type: "error",
446
446
  message: t.message
447
447
  });
@@ -450,34 +450,34 @@ function vt({ onDataAdded: e }) {
450
450
  }
451
451
  );
452
452
  }
453
- function $t({
453
+ function Rt({
454
454
  propertyKey: e,
455
- property: n,
456
- onEditClick: a,
455
+ property: a,
456
+ onEditClick: s,
457
457
  includeName: t = !0,
458
458
  onPropertyNameChanged: r,
459
- propertyTypeView: s
459
+ propertyTypeView: n
460
460
  }) {
461
- const { propertyConfigs: l } = G(), o = n ? we(n, l) : null;
462
- return /* @__PURE__ */ i(Ue, { children: /* @__PURE__ */ p(
461
+ const { propertyConfigs: l } = G(), o = a ? Se(a, l) : null;
462
+ return /* @__PURE__ */ i(We, { children: /* @__PURE__ */ p(
463
463
  "div",
464
464
  {
465
465
  className: "flex flex-row w-full items-center",
466
466
  children: [
467
- /* @__PURE__ */ i("div", { className: "mx-4", children: s ?? /* @__PURE__ */ i(Ce, { propertyConfig: o ?? void 0 }) }),
467
+ /* @__PURE__ */ i("div", { className: "mx-4", children: n ?? /* @__PURE__ */ i(Oe, { propertyConfig: o ?? void 0 }) }),
468
468
  /* @__PURE__ */ i("div", { className: "w-full flex flex-col grow", children: /* @__PURE__ */ p("div", { className: "flex flex-row items-center gap-2", children: [
469
469
  t && /* @__PURE__ */ i(
470
- ee,
470
+ re,
471
471
  {
472
472
  size: "small",
473
473
  className: "text-base grow",
474
- value: n?.name ?? "",
474
+ value: a?.name ?? "",
475
475
  onChange: (c) => {
476
476
  r && e && r(e, c.target.value);
477
477
  }
478
478
  }
479
479
  ),
480
- /* @__PURE__ */ i(ne, { onClick: a, size: "small", children: /* @__PURE__ */ i(nt, { size: "small" }) })
480
+ /* @__PURE__ */ i(Y, { onClick: s, size: "small", children: /* @__PURE__ */ i(st, { size: "small" }) })
481
481
  ] }) })
482
482
  ]
483
483
  }
@@ -485,135 +485,135 @@ function $t({
485
485
  }
486
486
  function wt({
487
487
  path: e,
488
- importConfig: n,
489
- collection: a,
488
+ importConfig: a,
489
+ collection: s,
490
490
  onImportSuccess: t
491
491
  }) {
492
- const [r, s] = C(void 0), l = De(), o = Re(!1), [c, d] = C(0);
492
+ const [r, n] = S(void 0), l = ke(), o = Je(!1), [c, d] = S(0);
493
493
  function u() {
494
- o.current || (o.current = !0, Pe(
494
+ o.current || (o.current = !0, Me(
495
495
  l,
496
- a,
496
+ s,
497
497
  e,
498
- n.entities,
498
+ a.entities,
499
499
  0,
500
500
  25,
501
501
  d
502
502
  ).then(() => {
503
- t(a), o.current = !1;
504
- }).catch((f) => {
505
- s(f), o.current = !1;
503
+ t(s), o.current = !1;
504
+ }).catch((m) => {
505
+ n(m), o.current = !1;
506
506
  }));
507
507
  }
508
- return ye(() => {
508
+ return De(() => {
509
509
  u();
510
- }, []), r ? /* @__PURE__ */ p(me, { className: "flex flex-col gap-4 items-center", children: [
511
- /* @__PURE__ */ i(m, { variant: "h6", children: "Error saving data" }),
512
- /* @__PURE__ */ i(m, { variant: "body2", color: "error", children: r.message }),
510
+ }, []), r ? /* @__PURE__ */ p(ye, { className: "flex flex-col gap-4 items-center", children: [
511
+ /* @__PURE__ */ i(f, { variant: "h6", children: "Error saving data" }),
512
+ /* @__PURE__ */ i(f, { variant: "body2", color: "error", children: r.message }),
513
513
  /* @__PURE__ */ i(
514
- _,
514
+ O,
515
515
  {
516
516
  onClick: u,
517
517
  variant: "outlined",
518
518
  children: "Retry"
519
519
  }
520
520
  )
521
- ] }) : /* @__PURE__ */ p(me, { className: "flex flex-col gap-4 items-center", children: [
522
- /* @__PURE__ */ i(_e, {}),
523
- /* @__PURE__ */ i(m, { variant: "h6", children: "Saving data" }),
524
- /* @__PURE__ */ p(m, { variant: "body2", children: [
521
+ ] }) : /* @__PURE__ */ p(ye, { className: "flex flex-col gap-4 items-center", children: [
522
+ /* @__PURE__ */ i(Ae, {}),
523
+ /* @__PURE__ */ i(f, { variant: "h6", children: "Saving data" }),
524
+ /* @__PURE__ */ p(f, { variant: "body2", children: [
525
525
  c,
526
526
  "/",
527
- n.entities.length,
527
+ a.entities.length,
528
528
  " entities saved"
529
529
  ] }),
530
- /* @__PURE__ */ i(m, { variant: "caption", children: "Do not close this tab or the import will be interrupted." })
530
+ /* @__PURE__ */ i(f, { variant: "caption", children: "Do not close this tab or the import will be interrupted." })
531
531
  ] });
532
532
  }
533
- function Pe(e, n, a, t, r = 0, s = 25, l) {
534
- console.debug("Saving imported data", r, s);
535
- const o = t.slice(r, r + s);
533
+ function Me(e, a, s, t, r = 0, n = 25, l) {
534
+ console.debug("Saving imported data", r, n);
535
+ const o = t.slice(r, r + n);
536
536
  return Promise.all(o.map((c) => e.saveEntity({
537
- path: a,
537
+ path: s,
538
538
  values: c.values,
539
539
  entityId: c.id,
540
- collection: n,
540
+ collection: a,
541
541
  status: "new"
542
- }))).then(() => r + s < t.length ? (l(r + s), Pe(e, n, a, t, r + s, s, l)) : (l(t.length), Promise.resolve()));
542
+ }))).then(() => r + n < t.length ? (l(r + n), Me(e, a, s, t, r + n, n, l)) : (l(t.length), Promise.resolve()));
543
543
  }
544
- function Ct({
544
+ function Dt({
545
545
  collection: e,
546
- path: n,
547
- collectionEntitiesCount: a,
546
+ path: a,
547
+ collectionEntitiesCount: s,
548
548
  onAnalyticsEvent: t
549
549
  }) {
550
- const r = G(), s = ve(), [l, o] = w.useState(!1), [c, d] = w.useState("initial"), u = pt(), f = D(() => {
550
+ const r = G(), n = Ne(), [l, o] = y.useState(!1), [c, d] = y.useState("initial"), u = ut(), m = v(() => {
551
551
  o(!0), t?.("import_open"), d("initial");
552
- }, [t]), h = D(() => {
552
+ }, [t]), h = v(() => {
553
553
  o(!1);
554
- }, [o]), g = D(() => {
554
+ }, [o]), g = v(() => {
555
555
  t?.("import_mapping_complete"), d("preview");
556
- }, [t]), O = D(() => {
556
+ }, [t]), x = v(() => {
557
557
  t?.("import_data_save"), d("import_data_saving");
558
- }, [t]), k = async (b) => {
558
+ }, [t]), R = async (b) => {
559
559
  if (u.setImportData(b), b.length > 0) {
560
- const T = await ct(b, gt);
560
+ const T = await dt(b, xt);
561
561
  u.setOriginProperties(T);
562
- const E = $e(b, e?.properties);
563
- u.setHeadersMapping(E);
564
- const j = Object.keys(E)?.[0];
565
- (j?.includes("id") || j?.includes("key")) && u.setIdColumn(j);
562
+ const j = $e(b, e?.properties);
563
+ u.setHeadersMapping(j);
564
+ const F = Object.keys(j)?.[0];
565
+ (F?.includes("id") || F?.includes("key")) && u.setIdColumn(F);
566
566
  }
567
567
  setTimeout(() => {
568
568
  t?.("import_data_added"), d("mapping");
569
569
  }, 100);
570
- }, I = Oe({
570
+ }, A = Ie({
571
571
  collection: e,
572
- path: n,
572
+ path: a,
573
573
  fields: r.propertyConfigs
574
- }), L = ze(I.properties, I.propertiesOrder), A = Object.entries(L).flatMap(([b, T]) => Me(b, T, 0)), V = I.propertiesOrder ?? Object.keys(I.properties);
575
- return e.collectionGroup ? null : /* @__PURE__ */ p($, { children: [
576
- /* @__PURE__ */ i(ae, { title: "Import", children: /* @__PURE__ */ i(ne, { color: "primary", onClick: f, children: /* @__PURE__ */ i(at, {}) }) }),
574
+ }), L = Xe(A.properties, A.propertiesOrder), E = Object.entries(L).flatMap(([b, T]) => Re(b, T, 0)), z = A.propertiesOrder ?? Object.keys(A.properties);
575
+ return e.collectionGroup ? null : /* @__PURE__ */ p(M, { children: [
576
+ /* @__PURE__ */ i(q, { title: "Import", children: /* @__PURE__ */ i(Y, { color: "primary", onClick: m, children: /* @__PURE__ */ i(it, {}) }) }),
577
577
  /* @__PURE__ */ p(
578
- Ie,
578
+ ie,
579
579
  {
580
580
  open: l,
581
581
  fullWidth: c === "preview",
582
582
  fullHeight: c === "preview",
583
583
  maxWidth: c === "initial" ? "lg" : "7xl",
584
584
  children: [
585
- /* @__PURE__ */ p(Ae, { className: "flex flex-col gap-4 my-4", fullHeight: c === "preview", children: [
586
- c === "initial" && /* @__PURE__ */ p($, { children: [
587
- /* @__PURE__ */ i(m, { variant: "h6", children: "Import data" }),
588
- /* @__PURE__ */ i(m, { variant: "body2", children: "Upload a CSV, Excel or JSON file and map it to your existing schema" }),
589
- /* @__PURE__ */ i(vt, { onDataAdded: k })
585
+ /* @__PURE__ */ p(le, { className: "flex flex-col gap-4 my-4", fullHeight: c === "preview", children: [
586
+ c === "initial" && /* @__PURE__ */ p(M, { children: [
587
+ /* @__PURE__ */ i(f, { variant: "h6", children: "Import data" }),
588
+ /* @__PURE__ */ i(f, { variant: "body2", children: "Upload a CSV, Excel or JSON file and map it to your existing schema" }),
589
+ /* @__PURE__ */ i(Ct, { onDataAdded: R })
590
590
  ] }),
591
- c === "mapping" && /* @__PURE__ */ p($, { children: [
592
- /* @__PURE__ */ i(m, { variant: "h6", className: "ml-3.5", children: "Map fields" }),
591
+ c === "mapping" && /* @__PURE__ */ p(M, { children: [
592
+ /* @__PURE__ */ i(f, { variant: "h6", className: "ml-3.5", children: "Map fields" }),
593
593
  /* @__PURE__ */ i(
594
- bt,
594
+ yt,
595
595
  {
596
596
  importConfig: u,
597
597
  destinationProperties: L,
598
598
  buildPropertyView: ({
599
599
  isIdColumn: b,
600
600
  property: T,
601
- propertyKey: E,
602
- importKey: j
601
+ propertyKey: j,
602
+ importKey: F
603
603
  }) => /* @__PURE__ */ i(
604
- Dt,
604
+ Nt,
605
605
  {
606
- selectedPropertyKey: E ?? "",
606
+ selectedPropertyKey: j ?? "",
607
607
  properties: L,
608
- propertiesAndLevel: A,
608
+ propertiesAndLevel: E,
609
609
  isIdColumn: b,
610
610
  onIdSelected: () => {
611
- u.setIdColumn(j);
611
+ u.setIdColumn(F);
612
612
  },
613
- onPropertySelected: (P) => {
613
+ onPropertySelected: ($) => {
614
614
  t?.("import_mapping_field_updated");
615
- const Y = Object.entries(u.headersMapping).map(([x, M]) => M === P ? { [x]: null } : x === j ? { [x]: P } : { [x]: M }).reduce((x, M) => ({ ...x, ...M }), {});
616
- u.setHeadersMapping(Y), P === u.idColumn && u.setIdColumn(void 0);
615
+ const Q = Object.entries(u.headersMapping).map(([C, B]) => B === $ ? { [C]: null } : C === F ? { [C]: $ } : { [C]: B }).reduce((C, B) => ({ ...C, ...B }), {});
616
+ u.setHeadersMapping(Q), $ === u.idColumn && u.setIdColumn(void 0);
617
617
  }
618
618
  }
619
619
  )
@@ -621,11 +621,11 @@ function Ct({
621
621
  )
622
622
  ] }),
623
623
  c === "preview" && /* @__PURE__ */ i(
624
- Ot,
624
+ St,
625
625
  {
626
626
  importConfig: u,
627
627
  properties: L,
628
- propertiesOrder: V
628
+ propertiesOrder: z
629
629
  }
630
630
  ),
631
631
  c === "import_data_saving" && u && /* @__PURE__ */ i(
@@ -633,9 +633,9 @@ function Ct({
633
633
  {
634
634
  importConfig: u,
635
635
  collection: e,
636
- path: n,
636
+ path: a,
637
637
  onImportSuccess: (b) => {
638
- h(), s.open({
638
+ h(), n.open({
639
639
  type: "info",
640
640
  message: "Data imported successfully"
641
641
  });
@@ -643,9 +643,9 @@ function Ct({
643
643
  }
644
644
  )
645
645
  ] }),
646
- /* @__PURE__ */ p(Te, { children: [
646
+ /* @__PURE__ */ p(oe, { children: [
647
647
  c === "mapping" && /* @__PURE__ */ i(
648
- _,
648
+ O,
649
649
  {
650
650
  onClick: () => d("initial"),
651
651
  variant: "text",
@@ -653,7 +653,7 @@ function Ct({
653
653
  }
654
654
  ),
655
655
  c === "preview" && /* @__PURE__ */ i(
656
- _,
656
+ O,
657
657
  {
658
658
  onClick: () => d("mapping"),
659
659
  variant: "text",
@@ -661,7 +661,7 @@ function Ct({
661
661
  }
662
662
  ),
663
663
  /* @__PURE__ */ i(
664
- _,
664
+ O,
665
665
  {
666
666
  onClick: h,
667
667
  variant: "text",
@@ -669,7 +669,7 @@ function Ct({
669
669
  }
670
670
  ),
671
671
  c === "mapping" && /* @__PURE__ */ i(
672
- _,
672
+ O,
673
673
  {
674
674
  variant: "filled",
675
675
  onClick: g,
@@ -677,10 +677,10 @@ function Ct({
677
677
  }
678
678
  ),
679
679
  c === "preview" && /* @__PURE__ */ i(
680
- _,
680
+ O,
681
681
  {
682
682
  variant: "filled",
683
- onClick: O,
683
+ onClick: x,
684
684
  children: "Save data"
685
685
  }
686
686
  )
@@ -691,91 +691,91 @@ function Ct({
691
691
  ] });
692
692
  }
693
693
  const W = "__internal_id__";
694
- function Dt({
694
+ function Nt({
695
695
  selectedPropertyKey: e,
696
- properties: n,
697
- onPropertySelected: a,
696
+ properties: a,
697
+ onPropertySelected: s,
698
698
  onIdSelected: t,
699
699
  propertiesAndLevel: r,
700
- isIdColumn: s
700
+ isIdColumn: n
701
701
  }) {
702
- const l = e ? B(n, e) : null, o = D((d) => d === W ? /* @__PURE__ */ i(m, { variant: "body2", className: "p-4", children: "Use this column as ID" }) : !d || !l ? /* @__PURE__ */ i(m, { variant: "body2", color: "disabled", className: "p-4", children: "Do not import this property" }) : /* @__PURE__ */ i(
703
- ge,
702
+ 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(
703
+ ve,
704
704
  {
705
705
  propertyKey: d,
706
706
  property: l
707
707
  }
708
708
  ), [l]);
709
709
  return /* @__PURE__ */ p(
710
- Se,
710
+ _e,
711
711
  {
712
- value: s ? W : e ?? void 0,
712
+ value: n ? W : e ?? void 0,
713
713
  onValueChange: (d) => {
714
- d === W ? (t(), a(null)) : a(d === "__do_not_import" ? null : d);
714
+ d === W ? (t(), s(null)) : s(d === "__do_not_import" ? null : d);
715
715
  },
716
716
  renderValue: o,
717
717
  children: [
718
- /* @__PURE__ */ i(J, { value: "__do_not_import", children: /* @__PURE__ */ i(m, { variant: "body2", color: "disabled", className: "p-4", children: "Do not import this property" }) }),
719
- /* @__PURE__ */ i(J, { value: W, children: /* @__PURE__ */ i(m, { variant: "body2", className: "p-4", children: "Use this column as ID" }) }),
718
+ /* @__PURE__ */ i(V, { value: "__do_not_import", children: /* @__PURE__ */ i(f, { variant: "body2", color: "disabled", className: "p-4", children: "Do not import this property" }) }),
719
+ /* @__PURE__ */ i(V, { value: W, children: /* @__PURE__ */ i(f, { variant: "body2", className: "p-4", children: "Use this column as ID" }) }),
720
720
  r.map(({
721
721
  property: d,
722
722
  level: u,
723
- propertyKey: f
723
+ propertyKey: m
724
724
  }) => /* @__PURE__ */ i(
725
- J,
725
+ V,
726
726
  {
727
- value: f,
727
+ value: m,
728
728
  disabled: d.dataType === "map",
729
729
  children: /* @__PURE__ */ i(
730
- ge,
730
+ ve,
731
731
  {
732
- propertyKey: f,
732
+ propertyKey: m,
733
733
  property: d,
734
734
  level: u
735
735
  }
736
736
  )
737
737
  },
738
- f
738
+ m
739
739
  ))
740
740
  ]
741
741
  }
742
742
  );
743
743
  }
744
- function Me(e, n, a) {
744
+ function Re(e, a, s) {
745
745
  const t = [];
746
746
  return t.push({
747
- property: n,
748
- level: a,
747
+ property: a,
748
+ level: s,
749
749
  propertyKey: e
750
- }), n.dataType === "map" && n.properties && Object.entries(n.properties).forEach(([r, s]) => {
751
- t.push(...Me(`${e}.${r}`, s, a + 1));
750
+ }), a.dataType === "map" && a.properties && Object.entries(a.properties).forEach(([r, n]) => {
751
+ t.push(...Re(`${e}.${r}`, n, s + 1));
752
752
  }), t;
753
753
  }
754
- function ge({
754
+ function ve({
755
755
  propertyKey: e,
756
- property: n,
757
- level: a = 0
756
+ property: a,
757
+ level: s = 0
758
758
  }) {
759
- const { propertyConfigs: t } = G(), r = we(n, t);
759
+ const { propertyConfigs: t } = G(), r = Se(a, t);
760
760
  return /* @__PURE__ */ p(
761
761
  "div",
762
762
  {
763
763
  className: "flex flex-row w-full text-start items-center h-full",
764
764
  children: [
765
- new Array(a).fill(0).map((s, l) => /* @__PURE__ */ i("div", { className: R(st, "ml-8 border-l h-12") }, l)),
766
- /* @__PURE__ */ i("div", { className: "m-4", children: /* @__PURE__ */ i(ae, { title: r?.name, children: /* @__PURE__ */ i(Ce, { propertyConfig: r }) }) }),
765
+ new Array(s).fill(0).map((n, l) => /* @__PURE__ */ i("div", { className: k(lt, "ml-8 border-l h-12") }, l)),
766
+ /* @__PURE__ */ i("div", { className: "m-4", children: /* @__PURE__ */ i(q, { title: r?.name, children: /* @__PURE__ */ i(Oe, { propertyConfig: r }) }) }),
767
767
  /* @__PURE__ */ p("div", { className: "flex flex-col flex-grow p-2 pl-2", children: [
768
768
  /* @__PURE__ */ i(
769
- m,
769
+ f,
770
770
  {
771
771
  variant: "body1",
772
772
  component: "span",
773
773
  className: "flex-grow pr-2",
774
- children: n.name ? n.name : " "
774
+ children: a.name ? a.name : " "
775
775
  }
776
776
  ),
777
777
  /* @__PURE__ */ i(
778
- m,
778
+ f,
779
779
  {
780
780
  className: " pr-2",
781
781
  variant: "body2",
@@ -789,202 +789,218 @@ function ge({
789
789
  }
790
790
  );
791
791
  }
792
- function Ot({
792
+ function St({
793
793
  importConfig: e,
794
- properties: n,
795
- propertiesOrder: a
794
+ properties: a,
795
+ propertiesOrder: s
796
796
  }) {
797
- ye(() => {
798
- const r = e.importData.map((s) => ht(s, e.idColumn, e.headersMapping, n, "TEMP_PATH", e.defaultValues));
797
+ De(() => {
798
+ const r = e.importData.map((n) => gt(n, e.idColumn, e.headersMapping, a, "TEMP_PATH", e.defaultValues));
799
799
  console.log("Mapped data", {
800
800
  importConfig: e,
801
801
  mappedData: r
802
802
  }), e.setEntities(r);
803
803
  }, []);
804
- const t = We();
804
+ const t = Ge();
805
805
  return /* @__PURE__ */ i(
806
- Xe,
806
+ Ye,
807
807
  {
808
808
  title: /* @__PURE__ */ p("div", { children: [
809
- /* @__PURE__ */ i(m, { variant: "subtitle2", children: "Imported data preview" }),
810
- /* @__PURE__ */ i(m, { variant: "caption", children: "Entities with the same id will be overwritten" })
809
+ /* @__PURE__ */ i(f, { variant: "subtitle2", children: "Imported data preview" }),
810
+ /* @__PURE__ */ i(f, { variant: "caption", children: "Entities with the same id will be overwritten" })
811
811
  ] }),
812
812
  tableController: {
813
813
  data: e.entities,
814
814
  dataLoading: !1,
815
815
  noMoreToLoad: !1
816
816
  },
817
+ enablePopupIcon: !1,
817
818
  endAdornment: /* @__PURE__ */ i("div", { className: "h-12" }),
818
819
  filterable: !1,
819
820
  sortable: !1,
820
821
  selectionController: t,
821
- properties: n
822
+ properties: a
822
823
  }
823
824
  );
824
825
  }
825
- function $e(e, n) {
826
- const a = {};
826
+ function $e(e, a) {
827
+ const s = {};
827
828
  return e.filter(Boolean).forEach((t) => {
828
829
  Object.keys(t).forEach((r) => {
829
- const s = t[r];
830
- if (typeof s == "object" && !Array.isArray(s)) {
831
- const l = n?.[r], o = l && "properties" in l ? l.properties : void 0, c = $e([s], o);
830
+ const n = t[r];
831
+ if (typeof n == "object" && !Array.isArray(n)) {
832
+ const l = a?.[r], o = l && "properties" in l ? l.properties : void 0, c = $e([n], o);
832
833
  Object.entries(c).forEach(([d, u]) => {
833
- a[`${r}.${d}`] = `${r}.${u}`;
834
+ s[`${r}.${d}`] = `${r}.${u}`;
834
835
  });
835
836
  }
836
- if (!n)
837
- a[r] = r;
838
- else if (r in n)
839
- a[r] = r;
837
+ if (!a)
838
+ s[r] = r;
839
+ else if (r in a)
840
+ s[r] = r;
840
841
  else {
841
- const l = Ge(r);
842
- l in n ? a[r] = l : a[r] = r;
842
+ const l = qe(r);
843
+ l in a ? s[r] = l : s[r] = r;
843
844
  }
844
845
  });
845
- }), a;
846
+ }), s;
846
847
  }
847
- function St(e, n, a, t, r, s, l) {
848
- console.debug("Downloading export", { dataLength: e.length, collection: a, exportType: s, dateExportType: l });
849
- const o = a.properties;
850
- if (s === "csv") {
851
- const c = t ? Ye(e.map((g) => g.values)) : {}, d = It(o, r, c), u = Nt(e, n, o, d, l), f = be(d.map((g) => g.label)), h = u.map((g) => be(g));
852
- xe([f, ...h], `${a.name}.csv`, "text/csv");
848
+ function Be(e, a, s, t, r, n, l, o, c) {
849
+ if (console.debug("Downloading export", {
850
+ dataLength: e.length,
851
+ properties: s,
852
+ exportType: o,
853
+ dateExportType: c
854
+ }), o === "csv") {
855
+ 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));
856
+ we([h, ...g], `${r}.csv`, "text/csv");
853
857
  } else {
854
- const c = _t(e, n, o, l), d = JSON.stringify(c, null, 2);
855
- xe([d], `${a.name}.json`, "application/json");
858
+ const d = kt(e, a, s, c), u = JSON.stringify(d, null, 2);
859
+ we([u], `${r}.json`, "application/json");
856
860
  }
857
861
  }
858
- function Nt(e, n, a, t, r) {
859
- const s = e.map((l) => ({
862
+ function Ot(e, a, s, t, r) {
863
+ const n = e.map((l) => ({
860
864
  id: l.id,
861
- ...se(l.values, a, "csv", r)
865
+ ...ce(l.values, s, "csv", r)
862
866
  }));
863
- return n && n.forEach((l, o) => {
864
- s[o] = { ...s[o], ...l };
865
- }), s && s.map((l) => t.map((o) => qe(l, o.key)));
867
+ return a && a.forEach((l, o) => {
868
+ n[o] = { ...n[o], ...l };
869
+ }), n && n.map((l) => t.map((o) => Ze(l, o.key)));
866
870
  }
867
- function _t(e, n, a, t) {
868
- const r = e.map((s) => ({
869
- id: s.id,
870
- ...se(s.values, a, "json", t)
871
+ function kt(e, a, s, t) {
872
+ const r = e.map((n) => ({
873
+ id: n.id,
874
+ ...ce(n.values, s, "json", t)
871
875
  }));
872
- return n && n.forEach((s, l) => {
873
- r[l] = { ...r[l], ...s };
876
+ return a && a.forEach((n, l) => {
877
+ r[l] = { ...r[l], ...n };
874
878
  }), r;
875
879
  }
876
- function It(e, n, a) {
877
- const t = [
878
- { label: "id", key: "id" },
879
- ...Object.entries(e).flatMap(([r, s]) => a && a[r] > 1 ? Array.from(
880
- { length: a[r] },
881
- (l, o) => re(s, `${r}[${o}]`, "")
882
- ).flat() : re(s, r, ""))
880
+ function It(e, a, s, t) {
881
+ const r = [
882
+ {
883
+ label: "id",
884
+ key: "id"
885
+ },
886
+ ...(a ?? Object.keys(e)).flatMap((n) => {
887
+ const l = e[n];
888
+ return t && t[n] > 1 ? Array.from(
889
+ { length: t[n] },
890
+ (o, c) => ne(l, `${n}[${c}]`, "")
891
+ ).flat() : ne(l, n, "");
892
+ })
883
893
  ];
884
- return n && t.push(...n.map((r) => ({ label: r, key: r }))), t;
894
+ return s && r.push(...s.map((n) => ({
895
+ label: n,
896
+ key: n
897
+ }))), r;
885
898
  }
886
- function re(e, n, a = "") {
887
- const t = a ? `${a}.${n}` : n;
888
- return e.dataType === "map" && e.properties ? Object.entries(e.properties).map(([r, s]) => re(s, r, t)).flat() : [{ label: t, key: t }];
899
+ function ne(e, a, s = "") {
900
+ const t = s ? `${s}.${a}` : a;
901
+ return e.dataType === "map" && e.properties ? Object.entries(e.properties).map(([r, n]) => ne(n, r, t)).flat() : [{
902
+ label: t,
903
+ key: t
904
+ }];
889
905
  }
890
- function X(e, n, a, t) {
906
+ function X(e, a, s, t) {
891
907
  let r;
892
- if (n.dataType === "map" && n.properties)
893
- r = se(e, n.properties, a, t);
894
- else if (n.dataType === "array")
895
- n.of && Array.isArray(e) ? Array.isArray(n.of) ? r = n.of.map((s, l) => X(e[l], s, a, t)) : n.of.dataType === "map" ? r = a === "csv" ? e.map((s) => JSON.stringify(s)) : e.map((s) => X(s, n.of, a, t)) : r = e.map((s) => X(s, n.of, a, t)) : r = e;
896
- else if (n.dataType === "reference" && e && e.isEntityReference && e.isEntityReference()) {
897
- const s = e || void 0;
898
- r = s ? s.pathWithId : null;
908
+ if (a.dataType === "map" && a.properties)
909
+ r = ce(e, a.properties, s, t);
910
+ else if (a.dataType === "array")
911
+ 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;
912
+ else if (a.dataType === "reference" && e && e.isEntityReference && e.isEntityReference()) {
913
+ const n = e || void 0;
914
+ r = n ? n.pathWithId : null;
899
915
  } else
900
- n.dataType === "date" && e instanceof Date ? r = e ? t === "timestamp" ? e.getTime() : e.toISOString() : null : r = e;
916
+ a.dataType === "date" && e instanceof Date ? r = e ? t === "timestamp" ? e.getTime() : e.toISOString() : null : r = e;
901
917
  return r;
902
918
  }
903
- function se(e, n, a, t) {
904
- const r = Object.entries(n).map(([s, l]) => {
905
- const o = e && e[s], c = X(o, l, a, t);
906
- return c === void 0 ? {} : { [s]: c };
907
- }).reduce((s, l) => ({ ...s, ...l }), {});
919
+ function ce(e, a, s, t) {
920
+ const r = Object.entries(a).map(([n, l]) => {
921
+ const o = e && e[n], c = X(o, l, s, t);
922
+ return c === void 0 ? {} : { [n]: c };
923
+ }).reduce((n, l) => ({ ...n, ...l }), {});
908
924
  return { ...e, ...r };
909
925
  }
910
- function be(e) {
911
- return e.map((n) => n == null ? "" : Array.isArray(n) ? '"' + JSON.stringify(n).replaceAll('"', '\\"') + '"' : '"' + String(n).replaceAll('"', '""') + '"').join(",") + `\r
926
+ function Ce(e) {
927
+ return e.map((a) => a == null ? "" : Array.isArray(a) ? '"' + JSON.stringify(a).replaceAll('"', '\\"') + '"' : '"' + String(a).replaceAll('"', '""') + '"').join(",") + `\r
912
928
  `;
913
929
  }
914
- function xe(e, n, a) {
915
- const t = new Blob(e, { type: a }), r = URL.createObjectURL(t), s = document.createElement("a");
916
- s.href = r, s.setAttribute("download", n), s.click();
930
+ function we(e, a, s) {
931
+ const t = new Blob(e, { type: s }), r = URL.createObjectURL(t), n = document.createElement("a");
932
+ n.href = r, n.setAttribute("download", a), n.click();
917
933
  }
918
- const At = 500;
919
- function Tt({
934
+ const _t = 500;
935
+ function At({
920
936
  collection: e,
921
- path: n,
922
- collectionEntitiesCount: a,
937
+ path: a,
938
+ collectionEntitiesCount: s,
923
939
  onAnalyticsEvent: t,
924
940
  exportAllowed: r,
925
- notAllowedView: s
941
+ notAllowedView: n
926
942
  }) {
927
- const l = G(), o = typeof e.exportable == "object" ? e.exportable : void 0, c = w.useRef(/* @__PURE__ */ new Date()), [d, u] = w.useState(!0), [f, h] = w.useState("csv"), [g, O] = w.useState("string"), k = Qe(), I = De(), A = Ze().resolveAliasesFrom(n), V = !r || r({
928
- collectionEntitiesCount: a,
929
- path: A,
943
+ 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({
944
+ collectionEntitiesCount: s,
945
+ path: E,
930
946
  collection: e
931
- }), b = w.useMemo(() => Oe({
947
+ }), b = y.useMemo(() => Ie({
932
948
  collection: e,
933
- path: A,
949
+ path: E,
934
950
  fields: l.propertyConfigs
935
- }), [e, A]), [T, E] = w.useState(!1), [j, P] = w.useState(), [Y, x] = w.useState(!1), M = D(() => {
936
- x(!0);
937
- }, [x]), q = D(() => {
938
- x(!1);
939
- }, [x]), ie = D(async (S) => {
940
- const U = o?.additionalFields, N = b.additionalFields, Q = U ? await Promise.all(S.map(async (F) => (await Promise.all(U.map(async (v) => ({
941
- [v.key]: await v.builder({
942
- entity: F,
943
- context: k
951
+ }), [e, E]), [T, j] = y.useState(!1), [F, $] = y.useState(), [Q, C] = y.useState(!1), B = v(() => {
952
+ C(!0);
953
+ }, [C]), Z = v(() => {
954
+ C(!1);
955
+ }, [C]), de = v(async (D) => {
956
+ const U = o?.additionalFields, I = b.additionalFields, K = U ? await Promise.all(D.map(async (P) => (await Promise.all(U.map(async (N) => ({
957
+ [N.key]: await N.builder({
958
+ entity: P,
959
+ context: R
944
960
  })
945
- })))).reduce((v, K) => ({ ...v, ...K }), {}))) : [], Z = N ? await Promise.all(S.map(async (F) => (await Promise.all(N.map(async (v) => v.value ? {
946
- [v.key]: await v.value({
947
- entity: F,
948
- context: k
961
+ })))).reduce((N, te) => ({ ...N, ...te }), {}))) : [], ee = I ? await Promise.all(D.map(async (P) => (await Promise.all(I.map(async (N) => N.value ? {
962
+ [N.key]: await N.value({
963
+ entity: P,
964
+ context: R
949
965
  })
950
- } : {}))).reduce((v, K) => ({ ...v, ...K }), {}))) : [];
951
- return [...Q, ...Z];
952
- }, [o?.additionalFields]), oe = D(async (S, U) => {
966
+ } : {}))).reduce((N, te) => ({ ...N, ...te }), {}))) : [];
967
+ return [...K, ...ee];
968
+ }, [o?.additionalFields]), pe = v(async (D, U) => {
953
969
  t?.("export_collection", {
954
- collection: S.path
955
- }), E(!0), I.fetchCollection({
956
- path: A,
957
- collection: S
958
- }).then(async (N) => {
959
- P(void 0);
960
- const Q = await ie(N), Z = [
961
- ...U?.additionalFields?.map((F) => F.key) ?? [],
962
- ...S.additionalFields?.map((F) => F.key) ?? []
970
+ collection: D.path
971
+ }), j(!0), A.fetchCollection({
972
+ path: E,
973
+ collection: D
974
+ }).then(async (I) => {
975
+ $(void 0);
976
+ const K = await de(I), ee = [
977
+ ...U?.additionalFields?.map((P) => P.key) ?? [],
978
+ ...D.additionalFields?.map((P) => P.key) ?? []
963
979
  ];
964
- St(N, Q, S, d, Z, f, g), t?.("export_collection_success", {
965
- collection: S.path
980
+ Be(I, K, D.properties, D.propertiesOrder, D.name, d, ee, m, g), t?.("export_collection_success", {
981
+ collection: D.path
966
982
  });
967
- }).catch((N) => {
968
- console.error("Error loading export data", N), P(N);
969
- }).finally(() => E(!1));
970
- }, [t, I, A, ie, d, f, g]), Le = D(() => {
971
- oe(b, o), q();
972
- }, [oe, b, o, q]);
973
- return /* @__PURE__ */ p($, { children: [
974
- /* @__PURE__ */ i(ae, { title: "Export", children: /* @__PURE__ */ i(ne, { color: "primary", onClick: M, children: /* @__PURE__ */ i(it, {}) }) }),
983
+ }).catch((I) => {
984
+ console.error("Error loading export data", I), $(I);
985
+ }).finally(() => j(!1));
986
+ }, [t, A, E, de, d, m, g]), Le = v(() => {
987
+ pe(b, o), Z();
988
+ }, [pe, b, o, Z]);
989
+ return /* @__PURE__ */ p(M, { children: [
990
+ /* @__PURE__ */ i(q, { title: "Export", children: /* @__PURE__ */ i(Y, { color: "primary", onClick: B, children: /* @__PURE__ */ i(Ee, {}) }) }),
975
991
  /* @__PURE__ */ p(
976
- Ie,
992
+ ie,
977
993
  {
978
- open: Y,
979
- onOpenChange: x,
994
+ open: Q,
995
+ onOpenChange: C,
980
996
  maxWidth: "xl",
981
997
  children: [
982
- /* @__PURE__ */ p(Ae, { className: "flex flex-col gap-4 my-4", children: [
983
- /* @__PURE__ */ i(m, { variant: "h6", children: "Export data" }),
998
+ /* @__PURE__ */ p(le, { className: "flex flex-col gap-4 my-4", children: [
999
+ /* @__PURE__ */ i(f, { variant: "h6", children: "Export data" }),
984
1000
  /* @__PURE__ */ i("div", { children: "Download the the content of this table as a CSV" }),
985
- a > At && /* @__PURE__ */ i(ot, { color: "warning", children: /* @__PURE__ */ p("div", { children: [
1001
+ s > _t && /* @__PURE__ */ i(ot, { color: "warning", children: /* @__PURE__ */ p("div", { children: [
986
1002
  "This collections has a large number of documents (",
987
- a,
1003
+ s,
988
1004
  ")."
989
1005
  ] }) }),
990
1006
  /* @__PURE__ */ p("div", { className: "flex flex-row gap-4", children: [
@@ -997,9 +1013,9 @@ function Tt({
997
1013
  type: "radio",
998
1014
  value: "csv",
999
1015
  name: "exportType",
1000
- checked: f === "csv",
1016
+ checked: m === "csv",
1001
1017
  onChange: () => h("csv"),
1002
- className: R(z, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1018
+ className: k(_, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1003
1019
  }
1004
1020
  ),
1005
1021
  /* @__PURE__ */ i(
@@ -1019,9 +1035,9 @@ function Tt({
1019
1035
  type: "radio",
1020
1036
  value: "json",
1021
1037
  name: "exportType",
1022
- checked: f === "json",
1038
+ checked: m === "json",
1023
1039
  onChange: () => h("json"),
1024
- className: R(z, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1040
+ className: k(_, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1025
1041
  }
1026
1042
  ),
1027
1043
  /* @__PURE__ */ i(
@@ -1044,8 +1060,8 @@ function Tt({
1044
1060
  value: "timestamp",
1045
1061
  name: "dateExportType",
1046
1062
  checked: g === "timestamp",
1047
- onChange: () => O("timestamp"),
1048
- className: R(z, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1063
+ onChange: () => x("timestamp"),
1064
+ className: k(_, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1049
1065
  }
1050
1066
  ),
1051
1067
  /* @__PURE__ */ p(
@@ -1070,8 +1086,8 @@ function Tt({
1070
1086
  value: "string",
1071
1087
  name: "dateExportType",
1072
1088
  checked: g === "string",
1073
- onChange: () => O("string"),
1074
- className: R(z, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1089
+ onChange: () => x("string"),
1090
+ className: k(_, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1075
1091
  }
1076
1092
  ),
1077
1093
  /* @__PURE__ */ p(
@@ -1090,33 +1106,33 @@ function Tt({
1090
1106
  ] })
1091
1107
  ] }),
1092
1108
  /* @__PURE__ */ i(
1093
- Ne,
1109
+ se,
1094
1110
  {
1095
1111
  size: "small",
1096
- disabled: f !== "csv",
1112
+ disabled: m !== "csv",
1097
1113
  value: d,
1098
1114
  onValueChange: u,
1099
1115
  label: "Flatten arrays"
1100
1116
  }
1101
1117
  ),
1102
- !V && s
1118
+ !z && n
1103
1119
  ] }),
1104
- /* @__PURE__ */ p(Te, { children: [
1105
- T && /* @__PURE__ */ i(_e, { size: "small" }),
1120
+ /* @__PURE__ */ p(oe, { children: [
1121
+ T && /* @__PURE__ */ i(Ae, { size: "small" }),
1106
1122
  /* @__PURE__ */ i(
1107
- _,
1123
+ O,
1108
1124
  {
1109
- onClick: q,
1125
+ onClick: Z,
1110
1126
  variant: "text",
1111
1127
  children: "Cancel"
1112
1128
  }
1113
1129
  ),
1114
1130
  /* @__PURE__ */ i(
1115
- _,
1131
+ O,
1116
1132
  {
1117
1133
  variant: "filled",
1118
1134
  onClick: Le,
1119
- disabled: T || !V,
1135
+ disabled: T || !z,
1120
1136
  children: "Download"
1121
1137
  }
1122
1138
  )
@@ -1126,27 +1142,196 @@ function Tt({
1126
1142
  )
1127
1143
  ] });
1128
1144
  }
1129
- function Lt(e) {
1130
- return Be(() => ({
1145
+ function $t(e) {
1146
+ return Ve(() => ({
1131
1147
  key: "import_export",
1132
1148
  collectionView: {
1133
- CollectionActions: [Ct, Tt],
1149
+ CollectionActions: [Dt, At],
1134
1150
  collectionActionsProps: e
1135
1151
  }
1136
1152
  }), [e]);
1137
1153
  }
1154
+ function Bt({
1155
+ data: e,
1156
+ properties: a,
1157
+ propertiesOrder: s
1158
+ }) {
1159
+ 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(() => {
1160
+ m(!0);
1161
+ }, [m]), g = v(() => {
1162
+ m(!1);
1163
+ }, [m]), x = v(() => {
1164
+ Be(e, [], a, s, "export.csv", r, [], l, c), g();
1165
+ }, []);
1166
+ return /* @__PURE__ */ p(M, { children: [
1167
+ /* @__PURE__ */ i(q, { title: "Export", children: /* @__PURE__ */ i(Y, { color: "primary", onClick: h, children: /* @__PURE__ */ i(Ee, {}) }) }),
1168
+ /* @__PURE__ */ p(
1169
+ ie,
1170
+ {
1171
+ open: u,
1172
+ onOpenChange: m,
1173
+ maxWidth: "xl",
1174
+ children: [
1175
+ /* @__PURE__ */ p(le, { className: "flex flex-col gap-4 my-4", children: [
1176
+ /* @__PURE__ */ i(f, { variant: "h6", children: "Export data" }),
1177
+ /* @__PURE__ */ i("div", { children: "Download the the content of this table as a CSV" }),
1178
+ /* @__PURE__ */ p("div", { className: "flex flex-row gap-4", children: [
1179
+ /* @__PURE__ */ p("div", { className: "p-4 flex flex-col", children: [
1180
+ /* @__PURE__ */ p("div", { className: "flex items-center", children: [
1181
+ /* @__PURE__ */ i(
1182
+ "input",
1183
+ {
1184
+ id: "radio-csv",
1185
+ type: "radio",
1186
+ value: "csv",
1187
+ name: "exportType",
1188
+ checked: l === "csv",
1189
+ onChange: () => o("csv"),
1190
+ className: k(_, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1191
+ }
1192
+ ),
1193
+ /* @__PURE__ */ i(
1194
+ "label",
1195
+ {
1196
+ htmlFor: "radio-csv",
1197
+ className: "p-2 text-sm font-medium text-gray-900 dark:text-slate-300",
1198
+ children: "CSV"
1199
+ }
1200
+ )
1201
+ ] }),
1202
+ /* @__PURE__ */ p("div", { className: "flex items-center", children: [
1203
+ /* @__PURE__ */ i(
1204
+ "input",
1205
+ {
1206
+ id: "radio-json",
1207
+ type: "radio",
1208
+ value: "json",
1209
+ name: "exportType",
1210
+ checked: l === "json",
1211
+ onChange: () => o("json"),
1212
+ className: k(_, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1213
+ }
1214
+ ),
1215
+ /* @__PURE__ */ i(
1216
+ "label",
1217
+ {
1218
+ htmlFor: "radio-json",
1219
+ className: "p-2 text-sm font-medium text-gray-900 dark:text-slate-300",
1220
+ children: "JSON"
1221
+ }
1222
+ )
1223
+ ] })
1224
+ ] }),
1225
+ /* @__PURE__ */ p("div", { className: "p-4 flex flex-col", children: [
1226
+ /* @__PURE__ */ p("div", { className: "flex items-center", children: [
1227
+ /* @__PURE__ */ i(
1228
+ "input",
1229
+ {
1230
+ id: "radio-timestamp",
1231
+ type: "radio",
1232
+ value: "timestamp",
1233
+ name: "dateExportType",
1234
+ checked: c === "timestamp",
1235
+ onChange: () => d("timestamp"),
1236
+ className: k(_, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1237
+ }
1238
+ ),
1239
+ /* @__PURE__ */ p(
1240
+ "label",
1241
+ {
1242
+ htmlFor: "radio-timestamp",
1243
+ className: "p-2 text-sm font-medium text-gray-900 dark:text-slate-300",
1244
+ children: [
1245
+ "Dates as timestamps (",
1246
+ t.current.getTime(),
1247
+ ")"
1248
+ ]
1249
+ }
1250
+ )
1251
+ ] }),
1252
+ /* @__PURE__ */ p("div", { className: "flex items-center", children: [
1253
+ /* @__PURE__ */ i(
1254
+ "input",
1255
+ {
1256
+ id: "radio-string",
1257
+ type: "radio",
1258
+ value: "string",
1259
+ name: "dateExportType",
1260
+ checked: c === "string",
1261
+ onChange: () => d("string"),
1262
+ className: k(_, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
1263
+ }
1264
+ ),
1265
+ /* @__PURE__ */ p(
1266
+ "label",
1267
+ {
1268
+ htmlFor: "radio-string",
1269
+ className: "p-2 text-sm font-medium text-gray-900 dark:text-slate-300",
1270
+ children: [
1271
+ "Dates as strings (",
1272
+ t.current.toISOString(),
1273
+ ")"
1274
+ ]
1275
+ }
1276
+ )
1277
+ ] })
1278
+ ] })
1279
+ ] }),
1280
+ /* @__PURE__ */ i(
1281
+ se,
1282
+ {
1283
+ size: "small",
1284
+ disabled: l !== "csv",
1285
+ value: r,
1286
+ onValueChange: n,
1287
+ label: "Flatten arrays"
1288
+ }
1289
+ )
1290
+ ] }),
1291
+ /* @__PURE__ */ p(oe, { children: [
1292
+ /* @__PURE__ */ i(
1293
+ O,
1294
+ {
1295
+ onClick: g,
1296
+ variant: "text",
1297
+ children: "Cancel"
1298
+ }
1299
+ ),
1300
+ /* @__PURE__ */ i(
1301
+ O,
1302
+ {
1303
+ variant: "filled",
1304
+ onClick: x,
1305
+ children: "Download"
1306
+ }
1307
+ )
1308
+ ] })
1309
+ ]
1310
+ }
1311
+ )
1312
+ ] });
1313
+ }
1138
1314
  export {
1139
- bt as DataNewPropertiesMapping,
1140
- vt as ImportFileUpload,
1141
- $t as ImportNewPropertyFieldPreview,
1315
+ Bt as BasicExportAction,
1316
+ yt as DataNewPropertiesMapping,
1317
+ At as ExportCollectionAction,
1318
+ Dt as ImportCollectionAction,
1319
+ St as ImportDataPreview,
1320
+ Ct as ImportFileUpload,
1321
+ Rt as ImportNewPropertyFieldPreview,
1142
1322
  wt as ImportSaveInProgress,
1143
- ht as convertDataToEntity,
1323
+ ve as PropertySelectEntry,
1324
+ gt as convertDataToEntity,
1144
1325
  ft as convertFileToJson,
1326
+ we as downloadBlob,
1327
+ Be as downloadEntitiesExport,
1145
1328
  Fe as flattenEntry,
1146
- gt as getInferenceType,
1147
- te as processValueMapping,
1329
+ Ot as getEntityCSVExportableData,
1330
+ kt as getEntityJsonExportableData,
1331
+ xt as getInferenceType,
1332
+ ae as processValueMapping,
1148
1333
  je as unflattenObject,
1149
- pt as useImportConfig,
1150
- Lt as useImportExportPlugin
1334
+ ut as useImportConfig,
1335
+ $t as useImportExportPlugin
1151
1336
  };
1152
1337
  //# sourceMappingURL=index.es.js.map