@vertz/ui-primitives 0.2.15 → 0.2.17

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 (109) hide show
  1. package/dist/shared/chunk-0mcr52hc.js +78 -0
  2. package/dist/shared/chunk-18y8gfk0.js +308 -0
  3. package/dist/shared/chunk-34yfm2b0.js +182 -0
  4. package/dist/shared/chunk-4085nbdq.js +196 -0
  5. package/dist/shared/chunk-4da5zksy.js +46 -0
  6. package/dist/shared/chunk-7ffg0caj.js +265 -0
  7. package/dist/shared/chunk-7kpsyjd7.js +61 -0
  8. package/dist/shared/chunk-7krvqrwq.js +177 -0
  9. package/dist/shared/chunk-8ak7vdk1.js +151 -0
  10. package/dist/shared/chunk-8nk0ya7a.js +163 -0
  11. package/dist/shared/chunk-8tvzqry6.js +218 -0
  12. package/dist/shared/chunk-8y1jf6xr.js +17 -0
  13. package/dist/shared/chunk-96d9nr7y.js +19 -0
  14. package/dist/shared/chunk-9hj9p7s2.js +95 -0
  15. package/dist/shared/chunk-a6wp8c32.js +32 -0
  16. package/dist/shared/chunk-avxcmmk6.js +178 -0
  17. package/dist/shared/chunk-bew4bjgf.js +165 -0
  18. package/dist/shared/chunk-dpsgb1xw.js +18 -0
  19. package/dist/shared/chunk-e2v1c9ex.js +62 -0
  20. package/dist/shared/chunk-g9qvd20g.js +133 -0
  21. package/dist/shared/chunk-gkddsbmh.js +73 -0
  22. package/dist/shared/chunk-gt0wth9h.js +128 -0
  23. package/dist/shared/chunk-hr9hx58m.js +71 -0
  24. package/dist/shared/chunk-j4cm8avr.js +175 -0
  25. package/dist/shared/chunk-jctqs9m4.js +60 -0
  26. package/dist/shared/chunk-jz0s6srh.js +161 -0
  27. package/dist/shared/chunk-kg27s15c.js +282 -0
  28. package/dist/shared/chunk-m1ptgp1s.js +142 -0
  29. package/dist/shared/chunk-n9nwx58j.js +60 -0
  30. package/dist/shared/chunk-ppcv3ehd.js +85 -0
  31. package/dist/shared/chunk-rnjm61t0.js +34 -0
  32. package/dist/shared/chunk-sqs8kyb2.js +288 -0
  33. package/dist/shared/chunk-t1vkvsz2.js +175 -0
  34. package/dist/shared/chunk-tfyg0qrp.js +117 -0
  35. package/dist/shared/chunk-ttsyf6ma.js +239 -0
  36. package/dist/shared/chunk-vvjyx7fe.js +62 -0
  37. package/dist/shared/chunk-x0we8gcy.js +219 -0
  38. package/dist/shared/chunk-x2hz98qn.js +108 -0
  39. package/dist/shared/chunk-yr9yzpvq.js +107 -0
  40. package/dist/src/accordion/accordion.d.ts +35 -0
  41. package/dist/src/accordion/accordion.js +10 -0
  42. package/dist/src/alert-dialog/alert-dialog.d.ts +26 -0
  43. package/dist/src/alert-dialog/alert-dialog.js +9 -0
  44. package/dist/src/badge/badge.d.ts +22 -0
  45. package/dist/src/badge/badge.js +8 -0
  46. package/dist/src/button/button.d.ts +20 -0
  47. package/dist/src/button/button.js +8 -0
  48. package/dist/src/calendar/calendar.d.ts +52 -0
  49. package/dist/src/calendar/calendar.js +7 -0
  50. package/dist/src/carousel/carousel.d.ts +39 -0
  51. package/dist/src/carousel/carousel.js +9 -0
  52. package/dist/src/checkbox/checkbox.d.ts +22 -0
  53. package/dist/src/checkbox/checkbox.js +9 -0
  54. package/dist/src/collapsible/collapsible.d.ts +33 -0
  55. package/dist/src/collapsible/collapsible.js +9 -0
  56. package/dist/src/combobox/combobox.d.ts +35 -0
  57. package/dist/src/combobox/combobox.js +10 -0
  58. package/dist/src/command/command.d.ts +41 -0
  59. package/dist/src/command/command.js +10 -0
  60. package/dist/src/context-menu/context-menu.d.ts +51 -0
  61. package/dist/src/context-menu/context-menu.js +12 -0
  62. package/dist/src/date-picker/date-picker.d.ts +47 -0
  63. package/dist/src/date-picker/date-picker.js +15 -0
  64. package/dist/src/dialog/dialog.d.ts +36 -0
  65. package/dist/src/dialog/dialog.js +11 -0
  66. package/dist/src/dropdown-menu/dropdown-menu.d.ts +54 -0
  67. package/dist/src/dropdown-menu/dropdown-menu.js +13 -0
  68. package/dist/src/hover-card/hover-card.d.ts +45 -0
  69. package/dist/src/hover-card/hover-card.js +11 -0
  70. package/dist/{index.d.ts → src/index.d.ts} +132 -140
  71. package/dist/src/index.js +137 -0
  72. package/dist/src/menu/menu.d.ts +51 -0
  73. package/dist/src/menu/menu.js +12 -0
  74. package/dist/src/menubar/menubar.d.ts +52 -0
  75. package/dist/src/menubar/menubar.js +13 -0
  76. package/dist/src/navigation-menu/navigation-menu.d.ts +37 -0
  77. package/dist/src/navigation-menu/navigation-menu.js +11 -0
  78. package/dist/src/popover/popover.d.ts +44 -0
  79. package/dist/src/popover/popover.js +13 -0
  80. package/dist/src/progress/progress.d.ts +32 -0
  81. package/dist/src/progress/progress.js +9 -0
  82. package/dist/src/radio/radio.d.ts +30 -0
  83. package/dist/src/radio/radio.js +11 -0
  84. package/dist/src/resizable-panel/resizable-panel.d.ts +36 -0
  85. package/dist/src/resizable-panel/resizable-panel.js +9 -0
  86. package/dist/src/scroll-area/scroll-area.d.ts +37 -0
  87. package/dist/src/scroll-area/scroll-area.js +7 -0
  88. package/dist/src/select/select.d.ts +53 -0
  89. package/dist/src/select/select.js +12 -0
  90. package/dist/src/sheet/sheet.d.ts +24 -0
  91. package/dist/src/sheet/sheet.js +10 -0
  92. package/dist/src/slider/slider.d.ts +36 -0
  93. package/dist/src/slider/slider.js +10 -0
  94. package/dist/src/switch/switch.d.ts +21 -0
  95. package/dist/src/switch/switch.js +9 -0
  96. package/dist/src/tabs/tabs.d.ts +35 -0
  97. package/dist/src/tabs/tabs.js +11 -0
  98. package/dist/src/toast/toast.d.ts +36 -0
  99. package/dist/src/toast/toast.js +9 -0
  100. package/dist/src/toggle/toggle.d.ts +21 -0
  101. package/dist/src/toggle/toggle.js +9 -0
  102. package/dist/src/toggle-group/toggle-group.d.ts +34 -0
  103. package/dist/src/toggle-group/toggle-group.js +10 -0
  104. package/dist/src/tooltip/tooltip.d.ts +44 -0
  105. package/dist/src/tooltip/tooltip.js +11 -0
  106. package/dist/src/utils.d.ts +176 -0
  107. package/dist/src/utils.js +72 -0
  108. package/package.json +12 -10
  109. package/dist/index.js +0 -3675
@@ -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 };
@@ -0,0 +1,175 @@
1
+ import {
2
+ Keys,
3
+ isKey
4
+ } from "./chunk-jctqs9m4.js";
5
+ import {
6
+ setDataState,
7
+ setValueRange
8
+ } from "./chunk-vvjyx7fe.js";
9
+ import {
10
+ applyAttrs
11
+ } from "./chunk-dpsgb1xw.js";
12
+
13
+ // src/resizable-panel/resizable-panel.tsx
14
+ import { __element, __on } from "@vertz/ui/internals";
15
+ import { signal } from "@vertz/ui";
16
+ function ResizablePanelRoot(options = {}) {
17
+ const { orientation = "horizontal", onResize, ...attrs } = options;
18
+ const state = { sizes: signal([]) };
19
+ const panels = [];
20
+ const handles = [];
21
+ function updateSizes(newSizes) {
22
+ state.sizes.value = [...newSizes];
23
+ for (let i = 0;i < panels.length; i++) {
24
+ const panel = panels[i];
25
+ if (!panel)
26
+ continue;
27
+ const size = newSizes[i] ?? 0;
28
+ panel.el.style.flex = `0 0 ${size}%`;
29
+ }
30
+ for (let i = 0;i < handles.length; i++) {
31
+ const handle = handles[i];
32
+ const leftPanel = panels[i];
33
+ if (handle && leftPanel) {
34
+ const size = newSizes[i] ?? 0;
35
+ setValueRange(handle, Math.round(size), Math.round(leftPanel.minSize), Math.round(leftPanel.maxSize));
36
+ }
37
+ }
38
+ onResize?.(newSizes);
39
+ }
40
+ const root = (() => {
41
+ const __el0 = __element("div");
42
+ {
43
+ const __v = `display: flex; flex-direction: ${orientation === "horizontal" ? "row" : "column"};`;
44
+ if (__v != null && __v !== false)
45
+ __el0.setAttribute("style", __v === true ? "" : __v);
46
+ }
47
+ {
48
+ const __v = orientation;
49
+ if (__v != null && __v !== false)
50
+ __el0.setAttribute("data-orientation", __v === true ? "" : __v);
51
+ }
52
+ return __el0;
53
+ })();
54
+ function Panel(panelOptions = {}) {
55
+ const { defaultSize, minSize = 0, maxSize = 100 } = panelOptions;
56
+ const el = (() => {
57
+ const __el1 = __element("div");
58
+ __el1.setAttribute("data-panel", "");
59
+ return __el1;
60
+ })();
61
+ panels.push({ el, minSize, maxSize });
62
+ const sizes = state.sizes.peek();
63
+ if (defaultSize != null) {
64
+ sizes.push(defaultSize);
65
+ } else {
66
+ const equalSize = 100 / panels.length;
67
+ sizes.length = 0;
68
+ for (let i = 0;i < panels.length; i++) {
69
+ sizes.push(equalSize);
70
+ }
71
+ }
72
+ updateSizes(sizes);
73
+ root.appendChild(el);
74
+ return el;
75
+ }
76
+ function Handle() {
77
+ const handleIndex = handles.length;
78
+ const handle = (() => {
79
+ const __el2 = __element("div");
80
+ __el2.setAttribute("role", "separator");
81
+ __el2.setAttribute("tabindex", "0");
82
+ {
83
+ const __v = orientation;
84
+ if (__v != null && __v !== false)
85
+ __el2.setAttribute("data-orientation", __v === true ? "" : __v);
86
+ }
87
+ __el2.setAttribute("data-state", "idle");
88
+ __on(__el2, "keydown", (event) => {
89
+ const sizes = [...state.sizes.peek()];
90
+ const leftIdx = handleIndex;
91
+ const rightIdx = handleIndex + 1;
92
+ const leftPanel = panels[leftIdx];
93
+ const rightPanel = panels[rightIdx];
94
+ if (!leftPanel || !rightPanel)
95
+ return;
96
+ let leftSize = sizes[leftIdx] ?? 0;
97
+ let rightSize = sizes[rightIdx] ?? 0;
98
+ const STEP = 5;
99
+ const growKey = orientation === "horizontal" ? Keys.ArrowRight : Keys.ArrowDown;
100
+ const shrinkKey = orientation === "horizontal" ? Keys.ArrowLeft : Keys.ArrowUp;
101
+ if (isKey(event, growKey)) {
102
+ event.preventDefault();
103
+ const delta = Math.min(STEP, rightSize - rightPanel.minSize, leftPanel.maxSize - leftSize);
104
+ leftSize += delta;
105
+ rightSize -= delta;
106
+ } else if (isKey(event, shrinkKey)) {
107
+ event.preventDefault();
108
+ const delta = Math.min(STEP, leftSize - leftPanel.minSize, rightPanel.maxSize - rightSize);
109
+ leftSize -= delta;
110
+ rightSize += delta;
111
+ } else if (isKey(event, Keys.Home)) {
112
+ event.preventDefault();
113
+ const delta = leftSize - leftPanel.minSize;
114
+ leftSize -= delta;
115
+ rightSize += delta;
116
+ } else if (isKey(event, Keys.End)) {
117
+ event.preventDefault();
118
+ const delta = rightSize - rightPanel.minSize;
119
+ leftSize += delta;
120
+ rightSize -= delta;
121
+ } else {
122
+ return;
123
+ }
124
+ sizes[leftIdx] = leftSize;
125
+ sizes[rightIdx] = rightSize;
126
+ updateSizes(sizes);
127
+ });
128
+ __on(__el2, "pointerdown", (event) => {
129
+ event.preventDefault();
130
+ handle.setPointerCapture(event.pointerId);
131
+ setDataState(handle, "dragging");
132
+ const startPos = orientation === "horizontal" ? event.clientX : event.clientY;
133
+ const rootSize = orientation === "horizontal" ? root.offsetWidth : root.offsetHeight;
134
+ const startSizes = [...state.sizes.peek()];
135
+ function onMove(e) {
136
+ const currentPos = orientation === "horizontal" ? e.clientX : e.clientY;
137
+ const delta = (currentPos - startPos) / rootSize * 100;
138
+ const sizes = [...startSizes];
139
+ const leftIdx = handleIndex;
140
+ const rightIdx = handleIndex + 1;
141
+ const leftPanel = panels[leftIdx];
142
+ const rightPanel = panels[rightIdx];
143
+ if (!leftPanel || !rightPanel)
144
+ return;
145
+ let newLeft = (startSizes[leftIdx] ?? 0) + delta;
146
+ let newRight = (startSizes[rightIdx] ?? 0) - delta;
147
+ newLeft = Math.max(leftPanel.minSize, Math.min(leftPanel.maxSize, newLeft));
148
+ newRight = Math.max(rightPanel.minSize, Math.min(rightPanel.maxSize, newRight));
149
+ sizes[leftIdx] = newLeft;
150
+ sizes[rightIdx] = newRight;
151
+ updateSizes(sizes);
152
+ }
153
+ function onUp(e) {
154
+ handle.releasePointerCapture(e.pointerId);
155
+ setDataState(handle, "idle");
156
+ handle.removeEventListener("pointermove", onMove);
157
+ handle.removeEventListener("pointerup", onUp);
158
+ }
159
+ handle.addEventListener("pointermove", onMove);
160
+ handle.addEventListener("pointerup", onUp);
161
+ });
162
+ return __el2;
163
+ })();
164
+ handles.push(handle);
165
+ root.appendChild(handle);
166
+ return handle;
167
+ }
168
+ applyAttrs(root, attrs);
169
+ return { root, state, Panel, Handle };
170
+ }
171
+ var ResizablePanel = {
172
+ Root: ResizablePanelRoot
173
+ };
174
+
175
+ export { ResizablePanel };
@@ -0,0 +1,60 @@
1
+ // src/utils/keyboard.ts
2
+ var Keys = {
3
+ Enter: "Enter",
4
+ Space: " ",
5
+ Escape: "Escape",
6
+ ArrowUp: "ArrowUp",
7
+ ArrowDown: "ArrowDown",
8
+ ArrowLeft: "ArrowLeft",
9
+ ArrowRight: "ArrowRight",
10
+ Home: "Home",
11
+ End: "End",
12
+ Tab: "Tab"
13
+ };
14
+ function isKey(event, ...keys) {
15
+ return keys.includes(event.key);
16
+ }
17
+ function handleListNavigation(event, items, options = {}) {
18
+ const { orientation = "vertical", loop = true } = options;
19
+ if (items.length === 0)
20
+ return null;
21
+ const prevKey = orientation === "vertical" ? Keys.ArrowUp : Keys.ArrowLeft;
22
+ const nextKey = orientation === "vertical" ? Keys.ArrowDown : Keys.ArrowRight;
23
+ const currentIndex = items.indexOf(document.activeElement);
24
+ let nextIndex = -1;
25
+ if (isKey(event, prevKey)) {
26
+ event.preventDefault();
27
+ if (currentIndex <= 0) {
28
+ nextIndex = loop ? items.length - 1 : 0;
29
+ } else {
30
+ nextIndex = currentIndex - 1;
31
+ }
32
+ } else if (isKey(event, nextKey)) {
33
+ event.preventDefault();
34
+ if (currentIndex >= items.length - 1) {
35
+ nextIndex = loop ? 0 : items.length - 1;
36
+ } else {
37
+ nextIndex = currentIndex + 1;
38
+ }
39
+ } else if (isKey(event, Keys.Home)) {
40
+ event.preventDefault();
41
+ nextIndex = 0;
42
+ } else if (isKey(event, Keys.End)) {
43
+ event.preventDefault();
44
+ nextIndex = items.length - 1;
45
+ }
46
+ const target = items[nextIndex];
47
+ if (target) {
48
+ target.focus();
49
+ return target;
50
+ }
51
+ return null;
52
+ }
53
+ function handleActivation(event, handler) {
54
+ if (isKey(event, Keys.Enter, Keys.Space)) {
55
+ event.preventDefault();
56
+ handler();
57
+ }
58
+ }
59
+
60
+ export { Keys, isKey, handleListNavigation, handleActivation };