@a-ludi/rjsf-formulas 0.4.1 → 0.5.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.mjs +198 -186
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { findSchemaDefinition as
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
function
|
|
1
|
+
import { findSchemaDefinition as ct } from "@rjsf/utils";
|
|
2
|
+
import { jsx as it } from "react/jsx-runtime";
|
|
3
|
+
import { useState as ut, useRef as m, useEffect as w, useCallback as Q, forwardRef as at, useMemo as V } from "react";
|
|
4
|
+
import lt from "@rjsf/core";
|
|
5
|
+
const X = Symbol("arrayIndex");
|
|
6
|
+
function pt(t, r) {
|
|
7
7
|
const e = (r == null ? void 0 : r.formulaKey) ?? "x-formula", s = (r == null ? void 0 : r.formulaContextKey) ?? "x-formula-context", n = (r == null ? void 0 : r.formulaConflictBehavior) ?? "warn", o = [];
|
|
8
8
|
return O(t, [], o, e, s, n, !0, t), o;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function G(t, r) {
|
|
11
11
|
if (t === !0) return r;
|
|
12
12
|
const e = t;
|
|
13
13
|
return Array.isArray(e.allOf) ? { allOf: [...e.allOf, r] } : { allOf: [t, r] };
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function yt(t, r) {
|
|
16
16
|
return t === void 0 || t === "siblings" ? "siblings" : t === "extended" ? "extended" : (console.warn(
|
|
17
|
-
`[rjsf-formulas] Unknown x-formula-context value "${t}" at path [${
|
|
17
|
+
`[rjsf-formulas] Unknown x-formula-context value "${t}" at path [${Y(r)}], treating as "siblings"`
|
|
18
18
|
), "siblings");
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Y(t) {
|
|
21
21
|
return t.map((r) => typeof r == "symbol" ? "[*]" : String(r)).join(", ");
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function W(t) {
|
|
24
24
|
return t.map((r) => typeof r == "symbol" ? "[*]" : String(r)).join(".");
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
const s =
|
|
26
|
+
function dt(t, r, e) {
|
|
27
|
+
const s = W(t.path);
|
|
28
28
|
if (e === "error")
|
|
29
29
|
throw new TypeError(
|
|
30
|
-
`[rjsf-formulas] Formula conflict at path [${
|
|
30
|
+
`[rjsf-formulas] Formula conflict at path [${Y(t.path)}]: "${t.formula}" vs "${r.formula}". Resolve the conflict or set formulaConflictBehavior to 'ignore' or 'warn'.`
|
|
31
31
|
);
|
|
32
32
|
e === "warn" && console.warn(
|
|
33
33
|
`[rjsf-formulas] Formula conflict at path [${s}]: "${t.formula}" (earlier allOf branch) is overridden by "${r.formula}" (later allOf branch).`
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function mt(t, r, e) {
|
|
37
37
|
for (const s of r) {
|
|
38
|
-
const n =
|
|
39
|
-
o !== -1 ? (
|
|
38
|
+
const n = W(s.path), o = t.findIndex((i) => W(i.path) === n);
|
|
39
|
+
o !== -1 ? (dt(t[o], s, e), t[o] = s) : t.push(s);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function O(t, r, e, s, n, o, i, u) {
|
|
43
43
|
const f = t;
|
|
44
44
|
if (typeof f.$ref == "string") {
|
|
45
|
-
const c =
|
|
45
|
+
const c = ct(f.$ref, u);
|
|
46
46
|
O(c, r, e, s, n, o, i, u);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
@@ -50,14 +50,14 @@ function O(t, r, e, s, n, o, i, u) {
|
|
|
50
50
|
const c = f[s];
|
|
51
51
|
if (typeof c != "string") {
|
|
52
52
|
console.warn(
|
|
53
|
-
`[rjsf-formulas] Formula at path [${
|
|
53
|
+
`[rjsf-formulas] Formula at path [${Y(r)}] is not a string (got ${typeof c}), skipping.`
|
|
54
54
|
);
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
e.push({
|
|
58
58
|
path: r,
|
|
59
59
|
formula: c,
|
|
60
|
-
contextMode:
|
|
60
|
+
contextMode: yt(f[n], r),
|
|
61
61
|
condition: i
|
|
62
62
|
});
|
|
63
63
|
return;
|
|
@@ -81,7 +81,7 @@ function O(t, r, e, s, n, o, i, u) {
|
|
|
81
81
|
O(c, [...r, a], e, s, n, o, i, u);
|
|
82
82
|
}), t.items && !Array.isArray(t.items) && O(
|
|
83
83
|
t.items,
|
|
84
|
-
[...r,
|
|
84
|
+
[...r, X],
|
|
85
85
|
e,
|
|
86
86
|
s,
|
|
87
87
|
n,
|
|
@@ -92,27 +92,27 @@ function O(t, r, e, s, n, o, i, u) {
|
|
|
92
92
|
const c = f.allOf;
|
|
93
93
|
for (const a of c) {
|
|
94
94
|
const d = [];
|
|
95
|
-
O(a, r, d, s, n, o, i, u),
|
|
95
|
+
O(a, r, d, s, n, o, i, u), mt(e, d, o);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
for (const c of ["oneOf", "anyOf"])
|
|
99
99
|
if (Array.isArray(f[c])) {
|
|
100
100
|
const a = f[c];
|
|
101
101
|
for (const d of a) {
|
|
102
|
-
const g =
|
|
102
|
+
const g = G(i, d);
|
|
103
103
|
O(d, r, e, s, n, o, g, u);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
if ("if" in f) {
|
|
107
107
|
const c = f.if, a = f.then, d = f.else;
|
|
108
108
|
if (s in c && console.warn(
|
|
109
|
-
`[rjsf-formulas] Formula key "${s}" found inside an "if" schema at path [${
|
|
109
|
+
`[rjsf-formulas] Formula key "${s}" found inside an "if" schema at path [${Y(r)}]. The "if" schema is a validation predicate and is never rendered — the formula will be ignored.`
|
|
110
110
|
), a !== void 0) {
|
|
111
|
-
const g =
|
|
111
|
+
const g = G(i, c);
|
|
112
112
|
O(a, r, e, s, n, o, g, u);
|
|
113
113
|
}
|
|
114
114
|
if (d !== void 0) {
|
|
115
|
-
const g =
|
|
115
|
+
const g = G(i, { not: c });
|
|
116
116
|
O(d, r, e, s, n, o, g, u);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -120,9 +120,9 @@ function O(t, r, e, s, n, o, i, u) {
|
|
|
120
120
|
function gt(t) {
|
|
121
121
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
122
122
|
}
|
|
123
|
-
var
|
|
124
|
-
function
|
|
125
|
-
return
|
|
123
|
+
var H, tt;
|
|
124
|
+
function ht() {
|
|
125
|
+
return tt || (tt = 1, H = function t(r, e) {
|
|
126
126
|
if (r === e) return !0;
|
|
127
127
|
if (r && e && typeof r == "object" && typeof e == "object") {
|
|
128
128
|
if (r.constructor !== e.constructor) return !1;
|
|
@@ -146,11 +146,11 @@ function mt() {
|
|
|
146
146
|
return !0;
|
|
147
147
|
}
|
|
148
148
|
return r !== r && e !== e;
|
|
149
|
-
}),
|
|
149
|
+
}), H;
|
|
150
150
|
}
|
|
151
|
-
var
|
|
152
|
-
const jt = /* @__PURE__ */ gt(
|
|
153
|
-
function
|
|
151
|
+
var wt = ht();
|
|
152
|
+
const jt = /* @__PURE__ */ gt(wt);
|
|
153
|
+
function At(t, r, e, s) {
|
|
154
154
|
const o = r.slice(0, -1).reduce((u, f) => {
|
|
155
155
|
if (!(u == null || typeof u != "object"))
|
|
156
156
|
return u[f];
|
|
@@ -163,41 +163,41 @@ function wt(t, r, e, s) {
|
|
|
163
163
|
[s.formulaPathKey]: [...r]
|
|
164
164
|
}) : i;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function rt(t) {
|
|
167
167
|
return t.map((r) => typeof r == "symbol" ? "[*]" : String(r)).join(", ");
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function F(t, r) {
|
|
170
170
|
return r.reduce((e, s) => {
|
|
171
171
|
if (!(e == null || typeof e != "object"))
|
|
172
172
|
return e[s];
|
|
173
173
|
}, t);
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function Z(t, r, e) {
|
|
176
176
|
if (r.length === 0) return;
|
|
177
|
-
const s =
|
|
177
|
+
const s = F(t, r.slice(0, -1));
|
|
178
178
|
s != null && typeof s == "object" && (s[r[r.length - 1]] = e);
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function M(t, r, e = []) {
|
|
181
181
|
if (t.length === 0) return [e];
|
|
182
182
|
const [s, ...n] = t;
|
|
183
|
-
if (s ===
|
|
184
|
-
const o =
|
|
183
|
+
if (s === X) {
|
|
184
|
+
const o = F(r, e);
|
|
185
185
|
if (!Array.isArray(o)) return [];
|
|
186
186
|
const i = [];
|
|
187
187
|
for (let u = 0; u < o.length; u++)
|
|
188
|
-
i.push(...
|
|
188
|
+
i.push(...M(n, r, [...e, u]));
|
|
189
189
|
return i;
|
|
190
190
|
}
|
|
191
|
-
return
|
|
191
|
+
return M(n, r, [...e, s]);
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function B(t, r) {
|
|
194
194
|
return jt(t, r);
|
|
195
195
|
}
|
|
196
|
-
async function
|
|
196
|
+
async function et(t, r, e, s) {
|
|
197
197
|
const n = structuredClone(t), o = [];
|
|
198
198
|
for (const f of r)
|
|
199
|
-
for (const l of
|
|
200
|
-
const c =
|
|
199
|
+
for (const l of M(f.path, n)) {
|
|
200
|
+
const c = At(f, l, n, s);
|
|
201
201
|
o.push({ field: f, concretePath: l, context: c });
|
|
202
202
|
}
|
|
203
203
|
const i = await Promise.allSettled(
|
|
@@ -206,118 +206,118 @@ async function rt(t, r, e, s) {
|
|
|
206
206
|
for (let f = 0; f < o.length; f++) {
|
|
207
207
|
const { concretePath: l } = o[f], c = i[f];
|
|
208
208
|
if (c.status === "fulfilled")
|
|
209
|
-
|
|
209
|
+
Z(n, l, c.value);
|
|
210
210
|
else {
|
|
211
211
|
const a = c.reason instanceof Error ? c.reason : new Error(String(c.reason));
|
|
212
|
-
u.push({ path: l, error: a }),
|
|
212
|
+
u.push({ path: l, error: a }), Z(n, l, void 0);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
return { data: n, errors: u };
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function Ot(t, r, e) {
|
|
218
218
|
for (const s of e)
|
|
219
|
-
for (const n of
|
|
220
|
-
if (!
|
|
219
|
+
for (const n of M(s.path, r))
|
|
220
|
+
if (!B(F(t, n), F(r, n)))
|
|
221
221
|
return !1;
|
|
222
222
|
return !0;
|
|
223
223
|
}
|
|
224
|
-
async function
|
|
224
|
+
async function xt(t, r, e, s, n, o, i, u, f) {
|
|
225
225
|
const l = r.filter(
|
|
226
|
-
(
|
|
226
|
+
(p) => p.condition === !0 || u(p.condition, t)
|
|
227
227
|
);
|
|
228
228
|
if (l.length === 0) return t;
|
|
229
229
|
const c = /* @__PURE__ */ new Map(), a = [];
|
|
230
|
-
for (const
|
|
231
|
-
const
|
|
232
|
-
if (c.has(
|
|
230
|
+
for (const p of l) {
|
|
231
|
+
const y = JSON.stringify(p.path);
|
|
232
|
+
if (c.has(y)) {
|
|
233
233
|
if (f === "error")
|
|
234
234
|
throw new TypeError(
|
|
235
|
-
`[rjsf-formulas] Formula conflict: two active fields share path [${
|
|
235
|
+
`[rjsf-formulas] Formula conflict: two active fields share path [${rt(p.path)}]`
|
|
236
236
|
);
|
|
237
237
|
f === "warn" && console.warn(
|
|
238
|
-
`[rjsf-formulas] Formula conflict: two active fields share path [${
|
|
238
|
+
`[rjsf-formulas] Formula conflict: two active fields share path [${rt(p.path)}]; taking last`
|
|
239
239
|
);
|
|
240
|
-
const h = a.indexOf(c.get(
|
|
241
|
-
a[h] =
|
|
240
|
+
const h = a.indexOf(c.get(y));
|
|
241
|
+
a[h] = p, c.set(y, p);
|
|
242
242
|
} else
|
|
243
|
-
c.set(
|
|
243
|
+
c.set(y, p), a.push(p);
|
|
244
244
|
}
|
|
245
245
|
const d = { formulaDataKey: o, formulaPathKey: i };
|
|
246
246
|
let g = t;
|
|
247
|
-
for (let
|
|
248
|
-
const { data:
|
|
249
|
-
if (
|
|
250
|
-
for (const { path:
|
|
251
|
-
n == null || n(
|
|
252
|
-
return
|
|
247
|
+
for (let p = 0; p < s; p++) {
|
|
248
|
+
const { data: y, errors: h } = await et(g, a, e, d);
|
|
249
|
+
if (Ot(g, y, a)) {
|
|
250
|
+
for (const { path: j, error: b } of h)
|
|
251
|
+
n == null || n(j, b);
|
|
252
|
+
return y;
|
|
253
253
|
}
|
|
254
|
-
g =
|
|
254
|
+
g = y;
|
|
255
255
|
}
|
|
256
|
-
const { data:
|
|
257
|
-
for (const
|
|
258
|
-
for (const
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
const { data: x } = await et(g, a, e, d), v = structuredClone(x);
|
|
257
|
+
for (const p of a)
|
|
258
|
+
for (const y of M(p.path, x))
|
|
259
|
+
B(F(g, y), F(x, y)) || (n == null || n(
|
|
260
|
+
y,
|
|
261
261
|
new Error(
|
|
262
|
-
`[rjsf-formulas] Formula at [${
|
|
262
|
+
`[rjsf-formulas] Formula at [${y.join(", ")}] did not converge after ${s} passes`
|
|
263
263
|
)
|
|
264
|
-
),
|
|
265
|
-
return
|
|
264
|
+
), Z(v, y, void 0));
|
|
265
|
+
return v;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function bt(t) {
|
|
268
268
|
return JSON.stringify(t);
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
const [
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}, [o]),
|
|
275
|
-
|
|
276
|
-
}, [i]),
|
|
277
|
-
|
|
278
|
-
}, [e]),
|
|
279
|
-
|
|
280
|
-
}, [r]),
|
|
281
|
-
|
|
282
|
-
}, [n]),
|
|
283
|
-
|
|
284
|
-
}, [u]),
|
|
285
|
-
|
|
286
|
-
}, [f]),
|
|
287
|
-
|
|
270
|
+
function Rt(t, r, e, s, n, o, i, u, f, l, c) {
|
|
271
|
+
const [a, d] = ut(t), g = m(t), x = m(t), v = m(/* @__PURE__ */ new Map()), p = m(null), y = m(!1), h = m(o), j = m(i), b = m(e), S = m(r), U = m(n), E = m(u), k = m(f), _ = m(l);
|
|
272
|
+
w(() => {
|
|
273
|
+
h.current = o;
|
|
274
|
+
}, [o]), w(() => {
|
|
275
|
+
j.current = i;
|
|
276
|
+
}, [i]), w(() => {
|
|
277
|
+
b.current = e;
|
|
278
|
+
}, [e]), w(() => {
|
|
279
|
+
S.current = r;
|
|
280
|
+
}, [r]), w(() => {
|
|
281
|
+
U.current = n;
|
|
282
|
+
}, [n]), w(() => {
|
|
283
|
+
E.current = u;
|
|
284
|
+
}, [u]), w(() => {
|
|
285
|
+
k.current = f;
|
|
286
|
+
}, [f]), w(() => {
|
|
287
|
+
_.current = l;
|
|
288
288
|
}, [l]);
|
|
289
|
-
const
|
|
289
|
+
const D = Q(() => {
|
|
290
290
|
if (y.current) return;
|
|
291
291
|
(async () => {
|
|
292
|
-
var
|
|
292
|
+
var R, K;
|
|
293
293
|
y.current = !0;
|
|
294
294
|
try {
|
|
295
295
|
for (; ; ) {
|
|
296
|
-
const
|
|
297
|
-
(
|
|
298
|
-
),
|
|
299
|
-
for (const
|
|
300
|
-
for (const
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
for (const
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
296
|
+
const P = g.current, C = S.current, nt = C.filter(
|
|
297
|
+
(I) => I.condition === !0 || k.current(I.condition, P)
|
|
298
|
+
), T = [];
|
|
299
|
+
for (const I of nt)
|
|
300
|
+
for (const ft of M(I.path, P))
|
|
301
|
+
T.push(ft);
|
|
302
|
+
const z = v.current;
|
|
303
|
+
z.clear();
|
|
304
|
+
for (const I of T) z.set(bt(I), "running");
|
|
305
|
+
T.length > 0 && ((R = j.current) == null || R.call(j, T));
|
|
306
|
+
const st = await xt(
|
|
307
|
+
P,
|
|
308
|
+
C,
|
|
309
|
+
b.current,
|
|
310
|
+
U.current,
|
|
311
|
+
h.current,
|
|
312
|
+
E.current.formulaDataKey,
|
|
313
|
+
E.current.formulaPathKey,
|
|
314
|
+
k.current,
|
|
315
|
+
_.current
|
|
316
316
|
);
|
|
317
|
-
if (
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
320
|
-
|
|
317
|
+
if (J.current) break;
|
|
318
|
+
const ot = [...z.values()].some((I) => I === "dirty");
|
|
319
|
+
if (z.clear(), !ot) {
|
|
320
|
+
d(st), T.length > 0 && ((K = j.current) == null || K.call(j, []));
|
|
321
321
|
break;
|
|
322
322
|
}
|
|
323
323
|
}
|
|
@@ -325,58 +325,58 @@ function bt(t, r, e, s, n, o, i, u, f, l) {
|
|
|
325
325
|
y.current = !1;
|
|
326
326
|
}
|
|
327
327
|
})();
|
|
328
|
-
}, []),
|
|
329
|
-
(
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
for (const [
|
|
333
|
-
|
|
334
|
-
y.current || (
|
|
335
|
-
|
|
328
|
+
}, []), q = Q(
|
|
329
|
+
(A) => {
|
|
330
|
+
g.current = A;
|
|
331
|
+
const R = v.current;
|
|
332
|
+
for (const [K, P] of R)
|
|
333
|
+
P === "running" && R.set(K, "dirty");
|
|
334
|
+
y.current || (p.current !== null && clearTimeout(p.current), p.current = setTimeout(() => {
|
|
335
|
+
p.current = null, D();
|
|
336
336
|
}, s));
|
|
337
337
|
},
|
|
338
|
-
[s,
|
|
339
|
-
),
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
}),
|
|
343
|
-
|
|
344
|
-
}), []), { enrichedFormData:
|
|
338
|
+
[s, D]
|
|
339
|
+
), $ = m(!1), J = m(!1);
|
|
340
|
+
return w(() => {
|
|
341
|
+
$.current ? B(t, x.current) || (x.current = t, q(t)) : ($.current = !0, x.current = t, c !== "skip" && q(t));
|
|
342
|
+
}), w(() => (J.current = !1, () => {
|
|
343
|
+
J.current = !0, $.current = !1, p.current !== null && clearTimeout(p.current);
|
|
344
|
+
}), []), { enrichedFormData: a, handleInput: q };
|
|
345
345
|
}
|
|
346
|
-
function
|
|
347
|
-
const e = structuredClone(t ?? {}), s =
|
|
346
|
+
function $t(t, r) {
|
|
347
|
+
const e = structuredClone(t ?? {}), s = It(r);
|
|
348
348
|
for (const n of r)
|
|
349
|
-
|
|
349
|
+
N(e, n.path, s);
|
|
350
350
|
return e;
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function It(t) {
|
|
353
353
|
const r = /* @__PURE__ */ new Set();
|
|
354
354
|
for (let e = 0; e < t.length; e++) {
|
|
355
355
|
const s = t[e].path;
|
|
356
356
|
for (let n = 0; n < s.length; n++) {
|
|
357
357
|
const o = s[n];
|
|
358
|
-
if (typeof o != "number" && o !==
|
|
359
|
-
const i =
|
|
358
|
+
if (typeof o != "number" && o !== X) continue;
|
|
359
|
+
const i = L(s.slice(0, n)), u = typeof o == "number";
|
|
360
360
|
t.some((l, c) => {
|
|
361
|
-
if (c === e || l.path.length <= n ||
|
|
361
|
+
if (c === e || l.path.length <= n || L(l.path.slice(0, n)) !== i) return !1;
|
|
362
362
|
const a = l.path[n];
|
|
363
|
-
return u ? a ===
|
|
363
|
+
return u ? a === X : typeof a == "number";
|
|
364
364
|
}) && r.add(i);
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
return r;
|
|
368
368
|
}
|
|
369
|
-
function
|
|
369
|
+
function L(t) {
|
|
370
370
|
return JSON.stringify(t.map((r) => typeof r == "symbol" ? "__ARRAY_INDEX__" : r));
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function N(t, r, e, s = []) {
|
|
373
373
|
if (r.length === 0) {
|
|
374
374
|
t["ui:readonly"] = !0;
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
377
|
const [n, ...o] = r;
|
|
378
378
|
if (typeof n == "string") {
|
|
379
|
-
(!t[n] || typeof t[n] != "object" || Array.isArray(t[n])) && (t[n] = {}),
|
|
379
|
+
(!t[n] || typeof t[n] != "object" || Array.isArray(t[n])) && (t[n] = {}), N(t[n], o, e, [...s, n]);
|
|
380
380
|
return;
|
|
381
381
|
}
|
|
382
382
|
if (typeof n == "number") {
|
|
@@ -386,86 +386,98 @@ function P(t, r, e, s = []) {
|
|
|
386
386
|
}
|
|
387
387
|
Array.isArray(t.items) || (t.items = []);
|
|
388
388
|
const f = t.items;
|
|
389
|
-
(!f[n] || typeof f[n] != "object") && (f[n] = {}),
|
|
389
|
+
(!f[n] || typeof f[n] != "object") && (f[n] = {}), N(f[n], o, e, [...s, n]);
|
|
390
390
|
return;
|
|
391
391
|
}
|
|
392
|
-
const i =
|
|
392
|
+
const i = L(s);
|
|
393
393
|
if (e.has(i))
|
|
394
|
-
(!t.additionalItems || typeof t.additionalItems != "object") && (t.additionalItems = {}),
|
|
394
|
+
(!t.additionalItems || typeof t.additionalItems != "object") && (t.additionalItems = {}), N(t.additionalItems, o, e, [...s, n]);
|
|
395
395
|
else {
|
|
396
396
|
if (Array.isArray(t.items)) {
|
|
397
397
|
console.warn("[rjsf-formulas] mergeReadOnly: cannot inject ui:readonly for uniform array because existing uiSchema has items as an array. Skipping.");
|
|
398
398
|
return;
|
|
399
399
|
}
|
|
400
|
-
(!t.items || typeof t.items != "object") && (t.items = {}),
|
|
400
|
+
(!t.items || typeof t.items != "object") && (t.items = {}), N(t.items, o, e, [...s, n]);
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function vt(t, r) {
|
|
404
404
|
const {
|
|
405
405
|
schema: e,
|
|
406
406
|
formData: s,
|
|
407
407
|
validator: n,
|
|
408
408
|
uiSchema: o,
|
|
409
409
|
evaluator: i,
|
|
410
|
-
Form: u =
|
|
410
|
+
Form: u = lt,
|
|
411
411
|
formulaKey: f = "x-formula",
|
|
412
412
|
formulaContextKey: l = "x-formula-context",
|
|
413
413
|
formulaDataKey: c = "__formData__",
|
|
414
414
|
formulaPathKey: a = "__path__",
|
|
415
415
|
maxConvergencePasses: d = 10,
|
|
416
416
|
debounceMs: g = 300,
|
|
417
|
-
onFormulaError:
|
|
418
|
-
onLoadingChange:
|
|
419
|
-
formulaConflictBehavior:
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
417
|
+
onFormulaError: x,
|
|
418
|
+
onLoadingChange: v,
|
|
419
|
+
formulaConflictBehavior: p = "warn",
|
|
420
|
+
initialComputationMode: y = "always",
|
|
421
|
+
onChange: h,
|
|
422
|
+
...j
|
|
423
|
+
} = t, b = V(
|
|
424
|
+
() => pt(e, { formulaKey: f, formulaContextKey: l }),
|
|
424
425
|
[e, f, l]
|
|
425
|
-
),
|
|
426
|
+
), S = V(
|
|
426
427
|
() => ({ formulaDataKey: c, formulaPathKey: a }),
|
|
427
428
|
[c, a]
|
|
428
|
-
),
|
|
429
|
-
() =>
|
|
430
|
-
[o,
|
|
431
|
-
),
|
|
432
|
-
(A,
|
|
429
|
+
), U = V(
|
|
430
|
+
() => $t(o, b),
|
|
431
|
+
[o, b]
|
|
432
|
+
), E = Q(
|
|
433
|
+
(A, R) => n.isValid(A, R, e),
|
|
433
434
|
[n, e]
|
|
434
|
-
),
|
|
435
|
+
), k = y === "always" ? 0 : y === "skip" ? 1 : 2, _ = m(k);
|
|
436
|
+
w(() => (_.current = k, () => {
|
|
437
|
+
_.current = k;
|
|
438
|
+
}), []);
|
|
439
|
+
const { enrichedFormData: D, handleInput: q } = Rt(
|
|
435
440
|
s,
|
|
436
|
-
|
|
441
|
+
b,
|
|
437
442
|
i,
|
|
438
443
|
g,
|
|
439
444
|
d,
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
445
|
+
x,
|
|
446
|
+
v,
|
|
447
|
+
S,
|
|
448
|
+
E,
|
|
449
|
+
p,
|
|
444
450
|
y
|
|
445
|
-
),
|
|
446
|
-
return
|
|
447
|
-
|
|
448
|
-
}, [
|
|
451
|
+
), $ = m(h);
|
|
452
|
+
return w(() => {
|
|
453
|
+
$.current = h;
|
|
454
|
+
}, [h]), w(() => {
|
|
449
455
|
var A;
|
|
450
|
-
|
|
451
|
-
|
|
456
|
+
if (b.length !== 0) {
|
|
457
|
+
if (_.current > 0) {
|
|
458
|
+
_.current--;
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
(A = $.current) == null || A.call($, { formData: D }, void 0);
|
|
462
|
+
}
|
|
463
|
+
}, [D]), /* @__PURE__ */ it(
|
|
452
464
|
u,
|
|
453
465
|
{
|
|
454
466
|
ref: r,
|
|
455
|
-
...
|
|
467
|
+
...j,
|
|
456
468
|
schema: e,
|
|
457
469
|
validator: n,
|
|
458
|
-
formData:
|
|
459
|
-
uiSchema:
|
|
460
|
-
onChange: (A,
|
|
461
|
-
|
|
470
|
+
formData: D,
|
|
471
|
+
uiSchema: U,
|
|
472
|
+
onChange: (A, R) => {
|
|
473
|
+
q(A.formData), h == null || h(A, R);
|
|
462
474
|
}
|
|
463
475
|
}
|
|
464
476
|
);
|
|
465
477
|
}
|
|
466
|
-
const
|
|
478
|
+
const Mt = at(vt);
|
|
467
479
|
export {
|
|
468
|
-
|
|
469
|
-
|
|
480
|
+
Mt as FormulaForm,
|
|
481
|
+
pt as analyzeSchema
|
|
470
482
|
};
|
|
471
483
|
//# sourceMappingURL=index.mjs.map
|