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