@firecms/data_import_export 3.0.0-alpha.38
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 +21 -0
- package/README.md +87 -0
- package/dist/components/DataNewPropertiesMapping.d.ts +15 -0
- package/dist/components/ImportFileUpload.d.ts +3 -0
- package/dist/components/ImportNewPropertyFieldPreview.d.ts +10 -0
- package/dist/components/ImportSaveInProgress.d.ts +9 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/export_import/ExportCollectionAction.d.ts +10 -0
- package/dist/export_import/ImportCollectionAction.d.ts +13 -0
- package/dist/export_import/export.d.ts +10 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useImportConfig.d.ts +2 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +966 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +3 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/column_mapping.d.ts +22 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/useImportExportPlugin.d.ts +14 -0
- package/dist/utils/data.d.ts +11 -0
- package/dist/utils/file_to_json.d.ts +11 -0
- package/dist/utils/get_import_inference_type.d.ts +2 -0
- package/dist/utils/get_properties_mapping.d.ts +3 -0
- package/dist/utils/index.d.ts +4 -0
- package/package.json +103 -0
- package/src/components/DataNewPropertiesMapping.tsx +128 -0
- package/src/components/ImportFileUpload.tsx +28 -0
- package/src/components/ImportNewPropertyFieldPreview.tsx +67 -0
- package/src/components/ImportSaveInProgress.tsx +103 -0
- package/src/components/index.ts +4 -0
- package/src/export_import/ExportCollectionAction.tsx +243 -0
- package/src/export_import/ImportCollectionAction.tsx +419 -0
- package/src/export_import/export.ts +198 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useImportConfig.tsx +28 -0
- package/src/index.ts +5 -0
- package/src/types/column_mapping.ts +32 -0
- package/src/types/index.ts +1 -0
- package/src/useImportExportPlugin.tsx +23 -0
- package/src/utils/data.ts +210 -0
- package/src/utils/file_to_json.ts +83 -0
- package/src/utils/get_import_inference_type.ts +27 -0
- package/src/utils/get_properties_mapping.ts +60 -0
- package/src/utils/index.ts +4 -0
- package/src/vite-env.d.ts +1 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,966 @@
|
|
|
1
|
+
import { jsxs as p, Fragment as P, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import w, { useState as T, useRef as Ne, useEffect as le, useCallback as x } from "react";
|
|
3
|
+
import { getPropertyInPath as M, EntityReference as ce, Table as Ie, TableHeader as Oe, TableCell as k, TableBody as Ae, TableRow as Ee, Typography as h, ChevronRightIcon as Te, Select as de, SelectItem as H, FileUpload as je, UploadIcon as Fe, useFireCMSContext as G, getFieldConfig as pe, ErrorBoundary as ke, FieldConfigBadge as fe, TextField as Pe, IconButton as K, EditIcon as Me, useDataSource as me, CenteredView as $e, CircularProgress as ue, useSnackbarController as _e, resolveCollection as he, getPropertiesWithPropertiesOrder as Le, Tooltip as ee, FileUploadIcon as Re, Dialog as ge, DialogContent as ye, DialogActions as xe, Button as j, cn as B, defaultBorderMixin as Be, useSelectionController as He, EntityCollectionTable as Je, getArrayValuesCount as Ue, getValueInPath as Ve, useNavigationContext as We, GetAppIcon as ze, Alert as Ge, focusedMixin as V, BooleanSwitchWithLabel as Xe } from "@firecms/core";
|
|
4
|
+
import { buildEntityPropertiesFromData as qe } from "@firecms/schema_inference";
|
|
5
|
+
import * as ae from "xlsx";
|
|
6
|
+
const Qe = () => {
|
|
7
|
+
const [e, r] = T(!1), [n, t] = T(), [a, i] = T([]), [o, l] = T([]), [d, c] = T({}), [f, m] = T({});
|
|
8
|
+
return {
|
|
9
|
+
inUse: e,
|
|
10
|
+
setInUse: r,
|
|
11
|
+
idColumn: n,
|
|
12
|
+
setIdColumn: t,
|
|
13
|
+
entities: o,
|
|
14
|
+
setEntities: l,
|
|
15
|
+
importData: a,
|
|
16
|
+
setImportData: i,
|
|
17
|
+
headersMapping: d,
|
|
18
|
+
setHeadersMapping: c,
|
|
19
|
+
originProperties: f,
|
|
20
|
+
setOriginProperties: m
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
function Ye(e) {
|
|
24
|
+
return new Promise((r, n) => {
|
|
25
|
+
if (e.type === "application/json") {
|
|
26
|
+
const t = new FileReader();
|
|
27
|
+
t.onload = function(a) {
|
|
28
|
+
const i = a.target?.result, o = JSON.parse(i);
|
|
29
|
+
r(o);
|
|
30
|
+
}, t.readAsText(e);
|
|
31
|
+
} else {
|
|
32
|
+
const t = new FileReader();
|
|
33
|
+
t.onload = function(a) {
|
|
34
|
+
const i = new Uint8Array(a.target?.result), o = ae.read(
|
|
35
|
+
i,
|
|
36
|
+
{
|
|
37
|
+
type: "array",
|
|
38
|
+
codepage: 65001,
|
|
39
|
+
cellDates: !0
|
|
40
|
+
}
|
|
41
|
+
), l = o.SheetNames[0], d = o.Sheets[l], m = ae.utils.sheet_to_json(d).map(Ze).map(be);
|
|
42
|
+
r(m);
|
|
43
|
+
}, t.readAsArrayBuffer(e);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function Ze(e) {
|
|
48
|
+
return Object.keys(e).reduce((r, n) => {
|
|
49
|
+
try {
|
|
50
|
+
r[n] = JSON.parse(e[n]);
|
|
51
|
+
} catch {
|
|
52
|
+
r[n] = e[n];
|
|
53
|
+
}
|
|
54
|
+
return r;
|
|
55
|
+
}, {});
|
|
56
|
+
}
|
|
57
|
+
function be(e) {
|
|
58
|
+
return Object.keys(e).reduce((r, n) => {
|
|
59
|
+
let t = r;
|
|
60
|
+
const a = n.split(".");
|
|
61
|
+
return a.forEach((i, o) => {
|
|
62
|
+
if (/^[\w]+\[\d+\]$/.test(i)) {
|
|
63
|
+
const l = i.slice(0, i.indexOf("[")), d = parseInt(i.slice(i.indexOf("[") + 1, i.indexOf("]")));
|
|
64
|
+
t[l] || (t[l] = []), o !== a.length - 1 ? (t[l][d] = t[l][d] || {}, t = t[l][d]) : t[l][d] = e[n];
|
|
65
|
+
} else
|
|
66
|
+
o !== a.length - 1 ? (t[i] = t[i] || {}, t = t[i]) : t[i] = e[n];
|
|
67
|
+
}), r;
|
|
68
|
+
}, {});
|
|
69
|
+
}
|
|
70
|
+
function Ke(e, r, n, t, a, i) {
|
|
71
|
+
const o = ve(e);
|
|
72
|
+
r && delete o[r];
|
|
73
|
+
const l = Object.entries(o).map(([c, f]) => {
|
|
74
|
+
const m = n[c] ?? c;
|
|
75
|
+
if (!M(t, m))
|
|
76
|
+
return {};
|
|
77
|
+
const u = a[m];
|
|
78
|
+
let N = f;
|
|
79
|
+
return u && (N = Y(f, u)), {
|
|
80
|
+
[m]: N
|
|
81
|
+
};
|
|
82
|
+
}).reduce((c, f) => ({ ...c, ...f }), {}), d = be(l);
|
|
83
|
+
return {
|
|
84
|
+
id: r ? e[r] : void 0,
|
|
85
|
+
values: d,
|
|
86
|
+
path: i
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function ve(e, r = "") {
|
|
90
|
+
return Object.keys(e).reduce((n, t) => {
|
|
91
|
+
const a = r ? `${r}.${t}` : t;
|
|
92
|
+
return typeof e[t] == "object" && e[t] !== null && !Array.isArray(e[t]) ? Object.assign(n, ve(e[t], a)) : n[a] = e[t], n;
|
|
93
|
+
}, {});
|
|
94
|
+
}
|
|
95
|
+
function Y(e, r) {
|
|
96
|
+
if (r === void 0)
|
|
97
|
+
return e;
|
|
98
|
+
const {
|
|
99
|
+
from: n,
|
|
100
|
+
to: t
|
|
101
|
+
} = r;
|
|
102
|
+
if (n === "array" && t === "array" && r.fromSubtype && r.toSubtype && Array.isArray(e))
|
|
103
|
+
return e.map((a) => Y(a, {
|
|
104
|
+
from: r.fromSubtype,
|
|
105
|
+
to: r.toSubtype
|
|
106
|
+
}));
|
|
107
|
+
if (n === "string" && t === "number" && typeof e == "string")
|
|
108
|
+
return Number(e);
|
|
109
|
+
if (n === "string" && t === "array" && r.toSubtype && typeof e == "string")
|
|
110
|
+
return e.split(",").map((a) => Y(a, {
|
|
111
|
+
from: "string",
|
|
112
|
+
to: r.toSubtype
|
|
113
|
+
}));
|
|
114
|
+
if (n === "string" && t === "boolean")
|
|
115
|
+
return e === "true";
|
|
116
|
+
if (n === "number" && t === "boolean")
|
|
117
|
+
return e === 1;
|
|
118
|
+
if (n === "boolean" && t === "number")
|
|
119
|
+
return e ? 1 : 0;
|
|
120
|
+
if (n === "boolean" && t === "string")
|
|
121
|
+
return e ? "true" : "false";
|
|
122
|
+
if (n === "number" && t === "string" && typeof e == "number")
|
|
123
|
+
return e.toString();
|
|
124
|
+
if (n === "string" && t === "array" && typeof e == "string")
|
|
125
|
+
return e.split(",").map((a) => a.trim());
|
|
126
|
+
if (n === "string" && t === "date" && typeof e == "string")
|
|
127
|
+
try {
|
|
128
|
+
return new Date(e);
|
|
129
|
+
} catch {
|
|
130
|
+
return e;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
if (n === "date" && t === "string")
|
|
134
|
+
return e instanceof Date && e.toISOString();
|
|
135
|
+
if (n === "number" && t === "date" && typeof e == "number")
|
|
136
|
+
try {
|
|
137
|
+
return new Date(e);
|
|
138
|
+
} catch {
|
|
139
|
+
return e;
|
|
140
|
+
}
|
|
141
|
+
else if (n === "string" && t === "reference" && typeof e == "string") {
|
|
142
|
+
const a = e.split("/").slice(0, -1).join("/"), i = e.split("/").slice(-1)[0];
|
|
143
|
+
return new ce(i, a);
|
|
144
|
+
} else {
|
|
145
|
+
if (n === t)
|
|
146
|
+
return e;
|
|
147
|
+
if (n === "array" && t === "string" && Array.isArray(e))
|
|
148
|
+
return e.join(",");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return e;
|
|
152
|
+
}
|
|
153
|
+
function et(e) {
|
|
154
|
+
return typeof e == "number" ? "number" : typeof e == "string" ? "string" : typeof e == "boolean" ? "boolean" : e instanceof Date ? "date" : Array.isArray(e) ? "array" : "map";
|
|
155
|
+
}
|
|
156
|
+
function tt(e, r) {
|
|
157
|
+
function n(t, a) {
|
|
158
|
+
const i = {};
|
|
159
|
+
return Object.keys(t).forEach((o) => {
|
|
160
|
+
const l = a ? `${a}.${o}` : o, d = M(t, o), c = M(e, l);
|
|
161
|
+
if (d) {
|
|
162
|
+
if (d.dataType === "map" && d.properties) {
|
|
163
|
+
const f = n(d.properties, l);
|
|
164
|
+
Object.keys(f).forEach((m) => {
|
|
165
|
+
i[`${l}.${m}`] = f[m];
|
|
166
|
+
});
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (c) {
|
|
170
|
+
const f = c.dataType, m = d.dataType;
|
|
171
|
+
let y, u;
|
|
172
|
+
d.dataType === "array" && d.of && (u = d.of.dataType), c?.dataType === "array" && c?.of && (y = c.of.dataType), (f !== m || y !== u) && (console.log("Mapping", { currentKey: l, inferredProperty: c, property: d, from: f, to: m, fromSubtype: y, toSubtype: u }), i[o] = {
|
|
173
|
+
from: f,
|
|
174
|
+
to: m,
|
|
175
|
+
fromSubtype: y,
|
|
176
|
+
toSubtype: u
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}), i;
|
|
181
|
+
}
|
|
182
|
+
return n(r);
|
|
183
|
+
}
|
|
184
|
+
function rt({
|
|
185
|
+
idColumn: e,
|
|
186
|
+
headersMapping: r,
|
|
187
|
+
originProperties: n,
|
|
188
|
+
destinationProperties: t,
|
|
189
|
+
onIdPropertyChanged: a,
|
|
190
|
+
buildPropertyView: i
|
|
191
|
+
}) {
|
|
192
|
+
return /* @__PURE__ */ p(P, { children: [
|
|
193
|
+
/* @__PURE__ */ s(
|
|
194
|
+
nt,
|
|
195
|
+
{
|
|
196
|
+
idColumn: e,
|
|
197
|
+
headersMapping: r,
|
|
198
|
+
onChange: a
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
/* @__PURE__ */ p(Ie, { style: {
|
|
202
|
+
tableLayout: "fixed"
|
|
203
|
+
}, children: [
|
|
204
|
+
/* @__PURE__ */ p(Oe, { children: [
|
|
205
|
+
/* @__PURE__ */ s(k, { header: !0, style: { width: "20%" }, children: "Column in file" }),
|
|
206
|
+
/* @__PURE__ */ s(k, { header: !0 }),
|
|
207
|
+
/* @__PURE__ */ s(k, { header: !0, style: { width: "75%" }, children: "Property" })
|
|
208
|
+
] }),
|
|
209
|
+
/* @__PURE__ */ s(Ae, { children: t && Object.entries(r).map(
|
|
210
|
+
([o, l]) => {
|
|
211
|
+
const d = r[o], c = l ? M(t, l) : null, f = M(n, o), m = f ? f.dataType === "array" && typeof f.of == "object" ? `${f.dataType} - ${f.of.dataType}` : f.dataType : void 0;
|
|
212
|
+
return /* @__PURE__ */ p(Ee, { style: { height: "90px" }, children: [
|
|
213
|
+
/* @__PURE__ */ p(k, { style: { width: "20%" }, children: [
|
|
214
|
+
/* @__PURE__ */ s(h, { variant: "body2", children: o }),
|
|
215
|
+
f && /* @__PURE__ */ s(
|
|
216
|
+
h,
|
|
217
|
+
{
|
|
218
|
+
variant: "caption",
|
|
219
|
+
color: "secondary",
|
|
220
|
+
children: m
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
] }),
|
|
224
|
+
/* @__PURE__ */ s(k, { children: /* @__PURE__ */ s(Te, {}) }),
|
|
225
|
+
/* @__PURE__ */ s(
|
|
226
|
+
k,
|
|
227
|
+
{
|
|
228
|
+
className: o === e ? "text-center" : void 0,
|
|
229
|
+
style: { width: "75%" },
|
|
230
|
+
children: i?.({
|
|
231
|
+
isIdColumn: o === e,
|
|
232
|
+
property: c,
|
|
233
|
+
propertyKey: d,
|
|
234
|
+
importKey: o
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
] }, o);
|
|
239
|
+
}
|
|
240
|
+
) })
|
|
241
|
+
] })
|
|
242
|
+
] });
|
|
243
|
+
}
|
|
244
|
+
function nt({
|
|
245
|
+
idColumn: e,
|
|
246
|
+
headersMapping: r,
|
|
247
|
+
onChange: n
|
|
248
|
+
}) {
|
|
249
|
+
return /* @__PURE__ */ s("div", { children: /* @__PURE__ */ p(
|
|
250
|
+
de,
|
|
251
|
+
{
|
|
252
|
+
size: "small",
|
|
253
|
+
value: e ?? "",
|
|
254
|
+
onChange: (t) => {
|
|
255
|
+
n(t.target.value);
|
|
256
|
+
},
|
|
257
|
+
renderValue: (t) => /* @__PURE__ */ s(h, { variant: "body2", children: t !== "" ? t : "Autogenerate ID" }),
|
|
258
|
+
label: "Column that will be used as ID for each document",
|
|
259
|
+
children: [
|
|
260
|
+
/* @__PURE__ */ s(H, { value: "", children: "Autogenerate ID" }),
|
|
261
|
+
Object.entries(r).map(([t, a]) => /* @__PURE__ */ s(H, { value: t, children: t }, t))
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
) });
|
|
265
|
+
}
|
|
266
|
+
function at({ onDataAdded: e }) {
|
|
267
|
+
return /* @__PURE__ */ s(
|
|
268
|
+
je,
|
|
269
|
+
{
|
|
270
|
+
accept: {
|
|
271
|
+
"text/*": [".csv", ".xls", ".xlsx"],
|
|
272
|
+
"application/vnd.ms-excel": [".xls", ".xlsx"],
|
|
273
|
+
"application/msexcel": [".xls", ".xlsx"],
|
|
274
|
+
"application/vnd.ms-office": [".xls", ".xlsx"],
|
|
275
|
+
"application/xls": [".xls", ".xlsx"],
|
|
276
|
+
"application/x-xls": [".xls", ".xlsx"],
|
|
277
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xls", ".xlsx"],
|
|
278
|
+
"application/json": [".json"]
|
|
279
|
+
},
|
|
280
|
+
preventDropOnDocument: !0,
|
|
281
|
+
size: "small",
|
|
282
|
+
maxFiles: 1,
|
|
283
|
+
uploadDescription: /* @__PURE__ */ p(P, { children: [
|
|
284
|
+
/* @__PURE__ */ s(Fe, {}),
|
|
285
|
+
"Drag and drop a file here or click to upload"
|
|
286
|
+
] }),
|
|
287
|
+
onFilesAdded: (r) => {
|
|
288
|
+
r.length > 0 && Ye(r[0]).then((n) => {
|
|
289
|
+
e(n);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
function bt({
|
|
296
|
+
propertyKey: e,
|
|
297
|
+
property: r,
|
|
298
|
+
onEditClick: n,
|
|
299
|
+
includeName: t = !0,
|
|
300
|
+
onPropertyNameChanged: a,
|
|
301
|
+
propertyTypeView: i
|
|
302
|
+
}) {
|
|
303
|
+
const { propertyConfigs: o } = G(), l = r ? pe(r, o) : null;
|
|
304
|
+
return /* @__PURE__ */ s(ke, { children: /* @__PURE__ */ p(
|
|
305
|
+
"div",
|
|
306
|
+
{
|
|
307
|
+
className: "flex flex-row w-full items-center",
|
|
308
|
+
children: [
|
|
309
|
+
/* @__PURE__ */ s("div", { className: "mx-4", children: i ?? /* @__PURE__ */ s(fe, { propertyConfig: l ?? void 0 }) }),
|
|
310
|
+
/* @__PURE__ */ s("div", { className: "w-full flex flex-col grow", children: /* @__PURE__ */ p("div", { className: "flex flex-row items-center gap-2", children: [
|
|
311
|
+
t && /* @__PURE__ */ s(
|
|
312
|
+
Pe,
|
|
313
|
+
{
|
|
314
|
+
size: "small",
|
|
315
|
+
className: "text-base grow",
|
|
316
|
+
value: r?.name ?? "",
|
|
317
|
+
onChange: (d) => {
|
|
318
|
+
a && e && a(e, d.target.value);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
),
|
|
322
|
+
/* @__PURE__ */ s(K, { onClick: n, size: "small", children: /* @__PURE__ */ s(Me, { size: "small" }) })
|
|
323
|
+
] }) })
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
) });
|
|
327
|
+
}
|
|
328
|
+
function it({
|
|
329
|
+
importConfig: e,
|
|
330
|
+
collection: r,
|
|
331
|
+
onImportSuccess: n
|
|
332
|
+
}) {
|
|
333
|
+
const t = me(), a = Ne(!1), [i, o] = T(0);
|
|
334
|
+
function l() {
|
|
335
|
+
a.current || (a.current = !0, we(
|
|
336
|
+
t,
|
|
337
|
+
r,
|
|
338
|
+
e.entities,
|
|
339
|
+
0,
|
|
340
|
+
25,
|
|
341
|
+
o
|
|
342
|
+
).then(() => {
|
|
343
|
+
n(r), a.current = !1;
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
return le(() => {
|
|
347
|
+
l();
|
|
348
|
+
}, []), /* @__PURE__ */ p($e, { className: "flex flex-col gap-4 items-center", children: [
|
|
349
|
+
/* @__PURE__ */ s(ue, {}),
|
|
350
|
+
/* @__PURE__ */ s(h, { variant: "h6", children: "Saving data" }),
|
|
351
|
+
/* @__PURE__ */ p(h, { variant: "body2", children: [
|
|
352
|
+
i,
|
|
353
|
+
"/",
|
|
354
|
+
e.entities.length,
|
|
355
|
+
" entities saved"
|
|
356
|
+
] }),
|
|
357
|
+
/* @__PURE__ */ s(h, { variant: "caption", children: "Do not close this tab or the import will be interrupted." })
|
|
358
|
+
] });
|
|
359
|
+
}
|
|
360
|
+
function we(e, r, n, t = 0, a = 25, i) {
|
|
361
|
+
console.debug("Saving imported data", t, a);
|
|
362
|
+
const o = n.slice(t, t + a);
|
|
363
|
+
return Promise.all(o.map((l) => e.saveEntity({
|
|
364
|
+
path: r.path,
|
|
365
|
+
// TODO: should check if this is correct, specially for subcollections
|
|
366
|
+
values: l.values,
|
|
367
|
+
entityId: l.id,
|
|
368
|
+
collection: r,
|
|
369
|
+
status: "new"
|
|
370
|
+
}))).then(() => t + a < n.length ? (i(t + a), we(e, r, n, t + a, a, i)) : (i(n.length), Promise.resolve()));
|
|
371
|
+
}
|
|
372
|
+
function st({
|
|
373
|
+
collection: e,
|
|
374
|
+
path: r,
|
|
375
|
+
collectionEntitiesCount: n
|
|
376
|
+
}) {
|
|
377
|
+
const t = G(), a = _e(), [i, o] = w.useState(!1), [l, d] = w.useState("initial"), c = Qe(), f = x(() => {
|
|
378
|
+
o(!0), d("initial");
|
|
379
|
+
}, [o]), m = x(() => {
|
|
380
|
+
o(!1);
|
|
381
|
+
}, [o]), y = x(() => {
|
|
382
|
+
d("preview");
|
|
383
|
+
}, []), u = x(() => {
|
|
384
|
+
d("import_data_saving");
|
|
385
|
+
}, []), N = async (g) => {
|
|
386
|
+
if (c.setImportData(g), g.length > 0) {
|
|
387
|
+
const I = await qe(g, et);
|
|
388
|
+
c.setOriginProperties(I);
|
|
389
|
+
const L = De(g);
|
|
390
|
+
c.setHeadersMapping(L);
|
|
391
|
+
const C = Object.keys(L)?.[0];
|
|
392
|
+
if (C?.includes("id") || C?.includes("key")) {
|
|
393
|
+
const O = C;
|
|
394
|
+
c.setIdColumn(O);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
setTimeout(() => {
|
|
398
|
+
d("mapping");
|
|
399
|
+
}, 100);
|
|
400
|
+
}, $ = he({
|
|
401
|
+
collection: e,
|
|
402
|
+
path: r,
|
|
403
|
+
fields: t.propertyConfigs
|
|
404
|
+
}), b = Le($.properties, $.propertiesOrder), J = Object.entries(b).flatMap(([g, I]) => Ce(g, I, 0)), _ = $.propertiesOrder ?? Object.keys($.properties);
|
|
405
|
+
return e.collectionGroup ? null : /* @__PURE__ */ p(P, { children: [
|
|
406
|
+
/* @__PURE__ */ s(ee, { title: "Import", children: /* @__PURE__ */ s(K, { color: "primary", onClick: f, children: /* @__PURE__ */ s(Re, {}) }) }),
|
|
407
|
+
/* @__PURE__ */ p(
|
|
408
|
+
ge,
|
|
409
|
+
{
|
|
410
|
+
open: i,
|
|
411
|
+
fullWidth: l === "preview",
|
|
412
|
+
fullHeight: l === "preview",
|
|
413
|
+
maxWidth: l === "initial" ? "lg" : "7xl",
|
|
414
|
+
children: [
|
|
415
|
+
/* @__PURE__ */ p(ye, { className: "flex flex-col gap-4 my-4", fullHeight: l === "preview", children: [
|
|
416
|
+
l === "initial" && /* @__PURE__ */ p(P, { children: [
|
|
417
|
+
/* @__PURE__ */ s(h, { variant: "h6", children: "Import data" }),
|
|
418
|
+
/* @__PURE__ */ s(h, { variant: "body2", children: "Upload a CSV, Excel or JSON file and map it to your existing schema" }),
|
|
419
|
+
/* @__PURE__ */ s(at, { onDataAdded: N })
|
|
420
|
+
] }),
|
|
421
|
+
l === "mapping" && /* @__PURE__ */ p(P, { children: [
|
|
422
|
+
/* @__PURE__ */ s(h, { variant: "h6", children: "Map fields" }),
|
|
423
|
+
/* @__PURE__ */ s(
|
|
424
|
+
rt,
|
|
425
|
+
{
|
|
426
|
+
headersMapping: c.headersMapping,
|
|
427
|
+
idColumn: c.idColumn,
|
|
428
|
+
originProperties: c.originProperties,
|
|
429
|
+
destinationProperties: b,
|
|
430
|
+
onIdPropertyChanged: (g) => c.setIdColumn(g),
|
|
431
|
+
buildPropertyView: ({
|
|
432
|
+
isIdColumn: g,
|
|
433
|
+
property: I,
|
|
434
|
+
propertyKey: L,
|
|
435
|
+
importKey: C
|
|
436
|
+
}) => /* @__PURE__ */ s(
|
|
437
|
+
ot,
|
|
438
|
+
{
|
|
439
|
+
selectedPropertyKey: L ?? "",
|
|
440
|
+
properties: b,
|
|
441
|
+
propertiesAndLevel: J,
|
|
442
|
+
isIdColumn: g,
|
|
443
|
+
onIdSelected: () => {
|
|
444
|
+
c.setIdColumn(C);
|
|
445
|
+
},
|
|
446
|
+
onPropertySelected: (O) => {
|
|
447
|
+
const A = Object.entries(c.headersMapping).map(([D, S]) => S === O ? { [D]: null } : D === C ? { [D]: O } : { [D]: S }).reduce((D, S) => ({ ...D, ...S }), {});
|
|
448
|
+
c.setHeadersMapping(A), O === c.idColumn && c.setIdColumn(void 0);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
)
|
|
452
|
+
}
|
|
453
|
+
)
|
|
454
|
+
] }),
|
|
455
|
+
l === "preview" && /* @__PURE__ */ s(
|
|
456
|
+
lt,
|
|
457
|
+
{
|
|
458
|
+
importConfig: c,
|
|
459
|
+
properties: b,
|
|
460
|
+
propertiesOrder: _
|
|
461
|
+
}
|
|
462
|
+
),
|
|
463
|
+
l === "import_data_saving" && c && /* @__PURE__ */ s(
|
|
464
|
+
it,
|
|
465
|
+
{
|
|
466
|
+
importConfig: c,
|
|
467
|
+
collection: e,
|
|
468
|
+
onImportSuccess: (g) => {
|
|
469
|
+
m(), a.open({
|
|
470
|
+
type: "info",
|
|
471
|
+
message: "Data imported successfully"
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
)
|
|
476
|
+
] }),
|
|
477
|
+
/* @__PURE__ */ p(xe, { children: [
|
|
478
|
+
l === "mapping" && /* @__PURE__ */ s(
|
|
479
|
+
j,
|
|
480
|
+
{
|
|
481
|
+
onClick: () => d("initial"),
|
|
482
|
+
variant: "text",
|
|
483
|
+
children: "Back"
|
|
484
|
+
}
|
|
485
|
+
),
|
|
486
|
+
l === "preview" && /* @__PURE__ */ s(
|
|
487
|
+
j,
|
|
488
|
+
{
|
|
489
|
+
onClick: () => d("mapping"),
|
|
490
|
+
variant: "text",
|
|
491
|
+
children: "Back"
|
|
492
|
+
}
|
|
493
|
+
),
|
|
494
|
+
/* @__PURE__ */ s(
|
|
495
|
+
j,
|
|
496
|
+
{
|
|
497
|
+
onClick: m,
|
|
498
|
+
variant: "text",
|
|
499
|
+
children: "Cancel"
|
|
500
|
+
}
|
|
501
|
+
),
|
|
502
|
+
l === "mapping" && /* @__PURE__ */ s(
|
|
503
|
+
j,
|
|
504
|
+
{
|
|
505
|
+
variant: "filled",
|
|
506
|
+
onClick: y,
|
|
507
|
+
children: "Next"
|
|
508
|
+
}
|
|
509
|
+
),
|
|
510
|
+
l === "preview" && /* @__PURE__ */ s(
|
|
511
|
+
j,
|
|
512
|
+
{
|
|
513
|
+
variant: "filled",
|
|
514
|
+
onClick: u,
|
|
515
|
+
children: "Save data"
|
|
516
|
+
}
|
|
517
|
+
)
|
|
518
|
+
] })
|
|
519
|
+
]
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
] });
|
|
523
|
+
}
|
|
524
|
+
const W = "__internal_id__";
|
|
525
|
+
function ot({
|
|
526
|
+
selectedPropertyKey: e,
|
|
527
|
+
properties: r,
|
|
528
|
+
onPropertySelected: n,
|
|
529
|
+
onIdSelected: t,
|
|
530
|
+
propertiesAndLevel: a,
|
|
531
|
+
isIdColumn: i
|
|
532
|
+
}) {
|
|
533
|
+
const o = e ? M(r, e) : null, l = x((c) => c === W ? /* @__PURE__ */ s(h, { variant: "body2", className: "p-4", children: "Use this column as ID" }) : !c || !o ? /* @__PURE__ */ s(h, { variant: "body2", className: "p-4", children: "Do not import this property" }) : /* @__PURE__ */ s(
|
|
534
|
+
ie,
|
|
535
|
+
{
|
|
536
|
+
propertyKey: c,
|
|
537
|
+
property: o
|
|
538
|
+
}
|
|
539
|
+
), [o]), d = x((c) => {
|
|
540
|
+
c === W ? (t(), n(null)) : n(c === "" ? null : c);
|
|
541
|
+
}, []);
|
|
542
|
+
return /* @__PURE__ */ p(
|
|
543
|
+
de,
|
|
544
|
+
{
|
|
545
|
+
value: i ? W : e ?? void 0,
|
|
546
|
+
onValueChange: d,
|
|
547
|
+
renderValue: l,
|
|
548
|
+
children: [
|
|
549
|
+
/* @__PURE__ */ s(H, { value: "", children: /* @__PURE__ */ s(h, { variant: "body2", className: "p-4", children: "Do not import this property" }) }),
|
|
550
|
+
/* @__PURE__ */ s(H, { value: W, children: /* @__PURE__ */ s(h, { variant: "body2", className: "p-4", children: "Use this column as ID" }) }),
|
|
551
|
+
a.map(({
|
|
552
|
+
property: c,
|
|
553
|
+
level: f,
|
|
554
|
+
propertyKey: m
|
|
555
|
+
}) => /* @__PURE__ */ s(
|
|
556
|
+
H,
|
|
557
|
+
{
|
|
558
|
+
value: m,
|
|
559
|
+
disabled: c.dataType === "map",
|
|
560
|
+
children: /* @__PURE__ */ s(
|
|
561
|
+
ie,
|
|
562
|
+
{
|
|
563
|
+
propertyKey: m,
|
|
564
|
+
property: c,
|
|
565
|
+
level: f
|
|
566
|
+
}
|
|
567
|
+
)
|
|
568
|
+
},
|
|
569
|
+
m
|
|
570
|
+
))
|
|
571
|
+
]
|
|
572
|
+
}
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
function Ce(e, r, n) {
|
|
576
|
+
const t = [];
|
|
577
|
+
return t.push({
|
|
578
|
+
property: r,
|
|
579
|
+
level: n,
|
|
580
|
+
propertyKey: e
|
|
581
|
+
}), r.dataType === "map" && r.properties && Object.entries(r.properties).forEach(([a, i]) => {
|
|
582
|
+
t.push(...Ce(`${e}.${a}`, i, n + 1));
|
|
583
|
+
}), t;
|
|
584
|
+
}
|
|
585
|
+
function ie({
|
|
586
|
+
propertyKey: e,
|
|
587
|
+
property: r,
|
|
588
|
+
level: n = 0
|
|
589
|
+
}) {
|
|
590
|
+
const { propertyConfigs: t } = G(), a = pe(r, t);
|
|
591
|
+
return /* @__PURE__ */ p(
|
|
592
|
+
"div",
|
|
593
|
+
{
|
|
594
|
+
className: "flex flex-row w-full text-start items-center h-full",
|
|
595
|
+
children: [
|
|
596
|
+
new Array(n).fill(0).map((i, o) => /* @__PURE__ */ s("div", { className: B(Be, "ml-8 border-l h-12") }, o)),
|
|
597
|
+
/* @__PURE__ */ s("div", { className: "m-4", children: /* @__PURE__ */ s(ee, { title: a?.name, children: /* @__PURE__ */ s(fe, { propertyConfig: a }) }) }),
|
|
598
|
+
/* @__PURE__ */ p("div", { className: "flex flex-col flex-grow p-2 pl-2", children: [
|
|
599
|
+
/* @__PURE__ */ s(
|
|
600
|
+
h,
|
|
601
|
+
{
|
|
602
|
+
variant: "body1",
|
|
603
|
+
component: "span",
|
|
604
|
+
className: "flex-grow pr-2",
|
|
605
|
+
children: r.name ? r.name : " "
|
|
606
|
+
}
|
|
607
|
+
),
|
|
608
|
+
/* @__PURE__ */ s(
|
|
609
|
+
h,
|
|
610
|
+
{
|
|
611
|
+
className: " pr-2",
|
|
612
|
+
variant: "body2",
|
|
613
|
+
component: "span",
|
|
614
|
+
color: "secondary",
|
|
615
|
+
children: e
|
|
616
|
+
}
|
|
617
|
+
)
|
|
618
|
+
] })
|
|
619
|
+
]
|
|
620
|
+
}
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
function lt({
|
|
624
|
+
importConfig: e,
|
|
625
|
+
properties: r,
|
|
626
|
+
propertiesOrder: n
|
|
627
|
+
}) {
|
|
628
|
+
le(() => {
|
|
629
|
+
const a = tt(e.originProperties, r), i = e.importData.map((o) => Ke(o, e.idColumn, e.headersMapping, r, a, "TEMP_PATH"));
|
|
630
|
+
e.setEntities(i);
|
|
631
|
+
}, []);
|
|
632
|
+
const t = He();
|
|
633
|
+
return /* @__PURE__ */ s(
|
|
634
|
+
Je,
|
|
635
|
+
{
|
|
636
|
+
title: /* @__PURE__ */ p("div", { children: [
|
|
637
|
+
/* @__PURE__ */ s(h, { variant: "subtitle2", children: "Imported data preview" }),
|
|
638
|
+
/* @__PURE__ */ s(h, { variant: "caption", children: "Entities with the same id will be overwritten" })
|
|
639
|
+
] }),
|
|
640
|
+
tableController: {
|
|
641
|
+
data: e.entities,
|
|
642
|
+
dataLoading: !1,
|
|
643
|
+
noMoreToLoad: !1
|
|
644
|
+
},
|
|
645
|
+
endAdornment: /* @__PURE__ */ s("div", { className: "h-12" }),
|
|
646
|
+
filterable: !1,
|
|
647
|
+
sortable: !1,
|
|
648
|
+
selectionController: t,
|
|
649
|
+
displayedColumnIds: n.map((a) => ({
|
|
650
|
+
key: a,
|
|
651
|
+
disabled: !1
|
|
652
|
+
})),
|
|
653
|
+
properties: r
|
|
654
|
+
}
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
function De(e) {
|
|
658
|
+
const r = {};
|
|
659
|
+
return e.forEach((n) => {
|
|
660
|
+
Object.keys(n).forEach((t) => {
|
|
661
|
+
const a = n[t];
|
|
662
|
+
typeof a == "object" && !Array.isArray(a) && Object.entries(De([a])).forEach(([i, o]) => {
|
|
663
|
+
r[`${t}.${i}`] = `${t}.${o}`;
|
|
664
|
+
}), r[t] = t;
|
|
665
|
+
});
|
|
666
|
+
}), r;
|
|
667
|
+
}
|
|
668
|
+
function ct(e, r, n, t, a, i, o) {
|
|
669
|
+
const l = n.properties;
|
|
670
|
+
if (i === "csv") {
|
|
671
|
+
const d = t ? Ue(e.map((u) => u.values)) : {}, c = ft(l, a, d), f = dt(e, r, l, c, o), m = se(c.map((u) => u.label)), y = f.map((u) => se(u));
|
|
672
|
+
oe([m, ...y], `${n.name}.csv`, "text/csv");
|
|
673
|
+
} else {
|
|
674
|
+
const d = pt(e, r, l, o), c = JSON.stringify(d, null, 2);
|
|
675
|
+
oe([c], `${n.name}.json`, "application/json");
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function dt(e, r, n, t, a) {
|
|
679
|
+
const i = e.map((o) => ({
|
|
680
|
+
id: o.id,
|
|
681
|
+
...te(o.values, n, "csv", a)
|
|
682
|
+
}));
|
|
683
|
+
return r && r.forEach((o, l) => {
|
|
684
|
+
i[l] = { ...i[l], ...o };
|
|
685
|
+
}), i && i.map((o) => t.map((l) => Ve(o, l.key)));
|
|
686
|
+
}
|
|
687
|
+
function pt(e, r, n, t) {
|
|
688
|
+
const a = e.map((i) => ({
|
|
689
|
+
id: i.id,
|
|
690
|
+
...te(i.values, n, "json", t)
|
|
691
|
+
}));
|
|
692
|
+
return r && r.forEach((i, o) => {
|
|
693
|
+
a[o] = { ...a[o], ...i };
|
|
694
|
+
}), a;
|
|
695
|
+
}
|
|
696
|
+
function ft(e, r, n) {
|
|
697
|
+
const t = [
|
|
698
|
+
{ label: "id", key: "id" },
|
|
699
|
+
...Object.entries(e).flatMap(([a, i]) => n && n[a] > 1 ? Array.from(
|
|
700
|
+
{ length: n[a] },
|
|
701
|
+
(o, l) => Z(i, `${a}[${l}]`, "")
|
|
702
|
+
).flat() : Z(i, a, ""))
|
|
703
|
+
];
|
|
704
|
+
return r && t.push(...r.map((a) => ({ label: a, key: a }))), t;
|
|
705
|
+
}
|
|
706
|
+
function Z(e, r, n = "") {
|
|
707
|
+
const t = n ? `${n}.${r}` : r;
|
|
708
|
+
return e.dataType === "map" && e.properties ? Object.entries(e.properties).map(([a, i]) => Z(i, a, t)).flat() : [{ label: t, key: t }];
|
|
709
|
+
}
|
|
710
|
+
function z(e, r, n, t) {
|
|
711
|
+
let a;
|
|
712
|
+
if (r.dataType === "map" && r.properties)
|
|
713
|
+
a = te(e, r.properties, n, t);
|
|
714
|
+
else if (r.dataType === "array")
|
|
715
|
+
r.of && Array.isArray(e) ? Array.isArray(r.of) ? a = r.of.map((i, o) => z(e[o], i, n, t)) : r.of.dataType === "map" ? a = n === "csv" ? e.map((i) => JSON.stringify(i)) : e.map((i) => z(i, r.of, n, t)) : a = e.map((i) => z(i, r.of, n, t)) : a = e;
|
|
716
|
+
else if (r.dataType === "reference" && e instanceof ce) {
|
|
717
|
+
const i = e || void 0;
|
|
718
|
+
a = i ? i.pathWithId : null;
|
|
719
|
+
} else
|
|
720
|
+
r.dataType === "date" && e instanceof Date ? a = e ? t === "timestamp" ? e.getTime() : e.toISOString() : null : a = e;
|
|
721
|
+
return a;
|
|
722
|
+
}
|
|
723
|
+
function te(e, r, n, t) {
|
|
724
|
+
const a = Object.entries(r).map(([i, o]) => {
|
|
725
|
+
const l = e && e[i], d = z(l, o, n, t);
|
|
726
|
+
return d === void 0 ? {} : { [i]: d };
|
|
727
|
+
}).reduce((i, o) => ({ ...i, ...o }), {});
|
|
728
|
+
return { ...e, ...a };
|
|
729
|
+
}
|
|
730
|
+
function se(e) {
|
|
731
|
+
return e.map((r) => r == null ? "" : Array.isArray(r) ? '"' + JSON.stringify(r).replaceAll('"', '\\"') + '"' : '"' + String(r).replaceAll('"', '""') + '"').join(",") + `\r
|
|
732
|
+
`;
|
|
733
|
+
}
|
|
734
|
+
function oe(e, r, n) {
|
|
735
|
+
const t = new Blob(e, { type: n }), a = URL.createObjectURL(t), i = document.createElement("a");
|
|
736
|
+
i.href = a, i.setAttribute("download", r), i.click();
|
|
737
|
+
}
|
|
738
|
+
const mt = 500;
|
|
739
|
+
function ut({
|
|
740
|
+
collection: e,
|
|
741
|
+
path: r,
|
|
742
|
+
collectionEntitiesCount: n,
|
|
743
|
+
exportAllowed: t,
|
|
744
|
+
notAllowedView: a
|
|
745
|
+
}) {
|
|
746
|
+
const i = typeof e.exportable == "object" ? e.exportable : void 0, o = w.useRef(/* @__PURE__ */ new Date()), [l, d] = w.useState(!0), [c, f] = w.useState("csv"), [m, y] = w.useState("string"), u = G(), N = me(), b = We().resolveAliasesFrom(r), J = !t || t({
|
|
747
|
+
collectionEntitiesCount: n,
|
|
748
|
+
path: b,
|
|
749
|
+
collection: e
|
|
750
|
+
}), _ = w.useMemo(() => he({
|
|
751
|
+
collection: e,
|
|
752
|
+
path: b,
|
|
753
|
+
fields: u.propertyConfigs
|
|
754
|
+
}), [e, b]), [g, I] = w.useState(!1), [L, C] = w.useState(), [O, A] = w.useState(!1), D = x(() => {
|
|
755
|
+
A(!0);
|
|
756
|
+
}, [A]), S = x(() => {
|
|
757
|
+
A(!1);
|
|
758
|
+
}, [A]), re = x(async (F) => {
|
|
759
|
+
const U = i?.additionalFields, R = _.additionalFields, X = U ? await Promise.all(F.map(async (E) => (await Promise.all(U.map(async (v) => ({
|
|
760
|
+
[v.key]: await v.builder({
|
|
761
|
+
entity: E,
|
|
762
|
+
context: u
|
|
763
|
+
})
|
|
764
|
+
})))).reduce((v, Q) => ({ ...v, ...Q }), {}))) : [], q = R ? await Promise.all(F.map(async (E) => (await Promise.all(R.map(async (v) => v.value ? {
|
|
765
|
+
[v.key]: await v.value({
|
|
766
|
+
entity: E,
|
|
767
|
+
context: u
|
|
768
|
+
})
|
|
769
|
+
} : {}))).reduce((v, Q) => ({ ...v, ...Q }), {}))) : [];
|
|
770
|
+
return [...X, ...q];
|
|
771
|
+
}, [i?.additionalFields]), ne = x(async (F, U) => {
|
|
772
|
+
I(!0), N.fetchCollection({
|
|
773
|
+
path: b,
|
|
774
|
+
collection: F
|
|
775
|
+
}).then(async (R) => {
|
|
776
|
+
C(void 0);
|
|
777
|
+
const X = await re(R), q = [
|
|
778
|
+
...U?.additionalFields?.map((E) => E.key) ?? [],
|
|
779
|
+
...F.additionalFields?.map((E) => E.key) ?? []
|
|
780
|
+
];
|
|
781
|
+
ct(R, X, F, l, q, c, m);
|
|
782
|
+
}).catch(C).finally(() => I(!1));
|
|
783
|
+
}, [N, b, re, l, c, m]), Se = x(() => {
|
|
784
|
+
ne(_, i), S();
|
|
785
|
+
}, [ne, _, i, S]);
|
|
786
|
+
return /* @__PURE__ */ p(P, { children: [
|
|
787
|
+
/* @__PURE__ */ s(ee, { title: "Export", children: /* @__PURE__ */ s(K, { color: "primary", onClick: D, children: /* @__PURE__ */ s(ze, {}) }) }),
|
|
788
|
+
/* @__PURE__ */ p(
|
|
789
|
+
ge,
|
|
790
|
+
{
|
|
791
|
+
open: O,
|
|
792
|
+
onOpenChange: A,
|
|
793
|
+
maxWidth: "xl",
|
|
794
|
+
children: [
|
|
795
|
+
/* @__PURE__ */ p(ye, { className: "flex flex-col gap-4 my-4", children: [
|
|
796
|
+
/* @__PURE__ */ s(h, { variant: "h6", children: "Export data" }),
|
|
797
|
+
/* @__PURE__ */ s("div", { children: "Download the the content of this table as a CSV" }),
|
|
798
|
+
n > mt && /* @__PURE__ */ s(Ge, { color: "warning", children: /* @__PURE__ */ p("div", { children: [
|
|
799
|
+
"This collections has a large number of documents (",
|
|
800
|
+
n,
|
|
801
|
+
")."
|
|
802
|
+
] }) }),
|
|
803
|
+
/* @__PURE__ */ p("div", { className: "flex flex-row gap-4", children: [
|
|
804
|
+
/* @__PURE__ */ p("div", { className: "p-4 flex flex-col", children: [
|
|
805
|
+
/* @__PURE__ */ p("div", { className: "flex items-center", children: [
|
|
806
|
+
/* @__PURE__ */ s(
|
|
807
|
+
"input",
|
|
808
|
+
{
|
|
809
|
+
id: "radio-csv",
|
|
810
|
+
type: "radio",
|
|
811
|
+
value: "csv",
|
|
812
|
+
name: "exportType",
|
|
813
|
+
checked: c === "csv",
|
|
814
|
+
onChange: () => f("csv"),
|
|
815
|
+
className: B(V, "w-4 text-blue-600 bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
|
816
|
+
}
|
|
817
|
+
),
|
|
818
|
+
/* @__PURE__ */ s(
|
|
819
|
+
"label",
|
|
820
|
+
{
|
|
821
|
+
htmlFor: "radio-csv",
|
|
822
|
+
className: "p-2 text-sm font-medium text-gray-900 dark:text-gray-300",
|
|
823
|
+
children: "CSV"
|
|
824
|
+
}
|
|
825
|
+
)
|
|
826
|
+
] }),
|
|
827
|
+
/* @__PURE__ */ p("div", { className: "flex items-center", children: [
|
|
828
|
+
/* @__PURE__ */ s(
|
|
829
|
+
"input",
|
|
830
|
+
{
|
|
831
|
+
id: "radio-json",
|
|
832
|
+
type: "radio",
|
|
833
|
+
value: "json",
|
|
834
|
+
name: "exportType",
|
|
835
|
+
checked: c === "json",
|
|
836
|
+
onChange: () => f("json"),
|
|
837
|
+
className: B(V, "w-4 text-blue-600 bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
|
838
|
+
}
|
|
839
|
+
),
|
|
840
|
+
/* @__PURE__ */ s(
|
|
841
|
+
"label",
|
|
842
|
+
{
|
|
843
|
+
htmlFor: "radio-json",
|
|
844
|
+
className: "p-2 text-sm font-medium text-gray-900 dark:text-gray-300",
|
|
845
|
+
children: "JSON"
|
|
846
|
+
}
|
|
847
|
+
)
|
|
848
|
+
] })
|
|
849
|
+
] }),
|
|
850
|
+
/* @__PURE__ */ p("div", { className: "p-4 flex flex-col", children: [
|
|
851
|
+
/* @__PURE__ */ p("div", { className: "flex items-center", children: [
|
|
852
|
+
/* @__PURE__ */ s(
|
|
853
|
+
"input",
|
|
854
|
+
{
|
|
855
|
+
id: "radio-timestamp",
|
|
856
|
+
type: "radio",
|
|
857
|
+
value: "timestamp",
|
|
858
|
+
name: "dateExportType",
|
|
859
|
+
checked: m === "timestamp",
|
|
860
|
+
onChange: () => y("timestamp"),
|
|
861
|
+
className: B(V, "w-4 text-blue-600 bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
|
862
|
+
}
|
|
863
|
+
),
|
|
864
|
+
/* @__PURE__ */ p(
|
|
865
|
+
"label",
|
|
866
|
+
{
|
|
867
|
+
htmlFor: "radio-timestamp",
|
|
868
|
+
className: "p-2 text-sm font-medium text-gray-900 dark:text-gray-300",
|
|
869
|
+
children: [
|
|
870
|
+
"Dates as timestamps (",
|
|
871
|
+
o.current.getTime(),
|
|
872
|
+
")"
|
|
873
|
+
]
|
|
874
|
+
}
|
|
875
|
+
)
|
|
876
|
+
] }),
|
|
877
|
+
/* @__PURE__ */ p("div", { className: "flex items-center", children: [
|
|
878
|
+
/* @__PURE__ */ s(
|
|
879
|
+
"input",
|
|
880
|
+
{
|
|
881
|
+
id: "radio-string",
|
|
882
|
+
type: "radio",
|
|
883
|
+
value: "string",
|
|
884
|
+
name: "dateExportType",
|
|
885
|
+
checked: m === "string",
|
|
886
|
+
onChange: () => y("string"),
|
|
887
|
+
className: B(V, "w-4 text-blue-600 bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
|
888
|
+
}
|
|
889
|
+
),
|
|
890
|
+
/* @__PURE__ */ p(
|
|
891
|
+
"label",
|
|
892
|
+
{
|
|
893
|
+
htmlFor: "radio-string",
|
|
894
|
+
className: "p-2 text-sm font-medium text-gray-900 dark:text-gray-300",
|
|
895
|
+
children: [
|
|
896
|
+
"Dates as strings (",
|
|
897
|
+
o.current.toISOString(),
|
|
898
|
+
")"
|
|
899
|
+
]
|
|
900
|
+
}
|
|
901
|
+
)
|
|
902
|
+
] })
|
|
903
|
+
] })
|
|
904
|
+
] }),
|
|
905
|
+
/* @__PURE__ */ s(
|
|
906
|
+
Xe,
|
|
907
|
+
{
|
|
908
|
+
size: "small",
|
|
909
|
+
disabled: c !== "csv",
|
|
910
|
+
value: l,
|
|
911
|
+
onValueChange: d,
|
|
912
|
+
label: "Flatten arrays"
|
|
913
|
+
}
|
|
914
|
+
),
|
|
915
|
+
!J && a
|
|
916
|
+
] }),
|
|
917
|
+
/* @__PURE__ */ p(xe, { children: [
|
|
918
|
+
g && /* @__PURE__ */ s(ue, { size: "small" }),
|
|
919
|
+
/* @__PURE__ */ s(
|
|
920
|
+
j,
|
|
921
|
+
{
|
|
922
|
+
onClick: S,
|
|
923
|
+
variant: "text",
|
|
924
|
+
children: "Cancel"
|
|
925
|
+
}
|
|
926
|
+
),
|
|
927
|
+
/* @__PURE__ */ s(
|
|
928
|
+
j,
|
|
929
|
+
{
|
|
930
|
+
variant: "filled",
|
|
931
|
+
onClick: Se,
|
|
932
|
+
disabled: g || !J,
|
|
933
|
+
children: "Download"
|
|
934
|
+
}
|
|
935
|
+
)
|
|
936
|
+
] })
|
|
937
|
+
]
|
|
938
|
+
}
|
|
939
|
+
)
|
|
940
|
+
] });
|
|
941
|
+
}
|
|
942
|
+
function vt(e) {
|
|
943
|
+
return {
|
|
944
|
+
name: "Import/Export",
|
|
945
|
+
collections: {
|
|
946
|
+
CollectionActions: [st, ut],
|
|
947
|
+
collectionActionsProps: e
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
export {
|
|
952
|
+
rt as DataNewPropertiesMapping,
|
|
953
|
+
at as ImportFileUpload,
|
|
954
|
+
bt as ImportNewPropertyFieldPreview,
|
|
955
|
+
it as ImportSaveInProgress,
|
|
956
|
+
Ke as convertDataToEntity,
|
|
957
|
+
Ye as convertFileToJson,
|
|
958
|
+
ve as flattenEntry,
|
|
959
|
+
et as getInferenceType,
|
|
960
|
+
tt as getPropertiesMapping,
|
|
961
|
+
Y as processValueMapping,
|
|
962
|
+
be as unflattenObject,
|
|
963
|
+
Qe as useImportConfig,
|
|
964
|
+
vt as useImportExportPlugin
|
|
965
|
+
};
|
|
966
|
+
//# sourceMappingURL=index.es.js.map
|