@dynamicforms/vue-forms 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dynamicforms-vue-forms.css +2 -1
- package/dist/dynamicforms-vue-forms.js +1962 -2887
- package/dist/dynamicforms-vue-forms.js.map +1 -1
- package/dist/index.d.ts +39 -3
- package/package.json +5 -5
|
@@ -1,2890 +1,1965 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
for (let e = this.undo.length - 1; e >= 0; e--) this.undo[e]();
|
|
196
|
-
this.undo.length = 0, this.settled.length = 0;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Announces what the transaction did. Values first and verdicts after, because a container's validators run
|
|
200
|
-
* with its value announcement and the verdict they reach is what the validity pass then reports. Both passes
|
|
201
|
-
* run deepest first - field, then row, then list - which is the order the change travelled in.
|
|
202
|
-
*
|
|
203
|
-
* A handler may write while the commit runs; its writes join this transaction, so both passes repeat until
|
|
204
|
-
* nothing is left dirty.
|
|
205
|
-
*/
|
|
206
|
-
commit() {
|
|
207
|
-
for (; !(!this.announceValues() && !this.settleValidity()); )
|
|
208
|
-
;
|
|
209
|
-
for (let t = 0; t < this.settled.length; t++) this.settled[t]();
|
|
210
|
-
this.settled.length = 0;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* The dirty participants a pass has to visit, one bucket per nesting depth; ties keep the order they were
|
|
214
|
-
* enrolled in. A nesting depth is a small integer, so the elements go into buckets rather than through a
|
|
215
|
-
* comparison sort: a whole-list assignment enrols one participant per field, and ordering those by comparison
|
|
216
|
-
* would cost more than the announcement it orders.
|
|
217
|
-
*/
|
|
218
|
-
buckets(t) {
|
|
219
|
-
const e = [];
|
|
220
|
-
return this.participants.forEach((s) => {
|
|
221
|
-
if (!t(s)) return;
|
|
222
|
-
const i = ct(s.element);
|
|
223
|
-
(e[i] ??= []).push(s);
|
|
224
|
-
}), e;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Runs one pass over the dirty participants, deepest bucket first; the caller repeats it until it answers
|
|
228
|
-
* false. The buckets are taken once, and the pass gives up as soon as a handler enrols an element at or below
|
|
229
|
-
* the depth being drained: that element is not in the bucket being walked, and going on would reach the
|
|
230
|
-
* containers above it first. The caller's next pass takes fresh buckets and finds it at its own depth.
|
|
231
|
-
*/
|
|
232
|
-
pass(t, e) {
|
|
233
|
-
const s = this.buckets(t);
|
|
234
|
-
if (!s.length) return !1;
|
|
235
|
-
for (let i = s.length - 1; i >= 0; i--) {
|
|
236
|
-
const r = s[i];
|
|
237
|
-
if (r) {
|
|
238
|
-
this.passDepth = i, this.restartPass = !1;
|
|
239
|
-
try {
|
|
240
|
-
for (let a = 0; a < r.length; a++) {
|
|
241
|
-
if (this.restartPass) return !0;
|
|
242
|
-
const o = r[a];
|
|
243
|
-
t(o) && e(o);
|
|
244
|
-
}
|
|
245
|
-
} finally {
|
|
246
|
-
this.passDepth = -1;
|
|
247
|
-
}
|
|
248
|
-
if (this.restartPass) return !0;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return !0;
|
|
252
|
-
}
|
|
253
|
-
announceValues() {
|
|
254
|
-
return this.pass(
|
|
255
|
-
(t) => t.valueDirty || t.structural !== void 0,
|
|
256
|
-
(t) => {
|
|
257
|
-
const { structural: e } = t, s = t.valueDirty, i = t.forceValue;
|
|
258
|
-
t.structural = void 0, t.valueDirty = !1, t.forceValue = !1, t.element[xt](this, s, i, e);
|
|
259
|
-
}
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
settleValidity() {
|
|
263
|
-
return this.pass(
|
|
264
|
-
(t) => t.validityDirty,
|
|
265
|
-
(t) => {
|
|
266
|
-
t.validityDirty = !1, t.element[At](this);
|
|
267
|
-
}
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
let A, H;
|
|
272
|
-
function It() {
|
|
273
|
-
return A;
|
|
274
|
-
}
|
|
275
|
-
class Tt {
|
|
276
|
-
}
|
|
277
|
-
class Zt {
|
|
278
|
-
open = !0;
|
|
279
|
-
rollback() {
|
|
280
|
-
throw this.open ? new Tt() : new TypeError(
|
|
281
|
-
"this transaction handle is spent: the transaction that handed it out has closed. A handle is only usable inside the call that received it."
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
close() {
|
|
285
|
-
this.open = !1;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
function ht(n) {
|
|
289
|
-
if (n != null && typeof n.then == "function")
|
|
290
|
-
throw new TypeError(
|
|
291
|
-
"a transaction may not be asynchronous: the callback returned a thenable. Do the awaiting outside and open a transaction for each synchronous part."
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
function J(n) {
|
|
295
|
-
if (A) {
|
|
296
|
-
const s = n(H);
|
|
297
|
-
return ht(s), s;
|
|
298
|
-
}
|
|
299
|
-
const t = new Jt(), e = new Zt();
|
|
300
|
-
A = t, H = e;
|
|
301
|
-
try {
|
|
302
|
-
const s = n(e);
|
|
303
|
-
return ht(s), t.commit(), s;
|
|
304
|
-
} catch (s) {
|
|
305
|
-
if (t.rollback(), s instanceof Tt) return;
|
|
306
|
-
throw s;
|
|
307
|
-
} finally {
|
|
308
|
-
A = void 0, H = void 0, e.close();
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
function u(n) {
|
|
312
|
-
return A ? n(A) : J(() => n(A));
|
|
313
|
-
}
|
|
314
|
-
const Ot = { useMarkdownInValidators: !0 };
|
|
315
|
-
function Gt() {
|
|
316
|
-
return Ot;
|
|
317
|
-
}
|
|
318
|
-
function te(n) {
|
|
319
|
-
Object.assign(Ot, n);
|
|
320
|
-
}
|
|
321
|
-
const Ue = {
|
|
322
|
-
install(n, t) {
|
|
323
|
-
t && te(t);
|
|
324
|
-
}
|
|
1
|
+
import { createTranslatable as e, interpolate as t } from "@dynamicforms/translatable";
|
|
2
|
+
import { computed as n, createBlock as r, defineComponent as i, h as a, isRef as o, openBlock as s, reactive as ee, ref as c, resolveComponent as l, toRef as u, unref as d, watch as f } from "vue";
|
|
3
|
+
import { isArray as p, isBoolean as m, isEmpty as h, isEqual as g, isObject as te, isString as _, truncate as ne } from "lodash-es";
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
var re = Object.defineProperty, ie = (e, t) => {
|
|
6
|
+
let n = {};
|
|
7
|
+
for (var r in e) re(n, r, {
|
|
8
|
+
get: e[r],
|
|
9
|
+
enumerable: !0
|
|
10
|
+
});
|
|
11
|
+
return t || re(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
12
|
+
}, v = /* @__PURE__ */ function(e) {
|
|
13
|
+
return e[e.SUPPRESS = 1] = "SUPPRESS", e[e.HIDDEN = 5] = "HIDDEN", e[e.INVISIBLE = 8] = "INVISIBLE", e[e.FULL = 10] = "FULL", e;
|
|
14
|
+
}(v || {}), ae = 10, oe = new Set(Object.values(v).filter((e) => typeof e == "number")), se = new Set(Object.values(v).filter((e) => typeof e == "string"));
|
|
15
|
+
function y(e) {
|
|
16
|
+
let t = typeof e == "string" ? `'${e}'` : String(e);
|
|
17
|
+
return /* @__PURE__ */ Error(`${t} is not a DisplayMode constant`);
|
|
18
|
+
}
|
|
19
|
+
(function(e) {
|
|
20
|
+
function t(e) {
|
|
21
|
+
let t = typeof e == "string" ? e.toUpperCase() : "";
|
|
22
|
+
if (t === "SUPPRESS") return 1;
|
|
23
|
+
if (t === "HIDDEN") return 5;
|
|
24
|
+
if (t === "INVISIBLE") return 8;
|
|
25
|
+
if (t === "FULL") return 10;
|
|
26
|
+
throw y(e);
|
|
27
|
+
}
|
|
28
|
+
e.fromString = t;
|
|
29
|
+
function n(e) {
|
|
30
|
+
if (typeof e == "number") {
|
|
31
|
+
if (oe.has(e)) return e;
|
|
32
|
+
throw y(e);
|
|
33
|
+
}
|
|
34
|
+
if (typeof e != "string") throw y(e);
|
|
35
|
+
return v.fromString(e);
|
|
36
|
+
}
|
|
37
|
+
e.fromAny = n;
|
|
38
|
+
function r(e) {
|
|
39
|
+
return typeof e == "number" ? oe.has(e) : typeof e == "string" && se.has(e.toUpperCase());
|
|
40
|
+
}
|
|
41
|
+
e.isDefined = r;
|
|
42
|
+
})(v ||= {}), Object.freeze(v);
|
|
43
|
+
var b = v, x = class {
|
|
44
|
+
static get classIdentifier() {
|
|
45
|
+
throw Error("classIdentifier must be declared");
|
|
46
|
+
}
|
|
47
|
+
get classIdentifier() {
|
|
48
|
+
return this.constructor.classIdentifier;
|
|
49
|
+
}
|
|
50
|
+
executorFn;
|
|
51
|
+
states = /* @__PURE__ */ new WeakMap();
|
|
52
|
+
constructor(e) {
|
|
53
|
+
this.executorFn = e;
|
|
54
|
+
}
|
|
55
|
+
state(e, t) {
|
|
56
|
+
return this.states.has(e) || this.states.set(e, t()), this.states.get(e);
|
|
57
|
+
}
|
|
58
|
+
execute(e, t, ...n) {
|
|
59
|
+
return this.executorFn(e, t, ...n);
|
|
60
|
+
}
|
|
61
|
+
get eager() {
|
|
62
|
+
return !1;
|
|
63
|
+
}
|
|
64
|
+
boundToBinding(e) {}
|
|
65
|
+
unregisterFrom(e) {}
|
|
66
|
+
}, S = class extends Error {}, ce = Symbol("ValueChangedAction"), C = class extends x {
|
|
67
|
+
constructor(e) {
|
|
68
|
+
super(e);
|
|
69
|
+
}
|
|
70
|
+
static get classIdentifier() {
|
|
71
|
+
return ce;
|
|
72
|
+
}
|
|
73
|
+
execute(e, t, n, r) {
|
|
74
|
+
return super.execute(e, t, n, r);
|
|
75
|
+
}
|
|
76
|
+
}, w = Symbol("Transaction.capture"), le = Symbol("Transaction.restore"), ue = Symbol("Transaction.announceValue"), de = Symbol("Transaction.settleValidity");
|
|
77
|
+
function T(e) {
|
|
78
|
+
return e;
|
|
79
|
+
}
|
|
80
|
+
function fe(e) {
|
|
81
|
+
let t = 0, n = e.parent;
|
|
82
|
+
for (; n;) t++, n = n.parent;
|
|
83
|
+
return t;
|
|
84
|
+
}
|
|
85
|
+
var pe = class {
|
|
86
|
+
participants = /* @__PURE__ */ new Map();
|
|
87
|
+
undo = [];
|
|
88
|
+
settled = [];
|
|
89
|
+
unwound = !1;
|
|
90
|
+
passDepth = -1;
|
|
91
|
+
restartPass = !1;
|
|
92
|
+
get rolledBack() {
|
|
93
|
+
return this.unwound;
|
|
94
|
+
}
|
|
95
|
+
participant(e) {
|
|
96
|
+
let t = this.participants.get(e);
|
|
97
|
+
return t || (t = {
|
|
98
|
+
element: e,
|
|
99
|
+
valueDirty: !1,
|
|
100
|
+
forceValue: !1,
|
|
101
|
+
validityDirty: !1
|
|
102
|
+
}, this.participants.set(e, t)), t;
|
|
103
|
+
}
|
|
104
|
+
touch(e) {
|
|
105
|
+
let t = this.participant(e);
|
|
106
|
+
t.snapshot ||= T(e)[w]();
|
|
107
|
+
}
|
|
108
|
+
markValueChanged(e, t) {
|
|
109
|
+
let n = this.participant(e);
|
|
110
|
+
n.valueDirty = !0, t && (n.forceValue = !0), this.noteDepth(e);
|
|
111
|
+
}
|
|
112
|
+
markValidityDirty(e) {
|
|
113
|
+
this.participant(e).validityDirty = !0, this.noteDepth(e);
|
|
114
|
+
}
|
|
115
|
+
recordStructural(e, t) {
|
|
116
|
+
let n = this.participant(e);
|
|
117
|
+
(n.structural ??= []).push(t), this.noteDepth(e);
|
|
118
|
+
}
|
|
119
|
+
willAnnounceValue(e) {
|
|
120
|
+
return this.participants.get(e)?.valueDirty ?? !1;
|
|
121
|
+
}
|
|
122
|
+
whenRolledBack(e) {
|
|
123
|
+
this.undo.push(e);
|
|
124
|
+
}
|
|
125
|
+
whenCommitted(e) {
|
|
126
|
+
this.settled.push(e);
|
|
127
|
+
}
|
|
128
|
+
noteDepth(e) {
|
|
129
|
+
this.passDepth < 0 || fe(e) >= this.passDepth && (this.restartPass = !0);
|
|
130
|
+
}
|
|
131
|
+
rollback() {
|
|
132
|
+
this.unwound = !0, [...this.participants.values()].reverse().forEach((e) => {
|
|
133
|
+
e.snapshot && T(e.element)[le](e.snapshot);
|
|
134
|
+
}), this.participants.clear();
|
|
135
|
+
for (let e = this.undo.length - 1; e >= 0; e--) this.undo[e]();
|
|
136
|
+
this.undo.length = 0, this.settled.length = 0;
|
|
137
|
+
}
|
|
138
|
+
commit() {
|
|
139
|
+
for (; !(!this.announceValues() && !this.settleValidity()););
|
|
140
|
+
for (let e = 0; e < this.settled.length; e++) this.settled[e]();
|
|
141
|
+
this.settled.length = 0;
|
|
142
|
+
}
|
|
143
|
+
buckets(e) {
|
|
144
|
+
let t = [];
|
|
145
|
+
return this.participants.forEach((n) => {
|
|
146
|
+
if (!e(n)) return;
|
|
147
|
+
let r = fe(n.element);
|
|
148
|
+
(t[r] ??= []).push(n);
|
|
149
|
+
}), t;
|
|
150
|
+
}
|
|
151
|
+
pass(e, t) {
|
|
152
|
+
let n = this.buckets(e);
|
|
153
|
+
if (!n.length) return !1;
|
|
154
|
+
for (let r = n.length - 1; r >= 0; r--) {
|
|
155
|
+
let i = n[r];
|
|
156
|
+
if (i) {
|
|
157
|
+
this.passDepth = r, this.restartPass = !1;
|
|
158
|
+
try {
|
|
159
|
+
for (let n = 0; n < i.length; n++) {
|
|
160
|
+
if (this.restartPass) return !0;
|
|
161
|
+
let r = i[n];
|
|
162
|
+
e(r) && t(r);
|
|
163
|
+
}
|
|
164
|
+
} finally {
|
|
165
|
+
this.passDepth = -1;
|
|
166
|
+
}
|
|
167
|
+
if (this.restartPass) return !0;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return !0;
|
|
171
|
+
}
|
|
172
|
+
announceValues() {
|
|
173
|
+
return this.pass((e) => e.valueDirty || e.structural !== void 0, (e) => {
|
|
174
|
+
let { structural: t } = e, n = e.valueDirty, r = e.forceValue;
|
|
175
|
+
e.structural = void 0, e.valueDirty = !1, e.forceValue = !1, T(e.element)[ue](this, n, r, t);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
settleValidity() {
|
|
179
|
+
return this.pass((e) => e.validityDirty, (e) => {
|
|
180
|
+
e.validityDirty = !1, T(e.element)[de](this);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}, E, me;
|
|
184
|
+
function he() {
|
|
185
|
+
return E;
|
|
186
|
+
}
|
|
187
|
+
var ge = class {}, _e = class {
|
|
188
|
+
open = !0;
|
|
189
|
+
rollback() {
|
|
190
|
+
throw this.open ? new ge() : TypeError("this transaction handle is spent: the transaction that handed it out has closed. A handle is only usable inside the call that received it.");
|
|
191
|
+
}
|
|
192
|
+
close() {
|
|
193
|
+
this.open = !1;
|
|
194
|
+
}
|
|
325
195
|
};
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
return W instanceof Promise ? (o.abandon = D, it?.whenRolledBack(D), s.beginValidating(), W.then(
|
|
480
|
-
(E) => {
|
|
481
|
-
$() && q(E);
|
|
482
|
-
},
|
|
483
|
-
(E) => {
|
|
484
|
-
$() && (q([new g(ne(), "", "validation-failed")]), console.error("Validation failed", E));
|
|
485
|
-
}
|
|
486
|
-
).finally(() => {
|
|
487
|
-
o.abandon === D && (o.abandon = void 0), s.endValidating();
|
|
488
|
-
}).catch((E) => console.error("Validation failed", E))) : q(W), i(s, r, a);
|
|
489
|
-
};
|
|
490
|
-
super(e), this.source = Symbol(this.constructor.name);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Returns the error instance this validator owns and may later withdraw: the argument itself when it carries no
|
|
494
|
-
* ownership stamp or already carries this validator's, a copy of it when it belongs to another validator. The
|
|
495
|
-
* stamp is not configurable, so an instance one validator owns can never be reassigned to another; the copy is
|
|
496
|
-
* what makes an error instance shareable between validators, and it keeps the prototype and every own property,
|
|
497
|
-
* including the non-enumerable ones, so it renders exactly like the instance it was made from.
|
|
498
|
-
*/
|
|
499
|
-
claim(t) {
|
|
500
|
-
const e = t.source;
|
|
501
|
-
if (e === this.source) return t;
|
|
502
|
-
const s = { value: this.source, enumerable: !1, configurable: !1 };
|
|
503
|
-
if (e === void 0)
|
|
504
|
-
return Object.defineProperty(t, "source", s), t;
|
|
505
|
-
const i = Object.getOwnPropertyDescriptors(t);
|
|
506
|
-
return Object.create(Object.getPrototypeOf(t), { ...i, source: s });
|
|
507
|
-
}
|
|
508
|
-
static get classIdentifier() {
|
|
509
|
-
return ie;
|
|
510
|
-
}
|
|
511
|
-
get eager() {
|
|
512
|
-
return !0;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Takes this validator off `field`: the errors it put there are withdrawn and the verdict is re-formed over what
|
|
516
|
-
* the validators the field still holds have to say. Withdrawing them is what keeps a field from staying invalid
|
|
517
|
-
* on an error no validator is left to take back.
|
|
518
|
-
*
|
|
519
|
-
* A run in flight over the field is cancelled once the removal stands, and not before: a transaction that
|
|
520
|
-
* unwinds puts the validator and its epoch back, and the run it never cancelled goes on to reach the verdict the
|
|
521
|
-
* field is then owed. Cancelling it as the removal is made would leave the field reporting itself valid over a
|
|
522
|
-
* value nothing checked, on the strength of a transaction that never happened.
|
|
523
|
-
*/
|
|
524
|
-
unregisterFrom(t) {
|
|
525
|
-
u((e) => {
|
|
526
|
-
e.whenCommitted(() => this.abandonRun(t));
|
|
527
|
-
for (let s = t.errors.length - 1; s >= 0; s--)
|
|
528
|
-
t.errors[s].source === this.source && t.errors.splice(s, 1);
|
|
529
|
-
t.validate();
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Cancels the asynchronous run in flight over `field`, where there is one. It is called once the field has
|
|
534
|
-
* stopped holding this validator: the field's validation epoch has moved on by then, so the run's verdict is
|
|
535
|
-
* already dropped and the signal it handed its check aborts with it.
|
|
536
|
-
*/
|
|
537
|
-
abandonRun(t) {
|
|
538
|
-
this.bindingState(t).abandon?.();
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* What this validator remembers about one of the fields it validates. One instance may be registered on several
|
|
542
|
-
* fields - every row of a list carries the instances the item template carries - so each field has a record of
|
|
543
|
-
* its own. A subclass that remembers more widens the record by overriding `newBindingState`.
|
|
544
|
-
*/
|
|
545
|
-
bindingState(t) {
|
|
546
|
-
return this.state(t, () => this.newBindingState());
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* The record a field starts with. `run` is the sequence number of the newest run over that field: every
|
|
550
|
-
* execution takes the next one and a result is applied only while its number is still the newest, so a slow run
|
|
551
|
-
* cannot overwrite the verdict of a faster one that started after it.
|
|
552
|
-
*/
|
|
553
|
-
newBindingState() {
|
|
554
|
-
return { run: 0 };
|
|
555
|
-
}
|
|
556
|
-
replacePlaceholdersFunction(t, e) {
|
|
557
|
-
return () => {
|
|
558
|
-
let s = h(t);
|
|
559
|
-
for (; M(s); )
|
|
560
|
-
s = h(this.replacePlaceholders(s(), e));
|
|
561
|
-
return s;
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
replacePlaceholders(t, e) {
|
|
565
|
-
if (M(t)) return this.replacePlaceholdersFunction(t, e);
|
|
566
|
-
if (Z(t)) return t;
|
|
567
|
-
if (Vt(t))
|
|
568
|
-
return this.replacePlaceholdersFunction(() => h(t), e);
|
|
569
|
-
let s = h(t);
|
|
570
|
-
return Object.keys(e).forEach((i) => {
|
|
571
|
-
s = s.replaceAll(`{${i}}`, e[i]);
|
|
572
|
-
}), t instanceof N ? new N(s.toString(), t.options, t.plugins) : s;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
class x {
|
|
576
|
-
/**
|
|
577
|
-
* Every action registered here, in registration order. It is replaced rather than written when an action is
|
|
578
|
-
* dropped, so a run already walking it finishes on the array it started with and the removal takes effect from
|
|
579
|
-
* the next trigger.
|
|
580
|
-
*/
|
|
581
|
-
actions = [];
|
|
582
|
-
/**
|
|
583
|
-
* Registers `action`. It becomes the outermost handler of its identifier, or - where `before` is given and is
|
|
584
|
-
* registered here under the same identifier - takes that action's place in the order, so `before` wraps it and
|
|
585
|
-
* reaches it through `supr`. That is what lets an action be added to a chain someone else built and still sit
|
|
586
|
-
* inside a handler already there.
|
|
587
|
-
*/
|
|
588
|
-
register(t, e) {
|
|
589
|
-
if (!(t instanceof m)) throw new Error("Invalid action type");
|
|
590
|
-
const s = e ? this.actions.indexOf(e) : -1;
|
|
591
|
-
if (e && (e.classIdentifier !== t.classIdentifier || s < 0))
|
|
592
|
-
throw new Error("Action to register before is not registered under the same identifier");
|
|
593
|
-
s < 0 ? this.actions.push(t) : this.actions.splice(s, 0, t);
|
|
594
|
-
}
|
|
595
|
-
/** Drops `action` and answers whether it was registered here. */
|
|
596
|
-
unregister(t) {
|
|
597
|
-
return this.actions.includes(t) ? (this.actions = this.actions.filter((e) => e !== t), !0) : !1;
|
|
598
|
-
}
|
|
599
|
-
/** True where something is registered under `identifier`. */
|
|
600
|
-
willTrigger(t) {
|
|
601
|
-
return this.actions.some((e) => e.classIdentifier === t);
|
|
602
|
-
}
|
|
603
|
-
/** True where any eager action is registered, whatever identifier it stands under. */
|
|
604
|
-
get hasEager() {
|
|
605
|
-
return this.actions.some((t) => t.eager);
|
|
606
|
-
}
|
|
607
|
-
/** Runs the actions registered under `ActionClass` and answers with what the outermost of them returned. */
|
|
608
|
-
trigger(t, e, ...s) {
|
|
609
|
-
return this.run(t.classIdentifier, !1, e, s);
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* Runs the eager actions of every identifier, each group on its own. A group is entered at its outermost eager
|
|
613
|
-
* action, which is the last one registered under that identifier.
|
|
614
|
-
*/
|
|
615
|
-
triggerEager(t, ...e) {
|
|
616
|
-
const s = this.actions;
|
|
617
|
-
for (let i = s.length - 1; i >= 0; i--) {
|
|
618
|
-
const r = s[i];
|
|
619
|
-
if (r.eager && x.outermostEager(s, i))
|
|
620
|
-
try {
|
|
621
|
-
const a = this.walk(s, i, r.classIdentifier, !0, t, e);
|
|
622
|
-
x.isPromise(a) && a.then(void 0, (o) => {
|
|
623
|
-
if (!(o instanceof S)) throw o;
|
|
624
|
-
});
|
|
625
|
-
} catch (a) {
|
|
626
|
-
if (!(a instanceof S)) throw a;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
/** Runs the eager actions registered under `identifier` and nothing else. */
|
|
631
|
-
triggerEagerFor(t, e, ...s) {
|
|
632
|
-
return this.run(t, !0, e, s);
|
|
633
|
-
}
|
|
634
|
-
/** the validators registered here, in registration order */
|
|
635
|
-
get validators() {
|
|
636
|
-
return this.actions.filter((t) => t instanceof f);
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* Tells every action here that it serves `owner`. A binding reads the map its declaration holds, so this is what
|
|
640
|
-
* announces the new element to the actions already in it - the way registering an action announces the elements
|
|
641
|
-
* it comes to serve.
|
|
642
|
-
*/
|
|
643
|
-
bindTo(t) {
|
|
644
|
-
this.actions.forEach((e) => e.boundToBinding(t));
|
|
645
|
-
}
|
|
646
|
-
/** True where no eager action of `identifier` stands after `index`, which makes `index` the group's entry. */
|
|
647
|
-
static outermostEager(t, e) {
|
|
648
|
-
const s = t[e].classIdentifier;
|
|
649
|
-
for (let i = t.length - 1; i > e; i--)
|
|
650
|
-
if (t[i].eager && t[i].classIdentifier === s) return !1;
|
|
651
|
-
return !0;
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* True where `value` is a promise, which is what a walk through an asynchronous handler answers with. The test is
|
|
655
|
-
* the type rather than a `then` member: a handler may answer with a value object that carries one, and calling
|
|
656
|
-
* `then` on such an object replaces the answer with whatever that call returns.
|
|
657
|
-
*/
|
|
658
|
-
static isPromise(t) {
|
|
659
|
-
return t instanceof Promise;
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* Answers an abort with itself on the asynchronous path as well. Where a handler in the chain is asynchronous, the
|
|
663
|
-
* walk answers with a promise and the abort raised under it arrives as that promise's rejection; this turns it back
|
|
664
|
-
* into the value the caller receives, so a promise the trigger answers with resolves to the exception instead of
|
|
665
|
-
* rejecting with it. Anything else keeps rejecting.
|
|
666
|
-
*/
|
|
667
|
-
static answerAbort(t) {
|
|
668
|
-
return x.isPromise(t) ? t.then(void 0, (e) => {
|
|
669
|
-
if (e instanceof S) return e;
|
|
670
|
-
throw e;
|
|
671
|
-
}) : t;
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Enters a group at its outermost action. An abort ends the run and is answered with rather than raised: the
|
|
675
|
-
* exception is what the caller receives - directly where the chain ran synchronously, as what the answered promise
|
|
676
|
-
* resolves to where it did not - so a run a handler ended is told apart from one that reached no handler and from
|
|
677
|
-
* one whose handler answered null.
|
|
678
|
-
*/
|
|
679
|
-
run(t, e, s, i) {
|
|
680
|
-
const r = this.actions;
|
|
681
|
-
try {
|
|
682
|
-
return x.answerAbort(this.walk(r, r.length - 1, t, e, s, i));
|
|
683
|
-
} catch (a) {
|
|
684
|
-
if (a instanceof S) return a;
|
|
685
|
-
throw a;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
/**
|
|
689
|
-
* Walks from `index` backwards to the first action of `identifier`, handing it a `supr` that continues at the one
|
|
690
|
-
* before it. The actions registered under other identifiers are passed over, so the array needs no grouping of
|
|
691
|
-
* its own; the closures exist for the length of the run and only as deep as the run actually goes.
|
|
692
|
-
*/
|
|
693
|
-
walk(t, e, s, i, r, a) {
|
|
694
|
-
let o = e;
|
|
695
|
-
for (; o >= 0 && (t[o].classIdentifier !== s || i && !t[o].eager); ) o--;
|
|
696
|
-
if (o < 0) return null;
|
|
697
|
-
const l = (v, ...p) => this.walk(t, o - 1, s, i, v, p);
|
|
698
|
-
return t[o].execute(r, l, ...a);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
function V(n) {
|
|
702
|
-
let t = n;
|
|
703
|
-
for (; t.fieldName !== void 0 && t.parent; ) t = t.parent;
|
|
704
|
-
return t;
|
|
705
|
-
}
|
|
706
|
-
function dt(n, t) {
|
|
707
|
-
let e = n;
|
|
708
|
-
for (const s of re(t))
|
|
709
|
-
if (e = e.field?.(s) ?? void 0, !e) return;
|
|
710
|
-
return e?.declaration === t ? e : void 0;
|
|
711
|
-
}
|
|
712
|
-
function re(n) {
|
|
713
|
-
const t = [];
|
|
714
|
-
let e = n;
|
|
715
|
-
for (; e.fieldName !== void 0 && e.parent; )
|
|
716
|
-
t.unshift(e.fieldName), e = e.parent;
|
|
717
|
-
return t;
|
|
718
|
-
}
|
|
719
|
-
function tt(n, t) {
|
|
720
|
-
const e = dt(t, n);
|
|
721
|
-
if (e) return e;
|
|
722
|
-
let s = t.parent;
|
|
723
|
-
for (; s; ) {
|
|
724
|
-
const i = dt(V(s), n);
|
|
725
|
-
if (i) return i;
|
|
726
|
-
s = s.parent;
|
|
727
|
-
}
|
|
728
|
-
return V(n) === V(t.declaration) ? void 0 : n;
|
|
729
|
-
}
|
|
730
|
-
function Pt(n, t) {
|
|
731
|
-
const e = tt(n, t);
|
|
732
|
-
if (!e) return [];
|
|
733
|
-
if (e !== n) return [e];
|
|
734
|
-
const s = t.bindingsOf(n);
|
|
735
|
-
return s.length > 0 ? s : [n];
|
|
736
|
-
}
|
|
737
|
-
function ae(n, t) {
|
|
738
|
-
let e = t.parent;
|
|
739
|
-
for (; e; ) {
|
|
740
|
-
const s = e.field?.(n);
|
|
741
|
-
if (s) return s;
|
|
742
|
-
e = e.parent;
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
const oe = /* @__PURE__ */ Symbol("ConditionalStatementAction");
|
|
746
|
-
class U extends P {
|
|
747
|
-
statement;
|
|
748
|
-
conditionalExecutor;
|
|
749
|
-
/**
|
|
750
|
-
* What the elements this action was registered on were declared as. It holds declarations rather than the
|
|
751
|
-
* elements themselves, so one entry stands for every row of a list, and the element a result is applied to is
|
|
752
|
-
* the one that declaration names within the record the change happened in.
|
|
753
|
-
*/
|
|
754
|
-
declarations = /* @__PURE__ */ new Set();
|
|
755
|
-
/**
|
|
756
|
-
* The elements this action was registered on. Registration reaches one element at a time - the rows of a list
|
|
757
|
-
* take the action on one by one, as they are built from the item template that carries it - so this is what
|
|
758
|
-
* says which of the elements a declaration stands for the action actually drives.
|
|
759
|
-
*/
|
|
760
|
-
registrations = /* @__PURE__ */ new WeakSet();
|
|
761
|
-
constructor(t, e) {
|
|
762
|
-
super((i, r, a, o) => (this.applyIn(V(i)) || i.markRecordIncomplete(), r(i, a, o))), this.statement = t, this.conditionalExecutor = e;
|
|
763
|
-
const s = new P((i, r, ...a) => (this.applyFrom(i), r(i, ...a)));
|
|
764
|
-
t.collectFields().forEach((i) => i.registerAction(s));
|
|
765
|
-
}
|
|
766
|
-
static get classIdentifier() {
|
|
767
|
-
return oe;
|
|
768
|
-
}
|
|
769
|
-
get eager() {
|
|
770
|
-
return !0;
|
|
771
|
-
}
|
|
772
|
-
boundToBinding(t) {
|
|
773
|
-
this.declarations.add(t.declaration), this.registrations.add(t);
|
|
774
|
-
}
|
|
775
|
-
unregisterFrom(t) {
|
|
776
|
-
this.registrations.delete(t);
|
|
777
|
-
}
|
|
778
|
-
/**
|
|
779
|
-
* The elements of `scope` this action controls: what each declaration it serves names within that record, and of
|
|
780
|
-
* those the ones that took the action on. A row of a list that never took it on is not one this action drives.
|
|
781
|
-
*/
|
|
782
|
-
targetsIn(t) {
|
|
783
|
-
const e = [];
|
|
784
|
-
return this.declarations.forEach(
|
|
785
|
-
(s) => Pt(s, t).forEach((i) => {
|
|
786
|
-
this.registrations.has(i) && e.push(i);
|
|
787
|
-
})
|
|
788
|
-
), e;
|
|
789
|
-
}
|
|
790
|
-
/**
|
|
791
|
-
* Re-evaluates the statement over one record and applies the result where it changed. The result is recorded
|
|
792
|
-
* before the executor runs, because an executor that writes a value re-enters through that value's eager pass
|
|
793
|
-
* and what it has to find there is the result being applied. It answers whether the record held anything for
|
|
794
|
-
* this action to drive, which is how a caller learns that the record is not assembled yet.
|
|
795
|
-
*/
|
|
796
|
-
applyIn(t) {
|
|
797
|
-
const e = this.targetsIn(t);
|
|
798
|
-
if (e.length === 0) return !1;
|
|
799
|
-
const s = this.state(t, () => ({ lastResult: void 0 })), i = this.statement.evaluate(t);
|
|
800
|
-
if (i === s.lastResult) return !0;
|
|
801
|
-
const r = s.lastResult;
|
|
802
|
-
return s.lastResult = i, e.forEach((a) => this.conditionalExecutor(a, i, r)), !0;
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Re-evaluates the records a change of `source` speaks for. A field of the record the targets live in speaks for
|
|
806
|
-
* that record alone, which is what keeps one row of a list from answering for another; a field above them - a
|
|
807
|
-
* form field every row reads - speaks for every record below it, and for the record the action was declared in
|
|
808
|
-
* where the change reaches none.
|
|
809
|
-
*/
|
|
810
|
-
applyFrom(t) {
|
|
811
|
-
const e = /* @__PURE__ */ new Set();
|
|
812
|
-
this.targetsIn(V(t)).forEach((s) => e.add(V(s))), e.forEach((s) => this.applyIn(s));
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
class le extends U {
|
|
816
|
-
constructor(t) {
|
|
817
|
-
super(t, (e, s) => {
|
|
818
|
-
e.visibility = s ? O.FULL : O.SUPPRESS;
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
class ue extends U {
|
|
823
|
-
constructor(t) {
|
|
824
|
-
super(t, (e, s) => {
|
|
825
|
-
e.enabled = s;
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
class ce extends U {
|
|
830
|
-
constructor(t, e) {
|
|
831
|
-
super(t, (s, i) => {
|
|
832
|
-
i && (s.value = e);
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
var B = /* @__PURE__ */ ((n) => (n[n.NOT = 0] = "NOT", n[n.OR = 1] = "OR", n[n.AND = 2] = "AND", n[n.XOR = 3] = "XOR", n[n.NAND = 4] = "NAND", n[n.NOR = 5] = "NOR", n[n.EQUALS = -1] = "EQUALS", n[n.NOT_EQUALS = -2] = "NOT_EQUALS", n[n.GT = -3] = "GT", n[n.LT = -4] = "LT", n[n.GE = -5] = "GE", n[n.LE = -6] = "LE", n[n.IN = -7] = "IN", n[n.NOT_IN = -8] = "NOT_IN", n[n.INCLUDES = -9] = "INCLUDES", n[n.NOT_INCLUDES = -10] = "NOT_INCLUDES", n))(B || {});
|
|
837
|
-
((n) => {
|
|
838
|
-
function t(r) {
|
|
839
|
-
const a = r.toLowerCase();
|
|
840
|
-
if (a === "not") return 0;
|
|
841
|
-
if (a === "or") return 1;
|
|
842
|
-
if (a === "and") return 2;
|
|
843
|
-
if (a === "xor") return 3;
|
|
844
|
-
if (a === "nand") return 4;
|
|
845
|
-
if (a === "nor") return 5;
|
|
846
|
-
if (a === "equals") return -1;
|
|
847
|
-
if (["not_equals", "not-equals", "not equals"].includes(a)) return -2;
|
|
848
|
-
if (a === "gt") return -3;
|
|
849
|
-
if (a === "lt") return -4;
|
|
850
|
-
if (a === "ge") return -5;
|
|
851
|
-
if (a === "le") return -6;
|
|
852
|
-
if (a === "in") return -7;
|
|
853
|
-
if (["not_in", "not-in", "not in"].includes(a)) return -8;
|
|
854
|
-
if (a === "includes") return -9;
|
|
855
|
-
if (["not_includes", "not-includes", "not includes"].includes(a)) return -10;
|
|
856
|
-
throw new Error(`Unrecognised operator ${a}`);
|
|
857
|
-
}
|
|
858
|
-
n.fromString = t;
|
|
859
|
-
function e(r) {
|
|
860
|
-
const a = typeof r == "number" ? r : n.fromString(r);
|
|
861
|
-
if (Object.values(n).includes(a)) return a;
|
|
862
|
-
throw new Error(`Unrecognised operator ${r}`);
|
|
863
|
-
}
|
|
864
|
-
n.fromAny = e;
|
|
865
|
-
function s(r) {
|
|
866
|
-
const a = typeof r == "number" ? r : n.fromString(r);
|
|
867
|
-
return Object.values(n).includes(a);
|
|
868
|
-
}
|
|
869
|
-
n.isDefined = s;
|
|
870
|
-
function i(r) {
|
|
871
|
-
return r >= 0;
|
|
872
|
-
}
|
|
873
|
-
n.isLogicOperator = i;
|
|
874
|
-
})(B || (B = {}));
|
|
875
|
-
Object.freeze(B);
|
|
876
|
-
const c = B, he = /* @__PURE__ */ Symbol("EnabledChangingAction");
|
|
877
|
-
class kt extends m {
|
|
878
|
-
constructor(t) {
|
|
879
|
-
super(t);
|
|
880
|
-
}
|
|
881
|
-
static get classIdentifier() {
|
|
882
|
-
return he;
|
|
883
|
-
}
|
|
884
|
-
execute(t, e, s, i) {
|
|
885
|
-
return super.execute(t, e, s, i);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
const de = /* @__PURE__ */ Symbol("EnabledChangedAction");
|
|
889
|
-
class Rt extends m {
|
|
890
|
-
constructor(t) {
|
|
891
|
-
super(t);
|
|
892
|
-
}
|
|
893
|
-
static get classIdentifier() {
|
|
894
|
-
return de;
|
|
895
|
-
}
|
|
896
|
-
execute(t, e, s, i) {
|
|
897
|
-
return super.execute(t, e, s, i);
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
const ge = /* @__PURE__ */ Symbol("ValidChangedAction");
|
|
901
|
-
class Ft extends m {
|
|
902
|
-
constructor(t) {
|
|
903
|
-
super(t);
|
|
904
|
-
}
|
|
905
|
-
static get classIdentifier() {
|
|
906
|
-
return ge;
|
|
907
|
-
}
|
|
908
|
-
execute(t, e, s, i) {
|
|
909
|
-
return super.execute(t, e, s, i);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
const fe = /* @__PURE__ */ Symbol("VisibilityChangingAction");
|
|
913
|
-
class _t extends m {
|
|
914
|
-
constructor(t) {
|
|
915
|
-
super(t);
|
|
916
|
-
}
|
|
917
|
-
static get classIdentifier() {
|
|
918
|
-
return fe;
|
|
919
|
-
}
|
|
920
|
-
execute(t, e, s, i) {
|
|
921
|
-
return super.execute(t, e, s, i);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
const pe = /* @__PURE__ */ Symbol("VisibilityChangedAction");
|
|
925
|
-
class jt extends m {
|
|
926
|
-
constructor(t) {
|
|
927
|
-
super(t);
|
|
928
|
-
}
|
|
929
|
-
static get classIdentifier() {
|
|
930
|
-
return pe;
|
|
931
|
-
}
|
|
932
|
-
execute(t, e, s, i) {
|
|
933
|
-
return super.execute(t, e, s, i);
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
const gt = /* @__PURE__ */ new WeakMap(), ft = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), pt = /* @__PURE__ */ new Set(["validators", "actions"]);
|
|
937
|
-
let X = 0;
|
|
938
|
-
class y {
|
|
939
|
-
/**
|
|
940
|
-
* Vue's getTargetType answers INVALID for an object that carries __v_skip, so reactive() hands an element back
|
|
941
|
-
* unwrapped and no element is ever behind a proxy of its own. isReactive() reads the second flag, and it stays
|
|
942
|
-
* true because what carries an element's reactivity - its state - is a reactive object.
|
|
943
|
-
*
|
|
944
|
-
* Two consequences for a consumer, both silent. watch(field, cb) with a bare element as the source registers
|
|
945
|
-
* no dependency, because the deep traversal Vue starts for a reactive source stops on __v_skip; the supported
|
|
946
|
-
* form is watch(() => field.value, cb). And readonly(field) hands the element straight back, so the value it
|
|
947
|
-
* returns is the element itself and a write through it reaches the field; what a caller hands out instead is
|
|
948
|
-
* the value, which is frozen, or a computed over it.
|
|
949
|
-
*/
|
|
950
|
-
get __v_skip() {
|
|
951
|
-
return !0;
|
|
952
|
-
}
|
|
953
|
-
get __v_isReactive() {
|
|
954
|
-
return !0;
|
|
955
|
-
}
|
|
956
|
-
/**
|
|
957
|
-
* Names the element's class, which is what a structural comparison of two elements answers on. An element keeps
|
|
958
|
-
* its state in private class fields, so a walk over own keys reaches none of it; lodash reads this tag through
|
|
959
|
-
* Object.prototype.toString before it compares anything, and a tag it does not know ends the comparison there.
|
|
960
|
-
* Two elements are therefore equal only where they are the same element. What they hold is compared as
|
|
961
|
-
* isEqual(a.value, b.value).
|
|
962
|
-
*
|
|
963
|
-
* It is an accessor on the prototype, so an element carries nothing for it, and `Object.prototype.toString`
|
|
964
|
-
* answers `[object Field]` rather than `[object Object]`. Each class states its own name as a literal: a
|
|
965
|
-
* minifier renames the class itself, so reading the constructor's name would report whatever the build called
|
|
966
|
-
* it.
|
|
967
|
-
*/
|
|
968
|
-
get [Symbol.toStringTag]() {
|
|
969
|
-
return "FormElement";
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* The element's mutable state, in an object beside the element. `#state` is the tracked view of it: a slot read
|
|
973
|
-
* through it inside an effect subscribes the effect to that slot, and a write to the slot re-runs the effect.
|
|
974
|
-
* `#raw` is the same object without the proxy, for the bookkeeping nothing renders from.
|
|
975
|
-
*
|
|
976
|
-
* They are private class fields, so no reflection over the element reaches the state or the parent link it
|
|
977
|
-
* carries, and a subclass reads its own slot type through the accessors below.
|
|
978
|
-
*/
|
|
979
|
-
#t;
|
|
980
|
-
#e;
|
|
981
|
-
constructor(t) {
|
|
982
|
-
this.#e = t, this.#t = Ut(t);
|
|
983
|
-
}
|
|
984
|
-
/** the tracked view of this element's state; a subclass narrows the return type to its own slots */
|
|
985
|
-
get state() {
|
|
986
|
-
return this.#t;
|
|
987
|
-
}
|
|
988
|
-
/** the untracked view of this element's state; a subclass narrows the return type to its own slots */
|
|
989
|
-
get raw() {
|
|
990
|
-
return this.#e;
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Exchanges the data this element holds for `data`, in place. The element is the same instance afterwards - its
|
|
994
|
-
* identity, its actions, its extended properties and its place in whatever container holds it all stand - and it
|
|
995
|
-
* ends up in the state `bind(data)` would have produced: the values are written, the change history starts over
|
|
996
|
-
* and the validators run. It is what recycles one element across records, which is what a virtualised renderer
|
|
997
|
-
* does with the rows it keeps.
|
|
998
|
-
*
|
|
999
|
-
* The element makes no statement of its own about the exchange: no `ValueChangedAction` fires for it, the way
|
|
1000
|
-
* none fires for an element that was just built. Its members do announce theirs, and a verdict that moves is
|
|
1001
|
-
* announced as always - a rebound element that is invalid says so to the container holding it. A change an
|
|
1002
|
-
* open transaction is already owed an announcement for stands: the commit reports the pair measured from
|
|
1003
|
-
* where the element was when the transaction opened.
|
|
1004
|
-
*
|
|
1005
|
-
* The data is measured against the element's `declaration`, so a key a record leaves out is taken from the
|
|
1006
|
-
* declaration rather than left as the previous record had it.
|
|
1007
|
-
*/
|
|
1008
|
-
rebind(t) {
|
|
1009
|
-
return u((e) => {
|
|
1010
|
-
e.touch(this);
|
|
1011
|
-
const s = e.willAnnounceValue(this), i = this.#e.announcedValue;
|
|
1012
|
-
this.resetTo(this.declaration, t), this.#e.announcedValue = s ? i : this.value;
|
|
1013
|
-
}), this;
|
|
1014
|
-
}
|
|
1015
|
-
/** contains original field value as was provided at creation */
|
|
1016
|
-
get originalValue() {
|
|
1017
|
-
return this.#t.originalValue;
|
|
1018
|
-
}
|
|
1019
|
-
set originalValue(t) {
|
|
1020
|
-
this.touchState(), this.#t.originalValue = t;
|
|
1021
|
-
}
|
|
1022
|
-
/**
|
|
1023
|
-
* The extended properties this element carries: what a consumer attached to it beyond the members the class
|
|
1024
|
-
* declares, such as the label, hint or css class a UI layer binds to the input it renders the element with.
|
|
1025
|
-
* The read is tracked, so a template rendering off `field.extra.label` re-renders when the property is written.
|
|
1026
|
-
*
|
|
1027
|
-
* Every property is optional here, whatever `X` states: a parameter object need not carry one and
|
|
1028
|
-
* setExtendedValues writes as few as a caller likes, so a property `X` declares as required is present only
|
|
1029
|
-
* once something has written it.
|
|
1030
|
-
*
|
|
1031
|
-
* The object is frozen and setExtendedValues is the way to change it: it is the object a transaction captured,
|
|
1032
|
-
* and one written in place would leave a rollback with nothing to put back.
|
|
1033
|
-
*/
|
|
1034
|
-
get extra() {
|
|
1035
|
-
return this.#t.extra;
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* Writes extended properties. The values given are merged over the ones the element carries, so a write of one
|
|
1039
|
-
* property leaves the others standing, and the merged set replaces the object the element held.
|
|
1040
|
-
*/
|
|
1041
|
-
setExtendedValues(t) {
|
|
1042
|
-
this.touchState(), this.#t.extra = Object.freeze({ ...this.#e.extra, ...t });
|
|
1043
|
-
}
|
|
1044
|
-
/**
|
|
1045
|
-
* The extended properties a parameter object carries: every key the element does not answer for itself. A key
|
|
1046
|
-
* the element answers for at the time the parameters are applied - `value`, `enabled`, an accessor a subclass
|
|
1047
|
-
* adds - is the element's own; a key that only Object.prototype answers for is nobody's declaration and counts
|
|
1048
|
-
* as extended, and `validators` and `actions` are neither, since they state what to register on the element.
|
|
1049
|
-
*
|
|
1050
|
-
* A member a subclass declares as a class field is not among the keys the element answers for: class fields are
|
|
1051
|
-
* defined on the instance after the base constructor returns, and the parameters are applied inside it. A
|
|
1052
|
-
* subclass that wants a parameter of its own name assigned to it declares that member as an accessor.
|
|
1053
|
-
*/
|
|
1054
|
-
extendedOf(t) {
|
|
1055
|
-
const e = /* @__PURE__ */ Object.create(null);
|
|
1056
|
-
return Object.entries(t).forEach(([s, i]) => {
|
|
1057
|
-
pt.has(s) || (!(s in this) || Object.hasOwn(Object.prototype, s)) && (e[s] = i);
|
|
1058
|
-
}), e;
|
|
1059
|
-
}
|
|
1060
|
-
/**
|
|
1061
|
-
* Applies a parameter object: the members the element answers for are assigned to the element and the rest
|
|
1062
|
-
* become its extended properties. Assigning a getter-only member throws a TypeError, which is what a caller
|
|
1063
|
-
* naming `valid` or `parent` past the type system gets.
|
|
1064
|
-
*/
|
|
1065
|
-
assignParams(t) {
|
|
1066
|
-
const e = this.extendedOf(t);
|
|
1067
|
-
Object.entries(t).forEach(([s, i]) => {
|
|
1068
|
-
Object.hasOwn(e, s) || pt.has(s) || (this[s] = i);
|
|
1069
|
-
}), j(e) || this.setExtendedValues(e);
|
|
1070
|
-
}
|
|
1071
|
-
/**
|
|
1072
|
-
* Takes this element into the record of the open transaction, where one is open. A write of a single slot that
|
|
1073
|
-
* announces nothing calls it instead of opening a transaction of its own: on its own such a write is already
|
|
1074
|
-
* atomic, and inside a transaction it has to be part of what a rollback puts back.
|
|
1075
|
-
*/
|
|
1076
|
-
touchState() {
|
|
1077
|
-
It()?.touch(this);
|
|
1078
|
-
}
|
|
1079
|
-
/**
|
|
1080
|
-
* Records the whole of this element's mutable state, so that a rolled-back transaction can put it back exactly
|
|
1081
|
-
* as it found it. The errors array is copied because a validator writes into the array it is handed rather than
|
|
1082
|
-
* replacing it, and a subclass copies whatever else it holds by reference the same way.
|
|
1083
|
-
*
|
|
1084
|
-
* What is not in the snapshot is the action map, which no write touches: an operation that replaces it hands
|
|
1085
|
-
* the transaction its own undo instead, so this stays the one shape every element captures.
|
|
1086
|
-
*/
|
|
1087
|
-
[k]() {
|
|
1088
|
-
return { ...this.#e, errors: [...this.#e.errors] };
|
|
1089
|
-
}
|
|
1090
|
-
/**
|
|
1091
|
-
* Puts a captured state back. It writes through the tracked view, so an effect that ran on the state the
|
|
1092
|
-
* transaction produced runs again on the state it is being returned to, and only for the slots that differ.
|
|
1093
|
-
*
|
|
1094
|
-
* The two validation counters are the slots the element keeps: they count runs that are in flight, and a
|
|
1095
|
-
* rollback cannot un-start one. Put back, the counts would no longer match the endValidating calls still to come.
|
|
1096
|
-
*/
|
|
1097
|
-
[St](t) {
|
|
1098
|
-
const e = this.#e.validatingCount, s = this.#e.validatingChildren;
|
|
1099
|
-
Object.assign(this.#t, t), this.#t.validatingCount = e, this.#t.validatingChildren = s;
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* True while an asynchronous validation is in flight on this element or on anything below it, so a form answers
|
|
1103
|
-
* for the whole tree it holds. The answer is a pair of counters rather than a walk: the element's own runs, and
|
|
1104
|
-
* how many of its children answer the same question with true. A child that starts running while it was idle,
|
|
1105
|
-
* or stops while it was the last one running, moves its container's tally, and a tally that changes the
|
|
1106
|
-
* container's own answer moves the one above it - the transition costs the nesting depth and the read costs
|
|
1107
|
-
* nothing.
|
|
1108
|
-
*/
|
|
1109
|
-
get validating() {
|
|
1110
|
-
return this.#t.validatingCount > 0 || this.#t.validatingChildren > 0;
|
|
1111
|
-
}
|
|
1112
|
-
/** announces the start of one asynchronous validation run; validators pair it with endValidating */
|
|
1113
|
-
beginValidating() {
|
|
1114
|
-
const t = !this.validating;
|
|
1115
|
-
this.#t.validatingCount++, t && this.container?.childValidatingChanged(!0);
|
|
1116
|
-
}
|
|
1117
|
-
/** announces the end of one asynchronous validation run */
|
|
1118
|
-
endValidating() {
|
|
1119
|
-
this.#e.validatingCount !== 0 && (this.#t.validatingCount--, this.validating || this.container?.childValidatingChanged(!1));
|
|
1120
|
-
}
|
|
1121
|
-
/**
|
|
1122
|
-
* Records that a child started or stopped answering `validating` with true, and carries the transition further
|
|
1123
|
-
* up where it changes this element's own answer.
|
|
1124
|
-
*/
|
|
1125
|
-
childValidatingChanged(t) {
|
|
1126
|
-
const e = this.validating;
|
|
1127
|
-
this.#t.validatingChildren += t ? 1 : -1, this.validating !== e && this.container?.childValidatingChanged(t);
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
|
-
* True while an `Action.execute()` at or below this element has yet to settle. An `Action` answers for its own
|
|
1131
|
-
* runs; a container answers for the actions below it; anything else answers false, because an element that is
|
|
1132
|
-
* not an action has nothing to execute.
|
|
1133
|
-
*
|
|
1134
|
-
* It states one thing and `validating` states the other, so a form that gates a submit button on the tree being
|
|
1135
|
-
* idle reads both.
|
|
1136
|
-
*/
|
|
1137
|
-
get busy() {
|
|
1138
|
-
return !1;
|
|
1139
|
-
}
|
|
1140
|
-
/**
|
|
1141
|
-
* The composed answer a container gives `busy`, memoised by Vue. An `Action` counts its executions in a counter
|
|
1142
|
-
* of its own, which no container is told about, so the answer is composed over the members instead of tallied;
|
|
1143
|
-
* the computed keeps the walk from repeating while nothing it read has moved, and a member that is itself a
|
|
1144
|
-
* container answers from its own computed.
|
|
1145
|
-
*/
|
|
1146
|
-
get busyRead() {
|
|
1147
|
-
let t = ft.get(this);
|
|
1148
|
-
return t || (t = K(() => this.composeBusy()), ft.set(this, t)), t.value;
|
|
1149
|
-
}
|
|
1150
|
-
/** What busyRead computes. A container answers over its members; anything else executes nothing. */
|
|
1151
|
-
composeBusy() {
|
|
1152
|
-
return !1;
|
|
1153
|
-
}
|
|
1154
|
-
/**
|
|
1155
|
-
* Resolves once nothing at or below this element is running - no asynchronous validation, no `Action.execute()`
|
|
1156
|
-
* that has yet to settle. It is what a submit path awaits instead of polling `validating` and `busy`, and it
|
|
1157
|
-
* resolves at once where nothing is running to begin with.
|
|
1158
|
-
*
|
|
1159
|
-
* It answers for the moment it resolves and makes no promise about the one after: work started later leaves the
|
|
1160
|
-
* element running again, so a caller that has to act on a settled tree reads what it needs immediately after
|
|
1161
|
-
* awaiting rather than at its leisure.
|
|
1162
|
-
*/
|
|
1163
|
-
settled() {
|
|
1164
|
-
return !this.validating && !this.busy ? Promise.resolve() : new Promise((t) => {
|
|
1165
|
-
const e = $t(
|
|
1166
|
-
() => this.validating || this.busy,
|
|
1167
|
-
(s) => {
|
|
1168
|
-
s || (e(), t());
|
|
1169
|
-
},
|
|
1170
|
-
{ flush: "sync" }
|
|
1171
|
-
);
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
|
-
/**
|
|
1175
|
-
* List of errors. The array handed out is the one the element holds, and a validator writes into it in place,
|
|
1176
|
-
* so a transaction that is open takes the element into its record here: a rollback that put back everything
|
|
1177
|
-
* except the errors would leave a state the form never held.
|
|
1178
|
-
*/
|
|
1179
|
-
get errors() {
|
|
1180
|
-
return this.touchState(), this.#t.errors;
|
|
1181
|
-
}
|
|
1182
|
-
set errors(t) {
|
|
1183
|
-
this.touchState(), this.#t.errors = t;
|
|
1184
|
-
}
|
|
1185
|
-
/**
|
|
1186
|
-
* The container that holds this element: the Group it is a member of, or the List whose row it is, and
|
|
1187
|
-
* undefined while no container holds it. The container writes it; everyone else reads it. The read is tracked,
|
|
1188
|
-
* so an effect rendering off the link - `v-if="field.parent"` - re-runs when a container takes the element or
|
|
1189
|
-
* releases it.
|
|
1190
|
-
*
|
|
1191
|
-
* A `List` holds rows and a row is a `Group`, so only a container can be a `List`'s child: `Field` narrows the
|
|
1192
|
-
* type to `Group | undefined`, and the sibling lookup `field.parent?.fields.other` is typed on a field.
|
|
1193
|
-
*/
|
|
1194
|
-
get parent() {
|
|
1195
|
-
return this.#t.parent;
|
|
1196
|
-
}
|
|
1197
|
-
/**
|
|
1198
|
-
* The same link at the type the internals reach through. The protected members a container is told things
|
|
1199
|
-
* through - childValidatingChanged, childValidityChanged - are declared here, and a union of two subclasses is
|
|
1200
|
-
* not an instance of this class, which is what a protected access needs.
|
|
1201
|
-
*/
|
|
1202
|
-
get container() {
|
|
1203
|
-
return this.#t.parent;
|
|
1204
|
-
}
|
|
1205
|
-
/** when member of a Group, fieldName specifies the name of this field. Written by the group, read-only after */
|
|
1206
|
-
get fieldName() {
|
|
1207
|
-
return this.#t.fieldName;
|
|
1208
|
-
}
|
|
1209
|
-
/**
|
|
1210
|
-
* The element this one was declared as: itself for an element built from parameters, and the element it was
|
|
1211
|
-
* bound from for a binding - transitively, so a binding of a binding names the same one. Every row a `List`
|
|
1212
|
-
* builds from an item template is a binding of it, so a row's member and the template's member it stands for
|
|
1213
|
-
* answer with the same element, and an action registered on the template can tell the two apart.
|
|
1214
|
-
*/
|
|
1215
|
-
get declaration() {
|
|
1216
|
-
return this.#e.declaration ?? this;
|
|
1217
|
-
}
|
|
1218
|
-
/** The elements this one holds: a Group's members, a List's rows, none for a leaf. */
|
|
1219
|
-
get members() {
|
|
1220
|
-
return [];
|
|
1221
|
-
}
|
|
1222
|
-
/**
|
|
1223
|
-
* Every element in this element's subtree, this element included, that was declared as `declaration`. It answers
|
|
1224
|
-
* the question a shared action asks when the record it changed in is not the record its targets live in - a form
|
|
1225
|
-
* field that every row of a list reacts to - and it costs the subtree, so it is the path taken only when the
|
|
1226
|
-
* cheaper one, resolving within a single record, does not apply.
|
|
1227
|
-
*/
|
|
1228
|
-
bindingsOf(t) {
|
|
1229
|
-
const e = t.declaration, s = [], i = (r) => {
|
|
1230
|
-
r.declaration === e && s.push(r), r.members.forEach(i);
|
|
1231
|
-
};
|
|
1232
|
-
return i(this), s;
|
|
1233
|
-
}
|
|
1234
|
-
/**
|
|
1235
|
-
* States that an eager pass over this element reached an element it needs and did not find it, because the
|
|
1236
|
-
* record this element belongs to was not assembled at the time: a `List` row is built member by member and its
|
|
1237
|
-
* members are bound before any of them holds the row, so a validator comparing two of them runs before the
|
|
1238
|
-
* row exists. The container that finishes the record runs the pass again, and a pass that still reaches
|
|
1239
|
-
* nothing says so again, so the next container above answers for it.
|
|
1240
|
-
*/
|
|
1241
|
-
markRecordIncomplete() {
|
|
1242
|
-
this._recordPending || (this._recordPending = !0, X++);
|
|
1243
|
-
}
|
|
1244
|
-
/**
|
|
1245
|
-
* Runs the eager passes outstanding in `element`'s subtree, now that the record it belongs to is assembled. A
|
|
1246
|
-
* container calls it where it has just made a record complete: a Group that has written its members, and a
|
|
1247
|
-
* List that has taken a row, which is what gives the row's fields the form above it.
|
|
1248
|
-
*/
|
|
1249
|
-
completeRecords(t = this) {
|
|
1250
|
-
X !== 0 && u(() => {
|
|
1251
|
-
const e = (s) => {
|
|
1252
|
-
s._recordPending && (s._recordPending = !1, X--, s.rerunEagerActions()), s.members.forEach(e);
|
|
1253
|
-
};
|
|
1254
|
-
e(t);
|
|
1255
|
-
});
|
|
1256
|
-
}
|
|
1257
|
-
/** Runs this element's eager actions over the value it holds and re-forms the verdict they reach. */
|
|
1258
|
-
rerunEagerActions() {
|
|
1259
|
-
u((t) => {
|
|
1260
|
-
this.boundActions?.triggerEager(this, this.value, this.value), t.markValidityDirty(this);
|
|
1261
|
-
});
|
|
1262
|
-
}
|
|
1263
|
-
/**
|
|
1264
|
-
* The actions this element answers to, absent where nothing is registered. A binding holds the very map its
|
|
1265
|
-
* declaration holds rather than a copy of it, so the slot is read directly: what a trigger costs is one property
|
|
1266
|
-
* read, and a rule registered on a `List`'s item template reaches every row through the map they share - the
|
|
1267
|
-
* rows built before the registration as much as the ones built after.
|
|
1268
|
-
*/
|
|
1269
|
-
get boundActions() {
|
|
1270
|
-
return this._actions;
|
|
1271
|
-
}
|
|
1272
|
-
/** Records that `binding` was made from this element, so a later registration can reach it. */
|
|
1273
|
-
noteBinding(t) {
|
|
1274
|
-
let e = Q.get(this);
|
|
1275
|
-
e || (e = /* @__PURE__ */ new Set(), Q.set(this, e)), e.add(new WeakRef(t));
|
|
1276
|
-
}
|
|
1277
|
-
/**
|
|
1278
|
-
* The bindings made from this element that are still alive, and this element itself. The dead references are
|
|
1279
|
-
* dropped as they are found, which is what keeps the set from growing over the life of a long-lived declaration.
|
|
1280
|
-
*/
|
|
1281
|
-
get boundElements() {
|
|
1282
|
-
const t = this.declaration, e = Q.get(t), s = [t];
|
|
1283
|
-
return e && e.forEach((i) => {
|
|
1284
|
-
const r = i.deref();
|
|
1285
|
-
r ? s.push(r) : e.delete(i);
|
|
1286
|
-
}), s;
|
|
1287
|
-
}
|
|
1288
|
-
/**
|
|
1289
|
-
* The map registrations go into: the declaration's, since that is where behaviour lives. The map is made on the
|
|
1290
|
-
* first registration and handed to every binding already made from the declaration, so all of them go on reading
|
|
1291
|
-
* one map through a slot of their own.
|
|
1292
|
-
*/
|
|
1293
|
-
get actions() {
|
|
1294
|
-
const t = this.declaration;
|
|
1295
|
-
if (!t._actions) {
|
|
1296
|
-
const e = new x();
|
|
1297
|
-
t.boundElements.forEach((s) => {
|
|
1298
|
-
s._actions = e;
|
|
1299
|
-
});
|
|
1300
|
-
}
|
|
1301
|
-
return t._actions;
|
|
1302
|
-
}
|
|
1303
|
-
/**
|
|
1304
|
-
* Counts the writes that have changed the value of this element or of anything below it. A container reads it
|
|
1305
|
-
* before answering from its value cache, and the read is an ordinary tracked one, so an effect that took a
|
|
1306
|
-
* cached value still re-runs when a descendant is written.
|
|
1307
|
-
*/
|
|
1308
|
-
get valueVersion() {
|
|
1309
|
-
return this.#t.valueVersion;
|
|
1310
|
-
}
|
|
1311
|
-
/**
|
|
1312
|
-
* Marks the value of this element and of every ancestor as superseded. It walks the parent chain, so it costs
|
|
1313
|
-
* the nesting depth: an ancestor rebuilds its value the next time one is asked of it, instead of being walked
|
|
1314
|
-
* here for a reader that may never come. The walk also brings each element into the open transaction, so a
|
|
1315
|
-
* rollback puts the versions back and no reader is left holding a cache the tree no longer supports.
|
|
1316
|
-
*/
|
|
1317
|
-
bumpValueVersion() {
|
|
1318
|
-
u((t) => {
|
|
1319
|
-
t.touch(this), this.#t.valueVersion++;
|
|
1320
|
-
let e = this.parent;
|
|
1321
|
-
for (; e; )
|
|
1322
|
-
t.touch(e), e.#t.valueVersion++, e = e.parent;
|
|
1323
|
-
});
|
|
1324
|
-
}
|
|
1325
|
-
/**
|
|
1326
|
-
* States that this element's value changed and that every container above it therefore holds a different value
|
|
1327
|
-
* too. Nothing is announced here: the transaction works out at commit which of the elements enrolled actually
|
|
1328
|
-
* ends up holding a different value, and announces those once each.
|
|
1329
|
-
*
|
|
1330
|
-
* `force` states that the caller already knows this element's value changed - one item more or fewer is a
|
|
1331
|
-
* different list whatever the items compare as - so the commit announces it without composing a comparison.
|
|
1332
|
-
*/
|
|
1333
|
-
propagateValueChanged(t = !1) {
|
|
1334
|
-
u((e) => {
|
|
1335
|
-
e.markValueChanged(this, t), e.markValidityDirty(this), this.parent?.notifyValueChanged();
|
|
1336
|
-
});
|
|
1337
|
-
}
|
|
1338
|
-
/**
|
|
1339
|
-
* The last step of a construction: it runs inside the transaction the construction is, with the parameters
|
|
1340
|
-
* applied and the value in place, before the element records what it was built as.
|
|
1341
|
-
*
|
|
1342
|
-
* A subclass overrides it to complete what the element was built with. What it writes here is part of the
|
|
1343
|
-
* construction rather than a change of it: the element announces no ValueChangedAction, and what the hook
|
|
1344
|
-
* leaves is what its eager actions and its validators run over, once. An element whose parameters named no
|
|
1345
|
-
* `originalValue` is baselined on the value the hook left and so starts unchanged; one that named a baseline is
|
|
1346
|
-
* measured against it, as any element is. A `Field` writes
|
|
1347
|
-
* `_value`, which reaches the slot on an element built `enabled: false` as well - the value setter, which a
|
|
1348
|
-
* disabled field refuses, states a change, and this is not one.
|
|
1349
|
-
*
|
|
1350
|
-
* A container completes itself through its members, and a member carries a construction of its own: the write
|
|
1351
|
-
* reaches it as any later one would, so the member announces it and reports itself changed. A member that is to
|
|
1352
|
-
* start unchanged is baselined here as well - `this.fields.x.originalValue = this.fields.x.value`.
|
|
1353
|
-
*
|
|
1354
|
-
* `params` is the parameter object the constructor received, where it received one.
|
|
1355
|
-
*/
|
|
1356
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1357
|
-
constructed(t) {
|
|
1358
|
-
}
|
|
1359
|
-
/**
|
|
1360
|
-
* Re-reads the value that the next ValueChangedAction will report as the one it replaces. A leaf records what
|
|
1361
|
-
* it announced at every announcement, so its copy is always current and there is nothing to re-read; a
|
|
1362
|
-
* container that skipped composing a value nobody was listening for overrides this.
|
|
1363
|
-
*/
|
|
1364
|
-
refreshPreviousValue() {
|
|
1365
|
-
}
|
|
1366
|
-
/**
|
|
1367
|
-
* The verdict validate() records and announces: this element's own errors plus the tally of children that
|
|
1368
|
-
* reported themselves invalid, so a container forms it without walking its members. `valid` is the read path
|
|
1369
|
-
* and answers over the live errors arrays instead; the two differ only for an error written into a member
|
|
1370
|
-
* without a validate() call, which is the documented cost of pushing errors by hand.
|
|
1371
|
-
*/
|
|
1372
|
-
get countedValid() {
|
|
1373
|
-
return this.#e.errors.length === 0 && this.#e.invalidChildren === 0;
|
|
1374
|
-
}
|
|
1375
|
-
/**
|
|
1376
|
-
* Makes this element the container of `child`: it installs the back-reference, records the name a Group holds
|
|
1377
|
-
* the child under, and takes the child into the invalid tally. An element belongs to one container at a time,
|
|
1378
|
-
* so a child that already carries the link is refused; releaseChild() takes the link away again, and an element
|
|
1379
|
-
* released that way can be handed on. The child's state is unreachable from outside FieldBase, so a container
|
|
1380
|
-
* writes the two slots through here rather than on the child.
|
|
1381
|
-
*/
|
|
1382
|
-
takeChild(t, e) {
|
|
1383
|
-
u((s) => {
|
|
1384
|
-
if (t.parent) throw new TypeError("This element already belongs to a container - pass a bind() of it");
|
|
1385
|
-
s.touch(t), t.#t.fieldName = e, t.#t.parent = this, this.adoptChild(t);
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1388
|
-
/** Takes a child into this element's invalid tally; a container calls it once the child's parent link exists. */
|
|
1389
|
-
adoptChild(t) {
|
|
1390
|
-
u((e) => {
|
|
1391
|
-
e.touch(this), t.#e.valid || this.#e.invalidChildren++, t.validating && this.childValidatingChanged(!0), e.whenRolledBack(() => {
|
|
1392
|
-
t.validating && this.childValidatingChanged(!1);
|
|
1393
|
-
}), e.markValidityDirty(this);
|
|
1394
|
-
});
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* Drops a child out of this element's invalid tally and takes its back-reference away. An element keeps no link
|
|
1398
|
-
* to a container that no longer holds it: it would go on moving that container's tally, and the link is what
|
|
1399
|
-
* stands in the way of the element being taken by another container.
|
|
1400
|
-
*/
|
|
1401
|
-
releaseChild(t) {
|
|
1402
|
-
u((e) => {
|
|
1403
|
-
e.touch(this), e.touch(t), t.#e.valid || this.#e.invalidChildren--, t.validating && this.childValidatingChanged(!1), e.whenRolledBack(() => {
|
|
1404
|
-
t.validating && this.childValidatingChanged(!0);
|
|
1405
|
-
}), t.#t.parent = void 0, t.#t.fieldName = void 0, e.markValidityDirty(this);
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
/**
|
|
1409
|
-
* Brings this element to the state a fresh binding of `source` carrying `value` would be in: `value` is written
|
|
1410
|
-
* where the caller supplied one and `source`'s own value where it did not, the change history - originalValue,
|
|
1411
|
-
* touched - starts over and the errors are dropped and re-established by the validators. A container that reuses
|
|
1412
|
-
* an element at a position it already holds calls it, so the element is indistinguishable from one built for
|
|
1413
|
-
* that position.
|
|
1414
|
-
*/
|
|
1415
|
-
resetTo(t, e) {
|
|
1416
|
-
u(() => {
|
|
1417
|
-
const s = e === void 0 ? t.value : e, i = this.errors.length > 0;
|
|
1418
|
-
i && (this.errors = []), this.touched = !1;
|
|
1419
|
-
const r = this.enabled && this.value !== s;
|
|
1420
|
-
this.value = s, this.originalValue = this.value, this.validate(!r && i);
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
/** Resets a member. It is what lets a container reach the reset of a child whose class it does not know. */
|
|
1424
|
-
resetChild(t, e, s) {
|
|
1425
|
-
t.resetTo(e, s);
|
|
1426
|
-
}
|
|
1427
|
-
/**
|
|
1428
|
-
* Records a child's new verdict in this element's tally. The child reports it as it settles, and the commit
|
|
1429
|
-
* settles the deepest element first, so the tally a container reads when its own turn comes is finished.
|
|
1430
|
-
*/
|
|
1431
|
-
childValidityChanged(t) {
|
|
1432
|
-
this.#e.invalidChildren += t ? -1 : 1;
|
|
1433
|
-
}
|
|
1434
|
-
/**
|
|
1435
|
-
* The composed verdict a container answers `valid` with, memoised by Vue. The walk over the members is what
|
|
1436
|
-
* makes an error pushed into one of them visible without a validate() call, and the computed keeps that walk
|
|
1437
|
-
* from repeating while nothing it read has moved.
|
|
1438
|
-
*/
|
|
1439
|
-
get validRead() {
|
|
1440
|
-
let t = gt.get(this);
|
|
1441
|
-
return t || (t = K(() => this.composeValid()), gt.set(this, t)), t.value;
|
|
1442
|
-
}
|
|
1443
|
-
/** What validRead computes. A leaf answers over its own errors; a container adds its members. */
|
|
1444
|
-
composeValid() {
|
|
1445
|
-
return this.#t.errors.length === 0;
|
|
1446
|
-
}
|
|
1447
|
-
// default property handlers
|
|
1448
|
-
get visibility() {
|
|
1449
|
-
return this.#t.visibility;
|
|
1450
|
-
}
|
|
1451
|
-
set visibility(t) {
|
|
1452
|
-
const e = this.#t.visibility;
|
|
1453
|
-
t !== e && u((s) => {
|
|
1454
|
-
const i = this.boundActions?.trigger(_t, this, t, e);
|
|
1455
|
-
if (!(i instanceof S)) {
|
|
1456
|
-
if (!O.isDefined(i ?? t))
|
|
1457
|
-
throw new Error("visibility must be a DisplayMode constant");
|
|
1458
|
-
s.touch(this), this.#t.visibility = O.fromAny(i ?? t), this.boundActions?.trigger(jt, this, this.#t.visibility, e);
|
|
1459
|
-
}
|
|
1460
|
-
});
|
|
1461
|
-
}
|
|
1462
|
-
get enabled() {
|
|
1463
|
-
return this.#t.enabled;
|
|
1464
|
-
}
|
|
1465
|
-
set enabled(t) {
|
|
1466
|
-
const e = this.#t.enabled;
|
|
1467
|
-
t !== e && u((s) => {
|
|
1468
|
-
const i = this.boundActions?.trigger(kt, this, t, e);
|
|
1469
|
-
if (!(i instanceof S)) {
|
|
1470
|
-
if (!Qt(i ?? t)) throw new Error("Enabled value must be boolean");
|
|
1471
|
-
s.touch(this), this.#t.enabled = i ?? t, this.#t.enabled !== e && this.bumpValueVersion(), this.boundActions?.trigger(Rt, this, this.#t.enabled, e);
|
|
1472
|
-
}
|
|
1473
|
-
});
|
|
1474
|
-
}
|
|
1475
|
-
/**
|
|
1476
|
-
* Whether this element and every container above it are enabled. A rendering layer binds one read instead of
|
|
1477
|
-
* walking the parent chain: a disabled `Group` states that its section cannot be edited, and the inputs
|
|
1478
|
-
* rendered from the members inside it read that here.
|
|
1479
|
-
*
|
|
1480
|
-
* It is a read and nothing else. `enabled` on each element stays exactly what was written to it, a write to a
|
|
1481
|
-
* member of a disabled container is accepted the way it always was, and what a container serializes is decided
|
|
1482
|
-
* by the members' own `enabled`. Where a whole subtree is to stop serializing, the members are disabled.
|
|
1483
|
-
*
|
|
1484
|
-
* `enabled` is the only member with a reading of this kind, and it is not a scheme the other members follow.
|
|
1485
|
-
* `visibility` has none because `SUPPRESS` states that an element is absent from the value as well, so folding
|
|
1486
|
-
* it down the tree would decide serialization rather than report it; `value` has none because a container
|
|
1487
|
-
* composes its own from its members rather than passing one down. A rendering layer that needs a third thing
|
|
1488
|
-
* folded down the tree has `provide`/`inject`, which is where the render tree's own context belongs.
|
|
1489
|
-
*/
|
|
1490
|
-
get effectiveEnabled() {
|
|
1491
|
-
return this.enabled && (this.parent?.effectiveEnabled ?? !0);
|
|
1492
|
-
}
|
|
1493
|
-
/**
|
|
1494
|
-
* True for an element whose value is composed of its members'. The commit builds such a value only where
|
|
1495
|
-
* something receives it, compares it by content rather than by identity, and runs the element's own validators
|
|
1496
|
-
* with the announcement: a container's validators read the composed value, which exists only once the members
|
|
1497
|
-
* have been written. A leaf's validators have run at the write instead, so its announcement carries no eager
|
|
1498
|
-
* pass of its own.
|
|
1499
|
-
*/
|
|
1500
|
-
get composesValue() {
|
|
1501
|
-
return !1;
|
|
1502
|
-
}
|
|
1503
|
-
/**
|
|
1504
|
-
* Whether `child` composes its value from members of its own. It is what lets a container tell a nested
|
|
1505
|
-
* container from a leaf without knowing the classes below it, the way `resetChild` reaches a reset it does not
|
|
1506
|
-
* know the shape of.
|
|
1507
|
-
*/
|
|
1508
|
-
childComposesValue(t) {
|
|
1509
|
-
return t.composesValue;
|
|
1510
|
-
}
|
|
1511
|
-
/**
|
|
1512
|
-
* Announces what this element's value became over the transaction. The pair carried is (value now, value at the
|
|
1513
|
-
* last announcement), so a value that went A -> B -> A within the transaction says nothing, and the events an
|
|
1514
|
-
* operation states rather than an element's state - an item added, an item removed - are emitted first, in the
|
|
1515
|
-
* order the operations happened.
|
|
1516
|
-
*/
|
|
1517
|
-
[xt](t, e, s, i) {
|
|
1518
|
-
if (i?.forEach((l) => this.boundActions?.trigger(l.actionClass, this, l.item, l.index)), !e) return;
|
|
1519
|
-
const r = this.boundActions;
|
|
1520
|
-
if (this.composesValue && !(r?.willTrigger(Ct) || r?.hasEager)) return;
|
|
1521
|
-
const a = this.value, o = this.#e.announcedValue;
|
|
1522
|
-
!s && (this.composesValue ? F(a, o) : a === o) || (t.touch(this), this.#e.announcedValue = a, this.composesValue && r?.triggerEager(this, a, o), r?.trigger(P, this, a, o));
|
|
1523
|
-
}
|
|
1524
|
-
/**
|
|
1525
|
-
* Forms the verdict this element ends the transaction with and announces a transition of it. The container is
|
|
1526
|
-
* told first, so a handler reads a tally that already includes this verdict, and it is enrolled in the same
|
|
1527
|
-
* transaction: its own verdict is composed of its members', so a member that moves without a value change - an
|
|
1528
|
-
* asynchronous validator, an error pushed in by hand - is what makes the container re-form its own. The
|
|
1529
|
-
* transaction settles the deepest element first, so a container is reached only once its members have decided.
|
|
1530
|
-
*/
|
|
1531
|
-
[At](t) {
|
|
1532
|
-
const e = this.#e.valid, s = this.countedValid;
|
|
1533
|
-
if (s === e) return;
|
|
1534
|
-
t.touch(this), this.#e.valid = s;
|
|
1535
|
-
const i = this.container;
|
|
1536
|
-
i && (t.touch(i), i.childValidityChanged(s), t.markValidityDirty(i)), this.boundActions?.trigger(Ft, this, s, e);
|
|
1537
|
-
}
|
|
1538
|
-
validate(t = !1) {
|
|
1539
|
-
u((e) => {
|
|
1540
|
-
t && this.boundActions?.triggerEager(this, this.value, this.value), e.markValidityDirty(this);
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
get valid() {
|
|
1544
|
-
return this.#t.errors.length === 0;
|
|
1545
|
-
}
|
|
1546
|
-
get fullValue() {
|
|
1547
|
-
return this.value;
|
|
1548
|
-
}
|
|
1549
|
-
get isChanged() {
|
|
1550
|
-
return !F(this.value, this.originalValue);
|
|
1551
|
-
}
|
|
1552
|
-
/**
|
|
1553
|
-
* Brings a fresh element into the state a binding of `source` is in: it records what it was declared as, takes
|
|
1554
|
-
* on the extended properties and the actions `source` carries, and runs the eager ones over the value it was
|
|
1555
|
-
* built with. The extended properties `overrides` states are written over the ones `source` carries, and they
|
|
1556
|
-
* are in place before the eager pass, so an action reading one sees what the binding ends up carrying. The
|
|
1557
|
-
* actions are the very instances `source` holds - what a binding takes on is data, not behaviour - and each is
|
|
1558
|
-
* told about this element as it is taken on, so an action serving several bindings knows all of them.
|
|
1559
|
-
*/
|
|
1560
|
-
boundFrom(t, e, s, i) {
|
|
1561
|
-
this.#e.declaration = t.declaration;
|
|
1562
|
-
const r = { ...t.extra, ...i && this.extendedOf(i) };
|
|
1563
|
-
j(r) || this.setExtendedValues(r);
|
|
1564
|
-
const a = this.declaration;
|
|
1565
|
-
a.noteBinding(this);
|
|
1566
|
-
const o = a._actions;
|
|
1567
|
-
o && (this._actions = o, o.bindTo(this), o.triggerEager(this, e, s));
|
|
1568
|
-
}
|
|
1569
|
-
/**
|
|
1570
|
-
* Registers the actions a constructor received in its parameters: registration without the eager trigger,
|
|
1571
|
-
* because a constructor ends with a single this.actions.triggerEager(...) over the finished value, and an
|
|
1572
|
-
* eager action registered here would otherwise also run once per registration, over a half-built field.
|
|
1573
|
-
*/
|
|
1574
|
-
registerInitialActions(t) {
|
|
1575
|
-
t.forEach((e) => {
|
|
1576
|
-
this.actions.register(e), e.boundToBinding(this);
|
|
1577
|
-
});
|
|
1578
|
-
}
|
|
1579
|
-
registerAction(t) {
|
|
1580
|
-
return u((e) => {
|
|
1581
|
-
e.willAnnounceValue(this) || this.refreshPreviousValue(), this.actions.register(t), this.registered(e, t);
|
|
1582
|
-
}), this;
|
|
1583
|
-
}
|
|
1584
|
-
/**
|
|
1585
|
-
* Registers `action` so that `before` wraps it: `before` reaches it through the `supr` it is handed, instead of
|
|
1586
|
-
* ending the run there. It is how an action is added to a chain someone else built and still sits inside a
|
|
1587
|
-
* handler already registered, which registration order alone cannot arrange. `before` has to be registered on
|
|
1588
|
-
* this element under the same identifier.
|
|
1589
|
-
*/
|
|
1590
|
-
registerActionBefore(t, e) {
|
|
1591
|
-
return u((s) => {
|
|
1592
|
-
s.willAnnounceValue(this) || this.refreshPreviousValue(), this.actions.register(t, e), this.registered(s, t);
|
|
1593
|
-
}), this;
|
|
1594
|
-
}
|
|
1595
|
-
/**
|
|
1596
|
-
* Drops `action` from this element and answers whether it held it. The instance goes on serving every other
|
|
1597
|
-
* element it was registered on: what is dropped is this element's registration, not the action. A validator
|
|
1598
|
-
* withdraws the errors it put on this element as it goes, so the verdict the element reports is the one the
|
|
1599
|
-
* validators it still holds reach.
|
|
1600
|
-
*/
|
|
1601
|
-
unregisterAction(t) {
|
|
1602
|
-
let e = !1;
|
|
1603
|
-
return u((s) => {
|
|
1604
|
-
const i = this.boundActions;
|
|
1605
|
-
if (!i || (e = i.unregister(t), !e)) return;
|
|
1606
|
-
s.touch(this), t instanceof f && this.#t.validationEpoch++;
|
|
1607
|
-
const r = this.boundElements;
|
|
1608
|
-
s.whenRolledBack(() => {
|
|
1609
|
-
i.register(t), r.forEach((a) => t.boundToBinding(a));
|
|
1610
|
-
}), r.forEach((a) => t.unregisterFrom(a));
|
|
1611
|
-
}), e;
|
|
1612
|
-
}
|
|
1613
|
-
/**
|
|
1614
|
-
* Records that `action` is now registered on this element, and that a rollback has to take that back. The
|
|
1615
|
-
* registration is not one of the state slots the snapshot covers, so it hands its own undo in.
|
|
1616
|
-
*/
|
|
1617
|
-
registered(t, e) {
|
|
1618
|
-
const s = this.boundElements;
|
|
1619
|
-
s.forEach((i) => {
|
|
1620
|
-
e.boundToBinding(i), e.eager && this.actions.triggerEagerFor(e.classIdentifier, i, i.value, i.originalValue);
|
|
1621
|
-
}), t.whenRolledBack(() => {
|
|
1622
|
-
this.boundActions?.unregister(e) && s.forEach((i) => e.unregisterFrom(i));
|
|
1623
|
-
});
|
|
1624
|
-
}
|
|
1625
|
-
triggerAction(t, ...e) {
|
|
1626
|
-
const s = this.boundActions;
|
|
1627
|
-
return s ? s.trigger(t, this, ...e) : null;
|
|
1628
|
-
}
|
|
1629
|
-
/**
|
|
1630
|
-
* Generation counter of the validators attached to this field. A Validator reads it when a run starts and drops
|
|
1631
|
-
* a result whose epoch no longer matches, so a validation still in flight when clearValidators() is called
|
|
1632
|
-
* cannot push an error onto a field that no longer has the validator that produced it.
|
|
1633
|
-
*/
|
|
1634
|
-
get validationEpoch() {
|
|
1635
|
-
return this.#t.validationEpoch;
|
|
1636
|
-
}
|
|
1637
|
-
clearValidators() {
|
|
1638
|
-
u((t) => {
|
|
1639
|
-
t.touch(this), this.#t.validationEpoch++;
|
|
1640
|
-
const e = this.boundActions;
|
|
1641
|
-
if (e) {
|
|
1642
|
-
const s = this.boundElements;
|
|
1643
|
-
e.validators.forEach((i) => {
|
|
1644
|
-
e.unregister(i), t.whenRolledBack(() => {
|
|
1645
|
-
e.register(i), s.forEach((r) => i.boundToBinding(r));
|
|
1646
|
-
}), s.forEach((r) => i.unregisterFrom(r));
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
this.errors = [], this.validate();
|
|
1650
|
-
});
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
function me(n, t) {
|
|
1654
|
-
return n ? !t : t;
|
|
1655
|
-
}
|
|
1656
|
-
class w {
|
|
1657
|
-
operand1;
|
|
1658
|
-
operator;
|
|
1659
|
-
operand2;
|
|
1660
|
-
/**
|
|
1661
|
-
* An operand is a nested `Statement`, a `FieldBase` whose value is compared, or a literal. `undefined` and a
|
|
1662
|
-
* function are neither: they are what a misspelled field name and a field accessor handed over uncalled answer
|
|
1663
|
-
* with, and a statement built from one compares nothing and never fires. The position names which of the two
|
|
1664
|
-
* operands is at fault, so the error points at the place the name was written.
|
|
1665
|
-
*/
|
|
1666
|
-
static validateOperand(t, e) {
|
|
1667
|
-
if (t === void 0)
|
|
1668
|
-
throw new TypeError(
|
|
1669
|
-
`Statement operand ${e} is undefined: an operand is a field, a nested statement or a literal, and a name resolving to nothing is none of them. Compare against null to test for an unset value.`
|
|
1670
|
-
);
|
|
1671
|
-
if (typeof t == "function")
|
|
1672
|
-
throw new TypeError(
|
|
1673
|
-
`Statement operand ${e} is a function: an operand is a field, a nested statement or a literal, and a function is none of them. An accessor states the field it answers with: group.field('name').`
|
|
1674
|
-
);
|
|
1675
|
-
}
|
|
1676
|
-
constructor(t, e, s) {
|
|
1677
|
-
w.validateOperand(t, 1), e !== c.NOT && w.validateOperand(s, 2), this.operand1 = t, this.operator = e, this.operand2 = s;
|
|
1678
|
-
}
|
|
1679
|
-
/**
|
|
1680
|
-
* The value an operand contributes. A field operand names a field of the record the statement is evaluated in:
|
|
1681
|
-
* the same statement over a `List` reads row 3's field while row 3 is the record, and a field belonging to no
|
|
1682
|
-
* record of the statement's own - a form field above the list - is read where it stands. A record that does not
|
|
1683
|
-
* hold the field yet contributes undefined, which is what a half-built row answers with.
|
|
1684
|
-
*/
|
|
1685
|
-
static valueOf(t, e) {
|
|
1686
|
-
if (t instanceof w) return t.evaluate(e);
|
|
1687
|
-
if (t instanceof y) {
|
|
1688
|
-
const s = e ? tt(t, e) : t;
|
|
1689
|
-
return s ? h(s.value) : void 0;
|
|
1690
|
-
}
|
|
1691
|
-
return t;
|
|
1692
|
-
}
|
|
1693
|
-
get operand1Value() {
|
|
1694
|
-
return w.valueOf(this.operand1);
|
|
1695
|
-
}
|
|
1696
|
-
get operand2Value() {
|
|
1697
|
-
return w.valueOf(this.operand2);
|
|
1698
|
-
}
|
|
1699
|
-
/**
|
|
1700
|
-
* The result of the statement, over the record `scope` belongs to where one is given and over the fields the
|
|
1701
|
-
* statement was built from where it is not.
|
|
1702
|
-
*/
|
|
1703
|
-
evaluate(t) {
|
|
1704
|
-
const e = w.valueOf(this.operand1, t), s = w.valueOf(this.operand2, t);
|
|
1705
|
-
switch (this.operator) {
|
|
1706
|
-
// logical operators
|
|
1707
|
-
// `&&` and `||` evaluate to one of their operands, and the operands are of any type. Without the
|
|
1708
|
-
// coercion evaluate() would hand out the operand itself, so `0` or `''` would reach callers that the
|
|
1709
|
-
// signature promises a boolean, and consumers comparing results with !== would see a change where the
|
|
1710
|
-
// logical value stayed the same.
|
|
1711
|
-
case c.AND:
|
|
1712
|
-
return !!(e && s);
|
|
1713
|
-
case c.OR:
|
|
1714
|
-
return !!(e || s);
|
|
1715
|
-
case c.NAND:
|
|
1716
|
-
return !(e && s);
|
|
1717
|
-
case c.NOR:
|
|
1718
|
-
return !(e || s);
|
|
1719
|
-
case c.XOR:
|
|
1720
|
-
return me(!!e, !!s);
|
|
1721
|
-
case c.NOT:
|
|
1722
|
-
return !e;
|
|
1723
|
-
// comparison operators
|
|
1724
|
-
case c.EQUALS:
|
|
1725
|
-
return e == s;
|
|
1726
|
-
case c.NOT_EQUALS:
|
|
1727
|
-
return e != s;
|
|
1728
|
-
case c.LT:
|
|
1729
|
-
return e < s;
|
|
1730
|
-
case c.LE:
|
|
1731
|
-
return e <= s;
|
|
1732
|
-
case c.GE:
|
|
1733
|
-
return e >= s;
|
|
1734
|
-
case c.GT:
|
|
1735
|
-
return e > s;
|
|
1736
|
-
case c.IN:
|
|
1737
|
-
return !!s?.includes?.(e);
|
|
1738
|
-
case c.NOT_IN:
|
|
1739
|
-
return !s?.includes?.(e);
|
|
1740
|
-
case c.INCLUDES:
|
|
1741
|
-
return C(e) && C(s) && e.indexOf(s) >= 0;
|
|
1742
|
-
case c.NOT_INCLUDES:
|
|
1743
|
-
return !(C(e) && C(s) && e.indexOf(s) >= 0);
|
|
1744
|
-
default:
|
|
1745
|
-
throw new Error(`Operator not implemented ${this.operator}`);
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
/**
|
|
1749
|
-
* Recursively collects all fields used in this statement and its nested statements
|
|
1750
|
-
* @returns A set of all fields used in this statement
|
|
1751
|
-
*/
|
|
1752
|
-
collectFields() {
|
|
1753
|
-
const t = /* @__PURE__ */ new Set();
|
|
1754
|
-
function e(s) {
|
|
1755
|
-
s instanceof y ? t.add(s) : s instanceof w && s.collectFields().forEach((r) => t.add(r));
|
|
1756
|
-
}
|
|
1757
|
-
return e(this.operand1), e(this.operand2), t;
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
const be = /* @__PURE__ */ Symbol("ExecuteAction");
|
|
1761
|
-
class Nt extends m {
|
|
1762
|
-
constructor(t) {
|
|
1763
|
-
super(t);
|
|
1764
|
-
}
|
|
1765
|
-
static get classIdentifier() {
|
|
1766
|
-
return be;
|
|
1767
|
-
}
|
|
1768
|
-
execute(t, e, s) {
|
|
1769
|
-
return super.execute(t, e, s);
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
const ve = /* @__PURE__ */ Symbol("ListItemAddedAction");
|
|
1773
|
-
class Y extends m {
|
|
1774
|
-
constructor(t) {
|
|
1775
|
-
super(t);
|
|
1776
|
-
}
|
|
1777
|
-
static get classIdentifier() {
|
|
1778
|
-
return ve;
|
|
1779
|
-
}
|
|
1780
|
-
execute(t, e, s, i) {
|
|
1781
|
-
return super.execute(t, e, s, i);
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
const we = /* @__PURE__ */ Symbol("ListItemRemovedAction");
|
|
1785
|
-
class Bt extends m {
|
|
1786
|
-
constructor(t) {
|
|
1787
|
-
super(t);
|
|
1788
|
-
}
|
|
1789
|
-
static get classIdentifier() {
|
|
1790
|
-
return we;
|
|
1791
|
-
}
|
|
1792
|
-
execute(t, e, s, i) {
|
|
1793
|
-
return super.execute(t, e, s, i);
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
const Ve = Object.freeze({});
|
|
1797
|
-
function Dt() {
|
|
1798
|
-
return {
|
|
1799
|
-
originalValue: void 0,
|
|
1800
|
-
announcedValue: void 0,
|
|
1801
|
-
errors: [],
|
|
1802
|
-
visibility: O.FULL,
|
|
1803
|
-
enabled: !0,
|
|
1804
|
-
valueVersion: 0,
|
|
1805
|
-
validatingCount: 0,
|
|
1806
|
-
validatingChildren: 0,
|
|
1807
|
-
parent: void 0,
|
|
1808
|
-
fieldName: void 0,
|
|
1809
|
-
validationEpoch: 0,
|
|
1810
|
-
declaration: void 0,
|
|
1811
|
-
extra: Ve,
|
|
1812
|
-
valid: !0,
|
|
1813
|
-
invalidChildren: 0
|
|
1814
|
-
};
|
|
1815
|
-
}
|
|
1816
|
-
function ye() {
|
|
1817
|
-
return { ...Dt(), value: void 0, touched: !1 };
|
|
1818
|
-
}
|
|
1819
|
-
function Lt() {
|
|
1820
|
-
return {
|
|
1821
|
-
...Dt(),
|
|
1822
|
-
announcedValue: null,
|
|
1823
|
-
cachedValue: null,
|
|
1824
|
-
cachedValueVersion: -1
|
|
1825
|
-
};
|
|
1826
|
-
}
|
|
1827
|
-
function Ee() {
|
|
1828
|
-
return { ...Lt(), fieldNames: [] };
|
|
1829
|
-
}
|
|
1830
|
-
function Ce() {
|
|
1831
|
-
return { ...Lt(), rows: null, rowsVersion: 0, cachedItems: null, cachedItemsVersion: -1 };
|
|
1832
|
-
}
|
|
1833
|
-
class et extends y {
|
|
1834
|
-
get [Symbol.toStringTag]() {
|
|
1835
|
-
return "Field";
|
|
1836
|
-
}
|
|
1837
|
-
get state() {
|
|
1838
|
-
return super.state;
|
|
1839
|
-
}
|
|
1840
|
-
get raw() {
|
|
1841
|
-
return super.raw;
|
|
1842
|
-
}
|
|
1843
|
-
/** the value slot itself, without the notifications the value setter carries around a write */
|
|
1844
|
-
get _value() {
|
|
1845
|
-
return this.state.value;
|
|
1846
|
-
}
|
|
1847
|
-
set _value(t) {
|
|
1848
|
-
this.state.value = t;
|
|
1849
|
-
}
|
|
1850
|
-
constructor(t) {
|
|
1851
|
-
super(ye()), this.init(t);
|
|
1852
|
-
}
|
|
1853
|
-
/**
|
|
1854
|
-
* Applies the constructor parameters. It is a hook so that a subclass needing different parameter handling
|
|
1855
|
-
* overrides one method instead of redeclaring the constructor - Action does exactly that.
|
|
1856
|
-
*
|
|
1857
|
-
* It is called from this constructor, so it runs before a subclass's own class field initializers, which
|
|
1858
|
-
* only run once super() returns. An override must therefore work off its parameters alone: members the
|
|
1859
|
-
* subclass initializes read as undefined inside it, and anything it writes to such a member is overwritten
|
|
1860
|
-
* the moment the initializer runs.
|
|
1861
|
-
*/
|
|
1862
|
-
init(t) {
|
|
1863
|
-
u(() => {
|
|
1864
|
-
if (t) {
|
|
1865
|
-
const { value: e, validators: s, actions: i, ...r } = t;
|
|
1866
|
-
this.registerInitialActions([...s || [], ...i || []]), this.assignParams(r), this._value = e !== void 0 ? e : this.originalValue;
|
|
1867
|
-
}
|
|
1868
|
-
this.constructed(t), this.originalValue === void 0 && (this.originalValue = this._value), this.raw.announcedValue = this._value, this.boundActions?.triggerEager(this, this.value, this.originalValue), this.validate();
|
|
1869
|
-
});
|
|
1870
|
-
}
|
|
1871
|
-
get value() {
|
|
1872
|
-
return this._value;
|
|
1873
|
-
}
|
|
1874
|
-
set value(t) {
|
|
1875
|
-
const e = this._value;
|
|
1876
|
-
!this.enabled || e === t || u((s) => {
|
|
1877
|
-
s.touch(this), this._value = t, this.bumpValueVersion(), this.boundActions?.triggerEager(this, t, e), this.propagateValueChanged();
|
|
1878
|
-
});
|
|
1879
|
-
}
|
|
1880
|
-
/**
|
|
1881
|
-
* The container that holds this field. A `List` holds rows and a row is a `Group`, so a field is never a `List`'s
|
|
1882
|
-
* child and the link is a `Group` wherever there is one: `field.parent?.fields.other` is the sibling lookup, and
|
|
1883
|
-
* it is typed here.
|
|
1884
|
-
*/
|
|
1885
|
-
get parent() {
|
|
1886
|
-
return super.parent;
|
|
1887
|
-
}
|
|
1888
|
-
get touched() {
|
|
1889
|
-
return this.state.touched;
|
|
1890
|
-
}
|
|
1891
|
-
set touched(t) {
|
|
1892
|
-
this.touchState(), this.state.touched = t;
|
|
1893
|
-
}
|
|
1894
|
-
bind(t, e) {
|
|
1895
|
-
const s = this.constructor, i = new s({
|
|
1896
|
-
// data is what the caller supplied, and undefined is not supplied; an explicit null is, and clears
|
|
1897
|
-
value: t !== void 0 ? t : this.value,
|
|
1898
|
-
...e && "originalValue" in e ? { originalValue: e.originalValue } : {},
|
|
1899
|
-
enabled: e?.enabled ?? this.enabled,
|
|
1900
|
-
visibility: e?.visibility ?? this.visibility
|
|
1901
|
-
});
|
|
1902
|
-
return i.boundFrom(this, i.value, i.originalValue, e), i;
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
const mt = /* @__PURE__ */ new WeakMap();
|
|
1906
|
-
function bt(n) {
|
|
1907
|
-
if (n != null)
|
|
1908
|
-
return Object.values(n).some((t) => t != null) ? n : void 0;
|
|
1909
|
-
}
|
|
1910
|
-
class Se extends et {
|
|
1911
|
-
get [Symbol.toStringTag]() {
|
|
1912
|
-
return "Action";
|
|
1913
|
-
}
|
|
1914
|
-
init(t) {
|
|
1915
|
-
u(() => {
|
|
1916
|
-
if (this._value = { label: void 0, icon: void 0 }, t) {
|
|
1917
|
-
const { value: e, originalValue: s, validators: i, actions: r, ...a } = t;
|
|
1918
|
-
this.registerInitialActions([...i || [], ...r || []]), this.assignParams(a);
|
|
1919
|
-
const o = bt(e), l = bt(s);
|
|
1920
|
-
o ? this._value = o : l && (this._value = { ...l }), l && (this.originalValue = Object.freeze({ ...l }));
|
|
1921
|
-
}
|
|
1922
|
-
this.constructed(t), this.originalValue === void 0 && (this.originalValue = this._value), this.raw.announcedValue = this._value, this.boundActions?.triggerEager(this, this.value, this.originalValue), this.validate();
|
|
1923
|
-
});
|
|
1924
|
-
}
|
|
1925
|
-
/**
|
|
1926
|
-
* A copy of the value this action holds, carrying one member rewritten. A member handed undefined is dropped
|
|
1927
|
-
* from the copy rather than written into it: an own key holding undefined is invisible to a reader and to
|
|
1928
|
-
* JSON, but lodash isEqual compares own-key sets, so writing one would leave the action permanently changed
|
|
1929
|
-
* against a baseline that never carried the key.
|
|
1930
|
-
*/
|
|
1931
|
-
valueWith(t, e) {
|
|
1932
|
-
const s = { ...this.value };
|
|
1933
|
-
return e === void 0 ? delete s[t] : s[t] = e, s;
|
|
1934
|
-
}
|
|
1935
|
-
get icon() {
|
|
1936
|
-
return this.value.icon;
|
|
1937
|
-
}
|
|
1938
|
-
set icon(t) {
|
|
1939
|
-
this.value.icon !== t && (this.value = this.valueWith("icon", t));
|
|
1940
|
-
}
|
|
1941
|
-
get label() {
|
|
1942
|
-
return this.value.label;
|
|
1943
|
-
}
|
|
1944
|
-
/**
|
|
1945
|
-
* The two setters hand the value setter a new object rather than writing into the one the action holds, so each
|
|
1946
|
-
* is an ordinary value change: the handlers fire, isChanged answers over it, and a disabled action refuses it.
|
|
1947
|
-
* The new object is built only for a member that differs from the one held - the value setter compares by
|
|
1948
|
-
* identity and every copy is a new object, so without the comparison here a write of the value already held
|
|
1949
|
-
* would announce a change and invalidate the value cache of every container above.
|
|
1950
|
-
*/
|
|
1951
|
-
set label(t) {
|
|
1952
|
-
this.value.label !== t && (this.value = this.valueWith("label", t));
|
|
1953
|
-
}
|
|
1954
|
-
/** the counter behind `busy`, allocated for this action the first time it is asked for */
|
|
1955
|
-
get busyRuns() {
|
|
1956
|
-
let t = mt.get(this);
|
|
1957
|
-
return t || (t = Wt(0), mt.set(this, t)), t;
|
|
1958
|
-
}
|
|
1959
|
-
/** true from the moment execute() is called until the handler it ran has settled, however it settles */
|
|
1960
|
-
get busy() {
|
|
1961
|
-
return this.busyRuns.value > 0;
|
|
1962
|
-
}
|
|
1963
|
-
/**
|
|
1964
|
-
* Runs the ExecuteAction chain registered on this action and answers what the chain returned. `busy` stands for
|
|
1965
|
-
* the length of the run: the chain is entered synchronously, and the flag is cleared once the value it produced
|
|
1966
|
-
* has settled - a handler that returns a promise holds it for as long as that promise takes, and one that
|
|
1967
|
-
* rejects clears it as it rejects.
|
|
1968
|
-
*
|
|
1969
|
-
* The answer is a promise whatever the handler returns, so a handler that throws rejects it rather than throwing
|
|
1970
|
-
* out of this call: a caller that does not await the answer and does not attach a catch handler leaves that
|
|
1971
|
-
* rejection unhandled. An `AbortEventHandlingException` is the one exception that does not reject: the answer
|
|
1972
|
-
* resolves with it, in a synchronous chain as in an asynchronous one.
|
|
1973
|
-
*/
|
|
1974
|
-
async execute(t) {
|
|
1975
|
-
const e = this.busyRuns;
|
|
1976
|
-
e.value++;
|
|
1977
|
-
try {
|
|
1978
|
-
return await this.triggerAction(Nt, t);
|
|
1979
|
-
} finally {
|
|
1980
|
-
e.value--;
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
const xe = /* @__PURE__ */ qt({
|
|
1985
|
-
__name: "messages-widget",
|
|
1986
|
-
props: {
|
|
1987
|
-
message: {},
|
|
1988
|
-
classes: {}
|
|
1989
|
-
},
|
|
1990
|
-
setup(n) {
|
|
1991
|
-
const t = n, e = lt("vue-markdown"), s = /* @__PURE__ */ new Set([
|
|
1992
|
-
"div",
|
|
1993
|
-
"span",
|
|
1994
|
-
"p",
|
|
1995
|
-
"h1",
|
|
1996
|
-
"h2",
|
|
1997
|
-
"h3",
|
|
1998
|
-
"h4",
|
|
1999
|
-
"h5",
|
|
2000
|
-
"h6",
|
|
2001
|
-
"section",
|
|
2002
|
-
"article",
|
|
2003
|
-
"aside",
|
|
2004
|
-
"nav",
|
|
2005
|
-
"header",
|
|
2006
|
-
"footer",
|
|
2007
|
-
"main",
|
|
2008
|
-
"figure",
|
|
2009
|
-
"figcaption",
|
|
2010
|
-
"blockquote",
|
|
2011
|
-
"pre",
|
|
2012
|
-
"code",
|
|
2013
|
-
"em",
|
|
2014
|
-
"strong",
|
|
2015
|
-
"small",
|
|
2016
|
-
"mark",
|
|
2017
|
-
"del",
|
|
2018
|
-
"ins",
|
|
2019
|
-
"sub",
|
|
2020
|
-
"sup",
|
|
2021
|
-
"i",
|
|
2022
|
-
"b",
|
|
2023
|
-
"u",
|
|
2024
|
-
"s",
|
|
2025
|
-
"a",
|
|
2026
|
-
"img",
|
|
2027
|
-
"button",
|
|
2028
|
-
"input",
|
|
2029
|
-
"textarea",
|
|
2030
|
-
"select",
|
|
2031
|
-
"option",
|
|
2032
|
-
"label",
|
|
2033
|
-
"form",
|
|
2034
|
-
"table",
|
|
2035
|
-
"tr",
|
|
2036
|
-
"td",
|
|
2037
|
-
"th",
|
|
2038
|
-
"thead",
|
|
2039
|
-
"tbody",
|
|
2040
|
-
"tfoot",
|
|
2041
|
-
"ul",
|
|
2042
|
-
"ol",
|
|
2043
|
-
"li",
|
|
2044
|
-
"dl",
|
|
2045
|
-
"dt",
|
|
2046
|
-
"dd"
|
|
2047
|
-
]), i = () => {
|
|
2048
|
-
if (typeof t.message == "string") return R("span", { class: t.classes }, t.message);
|
|
2049
|
-
const r = [];
|
|
2050
|
-
return t.message.forEach((a) => {
|
|
2051
|
-
switch (a.componentName) {
|
|
2052
|
-
case "template":
|
|
2053
|
-
r.push(R("div", { class: [t.classes, a.extraClasses] }, a.componentBody));
|
|
2054
|
-
break;
|
|
2055
|
-
case "vue-markdown":
|
|
2056
|
-
if (typeof e == "string")
|
|
2057
|
-
console.warn(
|
|
2058
|
-
"You are using markdown for messages-widget, but you haven't registered a vue-markdown component"
|
|
2059
|
-
), r.push(R("div", { class: [t.classes, a.extraClasses] }, a.componentBindings.source));
|
|
2060
|
-
else {
|
|
2061
|
-
const o = a.componentBindings;
|
|
2062
|
-
r.push(
|
|
2063
|
-
R(e, {
|
|
2064
|
-
class: [t.classes, a.extraClasses, "df-messages-widget-markdown"],
|
|
2065
|
-
source: o.source,
|
|
2066
|
-
options: o.options,
|
|
2067
|
-
plugins: o.plugins
|
|
2068
|
-
})
|
|
2069
|
-
);
|
|
2070
|
-
}
|
|
2071
|
-
break;
|
|
2072
|
-
default:
|
|
2073
|
-
r.push(
|
|
2074
|
-
R(
|
|
2075
|
-
s.has(a.componentName.toLowerCase()) ? a.componentName : lt(a.componentName),
|
|
2076
|
-
{
|
|
2077
|
-
class: [t.classes, a.extraClasses],
|
|
2078
|
-
...a.componentBindings,
|
|
2079
|
-
...a.componentBody ? { innerHTML: a.componentBody } : {}
|
|
2080
|
-
}
|
|
2081
|
-
)
|
|
2082
|
-
);
|
|
2083
|
-
break;
|
|
2084
|
-
}
|
|
2085
|
-
}), r;
|
|
2086
|
-
};
|
|
2087
|
-
return (r, a) => (zt(), Ht(i));
|
|
2088
|
-
}
|
|
2089
|
-
}), vt = /* @__PURE__ */ new WeakMap(), Ae = (n) => ({
|
|
2090
|
-
get(t, e, s) {
|
|
2091
|
-
return n(), Reflect.get(t, e, s);
|
|
2092
|
-
},
|
|
2093
|
-
has(t, e) {
|
|
2094
|
-
return n(), Reflect.has(t, e);
|
|
2095
|
-
},
|
|
2096
|
-
ownKeys(t) {
|
|
2097
|
-
return n(), Reflect.ownKeys(t);
|
|
2098
|
-
},
|
|
2099
|
-
getOwnPropertyDescriptor(t, e) {
|
|
2100
|
-
return n(), Reflect.getOwnPropertyDescriptor(t, e);
|
|
2101
|
-
},
|
|
2102
|
-
set(t, e) {
|
|
2103
|
-
throw new TypeError(`fields.${String(e)} cannot be assigned: use addField() to give the group a member`);
|
|
2104
|
-
},
|
|
2105
|
-
defineProperty(t, e) {
|
|
2106
|
-
throw new TypeError(`fields.${String(e)} cannot be redefined: use addField() to give the group a member`);
|
|
2107
|
-
},
|
|
2108
|
-
deleteProperty(t, e) {
|
|
2109
|
-
throw new TypeError(`fields.${String(e)} cannot be deleted: use removeField() to take a member out`);
|
|
2110
|
-
}
|
|
196
|
+
function ve(e) {
|
|
197
|
+
if (e != null && typeof e.then == "function") throw TypeError("a transaction may not be asynchronous: the callback returned a thenable. Do the awaiting outside and open a transaction for each synchronous part.");
|
|
198
|
+
}
|
|
199
|
+
function D(e) {
|
|
200
|
+
if (E) {
|
|
201
|
+
let t = e(me);
|
|
202
|
+
return ve(t), t;
|
|
203
|
+
}
|
|
204
|
+
let t = new pe(), n = new _e();
|
|
205
|
+
E = t, me = n;
|
|
206
|
+
try {
|
|
207
|
+
let r = e(n);
|
|
208
|
+
return ve(r), t.commit(), r;
|
|
209
|
+
} catch (e) {
|
|
210
|
+
if (t.rollback(), e instanceof ge) return;
|
|
211
|
+
throw e;
|
|
212
|
+
} finally {
|
|
213
|
+
E = void 0, me = void 0, n.close();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function O(e) {
|
|
217
|
+
return E ? e(E) : D(() => e(E));
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/config.ts
|
|
221
|
+
var ye = { useMarkdownInValidators: !0 };
|
|
222
|
+
function be() {
|
|
223
|
+
return ye;
|
|
224
|
+
}
|
|
225
|
+
function xe(e) {
|
|
226
|
+
Object.assign(ye, e);
|
|
227
|
+
}
|
|
228
|
+
var Se = { install(e, t) {
|
|
229
|
+
t && xe(t);
|
|
230
|
+
} }, k = class extends String {
|
|
231
|
+
plugins;
|
|
232
|
+
options;
|
|
233
|
+
constructor(e, t, n) {
|
|
234
|
+
super(e), this.plugins = n, this.options = t;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
function A(e) {
|
|
238
|
+
let t = d(e);
|
|
239
|
+
return typeof t == "object" && !!t && "componentName" in t;
|
|
240
|
+
}
|
|
241
|
+
function j(e) {
|
|
242
|
+
return typeof d(e) == "function";
|
|
243
|
+
}
|
|
244
|
+
var M = class {
|
|
245
|
+
code;
|
|
246
|
+
constructor(e) {
|
|
247
|
+
this.code = e;
|
|
248
|
+
}
|
|
249
|
+
sameAs(e) {
|
|
250
|
+
return Object.getPrototypeOf(this) === Object.getPrototypeOf(e) && this.code === e.code && this.componentName === e.componentName && g(this.componentBody, e.componentBody) && g(this.componentBindings, e.componentBindings) && g(this.extraClasses, e.extraClasses);
|
|
251
|
+
}
|
|
252
|
+
get componentName() {
|
|
253
|
+
return "Comment";
|
|
254
|
+
}
|
|
255
|
+
get componentBindings() {
|
|
256
|
+
return {};
|
|
257
|
+
}
|
|
258
|
+
get componentBody() {
|
|
259
|
+
return "";
|
|
260
|
+
}
|
|
261
|
+
get extraClasses() {
|
|
262
|
+
return "";
|
|
263
|
+
}
|
|
264
|
+
}, Ce = class extends M {
|
|
265
|
+
text;
|
|
266
|
+
classes;
|
|
267
|
+
constructor(e, t = "", n) {
|
|
268
|
+
super(n), this.text = e, this.classes = t;
|
|
269
|
+
}
|
|
270
|
+
get componentName() {
|
|
271
|
+
return "template";
|
|
272
|
+
}
|
|
273
|
+
get componentBody() {
|
|
274
|
+
return this.text;
|
|
275
|
+
}
|
|
276
|
+
get extraClasses() {
|
|
277
|
+
return this.classes;
|
|
278
|
+
}
|
|
279
|
+
}, N = class extends M {
|
|
280
|
+
classes;
|
|
281
|
+
text;
|
|
282
|
+
textType;
|
|
283
|
+
constructor(e, t = "", r) {
|
|
284
|
+
super(r), this.classes = t, this.text = e, this.textType = n(() => this.getTextType);
|
|
285
|
+
}
|
|
286
|
+
get resolvedText() {
|
|
287
|
+
let e = d(this.text);
|
|
288
|
+
return j(e) ? e() : e;
|
|
289
|
+
}
|
|
290
|
+
get getTextType() {
|
|
291
|
+
let e = this.resolvedText;
|
|
292
|
+
return e ? e instanceof k ? "md" : A(e) ? "component" : "string" : "string";
|
|
293
|
+
}
|
|
294
|
+
get componentName() {
|
|
295
|
+
switch (d(this.textType)) {
|
|
296
|
+
case "string": return "template";
|
|
297
|
+
case "md": return "vue-markdown";
|
|
298
|
+
case "component": return this.resolvedText.componentName;
|
|
299
|
+
default: return "template";
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
get componentBindings() {
|
|
303
|
+
switch (d(this.textType)) {
|
|
304
|
+
case "string": return {};
|
|
305
|
+
case "md": {
|
|
306
|
+
let e = this.resolvedText;
|
|
307
|
+
return {
|
|
308
|
+
source: e.toString(),
|
|
309
|
+
options: e.options,
|
|
310
|
+
plugins: e.plugins
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
case "component": return this.resolvedText.componentProps || {};
|
|
314
|
+
default: return {};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
get componentBody() {
|
|
318
|
+
switch (d(this.textType)) {
|
|
319
|
+
case "string": return this.resolvedText;
|
|
320
|
+
case "component": return this.resolvedText.componentVHtml || "";
|
|
321
|
+
default: return "";
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
get extraClasses() {
|
|
325
|
+
return this.classes;
|
|
326
|
+
}
|
|
327
|
+
}, we = class extends N {};
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/validators/error-message-builder.ts
|
|
330
|
+
function Te(e) {
|
|
331
|
+
return be().useMarkdownInValidators ? new k(e) : e.replace(/[*_~`]/g, "").replace(/!\[(.*?)\]\(.*?\)/g, "$1").replace(/\[(.*?)\]\((.*?)\)/g, "$1").replace(/#+\s?/g, "").replace(/>\s?/g, "").replace(/(\*|-|\d+\.)\s+/g, "").replace(/`{3}[\s\S]*?`{3}/g, "").replace(/`([^`]+)`/g, "$1").replace(/\n{2,}/g, "\n");
|
|
332
|
+
}
|
|
333
|
+
function P(e) {
|
|
334
|
+
return o(e) ? n(() => Te(e.value)) : Te(e);
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/validators/translations.ts
|
|
338
|
+
var { strings: Ee, translateStrings: De } = e({
|
|
339
|
+
Required: "Please enter a value",
|
|
340
|
+
MinValue: "Value must be larger or equal to **{minValue}**",
|
|
341
|
+
MaxValue: "Value must be less than or equal to **{maxValue}**",
|
|
342
|
+
ValueInRange: "Value must be between **{minValue}** and **{maxValue}**",
|
|
343
|
+
MinLength: "Length must be larger or equal to **{minLength}**",
|
|
344
|
+
MaxLength: "Length must be less than or equal to **{maxLength}**",
|
|
345
|
+
LengthInRange: "Length must be between **{minLength}** and **{maxLength}**",
|
|
346
|
+
Pattern: "Value must match pattern \"**{pattern}**\"",
|
|
347
|
+
InAllowedValues: "Must be one of [**{allowedAsText}**]",
|
|
348
|
+
ValidationFailed: "Validation could not be completed"
|
|
2111
349
|
});
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
u((i) => {
|
|
2268
|
-
i.touch(this), this.errors.length && (this.errors = []), Object.entries(this._fields).forEach(([a, o]) => {
|
|
2269
|
-
let l;
|
|
2270
|
-
e === null ? l = null : e !== void 0 && Object.hasOwn(e, a) && (l = e[a]), this.resetChild(o, s.field(a) ?? o, l);
|
|
2271
|
-
});
|
|
2272
|
-
const r = this.value;
|
|
2273
|
-
this.raw.announcedValue = r, this.originalValue = d.baseline(r), super.validate(!0);
|
|
2274
|
-
});
|
|
2275
|
-
}
|
|
2276
|
-
get touched() {
|
|
2277
|
-
return Object.values(this._fields).some((t) => t.touched);
|
|
2278
|
-
}
|
|
2279
|
-
set touched(t) {
|
|
2280
|
-
u(() => {
|
|
2281
|
-
Object.values(this._fields).forEach((e) => {
|
|
2282
|
-
e.touched = t;
|
|
2283
|
-
});
|
|
2284
|
-
});
|
|
2285
|
-
}
|
|
2286
|
-
get fullValue() {
|
|
2287
|
-
const t = /* @__PURE__ */ Object.create(null);
|
|
2288
|
-
return Object.entries(this._fields).forEach(([e, s]) => {
|
|
2289
|
-
t[e] = s.fullValue;
|
|
2290
|
-
}), { ...t };
|
|
2291
|
-
}
|
|
2292
|
-
/**
|
|
2293
|
-
* Records that a member changed its value, so that the transaction in progress works out at commit what this
|
|
2294
|
-
* group's own value became and announces it once. A mutation method calls it itself; you rarely need to.
|
|
2295
|
-
*/
|
|
2296
|
-
notifyValueChanged() {
|
|
2297
|
-
this.propagateValueChanged();
|
|
2298
|
-
}
|
|
2299
|
-
get composesValue() {
|
|
2300
|
-
return !0;
|
|
2301
|
-
}
|
|
2302
|
-
/**
|
|
2303
|
-
* A group with nothing listening for its value does not compose one at all, so the copy it holds is from before
|
|
2304
|
-
* the changes nobody received. A registration that adds a listener brings it up to date here, and what the
|
|
2305
|
-
* listener is then told about is the change that follows it.
|
|
2306
|
-
*/
|
|
2307
|
-
refreshPreviousValue() {
|
|
2308
|
-
this.raw.announcedValue = this.value;
|
|
2309
|
-
}
|
|
2310
|
-
get valid() {
|
|
2311
|
-
return this.validRead;
|
|
2312
|
-
}
|
|
2313
|
-
composeValid() {
|
|
2314
|
-
return this.state.errors.length === 0 && this.state.fieldNames.every((t) => this._fields[t].valid);
|
|
2315
|
-
}
|
|
2316
|
-
get busy() {
|
|
2317
|
-
return this.busyRead;
|
|
2318
|
-
}
|
|
2319
|
-
composeBusy() {
|
|
2320
|
-
return this.state.fieldNames.some((t) => this._fields[t].busy);
|
|
2321
|
-
}
|
|
2322
|
-
validate(t = !1) {
|
|
2323
|
-
u(() => {
|
|
2324
|
-
t && Object.values(this._fields).forEach((e) => e.validate(!0)), super.validate(t);
|
|
2325
|
-
});
|
|
2326
|
-
}
|
|
2327
|
-
/**
|
|
2328
|
-
* States that `res` was built from the members handed to it. A subclass whose constructor takes something other
|
|
2329
|
-
* than `(fields, params)` - one that composes its own members and passes them to super - never sees them, and
|
|
2330
|
-
* would answer with a binding carrying the declaration's data instead of the record's. That is a difference no
|
|
2331
|
-
* reader would find, so it is refused here rather than returned.
|
|
2332
|
-
*/
|
|
2333
|
-
static assertTookFields(t, e, s) {
|
|
2334
|
-
const i = Object.entries(e), r = t.raw.fieldNames;
|
|
2335
|
-
if (!(i.length === r.length && i.every(([a, o]) => t._fields[a] === o)))
|
|
2336
|
-
throw new TypeError(
|
|
2337
|
-
`${s}.bind() built an element that did not take the members it was given, so the binding would carry the declaration's data. A subclass whose constructor does not take (fields, params) has to override bind() and construct itself.`
|
|
2338
|
-
);
|
|
2339
|
-
}
|
|
2340
|
-
bind(t, e) {
|
|
2341
|
-
const s = /* @__PURE__ */ Object.create(null);
|
|
2342
|
-
Object.entries(this._fields).forEach(([a, o]) => {
|
|
2343
|
-
s[a] = o.bind();
|
|
2344
|
-
});
|
|
2345
|
-
const i = this.constructor, r = new i(s, {
|
|
2346
|
-
// data is what the caller supplied, and undefined is not supplied; an explicit null is, and clears
|
|
2347
|
-
value: t !== void 0 ? t : this.value,
|
|
2348
|
-
...e && "originalValue" in e ? { originalValue: e.originalValue } : {},
|
|
2349
|
-
enabled: e?.enabled ?? this.enabled,
|
|
2350
|
-
visibility: e?.visibility ?? this.visibility
|
|
2351
|
-
});
|
|
2352
|
-
return d.assertTookFields(r, s, this.constructor.name), r.boundFrom(this, r.raw.announcedValue, r.originalValue, e), r;
|
|
2353
|
-
}
|
|
2354
|
-
/**
|
|
2355
|
-
* A record need not name every member: a key it leaves out is taken from the declaration, the same way a member
|
|
2356
|
-
* the constructor is given no value for takes the one it was declared with.
|
|
2357
|
-
*/
|
|
2358
|
-
rebind(t) {
|
|
2359
|
-
return super.rebind(t);
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
class _ extends y {
|
|
2363
|
-
get [Symbol.toStringTag]() {
|
|
2364
|
-
return "List";
|
|
2365
|
-
}
|
|
2366
|
-
get state() {
|
|
2367
|
-
return super.state;
|
|
2368
|
-
}
|
|
2369
|
-
get raw() {
|
|
2370
|
-
return super.raw;
|
|
2371
|
-
}
|
|
2372
|
-
_itemTemplate;
|
|
2373
|
-
constructor(t, e) {
|
|
2374
|
-
super(Ce()), this._itemTemplate = t, u(() => {
|
|
2375
|
-
if (e) {
|
|
2376
|
-
const { value: s, validators: i, actions: r, ...a } = e;
|
|
2377
|
-
this.registerInitialActions([...i || [], ...r || []]), this.assignParams(a), s !== void 0 ? this.setValueInternal(s) : this.originalValue !== void 0 && this.setValueInternal(this.originalValue);
|
|
2378
|
-
}
|
|
2379
|
-
this.constructed(e), this.originalValue === void 0 && (this.originalValue = _.baseline(this.value)), this.raw.announcedValue = this.value, this.boundActions?.triggerEager(this, this.value, this.originalValue), this.validate();
|
|
2380
|
-
});
|
|
2381
|
-
}
|
|
2382
|
-
/** The row array is copied as well: a rollback puts back the set the list held, not the array it went on to hold. */
|
|
2383
|
-
[k]() {
|
|
2384
|
-
const t = super[k]();
|
|
2385
|
-
return t.rows = this.raw.rows ? [...this.raw.rows] : this.raw.rows, t;
|
|
2386
|
-
}
|
|
2387
|
-
/**
|
|
2388
|
-
* The copy of a built value that serves as a baseline. The value getter hands out one array per version, and a
|
|
2389
|
-
* baseline holding that same array would report every value as its own original.
|
|
2390
|
-
*/
|
|
2391
|
-
static baseline(t) {
|
|
2392
|
-
return t == null ? t : [...t];
|
|
2393
|
-
}
|
|
2394
|
-
processSetValueItem(t) {
|
|
2395
|
-
let e;
|
|
2396
|
-
return t instanceof d ? e = t : this._itemTemplate ? e = this._itemTemplate.bind(t) : e = d.createFromFormData(t), this.takeChild(e), this.completeRecords(e), e;
|
|
2397
|
-
}
|
|
2398
|
-
/**
|
|
2399
|
-
* Builds the item that fills a gap left by an insert beyond the end of the list: the item template bound to its
|
|
2400
|
-
* own values, or an empty group when the list has no template.
|
|
2401
|
-
*/
|
|
2402
|
-
createPaddingItem() {
|
|
2403
|
-
return this.processSetValueItem(this._itemTemplate ? this._itemTemplate.bind() : null);
|
|
2404
|
-
}
|
|
2405
|
-
/** Records that the set of rows changed, so `items` rebuilds the frozen array it hands out at the next read. */
|
|
2406
|
-
rowsChanged() {
|
|
2407
|
-
this.state.rowsVersion++;
|
|
2408
|
-
}
|
|
2409
|
-
/** True where `next` is a different set of rows than `previous`: another count, or another row at a position. */
|
|
2410
|
-
static rowsDiffer(t, e) {
|
|
2411
|
-
const s = t ?? [], i = e ?? [];
|
|
2412
|
-
return s.length !== i.length || s.some((r, a) => r !== i[a]);
|
|
2413
|
-
}
|
|
2414
|
-
setValueInternal(t) {
|
|
2415
|
-
if (t != null && !Array.isArray(t))
|
|
2416
|
-
throw new TypeError("Invalid value provided: a list takes an array of rows, or null to empty it");
|
|
2417
|
-
u((e) => {
|
|
2418
|
-
e.touch(this);
|
|
2419
|
-
const s = this.raw.rows;
|
|
2420
|
-
if (t == null)
|
|
2421
|
-
this.releaseRows(), this.state.rows = null;
|
|
2422
|
-
else {
|
|
2423
|
-
const i = this.state.rows ?? [], r = new Array(t.length);
|
|
2424
|
-
for (let a = 0; a < t.length; a++) {
|
|
2425
|
-
const o = t[a], l = i[a];
|
|
2426
|
-
l && this._itemTemplate && !(o instanceof d) ? (this.resetChild(l, this._itemTemplate, o), r[a] = l) : (l && this.releaseChild(l), r[a] = this.processSetValueItem(o));
|
|
2427
|
-
}
|
|
2428
|
-
for (let a = t.length; a < i.length; a++) this.releaseChild(i[a]);
|
|
2429
|
-
this.state.rows = r;
|
|
2430
|
-
}
|
|
2431
|
-
_.rowsDiffer(s, this.raw.rows) && this.rowsChanged(), this.bumpValueVersion();
|
|
2432
|
-
});
|
|
2433
|
-
}
|
|
2434
|
-
get value() {
|
|
2435
|
-
const t = this.valueVersion;
|
|
2436
|
-
if (this.raw.cachedValueVersion === t) return this.raw.cachedValue;
|
|
2437
|
-
const e = this.state.rows?.map((i) => i.value), s = j(e) ? null : Object.freeze(e);
|
|
2438
|
-
return this.raw.cachedValue = s, this.raw.cachedValueVersion = t, s;
|
|
2439
|
-
}
|
|
2440
|
-
set value(t) {
|
|
2441
|
-
u(() => {
|
|
2442
|
-
this.setValueInternal(t), this.propagateValueChanged(!0);
|
|
2443
|
-
});
|
|
2444
|
-
}
|
|
2445
|
-
/**
|
|
2446
|
-
* The rows are taken from `source` where the caller supplied no value of its own, so a list nested in a row that
|
|
2447
|
-
* a whole-list assignment reuses ends up holding what the template gives it rather than what it held before.
|
|
2448
|
-
*/
|
|
2449
|
-
resetTo(t, e) {
|
|
2450
|
-
u((s) => {
|
|
2451
|
-
s.touch(this), this.errors.length && (this.errors = []), this.setValueInternal(e === void 0 ? t.value : e);
|
|
2452
|
-
const i = this.value;
|
|
2453
|
-
this.raw.announcedValue = i, this.originalValue = _.baseline(i), super.validate(!0);
|
|
2454
|
-
});
|
|
2455
|
-
}
|
|
2456
|
-
get touched() {
|
|
2457
|
-
return this.state.rows?.some((t) => t.touched) || !1;
|
|
2458
|
-
}
|
|
2459
|
-
set touched(t) {
|
|
2460
|
-
u(() => {
|
|
2461
|
-
this.state.rows?.forEach((e) => {
|
|
2462
|
-
e.touched = t;
|
|
2463
|
-
});
|
|
2464
|
-
});
|
|
2465
|
-
}
|
|
2466
|
-
bind(t, e) {
|
|
2467
|
-
const s = this._itemTemplate?.bind(), i = this.constructor, r = new i(s, {
|
|
2468
|
-
// data is what the caller supplied, and undefined is not supplied; an explicit null is, and clears
|
|
2469
|
-
value: [...(t !== void 0 ? t : this.value) ?? []],
|
|
2470
|
-
...e && "originalValue" in e ? { originalValue: e.originalValue } : {},
|
|
2471
|
-
enabled: e?.enabled ?? this.enabled,
|
|
2472
|
-
visibility: e?.visibility ?? this.visibility
|
|
2473
|
-
});
|
|
2474
|
-
if (r._itemTemplate !== s)
|
|
2475
|
-
throw new TypeError(
|
|
2476
|
-
`${this.constructor.name}.bind() built a list that did not take the item template it was given, so the binding would carry the declaration's rows. A subclass whose constructor does not take (itemTemplate, params) has to override bind() and construct itself.`
|
|
2477
|
-
);
|
|
2478
|
-
return r.boundFrom(this, r.value, r.originalValue, e), r;
|
|
2479
|
-
}
|
|
2480
|
-
/**
|
|
2481
|
-
* Records that a row changed its value, so that the transaction in progress works out at commit what this
|
|
2482
|
-
* list's own value became and announces it once. The mutation methods call it themselves; you rarely need to.
|
|
2483
|
-
*/
|
|
2484
|
-
notifyValueChanged() {
|
|
2485
|
-
this.propagateValueChanged();
|
|
2486
|
-
}
|
|
2487
|
-
get composesValue() {
|
|
2488
|
-
return !0;
|
|
2489
|
-
}
|
|
2490
|
-
/**
|
|
2491
|
-
* A list with nothing listening for its value does not compose one at all, so the copy it holds is from before
|
|
2492
|
-
* the changes nobody received. A registration that adds a listener brings it up to date here, and what the
|
|
2493
|
-
* listener is then told about is the change that follows it.
|
|
2494
|
-
*/
|
|
2495
|
-
refreshPreviousValue() {
|
|
2496
|
-
this.raw.announcedValue = this.value;
|
|
2497
|
-
}
|
|
2498
|
-
get valid() {
|
|
2499
|
-
return this.validRead;
|
|
2500
|
-
}
|
|
2501
|
-
composeValid() {
|
|
2502
|
-
return this.state.errors.length === 0 && (this.state.rows?.every((t) => t.valid) ?? !0);
|
|
2503
|
-
}
|
|
2504
|
-
get busy() {
|
|
2505
|
-
return this.busyRead;
|
|
2506
|
-
}
|
|
2507
|
-
composeBusy() {
|
|
2508
|
-
return this.state.rows?.some((t) => t.busy) ?? !1;
|
|
2509
|
-
}
|
|
2510
|
-
validate(t = !1) {
|
|
2511
|
-
u(() => {
|
|
2512
|
-
t && this.state.rows?.forEach((e) => e.validate(!0)), super.validate(t);
|
|
2513
|
-
});
|
|
2514
|
-
}
|
|
2515
|
-
get members() {
|
|
2516
|
-
return this.raw.rows ?? [];
|
|
2517
|
-
}
|
|
2518
|
-
/**
|
|
2519
|
-
* How many rows this list holds. The read is tracked, so a template rendering off it re-renders as rows come and
|
|
2520
|
-
* go.
|
|
2521
|
-
*/
|
|
2522
|
-
/**
|
|
2523
|
-
* Every row of this list, each one built from all of its fields. Where `value` states what the list serializes -
|
|
2524
|
-
* rows composed of the fields that are enabled, and null where the list is empty - this states what the list
|
|
2525
|
-
* holds: the disabled fields are in it too, and an empty list reads back as an empty array rather than as null.
|
|
2526
|
-
*/
|
|
2527
|
-
get fullValue() {
|
|
2528
|
-
return (this.state.rows ?? []).map((t) => t.fullValue);
|
|
2529
|
-
}
|
|
2530
|
-
get length() {
|
|
2531
|
-
return this.state.rows?.length ?? 0;
|
|
2532
|
-
}
|
|
2533
|
-
/**
|
|
2534
|
-
* The rows this list holds, oldest position first. The array is a frozen copy: it states what the list held at
|
|
2535
|
-
* the read and nothing writes back through it - `push`, `insert`, `remove` and `clear` are what change the set -
|
|
2536
|
-
* so a caller may hold on to it. The rows in it are the live elements, so reading one reports what it holds now.
|
|
2537
|
-
*
|
|
2538
|
-
* The copy is built once per change of the set and handed to every reader until the next one: a write inside a
|
|
2539
|
-
* row changes what the list serializes without changing which rows it holds, and the array a reader took stays
|
|
2540
|
-
* the same one across such a write.
|
|
2541
|
-
*/
|
|
2542
|
-
get items() {
|
|
2543
|
-
const t = this.state.rowsVersion;
|
|
2544
|
-
return this.raw.cachedItemsVersion !== t && (this.raw.cachedItems = Object.freeze([...this.raw.rows ?? []]), this.raw.cachedItemsVersion = t), this.raw.cachedItems;
|
|
2545
|
-
}
|
|
2546
|
-
get(t) {
|
|
2547
|
-
return this.state.rows != null ? this.state.rows[t] : void 0;
|
|
2548
|
-
}
|
|
2549
|
-
push(t) {
|
|
2550
|
-
return this.insert(t, this.state.rows?.length ?? 0) + 1;
|
|
2551
|
-
}
|
|
2552
|
-
pop() {
|
|
2553
|
-
return this.remove((this.state.rows?.length ?? 0) - 1);
|
|
2554
|
-
}
|
|
2555
|
-
remove(t) {
|
|
2556
|
-
let e;
|
|
2557
|
-
return u((s) => {
|
|
2558
|
-
if (this.state.rows == null || t < 0 || this.state.rows.length <= t) return;
|
|
2559
|
-
s.touch(this);
|
|
2560
|
-
const i = this.state.rows.splice(t, 1)?.[0];
|
|
2561
|
-
i && (this.releaseChild(i), this.rowsChanged(), this.bumpValueVersion(), e = i, s.recordStructural(this, { actionClass: Bt, item: e, index: t }), this.propagateValueChanged(!0));
|
|
2562
|
-
}), e;
|
|
2563
|
-
}
|
|
2564
|
-
insert(t, e) {
|
|
2565
|
-
let s = 0;
|
|
2566
|
-
return u((i) => {
|
|
2567
|
-
for (i.touch(this), this.state.rows == null && (this.state.rows = []), s = e < 0 ? Math.max(this.state.rows.length + e, 0) : e; this.state.rows.length < s; ) {
|
|
2568
|
-
const a = this.createPaddingItem(), o = this.state.rows.push(a) - 1;
|
|
2569
|
-
this.bumpValueVersion(), i.recordStructural(this, { actionClass: Y, item: a, index: o });
|
|
2570
|
-
}
|
|
2571
|
-
const r = this.processSetValueItem(t);
|
|
2572
|
-
this.state.rows.splice(s, 0, r), i.recordStructural(this, { actionClass: Y, item: r, index: s }), this.rowsChanged(), this.bumpValueVersion(), this.propagateValueChanged(!0);
|
|
2573
|
-
}), s;
|
|
2574
|
-
}
|
|
2575
|
-
/** Drops every row this list holds out of its tally, so a row that changes its verdict later is not counted. */
|
|
2576
|
-
releaseRows() {
|
|
2577
|
-
this.state.rows?.forEach((t) => this.releaseChild(t));
|
|
2578
|
-
}
|
|
2579
|
-
clear() {
|
|
2580
|
-
u((t) => {
|
|
2581
|
-
const e = (this.state.rows?.length ?? 0) > 0;
|
|
2582
|
-
t.touch(this), this.releaseRows(), this.state.rows = null, e && this.rowsChanged(), this.bumpValueVersion(), this.propagateValueChanged(e);
|
|
2583
|
-
});
|
|
2584
|
-
}
|
|
2585
|
-
}
|
|
2586
|
-
class Ie extends f {
|
|
2587
|
-
constructor(t, e, s) {
|
|
2588
|
-
const i = (r, a, o) => {
|
|
2589
|
-
this.comparisonState(o).oldValue = a;
|
|
2590
|
-
const l = this.resolve(o);
|
|
2591
|
-
return l ? (this.listenOn(l), this.isValidComparison(h(r), h(l.value)) ? null : [
|
|
2592
|
-
new g(
|
|
2593
|
-
this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, otherField: l }),
|
|
2594
|
-
"",
|
|
2595
|
-
"compare-to"
|
|
2596
|
-
)
|
|
2597
|
-
]) : (o.markRecordIncomplete(), null);
|
|
2598
|
-
};
|
|
2599
|
-
super(i), this.isValidComparison = e, this.otherField = t;
|
|
2600
|
-
}
|
|
2601
|
-
isValidComparison;
|
|
2602
|
-
otherField;
|
|
2603
|
-
/**
|
|
2604
|
-
* The fields this validator is registered on. Registration reaches one element at a time - the rows of a list
|
|
2605
|
-
* take the validator on one by one, as they are built from the item template that carries it - so this is what
|
|
2606
|
-
* says which of the fields a declaration stands for actually carry the rule, and a field that never took it on
|
|
2607
|
-
* is left alone by a change of the compared field.
|
|
2608
|
-
*/
|
|
2609
|
-
registrations = /* @__PURE__ */ new WeakSet();
|
|
2610
|
-
/**
|
|
2611
|
-
* The fields this validator has installed its listener on. A binding of such a field carries the listener too -
|
|
2612
|
-
* a binding takes on the actions of the field it was bound from - so the field it was bound from is what is
|
|
2613
|
-
* asked about as well, and a list of a thousand rows installs one listener rather than a thousand.
|
|
2614
|
-
*/
|
|
2615
|
-
listening = /* @__PURE__ */ new WeakSet();
|
|
2616
|
-
/**
|
|
2617
|
-
* What the fields this validator was registered on were declared as. One entry stands for every binding of such a
|
|
2618
|
-
* field, so a change of a compared field finds the fields of the record that change happened in without a list
|
|
2619
|
-
* of a thousand rows being held here.
|
|
2620
|
-
*/
|
|
2621
|
-
declarations = /* @__PURE__ */ new Set();
|
|
2622
|
-
/** The field `field` is compared against, within the record `field` belongs to. */
|
|
2623
|
-
resolve(t) {
|
|
2624
|
-
const e = this.otherField;
|
|
2625
|
-
return typeof e == "function" ? e(t) ?? void 0 : typeof e == "string" ? ae(e, t) : tt(e, V(t));
|
|
2626
|
-
}
|
|
2627
|
-
/**
|
|
2628
|
-
* Makes a change of `other` re-run this comparison. The listener re-runs it over the fields of the record the
|
|
2629
|
-
* change happened in rather than over the field that installed it, so the listener a row inherits with the field
|
|
2630
|
-
* it was bound from serves that row; and it re-runs this one validator, not the chain around it.
|
|
2631
|
-
*/
|
|
2632
|
-
listenOn(t) {
|
|
2633
|
-
this.listening.has(t) || this.listening.has(t.declaration) || (this.listening.add(t), t.registerAction(
|
|
2634
|
-
new P((e, s, i, r) => {
|
|
2635
|
-
s(e, i, r);
|
|
2636
|
-
const a = V(e);
|
|
2637
|
-
this.declarations.forEach(
|
|
2638
|
-
(o) => Pt(o, a).forEach((l) => {
|
|
2639
|
-
this.registrations.has(l) && this.execute(l, () => null, l.value, this.comparisonState(l).oldValue);
|
|
2640
|
-
})
|
|
2641
|
-
);
|
|
2642
|
-
})
|
|
2643
|
-
));
|
|
2644
|
-
}
|
|
2645
|
-
boundToBinding(t) {
|
|
2646
|
-
this.declarations.add(t.declaration), this.registrations.add(t);
|
|
2647
|
-
}
|
|
2648
|
-
comparisonState(t) {
|
|
2649
|
-
return this.bindingState(t);
|
|
2650
|
-
}
|
|
2651
|
-
newBindingState() {
|
|
2652
|
-
return { ...super.newBindingState(), oldValue: void 0 };
|
|
2653
|
-
}
|
|
2654
|
-
unregisterFrom(t) {
|
|
2655
|
-
super.unregisterFrom(t), this.registrations.delete(t);
|
|
2656
|
-
}
|
|
2657
|
-
}
|
|
2658
|
-
class Te extends f {
|
|
2659
|
-
constructor(t, e) {
|
|
2660
|
-
const s = e || b("Must be one of [**{allowedAsText}**]"), i = () => {
|
|
2661
|
-
const o = h(t);
|
|
2662
|
-
return typeof o == "function" ? o() : o;
|
|
2663
|
-
}, r = (o) => {
|
|
2664
|
-
const l = o.join(", ");
|
|
2665
|
-
return l.length <= 60 ? l : Xt(l, { length: 40, separator: ", ", omission: `... (${o.length} items total)` });
|
|
2666
|
-
}, a = (o, l, v) => {
|
|
2667
|
-
const p = i();
|
|
2668
|
-
return p.includes(h(o)) ? null : [
|
|
2669
|
-
new g(
|
|
2670
|
-
this.replacePlaceholders(s, {
|
|
2671
|
-
newValue: o,
|
|
2672
|
-
oldValue: l,
|
|
2673
|
-
field: v,
|
|
2674
|
-
allowedValues: p,
|
|
2675
|
-
allowedAsText: r(p)
|
|
2676
|
-
}),
|
|
2677
|
-
"",
|
|
2678
|
-
"in-allowed-values"
|
|
2679
|
-
)
|
|
2680
|
-
];
|
|
2681
|
-
};
|
|
2682
|
-
super(a);
|
|
2683
|
-
}
|
|
2684
|
-
}
|
|
2685
|
-
function Oe(n) {
|
|
2686
|
-
return n == null ? 0 : yt(n) || C(n) ? n.length : Et(n) && Object.getPrototypeOf(n) === Object.prototype ? Object.keys(n).length : String(n).length;
|
|
2687
|
-
}
|
|
2688
|
-
function wt(n) {
|
|
2689
|
-
return typeof n == "object" && n !== null && !Vt(n) && !(n instanceof String) && !("componentName" in n);
|
|
2690
|
-
}
|
|
2691
|
-
class Pe extends f {
|
|
2692
|
-
constructor(t, e) {
|
|
2693
|
-
const s = wt(t) ? void 0 : t, i = (wt(t) ? t : e)?.trim ?? !0, r = s || b("Please enter a value"), a = (o, l, v) => {
|
|
2694
|
-
const p = h(o);
|
|
2695
|
-
return Oe(i && C(p) ? p.trim() : p) === 0 ? [
|
|
2696
|
-
new g(
|
|
2697
|
-
this.replacePlaceholders(r, { newValue: o, oldValue: l, field: v }),
|
|
2698
|
-
"",
|
|
2699
|
-
"required"
|
|
2700
|
-
)
|
|
2701
|
-
] : null;
|
|
2702
|
-
};
|
|
2703
|
-
super(a);
|
|
2704
|
-
}
|
|
2705
|
-
}
|
|
2706
|
-
class ke extends f {
|
|
2707
|
-
constructor(t, e) {
|
|
2708
|
-
const s = e || b("Value must be larger or equal to **{minValue}**"), i = (r, a, o) => r < t || r === void 0 ? [
|
|
2709
|
-
new g(
|
|
2710
|
-
this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, minValue: t }),
|
|
2711
|
-
"",
|
|
2712
|
-
"min"
|
|
2713
|
-
)
|
|
2714
|
-
] : null;
|
|
2715
|
-
super(i);
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
class Re extends f {
|
|
2719
|
-
constructor(t, e) {
|
|
2720
|
-
const s = e || b("Value must be less than or equal to **{maxValue}**"), i = (r, a, o) => r > t || r === void 0 ? [
|
|
2721
|
-
new g(
|
|
2722
|
-
this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, maxValue: t }),
|
|
2723
|
-
"",
|
|
2724
|
-
"max"
|
|
2725
|
-
)
|
|
2726
|
-
] : null;
|
|
2727
|
-
super(i);
|
|
2728
|
-
}
|
|
2729
|
-
}
|
|
2730
|
-
class Fe extends f {
|
|
2731
|
-
constructor(t, e, s) {
|
|
2732
|
-
const i = s || b("Value must be between **{minValue}** and **{maxValue}**"), r = (a, o, l) => a < t || a > e || a === void 0 ? [
|
|
2733
|
-
new g(
|
|
2734
|
-
this.replacePlaceholders(i, { newValue: a, oldValue: o, field: l, minValue: t, maxValue: e }),
|
|
2735
|
-
"",
|
|
2736
|
-
"range"
|
|
2737
|
-
)
|
|
2738
|
-
] : null;
|
|
2739
|
-
super(r);
|
|
2740
|
-
}
|
|
2741
|
-
}
|
|
2742
|
-
function st(n) {
|
|
2743
|
-
return n == null ? 0 : yt(n) || C(n) ? n.length : Et(n) && Object.getPrototypeOf(n) === Object.prototype ? Object.keys(n).length : String(n).length;
|
|
2744
|
-
}
|
|
2745
|
-
class _e extends f {
|
|
2746
|
-
constructor(t, e) {
|
|
2747
|
-
const s = e || b("Length must be larger or equal to **{minLength}**"), i = (r, a, o) => st(r) < t ? [
|
|
2748
|
-
new g(
|
|
2749
|
-
this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, minLength: t }),
|
|
2750
|
-
"",
|
|
2751
|
-
"min-length"
|
|
2752
|
-
)
|
|
2753
|
-
] : null;
|
|
2754
|
-
super(i);
|
|
2755
|
-
}
|
|
2756
|
-
}
|
|
2757
|
-
class je extends f {
|
|
2758
|
-
constructor(t, e) {
|
|
2759
|
-
const s = e || b("Length must be less than or equal to **{maxLength}**"), i = (r, a, o) => st(r) > t ? [
|
|
2760
|
-
new g(
|
|
2761
|
-
this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, maxLength: t }),
|
|
2762
|
-
"",
|
|
2763
|
-
"max-length"
|
|
2764
|
-
)
|
|
2765
|
-
] : null;
|
|
2766
|
-
super(i);
|
|
2767
|
-
}
|
|
2768
|
-
}
|
|
2769
|
-
class Ne extends f {
|
|
2770
|
-
constructor(t, e, s) {
|
|
2771
|
-
const i = s || b("Length must be between **{minLength}** and **{maxLength}**"), r = (a, o, l) => {
|
|
2772
|
-
const v = st(a);
|
|
2773
|
-
return v < t || v > e ? [
|
|
2774
|
-
new g(
|
|
2775
|
-
this.replacePlaceholders(i, { newValue: a, oldValue: o, field: l, minLength: t, maxLength: e }),
|
|
2776
|
-
"",
|
|
2777
|
-
"range-length"
|
|
2778
|
-
)
|
|
2779
|
-
] : null;
|
|
2780
|
-
};
|
|
2781
|
-
super(r);
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
class Be extends f {
|
|
2785
|
-
constructor(t, e) {
|
|
2786
|
-
const s = e || b('Value must match pattern "**{pattern}**"'), i = (r, a, o) => t.test(String(h(r))) ? null : [
|
|
2787
|
-
new g(
|
|
2788
|
-
this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, pattern: t }),
|
|
2789
|
-
"",
|
|
2790
|
-
"pattern"
|
|
2791
|
-
)
|
|
2792
|
-
];
|
|
2793
|
-
super(i);
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
|
-
const De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2797
|
-
__proto__: null,
|
|
2798
|
-
CompareTo: Ie,
|
|
2799
|
-
InAllowedValues: Te,
|
|
2800
|
-
LengthInRange: Ne,
|
|
2801
|
-
MaxLength: je,
|
|
2802
|
-
MaxValue: Re,
|
|
2803
|
-
MinLength: _e,
|
|
2804
|
-
MinValue: ke,
|
|
2805
|
-
Pattern: Be,
|
|
2806
|
-
Required: Pe,
|
|
2807
|
-
Validator: f,
|
|
2808
|
-
ValueInRange: Fe
|
|
2809
|
-
}, Symbol.toStringTag, { value: "Module" })), $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2810
|
-
__proto__: null,
|
|
2811
|
-
AbortEventHandlingException: S,
|
|
2812
|
-
Action: Se,
|
|
2813
|
-
ActionsMap: x,
|
|
2814
|
-
ConditionalEnabledAction: ue,
|
|
2815
|
-
ConditionalStatementAction: U,
|
|
2816
|
-
ConditionalValueAction: ce,
|
|
2817
|
-
ConditionalVisibilityAction: le,
|
|
2818
|
-
DisplayMode: O,
|
|
2819
|
-
EnabledChangedAction: Rt,
|
|
2820
|
-
EnabledChangingAction: kt,
|
|
2821
|
-
ExecuteAction: Nt,
|
|
2822
|
-
Field: et,
|
|
2823
|
-
FieldActionBase: m,
|
|
2824
|
-
FieldBase: y,
|
|
2825
|
-
Group: d,
|
|
2826
|
-
List: _,
|
|
2827
|
-
ListItemAddedAction: Y,
|
|
2828
|
-
ListItemRemovedAction: Bt,
|
|
2829
|
-
MdString: N,
|
|
2830
|
-
MessagesWidget: xe,
|
|
2831
|
-
Operator: c,
|
|
2832
|
-
RenderableValue: se,
|
|
2833
|
-
Statement: w,
|
|
2834
|
-
ValidChangedAction: Ft,
|
|
2835
|
-
ValidationError: G,
|
|
2836
|
-
ValidationErrorRenderContent: g,
|
|
2837
|
-
ValidationErrorText: ee,
|
|
2838
|
-
Validators: De,
|
|
2839
|
-
ValueChangedAction: P,
|
|
2840
|
-
VisibilityChangedAction: jt,
|
|
2841
|
-
VisibilityChangingAction: _t,
|
|
2842
|
-
buildErrorMessage: b,
|
|
2843
|
-
defaultDisplayMode: Kt,
|
|
2844
|
-
isCallableFunction: M,
|
|
2845
|
-
isSimpleComponentDef: Z,
|
|
2846
|
-
transaction: J
|
|
2847
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
2848
|
-
export {
|
|
2849
|
-
S as AbortEventHandlingException,
|
|
2850
|
-
Se as Action,
|
|
2851
|
-
x as ActionsMap,
|
|
2852
|
-
ue as ConditionalEnabledAction,
|
|
2853
|
-
U as ConditionalStatementAction,
|
|
2854
|
-
ce as ConditionalValueAction,
|
|
2855
|
-
le as ConditionalVisibilityAction,
|
|
2856
|
-
O as DisplayMode,
|
|
2857
|
-
Rt as EnabledChangedAction,
|
|
2858
|
-
kt as EnabledChangingAction,
|
|
2859
|
-
Nt as ExecuteAction,
|
|
2860
|
-
et as Field,
|
|
2861
|
-
m as FieldActionBase,
|
|
2862
|
-
y as FieldBase,
|
|
2863
|
-
d as Group,
|
|
2864
|
-
_ as List,
|
|
2865
|
-
Y as ListItemAddedAction,
|
|
2866
|
-
Bt as ListItemRemovedAction,
|
|
2867
|
-
N as MdString,
|
|
2868
|
-
xe as MessagesWidget,
|
|
2869
|
-
c as Operator,
|
|
2870
|
-
se as RenderableValue,
|
|
2871
|
-
w as Statement,
|
|
2872
|
-
Ft as ValidChangedAction,
|
|
2873
|
-
G as ValidationError,
|
|
2874
|
-
g as ValidationErrorRenderContent,
|
|
2875
|
-
ee as ValidationErrorText,
|
|
2876
|
-
De as Validators,
|
|
2877
|
-
P as ValueChangedAction,
|
|
2878
|
-
jt as VisibilityChangedAction,
|
|
2879
|
-
_t as VisibilityChangingAction,
|
|
2880
|
-
b as buildErrorMessage,
|
|
2881
|
-
$e as default,
|
|
2882
|
-
Kt as defaultDisplayMode,
|
|
2883
|
-
Ue as forms,
|
|
2884
|
-
Gt as getConfig,
|
|
2885
|
-
M as isCallableFunction,
|
|
2886
|
-
Z as isSimpleComponentDef,
|
|
2887
|
-
te as setConfig,
|
|
2888
|
-
J as transaction
|
|
350
|
+
function F(e) {
|
|
351
|
+
return P(u(Ee, e));
|
|
352
|
+
}
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/validators/validator.ts
|
|
355
|
+
var Oe = Symbol("Validator"), ke = () => F("ValidationFailed"), I = class extends C {
|
|
356
|
+
source;
|
|
357
|
+
constructor(e) {
|
|
358
|
+
super((t, n, r, i) => {
|
|
359
|
+
let a = this.bindingState(t), o = a.abandon, s = ++a.run, ee = t.validationEpoch, c = he(), l = !1, u = () => !l && a.run === s && t.validationEpoch === ee && !c?.rolledBack, d = new AbortController(), f = () => {
|
|
360
|
+
u() || (l = !0, a.abandon === f && (a.abandon = void 0), d.abort());
|
|
361
|
+
};
|
|
362
|
+
o?.();
|
|
363
|
+
let p = e(r, i, t, d.signal) || [], m = (e) => D(() => {
|
|
364
|
+
let n = e?.map((e) => this.claim(e)) ?? [];
|
|
365
|
+
for (let e = t.errors.length - 1; e >= 0; e--) {
|
|
366
|
+
let r = t.errors[e];
|
|
367
|
+
if (r.source === this.source) {
|
|
368
|
+
let i = n.findIndex((e) => e.sameAs(r));
|
|
369
|
+
i >= 0 ? n.splice(i, 1) : t.errors.splice(e, 1);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
n.length > 0 && t.errors.push(...n), t.validate();
|
|
373
|
+
});
|
|
374
|
+
return p instanceof Promise ? (a.abandon = f, c?.whenRolledBack(f), t.beginValidating(), p.then((e) => {
|
|
375
|
+
u() && m(e);
|
|
376
|
+
}, (e) => {
|
|
377
|
+
u() && (m([new N(ke(), "", "validation-failed")]), console.error("Validation failed", e));
|
|
378
|
+
}).finally(() => {
|
|
379
|
+
a.abandon === f && (a.abandon = void 0), t.endValidating();
|
|
380
|
+
}).catch((e) => console.error("Validation failed", e))) : m(p), n(t, r, i);
|
|
381
|
+
}), this.source = Symbol(this.constructor.name);
|
|
382
|
+
}
|
|
383
|
+
claim(e) {
|
|
384
|
+
let t = e.source;
|
|
385
|
+
if (t === this.source) return e;
|
|
386
|
+
let n = {
|
|
387
|
+
value: this.source,
|
|
388
|
+
enumerable: !1,
|
|
389
|
+
configurable: !1
|
|
390
|
+
};
|
|
391
|
+
if (t === void 0) return Object.defineProperty(e, "source", n), e;
|
|
392
|
+
let r = Object.getOwnPropertyDescriptors(e);
|
|
393
|
+
return Object.create(Object.getPrototypeOf(e), {
|
|
394
|
+
...r,
|
|
395
|
+
source: n
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
static get classIdentifier() {
|
|
399
|
+
return Oe;
|
|
400
|
+
}
|
|
401
|
+
get eager() {
|
|
402
|
+
return !0;
|
|
403
|
+
}
|
|
404
|
+
unregisterFrom(e) {
|
|
405
|
+
O((t) => {
|
|
406
|
+
t.whenCommitted(() => this.abandonRun(e));
|
|
407
|
+
for (let t = e.errors.length - 1; t >= 0; t--) e.errors[t].source === this.source && e.errors.splice(t, 1);
|
|
408
|
+
e.validate();
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
abandonRun(e) {
|
|
412
|
+
this.bindingState(e).abandon?.();
|
|
413
|
+
}
|
|
414
|
+
bindingState(e) {
|
|
415
|
+
return this.state(e, () => this.newBindingState());
|
|
416
|
+
}
|
|
417
|
+
newBindingState() {
|
|
418
|
+
return { run: 0 };
|
|
419
|
+
}
|
|
420
|
+
replacePlaceholdersFunction(e, t) {
|
|
421
|
+
return () => {
|
|
422
|
+
let n = d(e);
|
|
423
|
+
for (; j(n);) n = d(this.replacePlaceholders(n(), t));
|
|
424
|
+
return n;
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
replacePlaceholders(e, n) {
|
|
428
|
+
if (j(e)) return this.replacePlaceholdersFunction(e, n);
|
|
429
|
+
if (A(e)) return e;
|
|
430
|
+
if (o(e)) return this.replacePlaceholdersFunction(() => d(e), n);
|
|
431
|
+
let r = d(e), i = t(r.toString(), n);
|
|
432
|
+
return r instanceof k ? new k(i, r.options, r.plugins) : i;
|
|
433
|
+
}
|
|
434
|
+
}, L = class e {
|
|
435
|
+
actions = [];
|
|
436
|
+
register(e, t) {
|
|
437
|
+
if (!(e instanceof x)) throw Error("Invalid action type");
|
|
438
|
+
let n = t ? this.actions.indexOf(t) : -1;
|
|
439
|
+
if (t && (t.classIdentifier !== e.classIdentifier || n < 0)) throw Error("Action to register before is not registered under the same identifier");
|
|
440
|
+
n < 0 ? this.actions.push(e) : this.actions.splice(n, 0, e);
|
|
441
|
+
}
|
|
442
|
+
unregister(e) {
|
|
443
|
+
return this.actions.includes(e) ? (this.actions = this.actions.filter((t) => t !== e), !0) : !1;
|
|
444
|
+
}
|
|
445
|
+
willTrigger(e) {
|
|
446
|
+
return this.actions.some((t) => t.classIdentifier === e);
|
|
447
|
+
}
|
|
448
|
+
get hasEager() {
|
|
449
|
+
return this.actions.some((e) => e.eager);
|
|
450
|
+
}
|
|
451
|
+
trigger(e, t, ...n) {
|
|
452
|
+
return this.run(e.classIdentifier, !1, t, n);
|
|
453
|
+
}
|
|
454
|
+
triggerEager(t, ...n) {
|
|
455
|
+
let r = this.actions;
|
|
456
|
+
for (let i = r.length - 1; i >= 0; i--) {
|
|
457
|
+
let a = r[i];
|
|
458
|
+
if (a.eager && e.outermostEager(r, i)) try {
|
|
459
|
+
let o = this.walk(r, i, a.classIdentifier, !0, t, n);
|
|
460
|
+
e.isPromise(o) && o.then(void 0, (e) => {
|
|
461
|
+
if (!(e instanceof S)) throw e;
|
|
462
|
+
});
|
|
463
|
+
} catch (e) {
|
|
464
|
+
if (!(e instanceof S)) throw e;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
triggerEagerFor(e, t, ...n) {
|
|
469
|
+
return this.run(e, !0, t, n);
|
|
470
|
+
}
|
|
471
|
+
get validators() {
|
|
472
|
+
return this.actions.filter((e) => e instanceof I);
|
|
473
|
+
}
|
|
474
|
+
bindTo(e) {
|
|
475
|
+
this.actions.forEach((t) => t.boundToBinding(e));
|
|
476
|
+
}
|
|
477
|
+
static outermostEager(e, t) {
|
|
478
|
+
let n = e[t].classIdentifier;
|
|
479
|
+
for (let r = e.length - 1; r > t; r--) if (e[r].eager && e[r].classIdentifier === n) return !1;
|
|
480
|
+
return !0;
|
|
481
|
+
}
|
|
482
|
+
static isPromise(e) {
|
|
483
|
+
return e instanceof Promise;
|
|
484
|
+
}
|
|
485
|
+
static answerAbort(t) {
|
|
486
|
+
return e.isPromise(t) ? t.then(void 0, (e) => {
|
|
487
|
+
if (e instanceof S) return e;
|
|
488
|
+
throw e;
|
|
489
|
+
}) : t;
|
|
490
|
+
}
|
|
491
|
+
run(t, n, r, i) {
|
|
492
|
+
let a = this.actions;
|
|
493
|
+
try {
|
|
494
|
+
return e.answerAbort(this.walk(a, a.length - 1, t, n, r, i));
|
|
495
|
+
} catch (e) {
|
|
496
|
+
if (e instanceof S) return e;
|
|
497
|
+
throw e;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
walk(e, t, n, r, i, a) {
|
|
501
|
+
let o = t;
|
|
502
|
+
for (; o >= 0 && (e[o].classIdentifier !== n || r && !e[o].eager);) o--;
|
|
503
|
+
return o < 0 ? null : e[o].execute(i, (t, ...i) => this.walk(e, o - 1, n, r, t, i), ...a);
|
|
504
|
+
}
|
|
2889
505
|
};
|
|
2890
|
-
//#
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/binding/resolve.ts
|
|
508
|
+
function R(e) {
|
|
509
|
+
let t = e;
|
|
510
|
+
for (; t.fieldName !== void 0 && t.parent;) t = t.parent;
|
|
511
|
+
return t;
|
|
512
|
+
}
|
|
513
|
+
function Ae(e, t) {
|
|
514
|
+
let n = e;
|
|
515
|
+
for (let e of je(t)) if (n = n.field?.(e) ?? void 0, !n) return;
|
|
516
|
+
return n?.declaration === t ? n : void 0;
|
|
517
|
+
}
|
|
518
|
+
function je(e) {
|
|
519
|
+
let t = [], n = e;
|
|
520
|
+
for (; n.fieldName !== void 0 && n.parent;) t.unshift(n.fieldName), n = n.parent;
|
|
521
|
+
return t;
|
|
522
|
+
}
|
|
523
|
+
function Me(e, t) {
|
|
524
|
+
let n = Ae(t, e);
|
|
525
|
+
if (n) return n;
|
|
526
|
+
let r = t.parent;
|
|
527
|
+
for (; r;) {
|
|
528
|
+
let t = Ae(R(r), e);
|
|
529
|
+
if (t) return t;
|
|
530
|
+
r = r.parent;
|
|
531
|
+
}
|
|
532
|
+
return R(e) === R(t.declaration) ? void 0 : e;
|
|
533
|
+
}
|
|
534
|
+
function Ne(e, t) {
|
|
535
|
+
let n = Me(e, t);
|
|
536
|
+
if (!n) return [];
|
|
537
|
+
if (n !== e) return [n];
|
|
538
|
+
let r = t.bindingsOf(e);
|
|
539
|
+
return r.length > 0 ? r : [e];
|
|
540
|
+
}
|
|
541
|
+
function Pe(e, t) {
|
|
542
|
+
let n = t.parent;
|
|
543
|
+
for (; n;) {
|
|
544
|
+
let t = n.field?.(e);
|
|
545
|
+
if (t) return t;
|
|
546
|
+
n = n.parent;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/actions/conditional/conditional-statement-action.ts
|
|
551
|
+
var Fe = Symbol("ConditionalStatementAction"), z = class extends C {
|
|
552
|
+
statement;
|
|
553
|
+
conditionalExecutor;
|
|
554
|
+
declarations = /* @__PURE__ */ new Set();
|
|
555
|
+
registrations = /* @__PURE__ */ new WeakSet();
|
|
556
|
+
constructor(e, t) {
|
|
557
|
+
super((e, t, n, r) => (this.applyIn(R(e)) || e.markRecordIncomplete(), t(e, n, r))), this.statement = e, this.conditionalExecutor = t;
|
|
558
|
+
let n = new C((e, t, ...n) => (this.applyFrom(e), t(e, ...n)));
|
|
559
|
+
e.collectFields().forEach((e) => e.registerAction(n));
|
|
560
|
+
}
|
|
561
|
+
static get classIdentifier() {
|
|
562
|
+
return Fe;
|
|
563
|
+
}
|
|
564
|
+
get eager() {
|
|
565
|
+
return !0;
|
|
566
|
+
}
|
|
567
|
+
boundToBinding(e) {
|
|
568
|
+
this.declarations.add(e.declaration), this.registrations.add(e);
|
|
569
|
+
}
|
|
570
|
+
unregisterFrom(e) {
|
|
571
|
+
this.registrations.delete(e);
|
|
572
|
+
}
|
|
573
|
+
targetsIn(e) {
|
|
574
|
+
let t = [];
|
|
575
|
+
return this.declarations.forEach((n) => Ne(n, e).forEach((e) => {
|
|
576
|
+
this.registrations.has(e) && t.push(e);
|
|
577
|
+
})), t;
|
|
578
|
+
}
|
|
579
|
+
applyIn(e) {
|
|
580
|
+
let t = this.targetsIn(e);
|
|
581
|
+
if (t.length === 0) return !1;
|
|
582
|
+
let n = this.state(e, () => ({ lastResult: void 0 })), r = this.statement.evaluate(e);
|
|
583
|
+
if (r === n.lastResult) return !0;
|
|
584
|
+
let i = n.lastResult;
|
|
585
|
+
return n.lastResult = r, t.forEach((e) => this.conditionalExecutor(e, r, i)), !0;
|
|
586
|
+
}
|
|
587
|
+
applyFrom(e) {
|
|
588
|
+
let t = /* @__PURE__ */ new Set();
|
|
589
|
+
this.targetsIn(R(e)).forEach((e) => t.add(R(e))), t.forEach((e) => this.applyIn(e));
|
|
590
|
+
}
|
|
591
|
+
}, Ie = class extends z {
|
|
592
|
+
constructor(e) {
|
|
593
|
+
super(e, (e, t) => {
|
|
594
|
+
e.visibility = t ? b.FULL : b.SUPPRESS;
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
}, Le = class extends z {
|
|
598
|
+
constructor(e) {
|
|
599
|
+
super(e, (e, t) => {
|
|
600
|
+
e.enabled = t;
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}, Re = class extends z {
|
|
604
|
+
constructor(e, t) {
|
|
605
|
+
super(e, (e, n) => {
|
|
606
|
+
n && (e.value = t);
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}, B = /* @__PURE__ */ function(e) {
|
|
610
|
+
return e[e.NOT = 0] = "NOT", e[e.OR = 1] = "OR", e[e.AND = 2] = "AND", e[e.XOR = 3] = "XOR", e[e.NAND = 4] = "NAND", e[e.NOR = 5] = "NOR", e[e.EQUALS = -1] = "EQUALS", e[e.NOT_EQUALS = -2] = "NOT_EQUALS", e[e.GT = -3] = "GT", e[e.LT = -4] = "LT", e[e.GE = -5] = "GE", e[e.LE = -6] = "LE", e[e.IN = -7] = "IN", e[e.NOT_IN = -8] = "NOT_IN", e[e.INCLUDES = -9] = "INCLUDES", e[e.NOT_INCLUDES = -10] = "NOT_INCLUDES", e;
|
|
611
|
+
}(B || {});
|
|
612
|
+
(function(e) {
|
|
613
|
+
function t(e) {
|
|
614
|
+
let t = e.toLowerCase();
|
|
615
|
+
if (t === "not") return 0;
|
|
616
|
+
if (t === "or") return 1;
|
|
617
|
+
if (t === "and") return 2;
|
|
618
|
+
if (t === "xor") return 3;
|
|
619
|
+
if (t === "nand") return 4;
|
|
620
|
+
if (t === "nor") return 5;
|
|
621
|
+
if (t === "equals") return -1;
|
|
622
|
+
if ([
|
|
623
|
+
"not_equals",
|
|
624
|
+
"not-equals",
|
|
625
|
+
"not equals"
|
|
626
|
+
].includes(t)) return -2;
|
|
627
|
+
if (t === "gt") return -3;
|
|
628
|
+
if (t === "lt") return -4;
|
|
629
|
+
if (t === "ge") return -5;
|
|
630
|
+
if (t === "le") return -6;
|
|
631
|
+
if (t === "in") return -7;
|
|
632
|
+
if ([
|
|
633
|
+
"not_in",
|
|
634
|
+
"not-in",
|
|
635
|
+
"not in"
|
|
636
|
+
].includes(t)) return -8;
|
|
637
|
+
if (t === "includes") return -9;
|
|
638
|
+
if ([
|
|
639
|
+
"not_includes",
|
|
640
|
+
"not-includes",
|
|
641
|
+
"not includes"
|
|
642
|
+
].includes(t)) return -10;
|
|
643
|
+
throw Error(`Unrecognised operator ${t}`);
|
|
644
|
+
}
|
|
645
|
+
e.fromString = t;
|
|
646
|
+
function n(e) {
|
|
647
|
+
let t = typeof e == "number" ? e : B.fromString(e);
|
|
648
|
+
if (Object.values(B).includes(t)) return t;
|
|
649
|
+
throw Error(`Unrecognised operator ${e}`);
|
|
650
|
+
}
|
|
651
|
+
e.fromAny = n;
|
|
652
|
+
function r(e) {
|
|
653
|
+
let t = typeof e == "number" ? e : B.fromString(e);
|
|
654
|
+
return Object.values(B).includes(t);
|
|
655
|
+
}
|
|
656
|
+
e.isDefined = r;
|
|
657
|
+
function i(e) {
|
|
658
|
+
return e >= 0;
|
|
659
|
+
}
|
|
660
|
+
e.isLogicOperator = i;
|
|
661
|
+
})(B ||= {}), Object.freeze(B);
|
|
662
|
+
var V = B, ze = Symbol("EnabledChangingAction"), H = class extends x {
|
|
663
|
+
constructor(e) {
|
|
664
|
+
super(e);
|
|
665
|
+
}
|
|
666
|
+
static get classIdentifier() {
|
|
667
|
+
return ze;
|
|
668
|
+
}
|
|
669
|
+
execute(e, t, n, r) {
|
|
670
|
+
return super.execute(e, t, n, r);
|
|
671
|
+
}
|
|
672
|
+
}, Be = Symbol("EnabledChangedAction"), U = class extends x {
|
|
673
|
+
constructor(e) {
|
|
674
|
+
super(e);
|
|
675
|
+
}
|
|
676
|
+
static get classIdentifier() {
|
|
677
|
+
return Be;
|
|
678
|
+
}
|
|
679
|
+
execute(e, t, n, r) {
|
|
680
|
+
return super.execute(e, t, n, r);
|
|
681
|
+
}
|
|
682
|
+
}, Ve = Symbol("ValidChangedAction"), W = class extends x {
|
|
683
|
+
constructor(e) {
|
|
684
|
+
super(e);
|
|
685
|
+
}
|
|
686
|
+
static get classIdentifier() {
|
|
687
|
+
return Ve;
|
|
688
|
+
}
|
|
689
|
+
execute(e, t, n, r) {
|
|
690
|
+
return super.execute(e, t, n, r);
|
|
691
|
+
}
|
|
692
|
+
}, He = Symbol("VisibilityChangingAction"), G = class extends x {
|
|
693
|
+
constructor(e) {
|
|
694
|
+
super(e);
|
|
695
|
+
}
|
|
696
|
+
static get classIdentifier() {
|
|
697
|
+
return He;
|
|
698
|
+
}
|
|
699
|
+
execute(e, t, n, r) {
|
|
700
|
+
return super.execute(e, t, n, r);
|
|
701
|
+
}
|
|
702
|
+
}, Ue = Symbol("VisibilityChangedAction"), K = class extends x {
|
|
703
|
+
constructor(e) {
|
|
704
|
+
super(e);
|
|
705
|
+
}
|
|
706
|
+
static get classIdentifier() {
|
|
707
|
+
return Ue;
|
|
708
|
+
}
|
|
709
|
+
execute(e, t, n, r) {
|
|
710
|
+
return super.execute(e, t, n, r);
|
|
711
|
+
}
|
|
712
|
+
}, We = /* @__PURE__ */ new WeakMap(), Ge = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), Ke = /* @__PURE__ */ new Set(["validators", "actions"]), J = 0, Y = class {
|
|
713
|
+
get __v_skip() {
|
|
714
|
+
return !0;
|
|
715
|
+
}
|
|
716
|
+
get __v_isReactive() {
|
|
717
|
+
return !0;
|
|
718
|
+
}
|
|
719
|
+
get [Symbol.toStringTag]() {
|
|
720
|
+
return "FormElement";
|
|
721
|
+
}
|
|
722
|
+
#e;
|
|
723
|
+
#t;
|
|
724
|
+
constructor(e) {
|
|
725
|
+
this.#t = e, this.#e = ee(e);
|
|
726
|
+
}
|
|
727
|
+
get state() {
|
|
728
|
+
return this.#e;
|
|
729
|
+
}
|
|
730
|
+
get raw() {
|
|
731
|
+
return this.#t;
|
|
732
|
+
}
|
|
733
|
+
rebind(e) {
|
|
734
|
+
return O((t) => {
|
|
735
|
+
t.touch(this);
|
|
736
|
+
let n = t.willAnnounceValue(this), r = this.#t.announcedValue;
|
|
737
|
+
this.resetTo(this.declaration, e), this.#t.announcedValue = n ? r : this.value;
|
|
738
|
+
}), this;
|
|
739
|
+
}
|
|
740
|
+
get originalValue() {
|
|
741
|
+
return this.#e.originalValue;
|
|
742
|
+
}
|
|
743
|
+
set originalValue(e) {
|
|
744
|
+
this.touchState(), this.#e.originalValue = e;
|
|
745
|
+
}
|
|
746
|
+
get extra() {
|
|
747
|
+
return this.#e.extra;
|
|
748
|
+
}
|
|
749
|
+
setExtendedValues(e) {
|
|
750
|
+
this.touchState(), this.#e.extra = Object.freeze({
|
|
751
|
+
...this.#t.extra,
|
|
752
|
+
...e
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
extendedOf(e) {
|
|
756
|
+
let t = Object.create(null);
|
|
757
|
+
return Object.entries(e).forEach(([e, n]) => {
|
|
758
|
+
Ke.has(e) || (!(e in this) || Object.hasOwn(Object.prototype, e)) && (t[e] = n);
|
|
759
|
+
}), t;
|
|
760
|
+
}
|
|
761
|
+
assignParams(e) {
|
|
762
|
+
let t = this.extendedOf(e);
|
|
763
|
+
Object.entries(e).forEach(([e, n]) => {
|
|
764
|
+
Object.hasOwn(t, e) || Ke.has(e) || (this[e] = n);
|
|
765
|
+
}), h(t) || this.setExtendedValues(t);
|
|
766
|
+
}
|
|
767
|
+
touchState() {
|
|
768
|
+
he()?.touch(this);
|
|
769
|
+
}
|
|
770
|
+
[w]() {
|
|
771
|
+
return {
|
|
772
|
+
...this.#t,
|
|
773
|
+
errors: [...this.#t.errors]
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
[le](e) {
|
|
777
|
+
let t = this.#t.validatingCount, n = this.#t.validatingChildren;
|
|
778
|
+
Object.assign(this.#e, e), this.#e.validatingCount = t, this.#e.validatingChildren = n;
|
|
779
|
+
}
|
|
780
|
+
get validating() {
|
|
781
|
+
return this.#e.validatingCount > 0 || this.#e.validatingChildren > 0;
|
|
782
|
+
}
|
|
783
|
+
beginValidating() {
|
|
784
|
+
let e = !this.validating;
|
|
785
|
+
this.#e.validatingCount++, e && this.container?.childValidatingChanged(!0);
|
|
786
|
+
}
|
|
787
|
+
endValidating() {
|
|
788
|
+
this.#t.validatingCount !== 0 && (this.#e.validatingCount--, this.validating || this.container?.childValidatingChanged(!1));
|
|
789
|
+
}
|
|
790
|
+
childValidatingChanged(e) {
|
|
791
|
+
let t = this.validating;
|
|
792
|
+
this.#e.validatingChildren += e ? 1 : -1, this.validating !== t && this.container?.childValidatingChanged(e);
|
|
793
|
+
}
|
|
794
|
+
get busy() {
|
|
795
|
+
return !1;
|
|
796
|
+
}
|
|
797
|
+
get busyRead() {
|
|
798
|
+
let e = Ge.get(this);
|
|
799
|
+
return e || (e = n(() => this.composeBusy()), Ge.set(this, e)), e.value;
|
|
800
|
+
}
|
|
801
|
+
composeBusy() {
|
|
802
|
+
return !1;
|
|
803
|
+
}
|
|
804
|
+
settled() {
|
|
805
|
+
return !this.validating && !this.busy ? Promise.resolve() : new Promise((e) => {
|
|
806
|
+
let t = f(() => this.validating || this.busy, (n) => {
|
|
807
|
+
n || (t(), e());
|
|
808
|
+
}, { flush: "sync" });
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
get errors() {
|
|
812
|
+
return this.touchState(), this.#e.errors;
|
|
813
|
+
}
|
|
814
|
+
set errors(e) {
|
|
815
|
+
this.touchState(), this.#e.errors = e;
|
|
816
|
+
}
|
|
817
|
+
get parent() {
|
|
818
|
+
return this.#e.parent;
|
|
819
|
+
}
|
|
820
|
+
get container() {
|
|
821
|
+
return this.#e.parent;
|
|
822
|
+
}
|
|
823
|
+
get fieldName() {
|
|
824
|
+
return this.#e.fieldName;
|
|
825
|
+
}
|
|
826
|
+
get declaration() {
|
|
827
|
+
return this.#t.declaration ?? this;
|
|
828
|
+
}
|
|
829
|
+
get members() {
|
|
830
|
+
return [];
|
|
831
|
+
}
|
|
832
|
+
bindingsOf(e) {
|
|
833
|
+
let t = e.declaration, n = [], r = (e) => {
|
|
834
|
+
e.declaration === t && n.push(e), e.members.forEach(r);
|
|
835
|
+
};
|
|
836
|
+
return r(this), n;
|
|
837
|
+
}
|
|
838
|
+
markRecordIncomplete() {
|
|
839
|
+
this._recordPending || (this._recordPending = !0, J++);
|
|
840
|
+
}
|
|
841
|
+
completeRecords(e = this) {
|
|
842
|
+
J !== 0 && O(() => {
|
|
843
|
+
let t = (e) => {
|
|
844
|
+
e._recordPending && (e._recordPending = !1, J--, e.rerunEagerActions()), e.members.forEach(t);
|
|
845
|
+
};
|
|
846
|
+
t(e);
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
rerunEagerActions() {
|
|
850
|
+
O((e) => {
|
|
851
|
+
this.boundActions?.triggerEager(this, this.value, this.value), e.markValidityDirty(this);
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
get boundActions() {
|
|
855
|
+
return this._actions;
|
|
856
|
+
}
|
|
857
|
+
noteBinding(e) {
|
|
858
|
+
let t = q.get(this);
|
|
859
|
+
t || (t = /* @__PURE__ */ new Set(), q.set(this, t)), t.add(new WeakRef(e));
|
|
860
|
+
}
|
|
861
|
+
get boundElements() {
|
|
862
|
+
let e = this.declaration, t = q.get(e), n = [e];
|
|
863
|
+
return t && t.forEach((e) => {
|
|
864
|
+
let r = e.deref();
|
|
865
|
+
r ? n.push(r) : t.delete(e);
|
|
866
|
+
}), n;
|
|
867
|
+
}
|
|
868
|
+
get actions() {
|
|
869
|
+
let e = this.declaration;
|
|
870
|
+
if (!e._actions) {
|
|
871
|
+
let t = new L();
|
|
872
|
+
e.boundElements.forEach((e) => {
|
|
873
|
+
e._actions = t;
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
return e._actions;
|
|
877
|
+
}
|
|
878
|
+
get valueVersion() {
|
|
879
|
+
return this.#e.valueVersion;
|
|
880
|
+
}
|
|
881
|
+
bumpValueVersion() {
|
|
882
|
+
O((e) => {
|
|
883
|
+
e.touch(this), this.#e.valueVersion++;
|
|
884
|
+
let t = this.parent;
|
|
885
|
+
for (; t;) e.touch(t), t.#e.valueVersion++, t = t.parent;
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
propagateValueChanged(e = !1) {
|
|
889
|
+
O((t) => {
|
|
890
|
+
t.markValueChanged(this, e), t.markValidityDirty(this), this.parent?.notifyValueChanged();
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
constructed(e) {}
|
|
894
|
+
refreshPreviousValue() {}
|
|
895
|
+
get countedValid() {
|
|
896
|
+
return this.#t.errors.length === 0 && this.#t.invalidChildren === 0;
|
|
897
|
+
}
|
|
898
|
+
takeChild(e, t) {
|
|
899
|
+
O((n) => {
|
|
900
|
+
if (e.parent) throw TypeError("This element already belongs to a container - pass a bind() of it");
|
|
901
|
+
n.touch(e), e.#e.fieldName = t, e.#e.parent = this, this.adoptChild(e);
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
adoptChild(e) {
|
|
905
|
+
O((t) => {
|
|
906
|
+
t.touch(this), e.#t.valid || this.#t.invalidChildren++, e.validating && this.childValidatingChanged(!0), t.whenRolledBack(() => {
|
|
907
|
+
e.validating && this.childValidatingChanged(!1);
|
|
908
|
+
}), t.markValidityDirty(this);
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
releaseChild(e) {
|
|
912
|
+
O((t) => {
|
|
913
|
+
t.touch(this), t.touch(e), e.#t.valid || this.#t.invalidChildren--, e.validating && this.childValidatingChanged(!1), t.whenRolledBack(() => {
|
|
914
|
+
e.validating && this.childValidatingChanged(!0);
|
|
915
|
+
}), e.#e.parent = void 0, e.#e.fieldName = void 0, t.markValidityDirty(this);
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
resetTo(e, t) {
|
|
919
|
+
O(() => {
|
|
920
|
+
let n = t === void 0 ? e.value : t, r = this.errors.length > 0;
|
|
921
|
+
r && (this.errors = []), this.touched = !1;
|
|
922
|
+
let i = this.enabled && this.value !== n;
|
|
923
|
+
this.value = n, this.originalValue = this.value, this.validate(!i && r);
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
resetChild(e, t, n) {
|
|
927
|
+
e.resetTo(t, n);
|
|
928
|
+
}
|
|
929
|
+
childValidityChanged(e) {
|
|
930
|
+
this.#t.invalidChildren += e ? -1 : 1;
|
|
931
|
+
}
|
|
932
|
+
get validRead() {
|
|
933
|
+
let e = We.get(this);
|
|
934
|
+
return e || (e = n(() => this.composeValid()), We.set(this, e)), e.value;
|
|
935
|
+
}
|
|
936
|
+
composeValid() {
|
|
937
|
+
return this.#e.errors.length === 0;
|
|
938
|
+
}
|
|
939
|
+
get visibility() {
|
|
940
|
+
return this.#e.visibility;
|
|
941
|
+
}
|
|
942
|
+
set visibility(e) {
|
|
943
|
+
let t = this.#e.visibility;
|
|
944
|
+
e !== t && O((n) => {
|
|
945
|
+
let r = this.boundActions?.trigger(G, this, e, t);
|
|
946
|
+
if (!(r instanceof S)) {
|
|
947
|
+
if (!b.isDefined(r ?? e)) throw Error("visibility must be a DisplayMode constant");
|
|
948
|
+
n.touch(this), this.#e.visibility = b.fromAny(r ?? e), this.boundActions?.trigger(K, this, this.#e.visibility, t);
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
get enabled() {
|
|
953
|
+
return this.#e.enabled;
|
|
954
|
+
}
|
|
955
|
+
set enabled(e) {
|
|
956
|
+
let t = this.#e.enabled;
|
|
957
|
+
e !== t && O((n) => {
|
|
958
|
+
let r = this.boundActions?.trigger(H, this, e, t);
|
|
959
|
+
if (!(r instanceof S)) {
|
|
960
|
+
if (!m(r ?? e)) throw Error("Enabled value must be boolean");
|
|
961
|
+
n.touch(this), this.#e.enabled = r ?? e, this.#e.enabled !== t && this.bumpValueVersion(), this.boundActions?.trigger(U, this, this.#e.enabled, t);
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
get effectiveEnabled() {
|
|
966
|
+
return this.enabled && (this.parent?.effectiveEnabled ?? !0);
|
|
967
|
+
}
|
|
968
|
+
get composesValue() {
|
|
969
|
+
return !1;
|
|
970
|
+
}
|
|
971
|
+
childComposesValue(e) {
|
|
972
|
+
return e.composesValue;
|
|
973
|
+
}
|
|
974
|
+
[ue](e, t, n, r) {
|
|
975
|
+
if (r?.forEach((e) => this.boundActions?.trigger(e.actionClass, this, e.item, e.index)), !t) return;
|
|
976
|
+
let i = this.boundActions;
|
|
977
|
+
if (this.composesValue && !(i?.willTrigger(ce) || i?.hasEager)) return;
|
|
978
|
+
let a = this.value, o = this.#t.announcedValue;
|
|
979
|
+
!n && (this.composesValue ? g(a, o) : a === o) || (e.touch(this), this.#t.announcedValue = a, this.composesValue && i?.triggerEager(this, a, o), i?.trigger(C, this, a, o));
|
|
980
|
+
}
|
|
981
|
+
[de](e) {
|
|
982
|
+
let t = this.#t.valid, n = this.countedValid;
|
|
983
|
+
if (n === t) return;
|
|
984
|
+
e.touch(this), this.#t.valid = n;
|
|
985
|
+
let r = this.container;
|
|
986
|
+
r && (e.touch(r), r.childValidityChanged(n), e.markValidityDirty(r)), this.boundActions?.trigger(W, this, n, t);
|
|
987
|
+
}
|
|
988
|
+
validate(e = !1) {
|
|
989
|
+
O((t) => {
|
|
990
|
+
e && this.boundActions?.triggerEager(this, this.value, this.value), t.markValidityDirty(this);
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
get valid() {
|
|
994
|
+
return this.#e.errors.length === 0;
|
|
995
|
+
}
|
|
996
|
+
get fullValue() {
|
|
997
|
+
return this.value;
|
|
998
|
+
}
|
|
999
|
+
get isChanged() {
|
|
1000
|
+
return !g(this.value, this.originalValue);
|
|
1001
|
+
}
|
|
1002
|
+
boundFrom(e, t, n, r) {
|
|
1003
|
+
this.#t.declaration = e.declaration;
|
|
1004
|
+
let i = {
|
|
1005
|
+
...e.extra,
|
|
1006
|
+
...r && this.extendedOf(r)
|
|
1007
|
+
};
|
|
1008
|
+
h(i) || this.setExtendedValues(i);
|
|
1009
|
+
let a = this.declaration;
|
|
1010
|
+
a.noteBinding(this);
|
|
1011
|
+
let o = a._actions;
|
|
1012
|
+
o && (this._actions = o, o.bindTo(this), o.triggerEager(this, t, n));
|
|
1013
|
+
}
|
|
1014
|
+
registerInitialActions(e) {
|
|
1015
|
+
e.forEach((e) => {
|
|
1016
|
+
this.actions.register(e), e.boundToBinding(this);
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
registerAction(e) {
|
|
1020
|
+
return O((t) => {
|
|
1021
|
+
t.willAnnounceValue(this) || this.refreshPreviousValue(), this.actions.register(e), this.registered(t, e);
|
|
1022
|
+
}), this;
|
|
1023
|
+
}
|
|
1024
|
+
registerActionBefore(e, t) {
|
|
1025
|
+
return O((n) => {
|
|
1026
|
+
n.willAnnounceValue(this) || this.refreshPreviousValue(), this.actions.register(e, t), this.registered(n, e);
|
|
1027
|
+
}), this;
|
|
1028
|
+
}
|
|
1029
|
+
unregisterAction(e) {
|
|
1030
|
+
let t = !1;
|
|
1031
|
+
return O((n) => {
|
|
1032
|
+
let r = this.boundActions;
|
|
1033
|
+
if (!r || (t = r.unregister(e), !t)) return;
|
|
1034
|
+
n.touch(this), e instanceof I && this.#e.validationEpoch++;
|
|
1035
|
+
let i = this.boundElements;
|
|
1036
|
+
n.whenRolledBack(() => {
|
|
1037
|
+
r.register(e), i.forEach((t) => e.boundToBinding(t));
|
|
1038
|
+
}), i.forEach((t) => e.unregisterFrom(t));
|
|
1039
|
+
}), t;
|
|
1040
|
+
}
|
|
1041
|
+
registered(e, t) {
|
|
1042
|
+
let n = this.boundElements;
|
|
1043
|
+
n.forEach((e) => {
|
|
1044
|
+
t.boundToBinding(e), t.eager && this.actions.triggerEagerFor(t.classIdentifier, e, e.value, e.originalValue);
|
|
1045
|
+
}), e.whenRolledBack(() => {
|
|
1046
|
+
this.boundActions?.unregister(t) && n.forEach((e) => t.unregisterFrom(e));
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
triggerAction(e, ...t) {
|
|
1050
|
+
let n = this.boundActions;
|
|
1051
|
+
return n ? n.trigger(e, this, ...t) : null;
|
|
1052
|
+
}
|
|
1053
|
+
get validationEpoch() {
|
|
1054
|
+
return this.#e.validationEpoch;
|
|
1055
|
+
}
|
|
1056
|
+
clearValidators() {
|
|
1057
|
+
O((e) => {
|
|
1058
|
+
e.touch(this), this.#e.validationEpoch++;
|
|
1059
|
+
let t = this.boundActions;
|
|
1060
|
+
if (t) {
|
|
1061
|
+
let n = this.boundElements;
|
|
1062
|
+
t.validators.forEach((r) => {
|
|
1063
|
+
t.unregister(r), e.whenRolledBack(() => {
|
|
1064
|
+
t.register(r), n.forEach((e) => r.boundToBinding(e));
|
|
1065
|
+
}), n.forEach((e) => r.unregisterFrom(e));
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
this.errors = [], this.validate();
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region src/actions/conditional/statement.ts
|
|
1074
|
+
function qe(e, t) {
|
|
1075
|
+
return e ? !t : t;
|
|
1076
|
+
}
|
|
1077
|
+
var Je = class e {
|
|
1078
|
+
operand1;
|
|
1079
|
+
operator;
|
|
1080
|
+
operand2;
|
|
1081
|
+
static validateOperand(e, t) {
|
|
1082
|
+
if (e === void 0) throw TypeError(`Statement operand ${t} is undefined: an operand is a field, a nested statement or a literal, and a name resolving to nothing is none of them. Compare against null to test for an unset value.`);
|
|
1083
|
+
if (typeof e == "function") throw TypeError(`Statement operand ${t} is a function: an operand is a field, a nested statement or a literal, and a function is none of them. An accessor states the field it answers with: group.field('name').`);
|
|
1084
|
+
}
|
|
1085
|
+
constructor(t, n, r) {
|
|
1086
|
+
e.validateOperand(t, 1), n !== V.NOT && e.validateOperand(r, 2), this.operand1 = t, this.operator = n, this.operand2 = r;
|
|
1087
|
+
}
|
|
1088
|
+
static valueOf(t, n) {
|
|
1089
|
+
if (t instanceof e) return t.evaluate(n);
|
|
1090
|
+
if (t instanceof Y) {
|
|
1091
|
+
let e = n ? Me(t, n) : t;
|
|
1092
|
+
return e ? d(e.value) : void 0;
|
|
1093
|
+
}
|
|
1094
|
+
return t;
|
|
1095
|
+
}
|
|
1096
|
+
get operand1Value() {
|
|
1097
|
+
return e.valueOf(this.operand1);
|
|
1098
|
+
}
|
|
1099
|
+
get operand2Value() {
|
|
1100
|
+
return e.valueOf(this.operand2);
|
|
1101
|
+
}
|
|
1102
|
+
evaluate(t) {
|
|
1103
|
+
let n = e.valueOf(this.operand1, t), r = e.valueOf(this.operand2, t);
|
|
1104
|
+
switch (this.operator) {
|
|
1105
|
+
case V.AND: return !!(n && r);
|
|
1106
|
+
case V.OR: return !!(n || r);
|
|
1107
|
+
case V.NAND: return !(n && r);
|
|
1108
|
+
case V.NOR: return !(n || r);
|
|
1109
|
+
case V.XOR: return qe(!!n, !!r);
|
|
1110
|
+
case V.NOT: return !n;
|
|
1111
|
+
case V.EQUALS: return n == r;
|
|
1112
|
+
case V.NOT_EQUALS: return n != r;
|
|
1113
|
+
case V.LT: return n < r;
|
|
1114
|
+
case V.LE: return n <= r;
|
|
1115
|
+
case V.GE: return n >= r;
|
|
1116
|
+
case V.GT: return n > r;
|
|
1117
|
+
case V.IN: return !!r?.includes?.(n);
|
|
1118
|
+
case V.NOT_IN: return !r?.includes?.(n);
|
|
1119
|
+
case V.INCLUDES: return _(n) && _(r) && n.indexOf(r) >= 0;
|
|
1120
|
+
case V.NOT_INCLUDES: return !(_(n) && _(r) && n.indexOf(r) >= 0);
|
|
1121
|
+
default: throw Error(`Operator not implemented ${this.operator}`);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
collectFields() {
|
|
1125
|
+
let t = /* @__PURE__ */ new Set();
|
|
1126
|
+
function n(n) {
|
|
1127
|
+
n instanceof Y ? t.add(n) : n instanceof e && n.collectFields().forEach((e) => t.add(e));
|
|
1128
|
+
}
|
|
1129
|
+
return n(this.operand1), n(this.operand2), t;
|
|
1130
|
+
}
|
|
1131
|
+
}, Ye = Symbol("ExecuteAction"), X = class extends x {
|
|
1132
|
+
constructor(e) {
|
|
1133
|
+
super(e);
|
|
1134
|
+
}
|
|
1135
|
+
static get classIdentifier() {
|
|
1136
|
+
return Ye;
|
|
1137
|
+
}
|
|
1138
|
+
execute(e, t, n) {
|
|
1139
|
+
return super.execute(e, t, n);
|
|
1140
|
+
}
|
|
1141
|
+
}, Xe = Symbol("ListItemAddedAction"), Z = class extends x {
|
|
1142
|
+
constructor(e) {
|
|
1143
|
+
super(e);
|
|
1144
|
+
}
|
|
1145
|
+
static get classIdentifier() {
|
|
1146
|
+
return Xe;
|
|
1147
|
+
}
|
|
1148
|
+
execute(e, t, n, r) {
|
|
1149
|
+
return super.execute(e, t, n, r);
|
|
1150
|
+
}
|
|
1151
|
+
}, Ze = Symbol("ListItemRemovedAction"), Qe = class extends x {
|
|
1152
|
+
constructor(e) {
|
|
1153
|
+
super(e);
|
|
1154
|
+
}
|
|
1155
|
+
static get classIdentifier() {
|
|
1156
|
+
return Ze;
|
|
1157
|
+
}
|
|
1158
|
+
execute(e, t, n, r) {
|
|
1159
|
+
return super.execute(e, t, n, r);
|
|
1160
|
+
}
|
|
1161
|
+
}, $e = Object.freeze({});
|
|
1162
|
+
function et() {
|
|
1163
|
+
return {
|
|
1164
|
+
originalValue: void 0,
|
|
1165
|
+
announcedValue: void 0,
|
|
1166
|
+
errors: [],
|
|
1167
|
+
visibility: b.FULL,
|
|
1168
|
+
enabled: !0,
|
|
1169
|
+
valueVersion: 0,
|
|
1170
|
+
validatingCount: 0,
|
|
1171
|
+
validatingChildren: 0,
|
|
1172
|
+
parent: void 0,
|
|
1173
|
+
fieldName: void 0,
|
|
1174
|
+
validationEpoch: 0,
|
|
1175
|
+
declaration: void 0,
|
|
1176
|
+
extra: $e,
|
|
1177
|
+
valid: !0,
|
|
1178
|
+
invalidChildren: 0
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
function tt() {
|
|
1182
|
+
return {
|
|
1183
|
+
...et(),
|
|
1184
|
+
value: void 0,
|
|
1185
|
+
touched: !1
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
function nt() {
|
|
1189
|
+
return {
|
|
1190
|
+
...et(),
|
|
1191
|
+
announcedValue: null,
|
|
1192
|
+
cachedValue: null,
|
|
1193
|
+
cachedValueVersion: -1
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
function rt() {
|
|
1197
|
+
return {
|
|
1198
|
+
...nt(),
|
|
1199
|
+
fieldNames: []
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
function it() {
|
|
1203
|
+
return {
|
|
1204
|
+
...nt(),
|
|
1205
|
+
rows: null,
|
|
1206
|
+
rowsVersion: 0,
|
|
1207
|
+
cachedItems: null,
|
|
1208
|
+
cachedItemsVersion: -1
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
//#endregion
|
|
1212
|
+
//#region src/field.ts
|
|
1213
|
+
var Q = class extends Y {
|
|
1214
|
+
get [Symbol.toStringTag]() {
|
|
1215
|
+
return "Field";
|
|
1216
|
+
}
|
|
1217
|
+
get state() {
|
|
1218
|
+
return super.state;
|
|
1219
|
+
}
|
|
1220
|
+
get raw() {
|
|
1221
|
+
return super.raw;
|
|
1222
|
+
}
|
|
1223
|
+
get _value() {
|
|
1224
|
+
return this.state.value;
|
|
1225
|
+
}
|
|
1226
|
+
set _value(e) {
|
|
1227
|
+
this.state.value = e;
|
|
1228
|
+
}
|
|
1229
|
+
constructor(e) {
|
|
1230
|
+
super(tt()), this.init(e);
|
|
1231
|
+
}
|
|
1232
|
+
init(e) {
|
|
1233
|
+
O(() => {
|
|
1234
|
+
if (e) {
|
|
1235
|
+
let { value: t, validators: n, actions: r, ...i } = e;
|
|
1236
|
+
this.registerInitialActions([...n || [], ...r || []]), this.assignParams(i), this._value = t === void 0 ? this.originalValue : t;
|
|
1237
|
+
}
|
|
1238
|
+
this.constructed(e), this.originalValue === void 0 && (this.originalValue = this._value), this.raw.announcedValue = this._value, this.boundActions?.triggerEager(this, this.value, this.originalValue), this.validate();
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
get value() {
|
|
1242
|
+
return this._value;
|
|
1243
|
+
}
|
|
1244
|
+
set value(e) {
|
|
1245
|
+
let t = this._value;
|
|
1246
|
+
!this.enabled || t === e || O((n) => {
|
|
1247
|
+
n.touch(this), this._value = e, this.bumpValueVersion(), this.boundActions?.triggerEager(this, e, t), this.propagateValueChanged();
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
get parent() {
|
|
1251
|
+
return super.parent;
|
|
1252
|
+
}
|
|
1253
|
+
get touched() {
|
|
1254
|
+
return this.state.touched;
|
|
1255
|
+
}
|
|
1256
|
+
set touched(e) {
|
|
1257
|
+
this.touchState(), this.state.touched = e;
|
|
1258
|
+
}
|
|
1259
|
+
bind(e, t) {
|
|
1260
|
+
let n = this.constructor, r = new n({
|
|
1261
|
+
value: e === void 0 ? this.value : e,
|
|
1262
|
+
...t && "originalValue" in t ? { originalValue: t.originalValue } : {},
|
|
1263
|
+
enabled: t?.enabled ?? this.enabled,
|
|
1264
|
+
visibility: t?.visibility ?? this.visibility
|
|
1265
|
+
});
|
|
1266
|
+
return r.boundFrom(this, r.value, r.originalValue, t), r;
|
|
1267
|
+
}
|
|
1268
|
+
}, at = /* @__PURE__ */ new WeakMap();
|
|
1269
|
+
function ot(e) {
|
|
1270
|
+
if (e != null) return Object.values(e).some((e) => e != null) ? e : void 0;
|
|
1271
|
+
}
|
|
1272
|
+
var st = class extends Q {
|
|
1273
|
+
get [Symbol.toStringTag]() {
|
|
1274
|
+
return "Action";
|
|
1275
|
+
}
|
|
1276
|
+
init(e) {
|
|
1277
|
+
O(() => {
|
|
1278
|
+
if (this._value = {
|
|
1279
|
+
label: void 0,
|
|
1280
|
+
icon: void 0
|
|
1281
|
+
}, e) {
|
|
1282
|
+
let { value: t, originalValue: n, validators: r, actions: i, ...a } = e;
|
|
1283
|
+
this.registerInitialActions([...r || [], ...i || []]), this.assignParams(a);
|
|
1284
|
+
let o = ot(t), s = ot(n);
|
|
1285
|
+
o ? this._value = o : s && (this._value = { ...s }), s && (this.originalValue = Object.freeze({ ...s }));
|
|
1286
|
+
}
|
|
1287
|
+
this.constructed(e), this.originalValue === void 0 && (this.originalValue = this._value), this.raw.announcedValue = this._value, this.boundActions?.triggerEager(this, this.value, this.originalValue), this.validate();
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
valueWith(e, t) {
|
|
1291
|
+
let n = { ...this.value };
|
|
1292
|
+
return t === void 0 ? delete n[e] : n[e] = t, n;
|
|
1293
|
+
}
|
|
1294
|
+
get icon() {
|
|
1295
|
+
return this.value.icon;
|
|
1296
|
+
}
|
|
1297
|
+
set icon(e) {
|
|
1298
|
+
this.value.icon !== e && (this.value = this.valueWith("icon", e));
|
|
1299
|
+
}
|
|
1300
|
+
get label() {
|
|
1301
|
+
return this.value.label;
|
|
1302
|
+
}
|
|
1303
|
+
set label(e) {
|
|
1304
|
+
this.value.label !== e && (this.value = this.valueWith("label", e));
|
|
1305
|
+
}
|
|
1306
|
+
get busyRuns() {
|
|
1307
|
+
let e = at.get(this);
|
|
1308
|
+
return e || (e = c(0), at.set(this, e)), e;
|
|
1309
|
+
}
|
|
1310
|
+
get busy() {
|
|
1311
|
+
return this.busyRuns.value > 0;
|
|
1312
|
+
}
|
|
1313
|
+
async execute(e) {
|
|
1314
|
+
let t = this.busyRuns;
|
|
1315
|
+
t.value++;
|
|
1316
|
+
try {
|
|
1317
|
+
return await this.triggerAction(X, e);
|
|
1318
|
+
} finally {
|
|
1319
|
+
t.value--;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
}, ct = /* @__PURE__ */ i({
|
|
1323
|
+
__name: "messages-widget",
|
|
1324
|
+
props: {
|
|
1325
|
+
message: {},
|
|
1326
|
+
classes: {}
|
|
1327
|
+
},
|
|
1328
|
+
setup(e) {
|
|
1329
|
+
let t = e, n = l("vue-markdown"), i = /* @__PURE__ */ new Set(/* @__PURE__ */ "div.span.p.h1.h2.h3.h4.h5.h6.section.article.aside.nav.header.footer.main.figure.figcaption.blockquote.pre.code.em.strong.small.mark.del.ins.sub.sup.i.b.u.s.a.img.button.input.textarea.select.option.label.form.table.tr.td.th.thead.tbody.tfoot.ul.ol.li.dl.dt.dd".split(".")), o = () => {
|
|
1330
|
+
if (typeof t.message == "string") return a("span", { class: t.classes }, t.message);
|
|
1331
|
+
let e = [];
|
|
1332
|
+
return t.message.forEach((r) => {
|
|
1333
|
+
switch (r.componentName) {
|
|
1334
|
+
case "template":
|
|
1335
|
+
e.push(a("div", { class: [t.classes, r.extraClasses] }, r.componentBody));
|
|
1336
|
+
break;
|
|
1337
|
+
case "vue-markdown":
|
|
1338
|
+
if (typeof n == "string") console.warn("You are using markdown for messages-widget, but you haven't registered a vue-markdown component"), e.push(a("div", { class: [t.classes, r.extraClasses] }, r.componentBindings.source));
|
|
1339
|
+
else {
|
|
1340
|
+
let i = r.componentBindings;
|
|
1341
|
+
e.push(a(n, {
|
|
1342
|
+
class: [
|
|
1343
|
+
t.classes,
|
|
1344
|
+
r.extraClasses,
|
|
1345
|
+
"df-messages-widget-markdown"
|
|
1346
|
+
],
|
|
1347
|
+
source: i.source,
|
|
1348
|
+
options: i.options,
|
|
1349
|
+
plugins: i.plugins
|
|
1350
|
+
}));
|
|
1351
|
+
}
|
|
1352
|
+
break;
|
|
1353
|
+
default: e.push(a(i.has(r.componentName.toLowerCase()) ? r.componentName : l(r.componentName), {
|
|
1354
|
+
class: [t.classes, r.extraClasses],
|
|
1355
|
+
...r.componentBindings,
|
|
1356
|
+
...r.componentBody ? { innerHTML: r.componentBody } : {}
|
|
1357
|
+
}));
|
|
1358
|
+
}
|
|
1359
|
+
}), e;
|
|
1360
|
+
};
|
|
1361
|
+
return (e, t) => (s(), r(o));
|
|
1362
|
+
}
|
|
1363
|
+
}), lt = /* @__PURE__ */ new WeakMap(), ut = (e) => ({
|
|
1364
|
+
get(t, n, r) {
|
|
1365
|
+
return e(), Reflect.get(t, n, r);
|
|
1366
|
+
},
|
|
1367
|
+
has(t, n) {
|
|
1368
|
+
return e(), Reflect.has(t, n);
|
|
1369
|
+
},
|
|
1370
|
+
ownKeys(t) {
|
|
1371
|
+
return e(), Reflect.ownKeys(t);
|
|
1372
|
+
},
|
|
1373
|
+
getOwnPropertyDescriptor(t, n) {
|
|
1374
|
+
return e(), Reflect.getOwnPropertyDescriptor(t, n);
|
|
1375
|
+
},
|
|
1376
|
+
set(e, t) {
|
|
1377
|
+
throw TypeError(`fields.${String(t)} cannot be assigned: use addField() to give the group a member`);
|
|
1378
|
+
},
|
|
1379
|
+
defineProperty(e, t) {
|
|
1380
|
+
throw TypeError(`fields.${String(t)} cannot be redefined: use addField() to give the group a member`);
|
|
1381
|
+
},
|
|
1382
|
+
deleteProperty(e, t) {
|
|
1383
|
+
throw TypeError(`fields.${String(t)} cannot be deleted: use removeField() to take a member out`);
|
|
1384
|
+
}
|
|
1385
|
+
}), $ = class e extends Y {
|
|
1386
|
+
get [Symbol.toStringTag]() {
|
|
1387
|
+
return "Group";
|
|
1388
|
+
}
|
|
1389
|
+
get state() {
|
|
1390
|
+
return super.state;
|
|
1391
|
+
}
|
|
1392
|
+
get raw() {
|
|
1393
|
+
return super.raw;
|
|
1394
|
+
}
|
|
1395
|
+
_fields;
|
|
1396
|
+
constructor(t, n) {
|
|
1397
|
+
if (super(rt()), !e.isValidFields(t)) throw Error("Invalid fields object provided");
|
|
1398
|
+
this._fields = Object.create(null), O(() => {
|
|
1399
|
+
if (Object.entries(t).forEach(([e, t]) => this.addField(e, t)), n) {
|
|
1400
|
+
let { value: e, validators: t, actions: r, ...i } = n;
|
|
1401
|
+
this.registerInitialActions([...t || [], ...r || []]), this.assignParams(i), e === void 0 ? this.originalValue !== void 0 && this.assignMembers(this.originalValue) : this.assignMembers(e);
|
|
1402
|
+
}
|
|
1403
|
+
this.completeRecords(), this.constructed(n);
|
|
1404
|
+
let r = this.value;
|
|
1405
|
+
this.originalValue === void 0 && (this.originalValue = e.baseline(r)), this.raw.announcedValue = r, this.boundActions?.triggerEager(this, r, this.originalValue), this.validate();
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
[w]() {
|
|
1409
|
+
let e = super[w]();
|
|
1410
|
+
return e.fieldNames = [...this.raw.fieldNames], e;
|
|
1411
|
+
}
|
|
1412
|
+
static baseline(e) {
|
|
1413
|
+
return e == null ? e : { ...e };
|
|
1414
|
+
}
|
|
1415
|
+
addField(t, n) {
|
|
1416
|
+
return O((r) => {
|
|
1417
|
+
if (Object.hasOwn(this._fields, t)) throw Error(`Field ${t} is already in this form`);
|
|
1418
|
+
this.takeChild(n, t), r.touch(this), e.setEntry(this._fields, t, n), r.whenRolledBack(() => e.dropEntry(this._fields, t)), this.state.fieldNames.push(t), this.completeRecords(n), this.bumpValueVersion(), this.notifyValueChanged();
|
|
1419
|
+
}), this;
|
|
1420
|
+
}
|
|
1421
|
+
removeField(t) {
|
|
1422
|
+
let n;
|
|
1423
|
+
return O((r) => {
|
|
1424
|
+
if (!Object.hasOwn(this._fields, t)) return;
|
|
1425
|
+
let i = this._fields[t];
|
|
1426
|
+
r.touch(this), this.releaseChild(i), e.dropEntry(this._fields, t), r.whenRolledBack(() => e.setEntry(this._fields, t, i)), this.state.fieldNames.splice(this.state.fieldNames.indexOf(t), 1), this.bumpValueVersion(), this.notifyValueChanged(), n = i;
|
|
1427
|
+
}), n;
|
|
1428
|
+
}
|
|
1429
|
+
static setEntry(e, t, n) {
|
|
1430
|
+
e[t] = n;
|
|
1431
|
+
}
|
|
1432
|
+
static dropEntry(e, t) {
|
|
1433
|
+
delete e[t];
|
|
1434
|
+
}
|
|
1435
|
+
static isValidFields(e) {
|
|
1436
|
+
function t(e) {
|
|
1437
|
+
return e instanceof Y;
|
|
1438
|
+
}
|
|
1439
|
+
return typeof e == "object" && !!e && Object.entries(e).every(([, e]) => t(e));
|
|
1440
|
+
}
|
|
1441
|
+
static createFromFormData(t) {
|
|
1442
|
+
if (t instanceof Y) throw Error("data is already a Form structure, should be a simple object");
|
|
1443
|
+
return new e(t == null ? {} : Object.fromEntries(Object.entries(t).map(([e, t]) => [e, new Q({ value: t })])));
|
|
1444
|
+
}
|
|
1445
|
+
field(e) {
|
|
1446
|
+
return this._fields[e] ?? null;
|
|
1447
|
+
}
|
|
1448
|
+
get fields() {
|
|
1449
|
+
let e = lt.get(this);
|
|
1450
|
+
return e || (e = new Proxy(this._fields, ut(() => this.state.fieldNames.length)), lt.set(this, e)), e;
|
|
1451
|
+
}
|
|
1452
|
+
get members() {
|
|
1453
|
+
return this.raw.fieldNames.map((e) => this._fields[e]);
|
|
1454
|
+
}
|
|
1455
|
+
get value() {
|
|
1456
|
+
let e = this.valueVersion;
|
|
1457
|
+
if (this.raw.cachedValueVersion === e) return this.raw.cachedValue;
|
|
1458
|
+
let t = Object.create(null);
|
|
1459
|
+
Object.entries(this._fields).forEach(([e, n]) => {
|
|
1460
|
+
let r = n.value;
|
|
1461
|
+
(n.enabled || this.childComposesValue(n) && !h(r)) && (t[e] = r);
|
|
1462
|
+
});
|
|
1463
|
+
let n = h(t) ? null : Object.freeze({ ...t });
|
|
1464
|
+
return this.raw.cachedValue = n, this.raw.cachedValueVersion = e, n;
|
|
1465
|
+
}
|
|
1466
|
+
assignMembers(e) {
|
|
1467
|
+
O(() => {
|
|
1468
|
+
Object.entries(this._fields).forEach(([t, n]) => {
|
|
1469
|
+
(e == null || Object.hasOwn(e, t)) && (n.value = e == null ? null : e[t]);
|
|
1470
|
+
});
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
set value(e) {
|
|
1474
|
+
O((t) => {
|
|
1475
|
+
this.assignMembers(e), t.markValidityDirty(this);
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
resetTo(t, n) {
|
|
1479
|
+
let r = t;
|
|
1480
|
+
O((t) => {
|
|
1481
|
+
t.touch(this), this.errors.length && (this.errors = []), Object.entries(this._fields).forEach(([e, t]) => {
|
|
1482
|
+
let i;
|
|
1483
|
+
n === null ? i = null : n !== void 0 && Object.hasOwn(n, e) && (i = n[e]), this.resetChild(t, r.field(e) ?? t, i);
|
|
1484
|
+
});
|
|
1485
|
+
let i = this.value;
|
|
1486
|
+
this.raw.announcedValue = i, this.originalValue = e.baseline(i), super.validate(!0);
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
get touched() {
|
|
1490
|
+
return Object.values(this._fields).some((e) => e.touched);
|
|
1491
|
+
}
|
|
1492
|
+
set touched(e) {
|
|
1493
|
+
O(() => {
|
|
1494
|
+
Object.values(this._fields).forEach((t) => {
|
|
1495
|
+
t.touched = e;
|
|
1496
|
+
});
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
get fullValue() {
|
|
1500
|
+
let e = Object.create(null);
|
|
1501
|
+
return Object.entries(this._fields).forEach(([t, n]) => {
|
|
1502
|
+
e[t] = n.fullValue;
|
|
1503
|
+
}), { ...e };
|
|
1504
|
+
}
|
|
1505
|
+
notifyValueChanged() {
|
|
1506
|
+
this.propagateValueChanged();
|
|
1507
|
+
}
|
|
1508
|
+
get composesValue() {
|
|
1509
|
+
return !0;
|
|
1510
|
+
}
|
|
1511
|
+
refreshPreviousValue() {
|
|
1512
|
+
this.raw.announcedValue = this.value;
|
|
1513
|
+
}
|
|
1514
|
+
get valid() {
|
|
1515
|
+
return this.validRead;
|
|
1516
|
+
}
|
|
1517
|
+
composeValid() {
|
|
1518
|
+
return this.state.errors.length === 0 && this.state.fieldNames.every((e) => this._fields[e].valid);
|
|
1519
|
+
}
|
|
1520
|
+
get busy() {
|
|
1521
|
+
return this.busyRead;
|
|
1522
|
+
}
|
|
1523
|
+
composeBusy() {
|
|
1524
|
+
return this.state.fieldNames.some((e) => this._fields[e].busy);
|
|
1525
|
+
}
|
|
1526
|
+
validate(e = !1) {
|
|
1527
|
+
O(() => {
|
|
1528
|
+
e && Object.values(this._fields).forEach((e) => e.validate(!0)), super.validate(e);
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
static assertTookFields(e, t, n) {
|
|
1532
|
+
let r = Object.entries(t), i = e.raw.fieldNames;
|
|
1533
|
+
if (!(r.length === i.length && r.every(([t, n]) => e._fields[t] === n))) throw TypeError(`${n}.bind() built an element that did not take the members it was given, so the binding would carry the declaration's data. A subclass whose constructor does not take (fields, params) has to override bind() and construct itself.`);
|
|
1534
|
+
}
|
|
1535
|
+
bind(t, n) {
|
|
1536
|
+
let r = Object.create(null);
|
|
1537
|
+
Object.entries(this._fields).forEach(([e, t]) => {
|
|
1538
|
+
r[e] = t.bind();
|
|
1539
|
+
});
|
|
1540
|
+
let i = this.constructor, a = new i(r, {
|
|
1541
|
+
value: t === void 0 ? this.value : t,
|
|
1542
|
+
...n && "originalValue" in n ? { originalValue: n.originalValue } : {},
|
|
1543
|
+
enabled: n?.enabled ?? this.enabled,
|
|
1544
|
+
visibility: n?.visibility ?? this.visibility
|
|
1545
|
+
});
|
|
1546
|
+
return e.assertTookFields(a, r, this.constructor.name), a.boundFrom(this, a.raw.announcedValue, a.originalValue, n), a;
|
|
1547
|
+
}
|
|
1548
|
+
rebind(e) {
|
|
1549
|
+
return super.rebind(e);
|
|
1550
|
+
}
|
|
1551
|
+
}, dt = class e extends Y {
|
|
1552
|
+
get [Symbol.toStringTag]() {
|
|
1553
|
+
return "List";
|
|
1554
|
+
}
|
|
1555
|
+
get state() {
|
|
1556
|
+
return super.state;
|
|
1557
|
+
}
|
|
1558
|
+
get raw() {
|
|
1559
|
+
return super.raw;
|
|
1560
|
+
}
|
|
1561
|
+
_itemTemplate;
|
|
1562
|
+
constructor(t, n) {
|
|
1563
|
+
super(it()), this._itemTemplate = t, O(() => {
|
|
1564
|
+
if (n) {
|
|
1565
|
+
let { value: e, validators: t, actions: r, ...i } = n;
|
|
1566
|
+
this.registerInitialActions([...t || [], ...r || []]), this.assignParams(i), e === void 0 ? this.originalValue !== void 0 && this.setValueInternal(this.originalValue) : this.setValueInternal(e);
|
|
1567
|
+
}
|
|
1568
|
+
this.constructed(n), this.originalValue === void 0 && (this.originalValue = e.baseline(this.value)), this.raw.announcedValue = this.value, this.boundActions?.triggerEager(this, this.value, this.originalValue), this.validate();
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
[w]() {
|
|
1572
|
+
let e = super[w]();
|
|
1573
|
+
return e.rows = this.raw.rows ? [...this.raw.rows] : this.raw.rows, e;
|
|
1574
|
+
}
|
|
1575
|
+
static baseline(e) {
|
|
1576
|
+
return e == null ? e : [...e];
|
|
1577
|
+
}
|
|
1578
|
+
processSetValueItem(e) {
|
|
1579
|
+
let t;
|
|
1580
|
+
return t = e instanceof $ ? e : this._itemTemplate ? this._itemTemplate.bind(e) : $.createFromFormData(e), this.takeChild(t), this.completeRecords(t), t;
|
|
1581
|
+
}
|
|
1582
|
+
createPaddingItem() {
|
|
1583
|
+
return this.processSetValueItem(this._itemTemplate ? this._itemTemplate.bind() : null);
|
|
1584
|
+
}
|
|
1585
|
+
rowsChanged() {
|
|
1586
|
+
this.state.rowsVersion++;
|
|
1587
|
+
}
|
|
1588
|
+
static rowsDiffer(e, t) {
|
|
1589
|
+
let n = e ?? [], r = t ?? [];
|
|
1590
|
+
return n.length !== r.length || n.some((e, t) => e !== r[t]);
|
|
1591
|
+
}
|
|
1592
|
+
setValueInternal(t) {
|
|
1593
|
+
if (t != null && !Array.isArray(t)) throw TypeError("Invalid value provided: a list takes an array of rows, or null to empty it");
|
|
1594
|
+
O((n) => {
|
|
1595
|
+
n.touch(this);
|
|
1596
|
+
let r = this.raw.rows;
|
|
1597
|
+
if (t == null) this.releaseRows(), this.state.rows = null;
|
|
1598
|
+
else {
|
|
1599
|
+
let e = this.state.rows ?? [], n = Array(t.length);
|
|
1600
|
+
for (let r = 0; r < t.length; r++) {
|
|
1601
|
+
let i = t[r], a = e[r];
|
|
1602
|
+
a && this._itemTemplate && !(i instanceof $) ? (this.resetChild(a, this._itemTemplate, i), n[r] = a) : (a && this.releaseChild(a), n[r] = this.processSetValueItem(i));
|
|
1603
|
+
}
|
|
1604
|
+
for (let n = t.length; n < e.length; n++) this.releaseChild(e[n]);
|
|
1605
|
+
this.state.rows = n;
|
|
1606
|
+
}
|
|
1607
|
+
e.rowsDiffer(r, this.raw.rows) && this.rowsChanged(), this.bumpValueVersion();
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
get value() {
|
|
1611
|
+
let e = this.valueVersion;
|
|
1612
|
+
if (this.raw.cachedValueVersion === e) return this.raw.cachedValue;
|
|
1613
|
+
let t = this.state.rows?.map((e) => e.value), n = h(t) ? null : Object.freeze(t);
|
|
1614
|
+
return this.raw.cachedValue = n, this.raw.cachedValueVersion = e, n;
|
|
1615
|
+
}
|
|
1616
|
+
set value(e) {
|
|
1617
|
+
O(() => {
|
|
1618
|
+
this.setValueInternal(e), this.propagateValueChanged(!0);
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
resetTo(t, n) {
|
|
1622
|
+
O((r) => {
|
|
1623
|
+
r.touch(this), this.errors.length && (this.errors = []), this.setValueInternal(n === void 0 ? t.value : n);
|
|
1624
|
+
let i = this.value;
|
|
1625
|
+
this.raw.announcedValue = i, this.originalValue = e.baseline(i), super.validate(!0);
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
get touched() {
|
|
1629
|
+
return this.state.rows?.some((e) => e.touched) || !1;
|
|
1630
|
+
}
|
|
1631
|
+
set touched(e) {
|
|
1632
|
+
O(() => {
|
|
1633
|
+
this.state.rows?.forEach((t) => {
|
|
1634
|
+
t.touched = e;
|
|
1635
|
+
});
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
bind(e, t) {
|
|
1639
|
+
let n = this._itemTemplate?.bind(), r = this.constructor, i = new r(n, {
|
|
1640
|
+
value: [...(e === void 0 ? this.value : e) ?? []],
|
|
1641
|
+
...t && "originalValue" in t ? { originalValue: t.originalValue } : {},
|
|
1642
|
+
enabled: t?.enabled ?? this.enabled,
|
|
1643
|
+
visibility: t?.visibility ?? this.visibility
|
|
1644
|
+
});
|
|
1645
|
+
if (i._itemTemplate !== n) throw TypeError(`${this.constructor.name}.bind() built a list that did not take the item template it was given, so the binding would carry the declaration's rows. A subclass whose constructor does not take (itemTemplate, params) has to override bind() and construct itself.`);
|
|
1646
|
+
return i.boundFrom(this, i.value, i.originalValue, t), i;
|
|
1647
|
+
}
|
|
1648
|
+
notifyValueChanged() {
|
|
1649
|
+
this.propagateValueChanged();
|
|
1650
|
+
}
|
|
1651
|
+
get composesValue() {
|
|
1652
|
+
return !0;
|
|
1653
|
+
}
|
|
1654
|
+
refreshPreviousValue() {
|
|
1655
|
+
this.raw.announcedValue = this.value;
|
|
1656
|
+
}
|
|
1657
|
+
get valid() {
|
|
1658
|
+
return this.validRead;
|
|
1659
|
+
}
|
|
1660
|
+
composeValid() {
|
|
1661
|
+
return this.state.errors.length === 0 && (this.state.rows?.every((e) => e.valid) ?? !0);
|
|
1662
|
+
}
|
|
1663
|
+
get busy() {
|
|
1664
|
+
return this.busyRead;
|
|
1665
|
+
}
|
|
1666
|
+
composeBusy() {
|
|
1667
|
+
return this.state.rows?.some((e) => e.busy) ?? !1;
|
|
1668
|
+
}
|
|
1669
|
+
validate(e = !1) {
|
|
1670
|
+
O(() => {
|
|
1671
|
+
e && this.state.rows?.forEach((e) => e.validate(!0)), super.validate(e);
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
get members() {
|
|
1675
|
+
return this.raw.rows ?? [];
|
|
1676
|
+
}
|
|
1677
|
+
get fullValue() {
|
|
1678
|
+
return (this.state.rows ?? []).map((e) => e.fullValue);
|
|
1679
|
+
}
|
|
1680
|
+
get length() {
|
|
1681
|
+
return this.state.rows?.length ?? 0;
|
|
1682
|
+
}
|
|
1683
|
+
get items() {
|
|
1684
|
+
let e = this.state.rowsVersion;
|
|
1685
|
+
return this.raw.cachedItemsVersion !== e && (this.raw.cachedItems = Object.freeze([...this.raw.rows ?? []]), this.raw.cachedItemsVersion = e), this.raw.cachedItems;
|
|
1686
|
+
}
|
|
1687
|
+
get(e) {
|
|
1688
|
+
return this.state.rows == null ? void 0 : this.state.rows[e];
|
|
1689
|
+
}
|
|
1690
|
+
push(e) {
|
|
1691
|
+
return this.insert(e, this.state.rows?.length ?? 0) + 1;
|
|
1692
|
+
}
|
|
1693
|
+
pop() {
|
|
1694
|
+
return this.remove((this.state.rows?.length ?? 0) - 1);
|
|
1695
|
+
}
|
|
1696
|
+
remove(e) {
|
|
1697
|
+
let t;
|
|
1698
|
+
return O((n) => {
|
|
1699
|
+
if (this.state.rows == null || e < 0 || this.state.rows.length <= e) return;
|
|
1700
|
+
n.touch(this);
|
|
1701
|
+
let r = this.state.rows.splice(e, 1)?.[0];
|
|
1702
|
+
r && (this.releaseChild(r), this.rowsChanged(), this.bumpValueVersion(), t = r, n.recordStructural(this, {
|
|
1703
|
+
actionClass: Qe,
|
|
1704
|
+
item: t,
|
|
1705
|
+
index: e
|
|
1706
|
+
}), this.propagateValueChanged(!0));
|
|
1707
|
+
}), t;
|
|
1708
|
+
}
|
|
1709
|
+
insert(e, t) {
|
|
1710
|
+
let n = 0;
|
|
1711
|
+
return O((r) => {
|
|
1712
|
+
for (r.touch(this), this.state.rows ?? (this.state.rows = []), n = t < 0 ? Math.max(this.state.rows.length + t, 0) : t; this.state.rows.length < n;) {
|
|
1713
|
+
let e = this.createPaddingItem(), t = this.state.rows.push(e) - 1;
|
|
1714
|
+
this.bumpValueVersion(), r.recordStructural(this, {
|
|
1715
|
+
actionClass: Z,
|
|
1716
|
+
item: e,
|
|
1717
|
+
index: t
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
let i = this.processSetValueItem(e);
|
|
1721
|
+
this.state.rows.splice(n, 0, i), r.recordStructural(this, {
|
|
1722
|
+
actionClass: Z,
|
|
1723
|
+
item: i,
|
|
1724
|
+
index: n
|
|
1725
|
+
}), this.rowsChanged(), this.bumpValueVersion(), this.propagateValueChanged(!0);
|
|
1726
|
+
}), n;
|
|
1727
|
+
}
|
|
1728
|
+
releaseRows() {
|
|
1729
|
+
this.state.rows?.forEach((e) => this.releaseChild(e));
|
|
1730
|
+
}
|
|
1731
|
+
clear() {
|
|
1732
|
+
O((e) => {
|
|
1733
|
+
let t = (this.state.rows?.length ?? 0) > 0;
|
|
1734
|
+
e.touch(this), this.releaseRows(), this.state.rows = null, t && this.rowsChanged(), this.bumpValueVersion(), this.propagateValueChanged(t);
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
}, ft = class extends I {
|
|
1738
|
+
isValidComparison;
|
|
1739
|
+
otherField;
|
|
1740
|
+
registrations = /* @__PURE__ */ new WeakSet();
|
|
1741
|
+
listening = /* @__PURE__ */ new WeakSet();
|
|
1742
|
+
declarations = /* @__PURE__ */ new Set();
|
|
1743
|
+
constructor(e, t, n) {
|
|
1744
|
+
super((e, t, r) => {
|
|
1745
|
+
this.comparisonState(r).oldValue = t;
|
|
1746
|
+
let i = this.resolve(r);
|
|
1747
|
+
return i ? (this.listenOn(i), this.isValidComparison(d(e), d(i.value)) ? null : [new N(this.replacePlaceholders(n, {
|
|
1748
|
+
newValue: e,
|
|
1749
|
+
oldValue: t,
|
|
1750
|
+
field: r,
|
|
1751
|
+
otherField: i
|
|
1752
|
+
}), "", "compare-to")]) : (r.markRecordIncomplete(), null);
|
|
1753
|
+
}), this.isValidComparison = t, this.otherField = e;
|
|
1754
|
+
}
|
|
1755
|
+
resolve(e) {
|
|
1756
|
+
let t = this.otherField;
|
|
1757
|
+
return typeof t == "function" ? t(e) ?? void 0 : typeof t == "string" ? Pe(t, e) : Me(t, R(e));
|
|
1758
|
+
}
|
|
1759
|
+
listenOn(e) {
|
|
1760
|
+
this.listening.has(e) || this.listening.has(e.declaration) || (this.listening.add(e), e.registerAction(new C((e, t, n, r) => {
|
|
1761
|
+
t(e, n, r);
|
|
1762
|
+
let i = R(e);
|
|
1763
|
+
this.declarations.forEach((e) => Ne(e, i).forEach((e) => {
|
|
1764
|
+
this.registrations.has(e) && this.execute(e, () => null, e.value, this.comparisonState(e).oldValue);
|
|
1765
|
+
}));
|
|
1766
|
+
})));
|
|
1767
|
+
}
|
|
1768
|
+
boundToBinding(e) {
|
|
1769
|
+
this.declarations.add(e.declaration), this.registrations.add(e);
|
|
1770
|
+
}
|
|
1771
|
+
comparisonState(e) {
|
|
1772
|
+
return this.bindingState(e);
|
|
1773
|
+
}
|
|
1774
|
+
newBindingState() {
|
|
1775
|
+
return {
|
|
1776
|
+
...super.newBindingState(),
|
|
1777
|
+
oldValue: void 0
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1780
|
+
unregisterFrom(e) {
|
|
1781
|
+
super.unregisterFrom(e), this.registrations.delete(e);
|
|
1782
|
+
}
|
|
1783
|
+
}, pt = class extends I {
|
|
1784
|
+
constructor(e, t) {
|
|
1785
|
+
let n = t || F("InAllowedValues"), r = () => {
|
|
1786
|
+
let t = d(e);
|
|
1787
|
+
return typeof t == "function" ? t() : t;
|
|
1788
|
+
}, i = (e) => {
|
|
1789
|
+
let t = e.join(", ");
|
|
1790
|
+
return t.length <= 60 ? t : ne(t, {
|
|
1791
|
+
length: 40,
|
|
1792
|
+
separator: ", ",
|
|
1793
|
+
omission: `... (${e.length} items total)`
|
|
1794
|
+
});
|
|
1795
|
+
};
|
|
1796
|
+
super((e, t, a) => {
|
|
1797
|
+
let o = r();
|
|
1798
|
+
return o.includes(d(e)) ? null : [new N(this.replacePlaceholders(n, {
|
|
1799
|
+
newValue: e,
|
|
1800
|
+
oldValue: t,
|
|
1801
|
+
field: a,
|
|
1802
|
+
allowedValues: o,
|
|
1803
|
+
allowedAsText: i(o)
|
|
1804
|
+
}), "", "in-allowed-values")];
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
//#endregion
|
|
1809
|
+
//#region src/validators/validator-required.ts
|
|
1810
|
+
function mt(e) {
|
|
1811
|
+
return e == null ? 0 : p(e) || _(e) ? e.length : te(e) && Object.getPrototypeOf(e) === Object.prototype ? Object.keys(e).length : String(e).length;
|
|
1812
|
+
}
|
|
1813
|
+
function ht(e) {
|
|
1814
|
+
return typeof e == "object" && !!e && !o(e) && !(e instanceof String) && !("componentName" in e);
|
|
1815
|
+
}
|
|
1816
|
+
var gt = class extends I {
|
|
1817
|
+
constructor(e, t) {
|
|
1818
|
+
let n = ht(e) ? void 0 : e, r = (ht(e) ? e : t)?.trim ?? !0, i = n || F("Required");
|
|
1819
|
+
super((e, t, n) => {
|
|
1820
|
+
let a = d(e);
|
|
1821
|
+
return mt(r && _(a) ? a.trim() : a) === 0 ? [new N(this.replacePlaceholders(i, {
|
|
1822
|
+
newValue: e,
|
|
1823
|
+
oldValue: t,
|
|
1824
|
+
field: n
|
|
1825
|
+
}), "", "required")] : null;
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
}, _t = class extends I {
|
|
1829
|
+
constructor(e, t) {
|
|
1830
|
+
let n = t || F("MinValue");
|
|
1831
|
+
super((t, r, i) => t < e || t === void 0 ? [new N(this.replacePlaceholders(n, {
|
|
1832
|
+
newValue: t,
|
|
1833
|
+
oldValue: r,
|
|
1834
|
+
field: i,
|
|
1835
|
+
minValue: e
|
|
1836
|
+
}), "", "min")] : null);
|
|
1837
|
+
}
|
|
1838
|
+
}, vt = class extends I {
|
|
1839
|
+
constructor(e, t) {
|
|
1840
|
+
let n = t || F("MaxValue");
|
|
1841
|
+
super((t, r, i) => t > e || t === void 0 ? [new N(this.replacePlaceholders(n, {
|
|
1842
|
+
newValue: t,
|
|
1843
|
+
oldValue: r,
|
|
1844
|
+
field: i,
|
|
1845
|
+
maxValue: e
|
|
1846
|
+
}), "", "max")] : null);
|
|
1847
|
+
}
|
|
1848
|
+
}, yt = class extends I {
|
|
1849
|
+
constructor(e, t, n) {
|
|
1850
|
+
let r = n || F("ValueInRange");
|
|
1851
|
+
super((n, i, a) => n < e || n > t || n === void 0 ? [new N(this.replacePlaceholders(r, {
|
|
1852
|
+
newValue: n,
|
|
1853
|
+
oldValue: i,
|
|
1854
|
+
field: a,
|
|
1855
|
+
minValue: e,
|
|
1856
|
+
maxValue: t
|
|
1857
|
+
}), "", "range")] : null);
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
//#endregion
|
|
1861
|
+
//#region src/validators/validator-min-max-range-length.ts
|
|
1862
|
+
function bt(e) {
|
|
1863
|
+
return e == null ? 0 : p(e) || _(e) ? e.length : te(e) && Object.getPrototypeOf(e) === Object.prototype ? Object.keys(e).length : String(e).length;
|
|
1864
|
+
}
|
|
1865
|
+
var xt = class extends I {
|
|
1866
|
+
constructor(e, t) {
|
|
1867
|
+
let n = t || F("MinLength");
|
|
1868
|
+
super((t, r, i) => bt(t) < e ? [new N(this.replacePlaceholders(n, {
|
|
1869
|
+
newValue: t,
|
|
1870
|
+
oldValue: r,
|
|
1871
|
+
field: i,
|
|
1872
|
+
minLength: e
|
|
1873
|
+
}), "", "min-length")] : null);
|
|
1874
|
+
}
|
|
1875
|
+
}, St = class extends I {
|
|
1876
|
+
constructor(e, t) {
|
|
1877
|
+
let n = t || F("MaxLength");
|
|
1878
|
+
super((t, r, i) => bt(t) > e ? [new N(this.replacePlaceholders(n, {
|
|
1879
|
+
newValue: t,
|
|
1880
|
+
oldValue: r,
|
|
1881
|
+
field: i,
|
|
1882
|
+
maxLength: e
|
|
1883
|
+
}), "", "max-length")] : null);
|
|
1884
|
+
}
|
|
1885
|
+
}, Ct = class extends I {
|
|
1886
|
+
constructor(e, t, n) {
|
|
1887
|
+
let r = n || F("LengthInRange");
|
|
1888
|
+
super((n, i, a) => {
|
|
1889
|
+
let o = bt(n);
|
|
1890
|
+
return o < e || o > t ? [new N(this.replacePlaceholders(r, {
|
|
1891
|
+
newValue: n,
|
|
1892
|
+
oldValue: i,
|
|
1893
|
+
field: a,
|
|
1894
|
+
minLength: e,
|
|
1895
|
+
maxLength: t
|
|
1896
|
+
}), "", "range-length")] : null;
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1899
|
+
}, wt = class extends I {
|
|
1900
|
+
constructor(e, t) {
|
|
1901
|
+
let n = t || F("Pattern");
|
|
1902
|
+
super((t, r, i) => e.test(String(d(t))) ? null : [new N(this.replacePlaceholders(n, {
|
|
1903
|
+
newValue: t,
|
|
1904
|
+
oldValue: r,
|
|
1905
|
+
field: i,
|
|
1906
|
+
pattern: e
|
|
1907
|
+
}), "", "pattern")]);
|
|
1908
|
+
}
|
|
1909
|
+
}, Tt = /* @__PURE__ */ ie({
|
|
1910
|
+
CompareTo: () => ft,
|
|
1911
|
+
InAllowedValues: () => pt,
|
|
1912
|
+
LengthInRange: () => Ct,
|
|
1913
|
+
MaxLength: () => St,
|
|
1914
|
+
MaxValue: () => vt,
|
|
1915
|
+
MinLength: () => xt,
|
|
1916
|
+
MinValue: () => _t,
|
|
1917
|
+
Pattern: () => wt,
|
|
1918
|
+
Required: () => gt,
|
|
1919
|
+
Validator: () => I,
|
|
1920
|
+
ValueInRange: () => yt
|
|
1921
|
+
}), Et = /* @__PURE__ */ ie({
|
|
1922
|
+
AbortEventHandlingException: () => S,
|
|
1923
|
+
Action: () => st,
|
|
1924
|
+
ActionsMap: () => L,
|
|
1925
|
+
ConditionalEnabledAction: () => Le,
|
|
1926
|
+
ConditionalStatementAction: () => z,
|
|
1927
|
+
ConditionalValueAction: () => Re,
|
|
1928
|
+
ConditionalVisibilityAction: () => Ie,
|
|
1929
|
+
DisplayMode: () => b,
|
|
1930
|
+
EnabledChangedAction: () => U,
|
|
1931
|
+
EnabledChangingAction: () => H,
|
|
1932
|
+
ExecuteAction: () => X,
|
|
1933
|
+
Field: () => Q,
|
|
1934
|
+
FieldActionBase: () => x,
|
|
1935
|
+
FieldBase: () => Y,
|
|
1936
|
+
Group: () => $,
|
|
1937
|
+
List: () => dt,
|
|
1938
|
+
ListItemAddedAction: () => Z,
|
|
1939
|
+
ListItemRemovedAction: () => Qe,
|
|
1940
|
+
MdString: () => k,
|
|
1941
|
+
MessagesWidget: () => ct,
|
|
1942
|
+
Operator: () => V,
|
|
1943
|
+
RenderableValue: () => we,
|
|
1944
|
+
Statement: () => Je,
|
|
1945
|
+
ValidChangedAction: () => W,
|
|
1946
|
+
ValidationError: () => M,
|
|
1947
|
+
ValidationErrorRenderContent: () => N,
|
|
1948
|
+
ValidationErrorText: () => Ce,
|
|
1949
|
+
Validators: () => Tt,
|
|
1950
|
+
ValueChangedAction: () => C,
|
|
1951
|
+
VisibilityChangedAction: () => K,
|
|
1952
|
+
VisibilityChangingAction: () => G,
|
|
1953
|
+
buildErrorMessage: () => P,
|
|
1954
|
+
defaultDisplayMode: () => 10,
|
|
1955
|
+
isCallableFunction: () => j,
|
|
1956
|
+
isSimpleComponentDef: () => A,
|
|
1957
|
+
strings: () => Ee,
|
|
1958
|
+
transaction: () => D,
|
|
1959
|
+
translateStrings: () => De,
|
|
1960
|
+
translatedMessage: () => F
|
|
1961
|
+
});
|
|
1962
|
+
//#endregion
|
|
1963
|
+
export { S as AbortEventHandlingException, st as Action, L as ActionsMap, Le as ConditionalEnabledAction, z as ConditionalStatementAction, Re as ConditionalValueAction, Ie as ConditionalVisibilityAction, b as DisplayMode, U as EnabledChangedAction, H as EnabledChangingAction, X as ExecuteAction, Q as Field, x as FieldActionBase, Y as FieldBase, $ as Group, dt as List, Z as ListItemAddedAction, Qe as ListItemRemovedAction, k as MdString, ct as MessagesWidget, V as Operator, we as RenderableValue, Je as Statement, W as ValidChangedAction, M as ValidationError, N as ValidationErrorRenderContent, Ce as ValidationErrorText, Tt as Validators, C as ValueChangedAction, K as VisibilityChangedAction, G as VisibilityChangingAction, P as buildErrorMessage, Et as default, ae as defaultDisplayMode, Se as forms, be as getConfig, j as isCallableFunction, A as isSimpleComponentDef, xe as setConfig, Ee as strings, D as transaction, De as translateStrings, F as translatedMessage };
|
|
1964
|
+
|
|
1965
|
+
//# sourceMappingURL=dynamicforms-vue-forms.js.map
|