@tempots/beatui 1.7.5 → 1.9.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.
Files changed (159) hide show
  1. package/dist/{ar-Wr6gMs-M.cjs → ar-CEzAem0F.cjs} +1 -1
  2. package/dist/{ar-fdUqbCvM.js → ar-CQieaqsq.js} +1 -1
  3. package/dist/auth/index.cjs.js +1 -1
  4. package/dist/auth/index.es.js +1 -1
  5. package/dist/auth-divider-B8yr-E_b.cjs +1 -0
  6. package/dist/{auth-divider-D9KnNeyF.js → auth-divider-Byh5BWLc.js} +91 -88
  7. package/dist/better-auth/index.cjs.js +1 -1
  8. package/dist/better-auth/index.es.js +27 -26
  9. package/dist/card-BkA7Wvbh.cjs +1 -0
  10. package/dist/card-DX1DwGbL.js +62 -0
  11. package/dist/{colors-C2sgnzFH.js → colors-CyMhfbJi.js} +64 -58
  12. package/dist/{colors-DPCHjRMj.cjs → colors-IXZF9U-s.cjs} +1 -1
  13. package/dist/control-hqEuMzyI.js +343 -0
  14. package/dist/control-muup9GF1.cjs +1 -0
  15. package/dist/custom-validation-BA9iJWl_.cjs +1 -0
  16. package/dist/custom-validation-BOBoUwHY.js +181 -0
  17. package/dist/{de-C5-k5Eov.js → de-CBIwvkAH.js} +1 -1
  18. package/dist/{de-DZqdSEta.cjs → de-DdfxrlT3.cjs} +1 -1
  19. package/dist/deep-merge-8fwp1z4X.js +1346 -0
  20. package/dist/deep-merge-VDGE_HQD.cjs +1 -0
  21. package/dist/duration-input-DmsljXl3.cjs +1 -0
  22. package/dist/{duration-input-D4V_PHIg.js → duration-input-ZQlcqdXU.js} +32 -31
  23. package/dist/{editor-toolbar-group-FpOHrmtx.js → editor-toolbar-group-BNTBMJCe.js} +2 -2
  24. package/dist/{editor-toolbar-group-C_ft_T8D.cjs → editor-toolbar-group-DiMzqYgz.cjs} +1 -1
  25. package/dist/{es-h6jmoF4X.js → es--9HaEj2D.js} +1 -1
  26. package/dist/{es-CJgYfRap.cjs → es-DSdljxFJ.cjs} +1 -1
  27. package/dist/{fa-BuxK837l.js → fa-1Z-akcW7.js} +1 -1
  28. package/dist/{fa-BQ5PzwNY.cjs → fa-BolmeWRT.cjs} +1 -1
  29. package/dist/flyout-CuKFh_T7.js +151 -0
  30. package/dist/flyout-DC_tKaTG.cjs +1 -0
  31. package/dist/{fr-Bv3TG44U.cjs → fr-CODgUuoZ.cjs} +1 -1
  32. package/dist/{fr-BwILQ9G2.js → fr-DhHM9rou.js} +1 -1
  33. package/dist/{he-yC9Sc7JD.js → he-CBamXbGJ.js} +1 -1
  34. package/dist/{he-5LbvgMCC.cjs → he-Juw-dr28.cjs} +1 -1
  35. package/dist/{hi-Da7rcCpP.js → hi-DvvcX-Ra.js} +1 -1
  36. package/dist/{hi-YWhWcG_L.cjs → hi-R749jeg-.cjs} +1 -1
  37. package/dist/{index-CvU9E9wd.js → index-BfQaT5Jy.js} +104 -104
  38. package/dist/{index-XogEKwdt.cjs → index-Dv7nPuwA.cjs} +1 -1
  39. package/dist/index.cjs.js +4 -4
  40. package/dist/index.es.js +6713 -9831
  41. package/dist/{input-container-CyOgiiQD.cjs → input-container-BaWQLWB6.cjs} +1 -1
  42. package/dist/{input-container-8JFB11xN.js → input-container-DCS5oJ4S.js} +4 -4
  43. package/dist/{it-BxOIJE45.cjs → it-DT5oRZDH.cjs} +1 -1
  44. package/dist/{it-Yeklau78.js → it-aV6i8Qxz.js} +1 -1
  45. package/dist/{ja-Dxj9Q5Yd.js → ja-CuLhGnJX.js} +1 -1
  46. package/dist/{ja-CNhjK06P.cjs → ja-CwKaCYLB.cjs} +1 -1
  47. package/dist/json-schema/index.cjs.js +1 -1
  48. package/dist/json-schema/index.es.js +83 -79
  49. package/dist/json-schema-display/index.cjs.js +1 -1
  50. package/dist/json-schema-display/index.es.js +2 -2
  51. package/dist/json-structure/index.cjs.js +1 -1
  52. package/dist/json-structure/index.es.js +74 -72
  53. package/dist/{ko-DgkqcXTs.cjs → ko-Bucro9ID.cjs} +1 -1
  54. package/dist/{ko-gn_MsegK.js → ko-D-66BsEX.js} +1 -1
  55. package/dist/lexical/index.cjs.js +1 -1
  56. package/dist/lexical/index.es.js +5 -5
  57. package/dist/menu-BFLFKceF.cjs +1 -0
  58. package/dist/menu-BO6zqyfq.js +220 -0
  59. package/dist/modal-6Mq3vS5r.js +309 -0
  60. package/dist/modal-d77-TMc4.cjs +1 -0
  61. package/dist/{nl-vHNFtXXb.js → nl-CAny6wvm.js} +1 -1
  62. package/dist/{nl-Dy9lmbBO.cjs → nl-D7vHpehb.cjs} +1 -1
  63. package/dist/notice-BNGx86Yg.js +110 -0
  64. package/dist/notice-iF6zBMq9.cjs +1 -0
  65. package/dist/{oneof-branch-detection-Q_jxvJIA.js → oneof-branch-detection-Bm17RhC2.js} +27 -26
  66. package/dist/oneof-branch-detection-DZ4MrfBp.cjs +1 -0
  67. package/dist/openui/index.cjs.js +9 -0
  68. package/dist/openui/index.es.js +2174 -0
  69. package/dist/password-input-Bipt7Wsu.cjs +1 -0
  70. package/dist/password-input-mkRmrEPq.js +105 -0
  71. package/dist/{pl-BtYbtsmG.cjs → pl-CSiXoOKT.cjs} +1 -1
  72. package/dist/{pl-C0UdHla0.js → pl-rmZLgQ_V.js} +1 -1
  73. package/dist/prosemirror/index.cjs.js +1 -1
  74. package/dist/prosemirror/index.es.js +4 -4
  75. package/dist/{pt-CtNmqQ1X.cjs → pt-CJT-iq4y.cjs} +1 -1
  76. package/dist/{pt-DGKtfN0d.js → pt-DHnajqAi.js} +1 -1
  77. package/dist/{ru-CpXYLt-v.js → ru-C_E8OZNE.js} +1 -1
  78. package/dist/{ru-BaL_NPRU.cjs → ru-G3sr_ctV.cjs} +1 -1
  79. package/dist/slider-input-SLguFA0d.cjs +1 -0
  80. package/dist/slider-input-VYAMm7pE.js +285 -0
  81. package/dist/stepper-24p16Zsv.cjs +1 -0
  82. package/dist/stepper-TlzbfYWa.js +3222 -0
  83. package/dist/tailwind/preset.cjs.js +1 -1
  84. package/dist/tailwind/preset.es.js +38 -40
  85. package/dist/tailwind/vite-plugin.cjs.js +14 -12
  86. package/dist/tailwind/vite-plugin.es.js +317 -246
  87. package/dist/text-area-BdemKQ_w.cjs +1 -0
  88. package/dist/text-area-Br83-_PQ.js +431 -0
  89. package/dist/{text-input-NJypZSnE.js → text-input-ByuxdX8w.js} +5 -5
  90. package/dist/{text-input-DS5zlXb2.cjs → text-input-MjlUC_9u.cjs} +1 -1
  91. package/dist/{toolbar-BF2L6WKC.js → toolbar-CEBTTjHh.js} +1 -1
  92. package/dist/{toolbar-BBwfe8U9.cjs → toolbar-DWawYFFX.cjs} +1 -1
  93. package/dist/{tr-DwOd87oB.cjs → tr-DcxLHHTC.cjs} +1 -1
  94. package/dist/{tr-DIFZDFW_.js → tr-bVXwloKC.js} +1 -1
  95. package/dist/{translations-EwEmHe3v.cjs → translations-D3xqZUTA.cjs} +1 -1
  96. package/dist/{translations-BCMP-h52.js → translations-DU9wTV1y.js} +20 -19
  97. package/dist/{translations-5cXBrENb.js → translations-RT_UN8ny.js} +1 -1
  98. package/dist/{translations-BqWc0ZHz.cjs → translations-qljG2Chq.cjs} +1 -1
  99. package/dist/types/components/navigation/stepper.d.ts +4 -4
  100. package/dist/types/openui/index.d.ts +28 -0
  101. package/dist/types/openui/library/define-component.d.ts +15 -0
  102. package/dist/types/openui/library/library.d.ts +7 -0
  103. package/dist/types/openui/library/prompt-generator.d.ts +5 -0
  104. package/dist/types/openui/library/types.d.ts +33 -0
  105. package/dist/types/openui/parser/parser.d.ts +8 -0
  106. package/dist/types/openui/parser/streaming-parser.d.ts +14 -0
  107. package/dist/types/openui/parser/tokenizer.d.ts +9 -0
  108. package/dist/types/openui/parser/types.d.ts +46 -0
  109. package/dist/types/openui/registry/button.d.ts +148 -0
  110. package/dist/types/openui/registry/data.d.ts +177 -0
  111. package/dist/types/openui/registry/form.d.ts +65 -0
  112. package/dist/types/openui/registry/format.d.ts +67 -0
  113. package/dist/types/openui/registry/index.d.ts +9 -0
  114. package/dist/types/openui/registry/layout.d.ts +45 -0
  115. package/dist/types/openui/registry/navigation.d.ts +149 -0
  116. package/dist/types/openui/registry/overlay.d.ts +56 -0
  117. package/dist/types/openui/registry/typography.d.ts +17 -0
  118. package/dist/types/openui/renderer/action-context.d.ts +24 -0
  119. package/dist/types/openui/renderer/node-resolver.d.ts +9 -0
  120. package/dist/types/openui/renderer/openui-renderer.d.ts +32 -0
  121. package/dist/types/openui/renderer/skeleton.d.ts +2 -0
  122. package/dist/types/openui/streaming/from-fetch.d.ts +7 -0
  123. package/dist/types/openui/streaming/from-sse.d.ts +7 -0
  124. package/dist/types/openui/streaming/from-websocket.d.ts +10 -0
  125. package/dist/types/openui/streaming/types.d.ts +5 -0
  126. package/dist/types/tailwind/preset.d.ts +25 -4
  127. package/dist/types/tailwind/vite-plugin.d.ts +17 -5
  128. package/dist/types/tokens/colors.d.ts +87 -9
  129. package/dist/types/tokens/index.d.ts +7 -6
  130. package/dist/{ur-DBst-TXc.js → ur-Dls2qb4V.js} +1 -1
  131. package/dist/{ur-D9nLchps.cjs → ur-IRQoHh1E.cjs} +1 -1
  132. package/dist/use-form-BZ8vDYOv.cjs +2 -0
  133. package/dist/use-form-DsCzINfm.js +750 -0
  134. package/dist/utils-D3-NApSw.cjs +1 -0
  135. package/dist/utils-Nbh7yQ73.js +105 -0
  136. package/dist/{vi-Dg1aiMr5.cjs → vi-Bi9SvVCP.cjs} +1 -1
  137. package/dist/{vi-DQOJp32U.js → vi-C3mTzj50.js} +1 -1
  138. package/dist/widget-customization-BV6XB2v_.cjs +1 -0
  139. package/dist/widget-customization-Bso45ONQ.js +1198 -0
  140. package/dist/{zh-DPK4HXl2.js → zh-B4JRJBt2.js} +1 -1
  141. package/dist/{zh-tbwSTbmn.cjs → zh-BMU5rYu1.cjs} +1 -1
  142. package/package.json +31 -20
  143. package/dist/auth-divider-CjcrgXmq.cjs +0 -1
  144. package/dist/custom-validation-7por5nJN.js +0 -488
  145. package/dist/custom-validation-CLscGHY4.cjs +0 -1
  146. package/dist/deep-merge-D90SW1Ci.cjs +0 -1
  147. package/dist/deep-merge-DT2H9AGq.js +0 -1765
  148. package/dist/duration-input-4AQnQpyo.cjs +0 -1
  149. package/dist/menu-B60Q9j3-.cjs +0 -1
  150. package/dist/menu-BkqFGcXg.js +0 -366
  151. package/dist/notice-CQGJyZ8o.js +0 -211
  152. package/dist/notice-p2IqXS5-.cjs +0 -1
  153. package/dist/oneof-branch-detection-xDDDdYRk.cjs +0 -1
  154. package/dist/use-form-8NnZ-KHk.js +0 -1090
  155. package/dist/use-form-Dcra7GeE.cjs +0 -2
  156. package/dist/utils-DmEuG3Np.cjs +0 -1
  157. package/dist/utils-vUtP6iPG.js +0 -165
  158. package/dist/widget-customization-BIBva3f-.js +0 -1458
  159. package/dist/widget-customization-pqmtsraC.cjs +0 -1
@@ -1,1090 +0,0 @@
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-BCMP-h52.js";
3
- import { B as oe, I as ce } from "./input-container-8JFB11xN.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(" ");
40
- }
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(" ");
44
- }
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;
48
- }
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),
77
- c.class(
78
- T.map(i, (f) => f ? "bc-field--full-width" : "")
79
- ),
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(
89
- c.class(
90
- v(
91
- d,
92
- w
93
- )(
94
- (f, C) => me(
95
- f ?? !1,
96
- C ?? !1
97
- )
98
- )
99
- ),
100
- r
101
- ),
102
- r != null && n ? pe : _
103
- ),
104
- // Show description under label when horizontal
105
- x(
106
- v(
107
- $,
108
- o
109
- )((f, C) => f && C != null),
110
- () => b.div(
111
- c.class(
112
- "bc-field__description bc-field__description--under-label"
113
- ),
114
- c.id(V),
115
- o
116
- )
117
- )
118
- ),
119
- a != null ? de(a) : _,
120
- l
121
- ) : _,
122
- b.div(
123
- c.class("bc-field__content"),
124
- // Add data attributes to help inputs inherit accessibility information
125
- [V, O].filter(Boolean).length > 0 ? W(
126
- "describedby",
127
- [V, O].filter(Boolean).join(" ")
128
- ) : _,
129
- n ? W("required", "true") : _,
130
- x(d, () => W("invalid", "true")),
131
- u
132
- ),
133
- // Show description at bottom only when not horizontal
134
- x(
135
- v($, o)((f, C) => !f && C != null),
136
- () => b.div(
137
- c.class("bc-field__description"),
138
- c.id(V),
139
- o
140
- )
141
- ),
142
- x(
143
- d,
144
- () => b.div(
145
- c.class("bc-field__error"),
146
- c.id(O),
147
- S.live("polite"),
148
- // Announce errors to screen readers
149
- c.role("alert"),
150
- // Mark as alert for immediate attention
151
- h
152
- )
153
- ),
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))
163
- );
164
- };
165
- function Ae({
166
- size: s = "sm",
167
- icon: e = "line-md:close",
168
- disabled: t,
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(
177
- {
178
- variant: "text",
179
- size: s,
180
- roundedness: i,
181
- disabled: t,
182
- color: n,
183
- onClick: r
184
- },
185
- c.title(u),
186
- S.label(u),
187
- ...a,
188
- U({ icon: e, size: s ?? "sm" })
189
- );
190
- });
191
- }
192
- const Be = (s) => {
193
- const {
194
- value: e,
195
- onBlur: t,
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());
210
- };
211
- return ce(
212
- {
213
- baseContainer: !0,
214
- growInput: !1,
215
- ...s,
216
- input: b.span(
217
- c.class("bc-checkbox-input"),
218
- b.span(
219
- c.class("bc-checkbox-input__checkbox"),
220
- c.class(
221
- T.map(
222
- e,
223
- (d) => d ? "bc-checkbox-input__checkbox--checked" : "bc-checkbox-input__checkbox--unchecked"
224
- )
225
- ),
226
- c.class(
227
- T.map(
228
- l ?? !1,
229
- (d) => d ? "bc-checkbox-input__checkbox--disabled" : ""
230
- )
231
- ),
232
- c.id(p),
233
- c.role("checkbox"),
234
- c.tabindex(
235
- T.map(
236
- l ?? !1,
237
- (d) => d ? -1 : 0
238
- )
239
- ),
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(
247
- e,
248
- o,
249
- u
250
- )(
251
- (d, w, I) => d ? w ?? "ri:checkbox-fill" : I ?? "mdi:checkbox-blank-outline"
252
- ),
253
- accessibility: "decorative",
254
- size: h
255
- })
256
- ),
257
- r != null ? b.label(
258
- c.class("bc-checkbox-input__label"),
259
- c.id(y),
260
- c.for(p),
261
- he(r)
262
- ) : _
263
- )
264
- },
265
- F.click(k)
266
- );
267
- }, ve = (
268
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
269
- ((s, e) => () => {
270
- s.markTouched(), e?.();
271
- })
272
- ), z = (s, e) => (t) => {
273
- s.change(t), e?.(t);
274
- };
275
- function R(s, e) {
276
- const { controller: t, onBlur: i, onChange: n, id: r, triggerOn: l, ...a } = e;
277
- return s({
278
- id: r ?? t.name,
279
- disabled: t.disabled,
280
- value: t.signal,
281
- hasError: t.errorVisible,
282
- name: t.name,
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)
287
- });
288
- }
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(
292
- {
293
- ...i,
294
- hasError: i.controller.errorVisible,
295
- // TODO: Remove Primitive annotation once @tempots/dom TextNode is generic
296
- error: ne(i.controller.error.map((a) => a ?? "")),
297
- labelFor: l,
298
- content: R(
299
- (a) => s({ ...a, id: r }),
300
- i
301
- )
302
- },
303
- ...n
304
- );
305
- }
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
311
- });
312
- }
313
- function We(s, {
314
- id: e,
315
- labelFor: t,
316
- ...i
317
- }, ...n) {
318
- const r = e ?? i.controller.name ?? B("control");
319
- return q(
320
- {
321
- ...i,
322
- labelFor: t ?? r,
323
- content: ye(s, {
324
- ...i,
325
- id: r
326
- })
327
- },
328
- ...n
329
- );
330
- }
331
- function je(s) {
332
- return s.split(".").map((t) => {
333
- const i = t.match(/^\[(\d+)\]$/);
334
- return i ? Number(i[1]) : t;
335
- });
336
- }
337
- function ke(s) {
338
- return typeof s == "number" ? `[${s}]` : `.${s}`;
339
- }
340
- function De(s) {
341
- if (s.length === 0) return "";
342
- const [e, ...t] = s;
343
- return [
344
- typeof e == "number" ? `[${e}]` : e,
345
- ...t.map(ke)
346
- ].join("");
347
- }
348
- const Pe = {
349
- /** A valid validation result */
350
- valid: g.valid,
351
- /**
352
- * Create an invalid validation with a message
353
- */
354
- invalid(s) {
355
- return g.invalid({ message: s });
356
- },
357
- /**
358
- * Create an invalid validation with field-specific errors.
359
- * Values can be error messages (strings) or full ControllerError objects.
360
- */
361
- invalidFields(s) {
362
- const e = {};
363
- for (const [t, i] of Object.entries(s))
364
- e[t] = typeof i == "string" ? { message: i } : i;
365
- return g.invalid({ dependencies: e });
366
- },
367
- /**
368
- * Create an invalid validation from a ControllerError object
369
- */
370
- fromError(s) {
371
- return g.invalid(s);
372
- }
373
- };
374
- function A(s) {
375
- return function(t) {
376
- if (t.type === "valid") return t;
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);
381
- };
382
- }
383
- class E {
384
- /** The path segments identifying this controller's position in the form hierarchy (e.g., ['user', 'email']). */
385
- path;
386
- /** Callback to propagate value changes up to the parent form. */
387
- change;
388
- /** Reactive signal containing the current field value. */
389
- signal;
390
- /** Reactive signal containing the current validation state (valid, pending, or invalid with errors). */
391
- status;
392
- /** Reactive signal containing the current error message string, or undefined if valid. */
393
- error;
394
- /** Reactive signal indicating whether this field has any errors. */
395
- hasError;
396
- /** Reactive signal tracking whether the user has interacted with this field. */
397
- touched;
398
- /** Reactive signal indicating whether errors should be shown (respects validation mode and touched state). */
399
- errorVisible;
400
- /** Reactive signal tracking whether the current value differs from the baseline. */
401
- dirty;
402
- /** Reactive signal containing nested field errors for child controllers. */
403
- dependencyErrors;
404
- #e = {
405
- disabled: D(!1),
406
- touched: D(!1)
407
- };
408
- #s;
409
- #t = D(void 0);
410
- /** Parent controller context providing disabled state and optional validation mode. */
411
- parent;
412
- /** Reactive signal indicating whether this field is disabled (combines local and parent disabled state). */
413
- disabled;
414
- #i = [];
415
- /** Reactive signal indicating whether this field is disabled OR has errors (useful for submit button state). */
416
- disabledOrHasErrors;
417
- /**
418
- * Creates a new Controller instance.
419
- *
420
- * @param path - Field path segments in the form hierarchy
421
- * @param change - Callback to propagate value changes
422
- * @param signal - Reactive signal holding the field value
423
- * @param status - Reactive signal holding validation state
424
- * @param parent - Parent context with disabled state and optional validation mode
425
- * @param equals - Equality function for dirty tracking (defaults to strictEqual)
426
- */
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(
431
- this.hasError,
432
- this.touched,
433
- r.validationMode
434
- )((a, o, u) => u === "eager" ? !!a : !!a && !!o) : this.errorVisible = v(
435
- this.hasError,
436
- this.touched
437
- )((a, o) => !!a && !!o), this.dirty = v(
438
- this.signal,
439
- this.#t
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(
443
- this.#e.disabled,
444
- r.disabled
445
- )((a, o) => a || o), this.disabledOrHasErrors = v(
446
- this.disabled,
447
- this.hasError
448
- )((a, o) => a || o), this.onDispose(() => {
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();
450
- });
451
- }
452
- /**
453
- * Returns the field name as a dot-separated string (e.g., "user.email").
454
- */
455
- get name() {
456
- return De(this.path);
457
- }
458
- /**
459
- * Registers a callback to be executed when this controller is disposed.
460
- *
461
- * @param callback - Function to execute on disposal
462
- */
463
- onDispose = (e) => {
464
- this.#i.push(e);
465
- };
466
- /**
467
- * Disposes all internal resources and registered callbacks.
468
- * Should be called when the controller is no longer needed to prevent memory leaks.
469
- */
470
- dispose = () => {
471
- for (const e of this.#i)
472
- try {
473
- e();
474
- } catch (t) {
475
- console.error("Error in dispose callback:", t);
476
- }
477
- this.#i.length = 0;
478
- };
479
- /**
480
- * Sets the disabled state for this field.
481
- *
482
- * @param disabled - Whether the field should be disabled
483
- */
484
- setDisabled = (e) => {
485
- this.#e.disabled.set(e);
486
- };
487
- /**
488
- * Disables this field.
489
- */
490
- disable = () => this.setDisabled(!0);
491
- /**
492
- * Enables this field.
493
- */
494
- enable = () => this.setDisabled(!1);
495
- /**
496
- * Marks this field as touched (user has interacted with it).
497
- */
498
- markTouched = () => {
499
- this.#e.touched.set(!0);
500
- };
501
- /**
502
- * Resets the touched state to false.
503
- */
504
- resetTouched = () => {
505
- this.#e.touched.set(!1);
506
- };
507
- /**
508
- * Marks the current value as the new baseline for dirty tracking.
509
- */
510
- markPristine = () => {
511
- this.#t.set(this.signal.value);
512
- };
513
- /**
514
- * Resets the field value to the baseline value.
515
- */
516
- reset = () => {
517
- this.change(this.#t.value);
518
- };
519
- /**
520
- * Casts this controller to an ArrayController for managing array values.
521
- *
522
- * @param equals - Equality function for array comparison (defaults to strictEqual)
523
- * @returns An ArrayController instance
524
- */
525
- array = (e = M) => new Te(
526
- this.path,
527
- this.change,
528
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
529
- this.signal,
530
- this.status,
531
- this.parent,
532
- e
533
- );
534
- /**
535
- * Casts this controller to an ObjectController for managing object values with field access.
536
- *
537
- * @param equals - Equality function for object comparison (defaults to strictEqual)
538
- * @returns An ObjectController instance
539
- */
540
- object = (e = M) => new Ce(
541
- this.path,
542
- this.change,
543
- this.signal,
544
- this.status,
545
- this.parent,
546
- e
547
- );
548
- /**
549
- * Creates a transformed controller that maps values bidirectionally.
550
- * Useful for converting between internal and display representations.
551
- *
552
- * @template Out - The transformed value type
553
- * @param transform - Function to convert from T to Out
554
- * @param untransform - Function to convert from Out back to T
555
- * @param subpath - Optional path segments to append
556
- * @param equals - Equality function for the transformed type
557
- * @returns A new Controller instance managing the transformed value
558
- *
559
- * @example
560
- * ```typescript
561
- * // Transform number to string for text input
562
- * const stringController = numberController.transform(
563
- * (n) => n.toString(),
564
- * (s) => parseFloat(s) || 0
565
- * )
566
- * ```
567
- */
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)),
573
- this.parent,
574
- n
575
- );
576
- /**
577
- * Creates a transformed controller with async bidirectional mapping.
578
- * Useful for async operations like fetching related data or formatting.
579
- *
580
- * @template Out - The transformed value type
581
- * @param transform - Async function to convert from T to Out
582
- * @param untransform - Async function to convert from Out back to T
583
- * @param alt - Fallback value while async transform is pending
584
- * @param subpath - Optional path segments to append
585
- * @param equals - Equality function for the transformed type
586
- * @returns A new Controller instance managing the async-transformed value
587
- */
588
- asyncTransform = (e, t, i, n = [], r = M) => new E(
589
- [...this.path, ...n],
590
- (l) => {
591
- t(l).then((a) => this.change(a));
592
- },
593
- this.signal.mapAsync(e, i, void 0, r),
594
- this.status.map(A(n)),
595
- this.parent,
596
- r
597
- );
598
- }
599
- class Ce extends E {
600
- #e = /* @__PURE__ */ new Map();
601
- #s = /* @__PURE__ */ new Map();
602
- #t = /* @__PURE__ */ new Map();
603
- #i = D(!1);
604
- /** Reactive signal indicating whether this field or any child field is touched. */
605
- touchedDeep = this.#i;
606
- #a = /* @__PURE__ */ new Map();
607
- #n = /* @__PURE__ */ new Map();
608
- #r = D(!1);
609
- /** Reactive signal indicating whether this field or any child field is dirty. */
610
- dirtyDeep = this.#r;
611
- #c;
612
- #d;
613
- #o = () => {
614
- let e = !1;
615
- for (const t of this.#s.values())
616
- if (t) {
617
- e = !0;
618
- break;
619
- }
620
- this.#i.set(this.touched.value || e);
621
- };
622
- constructor(e, t, i, n, r, l) {
623
- super(
624
- e,
625
- t,
626
- i.map((o) => o ?? {}, l),
627
- n,
628
- r,
629
- l
630
- ), this.#c = this.touched.on(() => {
631
- this.#o();
632
- }), this.#d = this.dirty.on(() => {
633
- this.#l();
634
- });
635
- const a = this.signal.on(() => this.#l());
636
- this.onDispose(() => {
637
- for (const o of this.#e.values())
638
- o.dispose();
639
- this.#e.clear();
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();
644
- });
645
- }
646
- /**
647
- * Gets or creates a controller for a specific field in the object.
648
- * Controllers are cached and reused for the same field name.
649
- *
650
- * @template K - The field key type
651
- * @param field - The field name to access
652
- * @returns A Controller instance for the specified field
653
- *
654
- * @example
655
- * ```typescript
656
- * const emailController = userController.field('email')
657
- * const nameController = userController.field('name')
658
- * ```
659
- */
660
- field = (e) => {
661
- if (this.#e.has(e))
662
- return this.#e.get(e);
663
- const t = async (l) => {
664
- this.change({
665
- ...this.signal.value,
666
- [e]: l
667
- });
668
- }, i = new E(
669
- [...this.path, e],
670
- t,
671
- this.signal.map((l) => l[e]),
672
- this.status.map(A([e])),
673
- {
674
- disabled: this.disabled,
675
- // propagate validationMode to children if present
676
- validationMode: this.parent.validationMode
677
- }
678
- );
679
- this.#e.set(e, i);
680
- const n = i.touched.on((l) => {
681
- this.#s.set(e, l), this.#o();
682
- });
683
- this.#t.set(e, n);
684
- const r = i.dirty.on((l) => {
685
- this.#a.set(e, l), this.#l();
686
- });
687
- return this.#n.set(e, r), i;
688
- };
689
- /**
690
- * Marks this field and all child fields as touched recursively.
691
- * Useful for showing all validation errors when a form is submitted.
692
- */
693
- markAllTouched = () => {
694
- this.markTouched();
695
- const e = this.signal.value;
696
- for (const t of Object.keys(e))
697
- this.field(t).markTouched();
698
- for (const t of this.#e.values())
699
- t.markTouched();
700
- };
701
- /**
702
- * Marks this field and all child fields as pristine (resets baseline) recursively.
703
- */
704
- markAllPristine = () => {
705
- this.markPristine();
706
- const e = this.signal.value;
707
- for (const t of Object.keys(e))
708
- this.field(t).markPristine?.();
709
- for (const t of this.#e.values())
710
- t.markPristine?.();
711
- };
712
- #l = () => {
713
- let e = !1;
714
- for (const t of this.#a.values())
715
- if (t) {
716
- e = !0;
717
- break;
718
- }
719
- this.#r.set(this.dirty.value || e);
720
- };
721
- }
722
- class Te extends E {
723
- #e = new Array();
724
- /** Reactive signal containing the current array length. */
725
- length;
726
- #s = /* @__PURE__ */ new Map();
727
- #t = /* @__PURE__ */ new Map();
728
- #i = D(!1);
729
- /** Reactive signal indicating whether this array or any item is touched. */
730
- touchedDeep = this.#i;
731
- #a = /* @__PURE__ */ new Map();
732
- #n = /* @__PURE__ */ new Map();
733
- #r = D(!1);
734
- /** Reactive signal indicating whether this array or any item is dirty. */
735
- dirtyDeep = this.#r;
736
- #c;
737
- #d;
738
- #o = () => {
739
- let e = !1;
740
- for (const t of this.#s.values())
741
- if (t) {
742
- e = !0;
743
- break;
744
- }
745
- this.#i.set(this.touched.value || e);
746
- };
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());
756
- });
757
- this.length = a.map((h) => h.length), this.#c = this.touched.on(() => {
758
- this.#o();
759
- }), this.#d = this.dirty.on(() => {
760
- this.#l();
761
- });
762
- const u = this.signal.on(() => this.#l());
763
- this.onDispose(() => {
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();
771
- });
772
- }
773
- /**
774
- * Gets or creates a controller for a specific array item by index.
775
- * Controllers are cached and reused for the same index.
776
- *
777
- * @param index - The zero-based index of the item
778
- * @returns A Controller instance for the specified item
779
- *
780
- * @example
781
- * ```typescript
782
- * const firstTaskController = tasksController.item(0)
783
- * const secondTaskController = tasksController.item(1)
784
- * ```
785
- */
786
- item = (e) => {
787
- if (this.#e[e])
788
- return this.#e[e];
789
- const t = async (l) => {
790
- const a = this.signal.value.slice();
791
- a[e] = l, this.change(a);
792
- }, i = new E(
793
- [...this.path, e],
794
- t,
795
- this.signal.map((l) => l[e]),
796
- this.status.map(A([e])),
797
- {
798
- disabled: this.disabled,
799
- validationMode: this.parent.validationMode
800
- }
801
- );
802
- this.#e[e] = i;
803
- const n = i.touched.on((l) => {
804
- this.#s.set(e, l), this.#o();
805
- });
806
- this.#t.set(e, n);
807
- const r = i.dirty.on((l) => {
808
- this.#a.set(e, l), this.#l();
809
- });
810
- return this.#n.set(e, r), i;
811
- };
812
- /**
813
- * Appends one or more items to the end of the array.
814
- *
815
- * @param value - Items to append
816
- */
817
- push = (...e) => {
818
- this.change([...this.signal.value, ...e]);
819
- };
820
- /**
821
- * Removes the last item from the array.
822
- */
823
- pop = () => {
824
- this.splice(this.signal.value.length - 1, 1);
825
- };
826
- /**
827
- * Removes the first item from the array.
828
- */
829
- shift = () => {
830
- this.splice(0, 1);
831
- };
832
- /**
833
- * Inserts one or more items at the beginning of the array.
834
- *
835
- * @param value - Items to prepend
836
- */
837
- unshift = (...e) => {
838
- this.change([...e, ...this.signal.value]);
839
- };
840
- /**
841
- * Removes the item at the specified index.
842
- *
843
- * @param index - Zero-based index of the item to remove
844
- */
845
- removeAt = (e) => {
846
- this.splice(e, 1);
847
- };
848
- /**
849
- * Removes items from the array starting at the specified index.
850
- *
851
- * @param start - Zero-based index to start removing items
852
- * @param deleteCount - Number of items to remove (optional)
853
- */
854
- splice = (e, t) => {
855
- const i = this.signal.value.slice();
856
- i.splice(e, t), this.change(i);
857
- };
858
- /**
859
- * Moves one or more items from one index to another within the array.
860
- *
861
- * @param from - Source index to move from
862
- * @param to - Destination index to move to
863
- * @param length - Number of items to move (defaults to 1)
864
- *
865
- * @example
866
- * ```typescript
867
- * controller.move(0, 2) // Move first item to third position
868
- * controller.move(2, 0, 2) // Move items at index 2-3 to the beginning
869
- * ```
870
- */
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);
875
- };
876
- /**
877
- * Marks this array and all item controllers as touched recursively.
878
- * Useful for showing all validation errors when a form is submitted.
879
- */
880
- markAllTouched = () => {
881
- this.markTouched();
882
- const e = this.signal.value.length;
883
- for (let t = 0; t < e; t++)
884
- this.item(t).markTouched();
885
- };
886
- /**
887
- * Marks this array and all item controllers as pristine (resets baseline) recursively.
888
- */
889
- markAllPristine = () => {
890
- this.markPristine();
891
- const e = this.signal.value.length;
892
- for (let t = 0; t < e; t++)
893
- this.item(t).markPristine?.();
894
- };
895
- #l = () => {
896
- let e = !1;
897
- for (const t of this.#a.values())
898
- if (t) {
899
- e = !0;
900
- break;
901
- }
902
- this.#r.set(this.dirty.value || e);
903
- };
904
- }
905
- function _e(s) {
906
- function e(t) {
907
- return typeof t == "number" ? t : t.toString();
908
- }
909
- return s.map(
910
- (t) => typeof t == "object" && t.key != null ? e(t.key) : e(t)
911
- );
912
- }
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(`
921
- `);
922
- return {
923
- ...t,
924
- message: i != "" ? i : void 0
925
- };
926
- }
927
- function Ie({
928
- initialValue: s,
929
- onChange: e,
930
- validate: t,
931
- equals: i,
932
- validationMode: n,
933
- validateDebounceMs: r
934
- }) {
935
- const l = T.deriveProp(s), a = D(g.valid), o = D(!1), u = D(n ?? "onTouched"), h = (d) => {
936
- a.set(d);
937
- };
938
- let p;
939
- const y = async (d) => {
940
- if (t != null) {
941
- const w = await t(d);
942
- h(w);
943
- }
944
- }, k = async (d) => {
945
- l.set(d), e?.(d);
946
- const w = u.value;
947
- if (t != null) {
948
- if (w === "onSubmit")
949
- return;
950
- const I = r ?? 0;
951
- I > 0 ? (p && clearTimeout(p), p = setTimeout(() => {
952
- y(d);
953
- }, I)) : await y(d);
954
- }
955
- }, m = new E(
956
- [],
957
- k,
958
- l,
959
- a,
960
- {
961
- disabled: o,
962
- validationMode: u
963
- },
964
- i ?? M
965
- );
966
- return m.onDispose(() => {
967
- o.dispose(), l.dispose(), a.dispose(), u.dispose(), p && clearTimeout(p);
968
- }), { controller: m, setStatus: h };
969
- }
970
- function K(s) {
971
- return P(c.disabled(s.disabled), c.name(s.name));
972
- }
973
- function Le(s, {
974
- triggerOn: e = "change"
975
- } = {}) {
976
- return P(
977
- K(s),
978
- c.value(s.signal),
979
- (e === "input" ? F.input : F.change)(le(s.change))
980
- );
981
- }
982
- function $e(s, {
983
- triggerOn: e = "change"
984
- } = {}) {
985
- return P(
986
- K(s),
987
- c.valueAsNumber(s.signal),
988
- (e === "input" ? F.input : F.change)(
989
- ae(s.change)
990
- )
991
- );
992
- }
993
- function H(s) {
994
- return s.issues != null ? g.invalid(we(s.issues)) : g.valid;
995
- }
996
- async function ze({
997
- task: s,
998
- errorMessage: e,
999
- errorPath: t = ["root"],
1000
- validation: i
1001
- }) {
1002
- try {
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");
1007
- return t.length === 1 && t[0] === "root" ? g.invalid({
1008
- message: r
1009
- }) : g.invalid({
1010
- dependencies: Y(t, r)
1011
- });
1012
- }
1013
- }
1014
- function Y(s, e) {
1015
- if (s.length === 1)
1016
- return {
1017
- [s[0]]: { message: e }
1018
- };
1019
- const [t, ...i] = s;
1020
- return {
1021
- [t]: {
1022
- dependencies: Y(i, e)
1023
- }
1024
- };
1025
- }
1026
- function He({
1027
- initialValue: s = {},
1028
- schema: e,
1029
- onSubmit: t = async () => g.valid,
1030
- validationMode: i,
1031
- validateDebounceMs: n
1032
- }) {
1033
- const { controller: r, setStatus: l } = Ie({
1034
- initialValue: s,
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)
1039
- )
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)
1048
- );
1049
- if (l(k), k.type === "invalid") {
1050
- a.set(!1);
1051
- return;
1052
- }
1053
- }
1054
- const p = await t(o.signal.value);
1055
- a.set(!1), p.type === "invalid" && l(p);
1056
- },
1057
- submitting: a
1058
- };
1059
- }
1060
- export {
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
- Pe as a,
1069
- Be as b,
1070
- Oe as c,
1071
- z as d,
1072
- E as e,
1073
- A as f,
1074
- Ie as g,
1075
- j as h,
1076
- ye 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
1090
- };