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