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