@grasp-labs/ds-react-components 0.13.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/LICENSE +201 -0
- package/README.md +52 -0
- package/dist/assets/fonts/Inter-VariableFont_opsz,wght.ttf +0 -0
- package/dist/components/advancedFilter/AdvancedFilter.d.ts +8 -0
- package/dist/components/advancedFilter/AdvancedFilterRow.d.ts +7 -0
- package/dist/components/advancedFilter/index.d.ts +4 -0
- package/dist/components/advancedFilter/types.d.ts +43 -0
- package/dist/components/advancedFilter/utils.d.ts +3 -0
- package/dist/components/alert/Alert.d.ts +19 -0
- package/dist/components/alert/index.d.ts +1 -0
- package/dist/components/animatedList/AnimatedList.d.ts +19 -0
- package/dist/components/animatedList/hooks/useLayoutAnimation.d.ts +9 -0
- package/dist/components/animatedList/index.d.ts +2 -0
- package/dist/components/animatedList/types.d.ts +19 -0
- package/dist/components/baseButton/BaseButton.d.ts +13 -0
- package/dist/components/baseButton/index.d.ts +1 -0
- package/dist/components/baseTextBox/BaseTextBox.d.ts +40 -0
- package/dist/components/baseTextBox/index.d.ts +1 -0
- package/dist/components/baseTextBox/useInputValidation.d.ts +3 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +29 -0
- package/dist/components/breadcrumb/index.d.ts +1 -0
- package/dist/components/button/Button.d.ts +15 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/card/Card.d.ts +27 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +17 -0
- package/dist/components/checkbox/CheckboxIcon.d.ts +14 -0
- package/dist/components/checkbox/index.d.ts +4 -0
- package/dist/components/dialog/ConfirmationDialog.d.ts +36 -0
- package/dist/components/dialog/Dialog.d.ts +31 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dynamicIcon/DynamicIcon.d.ts +8 -0
- package/dist/components/dynamicIcon/index.d.ts +2 -0
- package/dist/components/field/Field.d.ts +82 -0
- package/dist/components/field/index.d.ts +16 -0
- package/dist/components/flow/FlowTile.d.ts +3 -0
- package/dist/components/flow/MetadataList.d.ts +6 -0
- package/dist/components/flow/StatusIcon.d.ts +5 -0
- package/dist/components/flow/TileHeader.d.ts +8 -0
- package/dist/components/flow/index.d.ts +2 -0
- package/dist/components/flow/types.d.ts +15 -0
- package/dist/components/iconButton/IconButton.d.ts +15 -0
- package/dist/components/iconButton/index.d.ts +1 -0
- package/dist/components/jsonEditor/JsonEditor.d.ts +7 -0
- package/dist/components/jsonEditor/index.d.ts +1 -0
- package/dist/components/list/List.d.ts +28 -0
- package/dist/components/list/ListItem.d.ts +20 -0
- package/dist/components/list/index.d.ts +2 -0
- package/dist/components/logo/Logo.d.ts +5 -0
- package/dist/components/logo/index.d.ts +2 -0
- package/dist/components/menu/Menu.d.ts +51 -0
- package/dist/components/menu/MenuEntry.d.ts +73 -0
- package/dist/components/menu/MenuFooter.d.ts +23 -0
- package/dist/components/menu/index.d.ts +11 -0
- package/dist/components/multiSelect/MultiSelect.d.ts +28 -0
- package/dist/components/multiSelect/index.d.ts +2 -0
- package/dist/components/popover/Popover.d.ts +60 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/radioButton/RadioButton.d.ts +29 -0
- package/dist/components/radioButton/index.d.ts +2 -0
- package/dist/components/select/Select.d.ts +30 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/tabPanel/Tab.d.ts +22 -0
- package/dist/components/tabPanel/TabPanel.d.ts +20 -0
- package/dist/components/tabPanel/index.d.ts +2 -0
- package/dist/components/tabPanel/useTabKeyboard.d.ts +16 -0
- package/dist/components/table/Table.d.ts +33 -0
- package/dist/components/table/TableCell.d.ts +17 -0
- package/dist/components/table/TableHeaderCell.d.ts +17 -0
- package/dist/components/table/components/Pagination.d.ts +21 -0
- package/dist/components/table/components/index.d.ts +1 -0
- package/dist/components/table/index.d.ts +6 -0
- package/dist/components/tag/Tag.d.ts +18 -0
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/tagList/TagList.d.ts +20 -0
- package/dist/components/tagList/index.d.ts +2 -0
- package/dist/components/tagList/utils.d.ts +2 -0
- package/dist/components/textBox/TextBox.d.ts +8 -0
- package/dist/components/textBox/index.d.ts +1 -0
- package/dist/components/toast/Toast.d.ts +2 -0
- package/dist/components/toast/Toaster.d.ts +10 -0
- package/dist/components/toast/index.d.ts +3 -0
- package/dist/components/toast/types.d.ts +22 -0
- package/dist/components/typography/Typography.d.ts +27 -0
- package/dist/components/typography/index.d.ts +2 -0
- package/dist/components/unstyledButton/UnstyledButton.d.ts +12 -0
- package/dist/components/unstyledButton/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useArrowNavigation.d.ts +30 -0
- package/dist/hooks/useResizeObserver.d.ts +1 -0
- package/dist/hooks/useViewportCollision.d.ts +7 -0
- package/dist/icons/icons.d.ts +256 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/index-CQ7w5dl6.js +8258 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.esm-DgyjJxy1.js +786 -0
- package/dist/index.js +92 -0
- package/dist/tailwind-styles.css +229 -0
- package/dist/test/setup.d.ts +0 -0
- package/dist/types/BaseOption.d.ts +5 -0
- package/dist/types/IconComponent.d.ts +6 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +94 -0
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
import { j as o } from "./index-CQ7w5dl6.js";
|
|
2
|
+
import { useState as G, useEffect as Oe, createContext as Xt, useRef as ce, useContext as Zt, useMemo as le, useCallback as Ie } from "react";
|
|
3
|
+
const Be = (e, t, n, r, a) => {
|
|
4
|
+
if (!r) throw new Error(a ?? `Invalid property path: ${t}
|
|
5
|
+
Couldn't access "${n}" in ${JSON.stringify(e)}`);
|
|
6
|
+
}, Wt = (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
|
+
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
|
+
var l;
|
|
9
|
+
const c = Object.assign(Object.assign({}, r), { remove: a, createNew: i, noError: s, fullData: p, fullPath: d }), u = Array.isArray(t) ? t : ((h) => Array.isArray(h) ? h : h.split(/(\.|\[\d+\])/).filter(((f) => f !== "." && f !== "")).map(((f) => {
|
|
10
|
+
const m = /\[(\d+)\]/.exec(f);
|
|
11
|
+
return m ? Number(m[1]) : f;
|
|
12
|
+
})).flat())(t).filter(((h) => h !== ""));
|
|
13
|
+
return gt(e) && a && u.length === 1 ? Qt(e, u[0]) : lt(e, u, n, c);
|
|
14
|
+
}, lt = (e, t, n, r) => {
|
|
15
|
+
const a = Wt(e) ? Object.assign({}, e) : null, i = gt(e) ? [...e] : null;
|
|
16
|
+
if (t.length === 0) return e;
|
|
17
|
+
if (!a && !i) throw new Error("Can't assign property -- invalid input object");
|
|
18
|
+
const { createNew: s, remove: p, noError: d, fullData: l, fullPath: c } = r, u = t[0];
|
|
19
|
+
if (i && typeof u == "string") return i.map(((v) => lt(v, t, n, r)));
|
|
20
|
+
if (t.length === 1) {
|
|
21
|
+
if (a && typeof u == "string") {
|
|
22
|
+
const v = Dn(a, u, n, r);
|
|
23
|
+
return v ?? a;
|
|
24
|
+
}
|
|
25
|
+
return i && typeof u == "number" ? (On(i, u, n, r), i) : (Be(l, c, u, d), e);
|
|
26
|
+
}
|
|
27
|
+
const h = a || i || [];
|
|
28
|
+
if (p && t.length === 2 && typeof t[1] == "number") {
|
|
29
|
+
const v = h[u], D = t[1];
|
|
30
|
+
return gt(v) ? h[u] = Qt(v, D) : Be(l, c, u, d, "Trying to remove an indexed item from an object that is not an array"), h;
|
|
31
|
+
}
|
|
32
|
+
const f = t.slice(1);
|
|
33
|
+
if (u in e) {
|
|
34
|
+
if (m = h[u], !gt(m) && !Wt(m)) {
|
|
35
|
+
if (!s) return Be(l, c, u, d), h;
|
|
36
|
+
h[u] = {};
|
|
37
|
+
}
|
|
38
|
+
return h[u] = lt(h[u], f, n, r), h;
|
|
39
|
+
}
|
|
40
|
+
var m;
|
|
41
|
+
if (s) {
|
|
42
|
+
const v = typeof f[0] == "number" ? [] : {};
|
|
43
|
+
if (a) return h[u] = v, h[u] = lt(h[u], f, n, r), h;
|
|
44
|
+
if (i && Array.isArray(h)) {
|
|
45
|
+
h.push(v);
|
|
46
|
+
const D = h.length - 1;
|
|
47
|
+
return h[D] = lt(h[D], f, n, r), h;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return Be(l, c, u, d), h;
|
|
51
|
+
}, Dn = (e, t, n, r) => {
|
|
52
|
+
const { remove: a, createNew: i, noError: s, insertAfter: p, insertBefore: d, fullData: l, fullPath: c } = r;
|
|
53
|
+
if (d !== void 0 || p !== void 0) {
|
|
54
|
+
const h = Object.entries(e);
|
|
55
|
+
let f = 1 / 0;
|
|
56
|
+
return f = typeof d == "number" ? d : typeof p == "number" ? p : h.findIndex((([m, v]) => m === (d ?? p))), p && f++, h.splice(f, 0, [t, n]), Object.fromEntries(h);
|
|
57
|
+
}
|
|
58
|
+
const u = t in e;
|
|
59
|
+
a ? u ? delete e[t] : Be(l, c, t, s) : i || u ? e[t] = n : Be(l, c, t, s);
|
|
60
|
+
}, On = (e, t, n, r) => {
|
|
61
|
+
const { noError: a, fullData: i, fullPath: s, createNew: p, insert: d } = r;
|
|
62
|
+
d && e.splice(t, 0, n), t in e ? e[t] = n : p ? e.push(n) : Be(i, s, t, a);
|
|
63
|
+
}, qe = (e, t, n) => {
|
|
64
|
+
const r = Array.isArray(t) ? t : Cn(t);
|
|
65
|
+
if (r.length === 0) return e;
|
|
66
|
+
const a = r[0];
|
|
67
|
+
if (Array.isArray(e) && typeof a != "number") return e.map(((s) => qe(s, r)));
|
|
68
|
+
if (typeof e != "object" || e === null || !(a in e)) return kn(e, a);
|
|
69
|
+
const i = e[a];
|
|
70
|
+
return r.length === 1 ? i : qe(i, r.slice(1));
|
|
71
|
+
}, Cn = (e) => e.split(/(\.|\[\d+\])/).filter(((t) => t !== "." && t !== "")).map(((t) => {
|
|
72
|
+
const n = /\[(\d+)\]/.exec(t);
|
|
73
|
+
return n ? Number(n[1]) : t;
|
|
74
|
+
})).flat(), kn = (e, t, n) => {
|
|
75
|
+
throw new Error(`Unable to extract object property
|
|
76
|
+
Looking for property: ${t}
|
|
77
|
+
In object: ${JSON.stringify(e)}`);
|
|
78
|
+
};
|
|
79
|
+
function qt(e, t) {
|
|
80
|
+
var n = {};
|
|
81
|
+
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
|
|
82
|
+
if (e != null && typeof Object.getOwnPropertySymbols == "function") {
|
|
83
|
+
var a = 0;
|
|
84
|
+
for (r = Object.getOwnPropertySymbols(e); a < r.length; a++) t.indexOf(r[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[a]) && (n[r[a]] = e[r[a]]);
|
|
85
|
+
}
|
|
86
|
+
return n;
|
|
87
|
+
}
|
|
88
|
+
function Qe(e, t, n, r) {
|
|
89
|
+
return new (n || (n = Promise))((function(a, i) {
|
|
90
|
+
function s(l) {
|
|
91
|
+
try {
|
|
92
|
+
d(r.next(l));
|
|
93
|
+
} catch (c) {
|
|
94
|
+
i(c);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function p(l) {
|
|
98
|
+
try {
|
|
99
|
+
d(r.throw(l));
|
|
100
|
+
} catch (c) {
|
|
101
|
+
i(c);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function d(l) {
|
|
105
|
+
var c;
|
|
106
|
+
l.done ? a(l.value) : (c = l.value, c instanceof n ? c : new n((function(u) {
|
|
107
|
+
u(c);
|
|
108
|
+
}))).then(s, p);
|
|
109
|
+
}
|
|
110
|
+
d((r = r.apply(e, [])).next());
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
const en = ({ className: e, name: t, value: n, setValue: r, handleKeyPress: a, styles: i, textAreaRef: s }) => {
|
|
114
|
+
if (typeof n != "string") return null;
|
|
115
|
+
const p = n.slice(-1) === `
|
|
116
|
+
` ? n + "." : n;
|
|
117
|
+
return o.jsxs("div", { style: { display: "grid" }, children: [o.jsx("textarea", { id: `${t}_textarea`, ref: s, style: Object.assign({ height: "auto", gridArea: "1 / 1 / 2 / 2", overflowY: "auto", whiteSpace: "pre-wrap" }, i), rows: 1, className: e, name: `${t}_textarea`, value: n, onChange: (d) => r(d.target.value), autoFocus: !0, onFocus: (d) => {
|
|
118
|
+
n.length < 40 && d.target.select();
|
|
119
|
+
}, onKeyDown: a }), o.jsx("span", { className: e, style: Object.assign({ visibility: "hidden", height: "auto", gridArea: "1 / 1 / 2 / 2", color: "red", opacity: 0.9, whiteSpace: "pre-wrap", overflowY: "auto", border: "1px solid transparent" }, i), children: p })] });
|
|
120
|
+
}, et = (e) => e !== null && typeof e == "object", tn = (e, t, n, r = "") => {
|
|
121
|
+
if (!n && !r) return !0;
|
|
122
|
+
switch (e) {
|
|
123
|
+
case "collection":
|
|
124
|
+
if (n) {
|
|
125
|
+
if (n(t, r)) return !0;
|
|
126
|
+
if (!Ct(r, t, n)) return !1;
|
|
127
|
+
}
|
|
128
|
+
if (!n && r && !Ct(r, t)) return !1;
|
|
129
|
+
break;
|
|
130
|
+
case "value":
|
|
131
|
+
if (n && !n(t, r) || !n && r && !tt(t, r)) return !1;
|
|
132
|
+
}
|
|
133
|
+
return !0;
|
|
134
|
+
}, Ct = (e = "", t, n = tt) => {
|
|
135
|
+
const r = t.value;
|
|
136
|
+
return Object.entries(r).some((([a, i]) => {
|
|
137
|
+
const s = [...t.path, a], p = Object.assign(Object.assign({}, t), { key: a, path: s, level: t.level + 1, value: i, size: s.length, parentData: r });
|
|
138
|
+
return et(i) ? Ct(e, p, n) : n(p, e);
|
|
139
|
+
}));
|
|
140
|
+
}, tt = (e, t = "") => {
|
|
141
|
+
const { value: n } = e;
|
|
142
|
+
if (n === null && "null".includes(t.toLowerCase())) return !0;
|
|
143
|
+
switch (typeof n) {
|
|
144
|
+
case "string":
|
|
145
|
+
return n.toLowerCase().includes(t.toLowerCase());
|
|
146
|
+
case "number":
|
|
147
|
+
return !!String(n).includes(t);
|
|
148
|
+
case "boolean":
|
|
149
|
+
return n ? "true".includes(t.toLowerCase()) || t === "1" : "false".includes(t.toLowerCase()) || t === "0";
|
|
150
|
+
default:
|
|
151
|
+
return !1;
|
|
152
|
+
}
|
|
153
|
+
}, Yt = ({ key: e, path: t }, n = "") => !!tt({ value: e }, n) || !!t.some(((r) => tt({ value: r }, n))), Ue = (e, t) => (t ?? "") + e.map(((n) => n === "" ? "\0" : n)).join("."), Tt = (e) => e.shiftKey ? "Shift" : e.metaKey ? "Meta" : e.ctrlKey ? "Control" : e.altKey ? "Alt" : void 0, Sn = (e, t, n) => {
|
|
154
|
+
const r = e.key, a = Tt(e);
|
|
155
|
+
if (Array.isArray(t)) return !!a && t.includes(a);
|
|
156
|
+
const { key: i, modifier: s } = t;
|
|
157
|
+
return (n !== "stringLineBreak" || r !== "Enter" || a !== "Shift" || i !== "Enter" || !s?.includes("Shift")) && r === i && (s === a || Array.isArray(s) && s.includes(a));
|
|
158
|
+
}, 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"] }, We = (e, t, n = "next", r) => {
|
|
159
|
+
const a = t.slice(0, t.length - 1), i = t.slice(-1)[0];
|
|
160
|
+
if (i === void 0) return null;
|
|
161
|
+
const s = qe(e, a), p = Nn(s);
|
|
162
|
+
Array.isArray(s) || r(p, (({ key: c, value: u }) => [c, u]));
|
|
163
|
+
const d = p.findIndex(((c) => c.key === i)), l = p[d + (n === "next" ? 1 : -1)];
|
|
164
|
+
return l ? et(l.value) ? Object.keys(l.value).length === 0 ? We(e, [...a, l.key], n, r) : nn(e, [...a, l.key], n, r) : [...a, l.key] : a.length === 0 ? null : We(e, a, n, r);
|
|
165
|
+
}, nn = (e, t, n = "next", r) => {
|
|
166
|
+
const a = qe(e, t);
|
|
167
|
+
if (!et(a)) return t;
|
|
168
|
+
const i = Array.isArray(a) ? a.map(((p, d) => d)) : Object.keys(a);
|
|
169
|
+
r(i, ((p) => [p, a]));
|
|
170
|
+
const s = n === "next" ? i[0] : i[i.length - 1];
|
|
171
|
+
return nn(e, [...t, s], n, r);
|
|
172
|
+
}, Nn = (e) => Array.isArray(e) ? e.map(((t, n) => ({ index: n, value: t, key: n }))) : Object.entries(e).map((([t, n], r) => ({ key: t, value: n, index: r }))), rn = (e, t) => {
|
|
173
|
+
var n, r, a, i;
|
|
174
|
+
const s = e.current, p = (n = s?.selectionStart) !== null && n !== void 0 ? n : 1 / 0, d = (r = s?.selectionEnd) !== null && r !== void 0 ? r : 1 / 0, l = ((a = s?.textContent) === null || a === void 0 ? void 0 : a.slice(0, p)) + t + ((i = s?.textContent) === null || i === void 0 ? void 0 : i.slice(d));
|
|
175
|
+
return s.value = l, s?.setSelectionRange(p + 1, p + 1), l;
|
|
176
|
+
}, kt = (e) => {
|
|
177
|
+
if (e !== on) {
|
|
178
|
+
if (Array.isArray(e)) return e.map(((t) => kt(t)));
|
|
179
|
+
if (e && typeof e == "object") for (const t in e) e[t] = kt(e[t]);
|
|
180
|
+
return e;
|
|
181
|
+
}
|
|
182
|
+
}, on = "__undefined__", At = { displayName: "Default", fragments: { edit: "rgb(42, 161, 152)" }, styles: { container: { backgroundColor: "#f6f6f6", fontFamily: "monospace" }, collection: {}, collectionInner: {}, collectionElement: {}, dropZone: {}, property: "#292929", bracket: { color: "rgb(0, 43, 54)", fontWeight: "bold" }, itemCount: { color: "rgba(0, 0, 0, 0.3)", fontStyle: "italic" }, string: "rgb(203, 75, 22)", number: "rgb(38, 139, 210)", boolean: "green", null: { color: "rgb(220, 50, 47)", fontVariant: "small-caps", fontWeight: "bold" }, input: ["#292929"], inputHighlight: "#b3d8ff", error: { fontSize: "0.8em", color: "red", fontWeight: "bold" }, iconCollection: "rgb(0, 43, 54)", iconEdit: "edit", iconDelete: "rgb(203, 75, 22)", iconAdd: "edit", iconCopy: "rgb(38, 139, 210)", iconOk: "green", iconCancel: "rgb(203, 75, 22)" } }, an = Xt({ getStyles: () => ({}), icons: {} }), Tn = ({ theme: e = At, icons: t = {}, docRoot: n, children: r }) => {
|
|
183
|
+
const a = An(e, n);
|
|
184
|
+
return o.jsx(an.Provider, { value: { getStyles: (i, s) => typeof a[i] == "function" ? a[i](s) : a[i], icons: t }, children: r });
|
|
185
|
+
}, Ce = () => Zt(an), An = (e, t) => {
|
|
186
|
+
var n, r, a, i;
|
|
187
|
+
const s = {}, p = (Array.isArray(e) ? e : [e]).map(((c) => Pn(c) ? Ot({ fragments: {}, styles: c }, s) : Ot(c, s))), d = Ot(At, {});
|
|
188
|
+
Object.keys(d).forEach(((c) => {
|
|
189
|
+
const u = c;
|
|
190
|
+
p.forEach(((h) => {
|
|
191
|
+
h[u] && (d[u] = Object.assign(Object.assign({}, d[u]), h[u]));
|
|
192
|
+
}));
|
|
193
|
+
}));
|
|
194
|
+
const l = Object.assign({}, d);
|
|
195
|
+
return Object.entries(s).forEach((([c, u]) => {
|
|
196
|
+
const h = c;
|
|
197
|
+
l[h] = (f) => {
|
|
198
|
+
const m = u(f) || {};
|
|
199
|
+
return Object.assign(Object.assign({}, d[h]), m);
|
|
200
|
+
};
|
|
201
|
+
})), typeof l?.inputHighlight != "function" && (!((n = l?.inputHighlight) === null || n === void 0) && n.backgroundColor) && t.style.setProperty("--jer-highlight-color", (r = l?.inputHighlight) === null || r === void 0 ? void 0 : r.backgroundColor), typeof l?.iconCopy != "function" && (!((a = l?.iconCopy) === null || a === void 0) && a.color) && t.style.setProperty("--jer-icon-copy-color", (i = l?.iconCopy) === null || i === void 0 ? void 0 : i.color), l;
|
|
202
|
+
}, Ot = (e, t) => {
|
|
203
|
+
const { fragments: n, styles: r } = e, a = {};
|
|
204
|
+
return Object.entries(r).forEach((([i, s]) => {
|
|
205
|
+
const p = (Array.isArray(s) ? s : [s]).reduce(((d, l) => {
|
|
206
|
+
var c, u;
|
|
207
|
+
if (typeof l == "function") return t[i] = l, Object.assign({}, d);
|
|
208
|
+
if (typeof l == "string") {
|
|
209
|
+
const h = (c = n?.[l]) !== null && c !== void 0 ? c : l;
|
|
210
|
+
return typeof h == "string" ? Object.assign(Object.assign({}, d), { [(u = In[i]) !== null && u !== void 0 ? u : "color"]: h }) : Object.assign(Object.assign({}, d), h);
|
|
211
|
+
}
|
|
212
|
+
return Object.assign(Object.assign({}, d), l);
|
|
213
|
+
}), {});
|
|
214
|
+
a[i] = p;
|
|
215
|
+
})), a;
|
|
216
|
+
}, Pn = (e) => !("styles" in e), In = { container: "backgroundColor", collection: "backgroundColor", collectionInner: "backgroundColor", collectionElement: "backgroundColor", dropZone: "borderColor", inputHighlight: "backgroundColor" }, sn = Xt(null), Kn = ({ children: e, onEditEvent: t, onCollapse: n }) => {
|
|
217
|
+
const [r, a] = G(null), [i, s] = G(null), [p, d] = G(null), [l, c] = G({ path: null, pathString: null }), u = ce(null), h = ce("next"), f = ce(null);
|
|
218
|
+
return o.jsx(sn.Provider, { value: { collapseState: r, setCollapseState: (m) => {
|
|
219
|
+
a(m), n && m !== null && (Array.isArray(m) ? m.forEach(((v) => n(v))) : n(m)), m !== null && setTimeout((() => a(null)), 2e3);
|
|
220
|
+
}, getMatchingCollapseState: (m) => {
|
|
221
|
+
if (Array.isArray(r)) {
|
|
222
|
+
for (const v of r) if (Ut(m, v)) return v;
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
return Ut(m, r) ? r : null;
|
|
226
|
+
}, currentlyEditingElement: i, setCurrentlyEditingElement: (m, v) => {
|
|
227
|
+
const D = typeof m == "string" || m === null ? m : Ue(m, v === "key" ? "key_" : void 0);
|
|
228
|
+
i !== null && D !== null && u.current !== null && u.current(), s(D), t && (Array.isArray(m) || m === null) && t(m, v === "key"), u.current = typeof v == "function" ? v : null;
|
|
229
|
+
}, areChildrenBeingEdited: (m) => i !== null && i.includes(m), previouslyEditedElement: f.current, setPreviouslyEditedElement: (m) => {
|
|
230
|
+
f.current = m;
|
|
231
|
+
}, tabDirection: h.current, setTabDirection: (m) => {
|
|
232
|
+
h.current = m;
|
|
233
|
+
}, previousValue: p, setPreviousValue: d, dragSource: l, setDragSource: c }, children: e });
|
|
234
|
+
}, He = () => {
|
|
235
|
+
const e = Zt(sn);
|
|
236
|
+
if (!e) throw new Error("Missing Context Provider");
|
|
237
|
+
return e;
|
|
238
|
+
}, Ut = (e, t) => {
|
|
239
|
+
if (t === null) return !1;
|
|
240
|
+
if (!t.includeChildren) return t.path.every(((n, r) => e[r] === n)) && t.path.length === e.length;
|
|
241
|
+
for (const [n, r] of t.path.entries()) if (r !== e[n]) return !1;
|
|
242
|
+
return !0;
|
|
243
|
+
}, St = "**INVALID_FUNCTION**", Rn = ({ nodeData: e, showStringQuotes: t = !0, stringTruncate: n = 200, pathString: r, canEdit: a, setIsEditing: i, styles: s, translate: p, value: d, TextWrapper: l = ({ children: c }) => c }) => {
|
|
244
|
+
const c = d ?? e.value, [u, h] = G(!1), f = t ? '"' : "", m = c.length > n, v = () => {
|
|
245
|
+
a ? i(!0) : h(!u);
|
|
246
|
+
};
|
|
247
|
+
return o.jsxs("div", { id: `${r}_display`, onDoubleClick: v, onClick: (D) => {
|
|
248
|
+
(D.getModifierState("Control") || D.getModifierState("Meta")) && v();
|
|
249
|
+
}, className: "jer-value-string", style: s, children: [f, m ? o.jsxs(o.Fragment, u ? { children: [o.jsx(l, { children: o.jsxs("span", { children: [c, f] }) }), o.jsxs("span", { className: "jer-string-expansion jer-show-less", onClick: () => h(!1), children: [" ", p("SHOW_LESS", e)] })] } : { children: [o.jsxs(l, { children: [o.jsx("span", { children: c.slice(0, n - 2).trimEnd() }), " "] }), o.jsx("span", { className: "jer-string-expansion jer-ellipsis", onClick: () => h(!0), children: "..." }), f] }) : o.jsx(l, { children: `${c}${f}` })] });
|
|
250
|
+
}, Vn = ({ styles: e, pathString: t, value: n, setValue: r, handleEdit: a, handleKeyboard: i, keyboardCommon: s }) => {
|
|
251
|
+
const p = ce(null);
|
|
252
|
+
return o.jsx(en, { className: "jer-input-text", textAreaRef: p, name: t, value: n, setValue: r, handleKeyPress: (d) => {
|
|
253
|
+
i(d, Object.assign({ stringConfirm: a, stringLineBreak: () => {
|
|
254
|
+
const l = rn(p, `
|
|
255
|
+
`);
|
|
256
|
+
r(l);
|
|
257
|
+
} }, s));
|
|
258
|
+
}, styles: e });
|
|
259
|
+
}, _n = (e) => {
|
|
260
|
+
var { isEditing: t, path: n, enumType: r } = e, a = qt(e, ["isEditing", "path", "enumType"]);
|
|
261
|
+
const { getStyles: i } = Ce(), s = Ue(n), { value: p, setValue: d, nodeData: l, handleEdit: c, handleKeyboard: u, keyboardCommon: h } = a;
|
|
262
|
+
return t && r ? o.jsxs("div", { className: "jer-select jer-select-enums", children: [o.jsx("select", { name: `${s}-value-select`, className: "jer-select-inner", onChange: (f) => d(f.target.value), value: p, autoFocus: !0, onKeyDown: (f) => {
|
|
263
|
+
u(f, Object.assign({ stringConfirm: c }, h));
|
|
264
|
+
}, children: r.values.map(((f) => o.jsx("option", { value: f, children: f }, f))) }), o.jsx("span", { className: "focus" })] }) : t ? o.jsx(Vn, Object.assign({ styles: i("input", l), pathString: s }, a, { setValue: a.setValue })) : o.jsx(Rn, Object.assign({ pathString: s, styles: i("string", l) }, a));
|
|
265
|
+
}, Ln = ({ value: e, setValue: t, isEditing: n, path: r, setIsEditing: a, handleEdit: i, nodeData: s, handleKeyboard: p, keyboardCommon: d }) => {
|
|
266
|
+
const { getStyles: l } = Ce();
|
|
267
|
+
return n ? o.jsx("input", { className: "jer-input-number", type: "text", name: Ue(r), value: e, onChange: (c) => t(c.target.value.replace(/[^0-9.-]/g, "")), autoFocus: !0, onFocus: (c) => setTimeout((() => c.target.select()), 10), onKeyDown: (c) => p(c, Object.assign({ numberConfirm: i, numberUp: () => t(Number(e) + 1), numberDown: () => t(Number(e) - 1) }, d)), style: Object.assign({ width: String(e).length / 1.5 + 2 + "em" }, l("input", s)) }) : o.jsx("span", { onDoubleClick: () => a(!0), className: "jer-value-number", style: l("number", s), children: e });
|
|
268
|
+
}, Mn = ({ value: e, setValue: t, isEditing: n, path: r, setIsEditing: a, handleEdit: i, nodeData: s, handleKeyboard: p, keyboardCommon: d }) => {
|
|
269
|
+
const { getStyles: l } = Ce();
|
|
270
|
+
return typeof e != "boolean" ? null : n ? o.jsx("input", { className: "jer-input-boolean", type: "checkbox", name: Ue(r), checked: e, onChange: () => t(!e), onKeyDown: (c) => {
|
|
271
|
+
c.key === " " && c.preventDefault(), p(c, Object.assign({ booleanConfirm: i, booleanToggle: () => t(!e) }, d));
|
|
272
|
+
}, autoFocus: !0 }) : o.jsx("span", { onDoubleClick: () => a(!0), className: "jer-value-boolean", style: l("boolean", s), children: String(e) });
|
|
273
|
+
}, zn = (e, t) => {
|
|
274
|
+
const n = ce(void 0), r = ce(t);
|
|
275
|
+
Oe((() => {
|
|
276
|
+
r.current = t;
|
|
277
|
+
}), [t]);
|
|
278
|
+
const a = (i) => {
|
|
279
|
+
r.current(i);
|
|
280
|
+
};
|
|
281
|
+
Oe((() => {
|
|
282
|
+
if (window.clearTimeout(n.current), e) return n.current = window.setTimeout((() => {
|
|
283
|
+
window.addEventListener("keydown", a);
|
|
284
|
+
}), 100), () => {
|
|
285
|
+
window.clearTimeout(n.current), window.removeEventListener("keydown", a);
|
|
286
|
+
};
|
|
287
|
+
}), [e]);
|
|
288
|
+
}, Fn = ({ value: e, isEditing: t, setIsEditing: n, handleEdit: r, nodeData: a, handleKeyboard: i, keyboardCommon: s }) => {
|
|
289
|
+
const { getStyles: p } = Ce();
|
|
290
|
+
return zn(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) });
|
|
291
|
+
}, Bn = ({ value: e }) => {
|
|
292
|
+
let t = "Error!";
|
|
293
|
+
switch (typeof e) {
|
|
294
|
+
case "string":
|
|
295
|
+
e === St && (t = "Function");
|
|
296
|
+
break;
|
|
297
|
+
case "undefined":
|
|
298
|
+
t = "Undefined";
|
|
299
|
+
break;
|
|
300
|
+
case "symbol":
|
|
301
|
+
t = "Symbol";
|
|
302
|
+
}
|
|
303
|
+
return o.jsx("span", { className: "jer-value-invalid", children: t });
|
|
304
|
+
}, 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, 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" })] }), Yn = ({ 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" })] }), $n = ({ 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" })] }), Gn = ({ 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" }) }), Jn = ({ 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" }) }), Ye = ({ name: e, nodeData: t }) => {
|
|
305
|
+
var n, r, a, i, s, p, d;
|
|
306
|
+
const { getStyles: l, icons: c } = Ce(), u = { size: "1.4em", className: "jer-icon" };
|
|
307
|
+
switch (e) {
|
|
308
|
+
case "add":
|
|
309
|
+
return (n = c?.add) !== null && n !== void 0 ? n : o.jsx(Wn, Object.assign({}, u, { style: l("iconAdd", t) }));
|
|
310
|
+
case "edit":
|
|
311
|
+
return (r = c?.edit) !== null && r !== void 0 ? r : o.jsx(Yn, Object.assign({}, u, { style: l("iconEdit", t) }));
|
|
312
|
+
case "delete":
|
|
313
|
+
return (a = c?.delete) !== null && a !== void 0 ? a : o.jsx(Hn, Object.assign({}, u, { style: l("iconDelete", t), size: "1.45em" }));
|
|
314
|
+
case "copy":
|
|
315
|
+
return (i = c?.copy) !== null && i !== void 0 ? i : o.jsx(Un, Object.assign({}, u, { style: l("iconCopy", t), size: "1.2em" }));
|
|
316
|
+
case "ok":
|
|
317
|
+
return (s = c?.ok) !== null && s !== void 0 ? s : o.jsx($n, Object.assign({}, u, { style: Object.assign({ fontSize: "90%" }, l("iconOk", t)) }));
|
|
318
|
+
case "cancel":
|
|
319
|
+
return (p = c?.cancel) !== null && p !== void 0 ? p : o.jsx(Gn, Object.assign({}, u, { style: Object.assign({ fontSize: "130%" }, l("iconCancel", t)) }));
|
|
320
|
+
case "chevron":
|
|
321
|
+
return (d = c?.chevron) !== null && d !== void 0 ? d : o.jsx(Jn, { size: "1em", style: l("iconCollection", t) });
|
|
322
|
+
default:
|
|
323
|
+
return o.jsx(o.Fragment, {});
|
|
324
|
+
}
|
|
325
|
+
}, ln = ({ startEdit: e, handleDelete: t, handleAdd: n, enableClipboard: r, type: a, customButtons: i, nodeData: s, translate: p, keyboardControls: d, handleKeyboard: l, editConfirmRef: c, getNewKeyOptions: u, jsonStringify: h, onEditEvent: f, showIconTooltips: m }) => {
|
|
326
|
+
const { getStyles: v } = Ce(), D = p("KEY_NEW", s), [O, w] = G(D), [N, _] = G(!1), { key: Y, path: F, value: H } = s, J = Array.isArray(N), W = (C) => {
|
|
327
|
+
var k;
|
|
328
|
+
if (f && f(C ? [...F, null] : null, C), !C) return void _(!1);
|
|
329
|
+
const L = Object.keys(qe(s.fullData, F)), $ = u ? (k = u(s)) === null || k === void 0 ? void 0 : k.filter(((ae) => !L.includes(ae))) : null;
|
|
330
|
+
$ && w(""), _($ == null || $);
|
|
331
|
+
};
|
|
332
|
+
return o.jsxs("div", { className: "jer-edit-buttons", style: { opacity: N ? 1 : void 0 }, onClick: (C) => C.stopPropagation(), children: [r && o.jsx("div", { onClick: (C) => {
|
|
333
|
+
var k;
|
|
334
|
+
C.stopPropagation();
|
|
335
|
+
let L, $, ae = "value", X = "", ne = null;
|
|
336
|
+
if (r) {
|
|
337
|
+
const Z = Tt(C);
|
|
338
|
+
if (Z && d.clipboardModifier.includes(Z) ? (L = Xn(F), X = L, ae = "path") : (L = H, X = typeof L == "object" ? h(H) : String(L)), !navigator.clipboard) return void (typeof r == "function" && r({ success: !1, value: L, stringValue: X, path: F, key: Y, type: ae, errorMessage: "Can't access clipboard API" }));
|
|
339
|
+
(k = navigator.clipboard) === null || k === void 0 || k.writeText(X).then((() => $ = !0)).catch(((M) => {
|
|
340
|
+
$ = !1, ne = M.message;
|
|
341
|
+
})).finally((() => {
|
|
342
|
+
typeof r == "function" && r({ success: $, errorMessage: ne, value: L, stringValue: X, path: F, key: Y, type: ae });
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
}, className: "jer-copy-pulse", title: m ? p("TOOLTIP_COPY", s) : "", children: o.jsx(Ye, { name: "copy", nodeData: s }) }), e && o.jsx("div", { onClick: e, title: m ? p("TOOLTIP_EDIT", s) : "", children: o.jsx(Ye, { name: "edit", nodeData: s }) }), t && o.jsx("div", { onClick: t, title: m ? p("TOOLTIP_DELETE", s) : "", children: o.jsx(Ye, { name: "delete", nodeData: s }) }), n && o.jsx("div", { onClick: () => {
|
|
346
|
+
a === "object" ? W(!0) : n("");
|
|
347
|
+
}, title: m ? p("TOOLTIP_ADD", s) : "", children: o.jsx(Ye, { name: "add", nodeData: s }) }), i?.map((({ Element: C, onClick: k }, L) => o.jsx("div", { onClick: ($) => k && k(s, $), children: o.jsx(C, { nodeData: s }) }, L))), N && n && a === "object" && o.jsxs(o.Fragment, { children: [J ? o.jsxs("div", { className: "jer-select jer-select-keys", children: [o.jsxs("select", { name: "new-key-select", className: "jer-select-inner", onChange: (C) => {
|
|
348
|
+
n(C.target.value), W(!1);
|
|
349
|
+
}, defaultValue: "", autoFocus: !0, onKeyDown: (C) => {
|
|
350
|
+
l(C, { cancel: () => W(!1) });
|
|
351
|
+
}, 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) => {
|
|
352
|
+
l(C, { stringConfirm: () => {
|
|
353
|
+
n && (W(!1), n(O), w(D));
|
|
354
|
+
}, cancel: () => {
|
|
355
|
+
W(!1), w(D);
|
|
356
|
+
} });
|
|
357
|
+
}, style: v("input", s) }), o.jsx(Pt, { onOk: () => {
|
|
358
|
+
J && !O || (W(!1), n(O));
|
|
359
|
+
}, onCancel: () => {
|
|
360
|
+
W(!1);
|
|
361
|
+
}, nodeData: s, editConfirmRef: c, hideOk: J })] })] });
|
|
362
|
+
}, 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(Ye, { name: "ok", nodeData: n }) }), o.jsx("div", { onClick: t, children: o.jsx(Ye, { name: "cancel", nodeData: n }) })] }), Xn = (e) => e.reduce(((t, n) => typeof n == "number" ? `${t}[${n}]` : t === "" ? n : `${t}.${n}`), ""), Zn = ["string", "number", "boolean", "null", "object", "array"], cn = ({ props: e, collapsed: t }) => {
|
|
363
|
+
const { data: n, nodeData: r, parentData: a, onEdit: i, onError: s, showErrorMessages: p, restrictEditFilter: d, restrictDeleteFilter: l, restrictAddFilter: c, restrictDragFilter: u, translate: h, errorMessageTimeout: f } = e, { currentlyEditingElement: m, setCurrentlyEditingElement: v } = He(), [D, O] = G(null), w = Object.assign(Object.assign({}, r), { collapsed: t }), { path: N, key: _, size: Y } = w, F = Ue(N), H = !d(w), J = !l(w), W = !c(w), C = !u(w) && J && m === null, k = (M) => {
|
|
364
|
+
p && (O(M), setTimeout((() => O(null)), f)), console.warn("Error", M);
|
|
365
|
+
}, L = Ie(((M, z) => {
|
|
366
|
+
k(M.message), s && s({ currentData: w.fullData, errorValue: z, currentValue: n, name: _, path: N, error: M });
|
|
367
|
+
}), [s, p]), $ = m === F, ae = m === `key_${F}`, X = typeof N.slice(-1)[0] == "number", ne = { isEditing: $, isEditingKey: ae, isArray: X, canEditKey: a !== null && H && W && J && !X }, Z = _ === "" && N.length > 0 ? h("EMPTY_STRING", w) : null;
|
|
368
|
+
return { pathString: F, nodeData: w, path: N, name: _, size: Y, canEdit: H, canDelete: J, canAdd: W, canDrag: C, error: D, showError: k, onError: L, setError: O, handleEditKey: (M) => {
|
|
369
|
+
if (v(null), _ === M || !a) return;
|
|
370
|
+
const z = N.slice(0, -1);
|
|
371
|
+
if (Object.keys(a).includes(M)) return void L({ code: "KEY_EXISTS", message: h("ERROR_KEY_EXISTS", w) }, M);
|
|
372
|
+
const ge = Object.fromEntries(Object.entries(a).map((([B, I]) => B === _ ? [M, I] : [B, I])));
|
|
373
|
+
i(ge, z).then(((B) => {
|
|
374
|
+
B && L({ code: "UPDATE_ERROR", message: B }, M);
|
|
375
|
+
}));
|
|
376
|
+
}, derivedValues: ne, emptyStringKey: Z };
|
|
377
|
+
}, un = ({ canDrag: e, canDragOnto: t, path: n, nodeData: r, onMove: a, onError: i, translate: s }) => {
|
|
378
|
+
const { getStyles: p } = Ce(), { dragSource: d, setDragSource: l } = He(), [c, u] = G(!1), h = Ue(n), f = le((() => e ? { onDragStart: (O) => {
|
|
379
|
+
O.stopPropagation(), l({ path: n, pathString: h });
|
|
380
|
+
}, onDragEnd: (O) => {
|
|
381
|
+
O.stopPropagation(), l({ path: null, pathString: null });
|
|
382
|
+
} } : {}), [e, h]), m = le((() => (O) => t ? { onDragOver: (w) => {
|
|
383
|
+
w.stopPropagation(), w.preventDefault();
|
|
384
|
+
}, onDrop: (w) => {
|
|
385
|
+
w.stopPropagation(), D(O), l({ path: null, pathString: null }), u(!1);
|
|
386
|
+
}, onDragEnter: (w) => {
|
|
387
|
+
var N;
|
|
388
|
+
w.stopPropagation(), h.startsWith((N = d.pathString) !== null && N !== void 0 ? N : "") || u(O);
|
|
389
|
+
}, onDragExit: (w) => {
|
|
390
|
+
w.stopPropagation(), u(!1);
|
|
391
|
+
} } : {}), [d, t, h]), v = le((() => t && d.pathString !== null ? o.jsx("div", Object.assign({ className: "jer-drop-target-bottom", style: { height: "50%", position: "absolute", width: "100%", top: "50%", zIndex: n.length } }, m("below"))) : null), [d, t, n.length]), D = (O) => {
|
|
392
|
+
var w, N;
|
|
393
|
+
const _ = (w = d.path) === null || w === void 0 ? void 0 : w.slice(-1)[0], Y = (N = d.path) === null || N === void 0 ? void 0 : N.slice(0, -1).join("."), F = n.slice(0, -1).join(""), { parentData: H } = r;
|
|
394
|
+
typeof _ == "string" && H && !Array.isArray(H) && Object.keys(H).includes(_) && _ in H && Y !== F ? i({ code: "KEY_EXISTS", message: s("ERROR_KEY_EXISTS", r) }, _) : a(d.path, n, O).then(((J) => {
|
|
395
|
+
J && i({ code: "UPDATE_ERROR", message: J }, r.value);
|
|
396
|
+
}));
|
|
397
|
+
};
|
|
398
|
+
return { dragSourceProps: f, getDropTargetProps: m, BottomDropTarget: v, DropTargetPadding: ({ position: O, nodeData: w }) => c === O ? o.jsx("div", { className: "jer-drag-n-drop-padding", style: p("dropZone", w) }) : null, handleDrop: D };
|
|
399
|
+
}, Qn = (e, t, n, r) => {
|
|
400
|
+
var a, i, s;
|
|
401
|
+
if (!t.current) return 0;
|
|
402
|
+
const p = parseInt((a = getComputedStyle(n.current).getPropertyValue("line-height")) !== null && a !== void 0 ? a : "16px"), d = ((s = (i = t.current) === null || i === void 0 ? void 0 : i.offsetWidth) !== null && s !== void 0 ? s : 0) / (0.5 * p), l = r(e).replace(/\\n/g, `
|
|
403
|
+
`).split(`
|
|
404
|
+
`).map(((c) => Math.ceil(c.length / d))).reduce(((c, u) => c + u), 0) * p;
|
|
405
|
+
return Math.min(l + 30, window.innerHeight - 50);
|
|
406
|
+
}, mt = ({ isEditingKey: e, canEditKey: t, pathString: n, path: r, name: a, arrayIndexFromOne: i, handleKeyboard: s, handleEditKey: p, handleCancel: d, handleClick: l, keyValueArray: c, styles: u, getNextOrPrevious: h, emptyStringKey: f }) => {
|
|
407
|
+
const { setCurrentlyEditingElement: m } = He(), v = typeof a == "number" ? String(a + (i ? 1 : 0)) : a;
|
|
408
|
+
return e ? o.jsx("input", { className: "jer-input-text jer-key-edit", type: "text", name: n, defaultValue: v, autoFocus: !0, onFocus: (D) => D.target.select(), onKeyDown: (D) => s(D, { stringConfirm: () => p(D.target.value), cancel: d, tabForward: () => {
|
|
409
|
+
if (p(D.target.value), c) {
|
|
410
|
+
const O = c?.[0][0];
|
|
411
|
+
m(O ? [...r, O] : h("next"));
|
|
412
|
+
} else m(r);
|
|
413
|
+
}, tabBack: () => {
|
|
414
|
+
p(D.target.value), m(h("prev"));
|
|
415
|
+
} }), style: { width: v.length / 1.5 + 0.5 + "em" } }) : o.jsxs("span", { className: "jer-key-text", style: Object.assign(Object.assign({}, u), { minWidth: `${Math.min(v.length + 1, 5)}ch`, flexShrink: v.length > 10 ? 1 : 0 }), onDoubleClick: () => t && m(r, "key"), onClick: l, children: [f ? o.jsx("span", { className: "jer-empty-string", children: f }) : v, v !== "" || f ? o.jsx("span", { className: "jer-key-colon", children: ":" }) : null] });
|
|
416
|
+
}, dn = (e) => {
|
|
417
|
+
const { data: t, parentData: n, onEdit: r, onDelete: a, onChange: i, onMove: s, enableClipboard: p, canDragOnto: d, restrictTypeSelection: l, searchFilter: c, searchText: u, showLabel: h, stringTruncate: f, showStringQuotes: m, arrayIndexFromOne: v, indent: D, translate: O, customNodeDefinitions: w, customNodeData: N, handleKeyboard: _, keyboardControls: Y, sort: F, editConfirmRef: H, jsonStringify: J, showIconTooltips: W } = e, { getStyles: C } = Ce(), { setCurrentlyEditingElement: k, setCollapseState: L, previouslyEditedElement: $, setPreviouslyEditedElement: ae, tabDirection: X, setTabDirection: ne, previousValue: Z, setPreviousValue: M } = He(), [z, ge] = G(typeof t == "function" ? St : t), { pathString: B, nodeData: I, path: R, name: q, canEdit: me, canDelete: Ke, canDrag: Ne, error: je, onError: ue, handleEditKey: ve, emptyStringKey: $e, derivedValues: ke } = cn({ props: e }), { dragSourceProps: nt, getDropTargetProps: rt, BottomDropTarget: re, DropTargetPadding: de } = un({ canDrag: Ne, canDragOnto: d, path: R, nodeData: I, onMove: s, onError: ue, translate: O }), [be, Ee] = G(Nt(t, N)), S = Ie(((g) => {
|
|
418
|
+
if (!i) return void ge(g);
|
|
419
|
+
const b = i({ currentData: I.fullData, newValue: g, currentValue: z, name: q, path: R });
|
|
420
|
+
ge(b);
|
|
421
|
+
}), [i]);
|
|
422
|
+
Oe((() => {
|
|
423
|
+
ge(typeof t == "function" ? St : t), Ee(Nt(t, N));
|
|
424
|
+
}), [t, je]);
|
|
425
|
+
const { CustomNode: V, customNodeProps: Q, hideKey: Te, showEditTools: xe = !0, showOnEdit: Ae, showOnView: Pe, passOriginalNode: Re } = N, Ve = [...Zn, ...w.filter((({ showInTypesSelector: g = !1, name: b }) => g && !!b)).map((({ name: g }) => g))], Se = le((() => {
|
|
426
|
+
if (typeof l == "boolean") return l ? [] : Ve;
|
|
427
|
+
if (Array.isArray(l)) return l;
|
|
428
|
+
const g = l(I);
|
|
429
|
+
return typeof g == "boolean" ? g ? [] : Ve : g;
|
|
430
|
+
}), [I, l]), [se, _e] = G(((g, b) => {
|
|
431
|
+
var P;
|
|
432
|
+
if (typeof g != "string") return null;
|
|
433
|
+
const oe = b.filter(((U) => U instanceof Object && U.enum && U.values.includes(g) && U.matchPriority));
|
|
434
|
+
return oe.sort(((U, te) => {
|
|
435
|
+
var Me, ze;
|
|
436
|
+
return ((Me = te.matchPriority) !== null && Me !== void 0 ? Me : 0) - ((ze = U.matchPriority) !== null && ze !== void 0 ? ze : 0);
|
|
437
|
+
})), (P = oe[0]) !== null && P !== void 0 ? P : null;
|
|
438
|
+
})(z, Se)), { isEditing: ie } = ke, Ge = tn("value", I, c, u);
|
|
439
|
+
if (ie && (!Ge || !me)) {
|
|
440
|
+
const g = We(I.fullData, R, X, F);
|
|
441
|
+
k(g || $);
|
|
442
|
+
}
|
|
443
|
+
if (!Ge) return null;
|
|
444
|
+
const we = (g) => {
|
|
445
|
+
let b;
|
|
446
|
+
if (k(null), M(null), g === void 0 || ((P) => P && typeof P == "object" && "type" in P && "target" in P && "preventDefault" in P && typeof P.preventDefault == "function")(g)) switch (be) {
|
|
447
|
+
case "object":
|
|
448
|
+
b = { [O("DEFAULT_NEW_KEY", I)]: z };
|
|
449
|
+
break;
|
|
450
|
+
case "array":
|
|
451
|
+
b = z ?? [];
|
|
452
|
+
break;
|
|
453
|
+
case "number": {
|
|
454
|
+
const P = Number(z);
|
|
455
|
+
b = isNaN(P) ? 0 : P;
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
default:
|
|
459
|
+
b = z;
|
|
460
|
+
}
|
|
461
|
+
else b = g;
|
|
462
|
+
r(b, R).then(((P) => {
|
|
463
|
+
P && ue({ code: "UPDATE_ERROR", message: P }, b);
|
|
464
|
+
}));
|
|
465
|
+
}, fe = () => {
|
|
466
|
+
k(null), Z === null ? (ge(t), M(null)) : r(Z, R);
|
|
467
|
+
}, { isEditingKey: Je, canEditKey: Xe } = ke, pe = !ie && je, ee = ie && Se.length > 1, Le = (be !== "invalid" || V) && !je && xe, E = h && !Te, j = V && (ie && Ae || !ie && Pe), x = { value: z, parentData: n, setValue: S, isEditing: ie, canEdit: me, setIsEditing: me ? () => k(R) : () => {
|
|
468
|
+
}, handleEdit: we, handleCancel: fe, path: R, stringTruncate: f, showStringQuotes: m, nodeData: I, enumType: se, translate: O, handleKeyboard: _, keyboardCommon: { cancel: fe, tabForward: () => {
|
|
469
|
+
ne("next"), ae(B);
|
|
470
|
+
const g = We(I.fullData, R, "next", F);
|
|
471
|
+
g && (we(), k(g));
|
|
472
|
+
}, tabBack: () => {
|
|
473
|
+
ne("prev"), ae(B);
|
|
474
|
+
const g = We(I.fullData, R, "prev", F);
|
|
475
|
+
g && (we(), k(g));
|
|
476
|
+
} } }, A = { canEditKey: Xe, isEditingKey: Je, pathString: B, path: R, name: q, arrayIndexFromOne: v, handleKeyboard: _, handleEditKey: ve, handleCancel: fe, styles: C("property", I), getNextOrPrevious: (g) => We(I.fullData, R, g, F), emptyStringKey: $e }, T = j ? o.jsx(V, Object.assign({}, e, { value: z, customNodeProps: Q, setValue: S, handleEdit: we, handleCancel: fe, handleKeyPress: (g) => _(g, { stringConfirm: we, cancel: fe }), isEditing: ie, setIsEditing: () => k(R), getStyles: C, originalNode: Re ? $t(t, x) : void 0, originalNodeKey: Re ? o.jsx(mt, Object.assign({}, A)) : void 0, canEdit: me, keyboardCommon: x.keyboardCommon, onError: ue })) : $t(t, x);
|
|
477
|
+
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(de, { position: "above", nodeData: I }), o.jsxs("div", { className: "jer-value-main-row", style: { flexWrap: q.length > 10 ? "wrap" : "nowrap" }, children: [E && 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: I, editConfirmRef: H }) : Le && o.jsx(ln, { startEdit: me ? () => {
|
|
478
|
+
M(Z), k(R, fe);
|
|
479
|
+
} : void 0, handleDelete: Ke ? () => {
|
|
480
|
+
a(z, R).then(((g) => {
|
|
481
|
+
g && ue({ code: "DELETE_ERROR", message: g }, z);
|
|
482
|
+
}));
|
|
483
|
+
} : void 0, enableClipboard: p, translate: O, customButtons: e.customButtons, nodeData: I, handleKeyboard: _, keyboardControls: Y, editConfirmRef: H, jsonStringify: J, showIconTooltips: W }), ee && o.jsxs("div", { className: "jer-select jer-select-types", children: [o.jsx("select", { name: `${q}-type-select`, className: "jer-select-inner", onChange: (g) => ((b) => {
|
|
484
|
+
const P = w.find(((te) => te.name === b));
|
|
485
|
+
if (P) return r(P.defaultValue, R), Ee(b), _e(null), k(null), void L({ path: R, collapsed: !1, includeChildren: !1 });
|
|
486
|
+
const oe = Se.find(((te) => te instanceof Object && te.enum === b));
|
|
487
|
+
if (oe) return typeof z == "string" && oe.values.includes(z) || r(oe.values[0], R).then(((te) => {
|
|
488
|
+
te && (ue({ code: "UPDATE_ERROR", message: te }, U), k(null));
|
|
489
|
+
})), void _e(oe);
|
|
490
|
+
const U = qn(z, b, O("DEFAULT_NEW_KEY", I), N?.CustomNode ? O("DEFAULT_STRING", I) : void 0);
|
|
491
|
+
["string", "number", "boolean"].includes(b) || k(null), r(U, R).then(((te) => {
|
|
492
|
+
te ? (ue({ code: "UPDATE_ERROR", message: te }, U), k(null)) : _e(null);
|
|
493
|
+
}));
|
|
494
|
+
})(g.target.value), value: se ? se.enum : be, children: Se.map(((g) => g instanceof Object && "enum" in g ? o.jsx("option", { value: g.enum, children: g.enum }, g.enum) : o.jsx("option", { value: g, children: g }, g))) }), o.jsx("span", { className: "focus" })] }), pe && o.jsx("span", { className: "jer-error-slug", style: C("error", I), children: je })] })] }), o.jsx(de, { position: "below", nodeData: I })] }));
|
|
495
|
+
}, Nt = (e, t) => t?.CustomNode && t?.name && t.showInTypesSelector ? t.name : typeof e == "string" ? "string" : typeof e == "number" ? "number" : typeof e == "boolean" ? "boolean" : e === null ? "null" : "invalid", $t = (e, t) => {
|
|
496
|
+
const n = Nt(e), { value: r } = t;
|
|
497
|
+
switch (n) {
|
|
498
|
+
case "string":
|
|
499
|
+
return o.jsx(_n, Object.assign({}, t, { value: r }));
|
|
500
|
+
case "number":
|
|
501
|
+
return o.jsx(Ln, Object.assign({}, t, { value: r }));
|
|
502
|
+
case "boolean":
|
|
503
|
+
return o.jsx(Mn, Object.assign({}, t, { value: r }));
|
|
504
|
+
case "null":
|
|
505
|
+
return o.jsx(Fn, Object.assign({}, t));
|
|
506
|
+
default:
|
|
507
|
+
return o.jsx(Bn, Object.assign({}, t));
|
|
508
|
+
}
|
|
509
|
+
}, qn = (e, t, n, r) => {
|
|
510
|
+
switch (t) {
|
|
511
|
+
case "string":
|
|
512
|
+
return r ?? String(e);
|
|
513
|
+
case "number": {
|
|
514
|
+
const a = Number(e);
|
|
515
|
+
return isNaN(a) ? 0 : a;
|
|
516
|
+
}
|
|
517
|
+
case "boolean":
|
|
518
|
+
return !!e;
|
|
519
|
+
case "null":
|
|
520
|
+
return null;
|
|
521
|
+
case "object":
|
|
522
|
+
return { [n]: e };
|
|
523
|
+
case "array":
|
|
524
|
+
return [e];
|
|
525
|
+
default:
|
|
526
|
+
return String(e);
|
|
527
|
+
}
|
|
528
|
+
}, pn = (e = [], t) => {
|
|
529
|
+
const n = e.filter((({ condition: m }) => m(t)));
|
|
530
|
+
if (n.length === 0) return {};
|
|
531
|
+
const r = n[0], { element: a, wrapperElement: i, customNodeProps: s, wrapperProps: p, hideKey: d = !1, showEditTools: l = !0, showOnEdit: c = !1, showOnView: u = !0, showCollectionWrapper: h = !0 } = r, f = qt(r, ["element", "wrapperElement", "customNodeProps", "wrapperProps", "hideKey", "showEditTools", "showOnEdit", "showOnView", "showCollectionWrapper"]);
|
|
532
|
+
return Object.assign({ CustomNode: a, CustomWrapper: i, customNodeProps: s, wrapperProps: p, hideKey: d, showEditTools: l, showOnEdit: c, showOnView: u, showCollectionWrapper: h }, f);
|
|
533
|
+
}, hn = (e) => {
|
|
534
|
+
const { getStyles: t } = Ce(), { collapseState: n, setCollapseState: r, getMatchingCollapseState: a, currentlyEditingElement: i, setCurrentlyEditingElement: s, areChildrenBeingEdited: p, previousValue: d, setPreviousValue: l } = He(), { mainContainerRef: c, data: u, nodeData: h, parentData: f, showCollectionCount: m, onEdit: v, onAdd: D, onDelete: O, canDragOnto: w, collapseFilter: N, collapseAnimationTime: _, onMove: Y, enableClipboard: F, onEditEvent: H, showIconTooltips: J, searchFilter: W, searchText: C, indent: k, sort: L, showArrayIndices: $, arrayIndexFromOne: ae, defaultValue: X, newKeyOptions: ne, translate: Z, customNodeDefinitions: M, customNodeData: z, jsonParse: ge, jsonStringify: B, TextEditor: I, keyboardControls: R, handleKeyboard: q, insertAtTop: me, onCollapse: Ke, editConfirmRef: Ne, collapseClickZones: je } = e, [ue, ve] = G(B(u)), $e = N(h), { contentRef: ke, isAnimating: nt, maxHeight: rt, collapsed: re, animateCollapse: de, cssTransitionValue: be } = ((y, K, ye, he, De) => {
|
|
535
|
+
const [vn, pt] = G(ye ? 0 : void 0), [ht, bn] = G(ye), bt = ce(!1), Et = ce(null), zt = ce(0), Ft = ce(0), En = K / 1e3 + "s", xn = Ie(((xt) => {
|
|
536
|
+
var wt, Dt;
|
|
537
|
+
if (ht !== xt) {
|
|
538
|
+
switch (window.clearTimeout(Ft.current), bt.current = !0, xt) {
|
|
539
|
+
case !0: {
|
|
540
|
+
const Bt = (Dt = (wt = Et.current) === null || wt === void 0 ? void 0 : wt.offsetHeight) !== null && Dt !== void 0 ? Dt : 0;
|
|
541
|
+
zt.current = Bt, pt(Bt), setTimeout((() => {
|
|
542
|
+
pt(0);
|
|
543
|
+
}), 5);
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
case !1:
|
|
547
|
+
pt(zt.current || Qn(y, Et, he, De));
|
|
548
|
+
}
|
|
549
|
+
bn(!ht), Ft.current = window.setTimeout((() => {
|
|
550
|
+
bt.current = !1, xt || pt(void 0);
|
|
551
|
+
}), K);
|
|
552
|
+
}
|
|
553
|
+
}), [K, ht, y, he, De]);
|
|
554
|
+
return { contentRef: Et, isAnimating: bt.current, animateCollapse: xn, maxHeight: vn, collapsed: ht, cssTransitionValue: En };
|
|
555
|
+
})(u, _, $e, c, B), { pathString: Ee, nodeData: S, path: V, name: Q, size: Te, canEdit: xe, canDelete: Ae, canAdd: Pe, canDrag: Re, error: Ve, setError: Se, onError: se, handleEditKey: _e, emptyStringKey: ie, derivedValues: Ge } = cn({ props: e, collapsed: re }), { dragSourceProps: we, getDropTargetProps: fe, BottomDropTarget: Je, DropTargetPadding: Xe } = un({ canDrag: Re, canDragOnto: w, path: V, nodeData: S, onMove: Y, onError: se, translate: Z }), pe = ce(!$e), { isEditing: ee, isEditingKey: Le, isArray: E, canEditKey: j } = Ge;
|
|
556
|
+
Oe((() => {
|
|
557
|
+
ve(B(u));
|
|
558
|
+
}), [u, B]), Oe((() => {
|
|
559
|
+
const y = N(S) && !ee;
|
|
560
|
+
pe.current = !y, de(y);
|
|
561
|
+
}), [N]), Oe((() => {
|
|
562
|
+
if (n !== null) {
|
|
563
|
+
const y = a(V);
|
|
564
|
+
y && (pe.current = !0, de(y.collapsed));
|
|
565
|
+
}
|
|
566
|
+
}), [n]);
|
|
567
|
+
const x = ce(null), A = Ie(((y, K) => {
|
|
568
|
+
if (typeof X != "function") return X;
|
|
569
|
+
const ye = X(y, K);
|
|
570
|
+
return ye !== void 0 ? ye : null;
|
|
571
|
+
}), [X]), T = Ie(((y) => ne ? typeof ne != "function" ? ne : ne(y) : null), [ne]), { CustomNode: g, customNodeProps: b, CustomWrapper: P, wrapperProps: oe = {}, hideKey: U, showEditTools: te = !0, showOnEdit: Me, showOnView: ze, showCollectionWrapper: ft = !0 } = z, ct = p(Ee);
|
|
572
|
+
if (ct && re && de(!1), !(tn("collection", S, W, C) || S.level === 0) && !ct) return null;
|
|
573
|
+
const Ze = Array.isArray(u) ? "array" : "object", yt = Ze === "array" ? { open: "[", close: "]" } : { open: "{", close: "}" }, It = (y) => {
|
|
574
|
+
if (y.key !== "Tab" || y.getModifierState("Shift")) q(y, { objectConfirm: dt, cancel: ot });
|
|
575
|
+
else {
|
|
576
|
+
y.preventDefault();
|
|
577
|
+
const K = rn(x, " ");
|
|
578
|
+
ve(K);
|
|
579
|
+
}
|
|
580
|
+
}, ut = (y) => {
|
|
581
|
+
y.stopPropagation();
|
|
582
|
+
const K = Tt(y);
|
|
583
|
+
if (K && R.collapseModifier.includes(K)) return pe.current = !0, void r({ collapsed: !re, path: V, includeChildren: !0 });
|
|
584
|
+
i && i.includes(Ee) || (pe.current = !0, r(null), Ke && Ke({ path: V, collapsed: !re, includeChildren: !1 }), de(!re));
|
|
585
|
+
}, dt = () => {
|
|
586
|
+
try {
|
|
587
|
+
const y = ge(ue);
|
|
588
|
+
if (s(null), l(null), Se(null), B(y) === B(u)) return;
|
|
589
|
+
v(y, V).then(((K) => {
|
|
590
|
+
K && se({ code: "UPDATE_ERROR", message: K }, y);
|
|
591
|
+
}));
|
|
592
|
+
} catch {
|
|
593
|
+
se({ code: "INVALID_JSON", message: Z("ERROR_INVALID_JSON", S) }, ue);
|
|
594
|
+
}
|
|
595
|
+
}, gn = V.length > 0 ? () => {
|
|
596
|
+
O(u, V).then(((y) => {
|
|
597
|
+
y && se({ code: "DELETE_ERROR", message: y }, u);
|
|
598
|
+
}));
|
|
599
|
+
} : void 0, ot = () => {
|
|
600
|
+
s(null), d === null ? (Se(null), ve(B(u)), l(null)) : v(d, V);
|
|
601
|
+
}, Kt = m === "when-closed" ? re : m, mn = !ee && te, fn = ($ || !E) && !U && Q !== void 0, yn = g && (ee && Me || !ee && ze), jt = Object.entries(u).map((([y, K]) => [Ze === "array" ? Number(y) : y, K]));
|
|
602
|
+
Ze === "object" && L(jt, ((y) => y));
|
|
603
|
+
const Rt = pe.current ? ee ? o.jsxs("div", { className: "jer-collection-text-edit", children: [I ? o.jsx(I, { value: ue, onChange: ve, onKeyDown: (y) => q(y, { objectConfirm: dt, cancel: ot }) }) : o.jsx(en, { textAreaRef: x, className: "jer-collection-text-area", name: Ee, value: ue, setValue: ve, handleKeyPress: It, styles: t("input", S) }), o.jsx("div", { className: "jer-collection-input-button-row", children: o.jsx(Pt, { onOk: dt, onCancel: ot, nodeData: S, editConfirmRef: Ne }) })] }) : jt.map((([y, K], ye) => {
|
|
604
|
+
const he = { key: y, value: K, path: [...V, y], level: V.length + 1, index: ye, size: et(K) ? Object.keys(K).length : null, parentData: u, fullData: S.fullData }, De = pn(M, he);
|
|
605
|
+
return o.jsx("div", { className: "jer-collection-element", style: t("collectionElement", he), children: et(K) && !De?.renderCollectionAsValue ? o.jsx(hn, Object.assign({}, e, { data: K, parentData: u, nodeData: he, showCollectionCount: m, canDragOnto: xe, customNodeData: De }), y) : o.jsx(dn, Object.assign({}, e, { data: K, parentData: u, nodeData: he, canDragOnto: xe, showLabel: Ze === "object" || $, customNodeData: De }), y) }, y);
|
|
606
|
+
})) : null, vt = !!ft && re && !ct;
|
|
607
|
+
vt || (pe.current = !0);
|
|
608
|
+
const Vt = Object.assign(Object.assign({}, e), { data: u, value: u, parentData: f, nodeData: S, setValue: (y) => Qe(void 0, void 0, void 0, (function* () {
|
|
609
|
+
return yield v(y, V);
|
|
610
|
+
})), handleEdit: dt, handleCancel: ot, handleKeyPress: It, isEditing: ee, setIsEditing: () => s(V), getStyles: t, canDragOnto: xe, canEdit: xe, keyboardCommon: {}, onError: se }), jn = yn ? o.jsx(g, Object.assign({ customNodeProps: b }, Vt, { children: Rt })) : Rt, _t = mn && o.jsx(ln, { startEdit: xe ? () => {
|
|
611
|
+
pe.current = !0, l(null), s(V);
|
|
612
|
+
} : void 0, handleAdd: Pe ? (y) => {
|
|
613
|
+
de(!1);
|
|
614
|
+
const K = A(S, y);
|
|
615
|
+
if (Ze === "array") {
|
|
616
|
+
const ye = me.array ? 0 : u.length, he = me.array ? { insert: !0 } : {};
|
|
617
|
+
D(K, [...V, ye], he).then(((De) => {
|
|
618
|
+
De && se({ code: "ADD_ERROR", message: De }, K);
|
|
619
|
+
}));
|
|
620
|
+
} else if (y in u) se({ code: "KEY_EXISTS", message: Z("ERROR_KEY_EXISTS", S) }, y);
|
|
621
|
+
else {
|
|
622
|
+
const ye = me.object ? { insertBefore: 0 } : {};
|
|
623
|
+
D(K, [...V, y], ye).then(((he) => {
|
|
624
|
+
he && se({ code: "ADD_ERROR", message: he }, K);
|
|
625
|
+
}));
|
|
626
|
+
}
|
|
627
|
+
} : void 0, handleDelete: Ae ? gn : void 0, enableClipboard: F, type: Ze, nodeData: S, translate: Z, customButtons: e.customButtons, keyboardControls: R, handleKeyboard: q, getNewKeyOptions: T, editConfirmRef: Ne, jsonStringify: B, onEditEvent: H, showIconTooltips: J }), Lt = { canEditKey: j, isEditingKey: Le, pathString: Ee, path: V, name: Q, arrayIndexFromOne: ae, handleKeyboard: q, handleEditKey: _e, handleCancel: ot, keyValueArray: jt, styles: t("property", S), getNextOrPrevious: (y) => We(S.fullData, V, y, L), handleClick: je.includes("property") ? ut : (y) => y.stopPropagation(), emptyStringKey: ie }, Mt = o.jsxs("div", Object.assign({ className: "jer-component jer-collection-component", style: Object.assign(Object.assign({ marginLeft: (V.length === 0 ? 0 : k / 2) + "em" }, t("collection", S)), { position: "relative" }), draggable: Re }, 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") ? ut : void 0 }), !ee && Je, o.jsx(Xe, { position: "above", nodeData: S }), ft ? o.jsxs("div", { className: "jer-collection-header-row", style: { position: "relative" }, onClick: je.includes("header") ? ut : 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: be }, onClick: ut, children: o.jsx(Ye, { 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 && Kt && o.jsx("div", { className: "jer-collection-item-count" + (Kt ? " jer-visible" : " jer-hidden"), style: Object.assign(Object.assign({}, t("itemCount", S)), { transition: be }), children: Te === 1 ? Z("ITEM_SINGLE", Object.assign(Object.assign({}, S), { size: 1 }), 1) : Z("ITEMS_MULTIPLE", S, Te) }), o.jsx("div", { className: "jer-brackets" + (vt ? " jer-visible" : " jer-hidden"), style: Object.assign(Object.assign({}, t("bracket", S)), { transition: be }), 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: vt || nt ? "clip" : "visible", maxHeight: ct ? void 0 : rt }, t("collectionInner", S)), { transition: be }), ref: ke, children: [jn, o.jsx("div", { className: ee ? "jer-collection-error-row" : "jer-collection-error-row-edit", children: Ve && o.jsx("span", { className: "jer-error-slug", style: t("error", S), children: Ve }) }), !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(Xe, { position: "below", nodeData: S })] }));
|
|
628
|
+
return P ? o.jsx(P, Object.assign({ customNodeProps: oe }, Vt, { children: Mt })) : Mt;
|
|
629
|
+
}, 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) => {
|
|
630
|
+
if (s[d]) {
|
|
631
|
+
const u = s[d](p);
|
|
632
|
+
if (u !== null) return u;
|
|
633
|
+
}
|
|
634
|
+
const c = d in i ? i[d] : er[d];
|
|
635
|
+
return l === void 0 ? c : c?.replace("{{count}}", String(l));
|
|
636
|
+
})(e, t, r, n, a);
|
|
637
|
+
var Gt = [], at = [];
|
|
638
|
+
(function(e, t) {
|
|
639
|
+
if (e && typeof document < "u") {
|
|
640
|
+
var n, r = t.prepend === !0 ? "prepend" : "append", a = t.singleTag === !0, i = typeof t.container == "string" ? document.querySelector(t.container) : document.getElementsByTagName("head")[0];
|
|
641
|
+
if (a) {
|
|
642
|
+
var s = Gt.indexOf(i);
|
|
643
|
+
s === -1 && (s = Gt.push(i) - 1, at[s] = {}), n = at[s] && at[s][r] ? at[s][r] : at[s][r] = p();
|
|
644
|
+
} else n = p();
|
|
645
|
+
e.charCodeAt(0) === 65279 && (e = e.substring(1)), n.styleSheet ? n.styleSheet.cssText += e : n.appendChild(document.createTextNode(e));
|
|
646
|
+
}
|
|
647
|
+
function p() {
|
|
648
|
+
var d = document.createElement("style");
|
|
649
|
+
if (d.setAttribute("type", "text/css"), t.attributes) for (var l = Object.keys(t.attributes), c = 0; c < l.length; c++) d.setAttribute(l[c], t.attributes[l[c]]);
|
|
650
|
+
var u = r === "prepend" ? "afterbegin" : "beforeend";
|
|
651
|
+
return i.insertAdjacentElement(u, d), d;
|
|
652
|
+
}
|
|
653
|
+
})(':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}', {});
|
|
654
|
+
const nr = ({ data: e, setData: t, rootName: n = "root", onUpdate: r = () => {
|
|
655
|
+
}, onEdit: a = r, onDelete: i = r, onAdd: s = r, onChange: p, onError: d, onEditEvent: l, showErrorMessages: c = !0, enableClipboard: u = !0, indent: h = 2, collapse: f = !1, collapseAnimationTime: m = 300, showCollectionCount: v = !0, restrictEdit: D = !1, restrictDelete: O = !1, restrictAdd: w = !1, restrictTypeSelection: N = !1, restrictDrag: _ = !0, viewOnly: Y, searchFilter: F, searchText: H, searchDebounceTime: J = 350, keySort: W = !1, showArrayIndices: C = !0, arrayIndexFromOne: k = !1, showStringQuotes: L = !0, showIconTooltips: $ = !1, defaultValue: ae = null, newKeyOptions: X, minWidth: ne = 250, maxWidth: Z = "min(600px, 90vw)", rootFontSize: M, stringTruncate: z = 250, translations: ge = {}, className: B, id: I, customText: R = {}, customNodeDefinitions: q = [], customButtons: me = [], jsonParse: Ke = JSON.parse, jsonStringify: Ne = (re, de) => JSON.stringify(re, de, 2), TextEditor: je, errorMessageTimeout: ue = 2500, keyboardControls: ve = {}, externalTriggers: $e, insertAtTop: ke = !1, onCollapse: nt, collapseClickZones: rt = ["header", "left"] }) => {
|
|
656
|
+
const { getStyles: re } = Ce(), { setCurrentlyEditingElement: de } = He(), be = le((() => it(f)), [f]), Ee = le((() => tr(ge, R)), [ge, R]), [S, V] = G(H), [Q, Te] = (({ setData: E, data: j }) => {
|
|
657
|
+
const [x, A] = G(E ? void 0 : j), T = Ie(((g) => {
|
|
658
|
+
E ? E(g) : A(g);
|
|
659
|
+
}), [E]);
|
|
660
|
+
return Oe((() => {
|
|
661
|
+
E || A(j);
|
|
662
|
+
}), [j]), [E ? j : x, T];
|
|
663
|
+
})({ setData: t, data: e }), xe = ce(null);
|
|
664
|
+
Oe((() => {
|
|
665
|
+
de(null);
|
|
666
|
+
const E = setTimeout((() => V(H)), J);
|
|
667
|
+
return () => clearTimeout(E);
|
|
668
|
+
}), [H, J]);
|
|
669
|
+
const Ae = { key: n, path: [], level: 0, index: 0, value: Q, size: typeof Q == "object" && Q !== null ? Object.keys(Q).length : 1, parentData: null, fullData: Q }, Pe = (E, j) => Qe(void 0, void 0, void 0, (function* () {
|
|
670
|
+
const x = yield E(j);
|
|
671
|
+
if (x === !0 || x === void 0) return void Te(j.newData);
|
|
672
|
+
const A = or(x) ? x : ["error", x], [T, g] = A;
|
|
673
|
+
if (T === "error") return Te(j.currentData), g === !1 ? Ee("ERROR_UPDATE", Ae) : String(g);
|
|
674
|
+
Te(g);
|
|
675
|
+
})), Re = le((() => it(D, Y)), [D, Y]), Ve = le((() => it(O, Y)), [O, Y]), Se = le((() => it(w, Y)), [w, Y]), se = le((() => it(_, Y)), [_, Y]), _e = le((() => rr(F)), [F]), ie = le((() => ((E) => {
|
|
676
|
+
const j = Object.assign({}, Ht);
|
|
677
|
+
for (const x of Object.keys(Ht)) {
|
|
678
|
+
const A = x;
|
|
679
|
+
if (E[A]) {
|
|
680
|
+
const T = E[A], g = ["clipboardModifier", "collapseModifier"].includes(x) ? Array.isArray(T) ? T : [T] : typeof T == "string" ? { key: T } : T;
|
|
681
|
+
j[A] = g, ["stringConfirm", "numberConfirm", "booleanConfirm"].forEach(((b) => {
|
|
682
|
+
!E[b] && E.confirm && (j[b] = j.confirm);
|
|
683
|
+
}));
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
return j;
|
|
687
|
+
})(ve)), [ve]), Ge = Ie(((E, j) => ((x, A, T) => {
|
|
688
|
+
const g = Object.entries(A);
|
|
689
|
+
for (const [b, P] of g) if (Sn(T, x[b], b)) {
|
|
690
|
+
T.preventDefault(), P();
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
693
|
+
})(ie, j, E)), [ie]), we = le((() => {
|
|
694
|
+
const E = Jt(q, "stringifyReplacer");
|
|
695
|
+
return (j) => Ne(j, E);
|
|
696
|
+
}), [q, Ne]), fe = le((() => {
|
|
697
|
+
const E = Jt(q, "parseReviver");
|
|
698
|
+
return (j) => {
|
|
699
|
+
const x = Ke(j, E);
|
|
700
|
+
return kt(x);
|
|
701
|
+
};
|
|
702
|
+
}), [q, Ke]), Je = ce(null);
|
|
703
|
+
((E, j) => {
|
|
704
|
+
const { setCurrentlyEditingElement: x, currentlyEditingElement: A, setCollapseState: T } = He();
|
|
705
|
+
Oe((() => {
|
|
706
|
+
if (!E) return;
|
|
707
|
+
const { collapse: g, edit: b } = E;
|
|
708
|
+
g && T(g);
|
|
709
|
+
const P = !b?.path || Ue(b.path) === A;
|
|
710
|
+
switch (b?.action) {
|
|
711
|
+
case "accept":
|
|
712
|
+
P && (j.current && j.current.click(), x(null));
|
|
713
|
+
break;
|
|
714
|
+
case "cancel":
|
|
715
|
+
P && x(null);
|
|
716
|
+
break;
|
|
717
|
+
default:
|
|
718
|
+
b?.path && x(b.path);
|
|
719
|
+
}
|
|
720
|
+
}), [E]);
|
|
721
|
+
})($e, Je);
|
|
722
|
+
const Xe = Ie(((E, j) => {
|
|
723
|
+
W !== !1 && (typeof W != "function" ? E.sort(((x, A) => {
|
|
724
|
+
const T = j(x)[0], g = j(A)[0];
|
|
725
|
+
return T < g ? -1 : T > g ? 1 : 0;
|
|
726
|
+
})) : E.sort(((x, A) => W(j(x), j(A)))));
|
|
727
|
+
}), [W]), pe = pn(q, Ae), ee = { mainContainerRef: xe, name: n, nodeData: Ae, onEdit: (E, j) => Qe(void 0, void 0, void 0, (function* () {
|
|
728
|
+
const { currentData: x, newData: A, currentValue: T, newValue: g } = st(Q, j, E, "update");
|
|
729
|
+
if (T !== g) return yield Pe(a, { currentData: x, newData: A, currentValue: T, newValue: g, name: j.slice(-1)[0], path: j });
|
|
730
|
+
})), onDelete: (E, j) => Qe(void 0, void 0, void 0, (function* () {
|
|
731
|
+
const { currentData: x, newData: A, currentValue: T, newValue: g } = st(Q, j, E, "delete");
|
|
732
|
+
return yield Pe(i, { currentData: x, newData: A, currentValue: T, newValue: g, name: j.slice(-1)[0], path: j });
|
|
733
|
+
})), onAdd: (E, j, x) => Qe(void 0, void 0, void 0, (function* () {
|
|
734
|
+
const { currentData: A, newData: T, currentValue: g, newValue: b } = st(Q, j, E, "add", x);
|
|
735
|
+
return yield Pe(s, { currentData: A, newData: T, currentValue: g, newValue: b, name: j.slice(-1)[0], path: j });
|
|
736
|
+
})), onChange: p, onError: d, onEditEvent: l, showErrorMessages: c, onMove: (E, j, x) => Qe(void 0, void 0, void 0, (function* () {
|
|
737
|
+
if (E === null) return;
|
|
738
|
+
const { currentData: A, newData: T, currentValue: g } = st(Q, E, "", "delete"), b = E.slice(-1)[0], P = j.slice(0, -1), oe = j.slice(-1)[0];
|
|
739
|
+
let U = typeof oe == "number" ? x === "above" ? oe : oe + 1 : typeof b == "number" ? `arr_${b}` : b;
|
|
740
|
+
E.slice(0, -1).join(".") === j.slice(0, -1).join(".") && typeof b == "number" && typeof U == "number" && b < U && (U -= 1);
|
|
741
|
+
const te = typeof U == "number" ? { insert: !0 } : x === "above" ? { insertBefore: oe } : { insertAfter: oe }, { newData: Me, newValue: ze } = st(T, [...P, U], g, "add", te);
|
|
742
|
+
return yield Pe(a, { currentData: A, newData: Me, currentValue: g, newValue: ze, name: j.slice(-1)[0], path: j });
|
|
743
|
+
})), showCollectionCount: v, collapseFilter: be, collapseAnimationTime: m, restrictEditFilter: Re, restrictDeleteFilter: Ve, restrictAddFilter: Se, restrictTypeSelection: N, restrictDragFilter: se, canDragOnto: !1, searchFilter: _e, searchText: S, enableClipboard: u, keySort: W, sort: Xe, showArrayIndices: C, arrayIndexFromOne: k, showStringQuotes: L, showIconTooltips: $, indent: h, defaultValue: ae, newKeyOptions: X, stringTruncate: z, translate: Ee, customNodeDefinitions: q, customNodeData: pe, customButtons: me, parentData: null, jsonParse: fe, jsonStringify: we, TextEditor: je, errorMessageTimeout: ue, handleKeyboard: Ge, keyboardControls: ie, insertAtTop: { object: ke === !0 || ke === "object", array: ke === !0 || ke === "array" }, onCollapse: nt, editConfirmRef: Je, collapseClickZones: rt }, Le = Object.assign(Object.assign({}, re("container", Ae)), { minWidth: ne, maxWidth: Z });
|
|
744
|
+
return Le.fontSize = M ?? Le.fontSize, o.jsx("div", { id: I, ref: xe, className: `jer-editor-container ${B ?? ""}`, style: Le, children: et(Q) && !pe.renderCollectionAsValue ? o.jsx(hn, Object.assign({ data: Q }, ee)) : o.jsx(dn, Object.assign({ data: Q, showLabel: !0 }, ee)) });
|
|
745
|
+
}, ir = (e) => {
|
|
746
|
+
var t;
|
|
747
|
+
const [n, r] = G();
|
|
748
|
+
return Oe((() => {
|
|
749
|
+
const a = document.documentElement;
|
|
750
|
+
r(a);
|
|
751
|
+
}), []), n ? o.jsx(Tn, { theme: (t = e.theme) !== null && t !== void 0 ? t : At, icons: e.icons, docRoot: n, children: o.jsx(Kn, { onEditEvent: e.onEditEvent, onCollapse: e.onCollapse, children: o.jsx(nr, Object.assign({}, e)) }) }) : null;
|
|
752
|
+
}, st = (e, t, n, r, a = {}) => {
|
|
753
|
+
if (t.length === 0) return { currentData: e, newData: n, currentValue: e, newValue: n };
|
|
754
|
+
const i = Object.assign({ remove: r === "delete" }, a), s = r !== "add" ? qe(e, t) : void 0;
|
|
755
|
+
return { currentData: e, newData: wn(e, t, n, i), currentValue: s, newValue: r !== "delete" ? n : void 0 };
|
|
756
|
+
}, it = (e, t) => t ? () => !0 : typeof e == "boolean" ? () => e : typeof e == "number" ? ({ level: n }) => n >= e : e, rr = (e) => {
|
|
757
|
+
if (e !== void 0) return e === "value" ? tt : e === "key" ? Yt : e === "all" ? (t, n) => tt(t, n) || Yt(t, n) : e;
|
|
758
|
+
}, or = (e) => Array.isArray(e) && e.length === 2 && ["error", "value"].includes(e[0]), Jt = (e, t) => {
|
|
759
|
+
const n = t === "stringifyReplacer" ? [(r) => r === void 0 ? on : r] : [];
|
|
760
|
+
if (n.push(...e.map(((r) => r[t])).filter(((r) => !!r))), n.length !== 0) return (r, a) => {
|
|
761
|
+
let i = a;
|
|
762
|
+
for (const s of n) i = s(i);
|
|
763
|
+
return i;
|
|
764
|
+
};
|
|
765
|
+
};
|
|
766
|
+
export {
|
|
767
|
+
Wn as IconAdd,
|
|
768
|
+
Gn as IconCancel,
|
|
769
|
+
Jn as IconChevron,
|
|
770
|
+
Un as IconCopy,
|
|
771
|
+
Hn as IconDelete,
|
|
772
|
+
Yn as IconEdit,
|
|
773
|
+
$n as IconOk,
|
|
774
|
+
ir as JsonEditor,
|
|
775
|
+
Rn as StringDisplay,
|
|
776
|
+
Vn as StringEdit,
|
|
777
|
+
wn as assign,
|
|
778
|
+
At as defaultTheme,
|
|
779
|
+
qe as extract,
|
|
780
|
+
et as isCollection,
|
|
781
|
+
tt as matchNode,
|
|
782
|
+
Yt as matchNodeKey,
|
|
783
|
+
Zn as standardDataTypes,
|
|
784
|
+
Ue as toPathString,
|
|
785
|
+
zn as useKeyboardListener
|
|
786
|
+
};
|