@vertz/ui-primitives 0.2.16 → 0.2.18

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 (117) hide show
  1. package/dist/shared/chunk-18y8gfk0.js +308 -0
  2. package/dist/shared/chunk-4085nbdq.js +196 -0
  3. package/dist/shared/chunk-4da5zksy.js +46 -0
  4. package/dist/shared/chunk-7ffg0caj.js +265 -0
  5. package/dist/shared/{chunk-w06tst6x.js → chunk-7kpsyjd7.js} +9 -5
  6. package/dist/shared/chunk-7krvqrwq.js +177 -0
  7. package/dist/shared/chunk-8ak7vdk1.js +151 -0
  8. package/dist/shared/chunk-8nk0ya7a.js +163 -0
  9. package/dist/shared/chunk-8tvzqry6.js +218 -0
  10. package/dist/shared/{chunk-qpfqyrc5.js → chunk-96d9nr7y.js} +1 -1
  11. package/dist/shared/chunk-9hj9p7s2.js +95 -0
  12. package/dist/shared/chunk-avxcmmk6.js +178 -0
  13. package/dist/shared/chunk-bew4bjgf.js +165 -0
  14. package/dist/shared/chunk-dpsgb1xw.js +18 -0
  15. package/dist/shared/chunk-g9qvd20g.js +133 -0
  16. package/dist/shared/chunk-gkddsbmh.js +73 -0
  17. package/dist/shared/chunk-gt0wth9h.js +128 -0
  18. package/dist/shared/chunk-hr9hx58m.js +71 -0
  19. package/dist/shared/{chunk-n92bvn5d.js → chunk-j4cm8avr.js} +85 -59
  20. package/dist/shared/chunk-jz0s6srh.js +161 -0
  21. package/dist/shared/chunk-kg27s15c.js +282 -0
  22. package/dist/shared/chunk-m1ptgp1s.js +142 -0
  23. package/dist/shared/{chunk-9cqe2q6e.js → chunk-n9nwx58j.js} +9 -5
  24. package/dist/shared/chunk-ppcv3ehd.js +85 -0
  25. package/dist/shared/{chunk-vq9tfzh8.js → chunk-rnjm61t0.js} +5 -1
  26. package/dist/shared/chunk-sqs8kyb2.js +288 -0
  27. package/dist/shared/chunk-tfyg0qrp.js +117 -0
  28. package/dist/shared/chunk-ttsyf6ma.js +239 -0
  29. package/dist/shared/chunk-x0we8gcy.js +219 -0
  30. package/dist/shared/{chunk-6pnjrst7.js → chunk-x2hz98qn.js} +2 -2
  31. package/dist/shared/chunk-yr9yzpvq.js +107 -0
  32. package/dist/src/accordion/accordion.d.ts +14 -2
  33. package/dist/src/accordion/accordion.js +2 -1
  34. package/dist/src/badge/badge.d.ts +13 -1
  35. package/dist/src/badge/badge.js +2 -1
  36. package/dist/src/button/button.d.ts +16 -14
  37. package/dist/src/button/button.js +2 -2
  38. package/dist/src/calendar/calendar.d.ts +14 -2
  39. package/dist/src/calendar/calendar.js +2 -1
  40. package/dist/src/carousel/carousel.d.ts +14 -2
  41. package/dist/src/carousel/carousel.js +2 -1
  42. package/dist/src/checkbox/checkbox.d.ts +15 -13
  43. package/dist/src/checkbox/checkbox.js +2 -2
  44. package/dist/src/collapsible/collapsible.d.ts +14 -2
  45. package/dist/src/collapsible/collapsible.js +2 -1
  46. package/dist/src/combobox/combobox.d.ts +14 -2
  47. package/dist/src/combobox/combobox.js +2 -1
  48. package/dist/src/command/command.d.ts +14 -2
  49. package/dist/src/command/command.js +2 -1
  50. package/dist/src/context-menu/context-menu.d.ts +14 -2
  51. package/dist/src/context-menu/context-menu.js +2 -1
  52. package/dist/src/date-picker/date-picker.js +4 -3
  53. package/dist/src/dialog/dialog.d.ts +14 -2
  54. package/dist/src/dialog/dialog.js +2 -1
  55. package/dist/src/dropdown-menu/dropdown-menu.d.ts +13 -1
  56. package/dist/src/dropdown-menu/dropdown-menu.js +3 -2
  57. package/dist/src/hover-card/hover-card.d.ts +14 -2
  58. package/dist/src/hover-card/hover-card.js +2 -1
  59. package/dist/src/index.d.ts +132 -140
  60. package/dist/src/index.js +31 -30
  61. package/dist/src/menu/menu.d.ts +14 -2
  62. package/dist/src/menu/menu.js +2 -1
  63. package/dist/src/menubar/menubar.d.ts +14 -2
  64. package/dist/src/menubar/menubar.js +2 -1
  65. package/dist/src/navigation-menu/navigation-menu.d.ts +14 -2
  66. package/dist/src/navigation-menu/navigation-menu.js +2 -1
  67. package/dist/src/popover/popover.d.ts +14 -2
  68. package/dist/src/popover/popover.js +2 -1
  69. package/dist/src/progress/progress.d.ts +14 -2
  70. package/dist/src/progress/progress.js +2 -1
  71. package/dist/src/radio/radio.d.ts +14 -2
  72. package/dist/src/radio/radio.js +2 -1
  73. package/dist/src/resizable-panel/resizable-panel.d.ts +14 -2
  74. package/dist/src/resizable-panel/resizable-panel.js +2 -1
  75. package/dist/src/scroll-area/scroll-area.d.ts +14 -2
  76. package/dist/src/scroll-area/scroll-area.js +2 -1
  77. package/dist/src/select/select.d.ts +14 -2
  78. package/dist/src/select/select.js +2 -1
  79. package/dist/src/slider/slider.d.ts +14 -2
  80. package/dist/src/slider/slider.js +2 -1
  81. package/dist/src/switch/switch.d.ts +13 -1
  82. package/dist/src/switch/switch.js +2 -1
  83. package/dist/src/tabs/tabs.d.ts +14 -2
  84. package/dist/src/tabs/tabs.js +2 -1
  85. package/dist/src/toast/toast.d.ts +14 -2
  86. package/dist/src/toast/toast.js +2 -1
  87. package/dist/src/toggle/toggle.d.ts +13 -1
  88. package/dist/src/toggle/toggle.js +2 -1
  89. package/dist/src/toggle-group/toggle-group.d.ts +14 -2
  90. package/dist/src/toggle-group/toggle-group.js +2 -1
  91. package/dist/src/tooltip/tooltip.d.ts +14 -2
  92. package/dist/src/tooltip/tooltip.js +2 -1
  93. package/package.json +3 -3
  94. package/dist/shared/chunk-2h5qpc00.js +0 -98
  95. package/dist/shared/chunk-31yptvbf.js +0 -151
  96. package/dist/shared/chunk-3pantb0p.js +0 -108
  97. package/dist/shared/chunk-3s6s6f06.js +0 -61
  98. package/dist/shared/chunk-48v8j0vh.js +0 -267
  99. package/dist/shared/chunk-6dmt4513.js +0 -78
  100. package/dist/shared/chunk-6sqwjfg8.js +0 -169
  101. package/dist/shared/chunk-8qfeqrrz.js +0 -179
  102. package/dist/shared/chunk-bcfzteh0.js +0 -148
  103. package/dist/shared/chunk-cr9sbwns.js +0 -235
  104. package/dist/shared/chunk-cvbf1js1.js +0 -52
  105. package/dist/shared/chunk-dkhst4wv.js +0 -97
  106. package/dist/shared/chunk-e3aj5yw4.js +0 -115
  107. package/dist/shared/chunk-fv1y77tn.js +0 -225
  108. package/dist/shared/chunk-h42bk324.js +0 -58
  109. package/dist/shared/chunk-h9m9x5my.js +0 -119
  110. package/dist/shared/chunk-qq0e0gym.js +0 -73
  111. package/dist/shared/chunk-tk1k1bet.js +0 -93
  112. package/dist/shared/chunk-tvpgeswh.js +0 -216
  113. package/dist/shared/chunk-vcp10kne.js +0 -175
  114. package/dist/shared/chunk-ve006hmy.js +0 -51
  115. package/dist/shared/chunk-vx1ajy2z.js +0 -115
  116. package/dist/shared/chunk-wnttq0gv.js +0 -49
  117. package/dist/shared/chunk-x6qzr3g6.js +0 -100
@@ -0,0 +1,165 @@
1
+ import {
2
+ createFloatingPosition
3
+ } from "./chunk-0mcr52hc.js";
4
+ import {
5
+ Keys,
6
+ isKey
7
+ } from "./chunk-jctqs9m4.js";
8
+ import {
9
+ setDataState,
10
+ setExpanded,
11
+ setHidden,
12
+ setHiddenAnimated
13
+ } from "./chunk-vvjyx7fe.js";
14
+ import {
15
+ applyAttrs
16
+ } from "./chunk-dpsgb1xw.js";
17
+ import {
18
+ uniqueId
19
+ } from "./chunk-8y1jf6xr.js";
20
+
21
+ // src/hover-card/hover-card.tsx
22
+ import { __element, __on } from "@vertz/ui/internals";
23
+ import { signal } from "@vertz/ui";
24
+ function HoverCardRoot(options = {}) {
25
+ const { openDelay = 700, closeDelay = 300, onOpenChange, positioning, ...attrs } = options;
26
+ const contentId = uniqueId("hovercard");
27
+ const state = { open: signal(false) };
28
+ let openTimeout = null;
29
+ let closeTimeout = null;
30
+ let floatingCleanup = null;
31
+ function cancelTimers() {
32
+ if (openTimeout) {
33
+ clearTimeout(openTimeout);
34
+ openTimeout = null;
35
+ }
36
+ if (closeTimeout) {
37
+ clearTimeout(closeTimeout);
38
+ closeTimeout = null;
39
+ }
40
+ }
41
+ function cancelCloseTimer() {
42
+ if (closeTimeout) {
43
+ clearTimeout(closeTimeout);
44
+ closeTimeout = null;
45
+ }
46
+ }
47
+ function positionContent() {
48
+ if (positioning) {
49
+ floatingCleanup?.();
50
+ const effectivePlacement = positioning.placement ?? "bottom";
51
+ const result = createFloatingPosition(trigger, content, {
52
+ ...positioning,
53
+ placement: effectivePlacement
54
+ });
55
+ floatingCleanup = result.cleanup;
56
+ }
57
+ }
58
+ function show() {
59
+ cancelTimers();
60
+ if (state.open.peek())
61
+ return;
62
+ openTimeout = setTimeout(() => {
63
+ state.open.value = true;
64
+ setExpanded(trigger, true);
65
+ setHidden(content, false);
66
+ setDataState(content, "open");
67
+ positionContent();
68
+ onOpenChange?.(true);
69
+ openTimeout = null;
70
+ }, openDelay);
71
+ }
72
+ function showImmediate() {
73
+ cancelTimers();
74
+ state.open.value = true;
75
+ setExpanded(trigger, true);
76
+ setHidden(content, false);
77
+ setDataState(content, "open");
78
+ positionContent();
79
+ onOpenChange?.(true);
80
+ }
81
+ function hide() {
82
+ cancelTimers();
83
+ if (!state.open.peek())
84
+ return;
85
+ closeTimeout = setTimeout(() => {
86
+ state.open.value = false;
87
+ setExpanded(trigger, false);
88
+ setDataState(content, "closed");
89
+ setHiddenAnimated(content, true);
90
+ floatingCleanup?.();
91
+ floatingCleanup = null;
92
+ onOpenChange?.(false);
93
+ closeTimeout = null;
94
+ }, closeDelay);
95
+ }
96
+ function hideImmediate() {
97
+ cancelTimers();
98
+ state.open.value = false;
99
+ setExpanded(trigger, false);
100
+ setDataState(content, "closed");
101
+ setHiddenAnimated(content, true);
102
+ floatingCleanup?.();
103
+ floatingCleanup = null;
104
+ onOpenChange?.(false);
105
+ }
106
+ function handleTriggerBlur(event) {
107
+ const related = event.relatedTarget;
108
+ if (related && (trigger.contains(related) || content.contains(related)))
109
+ return;
110
+ hide();
111
+ }
112
+ function handleTriggerKeydown(event) {
113
+ if (isKey(event, Keys.Escape) && state.open.peek()) {
114
+ hideImmediate();
115
+ }
116
+ }
117
+ function handleContentFocusout(event) {
118
+ const related = event.relatedTarget;
119
+ if (related && (trigger.contains(related) || content.contains(related)))
120
+ return;
121
+ hide();
122
+ }
123
+ function handleContentKeydown(event) {
124
+ if (isKey(event, Keys.Escape)) {
125
+ hideImmediate();
126
+ trigger.focus();
127
+ }
128
+ }
129
+ const trigger = (() => {
130
+ const __el0 = __element("span");
131
+ __el0.setAttribute("aria-haspopup", "dialog");
132
+ __el0.setAttribute("aria-expanded", "false");
133
+ __on(__el0, "mouseenter", show);
134
+ __on(__el0, "mouseleave", hide);
135
+ __on(__el0, "focus", showImmediate);
136
+ __on(__el0, "blur", handleTriggerBlur);
137
+ __on(__el0, "keydown", handleTriggerKeydown);
138
+ return __el0;
139
+ })();
140
+ const content = (() => {
141
+ const __el1 = __element("div");
142
+ __el1.setAttribute("role", "dialog");
143
+ {
144
+ const __v = contentId;
145
+ if (__v != null && __v !== false)
146
+ __el1.setAttribute("id", __v === true ? "" : __v);
147
+ }
148
+ __el1.setAttribute("aria-hidden", "true");
149
+ __el1.setAttribute("data-state", "closed");
150
+ __el1.setAttribute("style", "display: none");
151
+ __on(__el1, "mouseenter", cancelCloseTimer);
152
+ __on(__el1, "mouseleave", hide);
153
+ __on(__el1, "focusin", cancelCloseTimer);
154
+ __on(__el1, "focusout", handleContentFocusout);
155
+ __on(__el1, "keydown", handleContentKeydown);
156
+ return __el1;
157
+ })();
158
+ applyAttrs(trigger, attrs);
159
+ return { trigger, content, state };
160
+ }
161
+ var HoverCard = {
162
+ Root: HoverCardRoot
163
+ };
164
+
165
+ export { HoverCard };
@@ -0,0 +1,18 @@
1
+ // src/utils/attrs.ts
2
+ function applyAttrs(el, attrs) {
3
+ for (const [key, value] of Object.entries(attrs)) {
4
+ if (value == null)
5
+ continue;
6
+ if (key === "class") {
7
+ const existing = el.getAttribute("class");
8
+ el.setAttribute("class", existing ? `${existing} ${String(value)}` : String(value));
9
+ } else if (key === "style") {
10
+ const existing = el.getAttribute("style");
11
+ el.setAttribute("style", existing ? `${existing}; ${String(value)}` : String(value));
12
+ } else {
13
+ el.setAttribute(key, String(value));
14
+ }
15
+ }
16
+ }
17
+
18
+ export { applyAttrs };
@@ -0,0 +1,133 @@
1
+ import {
2
+ Keys,
3
+ isKey
4
+ } from "./chunk-jctqs9m4.js";
5
+ import {
6
+ setDataState
7
+ } from "./chunk-vvjyx7fe.js";
8
+ import {
9
+ applyAttrs
10
+ } from "./chunk-dpsgb1xw.js";
11
+
12
+ // src/carousel/carousel.tsx
13
+ import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
14
+ import { signal } from "@vertz/ui";
15
+ function CarouselRoot(options = {}) {
16
+ const {
17
+ orientation = "horizontal",
18
+ loop = false,
19
+ defaultIndex = 0,
20
+ onSlideChange,
21
+ ...attrs
22
+ } = options;
23
+ const state = {
24
+ currentIndex: signal(defaultIndex),
25
+ slideCount: signal(0)
26
+ };
27
+ const slides = [];
28
+ function updateSlideVisibility() {
29
+ const current = state.currentIndex.peek();
30
+ for (let i = 0;i < slides.length; i++) {
31
+ const slide = slides[i];
32
+ if (!slide)
33
+ continue;
34
+ slide.setAttribute("aria-hidden", String(i !== current));
35
+ slide.setAttribute("aria-label", `Slide ${i + 1} of ${slides.length}`);
36
+ setDataState(slide, i === current ? "active" : "inactive");
37
+ }
38
+ if (!loop) {
39
+ prevButton.disabled = current <= 0;
40
+ nextButton.disabled = current >= slides.length - 1;
41
+ }
42
+ const translateProp = orientation === "horizontal" ? "translateX" : "translateY";
43
+ viewport.style.transform = `${translateProp}(-${current * 100}%)`;
44
+ }
45
+ function goTo(index) {
46
+ const total = slides.length;
47
+ if (total === 0)
48
+ return;
49
+ let next = index;
50
+ if (loop) {
51
+ next = (index % total + total) % total;
52
+ } else {
53
+ next = Math.max(0, Math.min(total - 1, index));
54
+ }
55
+ if (next === state.currentIndex.peek())
56
+ return;
57
+ state.currentIndex.value = next;
58
+ updateSlideVisibility();
59
+ onSlideChange?.(next);
60
+ }
61
+ function goNext() {
62
+ goTo(state.currentIndex.peek() + 1);
63
+ }
64
+ function goPrev() {
65
+ goTo(state.currentIndex.peek() - 1);
66
+ }
67
+ const viewport = (() => {
68
+ const __el0 = __element("div");
69
+ __el0.setAttribute("style", "overflow: hidden;");
70
+ return __el0;
71
+ })();
72
+ const prevButton = (() => {
73
+ const __el1 = __element("button");
74
+ __el1.setAttribute("type", "button");
75
+ __el1.setAttribute("aria-label", "Previous slide");
76
+ __on(__el1, "click", goPrev);
77
+ return __el1;
78
+ })();
79
+ const nextButton = (() => {
80
+ const __el2 = __element("button");
81
+ __el2.setAttribute("type", "button");
82
+ __el2.setAttribute("aria-label", "Next slide");
83
+ __on(__el2, "click", goNext);
84
+ return __el2;
85
+ })();
86
+ const root = (() => {
87
+ const __el3 = __element("div");
88
+ __el3.setAttribute("role", "region");
89
+ __el3.setAttribute("aria-roledescription", "carousel");
90
+ {
91
+ const __v = orientation;
92
+ if (__v != null && __v !== false)
93
+ __el3.setAttribute("data-orientation", __v === true ? "" : __v);
94
+ }
95
+ __on(__el3, "keydown", (event) => {
96
+ const prevKey = orientation === "horizontal" ? Keys.ArrowLeft : Keys.ArrowUp;
97
+ const nextKey = orientation === "horizontal" ? Keys.ArrowRight : Keys.ArrowDown;
98
+ if (isKey(event, prevKey)) {
99
+ event.preventDefault();
100
+ goPrev();
101
+ }
102
+ if (isKey(event, nextKey)) {
103
+ event.preventDefault();
104
+ goNext();
105
+ }
106
+ });
107
+ __enterChildren(__el3);
108
+ __insert(__el3, viewport);
109
+ __exitChildren();
110
+ return __el3;
111
+ })();
112
+ function Slide() {
113
+ const slide = (() => {
114
+ const __el4 = __element("div");
115
+ __el4.setAttribute("role", "group");
116
+ __el4.setAttribute("aria-roledescription", "slide");
117
+ return __el4;
118
+ })();
119
+ slides.push(slide);
120
+ state.slideCount.value = slides.length;
121
+ viewport.appendChild(slide);
122
+ updateSlideVisibility();
123
+ return slide;
124
+ }
125
+ updateSlideVisibility();
126
+ applyAttrs(root, attrs);
127
+ return { root, viewport, prevButton, nextButton, state, Slide, goTo, goNext, goPrev };
128
+ }
129
+ var Carousel = {
130
+ Root: CarouselRoot
131
+ };
132
+
133
+ export { Carousel };
@@ -0,0 +1,73 @@
1
+ import {
2
+ setDataState
3
+ } from "./chunk-vvjyx7fe.js";
4
+ import {
5
+ applyAttrs
6
+ } from "./chunk-dpsgb1xw.js";
7
+ import {
8
+ uniqueId
9
+ } from "./chunk-8y1jf6xr.js";
10
+
11
+ // src/toast/toast.tsx
12
+ import { __element, __enterChildren, __exitChildren, __insert } from "@vertz/ui/internals";
13
+ import { signal } from "@vertz/ui";
14
+ function ToastRoot(options = {}) {
15
+ const { duration = 5000, politeness = "polite", ...attrs } = options;
16
+ const state = { messages: signal([]) };
17
+ const region = (() => {
18
+ const __el0 = __element("div");
19
+ __el0.setAttribute("role", "status");
20
+ {
21
+ const __v = politeness;
22
+ if (__v != null && __v !== false)
23
+ __el0.setAttribute("aria-live", __v === true ? "" : __v);
24
+ }
25
+ __el0.setAttribute("aria-atomic", "false");
26
+ __el0.setAttribute("data-state", "empty");
27
+ return __el0;
28
+ })();
29
+ applyAttrs(region, attrs);
30
+ function announce(content) {
31
+ const id = uniqueId("toast");
32
+ const el = (() => {
33
+ const __el1 = __element("div");
34
+ __el1.setAttribute("role", "status");
35
+ {
36
+ const __v = id;
37
+ if (__v != null && __v !== false)
38
+ __el1.setAttribute("data-toast-id", __v === true ? "" : __v);
39
+ }
40
+ __el1.setAttribute("data-state", "open");
41
+ __enterChildren(__el1);
42
+ __insert(__el1, content);
43
+ __exitChildren();
44
+ return __el1;
45
+ })();
46
+ const msg = { id, content, el };
47
+ state.messages.value = [...state.messages.peek(), msg];
48
+ region.appendChild(el);
49
+ setDataState(region, "active");
50
+ if (duration > 0) {
51
+ setTimeout(() => dismiss(id), duration);
52
+ }
53
+ return msg;
54
+ }
55
+ function dismiss(id) {
56
+ const messages = state.messages.peek().filter((m) => m.id !== id);
57
+ state.messages.value = messages;
58
+ const el = region.querySelector(`[data-toast-id="${id}"]`);
59
+ if (el) {
60
+ setDataState(el, "closed");
61
+ el.remove();
62
+ }
63
+ if (messages.length === 0) {
64
+ setDataState(region, "empty");
65
+ }
66
+ }
67
+ return { region, state, announce, dismiss };
68
+ }
69
+ var Toast = {
70
+ Root: ToastRoot
71
+ };
72
+
73
+ export { Toast };
@@ -0,0 +1,128 @@
1
+ import {
2
+ setRovingTabindex
3
+ } from "./chunk-e2v1c9ex.js";
4
+ import {
5
+ Keys,
6
+ handleListNavigation,
7
+ isKey
8
+ } from "./chunk-jctqs9m4.js";
9
+ import {
10
+ setDataState,
11
+ setPressed
12
+ } from "./chunk-vvjyx7fe.js";
13
+ import {
14
+ applyAttrs
15
+ } from "./chunk-dpsgb1xw.js";
16
+
17
+ // src/toggle-group/toggle-group.tsx
18
+ import { __element, __on } from "@vertz/ui/internals";
19
+ import { signal } from "@vertz/ui";
20
+ function ToggleGroupRoot(options = {}) {
21
+ const {
22
+ type = "single",
23
+ defaultValue = [],
24
+ orientation = "horizontal",
25
+ disabled = false,
26
+ onValueChange,
27
+ ...attrs
28
+ } = options;
29
+ const state = {
30
+ value: signal([...defaultValue]),
31
+ disabled: signal(disabled)
32
+ };
33
+ const items = [];
34
+ function toggleValue(itemValue) {
35
+ if (state.disabled.peek())
36
+ return;
37
+ const current = [...state.value.peek()];
38
+ const idx = current.indexOf(itemValue);
39
+ if (type === "single") {
40
+ if (idx >= 0) {
41
+ current.length = 0;
42
+ } else {
43
+ current.length = 0;
44
+ current.push(itemValue);
45
+ }
46
+ } else {
47
+ if (idx >= 0) {
48
+ current.splice(idx, 1);
49
+ } else {
50
+ current.push(itemValue);
51
+ }
52
+ }
53
+ state.value.value = current;
54
+ onValueChange?.(current);
55
+ for (const item of items) {
56
+ const val = item.getAttribute("data-value") ?? "";
57
+ const isOn = current.includes(val);
58
+ setPressed(item, isOn);
59
+ setDataState(item, isOn ? "on" : "off");
60
+ }
61
+ }
62
+ const root = (() => {
63
+ const __el0 = __element("div");
64
+ __el0.setAttribute("role", "group");
65
+ {
66
+ const __v = orientation;
67
+ if (__v != null && __v !== false)
68
+ __el0.setAttribute("data-orientation", __v === true ? "" : __v);
69
+ }
70
+ __on(__el0, "keydown", (event) => {
71
+ if (isKey(event, Keys.ArrowLeft, Keys.ArrowRight, Keys.ArrowUp, Keys.ArrowDown, Keys.Home, Keys.End)) {
72
+ const result = handleListNavigation(event, items, { orientation });
73
+ if (result) {
74
+ const idx = items.indexOf(result);
75
+ if (idx >= 0) {
76
+ setRovingTabindex(items, idx);
77
+ }
78
+ }
79
+ }
80
+ });
81
+ return __el0;
82
+ })();
83
+ function Item(value) {
84
+ const isOn = state.value.peek().includes(value);
85
+ const item = (() => {
86
+ const __el1 = __element("button");
87
+ __el1.setAttribute("type", "button");
88
+ {
89
+ const __v = value;
90
+ if (__v != null && __v !== false)
91
+ __el1.setAttribute("data-value", __v === true ? "" : __v);
92
+ }
93
+ {
94
+ const __v = isOn ? "true" : "false";
95
+ if (__v != null && __v !== false)
96
+ __el1.setAttribute("aria-pressed", __v === true ? "" : __v);
97
+ }
98
+ {
99
+ const __v = isOn ? "on" : "off";
100
+ if (__v != null && __v !== false)
101
+ __el1.setAttribute("data-state", __v === true ? "" : __v);
102
+ }
103
+ {
104
+ const __v = state.disabled.peek();
105
+ if (__v != null && __v !== false)
106
+ __el1.setAttribute("disabled", __v === true ? "" : __v);
107
+ }
108
+ {
109
+ const __v = state.disabled.peek() ? "true" : undefined;
110
+ if (__v != null && __v !== false)
111
+ __el1.setAttribute("aria-disabled", __v === true ? "" : __v);
112
+ }
113
+ __on(__el1, "click", () => toggleValue(value));
114
+ return __el1;
115
+ })();
116
+ items.push(item);
117
+ setRovingTabindex(items, 0);
118
+ root.appendChild(item);
119
+ return item;
120
+ }
121
+ applyAttrs(root, attrs);
122
+ return { root, state, Item };
123
+ }
124
+ var ToggleGroup = {
125
+ Root: ToggleGroupRoot
126
+ };
127
+
128
+ export { ToggleGroup };
@@ -0,0 +1,71 @@
1
+ import {
2
+ Keys,
3
+ isKey
4
+ } from "./chunk-jctqs9m4.js";
5
+ import {
6
+ applyAttrs
7
+ } from "./chunk-dpsgb1xw.js";
8
+ import {
9
+ uniqueId
10
+ } from "./chunk-8y1jf6xr.js";
11
+
12
+ // src/checkbox/checkbox.tsx
13
+ import { computed, signal } from "@vertz/ui";
14
+ import { __attr, __element, __on } from "@vertz/ui/internals";
15
+ function dataStateFor(checked) {
16
+ if (checked === "mixed")
17
+ return "indeterminate";
18
+ return checked ? "checked" : "unchecked";
19
+ }
20
+ function ariaCheckedFor(checked) {
21
+ if (checked === "mixed")
22
+ return "mixed";
23
+ return String(checked);
24
+ }
25
+ function CheckboxRoot(options = {}) {
26
+ const { defaultChecked = false, disabled = false, onCheckedChange, ...attrs } = options;
27
+ const checked = signal(defaultChecked, "checked");
28
+ function toggle() {
29
+ if (disabled)
30
+ return;
31
+ checked.value = checked.value === "mixed" ? true : !checked.value;
32
+ onCheckedChange?.(checked.value);
33
+ }
34
+ const el = computed(() => (() => {
35
+ const __el0 = __element("button");
36
+ __el0.setAttribute("type", "button");
37
+ __el0.setAttribute("role", "checkbox");
38
+ {
39
+ const __v = uniqueId("checkbox");
40
+ if (__v != null && __v !== false)
41
+ __el0.setAttribute("id", __v === true ? "" : __v);
42
+ }
43
+ __attr(__el0, "aria-checked", () => ariaCheckedFor(checked.value));
44
+ __attr(__el0, "data-state", () => dataStateFor(checked.value));
45
+ {
46
+ const __v = disabled;
47
+ if (__v != null && __v !== false)
48
+ __el0.setAttribute("disabled", __v === true ? "" : __v);
49
+ }
50
+ {
51
+ const __v = disabled ? "true" : undefined;
52
+ if (__v != null && __v !== false)
53
+ __el0.setAttribute("aria-disabled", __v === true ? "" : __v);
54
+ }
55
+ __on(__el0, "click", toggle);
56
+ __on(__el0, "keydown", (e) => {
57
+ if (isKey(e, Keys.Space)) {
58
+ e.preventDefault();
59
+ toggle();
60
+ }
61
+ });
62
+ return __el0;
63
+ })());
64
+ applyAttrs(el.value, attrs);
65
+ return el.value;
66
+ }
67
+ var Checkbox = {
68
+ Root: CheckboxRoot
69
+ };
70
+
71
+ export { Checkbox };