@firecms/collection_editor 3.0.0-canary.4 → 3.0.0-canary.5
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
|
@@ -3,7 +3,7 @@ import { SearchIconsView as gr, toSnakeCase as Pt, singular as vr, IconForView a
|
|
|
3
3
|
import * as je from "react";
|
|
4
4
|
import Y, { useState as $, useEffect as de, useMemo as Zt, useCallback as Q, useRef as Le, useDeferredValue as Ir, useContext as Jt } from "react";
|
|
5
5
|
import ve from "react-fast-compare";
|
|
6
|
-
import { Typography as O, useAutoComplete as _r, Container as mt, Tooltip as te, IconButton as oe, Chip as st, TextField as Oe, cn as
|
|
6
|
+
import { Typography as O, useAutoComplete as _r, Container as mt, Tooltip as te, IconButton as oe, Chip as st, TextField as Oe, cn as he, DebouncedTextField as Z, Autocomplete as Fr, AutocompleteItem as Sr, ExpandablePanel as xt, SettingsIcon as He, Select as be, SelectItem as ee, BooleanSwitchWithLabel as ct, Dialog as Fe, AutoAwesomeIcon as ht, Badge as Er, ListIcon as Ar, Button as z, CircularProgress as De, Paper as Ce, DialogContent as Be, DialogActions as ze, RuleIcon as Dr, FileUploadIcon as Br, MultiSelect as zr, MultiSelectItem as St, Checkbox as Et, cardMixin as Qt, cardClickableMixin as Xt, cardSelectedMixin as er, FunctionsIcon as Mr, RemoveCircleIcon as Rr, defaultBorderMixin as wt, RemoveIcon as Ur, DragHandleIcon as jr, AddIcon as se, SelectGroup as At, InfoLabel as Lr, DeleteIcon as dt, ContentCopyIcon as qr, CodeIcon as $r, Table as Dt, TableBody as Bt, TableRow as bt, TableCell as Ue, Alert as Yr, Icon as et, Card as tr, coolIconKeys as zt, Tabs as Hr, Tab as Ct, ArrowBackIcon as tt, LoadingButton as Mt, DoneIcon as Gr, UndoIcon as Kr, SaveIcon as Wr, Menu as Zr, MoreVertIcon as Jr, MenuItem as Qr, Collapse as Xr } from "@firecms/ui";
|
|
7
7
|
import * as rt from "yup";
|
|
8
8
|
import { useFormex as K, Field as H, getIn as I, useCreateFormex as Tt, Formex as kt } from "@firecms/formex";
|
|
9
9
|
import { extractEnumFromValues as ei, buildPropertyFromData as ti, buildEntityPropertiesFromData as ri } from "@firecms/schema_inference";
|
|
@@ -94,7 +94,7 @@ function yi({
|
|
|
94
94
|
),
|
|
95
95
|
/* @__PURE__ */ e(X, { error: m.name && !!c.name, children: m.name && c.name ? c.name : "Name of in this collection, usually a plural name (e.g. Products)" })
|
|
96
96
|
] }),
|
|
97
|
-
/* @__PURE__ */ a("div", { className:
|
|
97
|
+
/* @__PURE__ */ a("div", { className: he("col-span-12 ", R ? "" : "sm:col-span-8"), children: [
|
|
98
98
|
/* @__PURE__ */ e(
|
|
99
99
|
H,
|
|
100
100
|
{
|
|
@@ -291,7 +291,7 @@ function yi({
|
|
|
291
291
|
)
|
|
292
292
|
] }) });
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function me(t) {
|
|
295
295
|
return "properties." + t.replaceAll(".", ".properties.");
|
|
296
296
|
}
|
|
297
297
|
function bi(t) {
|
|
@@ -305,7 +305,7 @@ function ae(t, r) {
|
|
|
305
305
|
}
|
|
306
306
|
function ir(t, r) {
|
|
307
307
|
const n = r ? `${r}.${t}` : t;
|
|
308
|
-
return
|
|
308
|
+
return me(n);
|
|
309
309
|
}
|
|
310
310
|
function Ci({
|
|
311
311
|
enumValues: t,
|
|
@@ -1060,7 +1060,7 @@ function nr({
|
|
|
1060
1060
|
/* @__PURE__ */ a(
|
|
1061
1061
|
Ce,
|
|
1062
1062
|
{
|
|
1063
|
-
className:
|
|
1063
|
+
className: he(
|
|
1064
1064
|
"border",
|
|
1065
1065
|
"pl-2 w-full flex flex-row gap-4 items-center",
|
|
1066
1066
|
Qt,
|
|
@@ -1137,7 +1137,7 @@ function Ti({
|
|
|
1137
1137
|
/* @__PURE__ */ e(
|
|
1138
1138
|
Ce,
|
|
1139
1139
|
{
|
|
1140
|
-
className:
|
|
1140
|
+
className: he(
|
|
1141
1141
|
"pl-2 w-full flex flex-row gap-4 items-center",
|
|
1142
1142
|
Qt,
|
|
1143
1143
|
n ? Xt : "",
|
|
@@ -1385,7 +1385,7 @@ function Oi({ disabled: t, getData: r, allowDataInference: n, propertyConfigs: i
|
|
|
1385
1385
|
const w = N ? ae(N, f) : void 0;
|
|
1386
1386
|
if (!w)
|
|
1387
1387
|
throw Error("collection editor miss config");
|
|
1388
|
-
const _ =
|
|
1388
|
+
const _ = me(w), M = ye(f), R = I(o, M) ?? Object.keys(I(o, bi(f)));
|
|
1389
1389
|
d(_, void 0, !1), d(M, R.filter((D) => D !== N), !1), p(!1), m(void 0), g(void 0);
|
|
1390
1390
|
}, [d, o]), P = h ? ae(h, c) : void 0, k = P ? I(o.properties, P.replaceAll(".", ".properties.")) : void 0, b = !v || v.length < 1, C = Q((N, f) => {
|
|
1391
1391
|
d(ye(f), N, !1);
|
|
@@ -1740,7 +1740,7 @@ function Si({ disabled: t, getData: r, allowDataInference: n, propertyConfigs: i
|
|
|
1740
1740
|
const f = C ? ae(C, N) : void 0;
|
|
1741
1741
|
if (!f)
|
|
1742
1742
|
throw Error("collection editor miss config");
|
|
1743
|
-
d(`oneOf.${
|
|
1743
|
+
d(`oneOf.${me(f)}`, void 0, !1);
|
|
1744
1744
|
const w = `oneOf.${ye(N)}`, _ = I(o, w);
|
|
1745
1745
|
d(w, _.filter((M) => M !== C), !1), p(!1), m(void 0), g(void 0);
|
|
1746
1746
|
}, [d, o]), k = /* @__PURE__ */ a(
|
|
@@ -2374,7 +2374,7 @@ function or({ value: t, optionDisabled: r, propertyConfig: n, existing: i }) {
|
|
|
2374
2374
|
children: /* @__PURE__ */ a(
|
|
2375
2375
|
"div",
|
|
2376
2376
|
{
|
|
2377
|
-
className:
|
|
2377
|
+
className: he(
|
|
2378
2378
|
"flex flex-row items-center text-base min-h-[52px]",
|
|
2379
2379
|
r ? "w-full" : ""
|
|
2380
2380
|
),
|
|
@@ -2815,7 +2815,7 @@ function ji({
|
|
|
2815
2815
|
onClick: (re) => {
|
|
2816
2816
|
we && (re.stopPropagation(), re.preventDefault());
|
|
2817
2817
|
},
|
|
2818
|
-
className:
|
|
2818
|
+
className: he(
|
|
2819
2819
|
"flex items-center",
|
|
2820
2820
|
we ? "w-full pointer-events-none opacity-50" : ""
|
|
2821
2821
|
),
|
|
@@ -3056,21 +3056,21 @@ function Gi({
|
|
|
3056
3056
|
...U,
|
|
3057
3057
|
...g.propertiesOrder ?? []
|
|
3058
3058
|
];
|
|
3059
|
-
v("properties", T, !1),
|
|
3059
|
+
v("properties", T, !1), fe(S), Me(U);
|
|
3060
3060
|
}).finally(() => {
|
|
3061
3061
|
q(!1);
|
|
3062
3062
|
}));
|
|
3063
|
-
} : void 0, re = Q((F) => F ? we.current[F] ?? I(g, ye(F)) : we.current[""], [g]),
|
|
3063
|
+
} : void 0, re = Q((F) => F ? we.current[F] ?? I(g, ye(F)) : we.current[""], [g]), fe = Q((F, U) => {
|
|
3064
3064
|
const T = ye(U);
|
|
3065
3065
|
v(T, F, !1), we.current[U ?? ""] = F;
|
|
3066
3066
|
}, [v]), Te = Q((F, U) => {
|
|
3067
3067
|
const T = F ? ae(F, U) : void 0;
|
|
3068
3068
|
if (!T)
|
|
3069
3069
|
throw Error("collection editor miss config");
|
|
3070
|
-
v(
|
|
3070
|
+
v(me(T), void 0, !1);
|
|
3071
3071
|
const E = re(U).filter((ie) => ie !== F);
|
|
3072
|
-
|
|
3073
|
-
}, [re, v,
|
|
3072
|
+
fe(E, U), J(!1), w(void 0), M(void 0), D(void 0);
|
|
3073
|
+
}, [re, v, fe]), Ge = (F, U) => {
|
|
3074
3074
|
v(ye(U), F, !1);
|
|
3075
3075
|
}, gt = ({
|
|
3076
3076
|
id: F,
|
|
@@ -3083,14 +3083,14 @@ function Gi({
|
|
|
3083
3083
|
[F]: U
|
|
3084
3084
|
}, !1);
|
|
3085
3085
|
const T = [...g.propertiesOrder ?? Object.keys(g.properties), F];
|
|
3086
|
-
|
|
3087
|
-
},
|
|
3086
|
+
fe(T), J(!1), C && (w(T.indexOf(F)), M(F)), D(void 0);
|
|
3087
|
+
}, pe = ({
|
|
3088
3088
|
id: F,
|
|
3089
3089
|
property: U,
|
|
3090
3090
|
previousId: T,
|
|
3091
3091
|
namespace: S
|
|
3092
3092
|
}) => {
|
|
3093
|
-
const E = F ? ae(F, S) : void 0, ie = E ?
|
|
3093
|
+
const E = F ? ae(F, S) : void 0, ie = E ? me(E) : void 0;
|
|
3094
3094
|
if (T && T !== F) {
|
|
3095
3095
|
console.debug("onPropertyChanged, id change", {
|
|
3096
3096
|
id: F,
|
|
@@ -3098,8 +3098,8 @@ function Gi({
|
|
|
3098
3098
|
previousId: T,
|
|
3099
3099
|
namespace: S
|
|
3100
3100
|
});
|
|
3101
|
-
const ke = ae(T, S), Vt =
|
|
3102
|
-
|
|
3101
|
+
const ke = ae(T, S), Vt = me(ke), It = re(S).map((Xe) => Xe === T ? F : Xe).filter((Xe) => Xe !== void 0);
|
|
3102
|
+
fe(It, S), F && (w(It.indexOf(F)), M(F)), v(Vt, void 0, !1), y(Vt, !1, !1);
|
|
3103
3103
|
}
|
|
3104
3104
|
console.debug("onPropertyChanged", {
|
|
3105
3105
|
id: F,
|
|
@@ -3117,7 +3117,7 @@ function Gi({
|
|
|
3117
3117
|
propertyPath: S
|
|
3118
3118
|
}), S) {
|
|
3119
3119
|
const E = T && Object.keys(T).length > 0;
|
|
3120
|
-
i(F, U, E ? T : void 0), x(
|
|
3120
|
+
i(F, U, E ? T : void 0), x(me(S), E ? "Property error" : void 0);
|
|
3121
3121
|
}
|
|
3122
3122
|
}, []), We = () => {
|
|
3123
3123
|
w(void 0), M(void 0);
|
|
@@ -3127,7 +3127,7 @@ function Gi({
|
|
|
3127
3127
|
namespace: U
|
|
3128
3128
|
}), w(Re.indexOf(F)), M(F), D(U);
|
|
3129
3129
|
}, [Re]), yt = /* @__PURE__ */ a("div", { className: "grid grid-cols-12 gap-2 h-full bg-gray-50 dark:bg-gray-900", children: [
|
|
3130
|
-
/* @__PURE__ */ a("div", { className:
|
|
3130
|
+
/* @__PURE__ */ a("div", { className: he(
|
|
3131
3131
|
"p-4 md:p-8 pb-20 md:pb-20",
|
|
3132
3132
|
"col-span-12 lg:col-span-5 h-full overflow-auto",
|
|
3133
3133
|
!N && "border-r " + wt
|
|
@@ -3236,7 +3236,7 @@ function Gi({
|
|
|
3236
3236
|
propertyKey: _,
|
|
3237
3237
|
propertyNamespace: R,
|
|
3238
3238
|
property: s,
|
|
3239
|
-
onPropertyChanged:
|
|
3239
|
+
onPropertyChanged: pe,
|
|
3240
3240
|
onDelete: Te,
|
|
3241
3241
|
onError: Ke,
|
|
3242
3242
|
forceShowErrors: t,
|
|
@@ -3277,7 +3277,7 @@ function Gi({
|
|
|
3277
3277
|
propertyKey: _,
|
|
3278
3278
|
propertyNamespace: R,
|
|
3279
3279
|
property: s,
|
|
3280
|
-
onPropertyChanged:
|
|
3280
|
+
onPropertyChanged: pe,
|
|
3281
3281
|
onDelete: Te,
|
|
3282
3282
|
onError: Ke,
|
|
3283
3283
|
forceShowErrors: t,
|
|
@@ -4148,7 +4148,7 @@ function nt({
|
|
|
4148
4148
|
tr,
|
|
4149
4149
|
{
|
|
4150
4150
|
onClick: i,
|
|
4151
|
-
className:
|
|
4151
|
+
className: he(
|
|
4152
4152
|
"my-2 rounded-md border mx-0 p-6 px-4 focus:outline-none transition ease-in-out duration-150 flex flex-row gap-4 items-center",
|
|
4153
4153
|
"text-gray-700 dark:text-gray-300",
|
|
4154
4154
|
"hover:border-primary-dark hover:text-primary-dark dark:hover:text-primary focus:ring-primary hover:ring-1 hover:ring-primary",
|
|
@@ -4176,12 +4176,12 @@ function Qi({
|
|
|
4176
4176
|
previousId: y,
|
|
4177
4177
|
namespace: P
|
|
4178
4178
|
}) => {
|
|
4179
|
-
const k = v ? ae(v, P) : void 0, b = k ?
|
|
4179
|
+
const k = v ? ae(v, P) : void 0, b = k ? me(k) : void 0, C = (f) => f ? p.current[f] ?? I(o, ye(f)) : p.current[""], N = (f, w) => {
|
|
4180
4180
|
const _ = ye(w);
|
|
4181
4181
|
i(_, f, !1), p.current[w ?? ""] = f;
|
|
4182
4182
|
};
|
|
4183
4183
|
if (y && y !== v) {
|
|
4184
|
-
const f = ae(y, P), w =
|
|
4184
|
+
const f = ae(y, P), w = me(f), M = C(P).map((D) => D === y ? v : D).filter((D) => D !== void 0);
|
|
4185
4185
|
N(M, P);
|
|
4186
4186
|
const R = { ...t.headersMapping };
|
|
4187
4187
|
Object.keys(R).forEach((D) => {
|
|
@@ -4195,7 +4195,7 @@ function Qi({
|
|
|
4195
4195
|
property: y,
|
|
4196
4196
|
namespace: P
|
|
4197
4197
|
}) => {
|
|
4198
|
-
const k = v ? ae(v, P) : void 0, b = k ?
|
|
4198
|
+
const k = v ? ae(v, P) : void 0, b = k ? me(k) : void 0, C = t.importData.map((f) => I(f, x)), N = {
|
|
4199
4199
|
...ti(C, y, rr),
|
|
4200
4200
|
editable: !0
|
|
4201
4201
|
};
|
|
@@ -4575,30 +4575,30 @@ function rn({
|
|
|
4575
4575
|
}
|
|
4576
4576
|
}), {
|
|
4577
4577
|
values: re,
|
|
4578
|
-
setFieldValue:
|
|
4578
|
+
setFieldValue: fe,
|
|
4579
4579
|
isSubmitting: Te,
|
|
4580
4580
|
dirty: Ge,
|
|
4581
4581
|
submitCount: gt
|
|
4582
|
-
} = ue,
|
|
4582
|
+
} = ue, pe = re.path, Ke = l?.includes("/") ? l?.split("/").slice(0, -1).join("/") + "/" + pe : pe, We = Ht(pe, t, y, re.id), Ze = !We && i ? M.convertIdsToPaths(i) : void 0, Je = We ? void 0 : M.resolveAliasesFrom(Ke), Re = Je && x ? () => x(Je, Ze ?? []) : void 0;
|
|
4583
4583
|
de(() => {
|
|
4584
4584
|
m(Ge);
|
|
4585
4585
|
}, [Ge]);
|
|
4586
4586
|
function Qe(T) {
|
|
4587
4587
|
_.setInUse(!0), ri(T, rr).then((S) => {
|
|
4588
4588
|
const E = dr(S);
|
|
4589
|
-
|
|
4589
|
+
fe("properties", E.properties), fe("propertiesOrder", Object.keys(E.properties)), _.setIdColumn(E.idColumn), _.setImportData(T), _.setHeadersMapping(E.headersMapping), _.setOriginProperties(E.properties);
|
|
4590
4590
|
});
|
|
4591
4591
|
}
|
|
4592
4592
|
const vt = !!re.name && !!re.id, yt = () => {
|
|
4593
4593
|
const T = { ...re.properties };
|
|
4594
|
-
_.idColumn && delete T[_.idColumn],
|
|
4594
|
+
_.idColumn && delete T[_.idColumn], fe("properties", T), L();
|
|
4595
4595
|
}, U = b?.editable === void 0 || b?.editable === !0 || t;
|
|
4596
4596
|
return /* @__PURE__ */ e(Be, { fullHeight: !0, children: /* @__PURE__ */ e(kt, { value: ue, children: /* @__PURE__ */ a(j, { children: [
|
|
4597
4597
|
!t && /* @__PURE__ */ a(
|
|
4598
4598
|
Hr,
|
|
4599
4599
|
{
|
|
4600
4600
|
value: s,
|
|
4601
|
-
className:
|
|
4601
|
+
className: he(wt, "justify-end bg-gray-50 dark:bg-gray-950 border-b"),
|
|
4602
4602
|
onValueChange: (T) => V(T),
|
|
4603
4603
|
children: [
|
|
4604
4604
|
/* @__PURE__ */ e(Ct, { value: "details", children: "Details" }),
|
|
@@ -4612,17 +4612,17 @@ function rn({
|
|
|
4612
4612
|
{
|
|
4613
4613
|
noValidate: !0,
|
|
4614
4614
|
onSubmit: ue.handleSubmit,
|
|
4615
|
-
className:
|
|
4615
|
+
className: he(
|
|
4616
4616
|
t ? "h-full" : "h-[calc(100%-48px)]",
|
|
4617
4617
|
"flex-grow flex flex-col relative"
|
|
4618
4618
|
),
|
|
4619
4619
|
children: [
|
|
4620
4620
|
s === "loading" && /* @__PURE__ */ e(Nt, {}),
|
|
4621
|
-
s === "extra_view" &&
|
|
4621
|
+
s === "extra_view" && pe && p?.View && /* @__PURE__ */ e(p.View, { path: pe }),
|
|
4622
4622
|
s === "welcome" && /* @__PURE__ */ e(
|
|
4623
4623
|
Ji,
|
|
4624
4624
|
{
|
|
4625
|
-
path:
|
|
4625
|
+
path: pe,
|
|
4626
4626
|
onContinue: (T) => {
|
|
4627
4627
|
T ? (Qe(T), V("import_data_mapping")) : V("details");
|
|
4628
4628
|
},
|
|
@@ -4652,6 +4652,7 @@ function rn({
|
|
|
4652
4652
|
{
|
|
4653
4653
|
importConfig: _,
|
|
4654
4654
|
collection: re,
|
|
4655
|
+
path: pe,
|
|
4655
4656
|
onImportSuccess: async (T) => {
|
|
4656
4657
|
R.open({
|
|
4657
4658
|
type: "info",
|
|
@@ -5192,7 +5193,7 @@ function cn({
|
|
|
5192
5193
|
return /* @__PURE__ */ e(
|
|
5193
5194
|
tr,
|
|
5194
5195
|
{
|
|
5195
|
-
className:
|
|
5196
|
+
className: he("h-full p-4 min-h-[124px]"),
|
|
5196
5197
|
onClick: i && l ? () => i.createCollection({
|
|
5197
5198
|
initialValues: t ? { group: t } : void 0,
|
|
5198
5199
|
parentCollectionIds: [],
|
|
@@ -5450,7 +5451,7 @@ export {
|
|
|
5450
5451
|
qe as editableProperty,
|
|
5451
5452
|
ae as getFullId,
|
|
5452
5453
|
ir as getFullIdPath,
|
|
5453
|
-
|
|
5454
|
+
me as idToPropertiesPath,
|
|
5454
5455
|
ye as namespaceToPropertiesOrderPath,
|
|
5455
5456
|
bi as namespaceToPropertiesPath,
|
|
5456
5457
|
wi as removeNonEditableProperties,
|