@vertz/ui-primitives 0.2.21 → 0.2.23

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 (97) hide show
  1. package/dist/shared/{chunk-q8dm19a5.js → chunk-2db2dnp3.js} +0 -1
  2. package/dist/shared/chunk-3h1mxp95.js +148 -0
  3. package/dist/shared/chunk-3kwh27dv.js +135 -0
  4. package/dist/shared/chunk-4894pmy6.js +184 -0
  5. package/dist/shared/{chunk-v9qddmh9.js → chunk-56reyd5r.js} +20 -29
  6. package/dist/shared/chunk-67sn29eh.js +125 -0
  7. package/dist/shared/chunk-7cb3z0s8.js +287 -0
  8. package/dist/shared/chunk-8c01c8mb.js +217 -0
  9. package/dist/shared/chunk-99tk72t3.js +69 -0
  10. package/dist/shared/chunk-9gfp3ffv.js +204 -0
  11. package/dist/shared/chunk-b25npqer.js +149 -0
  12. package/dist/shared/chunk-cgb2j94g.js +141 -0
  13. package/dist/shared/chunk-e1jcf22s.js +79 -0
  14. package/dist/shared/chunk-e3h0ddmx.js +168 -0
  15. package/dist/shared/chunk-f2vx4tpw.js +168 -0
  16. package/dist/shared/chunk-h3v10x04.js +271 -0
  17. package/dist/shared/chunk-hdvdfd1c.js +96 -0
  18. package/dist/shared/{chunk-zf0rhm9e.js → chunk-j902w020.js} +1 -1
  19. package/dist/shared/chunk-jdygp28a.js +260 -0
  20. package/dist/shared/chunk-jqre4qtw.js +180 -0
  21. package/dist/shared/{chunk-pvy0tcd7.js → chunk-mgr904ap.js} +75 -35
  22. package/dist/shared/chunk-mr1tb0dp.js +167 -0
  23. package/dist/shared/chunk-nj420k31.js +54 -0
  24. package/dist/shared/chunk-p0x7hgv6.js +181 -0
  25. package/dist/shared/{chunk-gzgyfhz6.js → chunk-pn6shbcs.js} +134 -82
  26. package/dist/shared/chunk-pzx0vpq1.js +223 -0
  27. package/dist/shared/chunk-tn0m98j8.js +42 -0
  28. package/dist/shared/{chunk-g67tnd19.js → chunk-ttb2tt03.js} +49 -29
  29. package/dist/shared/{chunk-vvjyx7fe.js → chunk-vevfhpc9.js} +1 -1
  30. package/dist/shared/chunk-vy874zxe.js +68 -0
  31. package/dist/shared/chunk-ww7k2azn.js +297 -0
  32. package/dist/shared/{chunk-f501vw7e.js → chunk-xa1b96mb.js} +2 -2
  33. package/dist/shared/chunk-xs6gp369.js +245 -0
  34. package/dist/shared/chunk-y4mmmayp.js +206 -0
  35. package/dist/src/accordion/accordion.js +1 -1
  36. package/dist/src/alert-dialog/alert-dialog.js +1 -1
  37. package/dist/src/badge/badge.js +1 -1
  38. package/dist/src/button/button.js +1 -1
  39. package/dist/src/calendar/calendar.js +1 -1
  40. package/dist/src/carousel/carousel.js +1 -1
  41. package/dist/src/checkbox/checkbox.js +1 -1
  42. package/dist/src/collapsible/collapsible.js +1 -1
  43. package/dist/src/combobox/combobox.js +1 -1
  44. package/dist/src/command/command.js +1 -1
  45. package/dist/src/context-menu/context-menu.js +1 -1
  46. package/dist/src/date-picker/date-picker.js +1 -1
  47. package/dist/src/dialog/dialog.js +1 -1
  48. package/dist/src/dropdown-menu/dropdown-menu.js +1 -1
  49. package/dist/src/hover-card/hover-card.js +1 -1
  50. package/dist/src/index.d.ts +281 -106
  51. package/dist/src/index.js +5779 -4266
  52. package/dist/src/menu/menu.js +1 -1
  53. package/dist/src/menubar/menubar.js +1 -1
  54. package/dist/src/navigation-menu/navigation-menu.js +1 -1
  55. package/dist/src/popover/popover.js +1 -1
  56. package/dist/src/progress/progress.js +1 -1
  57. package/dist/src/radio/radio.js +1 -1
  58. package/dist/src/resizable-panel/resizable-panel.js +1 -1
  59. package/dist/src/scroll-area/scroll-area.js +1 -1
  60. package/dist/src/select/select.js +1 -1
  61. package/dist/src/sheet/sheet.js +1 -1
  62. package/dist/src/slider/slider.js +1 -1
  63. package/dist/src/switch/switch.js +1 -1
  64. package/dist/src/tabs/tabs.js +1 -1
  65. package/dist/src/toast/toast.js +1 -1
  66. package/dist/src/toggle/toggle.js +1 -1
  67. package/dist/src/toggle-group/toggle-group.js +1 -1
  68. package/dist/src/tooltip/tooltip.js +1 -1
  69. package/dist/src/utils.d.ts +1 -1
  70. package/dist/src/utils.js +3 -3
  71. package/package.json +3 -3
  72. package/dist/shared/chunk-0gn67thm.js +0 -88
  73. package/dist/shared/chunk-1dzcjmfq.js +0 -46
  74. package/dist/shared/chunk-1hv9yd28.js +0 -178
  75. package/dist/shared/chunk-2d05qxdw.js +0 -282
  76. package/dist/shared/chunk-4jnweh3m.js +0 -165
  77. package/dist/shared/chunk-90hmpm0w.js +0 -34
  78. package/dist/shared/chunk-ac86qw7a.js +0 -71
  79. package/dist/shared/chunk-b02fkvts.js +0 -128
  80. package/dist/shared/chunk-bsx59bv9.js +0 -61
  81. package/dist/shared/chunk-cm2akzrm.js +0 -161
  82. package/dist/shared/chunk-cvms20w3.js +0 -132
  83. package/dist/shared/chunk-d8n8mggh.js +0 -239
  84. package/dist/shared/chunk-er9625ar.js +0 -204
  85. package/dist/shared/chunk-ewxzhtej.js +0 -117
  86. package/dist/shared/chunk-ey4485fh.js +0 -196
  87. package/dist/shared/chunk-gbxbkmte.js +0 -175
  88. package/dist/shared/chunk-je7tqf67.js +0 -133
  89. package/dist/shared/chunk-kr5qg80z.js +0 -288
  90. package/dist/shared/chunk-kytkmdpc.js +0 -199
  91. package/dist/shared/chunk-q2q20y9a.js +0 -60
  92. package/dist/shared/chunk-q9fgfgh9.js +0 -267
  93. package/dist/shared/chunk-qfk1ycfw.js +0 -142
  94. package/dist/shared/chunk-te4pdqnh.js +0 -219
  95. package/dist/shared/chunk-vm37m55w.js +0 -175
  96. package/dist/shared/chunk-y5vdb6br.js +0 -151
  97. package/dist/shared/chunk-ztvj60xp.js +0 -185
@@ -1,204 +0,0 @@
1
- import {
2
- saveFocus,
3
- trapFocus
4
- } from "./chunk-e2v1c9ex.js";
5
- import {
6
- setDataState,
7
- setExpanded,
8
- setHidden,
9
- setHiddenAnimated
10
- } from "./chunk-vvjyx7fe.js";
11
- import {
12
- linkedIds
13
- } from "./chunk-8y1jf6xr.js";
14
-
15
- // src/alert-dialog/alert-dialog.tsx
16
- import { __element, __on, __styleStr } from "@vertz/ui/internals";
17
- import { signal } from "@vertz/ui";
18
- function AlertDialogTriggerEl(triggerId, contentId, defaultOpen, onClick) {
19
- return (() => {
20
- const __el0 = __element("button");
21
- __el0.setAttribute("type", "button");
22
- {
23
- const __v = triggerId;
24
- if (__v != null && __v !== false)
25
- __el0.setAttribute("id", __v === true ? "" : __v);
26
- }
27
- {
28
- const __v = contentId;
29
- if (__v != null && __v !== false)
30
- __el0.setAttribute("aria-controls", __v === true ? "" : __v);
31
- }
32
- {
33
- const __v = defaultOpen ? "true" : "false";
34
- if (__v != null && __v !== false)
35
- __el0.setAttribute("aria-expanded", __v === true ? "" : __v);
36
- }
37
- {
38
- const __v = defaultOpen ? "open" : "closed";
39
- if (__v != null && __v !== false)
40
- __el0.setAttribute("data-state", __v === true ? "" : __v);
41
- }
42
- __on(__el0, "click", onClick);
43
- return __el0;
44
- })();
45
- }
46
- function AlertDialogOverlayEl(defaultOpen) {
47
- return (() => {
48
- const __el0 = __element("div");
49
- __el0.setAttribute("data-alertdialog-overlay", "");
50
- {
51
- const __v = defaultOpen ? "false" : "true";
52
- if (__v != null && __v !== false)
53
- __el0.setAttribute("aria-hidden", __v === true ? "" : __v);
54
- }
55
- {
56
- const __v = defaultOpen ? "open" : "closed";
57
- if (__v != null && __v !== false)
58
- __el0.setAttribute("data-state", __v === true ? "" : __v);
59
- }
60
- {
61
- const __v = defaultOpen ? "" : "display: none";
62
- if (__v != null && __v !== false)
63
- __el0.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
64
- }
65
- return __el0;
66
- })();
67
- }
68
- function AlertDialogContentEl(contentId, titleId, descriptionId, defaultOpen) {
69
- return (() => {
70
- const __el0 = __element("div");
71
- __el0.setAttribute("role", "alertdialog");
72
- {
73
- const __v = contentId;
74
- if (__v != null && __v !== false)
75
- __el0.setAttribute("id", __v === true ? "" : __v);
76
- }
77
- __el0.setAttribute("aria-modal", "true");
78
- {
79
- const __v = titleId;
80
- if (__v != null && __v !== false)
81
- __el0.setAttribute("aria-labelledby", __v === true ? "" : __v);
82
- }
83
- {
84
- const __v = descriptionId;
85
- if (__v != null && __v !== false)
86
- __el0.setAttribute("aria-describedby", __v === true ? "" : __v);
87
- }
88
- {
89
- const __v = defaultOpen ? "false" : "true";
90
- if (__v != null && __v !== false)
91
- __el0.setAttribute("aria-hidden", __v === true ? "" : __v);
92
- }
93
- {
94
- const __v = defaultOpen ? "open" : "closed";
95
- if (__v != null && __v !== false)
96
- __el0.setAttribute("data-state", __v === true ? "" : __v);
97
- }
98
- {
99
- const __v = defaultOpen ? "" : "display: none";
100
- if (__v != null && __v !== false)
101
- __el0.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
102
- }
103
- return __el0;
104
- })();
105
- }
106
- function AlertDialogTitleEl(titleId) {
107
- return (() => {
108
- const __el0 = __element("h2");
109
- {
110
- const __v = titleId;
111
- if (__v != null && __v !== false)
112
- __el0.setAttribute("id", __v === true ? "" : __v);
113
- }
114
- return __el0;
115
- })();
116
- }
117
- function AlertDialogDescriptionEl(descriptionId) {
118
- return (() => {
119
- const __el0 = __element("p");
120
- {
121
- const __v = descriptionId;
122
- if (__v != null && __v !== false)
123
- __el0.setAttribute("id", __v === true ? "" : __v);
124
- }
125
- return __el0;
126
- })();
127
- }
128
- function AlertDialogCancelBtn(onClick) {
129
- return (() => {
130
- const __el0 = __element("button");
131
- __el0.setAttribute("type", "button");
132
- __on(__el0, "click", onClick);
133
- return __el0;
134
- })();
135
- }
136
- function AlertDialogActionBtn(onClick) {
137
- return (() => {
138
- const __el0 = __element("button");
139
- __el0.setAttribute("type", "button");
140
- __on(__el0, "click", onClick);
141
- return __el0;
142
- })();
143
- }
144
- function AlertDialogRoot(options = {}) {
145
- const { defaultOpen = false, onOpenChange, onAction } = options;
146
- const ids = linkedIds("alertdialog");
147
- const titleId = `${ids.contentId}-title`;
148
- const descriptionId = `${ids.contentId}-description`;
149
- const state = { open: signal(defaultOpen) };
150
- let restoreFocus = null;
151
- let removeTrap = null;
152
- function show() {
153
- if (state.open.peek())
154
- return;
155
- state.open.value = true;
156
- setExpanded(trigger, true);
157
- setHidden(overlay, false);
158
- setHidden(content, false);
159
- setDataState(trigger, "open");
160
- setDataState(overlay, "open");
161
- setDataState(content, "open");
162
- restoreFocus = saveFocus();
163
- removeTrap = trapFocus(content);
164
- queueMicrotask(() => cancel.focus());
165
- onOpenChange?.(true);
166
- }
167
- function hide() {
168
- if (!state.open.peek())
169
- return;
170
- state.open.value = false;
171
- setExpanded(trigger, false);
172
- setDataState(trigger, "closed");
173
- setDataState(overlay, "closed");
174
- setDataState(content, "closed");
175
- setHiddenAnimated(overlay, true);
176
- setHiddenAnimated(content, true);
177
- removeTrap?.();
178
- removeTrap = null;
179
- restoreFocus?.();
180
- restoreFocus = null;
181
- onOpenChange?.(false);
182
- }
183
- const trigger = AlertDialogTriggerEl(ids.triggerId, ids.contentId, defaultOpen, show);
184
- const overlay = AlertDialogOverlayEl(defaultOpen);
185
- const content = AlertDialogContentEl(ids.contentId, titleId, descriptionId, defaultOpen);
186
- const title = AlertDialogTitleEl(titleId);
187
- const description = AlertDialogDescriptionEl(descriptionId);
188
- const cancel = AlertDialogCancelBtn(() => hide());
189
- const action = AlertDialogActionBtn(() => {
190
- onAction?.();
191
- hide();
192
- });
193
- if (defaultOpen) {
194
- restoreFocus = saveFocus();
195
- removeTrap = trapFocus(content);
196
- queueMicrotask(() => cancel.focus());
197
- }
198
- return { trigger, overlay, content, title, description, cancel, action, state, show, hide };
199
- }
200
- var AlertDialog = {
201
- Root: AlertDialogRoot
202
- };
203
-
204
- export { AlertDialog };
@@ -1,117 +0,0 @@
1
- import {
2
- setDataState,
3
- setExpanded,
4
- setHidden,
5
- setHiddenAnimated
6
- } from "./chunk-vvjyx7fe.js";
7
- import {
8
- linkedIds
9
- } from "./chunk-8y1jf6xr.js";
10
- import {
11
- applyAttrs
12
- } from "./chunk-q8dm19a5.js";
13
-
14
- // src/collapsible/collapsible.tsx
15
- import { __element, __enterChildren, __exitChildren, __insert, __on, __styleStr } from "@vertz/ui/internals";
16
- import { signal } from "@vertz/ui";
17
- function CollapsibleRoot(options = {}) {
18
- const { defaultOpen = false, disabled = false, onOpenChange, ...attrs } = options;
19
- const ids = linkedIds("collapsible");
20
- const state = {
21
- open: signal(defaultOpen),
22
- disabled: signal(disabled)
23
- };
24
- function toggle() {
25
- if (state.disabled.peek())
26
- return;
27
- const next = !state.open.peek();
28
- state.open.value = next;
29
- if (next) {
30
- setHidden(content, false);
31
- }
32
- const height = content.scrollHeight;
33
- content.style.setProperty("--collapsible-content-height", `${height}px`);
34
- setExpanded(trigger, next);
35
- setDataState(trigger, next ? "open" : "closed");
36
- setDataState(content, next ? "open" : "closed");
37
- if (!next) {
38
- setHiddenAnimated(content, true);
39
- }
40
- onOpenChange?.(next);
41
- }
42
- const trigger = (() => {
43
- const __el0 = __element("button");
44
- __el0.setAttribute("type", "button");
45
- {
46
- const __v = ids.triggerId;
47
- if (__v != null && __v !== false)
48
- __el0.setAttribute("id", __v === true ? "" : __v);
49
- }
50
- {
51
- const __v = ids.contentId;
52
- if (__v != null && __v !== false)
53
- __el0.setAttribute("aria-controls", __v === true ? "" : __v);
54
- }
55
- {
56
- const __v = defaultOpen ? "true" : "false";
57
- if (__v != null && __v !== false)
58
- __el0.setAttribute("aria-expanded", __v === true ? "" : __v);
59
- }
60
- {
61
- const __v = defaultOpen ? "open" : "closed";
62
- if (__v != null && __v !== false)
63
- __el0.setAttribute("data-state", __v === true ? "" : __v);
64
- }
65
- {
66
- const __v = disabled;
67
- if (__v != null && __v !== false)
68
- __el0.setAttribute("disabled", __v === true ? "" : __v);
69
- }
70
- {
71
- const __v = disabled ? "true" : undefined;
72
- if (__v != null && __v !== false)
73
- __el0.setAttribute("aria-disabled", __v === true ? "" : __v);
74
- }
75
- __on(__el0, "click", toggle);
76
- return __el0;
77
- })();
78
- const content = (() => {
79
- const __el1 = __element("div");
80
- {
81
- const __v = ids.contentId;
82
- if (__v != null && __v !== false)
83
- __el1.setAttribute("id", __v === true ? "" : __v);
84
- }
85
- {
86
- const __v = defaultOpen ? "false" : "true";
87
- if (__v != null && __v !== false)
88
- __el1.setAttribute("aria-hidden", __v === true ? "" : __v);
89
- }
90
- {
91
- const __v = defaultOpen ? "open" : "closed";
92
- if (__v != null && __v !== false)
93
- __el1.setAttribute("data-state", __v === true ? "" : __v);
94
- }
95
- {
96
- const __v = defaultOpen ? "" : "display: none";
97
- if (__v != null && __v !== false)
98
- __el1.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
99
- }
100
- return __el1;
101
- })();
102
- const root = (() => {
103
- const __el2 = __element("div");
104
- __enterChildren(__el2);
105
- __insert(__el2, trigger);
106
- __insert(__el2, content);
107
- __exitChildren();
108
- return __el2;
109
- })();
110
- applyAttrs(root, attrs);
111
- return { root, trigger, content, state };
112
- }
113
- var Collapsible = {
114
- Root: CollapsibleRoot
115
- };
116
-
117
- export { Collapsible };
@@ -1,196 +0,0 @@
1
- import {
2
- Keys,
3
- isKey
4
- } from "./chunk-7867pr13.js";
5
- import {
6
- setDataState,
7
- setExpanded,
8
- setHidden,
9
- setHiddenAnimated,
10
- setSelected
11
- } from "./chunk-vvjyx7fe.js";
12
- import {
13
- linkedIds
14
- } from "./chunk-8y1jf6xr.js";
15
- import {
16
- applyAttrs
17
- } from "./chunk-q8dm19a5.js";
18
-
19
- // src/combobox/combobox.tsx
20
- import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
21
- import { signal } from "@vertz/ui";
22
- function ComboboxRoot(options = {}) {
23
- const { defaultValue = "", onValueChange, onInputChange, ...attrs } = options;
24
- const ids = linkedIds("combobox");
25
- const state = {
26
- open: signal(false),
27
- value: signal(defaultValue),
28
- inputValue: signal(defaultValue),
29
- activeIndex: signal(-1)
30
- };
31
- const optionElements = [];
32
- function open() {
33
- state.open.value = true;
34
- setExpanded(input, true);
35
- setHidden(listbox, false);
36
- setDataState(listbox, "open");
37
- }
38
- function close() {
39
- state.open.value = false;
40
- state.activeIndex.value = -1;
41
- setExpanded(input, false);
42
- setDataState(listbox, "closed");
43
- setHiddenAnimated(listbox, true);
44
- updateActiveDescendant(-1);
45
- }
46
- function selectOption(value) {
47
- state.value.value = value;
48
- state.inputValue.value = value;
49
- input.value = value;
50
- for (const opt of optionElements) {
51
- const isActive = opt.getAttribute("data-value") === value;
52
- setSelected(opt, isActive);
53
- setDataState(opt, isActive ? "active" : "inactive");
54
- }
55
- onValueChange?.(value);
56
- close();
57
- input.focus();
58
- }
59
- function updateActiveDescendant(index) {
60
- const opt = optionElements[index];
61
- if (index >= 0 && opt) {
62
- input.setAttribute("aria-activedescendant", opt.id);
63
- for (let i = 0;i < optionElements.length; i++) {
64
- const el = optionElements[i];
65
- if (el)
66
- setDataState(el, i === index ? "active" : "inactive");
67
- }
68
- } else {
69
- input.removeAttribute("aria-activedescendant");
70
- }
71
- }
72
- const input = (() => {
73
- const __el0 = __element("input");
74
- __el0.setAttribute("type", "text");
75
- __el0.setAttribute("role", "combobox");
76
- __el0.setAttribute("aria-autocomplete", "list");
77
- {
78
- const __v = ids.contentId;
79
- if (__v != null && __v !== false)
80
- __el0.setAttribute("aria-controls", __v === true ? "" : __v);
81
- }
82
- __el0.setAttribute("aria-haspopup", "listbox");
83
- {
84
- const __v = ids.triggerId;
85
- if (__v != null && __v !== false)
86
- __el0.setAttribute("id", __v === true ? "" : __v);
87
- }
88
- {
89
- const __v = defaultValue;
90
- if (__v != null && __v !== false)
91
- __el0.setAttribute("value", __v === true ? "" : __v);
92
- }
93
- __el0.setAttribute("aria-expanded", "false");
94
- __on(__el0, "input", () => {
95
- state.inputValue.value = input.value;
96
- onInputChange?.(input.value);
97
- if (!state.open.peek())
98
- open();
99
- });
100
- __on(__el0, "focus", () => {
101
- if (!state.open.peek() && input.value.length > 0)
102
- open();
103
- });
104
- __on(__el0, "keydown", (event) => {
105
- if (isKey(event, Keys.Escape)) {
106
- event.preventDefault();
107
- close();
108
- return;
109
- }
110
- if (isKey(event, Keys.ArrowDown)) {
111
- event.preventDefault();
112
- if (!state.open.peek()) {
113
- open();
114
- }
115
- const next = Math.min(state.activeIndex.peek() + 1, optionElements.length - 1);
116
- state.activeIndex.value = next;
117
- updateActiveDescendant(next);
118
- return;
119
- }
120
- if (isKey(event, Keys.ArrowUp)) {
121
- event.preventDefault();
122
- const prev = Math.max(state.activeIndex.peek() - 1, 0);
123
- state.activeIndex.value = prev;
124
- updateActiveDescendant(prev);
125
- return;
126
- }
127
- if (isKey(event, Keys.Enter)) {
128
- event.preventDefault();
129
- const idx = state.activeIndex.peek();
130
- if (idx >= 0 && idx < optionElements.length) {
131
- const val = optionElements[idx]?.getAttribute("data-value");
132
- if (val != null)
133
- selectOption(val);
134
- }
135
- return;
136
- }
137
- });
138
- return __el0;
139
- })();
140
- const listbox = (() => {
141
- const __el1 = __element("div");
142
- __el1.setAttribute("role", "listbox");
143
- {
144
- const __v = ids.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
- return __el1;
152
- })();
153
- function Option(value, label) {
154
- const optId = `${ids.contentId}-opt-${optionElements.length}`;
155
- const isSelectedOpt = value === defaultValue;
156
- const opt = (() => {
157
- const __el2 = __element("div");
158
- __el2.setAttribute("role", "option");
159
- {
160
- const __v = optId;
161
- if (__v != null && __v !== false)
162
- __el2.setAttribute("id", __v === true ? "" : __v);
163
- }
164
- {
165
- const __v = value;
166
- if (__v != null && __v !== false)
167
- __el2.setAttribute("data-value", __v === true ? "" : __v);
168
- }
169
- {
170
- const __v = isSelectedOpt ? "true" : "false";
171
- if (__v != null && __v !== false)
172
- __el2.setAttribute("aria-selected", __v === true ? "" : __v);
173
- }
174
- {
175
- const __v = isSelectedOpt ? "active" : "inactive";
176
- if (__v != null && __v !== false)
177
- __el2.setAttribute("data-state", __v === true ? "" : __v);
178
- }
179
- __on(__el2, "click", () => selectOption(value));
180
- __enterChildren(__el2);
181
- __insert(__el2, label ?? value);
182
- __exitChildren();
183
- return __el2;
184
- })();
185
- optionElements.push(opt);
186
- listbox.appendChild(opt);
187
- return opt;
188
- }
189
- applyAttrs(input, attrs);
190
- return { input, listbox, state, Option };
191
- }
192
- var Combobox = {
193
- Root: ComboboxRoot
194
- };
195
-
196
- export { Combobox };
@@ -1,175 +0,0 @@
1
- import {
2
- Keys,
3
- isKey
4
- } from "./chunk-7867pr13.js";
5
- import {
6
- setDataState,
7
- setValueRange
8
- } from "./chunk-vvjyx7fe.js";
9
- import {
10
- applyAttrs
11
- } from "./chunk-q8dm19a5.js";
12
-
13
- // src/resizable-panel/resizable-panel.tsx
14
- import { __element, __on, __styleStr } 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", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__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 };