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