@vertz/ui-primitives 0.2.20 → 0.2.21

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 (104) hide show
  1. package/dist/shared/{chunk-ppcv3ehd.js → chunk-0gn67thm.js} +14 -11
  2. package/dist/shared/{chunk-4da5zksy.js → chunk-1dzcjmfq.js} +2 -2
  3. package/dist/shared/{chunk-avxcmmk6.js → chunk-1hv9yd28.js} +6 -6
  4. package/dist/shared/{chunk-kg27s15c.js → chunk-2d05qxdw.js} +4 -4
  5. package/dist/shared/{chunk-bew4bjgf.js → chunk-4jnweh3m.js} +4 -4
  6. package/dist/shared/{chunk-jctqs9m4.js → chunk-7867pr13.js} +36 -12
  7. package/dist/shared/{chunk-rnjm61t0.js → chunk-90hmpm0w.js} +3 -3
  8. package/dist/shared/{chunk-hr9hx58m.js → chunk-ac86qw7a.js} +4 -4
  9. package/dist/shared/{chunk-gt0wth9h.js → chunk-b02fkvts.js} +2 -2
  10. package/dist/shared/{chunk-7kpsyjd7.js → chunk-bsx59bv9.js} +4 -4
  11. package/dist/shared/{chunk-jz0s6srh.js → chunk-cm2akzrm.js} +1 -1
  12. package/dist/shared/{chunk-yr9yzpvq.js → chunk-cvms20w3.js} +82 -57
  13. package/dist/shared/{chunk-ttsyf6ma.js → chunk-d8n8mggh.js} +4 -4
  14. package/dist/shared/{chunk-34yfm2b0.js → chunk-er9625ar.js} +105 -83
  15. package/dist/shared/{chunk-tfyg0qrp.js → chunk-ewxzhtej.js} +5 -5
  16. package/dist/shared/{chunk-4085nbdq.js → chunk-ey4485fh.js} +4 -4
  17. package/dist/shared/{chunk-x2hz98qn.js → chunk-f501vw7e.js} +2 -2
  18. package/dist/shared/{chunk-9hj9p7s2.js → chunk-g67tnd19.js} +36 -30
  19. package/dist/shared/{chunk-j4cm8avr.js → chunk-gbxbkmte.js} +4 -4
  20. package/dist/shared/chunk-gzgyfhz6.js +237 -0
  21. package/dist/shared/{chunk-g9qvd20g.js → chunk-je7tqf67.js} +2 -2
  22. package/dist/shared/{chunk-sqs8kyb2.js → chunk-kr5qg80z.js} +4 -4
  23. package/dist/shared/{chunk-7krvqrwq.js → chunk-kytkmdpc.js} +35 -13
  24. package/dist/shared/{chunk-18y8gfk0.js → chunk-pvy0tcd7.js} +115 -93
  25. package/dist/shared/{chunk-n9nwx58j.js → chunk-q2q20y9a.js} +4 -4
  26. package/dist/shared/{chunk-dpsgb1xw.js → chunk-q8dm19a5.js} +7 -2
  27. package/dist/shared/{chunk-7ffg0caj.js → chunk-q9fgfgh9.js} +7 -5
  28. package/dist/shared/{chunk-m1ptgp1s.js → chunk-qfk1ycfw.js} +6 -6
  29. package/dist/shared/{chunk-x0we8gcy.js → chunk-te4pdqnh.js} +4 -4
  30. package/dist/shared/{chunk-gkddsbmh.js → chunk-v9qddmh9.js} +3 -3
  31. package/dist/shared/{chunk-t1vkvsz2.js → chunk-vm37m55w.js} +4 -4
  32. package/dist/shared/{chunk-8ak7vdk1.js → chunk-y5vdb6br.js} +4 -4
  33. package/dist/shared/{chunk-96d9nr7y.js → chunk-zf0rhm9e.js} +1 -1
  34. package/dist/shared/chunk-ztvj60xp.js +185 -0
  35. package/dist/src/accordion/accordion.d.ts +2 -0
  36. package/dist/src/accordion/accordion.js +1 -5
  37. package/dist/src/alert-dialog/alert-dialog.d.ts +7 -7
  38. package/dist/src/alert-dialog/alert-dialog.js +1 -4
  39. package/dist/src/badge/badge.d.ts +2 -0
  40. package/dist/src/badge/badge.js +1 -3
  41. package/dist/src/button/button.d.ts +2 -0
  42. package/dist/src/button/button.js +1 -3
  43. package/dist/src/calendar/calendar.d.ts +9 -6
  44. package/dist/src/calendar/calendar.js +1 -2
  45. package/dist/src/carousel/carousel.d.ts +2 -0
  46. package/dist/src/carousel/carousel.js +1 -4
  47. package/dist/src/checkbox/checkbox.d.ts +2 -0
  48. package/dist/src/checkbox/checkbox.js +1 -4
  49. package/dist/src/collapsible/collapsible.d.ts +2 -0
  50. package/dist/src/collapsible/collapsible.js +1 -4
  51. package/dist/src/combobox/combobox.d.ts +2 -0
  52. package/dist/src/combobox/combobox.js +1 -5
  53. package/dist/src/command/command.d.ts +2 -0
  54. package/dist/src/command/command.js +1 -5
  55. package/dist/src/context-menu/context-menu.d.ts +2 -0
  56. package/dist/src/context-menu/context-menu.js +1 -7
  57. package/dist/src/date-picker/date-picker.d.ts +6 -6
  58. package/dist/src/date-picker/date-picker.js +1 -10
  59. package/dist/src/dialog/dialog.d.ts +3 -0
  60. package/dist/src/dialog/dialog.js +1 -6
  61. package/dist/src/dropdown-menu/dropdown-menu.d.ts +3 -0
  62. package/dist/src/dropdown-menu/dropdown-menu.js +1 -8
  63. package/dist/src/hover-card/hover-card.d.ts +2 -0
  64. package/dist/src/hover-card/hover-card.js +1 -6
  65. package/dist/src/index.d.ts +744 -34
  66. package/dist/src/index.js +4955 -39
  67. package/dist/src/menu/menu.d.ts +3 -0
  68. package/dist/src/menu/menu.js +1 -7
  69. package/dist/src/menubar/menubar.d.ts +2 -0
  70. package/dist/src/menubar/menubar.js +1 -8
  71. package/dist/src/navigation-menu/navigation-menu.d.ts +7 -5
  72. package/dist/src/navigation-menu/navigation-menu.js +1 -6
  73. package/dist/src/popover/popover.d.ts +2 -0
  74. package/dist/src/popover/popover.js +1 -8
  75. package/dist/src/progress/progress.d.ts +4 -2
  76. package/dist/src/progress/progress.js +1 -4
  77. package/dist/src/radio/radio.d.ts +9 -3
  78. package/dist/src/radio/radio.js +1 -6
  79. package/dist/src/resizable-panel/resizable-panel.d.ts +2 -0
  80. package/dist/src/resizable-panel/resizable-panel.js +1 -4
  81. package/dist/src/scroll-area/scroll-area.d.ts +2 -0
  82. package/dist/src/scroll-area/scroll-area.js +1 -2
  83. package/dist/src/select/select.d.ts +2 -0
  84. package/dist/src/select/select.js +1 -7
  85. package/dist/src/sheet/sheet.js +1 -5
  86. package/dist/src/slider/slider.d.ts +2 -0
  87. package/dist/src/slider/slider.js +1 -5
  88. package/dist/src/switch/switch.d.ts +2 -0
  89. package/dist/src/switch/switch.js +1 -4
  90. package/dist/src/tabs/tabs.d.ts +7 -4
  91. package/dist/src/tabs/tabs.js +1 -6
  92. package/dist/src/toast/toast.d.ts +2 -0
  93. package/dist/src/toast/toast.js +1 -4
  94. package/dist/src/toggle/toggle.d.ts +2 -0
  95. package/dist/src/toggle/toggle.js +1 -4
  96. package/dist/src/toggle-group/toggle-group.d.ts +2 -0
  97. package/dist/src/toggle-group/toggle-group.js +1 -5
  98. package/dist/src/tooltip/tooltip.d.ts +3 -1
  99. package/dist/src/tooltip/tooltip.js +1 -6
  100. package/dist/src/utils.d.ts +61 -1
  101. package/dist/src/utils.js +48 -1
  102. package/package.json +4 -6
  103. package/dist/shared/chunk-8nk0ya7a.js +0 -163
  104. package/dist/shared/chunk-8tvzqry6.js +0 -218
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  setDataState
3
3
  } from "./chunk-vvjyx7fe.js";
4
- import {
5
- applyAttrs
6
- } from "./chunk-dpsgb1xw.js";
7
4
  import {
8
5
  uniqueId
9
6
  } from "./chunk-8y1jf6xr.js";
7
+ import {
8
+ applyAttrs
9
+ } from "./chunk-q8dm19a5.js";
10
10
 
11
11
  // src/progress/progress.tsx
12
- import { __append, __element, __enterChildren, __exitChildren } from "@vertz/ui/internals";
12
+ import { __append, __element, __enterChildren, __exitChildren, __styleStr } from "@vertz/ui/internals";
13
13
  import { ref, signal } from "@vertz/ui";
14
14
  function dataStateFor(pct) {
15
15
  if (pct >= 100)
@@ -18,12 +18,8 @@ function dataStateFor(pct) {
18
18
  return "loading";
19
19
  return "idle";
20
20
  }
21
- function ProgressRoot(options = {}) {
22
- const { defaultValue = 0, min = 0, max = 100, ...attrs } = options;
23
- const state = { value: signal(defaultValue) };
24
- const indicatorRef = ref();
25
- const initialPct = (defaultValue - min) / (max - min) * 100;
26
- const root = (() => {
21
+ function ProgressBar(defaultValue, min, max, initialPct, indicatorRef) {
22
+ return (() => {
27
23
  const __el0 = __element("div");
28
24
  __el0.setAttribute("role", "progressbar");
29
25
  {
@@ -59,13 +55,20 @@ function ProgressRoot(options = {}) {
59
55
  {
60
56
  const __v = `width: ${initialPct}%`;
61
57
  if (__v != null && __v !== false)
62
- __el1.setAttribute("style", __v === true ? "" : __v);
58
+ __el1.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
63
59
  }
64
60
  return __el1;
65
61
  })());
66
62
  __exitChildren();
67
63
  return __el0;
68
64
  })();
65
+ }
66
+ function ProgressRoot(options = {}) {
67
+ const { defaultValue = 0, min = 0, max = 100, ...attrs } = options;
68
+ const state = { value: signal(defaultValue) };
69
+ const indicatorRef = ref();
70
+ const initialPct = (defaultValue - min) / (max - min) * 100;
71
+ const root = ProgressBar(defaultValue, min, max, initialPct, indicatorRef);
69
72
  const indicator = indicatorRef.current;
70
73
  applyAttrs(root, attrs);
71
74
  function setValue(val) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  handleActivation
3
- } from "./chunk-jctqs9m4.js";
3
+ } from "./chunk-7867pr13.js";
4
4
  import {
5
5
  applyAttrs
6
- } from "./chunk-dpsgb1xw.js";
6
+ } from "./chunk-q8dm19a5.js";
7
7
 
8
8
  // src/button/button.tsx
9
9
  import { __element, __on } from "@vertz/ui/internals";
@@ -2,22 +2,22 @@ import {
2
2
  Keys,
3
3
  handleListNavigation,
4
4
  isKey
5
- } from "./chunk-jctqs9m4.js";
5
+ } from "./chunk-7867pr13.js";
6
6
  import {
7
7
  setDataState,
8
8
  setExpanded,
9
9
  setHidden,
10
10
  setHiddenAnimated
11
11
  } from "./chunk-vvjyx7fe.js";
12
- import {
13
- applyAttrs
14
- } from "./chunk-dpsgb1xw.js";
15
12
  import {
16
13
  uniqueId
17
14
  } from "./chunk-8y1jf6xr.js";
15
+ import {
16
+ applyAttrs
17
+ } from "./chunk-q8dm19a5.js";
18
18
 
19
19
  // src/accordion/accordion.tsx
20
- import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
20
+ import { __element, __enterChildren, __exitChildren, __insert, __on, __styleStr } from "@vertz/ui/internals";
21
21
  import { signal } from "@vertz/ui";
22
22
  function AccordionRoot(options = {}) {
23
23
  const { multiple = false, defaultValue = [], onValueChange, ...attrs } = options;
@@ -140,7 +140,7 @@ function AccordionRoot(options = {}) {
140
140
  {
141
141
  const __v = isOpen ? "" : "display: none";
142
142
  if (__v != null && __v !== false)
143
- __el2.setAttribute("style", __v === true ? "" : __v);
143
+ __el2.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
144
144
  }
145
145
  return __el2;
146
146
  })();
@@ -8,7 +8,7 @@ import {
8
8
  Keys,
9
9
  handleListNavigation,
10
10
  isKey
11
- } from "./chunk-jctqs9m4.js";
11
+ } from "./chunk-7867pr13.js";
12
12
  import {
13
13
  setDataState,
14
14
  setExpanded,
@@ -16,12 +16,12 @@ import {
16
16
  setHiddenAnimated,
17
17
  setSelected
18
18
  } from "./chunk-vvjyx7fe.js";
19
- import {
20
- applyAttrs
21
- } from "./chunk-dpsgb1xw.js";
22
19
  import {
23
20
  linkedIds
24
21
  } from "./chunk-8y1jf6xr.js";
22
+ import {
23
+ applyAttrs
24
+ } from "./chunk-q8dm19a5.js";
25
25
 
26
26
  // src/select/select.tsx
27
27
  import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
@@ -4,19 +4,19 @@ import {
4
4
  import {
5
5
  Keys,
6
6
  isKey
7
- } from "./chunk-jctqs9m4.js";
7
+ } from "./chunk-7867pr13.js";
8
8
  import {
9
9
  setDataState,
10
10
  setExpanded,
11
11
  setHidden,
12
12
  setHiddenAnimated
13
13
  } from "./chunk-vvjyx7fe.js";
14
- import {
15
- applyAttrs
16
- } from "./chunk-dpsgb1xw.js";
17
14
  import {
18
15
  uniqueId
19
16
  } from "./chunk-8y1jf6xr.js";
17
+ import {
18
+ applyAttrs
19
+ } from "./chunk-q8dm19a5.js";
20
20
 
21
21
  // src/hover-card/hover-card.tsx
22
22
  import { __element, __on } from "@vertz/ui/internals";
@@ -24,24 +24,16 @@ function handleListNavigation(event, items, options = {}) {
24
24
  let nextIndex = -1;
25
25
  if (isKey(event, prevKey)) {
26
26
  event.preventDefault();
27
- if (currentIndex <= 0) {
28
- nextIndex = loop ? items.length - 1 : 0;
29
- } else {
30
- nextIndex = currentIndex - 1;
31
- }
27
+ nextIndex = findEnabled(items, currentIndex, -1, loop);
32
28
  } else if (isKey(event, nextKey)) {
33
29
  event.preventDefault();
34
- if (currentIndex >= items.length - 1) {
35
- nextIndex = loop ? 0 : items.length - 1;
36
- } else {
37
- nextIndex = currentIndex + 1;
38
- }
30
+ nextIndex = findEnabled(items, currentIndex, 1, loop);
39
31
  } else if (isKey(event, Keys.Home)) {
40
32
  event.preventDefault();
41
- nextIndex = 0;
33
+ nextIndex = findEnabledFrom(items, 0, 1);
42
34
  } else if (isKey(event, Keys.End)) {
43
35
  event.preventDefault();
44
- nextIndex = items.length - 1;
36
+ nextIndex = findEnabledFrom(items, items.length - 1, -1);
45
37
  }
46
38
  const target = items[nextIndex];
47
39
  if (target) {
@@ -50,6 +42,38 @@ function handleListNavigation(event, items, options = {}) {
50
42
  }
51
43
  return null;
52
44
  }
45
+ function isDisabled(el) {
46
+ return el.getAttribute("aria-disabled") === "true";
47
+ }
48
+ function findEnabled(items, current, direction, loop) {
49
+ const len = items.length;
50
+ let candidate = current;
51
+ for (let i = 0;i < len; i++) {
52
+ candidate += direction;
53
+ if (loop) {
54
+ candidate = (candidate % len + len) % len;
55
+ } else if (candidate < 0 || candidate >= len) {
56
+ return -1;
57
+ }
58
+ const el = items[candidate];
59
+ if (el && !isDisabled(el))
60
+ return candidate;
61
+ }
62
+ return -1;
63
+ }
64
+ function findEnabledFrom(items, start, direction) {
65
+ const len = items.length;
66
+ let candidate = start;
67
+ for (let i = 0;i < len; i++) {
68
+ if (candidate < 0 || candidate >= len)
69
+ return -1;
70
+ const el = items[candidate];
71
+ if (el && !isDisabled(el))
72
+ return candidate;
73
+ candidate += direction;
74
+ }
75
+ return -1;
76
+ }
53
77
  function handleActivation(event, handler) {
54
78
  if (isKey(event, Keys.Enter, Keys.Space)) {
55
79
  event.preventDefault();
@@ -1,9 +1,9 @@
1
- import {
2
- applyAttrs
3
- } from "./chunk-dpsgb1xw.js";
4
1
  import {
5
2
  uniqueId
6
3
  } from "./chunk-8y1jf6xr.js";
4
+ import {
5
+ applyAttrs
6
+ } from "./chunk-q8dm19a5.js";
7
7
 
8
8
  // src/badge/badge.tsx
9
9
  import { __element } from "@vertz/ui/internals";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  Keys,
3
3
  isKey
4
- } from "./chunk-jctqs9m4.js";
5
- import {
6
- applyAttrs
7
- } from "./chunk-dpsgb1xw.js";
4
+ } from "./chunk-7867pr13.js";
8
5
  import {
9
6
  uniqueId
10
7
  } from "./chunk-8y1jf6xr.js";
8
+ import {
9
+ applyAttrs
10
+ } from "./chunk-q8dm19a5.js";
11
11
 
12
12
  // src/checkbox/checkbox.tsx
13
13
  import { computed, signal } from "@vertz/ui";
@@ -5,14 +5,14 @@ import {
5
5
  Keys,
6
6
  handleListNavigation,
7
7
  isKey
8
- } from "./chunk-jctqs9m4.js";
8
+ } from "./chunk-7867pr13.js";
9
9
  import {
10
10
  setDataState,
11
11
  setPressed
12
12
  } from "./chunk-vvjyx7fe.js";
13
13
  import {
14
14
  applyAttrs
15
- } from "./chunk-dpsgb1xw.js";
15
+ } from "./chunk-q8dm19a5.js";
16
16
 
17
17
  // src/toggle-group/toggle-group.tsx
18
18
  import { __element, __on } from "@vertz/ui/internals";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  Keys,
3
3
  isKey
4
- } from "./chunk-jctqs9m4.js";
5
- import {
6
- applyAttrs
7
- } from "./chunk-dpsgb1xw.js";
4
+ } from "./chunk-7867pr13.js";
8
5
  import {
9
6
  uniqueId
10
7
  } from "./chunk-8y1jf6xr.js";
8
+ import {
9
+ applyAttrs
10
+ } from "./chunk-q8dm19a5.js";
11
11
 
12
12
  // src/switch/switch.tsx
13
13
  import { computed, signal } from "@vertz/ui";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  applyAttrs
3
- } from "./chunk-dpsgb1xw.js";
3
+ } from "./chunk-q8dm19a5.js";
4
4
 
5
5
  // src/scroll-area/scroll-area.tsx
6
6
  import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
@@ -3,40 +3,24 @@ import {
3
3
  } from "./chunk-e2v1c9ex.js";
4
4
  import {
5
5
  handleListNavigation
6
- } from "./chunk-jctqs9m4.js";
6
+ } from "./chunk-7867pr13.js";
7
7
  import {
8
8
  setChecked,
9
- setDataState
9
+ setDataState,
10
+ setDisabled
10
11
  } from "./chunk-vvjyx7fe.js";
11
- import {
12
- applyAttrs
13
- } from "./chunk-dpsgb1xw.js";
14
12
  import {
15
13
  uniqueId
16
14
  } from "./chunk-8y1jf6xr.js";
15
+ import {
16
+ applyAttrs
17
+ } from "./chunk-q8dm19a5.js";
17
18
 
18
19
  // src/radio/radio.tsx
19
20
  import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
20
21
  import { signal } from "@vertz/ui";
21
- function RadioRoot(options = {}) {
22
- const { defaultValue = "", onValueChange, ...attrs } = options;
23
- const state = { value: signal(defaultValue) };
24
- const items = [];
25
- const itemValues = [];
26
- function selectItem(value) {
27
- state.value.value = value;
28
- for (let i = 0;i < items.length; i++) {
29
- const item = items[i];
30
- if (!item)
31
- continue;
32
- const isActive = itemValues[i] === value;
33
- setChecked(item, isActive);
34
- setDataState(item, isActive ? "checked" : "unchecked");
35
- }
36
- setRovingTabindex(items, itemValues.indexOf(value));
37
- onValueChange?.(value);
38
- }
39
- const root = (() => {
22
+ function RadioGroup(items, itemValues, selectItem) {
23
+ return (() => {
40
24
  const __el0 = __element("div");
41
25
  __el0.setAttribute("role", "radiogroup");
42
26
  {
@@ -57,48 +41,89 @@ function RadioRoot(options = {}) {
57
41
  });
58
42
  return __el0;
59
43
  })();
60
- function Item(value, label) {
61
- const isActive = value === state.value.peek();
62
- const item = (() => {
63
- const __el1 = __element("div");
64
- __el1.setAttribute("role", "radio");
65
- {
66
- const __v = uniqueId("radio");
67
- if (__v != null && __v !== false)
68
- __el1.setAttribute("id", __v === true ? "" : __v);
69
- }
70
- {
71
- const __v = value;
72
- if (__v != null && __v !== false)
73
- __el1.setAttribute("data-value", __v === true ? "" : __v);
74
- }
75
- {
76
- const __v = isActive ? "true" : "false";
77
- if (__v != null && __v !== false)
78
- __el1.setAttribute("aria-checked", __v === true ? "" : __v);
79
- }
80
- {
81
- const __v = isActive ? "checked" : "unchecked";
82
- if (__v != null && __v !== false)
83
- __el1.setAttribute("data-state", __v === true ? "" : __v);
84
- }
85
- __on(__el1, "click", () => {
44
+ }
45
+ function RadioItem(value, label, isActive, disabled, selectItem) {
46
+ const el = (() => {
47
+ const __el0 = __element("div");
48
+ __el0.setAttribute("role", "radio");
49
+ {
50
+ const __v = uniqueId("radio");
51
+ if (__v != null && __v !== false)
52
+ __el0.setAttribute("id", __v === true ? "" : __v);
53
+ }
54
+ {
55
+ const __v = value;
56
+ if (__v != null && __v !== false)
57
+ __el0.setAttribute("data-value", __v === true ? "" : __v);
58
+ }
59
+ {
60
+ const __v = isActive ? "true" : "false";
61
+ if (__v != null && __v !== false)
62
+ __el0.setAttribute("aria-checked", __v === true ? "" : __v);
63
+ }
64
+ {
65
+ const __v = isActive ? "checked" : "unchecked";
66
+ if (__v != null && __v !== false)
67
+ __el0.setAttribute("data-state", __v === true ? "" : __v);
68
+ }
69
+ __on(__el0, "click", () => {
70
+ if (!disabled)
86
71
  selectItem(value);
72
+ });
73
+ __enterChildren(__el0);
74
+ __insert(__el0, label ?? value);
75
+ __exitChildren();
76
+ return __el0;
77
+ })();
78
+ if (disabled) {
79
+ setDisabled(el, true);
80
+ el.setAttribute("data-disabled", "");
81
+ }
82
+ return el;
83
+ }
84
+ function RadioRoot(options = {}) {
85
+ const { defaultValue = "", onValueChange, ...attrs } = options;
86
+ const state = { value: signal(defaultValue) };
87
+ const items = [];
88
+ const itemValues = [];
89
+ function selectItem(value) {
90
+ state.value.value = value;
91
+ for (let i = 0;i < items.length; i++) {
92
+ const item = items[i];
93
+ if (!item)
94
+ continue;
95
+ const isActive = itemValues[i] === value;
96
+ setChecked(item, isActive);
97
+ setDataState(item, isActive ? "checked" : "unchecked");
98
+ }
99
+ setRovingTabindex(items, itemValues.indexOf(value));
100
+ onValueChange?.(value);
101
+ }
102
+ const root = RadioGroup(items, itemValues, selectItem);
103
+ const cleanups = [];
104
+ function Item(value, label, itemOptions) {
105
+ const isActive = value === state.value.peek();
106
+ const disabled = itemOptions?.disabled ?? false;
107
+ const item = RadioItem(value, label, isActive, disabled, selectItem);
108
+ const handleClick = () => {
109
+ if (!disabled)
87
110
  item.focus();
88
- });
89
- __enterChildren(__el1);
90
- __insert(__el1, label ?? value);
91
- __exitChildren();
92
- return __el1;
93
- })();
111
+ };
112
+ item.addEventListener("click", handleClick);
113
+ cleanups.push(() => item.removeEventListener("click", handleClick));
94
114
  items.push(item);
95
115
  itemValues.push(value);
96
116
  root.appendChild(item);
97
117
  setRovingTabindex(items, itemValues.indexOf(state.value.peek()));
98
118
  return item;
99
119
  }
120
+ function destroy() {
121
+ for (const cleanup of cleanups)
122
+ cleanup();
123
+ cleanups.length = 0;
124
+ }
100
125
  applyAttrs(root, attrs);
101
- return { root, state, Item };
126
+ return { root, state, Item, destroy };
102
127
  }
103
128
  var Radio = {
104
129
  Root: RadioRoot
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  Keys,
3
3
  isKey
4
- } from "./chunk-jctqs9m4.js";
4
+ } from "./chunk-7867pr13.js";
5
5
  import {
6
6
  setHidden
7
7
  } from "./chunk-vvjyx7fe.js";
8
- import {
9
- applyAttrs
10
- } from "./chunk-dpsgb1xw.js";
11
8
  import {
12
9
  uniqueId
13
10
  } from "./chunk-8y1jf6xr.js";
11
+ import {
12
+ applyAttrs
13
+ } from "./chunk-q8dm19a5.js";
14
14
 
15
15
  // src/command/command.tsx
16
16
  import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";