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