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