@firecms/data_import_export 3.0.0-alpha.44 → 3.0.0-alpha.45
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/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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
|
|
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
|
|
2
|
+
import w, { useState as T, useRef as Ne, useEffect as le, useCallback as b } 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 be, Button as j, cn as B, defaultBorderMixin as Be, useSelectionController as He, EntityCollectionTable as Je, getArrayValuesCount as Ue, getValueInPath as Ve, useNavigationController as We, GetAppIcon as ze, Alert as Ge, focusedMixin as V, BooleanSwitchWithLabel as Xe } from "@firecms/core";
|
|
4
4
|
import { buildEntityPropertiesFromData as qe } from "@firecms/schema_inference";
|
|
5
5
|
import * as ae from "xlsx";
|
|
6
6
|
const Qe = () => {
|
|
@@ -38,7 +38,7 @@ function Ye(e) {
|
|
|
38
38
|
codepage: 65001,
|
|
39
39
|
cellDates: !0
|
|
40
40
|
}
|
|
41
|
-
), l = o.SheetNames[0], d = o.Sheets[l], m = ae.utils.sheet_to_json(d).map(Ze).map(
|
|
41
|
+
), l = o.SheetNames[0], d = o.Sheets[l], m = ae.utils.sheet_to_json(d).map(Ze).map(xe);
|
|
42
42
|
r(m);
|
|
43
43
|
}, t.readAsArrayBuffer(e);
|
|
44
44
|
}
|
|
@@ -54,7 +54,7 @@ function Ze(e) {
|
|
|
54
54
|
return r;
|
|
55
55
|
}, {});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function xe(e) {
|
|
58
58
|
return Object.keys(e).reduce((r, n) => {
|
|
59
59
|
let t = r;
|
|
60
60
|
const a = n.split(".");
|
|
@@ -79,7 +79,7 @@ function Ke(e, r, n, t, a, i) {
|
|
|
79
79
|
return u && (N = Y(f, u)), {
|
|
80
80
|
[m]: N
|
|
81
81
|
};
|
|
82
|
-
}).reduce((c, f) => ({ ...c, ...f }), {}), d =
|
|
82
|
+
}).reduce((c, f) => ({ ...c, ...f }), {}), d = xe(l);
|
|
83
83
|
return {
|
|
84
84
|
id: r ? e[r] : void 0,
|
|
85
85
|
values: d,
|
|
@@ -292,7 +292,7 @@ function at({ onDataAdded: e }) {
|
|
|
292
292
|
}
|
|
293
293
|
);
|
|
294
294
|
}
|
|
295
|
-
function
|
|
295
|
+
function xt({
|
|
296
296
|
propertyKey: e,
|
|
297
297
|
property: r,
|
|
298
298
|
onEditClick: n,
|
|
@@ -374,13 +374,13 @@ function st({
|
|
|
374
374
|
path: r,
|
|
375
375
|
collectionEntitiesCount: n
|
|
376
376
|
}) {
|
|
377
|
-
const t = G(), a = _e(), [i, o] = w.useState(!1), [l, d] = w.useState("initial"), c = Qe(), f =
|
|
377
|
+
const t = G(), a = _e(), [i, o] = w.useState(!1), [l, d] = w.useState("initial"), c = Qe(), f = b(() => {
|
|
378
378
|
o(!0), d("initial");
|
|
379
|
-
}, [o]), m =
|
|
379
|
+
}, [o]), m = b(() => {
|
|
380
380
|
o(!1);
|
|
381
|
-
}, [o]), y =
|
|
381
|
+
}, [o]), y = b(() => {
|
|
382
382
|
d("preview");
|
|
383
|
-
}, []), u =
|
|
383
|
+
}, []), u = b(() => {
|
|
384
384
|
d("import_data_saving");
|
|
385
385
|
}, []), N = async (g) => {
|
|
386
386
|
if (c.setImportData(g), g.length > 0) {
|
|
@@ -401,7 +401,7 @@ function st({
|
|
|
401
401
|
collection: e,
|
|
402
402
|
path: r,
|
|
403
403
|
fields: t.propertyConfigs
|
|
404
|
-
}),
|
|
404
|
+
}), x = Le($.properties, $.propertiesOrder), J = Object.entries(x).flatMap(([g, I]) => Ce(g, I, 0)), _ = $.propertiesOrder ?? Object.keys($.properties);
|
|
405
405
|
return e.collectionGroup ? null : /* @__PURE__ */ p(P, { children: [
|
|
406
406
|
/* @__PURE__ */ s(ee, { title: "Import", children: /* @__PURE__ */ s(K, { color: "primary", onClick: f, children: /* @__PURE__ */ s(Re, {}) }) }),
|
|
407
407
|
/* @__PURE__ */ p(
|
|
@@ -426,7 +426,7 @@ function st({
|
|
|
426
426
|
headersMapping: c.headersMapping,
|
|
427
427
|
idColumn: c.idColumn,
|
|
428
428
|
originProperties: c.originProperties,
|
|
429
|
-
destinationProperties:
|
|
429
|
+
destinationProperties: x,
|
|
430
430
|
onIdPropertyChanged: (g) => c.setIdColumn(g),
|
|
431
431
|
buildPropertyView: ({
|
|
432
432
|
isIdColumn: g,
|
|
@@ -437,7 +437,7 @@ function st({
|
|
|
437
437
|
ot,
|
|
438
438
|
{
|
|
439
439
|
selectedPropertyKey: L ?? "",
|
|
440
|
-
properties:
|
|
440
|
+
properties: x,
|
|
441
441
|
propertiesAndLevel: J,
|
|
442
442
|
isIdColumn: g,
|
|
443
443
|
onIdSelected: () => {
|
|
@@ -456,7 +456,7 @@ function st({
|
|
|
456
456
|
lt,
|
|
457
457
|
{
|
|
458
458
|
importConfig: c,
|
|
459
|
-
properties:
|
|
459
|
+
properties: x,
|
|
460
460
|
propertiesOrder: _
|
|
461
461
|
}
|
|
462
462
|
),
|
|
@@ -474,7 +474,7 @@ function st({
|
|
|
474
474
|
}
|
|
475
475
|
)
|
|
476
476
|
] }),
|
|
477
|
-
/* @__PURE__ */ p(
|
|
477
|
+
/* @__PURE__ */ p(be, { children: [
|
|
478
478
|
l === "mapping" && /* @__PURE__ */ s(
|
|
479
479
|
j,
|
|
480
480
|
{
|
|
@@ -530,13 +530,13 @@ function ot({
|
|
|
530
530
|
propertiesAndLevel: a,
|
|
531
531
|
isIdColumn: i
|
|
532
532
|
}) {
|
|
533
|
-
const o = e ? M(r, e) : null, l =
|
|
533
|
+
const o = e ? M(r, e) : null, l = b((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
534
|
ie,
|
|
535
535
|
{
|
|
536
536
|
propertyKey: c,
|
|
537
537
|
property: o
|
|
538
538
|
}
|
|
539
|
-
), [o]), d =
|
|
539
|
+
), [o]), d = b((c) => {
|
|
540
540
|
c === W ? (t(), n(null)) : n(c === "" ? null : c);
|
|
541
541
|
}, []);
|
|
542
542
|
return /* @__PURE__ */ p(
|
|
@@ -743,19 +743,19 @@ function ut({
|
|
|
743
743
|
exportAllowed: t,
|
|
744
744
|
notAllowedView: a
|
|
745
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(),
|
|
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(), x = We().resolveAliasesFrom(r), J = !t || t({
|
|
747
747
|
collectionEntitiesCount: n,
|
|
748
|
-
path:
|
|
748
|
+
path: x,
|
|
749
749
|
collection: e
|
|
750
750
|
}), _ = w.useMemo(() => he({
|
|
751
751
|
collection: e,
|
|
752
|
-
path:
|
|
752
|
+
path: x,
|
|
753
753
|
fields: u.propertyConfigs
|
|
754
|
-
}), [e,
|
|
754
|
+
}), [e, x]), [g, I] = w.useState(!1), [L, C] = w.useState(), [O, A] = w.useState(!1), D = b(() => {
|
|
755
755
|
A(!0);
|
|
756
|
-
}, [A]), S =
|
|
756
|
+
}, [A]), S = b(() => {
|
|
757
757
|
A(!1);
|
|
758
|
-
}, [A]), re =
|
|
758
|
+
}, [A]), re = b(async (F) => {
|
|
759
759
|
const U = i?.additionalFields, R = _.additionalFields, X = U ? await Promise.all(F.map(async (E) => (await Promise.all(U.map(async (v) => ({
|
|
760
760
|
[v.key]: await v.builder({
|
|
761
761
|
entity: E,
|
|
@@ -768,9 +768,9 @@ function ut({
|
|
|
768
768
|
})
|
|
769
769
|
} : {}))).reduce((v, Q) => ({ ...v, ...Q }), {}))) : [];
|
|
770
770
|
return [...X, ...q];
|
|
771
|
-
}, [i?.additionalFields]), ne =
|
|
771
|
+
}, [i?.additionalFields]), ne = b(async (F, U) => {
|
|
772
772
|
I(!0), N.fetchCollection({
|
|
773
|
-
path:
|
|
773
|
+
path: x,
|
|
774
774
|
collection: F
|
|
775
775
|
}).then(async (R) => {
|
|
776
776
|
C(void 0);
|
|
@@ -780,7 +780,7 @@ function ut({
|
|
|
780
780
|
];
|
|
781
781
|
ct(R, X, F, l, q, c, m);
|
|
782
782
|
}).catch(C).finally(() => I(!1));
|
|
783
|
-
}, [N,
|
|
783
|
+
}, [N, x, re, l, c, m]), Se = b(() => {
|
|
784
784
|
ne(_, i), S();
|
|
785
785
|
}, [ne, _, i, S]);
|
|
786
786
|
return /* @__PURE__ */ p(P, { children: [
|
|
@@ -914,7 +914,7 @@ function ut({
|
|
|
914
914
|
),
|
|
915
915
|
!J && a
|
|
916
916
|
] }),
|
|
917
|
-
/* @__PURE__ */ p(
|
|
917
|
+
/* @__PURE__ */ p(be, { children: [
|
|
918
918
|
g && /* @__PURE__ */ s(ue, { size: "small" }),
|
|
919
919
|
/* @__PURE__ */ s(
|
|
920
920
|
j,
|
|
@@ -951,7 +951,7 @@ function vt(e) {
|
|
|
951
951
|
export {
|
|
952
952
|
rt as DataNewPropertiesMapping,
|
|
953
953
|
at as ImportFileUpload,
|
|
954
|
-
|
|
954
|
+
xt as ImportNewPropertyFieldPreview,
|
|
955
955
|
it as ImportSaveInProgress,
|
|
956
956
|
Ke as convertDataToEntity,
|
|
957
957
|
Ye as convertFileToJson,
|
|
@@ -959,7 +959,7 @@ export {
|
|
|
959
959
|
et as getInferenceType,
|
|
960
960
|
tt as getPropertiesMapping,
|
|
961
961
|
Y as processValueMapping,
|
|
962
|
-
|
|
962
|
+
xe as unflattenObject,
|
|
963
963
|
Qe as useImportConfig,
|
|
964
964
|
vt as useImportExportPlugin
|
|
965
965
|
};
|