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