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

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