@tempots/beatui 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +1 -1
- package/dist/{auth-divider-D_3gKZ6g.js → auth-divider-BIATan1F.js} +3 -3
- package/dist/{auth-divider-itm5-j5G.cjs → auth-divider-CVKfA8Cp.cjs} +1 -1
- package/dist/beatui.css +393 -36
- package/dist/beatui.tailwind.css +393 -36
- package/dist/better-auth/index.cjs.js +1 -1
- package/dist/better-auth/index.es.js +2 -2
- package/dist/deep-merge-B33Qtlmw.cjs +1 -0
- package/dist/{deep-merge-CzZVsVF-.js → deep-merge-BUsrE2v4.js} +130 -130
- package/dist/{duration-input-BrYLC1js.cjs → duration-input-C5il_E0F.cjs} +1 -1
- package/dist/{duration-input-CFu6vq-y.js → duration-input-DoCCrqOG.js} +1 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +5609 -5130
- package/dist/json-schema/index.cjs.js +1 -1
- package/dist/json-schema/index.es.js +107 -107
- package/dist/json-structure/index.cjs.js +1 -1
- package/dist/json-structure/index.es.js +3 -3
- package/dist/{modal-YKqlh4Dk.js → modal-BHlp4QeT.js} +1 -1
- package/dist/{modal-DCxNGrzk.cjs → modal-BmpfNL48.cjs} +1 -1
- package/dist/{notice-Q0A1gIho.cjs → notice-BBnSXYUc.cjs} +1 -1
- package/dist/{notice-Du3tWJTW.js → notice-BXKtBEiC.js} +1 -1
- package/dist/types/components/data/data-table-context.d.ts +9 -1
- package/dist/types/components/data/data-table-row-details.d.ts +21 -0
- package/dist/types/components/data/data-table-types.d.ts +23 -0
- package/dist/types/components/data/index.d.ts +1 -0
- package/dist/types/components/form/control/control.d.ts +5 -5
- package/dist/types/components/form/control/list-control.d.ts +11 -11
- package/dist/types/components/form/fieldset/fieldset.d.ts +60 -0
- package/dist/types/components/form/fieldset/index.d.ts +1 -0
- package/dist/types/components/form/index.d.ts +1 -0
- package/dist/types/components/form/input/combobox-input.d.ts +2 -2
- package/dist/types/components/form/input/combobox-tags-input.d.ts +1 -1
- package/dist/types/components/form/input/date-time-input.d.ts +1 -1
- package/dist/types/components/form/input/dropdown-input.d.ts +2 -2
- package/dist/types/components/form/input/field-layout.d.ts +64 -0
- package/dist/types/components/form/input/{input-wrapper.d.ts → field.d.ts} +23 -14
- package/dist/types/components/form/input/index.d.ts +2 -1
- package/dist/types/components/form/input/multi-select.d.ts +2 -2
- package/dist/types/components/form/input/native-select.d.ts +1 -1
- package/dist/types/components/form/input/range-slider.d.ts +19 -2
- package/dist/types/components/form/input/select-tags-input.d.ts +1 -1
- package/dist/types/components/format/format-bigint.d.ts +64 -0
- package/dist/types/components/format/format-date-time.d.ts +54 -0
- package/dist/types/components/format/format-date.d.ts +82 -0
- package/dist/types/components/format/format-display-name.d.ts +70 -0
- package/dist/types/components/format/format-file-size.d.ts +30 -0
- package/dist/types/components/format/format-list.d.ts +61 -0
- package/dist/types/components/format/format-number.d.ts +88 -0
- package/dist/types/components/format/format-plural.d.ts +96 -0
- package/dist/types/components/format/format-relative-time.d.ts +62 -0
- package/dist/types/components/format/format-time.d.ts +66 -0
- package/dist/types/components/format/index.d.ts +11 -0
- package/dist/types/components/i18n/locale-selector.d.ts +1 -1
- package/dist/types/components/json-schema/controls/composition-shared.d.ts +1 -1
- package/dist/types/components/json-schema/controls/shared-utils.d.ts +3 -3
- package/dist/types/components/json-schema/widgets/string-controls.d.ts +2 -2
- package/dist/types/components/json-schema-display/display-wrapper.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/use-form-CP6nftVl.cjs +2 -0
- package/dist/{use-form-D_TJyZhP.js → use-form-CmQdxpOi.js} +474 -434
- package/dist/{widget-customization-DELy3SMQ.cjs → widget-customization-B0y-eesp.cjs} +1 -1
- package/dist/{widget-customization-BAchyOUo.js → widget-customization-CKbR4Dsg.js} +2 -2
- package/package.json +1 -1
- package/dist/deep-merge-Bydz6jLt.cjs +0 -1
- package/dist/use-form-BvBkVEKi.cjs +0 -2
|
@@ -1,313 +1,351 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as
|
|
3
|
-
import { B as
|
|
4
|
-
import { L as
|
|
5
|
-
import { s as
|
|
6
|
-
import { Validation as g, strictEqual as
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { ProviderNotFoundError as ee, makeProviderMark as te, Provide as se, Use as N, html as b, attr as c, computedOf as v, Value as T, Empty as _, When as x, dataAttr as W, aria as S, coalesce as ie, on as F, TextNode as ne, prop as D, Fragment as P, emitValueAsNumber as ae, emitValue as le } from "@tempots/dom";
|
|
2
|
+
import { B as re, I as U } from "./translations-DT5QQ4WO.js";
|
|
3
|
+
import { B as oe, I as ce } from "./input-container-CO3DNqpp.js";
|
|
4
|
+
import { L as de, M as he } from "./stack-BLMteGTn.js";
|
|
5
|
+
import { s as B } from "./session-id-3KiilioY.js";
|
|
6
|
+
import { Validation as g, strictEqual as M } from "@tempots/std";
|
|
7
|
+
const ue = {
|
|
8
|
+
layout: "vertical",
|
|
9
|
+
labelWidth: "7.5rem",
|
|
10
|
+
size: "md",
|
|
11
|
+
gap: "md",
|
|
12
|
+
columns: 1,
|
|
13
|
+
minFieldWidth: "15rem",
|
|
14
|
+
compact: !1
|
|
15
|
+
}, j = {
|
|
16
|
+
mark: te("FieldLayout"),
|
|
17
|
+
create: (s = {}, e) => {
|
|
18
|
+
let t = ue;
|
|
19
|
+
try {
|
|
20
|
+
t = e.getProvider(j.mark).value;
|
|
21
|
+
} catch (n) {
|
|
22
|
+
if (!(n instanceof ee))
|
|
23
|
+
throw n;
|
|
24
|
+
}
|
|
25
|
+
return { value: {
|
|
26
|
+
layout: s.layout ?? t.layout,
|
|
27
|
+
labelWidth: s.labelWidth ?? t.labelWidth,
|
|
28
|
+
size: s.size ?? t.size,
|
|
29
|
+
gap: s.gap ?? t.gap,
|
|
30
|
+
columns: s.columns ?? t.columns,
|
|
31
|
+
minFieldWidth: s.minFieldWidth ?? t.minFieldWidth,
|
|
32
|
+
compact: s.compact ?? t.compact
|
|
33
|
+
}, dispose: () => {
|
|
34
|
+
} };
|
|
35
|
+
}
|
|
36
|
+
}, pe = b.span(c.class("bc-field__required"), " *");
|
|
37
|
+
function fe(s, e) {
|
|
38
|
+
const t = ["bc-field"];
|
|
39
|
+
return s !== "vertical" && t.push(`bc-field--${s}`), e && t.push("bc-field--compact"), t.join(" ");
|
|
14
40
|
}
|
|
15
|
-
function
|
|
16
|
-
const t = ["bc-
|
|
17
|
-
return s ? t.push("bc-
|
|
41
|
+
function me(s, e) {
|
|
42
|
+
const t = ["bc-field__label-text"];
|
|
43
|
+
return s ? t.push("bc-field__label-text--error") : e ? t.push("bc-field__label-text--disabled") : t.push("bc-field__label-text--default"), t.join(" ");
|
|
18
44
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
45
|
+
function be(s, e, t) {
|
|
46
|
+
const i = [];
|
|
47
|
+
return (s === "horizontal-fixed" || s === "horizontal-end" || s === "responsive") && e != null && i.push(`--field-label-width: ${e}`), t != null && t > 0 && i.push(`grid-column: span ${t}`), i.length > 0 ? i.join("; ") : void 0;
|
|
22
48
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
function ge(s, e, t) {
|
|
50
|
+
const {
|
|
51
|
+
fullWidth: i = !1,
|
|
52
|
+
required: n,
|
|
53
|
+
label: r,
|
|
54
|
+
labelChildren: l,
|
|
55
|
+
context: a,
|
|
56
|
+
description: o,
|
|
57
|
+
content: u,
|
|
58
|
+
error: h,
|
|
59
|
+
labelFor: p,
|
|
60
|
+
hasError: y,
|
|
61
|
+
disabled: k,
|
|
62
|
+
span: m
|
|
63
|
+
} = e, d = y ?? h != null, w = k ?? !1, I = e.layout ?? s.layout, G = e.labelWidth ?? s.labelWidth, J = e.compact ?? s.compact, L = B("input-wrapper"), V = o ? `${L}-description` : void 0, O = h != null ? `${L}-error` : void 0, $ = v(I)(
|
|
64
|
+
(f) => f !== "vertical" && f !== "responsive"
|
|
65
|
+
), Q = v(
|
|
66
|
+
I,
|
|
67
|
+
G,
|
|
68
|
+
m ?? void 0
|
|
69
|
+
)(
|
|
70
|
+
(f, C, Z) => be(f, T.get(C), Z)
|
|
71
|
+
), X = v(
|
|
72
|
+
I,
|
|
73
|
+
J
|
|
74
|
+
)((f, C) => fe(f, C ?? !1));
|
|
75
|
+
return b.div(
|
|
76
|
+
c.class(X),
|
|
44
77
|
c.class(
|
|
45
|
-
|
|
46
|
-
s,
|
|
47
|
-
(b) => b ? "bc-input-wrapper--full-width" : ""
|
|
48
|
-
)
|
|
78
|
+
T.map(i, (f) => f ? "bc-field--full-width" : "")
|
|
49
79
|
),
|
|
50
|
-
c.style(
|
|
51
|
-
|
|
52
|
-
c.class("bc-
|
|
53
|
-
|
|
54
|
-
c.class("bc-
|
|
55
|
-
|
|
56
|
-
c.class("bc-
|
|
57
|
-
|
|
58
|
-
|
|
80
|
+
c.style(Q),
|
|
81
|
+
r != null || a != null ? b.div(
|
|
82
|
+
c.class("bc-field__header"),
|
|
83
|
+
b.div(
|
|
84
|
+
c.class("bc-field__label-section"),
|
|
85
|
+
b.label(
|
|
86
|
+
c.class("bc-field__label"),
|
|
87
|
+
p != null ? c.for(p) : _,
|
|
88
|
+
b.span(
|
|
59
89
|
c.class(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
90
|
+
v(
|
|
91
|
+
d,
|
|
92
|
+
w
|
|
63
93
|
)(
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
94
|
+
(f, C) => me(
|
|
95
|
+
f ?? !1,
|
|
96
|
+
C ?? !1
|
|
67
97
|
)
|
|
68
98
|
)
|
|
69
99
|
),
|
|
70
|
-
|
|
100
|
+
r
|
|
71
101
|
),
|
|
72
|
-
|
|
102
|
+
r != null && n ? pe : _
|
|
73
103
|
),
|
|
74
104
|
// Show description under label when horizontal
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
105
|
+
x(
|
|
106
|
+
v(
|
|
107
|
+
$,
|
|
78
108
|
o
|
|
79
|
-
)((
|
|
80
|
-
() =>
|
|
109
|
+
)((f, C) => f && C != null),
|
|
110
|
+
() => b.div(
|
|
81
111
|
c.class(
|
|
82
|
-
"bc-
|
|
112
|
+
"bc-field__description bc-field__description--under-label"
|
|
83
113
|
),
|
|
84
|
-
c.id(
|
|
114
|
+
c.id(V),
|
|
85
115
|
o
|
|
86
116
|
)
|
|
87
117
|
)
|
|
88
118
|
),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
) :
|
|
92
|
-
|
|
93
|
-
c.class("bc-
|
|
119
|
+
a != null ? de(a) : _,
|
|
120
|
+
l
|
|
121
|
+
) : _,
|
|
122
|
+
b.div(
|
|
123
|
+
c.class("bc-field__content"),
|
|
94
124
|
// Add data attributes to help inputs inherit accessibility information
|
|
95
|
-
[
|
|
125
|
+
[V, O].filter(Boolean).length > 0 ? W(
|
|
96
126
|
"describedby",
|
|
97
|
-
[
|
|
98
|
-
) :
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
127
|
+
[V, O].filter(Boolean).join(" ")
|
|
128
|
+
) : _,
|
|
129
|
+
n ? W("required", "true") : _,
|
|
130
|
+
x(d, () => W("invalid", "true")),
|
|
131
|
+
u
|
|
102
132
|
),
|
|
103
133
|
// Show description at bottom only when not horizontal
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
() =>
|
|
107
|
-
c.class("bc-
|
|
108
|
-
c.id(
|
|
134
|
+
x(
|
|
135
|
+
v($, o)((f, C) => !f && C != null),
|
|
136
|
+
() => b.div(
|
|
137
|
+
c.class("bc-field__description"),
|
|
138
|
+
c.id(V),
|
|
109
139
|
o
|
|
110
140
|
)
|
|
111
141
|
),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
() =>
|
|
115
|
-
c.class("bc-
|
|
142
|
+
x(
|
|
143
|
+
d,
|
|
144
|
+
() => b.div(
|
|
145
|
+
c.class("bc-field__error"),
|
|
116
146
|
c.id(O),
|
|
117
|
-
|
|
147
|
+
S.live("polite"),
|
|
118
148
|
// Announce errors to screen readers
|
|
119
149
|
c.role("alert"),
|
|
120
150
|
// Mark as alert for immediate attention
|
|
121
|
-
|
|
151
|
+
h
|
|
122
152
|
)
|
|
123
153
|
),
|
|
124
|
-
...
|
|
154
|
+
...t
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
const q = (s, ...e) => {
|
|
158
|
+
const t = {};
|
|
159
|
+
return s.layout !== void 0 && (t.layout = s.layout), s.labelWidth !== void 0 && (t.labelWidth = s.labelWidth), s.compact !== void 0 && (t.compact = s.compact), se(
|
|
160
|
+
j,
|
|
161
|
+
t,
|
|
162
|
+
() => N(j, (i) => ge(i, s, e))
|
|
125
163
|
);
|
|
126
164
|
};
|
|
127
|
-
function
|
|
165
|
+
function Ae({
|
|
128
166
|
size: s = "sm",
|
|
129
167
|
icon: e = "line-md:close",
|
|
130
168
|
disabled: t,
|
|
131
|
-
roundedness:
|
|
132
|
-
color:
|
|
133
|
-
onClick:
|
|
134
|
-
label:
|
|
135
|
-
}, ...
|
|
136
|
-
return
|
|
137
|
-
const
|
|
138
|
-
return
|
|
169
|
+
roundedness: i = "full",
|
|
170
|
+
color: n = "base",
|
|
171
|
+
onClick: r,
|
|
172
|
+
label: l
|
|
173
|
+
}, ...a) {
|
|
174
|
+
return N(re, (o) => {
|
|
175
|
+
const u = ie(l, o.$.closeModal);
|
|
176
|
+
return oe(
|
|
139
177
|
{
|
|
140
178
|
variant: "text",
|
|
141
179
|
size: s,
|
|
142
|
-
roundedness:
|
|
180
|
+
roundedness: i,
|
|
143
181
|
disabled: t,
|
|
144
|
-
color:
|
|
145
|
-
onClick:
|
|
182
|
+
color: n,
|
|
183
|
+
onClick: r
|
|
146
184
|
},
|
|
147
|
-
c.title(
|
|
148
|
-
|
|
149
|
-
...
|
|
150
|
-
|
|
185
|
+
c.title(u),
|
|
186
|
+
S.label(u),
|
|
187
|
+
...a,
|
|
188
|
+
U({ icon: e, size: s ?? "sm" })
|
|
151
189
|
);
|
|
152
190
|
});
|
|
153
191
|
}
|
|
154
|
-
const
|
|
192
|
+
const Be = (s) => {
|
|
155
193
|
const {
|
|
156
194
|
value: e,
|
|
157
195
|
onBlur: t,
|
|
158
|
-
onChange:
|
|
159
|
-
onInput:
|
|
160
|
-
placeholder:
|
|
161
|
-
disabled:
|
|
162
|
-
id:
|
|
163
|
-
activeIcon:
|
|
164
|
-
inactiveIcon:
|
|
165
|
-
size:
|
|
166
|
-
} = s, p =
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
},
|
|
171
|
-
|
|
196
|
+
onChange: i,
|
|
197
|
+
onInput: n,
|
|
198
|
+
placeholder: r,
|
|
199
|
+
disabled: l,
|
|
200
|
+
id: a,
|
|
201
|
+
activeIcon: o,
|
|
202
|
+
inactiveIcon: u,
|
|
203
|
+
size: h = "md"
|
|
204
|
+
} = s, p = a ?? B("checkbox"), y = `${p}-label`, k = () => {
|
|
205
|
+
if (T.get(l ?? !1)) return;
|
|
206
|
+
const d = T.get(e);
|
|
207
|
+
i?.(!d), n?.(!d);
|
|
208
|
+
}, m = (d) => {
|
|
209
|
+
T.get(l ?? !1) || (d.key === " " || d.key === "Enter") && (d.preventDefault(), k());
|
|
172
210
|
};
|
|
173
|
-
return
|
|
211
|
+
return ce(
|
|
174
212
|
{
|
|
175
213
|
baseContainer: !0,
|
|
176
214
|
growInput: !1,
|
|
177
215
|
...s,
|
|
178
|
-
input:
|
|
216
|
+
input: b.span(
|
|
179
217
|
c.class("bc-checkbox-input"),
|
|
180
|
-
|
|
218
|
+
b.span(
|
|
181
219
|
c.class("bc-checkbox-input__checkbox"),
|
|
182
220
|
c.class(
|
|
183
|
-
|
|
221
|
+
T.map(
|
|
184
222
|
e,
|
|
185
|
-
(
|
|
223
|
+
(d) => d ? "bc-checkbox-input__checkbox--checked" : "bc-checkbox-input__checkbox--unchecked"
|
|
186
224
|
)
|
|
187
225
|
),
|
|
188
226
|
c.class(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
(
|
|
227
|
+
T.map(
|
|
228
|
+
l ?? !1,
|
|
229
|
+
(d) => d ? "bc-checkbox-input__checkbox--disabled" : ""
|
|
192
230
|
)
|
|
193
231
|
),
|
|
194
232
|
c.id(p),
|
|
195
233
|
c.role("checkbox"),
|
|
196
234
|
c.tabindex(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
(
|
|
235
|
+
T.map(
|
|
236
|
+
l ?? !1,
|
|
237
|
+
(d) => d ? -1 : 0
|
|
200
238
|
)
|
|
201
239
|
),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
t != null ?
|
|
207
|
-
|
|
208
|
-
icon:
|
|
240
|
+
S.checked(e),
|
|
241
|
+
S.disabled(l),
|
|
242
|
+
r != null ? S.labelledby(y) : _,
|
|
243
|
+
F.keydown(m),
|
|
244
|
+
t != null ? F.blur(t) : _,
|
|
245
|
+
U({
|
|
246
|
+
icon: v(
|
|
209
247
|
e,
|
|
210
|
-
|
|
211
|
-
|
|
248
|
+
o,
|
|
249
|
+
u
|
|
212
250
|
)(
|
|
213
|
-
(
|
|
251
|
+
(d, w, I) => d ? w ?? "ri:checkbox-fill" : I ?? "mdi:checkbox-blank-outline"
|
|
214
252
|
),
|
|
215
253
|
accessibility: "decorative",
|
|
216
|
-
size:
|
|
254
|
+
size: h
|
|
217
255
|
})
|
|
218
256
|
),
|
|
219
|
-
|
|
257
|
+
r != null ? b.label(
|
|
220
258
|
c.class("bc-checkbox-input__label"),
|
|
221
|
-
c.id(
|
|
259
|
+
c.id(y),
|
|
222
260
|
c.for(p),
|
|
223
|
-
|
|
224
|
-
) :
|
|
261
|
+
he(r)
|
|
262
|
+
) : _
|
|
225
263
|
)
|
|
226
264
|
},
|
|
227
|
-
|
|
265
|
+
F.click(k)
|
|
228
266
|
);
|
|
229
|
-
},
|
|
267
|
+
}, ve = (
|
|
230
268
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
231
269
|
((s, e) => () => {
|
|
232
270
|
s.markTouched(), e?.();
|
|
233
271
|
})
|
|
234
|
-
),
|
|
272
|
+
), z = (s, e) => (t) => {
|
|
235
273
|
s.change(t), e?.(t);
|
|
236
274
|
};
|
|
237
|
-
function
|
|
238
|
-
const { controller: t, onBlur:
|
|
275
|
+
function R(s, e) {
|
|
276
|
+
const { controller: t, onBlur: i, onChange: n, id: r, triggerOn: l, ...a } = e;
|
|
239
277
|
return s({
|
|
240
|
-
id:
|
|
278
|
+
id: r ?? t.name,
|
|
241
279
|
disabled: t.disabled,
|
|
242
280
|
value: t.signal,
|
|
243
281
|
hasError: t.errorVisible,
|
|
244
282
|
name: t.name,
|
|
245
|
-
...
|
|
246
|
-
onInput:
|
|
247
|
-
onChange:
|
|
248
|
-
onBlur:
|
|
283
|
+
...a,
|
|
284
|
+
onInput: l === "input" ? z(t, n) : void 0,
|
|
285
|
+
onChange: l !== "input" ? z(t, n) : void 0,
|
|
286
|
+
onBlur: ve(t, i)
|
|
249
287
|
});
|
|
250
288
|
}
|
|
251
|
-
function
|
|
252
|
-
const
|
|
253
|
-
return
|
|
289
|
+
function Oe(s, { id: e, labelFor: t, ...i }, ...n) {
|
|
290
|
+
const r = e ?? i.controller.name ?? B("control"), l = t ?? r;
|
|
291
|
+
return q(
|
|
254
292
|
{
|
|
255
|
-
...
|
|
256
|
-
hasError:
|
|
293
|
+
...i,
|
|
294
|
+
hasError: i.controller.errorVisible,
|
|
257
295
|
// TODO: Remove Primitive annotation once @tempots/dom TextNode is generic
|
|
258
|
-
error:
|
|
259
|
-
labelFor:
|
|
260
|
-
content:
|
|
261
|
-
(
|
|
262
|
-
|
|
296
|
+
error: ne(i.controller.error.map((a) => a ?? "")),
|
|
297
|
+
labelFor: l,
|
|
298
|
+
content: R(
|
|
299
|
+
(a) => s({ ...a, id: r }),
|
|
300
|
+
i
|
|
263
301
|
)
|
|
264
302
|
},
|
|
265
|
-
...
|
|
303
|
+
...n
|
|
266
304
|
);
|
|
267
305
|
}
|
|
268
|
-
function
|
|
269
|
-
const { toInput: t, fromInput:
|
|
270
|
-
return
|
|
271
|
-
...
|
|
272
|
-
controller:
|
|
306
|
+
function ye(s, e) {
|
|
307
|
+
const { toInput: t, fromInput: i, controller: n, ...r } = e, l = n.transform(t, i);
|
|
308
|
+
return R(s, {
|
|
309
|
+
...r,
|
|
310
|
+
controller: l
|
|
273
311
|
});
|
|
274
312
|
}
|
|
275
|
-
function
|
|
313
|
+
function We(s, {
|
|
276
314
|
id: e,
|
|
277
315
|
labelFor: t,
|
|
278
|
-
...
|
|
279
|
-
}, ...
|
|
280
|
-
const
|
|
281
|
-
return
|
|
316
|
+
...i
|
|
317
|
+
}, ...n) {
|
|
318
|
+
const r = e ?? i.controller.name ?? B("control");
|
|
319
|
+
return q(
|
|
282
320
|
{
|
|
283
|
-
...
|
|
284
|
-
labelFor: t ??
|
|
285
|
-
content:
|
|
286
|
-
...
|
|
287
|
-
id:
|
|
321
|
+
...i,
|
|
322
|
+
labelFor: t ?? r,
|
|
323
|
+
content: ye(s, {
|
|
324
|
+
...i,
|
|
325
|
+
id: r
|
|
288
326
|
})
|
|
289
327
|
},
|
|
290
|
-
...
|
|
328
|
+
...n
|
|
291
329
|
);
|
|
292
330
|
}
|
|
293
|
-
function
|
|
331
|
+
function je(s) {
|
|
294
332
|
return s.split(".").map((t) => {
|
|
295
|
-
const
|
|
296
|
-
return
|
|
333
|
+
const i = t.match(/^\[(\d+)\]$/);
|
|
334
|
+
return i ? Number(i[1]) : t;
|
|
297
335
|
});
|
|
298
336
|
}
|
|
299
|
-
function
|
|
337
|
+
function ke(s) {
|
|
300
338
|
return typeof s == "number" ? `[${s}]` : `.${s}`;
|
|
301
339
|
}
|
|
302
|
-
function
|
|
340
|
+
function De(s) {
|
|
303
341
|
if (s.length === 0) return "";
|
|
304
342
|
const [e, ...t] = s;
|
|
305
343
|
return [
|
|
306
344
|
typeof e == "number" ? `[${e}]` : e,
|
|
307
|
-
...t.map(
|
|
345
|
+
...t.map(ke)
|
|
308
346
|
].join("");
|
|
309
347
|
}
|
|
310
|
-
const
|
|
348
|
+
const Pe = {
|
|
311
349
|
/** A valid validation result */
|
|
312
350
|
valid: g.valid,
|
|
313
351
|
/**
|
|
@@ -322,8 +360,8 @@ const Me = {
|
|
|
322
360
|
*/
|
|
323
361
|
invalidFields(s) {
|
|
324
362
|
const e = {};
|
|
325
|
-
for (const [t,
|
|
326
|
-
e[t] = typeof
|
|
363
|
+
for (const [t, i] of Object.entries(s))
|
|
364
|
+
e[t] = typeof i == "string" ? { message: i } : i;
|
|
327
365
|
return g.invalid({ dependencies: e });
|
|
328
366
|
},
|
|
329
367
|
/**
|
|
@@ -333,16 +371,16 @@ const Me = {
|
|
|
333
371
|
return g.invalid(s);
|
|
334
372
|
}
|
|
335
373
|
};
|
|
336
|
-
function
|
|
374
|
+
function A(s) {
|
|
337
375
|
return function(t) {
|
|
338
376
|
if (t.type === "valid") return t;
|
|
339
|
-
let
|
|
340
|
-
for (const
|
|
341
|
-
if (
|
|
342
|
-
return g.invalid(
|
|
377
|
+
let i = t.error;
|
|
378
|
+
for (const n of s)
|
|
379
|
+
if (i = i?.dependencies?.[n], i == null) return g.valid;
|
|
380
|
+
return g.invalid(i);
|
|
343
381
|
};
|
|
344
382
|
}
|
|
345
|
-
class
|
|
383
|
+
class E {
|
|
346
384
|
/** The path segments identifying this controller's position in the form hierarchy (e.g., ['user', 'email']). */
|
|
347
385
|
path;
|
|
348
386
|
/** Callback to propagate value changes up to the parent form. */
|
|
@@ -364,16 +402,16 @@ class _ {
|
|
|
364
402
|
/** Reactive signal containing nested field errors for child controllers. */
|
|
365
403
|
dependencyErrors;
|
|
366
404
|
#e = {
|
|
367
|
-
disabled:
|
|
368
|
-
touched:
|
|
405
|
+
disabled: D(!1),
|
|
406
|
+
touched: D(!1)
|
|
369
407
|
};
|
|
370
408
|
#s;
|
|
371
|
-
#t =
|
|
409
|
+
#t = D(void 0);
|
|
372
410
|
/** Parent controller context providing disabled state and optional validation mode. */
|
|
373
411
|
parent;
|
|
374
412
|
/** Reactive signal indicating whether this field is disabled (combines local and parent disabled state). */
|
|
375
413
|
disabled;
|
|
376
|
-
#
|
|
414
|
+
#i = [];
|
|
377
415
|
/** Reactive signal indicating whether this field is disabled OR has errors (useful for submit button state). */
|
|
378
416
|
disabledOrHasErrors;
|
|
379
417
|
/**
|
|
@@ -386,28 +424,28 @@ class _ {
|
|
|
386
424
|
* @param parent - Parent context with disabled state and optional validation mode
|
|
387
425
|
* @param equals - Equality function for dirty tracking (defaults to strictEqual)
|
|
388
426
|
*/
|
|
389
|
-
constructor(e, t,
|
|
390
|
-
this.path = e, this.change = t, this.signal =
|
|
391
|
-
(
|
|
392
|
-
), this.hasError = this.error.map((
|
|
427
|
+
constructor(e, t, i, n, r, l = M) {
|
|
428
|
+
this.path = e, this.change = t, this.signal = i, this.status = n, this.#s = l, this.#t.set(i.value), this.error = n.map(
|
|
429
|
+
(a) => a?.type === "invalid" ? a.error?.message : void 0
|
|
430
|
+
), this.hasError = this.error.map((a) => a != null), this.touched = this.#e.touched, r.validationMode ? this.errorVisible = v(
|
|
393
431
|
this.hasError,
|
|
394
432
|
this.touched,
|
|
395
|
-
|
|
396
|
-
)((
|
|
433
|
+
r.validationMode
|
|
434
|
+
)((a, o, u) => u === "eager" ? !!a : !!a && !!o) : this.errorVisible = v(
|
|
397
435
|
this.hasError,
|
|
398
436
|
this.touched
|
|
399
|
-
)((
|
|
437
|
+
)((a, o) => !!a && !!o), this.dirty = v(
|
|
400
438
|
this.signal,
|
|
401
439
|
this.#t
|
|
402
|
-
)((
|
|
403
|
-
(
|
|
404
|
-
), this.parent =
|
|
440
|
+
)((a, o) => !this.#s(a, o)), this.dependencyErrors = n.map(
|
|
441
|
+
(a) => a?.type === "invalid" ? a.error?.dependencies : void 0
|
|
442
|
+
), this.parent = r, this.disabled = v(
|
|
405
443
|
this.#e.disabled,
|
|
406
|
-
|
|
407
|
-
)((
|
|
444
|
+
r.disabled
|
|
445
|
+
)((a, o) => a || o), this.disabledOrHasErrors = v(
|
|
408
446
|
this.disabled,
|
|
409
447
|
this.hasError
|
|
410
|
-
)((
|
|
448
|
+
)((a, o) => a || o), this.onDispose(() => {
|
|
411
449
|
this.#e.disabled.dispose(), this.#e.touched.dispose(), this.disabled.dispose(), this.error.dispose(), this.errorVisible.dispose(), this.dirty.dispose(), this.#t.dispose(), this.dependencyErrors.dispose(), this.disabledOrHasErrors.dispose();
|
|
412
450
|
});
|
|
413
451
|
}
|
|
@@ -415,7 +453,7 @@ class _ {
|
|
|
415
453
|
* Returns the field name as a dot-separated string (e.g., "user.email").
|
|
416
454
|
*/
|
|
417
455
|
get name() {
|
|
418
|
-
return
|
|
456
|
+
return De(this.path);
|
|
419
457
|
}
|
|
420
458
|
/**
|
|
421
459
|
* Registers a callback to be executed when this controller is disposed.
|
|
@@ -423,20 +461,20 @@ class _ {
|
|
|
423
461
|
* @param callback - Function to execute on disposal
|
|
424
462
|
*/
|
|
425
463
|
onDispose = (e) => {
|
|
426
|
-
this.#
|
|
464
|
+
this.#i.push(e);
|
|
427
465
|
};
|
|
428
466
|
/**
|
|
429
467
|
* Disposes all internal resources and registered callbacks.
|
|
430
468
|
* Should be called when the controller is no longer needed to prevent memory leaks.
|
|
431
469
|
*/
|
|
432
470
|
dispose = () => {
|
|
433
|
-
for (const e of this.#
|
|
471
|
+
for (const e of this.#i)
|
|
434
472
|
try {
|
|
435
473
|
e();
|
|
436
474
|
} catch (t) {
|
|
437
475
|
console.error("Error in dispose callback:", t);
|
|
438
476
|
}
|
|
439
|
-
this.#
|
|
477
|
+
this.#i.length = 0;
|
|
440
478
|
};
|
|
441
479
|
/**
|
|
442
480
|
* Sets the disabled state for this field.
|
|
@@ -484,7 +522,7 @@ class _ {
|
|
|
484
522
|
* @param equals - Equality function for array comparison (defaults to strictEqual)
|
|
485
523
|
* @returns An ArrayController instance
|
|
486
524
|
*/
|
|
487
|
-
array = (e =
|
|
525
|
+
array = (e = M) => new Te(
|
|
488
526
|
this.path,
|
|
489
527
|
this.change,
|
|
490
528
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -499,7 +537,7 @@ class _ {
|
|
|
499
537
|
* @param equals - Equality function for object comparison (defaults to strictEqual)
|
|
500
538
|
* @returns An ObjectController instance
|
|
501
539
|
*/
|
|
502
|
-
object = (e =
|
|
540
|
+
object = (e = M) => new Ce(
|
|
503
541
|
this.path,
|
|
504
542
|
this.change,
|
|
505
543
|
this.signal,
|
|
@@ -527,13 +565,13 @@ class _ {
|
|
|
527
565
|
* )
|
|
528
566
|
* ```
|
|
529
567
|
*/
|
|
530
|
-
transform = (e, t,
|
|
531
|
-
[...this.path, ...
|
|
532
|
-
(
|
|
533
|
-
this.signal.map(e,
|
|
534
|
-
this.status.map(
|
|
568
|
+
transform = (e, t, i = [], n = M) => new E(
|
|
569
|
+
[...this.path, ...i],
|
|
570
|
+
(r) => this.change(t(r)),
|
|
571
|
+
this.signal.map(e, n),
|
|
572
|
+
this.status.map(A(i)),
|
|
535
573
|
this.parent,
|
|
536
|
-
|
|
574
|
+
n
|
|
537
575
|
);
|
|
538
576
|
/**
|
|
539
577
|
* Creates a transformed controller with async bidirectional mapping.
|
|
@@ -547,62 +585,62 @@ class _ {
|
|
|
547
585
|
* @param equals - Equality function for the transformed type
|
|
548
586
|
* @returns A new Controller instance managing the async-transformed value
|
|
549
587
|
*/
|
|
550
|
-
asyncTransform = (e, t,
|
|
551
|
-
[...this.path, ...
|
|
552
|
-
(
|
|
553
|
-
t(
|
|
588
|
+
asyncTransform = (e, t, i, n = [], r = M) => new E(
|
|
589
|
+
[...this.path, ...n],
|
|
590
|
+
(l) => {
|
|
591
|
+
t(l).then((a) => this.change(a));
|
|
554
592
|
},
|
|
555
|
-
this.signal.mapAsync(e,
|
|
556
|
-
this.status.map(
|
|
593
|
+
this.signal.mapAsync(e, i, void 0, r),
|
|
594
|
+
this.status.map(A(n)),
|
|
557
595
|
this.parent,
|
|
558
|
-
|
|
596
|
+
r
|
|
559
597
|
);
|
|
560
598
|
}
|
|
561
|
-
class
|
|
599
|
+
class Ce extends E {
|
|
562
600
|
#e = /* @__PURE__ */ new Map();
|
|
563
601
|
#s = /* @__PURE__ */ new Map();
|
|
564
602
|
#t = /* @__PURE__ */ new Map();
|
|
565
|
-
#
|
|
603
|
+
#i = D(!1);
|
|
566
604
|
/** Reactive signal indicating whether this field or any child field is touched. */
|
|
567
|
-
touchedDeep = this.#
|
|
568
|
-
#
|
|
569
|
-
#
|
|
570
|
-
#
|
|
605
|
+
touchedDeep = this.#i;
|
|
606
|
+
#a = /* @__PURE__ */ new Map();
|
|
607
|
+
#n = /* @__PURE__ */ new Map();
|
|
608
|
+
#r = D(!1);
|
|
571
609
|
/** Reactive signal indicating whether this field or any child field is dirty. */
|
|
572
|
-
dirtyDeep = this.#
|
|
610
|
+
dirtyDeep = this.#r;
|
|
573
611
|
#c;
|
|
574
|
-
#
|
|
575
|
-
#
|
|
612
|
+
#d;
|
|
613
|
+
#o = () => {
|
|
576
614
|
let e = !1;
|
|
577
615
|
for (const t of this.#s.values())
|
|
578
616
|
if (t) {
|
|
579
617
|
e = !0;
|
|
580
618
|
break;
|
|
581
619
|
}
|
|
582
|
-
this.#
|
|
620
|
+
this.#i.set(this.touched.value || e);
|
|
583
621
|
};
|
|
584
|
-
constructor(e, t,
|
|
622
|
+
constructor(e, t, i, n, r, l) {
|
|
585
623
|
super(
|
|
586
624
|
e,
|
|
587
625
|
t,
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
626
|
+
i.map((o) => o ?? {}, l),
|
|
627
|
+
n,
|
|
628
|
+
r,
|
|
629
|
+
l
|
|
592
630
|
), this.#c = this.touched.on(() => {
|
|
631
|
+
this.#o();
|
|
632
|
+
}), this.#d = this.dirty.on(() => {
|
|
593
633
|
this.#l();
|
|
594
|
-
}), this.#h = this.dirty.on(() => {
|
|
595
|
-
this.#a();
|
|
596
634
|
});
|
|
597
|
-
const
|
|
635
|
+
const a = this.signal.on(() => this.#l());
|
|
598
636
|
this.onDispose(() => {
|
|
599
|
-
for (const
|
|
600
|
-
|
|
637
|
+
for (const o of this.#e.values())
|
|
638
|
+
o.dispose();
|
|
601
639
|
this.#e.clear();
|
|
602
|
-
for (const
|
|
603
|
-
this.#t.clear(), this.#s.clear(), this.#
|
|
604
|
-
for (const
|
|
605
|
-
this.#
|
|
640
|
+
for (const o of this.#t.values()) o();
|
|
641
|
+
this.#t.clear(), this.#s.clear(), this.#i.dispose();
|
|
642
|
+
for (const o of this.#n.values()) o();
|
|
643
|
+
this.#n.clear(), this.#a.clear(), this.#r.dispose(), this.#c(), this.#d(), a();
|
|
606
644
|
});
|
|
607
645
|
}
|
|
608
646
|
/**
|
|
@@ -622,31 +660,31 @@ class ue extends _ {
|
|
|
622
660
|
field = (e) => {
|
|
623
661
|
if (this.#e.has(e))
|
|
624
662
|
return this.#e.get(e);
|
|
625
|
-
const t = async (
|
|
663
|
+
const t = async (l) => {
|
|
626
664
|
this.change({
|
|
627
665
|
...this.signal.value,
|
|
628
|
-
[e]:
|
|
666
|
+
[e]: l
|
|
629
667
|
});
|
|
630
|
-
},
|
|
668
|
+
}, i = new E(
|
|
631
669
|
[...this.path, e],
|
|
632
670
|
t,
|
|
633
|
-
this.signal.map((
|
|
634
|
-
this.status.map(
|
|
671
|
+
this.signal.map((l) => l[e]),
|
|
672
|
+
this.status.map(A([e])),
|
|
635
673
|
{
|
|
636
674
|
disabled: this.disabled,
|
|
637
675
|
// propagate validationMode to children if present
|
|
638
676
|
validationMode: this.parent.validationMode
|
|
639
677
|
}
|
|
640
678
|
);
|
|
641
|
-
this.#e.set(e,
|
|
642
|
-
const
|
|
643
|
-
this.#s.set(e,
|
|
679
|
+
this.#e.set(e, i);
|
|
680
|
+
const n = i.touched.on((l) => {
|
|
681
|
+
this.#s.set(e, l), this.#o();
|
|
644
682
|
});
|
|
645
|
-
this.#t.set(e,
|
|
646
|
-
const
|
|
647
|
-
this.#
|
|
683
|
+
this.#t.set(e, n);
|
|
684
|
+
const r = i.dirty.on((l) => {
|
|
685
|
+
this.#a.set(e, l), this.#l();
|
|
648
686
|
});
|
|
649
|
-
return this.#
|
|
687
|
+
return this.#n.set(e, r), i;
|
|
650
688
|
};
|
|
651
689
|
/**
|
|
652
690
|
* Marks this field and all child fields as touched recursively.
|
|
@@ -671,65 +709,65 @@ class ue extends _ {
|
|
|
671
709
|
for (const t of this.#e.values())
|
|
672
710
|
t.markPristine?.();
|
|
673
711
|
};
|
|
674
|
-
#
|
|
712
|
+
#l = () => {
|
|
675
713
|
let e = !1;
|
|
676
|
-
for (const t of this.#
|
|
714
|
+
for (const t of this.#a.values())
|
|
677
715
|
if (t) {
|
|
678
716
|
e = !0;
|
|
679
717
|
break;
|
|
680
718
|
}
|
|
681
|
-
this.#
|
|
719
|
+
this.#r.set(this.dirty.value || e);
|
|
682
720
|
};
|
|
683
721
|
}
|
|
684
|
-
class
|
|
722
|
+
class Te extends E {
|
|
685
723
|
#e = new Array();
|
|
686
724
|
/** Reactive signal containing the current array length. */
|
|
687
725
|
length;
|
|
688
726
|
#s = /* @__PURE__ */ new Map();
|
|
689
727
|
#t = /* @__PURE__ */ new Map();
|
|
690
|
-
#
|
|
728
|
+
#i = D(!1);
|
|
691
729
|
/** Reactive signal indicating whether this array or any item is touched. */
|
|
692
|
-
touchedDeep = this.#
|
|
693
|
-
#
|
|
694
|
-
#
|
|
695
|
-
#
|
|
730
|
+
touchedDeep = this.#i;
|
|
731
|
+
#a = /* @__PURE__ */ new Map();
|
|
732
|
+
#n = /* @__PURE__ */ new Map();
|
|
733
|
+
#r = D(!1);
|
|
696
734
|
/** Reactive signal indicating whether this array or any item is dirty. */
|
|
697
|
-
dirtyDeep = this.#
|
|
735
|
+
dirtyDeep = this.#r;
|
|
698
736
|
#c;
|
|
699
|
-
#
|
|
700
|
-
#
|
|
737
|
+
#d;
|
|
738
|
+
#o = () => {
|
|
701
739
|
let e = !1;
|
|
702
740
|
for (const t of this.#s.values())
|
|
703
741
|
if (t) {
|
|
704
742
|
e = !0;
|
|
705
743
|
break;
|
|
706
744
|
}
|
|
707
|
-
this.#
|
|
745
|
+
this.#i.set(this.touched.value || e);
|
|
708
746
|
};
|
|
709
|
-
constructor(e, t,
|
|
710
|
-
const
|
|
711
|
-
super(e, t,
|
|
712
|
-
const
|
|
713
|
-
const p = this.#e.length -
|
|
714
|
-
p > 0 && (this.#e.splice(
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
}), this.#
|
|
747
|
+
constructor(e, t, i, n, r, l) {
|
|
748
|
+
const a = i.map((h) => h ?? [], l);
|
|
749
|
+
super(e, t, a, n, r, l);
|
|
750
|
+
const o = a.on((h) => {
|
|
751
|
+
const p = this.#e.length - h.length;
|
|
752
|
+
p > 0 && (this.#e.splice(h.length, p).forEach((y, k) => {
|
|
753
|
+
const m = h.length + k;
|
|
754
|
+
y.dispose(), this.#t.get(m)?.(), this.#t.delete(m), this.#s.delete(m), this.#n.get(m)?.(), this.#n.delete(m), this.#a.delete(m);
|
|
755
|
+
}), this.#o(), this.#l());
|
|
718
756
|
});
|
|
719
|
-
this.length =
|
|
757
|
+
this.length = a.map((h) => h.length), this.#c = this.touched.on(() => {
|
|
758
|
+
this.#o();
|
|
759
|
+
}), this.#d = this.dirty.on(() => {
|
|
720
760
|
this.#l();
|
|
721
|
-
}), this.#h = this.dirty.on(() => {
|
|
722
|
-
this.#a();
|
|
723
761
|
});
|
|
724
|
-
const
|
|
762
|
+
const u = this.signal.on(() => this.#l());
|
|
725
763
|
this.onDispose(() => {
|
|
726
|
-
for (const
|
|
727
|
-
|
|
728
|
-
this.length.dispose(), this.#e.length = 0,
|
|
729
|
-
for (const
|
|
730
|
-
this.#t.clear(), this.#s.clear(), this.#
|
|
731
|
-
for (const
|
|
732
|
-
this.#
|
|
764
|
+
for (const h of this.#e)
|
|
765
|
+
h.dispose();
|
|
766
|
+
this.length.dispose(), this.#e.length = 0, o(), a.dispose();
|
|
767
|
+
for (const h of this.#t.values()) h();
|
|
768
|
+
this.#t.clear(), this.#s.clear(), this.#i.dispose();
|
|
769
|
+
for (const h of this.#n.values()) h();
|
|
770
|
+
this.#n.clear(), this.#a.clear(), this.#r.dispose(), this.#c(), this.#d(), u();
|
|
733
771
|
});
|
|
734
772
|
}
|
|
735
773
|
/**
|
|
@@ -748,28 +786,28 @@ class de extends _ {
|
|
|
748
786
|
item = (e) => {
|
|
749
787
|
if (this.#e[e])
|
|
750
788
|
return this.#e[e];
|
|
751
|
-
const t = async (
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
},
|
|
789
|
+
const t = async (l) => {
|
|
790
|
+
const a = this.signal.value.slice();
|
|
791
|
+
a[e] = l, this.change(a);
|
|
792
|
+
}, i = new E(
|
|
755
793
|
[...this.path, e],
|
|
756
794
|
t,
|
|
757
|
-
this.signal.map((
|
|
758
|
-
this.status.map(
|
|
795
|
+
this.signal.map((l) => l[e]),
|
|
796
|
+
this.status.map(A([e])),
|
|
759
797
|
{
|
|
760
798
|
disabled: this.disabled,
|
|
761
799
|
validationMode: this.parent.validationMode
|
|
762
800
|
}
|
|
763
801
|
);
|
|
764
|
-
this.#e[e] =
|
|
765
|
-
const
|
|
766
|
-
this.#s.set(e,
|
|
802
|
+
this.#e[e] = i;
|
|
803
|
+
const n = i.touched.on((l) => {
|
|
804
|
+
this.#s.set(e, l), this.#o();
|
|
767
805
|
});
|
|
768
|
-
this.#t.set(e,
|
|
769
|
-
const
|
|
770
|
-
this.#
|
|
806
|
+
this.#t.set(e, n);
|
|
807
|
+
const r = i.dirty.on((l) => {
|
|
808
|
+
this.#a.set(e, l), this.#l();
|
|
771
809
|
});
|
|
772
|
-
return this.#
|
|
810
|
+
return this.#n.set(e, r), i;
|
|
773
811
|
};
|
|
774
812
|
/**
|
|
775
813
|
* Appends one or more items to the end of the array.
|
|
@@ -814,8 +852,8 @@ class de extends _ {
|
|
|
814
852
|
* @param deleteCount - Number of items to remove (optional)
|
|
815
853
|
*/
|
|
816
854
|
splice = (e, t) => {
|
|
817
|
-
const
|
|
818
|
-
|
|
855
|
+
const i = this.signal.value.slice();
|
|
856
|
+
i.splice(e, t), this.change(i);
|
|
819
857
|
};
|
|
820
858
|
/**
|
|
821
859
|
* Moves one or more items from one index to another within the array.
|
|
@@ -830,10 +868,10 @@ class de extends _ {
|
|
|
830
868
|
* controller.move(2, 0, 2) // Move items at index 2-3 to the beginning
|
|
831
869
|
* ```
|
|
832
870
|
*/
|
|
833
|
-
move = (e, t,
|
|
834
|
-
if (
|
|
835
|
-
const
|
|
836
|
-
|
|
871
|
+
move = (e, t, i = 1) => {
|
|
872
|
+
if (i < 1 || e === t) return;
|
|
873
|
+
const n = this.signal.value.slice(), r = n.splice(e, i);
|
|
874
|
+
n.splice(t, 0, ...r), this.change(n);
|
|
837
875
|
};
|
|
838
876
|
/**
|
|
839
877
|
* Marks this array and all item controllers as touched recursively.
|
|
@@ -854,17 +892,17 @@ class de extends _ {
|
|
|
854
892
|
for (let t = 0; t < e; t++)
|
|
855
893
|
this.item(t).markPristine?.();
|
|
856
894
|
};
|
|
857
|
-
#
|
|
895
|
+
#l = () => {
|
|
858
896
|
let e = !1;
|
|
859
|
-
for (const t of this.#
|
|
897
|
+
for (const t of this.#a.values())
|
|
860
898
|
if (t) {
|
|
861
899
|
e = !0;
|
|
862
900
|
break;
|
|
863
901
|
}
|
|
864
|
-
this.#
|
|
902
|
+
this.#r.set(this.dirty.value || e);
|
|
865
903
|
};
|
|
866
904
|
}
|
|
867
|
-
function
|
|
905
|
+
function _e(s) {
|
|
868
906
|
function e(t) {
|
|
869
907
|
return typeof t == "number" ? t : t.toString();
|
|
870
908
|
}
|
|
@@ -872,179 +910,181 @@ function pe(s) {
|
|
|
872
910
|
(t) => typeof t == "object" && t.key != null ? e(t.key) : e(t)
|
|
873
911
|
);
|
|
874
912
|
}
|
|
875
|
-
function
|
|
876
|
-
const e = s.filter((
|
|
877
|
-
const
|
|
878
|
-
let
|
|
879
|
-
for (const
|
|
880
|
-
|
|
881
|
-
return
|
|
882
|
-
}, {}),
|
|
913
|
+
function we(s) {
|
|
914
|
+
const e = s.filter((n) => n.path == null || n.path.length === 0).map((n) => n.message), t = s.filter((n) => n.path != null && n.path.length > 0).reduce((n, r) => {
|
|
915
|
+
const l = _e(r.path), a = l.pop();
|
|
916
|
+
let o = n;
|
|
917
|
+
for (const u of l)
|
|
918
|
+
o.dependencies == null && (o.dependencies = {}), o.dependencies[u] == null && (o.dependencies[u] = {}), o = o.dependencies[u];
|
|
919
|
+
return o.dependencies == null && (o.dependencies = {}), o.dependencies[a] = { message: r.message }, n;
|
|
920
|
+
}, {}), i = e.join(`
|
|
883
921
|
`);
|
|
884
922
|
return {
|
|
885
923
|
...t,
|
|
886
|
-
message:
|
|
924
|
+
message: i != "" ? i : void 0
|
|
887
925
|
};
|
|
888
926
|
}
|
|
889
|
-
function
|
|
927
|
+
function Ie({
|
|
890
928
|
initialValue: s,
|
|
891
929
|
onChange: e,
|
|
892
930
|
validate: t,
|
|
893
|
-
equals:
|
|
894
|
-
validationMode:
|
|
895
|
-
validateDebounceMs:
|
|
931
|
+
equals: i,
|
|
932
|
+
validationMode: n,
|
|
933
|
+
validateDebounceMs: r
|
|
896
934
|
}) {
|
|
897
|
-
const
|
|
898
|
-
|
|
935
|
+
const l = T.deriveProp(s), a = D(g.valid), o = D(!1), u = D(n ?? "onTouched"), h = (d) => {
|
|
936
|
+
a.set(d);
|
|
899
937
|
};
|
|
900
938
|
let p;
|
|
901
|
-
const
|
|
939
|
+
const y = async (d) => {
|
|
902
940
|
if (t != null) {
|
|
903
|
-
const
|
|
904
|
-
|
|
941
|
+
const w = await t(d);
|
|
942
|
+
h(w);
|
|
905
943
|
}
|
|
906
|
-
},
|
|
907
|
-
|
|
908
|
-
const
|
|
944
|
+
}, k = async (d) => {
|
|
945
|
+
l.set(d), e?.(d);
|
|
946
|
+
const w = u.value;
|
|
909
947
|
if (t != null) {
|
|
910
|
-
if (
|
|
948
|
+
if (w === "onSubmit")
|
|
911
949
|
return;
|
|
912
|
-
const I =
|
|
950
|
+
const I = r ?? 0;
|
|
913
951
|
I > 0 ? (p && clearTimeout(p), p = setTimeout(() => {
|
|
914
|
-
|
|
915
|
-
}, I)) : await
|
|
952
|
+
y(d);
|
|
953
|
+
}, I)) : await y(d);
|
|
916
954
|
}
|
|
917
|
-
},
|
|
955
|
+
}, m = new E(
|
|
918
956
|
[],
|
|
919
|
-
|
|
957
|
+
k,
|
|
958
|
+
l,
|
|
920
959
|
a,
|
|
921
|
-
r,
|
|
922
960
|
{
|
|
923
|
-
disabled:
|
|
924
|
-
validationMode:
|
|
961
|
+
disabled: o,
|
|
962
|
+
validationMode: u
|
|
925
963
|
},
|
|
926
|
-
|
|
964
|
+
i ?? M
|
|
927
965
|
);
|
|
928
|
-
return
|
|
929
|
-
|
|
930
|
-
}), { controller:
|
|
966
|
+
return m.onDispose(() => {
|
|
967
|
+
o.dispose(), l.dispose(), a.dispose(), u.dispose(), p && clearTimeout(p);
|
|
968
|
+
}), { controller: m, setStatus: h };
|
|
931
969
|
}
|
|
932
|
-
function
|
|
933
|
-
return
|
|
970
|
+
function K(s) {
|
|
971
|
+
return P(c.disabled(s.disabled), c.name(s.name));
|
|
934
972
|
}
|
|
935
|
-
function
|
|
973
|
+
function Le(s, {
|
|
936
974
|
triggerOn: e = "change"
|
|
937
975
|
} = {}) {
|
|
938
|
-
return
|
|
939
|
-
|
|
976
|
+
return P(
|
|
977
|
+
K(s),
|
|
940
978
|
c.value(s.signal),
|
|
941
|
-
(e === "input" ?
|
|
979
|
+
(e === "input" ? F.input : F.change)(le(s.change))
|
|
942
980
|
);
|
|
943
981
|
}
|
|
944
|
-
function
|
|
982
|
+
function $e(s, {
|
|
945
983
|
triggerOn: e = "change"
|
|
946
984
|
} = {}) {
|
|
947
|
-
return
|
|
948
|
-
|
|
985
|
+
return P(
|
|
986
|
+
K(s),
|
|
949
987
|
c.valueAsNumber(s.signal),
|
|
950
|
-
(e === "input" ?
|
|
951
|
-
|
|
988
|
+
(e === "input" ? F.input : F.change)(
|
|
989
|
+
ae(s.change)
|
|
952
990
|
)
|
|
953
991
|
);
|
|
954
992
|
}
|
|
955
|
-
function
|
|
956
|
-
return s.issues != null ? g.invalid(
|
|
993
|
+
function H(s) {
|
|
994
|
+
return s.issues != null ? g.invalid(we(s.issues)) : g.valid;
|
|
957
995
|
}
|
|
958
|
-
async function
|
|
996
|
+
async function ze({
|
|
959
997
|
task: s,
|
|
960
998
|
errorMessage: e,
|
|
961
999
|
errorPath: t = ["root"],
|
|
962
|
-
validation:
|
|
1000
|
+
validation: i
|
|
963
1001
|
}) {
|
|
964
1002
|
try {
|
|
965
|
-
const
|
|
966
|
-
return
|
|
967
|
-
} catch (
|
|
968
|
-
const
|
|
1003
|
+
const n = await s();
|
|
1004
|
+
return i != null ? i(n) : g.valid;
|
|
1005
|
+
} catch (n) {
|
|
1006
|
+
const r = e ?? (n instanceof Error ? n.message : "Operation failed");
|
|
969
1007
|
return t.length === 1 && t[0] === "root" ? g.invalid({
|
|
970
|
-
message:
|
|
1008
|
+
message: r
|
|
971
1009
|
}) : g.invalid({
|
|
972
|
-
dependencies:
|
|
1010
|
+
dependencies: Y(t, r)
|
|
973
1011
|
});
|
|
974
1012
|
}
|
|
975
1013
|
}
|
|
976
|
-
function
|
|
1014
|
+
function Y(s, e) {
|
|
977
1015
|
if (s.length === 1)
|
|
978
1016
|
return {
|
|
979
1017
|
[s[0]]: { message: e }
|
|
980
1018
|
};
|
|
981
|
-
const [t, ...
|
|
1019
|
+
const [t, ...i] = s;
|
|
982
1020
|
return {
|
|
983
1021
|
[t]: {
|
|
984
|
-
dependencies:
|
|
1022
|
+
dependencies: Y(i, e)
|
|
985
1023
|
}
|
|
986
1024
|
};
|
|
987
1025
|
}
|
|
988
|
-
function
|
|
1026
|
+
function He({
|
|
989
1027
|
initialValue: s = {},
|
|
990
1028
|
schema: e,
|
|
991
1029
|
onSubmit: t = async () => g.valid,
|
|
992
|
-
validationMode:
|
|
993
|
-
validateDebounceMs:
|
|
1030
|
+
validationMode: i,
|
|
1031
|
+
validateDebounceMs: n
|
|
994
1032
|
}) {
|
|
995
|
-
const { controller:
|
|
1033
|
+
const { controller: r, setStatus: l } = Ie({
|
|
996
1034
|
initialValue: s,
|
|
997
|
-
validationMode:
|
|
998
|
-
validateDebounceMs:
|
|
999
|
-
validate: (
|
|
1000
|
-
await e["~standard"].validate(
|
|
1035
|
+
validationMode: i ?? "onTouched",
|
|
1036
|
+
validateDebounceMs: n,
|
|
1037
|
+
validate: (i ?? "onTouched") === "onSubmit" || e == null ? void 0 : async (h) => H(
|
|
1038
|
+
await e["~standard"].validate(h)
|
|
1001
1039
|
)
|
|
1002
|
-
}),
|
|
1003
|
-
return
|
|
1004
|
-
controller:
|
|
1005
|
-
setStatus:
|
|
1006
|
-
submit: async (
|
|
1007
|
-
if (
|
|
1008
|
-
const
|
|
1009
|
-
await e["~standard"].validate(
|
|
1040
|
+
}), a = D(!1), o = r.object();
|
|
1041
|
+
return o.onDispose(() => a.dispose()), {
|
|
1042
|
+
controller: o,
|
|
1043
|
+
setStatus: l,
|
|
1044
|
+
submit: async (h) => {
|
|
1045
|
+
if (a.set(!0), h?.preventDefault(), o.markAllTouched(), e != null) {
|
|
1046
|
+
const y = o.signal.value, k = H(
|
|
1047
|
+
await e["~standard"].validate(y)
|
|
1010
1048
|
);
|
|
1011
|
-
if (
|
|
1012
|
-
|
|
1049
|
+
if (l(k), k.type === "invalid") {
|
|
1050
|
+
a.set(!1);
|
|
1013
1051
|
return;
|
|
1014
1052
|
}
|
|
1015
1053
|
}
|
|
1016
|
-
const p = await t(
|
|
1017
|
-
|
|
1054
|
+
const p = await t(o.signal.value);
|
|
1055
|
+
a.set(!1), p.type === "invalid" && l(p);
|
|
1018
1056
|
},
|
|
1019
|
-
submitting:
|
|
1057
|
+
submitting: a
|
|
1020
1058
|
};
|
|
1021
1059
|
}
|
|
1022
1060
|
export {
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1061
|
+
Te as A,
|
|
1062
|
+
R as B,
|
|
1063
|
+
Ae as C,
|
|
1064
|
+
q as F,
|
|
1065
|
+
We as M,
|
|
1066
|
+
Ce as O,
|
|
1067
|
+
pe as R,
|
|
1068
|
+
Be as a,
|
|
1069
|
+
Oe as b,
|
|
1070
|
+
z as c,
|
|
1071
|
+
E as d,
|
|
1072
|
+
A as e,
|
|
1073
|
+
Ie as f,
|
|
1074
|
+
j as g,
|
|
1075
|
+
ye as h,
|
|
1076
|
+
Pe as i,
|
|
1077
|
+
ue as j,
|
|
1078
|
+
K as k,
|
|
1079
|
+
$e as l,
|
|
1080
|
+
ve as m,
|
|
1081
|
+
Le as n,
|
|
1082
|
+
we as o,
|
|
1083
|
+
_e as p,
|
|
1084
|
+
je as q,
|
|
1085
|
+
De as r,
|
|
1086
|
+
H as s,
|
|
1087
|
+
ze as t,
|
|
1088
|
+
He as u,
|
|
1089
|
+
ke as w
|
|
1050
1090
|
};
|