@reformer/core 10.0.0-beta.2 → 10.0.0-beta.4
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/{behaviors-node-DUrqAqp1.js → behaviors-node-DGEFMTQu.js} +1 -1
- package/dist/{behaviors-value-lCpqicfa.js → behaviors-value-C7dSEhCc.js} +43 -57
- package/dist/behaviors.js +108 -107
- package/dist/derived-registry-CluZCQ7U.js +16 -0
- package/dist/form/form-submitter.d.ts +0 -4
- package/dist/form/hooks/types.d.ts +3 -3
- package/dist/form/hooks/use-form-validation.d.ts +48 -0
- package/dist/form/index.d.ts +2 -3
- package/dist/form/nodes/array-node.d.ts +0 -84
- package/dist/form/nodes/form-node.d.ts +0 -14
- package/dist/form/nodes/group-node.d.ts +0 -4
- package/dist/form/status-machine.d.ts +0 -38
- package/dist/form/types/contracts.d.ts +0 -6
- package/dist/form/types/deep-schema.d.ts +0 -9
- package/dist/form/types/index.d.ts +4 -38
- package/dist/form/types/schema-node.d.ts +13 -16
- package/dist/form/types/validation-schema.d.ts +0 -25
- package/dist/form/unique-id.d.ts +3 -11
- package/dist/form/validation-schema.d.ts +16 -3
- package/dist/form/validation-strategy.d.ts +55 -0
- package/dist/form/validators.d.ts +8 -3
- package/dist/form-model-DYCzGGKF.js +286 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +477 -648
- package/dist/runtime-token.d.ts +23 -0
- package/dist/state/form-model.d.ts +12 -1
- package/dist/state.js +17 -15
- package/dist/subscription-manager-705bls97.js +171 -0
- package/dist/validation.js +133 -81
- package/dist/validators.d.ts +0 -4
- package/dist/validators.js +88 -122
- package/docs/llms/01-api-reference.md +63 -0
- package/docs/llms/02-quick-start.md +143 -0
- package/docs/llms/03-api-signatures.md +273 -0
- package/docs/llms/04-common-patterns.md +202 -0
- package/docs/llms/05-common-mistakes.md +167 -0
- package/docs/llms/06-troubleshooting.md +11 -0
- package/docs/llms/07-complete-import.md +99 -0
- package/docs/llms/08-form-types.md +47 -0
- package/docs/llms/09-formschema.md +143 -0
- package/docs/llms/10-arrays.md +161 -0
- package/docs/llms/11-async-watchfield.md +53 -0
- package/docs/llms/12-array-cleanup.md +31 -0
- package/docs/llms/13-multi-step.md +91 -0
- package/docs/llms/14-extended-mistakes.md +98 -0
- package/docs/llms/15-project-structure.md +125 -0
- package/docs/llms/16-ui-components.md +189 -0
- package/docs/llms/17-nonexistent-api.md +93 -0
- package/docs/llms/18-conditional-fields.md +183 -0
- package/docs/llms/19-reading-values.md +59 -0
- package/docs/llms/20-compute-vs-watch.md +138 -0
- package/docs/llms/21-array-operations.md +113 -0
- package/docs/llms/22-cycle-detection.md +86 -0
- package/docs/llms/23-copy-from.md +141 -0
- package/docs/llms/24-sync-fields.md +114 -0
- package/docs/llms/25-reset-when.md +115 -0
- package/docs/llms/26-transform-value.md +136 -0
- package/docs/llms/27-revalidate-when.md +132 -0
- package/docs/llms/28-submit-and-reset.md +259 -0
- package/docs/llms/29-async-preload.md +193 -0
- package/docs/llms/30-type-safety-recipes.md +159 -0
- package/docs/llms/31-async-validator-debounce.md +135 -0
- package/docs/llms/32-async-options-loading.md +108 -0
- package/docs/llms/33-validation-strategy.md +193 -0
- package/llms.txt +435 -1580
- package/package.json +33 -10
- package/dist/form-model-C8Fi83k4.js +0 -439
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as
|
|
3
|
-
import { i as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { signal as g, computed as
|
|
1
|
+
import { c as Le } from "./form-model-DYCzGGKF.js";
|
|
2
|
+
import { c as $e, a as Ge, r as je, b as Ue, d as Be, e as We, f as qe, s as Ke, t as He, w as ze } from "./behaviors-value-C7dSEhCc.js";
|
|
3
|
+
import { i as $ } from "./derived-registry-CluZCQ7U.js";
|
|
4
|
+
import { m as Ye, u as Qe } from "./derived-registry-CluZCQ7U.js";
|
|
5
|
+
import { S as I } from "./subscription-manager-705bls97.js";
|
|
6
|
+
import { signal as g, computed as f, effect as _, batch as X, Signal as G } from "@preact/signals-core";
|
|
7
7
|
import { r as Z } from "./signal-node-registry-tiwel-TV.js";
|
|
8
|
-
import { g as
|
|
9
|
-
import { d as
|
|
10
|
-
import
|
|
8
|
+
import { g as Ze } from "./signal-node-registry-tiwel-TV.js";
|
|
9
|
+
import { d as tt, e as st } from "./behaviors-node-DGEFMTQu.js";
|
|
10
|
+
import H, { useRef as V, useCallback as b, useMemo as ee, useEffect as te } from "react";
|
|
11
|
+
import { createFormValidation as se } from "./validation.js";
|
|
11
12
|
class M {
|
|
12
13
|
// ============================================================================
|
|
13
14
|
// Protected состояние (для Template Method паттерна)
|
|
@@ -34,33 +35,21 @@ class M {
|
|
|
34
35
|
* Пользователь взаимодействовал с узлом (touched)
|
|
35
36
|
* Computed из _touched для предоставления readonly интерфейса
|
|
36
37
|
*/
|
|
37
|
-
touched =
|
|
38
|
-
/**
|
|
39
|
-
* Пользователь не взаимодействовал с узлом (untouched)
|
|
40
|
-
*/
|
|
41
|
-
untouched = c(() => !this._touched.value);
|
|
38
|
+
touched = f(() => this._touched.value);
|
|
42
39
|
/**
|
|
43
40
|
* Значение узла было изменено (dirty)
|
|
44
41
|
* Computed из _dirty для предоставления readonly интерфейса
|
|
45
42
|
*/
|
|
46
|
-
dirty =
|
|
47
|
-
/**
|
|
48
|
-
* Значение узла не было изменено (pristine)
|
|
49
|
-
*/
|
|
50
|
-
pristine = c(() => !this._dirty.value);
|
|
43
|
+
dirty = f(() => this._dirty.value);
|
|
51
44
|
/**
|
|
52
45
|
* Текущий статус узла
|
|
53
46
|
* Computed из _status для предоставления readonly интерфейса
|
|
54
47
|
*/
|
|
55
|
-
status =
|
|
48
|
+
status = f(() => this._status.value);
|
|
56
49
|
/**
|
|
57
50
|
* Узел отключен (disabled)
|
|
58
51
|
*/
|
|
59
|
-
disabled =
|
|
60
|
-
/**
|
|
61
|
-
* Узел включен (enabled)
|
|
62
|
-
*/
|
|
63
|
-
enabled = c(() => this._status.value !== "disabled");
|
|
52
|
+
disabled = f(() => this._status.value === "disabled");
|
|
64
53
|
/**
|
|
65
54
|
* Получить ошибки валидации с фильтрацией
|
|
66
55
|
*
|
|
@@ -108,8 +97,8 @@ class M {
|
|
|
108
97
|
if (e.params !== void 0) {
|
|
109
98
|
if (!s.params)
|
|
110
99
|
return !1;
|
|
111
|
-
for (const [
|
|
112
|
-
if (s.params[
|
|
100
|
+
for (const [r, n] of Object.entries(e.params))
|
|
101
|
+
if (s.params[r] !== n)
|
|
113
102
|
return !1;
|
|
114
103
|
}
|
|
115
104
|
return !(e.predicate !== void 0 && !e.predicate(s));
|
|
@@ -285,7 +274,7 @@ class M {
|
|
|
285
274
|
onEnable() {
|
|
286
275
|
}
|
|
287
276
|
}
|
|
288
|
-
const
|
|
277
|
+
const O = {
|
|
289
278
|
/** FieldNode.watch() */
|
|
290
279
|
Watch: "watch",
|
|
291
280
|
/** FieldNode.computeFrom() */
|
|
@@ -293,20 +282,16 @@ const w = {
|
|
|
293
282
|
/** GroupNode.linkFields() */
|
|
294
283
|
LinkFields: "linkFields",
|
|
295
284
|
/** GroupNode.watchField() */
|
|
296
|
-
WatchField: "watchField"
|
|
297
|
-
/** ArrayNode.watchItems() */
|
|
298
|
-
WatchItems: "watchItems",
|
|
299
|
-
/** ArrayNode.watchLength() */
|
|
300
|
-
WatchLength: "watchLength"
|
|
285
|
+
WatchField: "watchField"
|
|
301
286
|
};
|
|
302
|
-
let
|
|
303
|
-
function
|
|
304
|
-
return `${
|
|
287
|
+
let re = 0;
|
|
288
|
+
function N(i) {
|
|
289
|
+
return `${i}-${++re}`;
|
|
305
290
|
}
|
|
306
|
-
var A = /* @__PURE__ */ ((
|
|
307
|
-
class
|
|
291
|
+
var A = /* @__PURE__ */ ((i) => (i.THROW = "throw", i.LOG = "log", i.CONVERT = "convert", i))(A || {});
|
|
292
|
+
class k {
|
|
308
293
|
static handle(e, t, s = "throw") {
|
|
309
|
-
const
|
|
294
|
+
const r = this.extractMessage(e);
|
|
310
295
|
switch (process.env.NODE_ENV !== "production" && console.error(`[${t}]`, e), s) {
|
|
311
296
|
case "throw":
|
|
312
297
|
throw e;
|
|
@@ -315,7 +300,7 @@ class F {
|
|
|
315
300
|
case "convert":
|
|
316
301
|
return {
|
|
317
302
|
code: "validator_error",
|
|
318
|
-
message:
|
|
303
|
+
message: r,
|
|
319
304
|
params: { field: t }
|
|
320
305
|
};
|
|
321
306
|
}
|
|
@@ -397,7 +382,7 @@ class F {
|
|
|
397
382
|
return typeof e == "object" && e !== null && "code" in e && "message" in e && typeof e.code == "string" && typeof e.message == "string";
|
|
398
383
|
}
|
|
399
384
|
}
|
|
400
|
-
class
|
|
385
|
+
class ie {
|
|
401
386
|
/** Внутренний сигнал статуса */
|
|
402
387
|
_status;
|
|
403
388
|
/** Публичный read-only сигнал статуса */
|
|
@@ -414,7 +399,7 @@ class te {
|
|
|
414
399
|
* @param initial - Начальный статус (по умолчанию 'valid')
|
|
415
400
|
*/
|
|
416
401
|
constructor(e = "valid") {
|
|
417
|
-
this._status = g(e), this.status =
|
|
402
|
+
this._status = g(e), this.status = f(() => this._status.value), this.valid = f(() => this._status.value === "valid"), this.invalid = f(() => this._status.value === "invalid"), this.pending = f(() => this._status.value === "pending"), this.disabled = f(() => this._status.value === "disabled");
|
|
418
403
|
}
|
|
419
404
|
/**
|
|
420
405
|
* Начать валидацию
|
|
@@ -496,53 +481,8 @@ class te {
|
|
|
496
481
|
enable(e = !1) {
|
|
497
482
|
this._status.value = e ? "invalid" : "valid";
|
|
498
483
|
}
|
|
499
|
-
/**
|
|
500
|
-
* Обработать событие (альтернативный API)
|
|
501
|
-
*
|
|
502
|
-
* @param event - Событие для обработки
|
|
503
|
-
*
|
|
504
|
-
* @example
|
|
505
|
-
* ```typescript
|
|
506
|
-
* statusMachine.dispatch({ type: 'START_VALIDATION' });
|
|
507
|
-
* statusMachine.dispatch({ type: 'VALIDATION_FAILURE' });
|
|
508
|
-
* ```
|
|
509
|
-
*/
|
|
510
|
-
dispatch(e) {
|
|
511
|
-
switch (e.type) {
|
|
512
|
-
case "START_VALIDATION":
|
|
513
|
-
this.startValidation();
|
|
514
|
-
break;
|
|
515
|
-
case "VALIDATION_SUCCESS":
|
|
516
|
-
this.completeValidation(!1);
|
|
517
|
-
break;
|
|
518
|
-
case "VALIDATION_FAILURE":
|
|
519
|
-
this.completeValidation(!0);
|
|
520
|
-
break;
|
|
521
|
-
case "DISABLE":
|
|
522
|
-
this.disable();
|
|
523
|
-
break;
|
|
524
|
-
case "ENABLE":
|
|
525
|
-
this.enable(e.hasErrors);
|
|
526
|
-
break;
|
|
527
|
-
case "SET_ERRORS":
|
|
528
|
-
this.setErrors(e.hasErrors);
|
|
529
|
-
break;
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Получить текущий статус
|
|
534
|
-
*/
|
|
535
|
-
getStatus() {
|
|
536
|
-
return this._status.value;
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* Проверить, можно ли начать валидацию
|
|
540
|
-
*/
|
|
541
|
-
canValidate() {
|
|
542
|
-
return this._status.value !== "disabled";
|
|
543
|
-
}
|
|
544
484
|
}
|
|
545
|
-
class
|
|
485
|
+
class ne extends M {
|
|
546
486
|
// ============================================================================
|
|
547
487
|
// Приватные сигналы
|
|
548
488
|
// ============================================================================
|
|
@@ -594,13 +534,13 @@ class se extends M {
|
|
|
594
534
|
* Менеджер подписок для централизованного cleanup
|
|
595
535
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
596
536
|
*/
|
|
597
|
-
disposers = new
|
|
537
|
+
disposers = new I();
|
|
598
538
|
component;
|
|
599
539
|
// ============================================================================
|
|
600
540
|
// Конструктор
|
|
601
541
|
// ============================================================================
|
|
602
542
|
constructor(e) {
|
|
603
|
-
super(), this.validators = e.validators || [], this.asyncValidators = e.asyncValidators || [], this.updateOn = e.updateOn || "blur", this.debounceMs = e.debounce || 0, this.component = e.component, this._value = e.valueSignal ?? g(e.value), this.initialValue = this._value.peek(), this._errors = g([]), this._componentProps = g(e.componentProps || {}), this.statusMachine = new
|
|
543
|
+
super(), this.validators = e.validators || [], this.asyncValidators = e.asyncValidators || [], this.updateOn = e.updateOn || "blur", this.debounceMs = e.debounce || 0, this.component = e.component, this._value = e.valueSignal ?? g(e.value), this.initialValue = this._value.peek(), this._errors = g([]), this._componentProps = g(e.componentProps || {}), this.statusMachine = new ie(e.disabled ? "disabled" : "valid"), this.value = f(() => this._value.value), this.valid = f(() => this.statusMachine.valid.value), this.invalid = f(() => this.statusMachine.invalid.value), this.pending = f(() => this.statusMachine.pending.value), this.status = f(() => this.statusMachine.status.value), this.disabled = f(() => this.statusMachine.disabled.value), this.errors = f(() => this._errors.value), this.componentProps = f(() => this._componentProps.value), this.shouldShowError = f(
|
|
604
544
|
() => this.statusMachine.invalid.value && (this._touched.value || this._dirty.value)
|
|
605
545
|
);
|
|
606
546
|
}
|
|
@@ -613,12 +553,12 @@ class se extends M {
|
|
|
613
553
|
setValue(e, t) {
|
|
614
554
|
if (this._value.value = e, this._dirty.value = !0, t?.emitEvent === !1)
|
|
615
555
|
return;
|
|
616
|
-
const s = this.validators.length > 0 || this.asyncValidators.length > 0,
|
|
556
|
+
const s = this.validators.length > 0 || this.asyncValidators.length > 0, r = this._errors.value.length > 0;
|
|
617
557
|
if (this.updateOn === "change") {
|
|
618
558
|
this.validate();
|
|
619
559
|
return;
|
|
620
560
|
}
|
|
621
|
-
|
|
561
|
+
r && s && this.validate();
|
|
622
562
|
}
|
|
623
563
|
patchValue(e) {
|
|
624
564
|
this.setValue(e);
|
|
@@ -712,19 +652,19 @@ class se extends M {
|
|
|
712
652
|
if (this.cancelPendingValidation(), t <= 0 || this.asyncValidators.length === 0)
|
|
713
653
|
return this.validateImmediate();
|
|
714
654
|
const s = new AbortController();
|
|
715
|
-
return new Promise((
|
|
716
|
-
this.pendingValidation = { resolve:
|
|
655
|
+
return new Promise((r) => {
|
|
656
|
+
this.pendingValidation = { resolve: r, abortController: s }, this.validateDebounceTimer = setTimeout(async () => {
|
|
717
657
|
if (this.validateDebounceTimer = void 0, s.signal.aborted) {
|
|
718
|
-
|
|
658
|
+
r(!1);
|
|
719
659
|
return;
|
|
720
660
|
}
|
|
721
661
|
this.pendingValidation = void 0;
|
|
722
|
-
const
|
|
723
|
-
|
|
662
|
+
const n = await this.validateImmediate(s);
|
|
663
|
+
r(n);
|
|
724
664
|
}, t), s.signal.addEventListener(
|
|
725
665
|
"abort",
|
|
726
666
|
() => {
|
|
727
|
-
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0),
|
|
667
|
+
this.validateDebounceTimer && (clearTimeout(this.validateDebounceTimer), this.validateDebounceTimer = void 0), r(!1);
|
|
728
668
|
},
|
|
729
669
|
{ once: !0 }
|
|
730
670
|
);
|
|
@@ -743,17 +683,17 @@ class se extends M {
|
|
|
743
683
|
async validateImmediate(e) {
|
|
744
684
|
const t = e ?? new AbortController();
|
|
745
685
|
e || this.currentAbortController?.abort(), this.currentAbortController = t;
|
|
746
|
-
const { signal: s } = t,
|
|
747
|
-
for (const
|
|
748
|
-
const l =
|
|
749
|
-
l &&
|
|
686
|
+
const { signal: s } = t, r = [];
|
|
687
|
+
for (const a of this.validators) {
|
|
688
|
+
const l = a(this._value.value);
|
|
689
|
+
l && r.push(l);
|
|
750
690
|
}
|
|
751
691
|
if (s.aborted)
|
|
752
692
|
return !1;
|
|
753
|
-
if (
|
|
754
|
-
this._errors.value =
|
|
755
|
-
const
|
|
756
|
-
if (this.statusMachine.setErrors(
|
|
693
|
+
if (r.length > 0) {
|
|
694
|
+
this._errors.value = r;
|
|
695
|
+
const a = r.some((l) => l.severity !== "warning");
|
|
696
|
+
if (this.statusMachine.setErrors(a), a)
|
|
757
697
|
return !1;
|
|
758
698
|
}
|
|
759
699
|
if (this.asyncValidators.length > 0) {
|
|
@@ -761,19 +701,19 @@ class se extends M {
|
|
|
761
701
|
return !1;
|
|
762
702
|
this.statusMachine.startValidation();
|
|
763
703
|
try {
|
|
764
|
-
const
|
|
765
|
-
this.asyncValidators.map(async (
|
|
704
|
+
const a = await Promise.all(
|
|
705
|
+
this.asyncValidators.map(async (d) => {
|
|
766
706
|
if (s.aborted)
|
|
767
707
|
throw new DOMException("Validation aborted", "AbortError");
|
|
768
708
|
try {
|
|
769
|
-
const u = await
|
|
709
|
+
const u = await d(this._value.value, { signal: s });
|
|
770
710
|
if (s.aborted)
|
|
771
711
|
throw new DOMException("Validation aborted", "AbortError");
|
|
772
712
|
return u;
|
|
773
713
|
} catch (u) {
|
|
774
714
|
if (u instanceof DOMException && u.name === "AbortError")
|
|
775
715
|
throw u;
|
|
776
|
-
return
|
|
716
|
+
return k.handle(
|
|
777
717
|
u,
|
|
778
718
|
"FieldNode AsyncValidator",
|
|
779
719
|
A.CONVERT
|
|
@@ -783,20 +723,20 @@ class se extends M {
|
|
|
783
723
|
);
|
|
784
724
|
if (s.aborted)
|
|
785
725
|
return !1;
|
|
786
|
-
const l =
|
|
726
|
+
const l = a.filter((d) => d !== null);
|
|
787
727
|
if (l.length > 0) {
|
|
788
728
|
this._errors.value = l;
|
|
789
|
-
const
|
|
790
|
-
if (this.statusMachine.completeValidation(
|
|
729
|
+
const d = l.some((u) => u.severity !== "warning");
|
|
730
|
+
if (this.statusMachine.completeValidation(d), d)
|
|
791
731
|
return !1;
|
|
792
732
|
}
|
|
793
|
-
} catch (
|
|
794
|
-
if (
|
|
733
|
+
} catch (a) {
|
|
734
|
+
if (a instanceof DOMException && a.name === "AbortError")
|
|
795
735
|
return !1;
|
|
796
|
-
throw
|
|
736
|
+
throw a;
|
|
797
737
|
}
|
|
798
738
|
}
|
|
799
|
-
return s.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this.statusMachine.completeValidation(!1)), !this._errors.value.some((
|
|
739
|
+
return s.aborted ? !1 : ((this.validators.length > 0 || this.asyncValidators.length > 0) && (this._errors.value = [], this.statusMachine.completeValidation(!1)), !this._errors.value.some((a) => a.severity !== "warning"));
|
|
800
740
|
}
|
|
801
741
|
setErrors(e) {
|
|
802
742
|
this._errors.value = e;
|
|
@@ -918,10 +858,10 @@ class se extends M {
|
|
|
918
858
|
*/
|
|
919
859
|
watch(e) {
|
|
920
860
|
const t = new AbortController(), s = _(() => {
|
|
921
|
-
const
|
|
922
|
-
e(
|
|
923
|
-
}),
|
|
924
|
-
return this.disposers.add(
|
|
861
|
+
const n = this.value.value;
|
|
862
|
+
e(n, t.signal);
|
|
863
|
+
}), r = N(O.Watch);
|
|
864
|
+
return this.disposers.add(r, () => {
|
|
925
865
|
t.abort(), s();
|
|
926
866
|
});
|
|
927
867
|
}
|
|
@@ -949,10 +889,10 @@ class se extends M {
|
|
|
949
889
|
*/
|
|
950
890
|
computeFrom(e, t) {
|
|
951
891
|
const s = _(() => {
|
|
952
|
-
const
|
|
953
|
-
this.setValue(
|
|
954
|
-
}),
|
|
955
|
-
return this.disposers.add(
|
|
892
|
+
const n = e.map((l) => l.value), a = t(...n);
|
|
893
|
+
this.setValue(a, { emitEvent: !1 });
|
|
894
|
+
}), r = N(O.ComputeFrom);
|
|
895
|
+
return this.disposers.add(r, s);
|
|
956
896
|
}
|
|
957
897
|
/**
|
|
958
898
|
* Очистить все ресурсы и таймеры
|
|
@@ -982,59 +922,59 @@ class se extends M {
|
|
|
982
922
|
}
|
|
983
923
|
}
|
|
984
924
|
}
|
|
985
|
-
function
|
|
986
|
-
const { getChildren: e, ownErrors: t, disabled: s } =
|
|
925
|
+
function L(i) {
|
|
926
|
+
const { getChildren: e, ownErrors: t, disabled: s } = i, r = f(() => t.value.length > 0 ? !1 : e().every((o) => o.disabled.value || o.valid.value)), n = f(() => !r.value), a = f(() => e().some((o) => o.pending.value)), l = f(() => e().some((o) => o.touched.value)), d = f(() => e().some((o) => o.dirty.value)), u = f(() => {
|
|
987
927
|
const o = [...t.value];
|
|
988
|
-
for (const
|
|
989
|
-
o.push(...
|
|
928
|
+
for (const m of e())
|
|
929
|
+
o.push(...m.errors.value);
|
|
990
930
|
return o;
|
|
991
|
-
}), v =
|
|
931
|
+
}), v = f(() => s?.value ? "disabled" : a.value ? "pending" : n.value ? "invalid" : "valid");
|
|
992
932
|
return {
|
|
993
|
-
valid:
|
|
994
|
-
invalid:
|
|
995
|
-
pending:
|
|
933
|
+
valid: r,
|
|
934
|
+
invalid: n,
|
|
935
|
+
pending: a,
|
|
996
936
|
touched: l,
|
|
997
|
-
dirty:
|
|
937
|
+
dirty: d,
|
|
998
938
|
errors: u,
|
|
999
939
|
status: v
|
|
1000
940
|
};
|
|
1001
941
|
}
|
|
1002
|
-
function
|
|
1003
|
-
return typeof
|
|
942
|
+
function j(i) {
|
|
943
|
+
return typeof i == "object" && i !== null && "getProxy" in i && typeof i.getProxy == "function";
|
|
1004
944
|
}
|
|
1005
|
-
const
|
|
1006
|
-
function
|
|
945
|
+
const U = "$";
|
|
946
|
+
function ae(i, e) {
|
|
1007
947
|
let t;
|
|
1008
948
|
const s = () => {
|
|
1009
949
|
if (!t) {
|
|
1010
|
-
const
|
|
1011
|
-
e.forEach((
|
|
1012
|
-
|
|
1013
|
-
}), t =
|
|
950
|
+
const r = {};
|
|
951
|
+
e.forEach((n, a) => {
|
|
952
|
+
r[a] = n && j(n) ? n.getProxy() : n;
|
|
953
|
+
}), t = r;
|
|
1014
954
|
}
|
|
1015
955
|
return t;
|
|
1016
956
|
};
|
|
1017
|
-
return new Proxy(
|
|
1018
|
-
get: (
|
|
1019
|
-
if (
|
|
957
|
+
return new Proxy(i, {
|
|
958
|
+
get: (r, n) => {
|
|
959
|
+
if (n === U)
|
|
1020
960
|
return s();
|
|
1021
|
-
if (
|
|
1022
|
-
return
|
|
1023
|
-
if (typeof
|
|
1024
|
-
const
|
|
1025
|
-
return
|
|
961
|
+
if (n in r)
|
|
962
|
+
return r[n];
|
|
963
|
+
if (typeof n == "string" && e.has(n)) {
|
|
964
|
+
const a = e.get(n);
|
|
965
|
+
return a && j(a) ? a.getProxy() : a;
|
|
1026
966
|
}
|
|
1027
967
|
},
|
|
1028
|
-
set: (
|
|
1029
|
-
has: (
|
|
1030
|
-
ownKeys: (
|
|
1031
|
-
const
|
|
1032
|
-
return [.../* @__PURE__ */ new Set([...
|
|
968
|
+
set: (r, n, a) => typeof n == "string" && e.has(n) ? !1 : (r[n] = a, !0),
|
|
969
|
+
has: (r, n) => n === U || typeof n == "string" && e.has(n) ? !0 : n in r,
|
|
970
|
+
ownKeys: (r) => {
|
|
971
|
+
const n = Reflect.ownKeys(r), a = Array.from(e.keys());
|
|
972
|
+
return [.../* @__PURE__ */ new Set([...n, ...a])];
|
|
1033
973
|
},
|
|
1034
|
-
getOwnPropertyDescriptor: (
|
|
974
|
+
getOwnPropertyDescriptor: (r, n) => typeof n == "string" && e.has(n) ? { enumerable: !0, configurable: !0 } : Reflect.getOwnPropertyDescriptor(r, n)
|
|
1035
975
|
});
|
|
1036
976
|
}
|
|
1037
|
-
class
|
|
977
|
+
class oe {
|
|
1038
978
|
/**
|
|
1039
979
|
* @param form - Форма для отправки
|
|
1040
980
|
*/
|
|
@@ -1044,7 +984,7 @@ class re {
|
|
|
1044
984
|
/** Внутренний сигнал состояния отправки */
|
|
1045
985
|
_submitting = g(!1);
|
|
1046
986
|
/** Публичный read-only сигнал состояния отправки */
|
|
1047
|
-
submitting =
|
|
987
|
+
submitting = f(() => this._submitting.value);
|
|
1048
988
|
/**
|
|
1049
989
|
* Отправить форму
|
|
1050
990
|
*
|
|
@@ -1079,8 +1019,8 @@ class re {
|
|
|
1079
1019
|
* ```
|
|
1080
1020
|
*/
|
|
1081
1021
|
async submit(e, t) {
|
|
1082
|
-
const { skipValidation: s = !1, skipTouch:
|
|
1083
|
-
if (
|
|
1022
|
+
const { skipValidation: s = !1, skipTouch: r = !1 } = t || {};
|
|
1023
|
+
if (r || this.form.markAsTouched(), !s && !await this.form.validate())
|
|
1084
1024
|
return null;
|
|
1085
1025
|
this._submitting.value = !0;
|
|
1086
1026
|
try {
|
|
@@ -1114,32 +1054,26 @@ class re {
|
|
|
1114
1054
|
* ```
|
|
1115
1055
|
*/
|
|
1116
1056
|
async submitWithResult(e, t) {
|
|
1117
|
-
const { skipValidation: s = !1, skipTouch:
|
|
1118
|
-
if (
|
|
1057
|
+
const { skipValidation: s = !1, skipTouch: r = !1 } = t || {};
|
|
1058
|
+
if (r || this.form.markAsTouched(), !s && !await this.form.validate())
|
|
1119
1059
|
return { success: !1, data: null };
|
|
1120
1060
|
this._submitting.value = !0;
|
|
1121
1061
|
try {
|
|
1122
1062
|
return { success: !0, data: await e(this.form.getValue()) };
|
|
1123
|
-
} catch (
|
|
1063
|
+
} catch (n) {
|
|
1124
1064
|
return {
|
|
1125
1065
|
success: !1,
|
|
1126
1066
|
data: null,
|
|
1127
|
-
error:
|
|
1067
|
+
error: n instanceof Error ? n : new Error(String(n))
|
|
1128
1068
|
};
|
|
1129
1069
|
} finally {
|
|
1130
1070
|
this._submitting.value = !1;
|
|
1131
1071
|
}
|
|
1132
1072
|
}
|
|
1133
|
-
/**
|
|
1134
|
-
* Проверить, идет ли отправка формы
|
|
1135
|
-
*/
|
|
1136
|
-
isSubmitting() {
|
|
1137
|
-
return this._submitting.value;
|
|
1138
|
-
}
|
|
1139
1073
|
}
|
|
1140
|
-
function
|
|
1074
|
+
function le(i) {
|
|
1141
1075
|
const e = [];
|
|
1142
|
-
for (const t of
|
|
1076
|
+
for (const t of i.split(".")) {
|
|
1143
1077
|
const s = /^([^[\]]+)(?:\[(\d+)\])?$/.exec(t);
|
|
1144
1078
|
if (!s) return [];
|
|
1145
1079
|
e.push(s[2] !== void 0 ? { key: s[1], index: Number(s[2]) } : { key: s[1] });
|
|
@@ -1159,7 +1093,7 @@ class S extends M {
|
|
|
1159
1093
|
/**
|
|
1160
1094
|
* Менеджер подписок для централизованного cleanup
|
|
1161
1095
|
*/
|
|
1162
|
-
disposers = new
|
|
1096
|
+
disposers = new I();
|
|
1163
1097
|
/**
|
|
1164
1098
|
* Ссылка на Proxy-инстанс
|
|
1165
1099
|
*/
|
|
@@ -1171,7 +1105,7 @@ class S extends M {
|
|
|
1171
1105
|
/**
|
|
1172
1106
|
* Фабрика для создания узлов формы
|
|
1173
1107
|
*/
|
|
1174
|
-
nodeFactory = new
|
|
1108
|
+
nodeFactory = new ue();
|
|
1175
1109
|
// ============================================================================
|
|
1176
1110
|
// Приватные сигналы состояния (inline из StateManager)
|
|
1177
1111
|
// ============================================================================
|
|
@@ -1202,24 +1136,24 @@ class S extends M {
|
|
|
1202
1136
|
status;
|
|
1203
1137
|
submitting;
|
|
1204
1138
|
constructor(e) {
|
|
1205
|
-
super(), this.formSubmitter = new
|
|
1206
|
-
const t = e.form, s = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t),
|
|
1207
|
-
for (const [l,
|
|
1208
|
-
const u = this.createNode(
|
|
1139
|
+
super(), this.formSubmitter = new oe(this);
|
|
1140
|
+
const t = e.form, s = t != null && typeof t == "object" && ("valueSignal" in t || "value" in t), n = "form" in e && !s ? e.form : e;
|
|
1141
|
+
for (const [l, d] of Object.entries(n)) {
|
|
1142
|
+
const u = this.createNode(d);
|
|
1209
1143
|
this._fields.set(l, u);
|
|
1210
1144
|
}
|
|
1211
|
-
this.value =
|
|
1145
|
+
this.value = f(() => {
|
|
1212
1146
|
const l = {};
|
|
1213
|
-
return this._fields.forEach((
|
|
1214
|
-
l[u] =
|
|
1147
|
+
return this._fields.forEach((d, u) => {
|
|
1148
|
+
l[u] = d.value.value;
|
|
1215
1149
|
}), l;
|
|
1216
1150
|
});
|
|
1217
|
-
const
|
|
1151
|
+
const a = L({
|
|
1218
1152
|
getChildren: () => Array.from(this._fields.values()),
|
|
1219
1153
|
ownErrors: this._formErrors,
|
|
1220
1154
|
disabled: this._disabled
|
|
1221
1155
|
});
|
|
1222
|
-
this.valid =
|
|
1156
|
+
this.valid = a.valid, this.invalid = a.invalid, this.pending = a.pending, this.touched = a.touched, this.dirty = a.dirty, this.errors = a.errors, this.status = a.status, this.submitting = this.formSubmitter.submitting;
|
|
1223
1157
|
}
|
|
1224
1158
|
// ============================================================================
|
|
1225
1159
|
// Приватный метод для создания Proxy
|
|
@@ -1229,7 +1163,7 @@ class S extends M {
|
|
|
1229
1163
|
* @see buildFormProxy
|
|
1230
1164
|
*/
|
|
1231
1165
|
buildProxy() {
|
|
1232
|
-
return
|
|
1166
|
+
return ae(this, this._fields);
|
|
1233
1167
|
}
|
|
1234
1168
|
// ============================================================================
|
|
1235
1169
|
// Реализация абстрактных методов FormNode
|
|
@@ -1241,23 +1175,23 @@ class S extends M {
|
|
|
1241
1175
|
}), e;
|
|
1242
1176
|
}
|
|
1243
1177
|
setValue(e, t) {
|
|
1244
|
-
for (const [s,
|
|
1245
|
-
const
|
|
1246
|
-
if (
|
|
1247
|
-
const
|
|
1248
|
-
if (
|
|
1249
|
-
|
|
1178
|
+
for (const [s, r] of Object.entries(e)) {
|
|
1179
|
+
const n = this._fields.get(s);
|
|
1180
|
+
if (n) {
|
|
1181
|
+
const a = this._fieldSignals.get(n) ?? n.value;
|
|
1182
|
+
if ($(a)) continue;
|
|
1183
|
+
n.setValue(r, t);
|
|
1250
1184
|
}
|
|
1251
1185
|
}
|
|
1252
1186
|
}
|
|
1253
1187
|
patchValue(e) {
|
|
1254
1188
|
X(() => {
|
|
1255
1189
|
for (const [t, s] of Object.entries(e)) {
|
|
1256
|
-
const
|
|
1257
|
-
if (
|
|
1258
|
-
const
|
|
1259
|
-
if (
|
|
1260
|
-
|
|
1190
|
+
const r = this._fields.get(t);
|
|
1191
|
+
if (r && s !== void 0) {
|
|
1192
|
+
const n = this._fieldSignals.get(r) ?? r.value;
|
|
1193
|
+
if ($(n)) continue;
|
|
1194
|
+
r.setValue(s, { emitEvent: !1 });
|
|
1261
1195
|
}
|
|
1262
1196
|
}
|
|
1263
1197
|
});
|
|
@@ -1281,8 +1215,8 @@ class S extends M {
|
|
|
1281
1215
|
*/
|
|
1282
1216
|
reset(e) {
|
|
1283
1217
|
this._formErrors.value = [], this._fields.forEach((t, s) => {
|
|
1284
|
-
const
|
|
1285
|
-
t.reset(
|
|
1218
|
+
const r = e?.[s];
|
|
1219
|
+
t.reset(r);
|
|
1286
1220
|
});
|
|
1287
1221
|
}
|
|
1288
1222
|
/**
|
|
@@ -1329,10 +1263,6 @@ class S extends M {
|
|
|
1329
1263
|
* - form.email вместо form.fields.get('email')
|
|
1330
1264
|
* - form.address.city вместо form.fields.get('address').fields.get('city')
|
|
1331
1265
|
*
|
|
1332
|
-
* Используется в:
|
|
1333
|
-
* - BehaviorApplicator для доступа к полям в behavior functions
|
|
1334
|
-
* - ValidationApplicator для доступа к форме в tree validators
|
|
1335
|
-
*
|
|
1336
1266
|
* @returns Proxy-инстанс с типобезопасным доступом к полям или сама форма, если proxy не доступен
|
|
1337
1267
|
*
|
|
1338
1268
|
* @example
|
|
@@ -1430,17 +1360,17 @@ class S extends M {
|
|
|
1430
1360
|
getFieldByPath(e) {
|
|
1431
1361
|
if (e.startsWith(".") || e.endsWith("."))
|
|
1432
1362
|
return;
|
|
1433
|
-
const t =
|
|
1363
|
+
const t = le(e);
|
|
1434
1364
|
if (t.length === 0)
|
|
1435
1365
|
return;
|
|
1436
1366
|
let s = this;
|
|
1437
|
-
for (const
|
|
1438
|
-
if (!(s instanceof S) || (s = s.getField(
|
|
1439
|
-
if (
|
|
1367
|
+
for (const r of t) {
|
|
1368
|
+
if (!(s instanceof S) || (s = s.getField(r.key), !s)) return;
|
|
1369
|
+
if (r.index !== void 0)
|
|
1440
1370
|
if ("at" in s && "length" in s && typeof s.at == "function") {
|
|
1441
|
-
const
|
|
1442
|
-
if (!
|
|
1443
|
-
s =
|
|
1371
|
+
const n = s.at(r.index);
|
|
1372
|
+
if (!n) return;
|
|
1373
|
+
s = n;
|
|
1444
1374
|
} else
|
|
1445
1375
|
return;
|
|
1446
1376
|
}
|
|
@@ -1474,16 +1404,16 @@ class S extends M {
|
|
|
1474
1404
|
* Связывает два поля: при изменении source автоматически обновляется target
|
|
1475
1405
|
*/
|
|
1476
1406
|
linkFields(e, t, s) {
|
|
1477
|
-
const
|
|
1478
|
-
if (!
|
|
1479
|
-
const
|
|
1480
|
-
throw new Error(`GroupNode.linkFields: field "${String(
|
|
1407
|
+
const r = this._fields.get(e), n = this._fields.get(t);
|
|
1408
|
+
if (!r || !n) {
|
|
1409
|
+
const d = r ? t : e;
|
|
1410
|
+
throw new Error(`GroupNode.linkFields: field "${String(d)}" not found`);
|
|
1481
1411
|
}
|
|
1482
|
-
const
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1485
|
-
}), l =
|
|
1486
|
-
return this.disposers.add(l,
|
|
1412
|
+
const a = _(() => {
|
|
1413
|
+
const d = r.value.value, u = s ? s(d) : d;
|
|
1414
|
+
n.setValue(u, { emitEvent: !1 });
|
|
1415
|
+
}), l = N(O.LinkFields);
|
|
1416
|
+
return this.disposers.add(l, a);
|
|
1487
1417
|
}
|
|
1488
1418
|
/**
|
|
1489
1419
|
* Подписка на изменения вложенного поля по строковому пути
|
|
@@ -1517,10 +1447,10 @@ class S extends M {
|
|
|
1517
1447
|
const s = this.getFieldByPath(e);
|
|
1518
1448
|
if (!s)
|
|
1519
1449
|
throw new Error(`GroupNode.watchField: field "${e}" not found`);
|
|
1520
|
-
const
|
|
1450
|
+
const r = _(() => {
|
|
1521
1451
|
t(s.value.value);
|
|
1522
|
-
}),
|
|
1523
|
-
return this.disposers.add(
|
|
1452
|
+
}), n = N(O.WatchField);
|
|
1453
|
+
return this.disposers.add(n, r);
|
|
1524
1454
|
}
|
|
1525
1455
|
/**
|
|
1526
1456
|
* Подписка на вложенное поле по строковому пути ("address.city").
|
|
@@ -1530,10 +1460,10 @@ class S extends M {
|
|
|
1530
1460
|
const s = this.getFieldByPath(e);
|
|
1531
1461
|
if (!s)
|
|
1532
1462
|
throw new Error(`GroupNode.watchFieldByPath: field "${e}" not found`);
|
|
1533
|
-
const
|
|
1463
|
+
const r = _(() => {
|
|
1534
1464
|
t(s.value.value);
|
|
1535
|
-
}),
|
|
1536
|
-
return this.disposers.add(
|
|
1465
|
+
}), n = N(O.WatchField);
|
|
1466
|
+
return this.disposers.add(n, r);
|
|
1537
1467
|
}
|
|
1538
1468
|
/**
|
|
1539
1469
|
* Hook: вызывается после disable()
|
|
@@ -1572,7 +1502,7 @@ class S extends M {
|
|
|
1572
1502
|
});
|
|
1573
1503
|
}
|
|
1574
1504
|
}
|
|
1575
|
-
class
|
|
1505
|
+
class B extends M {
|
|
1576
1506
|
// ============================================================================
|
|
1577
1507
|
// Приватные поля
|
|
1578
1508
|
// ============================================================================
|
|
@@ -1583,15 +1513,10 @@ class U extends M {
|
|
|
1583
1513
|
* Менеджер подписок для централизованного cleanup
|
|
1584
1514
|
* Использует SubscriptionManager вместо массива для управления подписками
|
|
1585
1515
|
*/
|
|
1586
|
-
disposers = new
|
|
1516
|
+
disposers = new I();
|
|
1587
1517
|
/** Array-level validation errors (e.g., "минимум 1 элемент") */
|
|
1588
1518
|
_arrayErrors = g([]);
|
|
1589
1519
|
// ============================================================================
|
|
1590
|
-
// Приватные поля для сохранения схем
|
|
1591
|
-
// ============================================================================
|
|
1592
|
-
validationSchemaFn;
|
|
1593
|
-
behaviorSchemaFn;
|
|
1594
|
-
// ============================================================================
|
|
1595
1520
|
// Публичные computed signals
|
|
1596
1521
|
// ============================================================================
|
|
1597
1522
|
value;
|
|
@@ -1608,10 +1533,10 @@ class U extends M {
|
|
|
1608
1533
|
// ============================================================================
|
|
1609
1534
|
constructor(e, t = []) {
|
|
1610
1535
|
super(), this.itemSchema = e, this.initialItems = t, this.items = g([]);
|
|
1611
|
-
for (const
|
|
1612
|
-
this.push(
|
|
1613
|
-
this.length =
|
|
1614
|
-
const s =
|
|
1536
|
+
for (const r of t)
|
|
1537
|
+
this.push(r);
|
|
1538
|
+
this.length = f(() => this.items.value.length), this.value = f(() => this.items.value.map((r) => r.value.value));
|
|
1539
|
+
const s = L({
|
|
1615
1540
|
getChildren: () => this.items.value,
|
|
1616
1541
|
ownErrors: this._arrayErrors
|
|
1617
1542
|
});
|
|
@@ -1637,7 +1562,7 @@ class U extends M {
|
|
|
1637
1562
|
*/
|
|
1638
1563
|
removeAt(e) {
|
|
1639
1564
|
if (e < 0 || e >= this.items.value.length) {
|
|
1640
|
-
|
|
1565
|
+
k.handle(
|
|
1641
1566
|
new Error(
|
|
1642
1567
|
`ArrayNode.removeAt: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1643
1568
|
),
|
|
@@ -1647,7 +1572,7 @@ class U extends M {
|
|
|
1647
1572
|
return;
|
|
1648
1573
|
}
|
|
1649
1574
|
const t = this.items.value[e];
|
|
1650
|
-
this.items.value = this.items.value.filter((s,
|
|
1575
|
+
this.items.value = this.items.value.filter((s, r) => r !== e), t && "dispose" in t && typeof t.dispose == "function" && t.dispose();
|
|
1651
1576
|
}
|
|
1652
1577
|
/**
|
|
1653
1578
|
* Вставить элемент в массив
|
|
@@ -1656,7 +1581,7 @@ class U extends M {
|
|
|
1656
1581
|
*/
|
|
1657
1582
|
insert(e, t) {
|
|
1658
1583
|
if (e < 0 || e > this.items.value.length) {
|
|
1659
|
-
|
|
1584
|
+
k.handle(
|
|
1660
1585
|
new Error(
|
|
1661
1586
|
`ArrayNode.insert: index ${e} out of bounds (length: ${this.items.value.length})`
|
|
1662
1587
|
),
|
|
@@ -1665,8 +1590,8 @@ class U extends M {
|
|
|
1665
1590
|
);
|
|
1666
1591
|
return;
|
|
1667
1592
|
}
|
|
1668
|
-
const s = this.createItem(t),
|
|
1669
|
-
|
|
1593
|
+
const s = this.createItem(t), r = [...this.items.value];
|
|
1594
|
+
r.splice(e, 0, s), this.items.value = r;
|
|
1670
1595
|
}
|
|
1671
1596
|
/**
|
|
1672
1597
|
* Переместить элемент массива с позиции `from` на позицию `to`
|
|
@@ -1687,7 +1612,7 @@ class U extends M {
|
|
|
1687
1612
|
move(e, t) {
|
|
1688
1613
|
const s = this.items.value.length;
|
|
1689
1614
|
if (e < 0 || e >= s || t < 0 || t >= s) {
|
|
1690
|
-
|
|
1615
|
+
k.handle(
|
|
1691
1616
|
new Error(`ArrayNode.move: index out of bounds (from=${e}, to=${t}, length=${s})`),
|
|
1692
1617
|
"ArrayNode.move",
|
|
1693
1618
|
A.LOG
|
|
@@ -1695,8 +1620,8 @@ class U extends M {
|
|
|
1695
1620
|
return;
|
|
1696
1621
|
}
|
|
1697
1622
|
if (e === t) return;
|
|
1698
|
-
const
|
|
1699
|
-
|
|
1623
|
+
const r = [...this.items.value], [n] = r.splice(e, 1);
|
|
1624
|
+
r.splice(t, 0, n), this.items.value = r;
|
|
1700
1625
|
}
|
|
1701
1626
|
/**
|
|
1702
1627
|
* Поменять местами два элемента массива
|
|
@@ -1715,7 +1640,7 @@ class U extends M {
|
|
|
1715
1640
|
swap(e, t) {
|
|
1716
1641
|
const s = this.items.value.length;
|
|
1717
1642
|
if (e < 0 || e >= s || t < 0 || t >= s) {
|
|
1718
|
-
|
|
1643
|
+
k.handle(
|
|
1719
1644
|
new Error(`ArrayNode.swap: index out of bounds (a=${e}, b=${t}, length=${s})`),
|
|
1720
1645
|
"ArrayNode.swap",
|
|
1721
1646
|
A.LOG
|
|
@@ -1723,8 +1648,8 @@ class U extends M {
|
|
|
1723
1648
|
return;
|
|
1724
1649
|
}
|
|
1725
1650
|
if (e === t) return;
|
|
1726
|
-
const
|
|
1727
|
-
[
|
|
1651
|
+
const r = [...this.items.value];
|
|
1652
|
+
[r[e], r[t]] = [r[t], r[e]], this.items.value = r;
|
|
1728
1653
|
}
|
|
1729
1654
|
/**
|
|
1730
1655
|
* Удалить все элементы массива
|
|
@@ -1756,7 +1681,7 @@ class U extends M {
|
|
|
1756
1681
|
}
|
|
1757
1682
|
setValue(e, t) {
|
|
1758
1683
|
this.clear(), e.forEach((s) => this.push(s)), t?.emitEvent !== !1 && this.validate().catch((s) => {
|
|
1759
|
-
|
|
1684
|
+
k.handle(s, "ArrayNode.setValue", A.LOG);
|
|
1760
1685
|
});
|
|
1761
1686
|
}
|
|
1762
1687
|
patchValue(e) {
|
|
@@ -1890,8 +1815,8 @@ class U extends M {
|
|
|
1890
1815
|
*/
|
|
1891
1816
|
forEach(e) {
|
|
1892
1817
|
this.items.value.forEach((t, s) => {
|
|
1893
|
-
const
|
|
1894
|
-
e(
|
|
1818
|
+
const r = t.getProxy();
|
|
1819
|
+
e(r, s);
|
|
1895
1820
|
});
|
|
1896
1821
|
}
|
|
1897
1822
|
/**
|
|
@@ -1901,8 +1826,8 @@ class U extends M {
|
|
|
1901
1826
|
*/
|
|
1902
1827
|
map(e) {
|
|
1903
1828
|
return this.items.value.map((t, s) => {
|
|
1904
|
-
const
|
|
1905
|
-
return e(
|
|
1829
|
+
const r = t.getProxy();
|
|
1830
|
+
return e(r, s);
|
|
1906
1831
|
});
|
|
1907
1832
|
}
|
|
1908
1833
|
// ============================================================================
|
|
@@ -1915,7 +1840,7 @@ class U extends M {
|
|
|
1915
1840
|
createItem(e) {
|
|
1916
1841
|
if (this.isGroupSchema(this.itemSchema)) {
|
|
1917
1842
|
const t = new S(this.itemSchema);
|
|
1918
|
-
return e && t.patchValue(e),
|
|
1843
|
+
return e && t.patchValue(e), t;
|
|
1919
1844
|
}
|
|
1920
1845
|
throw new Error(
|
|
1921
1846
|
"ArrayNode поддерживает только GroupNode элементы. Для массива примитивов используйте обычное поле с типом массива."
|
|
@@ -1929,116 +1854,8 @@ class U extends M {
|
|
|
1929
1854
|
return typeof e == "object" && e !== null && !("component" in e) && !Array.isArray(e);
|
|
1930
1855
|
}
|
|
1931
1856
|
// ============================================================================
|
|
1932
|
-
// Validation Schema
|
|
1933
|
-
// ============================================================================
|
|
1934
|
-
/**
|
|
1935
|
-
* Применить validation schema ко всем элементам массива
|
|
1936
|
-
*
|
|
1937
|
-
* Validation schema будет применена к:
|
|
1938
|
-
* - Всем существующим элементам
|
|
1939
|
-
* - Всем новым элементам, добавляемым через push/insert
|
|
1940
|
-
*
|
|
1941
|
-
* @param schemaFn - Функция валидации для элемента массива
|
|
1942
|
-
*
|
|
1943
|
-
* @example
|
|
1944
|
-
* ```typescript
|
|
1945
|
-
* import { propertyValidation } from './validation/property-validation';
|
|
1946
|
-
*
|
|
1947
|
-
* form.properties.applyValidationSchema(propertyValidation);
|
|
1948
|
-
* ```
|
|
1949
|
-
*/
|
|
1950
|
-
applyValidationSchema(e) {
|
|
1951
|
-
this.validationSchemaFn = e, this.items.value.forEach((t) => {
|
|
1952
|
-
"applyValidationSchema" in t && typeof t.applyValidationSchema == "function" && t.applyValidationSchema(e);
|
|
1953
|
-
});
|
|
1954
|
-
}
|
|
1955
|
-
/**
|
|
1956
|
-
* Применить behavior schema ко всем элементам ArrayNode
|
|
1957
|
-
*
|
|
1958
|
-
* Автоматически применяется к новым элементам при push/insert.
|
|
1959
|
-
*
|
|
1960
|
-
* @param schemaFn - Behavior schema функция
|
|
1961
|
-
*
|
|
1962
|
-
* @example
|
|
1963
|
-
* ```typescript
|
|
1964
|
-
* import { addressBehavior } from './behaviors/address-behavior';
|
|
1965
|
-
*
|
|
1966
|
-
* form.addresses.applyBehaviorSchema(addressBehavior);
|
|
1967
|
-
* ```
|
|
1968
|
-
*/
|
|
1969
|
-
applyBehaviorSchema(e) {
|
|
1970
|
-
this.behaviorSchemaFn = e, this.items.value.forEach((t) => {
|
|
1971
|
-
"applyBehaviorSchema" in t && typeof t.applyBehaviorSchema == "function" && t.applyBehaviorSchema(e);
|
|
1972
|
-
});
|
|
1973
|
-
}
|
|
1974
|
-
// ============================================================================
|
|
1975
1857
|
// Методы-помощники для реактивности (Фаза 1)
|
|
1976
1858
|
// ============================================================================
|
|
1977
|
-
/**
|
|
1978
|
-
* Подписка на изменения конкретного поля во всех элементах массива
|
|
1979
|
-
* Срабатывает при изменении значения поля в любом элементе
|
|
1980
|
-
*
|
|
1981
|
-
* @param fieldKey - Ключ поля для отслеживания
|
|
1982
|
-
* @param callback - Функция, вызываемая при изменении, получает массив всех значений и индекс измененного элемента
|
|
1983
|
-
* @returns Функция отписки для cleanup
|
|
1984
|
-
*
|
|
1985
|
-
* @example
|
|
1986
|
-
* ```typescript
|
|
1987
|
-
* // Автоматический пересчет общей стоимости при изменении цен
|
|
1988
|
-
* const dispose = form.existingLoans.watchItems(
|
|
1989
|
-
* 'remainingAmount',
|
|
1990
|
-
* (amounts) => {
|
|
1991
|
-
* const totalDebt = amounts.reduce((sum, amount) => sum + (amount || 0), 0);
|
|
1992
|
-
* form.totalDebt.setValue(totalDebt);
|
|
1993
|
-
* }
|
|
1994
|
-
* );
|
|
1995
|
-
*
|
|
1996
|
-
* // При изменении любого remainingAmount → пересчитается totalDebt
|
|
1997
|
-
* form.existingLoans.at(0)?.remainingAmount.setValue(500000);
|
|
1998
|
-
*
|
|
1999
|
-
* // Cleanup
|
|
2000
|
-
* useEffect(() => dispose, []);
|
|
2001
|
-
* ```
|
|
2002
|
-
*/
|
|
2003
|
-
watchItems(e, t) {
|
|
2004
|
-
const s = _(() => {
|
|
2005
|
-
const a = this.items.value.map((n) => {
|
|
2006
|
-
if (n instanceof S)
|
|
2007
|
-
return n.getFieldByPath(e)?.value.value;
|
|
2008
|
-
});
|
|
2009
|
-
t(a);
|
|
2010
|
-
}), i = V(w.WatchItems);
|
|
2011
|
-
return this.disposers.add(i, s);
|
|
2012
|
-
}
|
|
2013
|
-
/**
|
|
2014
|
-
* Подписка на изменение длины массива
|
|
2015
|
-
* Срабатывает при добавлении/удалении элементов
|
|
2016
|
-
*
|
|
2017
|
-
* @param callback - Функция, вызываемая при изменении длины, получает новую длину
|
|
2018
|
-
* @returns Функция отписки для cleanup
|
|
2019
|
-
*
|
|
2020
|
-
* @example
|
|
2021
|
-
* ```typescript
|
|
2022
|
-
* // Обновление счетчика элементов в UI
|
|
2023
|
-
* const dispose = form.properties.watchLength((length) => {
|
|
2024
|
-
* console.log(`Количество объектов недвижимости: ${length}`);
|
|
2025
|
-
* form.propertyCount.setValue(length);
|
|
2026
|
-
* });
|
|
2027
|
-
*
|
|
2028
|
-
* form.properties.push({ title: 'Квартира', value: 5000000 });
|
|
2029
|
-
* // Выведет: "Количество объектов недвижимости: 1"
|
|
2030
|
-
*
|
|
2031
|
-
* // Cleanup
|
|
2032
|
-
* useEffect(() => dispose, []);
|
|
2033
|
-
* ```
|
|
2034
|
-
*/
|
|
2035
|
-
watchLength(e) {
|
|
2036
|
-
const t = _(() => {
|
|
2037
|
-
const i = this.length.value;
|
|
2038
|
-
e(i);
|
|
2039
|
-
}), s = V(w.WatchLength);
|
|
2040
|
-
return this.disposers.add(s, t);
|
|
2041
|
-
}
|
|
2042
1859
|
/**
|
|
2043
1860
|
* Очистить все ресурсы узла
|
|
2044
1861
|
* Рекурсивно очищает все subscriptions и элементы массива
|
|
@@ -2100,7 +1917,7 @@ class U extends M {
|
|
|
2100
1917
|
});
|
|
2101
1918
|
}
|
|
2102
1919
|
}
|
|
2103
|
-
class
|
|
1920
|
+
class ue {
|
|
2104
1921
|
/**
|
|
2105
1922
|
* Создает узел формы на основе конфигурации
|
|
2106
1923
|
*
|
|
@@ -2150,9 +1967,9 @@ class ne {
|
|
|
2150
1967
|
if (Array.isArray(e) && e.length >= 1)
|
|
2151
1968
|
return this.createArrayNodeFromArray(e);
|
|
2152
1969
|
if (this.isFieldConfig(e))
|
|
2153
|
-
return new
|
|
1970
|
+
return new ne(e);
|
|
2154
1971
|
if (this.isArrayConfig(e))
|
|
2155
|
-
return new
|
|
1972
|
+
return new B(
|
|
2156
1973
|
e.schema,
|
|
2157
1974
|
e.initialItems
|
|
2158
1975
|
);
|
|
@@ -2191,11 +2008,11 @@ class ne {
|
|
|
2191
2008
|
*/
|
|
2192
2009
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2193
2010
|
createArrayNodeFromArray(e) {
|
|
2194
|
-
const [t, ...s] = e,
|
|
2195
|
-
this.isGroupConfig(t) &&
|
|
2196
|
-
for (const
|
|
2197
|
-
this.isGroupConfig(
|
|
2198
|
-
return new
|
|
2011
|
+
const [t, ...s] = e, r = [];
|
|
2012
|
+
this.isGroupConfig(t) && r.push(this.extractValues(t));
|
|
2013
|
+
for (const n of s)
|
|
2014
|
+
this.isGroupConfig(n) ? r.push(this.extractValues(n)) : r.push(n);
|
|
2015
|
+
return new B(t, r);
|
|
2199
2016
|
}
|
|
2200
2017
|
/**
|
|
2201
2018
|
* Извлечь значения из схемы (рекурсивно)
|
|
@@ -2233,8 +2050,8 @@ class ne {
|
|
|
2233
2050
|
return e.map((t) => this.extractValues(t));
|
|
2234
2051
|
if (this.isGroupConfig(e)) {
|
|
2235
2052
|
const t = {};
|
|
2236
|
-
for (const [s,
|
|
2237
|
-
t[s] = this.extractValues(
|
|
2053
|
+
for (const [s, r] of Object.entries(e))
|
|
2054
|
+
t[s] = this.extractValues(r);
|
|
2238
2055
|
return t;
|
|
2239
2056
|
}
|
|
2240
2057
|
return e;
|
|
@@ -2314,7 +2131,7 @@ class ne {
|
|
|
2314
2131
|
return e != null && typeof e == "object" && !this.isFieldConfig(e) && !this.isArrayConfig(e);
|
|
2315
2132
|
}
|
|
2316
2133
|
}
|
|
2317
|
-
class
|
|
2134
|
+
class de extends M {
|
|
2318
2135
|
/**
|
|
2319
2136
|
* @param control Реактивный массив модели (`model.<path>`).
|
|
2320
2137
|
* @param buildItem Строитель формы элемента по его под-модели (инъекция, чтобы избежать цикла
|
|
@@ -2322,22 +2139,22 @@ class oe extends M {
|
|
|
2322
2139
|
*/
|
|
2323
2140
|
constructor(e, t) {
|
|
2324
2141
|
super(), this.control = e, this.buildItem = t, this.initial = e.toArray(), this.disposeSync = _(() => {
|
|
2325
|
-
const
|
|
2326
|
-
for (let u = 0; u <
|
|
2142
|
+
const r = e.length, n = [], a = [];
|
|
2143
|
+
for (let u = 0; u < r; u++) {
|
|
2327
2144
|
const v = e.at(u);
|
|
2328
2145
|
if (!v) continue;
|
|
2329
2146
|
let o = this.cache.get(v);
|
|
2330
|
-
o || (o = t(v), this.cache.set(v, o)),
|
|
2147
|
+
o || (o = t(v), this.cache.set(v, o)), n.push(v), a.push(o);
|
|
2331
2148
|
}
|
|
2332
|
-
const l = new Set(
|
|
2149
|
+
const l = new Set(n), d = [];
|
|
2333
2150
|
for (const u of this.mountedModels) {
|
|
2334
2151
|
if (l.has(u)) continue;
|
|
2335
2152
|
const v = this.cache.get(u);
|
|
2336
|
-
this.cache.delete(u), v &&
|
|
2153
|
+
this.cache.delete(u), v && d.push(v);
|
|
2337
2154
|
}
|
|
2338
|
-
this.mountedModels =
|
|
2339
|
-
}), this.length =
|
|
2340
|
-
const s =
|
|
2155
|
+
this.mountedModels = n, this.itemNodes.value = a, d.forEach((u) => this.disposeItemNode(u));
|
|
2156
|
+
}), this.length = f(() => this.itemNodes.value.length), this.value = f(() => this.itemNodes.value.map((r) => r.value.value));
|
|
2157
|
+
const s = L({
|
|
2341
2158
|
getChildren: () => this.itemNodes.value,
|
|
2342
2159
|
ownErrors: this._arrayErrors
|
|
2343
2160
|
});
|
|
@@ -2476,230 +2293,228 @@ class oe extends M {
|
|
|
2476
2293
|
this.disposeSync(), this.itemNodes.value.forEach((e) => this.disposeItemNode(e)), this.mountedModels = [];
|
|
2477
2294
|
}
|
|
2478
2295
|
}
|
|
2479
|
-
const
|
|
2480
|
-
function
|
|
2481
|
-
if (
|
|
2482
|
-
if (Array.isArray(
|
|
2483
|
-
for (const
|
|
2296
|
+
const z = (i) => i !== null && typeof i == "object" && !Array.isArray(i) && !(i instanceof Date) && !(typeof Blob < "u" && i instanceof Blob) && !(typeof File < "u" && i instanceof File);
|
|
2297
|
+
function D(i, e, t) {
|
|
2298
|
+
if (i == null || typeof i != "object" || i instanceof G) return;
|
|
2299
|
+
if (Array.isArray(i)) {
|
|
2300
|
+
for (const n of i) D(n, e, t);
|
|
2484
2301
|
return;
|
|
2485
2302
|
}
|
|
2486
|
-
const s =
|
|
2487
|
-
if (
|
|
2488
|
-
t.set(
|
|
2303
|
+
const s = i, r = s.array;
|
|
2304
|
+
if (r && typeof r.__path == "string" && typeof s.item == "function") {
|
|
2305
|
+
t.set(r.__path, s.item);
|
|
2489
2306
|
return;
|
|
2490
2307
|
}
|
|
2491
|
-
s.value instanceof
|
|
2308
|
+
s.value instanceof G ? e.set(s.value, {
|
|
2492
2309
|
component: s.component,
|
|
2493
2310
|
componentProps: s.componentProps,
|
|
2494
|
-
validators: s.validators,
|
|
2495
|
-
asyncValidators: s.asyncValidators,
|
|
2496
2311
|
updateOn: s.updateOn,
|
|
2497
2312
|
disabled: s.disabled,
|
|
2498
2313
|
debounce: s.debounce
|
|
2499
2314
|
}) : process.env.NODE_ENV !== "production" && s.component !== void 0 && ("valueSignal" in s || s.value != null) && console.warn(
|
|
2500
2315
|
"[reformer] createForm({ schema }): узел с `component` не распознан как поле — `value` не является сигналом модели. Ожидается `value: model.$.<path>`; проверьте, что не передан `value: model.<path>` (value-прокси) или `valueSignal:`."
|
|
2501
2316
|
);
|
|
2502
|
-
for (const [
|
|
2503
|
-
|
|
2317
|
+
for (const [n, a] of Object.entries(s))
|
|
2318
|
+
n !== "value" && D(a, e, t);
|
|
2504
2319
|
}
|
|
2505
|
-
function
|
|
2506
|
-
const
|
|
2507
|
-
for (const [
|
|
2508
|
-
const l = t === "" ?
|
|
2509
|
-
if (Array.isArray(
|
|
2320
|
+
function J(i, e, t, s) {
|
|
2321
|
+
const r = {};
|
|
2322
|
+
for (const [n, a] of Object.entries(e)) {
|
|
2323
|
+
const l = t === "" ? n : `${t}.${n}`;
|
|
2324
|
+
if (Array.isArray(a))
|
|
2510
2325
|
continue;
|
|
2511
|
-
if (
|
|
2512
|
-
|
|
2326
|
+
if (z(a)) {
|
|
2327
|
+
r[n] = J(i, a, l, s);
|
|
2513
2328
|
continue;
|
|
2514
2329
|
}
|
|
2515
|
-
const
|
|
2516
|
-
if (!
|
|
2517
|
-
const u = s.get(
|
|
2518
|
-
|
|
2330
|
+
const d = i.signalAt(l);
|
|
2331
|
+
if (!d) throw new Error(`createForm({ model }): не найден сигнал для пути "${l}"`);
|
|
2332
|
+
const u = s.get(d) ?? {};
|
|
2333
|
+
r[n] = { ...u, valueSignal: d };
|
|
2519
2334
|
}
|
|
2520
|
-
return
|
|
2335
|
+
return r;
|
|
2521
2336
|
}
|
|
2522
|
-
function
|
|
2523
|
-
for (const [s,
|
|
2524
|
-
const
|
|
2525
|
-
Array.isArray(
|
|
2337
|
+
function Y(i, e, t) {
|
|
2338
|
+
for (const [s, r] of Object.entries(i)) {
|
|
2339
|
+
const n = e === "" ? s : `${e}.${s}`;
|
|
2340
|
+
Array.isArray(r) || (z(r) ? Y(r, n, t) : t.push(n));
|
|
2526
2341
|
}
|
|
2527
2342
|
}
|
|
2528
|
-
function Q(
|
|
2529
|
-
const { model: e, schema: t, behavior: s } =
|
|
2530
|
-
t !== void 0 &&
|
|
2531
|
-
const
|
|
2532
|
-
for (const [o,
|
|
2533
|
-
if (!Array.isArray(
|
|
2534
|
-
const
|
|
2535
|
-
if (!
|
|
2536
|
-
const
|
|
2537
|
-
l.fields.set(o,
|
|
2343
|
+
function Q(i) {
|
|
2344
|
+
const { model: e, schema: t, behavior: s } = i, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2345
|
+
t !== void 0 && D(t, r, n);
|
|
2346
|
+
const a = J(e, e.get(), "", r), l = new S(a), d = e.get();
|
|
2347
|
+
for (const [o, m] of Object.entries(d)) {
|
|
2348
|
+
if (!Array.isArray(m)) continue;
|
|
2349
|
+
const c = n.get(o);
|
|
2350
|
+
if (!c) continue;
|
|
2351
|
+
const h = e[o], p = (y) => Q({ model: y, schema: c(y) }), E = new de(h, p);
|
|
2352
|
+
l.fields.set(o, E);
|
|
2538
2353
|
}
|
|
2539
2354
|
const u = l.getProxy(), v = [];
|
|
2540
|
-
|
|
2355
|
+
Y(e.get(), "", v);
|
|
2541
2356
|
for (const o of v) {
|
|
2542
|
-
const
|
|
2543
|
-
if (
|
|
2544
|
-
Z(
|
|
2545
|
-
const
|
|
2546
|
-
|
|
2357
|
+
const m = e.signalAt(o), c = l.getFieldByPath(o);
|
|
2358
|
+
if (m && c) {
|
|
2359
|
+
Z(m, c);
|
|
2360
|
+
const h = o.lastIndexOf("."), p = h === -1 ? l : l.getFieldByPath(o.slice(0, h));
|
|
2361
|
+
p instanceof S && p.registerFieldSignal(c, m);
|
|
2547
2362
|
}
|
|
2548
2363
|
}
|
|
2549
2364
|
return s && l.attachBehaviorCleanup(s.__run(e, u)), u;
|
|
2550
2365
|
}
|
|
2551
|
-
const
|
|
2552
|
-
function
|
|
2553
|
-
return
|
|
2366
|
+
const ce = (i) => i != null && typeof i == "object" && "model" in i && typeof i.model?.signalAt == "function";
|
|
2367
|
+
function Ne(i) {
|
|
2368
|
+
return ce(i) ? Q(i) : new S(i).getProxy();
|
|
2554
2369
|
}
|
|
2555
|
-
function
|
|
2556
|
-
return
|
|
2370
|
+
function x(i) {
|
|
2371
|
+
return i == null ? !1 : typeof i == "object" && "value" in i && "setValue" in i && "getValue" in i && "validate" in i;
|
|
2557
2372
|
}
|
|
2558
|
-
function
|
|
2559
|
-
return
|
|
2373
|
+
function he(i) {
|
|
2374
|
+
return x(i) && "validators" in i && "asyncValidators" in i && // FieldNode имеет markAsTouched метод
|
|
2560
2375
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2561
|
-
typeof
|
|
2562
|
-
!("fields" in
|
|
2376
|
+
typeof i.markAsTouched == "function" && // У FieldNode нет fields или items
|
|
2377
|
+
!("fields" in i) && !("items" in i);
|
|
2563
2378
|
}
|
|
2564
|
-
function
|
|
2565
|
-
return
|
|
2566
|
-
!("items" in
|
|
2379
|
+
function fe(i) {
|
|
2380
|
+
return x(i) && "getFieldByPath" in i && "fields" in i && // GroupNode НЕ имеет items/push/removeAt (это ArrayNode/ModelArrayNode)
|
|
2381
|
+
!("items" in i) && !("push" in i) && !("removeAt" in i);
|
|
2567
2382
|
}
|
|
2568
|
-
function
|
|
2569
|
-
return
|
|
2570
|
-
typeof
|
|
2571
|
-
typeof
|
|
2383
|
+
function ve(i) {
|
|
2384
|
+
return x(i) && "items" in i && "length" in i && "push" in i && "removeAt" in i && "at" in i && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2385
|
+
typeof i.push == "function" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2386
|
+
typeof i.removeAt == "function";
|
|
2572
2387
|
}
|
|
2573
|
-
function
|
|
2574
|
-
return
|
|
2388
|
+
function Fe(i) {
|
|
2389
|
+
return he(i) ? "FieldNode" : fe(i) ? "GroupNode" : ve(i) ? "ArrayNode" : x(i) ? "FormNode" : "Unknown";
|
|
2575
2390
|
}
|
|
2576
|
-
var
|
|
2391
|
+
var F = { exports: {} }, P = {};
|
|
2577
2392
|
var W;
|
|
2578
|
-
function
|
|
2579
|
-
if (W) return
|
|
2393
|
+
function me() {
|
|
2394
|
+
if (W) return P;
|
|
2580
2395
|
W = 1;
|
|
2581
|
-
var
|
|
2582
|
-
function e(o,
|
|
2583
|
-
return o ===
|
|
2584
|
-
}
|
|
2585
|
-
var t = typeof Object.is == "function" ? Object.is : e, s =
|
|
2586
|
-
function l(o,
|
|
2587
|
-
var
|
|
2588
|
-
return
|
|
2396
|
+
var i = H;
|
|
2397
|
+
function e(o, m) {
|
|
2398
|
+
return o === m && (o !== 0 || 1 / o === 1 / m) || o !== o && m !== m;
|
|
2399
|
+
}
|
|
2400
|
+
var t = typeof Object.is == "function" ? Object.is : e, s = i.useState, r = i.useEffect, n = i.useLayoutEffect, a = i.useDebugValue;
|
|
2401
|
+
function l(o, m) {
|
|
2402
|
+
var c = m(), h = s({ inst: { value: c, getSnapshot: m } }), p = h[0].inst, E = h[1];
|
|
2403
|
+
return n(
|
|
2589
2404
|
function() {
|
|
2590
|
-
|
|
2405
|
+
p.value = c, p.getSnapshot = m, d(p) && E({ inst: p });
|
|
2591
2406
|
},
|
|
2592
|
-
[o,
|
|
2593
|
-
),
|
|
2407
|
+
[o, c, m]
|
|
2408
|
+
), r(
|
|
2594
2409
|
function() {
|
|
2595
|
-
return
|
|
2596
|
-
|
|
2410
|
+
return d(p) && E({ inst: p }), o(function() {
|
|
2411
|
+
d(p) && E({ inst: p });
|
|
2597
2412
|
});
|
|
2598
2413
|
},
|
|
2599
2414
|
[o]
|
|
2600
|
-
),
|
|
2415
|
+
), a(c), c;
|
|
2601
2416
|
}
|
|
2602
|
-
function
|
|
2603
|
-
var
|
|
2417
|
+
function d(o) {
|
|
2418
|
+
var m = o.getSnapshot;
|
|
2604
2419
|
o = o.value;
|
|
2605
2420
|
try {
|
|
2606
|
-
var
|
|
2607
|
-
return !t(o,
|
|
2421
|
+
var c = m();
|
|
2422
|
+
return !t(o, c);
|
|
2608
2423
|
} catch {
|
|
2609
2424
|
return !0;
|
|
2610
2425
|
}
|
|
2611
2426
|
}
|
|
2612
|
-
function u(o,
|
|
2613
|
-
return
|
|
2427
|
+
function u(o, m) {
|
|
2428
|
+
return m();
|
|
2614
2429
|
}
|
|
2615
2430
|
var v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
|
|
2616
|
-
return
|
|
2431
|
+
return P.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : v, P;
|
|
2617
2432
|
}
|
|
2618
|
-
var
|
|
2433
|
+
var T = {};
|
|
2619
2434
|
var q;
|
|
2620
|
-
function
|
|
2435
|
+
function pe() {
|
|
2621
2436
|
return q || (q = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
2622
|
-
function
|
|
2623
|
-
return
|
|
2437
|
+
function i(c, h) {
|
|
2438
|
+
return c === h && (c !== 0 || 1 / c === 1 / h) || c !== c && h !== h;
|
|
2624
2439
|
}
|
|
2625
|
-
function e(
|
|
2626
|
-
v ||
|
|
2440
|
+
function e(c, h) {
|
|
2441
|
+
v || r.startTransition === void 0 || (v = !0, console.error(
|
|
2627
2442
|
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
2628
2443
|
));
|
|
2629
|
-
var
|
|
2444
|
+
var p = h();
|
|
2630
2445
|
if (!o) {
|
|
2631
|
-
var
|
|
2632
|
-
|
|
2446
|
+
var E = h();
|
|
2447
|
+
n(p, E) || (console.error(
|
|
2633
2448
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
2634
2449
|
), o = !0);
|
|
2635
2450
|
}
|
|
2636
|
-
|
|
2637
|
-
inst: { value:
|
|
2451
|
+
E = a({
|
|
2452
|
+
inst: { value: p, getSnapshot: h }
|
|
2638
2453
|
});
|
|
2639
|
-
var y =
|
|
2640
|
-
return
|
|
2454
|
+
var y = E[0].inst, w = E[1];
|
|
2455
|
+
return d(
|
|
2641
2456
|
function() {
|
|
2642
|
-
y.value =
|
|
2457
|
+
y.value = p, y.getSnapshot = h, t(y) && w({ inst: y });
|
|
2643
2458
|
},
|
|
2644
|
-
[
|
|
2459
|
+
[c, p, h]
|
|
2645
2460
|
), l(
|
|
2646
2461
|
function() {
|
|
2647
|
-
return t(y) &&
|
|
2648
|
-
t(y) &&
|
|
2462
|
+
return t(y) && w({ inst: y }), c(function() {
|
|
2463
|
+
t(y) && w({ inst: y });
|
|
2649
2464
|
});
|
|
2650
2465
|
},
|
|
2651
|
-
[
|
|
2652
|
-
), u(
|
|
2466
|
+
[c]
|
|
2467
|
+
), u(p), p;
|
|
2653
2468
|
}
|
|
2654
|
-
function t(
|
|
2655
|
-
var
|
|
2656
|
-
|
|
2469
|
+
function t(c) {
|
|
2470
|
+
var h = c.getSnapshot;
|
|
2471
|
+
c = c.value;
|
|
2657
2472
|
try {
|
|
2658
|
-
var
|
|
2659
|
-
return !
|
|
2473
|
+
var p = h();
|
|
2474
|
+
return !n(c, p);
|
|
2660
2475
|
} catch {
|
|
2661
2476
|
return !0;
|
|
2662
2477
|
}
|
|
2663
2478
|
}
|
|
2664
|
-
function s(
|
|
2665
|
-
return
|
|
2479
|
+
function s(c, h) {
|
|
2480
|
+
return h();
|
|
2666
2481
|
}
|
|
2667
2482
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2668
|
-
var
|
|
2669
|
-
|
|
2670
|
-
})()),
|
|
2483
|
+
var r = H, n = typeof Object.is == "function" ? Object.is : i, a = r.useState, l = r.useEffect, d = r.useLayoutEffect, u = r.useDebugValue, v = !1, o = !1, m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? s : e;
|
|
2484
|
+
T.useSyncExternalStore = r.useSyncExternalStore !== void 0 ? r.useSyncExternalStore : m, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
2485
|
+
})()), T;
|
|
2671
2486
|
}
|
|
2672
|
-
var
|
|
2673
|
-
function
|
|
2674
|
-
return
|
|
2487
|
+
var K;
|
|
2488
|
+
function ye() {
|
|
2489
|
+
return K || (K = 1, process.env.NODE_ENV === "production" ? F.exports = me() : F.exports = pe()), F.exports;
|
|
2675
2490
|
}
|
|
2676
|
-
var
|
|
2677
|
-
function
|
|
2678
|
-
if (
|
|
2679
|
-
if (
|
|
2680
|
-
for (let t = 0; t <
|
|
2681
|
-
if (
|
|
2491
|
+
var C = ye();
|
|
2492
|
+
function ge(i, e) {
|
|
2493
|
+
if (i === e) return !0;
|
|
2494
|
+
if (i.length !== e.length) return !1;
|
|
2495
|
+
for (let t = 0; t < i.length; t++)
|
|
2496
|
+
if (i[t] !== e[t]) return !1;
|
|
2682
2497
|
return !0;
|
|
2683
2498
|
}
|
|
2684
|
-
function R(
|
|
2685
|
-
const
|
|
2686
|
-
|
|
2687
|
-
const
|
|
2688
|
-
|
|
2689
|
-
const l =
|
|
2690
|
-
if (l.current = t,
|
|
2499
|
+
function R(i, e, t, s) {
|
|
2500
|
+
const r = V(null), n = V(i);
|
|
2501
|
+
n.current = i;
|
|
2502
|
+
const a = V(e);
|
|
2503
|
+
a.current = e;
|
|
2504
|
+
const l = V(t);
|
|
2505
|
+
if (l.current = t, r.current === null) {
|
|
2691
2506
|
const v = {};
|
|
2692
|
-
for (const o in
|
|
2693
|
-
v[o] =
|
|
2694
|
-
|
|
2507
|
+
for (const o in i)
|
|
2508
|
+
v[o] = i[o].value;
|
|
2509
|
+
r.current = { ...v, __snapshot: null };
|
|
2695
2510
|
}
|
|
2696
|
-
const
|
|
2511
|
+
const d = b(
|
|
2697
2512
|
(v) => {
|
|
2698
2513
|
let o = !0;
|
|
2699
2514
|
return _(() => {
|
|
2700
|
-
const
|
|
2701
|
-
for (const
|
|
2702
|
-
|
|
2515
|
+
const c = n.current;
|
|
2516
|
+
for (const h in c)
|
|
2517
|
+
c[h].value;
|
|
2703
2518
|
if (o) {
|
|
2704
2519
|
o = !1;
|
|
2705
2520
|
return;
|
|
@@ -2708,43 +2523,43 @@ function R(r, e, t, s) {
|
|
|
2708
2523
|
});
|
|
2709
2524
|
},
|
|
2710
2525
|
[s]
|
|
2711
|
-
), u =
|
|
2712
|
-
const v =
|
|
2713
|
-
for (const
|
|
2714
|
-
|
|
2715
|
-
let
|
|
2716
|
-
for (const
|
|
2717
|
-
const { key:
|
|
2718
|
-
if (
|
|
2719
|
-
if (!
|
|
2720
|
-
|
|
2526
|
+
), u = b(() => {
|
|
2527
|
+
const v = r.current, o = n.current, m = {};
|
|
2528
|
+
for (const h in o)
|
|
2529
|
+
m[h] = o[h].value;
|
|
2530
|
+
let c = !1;
|
|
2531
|
+
for (const h of a.current) {
|
|
2532
|
+
const { key: p, useShallowArrayEqual: E } = h, y = m[p], w = v[p];
|
|
2533
|
+
if (E) {
|
|
2534
|
+
if (!ge(w, y)) {
|
|
2535
|
+
c = !0;
|
|
2721
2536
|
break;
|
|
2722
2537
|
}
|
|
2723
|
-
} else if (
|
|
2724
|
-
|
|
2538
|
+
} else if (w !== y) {
|
|
2539
|
+
c = !0;
|
|
2725
2540
|
break;
|
|
2726
2541
|
}
|
|
2727
2542
|
}
|
|
2728
|
-
if (!
|
|
2543
|
+
if (!c && v.__snapshot)
|
|
2729
2544
|
return v.__snapshot;
|
|
2730
|
-
for (const
|
|
2731
|
-
v[
|
|
2732
|
-
return v.__snapshot = l.current(
|
|
2545
|
+
for (const h in o)
|
|
2546
|
+
v[h] = m[h];
|
|
2547
|
+
return v.__snapshot = l.current(m), v.__snapshot;
|
|
2733
2548
|
}, [s]);
|
|
2734
|
-
return
|
|
2549
|
+
return C.useSyncExternalStore(d, u, u);
|
|
2735
2550
|
}
|
|
2736
|
-
function
|
|
2551
|
+
function Ee(i) {
|
|
2737
2552
|
const e = {
|
|
2738
|
-
value:
|
|
2739
|
-
disabled:
|
|
2740
|
-
errors:
|
|
2741
|
-
pending:
|
|
2742
|
-
valid:
|
|
2743
|
-
invalid:
|
|
2744
|
-
touched:
|
|
2745
|
-
dirty:
|
|
2746
|
-
shouldShowError:
|
|
2747
|
-
componentProps:
|
|
2553
|
+
value: i.value,
|
|
2554
|
+
disabled: i.disabled,
|
|
2555
|
+
errors: i.errors,
|
|
2556
|
+
pending: i.pending,
|
|
2557
|
+
valid: i.valid,
|
|
2558
|
+
invalid: i.invalid,
|
|
2559
|
+
touched: i.touched,
|
|
2560
|
+
dirty: i.dirty,
|
|
2561
|
+
shouldShowError: i.shouldShowError,
|
|
2562
|
+
componentProps: i.componentProps
|
|
2748
2563
|
}, t = [
|
|
2749
2564
|
{ key: "value" },
|
|
2750
2565
|
{ key: "disabled" },
|
|
@@ -2756,34 +2571,34 @@ function me(r) {
|
|
|
2756
2571
|
{ key: "dirty" },
|
|
2757
2572
|
{ key: "shouldShowError" },
|
|
2758
2573
|
{ key: "componentProps" }
|
|
2759
|
-
], s =
|
|
2760
|
-
(
|
|
2761
|
-
value:
|
|
2762
|
-
pending:
|
|
2763
|
-
disabled:
|
|
2764
|
-
errors:
|
|
2765
|
-
valid:
|
|
2766
|
-
invalid:
|
|
2767
|
-
touched:
|
|
2768
|
-
dirty:
|
|
2769
|
-
shouldShowError:
|
|
2770
|
-
componentProps:
|
|
2574
|
+
], s = b(
|
|
2575
|
+
(r) => ({
|
|
2576
|
+
value: r.value,
|
|
2577
|
+
pending: r.pending,
|
|
2578
|
+
disabled: r.disabled,
|
|
2579
|
+
errors: r.errors,
|
|
2580
|
+
valid: r.valid,
|
|
2581
|
+
invalid: r.invalid,
|
|
2582
|
+
touched: r.touched,
|
|
2583
|
+
dirty: r.dirty,
|
|
2584
|
+
shouldShowError: r.shouldShowError,
|
|
2585
|
+
componentProps: r.componentProps
|
|
2771
2586
|
}),
|
|
2772
2587
|
[]
|
|
2773
2588
|
);
|
|
2774
|
-
return R(e, t, s,
|
|
2589
|
+
return R(e, t, s, i);
|
|
2775
2590
|
}
|
|
2776
|
-
function
|
|
2591
|
+
function be(i) {
|
|
2777
2592
|
const e = {
|
|
2778
|
-
value:
|
|
2779
|
-
length:
|
|
2780
|
-
errors:
|
|
2781
|
-
pending:
|
|
2782
|
-
valid:
|
|
2783
|
-
invalid:
|
|
2784
|
-
touched:
|
|
2785
|
-
dirty:
|
|
2786
|
-
disabled:
|
|
2593
|
+
value: i.value,
|
|
2594
|
+
length: i.length,
|
|
2595
|
+
errors: i.errors,
|
|
2596
|
+
pending: i.pending,
|
|
2597
|
+
valid: i.valid,
|
|
2598
|
+
invalid: i.invalid,
|
|
2599
|
+
touched: i.touched,
|
|
2600
|
+
dirty: i.dirty,
|
|
2601
|
+
disabled: i.disabled
|
|
2787
2602
|
}, t = [
|
|
2788
2603
|
{ key: "value" },
|
|
2789
2604
|
{ key: "length" },
|
|
@@ -2794,24 +2609,24 @@ function ye(r) {
|
|
|
2794
2609
|
{ key: "touched" },
|
|
2795
2610
|
{ key: "dirty" },
|
|
2796
2611
|
{ key: "disabled" }
|
|
2797
|
-
], s =
|
|
2798
|
-
(
|
|
2799
|
-
value:
|
|
2800
|
-
length:
|
|
2801
|
-
pending:
|
|
2802
|
-
errors:
|
|
2803
|
-
valid:
|
|
2804
|
-
invalid:
|
|
2805
|
-
touched:
|
|
2806
|
-
dirty:
|
|
2807
|
-
disabled:
|
|
2612
|
+
], s = b(
|
|
2613
|
+
(r) => ({
|
|
2614
|
+
value: r.value,
|
|
2615
|
+
length: r.length,
|
|
2616
|
+
pending: r.pending,
|
|
2617
|
+
errors: r.errors,
|
|
2618
|
+
valid: r.valid,
|
|
2619
|
+
invalid: r.invalid,
|
|
2620
|
+
touched: r.touched,
|
|
2621
|
+
dirty: r.dirty,
|
|
2622
|
+
disabled: r.disabled
|
|
2808
2623
|
}),
|
|
2809
2624
|
[]
|
|
2810
2625
|
);
|
|
2811
|
-
return R(e, t, s,
|
|
2626
|
+
return R(e, t, s, i);
|
|
2812
2627
|
}
|
|
2813
|
-
function
|
|
2814
|
-
const
|
|
2628
|
+
function _e() {
|
|
2629
|
+
const i = b(
|
|
2815
2630
|
() => ({
|
|
2816
2631
|
value: [],
|
|
2817
2632
|
length: 0,
|
|
@@ -2825,90 +2640,104 @@ function ge() {
|
|
|
2825
2640
|
}),
|
|
2826
2641
|
[]
|
|
2827
2642
|
);
|
|
2828
|
-
return R({}, [],
|
|
2643
|
+
return R({}, [], i);
|
|
2829
2644
|
}
|
|
2830
|
-
function
|
|
2831
|
-
const e =
|
|
2832
|
-
return
|
|
2645
|
+
function Me(i) {
|
|
2646
|
+
const e = i && "length" in i && "map" in i;
|
|
2647
|
+
return i ? e ? be(i) : Ee(i) : _e();
|
|
2833
2648
|
}
|
|
2834
|
-
function
|
|
2835
|
-
const e =
|
|
2836
|
-
(
|
|
2837
|
-
let
|
|
2649
|
+
function xe(i) {
|
|
2650
|
+
const e = V({ value: i.value.value }), t = b(
|
|
2651
|
+
(r) => {
|
|
2652
|
+
let n = !0;
|
|
2838
2653
|
return _(() => {
|
|
2839
|
-
if (
|
|
2840
|
-
|
|
2654
|
+
if (i.value.value, n) {
|
|
2655
|
+
n = !1;
|
|
2841
2656
|
return;
|
|
2842
2657
|
}
|
|
2843
|
-
|
|
2658
|
+
r();
|
|
2844
2659
|
});
|
|
2845
2660
|
},
|
|
2846
|
-
[
|
|
2847
|
-
), s =
|
|
2848
|
-
const
|
|
2849
|
-
return e.current.value ===
|
|
2850
|
-
}, [
|
|
2851
|
-
return
|
|
2661
|
+
[i]
|
|
2662
|
+
), s = b(() => {
|
|
2663
|
+
const r = i.value.value;
|
|
2664
|
+
return e.current.value === r ? e.current.value : (e.current.value = r, r);
|
|
2665
|
+
}, [i]);
|
|
2666
|
+
return C.useSyncExternalStore(t, s, s);
|
|
2852
2667
|
}
|
|
2853
|
-
function
|
|
2854
|
-
const e =
|
|
2855
|
-
(
|
|
2856
|
-
let
|
|
2668
|
+
function Ce(i) {
|
|
2669
|
+
const e = V({ length: i.length.value }), t = b(
|
|
2670
|
+
(r) => {
|
|
2671
|
+
let n = !0;
|
|
2857
2672
|
return _(() => {
|
|
2858
|
-
if (
|
|
2859
|
-
|
|
2673
|
+
if (i.length.value, n) {
|
|
2674
|
+
n = !1;
|
|
2860
2675
|
return;
|
|
2861
2676
|
}
|
|
2862
|
-
|
|
2677
|
+
r();
|
|
2863
2678
|
});
|
|
2864
2679
|
},
|
|
2865
|
-
[
|
|
2866
|
-
), s =
|
|
2867
|
-
const
|
|
2868
|
-
return e.current.length ===
|
|
2869
|
-
}, [
|
|
2870
|
-
return
|
|
2680
|
+
[i]
|
|
2681
|
+
), s = b(() => {
|
|
2682
|
+
const r = i.length.value;
|
|
2683
|
+
return e.current.length === r ? e.current.length : (e.current.length = r, r);
|
|
2684
|
+
}, [i]);
|
|
2685
|
+
return C.useSyncExternalStore(t, s, s);
|
|
2686
|
+
}
|
|
2687
|
+
function Pe(i) {
|
|
2688
|
+
const { model: e, schema: t, strategy: s, debounce: r, liveAfterSubmit: n } = i, a = ee(
|
|
2689
|
+
() => se(e, t, { strategy: s, debounce: r, liveAfterSubmit: n }),
|
|
2690
|
+
[e, t, s, r, n]
|
|
2691
|
+
);
|
|
2692
|
+
te(() => a.start(), [a]);
|
|
2693
|
+
const l = C.useSyncExternalStore(
|
|
2694
|
+
b((u) => a.validating.subscribe(u), [a]),
|
|
2695
|
+
() => a.validating.peek(),
|
|
2696
|
+
() => !1
|
|
2697
|
+
// SSR: прогон не идёт
|
|
2698
|
+
), d = b(() => a.validate(), [a]);
|
|
2699
|
+
return { submit: d, validate: d, isValidating: l };
|
|
2871
2700
|
}
|
|
2701
|
+
const Te = Object.freeze({ runtime: "reformer-core", v: 1 });
|
|
2872
2702
|
export {
|
|
2873
|
-
|
|
2703
|
+
B as ArrayNode,
|
|
2704
|
+
Te as CORE_RUNTIME_TOKEN,
|
|
2874
2705
|
A as ErrorStrategy,
|
|
2875
|
-
|
|
2876
|
-
|
|
2706
|
+
ne as FieldNode,
|
|
2707
|
+
k as FormErrorHandler,
|
|
2877
2708
|
M as FormNode,
|
|
2878
|
-
|
|
2879
|
-
re as FormSubmitter,
|
|
2709
|
+
oe as FormSubmitter,
|
|
2880
2710
|
S as GroupNode,
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2711
|
+
de as ModelArrayNode,
|
|
2712
|
+
ue as NodeFactory,
|
|
2713
|
+
I as SubscriptionManager,
|
|
2714
|
+
$e as computeFrom,
|
|
2715
|
+
Ge as copyFrom,
|
|
2716
|
+
Ne as createForm,
|
|
2887
2717
|
Q as createFormFromModel,
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2718
|
+
Le as createModel,
|
|
2719
|
+
tt as disableWhen,
|
|
2720
|
+
st as enableWhen,
|
|
2721
|
+
Ze as getNodeForSignal,
|
|
2722
|
+
Fe as getNodeType,
|
|
2723
|
+
ve as isArrayNode,
|
|
2724
|
+
$ as isDerived,
|
|
2725
|
+
he as isFieldNode,
|
|
2726
|
+
x as isFormNode,
|
|
2727
|
+
fe as isGroupNode,
|
|
2728
|
+
Ye as markDerived,
|
|
2899
2729
|
Z as registerSignalNode,
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
We as watchField
|
|
2730
|
+
je as resetWhen,
|
|
2731
|
+
Ue as revalidateWhen,
|
|
2732
|
+
Be as runOutsideEffect,
|
|
2733
|
+
We as safeCallback,
|
|
2734
|
+
qe as safeDebouncedCallback,
|
|
2735
|
+
Ke as syncFields,
|
|
2736
|
+
He as transformValue,
|
|
2737
|
+
Qe as unmarkDerived,
|
|
2738
|
+
Ce as useArrayLength,
|
|
2739
|
+
Me as useFormControl,
|
|
2740
|
+
xe as useFormControlValue,
|
|
2741
|
+
Pe as useFormValidation,
|
|
2742
|
+
ze as watchField
|
|
2914
2743
|
};
|