@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
@@ -0,0 +1,750 @@
1
+ import { prop as p, computedOf as D, Fragment as M, attr as T, on as w, emitValueAsNumber as O, emitValue as P, Value as j } from "@tempots/dom";
2
+ import { Validation as c, strictEqual as b } from "@tempots/std";
3
+ function J(i) {
4
+ return i.split(".").map((t) => {
5
+ const s = t.match(/^\[(\d+)\]$/);
6
+ return s ? Number(s[1]) : t;
7
+ });
8
+ }
9
+ function H(i) {
10
+ return typeof i == "number" ? `[${i}]` : `.${i}`;
11
+ }
12
+ function I(i) {
13
+ if (i.length === 0) return "";
14
+ const [e, ...t] = i;
15
+ return [
16
+ typeof e == "number" ? `[${e}]` : e,
17
+ ...t.map(H)
18
+ ].join("");
19
+ }
20
+ const K = {
21
+ /** A valid validation result */
22
+ valid: c.valid,
23
+ /**
24
+ * Create an invalid validation with a message
25
+ */
26
+ invalid(i) {
27
+ return c.invalid({ message: i });
28
+ },
29
+ /**
30
+ * Create an invalid validation with field-specific errors.
31
+ * Values can be error messages (strings) or full ControllerError objects.
32
+ */
33
+ invalidFields(i) {
34
+ const e = {};
35
+ for (const [t, s] of Object.entries(i))
36
+ e[t] = typeof s == "string" ? { message: s } : s;
37
+ return c.invalid({ dependencies: e });
38
+ },
39
+ /**
40
+ * Create an invalid validation from a ControllerError object
41
+ */
42
+ fromError(i) {
43
+ return c.invalid(i);
44
+ }
45
+ };
46
+ function C(i) {
47
+ return function(t) {
48
+ if (t.type === "valid") return t;
49
+ let s = t.error;
50
+ for (const n of i)
51
+ if (s = s?.dependencies?.[n], s == null) return c.valid;
52
+ return c.invalid(s);
53
+ };
54
+ }
55
+ class g {
56
+ /** The path segments identifying this controller's position in the form hierarchy (e.g., ['user', 'email']). */
57
+ path;
58
+ /** Callback to propagate value changes up to the parent form. */
59
+ change;
60
+ /** Reactive signal containing the current field value. */
61
+ signal;
62
+ /** Reactive signal containing the current validation state (valid, pending, or invalid with errors). */
63
+ status;
64
+ /** Reactive signal containing the current error message string, or undefined if valid. */
65
+ error;
66
+ /** Reactive signal indicating whether this field has any errors. */
67
+ hasError;
68
+ /** Reactive signal tracking whether the user has interacted with this field. */
69
+ touched;
70
+ /** Reactive signal indicating whether errors should be shown (respects validation mode and touched state). */
71
+ errorVisible;
72
+ /** Reactive signal tracking whether the current value differs from the baseline. */
73
+ dirty;
74
+ /** Reactive signal containing nested field errors for child controllers. */
75
+ dependencyErrors;
76
+ #e = {
77
+ disabled: p(!1),
78
+ touched: p(!1)
79
+ };
80
+ #s;
81
+ #t = p(void 0);
82
+ /** Parent controller context providing disabled state and optional validation mode. */
83
+ parent;
84
+ /** Reactive signal indicating whether this field is disabled (combines local and parent disabled state). */
85
+ disabled;
86
+ #i = [];
87
+ /** Reactive signal indicating whether this field is disabled OR has errors (useful for submit button state). */
88
+ disabledOrHasErrors;
89
+ /**
90
+ * Creates a new Controller instance.
91
+ *
92
+ * @param path - Field path segments in the form hierarchy
93
+ * @param change - Callback to propagate value changes
94
+ * @param signal - Reactive signal holding the field value
95
+ * @param status - Reactive signal holding validation state
96
+ * @param parent - Parent context with disabled state and optional validation mode
97
+ * @param equals - Equality function for dirty tracking (defaults to strictEqual)
98
+ */
99
+ constructor(e, t, s, n, l, o = b) {
100
+ this.path = e, this.change = t, this.signal = s, this.status = n, this.#s = o, this.#t.set(s.value), this.error = n.map(
101
+ (a) => a?.type === "invalid" ? a.error?.message : void 0
102
+ ), this.hasError = this.error.map((a) => a != null), this.touched = this.#e.touched, l.validationMode ? this.errorVisible = D(
103
+ this.hasError,
104
+ this.touched,
105
+ l.validationMode
106
+ )((a, r, d) => d === "eager" ? !!a : !!a && !!r) : this.errorVisible = D(
107
+ this.hasError,
108
+ this.touched
109
+ )((a, r) => !!a && !!r), this.dirty = D(
110
+ this.signal,
111
+ this.#t
112
+ )((a, r) => !this.#s(a, r)), this.dependencyErrors = n.map(
113
+ (a) => a?.type === "invalid" ? a.error?.dependencies : void 0
114
+ ), this.parent = l, this.disabled = D(
115
+ this.#e.disabled,
116
+ l.disabled
117
+ )((a, r) => a || r), this.disabledOrHasErrors = D(
118
+ this.disabled,
119
+ this.hasError
120
+ )((a, r) => a || r), this.onDispose(() => {
121
+ 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();
122
+ });
123
+ }
124
+ /**
125
+ * Returns the field name as a dot-separated string (e.g., "user.email").
126
+ */
127
+ get name() {
128
+ return I(this.path);
129
+ }
130
+ /**
131
+ * Registers a callback to be executed when this controller is disposed.
132
+ *
133
+ * @param callback - Function to execute on disposal
134
+ */
135
+ onDispose = (e) => {
136
+ this.#i.push(e);
137
+ };
138
+ /**
139
+ * Disposes all internal resources and registered callbacks.
140
+ * Should be called when the controller is no longer needed to prevent memory leaks.
141
+ */
142
+ dispose = () => {
143
+ for (const e of this.#i)
144
+ try {
145
+ e();
146
+ } catch (t) {
147
+ console.error("Error in dispose callback:", t);
148
+ }
149
+ this.#i.length = 0;
150
+ };
151
+ /**
152
+ * Sets the disabled state for this field.
153
+ *
154
+ * @param disabled - Whether the field should be disabled
155
+ */
156
+ setDisabled = (e) => {
157
+ this.#e.disabled.set(e);
158
+ };
159
+ /**
160
+ * Disables this field.
161
+ */
162
+ disable = () => this.setDisabled(!0);
163
+ /**
164
+ * Enables this field.
165
+ */
166
+ enable = () => this.setDisabled(!1);
167
+ /**
168
+ * Marks this field as touched (user has interacted with it).
169
+ */
170
+ markTouched = () => {
171
+ this.#e.touched.set(!0);
172
+ };
173
+ /**
174
+ * Resets the touched state to false.
175
+ */
176
+ resetTouched = () => {
177
+ this.#e.touched.set(!1);
178
+ };
179
+ /**
180
+ * Marks the current value as the new baseline for dirty tracking.
181
+ */
182
+ markPristine = () => {
183
+ this.#t.set(this.signal.value);
184
+ };
185
+ /**
186
+ * Resets the field value to the baseline value.
187
+ */
188
+ reset = () => {
189
+ this.change(this.#t.value);
190
+ };
191
+ /**
192
+ * Casts this controller to an ArrayController for managing array values.
193
+ *
194
+ * @param equals - Equality function for array comparison (defaults to strictEqual)
195
+ * @returns An ArrayController instance
196
+ */
197
+ array = (e = b) => new $(
198
+ this.path,
199
+ this.change,
200
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
201
+ this.signal,
202
+ this.status,
203
+ this.parent,
204
+ e
205
+ );
206
+ /**
207
+ * Casts this controller to an ObjectController for managing object values with field access.
208
+ *
209
+ * @param equals - Equality function for object comparison (defaults to strictEqual)
210
+ * @returns An ObjectController instance
211
+ */
212
+ object = (e = b) => new N(
213
+ this.path,
214
+ this.change,
215
+ this.signal,
216
+ this.status,
217
+ this.parent,
218
+ e
219
+ );
220
+ /**
221
+ * Creates a transformed controller that maps values bidirectionally.
222
+ * Useful for converting between internal and display representations.
223
+ *
224
+ * @template Out - The transformed value type
225
+ * @param transform - Function to convert from T to Out
226
+ * @param untransform - Function to convert from Out back to T
227
+ * @param subpath - Optional path segments to append
228
+ * @param equals - Equality function for the transformed type
229
+ * @returns A new Controller instance managing the transformed value
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * // Transform number to string for text input
234
+ * const stringController = numberController.transform(
235
+ * (n) => n.toString(),
236
+ * (s) => parseFloat(s) || 0
237
+ * )
238
+ * ```
239
+ */
240
+ transform = (e, t, s = [], n = b) => new g(
241
+ [...this.path, ...s],
242
+ (l) => this.change(t(l)),
243
+ this.signal.map(e, n),
244
+ this.status.map(C(s)),
245
+ this.parent,
246
+ n
247
+ );
248
+ /**
249
+ * Creates a transformed controller with async bidirectional mapping.
250
+ * Useful for async operations like fetching related data or formatting.
251
+ *
252
+ * @template Out - The transformed value type
253
+ * @param transform - Async function to convert from T to Out
254
+ * @param untransform - Async function to convert from Out back to T
255
+ * @param alt - Fallback value while async transform is pending
256
+ * @param subpath - Optional path segments to append
257
+ * @param equals - Equality function for the transformed type
258
+ * @returns A new Controller instance managing the async-transformed value
259
+ */
260
+ asyncTransform = (e, t, s, n = [], l = b) => new g(
261
+ [...this.path, ...n],
262
+ (o) => {
263
+ t(o).then((a) => this.change(a));
264
+ },
265
+ this.signal.mapAsync(e, s, void 0, l),
266
+ this.status.map(C(n)),
267
+ this.parent,
268
+ l
269
+ );
270
+ }
271
+ class N extends g {
272
+ #e = /* @__PURE__ */ new Map();
273
+ #s = /* @__PURE__ */ new Map();
274
+ #t = /* @__PURE__ */ new Map();
275
+ #i = p(!1);
276
+ /** Reactive signal indicating whether this field or any child field is touched. */
277
+ touchedDeep = this.#i;
278
+ #a = /* @__PURE__ */ new Map();
279
+ #n = /* @__PURE__ */ new Map();
280
+ #o = p(!1);
281
+ /** Reactive signal indicating whether this field or any child field is dirty. */
282
+ dirtyDeep = this.#o;
283
+ #h;
284
+ #c;
285
+ #l = () => {
286
+ let e = !1;
287
+ for (const t of this.#s.values())
288
+ if (t) {
289
+ e = !0;
290
+ break;
291
+ }
292
+ this.#i.set(this.touched.value || e);
293
+ };
294
+ constructor(e, t, s, n, l, o) {
295
+ super(
296
+ e,
297
+ t,
298
+ s.map((r) => r ?? {}, o),
299
+ n,
300
+ l,
301
+ o
302
+ ), this.#h = this.touched.on(() => {
303
+ this.#l();
304
+ }), this.#c = this.dirty.on(() => {
305
+ this.#r();
306
+ });
307
+ const a = this.signal.on(() => this.#r());
308
+ this.onDispose(() => {
309
+ for (const r of this.#e.values())
310
+ r.dispose();
311
+ this.#e.clear();
312
+ for (const r of this.#t.values()) r();
313
+ this.#t.clear(), this.#s.clear(), this.#i.dispose();
314
+ for (const r of this.#n.values()) r();
315
+ this.#n.clear(), this.#a.clear(), this.#o.dispose(), this.#h(), this.#c(), a();
316
+ });
317
+ }
318
+ /**
319
+ * Gets or creates a controller for a specific field in the object.
320
+ * Controllers are cached and reused for the same field name.
321
+ *
322
+ * @template K - The field key type
323
+ * @param field - The field name to access
324
+ * @returns A Controller instance for the specified field
325
+ *
326
+ * @example
327
+ * ```typescript
328
+ * const emailController = userController.field('email')
329
+ * const nameController = userController.field('name')
330
+ * ```
331
+ */
332
+ field = (e) => {
333
+ if (this.#e.has(e))
334
+ return this.#e.get(e);
335
+ const t = async (o) => {
336
+ this.change({
337
+ ...this.signal.value,
338
+ [e]: o
339
+ });
340
+ }, s = new g(
341
+ [...this.path, e],
342
+ t,
343
+ this.signal.map((o) => o[e]),
344
+ this.status.map(C([e])),
345
+ {
346
+ disabled: this.disabled,
347
+ // propagate validationMode to children if present
348
+ validationMode: this.parent.validationMode
349
+ }
350
+ );
351
+ this.#e.set(e, s);
352
+ const n = s.touched.on((o) => {
353
+ this.#s.set(e, o), this.#l();
354
+ });
355
+ this.#t.set(e, n);
356
+ const l = s.dirty.on((o) => {
357
+ this.#a.set(e, o), this.#r();
358
+ });
359
+ return this.#n.set(e, l), s;
360
+ };
361
+ /**
362
+ * Marks this field and all child fields as touched recursively.
363
+ * Useful for showing all validation errors when a form is submitted.
364
+ */
365
+ markAllTouched = () => {
366
+ this.markTouched();
367
+ const e = this.signal.value;
368
+ for (const t of Object.keys(e))
369
+ this.field(t).markTouched();
370
+ for (const t of this.#e.values())
371
+ t.markTouched();
372
+ };
373
+ /**
374
+ * Marks this field and all child fields as pristine (resets baseline) recursively.
375
+ */
376
+ markAllPristine = () => {
377
+ this.markPristine();
378
+ const e = this.signal.value;
379
+ for (const t of Object.keys(e))
380
+ this.field(t).markPristine?.();
381
+ for (const t of this.#e.values())
382
+ t.markPristine?.();
383
+ };
384
+ #r = () => {
385
+ let e = !1;
386
+ for (const t of this.#a.values())
387
+ if (t) {
388
+ e = !0;
389
+ break;
390
+ }
391
+ this.#o.set(this.dirty.value || e);
392
+ };
393
+ }
394
+ class $ extends g {
395
+ #e = new Array();
396
+ /** Reactive signal containing the current array length. */
397
+ length;
398
+ #s = /* @__PURE__ */ new Map();
399
+ #t = /* @__PURE__ */ new Map();
400
+ #i = p(!1);
401
+ /** Reactive signal indicating whether this array or any item is touched. */
402
+ touchedDeep = this.#i;
403
+ #a = /* @__PURE__ */ new Map();
404
+ #n = /* @__PURE__ */ new Map();
405
+ #o = p(!1);
406
+ /** Reactive signal indicating whether this array or any item is dirty. */
407
+ dirtyDeep = this.#o;
408
+ #h;
409
+ #c;
410
+ #l = () => {
411
+ let e = !1;
412
+ for (const t of this.#s.values())
413
+ if (t) {
414
+ e = !0;
415
+ break;
416
+ }
417
+ this.#i.set(this.touched.value || e);
418
+ };
419
+ constructor(e, t, s, n, l, o) {
420
+ const a = s.map((h) => h ?? [], o);
421
+ super(e, t, a, n, l, o);
422
+ const r = a.on((h) => {
423
+ const u = this.#e.length - h.length;
424
+ u > 0 && (this.#e.splice(h.length, u).forEach((y, v) => {
425
+ const f = h.length + v;
426
+ y.dispose(), this.#t.get(f)?.(), this.#t.delete(f), this.#s.delete(f), this.#n.get(f)?.(), this.#n.delete(f), this.#a.delete(f);
427
+ }), this.#l(), this.#r());
428
+ });
429
+ this.length = a.map((h) => h.length), this.#h = this.touched.on(() => {
430
+ this.#l();
431
+ }), this.#c = this.dirty.on(() => {
432
+ this.#r();
433
+ });
434
+ const d = this.signal.on(() => this.#r());
435
+ this.onDispose(() => {
436
+ for (const h of this.#e)
437
+ h.dispose();
438
+ this.length.dispose(), this.#e.length = 0, r(), a.dispose();
439
+ for (const h of this.#t.values()) h();
440
+ this.#t.clear(), this.#s.clear(), this.#i.dispose();
441
+ for (const h of this.#n.values()) h();
442
+ this.#n.clear(), this.#a.clear(), this.#o.dispose(), this.#h(), this.#c(), d();
443
+ });
444
+ }
445
+ /**
446
+ * Gets or creates a controller for a specific array item by index.
447
+ * Controllers are cached and reused for the same index.
448
+ *
449
+ * @param index - The zero-based index of the item
450
+ * @returns A Controller instance for the specified item
451
+ *
452
+ * @example
453
+ * ```typescript
454
+ * const firstTaskController = tasksController.item(0)
455
+ * const secondTaskController = tasksController.item(1)
456
+ * ```
457
+ */
458
+ item = (e) => {
459
+ if (this.#e[e])
460
+ return this.#e[e];
461
+ const t = async (o) => {
462
+ const a = this.signal.value.slice();
463
+ a[e] = o, this.change(a);
464
+ }, s = new g(
465
+ [...this.path, e],
466
+ t,
467
+ this.signal.map((o) => o[e]),
468
+ this.status.map(C([e])),
469
+ {
470
+ disabled: this.disabled,
471
+ validationMode: this.parent.validationMode
472
+ }
473
+ );
474
+ this.#e[e] = s;
475
+ const n = s.touched.on((o) => {
476
+ this.#s.set(e, o), this.#l();
477
+ });
478
+ this.#t.set(e, n);
479
+ const l = s.dirty.on((o) => {
480
+ this.#a.set(e, o), this.#r();
481
+ });
482
+ return this.#n.set(e, l), s;
483
+ };
484
+ /**
485
+ * Appends one or more items to the end of the array.
486
+ *
487
+ * @param value - Items to append
488
+ */
489
+ push = (...e) => {
490
+ this.change([...this.signal.value, ...e]);
491
+ };
492
+ /**
493
+ * Removes the last item from the array.
494
+ */
495
+ pop = () => {
496
+ this.splice(this.signal.value.length - 1, 1);
497
+ };
498
+ /**
499
+ * Removes the first item from the array.
500
+ */
501
+ shift = () => {
502
+ this.splice(0, 1);
503
+ };
504
+ /**
505
+ * Inserts one or more items at the beginning of the array.
506
+ *
507
+ * @param value - Items to prepend
508
+ */
509
+ unshift = (...e) => {
510
+ this.change([...e, ...this.signal.value]);
511
+ };
512
+ /**
513
+ * Removes the item at the specified index.
514
+ *
515
+ * @param index - Zero-based index of the item to remove
516
+ */
517
+ removeAt = (e) => {
518
+ this.splice(e, 1);
519
+ };
520
+ /**
521
+ * Removes items from the array starting at the specified index.
522
+ *
523
+ * @param start - Zero-based index to start removing items
524
+ * @param deleteCount - Number of items to remove (optional)
525
+ */
526
+ splice = (e, t) => {
527
+ const s = this.signal.value.slice();
528
+ s.splice(e, t), this.change(s);
529
+ };
530
+ /**
531
+ * Moves one or more items from one index to another within the array.
532
+ *
533
+ * @param from - Source index to move from
534
+ * @param to - Destination index to move to
535
+ * @param length - Number of items to move (defaults to 1)
536
+ *
537
+ * @example
538
+ * ```typescript
539
+ * controller.move(0, 2) // Move first item to third position
540
+ * controller.move(2, 0, 2) // Move items at index 2-3 to the beginning
541
+ * ```
542
+ */
543
+ move = (e, t, s = 1) => {
544
+ if (s < 1 || e === t) return;
545
+ const n = this.signal.value.slice(), l = n.splice(e, s);
546
+ n.splice(t, 0, ...l), this.change(n);
547
+ };
548
+ /**
549
+ * Marks this array and all item controllers as touched recursively.
550
+ * Useful for showing all validation errors when a form is submitted.
551
+ */
552
+ markAllTouched = () => {
553
+ this.markTouched();
554
+ const e = this.signal.value.length;
555
+ for (let t = 0; t < e; t++)
556
+ this.item(t).markTouched();
557
+ };
558
+ /**
559
+ * Marks this array and all item controllers as pristine (resets baseline) recursively.
560
+ */
561
+ markAllPristine = () => {
562
+ this.markPristine();
563
+ const e = this.signal.value.length;
564
+ for (let t = 0; t < e; t++)
565
+ this.item(t).markPristine?.();
566
+ };
567
+ #r = () => {
568
+ let e = !1;
569
+ for (const t of this.#a.values())
570
+ if (t) {
571
+ e = !0;
572
+ break;
573
+ }
574
+ this.#o.set(this.dirty.value || e);
575
+ };
576
+ }
577
+ function F(i) {
578
+ function e(t) {
579
+ return typeof t == "number" ? t : t.toString();
580
+ }
581
+ return i.map(
582
+ (t) => typeof t == "object" && t.key != null ? e(t.key) : e(t)
583
+ );
584
+ }
585
+ function z(i) {
586
+ const e = i.filter((n) => n.path == null || n.path.length === 0).map((n) => n.message), t = i.filter((n) => n.path != null && n.path.length > 0).reduce((n, l) => {
587
+ const o = F(l.path), a = o.pop();
588
+ let r = n;
589
+ for (const d of o)
590
+ r.dependencies == null && (r.dependencies = {}), r.dependencies[d] == null && (r.dependencies[d] = {}), r = r.dependencies[d];
591
+ return r.dependencies == null && (r.dependencies = {}), r.dependencies[a] = { message: l.message }, n;
592
+ }, {}), s = e.join(`
593
+ `);
594
+ return {
595
+ ...t,
596
+ message: s != "" ? s : void 0
597
+ };
598
+ }
599
+ function R({
600
+ initialValue: i,
601
+ onChange: e,
602
+ validate: t,
603
+ equals: s,
604
+ validationMode: n,
605
+ validateDebounceMs: l
606
+ }) {
607
+ const o = j.deriveProp(i), a = p(c.valid), r = p(!1), d = p(n ?? "onTouched"), h = (m) => {
608
+ a.set(m);
609
+ };
610
+ let u;
611
+ const y = async (m) => {
612
+ if (t != null) {
613
+ const k = await t(m);
614
+ h(k);
615
+ }
616
+ }, v = async (m) => {
617
+ o.set(m), e?.(m);
618
+ const k = d.value;
619
+ if (t != null) {
620
+ if (k === "onSubmit")
621
+ return;
622
+ const V = l ?? 0;
623
+ V > 0 ? (u && clearTimeout(u), u = setTimeout(() => {
624
+ y(m);
625
+ }, V)) : await y(m);
626
+ }
627
+ }, f = new g(
628
+ [],
629
+ v,
630
+ o,
631
+ a,
632
+ {
633
+ disabled: r,
634
+ validationMode: d
635
+ },
636
+ s ?? b
637
+ );
638
+ return f.onDispose(() => {
639
+ r.dispose(), o.dispose(), a.dispose(), d.dispose(), u && clearTimeout(u);
640
+ }), { controller: f, setStatus: h };
641
+ }
642
+ function S(i) {
643
+ return M(T.disabled(i.disabled), T.name(i.name));
644
+ }
645
+ function L(i, {
646
+ triggerOn: e = "change"
647
+ } = {}) {
648
+ return M(
649
+ S(i),
650
+ T.value(i.signal),
651
+ (e === "input" ? w.input : w.change)(P(i.change))
652
+ );
653
+ }
654
+ function Q(i, {
655
+ triggerOn: e = "change"
656
+ } = {}) {
657
+ return M(
658
+ S(i),
659
+ T.valueAsNumber(i.signal),
660
+ (e === "input" ? w.input : w.change)(
661
+ O(i.change)
662
+ )
663
+ );
664
+ }
665
+ function E(i) {
666
+ return i.issues != null ? c.invalid(z(i.issues)) : c.valid;
667
+ }
668
+ async function U({
669
+ task: i,
670
+ errorMessage: e,
671
+ errorPath: t = ["root"],
672
+ validation: s
673
+ }) {
674
+ try {
675
+ const n = await i();
676
+ return s != null ? s(n) : c.valid;
677
+ } catch (n) {
678
+ const l = e ?? (n instanceof Error ? n.message : "Operation failed");
679
+ return t.length === 1 && t[0] === "root" ? c.invalid({
680
+ message: l
681
+ }) : c.invalid({
682
+ dependencies: A(t, l)
683
+ });
684
+ }
685
+ }
686
+ function A(i, e) {
687
+ if (i.length === 1)
688
+ return {
689
+ [i[0]]: { message: e }
690
+ };
691
+ const [t, ...s] = i;
692
+ return {
693
+ [t]: {
694
+ dependencies: A(s, e)
695
+ }
696
+ };
697
+ }
698
+ function W({
699
+ initialValue: i = {},
700
+ schema: e,
701
+ onSubmit: t = async () => c.valid,
702
+ validationMode: s,
703
+ validateDebounceMs: n
704
+ }) {
705
+ const { controller: l, setStatus: o } = R({
706
+ initialValue: i,
707
+ validationMode: s ?? "onTouched",
708
+ validateDebounceMs: n,
709
+ validate: (s ?? "onTouched") === "onSubmit" || e == null ? void 0 : async (h) => E(
710
+ await e["~standard"].validate(h)
711
+ )
712
+ }), a = p(!1), r = l.object();
713
+ return r.onDispose(() => a.dispose()), {
714
+ controller: r,
715
+ setStatus: o,
716
+ submit: async (h) => {
717
+ if (a.set(!0), h?.preventDefault(), r.markAllTouched(), e != null) {
718
+ const y = r.signal.value, v = E(
719
+ await e["~standard"].validate(y)
720
+ );
721
+ if (o(v), v.type === "invalid") {
722
+ a.set(!1);
723
+ return;
724
+ }
725
+ }
726
+ const u = await t(r.signal.value);
727
+ a.set(!1), u.type === "invalid" && o(u);
728
+ },
729
+ submitting: a
730
+ };
731
+ }
732
+ export {
733
+ $ as A,
734
+ K as C,
735
+ N as O,
736
+ g as a,
737
+ R as b,
738
+ S as c,
739
+ Q as d,
740
+ L as e,
741
+ z as f,
742
+ F as g,
743
+ I as h,
744
+ C as m,
745
+ J as p,
746
+ E as s,
747
+ U as t,
748
+ W as u,
749
+ H as w
750
+ };