@grasp-labs/ds-microfrontends-integration 1.0.2 → 1.1.0
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/README.md +49 -27
- package/dist/components/schemaFields/DictionaryField/DictionaryEntry.d.ts +1 -2
- package/dist/components/schemaFields/shared/EntryValueRenderer.d.ts +2 -2
- package/dist/index-BL3nv8aS.js +25113 -0
- package/dist/{index.esm-fQDYRCEr-Bu5aF9wZ.js → index.esm-nnN6KjKn-Bmc4Yh9P.js} +58 -58
- package/dist/index.js +10 -10
- package/dist/mf-common.js +1 -1
- package/dist/types/Navigation.d.ts +22 -14
- package/dist/utils/navigation.d.ts +4 -4
- package/package.json +7 -5
- package/dist/index-BoXm28ra.js +0 -22689
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState as J, useEffect as De,
|
|
3
|
-
const
|
|
1
|
+
import { C as o } from "./index-BL3nv8aS.js";
|
|
2
|
+
import { useState as J, useEffect as De, useRef as ce, useMemo as le, useCallback as Re, createContext as Zt, useContext as Gt } from "react";
|
|
3
|
+
const Be = (e, t, n, r, a) => {
|
|
4
4
|
if (!r) throw new Error(a ?? `Invalid property path: ${t}
|
|
5
5
|
Couldn't access "${n}" in ${JSON.stringify(e)}`);
|
|
6
|
-
},
|
|
6
|
+
}, $t = (e) => typeof e == "object" && e !== null && !Array.isArray(e), gt = (e) => Array.isArray(e), Qt = (e, t) => e.filter(((n, r) => r !== t)), wn = (e, t, n, r = {}) => {
|
|
7
7
|
const { remove: a = !1, createNew: i = !0, noError: s = !1 } = r, p = e, d = typeof (l = t) == "string" ? l : typeof l == "number" ? String(l) : l.reduce(((h, f) => typeof f == "number" ? `${h}[${f}]` : h === "" ? f : `${h}.${f}`), "");
|
|
8
8
|
var l;
|
|
9
9
|
const u = Object.assign(Object.assign({}, r), { remove: a, createNew: i, noError: s, fullData: p, fullPath: d }), c = Array.isArray(t) ? t : ((h) => Array.isArray(h) ? h : h.split(/(\.|\[\d+\])/).filter(((f) => f !== "." && f !== "")).map(((f) => {
|
|
@@ -12,22 +12,22 @@ Couldn't access "${n}" in ${JSON.stringify(e)}`);
|
|
|
12
12
|
})).flat())(t).filter(((h) => h !== ""));
|
|
13
13
|
return gt(e) && a && c.length === 1 ? Qt(e, c[0]) : lt(e, c, n, u);
|
|
14
14
|
}, lt = (e, t, n, r) => {
|
|
15
|
-
const a =
|
|
15
|
+
const a = $t(e) ? Object.assign({}, e) : null, i = gt(e) ? [...e] : null;
|
|
16
16
|
if (t.length === 0) return e;
|
|
17
17
|
if (!a && !i) throw new Error("Can't assign property -- invalid input object");
|
|
18
18
|
const { createNew: s, remove: p, noError: d, fullData: l, fullPath: u } = r, c = t[0];
|
|
19
19
|
if (i && typeof c == "string") return i.map(((b) => lt(b, t, n, r)));
|
|
20
20
|
if (t.length === 1)
|
|
21
|
-
return a && typeof c == "string" ? Dn(a, c, n, r) ?? a : i && typeof c == "number" ? (On(i, c, n, r), i) : (
|
|
21
|
+
return a && typeof c == "string" ? Dn(a, c, n, r) ?? a : i && typeof c == "number" ? (On(i, c, n, r), i) : (Be(l, u, c, d), e);
|
|
22
22
|
const h = a || i || [];
|
|
23
23
|
if (p && t.length === 2 && typeof t[1] == "number") {
|
|
24
24
|
const b = h[c], D = t[1];
|
|
25
|
-
return gt(b) ? h[c] = Qt(b, D) :
|
|
25
|
+
return gt(b) ? h[c] = Qt(b, D) : Be(l, u, c, d, "Trying to remove an indexed item from an object that is not an array"), h;
|
|
26
26
|
}
|
|
27
27
|
const f = t.slice(1);
|
|
28
28
|
if (c in e) {
|
|
29
|
-
if (m = h[c], !gt(m) &&
|
|
30
|
-
if (!s) return
|
|
29
|
+
if (m = h[c], !gt(m) && !$t(m)) {
|
|
30
|
+
if (!s) return Be(l, u, c, d), h;
|
|
31
31
|
h[c] = {};
|
|
32
32
|
}
|
|
33
33
|
return h[c] = lt(h[c], f, n, r), h;
|
|
@@ -42,7 +42,7 @@ Couldn't access "${n}" in ${JSON.stringify(e)}`);
|
|
|
42
42
|
return h[D] = lt(h[D], f, n, r), h;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
return
|
|
45
|
+
return Be(l, u, c, d), h;
|
|
46
46
|
}, Dn = (e, t, n, r) => {
|
|
47
47
|
const { remove: a, createNew: i, noError: s, insertAfter: p, insertBefore: d, fullData: l, fullPath: u } = r;
|
|
48
48
|
if (d !== void 0 || p !== void 0) {
|
|
@@ -51,15 +51,15 @@ Couldn't access "${n}" in ${JSON.stringify(e)}`);
|
|
|
51
51
|
return f = typeof d == "number" ? d : typeof p == "number" ? p : h.findIndex((([m, b]) => m === (d ?? p))), p && f++, h.splice(f, 0, [t, n]), Object.fromEntries(h);
|
|
52
52
|
}
|
|
53
53
|
const c = t in e;
|
|
54
|
-
a ? c ? delete e[t] :
|
|
54
|
+
a ? c ? delete e[t] : Be(l, u, t, s) : i || c ? e[t] = n : Be(l, u, t, s);
|
|
55
55
|
}, On = (e, t, n, r) => {
|
|
56
56
|
const { noError: a, fullData: i, fullPath: s, createNew: p, insert: d } = r;
|
|
57
|
-
d && e.splice(t, 0, n), t in e ? e[t] = n : p ? e.push(n) :
|
|
57
|
+
d && e.splice(t, 0, n), t in e ? e[t] = n : p ? e.push(n) : Be(i, s, t, a);
|
|
58
58
|
}, qe = (e, t, n) => {
|
|
59
59
|
const r = Array.isArray(t) ? t : Cn(t);
|
|
60
60
|
if (r.length === 0) return e;
|
|
61
61
|
const a = r[0];
|
|
62
|
-
if (Array.isArray(e) && typeof a != "number") return e.map(((s) => qe(s, r)));
|
|
62
|
+
if (Array.isArray(e) && typeof a != "number" && e.length > 0) return e.map(((s) => qe(s, r)));
|
|
63
63
|
if (typeof e != "object" || e === null || !(a in e)) return kn(e, a);
|
|
64
64
|
const i = e[a];
|
|
65
65
|
return r.length === 1 ? i : qe(i, r.slice(1));
|
|
@@ -150,13 +150,13 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
150
150
|
if (Array.isArray(t)) return !!a && t.includes(a);
|
|
151
151
|
const { key: i, modifier: s } = t;
|
|
152
152
|
return (n !== "stringLineBreak" || r !== "Enter" || a !== "Shift" || i !== "Enter" || !s?.includes("Shift")) && r === i && (s === a || Array.isArray(s) && s.includes(a));
|
|
153
|
-
}, Fe = { key: "Enter" }, Ht = { confirm: Fe, cancel: { key: "Escape" }, objectConfirm: Object.assign(Object.assign({}, Fe), { modifier: ["Meta", "Shift", "Control"] }), objectLineBreak: Fe, stringConfirm: Fe, stringLineBreak: Object.assign(Object.assign({}, Fe), { modifier: ["Shift"] }), numberConfirm: Fe, numberUp: { key: "ArrowUp" }, numberDown: { key: "ArrowDown" }, tabForward: { key: "Tab" }, tabBack: { key: "Tab", modifier: "Shift" }, booleanConfirm: Fe, booleanToggle: { key: " " }, clipboardModifier: ["Meta", "Control"], collapseModifier: ["Alt"] },
|
|
153
|
+
}, Fe = { key: "Enter" }, Ht = { confirm: Fe, cancel: { key: "Escape" }, objectConfirm: Object.assign(Object.assign({}, Fe), { modifier: ["Meta", "Shift", "Control"] }), objectLineBreak: Fe, stringConfirm: Fe, stringLineBreak: Object.assign(Object.assign({}, Fe), { modifier: ["Shift"] }), numberConfirm: Fe, numberUp: { key: "ArrowUp" }, numberDown: { key: "ArrowDown" }, tabForward: { key: "Tab" }, tabBack: { key: "Tab", modifier: "Shift" }, booleanConfirm: Fe, booleanToggle: { key: " " }, clipboardModifier: ["Meta", "Control"], collapseModifier: ["Alt"] }, $e = (e, t, n = "next", r) => {
|
|
154
154
|
const a = t.slice(0, t.length - 1), i = t.slice(-1)[0];
|
|
155
155
|
if (i === void 0) return null;
|
|
156
156
|
const s = qe(e, a), p = Nn(s);
|
|
157
157
|
Array.isArray(s) || r(p, (({ key: u, value: c }) => [u, c]));
|
|
158
158
|
const d = p.findIndex(((u) => u.key === i)), l = p[d + (n === "next" ? 1 : -1)];
|
|
159
|
-
return l ? et(l.value) ? Object.keys(l.value).length === 0 ?
|
|
159
|
+
return l ? et(l.value) ? Object.keys(l.value).length === 0 ? $e(e, [...a, l.key], n, r) : nn(e, [...a, l.key], n, r) : [...a, l.key] : a.length === 0 ? null : $e(e, a, n, r);
|
|
160
160
|
}, nn = (e, t, n = "next", r) => {
|
|
161
161
|
const a = qe(e, t);
|
|
162
162
|
if (!et(a)) return t;
|
|
@@ -283,7 +283,7 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
283
283
|
}, Fn = ({ value: e, isEditing: t, setIsEditing: n, handleEdit: r, nodeData: a, handleKeyboard: i, keyboardCommon: s }) => {
|
|
284
284
|
const { getStyles: p } = Oe();
|
|
285
285
|
return Mn(t, ((d) => i(d, Object.assign({ confirm: r }, s)))), o.jsx("div", { onDoubleClick: () => n(!0), className: "jer-value-null", style: p("null", a), children: String(e) });
|
|
286
|
-
},
|
|
286
|
+
}, Bn = ({ value: e }) => {
|
|
287
287
|
let t = "Error!";
|
|
288
288
|
switch (typeof e) {
|
|
289
289
|
case "string":
|
|
@@ -296,12 +296,12 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
296
296
|
t = "Symbol";
|
|
297
297
|
}
|
|
298
298
|
return o.jsx("span", { className: "jer-value-invalid", children: t });
|
|
299
|
-
},
|
|
299
|
+
}, $n = ({ size: e, style: t, className: n }) => o.jsxs("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: e, height: e, className: n, style: t, children: [o.jsx("path", { d: "M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z" }), o.jsx("path", { d: "M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z" })] }), Wn = ({ size: e, style: t, className: n }) => o.jsxs("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: e, height: e, className: n, style: t, transform: "translate(0, 0.5)", children: [o.jsx("path", { d: "M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z" }), o.jsx("path", { d: "M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z" })] }), Hn = ({ size: e, style: t, className: n }) => o.jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: e, height: e, className: n, style: t, children: o.jsx("path", { d: "M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z" }) }), Un = ({ size: e, style: t, className: n }) => o.jsxs("svg", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, viewBox: "0 0 24 24", width: e, height: e, className: n, style: t, children: [o.jsx("path", { d: "M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z" }), o.jsx("path", { d: "M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11" }), o.jsx("path", { d: "M15 10l-4 4 4 4" })] }), Yn = ({ size: e, style: t, className: n }) => o.jsxs("svg", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, viewBox: "0 0 24 24", width: e, height: e, className: n, style: t, children: [o.jsx("path", { d: "M22 11.08V12a10 10 0 11-5.93-9.14" }), o.jsx("path", { d: "M22 4L12 14.01l-3-3" })] }), Jn = ({ size: e, style: t, className: n }) => o.jsx("svg", { baseProfile: "tiny", viewBox: "0 0 24 24", fill: "currentColor", width: e, height: e, className: n, style: t, children: o.jsx("path", { d: "M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z" }) }), Xn = ({ size: e, style: t, className: n }) => o.jsx("svg", { viewBox: "0 0 512 512", fill: "currentColor", width: e, height: e, className: n, style: t, children: o.jsx("path", { d: "M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z" }) }), We = ({ name: e, nodeData: t }) => {
|
|
300
300
|
var n, r, a, i, s, p, d;
|
|
301
301
|
const { getStyles: l, icons: u } = Oe(), c = { size: "1.4em", className: "jer-icon" };
|
|
302
302
|
switch (e) {
|
|
303
303
|
case "add":
|
|
304
|
-
return (n = u?.add) !== null && n !== void 0 ? n : o.jsx(
|
|
304
|
+
return (n = u?.add) !== null && n !== void 0 ? n : o.jsx($n, Object.assign({}, c, { style: l("iconAdd", t) }));
|
|
305
305
|
case "edit":
|
|
306
306
|
return (r = u?.edit) !== null && r !== void 0 ? r : o.jsx(Wn, Object.assign({}, c, { style: l("iconEdit", t) }));
|
|
307
307
|
case "delete":
|
|
@@ -318,7 +318,7 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
318
318
|
return o.jsx(o.Fragment, {});
|
|
319
319
|
}
|
|
320
320
|
}, ln = ({ startEdit: e, handleDelete: t, handleAdd: n, enableClipboard: r, type: a, customButtons: i, nodeData: s, translate: p, keyboardControls: d, handleKeyboard: l, editConfirmRef: u, getNewKeyOptions: c, jsonStringify: h, onEditEvent: f, showIconTooltips: m }) => {
|
|
321
|
-
const { getStyles: b } = Oe(), D = p("KEY_NEW", s), [O, w] = J(D), [N, _] = J(!1), { key: W, path: z, value: H } = s, X = Array.isArray(N),
|
|
321
|
+
const { getStyles: b } = Oe(), D = p("KEY_NEW", s), [O, w] = J(D), [N, _] = J(!1), { key: W, path: z, value: H } = s, X = Array.isArray(N), B = (C) => {
|
|
322
322
|
var k;
|
|
323
323
|
if (f && f(C ? [...z, null] : null, C), !C) return void _(!1);
|
|
324
324
|
const L = Object.keys(qe(s.fullData, z)), Y = c ? (k = c(s)) === null || k === void 0 ? void 0 : k.filter(((ae) => !L.includes(ae))) : null;
|
|
@@ -338,35 +338,35 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
338
338
|
}));
|
|
339
339
|
}
|
|
340
340
|
}, className: "jer-copy-pulse", title: m ? p("TOOLTIP_COPY", s) : "", children: o.jsx(We, { name: "copy", nodeData: s }) }), e && o.jsx("div", { onClick: e, title: m ? p("TOOLTIP_EDIT", s) : "", children: o.jsx(We, { name: "edit", nodeData: s }) }), t && o.jsx("div", { onClick: t, title: m ? p("TOOLTIP_DELETE", s) : "", children: o.jsx(We, { name: "delete", nodeData: s }) }), n && o.jsx("div", { onClick: () => {
|
|
341
|
-
a === "object" ?
|
|
341
|
+
a === "object" ? B(!0) : n("");
|
|
342
342
|
}, title: m ? p("TOOLTIP_ADD", s) : "", children: o.jsx(We, { name: "add", nodeData: s }) }), i?.map((({ Element: C, onClick: k }, L) => o.jsx("div", { onClick: (Y) => k && k(s, Y), children: o.jsx(C, { nodeData: s }) }, L))), N && n && a === "object" && o.jsxs(o.Fragment, { children: [X ? o.jsxs("div", { className: "jer-select jer-select-keys", children: [o.jsxs("select", { name: "new-key-select", className: "jer-select-inner", onChange: (C) => {
|
|
343
|
-
n(C.target.value),
|
|
343
|
+
n(C.target.value), B(!1);
|
|
344
344
|
}, defaultValue: "", autoFocus: !0, onKeyDown: (C) => {
|
|
345
|
-
l(C, { cancel: () =>
|
|
345
|
+
l(C, { cancel: () => B(!1) });
|
|
346
346
|
}, children: [o.jsx("option", { value: "", disabled: !0, children: N.length > 0 ? p("KEY_SELECT", s) : p("NO_KEY_OPTIONS", s) }), N.map(((C) => o.jsx("option", { value: C, children: C }, C)))] }), o.jsx("span", { className: "focus" })] }) : o.jsx("input", { className: "jer-input-new-key", type: "text", name: "new-object-key", value: O, onChange: (C) => w(C.target.value), autoFocus: !0, onFocus: (C) => C.target.select(), onKeyDown: (C) => {
|
|
347
347
|
l(C, { stringConfirm: () => {
|
|
348
|
-
n && (
|
|
348
|
+
n && (B(!1), n(O), w(D));
|
|
349
349
|
}, cancel: () => {
|
|
350
|
-
|
|
350
|
+
B(!1), w(D);
|
|
351
351
|
} });
|
|
352
352
|
}, style: b("input", s) }), o.jsx(Pt, { onOk: () => {
|
|
353
|
-
X && !O || (
|
|
353
|
+
X && !O || (B(!1), n(O));
|
|
354
354
|
}, onCancel: () => {
|
|
355
|
-
|
|
355
|
+
B(!1);
|
|
356
356
|
}, nodeData: s, editConfirmRef: u, hideOk: X })] })] });
|
|
357
357
|
}, Pt = ({ onOk: e, onCancel: t, nodeData: n, editConfirmRef: r, hideOk: a = !1 }) => o.jsxs("div", { className: "jer-confirm-buttons", children: [!a && o.jsx("div", { onClick: e, ref: r, children: o.jsx(We, { name: "ok", nodeData: n }) }), o.jsx("div", { onClick: t, children: o.jsx(We, { name: "cancel", nodeData: n }) })] }), Zn = (e) => e.reduce(((t, n) => typeof n == "number" ? `${t}[${n}]` : t === "" ? n : `${t}.${n}`), ""), Gn = ["string", "number", "boolean", "null", "object", "array"], cn = ({ props: e, collapsed: t }) => {
|
|
358
|
-
const { data: n, nodeData: r, parentData: a, onEdit: i, onError: s, showErrorMessages: p, restrictEditFilter: d, restrictDeleteFilter: l, restrictAddFilter: u, restrictDragFilter: c, translate: h, errorMessageTimeout: f } = e, { currentlyEditingElement: m, setCurrentlyEditingElement: b } = He(), [D, O] = J(null), w = Object.assign(Object.assign({}, r), { collapsed: t }), { path: N, key: _, size: W } = w, z = Ue(N), H = !d(w), X = !l(w),
|
|
358
|
+
const { data: n, nodeData: r, parentData: a, onEdit: i, onError: s, showErrorMessages: p, restrictEditFilter: d, restrictDeleteFilter: l, restrictAddFilter: u, restrictDragFilter: c, translate: h, errorMessageTimeout: f } = e, { currentlyEditingElement: m, setCurrentlyEditingElement: b } = He(), [D, O] = J(null), w = Object.assign(Object.assign({}, r), { collapsed: t }), { path: N, key: _, size: W } = w, z = Ue(N), H = !d(w), X = !l(w), B = !u(w), C = !c(w) && X && m === null, k = (M) => {
|
|
359
359
|
p && (O(M), setTimeout((() => O(null)), f)), console.warn("Error", M);
|
|
360
360
|
}, L = Re(((M, F) => {
|
|
361
361
|
k(M.message), s && s({ currentData: w.fullData, errorValue: F, currentValue: n, name: _, path: N, error: M });
|
|
362
|
-
}), [s, p]), Y = m === z, ae = m === `key_${z}`, Z = typeof N.slice(-1)[0] == "number", ne = { isEditing: Y, isEditingKey: ae, isArray: Z, canEditKey: a !== null && H &&
|
|
363
|
-
return { pathString: z, nodeData: w, path: N, name: _, size: W, canEdit: H, canDelete: X, canAdd:
|
|
362
|
+
}), [s, p]), Y = m === z, ae = m === `key_${z}`, Z = typeof N.slice(-1)[0] == "number", ne = { isEditing: Y, isEditingKey: ae, isArray: Z, canEditKey: a !== null && H && B && X && !Z }, G = _ === "" && N.length > 0 ? h("EMPTY_STRING", w) : null;
|
|
363
|
+
return { pathString: z, nodeData: w, path: N, name: _, size: W, canEdit: H, canDelete: X, canAdd: B, canDrag: C, error: D, showError: k, onError: L, setError: O, handleEditKey: (M) => {
|
|
364
364
|
if (b(null), _ === M || !a) return;
|
|
365
365
|
const F = N.slice(0, -1);
|
|
366
366
|
if (Object.keys(a).includes(M)) return void L({ code: "KEY_EXISTS", message: h("ERROR_KEY_EXISTS", w) }, M);
|
|
367
|
-
const ge = Object.fromEntries(Object.entries(a).map((([
|
|
368
|
-
i(ge, F).then(((
|
|
369
|
-
|
|
367
|
+
const ge = Object.fromEntries(Object.entries(a).map((([$, R]) => $ === _ ? [M, R] : [$, R])));
|
|
368
|
+
i(ge, F).then((($) => {
|
|
369
|
+
$ && L({ code: "UPDATE_ERROR", message: $ }, M);
|
|
370
370
|
}));
|
|
371
371
|
}, derivedValues: ne, emptyStringKey: G };
|
|
372
372
|
}, dn = ({ canDrag: e, canDragOnto: t, path: n, nodeData: r, onMove: a, onError: i, translate: s }) => {
|
|
@@ -409,7 +409,7 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
409
409
|
p(D.target.value), m(h("prev"));
|
|
410
410
|
} }), style: { width: b.length / 1.5 + 0.5 + "em" } }) : o.jsxs("span", { className: "jer-key-text", style: Object.assign(Object.assign({}, c), { minWidth: `${Math.min(b.length + 1, 5)}ch`, flexShrink: b.length > 10 ? 1 : 0 }), onDoubleClick: () => t && m(r, "key"), onClick: l, children: [f ? o.jsx("span", { className: "jer-empty-string", children: f }) : b, b !== "" || f ? o.jsx("span", { className: "jer-key-colon", children: ":" }) : null] });
|
|
411
411
|
}, un = (e) => {
|
|
412
|
-
const { data: t, parentData: n, onEdit: r, onDelete: a, onChange: i, onMove: s, enableClipboard: p, canDragOnto: d, restrictTypeSelection: l, searchFilter: u, searchText: c, showLabel: h, stringTruncate: f, showStringQuotes: m, arrayIndexFromOne: b, indent: D, translate: O, customNodeDefinitions: w, customNodeData: N, handleKeyboard: _, keyboardControls: W, sort: z, editConfirmRef: H, jsonStringify: X, showIconTooltips:
|
|
412
|
+
const { data: t, parentData: n, onEdit: r, onDelete: a, onChange: i, onMove: s, enableClipboard: p, canDragOnto: d, restrictTypeSelection: l, searchFilter: u, searchText: c, showLabel: h, stringTruncate: f, showStringQuotes: m, arrayIndexFromOne: b, indent: D, translate: O, customNodeDefinitions: w, customNodeData: N, handleKeyboard: _, keyboardControls: W, sort: z, editConfirmRef: H, jsonStringify: X, showIconTooltips: B } = e, { getStyles: C } = Oe(), { setCurrentlyEditingElement: k, setCollapseState: L, previouslyEditedElement: Y, setPreviouslyEditedElement: ae, tabDirection: Z, setTabDirection: ne, previousValue: G, setPreviousValue: M } = He(), [F, ge] = J(typeof t == "function" ? St : t), { pathString: $, nodeData: R, path: V, name: q, canEdit: me, canDelete: Ie, canDrag: Ne, error: je, onError: de, handleEditKey: be, emptyStringKey: Ye, derivedValues: Ce } = cn({ props: e }), { dragSourceProps: nt, getDropTargetProps: rt, BottomDropTarget: re, DropTargetPadding: ue } = dn({ canDrag: Ne, canDragOnto: d, path: V, nodeData: R, onMove: s, onError: de, translate: O }), [ve, xe] = J(Nt(t, N)), S = Re(((g) => {
|
|
413
413
|
if (!i) return void ge(g);
|
|
414
414
|
const x = i({ currentData: R.fullData, newValue: g, currentValue: F, name: q, path: V });
|
|
415
415
|
ge(x);
|
|
@@ -432,7 +432,7 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
432
432
|
})), (P = oe[0]) !== null && P !== void 0 ? P : null;
|
|
433
433
|
})(F, ke)), { isEditing: ie } = Ce, Je = tn("value", R, u, c);
|
|
434
434
|
if (ie && (!Je || !me)) {
|
|
435
|
-
const g =
|
|
435
|
+
const g = $e(R.fullData, V, Z, z);
|
|
436
436
|
k(g || Y);
|
|
437
437
|
}
|
|
438
438
|
if (!Je) return null;
|
|
@@ -461,21 +461,21 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
461
461
|
k(null), G === null ? (ge(t), M(null)) : r(G, V);
|
|
462
462
|
}, { isEditingKey: Xe, canEditKey: Ze } = Ce, pe = !ie && je, ee = ie && ke.length > 1, Le = (ve !== "invalid" || K) && !je && Ee, v = h && !Te, j = K && (ie && Ae || !ie && Pe), E = { value: F, parentData: n, setValue: S, isEditing: ie, canEdit: me, setIsEditing: me ? () => k(V) : () => {
|
|
463
463
|
}, handleEdit: we, handleCancel: fe, path: V, stringTruncate: f, showStringQuotes: m, nodeData: R, enumType: se, translate: O, handleKeyboard: _, keyboardCommon: { cancel: fe, tabForward: () => {
|
|
464
|
-
ne("next"), ae(
|
|
465
|
-
const g =
|
|
464
|
+
ne("next"), ae($);
|
|
465
|
+
const g = $e(R.fullData, V, "next", z);
|
|
466
466
|
g && (we(), k(g));
|
|
467
467
|
}, tabBack: () => {
|
|
468
|
-
ne("prev"), ae(
|
|
469
|
-
const g =
|
|
468
|
+
ne("prev"), ae($);
|
|
469
|
+
const g = $e(R.fullData, V, "prev", z);
|
|
470
470
|
g && (we(), k(g));
|
|
471
|
-
} } }, A = { canEditKey: Ze, isEditingKey: Xe, pathString:
|
|
471
|
+
} } }, A = { canEditKey: Ze, isEditingKey: Xe, pathString: $, path: V, name: q, arrayIndexFromOne: b, handleKeyboard: _, handleEditKey: be, handleCancel: fe, styles: C("property", R), getNextOrPrevious: (g) => $e(R.fullData, V, g, z), emptyStringKey: Ye }, T = j ? o.jsx(K, Object.assign({}, e, { value: F, customNodeProps: Q, setValue: S, handleEdit: we, handleCancel: fe, handleKeyPress: (g) => _(g, { stringConfirm: we, cancel: fe }), isEditing: ie, setIsEditing: () => k(V), getStyles: C, originalNode: Ve ? Yt(t, E) : void 0, originalNodeKey: Ve ? o.jsx(mt, Object.assign({}, A)) : void 0, canEdit: me, keyboardCommon: E.keyboardCommon, onError: de })) : Yt(t, E);
|
|
472
472
|
return o.jsxs("div", Object.assign({ className: "jer-component jer-value-component", style: { marginLeft: n !== null ? D / 2 + "em" : 0, position: "relative" }, draggable: Ne }, nt, rt("above"), { children: [re, o.jsx(ue, { position: "above", nodeData: R }), o.jsxs("div", { className: "jer-value-main-row", style: { flexWrap: q.length > 10 ? "wrap" : "nowrap" }, children: [v && o.jsx(mt, Object.assign({}, A)), o.jsxs("div", { className: "jer-value-and-buttons", children: [o.jsx("div", { className: "jer-input-component", children: T }), ie ? o.jsx(Pt, { onOk: we, onCancel: fe, nodeData: R, editConfirmRef: H }) : Le && o.jsx(ln, { startEdit: me ? () => {
|
|
473
473
|
M(G), k(V, fe);
|
|
474
474
|
} : void 0, handleDelete: Ie ? () => {
|
|
475
475
|
a(F, V).then(((g) => {
|
|
476
476
|
g && de({ code: "DELETE_ERROR", message: g }, F);
|
|
477
477
|
}));
|
|
478
|
-
} : void 0, enableClipboard: p, translate: O, customButtons: e.customButtons, nodeData: R, handleKeyboard: _, keyboardControls: W, editConfirmRef: H, jsonStringify: X, showIconTooltips:
|
|
478
|
+
} : void 0, enableClipboard: p, translate: O, customButtons: e.customButtons, nodeData: R, handleKeyboard: _, keyboardControls: W, editConfirmRef: H, jsonStringify: X, showIconTooltips: B }), ee && o.jsxs("div", { className: "jer-select jer-select-types", children: [o.jsx("select", { name: `${q}-type-select`, className: "jer-select-inner", onChange: (g) => ((x) => {
|
|
479
479
|
const P = w.find(((te) => te.name === x));
|
|
480
480
|
if (P) return r(P.defaultValue, V), xe(x), _e(null), k(null), void L({ path: V, collapsed: !1, includeChildren: !1 });
|
|
481
481
|
const oe = ke.find(((te) => te instanceof Object && te.enum === x));
|
|
@@ -499,7 +499,7 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
499
499
|
case "null":
|
|
500
500
|
return o.jsx(Fn, Object.assign({}, t));
|
|
501
501
|
default:
|
|
502
|
-
return o.jsx(
|
|
502
|
+
return o.jsx(Bn, Object.assign({}, t));
|
|
503
503
|
}
|
|
504
504
|
}, qn = (e, t, n, r) => {
|
|
505
505
|
switch (t) {
|
|
@@ -526,14 +526,14 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
526
526
|
const r = n[0], { element: a, wrapperElement: i, customNodeProps: s, wrapperProps: p, hideKey: d = !1, showEditTools: l = !0, showOnEdit: u = !1, showOnView: c = !0, showCollectionWrapper: h = !0 } = r, f = qt(r, ["element", "wrapperElement", "customNodeProps", "wrapperProps", "hideKey", "showEditTools", "showOnEdit", "showOnView", "showCollectionWrapper"]);
|
|
527
527
|
return Object.assign({ CustomNode: a, CustomWrapper: i, customNodeProps: s, wrapperProps: p, hideKey: d, showEditTools: l, showOnEdit: u, showOnView: c, showCollectionWrapper: h }, f);
|
|
528
528
|
}, hn = (e) => {
|
|
529
|
-
const { getStyles: t } = Oe(), { collapseState: n, setCollapseState: r, getMatchingCollapseState: a, currentlyEditingElement: i, setCurrentlyEditingElement: s, areChildrenBeingEdited: p, previousValue: d, setPreviousValue: l } = He(), { mainContainerRef: u, data: c, nodeData: h, parentData: f, showCollectionCount: m, onEdit: b, onAdd: D, onDelete: O, canDragOnto: w, collapseFilter: N, collapseAnimationTime: _, onMove: W, enableClipboard: z, onEditEvent: H, showIconTooltips: X, searchFilter:
|
|
529
|
+
const { getStyles: t } = Oe(), { collapseState: n, setCollapseState: r, getMatchingCollapseState: a, currentlyEditingElement: i, setCurrentlyEditingElement: s, areChildrenBeingEdited: p, previousValue: d, setPreviousValue: l } = He(), { mainContainerRef: u, data: c, nodeData: h, parentData: f, showCollectionCount: m, onEdit: b, onAdd: D, onDelete: O, canDragOnto: w, collapseFilter: N, collapseAnimationTime: _, onMove: W, enableClipboard: z, onEditEvent: H, showIconTooltips: X, searchFilter: B, searchText: C, indent: k, sort: L, showArrayIndices: Y, arrayIndexFromOne: ae, defaultValue: Z, newKeyOptions: ne, translate: G, customNodeDefinitions: M, customNodeData: F, jsonParse: ge, jsonStringify: $, TextEditor: R, keyboardControls: V, handleKeyboard: q, insertAtTop: me, onCollapse: Ie, editConfirmRef: Ne, collapseClickZones: je } = e, [de, be] = J($(c)), Ye = N(h), { contentRef: Ce, isAnimating: nt, maxHeight: rt, collapsed: re, animateCollapse: ue, cssTransitionValue: ve } = ((y, I, ye, he, Se) => {
|
|
530
530
|
const [bn, pt] = J(ye ? 0 : void 0), [ht, vn] = J(ye), vt = ce(!1), xt = ce(null), Mt = ce(0), Ft = ce(0), xn = I / 1e3 + "s", En = Re(((Et) => {
|
|
531
531
|
var wt, Dt;
|
|
532
532
|
if (ht !== Et) {
|
|
533
533
|
switch (window.clearTimeout(Ft.current), vt.current = !0, Et) {
|
|
534
534
|
case !0: {
|
|
535
|
-
const
|
|
536
|
-
Mt.current =
|
|
535
|
+
const Bt = (Dt = (wt = xt.current) === null || wt === void 0 ? void 0 : wt.offsetHeight) !== null && Dt !== void 0 ? Dt : 0;
|
|
536
|
+
Mt.current = Bt, pt(Bt), setTimeout((() => {
|
|
537
537
|
pt(0);
|
|
538
538
|
}), 5);
|
|
539
539
|
break;
|
|
@@ -547,10 +547,10 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
547
547
|
}
|
|
548
548
|
}), [I, ht, y, he, Se]);
|
|
549
549
|
return { contentRef: xt, isAnimating: vt.current, animateCollapse: En, maxHeight: bn, collapsed: ht, cssTransitionValue: xn };
|
|
550
|
-
})(c, _, Ye, u,
|
|
550
|
+
})(c, _, Ye, u, $), { pathString: xe, nodeData: S, path: K, name: Q, size: Te, canEdit: Ee, canDelete: Ae, canAdd: Pe, canDrag: Ve, error: Ke, setError: ke, onError: se, handleEditKey: _e, emptyStringKey: ie, derivedValues: Je } = cn({ props: e, collapsed: re }), { dragSourceProps: we, getDropTargetProps: fe, BottomDropTarget: Xe, DropTargetPadding: Ze } = dn({ canDrag: Ve, canDragOnto: w, path: K, nodeData: S, onMove: W, onError: se, translate: G }), pe = ce(!Ye), { isEditing: ee, isEditingKey: Le, isArray: v, canEditKey: j } = Je;
|
|
551
551
|
De((() => {
|
|
552
|
-
be(
|
|
553
|
-
}), [c,
|
|
552
|
+
be($(c));
|
|
553
|
+
}), [c, $]), De((() => {
|
|
554
554
|
const y = N(S) && !ee;
|
|
555
555
|
pe.current = !y, ue(y);
|
|
556
556
|
}), [N]), De((() => {
|
|
@@ -564,7 +564,7 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
564
564
|
const ye = Z(y, I);
|
|
565
565
|
return ye !== void 0 ? ye : null;
|
|
566
566
|
}), [Z]), T = Re(((y) => ne ? typeof ne != "function" ? ne : ne(y) : null), [ne]), { CustomNode: g, customNodeProps: x, CustomWrapper: P, wrapperProps: oe = {}, hideKey: U, showEditTools: te = !0, showOnEdit: ze, showOnView: Me, showCollectionWrapper: ft = !0 } = F, ct = p(xe);
|
|
567
|
-
if (ct && re && ue(!1), !(tn("collection", S,
|
|
567
|
+
if (ct && re && ue(!1), !(tn("collection", S, B, C) || S.level === 0) && !ct) return null;
|
|
568
568
|
const Ge = Array.isArray(c) ? "array" : "object", yt = Ge === "array" ? { open: "[", close: "]" } : { open: "{", close: "}" }, Rt = (y) => {
|
|
569
569
|
if (y.key !== "Tab" || y.getModifierState("Shift")) q(y, { objectConfirm: ut, cancel: ot });
|
|
570
570
|
else {
|
|
@@ -580,7 +580,7 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
580
580
|
}, ut = () => {
|
|
581
581
|
try {
|
|
582
582
|
const y = ge(de);
|
|
583
|
-
if (s(null), l(null), ke(null),
|
|
583
|
+
if (s(null), l(null), ke(null), $(y) === $(c)) return;
|
|
584
584
|
b(y, K).then(((I) => {
|
|
585
585
|
I && se({ code: "UPDATE_ERROR", message: I }, y);
|
|
586
586
|
}));
|
|
@@ -592,7 +592,7 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
592
592
|
y && se({ code: "DELETE_ERROR", message: y }, c);
|
|
593
593
|
}));
|
|
594
594
|
} : void 0, ot = () => {
|
|
595
|
-
s(null), d === null ? (ke(null), be(
|
|
595
|
+
s(null), d === null ? (ke(null), be($(c)), l(null)) : b(d, K);
|
|
596
596
|
}, It = m === "when-closed" ? re : m, mn = !ee && te, fn = (Y || !v) && !U && Q !== void 0, yn = g && (ee && ze || !ee && Me), jt = Object.entries(c).map((([y, I]) => [Ge === "array" ? Number(y) : y, I]));
|
|
597
597
|
Ge === "object" && L(jt, ((y) => y));
|
|
598
598
|
const Vt = pe.current ? ee ? o.jsxs("div", { className: "jer-collection-text-edit", children: [R ? o.jsx(R, { value: de, onChange: be, onKeyDown: (y) => q(y, { objectConfirm: ut, cancel: ot }) }) : o.jsx(en, { textAreaRef: E, className: "jer-collection-text-area", name: xe, value: de, setValue: be, handleKeyPress: Rt, styles: t("input", S) }), o.jsx("div", { className: "jer-collection-input-button-row", children: o.jsx(Pt, { onOk: ut, onCancel: ot, nodeData: S, editConfirmRef: Ne }) })] }) : jt.map((([y, I], ye) => {
|
|
@@ -619,7 +619,7 @@ const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, s
|
|
|
619
619
|
he && se({ code: "ADD_ERROR", message: he }, I);
|
|
620
620
|
}));
|
|
621
621
|
}
|
|
622
|
-
} : void 0, handleDelete: Ae ? gn : void 0, enableClipboard: z, type: Ge, nodeData: S, translate: G, customButtons: e.customButtons, keyboardControls: V, handleKeyboard: q, getNewKeyOptions: T, editConfirmRef: Ne, jsonStringify:
|
|
622
|
+
} : void 0, handleDelete: Ae ? gn : void 0, enableClipboard: z, type: Ge, nodeData: S, translate: G, customButtons: e.customButtons, keyboardControls: V, handleKeyboard: q, getNewKeyOptions: T, editConfirmRef: Ne, jsonStringify: $, onEditEvent: H, showIconTooltips: X }), Lt = { canEditKey: j, isEditingKey: Le, pathString: xe, path: K, name: Q, arrayIndexFromOne: ae, handleKeyboard: q, handleEditKey: _e, handleCancel: ot, keyValueArray: jt, styles: t("property", S), getNextOrPrevious: (y) => $e(S.fullData, K, y, L), handleClick: je.includes("property") ? dt : (y) => y.stopPropagation(), emptyStringKey: ie }, zt = o.jsxs("div", Object.assign({ className: "jer-component jer-collection-component", style: Object.assign(Object.assign({ marginLeft: (K.length === 0 ? 0 : k / 2) + "em" }, t("collection", S)), { position: "relative" }), draggable: Ve }, we, fe("above"), { children: [o.jsx("div", { className: "jer-clickzone", style: { width: k / 2 + 1 + "em", zIndex: 10 + 2 * S.level }, onClick: je.includes("left") ? dt : void 0 }), !ee && Xe, o.jsx(Ze, { position: "above", nodeData: S }), ft ? o.jsxs("div", { className: "jer-collection-header-row", style: { position: "relative" }, onClick: je.includes("header") ? dt : void 0, children: [o.jsxs("div", { className: "jer-collection-name", children: [o.jsx("div", { className: "jer-collapse-icon jer-accordion-icon" + (re ? " jer-rotate-90" : ""), style: { zIndex: 11 + 2 * S.level, transition: ve }, onClick: dt, children: o.jsx(We, { name: "chevron", rotate: re, nodeData: S }) }), fn && o.jsx(mt, Object.assign({}, Lt)), !ee && o.jsx("span", { className: "jer-brackets jer-bracket-open", style: t("bracket", S), children: yt.open })] }), !ee && It && o.jsx("div", { className: "jer-collection-item-count" + (It ? " jer-visible" : " jer-hidden"), style: Object.assign(Object.assign({}, t("itemCount", S)), { transition: ve }), children: Te === 1 ? G("ITEM_SINGLE", Object.assign(Object.assign({}, S), { size: 1 }), 1) : G("ITEMS_MULTIPLE", S, Te) }), o.jsx("div", { className: "jer-brackets" + (bt ? " jer-visible" : " jer-hidden"), style: Object.assign(Object.assign({}, t("bracket", S)), { transition: ve }), children: yt.close }), _t] }) : U ? o.jsx(o.Fragment, {}) : o.jsxs("div", { className: "jer-collection-header-row", style: { position: "relative" }, children: [o.jsx(mt, Object.assign({}, Lt)), _t] }), o.jsxs("div", { className: "jer-collection-inner", style: Object.assign(Object.assign({ overflowY: bt || nt ? "clip" : "visible", maxHeight: ct ? void 0 : rt }, t("collectionInner", S)), { transition: ve }), ref: Ce, children: [jn, o.jsx("div", { className: ee ? "jer-collection-error-row" : "jer-collection-error-row-edit", children: Ke && o.jsx("span", { className: "jer-error-slug", style: t("error", S), children: Ke }) }), !ee && ft && o.jsx("div", { className: "jer-brackets jer-bracket-outside", style: Object.assign(Object.assign({}, t("bracket", S)), { marginLeft: (k < 3 ? -1 : k < 6 ? -0.5 : 0) + "em" }), children: yt.close })] }), o.jsx(Ze, { position: "below", nodeData: S })] }));
|
|
623
623
|
return P ? o.jsx(P, Object.assign({ customNodeProps: oe }, Kt, { children: zt })) : zt;
|
|
624
624
|
}, er = { ITEM_SINGLE: "{{count}} item", ITEMS_MULTIPLE: "{{count}} items", KEY_NEW: "Enter new key", KEY_SELECT: "Select key", NO_KEY_OPTIONS: "No key options", ERROR_KEY_EXISTS: "Key already exists", ERROR_INVALID_JSON: "Invalid JSON", ERROR_UPDATE: "Update unsuccessful", ERROR_DELETE: "Delete unsuccessful", ERROR_ADD: "Adding node unsuccessful", DEFAULT_STRING: "New data!", DEFAULT_NEW_KEY: "key", SHOW_LESS: "(Show less)", EMPTY_STRING: "<empty string>", TOOLTIP_COPY: "Copy to clipboard", TOOLTIP_EDIT: "Edit", TOOLTIP_DELETE: "Delete", TOOLTIP_ADD: "Add" }, tr = (e, t) => (n, r, a) => ((i, s, p, d, l) => {
|
|
625
625
|
if (s[d]) {
|
|
@@ -647,7 +647,7 @@ var Jt = [], at = [];
|
|
|
647
647
|
}
|
|
648
648
|
})(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-area{font-family:inherit;font-size:.85em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-rotate-90{transform:rotate(-90deg)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}', {});
|
|
649
649
|
const nr = ({ data: e, setData: t, rootName: n = "root", onUpdate: r = () => {
|
|
650
|
-
}, onEdit: a = r, onDelete: i = r, onAdd: s = r, onChange: p, onError: d, onEditEvent: l, showErrorMessages: u = !0, enableClipboard: c = !0, indent: h = 2, collapse: f = !1, collapseAnimationTime: m = 300, showCollectionCount: b = !0, restrictEdit: D = !1, restrictDelete: O = !1, restrictAdd: w = !1, restrictTypeSelection: N = !1, restrictDrag: _ = !0, viewOnly: W, searchFilter: z, searchText: H, searchDebounceTime: X = 350, keySort:
|
|
650
|
+
}, onEdit: a = r, onDelete: i = r, onAdd: s = r, onChange: p, onError: d, onEditEvent: l, showErrorMessages: u = !0, enableClipboard: c = !0, indent: h = 2, collapse: f = !1, collapseAnimationTime: m = 300, showCollectionCount: b = !0, restrictEdit: D = !1, restrictDelete: O = !1, restrictAdd: w = !1, restrictTypeSelection: N = !1, restrictDrag: _ = !0, viewOnly: W, searchFilter: z, searchText: H, searchDebounceTime: X = 350, keySort: B = !1, showArrayIndices: C = !0, arrayIndexFromOne: k = !1, showStringQuotes: L = !0, showIconTooltips: Y = !1, defaultValue: ae = null, newKeyOptions: Z, minWidth: ne = 250, maxWidth: G = "min(600px, 90vw)", rootFontSize: M, stringTruncate: F = 250, translations: ge = {}, className: $, id: R, customText: V = {}, customNodeDefinitions: q = [], customButtons: me = [], jsonParse: Ie = JSON.parse, jsonStringify: Ne = (re, ue) => JSON.stringify(re, ue, 2), TextEditor: je, errorMessageTimeout: de = 2500, keyboardControls: be = {}, externalTriggers: Ye, insertAtTop: Ce = !1, onCollapse: nt, collapseClickZones: rt = ["header", "left"] }) => {
|
|
651
651
|
const { getStyles: re } = Oe(), { setCurrentlyEditingElement: ue } = He(), ve = le((() => it(f)), [f]), xe = le((() => tr(ge, V)), [ge, V]), [S, K] = J(H), [Q, Te] = (({ setData: v, data: j }) => {
|
|
652
652
|
const [E, A] = J(v ? void 0 : j), T = Re(((g) => {
|
|
653
653
|
v ? v(g) : A(g);
|
|
@@ -715,11 +715,11 @@ const nr = ({ data: e, setData: t, rootName: n = "root", onUpdate: r = () => {
|
|
|
715
715
|
}), [v]);
|
|
716
716
|
})(Ye, Xe);
|
|
717
717
|
const Ze = Re(((v, j) => {
|
|
718
|
-
|
|
718
|
+
B !== !1 && (typeof B != "function" ? v.sort(((E, A) => {
|
|
719
719
|
const T = j(E)[0], g = j(A)[0];
|
|
720
720
|
return T < g ? -1 : T > g ? 1 : 0;
|
|
721
|
-
})) : v.sort(((E, A) =>
|
|
722
|
-
}), [
|
|
721
|
+
})) : v.sort(((E, A) => B(j(E), j(A)))));
|
|
722
|
+
}), [B]), pe = pn(q, Ae), ee = { mainContainerRef: Ee, name: n, nodeData: Ae, onEdit: (v, j) => Qe(void 0, void 0, void 0, (function* () {
|
|
723
723
|
const { currentData: E, newData: A, currentValue: T, newValue: g } = st(Q, j, v, "update");
|
|
724
724
|
if (T !== g) return yield Pe(a, { currentData: E, newData: A, currentValue: T, newValue: g, name: j.slice(-1)[0], path: j });
|
|
725
725
|
})), onDelete: (v, j) => Qe(void 0, void 0, void 0, (function* () {
|
|
@@ -735,8 +735,8 @@ const nr = ({ data: e, setData: t, rootName: n = "root", onUpdate: r = () => {
|
|
|
735
735
|
v.slice(0, -1).join(".") === j.slice(0, -1).join(".") && typeof x == "number" && typeof U == "number" && x < U && (U -= 1);
|
|
736
736
|
const te = typeof U == "number" ? { insert: !0 } : E === "above" ? { insertBefore: oe } : { insertAfter: oe }, { newData: ze, newValue: Me } = st(T, [...P, U], g, "add", te);
|
|
737
737
|
return yield Pe(a, { currentData: A, newData: ze, currentValue: g, newValue: Me, name: j.slice(-1)[0], path: j });
|
|
738
|
-
})), showCollectionCount: b, collapseFilter: ve, collapseAnimationTime: m, restrictEditFilter: Ve, restrictDeleteFilter: Ke, restrictAddFilter: ke, restrictTypeSelection: N, restrictDragFilter: se, canDragOnto: !1, searchFilter: _e, searchText: S, enableClipboard: c, keySort:
|
|
739
|
-
return Le.fontSize = M ?? Le.fontSize, o.jsx("div", { id: R, ref: Ee, className: `jer-editor-container ${
|
|
738
|
+
})), showCollectionCount: b, collapseFilter: ve, collapseAnimationTime: m, restrictEditFilter: Ve, restrictDeleteFilter: Ke, restrictAddFilter: ke, restrictTypeSelection: N, restrictDragFilter: se, canDragOnto: !1, searchFilter: _e, searchText: S, enableClipboard: c, keySort: B, sort: Ze, showArrayIndices: C, arrayIndexFromOne: k, showStringQuotes: L, showIconTooltips: Y, indent: h, defaultValue: ae, newKeyOptions: Z, stringTruncate: F, translate: xe, customNodeDefinitions: q, customNodeData: pe, customButtons: me, parentData: null, jsonParse: fe, jsonStringify: we, TextEditor: je, errorMessageTimeout: de, handleKeyboard: Je, keyboardControls: ie, insertAtTop: { object: Ce === !0 || Ce === "object", array: Ce === !0 || Ce === "array" }, onCollapse: nt, editConfirmRef: Xe, collapseClickZones: rt }, Le = Object.assign(Object.assign({}, re("container", Ae)), { minWidth: ne, maxWidth: G });
|
|
739
|
+
return Le.fontSize = M ?? Le.fontSize, o.jsx("div", { id: R, ref: Ee, className: `jer-editor-container ${$ ?? ""}`, style: Le, children: et(Q) && !pe.renderCollectionAsValue ? o.jsx(hn, Object.assign({ data: Q }, ee)) : o.jsx(un, Object.assign({ data: Q, showLabel: !0 }, ee)) });
|
|
740
740
|
}, ir = (e) => {
|
|
741
741
|
var t;
|
|
742
742
|
const [n, r] = J();
|
|
@@ -759,7 +759,7 @@ const nr = ({ data: e, setData: t, rootName: n = "root", onUpdate: r = () => {
|
|
|
759
759
|
};
|
|
760
760
|
};
|
|
761
761
|
export {
|
|
762
|
-
|
|
762
|
+
$n as IconAdd,
|
|
763
763
|
Jn as IconCancel,
|
|
764
764
|
Xn as IconChevron,
|
|
765
765
|
Un as IconCopy,
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as s, B as t, D as r,
|
|
1
|
+
import { A as s, B as t, D as r, a as i, b as l, E as o, F as d, G as u, c as n, J as c, L as F, N as g, S as m, T as p, d as P, U as h, V as D, e as v, f as S, g as f, h as y, i as V, j as x, k as b, l as O, m as T, n as A, o as G, p as L, q as R, r as E, s as I, t as N, u as U, v as j, w as B, x as C, y as H, z as J, H as W, I as k, K as q, M as w, O as z, P as K, Q as M, R as Q, W as X, X as Y, Y as Z, Z as _, _ as $, $ as aa, a0 as ea } from "./index-BL3nv8aS.js";
|
|
2
2
|
export {
|
|
3
3
|
s as ArrayField,
|
|
4
4
|
t as BooleanField,
|
|
@@ -24,19 +24,19 @@ export {
|
|
|
24
24
|
V as buildDefaultValues,
|
|
25
25
|
x as createFieldDescriptor,
|
|
26
26
|
b as createRuleHandler,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
O as defineNavigation,
|
|
28
|
+
T as evaluateCondition,
|
|
29
|
+
A as extractConstraints,
|
|
30
|
+
G as extractDescription,
|
|
31
|
+
L as extractPaths,
|
|
32
32
|
R as extractPlaceholder,
|
|
33
33
|
E as formatLabel,
|
|
34
34
|
I as getAdditionalPropertiesSchema,
|
|
35
35
|
N as getArrayItemsSchema,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
U as getDefaultValue,
|
|
37
|
+
j as getFieldType,
|
|
38
|
+
B as getLanguage,
|
|
39
|
+
C as getPatternPropertiesSchemas,
|
|
40
40
|
H as getSchemaResolver,
|
|
41
41
|
J as getTupleSchemas,
|
|
42
42
|
W as isAnyOfField,
|
package/dist/mf-common.js
CHANGED
|
@@ -16,7 +16,7 @@ const i = { react: "19.2.3", "react-dom": "19.2.3", "react-router": "7.12.0" },
|
|
|
16
16
|
},
|
|
17
17
|
"@grasp-labs/ds-microfrontends-integration": {
|
|
18
18
|
singleton: !0,
|
|
19
|
-
requiredVersion: ">=0.
|
|
19
|
+
requiredVersion: ">=1.0.0 <2.0.0"
|
|
20
20
|
}
|
|
21
21
|
}, c = (e) => `microfrontends/${e}/`, a = (e, r = {}) => {
|
|
22
22
|
const t = c(e);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IconName } from '@grasp-labs/ds-react-components';
|
|
2
|
-
export type BaseItem = {
|
|
2
|
+
export type BaseItem<TLocaleCode extends string = string> = {
|
|
3
3
|
/**
|
|
4
4
|
* Display label used as fallback when translation is not available
|
|
5
5
|
*/
|
|
@@ -7,8 +7,14 @@ export type BaseItem = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Translation key for internationalization.
|
|
9
9
|
* Must be placed in 'navigation' translation namespace in the host application for it to work.
|
|
10
|
+
* Kept for backward compatibility with hosts that resolve labels by key.
|
|
10
11
|
*/
|
|
11
|
-
labelKey
|
|
12
|
+
labelKey?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional inline translation dictionary for navigation labels.
|
|
15
|
+
* Use `ComposableNavigationConfig<LocaleCode>` (or `defineNavigation`) to enforce a consistent locale set.
|
|
16
|
+
*/
|
|
17
|
+
translations?: Record<TLocaleCode, string>;
|
|
12
18
|
icon: IconName;
|
|
13
19
|
/**
|
|
14
20
|
* Groups required to access this navigation item.
|
|
@@ -18,37 +24,39 @@ export type BaseItem = {
|
|
|
18
24
|
*/
|
|
19
25
|
requiredGroups?: string[];
|
|
20
26
|
};
|
|
21
|
-
export type RouteConfig = BaseItem & {
|
|
22
|
-
path:
|
|
27
|
+
export type RouteConfig<TLocaleCode extends string = string, TPath extends string = string> = BaseItem<TLocaleCode> & {
|
|
28
|
+
path: TPath;
|
|
23
29
|
type?: "hidden" | "visible";
|
|
24
30
|
};
|
|
25
|
-
export type CategoryConfig = BaseItem & {
|
|
31
|
+
export type CategoryConfig<TLocaleCode extends string = string, TPath extends string = string> = BaseItem<TLocaleCode> & {
|
|
26
32
|
type: "category";
|
|
27
|
-
children: Record<string, NavigationItem
|
|
33
|
+
children: Record<string, NavigationItem<TLocaleCode, TPath>>;
|
|
28
34
|
};
|
|
29
|
-
export type NavigationItem = RouteConfig | CategoryConfig
|
|
35
|
+
export type NavigationItem<TLocaleCode extends string = string, TPath extends string = string> = RouteConfig<TLocaleCode, TPath> | CategoryConfig<TLocaleCode, TPath>;
|
|
30
36
|
/**
|
|
31
37
|
* INDEX is a mandatory route representing the root of the microfrontend, used as the parent navigation item in the sidebar
|
|
32
38
|
* @deprecated Use ComposableNavigationConfig for new microfrontends
|
|
33
39
|
*/
|
|
34
|
-
export type IndexNavigationConfig = {
|
|
35
|
-
INDEX: RouteConfig
|
|
40
|
+
export type IndexNavigationConfig<TLocaleCode extends string = string, TPath extends string = string> = {
|
|
41
|
+
INDEX: RouteConfig<TLocaleCode, TPath>;
|
|
36
42
|
};
|
|
37
43
|
/**
|
|
38
44
|
* @deprecated Use ComposableNavigationConfig for new microfrontends
|
|
39
45
|
*/
|
|
40
|
-
export type NavigationConfig<TKeys extends string = string> = IndexNavigationConfig & Record<TKeys, NavigationItem
|
|
46
|
+
export type NavigationConfig<TKeys extends string = string, TLocaleCode extends string = string, TPath extends string = string> = IndexNavigationConfig<TLocaleCode, TPath> & Record<TKeys, NavigationItem<TLocaleCode, TPath>>;
|
|
41
47
|
/**
|
|
42
48
|
* Composable navigation configuration where each entry is a standalone NavigationItem.
|
|
43
49
|
*/
|
|
44
|
-
export type ComposableNavigationConfig = Record<string, NavigationItem
|
|
50
|
+
export type ComposableNavigationConfig<TLocaleCode extends string = string, TPath extends string = string> = Record<string, NavigationItem<TLocaleCode, TPath>>;
|
|
51
|
+
type InferLocaleCode<T> = T extends Record<string, NavigationItem<infer TLocaleCode, string>> ? TLocaleCode : string;
|
|
45
52
|
export type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
|
|
46
53
|
/**
|
|
47
54
|
* Recursively extracts a flat path map from a navigation config.
|
|
48
55
|
* For route items, extracts `{ KEY: path }`. For categories, recurses into children.
|
|
49
56
|
*/
|
|
50
|
-
export type ExtractPaths<T extends Record<string, NavigationItem>> = {
|
|
51
|
-
[K in keyof T as T[K] extends CategoryConfig ? never : K]: T[K] extends RouteConfig ? T[K]["path"] : never;
|
|
57
|
+
export type ExtractPaths<T extends Record<string, NavigationItem<TLocaleCode, string>>, TLocaleCode extends string = InferLocaleCode<T>> = {
|
|
58
|
+
[K in keyof T as T[K] extends CategoryConfig<TLocaleCode, string> ? never : K]: T[K] extends RouteConfig<TLocaleCode, string> ? T[K]["path"] : never;
|
|
52
59
|
} & UnionToIntersection<{
|
|
53
|
-
[K in keyof T]: T[K] extends CategoryConfig ? ExtractPaths<T[K]["children"]> : never;
|
|
60
|
+
[K in keyof T]: T[K] extends CategoryConfig<TLocaleCode, string> ? ExtractPaths<T[K]["children"], TLocaleCode> : never;
|
|
54
61
|
}[keyof T]>;
|
|
62
|
+
export {};
|
|
@@ -6,18 +6,18 @@ import { ComposableNavigationConfig, ExtractPaths } from '../types/Navigation';
|
|
|
6
6
|
* const PageRoutes = extractPaths(navigationConfig);
|
|
7
7
|
* // PageRoutes.DASHBOARD === "/dashboard"
|
|
8
8
|
*/
|
|
9
|
-
export declare const extractPaths: <const T extends ComposableNavigationConfig
|
|
9
|
+
export declare const extractPaths: <const TLocaleCode extends string, const T extends ComposableNavigationConfig<TLocaleCode>>(config: T) => ExtractPaths<T, TLocaleCode>;
|
|
10
10
|
/**
|
|
11
11
|
* Defines a navigation config and extracts its page routes in one step.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* const { navigationConfig, pageRoutes } = defineNavigation({
|
|
15
|
-
* INDEX: { label: "Home",
|
|
15
|
+
* INDEX: { label: "Home", path: "/", icon: "home" },
|
|
16
16
|
* });
|
|
17
17
|
* export const PageRoutes = pageRoutes;
|
|
18
18
|
* export default navigationConfig;
|
|
19
19
|
*/
|
|
20
|
-
export declare const defineNavigation: <const T extends ComposableNavigationConfig
|
|
20
|
+
export declare const defineNavigation: <const TLocaleCode extends string, const T extends ComposableNavigationConfig<TLocaleCode>>(config: T) => {
|
|
21
21
|
navigationConfig: T;
|
|
22
|
-
pageRoutes: ExtractPaths<T>;
|
|
22
|
+
pageRoutes: ExtractPaths<T, TLocaleCode>;
|
|
23
23
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grasp-labs/ds-microfrontends-integration",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,md}\"",
|
|
43
43
|
"test": "vitest run",
|
|
44
44
|
"test:watch": "vitest",
|
|
45
|
-
"test:coverage": "vitest run --coverage"
|
|
45
|
+
"test:coverage": "vitest run --coverage",
|
|
46
|
+
"tsc": "tsc --noEmit",
|
|
47
|
+
"check": "npm run tsc && npm run lint && npm run format:check && npm run test"
|
|
46
48
|
},
|
|
47
49
|
"peerDependencies": {
|
|
48
50
|
"@module-federation/vite": "^1.0.0",
|
|
@@ -61,9 +63,7 @@
|
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
63
65
|
"@eslint/js": "^9.32.0",
|
|
64
|
-
"
|
|
65
|
-
"ajv-formats": "^3.0.1",
|
|
66
|
-
"@grasp-labs/ds-react-components": "^0.23.0",
|
|
66
|
+
"@grasp-labs/ds-react-components": "^1.6.0",
|
|
67
67
|
"@hookform/resolvers": "^5.2.2",
|
|
68
68
|
"@module-federation/vite": "1.9.4",
|
|
69
69
|
"@storybook/addon-a11y": "^10.1.11",
|
|
@@ -79,6 +79,8 @@
|
|
|
79
79
|
"@types/react-dom": "^19.1.7",
|
|
80
80
|
"@vitejs/plugin-react": "^5.1.2",
|
|
81
81
|
"@vitest/coverage-v8": "^4.0.16",
|
|
82
|
+
"ajv": "^8.17.1",
|
|
83
|
+
"ajv-formats": "^3.0.1",
|
|
82
84
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
83
85
|
"eslint": "^9.32.0",
|
|
84
86
|
"eslint-config-prettier": "^10.1.8",
|