@firecms/data_import_export 3.0.0-alpha.78 → 3.0.0-alpha.80
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,7 +1,7 @@
|
|
|
1
|
-
import w, { useState as T, useRef as Ne, useEffect as le, useCallback as
|
|
1
|
+
import w, { useState as T, useRef as Ne, useEffect as le, useCallback as x, useMemo as Ie } from "react";
|
|
2
2
|
import { jsxs as p, Fragment as P, jsx as s } from "react/jsx-runtime";
|
|
3
3
|
import { getPropertyInPath as M, EntityReference as ce, useFireCMSContext as G, getFieldConfig as de, ErrorBoundary as Oe, FieldConfigBadge as pe, useDataSource as fe, useSnackbarController as Ae, resolveCollection as me, getPropertiesWithPropertiesOrder as Ee, useSelectionController as Te, EntityCollectionTable as je, getArrayValuesCount as Fe, getValueInPath as ke, useNavigationController as Pe } from "@firecms/core";
|
|
4
|
-
import { Table as Me, TableHeader as $e, TableCell as k, TableBody as _e, TableRow as Be, Typography as h, ChevronRightIcon as Le, Select as ue, SelectItem as H, FileUpload as Re, UploadIcon as He, TextField as Je, IconButton as K, EditIcon as Ue, CenteredView as Ve, CircularProgress as he, Tooltip as ee, FileUploadIcon as We, Dialog as ge, DialogContent as ye, DialogActions as
|
|
4
|
+
import { Table as Me, TableHeader as $e, TableCell as k, TableBody as _e, TableRow as Be, Typography as h, ChevronRightIcon as Le, Select as ue, SelectItem as H, FileUpload as Re, UploadIcon as He, TextField as Je, IconButton as K, EditIcon as Ue, CenteredView as Ve, CircularProgress as he, Tooltip as ee, FileUploadIcon as We, Dialog as ge, DialogContent as ye, DialogActions as xe, Button as j, cn as R, defaultBorderMixin as ze, GetAppIcon as Ge, Alert as Xe, focusedMixin as V, BooleanSwitchWithLabel as qe } from "@firecms/ui";
|
|
5
5
|
import { buildEntityPropertiesFromData as Qe } from "@firecms/schema_inference";
|
|
6
6
|
import * as ae from "xlsx";
|
|
7
7
|
const Ye = () => {
|
|
@@ -39,7 +39,7 @@ function Ze(e) {
|
|
|
39
39
|
codepage: 65001,
|
|
40
40
|
cellDates: !0
|
|
41
41
|
}
|
|
42
|
-
), l = o.SheetNames[0], d = o.Sheets[l], m = ae.utils.sheet_to_json(d).map(Ke).map(
|
|
42
|
+
), l = o.SheetNames[0], d = o.Sheets[l], m = ae.utils.sheet_to_json(d).map(Ke).map(be);
|
|
43
43
|
r(m);
|
|
44
44
|
}, t.readAsArrayBuffer(e);
|
|
45
45
|
}
|
|
@@ -55,7 +55,7 @@ function Ke(e) {
|
|
|
55
55
|
return r;
|
|
56
56
|
}, {});
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function be(e) {
|
|
59
59
|
return Object.keys(e).reduce((r, n) => {
|
|
60
60
|
let t = r;
|
|
61
61
|
const a = n.split(".");
|
|
@@ -80,7 +80,7 @@ function et(e, r, n, t, a, i) {
|
|
|
80
80
|
return u && (N = Y(f, u)), {
|
|
81
81
|
[m]: N
|
|
82
82
|
};
|
|
83
|
-
}).reduce((c, f) => ({ ...c, ...f }), {}), d =
|
|
83
|
+
}).reduce((c, f) => ({ ...c, ...f }), {}), d = be(l);
|
|
84
84
|
return {
|
|
85
85
|
id: r ? e[r] : void 0,
|
|
86
86
|
values: d,
|
|
@@ -375,13 +375,13 @@ function ot({
|
|
|
375
375
|
path: r,
|
|
376
376
|
collectionEntitiesCount: n
|
|
377
377
|
}) {
|
|
378
|
-
const t = G(), a = Ae(), [i, o] = w.useState(!1), [l, d] = w.useState("initial"), c = Ye(), f =
|
|
378
|
+
const t = G(), a = Ae(), [i, o] = w.useState(!1), [l, d] = w.useState("initial"), c = Ye(), f = x(() => {
|
|
379
379
|
o(!0), d("initial");
|
|
380
|
-
}, [o]), m =
|
|
380
|
+
}, [o]), m = x(() => {
|
|
381
381
|
o(!1);
|
|
382
|
-
}, [o]), y =
|
|
382
|
+
}, [o]), y = x(() => {
|
|
383
383
|
d("preview");
|
|
384
|
-
}, []), u =
|
|
384
|
+
}, []), u = x(() => {
|
|
385
385
|
d("import_data_saving");
|
|
386
386
|
}, []), N = async (g) => {
|
|
387
387
|
if (c.setImportData(g), g.length > 0) {
|
|
@@ -402,7 +402,7 @@ function ot({
|
|
|
402
402
|
collection: e,
|
|
403
403
|
path: r,
|
|
404
404
|
fields: t.propertyConfigs
|
|
405
|
-
}),
|
|
405
|
+
}), b = Ee($.properties, $.propertiesOrder), J = Object.entries(b).flatMap(([g, I]) => Ce(g, I, 0)), _ = $.propertiesOrder ?? Object.keys($.properties);
|
|
406
406
|
return e.collectionGroup ? null : /* @__PURE__ */ p(P, { children: [
|
|
407
407
|
/* @__PURE__ */ s(ee, { title: "Import", children: /* @__PURE__ */ s(K, { color: "primary", onClick: f, children: /* @__PURE__ */ s(We, {}) }) }),
|
|
408
408
|
/* @__PURE__ */ p(
|
|
@@ -427,7 +427,7 @@ function ot({
|
|
|
427
427
|
headersMapping: c.headersMapping,
|
|
428
428
|
idColumn: c.idColumn,
|
|
429
429
|
originProperties: c.originProperties,
|
|
430
|
-
destinationProperties:
|
|
430
|
+
destinationProperties: b,
|
|
431
431
|
onIdPropertyChanged: (g) => c.setIdColumn(g),
|
|
432
432
|
buildPropertyView: ({
|
|
433
433
|
isIdColumn: g,
|
|
@@ -438,7 +438,7 @@ function ot({
|
|
|
438
438
|
lt,
|
|
439
439
|
{
|
|
440
440
|
selectedPropertyKey: B ?? "",
|
|
441
|
-
properties:
|
|
441
|
+
properties: b,
|
|
442
442
|
propertiesAndLevel: J,
|
|
443
443
|
isIdColumn: g,
|
|
444
444
|
onIdSelected: () => {
|
|
@@ -457,7 +457,7 @@ function ot({
|
|
|
457
457
|
ct,
|
|
458
458
|
{
|
|
459
459
|
importConfig: c,
|
|
460
|
-
properties:
|
|
460
|
+
properties: b,
|
|
461
461
|
propertiesOrder: _
|
|
462
462
|
}
|
|
463
463
|
),
|
|
@@ -475,7 +475,7 @@ function ot({
|
|
|
475
475
|
}
|
|
476
476
|
)
|
|
477
477
|
] }),
|
|
478
|
-
/* @__PURE__ */ p(
|
|
478
|
+
/* @__PURE__ */ p(xe, { children: [
|
|
479
479
|
l === "mapping" && /* @__PURE__ */ s(
|
|
480
480
|
j,
|
|
481
481
|
{
|
|
@@ -531,13 +531,13 @@ function lt({
|
|
|
531
531
|
propertiesAndLevel: a,
|
|
532
532
|
isIdColumn: i
|
|
533
533
|
}) {
|
|
534
|
-
const o = e ? M(r, e) : null, l =
|
|
534
|
+
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(
|
|
535
535
|
ie,
|
|
536
536
|
{
|
|
537
537
|
propertyKey: c,
|
|
538
538
|
property: o
|
|
539
539
|
}
|
|
540
|
-
), [o]), d =
|
|
540
|
+
), [o]), d = x((c) => {
|
|
541
541
|
c === W ? (t(), n(null)) : n(c === "" ? null : c);
|
|
542
542
|
}, []);
|
|
543
543
|
return /* @__PURE__ */ p(
|
|
@@ -744,19 +744,19 @@ function ht({
|
|
|
744
744
|
exportAllowed: t,
|
|
745
745
|
notAllowedView: a
|
|
746
746
|
}) {
|
|
747
|
-
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 = fe(),
|
|
747
|
+
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 = fe(), b = Pe().resolveAliasesFrom(r), J = !t || t({
|
|
748
748
|
collectionEntitiesCount: n,
|
|
749
|
-
path:
|
|
749
|
+
path: b,
|
|
750
750
|
collection: e
|
|
751
751
|
}), _ = w.useMemo(() => me({
|
|
752
752
|
collection: e,
|
|
753
|
-
path:
|
|
753
|
+
path: b,
|
|
754
754
|
fields: u.propertyConfigs
|
|
755
|
-
}), [e,
|
|
755
|
+
}), [e, b]), [g, I] = w.useState(!1), [B, C] = w.useState(), [O, A] = w.useState(!1), D = x(() => {
|
|
756
756
|
A(!0);
|
|
757
|
-
}, [A]), S =
|
|
757
|
+
}, [A]), S = x(() => {
|
|
758
758
|
A(!1);
|
|
759
|
-
}, [A]), re =
|
|
759
|
+
}, [A]), re = x(async (F) => {
|
|
760
760
|
const U = i?.additionalFields, L = _.additionalFields, X = U ? await Promise.all(F.map(async (E) => (await Promise.all(U.map(async (v) => ({
|
|
761
761
|
[v.key]: await v.builder({
|
|
762
762
|
entity: E,
|
|
@@ -769,9 +769,9 @@ function ht({
|
|
|
769
769
|
})
|
|
770
770
|
} : {}))).reduce((v, Q) => ({ ...v, ...Q }), {}))) : [];
|
|
771
771
|
return [...X, ...q];
|
|
772
|
-
}, [i?.additionalFields]), ne =
|
|
772
|
+
}, [i?.additionalFields]), ne = x(async (F, U) => {
|
|
773
773
|
I(!0), N.fetchCollection({
|
|
774
|
-
path:
|
|
774
|
+
path: b,
|
|
775
775
|
collection: F
|
|
776
776
|
}).then(async (L) => {
|
|
777
777
|
C(void 0);
|
|
@@ -781,7 +781,7 @@ function ht({
|
|
|
781
781
|
];
|
|
782
782
|
dt(L, X, F, l, q, c, m);
|
|
783
783
|
}).catch(C).finally(() => I(!1));
|
|
784
|
-
}, [N,
|
|
784
|
+
}, [N, b, re, l, c, m]), Se = x(() => {
|
|
785
785
|
ne(_, i), S();
|
|
786
786
|
}, [ne, _, i, S]);
|
|
787
787
|
return /* @__PURE__ */ p(P, { children: [
|
|
@@ -813,7 +813,7 @@ function ht({
|
|
|
813
813
|
name: "exportType",
|
|
814
814
|
checked: c === "csv",
|
|
815
815
|
onChange: () => f("csv"),
|
|
816
|
-
className: R(V, "w-4 text-
|
|
816
|
+
className: R(V, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
|
817
817
|
}
|
|
818
818
|
),
|
|
819
819
|
/* @__PURE__ */ s(
|
|
@@ -835,7 +835,7 @@ function ht({
|
|
|
835
835
|
name: "exportType",
|
|
836
836
|
checked: c === "json",
|
|
837
837
|
onChange: () => f("json"),
|
|
838
|
-
className: R(V, "w-4 text-
|
|
838
|
+
className: R(V, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
|
839
839
|
}
|
|
840
840
|
),
|
|
841
841
|
/* @__PURE__ */ s(
|
|
@@ -859,7 +859,7 @@ function ht({
|
|
|
859
859
|
name: "dateExportType",
|
|
860
860
|
checked: m === "timestamp",
|
|
861
861
|
onChange: () => y("timestamp"),
|
|
862
|
-
className: R(V, "w-4 text-
|
|
862
|
+
className: R(V, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
|
863
863
|
}
|
|
864
864
|
),
|
|
865
865
|
/* @__PURE__ */ p(
|
|
@@ -885,7 +885,7 @@ function ht({
|
|
|
885
885
|
name: "dateExportType",
|
|
886
886
|
checked: m === "string",
|
|
887
887
|
onChange: () => y("string"),
|
|
888
|
-
className: R(V, "w-4 text-
|
|
888
|
+
className: R(V, "w-4 text-primary-dark bg-gray-100 border-gray-300 dark:bg-gray-700 dark:border-gray-600")
|
|
889
889
|
}
|
|
890
890
|
),
|
|
891
891
|
/* @__PURE__ */ p(
|
|
@@ -915,7 +915,7 @@ function ht({
|
|
|
915
915
|
),
|
|
916
916
|
!J && a
|
|
917
917
|
] }),
|
|
918
|
-
/* @__PURE__ */ p(
|
|
918
|
+
/* @__PURE__ */ p(xe, { children: [
|
|
919
919
|
g && /* @__PURE__ */ s(he, { size: "small" }),
|
|
920
920
|
/* @__PURE__ */ s(
|
|
921
921
|
j,
|
|
@@ -960,7 +960,7 @@ export {
|
|
|
960
960
|
tt as getInferenceType,
|
|
961
961
|
rt as getPropertiesMapping,
|
|
962
962
|
Y as processValueMapping,
|
|
963
|
-
|
|
963
|
+
be as unflattenObject,
|
|
964
964
|
Ye as useImportConfig,
|
|
965
965
|
Ct as useImportExportPlugin
|
|
966
966
|
};
|