@archduck/gst-forms 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +429 -0
- package/dist/gst-forms.css +1 -0
- package/dist/index.cjs +16 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +1387 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1387 @@
|
|
|
1
|
+
import { createTLPSchema as B, createLiveConfigRaw as J, loadJsonConfigRaw as I, loadLiveConfigRaw as Y, mount as Z, effect as W, isDebugActive as j, trace as R, pauseTracking as Q, getFieldValue as F, enableTracking as X, setFieldValue as H, clearFieldValue as q, createStage as C, bindFunctions as x, logger as A, isEventKey as ee } from "@archduck/gst-core";
|
|
2
|
+
import { createTLPSchema as wt } from "@archduck/gst-core";
|
|
3
|
+
const te = {
|
|
4
|
+
functions: { registry: !0, dependencies: [] },
|
|
5
|
+
actions: {
|
|
6
|
+
dependencies: ["functions"],
|
|
7
|
+
children: {
|
|
8
|
+
buttons: { registry: !0 },
|
|
9
|
+
hooks: {}
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
optionSets: { registry: !0, dependencies: [] },
|
|
13
|
+
fields: { registry: !0, dependencies: ["functions", "optionSets", "actions"] },
|
|
14
|
+
components: { registry: !0, dependencies: ["fields"] },
|
|
15
|
+
meta: { dependencies: [] },
|
|
16
|
+
state: { dependencies: [], default: {} },
|
|
17
|
+
layout: { dependencies: ["fields", "components", "actions"], default: [] },
|
|
18
|
+
record: { dependencies: [], default: null },
|
|
19
|
+
styles: { dependencies: [], default: null }
|
|
20
|
+
}, M = B(te);
|
|
21
|
+
async function Ne(e, t = {}) {
|
|
22
|
+
return I(e, { ...t, schema: M });
|
|
23
|
+
}
|
|
24
|
+
function We(e = {}) {
|
|
25
|
+
return J({ ...e, schema: M });
|
|
26
|
+
}
|
|
27
|
+
async function Me(e, t = {}) {
|
|
28
|
+
return Y(e, { ...t, schema: M });
|
|
29
|
+
}
|
|
30
|
+
function ne(e) {
|
|
31
|
+
const t = /* @__PURE__ */ new Set();
|
|
32
|
+
function n(r) {
|
|
33
|
+
if (!r) return;
|
|
34
|
+
if (typeof r == "string") {
|
|
35
|
+
t.add(r);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
r.name && !r.rows && !r.layout && t.add(r.name);
|
|
39
|
+
const i = r.rows || r.layout;
|
|
40
|
+
if (Array.isArray(i))
|
|
41
|
+
for (const s of i)
|
|
42
|
+
if (Array.isArray(s))
|
|
43
|
+
for (const o of s) n(o);
|
|
44
|
+
else n(s);
|
|
45
|
+
if (Array.isArray(r.children))
|
|
46
|
+
for (const s of r.children) n(s);
|
|
47
|
+
}
|
|
48
|
+
return n(e), t;
|
|
49
|
+
}
|
|
50
|
+
let v = null;
|
|
51
|
+
function re(e, t) {
|
|
52
|
+
var n, r, i, s, o;
|
|
53
|
+
Q();
|
|
54
|
+
try {
|
|
55
|
+
if (!(((n = t.meta) == null ? void 0 : n.clearHiddenFields) ?? !0)) return;
|
|
56
|
+
const c = ne(e);
|
|
57
|
+
if (c.size === 0) return;
|
|
58
|
+
const u = /* @__PURE__ */ new Set([
|
|
59
|
+
...((r = t.meta) == null ? void 0 : r.systemFields) || [],
|
|
60
|
+
...((i = t.meta) == null ? void 0 : i.readonly) || []
|
|
61
|
+
]);
|
|
62
|
+
for (const p of c) {
|
|
63
|
+
if (u.has(p)) continue;
|
|
64
|
+
const h = (o = (s = t.registries) == null ? void 0 : s.fields) == null ? void 0 : o[p];
|
|
65
|
+
if (h != null && h.bind) continue;
|
|
66
|
+
const f = F(t, p, h);
|
|
67
|
+
f != null && f !== "" && (v || (v = { store: t, fields: /* @__PURE__ */ new Set() }, queueMicrotask(ie)), v.fields.add(p));
|
|
68
|
+
}
|
|
69
|
+
} finally {
|
|
70
|
+
X();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function ie() {
|
|
74
|
+
var i, s, o, a, c, u, p, h, f;
|
|
75
|
+
const e = v;
|
|
76
|
+
if (v = null, !e || e.fields.size === 0) return;
|
|
77
|
+
const { store: t } = e, n = /* @__PURE__ */ new Map();
|
|
78
|
+
for (const l of e.fields) {
|
|
79
|
+
const d = (s = (i = t.registries) == null ? void 0 : i.fields) == null ? void 0 : s[l];
|
|
80
|
+
n.set(l, F(t, l, d));
|
|
81
|
+
}
|
|
82
|
+
for (const l of e.fields) {
|
|
83
|
+
const d = (a = (o = t.registries) == null ? void 0 : o.fields) == null ? void 0 : a[l];
|
|
84
|
+
q(t, l, d);
|
|
85
|
+
}
|
|
86
|
+
for (; v && v.fields.size > 0; ) {
|
|
87
|
+
const l = v;
|
|
88
|
+
v = null;
|
|
89
|
+
for (const d of l.fields) {
|
|
90
|
+
const m = (u = (c = t.registries) == null ? void 0 : c.fields) == null ? void 0 : u[d];
|
|
91
|
+
n.has(d) || n.set(d, F(t, d, m)), q(t, d, m);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if ((((p = t.meta) == null ? void 0 : p.confirmClearFields) ?? !1) && n.size > 0) {
|
|
95
|
+
const l = Array.from(n.keys()).map((m) => {
|
|
96
|
+
var g, y;
|
|
97
|
+
const b = (y = (g = t.registries) == null ? void 0 : g.fields) == null ? void 0 : y[m];
|
|
98
|
+
return (b == null ? void 0 : b.label) || m;
|
|
99
|
+
});
|
|
100
|
+
if (!window.confirm(
|
|
101
|
+
`The following fields will be cleared because their section is now hidden:
|
|
102
|
+
|
|
103
|
+
${l.join(", ")}
|
|
104
|
+
|
|
105
|
+
Do you want to proceed?`
|
|
106
|
+
))
|
|
107
|
+
for (const [m, b] of n) {
|
|
108
|
+
const g = (f = (h = t.registries) == null ? void 0 : h.fields) == null ? void 0 : f[m];
|
|
109
|
+
H(t, m, g, b);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function se(e, t) {
|
|
114
|
+
const n = typeof e == "function" ? e : () => e;
|
|
115
|
+
return Object.freeze({
|
|
116
|
+
get isDirty() {
|
|
117
|
+
return (t == null ? void 0 : t.isDirty) || !1;
|
|
118
|
+
},
|
|
119
|
+
get isSubmitting() {
|
|
120
|
+
return (t == null ? void 0 : t.isSubmitting) || !1;
|
|
121
|
+
},
|
|
122
|
+
get isDeleted() {
|
|
123
|
+
return (t == null ? void 0 : t.isDeleted) || !1;
|
|
124
|
+
},
|
|
125
|
+
get record() {
|
|
126
|
+
return t == null ? void 0 : t.record;
|
|
127
|
+
},
|
|
128
|
+
get data() {
|
|
129
|
+
var r;
|
|
130
|
+
return (r = t == null ? void 0 : t.record) == null ? void 0 : r.data;
|
|
131
|
+
},
|
|
132
|
+
get meta() {
|
|
133
|
+
return t == null ? void 0 : t.meta;
|
|
134
|
+
},
|
|
135
|
+
getValue(r) {
|
|
136
|
+
var s, o;
|
|
137
|
+
const i = (o = (s = t == null ? void 0 : t.registries) == null ? void 0 : s.fields) == null ? void 0 : o[r];
|
|
138
|
+
return F(t, r, i);
|
|
139
|
+
},
|
|
140
|
+
setValue(r, i) {
|
|
141
|
+
var o, a;
|
|
142
|
+
const s = (a = (o = t == null ? void 0 : t.registries) == null ? void 0 : o.fields) == null ? void 0 : a[r];
|
|
143
|
+
H(t, r, s, i);
|
|
144
|
+
},
|
|
145
|
+
getField(r) {
|
|
146
|
+
var i, s;
|
|
147
|
+
return (s = (i = t == null ? void 0 : t.registries) == null ? void 0 : i.fields) == null ? void 0 : s[r];
|
|
148
|
+
},
|
|
149
|
+
getErrors(r) {
|
|
150
|
+
var i;
|
|
151
|
+
return ((i = t == null ? void 0 : t.fieldErrors) == null ? void 0 : i[r]) || [];
|
|
152
|
+
},
|
|
153
|
+
setError(r, i) {
|
|
154
|
+
t != null && t.fieldErrors && (t.fieldErrors[r] = Array.isArray(i) ? i : [i]);
|
|
155
|
+
},
|
|
156
|
+
clearErrors(r) {
|
|
157
|
+
t != null && t.fieldErrors && (t.fieldErrors[r] = []);
|
|
158
|
+
},
|
|
159
|
+
get hasErrors() {
|
|
160
|
+
return Object.values((t == null ? void 0 : t.fieldErrors) || {}).some(
|
|
161
|
+
(r) => Array.isArray(r) && r.length > 0
|
|
162
|
+
);
|
|
163
|
+
},
|
|
164
|
+
executeAction(r, i) {
|
|
165
|
+
var s;
|
|
166
|
+
return (s = t == null ? void 0 : t.executeAction) == null ? void 0 : s.call(t, r, i);
|
|
167
|
+
},
|
|
168
|
+
reset() {
|
|
169
|
+
var r, i, s;
|
|
170
|
+
(s = (i = (r = n()) == null ? void 0 : r.form) == null ? void 0 : i.reset) == null || s.call(i);
|
|
171
|
+
},
|
|
172
|
+
loadRecord(r) {
|
|
173
|
+
var i, s, o;
|
|
174
|
+
(o = (s = (i = n()) == null ? void 0 : i.form) == null ? void 0 : s.loadRecord) == null || o.call(s, r);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function oe(e, t) {
|
|
179
|
+
const { actionHandlers: n = {}, wrapAction: r, onAction: i } = t, s = (f) => JSON.parse(JSON.stringify(f || {}));
|
|
180
|
+
let o = s(e.record);
|
|
181
|
+
function a() {
|
|
182
|
+
const f = s(o);
|
|
183
|
+
e.record.key = f.key ?? null;
|
|
184
|
+
const l = e.record.data;
|
|
185
|
+
for (const d of Object.keys(l)) delete l[d];
|
|
186
|
+
for (const [d, m] of Object.entries(f.data || {})) l[d] = m;
|
|
187
|
+
e.fieldErrors = {}, e.isDeleted = !1;
|
|
188
|
+
}
|
|
189
|
+
function c(f) {
|
|
190
|
+
o = s(f), e.record.key = f.key ?? null;
|
|
191
|
+
const l = e.record.data;
|
|
192
|
+
for (const d of Object.keys(l)) delete l[d];
|
|
193
|
+
for (const [d, m] of Object.entries(f.data || {})) l[d] = m;
|
|
194
|
+
e.fieldErrors = {}, e.isDeleted = !1;
|
|
195
|
+
}
|
|
196
|
+
function u(f, l = {}) {
|
|
197
|
+
var d, m, b;
|
|
198
|
+
return {
|
|
199
|
+
action: f,
|
|
200
|
+
record: e.record,
|
|
201
|
+
meta: e.meta,
|
|
202
|
+
registries: e.registries,
|
|
203
|
+
functions: ((d = e.registries) == null ? void 0 : d.functions) || {},
|
|
204
|
+
hooks: ((m = e.registries) == null ? void 0 : m.hooks) || ((b = e.actions) == null ? void 0 : b.hooks) || {},
|
|
205
|
+
form: {
|
|
206
|
+
isDirty: e.isDirty,
|
|
207
|
+
isSubmitting: e.isSubmitting,
|
|
208
|
+
isDeleted: e.isDeleted,
|
|
209
|
+
getValue: (g) => {
|
|
210
|
+
var E, w;
|
|
211
|
+
const y = (w = (E = e.registries) == null ? void 0 : E.fields) == null ? void 0 : w[g];
|
|
212
|
+
return F(e, g, y);
|
|
213
|
+
},
|
|
214
|
+
setValue: (g, y) => {
|
|
215
|
+
var w, $;
|
|
216
|
+
const E = ($ = (w = e.registries) == null ? void 0 : w.fields) == null ? void 0 : $[g];
|
|
217
|
+
H(e, g, E, y);
|
|
218
|
+
},
|
|
219
|
+
getFieldErrors: (g) => {
|
|
220
|
+
var y;
|
|
221
|
+
return ((y = e.fieldErrors) == null ? void 0 : y[g]) || [];
|
|
222
|
+
},
|
|
223
|
+
setFieldErrors: (g, y) => {
|
|
224
|
+
e.fieldErrors && (e.fieldErrors[g] = y);
|
|
225
|
+
},
|
|
226
|
+
setFieldError: (g, y) => {
|
|
227
|
+
e.fieldErrors && (e.fieldErrors[g] = Array.isArray(y) ? y : [y]);
|
|
228
|
+
},
|
|
229
|
+
clearFieldError: (g) => {
|
|
230
|
+
e.fieldErrors && (e.fieldErrors[g] = []);
|
|
231
|
+
},
|
|
232
|
+
reset: a,
|
|
233
|
+
loadRecord: c,
|
|
234
|
+
setDeleted: (g) => {
|
|
235
|
+
e.isDeleted = g;
|
|
236
|
+
},
|
|
237
|
+
isRequired: (g) => {
|
|
238
|
+
var y, E, w;
|
|
239
|
+
return !!((w = (E = (y = e.registries) == null ? void 0 : y.fields) == null ? void 0 : E[g]) != null && w.required);
|
|
240
|
+
},
|
|
241
|
+
isReadonly: (g) => {
|
|
242
|
+
var y, E, w;
|
|
243
|
+
return !!((y = e.meta) != null && y.readOnly) || ((w = (E = e.meta) == null ? void 0 : E.readonly) == null ? void 0 : w.includes(g)) || !1;
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
props: { onAction: i },
|
|
247
|
+
...l
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
const p = se(() => u("_stage"), e);
|
|
251
|
+
function h(f) {
|
|
252
|
+
var m, b, g, y;
|
|
253
|
+
const l = (b = (m = e.actions) == null ? void 0 : m.hooks) == null ? void 0 : b[f];
|
|
254
|
+
if (!l)
|
|
255
|
+
return j() && R("hook", `resolve-hook "${f}"`, "not defined", { hookName: f }), null;
|
|
256
|
+
const d = typeof l == "function" ? l : typeof l == "string" && l.startsWith("{{") ? (y = (g = e.registries) == null ? void 0 : g.functions) == null ? void 0 : y[l.slice(2, -2).trim()] : null;
|
|
257
|
+
return j() && R("hook", `resolve-hook "${f}"`, d ? "found" : "MISSING function", {
|
|
258
|
+
hookName: f,
|
|
259
|
+
hookType: typeof l,
|
|
260
|
+
hookValue: typeof l == "string" ? l : "(function)",
|
|
261
|
+
resolved: !!d
|
|
262
|
+
}), d ? d.bind(p) : null;
|
|
263
|
+
}
|
|
264
|
+
e._fireHook = (f) => {
|
|
265
|
+
const l = h(f);
|
|
266
|
+
l && queueMicrotask(() => l(u(f)));
|
|
267
|
+
}, e.executeAction = async (f, l = {}) => {
|
|
268
|
+
var b, g;
|
|
269
|
+
let d = f;
|
|
270
|
+
typeof f == "string" && f.startsWith("{{") && f.endsWith("}}") && (d = f.slice(2, -2).trim());
|
|
271
|
+
const m = u(d, l);
|
|
272
|
+
e.isSubmitting = !0;
|
|
273
|
+
try {
|
|
274
|
+
const y = (g = (b = e.registries) == null ? void 0 : b.functions) == null ? void 0 : g[d], E = (typeof y == "function" ? y : null) || n[d] || (i ? async ($) => i($) : null);
|
|
275
|
+
if (!E) {
|
|
276
|
+
j() && R("action", `execute-action "${d}"`, "NO HANDLER found", {
|
|
277
|
+
actionName: d,
|
|
278
|
+
inFunctionRegistry: !!y,
|
|
279
|
+
inActionHandlers: !!n[d],
|
|
280
|
+
hasOnAction: !!i
|
|
281
|
+
});
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (j()) {
|
|
285
|
+
const $ = typeof y == "function" ? "functions registry" : n[d] ? "actionHandlers" : "onAction callback";
|
|
286
|
+
R("action", `execute-action "${d}"`, `dispatching (via ${$})`, {
|
|
287
|
+
actionName: d,
|
|
288
|
+
source: $,
|
|
289
|
+
extra: l
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
const w = E.bind(p);
|
|
293
|
+
r ? await r(d, w).call(p, m, l) : await w(m, l);
|
|
294
|
+
} finally {
|
|
295
|
+
e.isSubmitting = !1;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function ae(e, t) {
|
|
300
|
+
const { onDirtyChange: n } = t, i = ((s) => JSON.parse(JSON.stringify(s || {})))(e.record);
|
|
301
|
+
return W(() => {
|
|
302
|
+
var u;
|
|
303
|
+
const s = e.record.data, o = i.data || {};
|
|
304
|
+
let a = !1;
|
|
305
|
+
const c = /* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(o)]);
|
|
306
|
+
for (const p of c) {
|
|
307
|
+
const h = s[p], f = o[p];
|
|
308
|
+
if (h !== f) {
|
|
309
|
+
if (typeof h == "object" && typeof f == "object" && JSON.stringify(h) === JSON.stringify(f)) continue;
|
|
310
|
+
a = !0;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
e.isDirty !== a && (e.isDirty = a, n && queueMicrotask(() => n(a)), (u = e._fireHook) == null || u.call(e, a ? "onDirty" : "onClean"));
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
function ce(e, t) {
|
|
318
|
+
const { onChange: n } = t;
|
|
319
|
+
let r = !0;
|
|
320
|
+
return W(() => {
|
|
321
|
+
var i;
|
|
322
|
+
if ({ ...e.record.data }, r) {
|
|
323
|
+
r = !1;
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
n && queueMicrotask(() => n(e.record)), (i = e._fireHook) == null || i.call(e, "onChange");
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
function fe(e) {
|
|
330
|
+
let t = !1;
|
|
331
|
+
return W(() => {
|
|
332
|
+
var r;
|
|
333
|
+
const n = Object.values(e.fieldErrors).some(
|
|
334
|
+
(i) => Array.isArray(i) && i.length > 0
|
|
335
|
+
);
|
|
336
|
+
n !== t && (t = n, (r = e._fireHook) == null || r.call(e, n ? "onError" : "onRecover"), n && queueMicrotask(() => {
|
|
337
|
+
var o;
|
|
338
|
+
const i = (o = Object.entries(e.fieldErrors).find(([, a]) => Array.isArray(a) && a.length > 0)) == null ? void 0 : o[0];
|
|
339
|
+
if (!i) return;
|
|
340
|
+
const s = document.querySelector(
|
|
341
|
+
`[name="${CSS.escape(i)}"]`
|
|
342
|
+
);
|
|
343
|
+
s && typeof s.focus == "function" && s.focus();
|
|
344
|
+
}));
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
function ue(e) {
|
|
348
|
+
typeof window > "u" || (window.gst = {
|
|
349
|
+
meta: e.meta,
|
|
350
|
+
state: e.state,
|
|
351
|
+
registries: e.registries,
|
|
352
|
+
actions: e.actions,
|
|
353
|
+
record: e.record,
|
|
354
|
+
get data() {
|
|
355
|
+
var t;
|
|
356
|
+
return (t = e.record) == null ? void 0 : t.data;
|
|
357
|
+
},
|
|
358
|
+
get isDirty() {
|
|
359
|
+
return e.isDirty;
|
|
360
|
+
},
|
|
361
|
+
get isSubmitting() {
|
|
362
|
+
return e.isSubmitting;
|
|
363
|
+
},
|
|
364
|
+
get errors() {
|
|
365
|
+
return e.fieldErrors;
|
|
366
|
+
},
|
|
367
|
+
getField: (t) => {
|
|
368
|
+
var n, r;
|
|
369
|
+
return (r = (n = e.registries) == null ? void 0 : n.fields) == null ? void 0 : r[t];
|
|
370
|
+
},
|
|
371
|
+
getButton: (t) => {
|
|
372
|
+
var n, r;
|
|
373
|
+
return (r = (n = e.registries) == null ? void 0 : n.buttons) == null ? void 0 : r[t];
|
|
374
|
+
},
|
|
375
|
+
getFunction: (t) => {
|
|
376
|
+
var n, r;
|
|
377
|
+
return (r = (n = e.registries) == null ? void 0 : n.functions) == null ? void 0 : r[t];
|
|
378
|
+
},
|
|
379
|
+
getOptions: (t) => {
|
|
380
|
+
var n, r;
|
|
381
|
+
return (r = (n = e.registries) == null ? void 0 : n.optionSets) == null ? void 0 : r[t];
|
|
382
|
+
},
|
|
383
|
+
executeAction: (t, n) => e.executeAction(t, n),
|
|
384
|
+
setValue: (t, n) => {
|
|
385
|
+
var i, s;
|
|
386
|
+
const r = (s = (i = e.registries) == null ? void 0 : i.fields) == null ? void 0 : s[t];
|
|
387
|
+
H(e, t, r, n);
|
|
388
|
+
},
|
|
389
|
+
getValue: (t) => {
|
|
390
|
+
var r, i;
|
|
391
|
+
const n = (i = (r = e.registries) == null ? void 0 : r.fields) == null ? void 0 : i[t];
|
|
392
|
+
return F(e, t, n);
|
|
393
|
+
},
|
|
394
|
+
setState: (t, n) => {
|
|
395
|
+
e.state && (e.state[t] = n);
|
|
396
|
+
},
|
|
397
|
+
getState: (t) => {
|
|
398
|
+
var n;
|
|
399
|
+
return (n = e.state) == null ? void 0 : n[t];
|
|
400
|
+
},
|
|
401
|
+
inspect: (t) => t.split(".").reduce((n, r) => n == null ? void 0 : n[r], window.gst),
|
|
402
|
+
listFields: () => {
|
|
403
|
+
var t;
|
|
404
|
+
return Object.keys(((t = e.registries) == null ? void 0 : t.fields) || {});
|
|
405
|
+
},
|
|
406
|
+
listButtons: () => {
|
|
407
|
+
var t;
|
|
408
|
+
return Object.keys(((t = e.registries) == null ? void 0 : t.buttons) || {});
|
|
409
|
+
},
|
|
410
|
+
listFunctions: () => {
|
|
411
|
+
var t;
|
|
412
|
+
return Object.keys(((t = e.registries) == null ? void 0 : t.functions) || {});
|
|
413
|
+
},
|
|
414
|
+
store: e
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
function le(e) {
|
|
418
|
+
var t;
|
|
419
|
+
typeof window < "u" && ((t = window.gst) == null ? void 0 : t.store) === e && delete window.gst;
|
|
420
|
+
}
|
|
421
|
+
function Ue(e, t, n = {}) {
|
|
422
|
+
const r = t.registries || {};
|
|
423
|
+
for (const [o, a] of Object.entries(r))
|
|
424
|
+
a && typeof a == "object" && !Array.isArray(a) && a.__source && console.error(
|
|
425
|
+
`[gst] "__source" found in ${o} registry but won't be processed at mount time. __source only works in JSON configs loaded via loadJsonConfig(). For JS configs, use imports instead: ${o}: { ...base.${o}, ...my${o[0].toUpperCase() + o.slice(1)} }`
|
|
426
|
+
);
|
|
427
|
+
const i = document.createElement("form");
|
|
428
|
+
i.addEventListener("submit", (o) => o.preventDefault());
|
|
429
|
+
for (const o of e.classList)
|
|
430
|
+
o.startsWith("theme-") && i.classList.add(o);
|
|
431
|
+
const s = document.createElement("a");
|
|
432
|
+
return s.className = "skip-link", s.href = "#", s.textContent = "Skip to form actions", s.addEventListener("click", (o) => {
|
|
433
|
+
o.preventDefault();
|
|
434
|
+
const a = i.querySelector(".form-actions, .group-buttons");
|
|
435
|
+
if (a) {
|
|
436
|
+
const c = a.querySelector("button:not(:disabled)");
|
|
437
|
+
c && c.focus();
|
|
438
|
+
}
|
|
439
|
+
}), i.appendChild(s), e.appendChild(i), Z(i, t, {
|
|
440
|
+
...n,
|
|
441
|
+
initialState: {
|
|
442
|
+
fieldErrors: {},
|
|
443
|
+
isDirty: !1,
|
|
444
|
+
isSubmitting: !1,
|
|
445
|
+
isDeleted: !1,
|
|
446
|
+
...n.initialState
|
|
447
|
+
},
|
|
448
|
+
onHide: re,
|
|
449
|
+
setupActions: oe,
|
|
450
|
+
effects: [
|
|
451
|
+
ae,
|
|
452
|
+
ce,
|
|
453
|
+
fe,
|
|
454
|
+
...n.effects || []
|
|
455
|
+
],
|
|
456
|
+
onMount: (o, a) => {
|
|
457
|
+
var h;
|
|
458
|
+
const c = o.addGuard(() => o.isDirty ? "You have unsaved changes." : !0), u = (f) => {
|
|
459
|
+
const l = a.checkGuards();
|
|
460
|
+
l !== !0 && (f.preventDefault(), f.returnValue = typeof l == "string" ? l : "");
|
|
461
|
+
};
|
|
462
|
+
window.addEventListener("beforeunload", u);
|
|
463
|
+
const p = (f) => {
|
|
464
|
+
f.key === "Enter" && (f.ctrlKey || f.metaKey) ? (f.preventDefault(), o.executeAction && o.executeAction("save")) : f.key === "Escape" && o.isDirty && i.contains(document.activeElement) && (f.preventDefault(), o.executeAction && o.executeAction("cancel"));
|
|
465
|
+
};
|
|
466
|
+
i.addEventListener("keydown", p), o._formGuardCleanup = { removeDirtyGuard: c, onBeforeUnload: u, onKeyDown: p }, (h = o._fireHook) == null || h.call(o, "onLoad"), ue(o), n.onMount && n.onMount(o, a);
|
|
467
|
+
},
|
|
468
|
+
onUnmount: (o) => {
|
|
469
|
+
var a;
|
|
470
|
+
o._formGuardCleanup && (o._formGuardCleanup.removeDirtyGuard(), window.removeEventListener("beforeunload", o._formGuardCleanup.onBeforeUnload), i.removeEventListener("keydown", o._formGuardCleanup.onKeyDown), delete o._formGuardCleanup), (a = o._fireHook) == null || a.call(o, "onUnload"), le(o), n.onUnmount && n.onUnmount(o);
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
const qe = {
|
|
475
|
+
key: null,
|
|
476
|
+
data: {}
|
|
477
|
+
}, k = {
|
|
478
|
+
// Field clearing behavior
|
|
479
|
+
clearHiddenFields: !0,
|
|
480
|
+
confirmClearFields: !1,
|
|
481
|
+
// Action confirmations
|
|
482
|
+
confirmCancel: !0,
|
|
483
|
+
confirmDelete: !0,
|
|
484
|
+
confirmDuplicate: !0,
|
|
485
|
+
confirmNew: !0,
|
|
486
|
+
// Navigation
|
|
487
|
+
preventNavigationWhenDirty: !0,
|
|
488
|
+
// Keyboard
|
|
489
|
+
submitOnEnter: !0,
|
|
490
|
+
// Debug
|
|
491
|
+
debug: !1,
|
|
492
|
+
// Record structure
|
|
493
|
+
recordKeyPath: "key",
|
|
494
|
+
recordDataPath: "data",
|
|
495
|
+
// Field arrays (empty by default)
|
|
496
|
+
readonly: [],
|
|
497
|
+
systemFields: []
|
|
498
|
+
};
|
|
499
|
+
function Ve(e = {}) {
|
|
500
|
+
return {
|
|
501
|
+
...k,
|
|
502
|
+
...e
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function de(e, t) {
|
|
506
|
+
if (!e) return {};
|
|
507
|
+
const n = t == null ? void 0 : t.recordDataPath;
|
|
508
|
+
if (n === "")
|
|
509
|
+
return e;
|
|
510
|
+
const r = n ?? k.recordDataPath;
|
|
511
|
+
return e[r] ?? {};
|
|
512
|
+
}
|
|
513
|
+
function pe(e, t, n) {
|
|
514
|
+
if (!e) return { [k.recordDataPath]: n };
|
|
515
|
+
const r = t == null ? void 0 : t.recordDataPath;
|
|
516
|
+
if (r === "")
|
|
517
|
+
return { ...e, ...n };
|
|
518
|
+
const i = r ?? k.recordDataPath;
|
|
519
|
+
return { ...e, [i]: n };
|
|
520
|
+
}
|
|
521
|
+
function ge(e, t) {
|
|
522
|
+
if (!e) return null;
|
|
523
|
+
const n = t == null ? void 0 : t.recordKeyPath;
|
|
524
|
+
if (n === "")
|
|
525
|
+
return null;
|
|
526
|
+
const r = n ?? k.recordKeyPath;
|
|
527
|
+
return e[r] ?? null;
|
|
528
|
+
}
|
|
529
|
+
function ze(e, t, n, r = {}) {
|
|
530
|
+
if (!n || n.length === 0) return e;
|
|
531
|
+
const s = { ...de(e, t) }, o = (c) => {
|
|
532
|
+
const u = (c == null ? void 0 : c.type) || "text", p = c == null ? void 0 : c.component;
|
|
533
|
+
return c && "value" in c ? c.value : u === "checkbox" || p === "Checkbox" ? !1 : u === "array" || p === "ArrayField" ? [] : "";
|
|
534
|
+
}, a = (c) => {
|
|
535
|
+
if (!c) return [];
|
|
536
|
+
const u = [];
|
|
537
|
+
return Array.isArray(c.rows) && c.rows.forEach((p) => {
|
|
538
|
+
Array.isArray(p) && p.forEach((h) => {
|
|
539
|
+
typeof h == "string" && u.push(h);
|
|
540
|
+
});
|
|
541
|
+
}), u;
|
|
542
|
+
};
|
|
543
|
+
return n.forEach((c) => {
|
|
544
|
+
a(c).forEach((p) => {
|
|
545
|
+
if (!(p in s)) {
|
|
546
|
+
const h = r[p];
|
|
547
|
+
s[p] = o(h);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}), pe(e, t, s);
|
|
551
|
+
}
|
|
552
|
+
function U(e, t = {}) {
|
|
553
|
+
const { path: n, suggestion: r, details: i } = t, s = ["🔴 Runtime Error:", e];
|
|
554
|
+
return n && s.push(`
|
|
555
|
+
Path: ${n}`), i && s.push(`
|
|
556
|
+
Details: ${i}`), r && s.push(`
|
|
557
|
+
💡 ${r}`), s.join("");
|
|
558
|
+
}
|
|
559
|
+
function z(e, t = {}) {
|
|
560
|
+
const { path: n, suggestion: r, details: i, available: s } = t, o = ["⚠️ ", e];
|
|
561
|
+
return n && o.push(`
|
|
562
|
+
Path: ${n}`), i && o.push(`
|
|
563
|
+
Details: ${i}`), (s == null ? void 0 : s.length) > 0 && o.push(`
|
|
564
|
+
Available: ${s.join(", ")}`), r && o.push(`
|
|
565
|
+
💡 ${r}`), o.join("");
|
|
566
|
+
}
|
|
567
|
+
function ye(e, t, n = {}) {
|
|
568
|
+
const { path: r, available: i = [] } = n;
|
|
569
|
+
return z(`${e} "${t}" not found`, {
|
|
570
|
+
path: r,
|
|
571
|
+
available: i,
|
|
572
|
+
suggestion: i.length > 0 ? `Check spelling or add "${t}" to your ${e.toLowerCase()} registry` : `No ${e.toLowerCase()} are registered. Add ${e.toLowerCase()} to your registries or load from file`
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
function Ke(e, t, n, r = {}) {
|
|
576
|
+
return U(`Error evaluating ${t} function "${e}"`, {
|
|
577
|
+
...r,
|
|
578
|
+
details: n.message,
|
|
579
|
+
suggestion: "Check function implementation for runtime errors"
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
function Ge(e, t) {
|
|
583
|
+
return z(`No ${e} handler provided`, {
|
|
584
|
+
path: `props.${e}`,
|
|
585
|
+
suggestion: `Pass ${e} prop to Form component to handle ${t} action`
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function Be(e, t, n, r = {}) {
|
|
589
|
+
return U(`Error ${e} field "${t}"`, {
|
|
590
|
+
...r,
|
|
591
|
+
details: n.message,
|
|
592
|
+
suggestion: `Check ${e === "parsing" ? "parse" : "format"} function for field "${t}"`
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
function Je(e, t, n) {
|
|
596
|
+
const {
|
|
597
|
+
isDirty: r = !1,
|
|
598
|
+
isTouched: i = !1,
|
|
599
|
+
isFocused: s = !1,
|
|
600
|
+
isDisabled: o = !1,
|
|
601
|
+
isReadonly: a = !1,
|
|
602
|
+
isRequired: c = !1,
|
|
603
|
+
isComputed: u = !1,
|
|
604
|
+
hasErrors: p = !1
|
|
605
|
+
} = e;
|
|
606
|
+
return {
|
|
607
|
+
"data-field": t,
|
|
608
|
+
"data-type": n || "text",
|
|
609
|
+
"data-dirty": r.toString(),
|
|
610
|
+
"data-touched": i.toString(),
|
|
611
|
+
"data-focused": s.toString(),
|
|
612
|
+
"data-disabled": o.toString(),
|
|
613
|
+
"data-readonly": a.toString(),
|
|
614
|
+
"data-required": c.toString(),
|
|
615
|
+
"data-computed": u.toString(),
|
|
616
|
+
"data-valid": (!p).toString(),
|
|
617
|
+
"data-invalid": p.toString(),
|
|
618
|
+
"data-has-error": p.toString()
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
function Ie(e, t, n, r, i) {
|
|
622
|
+
return {
|
|
623
|
+
"data-button": e || t || "button",
|
|
624
|
+
"data-action": t || "",
|
|
625
|
+
"data-variant": n || "secondary",
|
|
626
|
+
"data-loading": r.toString(),
|
|
627
|
+
"data-disabled": i.toString()
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
function Ye(e, t) {
|
|
631
|
+
return {
|
|
632
|
+
"data-group": e || "group",
|
|
633
|
+
"data-visible": t.toString()
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function he(e, t, n = "element") {
|
|
637
|
+
var r;
|
|
638
|
+
if (!e) return !0;
|
|
639
|
+
if (e.show !== void 0) {
|
|
640
|
+
const i = e.show, s = t.functions || ((r = t.registries) == null ? void 0 : r.functions) || {};
|
|
641
|
+
if (typeof i == "string" && i.startsWith("{{") && i.endsWith("}}")) {
|
|
642
|
+
const o = i.slice(2, -2).trim(), a = s[o];
|
|
643
|
+
if (a && typeof a == "function") {
|
|
644
|
+
const c = C(e, () => t, n);
|
|
645
|
+
return a.call(c, t) !== !1;
|
|
646
|
+
}
|
|
647
|
+
return !!i;
|
|
648
|
+
}
|
|
649
|
+
if (typeof i == "function") {
|
|
650
|
+
const o = C(e, () => t, n);
|
|
651
|
+
return i.call(o, t) !== !1;
|
|
652
|
+
}
|
|
653
|
+
return !!i;
|
|
654
|
+
}
|
|
655
|
+
return !0;
|
|
656
|
+
}
|
|
657
|
+
function Ze(e) {
|
|
658
|
+
return e ? e.toString().toLowerCase().trim().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-") : "";
|
|
659
|
+
}
|
|
660
|
+
function Qe(e, t, n, r, i, s = {}) {
|
|
661
|
+
if (!r) return /* @__PURE__ */ new Set();
|
|
662
|
+
const o = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set([
|
|
663
|
+
...r.systemFields || [],
|
|
664
|
+
...r.readonly || []
|
|
665
|
+
]), c = i || { record: t, registries: n, config: r };
|
|
666
|
+
return e.forEach((u, p) => {
|
|
667
|
+
var d, m;
|
|
668
|
+
const h = x(
|
|
669
|
+
u,
|
|
670
|
+
c.functions || ((d = c.registries) == null ? void 0 : d.functions) || {},
|
|
671
|
+
((m = c.registries) == null ? void 0 : m.optionSets) || {},
|
|
672
|
+
() => c
|
|
673
|
+
), f = he(
|
|
674
|
+
h,
|
|
675
|
+
c,
|
|
676
|
+
h.name || `group[${p}]`
|
|
677
|
+
);
|
|
678
|
+
if (s[p] === !0 && !f && u.rows)
|
|
679
|
+
for (const b of u.rows)
|
|
680
|
+
for (const g of b) {
|
|
681
|
+
const y = typeof g == "string" ? g : g.name;
|
|
682
|
+
a.has(y) || o.add(y);
|
|
683
|
+
}
|
|
684
|
+
}), o;
|
|
685
|
+
}
|
|
686
|
+
function O(e) {
|
|
687
|
+
var n, r;
|
|
688
|
+
const t = ge(e.record, e.meta);
|
|
689
|
+
return {
|
|
690
|
+
hasKey: t != null && t !== "",
|
|
691
|
+
isDirty: ((n = e.form) == null ? void 0 : n.isDirty) ?? !1,
|
|
692
|
+
isDeleted: ((r = e.form) == null ? void 0 : r.isDeleted) ?? !1
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
function me(e) {
|
|
696
|
+
const { hasKey: t, isDirty: n, isDeleted: r } = O(e);
|
|
697
|
+
return r ? !1 : t || n;
|
|
698
|
+
}
|
|
699
|
+
function be(e) {
|
|
700
|
+
const { hasKey: t, isDeleted: n } = O(e);
|
|
701
|
+
return t && !n;
|
|
702
|
+
}
|
|
703
|
+
function we(e) {
|
|
704
|
+
const { hasKey: t, isDeleted: n } = O(e);
|
|
705
|
+
return t && !n;
|
|
706
|
+
}
|
|
707
|
+
function Ee(e) {
|
|
708
|
+
const { isDirty: t, isDeleted: n } = O(e);
|
|
709
|
+
return n ? !1 : t;
|
|
710
|
+
}
|
|
711
|
+
function Ae() {
|
|
712
|
+
return !0;
|
|
713
|
+
}
|
|
714
|
+
function ve(e) {
|
|
715
|
+
const { hasKey: t, isDeleted: n } = O(e);
|
|
716
|
+
return n ? "Undo Delete" : t ? "Save" : "Create";
|
|
717
|
+
}
|
|
718
|
+
function ke() {
|
|
719
|
+
return "Cancel";
|
|
720
|
+
}
|
|
721
|
+
const Xe = {
|
|
722
|
+
showNew: me,
|
|
723
|
+
showDuplicate: be,
|
|
724
|
+
showDelete: we,
|
|
725
|
+
showCancel: Ee,
|
|
726
|
+
showSave: Ae,
|
|
727
|
+
saveLabel: ve,
|
|
728
|
+
cancelLabel: ke
|
|
729
|
+
}, xe = {
|
|
730
|
+
save: {
|
|
731
|
+
name: "save",
|
|
732
|
+
label: "{{saveLabel}}",
|
|
733
|
+
action: "save",
|
|
734
|
+
variant: "primary",
|
|
735
|
+
show: "{{showSave}}"
|
|
736
|
+
},
|
|
737
|
+
cancel: {
|
|
738
|
+
name: "cancel",
|
|
739
|
+
label: "Cancel",
|
|
740
|
+
action: "cancel",
|
|
741
|
+
variant: "secondary",
|
|
742
|
+
show: "{{showCancel}}"
|
|
743
|
+
},
|
|
744
|
+
delete: {
|
|
745
|
+
name: "delete",
|
|
746
|
+
label: "Delete",
|
|
747
|
+
action: "delete",
|
|
748
|
+
variant: "danger",
|
|
749
|
+
show: "{{showDelete}}",
|
|
750
|
+
confirm: "Are you sure you want to delete this record?"
|
|
751
|
+
},
|
|
752
|
+
new: {
|
|
753
|
+
name: "new",
|
|
754
|
+
label: "New",
|
|
755
|
+
action: "new",
|
|
756
|
+
variant: "primary",
|
|
757
|
+
show: "{{showNew}}"
|
|
758
|
+
},
|
|
759
|
+
duplicate: {
|
|
760
|
+
name: "duplicate",
|
|
761
|
+
label: "Duplicate",
|
|
762
|
+
action: "duplicate",
|
|
763
|
+
variant: "secondary",
|
|
764
|
+
show: "{{showDuplicate}}"
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
async function _(e, t, n) {
|
|
768
|
+
var s;
|
|
769
|
+
const r = (s = t.hooks) == null ? void 0 : s[e];
|
|
770
|
+
if (!r) return !0;
|
|
771
|
+
const i = Array.isArray(r) ? r : [r];
|
|
772
|
+
for (const o of i) {
|
|
773
|
+
const a = o.replace(/{{|}}/g, "").trim(), c = t.functions[a];
|
|
774
|
+
if (!c) {
|
|
775
|
+
A.warn(ye("Hook function", a, {
|
|
776
|
+
path: `hooks.${e}`,
|
|
777
|
+
available: Object.keys(t.functions)
|
|
778
|
+
}));
|
|
779
|
+
continue;
|
|
780
|
+
}
|
|
781
|
+
try {
|
|
782
|
+
if (await c(t, n) === !1)
|
|
783
|
+
return !1;
|
|
784
|
+
} catch (u) {
|
|
785
|
+
return A.error(U(`Hook "${a}" failed`, {
|
|
786
|
+
path: `hooks.${e}`,
|
|
787
|
+
details: u.message,
|
|
788
|
+
suggestion: "Check hook function implementation for errors"
|
|
789
|
+
})), !1;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return !0;
|
|
793
|
+
}
|
|
794
|
+
function P(e) {
|
|
795
|
+
return e ? e.charAt(0).toUpperCase() + e.slice(1) : "";
|
|
796
|
+
}
|
|
797
|
+
function T(e) {
|
|
798
|
+
return e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
799
|
+
}
|
|
800
|
+
function $e(e) {
|
|
801
|
+
var i, s;
|
|
802
|
+
const t = ((i = e.registries) == null ? void 0 : i.fields) || {}, n = ((s = e.record) == null ? void 0 : s.data) || {};
|
|
803
|
+
let r = !0;
|
|
804
|
+
for (const [o, a] of Object.entries(t))
|
|
805
|
+
if (!(!a || typeof a != "object")) {
|
|
806
|
+
if (a.fields && typeof a.fields == "object") {
|
|
807
|
+
const c = a.fields, u = !!a.required, p = Object.entries(c).filter(([, f]) => f && typeof f == "object" && f.required).map(([f]) => f), h = !u && Object.keys(c).some(
|
|
808
|
+
(f) => !T(n[f])
|
|
809
|
+
);
|
|
810
|
+
if (u || h)
|
|
811
|
+
for (const f of p)
|
|
812
|
+
T(n[f]) && (e.form.setFieldErrors(f, ["Required"]), r = !1);
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
a.required && T(n[o]) && (e.form.setFieldErrors(o, ["Required"]), r = !1);
|
|
816
|
+
}
|
|
817
|
+
return r;
|
|
818
|
+
}
|
|
819
|
+
function et(e, t) {
|
|
820
|
+
return async function(r, i) {
|
|
821
|
+
const s = r.record;
|
|
822
|
+
if ((e === "save" || e === "create" || e === "update") && !$e(r))
|
|
823
|
+
return;
|
|
824
|
+
const o = `before${P(e)}`;
|
|
825
|
+
if (!await _(o, r, s)) return;
|
|
826
|
+
const c = await t(r, i), u = `after${P(e)}`;
|
|
827
|
+
return await _(u, r, s), c;
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
function L(e, t) {
|
|
831
|
+
var i, s, o;
|
|
832
|
+
const n = `on${P(t)}`, r = (i = e.props) == null ? void 0 : i[n];
|
|
833
|
+
return r || ((s = e.props) != null && s.onAction ? e.props.onAction : (o = e.functions) == null ? void 0 : o[t]);
|
|
834
|
+
}
|
|
835
|
+
const tt = {
|
|
836
|
+
async save(e, t) {
|
|
837
|
+
const { record: n, meta: r, form: i } = e, s = !!n.key;
|
|
838
|
+
if ((i == null ? void 0 : i.isDeleted) && (i != null && i.setDeleted) && i.setDeleted(!1), !await _(s ? "beforeUpdate" : "beforeCreate", e, n)) return;
|
|
839
|
+
const u = L(e, "save");
|
|
840
|
+
u && await u(e), await _(s ? "afterUpdate" : "afterCreate", e, n);
|
|
841
|
+
},
|
|
842
|
+
async cancel(e, t) {
|
|
843
|
+
const { meta: n, form: r } = e, i = (n == null ? void 0 : n.confirmCancel) ?? k.confirmCancel;
|
|
844
|
+
if (r.isDirty && i && !confirm(typeof i == "string" ? i : "You have unsaved changes. Are you sure you want to cancel?"))
|
|
845
|
+
return;
|
|
846
|
+
r != null && r.reset && r.reset();
|
|
847
|
+
const s = L(e, "cancel");
|
|
848
|
+
s && await s(e);
|
|
849
|
+
},
|
|
850
|
+
async delete(e, t) {
|
|
851
|
+
const { meta: n, form: r } = e, i = (n == null ? void 0 : n.confirmDelete) ?? k.confirmDelete;
|
|
852
|
+
if (i && !confirm(typeof i == "string" ? i : "Are you sure you want to delete this record?"))
|
|
853
|
+
return;
|
|
854
|
+
const s = L(e, "delete");
|
|
855
|
+
s && await s(e), r != null && r.setDeleted && r.setDeleted(!0);
|
|
856
|
+
},
|
|
857
|
+
async duplicate(e, t) {
|
|
858
|
+
const { meta: n, form: r, record: i } = e, s = (n == null ? void 0 : n.confirmDuplicate) ?? k.confirmDuplicate;
|
|
859
|
+
if (r.isDirty && s && !confirm(typeof s == "string" ? s : "You have unsaved changes. Duplicating will discard them. Continue?"))
|
|
860
|
+
return;
|
|
861
|
+
r.loadRecord({ key: null, data: { ...i.data } });
|
|
862
|
+
const o = L(e, "duplicate");
|
|
863
|
+
o && await o(e);
|
|
864
|
+
},
|
|
865
|
+
async new(e, t) {
|
|
866
|
+
var a;
|
|
867
|
+
const { meta: n, form: r } = e, i = (n == null ? void 0 : n.confirmNew) ?? k.confirmNew;
|
|
868
|
+
if (r.isDirty && i && !confirm(typeof i == "string" ? i : "You have unsaved changes. Creating new will discard them. Continue?"))
|
|
869
|
+
return;
|
|
870
|
+
const s = ((a = n == null ? void 0 : n.defaultRecord) == null ? void 0 : a.data) || {};
|
|
871
|
+
r.loadRecord({ key: null, data: { ...s } });
|
|
872
|
+
const o = L(e, "new");
|
|
873
|
+
o && await o(e);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
function nt(e) {
|
|
877
|
+
if (!e || typeof e != "string") return null;
|
|
878
|
+
const t = {
|
|
879
|
+
phone: /^\([0-9]{3}\) [0-9]{3}-[0-9]{4}$/,
|
|
880
|
+
ssn: /^[0-9]{3}-[0-9]{2}-[0-9]{4}$/,
|
|
881
|
+
ein: /^[0-9]{2}-[0-9]{7}$/,
|
|
882
|
+
creditCard: /^[0-9]{4} [0-9]{4} [0-9]{4} [0-9]{4}$/,
|
|
883
|
+
date: /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/[0-9]{4}$/,
|
|
884
|
+
zip: /^[0-9]{5}$/,
|
|
885
|
+
zipPlus4: /^[0-9]{5}-[0-9]{4}$/
|
|
886
|
+
};
|
|
887
|
+
for (const [n, r] of Object.entries(t))
|
|
888
|
+
if (r.test(e.replace(/[#9]/g, "0")))
|
|
889
|
+
return n;
|
|
890
|
+
return "custom";
|
|
891
|
+
}
|
|
892
|
+
function rt(e, t) {
|
|
893
|
+
if (!e || !t) return e;
|
|
894
|
+
const n = [];
|
|
895
|
+
for (const s of e)
|
|
896
|
+
(/\d/.test(s) || /[a-zA-Z]/.test(s)) && n.push(s);
|
|
897
|
+
let r = "", i = 0;
|
|
898
|
+
for (let s = 0; s < t.length && i < n.length; s++) {
|
|
899
|
+
const o = t[s];
|
|
900
|
+
if (o === "#" || o === "9") {
|
|
901
|
+
for (; i < n.length && !/\d/.test(n[i]); ) i++;
|
|
902
|
+
if (i >= n.length) break;
|
|
903
|
+
r += n[i++];
|
|
904
|
+
} else if (o === "A") {
|
|
905
|
+
for (; i < n.length && !/[a-zA-Z]/.test(n[i]); ) i++;
|
|
906
|
+
if (i >= n.length) break;
|
|
907
|
+
r += n[i++].toUpperCase();
|
|
908
|
+
} else
|
|
909
|
+
r += o;
|
|
910
|
+
}
|
|
911
|
+
return r;
|
|
912
|
+
}
|
|
913
|
+
function De(e, t, n, r) {
|
|
914
|
+
var a;
|
|
915
|
+
if (t == null || typeof t == "function" || typeof t != "string" || !t.startsWith("{{")) return t;
|
|
916
|
+
const i = t.slice(2, -2).trim(), s = (a = n == null ? void 0 : n.functions) == null ? void 0 : a[i];
|
|
917
|
+
if (!s) {
|
|
918
|
+
A.warn(`Function "${i}" not found for property "${e}"`);
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
const o = C(r, () => n, r == null ? void 0 : r.name);
|
|
922
|
+
if (ee(e))
|
|
923
|
+
return (c) => {
|
|
924
|
+
try {
|
|
925
|
+
return s.call(o, n, c);
|
|
926
|
+
} catch (u) {
|
|
927
|
+
A.error(`Error in event handler ${e} with function ${i}:`, u);
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
try {
|
|
932
|
+
return s.call(o, n, null);
|
|
933
|
+
} catch (c) {
|
|
934
|
+
A.error(`Error resolving ${e} with function ${i}:`, c);
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
function it(e, t) {
|
|
939
|
+
return e && e.show !== void 0 ? !!De("show", e.show, t, e) : !0;
|
|
940
|
+
}
|
|
941
|
+
function st(e, t, n) {
|
|
942
|
+
var i;
|
|
943
|
+
if (!(t != null && t.format)) return e;
|
|
944
|
+
let r;
|
|
945
|
+
if (typeof t.format == "function")
|
|
946
|
+
r = t.format;
|
|
947
|
+
else if (typeof t.format == "string") {
|
|
948
|
+
const s = t.format.replace(/^\{\{|\}\}$/g, "");
|
|
949
|
+
r = (i = n == null ? void 0 : n.functions) == null ? void 0 : i[s];
|
|
950
|
+
}
|
|
951
|
+
if (!r) return e;
|
|
952
|
+
try {
|
|
953
|
+
const s = C(t, () => n, t.name), o = r.call(s, n, null);
|
|
954
|
+
return o !== void 0 ? o : e;
|
|
955
|
+
} catch (s) {
|
|
956
|
+
return A.error(`Format error for field ${t.name}:`, s), e;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
function ot(e, t, n) {
|
|
960
|
+
var i;
|
|
961
|
+
if (!(t != null && t.parse)) return e;
|
|
962
|
+
const r = typeof t.parse == "function" ? t.parse : (i = n == null ? void 0 : n.functions) == null ? void 0 : i[t.parse];
|
|
963
|
+
if (!r) return e;
|
|
964
|
+
try {
|
|
965
|
+
const o = { ...C(t, () => n, t.name), value: e }, a = r.call(o, n, null);
|
|
966
|
+
return a !== void 0 ? a : e;
|
|
967
|
+
} catch (s) {
|
|
968
|
+
return A.error(`Parse error for field ${t.name}:`, s), e;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
const Se = /* @__PURE__ */ new Set([
|
|
972
|
+
"def",
|
|
973
|
+
"name",
|
|
974
|
+
"show",
|
|
975
|
+
"options",
|
|
976
|
+
"fields",
|
|
977
|
+
"layout",
|
|
978
|
+
"rows",
|
|
979
|
+
"validate",
|
|
980
|
+
"validator",
|
|
981
|
+
"format",
|
|
982
|
+
"formatter",
|
|
983
|
+
"parse",
|
|
984
|
+
"parser",
|
|
985
|
+
"mask",
|
|
986
|
+
"component",
|
|
987
|
+
"action",
|
|
988
|
+
"handler",
|
|
989
|
+
"__source",
|
|
990
|
+
"transform",
|
|
991
|
+
"dependencies",
|
|
992
|
+
"triggers",
|
|
993
|
+
"effects",
|
|
994
|
+
"rules",
|
|
995
|
+
"meta",
|
|
996
|
+
"itemlabel",
|
|
997
|
+
"itemlayout",
|
|
998
|
+
"defaultitem",
|
|
999
|
+
"buttons",
|
|
1000
|
+
"items",
|
|
1001
|
+
"legend",
|
|
1002
|
+
"innertext",
|
|
1003
|
+
"group",
|
|
1004
|
+
"title",
|
|
1005
|
+
"description",
|
|
1006
|
+
"confirm",
|
|
1007
|
+
"variant",
|
|
1008
|
+
"label",
|
|
1009
|
+
"hint",
|
|
1010
|
+
"clearable",
|
|
1011
|
+
"_componentName",
|
|
1012
|
+
"_component",
|
|
1013
|
+
"_adapter"
|
|
1014
|
+
]);
|
|
1015
|
+
function at(e) {
|
|
1016
|
+
const t = {}, n = {};
|
|
1017
|
+
for (const [r, i] of Object.entries(e))
|
|
1018
|
+
Se.has(r) || Array.isArray(i) || i !== null && typeof i == "object" && r !== "style" && !r.startsWith("data-") || r === "style" && typeof i == "string" || (r === "class" || r === "style" || r.startsWith("data-") ? t[r] = i : n[r] = i);
|
|
1019
|
+
return { wrapperProps: t, inputProps: n };
|
|
1020
|
+
}
|
|
1021
|
+
function ct({ meta: e = {}, layout: t = [], registries: n = {} }) {
|
|
1022
|
+
const r = [], { fields: i = {}, buttons: s = {}, optionSets: o = {}, functions: a = {} } = n;
|
|
1023
|
+
Fe(r, e, t, i, s, a), Le(r, i, s), Ce(r, t, i);
|
|
1024
|
+
const c = Oe(t);
|
|
1025
|
+
return je(r, i, o, c), Re(r, a), _e(r, i), r;
|
|
1026
|
+
}
|
|
1027
|
+
function S(e, t = "") {
|
|
1028
|
+
const n = [];
|
|
1029
|
+
if (typeof e == "string" && e.startsWith("{{") && e.endsWith("}}")) {
|
|
1030
|
+
const r = e.slice(2, -2);
|
|
1031
|
+
n.push({ name: r, path: t });
|
|
1032
|
+
} else typeof e == "object" && e !== null ? Object.entries(e).forEach(([r, i]) => {
|
|
1033
|
+
n.push(...S(i, t ? `${t}.${r}` : r));
|
|
1034
|
+
}) : Array.isArray(e) && e.forEach((r, i) => {
|
|
1035
|
+
n.push(...S(r, `${t}[${i}]`));
|
|
1036
|
+
});
|
|
1037
|
+
return n;
|
|
1038
|
+
}
|
|
1039
|
+
function Fe(e, t, n, r, i, s) {
|
|
1040
|
+
const o = [];
|
|
1041
|
+
o.push(...S(t, "meta")), o.push(...S(n, "layout")), Object.entries(r).forEach(([c, u]) => {
|
|
1042
|
+
o.push(...S(u, `fields.${c}`));
|
|
1043
|
+
}), Object.entries(i).forEach(([c, u]) => {
|
|
1044
|
+
o.push(...S(u, `buttons.${c}`));
|
|
1045
|
+
});
|
|
1046
|
+
const a = Object.keys(s);
|
|
1047
|
+
o.forEach(({ name: c, path: u }) => {
|
|
1048
|
+
s[c] || e.push({
|
|
1049
|
+
type: "missing_function",
|
|
1050
|
+
severity: "high",
|
|
1051
|
+
path: u,
|
|
1052
|
+
message: `Function "{{${c}}}" not found in registries.functions`,
|
|
1053
|
+
suggestion: a.length > 0 ? `Available functions: ${a.join(", ")}` : "No functions are registered. Add functions to registries.functions or load from functions.js"
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
function Le(e, t, n) {
|
|
1058
|
+
Object.entries(t).forEach(([r, i]) => {
|
|
1059
|
+
if (typeof i == "object" && i !== null && i["..."]) {
|
|
1060
|
+
const s = i["..."];
|
|
1061
|
+
t[s] || e.push({
|
|
1062
|
+
type: "missing_spread_ref",
|
|
1063
|
+
severity: "high",
|
|
1064
|
+
path: `fields.${r}`,
|
|
1065
|
+
message: `Spread reference "...": "${s}" not found in fields registry`,
|
|
1066
|
+
suggestion: `Available fields: ${Object.keys(t).join(", ")}`
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
}), Object.entries(n).forEach(([r, i]) => {
|
|
1070
|
+
if (typeof i == "object" && i !== null && i["..."]) {
|
|
1071
|
+
const s = i["..."];
|
|
1072
|
+
n[s] || e.push({
|
|
1073
|
+
type: "missing_spread_ref",
|
|
1074
|
+
severity: "high",
|
|
1075
|
+
path: `buttons.${r}`,
|
|
1076
|
+
message: `Spread reference "...": "${s}" not found in buttons registry`,
|
|
1077
|
+
suggestion: `Available buttons: ${Object.keys(n).join(", ")}`
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
function Ce(e, t, n) {
|
|
1083
|
+
const r = Object.keys(n);
|
|
1084
|
+
function i(s, o) {
|
|
1085
|
+
typeof s == "string" ? n[s] || e.push({
|
|
1086
|
+
type: "missing_field_ref",
|
|
1087
|
+
severity: "high",
|
|
1088
|
+
path: o,
|
|
1089
|
+
message: `Layout references field "${s}" but it doesn't exist in fields registry`,
|
|
1090
|
+
suggestion: r.length > 0 ? `Available fields: ${r.join(", ")}` : "No fields are defined. Add fields to registries.fields"
|
|
1091
|
+
}) : Array.isArray(s) ? s.forEach((a, c) => {
|
|
1092
|
+
i(a, `${o}[${c}]`);
|
|
1093
|
+
}) : typeof s == "object" && s !== null && (s.layout && s.layout.forEach((a, c) => {
|
|
1094
|
+
i(a, `${o}.layout[${c}]`);
|
|
1095
|
+
}), s.rows && s.rows.forEach((a, c) => {
|
|
1096
|
+
i(a, `${o}.rows[${c}]`);
|
|
1097
|
+
}));
|
|
1098
|
+
}
|
|
1099
|
+
t.forEach((s, o) => {
|
|
1100
|
+
i(s, `layout[${o}]`);
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
function Oe(e) {
|
|
1104
|
+
const t = /* @__PURE__ */ new Set();
|
|
1105
|
+
function n(r) {
|
|
1106
|
+
typeof r == "string" ? t.add(r) : Array.isArray(r) ? r.forEach(n) : typeof r == "object" && r !== null && (r.layout && r.layout.forEach(n), r.rows && r.rows.forEach(n));
|
|
1107
|
+
}
|
|
1108
|
+
return e.forEach(n), t;
|
|
1109
|
+
}
|
|
1110
|
+
function je(e, t, n, r) {
|
|
1111
|
+
const i = Object.keys(n);
|
|
1112
|
+
Object.entries(t).forEach(([s, o]) => {
|
|
1113
|
+
if (!(r && !r.has(s)) && typeof o == "object" && o !== null) {
|
|
1114
|
+
const a = o.options;
|
|
1115
|
+
if (typeof a == "string") {
|
|
1116
|
+
if (a.startsWith("{{") && a.endsWith("}}"))
|
|
1117
|
+
return;
|
|
1118
|
+
const c = a.startsWith("@") ? a.slice(1) : a;
|
|
1119
|
+
Array.isArray(n[c]) || e.push({
|
|
1120
|
+
type: "missing_options_ref",
|
|
1121
|
+
severity: "high",
|
|
1122
|
+
path: `fields.${s}.options`,
|
|
1123
|
+
message: `Options reference "${a}" not found in registries.optionSets`,
|
|
1124
|
+
suggestion: i.length > 0 ? `Available option sets: ${i.join(", ")}` : "No option sets are defined. Add options to registries.optionSets"
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
function Re(e, t) {
|
|
1131
|
+
Object.entries(t).forEach(([n, r]) => {
|
|
1132
|
+
typeof r == "object" && r !== null && typeof r.value == "function" && (r.value.prototype || e.push({
|
|
1133
|
+
type: "arrow_function_in_wrapper",
|
|
1134
|
+
severity: "high",
|
|
1135
|
+
path: `functions.${n}`,
|
|
1136
|
+
message: `Function "${n}" uses arrow function in wrapper format`,
|
|
1137
|
+
suggestion: 'Arrow functions cannot access stage via "this". Use regular function: function(context, event) { ... }'
|
|
1138
|
+
}));
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
function _e(e, t) {
|
|
1142
|
+
Object.entries(t).forEach(([n, r]) => {
|
|
1143
|
+
if (typeof r == "object" && r !== null) {
|
|
1144
|
+
const i = r.component, s = r.options !== void 0;
|
|
1145
|
+
(i === "Checkbox" || i === "Radio") && !s && e.push({
|
|
1146
|
+
type: "missing_options",
|
|
1147
|
+
severity: "medium",
|
|
1148
|
+
path: `fields.${n}`,
|
|
1149
|
+
message: `Field "${n}" uses component="${i}" but has no options defined`,
|
|
1150
|
+
suggestion: 'Add options property: options: ["option1", "option2"] or options: "optionSetName"'
|
|
1151
|
+
}), i === "Select" && !s && e.push({
|
|
1152
|
+
type: "missing_options",
|
|
1153
|
+
severity: "medium",
|
|
1154
|
+
path: `fields.${n}`,
|
|
1155
|
+
message: `Field "${n}" uses component="Select" but has no options defined`,
|
|
1156
|
+
suggestion: 'Add options property: options: ["option1", "option2"] or options: "optionSetName"'
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
function ft(e) {
|
|
1162
|
+
if (e.length === 0)
|
|
1163
|
+
return "✅ No validation errors found";
|
|
1164
|
+
const t = [`
|
|
1165
|
+
⚠️ Found ${e.length} validation error${e.length > 1 ? "s" : ""}:
|
|
1166
|
+
`];
|
|
1167
|
+
return e.forEach((n, r) => {
|
|
1168
|
+
const i = n.severity === "high" ? "🔴" : "🟡";
|
|
1169
|
+
t.push(`${i} ${r + 1}. ${n.message}`), t.push(` Path: ${n.path}`), n.suggestion && t.push(` 💡 ${n.suggestion}`), t.push("");
|
|
1170
|
+
}), t.join(`
|
|
1171
|
+
`);
|
|
1172
|
+
}
|
|
1173
|
+
const K = ["javascript:", "data:", "vbscript:"], He = /* @__PURE__ */ new Set([
|
|
1174
|
+
"b",
|
|
1175
|
+
"i",
|
|
1176
|
+
"em",
|
|
1177
|
+
"strong",
|
|
1178
|
+
"u",
|
|
1179
|
+
"s",
|
|
1180
|
+
"strike",
|
|
1181
|
+
"del",
|
|
1182
|
+
"p",
|
|
1183
|
+
"br",
|
|
1184
|
+
"hr",
|
|
1185
|
+
"div",
|
|
1186
|
+
"span",
|
|
1187
|
+
"h1",
|
|
1188
|
+
"h2",
|
|
1189
|
+
"h3",
|
|
1190
|
+
"h4",
|
|
1191
|
+
"h5",
|
|
1192
|
+
"h6",
|
|
1193
|
+
"ul",
|
|
1194
|
+
"ol",
|
|
1195
|
+
"li",
|
|
1196
|
+
"a",
|
|
1197
|
+
"code",
|
|
1198
|
+
"pre",
|
|
1199
|
+
"blockquote"
|
|
1200
|
+
]), V = {
|
|
1201
|
+
a: ["href", "title"],
|
|
1202
|
+
span: ["class"],
|
|
1203
|
+
div: ["class"],
|
|
1204
|
+
"*": ["id", "class"]
|
|
1205
|
+
// Attributes allowed on all tags
|
|
1206
|
+
};
|
|
1207
|
+
function ut(e) {
|
|
1208
|
+
if (!e || typeof e != "string") return "";
|
|
1209
|
+
const t = {
|
|
1210
|
+
"&": "&",
|
|
1211
|
+
"<": "<",
|
|
1212
|
+
">": ">",
|
|
1213
|
+
'"': """,
|
|
1214
|
+
"'": "'",
|
|
1215
|
+
"/": "/"
|
|
1216
|
+
};
|
|
1217
|
+
return e.replace(/[&<>"'/]/g, (n) => t[n]);
|
|
1218
|
+
}
|
|
1219
|
+
function N(e, t = {}) {
|
|
1220
|
+
if (typeof e != "string") return e;
|
|
1221
|
+
const { allowBasicHTML: n = !1, maxLength: r = void 0 } = t;
|
|
1222
|
+
let i = e;
|
|
1223
|
+
return n ? i = G(i) : i = i.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/\s*on\w+\s*=\s*["'][^"']*["']/gi, "").replace(/javascript:/gi, "").replace(/data:text\/html[^,]*,/gi, "").replace(/<[^>]+>/g, ""), r && i.length > r && (i = i.substring(0, r)), i.trim();
|
|
1224
|
+
}
|
|
1225
|
+
function G(e) {
|
|
1226
|
+
const t = document.createElement("div");
|
|
1227
|
+
return t.innerHTML = e, t.querySelectorAll("*").forEach((r) => {
|
|
1228
|
+
const i = r.tagName.toLowerCase();
|
|
1229
|
+
if (!He.has(i)) {
|
|
1230
|
+
r.remove();
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
Array.from(r.attributes).forEach((o) => {
|
|
1234
|
+
const a = o.name.toLowerCase();
|
|
1235
|
+
(!(V[i] || []).concat(V["*"] || []).includes(a) || a.startsWith("on")) && r.removeAttribute(o.name), (a === "href" || a === "src") && K.some((u) => o.value.toLowerCase().startsWith(u)) && (r.removeAttribute(o.name), A.error(`Blocked dangerous protocol in ${a}: ${o.value}`));
|
|
1236
|
+
});
|
|
1237
|
+
}), t.innerHTML;
|
|
1238
|
+
}
|
|
1239
|
+
function lt(e, t = {}) {
|
|
1240
|
+
return !e || typeof e != "string" ? "" : (A.warn("HTML sanitization in use. Consider using plain text or markdown instead."), G(e));
|
|
1241
|
+
}
|
|
1242
|
+
function dt(e) {
|
|
1243
|
+
if (!e || typeof e != "string") return "";
|
|
1244
|
+
let t = e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi, "");
|
|
1245
|
+
const n = document.createElement("div");
|
|
1246
|
+
return n.innerHTML = t, (n.textContent || n.innerText || "").trim();
|
|
1247
|
+
}
|
|
1248
|
+
function pt(e) {
|
|
1249
|
+
if (!e || typeof e != "string") return !1;
|
|
1250
|
+
const t = e.toLowerCase().trim();
|
|
1251
|
+
return K.some((n) => t.startsWith(n)) ? (A.error(`Dangerous URL protocol detected: ${e}`), !1) : t.startsWith("/") || t.startsWith("#") || t.startsWith("http://") || t.startsWith("https://") || t.startsWith("mailto:");
|
|
1252
|
+
}
|
|
1253
|
+
function Te(e, t = {}) {
|
|
1254
|
+
if (!e || typeof e != "object") return e;
|
|
1255
|
+
const { exclude: n = [], fieldOptions: r = {} } = t, i = {};
|
|
1256
|
+
for (const [s, o] of Object.entries(e)) {
|
|
1257
|
+
if (n.includes(s)) {
|
|
1258
|
+
i[s] = o;
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
const a = r[s] || {};
|
|
1262
|
+
typeof o == "string" ? i[s] = N(o, a) : Array.isArray(o) ? i[s] = o.map(
|
|
1263
|
+
(c) => typeof c == "string" ? N(c, a) : c
|
|
1264
|
+
) : o && typeof o == "object" ? i[s] = Te(o, {
|
|
1265
|
+
exclude: a.exclude,
|
|
1266
|
+
fieldOptions: a.nestedOptions
|
|
1267
|
+
}) : i[s] = o;
|
|
1268
|
+
}
|
|
1269
|
+
return i;
|
|
1270
|
+
}
|
|
1271
|
+
function D(e = {}) {
|
|
1272
|
+
return (t, n = {}) => N(t, { ...e, ...n });
|
|
1273
|
+
}
|
|
1274
|
+
const gt = {
|
|
1275
|
+
text: D({ maxLength: 1e3 }),
|
|
1276
|
+
name: D({ maxLength: 100 }),
|
|
1277
|
+
email: D({ maxLength: 254 }),
|
|
1278
|
+
// RFC 5321
|
|
1279
|
+
url: D({ maxLength: 2083 }),
|
|
1280
|
+
// IE limit
|
|
1281
|
+
phone: D({ maxLength: 20 }),
|
|
1282
|
+
username: D({ maxLength: 50 }),
|
|
1283
|
+
password: (e) => e,
|
|
1284
|
+
// Don't sanitize passwords
|
|
1285
|
+
richText: D({ allowBasicHTML: !0, maxLength: 1e4 }),
|
|
1286
|
+
comment: D({ maxLength: 5e3 }),
|
|
1287
|
+
numeric: (e) => typeof e != "string" ? e : e.replace(/[^\d.-]/g, "")
|
|
1288
|
+
}, yt = {
|
|
1289
|
+
innerHTML: "NEVER use innerHTML with user-generated content. Use textContent for safe text rendering.",
|
|
1290
|
+
userInput: "Always validate and sanitize user input on both client and server.",
|
|
1291
|
+
externalContent: "Treat all external content as untrusted. Sanitize before rendering.",
|
|
1292
|
+
urlValidation: "Always validate URLs before using them in href or src attributes."
|
|
1293
|
+
};
|
|
1294
|
+
function ht({ name: e, context: t, actionsContext: n, parentValidate: r }) {
|
|
1295
|
+
var i;
|
|
1296
|
+
return {
|
|
1297
|
+
...t,
|
|
1298
|
+
// Explicitly include registries
|
|
1299
|
+
registries: t.registries,
|
|
1300
|
+
functions: t.functions || ((i = t.registries) == null ? void 0 : i.functions) || {},
|
|
1301
|
+
form: {
|
|
1302
|
+
...n,
|
|
1303
|
+
getValue: (s) => (n.getValue(e) || {})[s],
|
|
1304
|
+
setValue: (s, o) => {
|
|
1305
|
+
const a = n.getValue(e) || {};
|
|
1306
|
+
n.setValue(e, {
|
|
1307
|
+
...a,
|
|
1308
|
+
[s]: o
|
|
1309
|
+
});
|
|
1310
|
+
},
|
|
1311
|
+
getFieldErrors: (s) => (n.getFieldErrors(e) || {})[s] || [],
|
|
1312
|
+
setFieldErrors: (s, o) => {
|
|
1313
|
+
const a = n.getFieldErrors(e) || {};
|
|
1314
|
+
n.setFieldErrors(e, {
|
|
1315
|
+
...a,
|
|
1316
|
+
[s]: o
|
|
1317
|
+
});
|
|
1318
|
+
},
|
|
1319
|
+
setFieldError: (s, o) => {
|
|
1320
|
+
const a = n.getFieldErrors(e) || {};
|
|
1321
|
+
n.setFieldErrors(e, {
|
|
1322
|
+
...a,
|
|
1323
|
+
[s]: Array.isArray(o) ? o : [o]
|
|
1324
|
+
});
|
|
1325
|
+
},
|
|
1326
|
+
clearFieldError: (s) => {
|
|
1327
|
+
const o = n.getFieldErrors(e) || {}, { [s]: a, ...c } = o;
|
|
1328
|
+
n.setFieldErrors(e, c);
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
fieldPath: t.fieldPath ? `${t.fieldPath}.${e}` : e,
|
|
1332
|
+
parentValidate: r
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
export {
|
|
1336
|
+
qe as DEFAULT_RECORD,
|
|
1337
|
+
te as FORM_TLP_DECLARATIONS,
|
|
1338
|
+
k as META_DEFAULTS,
|
|
1339
|
+
yt as SECURITY_WARNINGS,
|
|
1340
|
+
rt as applyMask,
|
|
1341
|
+
Ve as applyMetaDefaults,
|
|
1342
|
+
Xe as coreButtonFunctions,
|
|
1343
|
+
We as createLiveConfig,
|
|
1344
|
+
D as createSanitizer,
|
|
1345
|
+
ht as createScopedFormContext,
|
|
1346
|
+
wt as createTLPSchema,
|
|
1347
|
+
tt as defaultActions,
|
|
1348
|
+
xe as defaultButtons,
|
|
1349
|
+
nt as detectMaskType,
|
|
1350
|
+
ut as escapeHTML,
|
|
1351
|
+
he as evaluateVisibility,
|
|
1352
|
+
_ as executeHooks,
|
|
1353
|
+
M as formSchema,
|
|
1354
|
+
ft as formatValidationErrors,
|
|
1355
|
+
st as formatValue,
|
|
1356
|
+
Ke as functionError,
|
|
1357
|
+
Ie as getButtonDataAttributes,
|
|
1358
|
+
Je as getFieldDataAttributes,
|
|
1359
|
+
Qe as getFieldsToClear,
|
|
1360
|
+
Ye as getGroupDataAttributes,
|
|
1361
|
+
de as getRecordData,
|
|
1362
|
+
ge as getRecordKey,
|
|
1363
|
+
ze as initializeRecordFields,
|
|
1364
|
+
pt as isSafeURL,
|
|
1365
|
+
Ne as loadJsonConfig,
|
|
1366
|
+
Me as loadLiveConfig,
|
|
1367
|
+
Ge as missingHandler,
|
|
1368
|
+
ye as missingReference,
|
|
1369
|
+
Ue as mountForm,
|
|
1370
|
+
ot as parseValue,
|
|
1371
|
+
De as resolveProp,
|
|
1372
|
+
it as resolveVisibility,
|
|
1373
|
+
U as runtimeError,
|
|
1374
|
+
z as runtimeWarning,
|
|
1375
|
+
lt as sanitizeHTML,
|
|
1376
|
+
N as sanitizeInput,
|
|
1377
|
+
Te as sanitizeRecord,
|
|
1378
|
+
gt as sanitizers,
|
|
1379
|
+
at as separateProps,
|
|
1380
|
+
pe as setRecordData,
|
|
1381
|
+
Ze as slugify,
|
|
1382
|
+
dt as stripHTML,
|
|
1383
|
+
Be as transformError,
|
|
1384
|
+
ct as validateConfig,
|
|
1385
|
+
et as wrapWithHooks
|
|
1386
|
+
};
|
|
1387
|
+
//# sourceMappingURL=index.js.map
|