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