mlform 0.1.15 → 0.1.18
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/README.md +2 -2
- package/dist/{builtins-CcS-sHJa.js → builtins-STiTwaH9.js} +102 -107
- package/dist/mlform/builtins.mjs +2 -2
- package/dist/mlform/kit.mjs +251 -231
- package/dist/mlform/primitives.mjs +1 -1
- package/dist/mlform/runtime.mjs +3 -3
- package/dist/mlform/schema.mjs +2 -2
- package/dist/mlform/transport.mjs +1 -1
- package/dist/{primitives-9obTthA6.js → primitives-BcXt2QWI.js} +83 -53
- package/dist/{runtime-Bn_x46y-.js → runtime-Eo_q4pgg.js} +610 -506
- package/dist/schema-CNKKJZRx.js +173 -0
- package/dist/{transport-D173EDlB.js → transport-Cloa_erk.js} +204 -196
- package/dist/types/src/builtins/constants.d.ts +0 -4
- package/dist/types/src/builtins/definitions/fields/series-helpers.d.ts +1 -0
- package/dist/types/src/builtins/definitions/shared.d.ts +1 -1
- package/dist/types/src/kit/mount-types.d.ts +2 -0
- package/dist/types/src/kit/view-core-types.d.ts +4 -1
- package/dist/types/src/primitives/components/form-root-templates.d.ts +3 -1
- package/dist/types/src/primitives/components/form-root.d.ts +3 -1
- package/dist/types/src/primitives/components/report-frame.d.ts +2 -1
- package/dist/types/src/primitives/controller-types.d.ts +46 -2
- package/dist/types/src/primitives/types.d.ts +6 -2
- package/dist/types/src/runtime/index.d.ts +4 -2
- package/dist/types/src/runtime/submission/index.d.ts +2 -0
- package/dist/types/src/runtime/submission/multi-backend.d.ts +25 -0
- package/dist/types/src/runtime/submission/request.d.ts +14 -0
- package/dist/types/src/runtime/submission/snapshot.d.ts +12 -0
- package/dist/types/src/runtime/types/behavior.d.ts +4 -0
- package/dist/types/src/runtime/types/field.d.ts +1 -0
- package/dist/types/src/runtime/types/form.d.ts +4 -0
- package/dist/types/src/runtime/types/transport.d.ts +11 -2
- package/dist/types/src/schema/index.d.ts +2 -0
- package/dist/types/src/schema/mapped-to.d.ts +3 -2
- package/dist/types/src/schema/onehot-display.d.ts +15 -0
- package/dist/types/src/schema/report-context.d.ts +17 -0
- package/dist/types/src/schema/types/field.d.ts +1 -0
- package/dist/types/src/schema/types/report.d.ts +7 -2
- package/dist/types/src/schema/types/submit.d.ts +31 -1
- package/dist/types/src/transport/types/core.d.ts +19 -2
- package/package.json +2 -1
- package/dist/schema-DYDo_1VV.js +0 -95
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { I as
|
|
1
|
+
import { a as e, d as t, f as n, m as r, n as i, p as a, t as o, u as s } from "./schema-CNKKJZRx.js";
|
|
2
|
+
import { I as c, J as l, L as u, Y as d } from "./transport-Cloa_erk.js";
|
|
3
3
|
//#region src/runtime/submission/report-fetches.ts
|
|
4
|
-
var
|
|
4
|
+
var f = "Unknown report fetch error.", p = async ({ reports: e, request: t }) => {
|
|
5
5
|
let n = e.filter((e) => e.canFetch && e.state.status === "idle");
|
|
6
6
|
if (n.length === 0) return {
|
|
7
7
|
results: {},
|
|
@@ -9,7 +9,8 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
9
9
|
};
|
|
10
10
|
await Promise.allSettled(n.map((e) => e.fetch({
|
|
11
11
|
...t,
|
|
12
|
-
reportId: e.id
|
|
12
|
+
reportId: e.id,
|
|
13
|
+
reportContext: t.reportContexts?.[e.id]
|
|
13
14
|
})));
|
|
14
15
|
let r = {}, i = {};
|
|
15
16
|
for (let e of n) {
|
|
@@ -18,38 +19,74 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
18
19
|
r[e.id] = t.payload;
|
|
19
20
|
continue;
|
|
20
21
|
}
|
|
21
|
-
t.status === "error" && (i[e.id] = t.error ??
|
|
22
|
+
t.status === "error" && (i[e.id] = t.error ?? f);
|
|
22
23
|
}
|
|
23
24
|
return {
|
|
24
25
|
results: r,
|
|
25
26
|
errors: i
|
|
26
27
|
};
|
|
27
|
-
},
|
|
28
|
-
let
|
|
28
|
+
}, m = Object.freeze({}), h = async ({ form: e, submit: t, artifactAdapter: n, reportFetchMode: r = "all" }) => {
|
|
29
|
+
let i = await e.submit(t), a = r === "all" ? await p({
|
|
29
30
|
reports: e.reports,
|
|
30
|
-
request: i
|
|
31
|
+
request: o(i, { signal: t?.signal })
|
|
31
32
|
}) : {
|
|
32
33
|
results: {},
|
|
33
34
|
errors: {}
|
|
34
35
|
}, s = {
|
|
35
|
-
submitResult:
|
|
36
|
-
reportFetchResults:
|
|
37
|
-
reportFetchErrors:
|
|
38
|
-
}, c = n ? await n.derive(s) :
|
|
36
|
+
submitResult: i,
|
|
37
|
+
reportFetchResults: a.results,
|
|
38
|
+
reportFetchErrors: a.errors
|
|
39
|
+
}, c = n ? await n.derive(s) : m;
|
|
39
40
|
return {
|
|
40
|
-
submitResult:
|
|
41
|
-
reportFetchResults:
|
|
42
|
-
reportFetchErrors:
|
|
41
|
+
submitResult: i,
|
|
42
|
+
reportFetchResults: a.results,
|
|
43
|
+
reportFetchErrors: a.errors,
|
|
43
44
|
artifacts: c
|
|
44
45
|
};
|
|
45
|
-
},
|
|
46
|
+
}, g = class extends Error {
|
|
47
|
+
constructor(e) {
|
|
48
|
+
super(e), this.name = "EngineError";
|
|
49
|
+
}
|
|
50
|
+
}, _ = class extends g {
|
|
51
|
+
constructor(e) {
|
|
52
|
+
super(e), this.name = "RegistryError";
|
|
53
|
+
}
|
|
54
|
+
}, v = class extends g {
|
|
55
|
+
result;
|
|
56
|
+
constructor(e) {
|
|
57
|
+
super("Form validation failed."), this.name = "ValidationError", this.result = e;
|
|
58
|
+
}
|
|
59
|
+
}, y = class extends g {
|
|
60
|
+
cause;
|
|
61
|
+
constructor(e, t) {
|
|
62
|
+
super(e), this.name = "SubmitError", this.cause = t;
|
|
63
|
+
}
|
|
64
|
+
}, b = class extends y {
|
|
65
|
+
reportId;
|
|
66
|
+
constructor(e, t, n) {
|
|
67
|
+
super(`Invalid payload for report "${e}": ${t}`, n), this.name = "ReportPayloadError", this.reportId = e;
|
|
68
|
+
}
|
|
69
|
+
}, x = class extends y {
|
|
70
|
+
code = d.ABORTED;
|
|
71
|
+
constructor(e = "Form submission was aborted.", t) {
|
|
72
|
+
super(e, t), this.name = "SubmissionAbortedError";
|
|
73
|
+
}
|
|
74
|
+
}, S = (e) => new x(e ? `Form submission was aborted: ${e}` : void 0), ee = (e) => e instanceof x || e instanceof Error && e.name === "AbortError", C = (e) => {
|
|
75
|
+
if (!e || typeof e.submit != "function") throw new g("createForm requires a transport with a submit(request) function.");
|
|
76
|
+
}, w = (e) => {
|
|
77
|
+
for (let t in e) {
|
|
78
|
+
let n = e[t];
|
|
79
|
+
if (n?.dirty || n?.touched) return !0;
|
|
80
|
+
}
|
|
81
|
+
return !1;
|
|
82
|
+
}, T = (e, t) => e.config.inactiveFieldPolicy ?? t ?? "omit", E = (e, t) => new g(`${e} definition "${t}" disappeared during form creation.`), D = (e) => typeof e == "object" && !!e && !Array.isArray(e), O = (e) => typeof e == "object" && !!e || typeof e == "function", k = (e) => O(e) && "then" in e && typeof e.then == "function", A = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) ? e.length === 0 : e instanceof Date ? Number.isNaN(e.getTime()) : !1, te = (e) => e, j = (e) => {
|
|
46
83
|
let t = typeof ArrayBuffer < "u" && ArrayBuffer.isView(e), n = typeof ArrayBuffer < "u" && e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer, r = typeof Blob < "u" && e instanceof Blob || typeof File < "u" && e instanceof File;
|
|
47
84
|
if (e !== null && (typeof e == "object" || typeof e == "function") && !t && !n && !r && !Object.isFrozen(e)) {
|
|
48
85
|
Object.freeze(e);
|
|
49
|
-
for (let t of Object.values(e))
|
|
86
|
+
for (let t of Object.values(e)) j(t);
|
|
50
87
|
}
|
|
51
88
|
return e;
|
|
52
|
-
},
|
|
89
|
+
}, ne = (e, t) => e <= 0 ? Promise.resolve() : new Promise((n, r) => {
|
|
53
90
|
let i = setTimeout(() => {
|
|
54
91
|
t?.removeEventListener("abort", a), n();
|
|
55
92
|
}, e), a = () => {
|
|
@@ -60,12 +97,12 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
60
97
|
return;
|
|
61
98
|
}
|
|
62
99
|
t?.addEventListener("abort", a, { once: !0 });
|
|
63
|
-
}),
|
|
100
|
+
}), re = (e, t) => (Array.isArray(e) ? e : (e ?? t).split(".")).map((e) => e.trim()).filter(Boolean), M = (e, t, n) => {
|
|
64
101
|
if (t.length === 0) return;
|
|
65
102
|
let r = e;
|
|
66
103
|
for (let e of t.slice(0, -1)) {
|
|
67
104
|
let t = r[e];
|
|
68
|
-
if (!
|
|
105
|
+
if (!D(t)) {
|
|
69
106
|
let t = {};
|
|
70
107
|
r[e] = t, r = t;
|
|
71
108
|
continue;
|
|
@@ -73,158 +110,206 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
73
110
|
r = t;
|
|
74
111
|
}
|
|
75
112
|
r[t[t.length - 1]] = n;
|
|
76
|
-
},
|
|
113
|
+
}, ie = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView), ae = (e) => {
|
|
77
114
|
let t = new Uint8Array(e.byteLength);
|
|
78
115
|
return t.set(new Uint8Array(e)), t.buffer;
|
|
79
|
-
},
|
|
116
|
+
}, oe = (e) => typeof File < "u" && e instanceof File ? new File([e], e.name, {
|
|
80
117
|
type: e.type,
|
|
81
118
|
lastModified: e.lastModified
|
|
82
|
-
}) : typeof Blob < "u" && e instanceof Blob ? e.slice(0, e.size, e.type) : e,
|
|
119
|
+
}) : typeof Blob < "u" && e instanceof Blob ? e.slice(0, e.size, e.type) : e, se = (e, t) => e.length === t.length && e.every((e, n) => e === t[n]), ce = (e, t) => e.byteLength === t.byteLength ? se(new Uint8Array(e), new Uint8Array(t)) : !1, N = (e) => {
|
|
83
120
|
if (e instanceof Date) return new Date(e.getTime());
|
|
84
121
|
if (e instanceof RegExp) return new RegExp(e.source, e.flags);
|
|
85
|
-
if (e instanceof ArrayBuffer) return
|
|
86
|
-
if (e instanceof DataView) return new DataView(
|
|
87
|
-
if (
|
|
122
|
+
if (e instanceof ArrayBuffer) return ae(e);
|
|
123
|
+
if (e instanceof DataView) return new DataView(ae(e.buffer), e.byteOffset, e.byteLength);
|
|
124
|
+
if (ie(e)) {
|
|
88
125
|
let t = e.constructor;
|
|
89
|
-
return new t(
|
|
126
|
+
return new t(ae(e.buffer), e.byteOffset, e.length);
|
|
90
127
|
}
|
|
91
|
-
return e instanceof Map ? new Map(Array.from(e.entries(), ([e, t]) => [
|
|
92
|
-
},
|
|
128
|
+
return e instanceof Map ? new Map(Array.from(e.entries(), ([e, t]) => [N(e), N(t)])) : e instanceof Set ? new Set(Array.from(e.values(), (e) => N(e))) : typeof File < "u" && e instanceof File || typeof Blob < "u" && e instanceof Blob ? oe(e) : Array.isArray(e) ? e.map((e) => N(e)) : D(e) ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e, N(t)])) : e;
|
|
129
|
+
}, P = (e, t) => {
|
|
93
130
|
if (Object.is(e, t)) return !0;
|
|
94
131
|
if (e instanceof Date && t instanceof Date) return e.getTime() === t.getTime();
|
|
95
132
|
if (e instanceof RegExp && t instanceof RegExp) return e.source === t.source && e.flags === t.flags;
|
|
96
|
-
if (e instanceof ArrayBuffer && t instanceof ArrayBuffer) return
|
|
97
|
-
if (e instanceof DataView && t instanceof DataView) return e.byteOffset === t.byteOffset && e.byteLength === t.byteLength &&
|
|
98
|
-
if (
|
|
133
|
+
if (e instanceof ArrayBuffer && t instanceof ArrayBuffer) return ce(e, t);
|
|
134
|
+
if (e instanceof DataView && t instanceof DataView) return e.byteOffset === t.byteOffset && e.byteLength === t.byteLength && ce(e.buffer, t.buffer);
|
|
135
|
+
if (ie(e) && ie(t)) {
|
|
99
136
|
let n = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), r = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
100
|
-
return e.constructor === t.constructor &&
|
|
137
|
+
return e.constructor === t.constructor && se(n, r);
|
|
101
138
|
}
|
|
102
139
|
if (e instanceof Map && t instanceof Map) return e.size === t.size && Array.from(e.entries()).every(([e, n], r) => {
|
|
103
140
|
let i = Array.from(t.entries())[r];
|
|
104
|
-
return i !== void 0 &&
|
|
141
|
+
return i !== void 0 && P(e, i[0]) && P(n, i[1]);
|
|
105
142
|
});
|
|
106
143
|
if (e instanceof Set && t instanceof Set) {
|
|
107
144
|
let n = Array.from(t.values());
|
|
108
145
|
for (let t of e.values()) {
|
|
109
|
-
let e = n.findIndex((e) =>
|
|
146
|
+
let e = n.findIndex((e) => P(t, e));
|
|
110
147
|
if (e < 0) return !1;
|
|
111
148
|
n.splice(e, 1);
|
|
112
149
|
}
|
|
113
150
|
return n.length === 0;
|
|
114
151
|
}
|
|
115
152
|
if (typeof Blob < "u" && typeof File < "u" && e instanceof Blob && t instanceof Blob) return e.size === t.size && e.type === t.type ? e instanceof File && t instanceof File ? e.name === t.name && e.lastModified === t.lastModified : !0 : !1;
|
|
116
|
-
if (Array.isArray(e) && Array.isArray(t)) return e.length === t.length && e.every((e, n) =>
|
|
117
|
-
if (
|
|
153
|
+
if (Array.isArray(e) && Array.isArray(t)) return e.length === t.length && e.every((e, n) => P(e, t[n]));
|
|
154
|
+
if (D(e) && D(t)) {
|
|
118
155
|
let n = Object.keys(e), r = Object.keys(t);
|
|
119
|
-
return n.length === r.length && n.every((n) =>
|
|
156
|
+
return n.length === r.length && n.every((n) => P(e[n], t[n]));
|
|
120
157
|
}
|
|
121
158
|
return !1;
|
|
122
|
-
},
|
|
159
|
+
}, le = (e) => {
|
|
123
160
|
try {
|
|
124
161
|
return new TextEncoder().encode(JSON.stringify(e)).byteLength;
|
|
125
162
|
} catch {
|
|
126
163
|
return;
|
|
127
164
|
}
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
165
|
+
}, F = (e) => ({
|
|
166
|
+
inputs: N(e.inputs),
|
|
167
|
+
displayValues: N(e.displayValues),
|
|
168
|
+
modelValues: N(e.modelValues),
|
|
169
|
+
values: N(e.values),
|
|
170
|
+
fieldValues: N(e.fieldValues),
|
|
171
|
+
serializedValues: N(e.serializedValues),
|
|
172
|
+
serializedFieldValues: N(e.serializedFieldValues)
|
|
173
|
+
}), ue = (e, t) => {
|
|
134
174
|
if (e.config.includeInSubmission === !1) return !1;
|
|
135
175
|
let n = t(e), r = e.state;
|
|
136
176
|
return !((!r.visible || r.disabled) && (n === "omit" || n === "reset-on-hide"));
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
if (!
|
|
141
|
-
let
|
|
142
|
-
if (
|
|
143
|
-
let
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
177
|
+
}, de = (e) => e.kind === "onehot-category" && Array.isArray(e.options), I = (e, t, n, r) => {
|
|
178
|
+
M(e, re(t, n), N(r));
|
|
179
|
+
}, fe = (e, t, r, i) => {
|
|
180
|
+
if (!de(e.config)) return {};
|
|
181
|
+
let a = e.state.value;
|
|
182
|
+
if (a != null && typeof a != "string" && typeof a != "number" && typeof a != "boolean" && typeof a != "bigint") throw Error(`onehot-category "${e.id}": value is not scalar.`);
|
|
183
|
+
let o = a == null ? void 0 : String(a), c = /* @__PURE__ */ new Set();
|
|
184
|
+
if (o !== void 0 && !e.config.options.some((e) => e.value === o)) throw Error(`onehot-category "${e.id}": value "${o}" is not an option.`);
|
|
185
|
+
let l = {};
|
|
186
|
+
for (let a of e.config.options) {
|
|
187
|
+
let u = n(a.mappedTo, t);
|
|
188
|
+
if (u.length === 0) throw Error(`onehot-category "${e.id}": option "${a.value}" has no mappedTo.`);
|
|
189
|
+
let d = +(o === a.value);
|
|
190
|
+
for (let t of u) {
|
|
191
|
+
let n = s(t);
|
|
192
|
+
if (c.has(n)) throw Error(`onehot-category "${e.id}": duplicate mappedTo "${n}".`);
|
|
193
|
+
c.add(n), I(r, n, e.id, d), I(i, n, e.id, d), I(l, n, e.id, d);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return l;
|
|
197
|
+
}, pe = (e) => {
|
|
198
|
+
if (typeof e.config.displayKey != "string") return;
|
|
199
|
+
let t = e.config.displayKey.trim();
|
|
200
|
+
return t.length > 0 ? t : void 0;
|
|
201
|
+
}, me = (e, t, n, r, i) => {
|
|
202
|
+
if (!(!n.state.visible || r === void 0)) {
|
|
203
|
+
if (t.has(r)) throw Error(`field "${n.id}": duplicate displayKey "${r}".`);
|
|
204
|
+
t.add(r), e[r] = N(i);
|
|
153
205
|
}
|
|
154
|
-
},
|
|
155
|
-
let a = {}, o = {},
|
|
156
|
-
for (let
|
|
157
|
-
if (!
|
|
158
|
-
let e =
|
|
159
|
-
if (
|
|
160
|
-
|
|
206
|
+
}, he = (e, t, r) => {
|
|
207
|
+
let i = [], a = {}, o = {}, c = {}, l = {}, u = {}, d = /* @__PURE__ */ new Set();
|
|
208
|
+
for (let f of e) {
|
|
209
|
+
if (!ue(f, r)) continue;
|
|
210
|
+
let e = n(f.config.mappedTo, t), p = e.length > 0 ? e.map(s) : f.config.valuePath === void 0 ? [] : [f.config.valuePath], m = f.state.value, h = f.serialize(), g = pe(f), _ = {};
|
|
211
|
+
if (c[f.id] = N(m), u[f.id] = N(h), de(f.config)) {
|
|
212
|
+
_ = fe(f, t, o, l), me(a, d, f, g, m), i.push({
|
|
213
|
+
fieldId: f.id,
|
|
214
|
+
displayKey: g,
|
|
215
|
+
label: f.config.label,
|
|
216
|
+
value: N(m),
|
|
217
|
+
serializedValue: N(h),
|
|
218
|
+
modelValues: N(_),
|
|
219
|
+
visible: f.state.visible,
|
|
220
|
+
disabled: f.state.disabled
|
|
221
|
+
});
|
|
161
222
|
continue;
|
|
162
223
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
224
|
+
for (let e of p) {
|
|
225
|
+
let t = re(e, f.id);
|
|
226
|
+
M(o, t, N(m)), M(l, t, N(h)), M(_, t, N(h));
|
|
227
|
+
}
|
|
228
|
+
me(a, d, f, g, m), i.push({
|
|
229
|
+
fieldId: f.id,
|
|
230
|
+
displayKey: g,
|
|
231
|
+
label: f.config.label,
|
|
232
|
+
value: N(m),
|
|
233
|
+
serializedValue: N(h),
|
|
234
|
+
mappedTo: e[0],
|
|
235
|
+
modelValues: N(_),
|
|
236
|
+
visible: f.state.visible,
|
|
237
|
+
disabled: f.state.disabled
|
|
238
|
+
});
|
|
166
239
|
}
|
|
167
240
|
return {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
241
|
+
inputs: i,
|
|
242
|
+
displayValues: a,
|
|
243
|
+
modelValues: N(l),
|
|
244
|
+
values: o,
|
|
245
|
+
fieldValues: c,
|
|
246
|
+
serializedValues: l,
|
|
247
|
+
serializedFieldValues: u
|
|
172
248
|
};
|
|
173
|
-
},
|
|
174
|
-
reports:
|
|
175
|
-
meta:
|
|
249
|
+
}, ge = (e) => D(e) ? {
|
|
250
|
+
reports: Array.isArray(e.reports) ? e.reports : void 0,
|
|
251
|
+
meta: D(e.meta) ? e.meta : void 0,
|
|
176
252
|
raw: "raw" in e ? e.raw : e
|
|
177
|
-
} : { raw: e },
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
253
|
+
} : { raw: e }, L = (e, t = {}) => he(e.fields, t.backend, (e) => T(e, t.inactiveFieldPolicy)), _e = (e, t) => Object.fromEntries(t.backends.map((n) => [n, L(e, {
|
|
254
|
+
backend: n,
|
|
255
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy
|
|
256
|
+
})])), ve = (e) => typeof e == "string" ? { backend: e } : e, ye = (e, t, n) => e.filter((e) => !(e.id in t) && !(e.id in n)).map((e) => e.id), be = async ({ form: e, backends: t, reportFetchMode: n = "all", continueOnError: r = !0 }) => {
|
|
257
|
+
let i = {};
|
|
258
|
+
for (let a of t) {
|
|
259
|
+
let t = ve(a), s = t.backend;
|
|
260
|
+
if (s === void 0) continue;
|
|
261
|
+
let c = L(e, { backend: s });
|
|
262
|
+
try {
|
|
263
|
+
let r = await e.submit(t), a = n === "all" ? await p({
|
|
264
|
+
reports: e.reports,
|
|
265
|
+
request: o(r, { signal: t.signal })
|
|
266
|
+
}) : {
|
|
267
|
+
results: {},
|
|
268
|
+
errors: {}
|
|
269
|
+
};
|
|
270
|
+
i[s] = {
|
|
271
|
+
backend: s,
|
|
272
|
+
snapshot: c,
|
|
273
|
+
submitResult: r,
|
|
274
|
+
reportFetchResults: a.results,
|
|
275
|
+
reportFetchErrors: a.errors,
|
|
276
|
+
skippedReportIds: ye(e.reports, a.results, a.errors)
|
|
277
|
+
};
|
|
278
|
+
} catch (t) {
|
|
279
|
+
if (i[s] = {
|
|
280
|
+
backend: s,
|
|
281
|
+
snapshot: c,
|
|
282
|
+
reportFetchResults: {},
|
|
283
|
+
reportFetchErrors: {},
|
|
284
|
+
skippedReportIds: e.reports.map((e) => e.id),
|
|
285
|
+
error: t
|
|
286
|
+
}, !r) throw t;
|
|
287
|
+
}
|
|
204
288
|
}
|
|
205
|
-
|
|
289
|
+
return { runs: i };
|
|
290
|
+
}, xe = async (e, t) => {
|
|
206
291
|
let n = /* @__PURE__ */ new Map();
|
|
207
292
|
return await Promise.all(e.map(async (e) => {
|
|
208
293
|
n.set(e.id, await e.prepareState(t));
|
|
209
294
|
})), n;
|
|
210
|
-
},
|
|
295
|
+
}, Se = (e, t) => {
|
|
211
296
|
for (let n of e) {
|
|
212
297
|
let e = t.get(n.id);
|
|
213
|
-
if (!e) throw new
|
|
298
|
+
if (!e) throw new g(`Prepared report state missing for "${n.id}".`);
|
|
214
299
|
n.commitState(e);
|
|
215
300
|
}
|
|
216
|
-
},
|
|
301
|
+
}, Ce = (e, t) => Object.fromEntries(e.map((e) => {
|
|
217
302
|
let n = t.get(e.id);
|
|
218
|
-
if (!n) throw new
|
|
303
|
+
if (!n) throw new g(`Prepared report state missing for "${e.id}".`);
|
|
219
304
|
return [e.id, e.cloneState(n)];
|
|
220
|
-
})),
|
|
305
|
+
})), we = () => {
|
|
221
306
|
let e = null, t = "", n = null, r = 0, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = (e) => {
|
|
222
307
|
let t = a.get(e);
|
|
223
308
|
t && (a.delete(e), t());
|
|
224
309
|
};
|
|
225
310
|
return {
|
|
226
311
|
ensureIdle() {
|
|
227
|
-
if (n !== null) throw new
|
|
312
|
+
if (n !== null) throw new g("Form submission is already in progress.");
|
|
228
313
|
},
|
|
229
314
|
begin() {
|
|
230
315
|
let e = ++r;
|
|
@@ -247,7 +332,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
247
332
|
},
|
|
248
333
|
attachExternalSignal(r, i) {
|
|
249
334
|
if (!r?.signal) return;
|
|
250
|
-
if (r.signal.aborted) throw this.clear(i),
|
|
335
|
+
if (r.signal.aborted) throw this.clear(i), S(String(r.signal.reason ?? ""));
|
|
251
336
|
let s = () => {
|
|
252
337
|
if (n !== i) {
|
|
253
338
|
o(i);
|
|
@@ -272,7 +357,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
272
357
|
n = null, e = null, t = "", i.clear();
|
|
273
358
|
}
|
|
274
359
|
};
|
|
275
|
-
},
|
|
360
|
+
}, Te = () => ({
|
|
276
361
|
status: "idle",
|
|
277
362
|
submitCount: 0,
|
|
278
363
|
lastResult: null,
|
|
@@ -283,8 +368,8 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
283
368
|
lifecycleVersion: 0,
|
|
284
369
|
activeValidationVersion: 0,
|
|
285
370
|
activeSubmissionVersion: null
|
|
286
|
-
}),
|
|
287
|
-
switch (
|
|
371
|
+
}), R = (e, t) => {
|
|
372
|
+
switch (De(e.status, t.type), t.type) {
|
|
288
373
|
case "bump-lifecycle": return {
|
|
289
374
|
...e,
|
|
290
375
|
lifecycleVersion: e.lifecycleVersion + 1
|
|
@@ -357,15 +442,15 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
357
442
|
submissionProgress: null,
|
|
358
443
|
activeSubmissionVersion: null
|
|
359
444
|
};
|
|
360
|
-
default: return
|
|
445
|
+
default: return Ee(t);
|
|
361
446
|
}
|
|
362
|
-
},
|
|
447
|
+
}, Ee = (e) => {
|
|
363
448
|
throw Error("Unsupported engine transition.");
|
|
364
|
-
},
|
|
449
|
+
}, De = (e, t) => {
|
|
365
450
|
if (!(t === "submission-success" || t === "submission-aborted" ? e === "submitting" : t === "submission-error" ? e === "submitting" || e === "success" : t !== "validation-error" || e === "validating")) throw Error(`Invalid engine transition "${t}" from status "${e}".`);
|
|
366
|
-
},
|
|
367
|
-
value:
|
|
368
|
-
initialValue:
|
|
451
|
+
}, z = (e) => ({
|
|
452
|
+
value: N(e.value),
|
|
453
|
+
initialValue: N(e.initialValue),
|
|
369
454
|
touched: e.touched,
|
|
370
455
|
dirty: e.dirty,
|
|
371
456
|
valid: e.valid,
|
|
@@ -374,8 +459,8 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
374
459
|
readOnly: e.readOnly,
|
|
375
460
|
errors: [...e.errors],
|
|
376
461
|
status: e.status
|
|
377
|
-
}),
|
|
378
|
-
let t = Object.fromEntries(Object.entries(e.fieldStates).map(([e, t]) => [e,
|
|
462
|
+
}), Oe = (e) => Object.fromEntries(Object.entries(e).map(([e, t]) => [e, z(t)])), B = (e) => {
|
|
463
|
+
let t = Object.fromEntries(Object.entries(e.fieldStates).map(([e, t]) => [e, N(t.value)])), n = Oe(e.fieldStates), r = Object.fromEntries(Object.entries(n).map(([e, t]) => [e, t.errors])), i = e.formErrors.length === 0 && Object.values(n).every((e) => e.valid), a = Object.values(n).some((e) => e.dirty), o = Object.values(n).some((e) => e.touched);
|
|
379
464
|
return {
|
|
380
465
|
status: e.status,
|
|
381
466
|
submitCount: e.submitCount,
|
|
@@ -383,15 +468,15 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
383
468
|
dirty: a,
|
|
384
469
|
touched: o,
|
|
385
470
|
values: t,
|
|
386
|
-
reportStates:
|
|
387
|
-
submissionProgress:
|
|
471
|
+
reportStates: N(e.reportStates),
|
|
472
|
+
submissionProgress: N(e.submissionProgress),
|
|
388
473
|
errors: {
|
|
389
474
|
form: [...e.formErrors],
|
|
390
475
|
fields: r
|
|
391
476
|
},
|
|
392
|
-
lastResult:
|
|
477
|
+
lastResult: N(e.lastResult)
|
|
393
478
|
};
|
|
394
|
-
},
|
|
479
|
+
}, ke = (e) => typeof AggregateError < "u" ? AggregateError(e, "Store listener notification failed.") : /* @__PURE__ */ Error("Store listener notification failed."), Ae = (e, t = {}) => {
|
|
395
480
|
let n = e, r = 0, i = !1, a = /* @__PURE__ */ new Set(), o = () => {
|
|
396
481
|
let e = [];
|
|
397
482
|
for (let r of a) try {
|
|
@@ -399,7 +484,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
399
484
|
} catch (r) {
|
|
400
485
|
e.push(r), t.onListenerError?.(r, n);
|
|
401
486
|
}
|
|
402
|
-
if (e.length > 0 && t.listenerErrorPolicy === "throw-aggregate") throw
|
|
487
|
+
if (e.length > 0 && t.listenerErrorPolicy === "throw-aggregate") throw ke(e);
|
|
403
488
|
};
|
|
404
489
|
return {
|
|
405
490
|
getState() {
|
|
@@ -427,10 +512,10 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
427
512
|
return a.add(e), () => a.delete(e);
|
|
428
513
|
}
|
|
429
514
|
};
|
|
430
|
-
},
|
|
515
|
+
}, je = ({ store: e, resetReports: t, syncAfterSubmissionTransition: n }) => ({
|
|
431
516
|
start(t) {
|
|
432
517
|
e.batch(() => {
|
|
433
|
-
e.update((e) =>
|
|
518
|
+
e.update((e) => R(e, {
|
|
434
519
|
type: "start-submission",
|
|
435
520
|
submissionVersion: t
|
|
436
521
|
})), n();
|
|
@@ -438,7 +523,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
438
523
|
},
|
|
439
524
|
succeed(t) {
|
|
440
525
|
e.batch(() => {
|
|
441
|
-
e.update((e) =>
|
|
526
|
+
e.update((e) => R(e, {
|
|
442
527
|
type: "submission-success",
|
|
443
528
|
result: t
|
|
444
529
|
})), n();
|
|
@@ -446,7 +531,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
446
531
|
},
|
|
447
532
|
abort(r) {
|
|
448
533
|
e.batch(() => {
|
|
449
|
-
t(), e.update((e) =>
|
|
534
|
+
t(), e.update((e) => R(e, {
|
|
450
535
|
type: "submission-aborted",
|
|
451
536
|
message: r
|
|
452
537
|
})), n();
|
|
@@ -454,40 +539,44 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
454
539
|
},
|
|
455
540
|
fail(r) {
|
|
456
541
|
e.batch(() => {
|
|
457
|
-
t(), e.update((e) =>
|
|
542
|
+
t(), e.update((e) => R(e, {
|
|
458
543
|
type: "submission-error",
|
|
459
544
|
message: r
|
|
460
545
|
})), n();
|
|
461
546
|
});
|
|
462
547
|
},
|
|
463
548
|
clear(t) {
|
|
464
|
-
e.update((e) =>
|
|
549
|
+
e.update((e) => R(e, {
|
|
465
550
|
type: "clear-active-submission",
|
|
466
551
|
submissionVersion: t
|
|
467
552
|
}));
|
|
468
553
|
}
|
|
469
|
-
}),
|
|
554
|
+
}), Me = (e, t, n) => ({
|
|
470
555
|
...t,
|
|
471
|
-
reportStates:
|
|
472
|
-
}),
|
|
556
|
+
reportStates: Ce(e, n)
|
|
557
|
+
}), V = (e, t) => {
|
|
473
558
|
let n = Object.fromEntries(e.map((e) => {
|
|
474
559
|
let n = t.reportStates[e.id];
|
|
475
560
|
return [e.id, n && e.cloneState(n)];
|
|
476
561
|
}));
|
|
477
562
|
return {
|
|
478
563
|
backend: t.backend,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
564
|
+
inputs: N(t.inputs ?? []),
|
|
565
|
+
displayValues: N(t.displayValues ?? {}),
|
|
566
|
+
modelValues: N(t.modelValues ?? t.serializedValues),
|
|
567
|
+
values: N(t.values),
|
|
568
|
+
fieldValues: N(t.fieldValues),
|
|
569
|
+
serializedValues: N(t.serializedValues),
|
|
570
|
+
serializedFieldValues: N(t.serializedFieldValues),
|
|
571
|
+
reports: N(t.reports),
|
|
572
|
+
reportContexts: N(t.reportContexts ?? {}),
|
|
484
573
|
reportStates: n,
|
|
485
|
-
meta:
|
|
486
|
-
raw:
|
|
574
|
+
meta: N(t.meta),
|
|
575
|
+
raw: N(t.raw)
|
|
487
576
|
};
|
|
488
|
-
},
|
|
577
|
+
}, Ne = ({ hooks: e, abortManager: t, lifecycle: n, store: r }) => {
|
|
489
578
|
let i = async (t, n, r, i) => {
|
|
490
|
-
let a =
|
|
579
|
+
let a = F(n);
|
|
491
580
|
await e?.onSubmitError?.({
|
|
492
581
|
backend: t,
|
|
493
582
|
...a,
|
|
@@ -498,15 +587,15 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
498
587
|
return {
|
|
499
588
|
notifySubmitError: i,
|
|
500
589
|
handleSubmissionAbort: async (e, a, o, s, c, l) => {
|
|
501
|
-
let u = e instanceof
|
|
590
|
+
let u = e instanceof x ? e : S(t.getAbortReason(a));
|
|
502
591
|
throw t.getCurrentRequestId() === a && r.getState().lifecycleVersion === o && n.abort(u.message), await i(l, c, s, u), u;
|
|
503
592
|
},
|
|
504
593
|
handleSubmissionError: async (e, a, o, s, c, l) => {
|
|
505
594
|
let u = e instanceof Error ? e.message : String(e);
|
|
506
|
-
throw t.getCurrentRequestId() === a && r.getState().lifecycleVersion === o && n.fail(u), await i(l, c, s, e), new
|
|
595
|
+
throw t.getCurrentRequestId() === a && r.getState().lifecycleVersion === o && n.fail(u), await i(l, c, s, e), new y(`Form submission failed: ${u}`, e);
|
|
507
596
|
}
|
|
508
597
|
};
|
|
509
|
-
},
|
|
598
|
+
}, Pe = (e, t, n) => {
|
|
510
599
|
e.update((e) => ({
|
|
511
600
|
...e,
|
|
512
601
|
submissionProgress: e.submissionProgress ? {
|
|
@@ -520,67 +609,74 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
520
609
|
}
|
|
521
610
|
} : e.submissionProgress
|
|
522
611
|
}));
|
|
523
|
-
},
|
|
524
|
-
if (n === "replace") return
|
|
525
|
-
if (n === "shallow-merge") return !
|
|
526
|
-
...
|
|
527
|
-
...
|
|
612
|
+
}, H = (e) => typeof e == "object" && !!e && !Array.isArray(e), U = (e, t, n = "deep-merge") => {
|
|
613
|
+
if (n === "replace") return N(t);
|
|
614
|
+
if (n === "shallow-merge") return !H(e) || !H(t) ? N(t) : {
|
|
615
|
+
...N(e),
|
|
616
|
+
...N(t)
|
|
528
617
|
};
|
|
529
|
-
if (!
|
|
530
|
-
let r = { ...
|
|
531
|
-
for (let [e, n] of Object.entries(t)) r[e] = e in r ?
|
|
618
|
+
if (!H(e) || !H(t)) return N(t);
|
|
619
|
+
let r = { ...N(e) };
|
|
620
|
+
for (let [e, n] of Object.entries(t)) r[e] = e in r ? U(r[e], n, "deep-merge") : N(n);
|
|
532
621
|
return r;
|
|
533
|
-
},
|
|
534
|
-
let
|
|
622
|
+
}, Fe = ({ reportMap: e, getReportState: t, getReportStates: n, getSubmissionMeta: r, storePendingPatch: i }) => {
|
|
623
|
+
let o = (t, n) => {
|
|
535
624
|
let r = e.get(t);
|
|
536
625
|
r && r.commitState({
|
|
537
|
-
payload:
|
|
626
|
+
payload: N(n),
|
|
538
627
|
error: null,
|
|
539
628
|
status: n === void 0 ? "idle" : "ready"
|
|
540
629
|
});
|
|
541
|
-
}, c = (
|
|
542
|
-
let l =
|
|
630
|
+
}, c = (t, i, o, c) => {
|
|
631
|
+
let l = a(e.get(o)?.config.mappedTo, i);
|
|
632
|
+
if (l === void 0) throw Error(`Report "${o}" requires mappedTo for validated stream updates.`);
|
|
543
633
|
return {
|
|
544
|
-
backend:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
634
|
+
backend: i,
|
|
635
|
+
inputs: N(t.inputs),
|
|
636
|
+
displayValues: N(t.displayValues),
|
|
637
|
+
modelValues: N(t.modelValues),
|
|
638
|
+
values: N(t.values),
|
|
639
|
+
fieldValues: N(t.fieldValues),
|
|
640
|
+
serializedValues: N(t.serializedValues),
|
|
641
|
+
serializedFieldValues: N(t.serializedFieldValues),
|
|
642
|
+
reports: [{
|
|
643
|
+
mappedTo: s(l),
|
|
644
|
+
payload: N(c)
|
|
645
|
+
}],
|
|
646
|
+
reportStates: N(n()),
|
|
647
|
+
meta: N(r()),
|
|
648
|
+
raw: N(c)
|
|
553
649
|
};
|
|
554
|
-
}, l = async (t, n, r,
|
|
555
|
-
let
|
|
556
|
-
if (
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
if (a.partialUpdatePolicy === "defer") {
|
|
562
|
-
o(t, {
|
|
563
|
-
type: "replace",
|
|
564
|
-
payload: D(n)
|
|
565
|
-
});
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
try {
|
|
569
|
-
let e = await a.prepareState(c(r, i, t, n));
|
|
570
|
-
a.commitState(e);
|
|
571
|
-
} catch (e) {
|
|
572
|
-
let t = e instanceof Error ? e.message : String(e);
|
|
573
|
-
a.commitState({
|
|
574
|
-
payload: void 0,
|
|
575
|
-
error: t,
|
|
576
|
-
status: "error"
|
|
577
|
-
});
|
|
578
|
-
}
|
|
650
|
+
}, l = async (t, n, r, a) => {
|
|
651
|
+
let s = e.get(t);
|
|
652
|
+
if (!s) return;
|
|
653
|
+
if (s.partialUpdatePolicy === "trust") {
|
|
654
|
+
o(t, n);
|
|
655
|
+
return;
|
|
579
656
|
}
|
|
580
|
-
|
|
581
|
-
|
|
657
|
+
if (s.partialUpdatePolicy === "defer") {
|
|
658
|
+
i(t, {
|
|
659
|
+
type: "replace",
|
|
660
|
+
payload: N(n)
|
|
661
|
+
});
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
let l = c(r, a, t, n);
|
|
665
|
+
try {
|
|
666
|
+
let e = await s.prepareState(l);
|
|
667
|
+
s.commitState(e);
|
|
668
|
+
} catch (e) {
|
|
669
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
670
|
+
s.commitState({
|
|
671
|
+
payload: void 0,
|
|
672
|
+
error: t,
|
|
673
|
+
status: "error"
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}, u = (n, r, i = "deep-merge") => {
|
|
677
|
+
let a = e.get(n);
|
|
582
678
|
if (!a) return;
|
|
583
|
-
let o =
|
|
679
|
+
let o = U(t(n)?.payload, r, i);
|
|
584
680
|
a.commitState({
|
|
585
681
|
payload: o,
|
|
586
682
|
error: null,
|
|
@@ -589,24 +685,24 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
589
685
|
};
|
|
590
686
|
return {
|
|
591
687
|
applyValidatedReportReplace: l,
|
|
592
|
-
applyValidatedReportPatch: async (
|
|
593
|
-
let l = e.get(
|
|
688
|
+
applyValidatedReportPatch: async (n, r, a = "deep-merge", o, s) => {
|
|
689
|
+
let l = e.get(n);
|
|
594
690
|
if (!l) return;
|
|
595
691
|
if (l.partialUpdatePolicy === "trust") {
|
|
596
|
-
u(
|
|
692
|
+
u(n, r, a);
|
|
597
693
|
return;
|
|
598
694
|
}
|
|
599
695
|
if (l.partialUpdatePolicy === "defer") {
|
|
600
|
-
|
|
696
|
+
i(n, {
|
|
601
697
|
type: "patch",
|
|
602
|
-
patch:
|
|
603
|
-
strategy:
|
|
698
|
+
patch: N(r),
|
|
699
|
+
strategy: a
|
|
604
700
|
});
|
|
605
701
|
return;
|
|
606
702
|
}
|
|
607
|
-
let d =
|
|
703
|
+
let d = c(o, s, n, U(t(n)?.payload, r, a));
|
|
608
704
|
try {
|
|
609
|
-
let e = await l.prepareState(
|
|
705
|
+
let e = await l.prepareState(d);
|
|
610
706
|
l.commitState(e);
|
|
611
707
|
} catch (e) {
|
|
612
708
|
let t = e instanceof Error ? e.message : String(e);
|
|
@@ -618,7 +714,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
618
714
|
}
|
|
619
715
|
}
|
|
620
716
|
};
|
|
621
|
-
},
|
|
717
|
+
}, Ie = (e) => {
|
|
622
718
|
if (e instanceof Date) return Number.isNaN(e.getTime()) ? null : e.getTime();
|
|
623
719
|
if (typeof e == "number") return Number.isNaN(e) ? null : e;
|
|
624
720
|
if (typeof e == "string") {
|
|
@@ -626,11 +722,11 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
626
722
|
return !Number.isNaN(t) && /^\d{4}-\d{2}-\d{2}/.test(e) ? t : e;
|
|
627
723
|
}
|
|
628
724
|
return typeof e == "bigint" ? e : null;
|
|
629
|
-
},
|
|
630
|
-
let n =
|
|
725
|
+
}, Le = (e, t) => {
|
|
726
|
+
let n = Ie(e), r = Ie(t);
|
|
631
727
|
return n === null || r === null || typeof n != typeof r ? null : n === r ? 0 : n < r ? -1 : 1;
|
|
632
|
-
},
|
|
633
|
-
let r =
|
|
728
|
+
}, W = (e, t, n) => e ? typeof e == "function" ? e(t) : K(e, t) : n, Re = (e, t) => t.some((t) => Object.is(t, e)), G = (e, t, n) => {
|
|
729
|
+
let r = Le(e, t);
|
|
634
730
|
if (r === null) return !1;
|
|
635
731
|
switch (n) {
|
|
636
732
|
case "eq": return r === 0;
|
|
@@ -639,27 +735,27 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
639
735
|
case "gte": return r >= 0;
|
|
640
736
|
case "lt": return r < 0;
|
|
641
737
|
case "lte": return r <= 0;
|
|
642
|
-
default: return
|
|
738
|
+
default: return ze(n);
|
|
643
739
|
}
|
|
644
|
-
},
|
|
740
|
+
}, ze = (e) => {
|
|
645
741
|
throw Error("Unsupported comparison operator.");
|
|
646
|
-
},
|
|
742
|
+
}, K = (e, t) => {
|
|
647
743
|
switch (e.kind) {
|
|
648
744
|
case "field-value": {
|
|
649
745
|
let n = t.values[e.field];
|
|
650
|
-
return !(e.equals !== void 0 && !Object.is(n, e.equals) || e.notEquals !== void 0 && Object.is(n, e.notEquals) || e.greaterThan !== void 0 && !
|
|
746
|
+
return !(e.equals !== void 0 && !Object.is(n, e.equals) || e.notEquals !== void 0 && Object.is(n, e.notEquals) || e.greaterThan !== void 0 && !G(n, e.greaterThan, "gt") || e.greaterThanOrEqual !== void 0 && !G(n, e.greaterThanOrEqual, "gte") || e.lessThan !== void 0 && !G(n, e.lessThan, "lt") || e.lessThanOrEqual !== void 0 && !G(n, e.lessThanOrEqual, "lte") || e.in && !Re(n, e.in) || e.notIn && Re(n, e.notIn) || e.empty === !0 && !A(n) || e.notEmpty === !0 && A(n) || e.truthy === !0 && !n || e.falsy === !0 && n);
|
|
651
747
|
}
|
|
652
|
-
case "field-comparison": return
|
|
748
|
+
case "field-comparison": return G(t.values[e.field], t.values[e.otherField], e.operator);
|
|
653
749
|
case "form-status": return (Array.isArray(e.equals) ? e.equals : [e.equals]).includes(t.formStatus);
|
|
654
750
|
case "submit-count": return !(e.eq !== void 0 && t.submitCount !== e.eq || e.gte !== void 0 && t.submitCount < e.gte || e.lte !== void 0 && t.submitCount > e.lte);
|
|
655
|
-
case "all": return e.conditions.every((e) =>
|
|
656
|
-
case "any": return e.conditions.some((e) =>
|
|
657
|
-
case "not": return !
|
|
658
|
-
default: return
|
|
751
|
+
case "all": return e.conditions.every((e) => K(e, t));
|
|
752
|
+
case "any": return e.conditions.some((e) => K(e, t));
|
|
753
|
+
case "not": return !K(e.condition, t);
|
|
754
|
+
default: return Be(e);
|
|
659
755
|
}
|
|
660
|
-
},
|
|
756
|
+
}, Be = (e) => {
|
|
661
757
|
throw Error("Unsupported field condition.");
|
|
662
|
-
},
|
|
758
|
+
}, Ve = (e, t, n, r) => {
|
|
663
759
|
let i = {
|
|
664
760
|
field: e,
|
|
665
761
|
values: t,
|
|
@@ -667,28 +763,28 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
667
763
|
formStatus: r
|
|
668
764
|
};
|
|
669
765
|
return {
|
|
670
|
-
visible: !
|
|
671
|
-
disabled:
|
|
672
|
-
readOnly:
|
|
766
|
+
visible: !W(e.hiddenWhen, i, !!e.hidden),
|
|
767
|
+
disabled: W(e.disabledWhen, i, !!e.disabled),
|
|
768
|
+
readOnly: W(e.readOnlyWhen, i, !!e.readOnly)
|
|
673
769
|
};
|
|
674
|
-
},
|
|
770
|
+
}, He = (e) => [
|
|
675
771
|
...e.syncErrors,
|
|
676
772
|
...e.validationErrors,
|
|
677
773
|
...e.externalErrors
|
|
678
|
-
],
|
|
679
|
-
let t =
|
|
774
|
+
], q = (e) => {
|
|
775
|
+
let t = He(e);
|
|
680
776
|
return {
|
|
681
777
|
...e,
|
|
682
778
|
errors: t,
|
|
683
779
|
valid: t.length === 0,
|
|
684
780
|
status: t.length === 0 ? "valid" : "invalid"
|
|
685
781
|
};
|
|
686
|
-
},
|
|
782
|
+
}, Ue = (e) => ({
|
|
687
783
|
...e,
|
|
688
|
-
errors:
|
|
689
|
-
valid:
|
|
784
|
+
errors: He(e),
|
|
785
|
+
valid: He(e).length === 0,
|
|
690
786
|
status: "validating"
|
|
691
|
-
}),
|
|
787
|
+
}), We = (e, t) => e.required && A(t) ? ["This field is required."] : [], Ge = (e, t, n) => e.cloneValue ? e.cloneValue(n, t) : N(n), J = (e, t, n) => e.normalizeValue ? Ge(e, t, e.normalizeValue(n, t)) : Ge(e, t, n), Ke = (e, t, n, r) => e.isEqual ? e.isEqual(n, r, t) : P(n, r), qe = (e, t, n, r, i) => {
|
|
692
788
|
if (!e.validate || typeof t.asyncValidationDebounceMs == "number" && t.asyncValidationDebounceMs > 0) return [];
|
|
693
789
|
let a = e.validate(n, t, {
|
|
694
790
|
field: t,
|
|
@@ -697,14 +793,14 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
697
793
|
validationVersion: 0,
|
|
698
794
|
signal: void 0
|
|
699
795
|
});
|
|
700
|
-
return
|
|
701
|
-
},
|
|
796
|
+
return k(a) ? [] : a;
|
|
797
|
+
}, Y = (e, t, n, r, i, a) => {
|
|
702
798
|
if (!a.visible || a.disabled) return [];
|
|
703
|
-
let o =
|
|
704
|
-
return o.length > 0 ? o :
|
|
705
|
-
},
|
|
706
|
-
let o =
|
|
707
|
-
return
|
|
799
|
+
let o = We(t, n);
|
|
800
|
+
return o.length > 0 ? o : qe(e, t, n, r, i);
|
|
801
|
+
}, Je = (e, t, n, r, i, a) => {
|
|
802
|
+
let o = J(e, t, n), s = Ve(t, r, i, a), c = Y(e, t, o, r, i, s);
|
|
803
|
+
return q({
|
|
708
804
|
value: o,
|
|
709
805
|
initialValue: o,
|
|
710
806
|
touched: !1,
|
|
@@ -720,90 +816,90 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
720
816
|
valid: c.length === 0,
|
|
721
817
|
status: c.length === 0 ? "valid" : "invalid"
|
|
722
818
|
});
|
|
723
|
-
},
|
|
819
|
+
}, Ye = ({ config: e, definition: t, store: n, getValues: r, getSubmitCount: i, getFormStatus: a, commitState: o }) => {
|
|
724
820
|
let s = null, c = 0;
|
|
725
821
|
return {
|
|
726
822
|
abort(e) {
|
|
727
823
|
s?.abort(e), s = null;
|
|
728
824
|
},
|
|
729
825
|
async validate(l, u = n.getState().activeValidationVersion) {
|
|
730
|
-
let d = n.getState().lifecycleVersion, f = r(), p =
|
|
731
|
-
if (s?.abort("validation-restarted"), s =
|
|
732
|
-
let t =
|
|
826
|
+
let d = n.getState().lifecycleVersion, f = r(), p = J(t, e, l.value), m = i(), h = Ve(e, f, m, a()), g = ++c, _ = typeof AbortController < "u" ? new AbortController() : null, v = Y(t, e, p, f, m, h);
|
|
827
|
+
if (s?.abort("validation-restarted"), s = _, !h.visible || h.disabled) {
|
|
828
|
+
let t = q({
|
|
733
829
|
...l,
|
|
734
830
|
value: p,
|
|
735
831
|
visible: h.visible,
|
|
736
832
|
disabled: h.disabled,
|
|
737
833
|
readOnly: h.readOnly,
|
|
738
|
-
syncErrors:
|
|
834
|
+
syncErrors: v,
|
|
739
835
|
validationErrors: [],
|
|
740
836
|
externalErrors: []
|
|
741
837
|
});
|
|
742
|
-
return s ===
|
|
838
|
+
return s === _ && (s = null), o(e.id, t), {
|
|
743
839
|
fieldId: e.id,
|
|
744
840
|
valid: !0,
|
|
745
841
|
errors: []
|
|
746
842
|
};
|
|
747
843
|
}
|
|
748
|
-
o(e.id,
|
|
844
|
+
o(e.id, Ue({
|
|
749
845
|
...l,
|
|
750
846
|
visible: h.visible,
|
|
751
847
|
disabled: h.disabled,
|
|
752
848
|
readOnly: h.readOnly,
|
|
753
849
|
validationVersion: u,
|
|
754
|
-
syncErrors:
|
|
850
|
+
syncErrors: v,
|
|
755
851
|
validationErrors: [...l.validationErrors],
|
|
756
852
|
externalErrors: [...l.externalErrors],
|
|
757
853
|
status: "validating"
|
|
758
854
|
}));
|
|
759
|
-
let
|
|
760
|
-
if (
|
|
855
|
+
let y = [];
|
|
856
|
+
if (v.length === 0 && t.validate) try {
|
|
761
857
|
let n = typeof e.asyncValidationDebounceMs == "number" ? e.asyncValidationDebounceMs : 0;
|
|
762
|
-
n > 0 && await
|
|
858
|
+
n > 0 && await ne(n, _?.signal);
|
|
763
859
|
let r = t.validate(p, e, {
|
|
764
860
|
field: e,
|
|
765
861
|
values: f,
|
|
766
862
|
submitCount: m,
|
|
767
863
|
validationVersion: u,
|
|
768
|
-
signal:
|
|
864
|
+
signal: _?.signal
|
|
769
865
|
});
|
|
770
|
-
|
|
866
|
+
k(r) && (y = await r);
|
|
771
867
|
} catch (t) {
|
|
772
|
-
if (
|
|
868
|
+
if (_?.signal.aborted || ee(t)) return {
|
|
773
869
|
fieldId: e.id,
|
|
774
870
|
valid: l.valid,
|
|
775
871
|
errors: [...l.errors]
|
|
776
872
|
};
|
|
777
873
|
throw t;
|
|
778
874
|
}
|
|
779
|
-
let
|
|
875
|
+
let b = n.getState().activeValidationVersion === u && n.getState().lifecycleVersion === d && c === g && !_?.signal.aborted, x = q({
|
|
780
876
|
...l,
|
|
781
877
|
value: p,
|
|
782
878
|
touched: !0,
|
|
783
|
-
dirty: !
|
|
879
|
+
dirty: !Ke(t, e, p, l.initialValue),
|
|
784
880
|
visible: h.visible,
|
|
785
881
|
disabled: h.disabled,
|
|
786
882
|
readOnly: h.readOnly,
|
|
787
|
-
syncErrors:
|
|
788
|
-
validationErrors:
|
|
883
|
+
syncErrors: v,
|
|
884
|
+
validationErrors: y,
|
|
789
885
|
externalErrors: [...l.externalErrors],
|
|
790
886
|
validationVersion: u
|
|
791
887
|
});
|
|
792
|
-
return
|
|
888
|
+
return b && o(e.id, x), s === _ && (s = null), {
|
|
793
889
|
fieldId: e.id,
|
|
794
|
-
valid:
|
|
795
|
-
errors: [...
|
|
890
|
+
valid: x.valid,
|
|
891
|
+
errors: [...x.errors]
|
|
796
892
|
};
|
|
797
893
|
}
|
|
798
894
|
};
|
|
799
|
-
},
|
|
800
|
-
let t =
|
|
895
|
+
}, X = (e) => {
|
|
896
|
+
let t = B(e.getState());
|
|
801
897
|
return {
|
|
802
898
|
valid: t.valid,
|
|
803
899
|
fields: t.errors.fields,
|
|
804
900
|
formErrors: t.errors.form
|
|
805
901
|
};
|
|
806
|
-
},
|
|
902
|
+
}, Xe = (e, t, n) => {
|
|
807
903
|
if (n) {
|
|
808
904
|
if (Array.isArray(n)) {
|
|
809
905
|
t.push(...n);
|
|
@@ -811,7 +907,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
811
907
|
}
|
|
812
908
|
if (n.form && t.push(...n.form), n.fields) for (let [t, r] of Object.entries(n.fields)) e[t] = [...e[t] ?? [], ...r];
|
|
813
909
|
}
|
|
814
|
-
},
|
|
910
|
+
}, Ze = ({ store: e, fields: t, normalizedSchema: n, validators: r, hooks: i, getValues: a, getSubmitCount: o, getFormStatus: s, syncDerivedFieldState: c, setRestingStatus: l, shouldResetInactiveFields: u, inactiveFieldPolicy: d }) => {
|
|
815
911
|
let f = 0, p = new Set(t.map((e) => e.id)), m = async (i, c) => {
|
|
816
912
|
let l = [], u = Object.fromEntries(t.map((e) => [e.id, []]));
|
|
817
913
|
if (r?.length) {
|
|
@@ -819,26 +915,26 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
819
915
|
values: a(),
|
|
820
916
|
submitCount: o(),
|
|
821
917
|
formStatus: s(),
|
|
822
|
-
fields:
|
|
918
|
+
fields: Oe(e.getState().fieldStates),
|
|
823
919
|
schema: {
|
|
824
920
|
fields: n.fields,
|
|
825
921
|
reports: n.reports
|
|
826
922
|
}
|
|
827
923
|
};
|
|
828
|
-
for (let n of r) if (
|
|
924
|
+
for (let n of r) if (Xe(u, l, await n(t)), e.getState().activeValidationVersion !== i || e.getState().lifecycleVersion !== c) return X(e);
|
|
829
925
|
}
|
|
830
926
|
let d = Object.keys(u).filter((e) => !p.has(e));
|
|
831
|
-
if (d.length > 0) throw new
|
|
832
|
-
if (e.getState().activeValidationVersion !== i || e.getState().lifecycleVersion !== c) return
|
|
927
|
+
if (d.length > 0) throw new g(`Form validator returned errors for unknown fields: ${d.join(", ")}.`);
|
|
928
|
+
if (e.getState().activeValidationVersion !== i || e.getState().lifecycleVersion !== c) return X(e);
|
|
833
929
|
for (let e of t) e.setExternalErrors(u[e.id] ?? []);
|
|
834
930
|
return e.update((e) => ({
|
|
835
931
|
...e,
|
|
836
932
|
formErrors: l
|
|
837
|
-
})),
|
|
933
|
+
})), X(e);
|
|
838
934
|
};
|
|
839
935
|
return { async validate() {
|
|
840
936
|
let n = e.getState().lifecycleVersion, r = ++f;
|
|
841
|
-
e.update((e) =>
|
|
937
|
+
e.update((e) => R(e, {
|
|
842
938
|
type: "start-validation",
|
|
843
939
|
validationVersion: r
|
|
844
940
|
}));
|
|
@@ -846,7 +942,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
846
942
|
if (await i?.beforeValidate?.({
|
|
847
943
|
values: a(),
|
|
848
944
|
submitCount: o()
|
|
849
|
-
}), await Promise.all(t.map((e) => e.validate(r))), e.getState().lifecycleVersion !== n) return
|
|
945
|
+
}), await Promise.all(t.map((e) => e.validate(r))), e.getState().lifecycleVersion !== n) return X(e);
|
|
850
946
|
c({
|
|
851
947
|
preserveValidationErrors: !0,
|
|
852
948
|
preserveExternalErrors: !1,
|
|
@@ -861,7 +957,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
861
957
|
}), e.getState().activeValidationVersion === r && l(), s;
|
|
862
958
|
} catch (t) {
|
|
863
959
|
let i = t instanceof Error ? t.message : String(t);
|
|
864
|
-
throw e.getState().activeValidationVersion === r && e.getState().lifecycleVersion === n && (e.update((e) =>
|
|
960
|
+
throw e.getState().activeValidationVersion === r && e.getState().lifecycleVersion === n && (e.update((e) => R(e, {
|
|
865
961
|
type: "validation-error",
|
|
866
962
|
message: i
|
|
867
963
|
})), c({
|
|
@@ -872,28 +968,28 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
872
968
|
})), t;
|
|
873
969
|
}
|
|
874
970
|
} };
|
|
875
|
-
},
|
|
971
|
+
}, Qe = ({ store: e, fieldMap: t, onRemoteFieldUpdate: n }) => ({ applyFieldUpdate: (r) => {
|
|
876
972
|
let i = t.get(r.fieldId);
|
|
877
973
|
if (!i) return;
|
|
878
974
|
let a = e.getState().fieldStates[r.fieldId];
|
|
879
975
|
if (!a) return;
|
|
880
976
|
let o = r.value === void 0 ? a.value : i.coerceValue(r.value);
|
|
881
|
-
i.commitState(
|
|
977
|
+
i.commitState(q({
|
|
882
978
|
...a,
|
|
883
979
|
value: o,
|
|
884
980
|
touched: r.touched ?? a.touched,
|
|
885
981
|
dirty: r.dirty ?? a.dirty,
|
|
886
982
|
externalErrors: r.errors ? [...r.errors] : a.externalErrors
|
|
887
983
|
})), n?.(r.fieldId);
|
|
888
|
-
} }),
|
|
984
|
+
} }), $e = async (e, t) => {
|
|
889
985
|
await e.applyValidatedReportPatch(t.reportId, t.patch, t.strategy, e.records, e.backend);
|
|
890
|
-
},
|
|
986
|
+
}, et = async ({ event: e, records: t, backend: n, applyValidatedReportReplace: r, applyValidatedReportPatch: i, applyFieldUpdate: a }) => {
|
|
891
987
|
switch (e.type) {
|
|
892
988
|
case "report-replace":
|
|
893
989
|
await r(e.reportId, e.payload, t, n);
|
|
894
990
|
break;
|
|
895
991
|
case "report-patch":
|
|
896
|
-
await
|
|
992
|
+
await $e({
|
|
897
993
|
event: e,
|
|
898
994
|
records: t,
|
|
899
995
|
backend: n,
|
|
@@ -907,12 +1003,12 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
907
1003
|
break;
|
|
908
1004
|
default: break;
|
|
909
1005
|
}
|
|
910
|
-
},
|
|
1006
|
+
}, tt = (e, t, n, r, i) => {
|
|
911
1007
|
t() !== r || e.getState().lifecycleVersion !== i || e.update((e) => ({
|
|
912
1008
|
...e,
|
|
913
1009
|
submissionProgress: n
|
|
914
1010
|
}));
|
|
915
|
-
},
|
|
1011
|
+
}, nt = (e, t) => {
|
|
916
1012
|
let n = e ?? {
|
|
917
1013
|
meta: {},
|
|
918
1014
|
chunkCount: 0
|
|
@@ -965,142 +1061,144 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
965
1061
|
lastEventType: t.type
|
|
966
1062
|
};
|
|
967
1063
|
}
|
|
968
|
-
},
|
|
969
|
-
let
|
|
1064
|
+
}, rt = ({ store: e, transport: t, hooks: n, hookFailurePolicy: r, normalizedSchema: a, fields: o, reports: s, validate: c, getSubmitCount: u, markReportsLoading: f, resetReports: p, syncDerivedFieldState: m, shouldResetInactiveFields: h, resolveInactiveFieldPolicy: g, inactiveFieldPolicy: _, onRemoteFieldUpdate: y, beforeSubmitRecords: b }) => {
|
|
1065
|
+
let x = we(), C = je({
|
|
970
1066
|
store: e,
|
|
971
|
-
resetReports:
|
|
1067
|
+
resetReports: p,
|
|
972
1068
|
syncAfterSubmissionTransition: () => {
|
|
973
|
-
|
|
1069
|
+
m({
|
|
974
1070
|
preserveValidationErrors: !0,
|
|
975
1071
|
preserveExternalErrors: !0,
|
|
976
|
-
resetInactiveToInitial:
|
|
977
|
-
inactiveFieldPolicy:
|
|
1072
|
+
resetInactiveToInitial: h(),
|
|
1073
|
+
inactiveFieldPolicy: _
|
|
978
1074
|
});
|
|
979
1075
|
}
|
|
980
|
-
}),
|
|
1076
|
+
}), w = new Map(o.map((e) => [e.id, e])), T = new Map(s.map((e) => [e.id, e])), { notifySubmitError: E, handleSubmissionAbort: D, handleSubmissionError: O } = Ne({
|
|
981
1077
|
hooks: n,
|
|
982
|
-
abortManager:
|
|
983
|
-
lifecycle:
|
|
1078
|
+
abortManager: x,
|
|
1079
|
+
lifecycle: C,
|
|
984
1080
|
store: e
|
|
985
|
-
}), { applyValidatedReportReplace:
|
|
986
|
-
reportMap:
|
|
1081
|
+
}), { applyValidatedReportReplace: k, applyValidatedReportPatch: A } = Fe({
|
|
1082
|
+
reportMap: T,
|
|
987
1083
|
getReportState: (t) => e.getState().reportStates[t],
|
|
988
1084
|
getReportStates: () => e.getState().reportStates,
|
|
989
1085
|
getSubmissionMeta: () => e.getState().submissionProgress?.meta ?? {},
|
|
990
|
-
storePendingPatch: (t, n) =>
|
|
991
|
-
}), { applyFieldUpdate:
|
|
1086
|
+
storePendingPatch: (t, n) => Pe(e, t, n)
|
|
1087
|
+
}), { applyFieldUpdate: te } = Qe({
|
|
992
1088
|
store: e,
|
|
993
|
-
fieldMap:
|
|
994
|
-
onRemoteFieldUpdate:
|
|
995
|
-
}),
|
|
1089
|
+
fieldMap: w,
|
|
1090
|
+
onRemoteFieldUpdate: y
|
|
1091
|
+
}), j = (e, t, n) => et({
|
|
996
1092
|
event: e,
|
|
997
1093
|
records: t,
|
|
998
1094
|
backend: n,
|
|
999
|
-
applyValidatedReportReplace:
|
|
1000
|
-
applyValidatedReportPatch:
|
|
1001
|
-
applyFieldUpdate:
|
|
1095
|
+
applyValidatedReportReplace: k,
|
|
1096
|
+
applyValidatedReportPatch: A,
|
|
1097
|
+
applyFieldUpdate: te
|
|
1002
1098
|
});
|
|
1003
1099
|
return {
|
|
1004
|
-
async submit(
|
|
1005
|
-
|
|
1006
|
-
let
|
|
1100
|
+
async submit(p) {
|
|
1101
|
+
x.ensureIdle();
|
|
1102
|
+
let m = x.begin(), h = p?.backend, _;
|
|
1007
1103
|
try {
|
|
1008
|
-
|
|
1104
|
+
_ = await c();
|
|
1009
1105
|
} catch (e) {
|
|
1010
|
-
throw
|
|
1106
|
+
throw x.clear(m), e;
|
|
1011
1107
|
}
|
|
1012
|
-
if (
|
|
1013
|
-
if (!
|
|
1014
|
-
if (
|
|
1015
|
-
let
|
|
1016
|
-
await
|
|
1017
|
-
|
|
1108
|
+
if (x.getCurrentRequestId() !== m) throw x.clear(m), S(x.getAbortReason(m) || "superseded");
|
|
1109
|
+
if (!_.valid) throw x.clear(m), new v(_);
|
|
1110
|
+
if (p?.signal?.aborted) throw x.clear(m), S(String(p.signal.reason ?? ""));
|
|
1111
|
+
let y = he(o, h, g);
|
|
1112
|
+
await b?.(y), x.setActiveController(m, typeof AbortController < "u" ? new AbortController() : null), x.attachExternalSignal(p, m), e.batch(() => {
|
|
1113
|
+
f(), C.start(m);
|
|
1018
1114
|
});
|
|
1019
|
-
let
|
|
1115
|
+
let w = u(), T = e.getState().lifecycleVersion, k = x.createSignal(p);
|
|
1020
1116
|
try {
|
|
1021
|
-
let
|
|
1117
|
+
let o = F(y);
|
|
1022
1118
|
if (await n?.beforeSubmit?.({
|
|
1023
|
-
backend:
|
|
1024
|
-
...
|
|
1025
|
-
submitCount:
|
|
1026
|
-
signal:
|
|
1027
|
-
}),
|
|
1028
|
-
let c =
|
|
1029
|
-
backend:
|
|
1119
|
+
backend: h,
|
|
1120
|
+
...o,
|
|
1121
|
+
submitCount: w,
|
|
1122
|
+
signal: k
|
|
1123
|
+
}), k.aborted || x.isAborted(m)) throw S(x.getAbortReason(m));
|
|
1124
|
+
let c = F(y), u = {
|
|
1125
|
+
backend: h,
|
|
1030
1126
|
...c,
|
|
1031
|
-
fields:
|
|
1032
|
-
reports:
|
|
1033
|
-
metadata: { estimatedPayloadBytes:
|
|
1127
|
+
fields: a.fields,
|
|
1128
|
+
reports: a.reports,
|
|
1129
|
+
metadata: { estimatedPayloadBytes: le({
|
|
1034
1130
|
values: c.serializedValues,
|
|
1035
1131
|
fieldValues: c.serializedFieldValues
|
|
1036
1132
|
}) },
|
|
1037
|
-
signal:
|
|
1038
|
-
},
|
|
1133
|
+
signal: k
|
|
1134
|
+
}, f;
|
|
1039
1135
|
if (t.stream) {
|
|
1040
1136
|
let n = !1, r = await t.stream(u);
|
|
1041
|
-
for await (let t of r) if (
|
|
1137
|
+
for await (let t of r) if (tt(e, () => x.getCurrentRequestId(), nt(e.getState().submissionProgress, t), m, T), await j(t, y, h), t.type === "result") f = t.result, n = !0;
|
|
1042
1138
|
else if (t.type === "error") throw t.error;
|
|
1043
|
-
if (!n) throw new
|
|
1044
|
-
code:
|
|
1139
|
+
if (!n) throw new l("Form submission failed: stream completed without a result.", {
|
|
1140
|
+
code: d.SESSION_RESULT_MISSING,
|
|
1045
1141
|
retryable: !1,
|
|
1046
|
-
details: { backend:
|
|
1142
|
+
details: { backend: h }
|
|
1047
1143
|
});
|
|
1048
|
-
} else
|
|
1049
|
-
if (!(
|
|
1050
|
-
let
|
|
1051
|
-
backend:
|
|
1052
|
-
...
|
|
1053
|
-
reports:
|
|
1054
|
-
meta:
|
|
1055
|
-
raw:
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1144
|
+
} else f = await t.submit(u);
|
|
1145
|
+
if (!(x.getCurrentRequestId() === m && e.getState().lifecycleVersion === T && !k.aborted && !x.isAborted(m))) throw S(x.getAbortReason(m));
|
|
1146
|
+
let p = ge(f), g = {
|
|
1147
|
+
backend: h,
|
|
1148
|
+
...y,
|
|
1149
|
+
reports: p.reports ?? [],
|
|
1150
|
+
meta: p.meta ?? {},
|
|
1151
|
+
raw: p.raw
|
|
1152
|
+
};
|
|
1153
|
+
g.reportContexts = i(a.reports, g);
|
|
1154
|
+
let _ = await xe(s, {
|
|
1155
|
+
...g,
|
|
1058
1156
|
reportStates: {}
|
|
1059
|
-
}), v =
|
|
1157
|
+
}), v = Me(s, g, _), b = V(s, v);
|
|
1060
1158
|
e.batch(() => {
|
|
1061
|
-
|
|
1159
|
+
Se(s, _), C.succeed(b);
|
|
1062
1160
|
});
|
|
1063
1161
|
try {
|
|
1064
|
-
let e =
|
|
1162
|
+
let e = F(y);
|
|
1065
1163
|
await n?.afterSubmit?.({
|
|
1066
|
-
backend:
|
|
1164
|
+
backend: h,
|
|
1067
1165
|
...e,
|
|
1068
|
-
submitCount:
|
|
1069
|
-
result:
|
|
1166
|
+
submitCount: w,
|
|
1167
|
+
result: V(s, v)
|
|
1070
1168
|
});
|
|
1071
1169
|
} catch (e) {
|
|
1072
1170
|
if (r?.afterSubmit !== "preserve-success") throw e;
|
|
1073
|
-
await
|
|
1171
|
+
await E(h, y, w, e);
|
|
1074
1172
|
}
|
|
1075
|
-
return
|
|
1173
|
+
return V(s, v);
|
|
1076
1174
|
} catch (e) {
|
|
1077
|
-
return
|
|
1175
|
+
return ee(e) || k.aborted || x.isAborted(m) ? await D(e, m, T, w, y, h) : await O(e, m, T, w, y, h);
|
|
1078
1176
|
} finally {
|
|
1079
|
-
|
|
1177
|
+
x.clear(m), C.clear(m);
|
|
1080
1178
|
}
|
|
1081
1179
|
},
|
|
1082
1180
|
abort(e) {
|
|
1083
|
-
|
|
1181
|
+
x.abort(e);
|
|
1084
1182
|
},
|
|
1085
1183
|
reset() {
|
|
1086
|
-
|
|
1184
|
+
x.reset();
|
|
1087
1185
|
}
|
|
1088
1186
|
};
|
|
1089
|
-
},
|
|
1187
|
+
}, it = (e) => typeof e == "object" && !!e && !Array.isArray(e), at = (e, t) => Object.is(e, t), ot = (e, t) => e === t ? !0 : e.length === t.length ? e.every((e, n) => Object.is(e, t[n])) : !1, st = (e, t) => {
|
|
1090
1188
|
if (e === t) return !0;
|
|
1091
1189
|
let n = Object.keys(e), r = Object.keys(t);
|
|
1092
1190
|
return n.length === r.length ? n.every((n) => Object.is(e[n], t[n])) : !1;
|
|
1093
|
-
},
|
|
1094
|
-
let s =
|
|
1095
|
-
if (!c.visible) throw new
|
|
1096
|
-
if (c.disabled) throw new
|
|
1097
|
-
if (c.readOnly) throw new
|
|
1098
|
-
let l =
|
|
1099
|
-
return
|
|
1191
|
+
}, ct = (e, t) => Object.is(e, t) ? !0 : Array.isArray(e) && Array.isArray(t) ? ot(e, t) : it(e) && it(t) ? st(e, t) : !1, lt = (e, t, n, r) => Ve(e, t, n(), r()), ut = ({ config: e, definition: t, value: n, values: r, currentState: i, getSubmitCount: a, getFormStatus: o }) => {
|
|
1192
|
+
let s = J(t, e, n), c = lt(e, r, a, o);
|
|
1193
|
+
if (!c.visible) throw new g(`Field "${e.id}" is hidden and cannot be updated.`);
|
|
1194
|
+
if (c.disabled) throw new g(`Field "${e.id}" is disabled and cannot be updated.`);
|
|
1195
|
+
if (c.readOnly) throw new g(`Field "${e.id}" is read-only and cannot be updated.`);
|
|
1196
|
+
let l = Y(t, e, s, r, a(), c);
|
|
1197
|
+
return q({
|
|
1100
1198
|
...i,
|
|
1101
1199
|
value: s,
|
|
1102
1200
|
touched: !0,
|
|
1103
|
-
dirty: !
|
|
1201
|
+
dirty: !Ke(t, e, s, i.initialValue),
|
|
1104
1202
|
visible: c.visible,
|
|
1105
1203
|
disabled: c.disabled,
|
|
1106
1204
|
readOnly: c.readOnly,
|
|
@@ -1108,12 +1206,12 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1108
1206
|
validationErrors: [],
|
|
1109
1207
|
externalErrors: []
|
|
1110
1208
|
});
|
|
1111
|
-
},
|
|
1112
|
-
let s =
|
|
1113
|
-
return
|
|
1209
|
+
}, dt = ({ config: e, definition: t, currentState: n, values: r, getSubmitCount: i, getFormStatus: a, options: o }) => {
|
|
1210
|
+
let s = lt(e, r, i, a), c = e.inactiveFieldPolicy ?? o?.inactiveFieldPolicy, l = J(t, e, (o?.resetInactiveToInitial === !0 || c === "reset-on-hide") && (!s.visible || s.disabled) ? n.initialValue : n.value), u = Y(t, e, l, r, i(), s);
|
|
1211
|
+
return q({
|
|
1114
1212
|
...n,
|
|
1115
1213
|
value: l,
|
|
1116
|
-
dirty: !
|
|
1214
|
+
dirty: !Ke(t, e, l, n.initialValue),
|
|
1117
1215
|
visible: s.visible,
|
|
1118
1216
|
disabled: s.disabled,
|
|
1119
1217
|
readOnly: s.readOnly,
|
|
@@ -1130,10 +1228,10 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1130
1228
|
[t]: n
|
|
1131
1229
|
}
|
|
1132
1230
|
}));
|
|
1133
|
-
},
|
|
1134
|
-
let s =
|
|
1231
|
+
}, ft = ({ config: e, definition: t, store: n, getValues: r, getSubmitCount: i, getFormStatus: a, onValueChange: o }) => {
|
|
1232
|
+
let s = j(N(e)), c = Je(t, s, s.defaultValue === void 0 ? t.getDefaultValue?.(s) : s.defaultValue, r(), i(), a());
|
|
1135
1233
|
Z(n, e.id, c);
|
|
1136
|
-
let l = () => n.getState().fieldStates[e.id], u =
|
|
1234
|
+
let l = () => n.getState().fieldStates[e.id], u = Ye({
|
|
1137
1235
|
config: s,
|
|
1138
1236
|
definition: t,
|
|
1139
1237
|
store: n,
|
|
@@ -1153,7 +1251,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1153
1251
|
return s;
|
|
1154
1252
|
},
|
|
1155
1253
|
get state() {
|
|
1156
|
-
return
|
|
1254
|
+
return z(l());
|
|
1157
1255
|
},
|
|
1158
1256
|
setValue(t) {
|
|
1159
1257
|
let i = {
|
|
@@ -1175,7 +1273,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1175
1273
|
u.abort("value-updated"), this.commitState(this.prepareValue(e, t));
|
|
1176
1274
|
},
|
|
1177
1275
|
prepareValue(e, n) {
|
|
1178
|
-
return
|
|
1276
|
+
return ut({
|
|
1179
1277
|
config: s,
|
|
1180
1278
|
definition: t,
|
|
1181
1279
|
value: e,
|
|
@@ -1209,7 +1307,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1209
1307
|
let t = l();
|
|
1210
1308
|
return n.subscribe(() => {
|
|
1211
1309
|
let r = n.getState().fieldStates[s.id];
|
|
1212
|
-
|
|
1310
|
+
at(t, r) || (t = r, e(z(r)));
|
|
1213
1311
|
});
|
|
1214
1312
|
},
|
|
1215
1313
|
serialize() {
|
|
@@ -1217,17 +1315,17 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1217
1315
|
return t.serializeValue ? t.serializeValue(e, s) : e;
|
|
1218
1316
|
},
|
|
1219
1317
|
coerceValue(e) {
|
|
1220
|
-
return
|
|
1318
|
+
return J(t, s, e);
|
|
1221
1319
|
},
|
|
1222
1320
|
setExternalErrors(e) {
|
|
1223
1321
|
let t = l();
|
|
1224
|
-
Z(n, s.id,
|
|
1322
|
+
Z(n, s.id, q({
|
|
1225
1323
|
...t,
|
|
1226
1324
|
externalErrors: [...e]
|
|
1227
1325
|
}));
|
|
1228
1326
|
},
|
|
1229
1327
|
refresh(e) {
|
|
1230
|
-
let o =
|
|
1328
|
+
let o = dt({
|
|
1231
1329
|
config: s,
|
|
1232
1330
|
definition: t,
|
|
1233
1331
|
currentState: l(),
|
|
@@ -1243,14 +1341,14 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1243
1341
|
payload: void 0,
|
|
1244
1342
|
error: null,
|
|
1245
1343
|
status: "idle"
|
|
1246
|
-
},
|
|
1344
|
+
}, pt = {
|
|
1247
1345
|
payload: void 0,
|
|
1248
1346
|
error: null,
|
|
1249
1347
|
status: "loading"
|
|
1250
|
-
},
|
|
1251
|
-
if (n !== void 0) return e.clonePayload ? e.clonePayload(n, t) :
|
|
1252
|
-
},
|
|
1253
|
-
payload:
|
|
1348
|
+
}, mt = (e, t, n) => {
|
|
1349
|
+
if (n !== void 0) return e.clonePayload ? e.clonePayload(n, t) : N(n);
|
|
1350
|
+
}, ht = (e, t, n) => ({
|
|
1351
|
+
payload: mt(e, t, n.payload),
|
|
1254
1352
|
error: n.error,
|
|
1255
1353
|
status: n.status
|
|
1256
1354
|
}), $ = (e, t, n) => {
|
|
@@ -1261,20 +1359,20 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1261
1359
|
[t]: n
|
|
1262
1360
|
}
|
|
1263
1361
|
}));
|
|
1264
|
-
},
|
|
1362
|
+
}, gt = (e, t, n, r) => {
|
|
1265
1363
|
if (n === void 0 || !e.payloadSchema) return {
|
|
1266
|
-
payload:
|
|
1364
|
+
payload: mt(e, t, n),
|
|
1267
1365
|
error: null,
|
|
1268
1366
|
status: n === void 0 ? "idle" : "ready"
|
|
1269
1367
|
};
|
|
1270
1368
|
try {
|
|
1271
1369
|
return {
|
|
1272
|
-
payload:
|
|
1370
|
+
payload: mt(e, t, e.payloadSchema.parse(n)),
|
|
1273
1371
|
error: null,
|
|
1274
1372
|
status: "ready"
|
|
1275
1373
|
};
|
|
1276
1374
|
} catch (t) {
|
|
1277
|
-
let n =
|
|
1375
|
+
let n = u(t);
|
|
1278
1376
|
if (e.payloadValidationPolicy === "fail-submit") throw r(n, t);
|
|
1279
1377
|
return {
|
|
1280
1378
|
payload: void 0,
|
|
@@ -1282,10 +1380,10 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1282
1380
|
status: "error"
|
|
1283
1381
|
};
|
|
1284
1382
|
}
|
|
1285
|
-
},
|
|
1286
|
-
let a =
|
|
1383
|
+
}, _t = ({ config: e, definition: n, store: r, hooks: i }) => {
|
|
1384
|
+
let a = j(N(e));
|
|
1287
1385
|
$(r, a.id, Q);
|
|
1288
|
-
let
|
|
1386
|
+
let o = c();
|
|
1289
1387
|
return {
|
|
1290
1388
|
get id() {
|
|
1291
1389
|
return a.id;
|
|
@@ -1303,18 +1401,18 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1303
1401
|
return n.fetch !== void 0;
|
|
1304
1402
|
},
|
|
1305
1403
|
get state() {
|
|
1306
|
-
return
|
|
1404
|
+
return ht(n, a, r.getState().reportStates[a.id]);
|
|
1307
1405
|
},
|
|
1308
1406
|
cloneState(e) {
|
|
1309
|
-
return
|
|
1407
|
+
return ht(n, a, e);
|
|
1310
1408
|
},
|
|
1311
|
-
async prepareState(
|
|
1409
|
+
async prepareState(e) {
|
|
1312
1410
|
let r;
|
|
1313
1411
|
try {
|
|
1314
1412
|
r = n.resolvePayload ? await n.resolvePayload(a, {
|
|
1315
1413
|
report: a,
|
|
1316
|
-
result:
|
|
1317
|
-
}) :
|
|
1414
|
+
result: e
|
|
1415
|
+
}) : n.fetch && a.mappedTo === void 0 ? void 0 : t(a, e);
|
|
1318
1416
|
} catch (e) {
|
|
1319
1417
|
return {
|
|
1320
1418
|
payload: void 0,
|
|
@@ -1322,7 +1420,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1322
1420
|
status: "error"
|
|
1323
1421
|
};
|
|
1324
1422
|
}
|
|
1325
|
-
return
|
|
1423
|
+
return gt(n, a, r, (e, t) => new b(a.id, e, t));
|
|
1326
1424
|
},
|
|
1327
1425
|
commitState(e) {
|
|
1328
1426
|
$(r, a.id, this.cloneState(e));
|
|
@@ -1331,16 +1429,16 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1331
1429
|
this.commitState(await this.prepareState(e));
|
|
1332
1430
|
},
|
|
1333
1431
|
markLoading() {
|
|
1334
|
-
$(r, a.id,
|
|
1432
|
+
$(r, a.id, pt);
|
|
1335
1433
|
},
|
|
1336
1434
|
async fetch(e) {
|
|
1337
1435
|
let t = r.getState().reportStates[a.id] ?? Q;
|
|
1338
1436
|
if (!n.fetch || t.status !== "idle") return;
|
|
1339
|
-
$(r, a.id,
|
|
1340
|
-
let
|
|
1437
|
+
$(r, a.id, pt);
|
|
1438
|
+
let s = n.fetch({
|
|
1341
1439
|
config: a,
|
|
1342
1440
|
reportId: a.id
|
|
1343
|
-
}), c = await
|
|
1441
|
+
}), c = await o.run((t) => s.submit({
|
|
1344
1442
|
...e,
|
|
1345
1443
|
signal: t
|
|
1346
1444
|
}), [e.signal]);
|
|
@@ -1349,7 +1447,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1349
1447
|
return;
|
|
1350
1448
|
}
|
|
1351
1449
|
if (c.status === "completed") {
|
|
1352
|
-
let e =
|
|
1450
|
+
let e = gt(n, a, c.value, (e, t) => t instanceof Error ? t : Error(String(t)));
|
|
1353
1451
|
$(r, a.id, e), e.status === "ready" && await i?.afterReportFetch?.({
|
|
1354
1452
|
reportId: a.id,
|
|
1355
1453
|
kind: a.kind,
|
|
@@ -1368,29 +1466,21 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1368
1466
|
});
|
|
1369
1467
|
},
|
|
1370
1468
|
abort() {
|
|
1371
|
-
|
|
1469
|
+
o.abort(), $(r, a.id, Q);
|
|
1372
1470
|
},
|
|
1373
1471
|
reset() {
|
|
1374
|
-
|
|
1472
|
+
o.abort(), $(r, a.id, Q);
|
|
1375
1473
|
},
|
|
1376
1474
|
subscribe(e) {
|
|
1377
1475
|
let t = r.getState().reportStates[a.id];
|
|
1378
1476
|
return r.subscribe(() => {
|
|
1379
1477
|
let n = r.getState().reportStates[a.id];
|
|
1380
|
-
|
|
1478
|
+
at(t, n) || (t = n, e(this.cloneState(n)));
|
|
1381
1479
|
});
|
|
1382
1480
|
}
|
|
1383
1481
|
};
|
|
1384
|
-
},
|
|
1385
|
-
|
|
1386
|
-
}, ot = (e) => {
|
|
1387
|
-
for (let t in e) {
|
|
1388
|
-
let n = e[t];
|
|
1389
|
-
if (n?.dirty || n?.touched) return !0;
|
|
1390
|
-
}
|
|
1391
|
-
return !1;
|
|
1392
|
-
}, st = (e, t) => e.config.inactiveFieldPolicy ?? t ?? "omit", ct = (e, t) => new A(`${e} definition "${t}" disappeared during form creation.`), lt = ({ registry: e, behaviors: t, fields: n, getValues: r, getSubmitCount: i, getFormStatus: o, commitDerivedValue: s, syncDerivedState: c, onListenerError: l }) => {
|
|
1393
|
-
let u = new Map(n.map((e) => [e.id, e])), d = (e) => u.get(e) ?? u.get(a(e)), f = () => ({
|
|
1482
|
+
}, vt = ({ registry: e, behaviors: t, fields: n, getValues: i, getSubmitCount: a, getFormStatus: o, commitDerivedValue: s, syncDerivedState: c, onListenerError: l }) => {
|
|
1483
|
+
let u = new Map(n.map((e) => [e.id, e])), d = (e) => u.get(e) ?? u.get(r(e)), f = () => ({
|
|
1394
1484
|
registry: e,
|
|
1395
1485
|
fields: n,
|
|
1396
1486
|
getField(e) {
|
|
@@ -1399,8 +1489,8 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1399
1489
|
resolveFieldId(e) {
|
|
1400
1490
|
return d(e)?.id;
|
|
1401
1491
|
},
|
|
1402
|
-
getValues:
|
|
1403
|
-
getSubmitCount:
|
|
1492
|
+
getValues: i,
|
|
1493
|
+
getSubmitCount: a,
|
|
1404
1494
|
getFormStatus: o,
|
|
1405
1495
|
commitDerivedValue: s,
|
|
1406
1496
|
syncDerivedState: c
|
|
@@ -1411,7 +1501,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1411
1501
|
let n = f();
|
|
1412
1502
|
for (let r of t) {
|
|
1413
1503
|
let t = r.onValuesChanged?.(e, n);
|
|
1414
|
-
|
|
1504
|
+
k(t) && Promise.resolve(t).catch((e) => {
|
|
1415
1505
|
l?.(e);
|
|
1416
1506
|
});
|
|
1417
1507
|
}
|
|
@@ -1427,57 +1517,71 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1427
1517
|
fieldMap: u,
|
|
1428
1518
|
resolveField: d
|
|
1429
1519
|
};
|
|
1430
|
-
},
|
|
1431
|
-
let
|
|
1520
|
+
}, yt = ({ fields: e, reports: t, fieldMap: n, reportMap: r, store: i, getPublicState: o, getValues: c, getInternalValues: l, formValidator: u, formSubmitter: d, syncDerivedFieldState: f, shouldResetInactiveFields: p, inactiveFieldPolicy: m, bumpLifecycleVersion: h, resetReports: _, runBehaviorValueChange: v }) => {
|
|
1521
|
+
let y = Object.freeze([...e]), b = Object.freeze([...t]);
|
|
1432
1522
|
return {
|
|
1433
1523
|
get fields() {
|
|
1434
|
-
return
|
|
1524
|
+
return y;
|
|
1435
1525
|
},
|
|
1436
1526
|
get reports() {
|
|
1437
|
-
return
|
|
1527
|
+
return b;
|
|
1438
1528
|
},
|
|
1439
1529
|
get state() {
|
|
1440
|
-
return
|
|
1530
|
+
return o();
|
|
1441
1531
|
},
|
|
1442
1532
|
getField(e) {
|
|
1443
1533
|
return n.get(e);
|
|
1444
1534
|
},
|
|
1535
|
+
getFieldByDisplayKey(t) {
|
|
1536
|
+
let n = t.trim();
|
|
1537
|
+
return e.find((e) => e.config.displayKey?.trim() === n);
|
|
1538
|
+
},
|
|
1539
|
+
getFieldByMappedTo(t, n) {
|
|
1540
|
+
let r = s(t);
|
|
1541
|
+
return e.find((e) => {
|
|
1542
|
+
let t = a(e.config.mappedTo, n?.backend);
|
|
1543
|
+
return t !== void 0 && s(t) === r ? !0 : e.config.options?.some((e) => {
|
|
1544
|
+
let t = a(e.mappedTo, n?.backend);
|
|
1545
|
+
return t !== void 0 && s(t) === r;
|
|
1546
|
+
}) ?? !1;
|
|
1547
|
+
});
|
|
1548
|
+
},
|
|
1445
1549
|
getReport(e) {
|
|
1446
1550
|
return r.get(e);
|
|
1447
1551
|
},
|
|
1448
1552
|
getValues() {
|
|
1449
|
-
return
|
|
1553
|
+
return c();
|
|
1450
1554
|
},
|
|
1451
1555
|
setValues(e) {
|
|
1452
1556
|
i.batch(() => {
|
|
1453
|
-
let t = Object.entries(e), r = { ...
|
|
1557
|
+
let t = Object.entries(e), r = { ...l() }, a = /* @__PURE__ */ new Map();
|
|
1454
1558
|
for (let [e, i] of t) {
|
|
1455
1559
|
let t = n.get(e);
|
|
1456
|
-
if (!t) throw new
|
|
1560
|
+
if (!t) throw new g(`Unknown field "${e}".`);
|
|
1457
1561
|
r[e] = t.coerceValue(i);
|
|
1458
1562
|
}
|
|
1459
1563
|
for (let [e, i] of t) {
|
|
1460
1564
|
let t = n.get(e);
|
|
1461
|
-
if (!t) throw new
|
|
1565
|
+
if (!t) throw new g(`Unknown field "${e}".`);
|
|
1462
1566
|
a.set(e, t.prepareValue(i, r));
|
|
1463
1567
|
}
|
|
1464
|
-
|
|
1568
|
+
h();
|
|
1465
1569
|
for (let [e, t] of a) {
|
|
1466
1570
|
let r = n.get(e);
|
|
1467
|
-
if (!r) throw new
|
|
1571
|
+
if (!r) throw new g(`Unknown field "${e}".`);
|
|
1468
1572
|
r.commitState(t);
|
|
1469
1573
|
}
|
|
1470
|
-
i.update((e) =>
|
|
1574
|
+
i.update((e) => R(e, {
|
|
1471
1575
|
type: "editing",
|
|
1472
1576
|
clearFormErrors: !0
|
|
1473
|
-
})),
|
|
1577
|
+
})), f({
|
|
1474
1578
|
values: r,
|
|
1475
1579
|
preserveValidationErrors: !1,
|
|
1476
1580
|
preserveExternalErrors: !1,
|
|
1477
|
-
resetInactiveToInitial:
|
|
1478
|
-
inactiveFieldPolicy:
|
|
1581
|
+
resetInactiveToInitial: p(),
|
|
1582
|
+
inactiveFieldPolicy: m
|
|
1479
1583
|
});
|
|
1480
|
-
for (let [e] of t)
|
|
1584
|
+
for (let [e] of t) v({
|
|
1481
1585
|
fieldId: e,
|
|
1482
1586
|
source: "local",
|
|
1483
1587
|
values: r
|
|
@@ -1485,19 +1589,19 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1485
1589
|
});
|
|
1486
1590
|
},
|
|
1487
1591
|
validate() {
|
|
1488
|
-
return
|
|
1592
|
+
return u.validate();
|
|
1489
1593
|
},
|
|
1490
1594
|
submit(e) {
|
|
1491
|
-
return
|
|
1595
|
+
return d.submit(e);
|
|
1492
1596
|
},
|
|
1493
1597
|
abortSubmit(e) {
|
|
1494
|
-
|
|
1598
|
+
d.abort(e);
|
|
1495
1599
|
},
|
|
1496
1600
|
reset() {
|
|
1497
1601
|
i.batch(() => {
|
|
1498
|
-
|
|
1602
|
+
d.abort("reset"), h();
|
|
1499
1603
|
for (let t of e) t.reset();
|
|
1500
|
-
|
|
1604
|
+
_(), d.reset(), i.update((e) => R(e, { type: "reset" })), f({
|
|
1501
1605
|
preserveValidationErrors: !1,
|
|
1502
1606
|
preserveExternalErrors: !1
|
|
1503
1607
|
});
|
|
@@ -1505,18 +1609,18 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1505
1609
|
},
|
|
1506
1610
|
subscribe(e) {
|
|
1507
1611
|
return i.subscribe(() => {
|
|
1508
|
-
e(
|
|
1612
|
+
e(o());
|
|
1509
1613
|
});
|
|
1510
1614
|
},
|
|
1511
1615
|
subscribeSelector(e, t, n) {
|
|
1512
|
-
let r = n?.equality ??
|
|
1513
|
-
return n?.emitInitial && t(
|
|
1514
|
-
let n =
|
|
1515
|
-
r(
|
|
1616
|
+
let r = n?.equality ?? ct, a = e(o());
|
|
1617
|
+
return n?.emitInitial && t(a, o()), i.subscribe(() => {
|
|
1618
|
+
let n = o(), i = e(n);
|
|
1619
|
+
r(a, i) || (a = i, t(i, n));
|
|
1516
1620
|
});
|
|
1517
1621
|
}
|
|
1518
1622
|
};
|
|
1519
|
-
},
|
|
1623
|
+
}, bt = ({ store: e, fields: t, shouldResetInactiveFields: n, inactiveFieldPolicy: r, hasInteractiveFieldState: i }) => {
|
|
1520
1624
|
function a(n) {
|
|
1521
1625
|
e.batch(() => {
|
|
1522
1626
|
let e = n?.resetInactiveToInitial === !0 ? { ...n.values } : n?.values;
|
|
@@ -1535,7 +1639,7 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1535
1639
|
setRestingStatus: () => {
|
|
1536
1640
|
e.batch(() => {
|
|
1537
1641
|
let t = i(e.getState().fieldStates) ? "editing" : "idle";
|
|
1538
|
-
e.update((e) =>
|
|
1642
|
+
e.update((e) => R(e, {
|
|
1539
1643
|
type: "rest",
|
|
1540
1644
|
status: t
|
|
1541
1645
|
})), a({
|
|
@@ -1547,11 +1651,11 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1547
1651
|
});
|
|
1548
1652
|
}
|
|
1549
1653
|
};
|
|
1550
|
-
},
|
|
1551
|
-
getValues: () => Object.fromEntries(Object.entries(t()).map(([e, t]) => [e,
|
|
1654
|
+
}, xt = (e, t) => e.get(t), St = ({ getFieldMap: e, getValues: t, getCurrentFieldState: n, syncDerivedFieldState: r, shouldResetInactiveFields: i, inactiveFieldPolicy: a }) => ({
|
|
1655
|
+
getValues: () => Object.fromEntries(Object.entries(t()).map(([e, t]) => [e, N(t)])),
|
|
1552
1656
|
commitDerivedValue: (o, s) => {
|
|
1553
|
-
let c =
|
|
1554
|
-
if (!c) throw new
|
|
1657
|
+
let c = xt(e(), o);
|
|
1658
|
+
if (!c) throw new g(`Unknown field "${o}".`);
|
|
1555
1659
|
let l = c.coerceValue(s), u = {
|
|
1556
1660
|
...t(),
|
|
1557
1661
|
[c.id]: l
|
|
@@ -1567,30 +1671,30 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1567
1671
|
inactiveFieldPolicy: a
|
|
1568
1672
|
}), c.validate());
|
|
1569
1673
|
}
|
|
1570
|
-
}),
|
|
1571
|
-
|
|
1572
|
-
let
|
|
1573
|
-
listenerErrorPolicy:
|
|
1574
|
-
onListenerError:
|
|
1575
|
-
}), a = i.getState(), o =
|
|
1674
|
+
}), Ct = (t) => {
|
|
1675
|
+
C(t.transport);
|
|
1676
|
+
let n = e(t.schema, t.registry), r = t.behaviors ?? [], i = Ae(Te(), {
|
|
1677
|
+
listenerErrorPolicy: t.listenerErrorPolicy ?? "ignore",
|
|
1678
|
+
onListenerError: t.onListenerError
|
|
1679
|
+
}), a = i.getState(), o = B(a), s = () => {
|
|
1576
1680
|
let e = i.getState();
|
|
1577
|
-
return e !== a && (a = e, o =
|
|
1578
|
-
}, c = () => i.getState().submitCount, l = () => i.getState().status, u = () =>
|
|
1579
|
-
let n =
|
|
1580
|
-
if (!n) throw
|
|
1581
|
-
return
|
|
1681
|
+
return e !== a && (a = e, o = B(e)), o;
|
|
1682
|
+
}, c = () => i.getState().submitCount, l = () => i.getState().status, u = () => t.inactiveFieldPolicy === "reset-on-hide", d = () => Object.fromEntries(Object.entries(i.getState().fieldStates).map(([e, t]) => [e, t.value])), f = n.fields.map((e) => {
|
|
1683
|
+
let n = t.registry.getField(e.kind);
|
|
1684
|
+
if (!n) throw E("Field", e.kind);
|
|
1685
|
+
return ft({
|
|
1582
1686
|
config: {
|
|
1583
|
-
...
|
|
1584
|
-
defaultValue:
|
|
1687
|
+
...e,
|
|
1688
|
+
defaultValue: t.initialValues?.[e.id] === void 0 ? e.defaultValue : t.initialValues[e.id]
|
|
1585
1689
|
},
|
|
1586
1690
|
definition: n,
|
|
1587
1691
|
store: i,
|
|
1588
1692
|
getValues: () => d(),
|
|
1589
1693
|
getSubmitCount: c,
|
|
1590
1694
|
getFormStatus: l,
|
|
1591
|
-
onValueChange: (
|
|
1695
|
+
onValueChange: (e, n) => {
|
|
1592
1696
|
i.batch(() => {
|
|
1593
|
-
i.update((e) =>
|
|
1697
|
+
i.update((e) => R(e, {
|
|
1594
1698
|
type: "editing",
|
|
1595
1699
|
clearFormErrors: !0,
|
|
1596
1700
|
bumpLifecycle: !0
|
|
@@ -1599,73 +1703,73 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1599
1703
|
preserveValidationErrors: !1,
|
|
1600
1704
|
preserveExternalErrors: !1,
|
|
1601
1705
|
resetInactiveToInitial: u(),
|
|
1602
|
-
inactiveFieldPolicy:
|
|
1706
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy
|
|
1603
1707
|
});
|
|
1604
1708
|
}), x({
|
|
1605
|
-
fieldId:
|
|
1709
|
+
fieldId: e,
|
|
1606
1710
|
source: "local",
|
|
1607
1711
|
values: n
|
|
1608
1712
|
});
|
|
1609
1713
|
}
|
|
1610
1714
|
});
|
|
1611
|
-
}), p =
|
|
1612
|
-
let n =
|
|
1613
|
-
if (!n) throw
|
|
1614
|
-
return
|
|
1615
|
-
config:
|
|
1715
|
+
}), p = n.reports.map((e) => {
|
|
1716
|
+
let n = t.registry.getReport(e.kind);
|
|
1717
|
+
if (!n) throw E("Report", e.kind);
|
|
1718
|
+
return _t({
|
|
1719
|
+
config: e,
|
|
1616
1720
|
definition: n,
|
|
1617
1721
|
store: i,
|
|
1618
|
-
hooks:
|
|
1722
|
+
hooks: t.hooks
|
|
1619
1723
|
});
|
|
1620
|
-
}), m = new Map(f.map((e) => [e.id, e])), h = new Map(p.map((e) => [e.id, e])), g = (e) => i.getState().fieldStates[e], { syncDerivedFieldState: _, setRestingStatus: v } =
|
|
1724
|
+
}), m = new Map(f.map((e) => [e.id, e])), h = new Map(p.map((e) => [e.id, e])), g = (e) => i.getState().fieldStates[e], { syncDerivedFieldState: _, setRestingStatus: v } = bt({
|
|
1621
1725
|
store: i,
|
|
1622
1726
|
fields: f,
|
|
1623
1727
|
shouldResetInactiveFields: u,
|
|
1624
|
-
inactiveFieldPolicy:
|
|
1625
|
-
hasInteractiveFieldState:
|
|
1626
|
-
}), { getValues: y, commitDerivedValue: b } =
|
|
1728
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy,
|
|
1729
|
+
hasInteractiveFieldState: w
|
|
1730
|
+
}), { getValues: y, commitDerivedValue: b } = St({
|
|
1627
1731
|
getFieldMap: () => m,
|
|
1628
1732
|
getValues: d,
|
|
1629
1733
|
getCurrentFieldState: g,
|
|
1630
1734
|
syncDerivedFieldState: _,
|
|
1631
1735
|
shouldResetInactiveFields: u,
|
|
1632
|
-
inactiveFieldPolicy:
|
|
1633
|
-
}), { runBehaviorValueChange: x, runBeforeSubmitRecords: S, validateBehaviors:
|
|
1634
|
-
registry:
|
|
1736
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy
|
|
1737
|
+
}), { runBehaviorValueChange: x, runBeforeSubmitRecords: S, validateBehaviors: ee } = vt({
|
|
1738
|
+
registry: t.registry,
|
|
1635
1739
|
behaviors: r,
|
|
1636
1740
|
fields: f,
|
|
1637
1741
|
getValues: y,
|
|
1638
1742
|
getSubmitCount: c,
|
|
1639
1743
|
getFormStatus: l,
|
|
1640
1744
|
commitDerivedValue: b,
|
|
1641
|
-
syncDerivedState(
|
|
1745
|
+
syncDerivedState(e) {
|
|
1642
1746
|
_({
|
|
1643
|
-
values:
|
|
1747
|
+
values: e,
|
|
1644
1748
|
preserveValidationErrors: !0,
|
|
1645
1749
|
preserveExternalErrors: !0,
|
|
1646
1750
|
resetInactiveToInitial: u(),
|
|
1647
|
-
inactiveFieldPolicy:
|
|
1751
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy
|
|
1648
1752
|
});
|
|
1649
1753
|
},
|
|
1650
|
-
onListenerError:
|
|
1651
|
-
}),
|
|
1754
|
+
onListenerError: t.onListenerError
|
|
1755
|
+
}), D = () => {
|
|
1652
1756
|
for (let e of p) e.reset();
|
|
1653
|
-
},
|
|
1757
|
+
}, O = () => {
|
|
1654
1758
|
for (let e of p) e.markLoading();
|
|
1655
|
-
},
|
|
1759
|
+
}, k = () => (i.update((e) => R(e, { type: "bump-lifecycle" })), i.getState().lifecycleVersion), A = Ze({
|
|
1656
1760
|
store: i,
|
|
1657
1761
|
fields: f,
|
|
1658
|
-
normalizedSchema:
|
|
1659
|
-
validators:
|
|
1660
|
-
hooks:
|
|
1762
|
+
normalizedSchema: n,
|
|
1763
|
+
validators: t.validators,
|
|
1764
|
+
hooks: t.hooks,
|
|
1661
1765
|
getValues: y,
|
|
1662
1766
|
getSubmitCount: c,
|
|
1663
1767
|
getFormStatus: l,
|
|
1664
1768
|
syncDerivedFieldState: _,
|
|
1665
1769
|
setRestingStatus: v,
|
|
1666
1770
|
shouldResetInactiveFields: u,
|
|
1667
|
-
inactiveFieldPolicy:
|
|
1668
|
-
}),
|
|
1771
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy
|
|
1772
|
+
}), te = yt({
|
|
1669
1773
|
fields: f,
|
|
1670
1774
|
reports: p,
|
|
1671
1775
|
fieldMap: m,
|
|
@@ -1674,33 +1778,33 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1674
1778
|
getPublicState: s,
|
|
1675
1779
|
getValues: y,
|
|
1676
1780
|
getInternalValues: d,
|
|
1677
|
-
formValidator:
|
|
1678
|
-
formSubmitter:
|
|
1781
|
+
formValidator: A,
|
|
1782
|
+
formSubmitter: rt({
|
|
1679
1783
|
store: i,
|
|
1680
|
-
transport:
|
|
1681
|
-
hooks:
|
|
1682
|
-
hookFailurePolicy:
|
|
1683
|
-
normalizedSchema:
|
|
1784
|
+
transport: t.transport,
|
|
1785
|
+
hooks: t.hooks,
|
|
1786
|
+
hookFailurePolicy: t.hookFailurePolicy,
|
|
1787
|
+
normalizedSchema: n,
|
|
1684
1788
|
fields: f,
|
|
1685
1789
|
reports: p,
|
|
1686
|
-
validate: () =>
|
|
1790
|
+
validate: () => A.validate(),
|
|
1687
1791
|
getSubmitCount: c,
|
|
1688
|
-
markReportsLoading:
|
|
1689
|
-
resetReports:
|
|
1792
|
+
markReportsLoading: O,
|
|
1793
|
+
resetReports: D,
|
|
1690
1794
|
syncDerivedFieldState: _,
|
|
1691
1795
|
shouldResetInactiveFields: u,
|
|
1692
|
-
resolveInactiveFieldPolicy: (
|
|
1693
|
-
inactiveFieldPolicy:
|
|
1694
|
-
onRemoteFieldUpdate: async (
|
|
1796
|
+
resolveInactiveFieldPolicy: (e) => T(e, t.inactiveFieldPolicy),
|
|
1797
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy,
|
|
1798
|
+
onRemoteFieldUpdate: async (e) => {
|
|
1695
1799
|
let n = y();
|
|
1696
1800
|
_({
|
|
1697
1801
|
values: n,
|
|
1698
1802
|
preserveValidationErrors: !0,
|
|
1699
1803
|
preserveExternalErrors: !0,
|
|
1700
1804
|
resetInactiveToInitial: u(),
|
|
1701
|
-
inactiveFieldPolicy:
|
|
1805
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy
|
|
1702
1806
|
}), x({
|
|
1703
|
-
fieldId:
|
|
1807
|
+
fieldId: e,
|
|
1704
1808
|
source: "remote",
|
|
1705
1809
|
values: n
|
|
1706
1810
|
});
|
|
@@ -1709,9 +1813,9 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1709
1813
|
}),
|
|
1710
1814
|
syncDerivedFieldState: _,
|
|
1711
1815
|
shouldResetInactiveFields: u,
|
|
1712
|
-
inactiveFieldPolicy:
|
|
1713
|
-
bumpLifecycleVersion:
|
|
1714
|
-
resetReports:
|
|
1816
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy,
|
|
1817
|
+
bumpLifecycleVersion: k,
|
|
1818
|
+
resetReports: D,
|
|
1715
1819
|
runBehaviorValueChange: x
|
|
1716
1820
|
});
|
|
1717
1821
|
return _({
|
|
@@ -1719,8 +1823,8 @@ var u = "Unknown report fetch error.", d = async ({ reports: e, request: t }) =>
|
|
|
1719
1823
|
preserveValidationErrors: !1,
|
|
1720
1824
|
preserveExternalErrors: !1,
|
|
1721
1825
|
resetInactiveToInitial: u(),
|
|
1722
|
-
inactiveFieldPolicy:
|
|
1723
|
-
}),
|
|
1826
|
+
inactiveFieldPolicy: t.inactiveFieldPolicy
|
|
1827
|
+
}), ee(), te;
|
|
1724
1828
|
};
|
|
1725
1829
|
//#endregion
|
|
1726
|
-
export {
|
|
1830
|
+
export { h as _, st as a, L as c, g as d, _ as f, v as g, y as h, ct as i, te as l, x as m, at as n, be as o, b as p, ot as r, _e as s, Ct as t, k as u, p as v };
|