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