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