legend-state-dev-tools 0.0.12 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +919 -803
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +98 -1
- package/package.json +20 -14
- package/README.md +0 -146
- package/dist/dist/index.d.ts +0 -17
- package/dist/dist/index.js +0 -73
- package/dist/dist/index.js.map +0 -1
- package/dist/dist/index.mjs +0 -1402
- package/dist/dist/index.mjs.map +0 -1
- package/dist/dist/styles.css +0 -184
package/dist/index.mjs
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { createRoot as
|
|
4
|
-
var ct = { exports: {} },
|
|
5
|
-
function
|
|
6
|
-
return
|
|
1
|
+
import { jsx as l, jsxs as $, Fragment as vt } from "react/jsx-runtime";
|
|
2
|
+
import Pn, { useState as de, useEffect as Pe, useRef as Oe, useMemo as De, useCallback as Fe, createContext as rn, useContext as on, Component as Rn } from "react";
|
|
3
|
+
import { createRoot as In } from "react-dom/client";
|
|
4
|
+
var ct = { exports: {} }, Mn = ct.exports, Yt;
|
|
5
|
+
function Vn() {
|
|
6
|
+
return Yt || (Yt = 1, (function(t, e) {
|
|
7
7
|
(function(n, r) {
|
|
8
8
|
r(e);
|
|
9
|
-
})(
|
|
9
|
+
})(Mn, function(n) {
|
|
10
10
|
function r() {
|
|
11
|
-
return r = Object.assign ? Object.assign.bind() : function(
|
|
12
|
-
for (var
|
|
13
|
-
var
|
|
14
|
-
for (var
|
|
11
|
+
return r = Object.assign ? Object.assign.bind() : function(p) {
|
|
12
|
+
for (var h = 1; h < arguments.length; h++) {
|
|
13
|
+
var u = arguments[h];
|
|
14
|
+
for (var y in u) Object.prototype.hasOwnProperty.call(u, y) && (p[y] = u[y]);
|
|
15
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return p;
|
|
17
17
|
}, r.apply(this, arguments);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
19
|
+
function i(p, h) {
|
|
20
|
+
p.prototype = Object.create(h.prototype), p.prototype.constructor = p, o(p, h);
|
|
21
21
|
}
|
|
22
|
-
function a(
|
|
23
|
-
return a = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(
|
|
24
|
-
return
|
|
25
|
-
}, a(
|
|
22
|
+
function a(p) {
|
|
23
|
+
return a = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(h) {
|
|
24
|
+
return h.__proto__ || Object.getPrototypeOf(h);
|
|
25
|
+
}, a(p);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
29
|
-
return
|
|
30
|
-
},
|
|
27
|
+
function o(p, h) {
|
|
28
|
+
return o = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(u, y) {
|
|
29
|
+
return u.__proto__ = y, u;
|
|
30
|
+
}, o(p, h);
|
|
31
31
|
}
|
|
32
|
-
function g(
|
|
32
|
+
function g(p, h, u) {
|
|
33
33
|
return g = (function() {
|
|
34
34
|
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
|
|
35
35
|
if (typeof Proxy == "function") return !0;
|
|
@@ -39,262 +39,262 @@ function Pn() {
|
|
|
39
39
|
} catch {
|
|
40
40
|
return !1;
|
|
41
41
|
}
|
|
42
|
-
})() ? Reflect.construct.bind() : function(
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
return
|
|
42
|
+
})() ? Reflect.construct.bind() : function(y, E, T) {
|
|
43
|
+
var K = [null];
|
|
44
|
+
K.push.apply(K, E);
|
|
45
|
+
var I = new (Function.bind.apply(y, K))();
|
|
46
|
+
return T && o(I, T.prototype), I;
|
|
47
47
|
}, g.apply(null, arguments);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
var
|
|
51
|
-
return
|
|
52
|
-
if (
|
|
53
|
-
if (typeof
|
|
54
|
-
if (
|
|
55
|
-
if (
|
|
56
|
-
|
|
49
|
+
function f(p) {
|
|
50
|
+
var h = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
51
|
+
return f = function(u) {
|
|
52
|
+
if (u === null || Function.toString.call(u).indexOf("[native code]") === -1) return u;
|
|
53
|
+
if (typeof u != "function") throw new TypeError("Super expression must either be null or a function");
|
|
54
|
+
if (h !== void 0) {
|
|
55
|
+
if (h.has(u)) return h.get(u);
|
|
56
|
+
h.set(u, y);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
return g(
|
|
58
|
+
function y() {
|
|
59
|
+
return g(u, arguments, a(this).constructor);
|
|
60
60
|
}
|
|
61
|
-
return
|
|
62
|
-
},
|
|
61
|
+
return y.prototype = Object.create(u.prototype, { constructor: { value: y, enumerable: !1, writable: !0, configurable: !0 } }), o(y, u);
|
|
62
|
+
}, f(p);
|
|
63
63
|
}
|
|
64
64
|
var s = /* @__PURE__ */ (function() {
|
|
65
|
-
function
|
|
66
|
-
this.cache = void 0, this.cache =
|
|
65
|
+
function p(u) {
|
|
66
|
+
this.cache = void 0, this.cache = u;
|
|
67
67
|
}
|
|
68
|
-
var
|
|
69
|
-
return
|
|
70
|
-
this.cache[
|
|
71
|
-
},
|
|
72
|
-
return this.cache[
|
|
73
|
-
},
|
|
74
|
-
delete this.cache[
|
|
75
|
-
},
|
|
68
|
+
var h = p.prototype;
|
|
69
|
+
return h.define = function(u, y) {
|
|
70
|
+
this.cache[u] = y;
|
|
71
|
+
}, h.get = function(u) {
|
|
72
|
+
return this.cache[u];
|
|
73
|
+
}, h.remove = function(u) {
|
|
74
|
+
delete this.cache[u];
|
|
75
|
+
}, h.reset = function() {
|
|
76
76
|
this.cache = {};
|
|
77
|
-
},
|
|
78
|
-
this.cache = r({}, this.cache,
|
|
79
|
-
},
|
|
80
|
-
})(),
|
|
81
|
-
function
|
|
82
|
-
var
|
|
83
|
-
return (
|
|
77
|
+
}, h.load = function(u) {
|
|
78
|
+
this.cache = r({}, this.cache, u);
|
|
79
|
+
}, p;
|
|
80
|
+
})(), c = /* @__PURE__ */ (function(p) {
|
|
81
|
+
function h(u) {
|
|
82
|
+
var y;
|
|
83
|
+
return (y = p.call(this, u) || this).name = "Eta Error", y;
|
|
84
84
|
}
|
|
85
|
-
return
|
|
86
|
-
})(/* @__PURE__ */
|
|
87
|
-
function
|
|
88
|
-
var
|
|
89
|
-
return (
|
|
85
|
+
return i(h, p), h;
|
|
86
|
+
})(/* @__PURE__ */ f(Error)), d = /* @__PURE__ */ (function(p) {
|
|
87
|
+
function h(u) {
|
|
88
|
+
var y;
|
|
89
|
+
return (y = p.call(this, u) || this).name = "EtaParser Error", y;
|
|
90
90
|
}
|
|
91
|
-
return
|
|
92
|
-
})(
|
|
93
|
-
function
|
|
94
|
-
var
|
|
95
|
-
return (
|
|
91
|
+
return i(h, p), h;
|
|
92
|
+
})(c), m = /* @__PURE__ */ (function(p) {
|
|
93
|
+
function h(u) {
|
|
94
|
+
var y;
|
|
95
|
+
return (y = p.call(this, u) || this).name = "EtaRuntime Error", y;
|
|
96
96
|
}
|
|
97
|
-
return
|
|
98
|
-
})(
|
|
99
|
-
function
|
|
100
|
-
var
|
|
101
|
-
return (
|
|
97
|
+
return i(h, p), h;
|
|
98
|
+
})(c), j = /* @__PURE__ */ (function(p) {
|
|
99
|
+
function h(u) {
|
|
100
|
+
var y;
|
|
101
|
+
return (y = p.call(this, u) || this).name = "EtaNameResolution Error", y;
|
|
102
102
|
}
|
|
103
|
-
return
|
|
104
|
-
})(
|
|
105
|
-
function b(
|
|
106
|
-
var
|
|
107
|
-
throw
|
|
103
|
+
return i(h, p), h;
|
|
104
|
+
})(c);
|
|
105
|
+
function b(p, h, u) {
|
|
106
|
+
var y = h.slice(0, u).split(/\n/), E = y.length, T = y[E - 1].length + 1;
|
|
107
|
+
throw p += " at line " + E + " col " + T + `:
|
|
108
108
|
|
|
109
|
-
` +
|
|
110
|
-
` + Array(
|
|
109
|
+
` + h.split(/\n/)[E - 1] + `
|
|
110
|
+
` + Array(T).join(" ") + "^", new d(p);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
var E =
|
|
114
|
-
`),
|
|
115
|
-
var re = Te +
|
|
116
|
-
return (re ==
|
|
112
|
+
function D(p, h, u, y) {
|
|
113
|
+
var E = h.split(`
|
|
114
|
+
`), T = Math.max(u - 3, 0), K = Math.min(E.length, u + 3), I = y, he = E.slice(T, K).map(function(je, Te) {
|
|
115
|
+
var re = Te + T + 1;
|
|
116
|
+
return (re == u ? " >> " : " ") + re + "| " + je;
|
|
117
117
|
}).join(`
|
|
118
|
-
`),
|
|
119
|
-
` : "line " +
|
|
118
|
+
`), Y = new m((I ? I + ":" + u + `
|
|
119
|
+
` : "line " + u + `
|
|
120
120
|
`) + he + `
|
|
121
121
|
|
|
122
|
-
` +
|
|
123
|
-
throw
|
|
122
|
+
` + p.message);
|
|
123
|
+
throw Y.name = p.name, Y;
|
|
124
124
|
}
|
|
125
|
-
var
|
|
125
|
+
var C = (function() {
|
|
126
126
|
return Promise.resolve();
|
|
127
127
|
}).constructor;
|
|
128
|
-
function N(
|
|
129
|
-
var
|
|
128
|
+
function N(p, h) {
|
|
129
|
+
var u = this.config, y = h && h.async ? C : Function;
|
|
130
130
|
try {
|
|
131
|
-
return new
|
|
131
|
+
return new y(u.varName, "options", this.compileToString.call(this, p, h));
|
|
132
132
|
} catch (E) {
|
|
133
|
-
throw E instanceof SyntaxError ? new
|
|
133
|
+
throw E instanceof SyntaxError ? new d(`Bad template syntax
|
|
134
134
|
|
|
135
135
|
` + E.message + `
|
|
136
136
|
` + Array(E.message.length + 1).join("=") + `
|
|
137
|
-
` + this.compileToString.call(this,
|
|
137
|
+
` + this.compileToString.call(this, p, h) + `
|
|
138
138
|
`) : E;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function x(
|
|
142
|
-
var
|
|
141
|
+
function x(p, h) {
|
|
142
|
+
var u = this.config, y = h && h.async, E = this.compileBody, T = this.parse.call(this, p), K = u.functionHeader + `
|
|
143
143
|
let include = (template, data) => this.render(template, data, options);
|
|
144
144
|
let includeAsync = (template, data) => this.renderAsync(template, data, options);
|
|
145
145
|
|
|
146
|
-
let __eta = {res: "", e: this.config.escapeFunction, f: this.config.filterFunction` + (
|
|
146
|
+
let __eta = {res: "", e: this.config.escapeFunction, f: this.config.filterFunction` + (u.debug ? ', line: 1, templateStr: "' + p.replace(/\\|"/g, "\\$&").replace(/\r\n|\n|\r/g, "\\n") + '"' : "") + `};
|
|
147
147
|
|
|
148
148
|
function layout(path, data) {
|
|
149
149
|
__eta.layout = path;
|
|
150
150
|
__eta.layoutData = data;
|
|
151
|
-
}` + (
|
|
151
|
+
}` + (u.debug ? "try {" : "") + (u.useWith ? "with(" + u.varName + "||{}){" : "") + `
|
|
152
152
|
|
|
153
|
-
` + E.call(this,
|
|
153
|
+
` + E.call(this, T) + `
|
|
154
154
|
if (__eta.layout) {
|
|
155
|
-
__eta.res = ` + (
|
|
155
|
+
__eta.res = ` + (y ? "await includeAsync" : "include") + " (__eta.layout, {..." + u.varName + `, body: __eta.res, ...__eta.layoutData});
|
|
156
156
|
}
|
|
157
|
-
` + (
|
|
157
|
+
` + (u.useWith ? "}" : "") + (u.debug ? "} catch (e) { this.RuntimeErr(e, __eta.templateStr, __eta.line, options.filepath) }" : "") + `
|
|
158
158
|
return __eta.res;
|
|
159
159
|
`;
|
|
160
|
-
if (
|
|
161
|
-
var he =
|
|
162
|
-
he.processFnString && (
|
|
160
|
+
if (u.plugins) for (var I = 0; I < u.plugins.length; I++) {
|
|
161
|
+
var he = u.plugins[I];
|
|
162
|
+
he.processFnString && (K = he.processFnString(K, u));
|
|
163
163
|
}
|
|
164
|
-
return
|
|
164
|
+
return K;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
167
|
-
for (var
|
|
168
|
-
var
|
|
169
|
-
if (typeof
|
|
166
|
+
function _(p) {
|
|
167
|
+
for (var h = this.config, u = 0, y = p.length, E = ""; u < y; u++) {
|
|
168
|
+
var T = p[u];
|
|
169
|
+
if (typeof T == "string") E += "__eta.res+='" + T + `'
|
|
170
170
|
`;
|
|
171
171
|
else {
|
|
172
|
-
var
|
|
173
|
-
|
|
174
|
-
`),
|
|
175
|
-
`) :
|
|
176
|
-
`) :
|
|
172
|
+
var K = T.t, I = T.val || "";
|
|
173
|
+
h.debug && (E += "__eta.line=" + T.lineNo + `
|
|
174
|
+
`), K === "r" ? (h.autoFilter && (I = "__eta.f(" + I + ")"), E += "__eta.res+=" + I + `
|
|
175
|
+
`) : K === "i" ? (h.autoFilter && (I = "__eta.f(" + I + ")"), h.autoEscape && (I = "__eta.e(" + I + ")"), E += "__eta.res+=" + I + `
|
|
176
|
+
`) : K === "e" && (E += I + `
|
|
177
177
|
`);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
return E;
|
|
181
181
|
}
|
|
182
|
-
var
|
|
183
|
-
function te(
|
|
184
|
-
return
|
|
182
|
+
var W = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
183
|
+
function te(p) {
|
|
184
|
+
return W[p];
|
|
185
185
|
}
|
|
186
|
-
var
|
|
187
|
-
var
|
|
188
|
-
return /[&<>"']/.test(
|
|
189
|
-
}, filterFunction: function(
|
|
190
|
-
return String(
|
|
191
|
-
}, functionHeader: "", parse: { exec: "", interpolate: "=", raw: "~" }, plugins: [], rmWhitespace: !1, tags: ["<%", "%>"], useWith: !1, varName: "it", defaultExtension: ".eta" },
|
|
192
|
-
function A(
|
|
193
|
-
return
|
|
186
|
+
var G = { autoEscape: !0, autoFilter: !1, autoTrim: [!1, "nl"], cache: !1, cacheFilepaths: !0, debug: !1, escapeFunction: function(p) {
|
|
187
|
+
var h = String(p);
|
|
188
|
+
return /[&<>"']/.test(h) ? h.replace(/[&<>"']/g, te) : h;
|
|
189
|
+
}, filterFunction: function(p) {
|
|
190
|
+
return String(p);
|
|
191
|
+
}, functionHeader: "", parse: { exec: "", interpolate: "=", raw: "~" }, plugins: [], rmWhitespace: !1, tags: ["<%", "%>"], useWith: !1, varName: "it", defaultExtension: ".eta" }, X = /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g, ee = /'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g, U = /"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;
|
|
192
|
+
function A(p) {
|
|
193
|
+
return p.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
|
|
194
194
|
}
|
|
195
|
-
function
|
|
196
|
-
return
|
|
195
|
+
function R(p, h) {
|
|
196
|
+
return p.slice(0, h).split(`
|
|
197
197
|
`).length;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
var
|
|
201
|
-
if (
|
|
202
|
-
var
|
|
203
|
-
|
|
199
|
+
function J(p) {
|
|
200
|
+
var h = this.config, u = [], y = !1, E = 0, T = h.parse;
|
|
201
|
+
if (h.plugins) for (var K = 0; K < h.plugins.length; K++) {
|
|
202
|
+
var I = h.plugins[K];
|
|
203
|
+
I.processTemplate && (p = I.processTemplate(p, h));
|
|
204
204
|
}
|
|
205
205
|
function he(ae, me) {
|
|
206
|
-
ae && (ae = (function(se,
|
|
207
|
-
var ce,
|
|
208
|
-
return Array.isArray(
|
|
209
|
-
})(ae,
|
|
206
|
+
ae && (ae = (function(se, Ce, Ne, Ae) {
|
|
207
|
+
var ce, Q;
|
|
208
|
+
return Array.isArray(Ce.autoTrim) ? (ce = Ce.autoTrim[1], Q = Ce.autoTrim[0]) : ce = Q = Ce.autoTrim, (Ne || Ne === !1) && (ce = Ne), (Ae || Ae === !1) && (Q = Ae), Q || ce ? ce === "slurp" && Q === "slurp" ? se.trim() : (ce === "_" || ce === "slurp" ? se = se.trimStart() : ce !== "-" && ce !== "nl" || (se = se.replace(/^(?:\r\n|\n|\r)/, "")), Q === "_" || Q === "slurp" ? se = se.trimEnd() : Q !== "-" && Q !== "nl" || (se = se.replace(/(?:\r\n|\n|\r)$/, "")), se) : se;
|
|
209
|
+
})(ae, h, y, me), ae && (ae = ae.replace(/\\|'/g, "\\$&").replace(/\r\n|\n|\r/g, "\\n"), u.push(ae)));
|
|
210
210
|
}
|
|
211
|
-
|
|
212
|
-
`).replace(/^\s+|\s+$/gm, "")),
|
|
213
|
-
for (var
|
|
211
|
+
h.rmWhitespace && (p = p.replace(/[\r\n]+/g, `
|
|
212
|
+
`).replace(/^\s+|\s+$/gm, "")), X.lastIndex = 0, ee.lastIndex = 0, U.lastIndex = 0;
|
|
213
|
+
for (var Y, je = [T.exec, T.interpolate, T.raw].reduce(function(ae, me) {
|
|
214
214
|
return ae && me ? ae + "|" + A(me) : me ? A(me) : ae;
|
|
215
|
-
}, ""), Te = new RegExp(A(
|
|
216
|
-
var
|
|
217
|
-
E =
|
|
218
|
-
var
|
|
219
|
-
he(
|
|
220
|
-
for (var z = void 0, ge = !1; z = re.exec(
|
|
215
|
+
}, ""), Te = new RegExp(A(h.tags[0]) + "(-|_)?\\s*(" + je + ")?\\s*", "g"), re = new RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?" + A(h.tags[1]) + ")", "g"); Y = Te.exec(p); ) {
|
|
216
|
+
var Ke = p.slice(E, Y.index);
|
|
217
|
+
E = Y[0].length + Y.index;
|
|
218
|
+
var Ve = Y[2] || "";
|
|
219
|
+
he(Ke, Y[1]), re.lastIndex = E;
|
|
220
|
+
for (var z = void 0, ge = !1; z = re.exec(p); ) {
|
|
221
221
|
if (z[1]) {
|
|
222
|
-
var Se =
|
|
223
|
-
Te.lastIndex = E = re.lastIndex,
|
|
222
|
+
var Se = p.slice(E, z.index);
|
|
223
|
+
Te.lastIndex = E = re.lastIndex, y = z[2], ge = { t: Ve === T.exec ? "e" : Ve === T.raw ? "r" : Ve === T.interpolate ? "i" : "", val: Se };
|
|
224
224
|
break;
|
|
225
225
|
}
|
|
226
226
|
var be = z[0];
|
|
227
227
|
if (be === "/*") {
|
|
228
|
-
var
|
|
229
|
-
|
|
230
|
-
} else be === "'" ? (ee.lastIndex = z.index, ee.exec(
|
|
228
|
+
var P = p.indexOf("*/", re.lastIndex);
|
|
229
|
+
P === -1 && b("unclosed comment", p, z.index), re.lastIndex = P;
|
|
230
|
+
} else be === "'" ? (ee.lastIndex = z.index, ee.exec(p) ? re.lastIndex = ee.lastIndex : b("unclosed string", p, z.index)) : be === '"' ? (U.lastIndex = z.index, U.exec(p) ? re.lastIndex = U.lastIndex : b("unclosed string", p, z.index)) : be === "`" && (X.lastIndex = z.index, X.exec(p) ? re.lastIndex = X.lastIndex : b("unclosed string", p, z.index));
|
|
231
231
|
}
|
|
232
|
-
ge ? (
|
|
232
|
+
ge ? (h.debug && (ge.lineNo = R(p, Y.index)), u.push(ge)) : b("unclosed tag", p, Y.index);
|
|
233
233
|
}
|
|
234
|
-
if (he(
|
|
235
|
-
var
|
|
236
|
-
|
|
234
|
+
if (he(p.slice(E, p.length), !1), h.plugins) for (var B = 0; B < h.plugins.length; B++) {
|
|
235
|
+
var oe = h.plugins[B];
|
|
236
|
+
oe.processAST && (u = oe.processAST(u, h));
|
|
237
237
|
}
|
|
238
|
-
return
|
|
238
|
+
return u;
|
|
239
239
|
}
|
|
240
|
-
function ne(
|
|
241
|
-
var
|
|
242
|
-
if (this.resolvePath && this.readFile && !
|
|
243
|
-
var
|
|
240
|
+
function ne(p, h) {
|
|
241
|
+
var u = h && h.async ? this.templatesAsync : this.templatesSync;
|
|
242
|
+
if (this.resolvePath && this.readFile && !p.startsWith("@")) {
|
|
243
|
+
var y = h.filepath, E = u.get(y);
|
|
244
244
|
if (this.config.cache && E) return E;
|
|
245
|
-
var
|
|
246
|
-
return this.config.cache &&
|
|
245
|
+
var T = this.readFile(y), K = this.compile(T, h);
|
|
246
|
+
return this.config.cache && u.define(y, K), K;
|
|
247
247
|
}
|
|
248
|
-
var
|
|
249
|
-
if (
|
|
250
|
-
throw new j("Failed to get template '" +
|
|
248
|
+
var I = u.get(p);
|
|
249
|
+
if (I) return I;
|
|
250
|
+
throw new j("Failed to get template '" + p + "'");
|
|
251
251
|
}
|
|
252
|
-
function pe(
|
|
253
|
-
var
|
|
254
|
-
return typeof
|
|
252
|
+
function pe(p, h, u) {
|
|
253
|
+
var y, E = r({}, u, { async: !1 });
|
|
254
|
+
return typeof p == "string" ? (this.resolvePath && this.readFile && !p.startsWith("@") && (E.filepath = this.resolvePath(p, E)), y = ne.call(this, p, E)) : y = p, y.call(this, h, E);
|
|
255
255
|
}
|
|
256
|
-
function
|
|
257
|
-
var
|
|
258
|
-
typeof
|
|
259
|
-
var
|
|
260
|
-
return Promise.resolve(
|
|
256
|
+
function ie(p, h, u) {
|
|
257
|
+
var y, E = r({}, u, { async: !0 });
|
|
258
|
+
typeof p == "string" ? (this.resolvePath && this.readFile && !p.startsWith("@") && (E.filepath = this.resolvePath(p, E)), y = ne.call(this, p, E)) : y = p;
|
|
259
|
+
var T = y.call(this, h, E);
|
|
260
|
+
return Promise.resolve(T);
|
|
261
261
|
}
|
|
262
|
-
function fe(
|
|
263
|
-
var
|
|
264
|
-
return pe.call(this,
|
|
262
|
+
function fe(p, h) {
|
|
263
|
+
var u = this.compile(p, { async: !1 });
|
|
264
|
+
return pe.call(this, u, h);
|
|
265
265
|
}
|
|
266
|
-
function le(
|
|
267
|
-
var
|
|
268
|
-
return
|
|
266
|
+
function le(p, h) {
|
|
267
|
+
var u = this.compile(p, { async: !0 });
|
|
268
|
+
return ie.call(this, u, h);
|
|
269
269
|
}
|
|
270
270
|
var Z = /* @__PURE__ */ (function() {
|
|
271
|
-
function
|
|
272
|
-
this.config = void 0, this.RuntimeErr =
|
|
271
|
+
function p(u) {
|
|
272
|
+
this.config = void 0, this.RuntimeErr = D, this.compile = N, this.compileToString = x, this.compileBody = _, this.parse = J, this.render = pe, this.renderAsync = ie, this.renderString = fe, this.renderStringAsync = le, this.filepathCache = {}, this.templatesSync = new s({}), this.templatesAsync = new s({}), this.resolvePath = null, this.readFile = null, this.config = u ? r({}, G, u) : r({}, G);
|
|
273
273
|
}
|
|
274
|
-
var
|
|
275
|
-
return
|
|
276
|
-
this.config = r({}, this.config,
|
|
277
|
-
},
|
|
278
|
-
return r({}, this, { config: r({}, this.config,
|
|
279
|
-
},
|
|
280
|
-
if (typeof
|
|
274
|
+
var h = p.prototype;
|
|
275
|
+
return h.configure = function(u) {
|
|
276
|
+
this.config = r({}, this.config, u);
|
|
277
|
+
}, h.withConfig = function(u) {
|
|
278
|
+
return r({}, this, { config: r({}, this.config, u) });
|
|
279
|
+
}, h.loadTemplate = function(u, y, E) {
|
|
280
|
+
if (typeof y == "string") (E && E.async ? this.templatesAsync : this.templatesSync).define(u, this.compile(y, E));
|
|
281
281
|
else {
|
|
282
|
-
var
|
|
283
|
-
(
|
|
282
|
+
var T = this.templatesSync;
|
|
283
|
+
(y.constructor.name === "AsyncFunction" || E && E.async) && (T = this.templatesAsync), T.define(u, y);
|
|
284
284
|
}
|
|
285
|
-
},
|
|
286
|
-
})(),
|
|
287
|
-
function
|
|
288
|
-
return
|
|
285
|
+
}, p;
|
|
286
|
+
})(), q = /* @__PURE__ */ (function(p) {
|
|
287
|
+
function h() {
|
|
288
|
+
return p.apply(this, arguments) || this;
|
|
289
289
|
}
|
|
290
|
-
return
|
|
290
|
+
return i(h, p), h;
|
|
291
291
|
})(Z);
|
|
292
|
-
n.Eta =
|
|
292
|
+
n.Eta = q;
|
|
293
293
|
});
|
|
294
294
|
})(ct, ct.exports)), ct.exports;
|
|
295
295
|
}
|
|
296
|
-
var
|
|
297
|
-
const
|
|
296
|
+
var Fn = /* @__PURE__ */ Vn();
|
|
297
|
+
const Kn = `<div class="lsdt-toolbar-header">
|
|
298
298
|
<div class="lsdt-toolbar-title">
|
|
299
299
|
<span class="lsdt-toolbar-indicator"></span>
|
|
300
300
|
Legend State
|
|
@@ -307,47 +307,56 @@ const In = `<div class="lsdt-toolbar-header">
|
|
|
307
307
|
<%= it.panelVisible ? 'Hide' : 'Show' %> <%= it.rootName %>
|
|
308
308
|
</button>
|
|
309
309
|
</div>
|
|
310
|
-
`,
|
|
310
|
+
`, zn = `<div class="lsdt-panel-header">
|
|
311
311
|
<h3><%= it.rootName %></h3>
|
|
312
312
|
<div class="lsdt-panel-actions">
|
|
313
313
|
<% if (it.readOnly) { %>
|
|
314
314
|
<span class="lsdt-readonly-badge">Read-only</span>
|
|
315
315
|
<% } %>
|
|
316
|
+
<button class="lsdt-dump-btn" data-action="dump-state" title="Download state as JSON">
|
|
317
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
|
|
318
|
+
</button>
|
|
316
319
|
<button class="lsdt-close-btn" data-action="close-panel" title="Close">×</button>
|
|
317
320
|
</div>
|
|
318
321
|
</div>
|
|
319
322
|
<div class="lsdt-panel-content">
|
|
320
323
|
<div id="lsdt-json-editor-root"></div>
|
|
321
324
|
</div>
|
|
322
|
-
`,
|
|
325
|
+
`, Bn = new Fn.Eta({
|
|
323
326
|
autoEscape: !0,
|
|
324
327
|
autoTrim: !1
|
|
325
|
-
}),
|
|
326
|
-
toolbar:
|
|
327
|
-
panel:
|
|
328
|
+
}), $n = {
|
|
329
|
+
toolbar: Kn,
|
|
330
|
+
panel: zn
|
|
328
331
|
};
|
|
329
|
-
function
|
|
330
|
-
const n =
|
|
332
|
+
function an(t, e) {
|
|
333
|
+
const n = $n[t];
|
|
331
334
|
if (!n)
|
|
332
335
|
return console.error(`[LSDT] Template not found: ${t}`), "";
|
|
333
336
|
try {
|
|
334
|
-
return
|
|
337
|
+
return Bn.renderString(n, e);
|
|
335
338
|
} catch (r) {
|
|
336
339
|
return console.error(`[LSDT] Error rendering template ${t}:`, r), "";
|
|
337
340
|
}
|
|
338
341
|
}
|
|
339
|
-
function
|
|
340
|
-
return
|
|
342
|
+
function Wn(t) {
|
|
343
|
+
return an("toolbar", t);
|
|
341
344
|
}
|
|
342
|
-
function
|
|
343
|
-
return
|
|
345
|
+
function Hn(t) {
|
|
346
|
+
return an("panel", t);
|
|
344
347
|
}
|
|
345
|
-
const
|
|
346
|
-
function
|
|
347
|
-
const n = localStorage.getItem(`${
|
|
348
|
+
const _t = "lsdt";
|
|
349
|
+
function Un(t, e) {
|
|
350
|
+
const n = localStorage.getItem(`${_t}-${t}`);
|
|
348
351
|
return n === null ? e : n === "true";
|
|
349
352
|
}
|
|
350
|
-
function
|
|
353
|
+
function Gt(t, e) {
|
|
354
|
+
return localStorage.getItem(`${_t}-${t}`) || e;
|
|
355
|
+
}
|
|
356
|
+
function Xt(t, e) {
|
|
357
|
+
localStorage.setItem(`${_t}-${t}`, e);
|
|
358
|
+
}
|
|
359
|
+
function Yn() {
|
|
351
360
|
const t = [];
|
|
352
361
|
return {
|
|
353
362
|
add: (e) => t.push(e),
|
|
@@ -362,24 +371,27 @@ function Wn() {
|
|
|
362
371
|
}
|
|
363
372
|
};
|
|
364
373
|
}
|
|
365
|
-
class
|
|
374
|
+
class Gn {
|
|
366
375
|
constructor(e = {}) {
|
|
367
|
-
this.container = null, this.isDragging = !1, this.offsetX = 0, this.offsetY = 0, this.isMinimized =
|
|
368
|
-
var
|
|
369
|
-
const
|
|
370
|
-
if (!
|
|
371
|
-
|
|
376
|
+
this.container = null, this.isDragging = !1, this.offsetX = 0, this.offsetY = 0, this.isMinimized = Un("toolbar-minimized", !1), this.panelVisible = !1, this.handleClick = (n) => {
|
|
377
|
+
var o;
|
|
378
|
+
const i = n.target.closest("[data-action]");
|
|
379
|
+
if (!i) return;
|
|
380
|
+
i.getAttribute("data-action") === "toggle-panel" && ((o = this.onTogglePanel) == null || o.call(this));
|
|
372
381
|
}, this.handleMouseDown = (n) => {
|
|
373
|
-
if (n.target.tagName !== "BUTTON"
|
|
374
|
-
this.container
|
|
375
|
-
|
|
376
|
-
|
|
382
|
+
if (n.target.tagName !== "BUTTON") {
|
|
383
|
+
if (this.isDragging = !0, this.container) {
|
|
384
|
+
this.container.classList.add("dragging");
|
|
385
|
+
const i = this.container.getBoundingClientRect();
|
|
386
|
+
this.offsetX = n.clientX - i.left, this.offsetY = n.clientY - i.top;
|
|
387
|
+
}
|
|
388
|
+
document.addEventListener("mousemove", this.handleMouseMove), document.addEventListener("mouseup", this.handleMouseUp);
|
|
377
389
|
}
|
|
378
390
|
}, this.handleMouseMove = (n) => {
|
|
379
391
|
!this.isDragging || !this.container || (this.container.style.left = `${n.clientX - this.offsetX}px`, this.container.style.top = `${n.clientY - this.offsetY}px`, this.container.style.right = "auto", this.container.style.bottom = "auto");
|
|
380
392
|
}, this.handleMouseUp = () => {
|
|
381
393
|
var n;
|
|
382
|
-
this.isDragging = !1, (n = this.container) == null || n.classList.remove("dragging");
|
|
394
|
+
this.isDragging = !1, (n = this.container) == null || n.classList.remove("dragging"), document.removeEventListener("mousemove", this.handleMouseMove), document.removeEventListener("mouseup", this.handleMouseUp);
|
|
383
395
|
}, this.onTogglePanel = e.onTogglePanel, this.rootName = e.rootName || "state$";
|
|
384
396
|
}
|
|
385
397
|
mount() {
|
|
@@ -392,10 +404,10 @@ class $n {
|
|
|
392
404
|
panelVisible: this.panelVisible,
|
|
393
405
|
rootName: this.rootName
|
|
394
406
|
};
|
|
395
|
-
this.container.innerHTML =
|
|
407
|
+
this.container.innerHTML = Wn(e);
|
|
396
408
|
}
|
|
397
409
|
attachEventListeners() {
|
|
398
|
-
this.container && (this.container.addEventListener("click", this.handleClick), this.container.addEventListener("mousedown", this.handleMouseDown)
|
|
410
|
+
this.container && (this.container.addEventListener("click", this.handleClick), this.container.addEventListener("mousedown", this.handleMouseDown));
|
|
399
411
|
}
|
|
400
412
|
setPanelVisible(e) {
|
|
401
413
|
this.panelVisible = e, this.render();
|
|
@@ -404,28 +416,55 @@ class $n {
|
|
|
404
416
|
this.container && (this.container.removeEventListener("click", this.handleClick), this.container.removeEventListener("mousedown", this.handleMouseDown), this.container.remove(), this.container = null), document.removeEventListener("mousemove", this.handleMouseMove), document.removeEventListener("mouseup", this.handleMouseUp);
|
|
405
417
|
}
|
|
406
418
|
}
|
|
407
|
-
class
|
|
419
|
+
class Xn {
|
|
408
420
|
constructor(e = {}) {
|
|
409
|
-
this.container = null, this.visible = !1, this.handleClick = (n) => {
|
|
410
|
-
var
|
|
411
|
-
const
|
|
412
|
-
if (!
|
|
413
|
-
|
|
414
|
-
|
|
421
|
+
this.container = null, this.visible = !1, this.resizeHandle = null, this.isDragging = !1, this.dragOffsetX = 0, this.dragOffsetY = 0, this.dragStartLeft = 0, this.dragStartTop = 0, this.handleClick = (n) => {
|
|
422
|
+
var o, g;
|
|
423
|
+
const i = n.target.closest("[data-action]");
|
|
424
|
+
if (!i) return;
|
|
425
|
+
const a = i.getAttribute("data-action");
|
|
426
|
+
a === "close-panel" ? (o = this.onClose) == null || o.call(this) : a === "dump-state" && ((g = this.onDumpState) == null || g.call(this));
|
|
427
|
+
}, this.handleDragStart = (n) => {
|
|
428
|
+
const r = n.target;
|
|
429
|
+
if (r.closest("button") || r.closest("[data-action]") || (n.preventDefault(), !this.container)) return;
|
|
430
|
+
this.isDragging = !0;
|
|
431
|
+
const i = this.container.getBoundingClientRect();
|
|
432
|
+
this.dragOffsetX = n.clientX - i.left, this.dragOffsetY = n.clientY - i.top, this.dragStartLeft = i.left, this.dragStartTop = i.top, this.container.classList.add("lsdt-dragging"), document.addEventListener("mousemove", this.handleDragMove), document.addEventListener("mouseup", this.handleDragEnd);
|
|
433
|
+
}, this.handleDragMove = (n) => {
|
|
434
|
+
if (!this.isDragging || !this.container) return;
|
|
435
|
+
const r = n.clientX - this.dragOffsetX - this.dragStartLeft, i = n.clientY - this.dragOffsetY - this.dragStartTop;
|
|
436
|
+
this.container.style.transform = `translate(${r}px, ${i}px)`;
|
|
437
|
+
}, this.handleDragEnd = () => {
|
|
438
|
+
if (!this.isDragging || !this.container) return;
|
|
439
|
+
this.isDragging = !1;
|
|
440
|
+
const n = this.container.getBoundingClientRect();
|
|
441
|
+
this.container.style.left = `${n.left}px`, this.container.style.top = `${n.top}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", this.container.style.transform = "", this.container.classList.remove("lsdt-dragging"), document.removeEventListener("mousemove", this.handleDragMove), document.removeEventListener("mouseup", this.handleDragEnd), Xt("panel-position", JSON.stringify({
|
|
442
|
+
top: this.container.style.top,
|
|
443
|
+
left: this.container.style.left
|
|
444
|
+
}));
|
|
445
|
+
}, this.rootName = e.rootName || "state$", this.readOnly = e.readOnly || !1, this.onClose = e.onClose, this.onDumpState = e.onDumpState, this.position = e.position || "right";
|
|
415
446
|
}
|
|
416
447
|
toggle() {
|
|
417
448
|
this.visible ? this.hide() : this.show();
|
|
418
449
|
}
|
|
419
450
|
show() {
|
|
420
|
-
this.visible = !0, this.container
|
|
451
|
+
if (this.visible = !0, !this.container) {
|
|
452
|
+
this.container = document.createElement("div"), this.container.id = "lsdt-panel", this.position === "left" && this.container.classList.add("lsdt-panel-left");
|
|
453
|
+
const e = Gt("panel-width", "");
|
|
454
|
+
e && (this.container.style.width = e), this.restoreSavedPosition(), this.resizeHandle = document.createElement("div"), this.resizeHandle.className = "lsdt-resize-handle", this.attachResizeListeners(this.resizeHandle), document.body.appendChild(this.container), this.attachEventListeners();
|
|
455
|
+
}
|
|
456
|
+
this.render();
|
|
421
457
|
}
|
|
422
458
|
hide() {
|
|
423
459
|
var e;
|
|
424
|
-
this.visible = !1, (e = this.container) == null || e.remove(), this.container = null;
|
|
460
|
+
this.visible = !1, this.cleanupListeners(), (e = this.container) == null || e.remove(), this.container = null, this.resizeHandle = null;
|
|
425
461
|
}
|
|
426
462
|
isVisible() {
|
|
427
463
|
return this.visible;
|
|
428
464
|
}
|
|
465
|
+
getIsDragging() {
|
|
466
|
+
return this.isDragging;
|
|
467
|
+
}
|
|
429
468
|
getEditorRoot() {
|
|
430
469
|
var e;
|
|
431
470
|
return ((e = this.container) == null ? void 0 : e.querySelector("#lsdt-json-editor-root")) || null;
|
|
@@ -436,16 +475,50 @@ class Gn {
|
|
|
436
475
|
rootName: this.rootName,
|
|
437
476
|
readOnly: this.readOnly
|
|
438
477
|
};
|
|
439
|
-
this.container.innerHTML =
|
|
478
|
+
this.container.innerHTML = Hn(e), this.resizeHandle && this.container.appendChild(this.resizeHandle), this.attachDragListeners();
|
|
440
479
|
}
|
|
441
480
|
attachEventListeners() {
|
|
442
481
|
this.container && this.container.addEventListener("click", this.handleClick);
|
|
443
482
|
}
|
|
483
|
+
attachResizeListeners(e) {
|
|
484
|
+
e.addEventListener("mousedown", (n) => {
|
|
485
|
+
n.preventDefault();
|
|
486
|
+
const r = this.container;
|
|
487
|
+
if (!r) return;
|
|
488
|
+
const i = n.clientX, a = r.getBoundingClientRect().width, o = this.position === "left";
|
|
489
|
+
r.classList.add("lsdt-resizing");
|
|
490
|
+
const g = (s) => {
|
|
491
|
+
const c = s.clientX - i, d = o ? a + c : a - c, m = Math.max(280, Math.min(d, window.innerWidth * 0.9));
|
|
492
|
+
r.style.width = `${m}px`;
|
|
493
|
+
}, f = () => {
|
|
494
|
+
r.classList.remove("lsdt-resizing"), document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", f), Xt("panel-width", r.style.width);
|
|
495
|
+
};
|
|
496
|
+
document.addEventListener("mousemove", g), document.addEventListener("mouseup", f);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
restoreSavedPosition() {
|
|
500
|
+
if (!this.container) return;
|
|
501
|
+
const e = Gt("panel-position", "");
|
|
502
|
+
if (e)
|
|
503
|
+
try {
|
|
504
|
+
const n = JSON.parse(e);
|
|
505
|
+
this.container.style.top = n.top, this.container.style.left = n.left, this.container.style.right = "auto", this.container.style.bottom = "auto";
|
|
506
|
+
} catch {
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
attachDragListeners() {
|
|
510
|
+
if (!this.container) return;
|
|
511
|
+
const e = this.container.querySelector(".lsdt-panel-header");
|
|
512
|
+
e && e.addEventListener("mousedown", this.handleDragStart);
|
|
513
|
+
}
|
|
514
|
+
cleanupListeners() {
|
|
515
|
+
document.removeEventListener("mousemove", this.handleDragMove), document.removeEventListener("mouseup", this.handleDragEnd);
|
|
516
|
+
}
|
|
444
517
|
unmount() {
|
|
445
|
-
this.container && (this.container.removeEventListener("click", this.handleClick), this.container.remove(), this.container = null), this.visible = !1;
|
|
518
|
+
this.container && (this.cleanupListeners(), this.container.removeEventListener("click", this.handleClick), this.container.remove(), this.container = null, this.resizeHandle = null), this.visible = !1;
|
|
446
519
|
}
|
|
447
520
|
}
|
|
448
|
-
function
|
|
521
|
+
function Jn(t, e) {
|
|
449
522
|
const n = () => {
|
|
450
523
|
try {
|
|
451
524
|
return JSON.parse(JSON.stringify(t.peek()));
|
|
@@ -457,8 +530,8 @@ function Hn(t, e) {
|
|
|
457
530
|
try {
|
|
458
531
|
r = t.onChange(
|
|
459
532
|
() => {
|
|
460
|
-
const
|
|
461
|
-
e.onSnapshot(
|
|
533
|
+
const i = n();
|
|
534
|
+
e.onSnapshot(i);
|
|
462
535
|
},
|
|
463
536
|
{ trackingType: !1 }
|
|
464
537
|
);
|
|
@@ -467,9 +540,9 @@ function Hn(t, e) {
|
|
|
467
540
|
}
|
|
468
541
|
return {
|
|
469
542
|
getSnapshot: n,
|
|
470
|
-
setData: (
|
|
543
|
+
setData: (i) => {
|
|
471
544
|
try {
|
|
472
|
-
t.set(
|
|
545
|
+
t.set(i);
|
|
473
546
|
} catch (a) {
|
|
474
547
|
console.error("[Legend State DevTools] Failed to set data:", a);
|
|
475
548
|
}
|
|
@@ -479,124 +552,124 @@ function Hn(t, e) {
|
|
|
479
552
|
}
|
|
480
553
|
};
|
|
481
554
|
}
|
|
482
|
-
const
|
|
483
|
-
if (!r) throw new Error(
|
|
555
|
+
const Ue = (t, e, n, r, i) => {
|
|
556
|
+
if (!r) throw new Error(i ?? `Invalid property path: ${e}
|
|
484
557
|
Couldn't access "${n}" in ${JSON.stringify(t)}`);
|
|
485
|
-
},
|
|
486
|
-
const { remove:
|
|
558
|
+
}, Jt = (t) => typeof t == "object" && t !== null && !Array.isArray(t), mt = (t) => Array.isArray(t), sn = (t, e) => t.filter(((n, r) => r !== e)), Zn = (t, e, n, r = {}) => {
|
|
559
|
+
const { remove: i = !1, createNew: a = !0, noError: o = !1 } = r, g = t, f = typeof (s = e) == "string" ? s : typeof s == "number" ? String(s) : s.reduce(((m, j) => typeof j == "number" ? `${m}[${j}]` : m === "" ? j : `${m}.${j}`), "");
|
|
487
560
|
var s;
|
|
488
|
-
const
|
|
561
|
+
const c = Object.assign(Object.assign({}, r), { remove: i, createNew: a, noError: o, fullData: g, fullPath: f }), d = Array.isArray(e) ? e : ((m) => Array.isArray(m) ? m : m.split(/(\.|\[\d+\])/).filter(((j) => j !== "." && j !== "")).map(((j) => {
|
|
489
562
|
const b = /\[(\d+)\]/.exec(j);
|
|
490
563
|
return b ? Number(b[1]) : j;
|
|
491
|
-
})).flat())(e).filter(((
|
|
492
|
-
return mt(t) &&
|
|
564
|
+
})).flat())(e).filter(((m) => m !== ""));
|
|
565
|
+
return mt(t) && i && d.length === 1 ? sn(t, d[0]) : ut(t, d, n, c);
|
|
493
566
|
}, ut = (t, e, n, r) => {
|
|
494
|
-
const
|
|
567
|
+
const i = Jt(t) ? Object.assign({}, t) : null, a = mt(t) ? [...t] : null;
|
|
495
568
|
if (e.length === 0) return t;
|
|
496
|
-
if (!
|
|
497
|
-
const { createNew:
|
|
498
|
-
if (a && typeof
|
|
569
|
+
if (!i && !a) throw new Error("Can't assign property -- invalid input object");
|
|
570
|
+
const { createNew: o, remove: g, noError: f, fullData: s, fullPath: c } = r, d = e[0];
|
|
571
|
+
if (a && typeof d == "string") return a.map(((D) => ut(D, e, n, r)));
|
|
499
572
|
if (e.length === 1) {
|
|
500
|
-
if (
|
|
501
|
-
const
|
|
502
|
-
return
|
|
573
|
+
if (i && typeof d == "string") {
|
|
574
|
+
const D = qn(i, d, n, r);
|
|
575
|
+
return D ?? i;
|
|
503
576
|
}
|
|
504
|
-
return a && typeof
|
|
577
|
+
return a && typeof d == "number" ? (Qn(a, d, n, r), a) : (Ue(s, c, d, f), t);
|
|
505
578
|
}
|
|
506
|
-
const
|
|
579
|
+
const m = i || a || [];
|
|
507
580
|
if (g && e.length === 2 && typeof e[1] == "number") {
|
|
508
|
-
const
|
|
509
|
-
return mt(
|
|
581
|
+
const D = m[d], C = e[1];
|
|
582
|
+
return mt(D) ? m[d] = sn(D, C) : Ue(s, c, d, f, "Trying to remove an indexed item from an object that is not an array"), m;
|
|
510
583
|
}
|
|
511
584
|
const j = e.slice(1);
|
|
512
|
-
if (
|
|
513
|
-
if (b =
|
|
514
|
-
if (!
|
|
515
|
-
|
|
585
|
+
if (d in t) {
|
|
586
|
+
if (b = m[d], !mt(b) && !Jt(b)) {
|
|
587
|
+
if (!o) return Ue(s, c, d, f), m;
|
|
588
|
+
m[d] = {};
|
|
516
589
|
}
|
|
517
|
-
return
|
|
590
|
+
return m[d] = ut(m[d], j, n, r), m;
|
|
518
591
|
}
|
|
519
592
|
var b;
|
|
520
|
-
if (
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
if (a && Array.isArray(
|
|
524
|
-
|
|
525
|
-
const
|
|
526
|
-
return
|
|
593
|
+
if (o) {
|
|
594
|
+
const D = typeof j[0] == "number" ? [] : {};
|
|
595
|
+
if (i) return m[d] = D, m[d] = ut(m[d], j, n, r), m;
|
|
596
|
+
if (a && Array.isArray(m)) {
|
|
597
|
+
m.push(D);
|
|
598
|
+
const C = m.length - 1;
|
|
599
|
+
return m[C] = ut(m[C], j, n, r), m;
|
|
527
600
|
}
|
|
528
601
|
}
|
|
529
|
-
return
|
|
530
|
-
},
|
|
531
|
-
const { remove:
|
|
532
|
-
if (
|
|
533
|
-
const
|
|
602
|
+
return Ue(s, c, d, f), m;
|
|
603
|
+
}, qn = (t, e, n, r) => {
|
|
604
|
+
const { remove: i, createNew: a, noError: o, insertAfter: g, insertBefore: f, fullData: s, fullPath: c } = r;
|
|
605
|
+
if (f !== void 0 || g !== void 0) {
|
|
606
|
+
const m = Object.entries(t);
|
|
534
607
|
let j = 1 / 0;
|
|
535
|
-
return j = typeof
|
|
608
|
+
return j = typeof f == "number" ? f : typeof g == "number" ? g : m.findIndex((([b, D]) => b === (f ?? g))), g && j++, m.splice(j, 0, [e, n]), Object.fromEntries(m);
|
|
536
609
|
}
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
},
|
|
540
|
-
const { noError:
|
|
541
|
-
|
|
610
|
+
const d = e in t;
|
|
611
|
+
i ? d ? delete t[e] : Ue(s, c, e, o) : a || d ? t[e] = n : Ue(s, c, e, o);
|
|
612
|
+
}, Qn = (t, e, n, r) => {
|
|
613
|
+
const { noError: i, fullData: a, fullPath: o, createNew: g, insert: f } = r;
|
|
614
|
+
f && t.splice(e, 0, n), e in t ? t[e] = n : g ? t.push(n) : Ue(a, o, e, i);
|
|
542
615
|
}, nt = (t, e, n) => {
|
|
543
|
-
const r = Array.isArray(e) ? e :
|
|
616
|
+
const r = Array.isArray(e) ? e : er(e);
|
|
544
617
|
if (r.length === 0) return t;
|
|
545
|
-
const
|
|
546
|
-
if (Array.isArray(t) && typeof
|
|
547
|
-
if (typeof t != "object" || t === null || !(
|
|
548
|
-
const a = t[
|
|
618
|
+
const i = r[0];
|
|
619
|
+
if (Array.isArray(t) && typeof i != "number") return t.map(((o) => nt(o, r)));
|
|
620
|
+
if (typeof t != "object" || t === null || !(i in t)) return tr(t, i);
|
|
621
|
+
const a = t[i];
|
|
549
622
|
return r.length === 1 ? a : nt(a, r.slice(1));
|
|
550
|
-
},
|
|
623
|
+
}, er = (t) => t.split(/(\.|\[\d+\])/).filter(((e) => e !== "." && e !== "")).map(((e) => {
|
|
551
624
|
const n = /\[(\d+)\]/.exec(e);
|
|
552
625
|
return n ? Number(n[1]) : e;
|
|
553
|
-
})).flat(),
|
|
626
|
+
})).flat(), tr = (t, e, n) => {
|
|
554
627
|
throw new Error(`Unable to extract object property
|
|
555
628
|
Looking for property: ${e}
|
|
556
629
|
In object: ${JSON.stringify(t)}`);
|
|
557
630
|
};
|
|
558
|
-
function
|
|
631
|
+
function ln(t, e) {
|
|
559
632
|
var n = {};
|
|
560
633
|
for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
|
|
561
634
|
if (t != null && typeof Object.getOwnPropertySymbols == "function") {
|
|
562
|
-
var
|
|
563
|
-
for (r = Object.getOwnPropertySymbols(t);
|
|
635
|
+
var i = 0;
|
|
636
|
+
for (r = Object.getOwnPropertySymbols(t); i < r.length; i++) e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
|
|
564
637
|
}
|
|
565
638
|
return n;
|
|
566
639
|
}
|
|
567
640
|
function tt(t, e, n, r) {
|
|
568
|
-
return new (n || (n = Promise))((function(
|
|
569
|
-
function
|
|
641
|
+
return new (n || (n = Promise))((function(i, a) {
|
|
642
|
+
function o(s) {
|
|
570
643
|
try {
|
|
571
|
-
|
|
572
|
-
} catch (
|
|
573
|
-
a(
|
|
644
|
+
f(r.next(s));
|
|
645
|
+
} catch (c) {
|
|
646
|
+
a(c);
|
|
574
647
|
}
|
|
575
648
|
}
|
|
576
649
|
function g(s) {
|
|
577
650
|
try {
|
|
578
|
-
|
|
579
|
-
} catch (
|
|
580
|
-
a(
|
|
651
|
+
f(r.throw(s));
|
|
652
|
+
} catch (c) {
|
|
653
|
+
a(c);
|
|
581
654
|
}
|
|
582
655
|
}
|
|
583
|
-
function
|
|
584
|
-
var
|
|
585
|
-
s.done ?
|
|
586
|
-
|
|
587
|
-
}))).then(
|
|
656
|
+
function f(s) {
|
|
657
|
+
var c;
|
|
658
|
+
s.done ? i(s.value) : (c = s.value, c instanceof n ? c : new n((function(d) {
|
|
659
|
+
d(c);
|
|
660
|
+
}))).then(o, g);
|
|
588
661
|
}
|
|
589
|
-
|
|
662
|
+
f((r = r.apply(t, [])).next());
|
|
590
663
|
}));
|
|
591
664
|
}
|
|
592
|
-
const
|
|
665
|
+
const cn = ({ className: t, name: e, value: n, setValue: r, handleKeyPress: i, styles: a, textAreaRef: o }) => {
|
|
593
666
|
if (typeof n != "string") return null;
|
|
594
667
|
const g = n.slice(-1) === `
|
|
595
668
|
` ? n + "." : n;
|
|
596
|
-
return $("div", { style: { display: "grid" }, children: [
|
|
597
|
-
n.length < 40 &&
|
|
598
|
-
}, onKeyDown:
|
|
599
|
-
}, rt = (t) => t !== null && typeof t == "object",
|
|
669
|
+
return $("div", { style: { display: "grid" }, children: [l("textarea", { id: `${e}_textarea`, ref: o, style: Object.assign({ height: "auto", gridArea: "1 / 1 / 2 / 2", overflowY: "auto", whiteSpace: "pre-wrap" }, a), rows: 1, className: t, name: `${e}_textarea`, value: n, onChange: (f) => r(f.target.value), autoFocus: !0, onFocus: (f) => {
|
|
670
|
+
n.length < 40 && f.target.select();
|
|
671
|
+
}, onKeyDown: i }), l("span", { className: t, 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" }, a), children: g })] });
|
|
672
|
+
}, rt = (t) => t !== null && typeof t == "object", un = (t, e, n, r = "") => {
|
|
600
673
|
if (!n && !r) return !0;
|
|
601
674
|
switch (t) {
|
|
602
675
|
case "collection":
|
|
@@ -607,16 +680,16 @@ const an = ({ className: t, name: e, value: n, setValue: r, handleKeyPress: o, s
|
|
|
607
680
|
if (!n && r && !Tt(r, e)) return !1;
|
|
608
681
|
break;
|
|
609
682
|
case "value":
|
|
610
|
-
if (n && !n(e, r) || !n && r && !
|
|
683
|
+
if (n && !n(e, r) || !n && r && !it(e, r)) return !1;
|
|
611
684
|
}
|
|
612
685
|
return !0;
|
|
613
|
-
}, Tt = (t = "", e, n =
|
|
686
|
+
}, Tt = (t = "", e, n = it) => {
|
|
614
687
|
const r = e.value;
|
|
615
|
-
return Object.entries(r).some((([
|
|
616
|
-
const
|
|
688
|
+
return Object.entries(r).some((([i, a]) => {
|
|
689
|
+
const o = [...e.path, i], g = Object.assign(Object.assign({}, e), { key: i, path: o, level: e.level + 1, value: a, size: o.length, parentData: r });
|
|
617
690
|
return rt(a) ? Tt(t, g, n) : n(g, t);
|
|
618
691
|
}));
|
|
619
|
-
},
|
|
692
|
+
}, it = (t, e = "") => {
|
|
620
693
|
const { value: n } = t;
|
|
621
694
|
if (n === null && "null".includes(e.toLowerCase())) return !0;
|
|
622
695
|
switch (typeof n) {
|
|
@@ -629,145 +702,145 @@ const an = ({ className: t, name: e, value: n, setValue: r, handleKeyPress: o, s
|
|
|
629
702
|
default:
|
|
630
703
|
return !1;
|
|
631
704
|
}
|
|
632
|
-
},
|
|
633
|
-
const r = t.key,
|
|
634
|
-
if (Array.isArray(e)) return !!
|
|
635
|
-
const { key: a, modifier:
|
|
636
|
-
return (n !== "stringLineBreak" || r !== "Enter" ||
|
|
637
|
-
},
|
|
638
|
-
const
|
|
705
|
+
}, Zt = ({ key: t, path: e }, n = "") => !!it({ value: t }, n) || !!e.some(((r) => it({ value: r }, n))), Je = (t, e) => (e ?? "") + t.map(((n) => n === "" ? "\0" : n)).join("."), Pt = (t) => t.shiftKey ? "Shift" : t.metaKey ? "Meta" : t.ctrlKey ? "Control" : t.altKey ? "Alt" : void 0, nr = (t, e, n) => {
|
|
706
|
+
const r = t.key, i = Pt(t);
|
|
707
|
+
if (Array.isArray(e)) return !!i && e.includes(i);
|
|
708
|
+
const { key: a, modifier: o } = e;
|
|
709
|
+
return (n !== "stringLineBreak" || r !== "Enter" || i !== "Shift" || a !== "Enter" || !(o != null && o.includes("Shift"))) && r === a && (o === i || Array.isArray(o) && o.includes(i));
|
|
710
|
+
}, He = { key: "Enter" }, qt = { confirm: He, cancel: { key: "Escape" }, objectConfirm: Object.assign(Object.assign({}, He), { modifier: ["Meta", "Shift", "Control"] }), objectLineBreak: He, stringConfirm: He, stringLineBreak: Object.assign(Object.assign({}, He), { modifier: ["Shift"] }), numberConfirm: He, numberUp: { key: "ArrowUp" }, numberDown: { key: "ArrowDown" }, tabForward: { key: "Tab" }, tabBack: { key: "Tab", modifier: "Shift" }, booleanConfirm: He, booleanToggle: { key: " " }, clipboardModifier: ["Meta", "Control"], collapseModifier: ["Alt"] }, Ye = (t, e, n = "next", r) => {
|
|
711
|
+
const i = e.slice(0, e.length - 1), a = e.slice(-1)[0];
|
|
639
712
|
if (a === void 0) return null;
|
|
640
|
-
const
|
|
641
|
-
Array.isArray(
|
|
642
|
-
const
|
|
643
|
-
return s ? rt(s.value) ? Object.keys(s.value).length === 0 ?
|
|
644
|
-
},
|
|
645
|
-
const
|
|
646
|
-
if (!rt(
|
|
647
|
-
const a = Array.isArray(
|
|
648
|
-
r(a, ((g) => [g,
|
|
649
|
-
const
|
|
650
|
-
return
|
|
651
|
-
},
|
|
652
|
-
var n, r,
|
|
653
|
-
const
|
|
654
|
-
return
|
|
713
|
+
const o = nt(t, i), g = rr(o);
|
|
714
|
+
Array.isArray(o) || r(g, (({ key: c, value: d }) => [c, d]));
|
|
715
|
+
const f = g.findIndex(((c) => c.key === a)), s = g[f + (n === "next" ? 1 : -1)];
|
|
716
|
+
return s ? rt(s.value) ? Object.keys(s.value).length === 0 ? Ye(t, [...i, s.key], n, r) : dn(t, [...i, s.key], n, r) : [...i, s.key] : i.length === 0 ? null : Ye(t, i, n, r);
|
|
717
|
+
}, dn = (t, e, n = "next", r) => {
|
|
718
|
+
const i = nt(t, e);
|
|
719
|
+
if (!rt(i)) return e;
|
|
720
|
+
const a = Array.isArray(i) ? i.map(((g, f) => f)) : Object.keys(i);
|
|
721
|
+
r(a, ((g) => [g, i]));
|
|
722
|
+
const o = n === "next" ? a[0] : a[a.length - 1];
|
|
723
|
+
return dn(t, [...e, o], n, r);
|
|
724
|
+
}, rr = (t) => Array.isArray(t) ? t.map(((e, n) => ({ index: n, value: e, key: n }))) : Object.entries(t).map((([e, n], r) => ({ key: e, value: n, index: r }))), hn = (t, e) => {
|
|
725
|
+
var n, r, i, a;
|
|
726
|
+
const o = t.current, g = (n = o == null ? void 0 : o.selectionStart) !== null && n !== void 0 ? n : 1 / 0, f = (r = o == null ? void 0 : o.selectionEnd) !== null && r !== void 0 ? r : 1 / 0, s = ((i = o == null ? void 0 : o.textContent) === null || i === void 0 ? void 0 : i.slice(0, g)) + e + ((a = o == null ? void 0 : o.textContent) === null || a === void 0 ? void 0 : a.slice(f));
|
|
727
|
+
return o.value = s, o == null || o.setSelectionRange(g + 1, g + 1), s;
|
|
655
728
|
}, Nt = (t) => {
|
|
656
|
-
if (t !==
|
|
729
|
+
if (t !== pn) {
|
|
657
730
|
if (Array.isArray(t)) return t.map(((e) => Nt(e)));
|
|
658
731
|
if (t && typeof t == "object") for (const e in t) t[e] = Nt(t[e]);
|
|
659
732
|
return t;
|
|
660
733
|
}
|
|
661
|
-
},
|
|
662
|
-
const
|
|
663
|
-
return
|
|
664
|
-
},
|
|
665
|
-
var n, r,
|
|
666
|
-
const
|
|
667
|
-
Object.keys(
|
|
668
|
-
const
|
|
669
|
-
g.forEach(((
|
|
670
|
-
|
|
734
|
+
}, pn = "__undefined__", Rt = { 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)" } }, fn = rn({ getStyles: () => ({}), icons: {} }), ir = ({ theme: t = Rt, icons: e = {}, docRoot: n, children: r }) => {
|
|
735
|
+
const i = or(t, n);
|
|
736
|
+
return l(fn.Provider, { value: { getStyles: (a, o) => typeof i[a] == "function" ? i[a](o) : i[a], icons: e }, children: r });
|
|
737
|
+
}, Me = () => on(fn), or = (t, e) => {
|
|
738
|
+
var n, r, i, a;
|
|
739
|
+
const o = {}, g = (Array.isArray(t) ? t : [t]).map(((c) => ar(c) ? xt({ fragments: {}, styles: c }, o) : xt(c, o))), f = xt(Rt, {});
|
|
740
|
+
Object.keys(f).forEach(((c) => {
|
|
741
|
+
const d = c;
|
|
742
|
+
g.forEach(((m) => {
|
|
743
|
+
m[d] && (f[d] = Object.assign(Object.assign({}, f[d]), m[d]));
|
|
671
744
|
}));
|
|
672
745
|
}));
|
|
673
|
-
const s = Object.assign({},
|
|
674
|
-
return Object.entries(
|
|
675
|
-
const
|
|
676
|
-
s[
|
|
677
|
-
const b =
|
|
678
|
-
return Object.assign(Object.assign({},
|
|
746
|
+
const s = Object.assign({}, f);
|
|
747
|
+
return Object.entries(o).forEach((([c, d]) => {
|
|
748
|
+
const m = c;
|
|
749
|
+
s[m] = (j) => {
|
|
750
|
+
const b = d(j) || {};
|
|
751
|
+
return Object.assign(Object.assign({}, f[m]), b);
|
|
679
752
|
};
|
|
680
|
-
})), typeof (s == null ? void 0 : s.inputHighlight) != "function" && (!((n = s == null ? void 0 : s.inputHighlight) === null || n === void 0) && n.backgroundColor) && e.style.setProperty("--jer-highlight-color", (r = s == null ? void 0 : s.inputHighlight) === null || r === void 0 ? void 0 : r.backgroundColor), typeof (s == null ? void 0 : s.iconCopy) != "function" && (!((
|
|
753
|
+
})), typeof (s == null ? void 0 : s.inputHighlight) != "function" && (!((n = s == null ? void 0 : s.inputHighlight) === null || n === void 0) && n.backgroundColor) && e.style.setProperty("--jer-highlight-color", (r = s == null ? void 0 : s.inputHighlight) === null || r === void 0 ? void 0 : r.backgroundColor), typeof (s == null ? void 0 : s.iconCopy) != "function" && (!((i = s == null ? void 0 : s.iconCopy) === null || i === void 0) && i.color) && e.style.setProperty("--jer-icon-copy-color", (a = s == null ? void 0 : s.iconCopy) === null || a === void 0 ? void 0 : a.color), s;
|
|
681
754
|
}, xt = (t, e) => {
|
|
682
|
-
const { fragments: n, styles: r } = t,
|
|
683
|
-
return Object.entries(r).forEach((([a,
|
|
684
|
-
const g = (Array.isArray(
|
|
685
|
-
var
|
|
686
|
-
if (typeof s == "function") return e[a] = s, Object.assign({},
|
|
755
|
+
const { fragments: n, styles: r } = t, i = {};
|
|
756
|
+
return Object.entries(r).forEach((([a, o]) => {
|
|
757
|
+
const g = (Array.isArray(o) ? o : [o]).reduce(((f, s) => {
|
|
758
|
+
var c, d;
|
|
759
|
+
if (typeof s == "function") return e[a] = s, Object.assign({}, f);
|
|
687
760
|
if (typeof s == "string") {
|
|
688
|
-
const
|
|
689
|
-
return typeof
|
|
761
|
+
const m = (c = n == null ? void 0 : n[s]) !== null && c !== void 0 ? c : s;
|
|
762
|
+
return typeof m == "string" ? Object.assign(Object.assign({}, f), { [(d = sr[a]) !== null && d !== void 0 ? d : "color"]: m }) : Object.assign(Object.assign({}, f), m);
|
|
690
763
|
}
|
|
691
|
-
return Object.assign(Object.assign({},
|
|
764
|
+
return Object.assign(Object.assign({}, f), s);
|
|
692
765
|
}), {});
|
|
693
|
-
|
|
694
|
-
})),
|
|
695
|
-
},
|
|
696
|
-
const [r,
|
|
697
|
-
return
|
|
698
|
-
|
|
766
|
+
i[a] = g;
|
|
767
|
+
})), i;
|
|
768
|
+
}, ar = (t) => !("styles" in t), sr = { container: "backgroundColor", collection: "backgroundColor", collectionInner: "backgroundColor", collectionElement: "backgroundColor", dropZone: "borderColor", inputHighlight: "backgroundColor" }, gn = rn(null), lr = ({ children: t, onEditEvent: e, onCollapse: n }) => {
|
|
769
|
+
const [r, i] = de(null), [a, o] = de(null), [g, f] = de(null), [s, c] = de({ path: null, pathString: null }), d = Oe(null), m = Oe("next"), j = Oe(null);
|
|
770
|
+
return l(gn.Provider, { value: { collapseState: r, setCollapseState: (b) => {
|
|
771
|
+
i(b), n && b !== null && (Array.isArray(b) ? b.forEach(((D) => n(D))) : n(b)), b !== null && setTimeout((() => i(null)), 2e3);
|
|
699
772
|
}, getMatchingCollapseState: (b) => {
|
|
700
773
|
if (Array.isArray(r)) {
|
|
701
|
-
for (const
|
|
774
|
+
for (const D of r) if (Qt(b, D)) return D;
|
|
702
775
|
return null;
|
|
703
776
|
}
|
|
704
|
-
return
|
|
705
|
-
}, currentlyEditingElement: a, setCurrentlyEditingElement: (b,
|
|
706
|
-
const
|
|
707
|
-
a !== null &&
|
|
777
|
+
return Qt(b, r) ? r : null;
|
|
778
|
+
}, currentlyEditingElement: a, setCurrentlyEditingElement: (b, D) => {
|
|
779
|
+
const C = typeof b == "string" || b === null ? b : Je(b, D === "key" ? "key_" : void 0);
|
|
780
|
+
a !== null && C !== null && d.current !== null && d.current(), o(C), e && (Array.isArray(b) || b === null) && e(b, D === "key"), d.current = typeof D == "function" ? D : null;
|
|
708
781
|
}, areChildrenBeingEdited: (b) => a !== null && a.includes(b), previouslyEditedElement: j.current, setPreviouslyEditedElement: (b) => {
|
|
709
782
|
j.current = b;
|
|
710
|
-
}, tabDirection:
|
|
711
|
-
|
|
712
|
-
}, previousValue: g, setPreviousValue:
|
|
713
|
-
},
|
|
714
|
-
const t =
|
|
783
|
+
}, tabDirection: m.current, setTabDirection: (b) => {
|
|
784
|
+
m.current = b;
|
|
785
|
+
}, previousValue: g, setPreviousValue: f, dragSource: s, setDragSource: c }, children: t });
|
|
786
|
+
}, Xe = () => {
|
|
787
|
+
const t = on(gn);
|
|
715
788
|
if (!t) throw new Error("Missing Context Provider");
|
|
716
789
|
return t;
|
|
717
|
-
},
|
|
790
|
+
}, Qt = (t, e) => {
|
|
718
791
|
if (e === null) return !1;
|
|
719
792
|
if (!e.includeChildren) return e.path.every(((n, r) => t[r] === n)) && e.path.length === t.length;
|
|
720
793
|
for (const [n, r] of e.path.entries()) if (r !== t[n]) return !1;
|
|
721
794
|
return !0;
|
|
722
|
-
}, At = "**INVALID_FUNCTION**",
|
|
723
|
-
const
|
|
724
|
-
|
|
795
|
+
}, At = "**INVALID_FUNCTION**", cr = ({ nodeData: t, showStringQuotes: e = !0, stringTruncate: n = 200, pathString: r, canEdit: i, setIsEditing: a, styles: o, translate: g, value: f, TextWrapper: s = ({ children: c }) => c }) => {
|
|
796
|
+
const c = f ?? t.value, [d, m] = de(!1), j = e ? '"' : "", b = c.length > n, D = () => {
|
|
797
|
+
i ? a(!0) : m(!d);
|
|
725
798
|
};
|
|
726
|
-
return $("div", { id: `${r}_display`, onDoubleClick:
|
|
727
|
-
(
|
|
728
|
-
}, className: "jer-value-string", style:
|
|
729
|
-
},
|
|
730
|
-
const g =
|
|
731
|
-
return
|
|
732
|
-
a(
|
|
733
|
-
const s =
|
|
799
|
+
return $("div", { id: `${r}_display`, onDoubleClick: D, onClick: (C) => {
|
|
800
|
+
(C.getModifierState("Control") || C.getModifierState("Meta")) && D();
|
|
801
|
+
}, className: "jer-value-string", style: o, children: [j, b ? $(vt, d ? { children: [l(s, { children: $("span", { children: [c, j] }) }), $("span", { className: "jer-string-expansion jer-show-less", onClick: () => m(!1), children: [" ", g("SHOW_LESS", t)] })] } : { children: [$(s, { children: [l("span", { children: c.slice(0, n - 2).trimEnd() }), " "] }), l("span", { className: "jer-string-expansion jer-ellipsis", onClick: () => m(!0), children: "..." }), j] }) : l(s, { children: `${c}${j}` })] });
|
|
802
|
+
}, ur = ({ styles: t, pathString: e, value: n, setValue: r, handleEdit: i, handleKeyboard: a, keyboardCommon: o }) => {
|
|
803
|
+
const g = Oe(null);
|
|
804
|
+
return l(cn, { className: "jer-input-text", textAreaRef: g, name: e, value: n, setValue: r, handleKeyPress: (f) => {
|
|
805
|
+
a(f, Object.assign({ stringConfirm: i, stringLineBreak: () => {
|
|
806
|
+
const s = hn(g, `
|
|
734
807
|
`);
|
|
735
808
|
r(s);
|
|
736
|
-
} },
|
|
809
|
+
} }, o));
|
|
737
810
|
}, styles: t });
|
|
738
|
-
},
|
|
739
|
-
var { isEditing: e, path: n, enumType: r } = t,
|
|
740
|
-
const { getStyles: a } =
|
|
741
|
-
return e && r ? $("div", { className: "jer-select jer-select-enums", children: [
|
|
742
|
-
|
|
743
|
-
}, children: r.values.map(((j) =>
|
|
744
|
-
},
|
|
745
|
-
const { getStyles: s } =
|
|
746
|
-
return n ?
|
|
747
|
-
},
|
|
748
|
-
const { getStyles: s } =
|
|
749
|
-
return typeof t != "boolean" ? null : n ?
|
|
750
|
-
|
|
751
|
-
}, autoFocus: !0 }) :
|
|
752
|
-
},
|
|
753
|
-
const n =
|
|
754
|
-
|
|
811
|
+
}, dr = (t) => {
|
|
812
|
+
var { isEditing: e, path: n, enumType: r } = t, i = ln(t, ["isEditing", "path", "enumType"]);
|
|
813
|
+
const { getStyles: a } = Me(), o = Je(n), { value: g, setValue: f, nodeData: s, handleEdit: c, handleKeyboard: d, keyboardCommon: m } = i;
|
|
814
|
+
return e && r ? $("div", { className: "jer-select jer-select-enums", children: [l("select", { name: `${o}-value-select`, className: "jer-select-inner", onChange: (j) => f(j.target.value), value: g, autoFocus: !0, onKeyDown: (j) => {
|
|
815
|
+
d(j, Object.assign({ stringConfirm: c }, m));
|
|
816
|
+
}, children: r.values.map(((j) => l("option", { value: j, children: j }, j))) }), l("span", { className: "focus" })] }) : e ? l(ur, Object.assign({ styles: a("input", s), pathString: o }, i, { setValue: i.setValue })) : l(cr, Object.assign({ pathString: o, styles: a("string", s) }, i));
|
|
817
|
+
}, hr = ({ value: t, setValue: e, isEditing: n, path: r, setIsEditing: i, handleEdit: a, nodeData: o, handleKeyboard: g, keyboardCommon: f }) => {
|
|
818
|
+
const { getStyles: s } = Me();
|
|
819
|
+
return n ? l("input", { className: "jer-input-number", type: "text", name: Je(r), value: t, onChange: (c) => e(c.target.value.replace(/[^0-9.-]/g, "")), autoFocus: !0, onFocus: (c) => setTimeout((() => c.target.select()), 10), onKeyDown: (c) => g(c, Object.assign({ numberConfirm: a, numberUp: () => e(Number(t) + 1), numberDown: () => e(Number(t) - 1) }, f)), style: Object.assign({ width: String(t).length / 1.5 + 2 + "em" }, s("input", o)) }) : l("span", { onDoubleClick: () => i(!0), className: "jer-value-number", style: s("number", o), children: t });
|
|
820
|
+
}, pr = ({ value: t, setValue: e, isEditing: n, path: r, setIsEditing: i, handleEdit: a, nodeData: o, handleKeyboard: g, keyboardCommon: f }) => {
|
|
821
|
+
const { getStyles: s } = Me();
|
|
822
|
+
return typeof t != "boolean" ? null : n ? l("input", { className: "jer-input-boolean", type: "checkbox", name: Je(r), checked: t, onChange: () => e(!t), onKeyDown: (c) => {
|
|
823
|
+
c.key === " " && c.preventDefault(), g(c, Object.assign({ booleanConfirm: a, booleanToggle: () => e(!t) }, f));
|
|
824
|
+
}, autoFocus: !0 }) : l("span", { onDoubleClick: () => i(!0), className: "jer-value-boolean", style: s("boolean", o), children: String(t) });
|
|
825
|
+
}, fr = (t, e) => {
|
|
826
|
+
const n = Oe(void 0), r = Oe(e);
|
|
827
|
+
Pe((() => {
|
|
755
828
|
r.current = e;
|
|
756
829
|
}), [e]);
|
|
757
|
-
const
|
|
830
|
+
const i = (a) => {
|
|
758
831
|
r.current(a);
|
|
759
832
|
};
|
|
760
|
-
|
|
833
|
+
Pe((() => {
|
|
761
834
|
if (window.clearTimeout(n.current), t) return n.current = window.setTimeout((() => {
|
|
762
|
-
window.addEventListener("keydown",
|
|
835
|
+
window.addEventListener("keydown", i);
|
|
763
836
|
}), 100), () => {
|
|
764
|
-
window.clearTimeout(n.current), window.removeEventListener("keydown",
|
|
837
|
+
window.clearTimeout(n.current), window.removeEventListener("keydown", i);
|
|
765
838
|
};
|
|
766
839
|
}), [t]);
|
|
767
|
-
},
|
|
768
|
-
const { getStyles: g } =
|
|
769
|
-
return
|
|
770
|
-
},
|
|
840
|
+
}, gr = ({ value: t, isEditing: e, setIsEditing: n, handleEdit: r, nodeData: i, handleKeyboard: a, keyboardCommon: o }) => {
|
|
841
|
+
const { getStyles: g } = Me();
|
|
842
|
+
return fr(e, ((f) => a(f, Object.assign({ confirm: r }, o)))), l("div", { onDoubleClick: () => n(!0), className: "jer-value-null", style: g("null", i), children: String(t) });
|
|
843
|
+
}, mr = ({ value: t }) => {
|
|
771
844
|
let e = "Error!";
|
|
772
845
|
switch (typeof t) {
|
|
773
846
|
case "string":
|
|
@@ -779,219 +852,219 @@ const an = ({ className: t, name: e, value: n, setValue: r, handleKeyPress: o, s
|
|
|
779
852
|
case "symbol":
|
|
780
853
|
e = "Symbol";
|
|
781
854
|
}
|
|
782
|
-
return
|
|
783
|
-
},
|
|
784
|
-
var n, r,
|
|
785
|
-
const { getStyles: s, icons:
|
|
855
|
+
return l("span", { className: "jer-value-invalid", children: e });
|
|
856
|
+
}, yr = ({ size: t, style: e, className: n }) => $("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: t, height: t, className: n, style: e, children: [l("path", { d: "M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z" }), l("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" })] }), vr = ({ size: t, style: e, className: n }) => $("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: t, height: t, className: n, style: e, transform: "translate(0, 0.5)", children: [l("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" }), l("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" })] }), br = ({ size: t, style: e, className: n }) => l("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: t, height: t, className: n, style: e, children: l("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" }) }), Er = ({ size: t, style: e, className: n }) => $("svg", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, viewBox: "0 0 24 24", width: t, height: t, className: n, style: e, children: [l("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" }), l("path", { d: "M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11" }), l("path", { d: "M15 10l-4 4 4 4" })] }), jr = ({ size: t, style: e, className: n }) => $("svg", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, viewBox: "0 0 24 24", width: t, height: t, className: n, style: e, children: [l("path", { d: "M22 11.08V12a10 10 0 11-5.93-9.14" }), l("path", { d: "M22 4L12 14.01l-3-3" })] }), wr = ({ size: t, style: e, className: n }) => l("svg", { baseProfile: "tiny", viewBox: "0 0 24 24", fill: "currentColor", width: t, height: t, className: n, style: e, children: l("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" }) }), Dr = ({ size: t, style: e, className: n }) => l("svg", { viewBox: "0 0 512 512", fill: "currentColor", width: t, height: t, className: n, style: e, children: l("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" }) }), Ge = ({ name: t, nodeData: e }) => {
|
|
857
|
+
var n, r, i, a, o, g, f;
|
|
858
|
+
const { getStyles: s, icons: c } = Me(), d = { size: "1.4em", className: "jer-icon" };
|
|
786
859
|
switch (t) {
|
|
787
860
|
case "add":
|
|
788
|
-
return (n =
|
|
861
|
+
return (n = c == null ? void 0 : c.add) !== null && n !== void 0 ? n : l(yr, Object.assign({}, d, { style: s("iconAdd", e) }));
|
|
789
862
|
case "edit":
|
|
790
|
-
return (r =
|
|
863
|
+
return (r = c == null ? void 0 : c.edit) !== null && r !== void 0 ? r : l(vr, Object.assign({}, d, { style: s("iconEdit", e) }));
|
|
791
864
|
case "delete":
|
|
792
|
-
return (
|
|
865
|
+
return (i = c == null ? void 0 : c.delete) !== null && i !== void 0 ? i : l(br, Object.assign({}, d, { style: s("iconDelete", e), size: "1.45em" }));
|
|
793
866
|
case "copy":
|
|
794
|
-
return (a =
|
|
867
|
+
return (a = c == null ? void 0 : c.copy) !== null && a !== void 0 ? a : l(Er, Object.assign({}, d, { style: s("iconCopy", e), size: "1.2em" }));
|
|
795
868
|
case "ok":
|
|
796
|
-
return (
|
|
869
|
+
return (o = c == null ? void 0 : c.ok) !== null && o !== void 0 ? o : l(jr, Object.assign({}, d, { style: Object.assign({ fontSize: "90%" }, s("iconOk", e)) }));
|
|
797
870
|
case "cancel":
|
|
798
|
-
return (g =
|
|
871
|
+
return (g = c == null ? void 0 : c.cancel) !== null && g !== void 0 ? g : l(wr, Object.assign({}, d, { style: Object.assign({ fontSize: "130%" }, s("iconCancel", e)) }));
|
|
799
872
|
case "chevron":
|
|
800
|
-
return (
|
|
873
|
+
return (f = c == null ? void 0 : c.chevron) !== null && f !== void 0 ? f : l(Dr, { size: "1em", style: s("iconCollection", e) });
|
|
801
874
|
default:
|
|
802
|
-
return
|
|
875
|
+
return l(vt, {});
|
|
803
876
|
}
|
|
804
|
-
},
|
|
805
|
-
const { getStyles:
|
|
806
|
-
var
|
|
807
|
-
if (j && j(A ? [...
|
|
808
|
-
const
|
|
809
|
-
ne && x(""),
|
|
877
|
+
}, mn = ({ startEdit: t, handleDelete: e, handleAdd: n, enableClipboard: r, type: i, customButtons: a, nodeData: o, translate: g, keyboardControls: f, handleKeyboard: s, editConfirmRef: c, getNewKeyOptions: d, jsonStringify: m, onEditEvent: j, showIconTooltips: b }) => {
|
|
878
|
+
const { getStyles: D } = Me(), C = g("KEY_NEW", o), [N, x] = de(C), [_, W] = de(!1), { key: te, path: G, value: X } = o, ee = Array.isArray(_), U = (A) => {
|
|
879
|
+
var R;
|
|
880
|
+
if (j && j(A ? [...G, null] : null, A), !A) return void W(!1);
|
|
881
|
+
const J = Object.keys(nt(o.fullData, G)), ne = d ? (R = d(o)) === null || R === void 0 ? void 0 : R.filter(((pe) => !J.includes(pe))) : null;
|
|
882
|
+
ne && x(""), W(ne == null || ne);
|
|
810
883
|
};
|
|
811
|
-
return $("div", { className: "jer-edit-buttons", style: { opacity:
|
|
812
|
-
var
|
|
884
|
+
return $("div", { className: "jer-edit-buttons", style: { opacity: _ ? 1 : void 0 }, onClick: (A) => A.stopPropagation(), children: [r && l("div", { onClick: (A) => {
|
|
885
|
+
var R;
|
|
813
886
|
A.stopPropagation();
|
|
814
|
-
let
|
|
887
|
+
let J, ne, pe = "value", ie = "", fe = null;
|
|
815
888
|
if (r) {
|
|
816
889
|
const le = Pt(A);
|
|
817
|
-
if (le &&
|
|
818
|
-
(
|
|
890
|
+
if (le && f.clipboardModifier.includes(le) ? (J = Or(G), ie = J, pe = "path") : (J = X, ie = typeof J == "object" ? m(X) : String(J)), !navigator.clipboard) return void (typeof r == "function" && r({ success: !1, value: J, stringValue: ie, path: G, key: te, type: pe, errorMessage: "Can't access clipboard API" }));
|
|
891
|
+
(R = navigator.clipboard) === null || R === void 0 || R.writeText(ie).then((() => ne = !0)).catch(((Z) => {
|
|
819
892
|
ne = !1, fe = Z.message;
|
|
820
893
|
})).finally((() => {
|
|
821
|
-
typeof r == "function" && r({ success: ne, errorMessage: fe, value:
|
|
894
|
+
typeof r == "function" && r({ success: ne, errorMessage: fe, value: J, stringValue: ie, path: G, key: te, type: pe });
|
|
822
895
|
}));
|
|
823
896
|
}
|
|
824
|
-
}, className: "jer-copy-pulse", title: b ? g("TOOLTIP_COPY",
|
|
825
|
-
|
|
826
|
-
}, title: b ? g("TOOLTIP_ADD",
|
|
827
|
-
n(A.target.value),
|
|
897
|
+
}, className: "jer-copy-pulse", title: b ? g("TOOLTIP_COPY", o) : "", children: l(Ge, { name: "copy", nodeData: o }) }), t && l("div", { onClick: t, title: b ? g("TOOLTIP_EDIT", o) : "", children: l(Ge, { name: "edit", nodeData: o }) }), e && l("div", { onClick: e, title: b ? g("TOOLTIP_DELETE", o) : "", children: l(Ge, { name: "delete", nodeData: o }) }), n && l("div", { onClick: () => {
|
|
898
|
+
i === "object" ? U(!0) : n("");
|
|
899
|
+
}, title: b ? g("TOOLTIP_ADD", o) : "", children: l(Ge, { name: "add", nodeData: o }) }), a == null ? void 0 : a.map((({ Element: A, onClick: R }, J) => l("div", { onClick: (ne) => R && R(o, ne), children: l(A, { nodeData: o }) }, J))), _ && n && i === "object" && $(vt, { children: [ee ? $("div", { className: "jer-select jer-select-keys", children: [$("select", { name: "new-key-select", className: "jer-select-inner", onChange: (A) => {
|
|
900
|
+
n(A.target.value), U(!1);
|
|
828
901
|
}, defaultValue: "", autoFocus: !0, onKeyDown: (A) => {
|
|
829
|
-
s(A, { cancel: () =>
|
|
830
|
-
}, children: [
|
|
902
|
+
s(A, { cancel: () => U(!1) });
|
|
903
|
+
}, children: [l("option", { value: "", disabled: !0, children: _.length > 0 ? g("KEY_SELECT", o) : g("NO_KEY_OPTIONS", o) }), _.map(((A) => l("option", { value: A, children: A }, A)))] }), l("span", { className: "focus" })] }) : l("input", { className: "jer-input-new-key", type: "text", name: "new-object-key", value: N, onChange: (A) => x(A.target.value), autoFocus: !0, onFocus: (A) => A.target.select(), onKeyDown: (A) => {
|
|
831
904
|
s(A, { stringConfirm: () => {
|
|
832
|
-
n && (
|
|
905
|
+
n && (U(!1), n(N), x(C));
|
|
833
906
|
}, cancel: () => {
|
|
834
|
-
|
|
907
|
+
U(!1), x(C);
|
|
835
908
|
} });
|
|
836
|
-
}, style:
|
|
837
|
-
ee && !N || (
|
|
909
|
+
}, style: D("input", o) }), l(It, { onOk: () => {
|
|
910
|
+
ee && !N || (U(!1), n(N));
|
|
838
911
|
}, onCancel: () => {
|
|
839
|
-
|
|
840
|
-
}, nodeData:
|
|
841
|
-
}, It = ({ onOk: t, onCancel: e, nodeData: n, editConfirmRef: r, hideOk:
|
|
842
|
-
const { data: n, nodeData: r, parentData:
|
|
912
|
+
U(!1);
|
|
913
|
+
}, nodeData: o, editConfirmRef: c, hideOk: ee })] })] });
|
|
914
|
+
}, It = ({ onOk: t, onCancel: e, nodeData: n, editConfirmRef: r, hideOk: i = !1 }) => $("div", { className: "jer-confirm-buttons", children: [!i && l("div", { onClick: t, ref: r, children: l(Ge, { name: "ok", nodeData: n }) }), l("div", { onClick: e, children: l(Ge, { name: "cancel", nodeData: n }) })] }), Or = (t) => t.reduce(((e, n) => typeof n == "number" ? `${e}[${n}]` : e === "" ? n : `${e}.${n}`), ""), Cr = ["string", "number", "boolean", "null", "object", "array"], yn = ({ props: t, collapsed: e }) => {
|
|
915
|
+
const { data: n, nodeData: r, parentData: i, onEdit: a, onError: o, showErrorMessages: g, restrictEditFilter: f, restrictDeleteFilter: s, restrictAddFilter: c, restrictDragFilter: d, translate: m, errorMessageTimeout: j } = t, { currentlyEditingElement: b, setCurrentlyEditingElement: D } = Xe(), [C, N] = de(null), x = Object.assign(Object.assign({}, r), { collapsed: e }), { path: _, key: W, size: te } = x, G = Je(_), X = !f(x), ee = !s(x), U = !c(x), A = !d(x) && ee && b === null, R = (Z) => {
|
|
843
916
|
g && (N(Z), setTimeout((() => N(null)), j)), console.warn("Error", Z);
|
|
844
|
-
},
|
|
845
|
-
|
|
846
|
-
}), [
|
|
847
|
-
return { pathString:
|
|
848
|
-
if (
|
|
849
|
-
const
|
|
850
|
-
if (Object.keys(
|
|
851
|
-
const
|
|
852
|
-
a(
|
|
853
|
-
|
|
917
|
+
}, J = Fe(((Z, q) => {
|
|
918
|
+
R(Z.message), o && o({ currentData: x.fullData, errorValue: q, currentValue: n, name: W, path: _, error: Z });
|
|
919
|
+
}), [o, g]), ne = b === G, pe = b === `key_${G}`, ie = typeof _.slice(-1)[0] == "number", fe = { isEditing: ne, isEditingKey: pe, isArray: ie, canEditKey: i !== null && X && U && ee && !ie }, le = W === "" && _.length > 0 ? m("EMPTY_STRING", x) : null;
|
|
920
|
+
return { pathString: G, nodeData: x, path: _, name: W, size: te, canEdit: X, canDelete: ee, canAdd: U, canDrag: A, error: C, showError: R, onError: J, setError: N, handleEditKey: (Z) => {
|
|
921
|
+
if (D(null), W === Z || !i) return;
|
|
922
|
+
const q = _.slice(0, -1);
|
|
923
|
+
if (Object.keys(i).includes(Z)) return void J({ code: "KEY_EXISTS", message: m("ERROR_KEY_EXISTS", x) }, Z);
|
|
924
|
+
const p = Object.fromEntries(Object.entries(i).map((([h, u]) => h === W ? [Z, u] : [h, u])));
|
|
925
|
+
a(p, q).then(((h) => {
|
|
926
|
+
h && J({ code: "UPDATE_ERROR", message: h }, Z);
|
|
854
927
|
}));
|
|
855
928
|
}, derivedValues: fe, emptyStringKey: le };
|
|
856
|
-
},
|
|
857
|
-
const { getStyles: g } =
|
|
858
|
-
N.stopPropagation(), s({ path: n, pathString:
|
|
929
|
+
}, vn = ({ canDrag: t, canDragOnto: e, path: n, nodeData: r, onMove: i, onError: a, translate: o }) => {
|
|
930
|
+
const { getStyles: g } = Me(), { dragSource: f, setDragSource: s } = Xe(), [c, d] = de(!1), m = Je(n), j = De((() => t ? { onDragStart: (N) => {
|
|
931
|
+
N.stopPropagation(), s({ path: n, pathString: m });
|
|
859
932
|
}, onDragEnd: (N) => {
|
|
860
933
|
N.stopPropagation(), s({ path: null, pathString: null });
|
|
861
|
-
} } : {}), [t,
|
|
934
|
+
} } : {}), [t, m]), b = De((() => (N) => e ? { onDragOver: (x) => {
|
|
862
935
|
x.stopPropagation(), x.preventDefault();
|
|
863
936
|
}, onDrop: (x) => {
|
|
864
|
-
x.stopPropagation(),
|
|
937
|
+
x.stopPropagation(), C(N), s({ path: null, pathString: null }), d(!1);
|
|
865
938
|
}, onDragEnter: (x) => {
|
|
866
|
-
var
|
|
867
|
-
x.stopPropagation(),
|
|
939
|
+
var _;
|
|
940
|
+
x.stopPropagation(), m.startsWith((_ = f.pathString) !== null && _ !== void 0 ? _ : "") || d(N);
|
|
868
941
|
}, onDragExit: (x) => {
|
|
869
|
-
x.stopPropagation(),
|
|
870
|
-
} } : {}), [
|
|
871
|
-
var x,
|
|
872
|
-
const
|
|
873
|
-
typeof
|
|
942
|
+
x.stopPropagation(), d(!1);
|
|
943
|
+
} } : {}), [f, e, m]), D = De((() => e && f.pathString !== null ? l("div", Object.assign({ className: "jer-drop-target-bottom", style: { height: "50%", position: "absolute", width: "100%", top: "50%", zIndex: n.length } }, b("below"))) : null), [f, e, n.length]), C = (N) => {
|
|
944
|
+
var x, _;
|
|
945
|
+
const W = (x = f.path) === null || x === void 0 ? void 0 : x.slice(-1)[0], te = (_ = f.path) === null || _ === void 0 ? void 0 : _.slice(0, -1).join("."), G = n.slice(0, -1).join(""), { parentData: X } = r;
|
|
946
|
+
typeof W == "string" && X && !Array.isArray(X) && Object.keys(X).includes(W) && W in X && te !== G ? a({ code: "KEY_EXISTS", message: o("ERROR_KEY_EXISTS", r) }, W) : i(f.path, n, N).then(((ee) => {
|
|
874
947
|
ee && a({ code: "UPDATE_ERROR", message: ee }, r.value);
|
|
875
948
|
}));
|
|
876
949
|
};
|
|
877
|
-
return { dragSourceProps: j, getDropTargetProps: b, BottomDropTarget:
|
|
878
|
-
},
|
|
879
|
-
var
|
|
950
|
+
return { dragSourceProps: j, getDropTargetProps: b, BottomDropTarget: D, DropTargetPadding: ({ position: N, nodeData: x }) => c === N ? l("div", { className: "jer-drag-n-drop-padding", style: g("dropZone", x) }) : null, handleDrop: C };
|
|
951
|
+
}, Sr = (t, e, n, r) => {
|
|
952
|
+
var i, a, o;
|
|
880
953
|
if (!e.current) return 0;
|
|
881
|
-
const g = parseInt((
|
|
954
|
+
const g = parseInt((i = getComputedStyle(n.current).getPropertyValue("line-height")) !== null && i !== void 0 ? i : "16px"), f = ((o = (a = e.current) === null || a === void 0 ? void 0 : a.offsetWidth) !== null && o !== void 0 ? o : 0) / (0.5 * g), s = r(t).replace(/\\n/g, `
|
|
882
955
|
`).split(`
|
|
883
|
-
`).map(((
|
|
956
|
+
`).map(((c) => Math.ceil(c.length / f))).reduce(((c, d) => c + d), 0) * g;
|
|
884
957
|
return Math.min(s + 30, window.innerHeight - 50);
|
|
885
|
-
}, yt = ({ isEditingKey: t, canEditKey: e, pathString: n, path: r, name:
|
|
886
|
-
const { setCurrentlyEditingElement: b } =
|
|
887
|
-
return t ?
|
|
888
|
-
if (g(
|
|
889
|
-
const N =
|
|
890
|
-
b(N ? [...r, N] :
|
|
958
|
+
}, yt = ({ isEditingKey: t, canEditKey: e, pathString: n, path: r, name: i, arrayIndexFromOne: a, handleKeyboard: o, handleEditKey: g, handleCancel: f, handleClick: s, keyValueArray: c, styles: d, getNextOrPrevious: m, emptyStringKey: j }) => {
|
|
959
|
+
const { setCurrentlyEditingElement: b } = Xe(), D = typeof i == "number" ? String(i + (a ? 1 : 0)) : i;
|
|
960
|
+
return t ? l("input", { className: "jer-input-text jer-key-edit", type: "text", name: n, defaultValue: D, autoFocus: !0, onFocus: (C) => C.target.select(), onKeyDown: (C) => o(C, { stringConfirm: () => g(C.target.value), cancel: f, tabForward: () => {
|
|
961
|
+
if (g(C.target.value), c) {
|
|
962
|
+
const N = c == null ? void 0 : c[0][0];
|
|
963
|
+
b(N ? [...r, N] : m("next"));
|
|
891
964
|
} else b(r);
|
|
892
965
|
}, tabBack: () => {
|
|
893
|
-
g(
|
|
894
|
-
} }), style: { width:
|
|
895
|
-
},
|
|
896
|
-
const { data: e, parentData: n, onEdit: r, onDelete:
|
|
897
|
-
if (!a) return void
|
|
898
|
-
const
|
|
899
|
-
|
|
966
|
+
g(C.target.value), b(m("prev"));
|
|
967
|
+
} }), style: { width: D.length / 1.5 + 0.5 + "em" } }) : $("span", { className: "jer-key-text", style: Object.assign(Object.assign({}, d), { minWidth: `${Math.min(D.length + 1, 5)}ch`, flexShrink: D.length > 10 ? 1 : 0 }), onDoubleClick: () => e && b(r, "key"), onClick: s, children: [j ? l("span", { className: "jer-empty-string", children: j }) : D, D !== "" || j ? l("span", { className: "jer-key-colon", children: ":" }) : null] });
|
|
968
|
+
}, bn = (t) => {
|
|
969
|
+
const { data: e, parentData: n, onEdit: r, onDelete: i, onChange: a, onMove: o, enableClipboard: g, canDragOnto: f, restrictTypeSelection: s, searchFilter: c, searchText: d, showLabel: m, stringTruncate: j, showStringQuotes: b, arrayIndexFromOne: D, indent: C, translate: N, customNodeDefinitions: x, customNodeData: _, handleKeyboard: W, keyboardControls: te, sort: G, editConfirmRef: X, jsonStringify: ee, showIconTooltips: U } = t, { getStyles: A } = Me(), { setCurrentlyEditingElement: R, setCollapseState: J, previouslyEditedElement: ne, setPreviouslyEditedElement: pe, tabDirection: ie, setTabDirection: fe, previousValue: le, setPreviousValue: Z } = Xe(), [q, p] = de(typeof e == "function" ? At : e), { pathString: h, nodeData: u, path: y, name: E, canEdit: T, canDelete: K, canDrag: I, error: he, onError: Y, handleEditKey: je, emptyStringKey: Te, derivedValues: re } = yn({ props: t }), { dragSourceProps: Ke, getDropTargetProps: Ve, BottomDropTarget: z, DropTargetPadding: ge } = vn({ canDrag: I, canDragOnto: f, path: y, nodeData: u, onMove: o, onError: Y, translate: N }), [Se, be] = de(Lt(e, _)), P = Fe(((v) => {
|
|
970
|
+
if (!a) return void p(v);
|
|
971
|
+
const S = a({ currentData: u.fullData, newValue: v, currentValue: q, name: E, path: y });
|
|
972
|
+
p(S);
|
|
900
973
|
}), [a]);
|
|
901
|
-
|
|
902
|
-
|
|
974
|
+
Pe((() => {
|
|
975
|
+
p(typeof e == "function" ? At : e), be(Lt(e, _));
|
|
903
976
|
}), [e, he]);
|
|
904
|
-
const { CustomNode: B, customNodeProps:
|
|
977
|
+
const { CustomNode: B, customNodeProps: oe, hideKey: ae, showEditTools: me = !0, showOnEdit: se, showOnView: Ce, passOriginalNode: Ne } = _, Ae = [...Cr, ...x.filter((({ showInTypesSelector: v = !1, name: S }) => v && !!S)).map((({ name: v }) => v))], ce = De((() => {
|
|
905
978
|
if (typeof s == "boolean") return s ? [] : Ae;
|
|
906
979
|
if (Array.isArray(s)) return s;
|
|
907
|
-
const v = s(
|
|
980
|
+
const v = s(u);
|
|
908
981
|
return typeof v == "boolean" ? v ? [] : Ae : v;
|
|
909
|
-
}), [
|
|
910
|
-
var
|
|
982
|
+
}), [u, s]), [Q, ze] = de(((v, S) => {
|
|
983
|
+
var F;
|
|
911
984
|
if (typeof v != "string") return null;
|
|
912
|
-
const Ee =
|
|
985
|
+
const Ee = S.filter(((ue) => ue instanceof Object && ue.enum && ue.values.includes(v) && ue.matchPriority));
|
|
913
986
|
return Ee.sort(((ue, ve) => {
|
|
914
|
-
var
|
|
915
|
-
return ((
|
|
916
|
-
})), (
|
|
917
|
-
})(
|
|
918
|
-
if (we && (!Ze || !
|
|
919
|
-
const v =
|
|
920
|
-
|
|
987
|
+
var $e, We;
|
|
988
|
+
return (($e = ve.matchPriority) !== null && $e !== void 0 ? $e : 0) - ((We = ue.matchPriority) !== null && We !== void 0 ? We : 0);
|
|
989
|
+
})), (F = Ee[0]) !== null && F !== void 0 ? F : null;
|
|
990
|
+
})(q, ce)), { isEditing: we } = re, Ze = un("value", u, c, d);
|
|
991
|
+
if (we && (!Ze || !T)) {
|
|
992
|
+
const v = Ye(u.fullData, y, ie, G);
|
|
993
|
+
R(v || ne);
|
|
921
994
|
}
|
|
922
995
|
if (!Ze) return null;
|
|
923
|
-
const
|
|
924
|
-
let
|
|
925
|
-
if (
|
|
996
|
+
const Re = (v) => {
|
|
997
|
+
let S;
|
|
998
|
+
if (R(null), Z(null), v === void 0 || ((F) => F && typeof F == "object" && "type" in F && "target" in F && "preventDefault" in F && typeof F.preventDefault == "function")(v)) switch (Se) {
|
|
926
999
|
case "object":
|
|
927
|
-
|
|
1000
|
+
S = { [N("DEFAULT_NEW_KEY", u)]: q };
|
|
928
1001
|
break;
|
|
929
1002
|
case "array":
|
|
930
|
-
|
|
1003
|
+
S = q ?? [];
|
|
931
1004
|
break;
|
|
932
1005
|
case "number": {
|
|
933
|
-
const
|
|
934
|
-
|
|
1006
|
+
const F = Number(q);
|
|
1007
|
+
S = isNaN(F) ? 0 : F;
|
|
935
1008
|
break;
|
|
936
1009
|
}
|
|
937
1010
|
default:
|
|
938
|
-
|
|
1011
|
+
S = q;
|
|
939
1012
|
}
|
|
940
|
-
else
|
|
941
|
-
r(
|
|
942
|
-
|
|
1013
|
+
else S = v;
|
|
1014
|
+
r(S, y).then(((F) => {
|
|
1015
|
+
F && Y({ code: "UPDATE_ERROR", message: F }, S);
|
|
943
1016
|
}));
|
|
944
|
-
},
|
|
945
|
-
|
|
946
|
-
}, { isEditingKey:
|
|
947
|
-
}, handleEdit:
|
|
948
|
-
fe("next"), pe(
|
|
949
|
-
const v =
|
|
950
|
-
v && (
|
|
1017
|
+
}, Le = () => {
|
|
1018
|
+
R(null), le === null ? (p(e), Z(null)) : r(le, y);
|
|
1019
|
+
}, { isEditingKey: qe, canEditKey: Qe } = re, ke = !we && he, ye = we && ce.length > 1, Be = (Se !== "invalid" || B) && !he && me, k = m && !ae, O = B && (we && se || !we && Ce), L = { value: q, parentData: n, setValue: P, isEditing: we, canEdit: T, setIsEditing: T ? () => R(y) : () => {
|
|
1020
|
+
}, handleEdit: Re, handleCancel: Le, path: y, stringTruncate: j, showStringQuotes: b, nodeData: u, enumType: Q, translate: N, handleKeyboard: W, keyboardCommon: { cancel: Le, tabForward: () => {
|
|
1021
|
+
fe("next"), pe(h);
|
|
1022
|
+
const v = Ye(u.fullData, y, "next", G);
|
|
1023
|
+
v && (Re(), R(v));
|
|
951
1024
|
}, tabBack: () => {
|
|
952
|
-
fe("prev"), pe(
|
|
953
|
-
const v =
|
|
954
|
-
v && (
|
|
955
|
-
} } },
|
|
956
|
-
return $("div", Object.assign({ className: "jer-component jer-value-component", style: { marginLeft: n !== null ?
|
|
957
|
-
Z(le),
|
|
958
|
-
} : void 0, handleDelete:
|
|
959
|
-
|
|
960
|
-
v &&
|
|
1025
|
+
fe("prev"), pe(h);
|
|
1026
|
+
const v = Ye(u.fullData, y, "prev", G);
|
|
1027
|
+
v && (Re(), R(v));
|
|
1028
|
+
} } }, V = { canEditKey: Qe, isEditingKey: qe, pathString: h, path: y, name: E, arrayIndexFromOne: D, handleKeyboard: W, handleEditKey: je, handleCancel: Le, styles: A("property", u), getNextOrPrevious: (v) => Ye(u.fullData, y, v, G), emptyStringKey: Te }, M = O ? l(B, Object.assign({}, t, { value: q, customNodeProps: oe, setValue: P, handleEdit: Re, handleCancel: Le, handleKeyPress: (v) => W(v, { stringConfirm: Re, cancel: Le }), isEditing: we, setIsEditing: () => R(y), getStyles: A, originalNode: Ne ? en(e, L) : void 0, originalNodeKey: Ne ? l(yt, Object.assign({}, V)) : void 0, canEdit: T, keyboardCommon: L.keyboardCommon, onError: Y })) : en(e, L);
|
|
1029
|
+
return $("div", Object.assign({ className: "jer-component jer-value-component", style: { marginLeft: n !== null ? C / 2 + "em" : 0, position: "relative" }, draggable: I }, Ke, Ve("above"), { children: [z, l(ge, { position: "above", nodeData: u }), $("div", { className: "jer-value-main-row", style: { flexWrap: E.length > 10 ? "wrap" : "nowrap" }, children: [k && l(yt, Object.assign({}, V)), $("div", { className: "jer-value-and-buttons", children: [l("div", { className: "jer-input-component", children: M }), we ? l(It, { onOk: Re, onCancel: Le, nodeData: u, editConfirmRef: X }) : Be && l(mn, { startEdit: T ? () => {
|
|
1030
|
+
Z(le), R(y, Le);
|
|
1031
|
+
} : void 0, handleDelete: K ? () => {
|
|
1032
|
+
i(q, y).then(((v) => {
|
|
1033
|
+
v && Y({ code: "DELETE_ERROR", message: v }, q);
|
|
961
1034
|
}));
|
|
962
|
-
} : void 0, enableClipboard: g, translate: N, customButtons: t.customButtons, nodeData:
|
|
963
|
-
const
|
|
964
|
-
if (
|
|
965
|
-
const Ee = ce.find(((ve) => ve instanceof Object && ve.enum ===
|
|
966
|
-
if (Ee) return typeof
|
|
967
|
-
ve && (
|
|
1035
|
+
} : void 0, enableClipboard: g, translate: N, customButtons: t.customButtons, nodeData: u, handleKeyboard: W, keyboardControls: te, editConfirmRef: X, jsonStringify: ee, showIconTooltips: U }), ye && $("div", { className: "jer-select jer-select-types", children: [l("select", { name: `${E}-type-select`, className: "jer-select-inner", onChange: (v) => ((S) => {
|
|
1036
|
+
const F = x.find(((ve) => ve.name === S));
|
|
1037
|
+
if (F) return r(F.defaultValue, y), be(S), ze(null), R(null), void J({ path: y, collapsed: !1, includeChildren: !1 });
|
|
1038
|
+
const Ee = ce.find(((ve) => ve instanceof Object && ve.enum === S));
|
|
1039
|
+
if (Ee) return typeof q == "string" && Ee.values.includes(q) || r(Ee.values[0], y).then(((ve) => {
|
|
1040
|
+
ve && (Y({ code: "UPDATE_ERROR", message: ve }, ue), R(null));
|
|
968
1041
|
})), void ze(Ee);
|
|
969
|
-
const ue =
|
|
970
|
-
["string", "number", "boolean"].includes(
|
|
971
|
-
ve ? (
|
|
1042
|
+
const ue = kr(q, S, N("DEFAULT_NEW_KEY", u), _ != null && _.CustomNode ? N("DEFAULT_STRING", u) : void 0);
|
|
1043
|
+
["string", "number", "boolean"].includes(S) || R(null), r(ue, y).then(((ve) => {
|
|
1044
|
+
ve ? (Y({ code: "UPDATE_ERROR", message: ve }, ue), R(null)) : ze(null);
|
|
972
1045
|
}));
|
|
973
|
-
})(v.target.value), value:
|
|
974
|
-
},
|
|
975
|
-
const n =
|
|
1046
|
+
})(v.target.value), value: Q ? Q.enum : Se, children: ce.map(((v) => v instanceof Object && "enum" in v ? l("option", { value: v.enum, children: v.enum }, v.enum) : l("option", { value: v, children: v }, v))) }), l("span", { className: "focus" })] }), ke && l("span", { className: "jer-error-slug", style: A("error", u), children: he })] })] }), l(ge, { position: "below", nodeData: u })] }));
|
|
1047
|
+
}, Lt = (t, e) => e != null && e.CustomNode && (e != null && e.name) && e.showInTypesSelector ? e.name : typeof t == "string" ? "string" : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null ? "null" : "invalid", en = (t, e) => {
|
|
1048
|
+
const n = Lt(t), { value: r } = e;
|
|
976
1049
|
switch (n) {
|
|
977
1050
|
case "string":
|
|
978
|
-
return
|
|
1051
|
+
return l(dr, Object.assign({}, e, { value: r }));
|
|
979
1052
|
case "number":
|
|
980
|
-
return
|
|
1053
|
+
return l(hr, Object.assign({}, e, { value: r }));
|
|
981
1054
|
case "boolean":
|
|
982
|
-
return
|
|
1055
|
+
return l(pr, Object.assign({}, e, { value: r }));
|
|
983
1056
|
case "null":
|
|
984
|
-
return
|
|
1057
|
+
return l(gr, Object.assign({}, e));
|
|
985
1058
|
default:
|
|
986
|
-
return
|
|
1059
|
+
return l(mr, Object.assign({}, e));
|
|
987
1060
|
}
|
|
988
|
-
},
|
|
1061
|
+
}, kr = (t, e, n, r) => {
|
|
989
1062
|
switch (e) {
|
|
990
1063
|
case "string":
|
|
991
1064
|
return r ?? String(t);
|
|
992
1065
|
case "number": {
|
|
993
|
-
const
|
|
994
|
-
return isNaN(
|
|
1066
|
+
const i = Number(t);
|
|
1067
|
+
return isNaN(i) ? 0 : i;
|
|
995
1068
|
}
|
|
996
1069
|
case "boolean":
|
|
997
1070
|
return !!t;
|
|
@@ -1004,250 +1077,259 @@ const an = ({ className: t, name: e, value: n, setValue: r, handleKeyPress: o, s
|
|
|
1004
1077
|
default:
|
|
1005
1078
|
return String(t);
|
|
1006
1079
|
}
|
|
1007
|
-
},
|
|
1080
|
+
}, En = (t = [], e) => {
|
|
1008
1081
|
const n = t.filter((({ condition: b }) => b(e)));
|
|
1009
1082
|
if (n.length === 0) return {};
|
|
1010
|
-
const r = n[0], { element:
|
|
1011
|
-
return Object.assign({ CustomNode:
|
|
1012
|
-
},
|
|
1013
|
-
const { getStyles: e } =
|
|
1014
|
-
const [
|
|
1083
|
+
const r = n[0], { element: i, wrapperElement: a, customNodeProps: o, wrapperProps: g, hideKey: f = !1, showEditTools: s = !0, showOnEdit: c = !1, showOnView: d = !0, showCollectionWrapper: m = !0 } = r, j = ln(r, ["element", "wrapperElement", "customNodeProps", "wrapperProps", "hideKey", "showEditTools", "showOnEdit", "showOnView", "showCollectionWrapper"]);
|
|
1084
|
+
return Object.assign({ CustomNode: i, CustomWrapper: a, customNodeProps: o, wrapperProps: g, hideKey: f, showEditTools: s, showOnEdit: c, showOnView: d, showCollectionWrapper: m }, j);
|
|
1085
|
+
}, jn = (t) => {
|
|
1086
|
+
const { getStyles: e } = Me(), { collapseState: n, setCollapseState: r, getMatchingCollapseState: i, currentlyEditingElement: a, setCurrentlyEditingElement: o, areChildrenBeingEdited: g, previousValue: f, setPreviousValue: s } = Xe(), { mainContainerRef: c, data: d, nodeData: m, parentData: j, showCollectionCount: b, onEdit: D, onAdd: C, onDelete: N, canDragOnto: x, collapseFilter: _, collapseAnimationTime: W, onMove: te, enableClipboard: G, onEditEvent: X, showIconTooltips: ee, searchFilter: U, searchText: A, indent: R, sort: J, showArrayIndices: ne, arrayIndexFromOne: pe, defaultValue: ie, newKeyOptions: fe, translate: le, customNodeDefinitions: Z, customNodeData: q, jsonParse: p, jsonStringify: h, TextEditor: u, keyboardControls: y, handleKeyboard: E, insertAtTop: T, onCollapse: K, editConfirmRef: I, collapseClickZones: he } = t, [Y, je] = de(h(d)), Te = _(m), { contentRef: re, isAnimating: Ke, maxHeight: Ve, collapsed: z, animateCollapse: ge, cssTransitionValue: Se } = ((w, H, _e, xe, Ie) => {
|
|
1087
|
+
const [Nn, ft] = de(_e ? 0 : void 0), [gt, An] = de(_e), Dt = Oe(!1), Ot = Oe(null), Wt = Oe(0), Ht = Oe(0), Ln = H / 1e3 + "s", _n = Fe(((Ct) => {
|
|
1015
1088
|
var St, kt;
|
|
1016
|
-
if (gt !==
|
|
1017
|
-
switch (window.clearTimeout(
|
|
1089
|
+
if (gt !== Ct) {
|
|
1090
|
+
switch (window.clearTimeout(Ht.current), Dt.current = !0, Ct) {
|
|
1018
1091
|
case !0: {
|
|
1019
|
-
const
|
|
1020
|
-
Wt.current =
|
|
1092
|
+
const Ut = (kt = (St = Ot.current) === null || St === void 0 ? void 0 : St.offsetHeight) !== null && kt !== void 0 ? kt : 0;
|
|
1093
|
+
Wt.current = Ut, ft(Ut), setTimeout((() => {
|
|
1021
1094
|
ft(0);
|
|
1022
1095
|
}), 5);
|
|
1023
1096
|
break;
|
|
1024
1097
|
}
|
|
1025
1098
|
case !1:
|
|
1026
|
-
ft(Wt.current ||
|
|
1099
|
+
ft(Wt.current || Sr(w, Ot, xe, Ie));
|
|
1027
1100
|
}
|
|
1028
|
-
|
|
1029
|
-
Dt.current = !1,
|
|
1030
|
-
}),
|
|
1101
|
+
An(!gt), Ht.current = window.setTimeout((() => {
|
|
1102
|
+
Dt.current = !1, Ct || ft(void 0);
|
|
1103
|
+
}), H);
|
|
1031
1104
|
}
|
|
1032
|
-
}), [
|
|
1033
|
-
return { contentRef:
|
|
1034
|
-
})(
|
|
1035
|
-
|
|
1036
|
-
je(d
|
|
1037
|
-
}), [
|
|
1038
|
-
const
|
|
1039
|
-
ke.current = !
|
|
1040
|
-
}), [
|
|
1105
|
+
}), [H, gt, w, xe, Ie]);
|
|
1106
|
+
return { contentRef: Ot, isAnimating: Dt.current, animateCollapse: _n, maxHeight: Nn, collapsed: gt, cssTransitionValue: Ln };
|
|
1107
|
+
})(d, W, Te, c, h), { pathString: be, nodeData: P, path: B, name: oe, size: ae, canEdit: me, canDelete: se, canAdd: Ce, canDrag: Ne, error: Ae, setError: ce, onError: Q, handleEditKey: ze, emptyStringKey: we, derivedValues: Ze } = yn({ props: t, collapsed: z }), { dragSourceProps: Re, getDropTargetProps: Le, BottomDropTarget: qe, DropTargetPadding: Qe } = vn({ canDrag: Ne, canDragOnto: x, path: B, nodeData: P, onMove: te, onError: Q, translate: le }), ke = Oe(!Te), { isEditing: ye, isEditingKey: Be, isArray: k, canEditKey: O } = Ze;
|
|
1108
|
+
Pe((() => {
|
|
1109
|
+
je(h(d));
|
|
1110
|
+
}), [d, h]), Pe((() => {
|
|
1111
|
+
const w = _(P) && !ye;
|
|
1112
|
+
ke.current = !w, ge(w);
|
|
1113
|
+
}), [_]), Pe((() => {
|
|
1041
1114
|
if (n !== null) {
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1115
|
+
const w = i(B);
|
|
1116
|
+
w && (ke.current = !0, ge(w.collapsed));
|
|
1044
1117
|
}
|
|
1045
1118
|
}), [n]);
|
|
1046
|
-
const
|
|
1047
|
-
if (typeof
|
|
1048
|
-
const
|
|
1049
|
-
return
|
|
1050
|
-
}), [
|
|
1051
|
-
if (dt && z && ge(!1), !(
|
|
1052
|
-
const et = Array.isArray(
|
|
1053
|
-
if (
|
|
1119
|
+
const L = Oe(null), V = Fe(((w, H) => {
|
|
1120
|
+
if (typeof ie != "function") return ie;
|
|
1121
|
+
const _e = ie(w, H);
|
|
1122
|
+
return _e !== void 0 ? _e : null;
|
|
1123
|
+
}), [ie]), M = Fe(((w) => fe ? typeof fe != "function" ? fe : fe(w) : null), [fe]), { CustomNode: v, customNodeProps: S, CustomWrapper: F, wrapperProps: Ee = {}, hideKey: ue, showEditTools: ve = !0, showOnEdit: $e, showOnView: We, showCollectionWrapper: bt = !0 } = q, dt = g(be);
|
|
1124
|
+
if (dt && z && ge(!1), !(un("collection", P, U, A) || P.level === 0) && !dt) return null;
|
|
1125
|
+
const et = Array.isArray(d) ? "array" : "object", Et = et === "array" ? { open: "[", close: "]" } : { open: "{", close: "}" }, Mt = (w) => {
|
|
1126
|
+
if (w.key !== "Tab" || w.getModifierState("Shift")) E(w, { objectConfirm: pt, cancel: ot });
|
|
1054
1127
|
else {
|
|
1055
|
-
|
|
1056
|
-
const
|
|
1057
|
-
je(
|
|
1128
|
+
w.preventDefault();
|
|
1129
|
+
const H = hn(L, " ");
|
|
1130
|
+
je(H);
|
|
1058
1131
|
}
|
|
1059
|
-
}, ht = (
|
|
1060
|
-
|
|
1061
|
-
const
|
|
1062
|
-
if (
|
|
1063
|
-
a && a.includes(be) || (ke.current = !0, r(null),
|
|
1132
|
+
}, ht = (w) => {
|
|
1133
|
+
w.stopPropagation();
|
|
1134
|
+
const H = Pt(w);
|
|
1135
|
+
if (H && y.collapseModifier.includes(H)) return ke.current = !0, void r({ collapsed: !z, path: B, includeChildren: !0 });
|
|
1136
|
+
a && a.includes(be) || (ke.current = !0, r(null), K && K({ path: B, collapsed: !z, includeChildren: !1 }), ge(!z));
|
|
1064
1137
|
}, pt = () => {
|
|
1065
1138
|
try {
|
|
1066
|
-
const
|
|
1067
|
-
if (
|
|
1068
|
-
w
|
|
1069
|
-
|
|
1139
|
+
const w = p(Y);
|
|
1140
|
+
if (o(null), s(null), ce(null), h(w) === h(d)) return;
|
|
1141
|
+
D(w, B).then(((H) => {
|
|
1142
|
+
H && Q({ code: "UPDATE_ERROR", message: H }, w);
|
|
1070
1143
|
}));
|
|
1071
1144
|
} catch {
|
|
1072
|
-
|
|
1145
|
+
Q({ code: "INVALID_JSON", message: le("ERROR_INVALID_JSON", P) }, Y);
|
|
1073
1146
|
}
|
|
1074
|
-
},
|
|
1075
|
-
N(
|
|
1076
|
-
|
|
1147
|
+
}, Cn = B.length > 0 ? () => {
|
|
1148
|
+
N(d, B).then(((w) => {
|
|
1149
|
+
w && Q({ code: "DELETE_ERROR", message: w }, d);
|
|
1077
1150
|
}));
|
|
1078
|
-
} : void 0,
|
|
1079
|
-
|
|
1080
|
-
}, Vt = b === "when-closed" ? z : b,
|
|
1081
|
-
et === "object" &&
|
|
1082
|
-
const Ft = ke.current ? ye ? $("div", { className: "jer-collection-text-edit", children: [
|
|
1083
|
-
const xe = { key:
|
|
1084
|
-
return
|
|
1151
|
+
} : void 0, ot = () => {
|
|
1152
|
+
o(null), f === null ? (ce(null), je(h(d)), s(null)) : D(f, B);
|
|
1153
|
+
}, Vt = b === "when-closed" ? z : b, Sn = !ye && ve, kn = (ne || !k) && !ue && oe !== void 0, xn = v && (ye && $e || !ye && We), jt = Object.entries(d).map((([w, H]) => [et === "array" ? Number(w) : w, H]));
|
|
1154
|
+
et === "object" && J(jt, ((w) => w));
|
|
1155
|
+
const Ft = ke.current ? ye ? $("div", { className: "jer-collection-text-edit", children: [u ? l(u, { value: Y, onChange: je, onKeyDown: (w) => E(w, { objectConfirm: pt, cancel: ot }) }) : l(cn, { textAreaRef: L, className: "jer-collection-text-area", name: be, value: Y, setValue: je, handleKeyPress: Mt, styles: e("input", P) }), l("div", { className: "jer-collection-input-button-row", children: l(It, { onOk: pt, onCancel: ot, nodeData: P, editConfirmRef: I }) })] }) : jt.map((([w, H], _e) => {
|
|
1156
|
+
const xe = { key: w, value: H, path: [...B, w], level: B.length + 1, index: _e, size: rt(H) ? Object.keys(H).length : null, parentData: d, fullData: P.fullData }, Ie = En(Z, xe);
|
|
1157
|
+
return l("div", { className: "jer-collection-element", style: e("collectionElement", xe), children: rt(H) && !(Ie != null && Ie.renderCollectionAsValue) ? l(jn, Object.assign({}, t, { data: H, parentData: d, nodeData: xe, showCollectionCount: b, canDragOnto: me, customNodeData: Ie }), w) : l(bn, Object.assign({}, t, { data: H, parentData: d, nodeData: xe, canDragOnto: me, showLabel: et === "object" || ne, customNodeData: Ie }), w) }, w);
|
|
1085
1158
|
})) : null, wt = !!bt && z && !dt;
|
|
1086
1159
|
wt || (ke.current = !0);
|
|
1087
|
-
const Kt = Object.assign(Object.assign({}, t), { data:
|
|
1088
|
-
return yield w
|
|
1089
|
-
})), handleEdit: pt, handleCancel:
|
|
1090
|
-
ke.current = !0, s(null),
|
|
1091
|
-
} : void 0, handleAdd:
|
|
1160
|
+
const Kt = Object.assign(Object.assign({}, t), { data: d, value: d, parentData: j, nodeData: P, setValue: (w) => tt(void 0, void 0, void 0, (function* () {
|
|
1161
|
+
return yield D(w, B);
|
|
1162
|
+
})), handleEdit: pt, handleCancel: ot, handleKeyPress: Mt, isEditing: ye, setIsEditing: () => o(B), getStyles: e, canDragOnto: me, canEdit: me, keyboardCommon: {}, onError: Q }), Tn = xn ? l(v, Object.assign({ customNodeProps: S }, Kt, { children: Ft })) : Ft, zt = Sn && l(mn, { startEdit: me ? () => {
|
|
1163
|
+
ke.current = !0, s(null), o(B);
|
|
1164
|
+
} : void 0, handleAdd: Ce ? (w) => {
|
|
1092
1165
|
ge(!1);
|
|
1093
|
-
const
|
|
1166
|
+
const H = V(P, w);
|
|
1094
1167
|
if (et === "array") {
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
|
|
1168
|
+
const _e = T.array ? 0 : d.length, xe = T.array ? { insert: !0 } : {};
|
|
1169
|
+
C(H, [...B, _e], xe).then(((Ie) => {
|
|
1170
|
+
Ie && Q({ code: "ADD_ERROR", message: Ie }, H);
|
|
1098
1171
|
}));
|
|
1099
|
-
} else if (
|
|
1172
|
+
} else if (w in d) Q({ code: "KEY_EXISTS", message: le("ERROR_KEY_EXISTS", P) }, w);
|
|
1100
1173
|
else {
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
xe &&
|
|
1174
|
+
const _e = T.object ? { insertBefore: 0 } : {};
|
|
1175
|
+
C(H, [...B, w], _e).then(((xe) => {
|
|
1176
|
+
xe && Q({ code: "ADD_ERROR", message: xe }, H);
|
|
1104
1177
|
}));
|
|
1105
1178
|
}
|
|
1106
|
-
} : void 0, handleDelete: se ?
|
|
1107
|
-
return
|
|
1108
|
-
},
|
|
1109
|
-
if (
|
|
1110
|
-
const
|
|
1111
|
-
if (
|
|
1179
|
+
} : void 0, handleDelete: se ? Cn : void 0, enableClipboard: G, type: et, nodeData: P, translate: le, customButtons: t.customButtons, keyboardControls: y, handleKeyboard: E, getNewKeyOptions: M, editConfirmRef: I, jsonStringify: h, onEditEvent: X, showIconTooltips: ee }), Bt = { canEditKey: O, isEditingKey: Be, pathString: be, path: B, name: oe, arrayIndexFromOne: pe, handleKeyboard: E, handleEditKey: ze, handleCancel: ot, keyValueArray: jt, styles: e("property", P), getNextOrPrevious: (w) => Ye(P.fullData, B, w, J), handleClick: he.includes("property") ? ht : (w) => w.stopPropagation(), emptyStringKey: we }, $t = $("div", Object.assign({ className: "jer-component jer-collection-component", style: Object.assign(Object.assign({ marginLeft: (B.length === 0 ? 0 : R / 2) + "em" }, e("collection", P)), { position: "relative" }), draggable: Ne }, Re, Le("above"), { children: [l("div", { className: "jer-clickzone", style: { width: R / 2 + 1 + "em", zIndex: 10 + 2 * P.level }, onClick: he.includes("left") ? ht : void 0 }), !ye && qe, l(Qe, { position: "above", nodeData: P }), bt ? $("div", { className: "jer-collection-header-row", style: { position: "relative" }, onClick: he.includes("header") ? ht : void 0, children: [$("div", { className: "jer-collection-name", children: [l("div", { className: "jer-collapse-icon jer-accordion-icon" + (z ? " jer-rotate-90" : ""), style: { zIndex: 11 + 2 * P.level, transition: Se }, onClick: ht, children: l(Ge, { name: "chevron", rotate: z, nodeData: P }) }), kn && l(yt, Object.assign({}, Bt)), !ye && l("span", { className: "jer-brackets jer-bracket-open", style: e("bracket", P), children: Et.open })] }), !ye && Vt && l("div", { className: "jer-collection-item-count" + (Vt ? " jer-visible" : " jer-hidden"), style: Object.assign(Object.assign({}, e("itemCount", P)), { transition: Se }), children: ae === 1 ? le("ITEM_SINGLE", Object.assign(Object.assign({}, P), { size: 1 }), 1) : le("ITEMS_MULTIPLE", P, ae) }), l("div", { className: "jer-brackets" + (wt ? " jer-visible" : " jer-hidden"), style: Object.assign(Object.assign({}, e("bracket", P)), { transition: Se }), children: Et.close }), zt] }) : ue ? l(vt, {}) : $("div", { className: "jer-collection-header-row", style: { position: "relative" }, children: [l(yt, Object.assign({}, Bt)), zt] }), $("div", { className: "jer-collection-inner", style: Object.assign(Object.assign({ overflowY: wt || Ke ? "clip" : "visible", maxHeight: dt ? void 0 : Ve }, e("collectionInner", P)), { transition: Se }), ref: re, children: [Tn, l("div", { className: ye ? "jer-collection-error-row" : "jer-collection-error-row-edit", children: Ae && l("span", { className: "jer-error-slug", style: e("error", P), children: Ae }) }), !ye && bt && l("div", { className: "jer-brackets jer-bracket-outside", style: Object.assign(Object.assign({}, e("bracket", P)), { marginLeft: (R < 3 ? -1 : R < 6 ? -0.5 : 0) + "em" }), children: Et.close })] }), l(Qe, { position: "below", nodeData: P })] }));
|
|
1180
|
+
return F ? l(F, Object.assign({ customNodeProps: Ee }, Kt, { children: $t })) : $t;
|
|
1181
|
+
}, xr = { 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 = (t, e) => (n, r, i) => ((a, o, g, f, s) => {
|
|
1182
|
+
if (o[f]) {
|
|
1183
|
+
const d = o[f](g);
|
|
1184
|
+
if (d !== null) return d;
|
|
1112
1185
|
}
|
|
1113
|
-
const
|
|
1114
|
-
return s === void 0 ?
|
|
1115
|
-
})(t, e, r, n,
|
|
1116
|
-
var
|
|
1186
|
+
const c = f in a ? a[f] : xr[f];
|
|
1187
|
+
return s === void 0 ? c : c == null ? void 0 : c.replace("{{count}}", String(s));
|
|
1188
|
+
})(t, e, r, n, i);
|
|
1189
|
+
var tn = [], at = [];
|
|
1117
1190
|
(function(t, e) {
|
|
1118
1191
|
if (t && typeof document < "u") {
|
|
1119
|
-
var n, r = e.prepend === !0 ? "prepend" : "append",
|
|
1120
|
-
if (
|
|
1121
|
-
var
|
|
1122
|
-
|
|
1192
|
+
var n, r = e.prepend === !0 ? "prepend" : "append", i = e.singleTag === !0, a = typeof e.container == "string" ? document.querySelector(e.container) : document.getElementsByTagName("head")[0];
|
|
1193
|
+
if (i) {
|
|
1194
|
+
var o = tn.indexOf(a);
|
|
1195
|
+
o === -1 && (o = tn.push(a) - 1, at[o] = {}), n = at[o] && at[o][r] ? at[o][r] : at[o][r] = g();
|
|
1123
1196
|
} else n = g();
|
|
1124
1197
|
t.charCodeAt(0) === 65279 && (t = t.substring(1)), n.styleSheet ? n.styleSheet.cssText += t : n.appendChild(document.createTextNode(t));
|
|
1125
1198
|
}
|
|
1126
1199
|
function g() {
|
|
1127
|
-
var
|
|
1128
|
-
if (
|
|
1129
|
-
var
|
|
1130
|
-
return a.insertAdjacentElement(
|
|
1200
|
+
var f = document.createElement("style");
|
|
1201
|
+
if (f.setAttribute("type", "text/css"), e.attributes) for (var s = Object.keys(e.attributes), c = 0; c < s.length; c++) f.setAttribute(s[c], e.attributes[s[c]]);
|
|
1202
|
+
var d = r === "prepend" ? "afterbegin" : "beforeend";
|
|
1203
|
+
return a.insertAdjacentElement(d, f), f;
|
|
1131
1204
|
}
|
|
1132
1205
|
})(':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}', {});
|
|
1133
|
-
const
|
|
1134
|
-
}, onEdit:
|
|
1135
|
-
const { getStyles: z } =
|
|
1136
|
-
const [
|
|
1137
|
-
|
|
1138
|
-
}), [
|
|
1139
|
-
return
|
|
1140
|
-
|
|
1141
|
-
}), [
|
|
1142
|
-
})({ setData: e, data: t }), me =
|
|
1143
|
-
|
|
1206
|
+
const Nr = ({ data: t, setData: e, rootName: n = "root", onUpdate: r = () => {
|
|
1207
|
+
}, onEdit: i = r, onDelete: a = r, onAdd: o = r, onChange: g, onError: f, onEditEvent: s, showErrorMessages: c = !0, enableClipboard: d = !0, indent: m = 2, collapse: j = !1, collapseAnimationTime: b = 300, showCollectionCount: D = !0, restrictEdit: C = !1, restrictDelete: N = !1, restrictAdd: x = !1, restrictTypeSelection: _ = !1, restrictDrag: W = !0, viewOnly: te, searchFilter: G, searchText: X, searchDebounceTime: ee = 350, keySort: U = !1, showArrayIndices: A = !0, arrayIndexFromOne: R = !1, showStringQuotes: J = !0, showIconTooltips: ne = !1, defaultValue: pe = null, newKeyOptions: ie, minWidth: fe = 250, maxWidth: le = "min(600px, 90vw)", rootFontSize: Z, stringTruncate: q = 250, translations: p = {}, className: h, id: u, customText: y = {}, customNodeDefinitions: E = [], customButtons: T = [], jsonParse: K = JSON.parse, jsonStringify: I = (z, ge) => JSON.stringify(z, ge, 2), TextEditor: he, errorMessageTimeout: Y = 2500, keyboardControls: je = {}, externalTriggers: Te, insertAtTop: re = !1, onCollapse: Ke, collapseClickZones: Ve = ["header", "left"] }) => {
|
|
1208
|
+
const { getStyles: z } = Me(), { setCurrentlyEditingElement: ge } = Xe(), Se = De((() => lt(j)), [j]), be = De((() => Tr(p, y)), [p, y]), [P, B] = de(X), [oe, ae] = (({ setData: k, data: O }) => {
|
|
1209
|
+
const [L, V] = de(k ? void 0 : O), M = Fe(((v) => {
|
|
1210
|
+
k ? k(v) : V(v);
|
|
1211
|
+
}), [k]);
|
|
1212
|
+
return Pe((() => {
|
|
1213
|
+
k || V(O);
|
|
1214
|
+
}), [O]), [k ? O : L, M];
|
|
1215
|
+
})({ setData: e, data: t }), me = Oe(null);
|
|
1216
|
+
Pe((() => {
|
|
1144
1217
|
ge(null);
|
|
1145
|
-
const
|
|
1146
|
-
return () => clearTimeout(
|
|
1147
|
-
}), [
|
|
1148
|
-
const se = { key: n, path: [], level: 0, index: 0, value:
|
|
1149
|
-
const
|
|
1150
|
-
if (
|
|
1151
|
-
const
|
|
1152
|
-
if (
|
|
1218
|
+
const k = setTimeout((() => B(X)), ee);
|
|
1219
|
+
return () => clearTimeout(k);
|
|
1220
|
+
}), [X, ee]);
|
|
1221
|
+
const se = { key: n, path: [], level: 0, index: 0, value: oe, size: typeof oe == "object" && oe !== null ? Object.keys(oe).length : 1, parentData: null, fullData: oe }, Ce = (k, O) => tt(void 0, void 0, void 0, (function* () {
|
|
1222
|
+
const L = yield k(O);
|
|
1223
|
+
if (L === !0 || L === void 0) return void ae(O.newData);
|
|
1224
|
+
const V = _r(L) ? L : ["error", L], [M, v] = V;
|
|
1225
|
+
if (M === "error") return ae(O.currentData), v === !1 ? be("ERROR_UPDATE", se) : String(v);
|
|
1153
1226
|
ae(v);
|
|
1154
|
-
})), Ne = De((() => lt(
|
|
1155
|
-
const
|
|
1156
|
-
for (const
|
|
1157
|
-
const
|
|
1158
|
-
if (
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1161
|
-
!S
|
|
1227
|
+
})), Ne = De((() => lt(C, te)), [C, te]), Ae = De((() => lt(N, te)), [N, te]), ce = De((() => lt(x, te)), [x, te]), Q = De((() => lt(W, te)), [W, te]), ze = De((() => Lr(G)), [G]), we = De((() => ((k) => {
|
|
1228
|
+
const O = Object.assign({}, qt);
|
|
1229
|
+
for (const L of Object.keys(qt)) {
|
|
1230
|
+
const V = L;
|
|
1231
|
+
if (k[V]) {
|
|
1232
|
+
const M = k[V], v = ["clipboardModifier", "collapseModifier"].includes(L) ? Array.isArray(M) ? M : [M] : typeof M == "string" ? { key: M } : M;
|
|
1233
|
+
O[V] = v, ["stringConfirm", "numberConfirm", "booleanConfirm"].forEach(((S) => {
|
|
1234
|
+
!k[S] && k.confirm && (O[S] = O.confirm);
|
|
1162
1235
|
}));
|
|
1163
1236
|
}
|
|
1164
1237
|
}
|
|
1165
|
-
return
|
|
1166
|
-
})(je)), [je]), Ze =
|
|
1167
|
-
const v = Object.entries(
|
|
1168
|
-
for (const [
|
|
1169
|
-
|
|
1238
|
+
return O;
|
|
1239
|
+
})(je)), [je]), Ze = Fe(((k, O) => ((L, V, M) => {
|
|
1240
|
+
const v = Object.entries(V);
|
|
1241
|
+
for (const [S, F] of v) if (nr(M, L[S], S)) {
|
|
1242
|
+
M.preventDefault(), F();
|
|
1170
1243
|
break;
|
|
1171
1244
|
}
|
|
1172
|
-
})(we,
|
|
1173
|
-
const
|
|
1174
|
-
return (
|
|
1175
|
-
}), [E,
|
|
1176
|
-
const
|
|
1177
|
-
return (
|
|
1178
|
-
const
|
|
1179
|
-
return Nt(
|
|
1245
|
+
})(we, O, k)), [we]), Re = De((() => {
|
|
1246
|
+
const k = nn(E, "stringifyReplacer");
|
|
1247
|
+
return (O) => I(O, k);
|
|
1248
|
+
}), [E, I]), Le = De((() => {
|
|
1249
|
+
const k = nn(E, "parseReviver");
|
|
1250
|
+
return (O) => {
|
|
1251
|
+
const L = K(O, k);
|
|
1252
|
+
return Nt(L);
|
|
1180
1253
|
};
|
|
1181
|
-
}), [E,
|
|
1182
|
-
((
|
|
1183
|
-
const { setCurrentlyEditingElement:
|
|
1184
|
-
|
|
1185
|
-
if (!
|
|
1186
|
-
const { collapse: v, edit:
|
|
1187
|
-
v &&
|
|
1188
|
-
const
|
|
1189
|
-
switch (
|
|
1254
|
+
}), [E, K]), qe = Oe(null);
|
|
1255
|
+
((k, O) => {
|
|
1256
|
+
const { setCurrentlyEditingElement: L, currentlyEditingElement: V, setCollapseState: M } = Xe();
|
|
1257
|
+
Pe((() => {
|
|
1258
|
+
if (!k) return;
|
|
1259
|
+
const { collapse: v, edit: S } = k;
|
|
1260
|
+
v && M(v);
|
|
1261
|
+
const F = !(S != null && S.path) || Je(S.path) === V;
|
|
1262
|
+
switch (S == null ? void 0 : S.action) {
|
|
1190
1263
|
case "accept":
|
|
1191
|
-
|
|
1264
|
+
F && (O.current && O.current.click(), L(null));
|
|
1192
1265
|
break;
|
|
1193
1266
|
case "cancel":
|
|
1194
|
-
|
|
1267
|
+
F && L(null);
|
|
1195
1268
|
break;
|
|
1196
1269
|
default:
|
|
1197
|
-
|
|
1270
|
+
S != null && S.path && L(S.path);
|
|
1198
1271
|
}
|
|
1199
|
-
}), [
|
|
1200
|
-
})(Te,
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1203
|
-
const
|
|
1204
|
-
return
|
|
1205
|
-
})) :
|
|
1206
|
-
}), [
|
|
1207
|
-
const { currentData:
|
|
1208
|
-
if (
|
|
1209
|
-
})), onDelete: (
|
|
1210
|
-
const { currentData:
|
|
1211
|
-
return yield
|
|
1212
|
-
})), onAdd: (
|
|
1213
|
-
const { currentData:
|
|
1214
|
-
return yield
|
|
1215
|
-
})), onChange: g, onError:
|
|
1216
|
-
if (
|
|
1217
|
-
const { currentData:
|
|
1218
|
-
let ue = typeof Ee == "number" ?
|
|
1219
|
-
|
|
1220
|
-
const ve = typeof ue == "number" ? { insert: !0 } :
|
|
1221
|
-
return yield
|
|
1222
|
-
})), showCollectionCount:
|
|
1223
|
-
return Be.fontSize = Z ?? Be.fontSize,
|
|
1224
|
-
},
|
|
1272
|
+
}), [k]);
|
|
1273
|
+
})(Te, qe);
|
|
1274
|
+
const Qe = Fe(((k, O) => {
|
|
1275
|
+
U !== !1 && (typeof U != "function" ? k.sort(((L, V) => {
|
|
1276
|
+
const M = O(L)[0], v = O(V)[0];
|
|
1277
|
+
return M < v ? -1 : M > v ? 1 : 0;
|
|
1278
|
+
})) : k.sort(((L, V) => U(O(L), O(V)))));
|
|
1279
|
+
}), [U]), ke = En(E, se), ye = { mainContainerRef: me, name: n, nodeData: se, onEdit: (k, O) => tt(void 0, void 0, void 0, (function* () {
|
|
1280
|
+
const { currentData: L, newData: V, currentValue: M, newValue: v } = st(oe, O, k, "update");
|
|
1281
|
+
if (M !== v) return yield Ce(i, { currentData: L, newData: V, currentValue: M, newValue: v, name: O.slice(-1)[0], path: O });
|
|
1282
|
+
})), onDelete: (k, O) => tt(void 0, void 0, void 0, (function* () {
|
|
1283
|
+
const { currentData: L, newData: V, currentValue: M, newValue: v } = st(oe, O, k, "delete");
|
|
1284
|
+
return yield Ce(a, { currentData: L, newData: V, currentValue: M, newValue: v, name: O.slice(-1)[0], path: O });
|
|
1285
|
+
})), onAdd: (k, O, L) => tt(void 0, void 0, void 0, (function* () {
|
|
1286
|
+
const { currentData: V, newData: M, currentValue: v, newValue: S } = st(oe, O, k, "add", L);
|
|
1287
|
+
return yield Ce(o, { currentData: V, newData: M, currentValue: v, newValue: S, name: O.slice(-1)[0], path: O });
|
|
1288
|
+
})), onChange: g, onError: f, onEditEvent: s, showErrorMessages: c, onMove: (k, O, L) => tt(void 0, void 0, void 0, (function* () {
|
|
1289
|
+
if (k === null) return;
|
|
1290
|
+
const { currentData: V, newData: M, currentValue: v } = st(oe, k, "", "delete"), S = k.slice(-1)[0], F = O.slice(0, -1), Ee = O.slice(-1)[0];
|
|
1291
|
+
let ue = typeof Ee == "number" ? L === "above" ? Ee : Ee + 1 : typeof S == "number" ? `arr_${S}` : S;
|
|
1292
|
+
k.slice(0, -1).join(".") === O.slice(0, -1).join(".") && typeof S == "number" && typeof ue == "number" && S < ue && (ue -= 1);
|
|
1293
|
+
const ve = typeof ue == "number" ? { insert: !0 } : L === "above" ? { insertBefore: Ee } : { insertAfter: Ee }, { newData: $e, newValue: We } = st(M, [...F, ue], v, "add", ve);
|
|
1294
|
+
return yield Ce(i, { currentData: V, newData: $e, currentValue: v, newValue: We, name: O.slice(-1)[0], path: O });
|
|
1295
|
+
})), showCollectionCount: D, collapseFilter: Se, collapseAnimationTime: b, restrictEditFilter: Ne, restrictDeleteFilter: Ae, restrictAddFilter: ce, restrictTypeSelection: _, restrictDragFilter: Q, canDragOnto: !1, searchFilter: ze, searchText: P, enableClipboard: d, keySort: U, sort: Qe, showArrayIndices: A, arrayIndexFromOne: R, showStringQuotes: J, showIconTooltips: ne, indent: m, defaultValue: pe, newKeyOptions: ie, stringTruncate: q, translate: be, customNodeDefinitions: E, customNodeData: ke, customButtons: T, parentData: null, jsonParse: Le, jsonStringify: Re, TextEditor: he, errorMessageTimeout: Y, handleKeyboard: Ze, keyboardControls: we, insertAtTop: { object: re === !0 || re === "object", array: re === !0 || re === "array" }, onCollapse: Ke, editConfirmRef: qe, collapseClickZones: Ve }, Be = Object.assign(Object.assign({}, z("container", se)), { minWidth: fe, maxWidth: le });
|
|
1296
|
+
return Be.fontSize = Z ?? Be.fontSize, l("div", { id: u, ref: me, className: `jer-editor-container ${h ?? ""}`, style: Be, children: rt(oe) && !ke.renderCollectionAsValue ? l(jn, Object.assign({ data: oe }, ye)) : l(bn, Object.assign({ data: oe, showLabel: !0 }, ye)) });
|
|
1297
|
+
}, Ar = (t) => {
|
|
1225
1298
|
var e;
|
|
1226
1299
|
const [n, r] = de();
|
|
1227
|
-
return
|
|
1228
|
-
const
|
|
1229
|
-
r(
|
|
1230
|
-
}), []), n ?
|
|
1231
|
-
}, st = (t, e, n, r,
|
|
1300
|
+
return Pe((() => {
|
|
1301
|
+
const i = document.documentElement;
|
|
1302
|
+
r(i);
|
|
1303
|
+
}), []), n ? l(ir, { theme: (e = t.theme) !== null && e !== void 0 ? e : Rt, icons: t.icons, docRoot: n, children: l(lr, { onEditEvent: t.onEditEvent, onCollapse: t.onCollapse, children: l(Nr, Object.assign({}, t)) }) }) : null;
|
|
1304
|
+
}, st = (t, e, n, r, i = {}) => {
|
|
1232
1305
|
if (e.length === 0) return { currentData: t, newData: n, currentValue: t, newValue: n };
|
|
1233
|
-
const a = Object.assign({ remove: r === "delete" },
|
|
1234
|
-
return { currentData: t, newData:
|
|
1235
|
-
}, lt = (t, e) => e ? () => !0 : typeof t == "boolean" ? () => t : typeof t == "number" ? ({ level: n }) => n >= t : t,
|
|
1236
|
-
if (t !== void 0) return t === "value" ?
|
|
1237
|
-
},
|
|
1238
|
-
const n = e === "stringifyReplacer" ? [(r) => r === void 0 ?
|
|
1239
|
-
if (n.push(...t.map(((r) => r[e])).filter(((r) => !!r))), n.length !== 0) return (r,
|
|
1240
|
-
let a =
|
|
1241
|
-
for (const
|
|
1306
|
+
const a = Object.assign({ remove: r === "delete" }, i), o = r !== "add" ? nt(t, e) : void 0;
|
|
1307
|
+
return { currentData: t, newData: Zn(t, e, n, a), currentValue: o, newValue: r !== "delete" ? n : void 0 };
|
|
1308
|
+
}, lt = (t, e) => e ? () => !0 : typeof t == "boolean" ? () => t : typeof t == "number" ? ({ level: n }) => n >= t : t, Lr = (t) => {
|
|
1309
|
+
if (t !== void 0) return t === "value" ? it : t === "key" ? Zt : t === "all" ? (e, n) => it(e, n) || Zt(e, n) : t;
|
|
1310
|
+
}, _r = (t) => Array.isArray(t) && t.length === 2 && ["error", "value"].includes(t[0]), nn = (t, e) => {
|
|
1311
|
+
const n = e === "stringifyReplacer" ? [(r) => r === void 0 ? pn : r] : [];
|
|
1312
|
+
if (n.push(...t.map(((r) => r[e])).filter(((r) => !!r))), n.length !== 0) return (r, i) => {
|
|
1313
|
+
let a = i;
|
|
1314
|
+
for (const o of n) a = o(a);
|
|
1242
1315
|
return a;
|
|
1243
1316
|
};
|
|
1244
|
-
},
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1317
|
+
}, wn = { displayName: "Github Dark", styles: { container: { backgroundColor: "#0d1117", color: "white" }, dropZone: "rgba(165, 214, 255, 0.17)", property: "#E6EDF3", bracket: "#56d364", itemCount: "#8B949E", string: "#A5D6FF", number: "#D2A8FF", boolean: { color: "#FF7B72", fontSize: "90%", fontWeight: "bold" }, null: "green", iconCollection: "#D2A8FF", iconEdit: "#D2A8FF", iconDelete: "rgb(203, 75, 22)", iconAdd: "rgb(203, 75, 22)", iconCopy: "#A5D6FF", iconOk: "#56d364", iconCancel: "rgb(203, 75, 22)" } }, Pr = { displayName: "Github Light", styles: { container: "white", property: "#1F2328", bracket: "#00802e", itemCount: "#8B949E", string: "#0A3069", number: "#953800", boolean: { color: "#CF222E", fontSize: "90%", fontWeight: "bold" }, null: "#FF7B72", iconCollection: "#8250DF", iconEdit: "#8250DF", iconDelete: "rgb(203, 75, 22)", iconAdd: "#8250DF", iconCopy: "#57606A" } }, Rr = { displayName: "Black & White", fragments: { lightText: { color: "white" }, midGrey: "#5c5c5c" }, styles: { container: ["lightText", { backgroundColor: "black" }], dropZone: "#e0e0e029", property: "lightText", bracket: "midGrey", itemCount: "#4a4a4a", string: "#a8a8a8", number: "#666666", boolean: { color: "#848484", fontStyle: "italic" }, null: "#333333", iconCollection: "midGrey", iconEdit: "midGrey", iconDelete: "midGrey", iconAdd: "midGrey", iconCopy: "midGrey", iconOk: "midGrey", iconCancel: "midGrey" } }, Ir = { fragments: { midGrey: "#a3a3a3" }, displayName: "White & Black", styles: { container: "white", property: "black", bracket: "midGrey", itemCount: "#b5b5b5", string: "#575757", number: "#999999", boolean: { color: "#7b7b7b", fontStyle: "italic" }, null: "#cccccc", iconCollection: "midGrey", iconEdit: "midGrey", iconDelete: "midGrey", iconAdd: "midGrey", iconCopy: "midGrey", iconOk: "midGrey", iconCancel: "midGrey" } };
|
|
1318
|
+
function Dn(t, e) {
|
|
1319
|
+
const n = JSON.stringify(t, null, 2), r = new Blob([n], { type: "application/json" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
1320
|
+
a.href = i, a.download = e, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
1321
|
+
}
|
|
1322
|
+
function On(t, e) {
|
|
1323
|
+
const n = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, -1), r = e && e.length > 0 ? "." + e.join(".") : "";
|
|
1324
|
+
return `${t}${r}-${n}.json`;
|
|
1325
|
+
}
|
|
1326
|
+
const Mr = {
|
|
1327
|
+
githubDark: wn,
|
|
1328
|
+
githubLight: Pr,
|
|
1329
|
+
monoDark: Rr,
|
|
1330
|
+
monoLight: Ir
|
|
1249
1331
|
};
|
|
1250
|
-
class
|
|
1332
|
+
class Vr extends Rn {
|
|
1251
1333
|
constructor() {
|
|
1252
1334
|
super(...arguments), this.state = { error: null };
|
|
1253
1335
|
}
|
|
@@ -1258,7 +1340,7 @@ class Rr extends Nn {
|
|
|
1258
1340
|
console.error("[Legend State DevTools] React error:", e, n);
|
|
1259
1341
|
}
|
|
1260
1342
|
render() {
|
|
1261
|
-
return this.state.error ?
|
|
1343
|
+
return this.state.error ? Pn.createElement(
|
|
1262
1344
|
"pre",
|
|
1263
1345
|
{ style: { color: "#ff6b6b", padding: 16, fontSize: 12 } },
|
|
1264
1346
|
`DevTools Error: ${this.state.error.message}
|
|
@@ -1266,41 +1348,70 @@ ${this.state.error.stack}`
|
|
|
1266
1348
|
) : this.props.children;
|
|
1267
1349
|
}
|
|
1268
1350
|
}
|
|
1269
|
-
function
|
|
1351
|
+
function Fr() {
|
|
1352
|
+
return /* @__PURE__ */ $(
|
|
1353
|
+
"svg",
|
|
1354
|
+
{
|
|
1355
|
+
className: "lsdt-node-dump-btn",
|
|
1356
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1357
|
+
width: "16",
|
|
1358
|
+
height: "16",
|
|
1359
|
+
viewBox: "0 0 24 24",
|
|
1360
|
+
fill: "none",
|
|
1361
|
+
stroke: "currentColor",
|
|
1362
|
+
strokeWidth: "2",
|
|
1363
|
+
strokeLinecap: "round",
|
|
1364
|
+
strokeLinejoin: "round",
|
|
1365
|
+
children: [
|
|
1366
|
+
/* @__PURE__ */ l("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1367
|
+
/* @__PURE__ */ l("polyline", { points: "7 10 12 15 17 10" }),
|
|
1368
|
+
/* @__PURE__ */ l("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
|
|
1369
|
+
]
|
|
1370
|
+
}
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1373
|
+
function Kr({
|
|
1270
1374
|
data: t,
|
|
1271
1375
|
onEdit: e,
|
|
1272
1376
|
readOnly: n,
|
|
1273
1377
|
theme: r,
|
|
1274
|
-
rootName:
|
|
1378
|
+
rootName: i
|
|
1275
1379
|
}) {
|
|
1276
|
-
const a =
|
|
1277
|
-
return /* @__PURE__ */
|
|
1278
|
-
|
|
1380
|
+
const a = Mr[r] ?? wn;
|
|
1381
|
+
return /* @__PURE__ */ l(
|
|
1382
|
+
Ar,
|
|
1279
1383
|
{
|
|
1280
1384
|
data: t,
|
|
1281
1385
|
setData: e,
|
|
1282
|
-
rootName:
|
|
1386
|
+
rootName: i,
|
|
1283
1387
|
theme: a,
|
|
1284
1388
|
collapse: 2,
|
|
1285
1389
|
restrictEdit: n,
|
|
1286
1390
|
restrictDelete: n,
|
|
1287
1391
|
restrictAdd: n,
|
|
1288
|
-
restrictTypeSelection: n ? !0 : void 0
|
|
1392
|
+
restrictTypeSelection: n ? !0 : void 0,
|
|
1393
|
+
customButtons: [{
|
|
1394
|
+
Element: Fr,
|
|
1395
|
+
onClick: (g) => {
|
|
1396
|
+
const f = g.path.map(String);
|
|
1397
|
+
Dn(g.value, On(i, f));
|
|
1398
|
+
}
|
|
1399
|
+
}]
|
|
1289
1400
|
}
|
|
1290
1401
|
);
|
|
1291
1402
|
}
|
|
1292
|
-
function
|
|
1403
|
+
function zr(t) {
|
|
1293
1404
|
const [e, n] = de(t.initialData);
|
|
1294
|
-
return
|
|
1295
|
-
t.registerUpdater((
|
|
1296
|
-
n(
|
|
1405
|
+
return Pe(() => {
|
|
1406
|
+
t.registerUpdater((i) => {
|
|
1407
|
+
n(i);
|
|
1297
1408
|
});
|
|
1298
|
-
}, []), /* @__PURE__ */
|
|
1299
|
-
|
|
1409
|
+
}, []), /* @__PURE__ */ l(
|
|
1410
|
+
Kr,
|
|
1300
1411
|
{
|
|
1301
1412
|
data: e,
|
|
1302
|
-
onEdit: (
|
|
1303
|
-
n(
|
|
1413
|
+
onEdit: (i) => {
|
|
1414
|
+
n(i), t.onEdit(i);
|
|
1304
1415
|
},
|
|
1305
1416
|
readOnly: t.readOnly,
|
|
1306
1417
|
theme: t.theme,
|
|
@@ -1308,95 +1419,100 @@ function Lr(t) {
|
|
|
1308
1419
|
}
|
|
1309
1420
|
);
|
|
1310
1421
|
}
|
|
1311
|
-
function
|
|
1422
|
+
function Br(t, e) {
|
|
1312
1423
|
let n = null, r = null;
|
|
1313
|
-
return n =
|
|
1314
|
-
/* @__PURE__ */
|
|
1315
|
-
|
|
1424
|
+
return n = In(t), n.render(
|
|
1425
|
+
/* @__PURE__ */ l(Vr, { children: /* @__PURE__ */ l(
|
|
1426
|
+
zr,
|
|
1316
1427
|
{
|
|
1317
1428
|
initialData: e.initialData,
|
|
1318
1429
|
onEdit: e.onEdit,
|
|
1319
1430
|
readOnly: e.readOnly,
|
|
1320
1431
|
theme: e.theme,
|
|
1321
1432
|
rootName: e.rootName,
|
|
1322
|
-
registerUpdater: (
|
|
1323
|
-
r =
|
|
1433
|
+
registerUpdater: (i) => {
|
|
1434
|
+
r = i;
|
|
1324
1435
|
}
|
|
1325
1436
|
}
|
|
1326
1437
|
) })
|
|
1327
1438
|
), {
|
|
1328
|
-
updateData: (
|
|
1329
|
-
r == null || r(
|
|
1439
|
+
updateData: (i) => {
|
|
1440
|
+
r == null || r(i);
|
|
1330
1441
|
},
|
|
1331
1442
|
destroy: () => {
|
|
1332
1443
|
n && (n.unmount(), n = null);
|
|
1333
1444
|
}
|
|
1334
1445
|
};
|
|
1335
1446
|
}
|
|
1336
|
-
function
|
|
1447
|
+
function Ur(t, e = {}) {
|
|
1337
1448
|
const {
|
|
1338
1449
|
enabled: n = !0,
|
|
1339
1450
|
readOnly: r = !1,
|
|
1340
|
-
theme:
|
|
1451
|
+
theme: i = "githubDark",
|
|
1341
1452
|
rootName: a = "state$",
|
|
1342
|
-
position:
|
|
1453
|
+
position: o = "right",
|
|
1454
|
+
defaultOpen: g = !1
|
|
1343
1455
|
} = e;
|
|
1344
1456
|
if (!n)
|
|
1345
1457
|
return { destroy: () => {
|
|
1346
1458
|
} };
|
|
1347
|
-
const
|
|
1348
|
-
let
|
|
1349
|
-
|
|
1459
|
+
const f = Yn();
|
|
1460
|
+
let s = null, c = null, d = null, m = null;
|
|
1461
|
+
s = new Xn({
|
|
1350
1462
|
rootName: a,
|
|
1351
1463
|
readOnly: r,
|
|
1352
|
-
position:
|
|
1464
|
+
position: o,
|
|
1353
1465
|
onClose: () => {
|
|
1354
|
-
|
|
1466
|
+
b();
|
|
1467
|
+
},
|
|
1468
|
+
onDumpState: () => {
|
|
1469
|
+
const C = d == null ? void 0 : d.getSnapshot();
|
|
1470
|
+
C !== void 0 && Dn(C, On(a));
|
|
1355
1471
|
}
|
|
1356
1472
|
});
|
|
1357
|
-
const
|
|
1358
|
-
if (!
|
|
1359
|
-
|
|
1360
|
-
const
|
|
1361
|
-
const
|
|
1362
|
-
if (!
|
|
1363
|
-
|
|
1473
|
+
const j = () => {
|
|
1474
|
+
if (!s) return;
|
|
1475
|
+
s.show(), c == null || c.setPanelVisible(!0);
|
|
1476
|
+
const C = (N = 10) => {
|
|
1477
|
+
const x = s == null ? void 0 : s.getEditorRoot();
|
|
1478
|
+
if (!x) {
|
|
1479
|
+
N > 0 ? setTimeout(() => C(N - 1), 16) : console.warn("[Legend State DevTools] Could not find #lsdt-json-editor-root after retries");
|
|
1364
1480
|
return;
|
|
1365
1481
|
}
|
|
1366
|
-
if (
|
|
1367
|
-
const
|
|
1368
|
-
|
|
1369
|
-
initialData:
|
|
1370
|
-
onEdit: (
|
|
1371
|
-
|
|
1482
|
+
if (m) return;
|
|
1483
|
+
const _ = (d == null ? void 0 : d.getSnapshot()) ?? {};
|
|
1484
|
+
m = Br(x, {
|
|
1485
|
+
initialData: _,
|
|
1486
|
+
onEdit: (W) => {
|
|
1487
|
+
d == null || d.setData(W);
|
|
1372
1488
|
},
|
|
1373
1489
|
readOnly: r,
|
|
1374
|
-
theme:
|
|
1490
|
+
theme: i,
|
|
1375
1491
|
rootName: a
|
|
1376
1492
|
});
|
|
1377
1493
|
};
|
|
1378
|
-
|
|
1379
|
-
}, j = () => {
|
|
1380
|
-
p && (p.destroy(), p = null), h == null || h.hide(), s == null || s.setPanelVisible(!1);
|
|
1494
|
+
C();
|
|
1381
1495
|
}, b = () => {
|
|
1382
|
-
|
|
1496
|
+
m && (m.destroy(), m = null), s == null || s.hide(), c == null || c.setPanelVisible(!1);
|
|
1497
|
+
}, D = () => {
|
|
1498
|
+
s != null && s.isVisible() ? b() : j();
|
|
1383
1499
|
};
|
|
1384
|
-
return
|
|
1385
|
-
onTogglePanel:
|
|
1500
|
+
return c = new Gn({
|
|
1501
|
+
onTogglePanel: D,
|
|
1386
1502
|
rootName: a
|
|
1387
|
-
}),
|
|
1388
|
-
onSnapshot: (
|
|
1389
|
-
|
|
1503
|
+
}), c.mount(), f.add(() => c == null ? void 0 : c.unmount()), d = Jn(t, {
|
|
1504
|
+
onSnapshot: (C) => {
|
|
1505
|
+
s != null && s.getIsDragging() || m == null || m.updateData(C);
|
|
1390
1506
|
}
|
|
1391
|
-
}),
|
|
1392
|
-
|
|
1393
|
-
}),
|
|
1507
|
+
}), f.add(() => d == null ? void 0 : d.destroy()), f.add(() => {
|
|
1508
|
+
m && (m.destroy(), m = null);
|
|
1509
|
+
}), f.add(() => s == null ? void 0 : s.unmount()), g && j(), {
|
|
1394
1510
|
destroy: () => {
|
|
1395
|
-
|
|
1511
|
+
f.run();
|
|
1396
1512
|
}
|
|
1397
1513
|
};
|
|
1398
1514
|
}
|
|
1399
1515
|
export {
|
|
1400
|
-
|
|
1516
|
+
Ur as init
|
|
1401
1517
|
};
|
|
1402
1518
|
//# sourceMappingURL=index.mjs.map
|