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