@reformer/core 11.0.0-beta.8 → 11.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -73
- package/dist/behaviors-value-HA_Q03hc.js +108 -0
- package/dist/behaviors.js +370 -242
- package/dist/{create-model-BBRHhHwK.js → create-model-BvcbNPgL.js} +6 -6
- package/dist/date-utils-90-qZbse.js +43 -0
- package/dist/{en-CjAqn7h0.js → en-HP8XEych.js} +6 -3
- package/dist/form/aggregate-signals.d.ts +21 -63
- package/dist/form/behaviors/collections.d.ts +28 -7
- package/dist/form/behaviors/context.d.ts +19 -2
- package/dist/form/behaviors/index.d.ts +3 -3
- package/dist/form/behaviors/internals.d.ts +9 -2
- package/dist/form/behaviors/node.d.ts +25 -2
- package/dist/form/behaviors/operators.d.ts +17 -9
- package/dist/form/behaviors/schema-operators.d.ts +6 -4
- package/dist/form/behaviors/types.d.ts +12 -4
- package/dist/form/create-form.d.ts +47 -35
- package/dist/form/flow/flow.d.ts +87 -0
- package/dist/form/form-bundle.d.ts +45 -28
- package/dist/form/form-config-base.d.ts +46 -0
- package/dist/form/form-level.d.ts +121 -0
- package/dist/form/form-proxy-builder.d.ts +6 -22
- package/dist/form/index.d.ts +16 -21
- package/dist/form/nodes/form-array-node.d.ts +100 -0
- package/dist/form/nodes/form-control-node.d.ts +73 -0
- package/dist/form/nodes/form-group-node.d.ts +66 -0
- package/dist/form/nodes/node-kind.d.ts +29 -0
- package/dist/form/nodes/state/availability.d.ts +6 -0
- package/dist/form/nodes/state/component.d.ts +6 -0
- package/dist/form/nodes/state/index.d.ts +12 -0
- package/dist/form/nodes/state/interaction.d.ts +13 -0
- package/dist/form/nodes/state/issues.d.ts +9 -0
- package/dist/form/nodes/state/pending.d.ts +6 -0
- package/dist/form/schema/compile.d.ts +59 -0
- package/dist/form/schema/compiled.d.ts +143 -0
- package/dist/form/schema/row-key.d.ts +11 -0
- package/dist/form/schema-controller.d.ts +30 -14
- package/dist/form/signal-node-registry.d.ts +6 -7
- package/dist/form/submission.d.ts +93 -0
- package/dist/form/type-guards.d.ts +14 -73
- package/dist/form/types/contracts.d.ts +19 -92
- package/dist/form/types/field-config.d.ts +27 -0
- package/dist/form/types/index.d.ts +5 -57
- package/dist/form/types/nodes.d.ts +159 -0
- package/dist/form/types/schema-node.d.ts +139 -63
- package/dist/form/types/validation-schema.d.ts +23 -27
- package/dist/form/validation/context.d.ts +42 -7
- package/dist/form/validation/index.d.ts +9 -8
- package/dist/form/validation/operators.d.ts +22 -30
- package/dist/form/validation/run.d.ts +93 -18
- package/dist/form/validation/strategy.d.ts +41 -13
- package/dist/form/validation/types.d.ts +74 -20
- package/dist/form/validators/date-utils.d.ts +13 -1
- package/dist/form/validators/email.d.ts +8 -7
- package/dist/form/validators/file-type.d.ts +8 -7
- package/dist/form/validators/file-utils.d.ts +2 -1
- package/dist/form/validators/future-date.d.ts +8 -7
- package/dist/form/validators/index.d.ts +1 -1
- package/dist/form/validators/integer.d.ts +8 -7
- package/dist/form/validators/is-date.d.ts +11 -9
- package/dist/form/validators/is-number.d.ts +11 -9
- package/dist/form/validators/max-age.d.ts +13 -9
- package/dist/form/validators/max-date.d.ts +8 -7
- package/dist/form/validators/max-file-size.d.ts +8 -7
- package/dist/form/validators/max-files.d.ts +8 -7
- package/dist/form/validators/max-length.d.ts +14 -7
- package/dist/form/validators/max-total-file-size.d.ts +8 -7
- package/dist/form/validators/max.d.ts +10 -8
- package/dist/form/validators/min-age.d.ts +12 -9
- package/dist/form/validators/min-date.d.ts +8 -7
- package/dist/form/validators/min-file-size.d.ts +8 -7
- package/dist/form/validators/min-files.d.ts +11 -9
- package/dist/form/validators/min-length.d.ts +14 -7
- package/dist/form/validators/min.d.ts +10 -8
- package/dist/form/validators/multiple-of.d.ts +10 -8
- package/dist/form/validators/non-negative.d.ts +8 -7
- package/dist/form/validators/non-zero.d.ts +8 -7
- package/dist/form/validators/past-date.d.ts +8 -7
- package/dist/form/validators/pattern.d.ts +9 -8
- package/dist/form/validators/phone.d.ts +8 -7
- package/dist/form/validators/required.d.ts +11 -9
- package/dist/form/validators/url.d.ts +20 -13
- package/dist/form/validators/validation-issue.d.ts +8 -0
- package/dist/i18n/descriptor.d.ts +1 -1
- package/dist/i18n/en.json.d.ts +5 -1
- package/dist/i18n/locale-store.d.ts +7 -0
- package/dist/i18n/message-format.d.ts +24 -4
- package/dist/i18n/ru.json.d.ts +5 -1
- package/dist/i18n/translator.d.ts +11 -0
- package/dist/i18n/validation-message.d.ts +42 -7
- package/dist/i18n.d.ts +7 -12
- package/dist/i18n.js +66 -283
- package/dist/index.d.ts +16 -7
- package/dist/index.js +924 -2855
- package/dist/loader-BWkigpVe.js +52 -0
- package/dist/locale/en.js +1 -1
- package/dist/locale/en.json +4 -1
- package/dist/locale/ru.js +4 -1
- package/dist/locale/ru.json +4 -1
- package/dist/locale-CG54AU2Q.js +219 -0
- package/dist/locale.js +1 -1
- package/dist/model/behaviors-value.d.ts +24 -6
- package/dist/model/create-model.d.ts +2 -2
- package/dist/model/derived-registry.d.ts +1 -1
- package/dist/model/index.d.ts +11 -5
- package/dist/model/model-nodes.d.ts +79 -12
- package/dist/model/model-signals-proxy.d.ts +5 -6
- package/dist/model/model-value-proxy.d.ts +20 -15
- package/dist/model/safe-effect.d.ts +33 -1
- package/dist/model/types.d.ts +63 -13
- package/dist/model.js +20 -18
- package/dist/node-kind-C-r6ZMdo.js +15 -0
- package/dist/platforms/react/field-binding/field-adapter.d.ts +1 -1
- package/dist/platforms/react/field-binding/field-handle.d.ts +5 -2
- package/dist/platforms/react/form-bundle-context.d.ts +2 -2
- package/dist/platforms/react/hooks/types.d.ts +57 -38
- package/dist/platforms/react/hooks/use-form-bundle.d.ts +19 -4
- package/dist/platforms/react/hooks/use-form-flow.d.ts +40 -0
- package/dist/platforms/react/hooks/use-form-validation.d.ts +12 -6
- package/dist/platforms/react/hooks/useArrayLength.d.ts +6 -6
- package/dist/platforms/react/hooks/useFormControl.d.ts +7 -9
- package/dist/platforms/react/hooks/useFormControlValue.d.ts +18 -19
- package/dist/platforms/react/hooks/useSignalSubscription.d.ts +9 -1
- package/dist/platforms/react/i18n/context.d.ts +6 -1
- package/dist/platforms/react/i18n/hooks.d.ts +16 -10
- package/dist/platforms/react/i18n/provider.d.ts +9 -2
- package/dist/platforms/react/index.d.ts +6 -4
- package/dist/react.d.ts +22 -0
- package/dist/react.js +505 -0
- package/dist/runtime-token.d.ts +1 -2
- package/dist/safe-effect-BbtX3KuN.js +643 -0
- package/dist/schema-controller-CpiO2JoK.js +143 -0
- package/dist/signals.d.ts +15 -9
- package/dist/signals.js +11 -6
- package/dist/strategy-CoFSemuP.js +375 -0
- package/dist/type-guards-D-N_5Ddh.js +19 -0
- package/dist/validation-issue-B9mjI8jz.js +7 -0
- package/dist/validation-message-Ced9MGxs.js +194 -0
- package/dist/validation.js +9 -9
- package/dist/validators/email.js +5 -5
- package/dist/validators/future-date.js +8 -8
- package/dist/validators/integer.js +3 -3
- package/dist/validators/is-date.js +4 -4
- package/dist/validators/is-number.js +4 -4
- package/dist/validators/max-age.js +8 -9
- package/dist/validators/max-date.js +8 -8
- package/dist/validators/max-length.js +7 -7
- package/dist/validators/max.js +4 -4
- package/dist/validators/min-age.js +10 -8
- package/dist/validators/min-date.js +3 -3
- package/dist/validators/min-length.js +5 -5
- package/dist/validators/min.js +4 -4
- package/dist/validators/multiple-of.js +11 -7
- package/dist/validators/non-negative.js +3 -3
- package/dist/validators/non-zero.js +3 -3
- package/dist/validators/past-date.js +8 -8
- package/dist/validators/pattern.js +5 -5
- package/dist/validators/phone.js +11 -9
- package/dist/validators/required.js +2 -2
- package/dist/validators/url.js +48 -12
- package/dist/validators.js +17 -17
- package/docs/llms/01-api-reference.md +60 -34
- package/docs/llms/02-quick-start.md +111 -80
- package/docs/llms/03-api-signatures.md +368 -153
- package/docs/llms/04-common-patterns.md +58 -56
- package/docs/llms/05-common-mistakes.md +69 -44
- package/docs/llms/06-troubleshooting.md +14 -9
- package/docs/llms/07-complete-import.md +74 -43
- package/docs/llms/08-form-types.md +11 -4
- package/docs/llms/09-formschema.md +129 -81
- package/docs/llms/10-arrays.md +106 -75
- package/docs/llms/11-async-watchfield.md +2 -2
- package/docs/llms/13-multi-step.md +134 -63
- package/docs/llms/14-extended-mistakes.md +20 -17
- package/docs/llms/15-project-structure.md +221 -74
- package/docs/llms/16-ui-components.md +55 -42
- package/docs/llms/17-nonexistent-api.md +199 -32
- package/docs/llms/18-conditional-fields.md +66 -32
- package/docs/llms/19-reading-values.md +15 -3
- package/docs/llms/20-compute-vs-watch.md +16 -10
- package/docs/llms/21-array-operations.md +51 -27
- package/docs/llms/22-cycle-detection.md +1 -1
- package/docs/llms/23-copy-from.md +2 -2
- package/docs/llms/24-sync-fields.md +6 -5
- package/docs/llms/25-reset-when.md +14 -7
- package/docs/llms/26-transform-value.md +4 -4
- package/docs/llms/27-revalidate-when.md +16 -15
- package/docs/llms/28-submit-and-reset.md +276 -128
- package/docs/llms/29-async-preload.md +39 -29
- package/docs/llms/30-type-safety-recipes.md +105 -51
- package/docs/llms/31-async-validator-debounce.md +96 -53
- package/docs/llms/33-validation-strategy.md +177 -65
- package/docs/llms/34-i18n.md +69 -43
- package/docs/llms/35-unified-contract.md +100 -39
- package/docs/llms/36-issue-messages.md +284 -0
- package/docs/llms/37-compiled-schema.md +332 -0
- package/docs/llms/38-form-flow.md +397 -0
- package/llms-index.json +1 -1
- package/llms.txt +6084 -3420
- package/package.json +23 -4
- package/dist/behaviors-value-C7dSEhCc.js +0 -134
- package/dist/date-utils-dTT_x_Be.js +0 -31
- package/dist/form/create-core-form.d.ts +0 -72
- package/dist/form/factories/index.d.ts +0 -6
- package/dist/form/factories/node-factory.d.ts +0 -189
- package/dist/form/form-submitter.d.ts +0 -121
- package/dist/form/nodes/array-node.d.ts +0 -276
- package/dist/form/nodes/field-node.d.ts +0 -297
- package/dist/form/nodes/form-node.d.ts +0 -326
- package/dist/form/nodes/group-node.d.ts +0 -284
- package/dist/form/nodes/model-array-node.d.ts +0 -126
- package/dist/form/nodes/subscription-manager.d.ts +0 -180
- package/dist/form/status-machine.d.ts +0 -115
- package/dist/form/types/deep-schema.d.ts +0 -107
- package/dist/form/types/form-proxy.d.ts +0 -141
- package/dist/form/unique-id.d.ts +0 -45
- package/dist/form/validation/config.d.ts +0 -73
- package/dist/form/validation/error-handler.d.ts +0 -166
- package/dist/form/validators/validation-error.d.ts +0 -8
- package/dist/index-BrNkQj1y.js +0 -105
- package/dist/loader-Dv_Hl7JC.js +0 -216
- package/dist/model-value-proxy-caTmAiUd.js +0 -419
- package/dist/node-BeV_lV5i.js +0 -100
- package/dist/strategy-DgzELWno.js +0 -204
- package/dist/validation-error-B-U3RsV0.js +0 -11
|
@@ -1,419 +0,0 @@
|
|
|
1
|
-
import { batch as A, signal as x, Signal as I, computed as F } from "@preact/signals-core";
|
|
2
|
-
const u = /* @__PURE__ */ new WeakMap();
|
|
3
|
-
function z(e) {
|
|
4
|
-
u.set(e, (u.get(e) ?? 0) + 1);
|
|
5
|
-
}
|
|
6
|
-
function Q(e) {
|
|
7
|
-
const t = u.get(e);
|
|
8
|
-
t !== void 0 && (t <= 1 ? u.delete(e) : u.set(e, t - 1));
|
|
9
|
-
}
|
|
10
|
-
function T(e) {
|
|
11
|
-
return u.has(e);
|
|
12
|
-
}
|
|
13
|
-
const d = (e) => !(e === null || typeof e != "object" || Array.isArray(e) || e instanceof Date || typeof Blob < "u" && e instanceof Blob || typeof File < "u" && e instanceof File), h = (e, t) => e === "" ? String(t) : `${e}.${t}`, v = (e) => /^\d+$/.test(e), c = (e) => {
|
|
14
|
-
if (Array.isArray(e)) return e.map(c);
|
|
15
|
-
if (d(e)) {
|
|
16
|
-
const t = {};
|
|
17
|
-
for (const r of Object.keys(e)) t[r] = c(e[r]);
|
|
18
|
-
return t;
|
|
19
|
-
}
|
|
20
|
-
return e;
|
|
21
|
-
}, g = (e, t) => {
|
|
22
|
-
if (e === t) return !0;
|
|
23
|
-
if (Array.isArray(e) && Array.isArray(t))
|
|
24
|
-
return e.length !== t.length ? !1 : e.every((r, i) => g(r, t[i]));
|
|
25
|
-
if (d(e) && d(t)) {
|
|
26
|
-
const r = Object.keys(e), i = Object.keys(t);
|
|
27
|
-
return r.length !== i.length ? !1 : r.every((n) => g(e[n], t[n]));
|
|
28
|
-
}
|
|
29
|
-
return !1;
|
|
30
|
-
}, M = Symbol.for("@reformer/core:arrayBlank"), _ = (e) => Array.isArray(e) ? e[M] : void 0, W = (e, t) => d(e) ? e[t] : void 0;
|
|
31
|
-
function U(e, t = []) {
|
|
32
|
-
const r = [...t];
|
|
33
|
-
return Object.defineProperty(r, M, { value: e }), r;
|
|
34
|
-
}
|
|
35
|
-
class C {
|
|
36
|
-
constructor(t, r) {
|
|
37
|
-
this.path = r;
|
|
38
|
-
const i = x(t);
|
|
39
|
-
i.__path = r, this.signal = i, this.initial = c(t);
|
|
40
|
-
}
|
|
41
|
-
kind = "leaf";
|
|
42
|
-
signal;
|
|
43
|
-
initial;
|
|
44
|
-
rebase(t) {
|
|
45
|
-
this.path = t, this.signal.__path = t;
|
|
46
|
-
}
|
|
47
|
-
/** Реактивное чтение (внутри effect/computed создаёт зависимость). */
|
|
48
|
-
read() {
|
|
49
|
-
return this.signal.value;
|
|
50
|
-
}
|
|
51
|
-
/** Нереактивный снимок. */
|
|
52
|
-
peek() {
|
|
53
|
-
return this.signal.peek();
|
|
54
|
-
}
|
|
55
|
-
set(t) {
|
|
56
|
-
this.signal.value = t;
|
|
57
|
-
}
|
|
58
|
-
resetToInitial() {
|
|
59
|
-
this.signal.value = c(this.initial);
|
|
60
|
-
}
|
|
61
|
-
captureInitial() {
|
|
62
|
-
this.initial = c(this.signal.peek());
|
|
63
|
-
}
|
|
64
|
-
dirty() {
|
|
65
|
-
return !g(this.signal.peek(), this.initial);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
class K {
|
|
69
|
-
/**
|
|
70
|
-
* @param shape Образец той же группы из шаблона родительского массива: из него вложенные
|
|
71
|
-
* массивы берут шаблоны, если значение пришло обычными данными (см. {@link ArrayNode}).
|
|
72
|
-
*/
|
|
73
|
-
constructor(t, r, i) {
|
|
74
|
-
this.path = r;
|
|
75
|
-
for (const n of Object.keys(t)) {
|
|
76
|
-
const s = i && (() => W(i(), n));
|
|
77
|
-
this.children.set(n, E(t[n], h(r, n), s));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
kind = "group";
|
|
81
|
-
children = /* @__PURE__ */ new Map();
|
|
82
|
-
rebase(t) {
|
|
83
|
-
this.path = t;
|
|
84
|
-
for (const [r, i] of this.children) i.rebase(h(t, r));
|
|
85
|
-
}
|
|
86
|
-
/** Реактивное чтение поддерева (внутри effect/computed подписывает на все листья группы). */
|
|
87
|
-
read() {
|
|
88
|
-
const t = {};
|
|
89
|
-
for (const [r, i] of this.children) t[r] = i.read();
|
|
90
|
-
return t;
|
|
91
|
-
}
|
|
92
|
-
peek() {
|
|
93
|
-
const t = {};
|
|
94
|
-
for (const [r, i] of this.children) t[r] = i.peek();
|
|
95
|
-
return t;
|
|
96
|
-
}
|
|
97
|
-
set(t) {
|
|
98
|
-
if (t == null || typeof t != "object") return;
|
|
99
|
-
const r = t;
|
|
100
|
-
A(() => {
|
|
101
|
-
for (const [i, n] of this.children)
|
|
102
|
-
i in r && (n.kind === "leaf" && T(n.signal) || n.set(r[i]));
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
resetToInitial() {
|
|
106
|
-
A(() => {
|
|
107
|
-
for (const t of this.children.values()) t.resetToInitial();
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
captureInitial() {
|
|
111
|
-
for (const t of this.children.values()) t.captureInitial();
|
|
112
|
-
}
|
|
113
|
-
dirty() {
|
|
114
|
-
for (const t of this.children.values()) if (t.dirty()) return !0;
|
|
115
|
-
return !1;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
class G {
|
|
119
|
-
/** @param shape Образец того же массива из шаблона родителя (см. {@link GroupNode}). */
|
|
120
|
-
constructor(t, r, i) {
|
|
121
|
-
this.path = r, this.shape = i, this.blank = _(t), this.items = x(t.map((n, s) => this.build(n, s))), this.initial = c(t);
|
|
122
|
-
}
|
|
123
|
-
kind = "array";
|
|
124
|
-
items;
|
|
125
|
-
initial;
|
|
126
|
-
// Шаблон нового элемента (`arrayOf`). Принадлежит узлу, а не значению: `set`/`reset` заменяют
|
|
127
|
-
// элементы, узел остаётся — и шаблон с ним.
|
|
128
|
-
blank;
|
|
129
|
-
// Запасной шаблон — `initialValue` узла-массива схемы.
|
|
130
|
-
fallback;
|
|
131
|
-
// Образец элемента — один вызов шаблона. Нужен только ради вложенных шаблонов: элемент из
|
|
132
|
-
// обычных данных (`set` с сервера, `push(значение)`) метку `arrayOf` на своих массивах не несёт.
|
|
133
|
-
sample;
|
|
134
|
-
/** Шаблон по старшинству: свой (`arrayOf`) → из шаблона родителя → из схемы. */
|
|
135
|
-
template() {
|
|
136
|
-
return this.blank ??= _(this.shape?.()), this.blank ?? this.fallback;
|
|
137
|
-
}
|
|
138
|
-
// Образец читается лениво — лишний вызов шаблона случается, только когда вложенному массиву
|
|
139
|
-
// элемента из обычных данных понадобился свой шаблон.
|
|
140
|
-
itemShape = () => {
|
|
141
|
-
if (!this.sample) {
|
|
142
|
-
const t = this.template();
|
|
143
|
-
if (!t) return;
|
|
144
|
-
this.sample = { value: t() };
|
|
145
|
-
}
|
|
146
|
-
return this.sample.value;
|
|
147
|
-
};
|
|
148
|
-
build(t, r) {
|
|
149
|
-
return E(t, h(this.path, r), this.itemShape);
|
|
150
|
-
}
|
|
151
|
-
/** Значение нового элемента: переданное либо из шаблона. */
|
|
152
|
-
fresh(t) {
|
|
153
|
-
if (t !== void 0) return t;
|
|
154
|
-
const r = this.template();
|
|
155
|
-
if (!r)
|
|
156
|
-
throw new Error(
|
|
157
|
-
`[@reformer/core] ${this.path || "массив"}: добавление элемента без значения, а шаблона у массива нет. Объявите его в модели — \`arrayOf(() => ({ … }))\` — либо передайте значение: \`push(значение)\`.`
|
|
158
|
-
);
|
|
159
|
-
return r();
|
|
160
|
-
}
|
|
161
|
-
/** Шаблон из схемы (`initialValue` узла-массива) — запасной: шаблон модели главнее. */
|
|
162
|
-
provideBlank(t) {
|
|
163
|
-
this.fallback ??= t;
|
|
164
|
-
}
|
|
165
|
-
rebase(t) {
|
|
166
|
-
this.path = t, this.items.peek().forEach((r, i) => r.rebase(h(t, i)));
|
|
167
|
-
}
|
|
168
|
-
reindex() {
|
|
169
|
-
this.items.peek().forEach((t, r) => t.rebase(h(this.path, r)));
|
|
170
|
-
}
|
|
171
|
-
push(t) {
|
|
172
|
-
const r = this.items.peek();
|
|
173
|
-
this.items.value = [...r, this.build(this.fresh(t), r.length)];
|
|
174
|
-
}
|
|
175
|
-
insertAt(t, r) {
|
|
176
|
-
const i = [...this.items.peek()];
|
|
177
|
-
i.splice(t, 0, this.build(this.fresh(r), t)), this.items.value = i, this.reindex();
|
|
178
|
-
}
|
|
179
|
-
removeAt(t) {
|
|
180
|
-
const r = [...this.items.peek()];
|
|
181
|
-
r.splice(t, 1), this.items.value = r, this.reindex();
|
|
182
|
-
}
|
|
183
|
-
move(t, r) {
|
|
184
|
-
const i = [...this.items.peek()], [n] = i.splice(t, 1);
|
|
185
|
-
n && i.splice(r, 0, n), this.items.value = i, this.reindex();
|
|
186
|
-
}
|
|
187
|
-
swap(t, r) {
|
|
188
|
-
const i = [...this.items.peek()];
|
|
189
|
-
t < 0 || r < 0 || t >= i.length || r >= i.length || t === r || ([i[t], i[r]] = [i[r], i[t]], this.items.value = i, this.reindex());
|
|
190
|
-
}
|
|
191
|
-
clear() {
|
|
192
|
-
this.items.value = [];
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Реактивное чтение массива. Читаем `items.value` (а не `.peek()`) — внутри effect/computed это
|
|
196
|
-
* подписка на СОСТАВ массива, поэтому push/removeAt/move ретригерят наравне с правкой элемента.
|
|
197
|
-
*/
|
|
198
|
-
read() {
|
|
199
|
-
return this.items.value.map((t) => t.read());
|
|
200
|
-
}
|
|
201
|
-
peek() {
|
|
202
|
-
return this.items.peek().map((t) => t.peek());
|
|
203
|
-
}
|
|
204
|
-
set(t) {
|
|
205
|
-
const r = Array.isArray(t) ? t : [];
|
|
206
|
-
this.items.value = r.map((i, n) => this.build(i, n));
|
|
207
|
-
}
|
|
208
|
-
resetToInitial() {
|
|
209
|
-
this.set(c(this.initial));
|
|
210
|
-
}
|
|
211
|
-
captureInitial() {
|
|
212
|
-
this.initial = c(this.peek());
|
|
213
|
-
}
|
|
214
|
-
dirty() {
|
|
215
|
-
return !g(this.peek(), this.initial);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
function E(e, t, r) {
|
|
219
|
-
return Array.isArray(e) ? new G(e, t, r) : d(e) ? new K(e, t, r) : new C(e, t);
|
|
220
|
-
}
|
|
221
|
-
const H = (e) => typeof e == "function" ? e : () => c(e), O = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap();
|
|
222
|
-
function L(e) {
|
|
223
|
-
const t = F(() => e.read());
|
|
224
|
-
return {
|
|
225
|
-
get value() {
|
|
226
|
-
return t.value;
|
|
227
|
-
},
|
|
228
|
-
peek: () => t.peek(),
|
|
229
|
-
subscribe: (r) => t.subscribe(r),
|
|
230
|
-
valueOf: () => t.value,
|
|
231
|
-
toString: () => String(t.value),
|
|
232
|
-
toJSON: () => t.value,
|
|
233
|
-
brand: t.brand
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
function p(e) {
|
|
237
|
-
if (e.kind === "leaf") return e.signal;
|
|
238
|
-
const t = O.get(e);
|
|
239
|
-
if (t) return t;
|
|
240
|
-
const r = L(e), i = e.kind === "group", n = (l) => i ? e.children.get(l) : v(l) ? e.items.value[Number(l)] : void 0, s = i ? {} : {
|
|
241
|
-
get length() {
|
|
242
|
-
return e.items.value.length;
|
|
243
|
-
}
|
|
244
|
-
}, o = new Proxy(s, {
|
|
245
|
-
get: (l, a, k) => {
|
|
246
|
-
if (a === "__path") return e.path;
|
|
247
|
-
if (a === "__kind") return e.kind;
|
|
248
|
-
if (typeof a != "string") return Reflect.get(r, a, r);
|
|
249
|
-
const m = n(a);
|
|
250
|
-
return m ? p(m) : !i && Reflect.has(l, a) ? Reflect.get(l, a, k) : Reflect.get(r, a, r);
|
|
251
|
-
},
|
|
252
|
-
set: (l, a, k) => {
|
|
253
|
-
if (!i && a === "value")
|
|
254
|
-
return e.set(k), !0;
|
|
255
|
-
const m = e.path === "" ? "model.$" : `model.$.${e.path}`;
|
|
256
|
-
throw new TypeError(
|
|
257
|
-
`[@reformer/core] ${m}: запись в «${String(a)}» ` + (i ? "узла-группы невозможна — группа читается целиком, а пишется по полям (model.$.<поле>.value) либо через model.patch(...)" : "узла-массива невозможна — массив заменяется целиком через .value, а элемент правится своим сигналом (model.$.<массив>[i].value)")
|
|
258
|
-
);
|
|
259
|
-
},
|
|
260
|
-
has: (l, a) => typeof a == "string" && (n(a) !== void 0 || !i && Reflect.has(l, a)),
|
|
261
|
-
ownKeys: () => i ? [...e.children.keys()] : Reflect.ownKeys(s),
|
|
262
|
-
getOwnPropertyDescriptor: (l, a) => typeof a == "string" && n(a) ? { enumerable: !0, configurable: !0 } : i ? void 0 : Reflect.getOwnPropertyDescriptor(l, a)
|
|
263
|
-
});
|
|
264
|
-
return O.set(e, o), N.set(o, e), o;
|
|
265
|
-
}
|
|
266
|
-
function P(e) {
|
|
267
|
-
if (!(e == null || typeof e != "object"))
|
|
268
|
-
return N.get(e);
|
|
269
|
-
}
|
|
270
|
-
function V(e) {
|
|
271
|
-
if (e == null || typeof e != "object") return !1;
|
|
272
|
-
const t = e.__kind;
|
|
273
|
-
return t === "group" || t === "array";
|
|
274
|
-
}
|
|
275
|
-
function y(e) {
|
|
276
|
-
return e == null || typeof e != "object" ? !1 : e.__kind === "array";
|
|
277
|
-
}
|
|
278
|
-
function X(e) {
|
|
279
|
-
return e instanceof I || y(e);
|
|
280
|
-
}
|
|
281
|
-
function q(e, t) {
|
|
282
|
-
if (!t) return;
|
|
283
|
-
let r = e;
|
|
284
|
-
for (const i of t.split(".")) {
|
|
285
|
-
if (!r) return;
|
|
286
|
-
if (r.kind === "group") r = r.children.get(i);
|
|
287
|
-
else if (r.kind === "array") r = r.items.peek()[Number(i)];
|
|
288
|
-
else return;
|
|
289
|
-
}
|
|
290
|
-
if (r)
|
|
291
|
-
return r.kind === "leaf" ? r.signal : r.kind === "array" ? p(r) : void 0;
|
|
292
|
-
}
|
|
293
|
-
function f(e) {
|
|
294
|
-
if (e)
|
|
295
|
-
return e.kind === "group" ? B(e) : e.kind === "array" ? R(e) : e.read();
|
|
296
|
-
}
|
|
297
|
-
const S = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap();
|
|
298
|
-
function R(e) {
|
|
299
|
-
const t = S.get(e);
|
|
300
|
-
if (t) return t;
|
|
301
|
-
const r = {
|
|
302
|
-
get length() {
|
|
303
|
-
return e.items.value.length;
|
|
304
|
-
},
|
|
305
|
-
push: (n) => e.push(n),
|
|
306
|
-
insertAt: (n, s) => e.insertAt(n, s),
|
|
307
|
-
removeAt: (n) => e.removeAt(n),
|
|
308
|
-
move: (n, s) => e.move(n, s),
|
|
309
|
-
swap: (n, s) => e.swap(n, s),
|
|
310
|
-
clear: () => e.clear(),
|
|
311
|
-
at: (n) => f(e.items.value[n]),
|
|
312
|
-
map: (n) => e.items.value.map((s, o) => n(f(s), o)),
|
|
313
|
-
forEach: (n) => e.items.value.forEach((s, o) => n(f(s), o)),
|
|
314
|
-
toArray: () => e.peek(),
|
|
315
|
-
[Symbol.iterator]: function* () {
|
|
316
|
-
const n = e.items.value;
|
|
317
|
-
for (let s = 0; s < n.length; s++) yield f(n[s]);
|
|
318
|
-
}
|
|
319
|
-
}, i = new Proxy(r, {
|
|
320
|
-
get: (n, s, o) => s === "__path" ? e.path : typeof s == "string" && v(s) ? f(e.items.value[Number(s)]) : Reflect.get(n, s, o),
|
|
321
|
-
has: (n, s) => typeof s == "string" && v(s) ? Number(s) < e.items.value.length : Reflect.has(n, s)
|
|
322
|
-
});
|
|
323
|
-
return S.set(e, i), b.set(i, e), i;
|
|
324
|
-
}
|
|
325
|
-
const $ = /* @__PURE__ */ new Set([
|
|
326
|
-
"$",
|
|
327
|
-
"get",
|
|
328
|
-
"set",
|
|
329
|
-
"patch",
|
|
330
|
-
"isDirty",
|
|
331
|
-
"reset",
|
|
332
|
-
"captureInitial",
|
|
333
|
-
"signalAt"
|
|
334
|
-
]), j = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap();
|
|
335
|
-
function B(e) {
|
|
336
|
-
const t = j.get(e);
|
|
337
|
-
if (t) return t;
|
|
338
|
-
const r = {
|
|
339
|
-
$: p(e),
|
|
340
|
-
get: () => e.peek(),
|
|
341
|
-
set: (n) => e.set(n),
|
|
342
|
-
patch: (n) => e.set(n),
|
|
343
|
-
isDirty: () => e.dirty(),
|
|
344
|
-
reset: () => e.resetToInitial(),
|
|
345
|
-
captureInitial: () => e.captureInitial(),
|
|
346
|
-
signalAt: (n) => q(e, n)
|
|
347
|
-
}, i = new Proxy(
|
|
348
|
-
{},
|
|
349
|
-
{
|
|
350
|
-
get: (n, s) => {
|
|
351
|
-
if (s === "__path") return e.path;
|
|
352
|
-
if (typeof s != "string") return;
|
|
353
|
-
const o = e.children.get(s);
|
|
354
|
-
if (o) return f(o);
|
|
355
|
-
if ($.has(s)) return r[s];
|
|
356
|
-
},
|
|
357
|
-
set: (n, s, o) => {
|
|
358
|
-
if (typeof s != "string") return !1;
|
|
359
|
-
const l = e.children.get(s);
|
|
360
|
-
return l ? (l.set(o), !0) : !1;
|
|
361
|
-
},
|
|
362
|
-
has: (n, s) => typeof s == "string" && (e.children.has(s) || $.has(s)),
|
|
363
|
-
ownKeys: () => [...e.children.keys()],
|
|
364
|
-
getOwnPropertyDescriptor: (n, s) => typeof s == "string" && e.children.has(s) ? { enumerable: !0, configurable: !0 } : void 0
|
|
365
|
-
}
|
|
366
|
-
);
|
|
367
|
-
return j.set(e, i), w.set(i, e), i;
|
|
368
|
-
}
|
|
369
|
-
function Y(e) {
|
|
370
|
-
const t = P(e);
|
|
371
|
-
if (!t) {
|
|
372
|
-
const r = e?.__path, i = typeof r == "string" && r !== "" ? ` «${r}»` : "";
|
|
373
|
-
throw new TypeError(
|
|
374
|
-
e instanceof I ? `[@reformer/core] modelOf: ручка${i} — лист, у него нет под-модели. Группа или массив, созданные из начального null, в модели тоже лист: задайте начальное значение объектом или массивом.` : "[@reformer/core] modelOf: ожидалась ручка группы или массива из дерева model.$ (например, model.$.address или model.$.items)."
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
return t.kind === "group" ? B(t) : R(t);
|
|
378
|
-
}
|
|
379
|
-
function D(e) {
|
|
380
|
-
if (e == null || typeof e != "object") return;
|
|
381
|
-
const t = b.get(e);
|
|
382
|
-
if (t) return p(t);
|
|
383
|
-
const r = w.get(e);
|
|
384
|
-
return r ? p(r) : void 0;
|
|
385
|
-
}
|
|
386
|
-
function Z(e) {
|
|
387
|
-
if (y(e)) return e;
|
|
388
|
-
const t = D(e);
|
|
389
|
-
return y(t) ? t : void 0;
|
|
390
|
-
}
|
|
391
|
-
function ee(e) {
|
|
392
|
-
const t = V(e) ? e : D(e);
|
|
393
|
-
return t !== void 0 && !y(t) ? t : void 0;
|
|
394
|
-
}
|
|
395
|
-
function te(e, t) {
|
|
396
|
-
const r = P(e);
|
|
397
|
-
r?.kind === "array" && r.provideBlank(H(t));
|
|
398
|
-
}
|
|
399
|
-
function re(e) {
|
|
400
|
-
return e == null || typeof e != "object" ? !1 : b.has(e) || w.has(e);
|
|
401
|
-
}
|
|
402
|
-
export {
|
|
403
|
-
K as G,
|
|
404
|
-
U as a,
|
|
405
|
-
X as b,
|
|
406
|
-
z as c,
|
|
407
|
-
T as d,
|
|
408
|
-
B as e,
|
|
409
|
-
re as f,
|
|
410
|
-
ee as g,
|
|
411
|
-
Z as h,
|
|
412
|
-
V as i,
|
|
413
|
-
y as j,
|
|
414
|
-
Y as m,
|
|
415
|
-
te as p,
|
|
416
|
-
w as r,
|
|
417
|
-
p as s,
|
|
418
|
-
Q as u
|
|
419
|
-
};
|
package/dist/node-BeV_lV5i.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { signal as o, effect as a } from "@preact/signals-core";
|
|
2
|
-
import { b as f, i as c, f as u } from "./model-value-proxy-caTmAiUd.js";
|
|
3
|
-
import { g as d } from "./signal-node-registry-tiwel-TV.js";
|
|
4
|
-
import { d as l } from "./behaviors-value-C7dSEhCc.js";
|
|
5
|
-
function p() {
|
|
6
|
-
const e = /* @__PURE__ */ new Map();
|
|
7
|
-
return {
|
|
8
|
-
hiddenOverrides: /* @__PURE__ */ new Map(),
|
|
9
|
-
propsOverrides: /* @__PURE__ */ new Map(),
|
|
10
|
-
refRegistry: /* @__PURE__ */ new Map(),
|
|
11
|
-
conditionRegistry: /* @__PURE__ */ new Map(),
|
|
12
|
-
effectRegistry: [],
|
|
13
|
-
callbackRegistry: /* @__PURE__ */ new Map(),
|
|
14
|
-
lifecycleRegistry: /* @__PURE__ */ new Map(),
|
|
15
|
-
version: o(0),
|
|
16
|
-
versionFor(t) {
|
|
17
|
-
let r = e.get(t);
|
|
18
|
-
return r || (r = o(0), e.set(t, r)), r;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function g(e = p()) {
|
|
23
|
-
const t = (r) => {
|
|
24
|
-
e.version.value++, e.versionFor(r).value++;
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
__overrideMaps: e,
|
|
28
|
-
node: (r) => ({
|
|
29
|
-
setHidden(n) {
|
|
30
|
-
return e.hiddenOverrides.set(r, n), t(r), this;
|
|
31
|
-
},
|
|
32
|
-
resetHidden() {
|
|
33
|
-
return e.hiddenOverrides.delete(r), t(r), this;
|
|
34
|
-
},
|
|
35
|
-
patchProps(n) {
|
|
36
|
-
return e.propsOverrides.set(r, {
|
|
37
|
-
...e.propsOverrides.get(r) ?? {},
|
|
38
|
-
...n
|
|
39
|
-
}), t(r), this;
|
|
40
|
-
},
|
|
41
|
-
resetProps() {
|
|
42
|
-
return e.propsOverrides.delete(r), t(r), this;
|
|
43
|
-
},
|
|
44
|
-
getRef() {
|
|
45
|
-
let n = e.refRegistry.get(r);
|
|
46
|
-
return n || (n = { current: null }, e.refRegistry.set(r, n)), n;
|
|
47
|
-
},
|
|
48
|
-
__selector: r,
|
|
49
|
-
__overrideMaps: e
|
|
50
|
-
})
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function S() {
|
|
54
|
-
const e = /* @__PURE__ */ new WeakMap();
|
|
55
|
-
return {
|
|
56
|
-
scopeOf(t) {
|
|
57
|
-
let r = e.get(t);
|
|
58
|
-
return r || (r = g(), e.set(t, r)), r;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function s(e, t, r) {
|
|
63
|
-
if (e == null || typeof e != "object" || f(e) || c(e) || u(e) || e.$$typeof !== void 0 || r.has(e)) return;
|
|
64
|
-
if (r.add(e), Array.isArray(e)) {
|
|
65
|
-
for (const i of e) s(i, t, r);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const n = e.selector;
|
|
69
|
-
typeof n == "string" && t.add(n);
|
|
70
|
-
for (const i of Object.values(e)) s(i, t, r);
|
|
71
|
-
}
|
|
72
|
-
function b(e, t) {
|
|
73
|
-
const r = /* @__PURE__ */ new Set();
|
|
74
|
-
return s(t, r, /* @__PURE__ */ new WeakSet()), [.../* @__PURE__ */ new Set([
|
|
75
|
-
...e.hiddenOverrides.keys(),
|
|
76
|
-
...e.propsOverrides.keys(),
|
|
77
|
-
...e.conditionRegistry.keys(),
|
|
78
|
-
...e.callbackRegistry.keys(),
|
|
79
|
-
...e.lifecycleRegistry.keys()
|
|
80
|
-
])].filter((i) => !r.has(i));
|
|
81
|
-
}
|
|
82
|
-
function y(e, t, r) {
|
|
83
|
-
return a(() => {
|
|
84
|
-
const n = t(), i = d(e);
|
|
85
|
-
i && l(() => {
|
|
86
|
-
n ? i.enable() : (i.disable(), r?.resetOnDisable && i.reset());
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
function M(e, t, r) {
|
|
91
|
-
return y(e, () => !t(), r);
|
|
92
|
-
}
|
|
93
|
-
export {
|
|
94
|
-
g as a,
|
|
95
|
-
p as b,
|
|
96
|
-
S as c,
|
|
97
|
-
M as d,
|
|
98
|
-
y as e,
|
|
99
|
-
b as u
|
|
100
|
-
};
|