@firecms/data_import_export 3.0.0-canary.42 → 3.0.0-canary.44

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