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