@tachui/forms 0.8.15 → 0.8.16

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.
@@ -1,45 +1,46 @@
1
- import { createSignal as M, createEffect as N, h as n, text as s, useLifecycle as te, setupOutsideClickDetection as re } from "@tachui/core";
2
- import { a as T } from "./index-D3WfkqVv.js";
3
- const Q = (p) => {
1
+ import { createSignal as E, createEffect as H, h as n, text as s, useLifecycle as ne, setupOutsideClickDetection as de } from "@tachui/core";
2
+ import { a as R } from "./index-D3WfkqVv.js";
3
+ const J = (p) => {
4
4
  const {
5
5
  name: e,
6
6
  label: f,
7
- disabled: o = !1,
7
+ disabled: d = !1,
8
8
  required: u = !1,
9
9
  checked: v,
10
- defaultChecked: m = !1,
11
- indeterminate: w = !1,
12
- validation: q,
13
- onChange: V,
10
+ defaultChecked: k = !1,
11
+ indeterminate: C = !1,
12
+ validation: A,
13
+ onChange: D,
14
14
  onBlur: I,
15
- onFocus: D,
15
+ onFocus: w,
16
16
  error: B,
17
- helperText: C,
17
+ helperText: $,
18
18
  ...b
19
- } = p, h = p._formContext, t = T(
19
+ } = p, h = p._formContext, t = R(
20
20
  e,
21
- v ?? m,
22
- q
21
+ v ?? k,
22
+ A
23
23
  );
24
- h && h.register(e, q);
25
- const [c, k] = M(!1);
26
- v !== void 0 && N(() => {
24
+ h && h.register(e, A);
25
+ const [c, x] = E(!1);
26
+ v !== void 0 && H(() => {
27
27
  t.value() !== v && t.setValue(v);
28
28
  });
29
- const S = (x) => {
30
- const $ = x.target.checked;
31
- t.setValue($), h && h.setValue(e, $), V && V(e, $, t);
32
- }, r = (x) => {
33
- k(!0), t.onFocus(), D && D(e, t.value());
34
- }, g = (x) => {
35
- k(!1), t.onBlur(), I && I(e, t.value());
36
- }, l = B || t.error() || h?.getError(e), i = (x) => {
37
- if (x.key === " " || x.key === "Enter") {
38
- x.preventDefault();
39
- const E = x.target;
40
- E.checked = !E.checked, S(x);
29
+ const S = (g) => {
30
+ if (y()) return;
31
+ const M = g.target.checked;
32
+ t.setValue(M), h && h.setValue(e, M), D && D(e, M, t);
33
+ }, r = (g) => {
34
+ x(!0), t.onFocus(), w && w(e, t.value());
35
+ }, m = (g) => {
36
+ x(!1), t.onBlur(), I && I(e, t.value());
37
+ }, l = B || t.error() || h?.getError(e), i = (g) => {
38
+ if (!y() && (g.key === " " || g.key === "Enter")) {
39
+ g.preventDefault();
40
+ const F = g.target;
41
+ F.checked = !F.checked, S(g);
41
42
  }
42
- };
43
+ }, y = () => typeof d == "function" ? d() : d, q = typeof d == "function" ? d : () => d;
43
44
  return {
44
45
  type: "component",
45
46
  id: b.id || `checkbox-${e}`,
@@ -51,8 +52,8 @@ const Q = (p) => {
51
52
  "data-tachui-checkbox-container": !0,
52
53
  "data-field-state": l ? "error" : t.validating() ? "validating" : "valid",
53
54
  "data-checked": t.value(),
54
- "data-indeterminate": w,
55
- "data-disabled": o
55
+ "data-indeterminate": C,
56
+ "data-disabled": q
56
57
  },
57
58
  // Checkbox input and label wrapper
58
59
  n(
@@ -60,7 +61,7 @@ const Q = (p) => {
60
61
  {
61
62
  "data-tachui-checkbox-label": !0,
62
63
  "data-focused": c(),
63
- "data-disabled": o
64
+ "data-disabled": q
64
65
  },
65
66
  // Hidden native checkbox for accessibility
66
67
  n("input", {
@@ -68,16 +69,16 @@ const Q = (p) => {
68
69
  id: b.id || e,
69
70
  name: e,
70
71
  checked: t.value(),
71
- disabled: o,
72
+ disabled: q,
72
73
  required: u,
73
74
  onchange: S,
74
75
  onfocus: r,
75
- onblur: g,
76
+ onblur: m,
76
77
  onkeydown: i,
77
78
  "aria-invalid": !!l,
78
79
  "aria-describedby": [
79
80
  l ? `${e}-error` : null,
80
- C ? `${e}-helper` : null
81
+ $ ? `${e}-helper` : null
81
82
  ].filter(Boolean).join(" ") || void 0,
82
83
  "data-tachui-checkbox-input": !0,
83
84
  style: {
@@ -97,21 +98,21 @@ const Q = (p) => {
97
98
  {
98
99
  "data-tachui-checkbox-visual": !0,
99
100
  "data-checked": t.value(),
100
- "data-indeterminate": w,
101
+ "data-indeterminate": C,
101
102
  "data-focused": c(),
102
- "data-disabled": o,
103
+ "data-disabled": q,
103
104
  "data-error": !!l,
104
105
  "aria-hidden": "true",
105
106
  role: "presentation"
106
107
  },
107
- ...t.value() || w ? [
108
+ ...t.value() || C ? [
108
109
  n(
109
110
  "div",
110
111
  {
111
112
  "data-tachui-checkbox-indicator": !0,
112
- "data-type": w ? "indeterminate" : "checked"
113
+ "data-type": C ? "indeterminate" : "checked"
113
114
  },
114
- s(w ? "−" : "✓")
115
+ s(C ? "−" : "✓")
115
116
  )
116
117
  ] : []
117
118
  ),
@@ -120,7 +121,7 @@ const Q = (p) => {
120
121
  "span",
121
122
  {
122
123
  "data-tachui-checkbox-text": !0,
123
- "data-disabled": o
124
+ "data-disabled": q
124
125
  },
125
126
  s(f),
126
127
  ...u ? [
@@ -148,14 +149,14 @@ const Q = (p) => {
148
149
  s(l)
149
150
  )
150
151
  ] : [],
151
- ...C && !l ? [
152
+ ...$ && !l ? [
152
153
  n(
153
154
  "div",
154
155
  {
155
156
  id: `${e}-helper`,
156
157
  "data-tachui-helper": !0
157
158
  },
158
- s(C)
159
+ s($)
159
160
  )
160
161
  ] : [],
161
162
  ...t.validating() ? [
@@ -176,19 +177,19 @@ const Q = (p) => {
176
177
  }
177
178
  ]
178
179
  };
179
- }, de = (p) => {
180
- const { size: e = "medium", ...f } = p, o = {
180
+ }, ue = (p) => {
181
+ const { size: e = "medium", ...f } = p, d = {
181
182
  ...f,
182
183
  class: `tachui-switch tachui-switch-${e} ${f.class || ""}`.trim()
183
- }, u = Q(o);
184
+ }, u = J(d);
184
185
  return {
185
186
  ...u,
186
187
  render: () => {
187
188
  const v = u.render();
188
- return Array.isArray(v) ? v.map((m) => ({
189
- ...m,
189
+ return Array.isArray(v) ? v.map((k) => ({
190
+ ...k,
190
191
  props: {
191
- ...m.props,
192
+ ...k.props,
192
193
  "data-tachui-switch": !0,
193
194
  "data-switch-size": e
194
195
  }
@@ -202,33 +203,33 @@ const Q = (p) => {
202
203
  };
203
204
  }
204
205
  };
205
- }, oe = (p) => {
206
+ }, he = (p) => {
206
207
  const {
207
208
  name: e,
208
209
  label: f,
209
- options: o,
210
+ options: d,
210
211
  value: u,
211
212
  defaultValue: v = [],
212
- onChange: m,
213
- validation: w,
214
- error: q,
215
- helperText: V,
213
+ onChange: k,
214
+ validation: C,
215
+ error: A,
216
+ helperText: D,
216
217
  disabled: I = !1,
217
- required: D = !1,
218
+ required: w = !1,
218
219
  direction: B = "vertical",
219
- ...C
220
- } = p, b = T(e, u ?? v, w), h = (c, k) => {
220
+ ...$
221
+ } = p, b = R(e, u ?? v, C), h = (c, x) => {
221
222
  const S = b.value() || [];
222
223
  let r;
223
- k ? r = [...S, c] : r = S.filter((g) => g !== c), b.setValue(r), m && m(e, r, c);
224
+ x ? r = [...S, c] : r = S.filter((m) => m !== c), b.setValue(r), k && k(e, r, c);
224
225
  };
225
226
  return {
226
227
  type: "component",
227
- id: C.id || `checkbox-group-${e}`,
228
+ id: $.id || `checkbox-group-${e}`,
228
229
  render: () => n(
229
230
  "fieldset",
230
231
  {
231
- ...C,
232
+ ...$,
232
233
  "data-tachui-checkbox-group": !0,
233
234
  "data-direction": B,
234
235
  "data-disabled": I
@@ -240,7 +241,7 @@ const Q = (p) => {
240
241
  "data-tachui-group-label": !0
241
242
  },
242
243
  s(f),
243
- ...D ? [
244
+ ...w ? [
244
245
  n(
245
246
  "span",
246
247
  {
@@ -259,18 +260,18 @@ const Q = (p) => {
259
260
  "data-tachui-checkbox-options": !0,
260
261
  "data-direction": B
261
262
  },
262
- ...o.flatMap((c, k) => {
263
- const r = Q({
264
- name: `${e}-${k}`,
263
+ ...d.flatMap((c, x) => {
264
+ const r = J({
265
+ name: `${e}-${x}`,
265
266
  label: c.label,
266
267
  checked: (b.value() || []).includes(c.value),
267
268
  disabled: I || c.disabled,
268
- onChange: (g, l) => h(c.value, l)
269
+ onChange: (m, l) => h(c.value, l)
269
270
  }).render();
270
271
  return Array.isArray(r) ? r : [r];
271
272
  })
272
273
  ),
273
- ...q ? [
274
+ ...A ? [
274
275
  n(
275
276
  "div",
276
277
  {
@@ -279,52 +280,52 @@ const Q = (p) => {
279
280
  "aria-live": "polite",
280
281
  "data-tachui-error": !0
281
282
  },
282
- s(q)
283
+ s(A)
283
284
  )
284
285
  ] : [],
285
- ...V && !q ? [
286
+ ...D && !A ? [
286
287
  n(
287
288
  "div",
288
289
  {
289
290
  id: `${e}-helper`,
290
291
  "data-tachui-helper": !0
291
292
  },
292
- s(V)
293
+ s(D)
293
294
  )
294
295
  ] : []
295
296
  ),
296
297
  props: p
297
298
  };
298
- }, le = (p) => {
299
+ }, oe = (p) => {
299
300
  const {
300
301
  name: e,
301
302
  value: f,
302
- label: o,
303
+ label: d,
303
304
  checked: u,
304
305
  groupName: v,
305
- disabled: m = !1,
306
- required: w = !1,
307
- validation: q,
308
- onChange: V,
306
+ disabled: k = !1,
307
+ required: C = !1,
308
+ validation: A,
309
+ onChange: D,
309
310
  onBlur: I,
310
- onFocus: D,
311
+ onFocus: w,
311
312
  error: B,
312
- helperText: C,
313
+ helperText: $,
313
314
  ...b
314
- } = p, h = p._formContext, t = v || e, c = T(
315
+ } = p, h = p._formContext, t = v || e, c = R(
315
316
  t,
316
317
  u ? f : void 0,
317
- q
318
+ A
318
319
  );
319
- h && h.register(t, q);
320
- const [k, S] = M(!1), r = () => c.value() === f, g = ($) => {
321
- $.target.checked && (c.setValue(f), h && h.setValue(t, f), V && V(t, f, c));
322
- }, l = ($) => {
323
- S(!0), c.onFocus(), D && D(t, c.value());
324
- }, i = ($) => {
320
+ h && h.register(t, A);
321
+ const [x, S] = E(!1), r = () => c.value() === f, m = (g) => {
322
+ g.target.checked && (c.setValue(f), h && h.setValue(t, f), D && D(t, f, c));
323
+ }, l = (g) => {
324
+ S(!0), c.onFocus(), w && w(t, c.value());
325
+ }, i = (g) => {
325
326
  S(!1), c.onBlur(), I && I(t, c.value());
326
- }, y = B || c.error() || h?.getError(t), x = ($) => {
327
- ($.key === " " || $.key === "Enter") && ($.preventDefault(), g($));
327
+ }, y = B || c.error() || h?.getError(t), q = (g) => {
328
+ (g.key === " " || g.key === "Enter") && (g.preventDefault(), m(g));
328
329
  };
329
330
  return {
330
331
  type: "component",
@@ -337,15 +338,15 @@ const Q = (p) => {
337
338
  "data-tachui-radio-container": !0,
338
339
  "data-field-state": y ? "error" : c.validating() ? "validating" : "valid",
339
340
  "data-checked": r(),
340
- "data-disabled": m
341
+ "data-disabled": k
341
342
  },
342
343
  // Radio input and label wrapper
343
344
  n(
344
345
  "label",
345
346
  {
346
347
  "data-tachui-radio-label": !0,
347
- "data-focused": k(),
348
- "data-disabled": m
348
+ "data-focused": x(),
349
+ "data-disabled": k
349
350
  },
350
351
  // Hidden native radio for accessibility
351
352
  n("input", {
@@ -354,16 +355,16 @@ const Q = (p) => {
354
355
  name: t,
355
356
  value: f,
356
357
  checked: r(),
357
- disabled: m,
358
- required: w,
359
- onchange: g,
358
+ disabled: k,
359
+ required: C,
360
+ onchange: m,
360
361
  onfocus: l,
361
362
  onblur: i,
362
- onkeydown: x,
363
+ onkeydown: q,
363
364
  "aria-invalid": !!y,
364
365
  "aria-describedby": [
365
366
  y ? `${t}-error` : null,
366
- C ? `${t}-helper` : null
367
+ $ ? `${t}-helper` : null
367
368
  ].filter(Boolean).join(" ") || void 0,
368
369
  "data-tachui-radio-input": !0,
369
370
  style: {
@@ -383,8 +384,8 @@ const Q = (p) => {
383
384
  {
384
385
  "data-tachui-radio-visual": !0,
385
386
  "data-checked": r(),
386
- "data-focused": k(),
387
- "data-disabled": m,
387
+ "data-focused": x(),
388
+ "data-disabled": k,
388
389
  "data-error": !!y,
389
390
  "aria-hidden": "true",
390
391
  role: "presentation"
@@ -395,15 +396,15 @@ const Q = (p) => {
395
396
  })
396
397
  ] : []
397
398
  ),
398
- ...o ? [
399
+ ...d ? [
399
400
  n(
400
401
  "span",
401
402
  {
402
403
  "data-tachui-radio-text": !0,
403
- "data-disabled": m
404
+ "data-disabled": k
404
405
  },
405
- s(o),
406
- ...w ? [
406
+ s(d),
407
+ ...C ? [
407
408
  n(
408
409
  "span",
409
410
  {
@@ -423,72 +424,72 @@ const Q = (p) => {
423
424
  }
424
425
  ]
425
426
  };
426
- }, ce = (p) => {
427
+ }, pe = (p) => {
427
428
  const {
428
429
  name: e,
429
430
  label: f,
430
- options: o,
431
+ options: d,
431
432
  value: u,
432
433
  defaultValue: v,
433
- onChange: m,
434
- validation: w,
435
- error: q,
436
- helperText: V,
434
+ onChange: k,
435
+ validation: C,
436
+ error: A,
437
+ helperText: D,
437
438
  disabled: I = !1,
438
- required: D = !1,
439
+ required: w = !1,
439
440
  direction: B = "vertical",
440
- ...C
441
- } = p, b = p._formContext, h = T(e, u ?? v, w);
442
- b && b.register(e, w), u !== void 0 && N(() => {
441
+ ...$
442
+ } = p, b = p._formContext, h = R(e, u ?? v, C);
443
+ b && b.register(e, C), u !== void 0 && H(() => {
443
444
  h.value() !== u && h.setValue(u);
444
445
  });
445
446
  const t = (r) => {
446
- h.setValue(r), b && b.setValue(e, r), m && m(e, r);
447
+ h.setValue(r), b && b.setValue(e, r), k && k(e, r);
447
448
  }, c = (r) => {
448
- const g = o.findIndex((i) => i.value === h.value());
449
- let l = g;
449
+ const m = d.findIndex((i) => i.value === h.value());
450
+ let l = m;
450
451
  switch (r.key) {
451
452
  case "ArrowDown":
452
453
  case "ArrowRight":
453
- r.preventDefault(), l = (g + 1) % o.length;
454
+ r.preventDefault(), l = (m + 1) % d.length;
454
455
  break;
455
456
  case "ArrowUp":
456
457
  case "ArrowLeft":
457
- r.preventDefault(), l = g === 0 ? o.length - 1 : g - 1;
458
+ r.preventDefault(), l = m === 0 ? d.length - 1 : m - 1;
458
459
  break;
459
460
  case "Home":
460
461
  r.preventDefault(), l = 0;
461
462
  break;
462
463
  case "End":
463
- r.preventDefault(), l = o.length - 1;
464
+ r.preventDefault(), l = d.length - 1;
464
465
  break;
465
466
  default:
466
467
  return;
467
468
  }
468
- for (; o[l]?.disabled && (r.key === "ArrowDown" || r.key === "ArrowRight" ? l = (l + 1) % o.length : l = l === 0 ? o.length - 1 : l - 1, l !== g); )
469
+ for (; d[l]?.disabled && (r.key === "ArrowDown" || r.key === "ArrowRight" ? l = (l + 1) % d.length : l = l === 0 ? d.length - 1 : l - 1, l !== m); )
469
470
  ;
470
- o[l]?.disabled || (t(o[l].value), setTimeout(() => {
471
+ d[l]?.disabled || (t(d[l].value), setTimeout(() => {
471
472
  const i = document.querySelector(
472
- `input[name="${e}"][value="${o[l].value}"]`
473
+ `input[name="${e}"][value="${d[l].value}"]`
473
474
  );
474
475
  i && i.focus();
475
476
  }, 0));
476
- }, k = q || h.error();
477
+ }, x = A || h.error();
477
478
  return {
478
479
  type: "component",
479
- id: C.id || `radio-group-${e}`,
480
+ id: $.id || `radio-group-${e}`,
480
481
  render: () => n(
481
482
  "fieldset",
482
483
  {
483
- ...C,
484
+ ...$,
484
485
  "data-tachui-radio-group": !0,
485
486
  "data-direction": B,
486
487
  "data-disabled": I,
487
488
  role: "radiogroup",
488
- "aria-invalid": !!k,
489
+ "aria-invalid": !!x,
489
490
  "aria-describedby": [
490
- k ? `${e}-error` : null,
491
- V ? `${e}-helper` : null
491
+ x ? `${e}-error` : null,
492
+ D ? `${e}-helper` : null
492
493
  ].filter(Boolean).join(" ") || void 0,
493
494
  onkeydown: c
494
495
  },
@@ -499,7 +500,7 @@ const Q = (p) => {
499
500
  "data-tachui-group-label": !0
500
501
  },
501
502
  s(f),
502
- ...D ? [
503
+ ...w ? [
503
504
  n(
504
505
  "span",
505
506
  {
@@ -518,22 +519,22 @@ const Q = (p) => {
518
519
  "data-tachui-radio-options": !0,
519
520
  "data-direction": B
520
521
  },
521
- ...o.flatMap((r, g) => {
522
- const i = le({
523
- name: `${e}-${g}`,
522
+ ...d.flatMap((r, m) => {
523
+ const i = oe({
524
+ name: `${e}-${m}`,
524
525
  groupName: e,
525
526
  value: r.value,
526
527
  label: r.label,
527
528
  checked: h.value() === r.value,
528
529
  disabled: I || r.disabled,
529
- required: D,
530
+ required: w,
530
531
  onChange: () => t(r.value),
531
532
  _formContext: b
532
533
  }).render();
533
534
  return Array.isArray(i) ? i : [i];
534
535
  })
535
536
  ),
536
- ...k ? [
537
+ ...x ? [
537
538
  n(
538
539
  "div",
539
540
  {
@@ -542,17 +543,17 @@ const Q = (p) => {
542
543
  "aria-live": "polite",
543
544
  "data-tachui-error": !0
544
545
  },
545
- s(k)
546
+ s(x)
546
547
  )
547
548
  ] : [],
548
- ...V && !k ? [
549
+ ...D && !x ? [
549
550
  n(
550
551
  "div",
551
552
  {
552
553
  id: `${e}-helper`,
553
554
  "data-tachui-helper": !0
554
555
  },
555
- s(V)
556
+ s(D)
556
557
  )
557
558
  ] : []
558
559
  ),
@@ -563,136 +564,140 @@ const Q = (p) => {
563
564
  }
564
565
  ]
565
566
  };
566
- }, U = (p) => {
567
+ }, W = (p) => {
567
568
  const {
568
569
  name: e,
569
570
  label: f,
570
- options: o,
571
+ options: d,
571
572
  multiple: u = !1,
572
573
  searchable: v = !1,
573
- clearable: m = !1,
574
- placeholder: w = u ? "Select options..." : "Select an option...",
575
- noOptionsMessage: q = "No options available",
576
- loadingMessage: V = "Loading...",
574
+ clearable: k = !1,
575
+ placeholder: C = u ? "Select options..." : "Select an option...",
576
+ noOptionsMessage: A = "No options available",
577
+ loadingMessage: D = "Loading...",
577
578
  maxMenuHeight: I = 200,
578
- disabled: D = !1,
579
+ disabled: w = !1,
579
580
  required: B = !1,
580
- value: C,
581
+ value: $,
581
582
  defaultValue: b,
582
583
  validation: h,
583
584
  onChange: t,
584
585
  onBlur: c,
585
- onFocus: k,
586
+ onFocus: x,
586
587
  error: S,
587
588
  helperText: r,
588
- ...g
589
- } = p, l = p._formContext, i = T(e, C ?? b, h);
589
+ ...m
590
+ } = p, l = p._formContext, i = R(e, $ ?? b, h);
590
591
  l && l.register(e, h);
591
- const [y, x] = M(!1), [E, $] = M(!1), [R, L] = M(""), [O, _] = M(-1), [J] = M(!1);
592
- C !== void 0 && N(() => {
593
- i.value() !== C && i.setValue(C);
592
+ const [y, q] = E(!1), [K, g] = E(!1), [F, M] = E(""), [_, T] = E(-1), [X, Y] = E(0), [Z] = E(!1);
593
+ $ !== void 0 && H(() => {
594
+ i.value() !== $ && i.setValue($);
594
595
  });
595
- const K = () => {
596
- if (!v || !R())
597
- return o;
598
- const a = R().toLowerCase();
599
- return o.filter(
600
- (d) => d.label.toLowerCase().includes(a) || String(d.value).toLowerCase().includes(a)
596
+ const N = () => {
597
+ if (!v || !F())
598
+ return d;
599
+ const a = F().toLowerCase();
600
+ return d.filter(
601
+ (o) => o.label.toLowerCase().includes(a) || String(o.value).toLowerCase().includes(a)
601
602
  );
602
- }, W = () => {
603
+ }, ee = () => {
603
604
  const a = i.value();
604
605
  if (u)
605
- return !a || !Array.isArray(a) || a.length === 0 ? w : o.filter((A) => a.includes(A.value)).map((A) => A.label).join(", ");
606
+ return !a || !Array.isArray(a) || a.length === 0 ? C : d.filter((V) => a.includes(V.value)).map((V) => V.label).join(", ");
606
607
  {
607
608
  if (a == null || a === "")
608
- return w;
609
- const d = o.find((A) => A.value === a);
610
- return d ? d.label : String(a);
609
+ return C;
610
+ const o = d.find((V) => V.value === a);
611
+ return o ? o.label : String(a);
611
612
  }
612
613
  }, z = (a) => {
613
614
  if (a.disabled) return;
614
- let d;
615
+ let o;
615
616
  if (u) {
616
- const A = i.value() || [];
617
- A.includes(a.value) ? d = A.filter((ae) => ae !== a.value) : d = [...A, a.value];
617
+ const V = i.value() || [];
618
+ V.includes(a.value) ? o = V.filter((ie) => ie !== a.value) : o = [...V, a.value];
618
619
  } else
619
- d = a.value, x(!1), L("");
620
- i.setValue(d), l && l.setValue(e, d), t && t(e, d, i);
621
- }, j = () => {
622
- if (D) return;
620
+ o = a.value, q(!1), M("");
621
+ i.setValue(o), l && l.setValue(e, o), t && t(e, o, i);
622
+ }, G = () => typeof w == "function" ? w() : w, Q = typeof w == "function" ? w : () => w;
623
+ H(() => {
624
+ Y(G() ? -1 : 0);
625
+ });
626
+ const L = () => {
627
+ if (G()) return;
623
628
  const a = !y();
624
- x(a), a && (_(-1), v && L(""));
625
- }, X = (a) => {
626
- const d = a.target;
627
- L(d.value), _(-1);
628
- }, Y = (a) => {
629
- const d = K();
629
+ q(a), a && (T(-1), v && M(""));
630
+ }, ae = (a) => {
631
+ const o = a.target;
632
+ M(o.value), T(-1);
633
+ }, te = (a) => {
634
+ const o = N();
630
635
  switch (a.key) {
631
636
  case "Enter":
632
- a.preventDefault(), y() ? O() >= 0 && d[O()] && z(d[O()]) : j();
637
+ a.preventDefault(), y() ? _() >= 0 && o[_()] && z(o[_()]) : L();
633
638
  break;
634
639
  case " ":
635
- (!v || !y()) && (a.preventDefault(), j());
640
+ (!v || !y()) && (a.preventDefault(), L());
636
641
  break;
637
642
  case "Escape":
638
- a.preventDefault(), x(!1), L("");
643
+ a.preventDefault(), q(!1), M("");
639
644
  break;
640
645
  case "ArrowDown":
641
646
  if (a.preventDefault(), !y())
642
- j();
647
+ L();
643
648
  else {
644
- const A = Math.min(
645
- O() + 1,
646
- d.length - 1
649
+ const V = Math.min(
650
+ _() + 1,
651
+ o.length - 1
647
652
  );
648
- _(A);
653
+ T(V);
649
654
  }
650
655
  break;
651
656
  case "ArrowUp":
652
657
  if (a.preventDefault(), y()) {
653
- const A = Math.max(O() - 1, -1);
654
- _(A);
658
+ const V = Math.max(_() - 1, -1);
659
+ T(V);
655
660
  }
656
661
  break;
657
662
  case "Home":
658
- y() && (a.preventDefault(), _(0));
663
+ y() && (a.preventDefault(), T(0));
659
664
  break;
660
665
  case "End":
661
- y() && (a.preventDefault(), _(d.length - 1));
666
+ y() && (a.preventDefault(), T(o.length - 1));
662
667
  break;
663
668
  case "Backspace":
664
- m && !v && i.value() !== null && (a.preventDefault(), G());
669
+ k && !v && i.value() !== null && (a.preventDefault(), U());
665
670
  break;
666
671
  }
667
- }, Z = () => {
668
- $(!0), i.onFocus(), k && k(e, i.value());
669
- }, ee = (a) => {
672
+ }, re = () => {
673
+ g(!0), i.onFocus(), x && x(e, i.value());
674
+ }, le = (a) => {
670
675
  requestAnimationFrame(() => {
671
- const d = a.relatedTarget;
676
+ const o = a.relatedTarget;
672
677
  a.target.closest(
673
678
  "[data-tachui-select-container]"
674
- )?.contains(d) || ($(!1), x(!1), i.onBlur(), c && c(e, i.value()));
679
+ )?.contains(o) || (g(!1), q(!1), i.onBlur(), c && c(e, i.value()));
675
680
  });
676
- }, G = () => {
681
+ }, U = () => {
677
682
  const a = u ? [] : null;
678
683
  i.setValue(a), l && l.setValue(e, a), t && t(e, a, i);
679
- }, H = (a) => {
680
- const d = i.value();
681
- return u ? Array.isArray(d) && d.includes(a.value) : d === a.value;
682
- }, F = S || i.error() || l?.getError(e), P = {
684
+ }, j = (a) => {
685
+ const o = i.value();
686
+ return u ? Array.isArray(o) && o.includes(a.value) : o === a.value;
687
+ }, O = S || i.error() || l?.getError(e), P = {
683
688
  type: "component",
684
- id: g.id || `select-${e}`,
689
+ id: m.id || `select-${e}`,
685
690
  cleanup: [],
686
691
  render: () => ({
687
692
  type: "element",
688
693
  tag: "div",
689
694
  props: {
690
- ...g,
691
- class: `tachui-select ${g.class || ""}`.trim(),
695
+ ...m,
696
+ class: `tachui-select ${m.class || ""}`.trim(),
692
697
  "data-tachui-select-container": !0,
693
- "data-field-state": F ? "error" : i.validating() ? "validating" : "valid",
698
+ "data-field-state": O ? "error" : i.validating() ? "validating" : "valid",
694
699
  "data-open": y(),
695
- "data-disabled": D,
700
+ "data-disabled": Q,
696
701
  "data-multiple": u,
697
702
  "data-searchable": v
698
703
  },
@@ -702,7 +707,7 @@ const Q = (p) => {
702
707
  n(
703
708
  "label",
704
709
  {
705
- for: g.id || e,
710
+ for: m.id || e,
706
711
  "data-tachui-label": !0,
707
712
  "data-required": B
708
713
  },
@@ -724,24 +729,24 @@ const Q = (p) => {
724
729
  type: "element",
725
730
  tag: "div",
726
731
  props: {
727
- id: g.id || e,
728
- tabindex: D ? -1 : 0,
732
+ id: m.id || e,
733
+ tabindex: X,
729
734
  role: "combobox",
730
735
  "aria-expanded": y(),
731
736
  "aria-haspopup": "listbox",
732
- "aria-invalid": !!F,
737
+ "aria-invalid": !!O,
733
738
  "aria-describedby": [
734
- F ? `${e}-error` : null,
739
+ O ? `${e}-error` : null,
735
740
  r ? `${e}-helper` : null
736
741
  ].filter(Boolean).join(" ") || void 0,
737
- onclick: j,
738
- onkeydown: Y,
739
- onfocus: Z,
740
- onblur: ee,
742
+ onclick: L,
743
+ onkeydown: te,
744
+ onfocus: re,
745
+ onblur: le,
741
746
  "data-tachui-select-trigger": !0,
742
- "data-focused": E(),
743
- "data-disabled": D,
744
- "data-error": !!F
747
+ "data-focused": K(),
748
+ "data-disabled": Q,
749
+ "data-error": !!O
745
750
  },
746
751
  children: [
747
752
  // Display value
@@ -752,7 +757,7 @@ const Q = (p) => {
752
757
  "data-tachui-select-value": !0,
753
758
  "data-placeholder": !i.value() || u && (!i.value() || i.value().length === 0)
754
759
  },
755
- children: [s(W())]
760
+ children: [s(ee())]
756
761
  },
757
762
  // Actions (clear, dropdown arrow)
758
763
  {
@@ -763,14 +768,14 @@ const Q = (p) => {
763
768
  },
764
769
  children: [
765
770
  // Clear button
766
- ...m && i.value() && (!u || Array.isArray(i.value()) && i.value().length > 0) ? [
771
+ ...k && i.value() && (!u || Array.isArray(i.value()) && i.value().length > 0) ? [
767
772
  {
768
773
  type: "element",
769
774
  tag: "button",
770
775
  props: {
771
776
  type: "button",
772
777
  onclick: (a) => {
773
- a.stopPropagation(), G();
778
+ a.stopPropagation(), U();
774
779
  },
775
780
  "aria-label": "Clear selection",
776
781
  "data-tachui-select-clear": !0
@@ -819,8 +824,8 @@ const Q = (p) => {
819
824
  props: {
820
825
  type: "text",
821
826
  placeholder: "Search...",
822
- value: R(),
823
- oninput: X,
827
+ value: F(),
828
+ oninput: ae,
824
829
  "data-tachui-select-search-input": !0
825
830
  }
826
831
  }
@@ -836,17 +841,17 @@ const Q = (p) => {
836
841
  "aria-multiselectable": u,
837
842
  "data-tachui-select-options": !0
838
843
  },
839
- children: K().length > 0 ? K().map((a, d) => ({
844
+ children: N().length > 0 ? N().map((a, o) => ({
840
845
  type: "element",
841
846
  tag: "div",
842
847
  props: {
843
848
  role: "option",
844
- "aria-selected": H(a),
849
+ "aria-selected": j(a),
845
850
  "aria-disabled": a.disabled,
846
851
  onclick: () => z(a),
847
852
  "data-tachui-select-option": !0,
848
- "data-selected": H(a),
849
- "data-highlighted": O() === d,
853
+ "data-selected": j(a),
854
+ "data-highlighted": _() === o,
850
855
  "data-disabled": a.disabled,
851
856
  "data-group": a.group
852
857
  },
@@ -858,11 +863,11 @@ const Q = (p) => {
858
863
  tag: "div",
859
864
  props: {
860
865
  "data-tachui-select-checkbox": !0,
861
- "data-checked": H(a)
866
+ "data-checked": j(a)
862
867
  },
863
868
  children: [
864
869
  s(
865
- H(a) ? "✓" : ""
870
+ j(a) ? "✓" : ""
866
871
  )
867
872
  ]
868
873
  }
@@ -879,7 +884,7 @@ const Q = (p) => {
879
884
  },
880
885
  children: [
881
886
  s(
882
- J() ? V : q
887
+ Z() ? D : A
883
888
  )
884
889
  ]
885
890
  }
@@ -889,7 +894,7 @@ const Q = (p) => {
889
894
  }
890
895
  ] : [],
891
896
  // Error message
892
- ...F ? [
897
+ ...O ? [
893
898
  {
894
899
  type: "element",
895
900
  tag: "div",
@@ -899,11 +904,11 @@ const Q = (p) => {
899
904
  "aria-live": "polite",
900
905
  "data-tachui-error": !0
901
906
  },
902
- children: [s(F)]
907
+ children: [s(O)]
903
908
  }
904
909
  ] : [],
905
910
  // Helper text
906
- ...r && !F ? [
911
+ ...r && !O ? [
907
912
  {
908
913
  type: "element",
909
914
  tag: "div",
@@ -920,25 +925,25 @@ const Q = (p) => {
920
925
  };
921
926
  return P.cleanup || (P.cleanup = []), P.cleanup.push(() => {
922
927
  l && l.unregister(e);
923
- }), te(P, {
924
- onDOMReady: (a, d) => {
925
- d && re(
928
+ }), ne(P, {
929
+ onDOMReady: (a, o) => {
930
+ o && de(
926
931
  P,
927
932
  () => {
928
- y() && (x(!1), $(!1), i.onBlur(), c && c(e, i.value()));
933
+ y() && (q(!1), g(!1), i.onBlur(), c && c(e, i.value()));
929
934
  },
930
935
  "[data-tachui-select-container]"
931
936
  );
932
937
  }
933
938
  }), P;
934
- }, se = (p) => U({ ...p, multiple: !0 }), ue = (p) => U({ ...p, searchable: !0 });
939
+ }, fe = (p) => W({ ...p, multiple: !0 }), be = (p) => W({ ...p, searchable: !0 });
935
940
  export {
936
- Q as C,
937
- se as M,
938
- le as R,
939
- de as S,
940
- oe as a,
941
- ce as b,
942
- ue as c,
943
- U as d
941
+ J as C,
942
+ fe as M,
943
+ oe as R,
944
+ ue as S,
945
+ he as a,
946
+ pe as b,
947
+ be as c,
948
+ W as d
944
949
  };