@vertz/ui-primitives 0.2.38 → 0.2.42
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.
- package/dist/shared/chunk-06m8prfg.js +52 -0
- package/dist/shared/chunk-0n9jj8xr.js +24 -0
- package/dist/shared/chunk-1ben27xq.js +317 -0
- package/dist/shared/chunk-1j2mj0sa.js +45 -0
- package/dist/shared/chunk-250hj18f.js +243 -0
- package/dist/shared/chunk-2h4m9c71.js +38 -0
- package/dist/shared/chunk-2sbx20hv.js +128 -0
- package/dist/shared/chunk-2ye674gr.js +70 -0
- package/dist/shared/chunk-34d8385y.js +15 -0
- package/dist/shared/chunk-4d7bm8h0.js +113 -0
- package/dist/shared/chunk-4zjgxr7x.js +157 -0
- package/dist/shared/chunk-5c150wvr.js +140 -0
- package/dist/shared/chunk-5gycdypd.js +58 -0
- package/dist/shared/chunk-6mm7fhp8.js +105 -0
- package/dist/shared/chunk-6zmnqvh6.js +109 -0
- package/dist/shared/{chunk-yy3ft5mb.js → chunk-7amn5d71.js} +2 -2
- package/dist/shared/chunk-7pbff2hg.js +118 -0
- package/dist/shared/chunk-7zpjshwz.js +194 -0
- package/dist/shared/chunk-993ff51d.js +155 -0
- package/dist/shared/chunk-9pdt5aw7.js +24 -0
- package/dist/shared/chunk-a71m4xkv.js +106 -0
- package/dist/shared/chunk-aj8m39pk.js +127 -0
- package/dist/shared/chunk-ajawpc05.js +305 -0
- package/dist/shared/chunk-b7mzwqhj.js +125 -0
- package/dist/shared/chunk-bb887de4.js +200 -0
- package/dist/shared/chunk-bfsmbrxc.js +111 -0
- package/dist/shared/chunk-c2f63m5n.js +56 -0
- package/dist/shared/chunk-c5r3s5km.js +263 -0
- package/dist/shared/chunk-caba5bhd.js +427 -0
- package/dist/shared/chunk-crym07yc.js +264 -0
- package/dist/shared/{chunk-5964gmv0.js → chunk-csjtyvam.js} +62 -88
- package/dist/shared/chunk-d6rtejz3.js +128 -0
- package/dist/shared/chunk-dvaf0bmq.js +140 -0
- package/dist/shared/chunk-dwkv9ya6.js +22 -0
- package/dist/shared/chunk-e0ckxrjg.js +41 -0
- package/dist/shared/chunk-ennxcymj.js +225 -0
- package/dist/shared/{chunk-1jd1n0dt.js → chunk-ey38de46.js} +19 -47
- package/dist/shared/chunk-f0v1gs5e.js +52 -0
- package/dist/shared/chunk-f86rsf84.js +231 -0
- package/dist/shared/chunk-fdse46x5.js +21 -0
- package/dist/shared/chunk-gj4hrssn.js +135 -0
- package/dist/shared/chunk-gyvq4gk9.js +24 -0
- package/dist/shared/chunk-hbnps9sq.js +229 -0
- package/dist/shared/{chunk-fhss32ya.js → chunk-hdmpyeq9.js} +43 -132
- package/dist/shared/chunk-hgnkd4he.js +256 -0
- package/dist/shared/chunk-hpcyffm7.js +185 -0
- package/dist/shared/chunk-hpmvwx0h.js +99 -0
- package/dist/shared/chunk-hz0e504p.js +69 -0
- package/dist/shared/chunk-hzk4wfq9.js +43 -0
- package/dist/shared/chunk-j7znzkpa.js +48 -0
- package/dist/shared/chunk-j9kxgrnn.js +167 -0
- package/dist/shared/chunk-jetwnv0w.js +130 -0
- package/dist/shared/chunk-jjdg26c1.js +155 -0
- package/dist/shared/chunk-k0m4yh86.js +123 -0
- package/dist/shared/chunk-k43q9cjr.js +82 -0
- package/dist/shared/chunk-k9k8tbr5.js +119 -0
- package/dist/shared/chunk-meaj7br1.js +232 -0
- package/dist/shared/chunk-mgj0n08k.js +34 -0
- package/dist/shared/chunk-mjz4rp6c.js +46 -0
- package/dist/shared/chunk-n4rr5gme.js +239 -0
- package/dist/shared/chunk-nk55etpp.js +65 -0
- package/dist/shared/chunk-nkh1ks3k.js +264 -0
- package/dist/shared/chunk-pgvpvbpe.js +26 -0
- package/dist/shared/chunk-pma8gnv7.js +178 -0
- package/dist/shared/chunk-q7xv6xze.js +131 -0
- package/dist/shared/chunk-qey801nq.js +22 -0
- package/dist/shared/chunk-s6b4c3tj.js +58 -0
- package/dist/shared/chunk-sq27a4h0.js +36 -0
- package/dist/shared/chunk-taa5pj15.js +103 -0
- package/dist/shared/chunk-tc5rpvyx.js +127 -0
- package/dist/shared/chunk-tescm0b3.js +192 -0
- package/dist/shared/chunk-tkftdwnq.js +71 -0
- package/dist/shared/chunk-tqhnjcfp.js +116 -0
- package/dist/shared/chunk-vfknb5ht.js +183 -0
- package/dist/shared/chunk-vsc369w3.js +185 -0
- package/dist/shared/chunk-whq9s8v5.js +301 -0
- package/dist/shared/{chunk-hze1f32t.js → chunk-wrqddgaj.js} +1 -1
- package/dist/shared/chunk-yzbmkx4r.js +155 -0
- package/dist/shared/chunk-zaen0ajc.js +347 -0
- package/dist/src/accordion/accordion-composed.js +1 -1
- package/dist/src/accordion/accordion.js +1 -1
- package/dist/src/alert/alert-composed.js +1 -1
- package/dist/src/alert-dialog/alert-dialog-composed.js +1 -1
- package/dist/src/alert-dialog/alert-dialog.js +1 -1
- package/dist/src/avatar/avatar-composed.js +1 -1
- package/dist/src/badge/badge-composed.js +1 -1
- package/dist/src/badge/badge.js +1 -1
- package/dist/src/breadcrumb/breadcrumb-composed.js +1 -1
- package/dist/src/button/button-composed.js +1 -1
- package/dist/src/button/button.js +1 -1
- package/dist/src/calendar/calendar-composed.js +1 -1
- package/dist/src/calendar/calendar.js +1 -1
- package/dist/src/card/card-composed.js +1 -1
- package/dist/src/carousel/carousel-composed.js +1 -1
- package/dist/src/carousel/carousel.js +1 -1
- package/dist/src/checkbox/checkbox-composed.js +1 -1
- package/dist/src/checkbox/checkbox.js +1 -1
- package/dist/src/collapsible/collapsible-composed.js +1 -1
- package/dist/src/collapsible/collapsible.js +1 -1
- package/dist/src/combobox/combobox-composed.js +1 -1
- package/dist/src/combobox/combobox.js +1 -1
- package/dist/src/command/command-composed.js +1 -1
- package/dist/src/command/command.js +1 -1
- package/dist/src/composed/with-styles.js +1 -1
- package/dist/src/context-menu/context-menu-composed.js +1 -1
- package/dist/src/context-menu/context-menu.js +1 -1
- package/dist/src/date-picker/date-picker-composed.js +1 -1
- package/dist/src/date-picker/date-picker.js +1 -1
- package/dist/src/dialog/dialog-composed.js +1 -1
- package/dist/src/dialog/dialog-stack-parts.js +1 -1
- package/dist/src/dialog/dialog.js +1 -1
- package/dist/src/dropdown-menu/dropdown-menu-composed.js +1 -1
- package/dist/src/dropdown-menu/dropdown-menu.js +1 -1
- package/dist/src/empty-state/empty-state-composed.js +1 -1
- package/dist/src/form-group/form-group-composed.js +1 -1
- package/dist/src/hover-card/hover-card-composed.js +1 -1
- package/dist/src/hover-card/hover-card.js +1 -1
- package/dist/src/input/input-composed.js +1 -1
- package/dist/src/label/label-composed.js +1 -1
- package/dist/src/list/list-composed.js +1 -1
- package/dist/src/menu/menu-composed.js +1 -1
- package/dist/src/menu/menu.js +1 -1
- package/dist/src/menubar/menubar-composed.js +1 -1
- package/dist/src/menubar/menubar.js +1 -1
- package/dist/src/navigation-menu/navigation-menu-composed.js +1 -1
- package/dist/src/navigation-menu/navigation-menu.js +1 -1
- package/dist/src/pagination/pagination-composed.js +1 -1
- package/dist/src/popover/popover-composed.js +1 -1
- package/dist/src/popover/popover.js +1 -1
- package/dist/src/progress/progress-composed.js +1 -1
- package/dist/src/progress/progress.js +1 -1
- package/dist/src/radio/radio-composed.js +1 -1
- package/dist/src/radio/radio.js +1 -1
- package/dist/src/resizable-panel/resizable-panel-composed.js +1 -1
- package/dist/src/resizable-panel/resizable-panel.js +1 -1
- package/dist/src/scroll-area/scroll-area-composed.js +1 -1
- package/dist/src/scroll-area/scroll-area.js +1 -1
- package/dist/src/select/select-composed.js +1 -1
- package/dist/src/select/select.js +1 -1
- package/dist/src/separator/separator-composed.js +1 -1
- package/dist/src/sheet/sheet-composed.js +1 -1
- package/dist/src/sheet/sheet.js +1 -1
- package/dist/src/skeleton/skeleton-composed.js +1 -1
- package/dist/src/slider/slider-composed.js +1 -1
- package/dist/src/slider/slider.js +1 -1
- package/dist/src/switch/switch-composed.js +1 -1
- package/dist/src/switch/switch.js +1 -1
- package/dist/src/table/table-composed.js +1 -1
- package/dist/src/tabs/tabs-composed.js +1 -1
- package/dist/src/tabs/tabs.js +1 -1
- package/dist/src/textarea/textarea-composed.js +1 -1
- package/dist/src/toast/toast.js +1 -1
- package/dist/src/toggle/toggle-composed.js +1 -1
- package/dist/src/toggle/toggle.js +1 -1
- package/dist/src/toggle-group/toggle-group-composed.js +1 -1
- package/dist/src/toggle-group/toggle-group.js +1 -1
- package/dist/src/tooltip/tooltip-composed.js +1 -1
- package/dist/src/tooltip/tooltip.js +1 -1
- package/package.json +3 -3
- package/dist/shared/chunk-144kbnmx.js +0 -95
- package/dist/shared/chunk-1ewxfgsa.js +0 -167
- package/dist/shared/chunk-1hm0mbke.js +0 -258
- package/dist/shared/chunk-22rt6ws9.js +0 -69
- package/dist/shared/chunk-2ssqz188.js +0 -162
- package/dist/shared/chunk-33he7ay9.js +0 -218
- package/dist/shared/chunk-3jack97k.js +0 -509
- package/dist/shared/chunk-75pegjs7.js +0 -26
- package/dist/shared/chunk-862x7dja.js +0 -398
- package/dist/shared/chunk-8pk1pn5h.js +0 -215
- package/dist/shared/chunk-8t0nm721.js +0 -152
- package/dist/shared/chunk-94twh4s4.js +0 -28
- package/dist/shared/chunk-9yb26c0w.js +0 -232
- package/dist/shared/chunk-a82r2pnq.js +0 -67
- package/dist/shared/chunk-axpbdpgx.js +0 -177
- package/dist/shared/chunk-b3j6mym6.js +0 -203
- package/dist/shared/chunk-b4zzg457.js +0 -410
- package/dist/shared/chunk-b9qxfcsy.js +0 -60
- package/dist/shared/chunk-bc2qqkhr.js +0 -194
- package/dist/shared/chunk-bv12nkdm.js +0 -149
- package/dist/shared/chunk-bvxc1ww4.js +0 -164
- package/dist/shared/chunk-czv0kqj4.js +0 -107
- package/dist/shared/chunk-d83ag07h.js +0 -189
- package/dist/shared/chunk-de18ashk.js +0 -134
- package/dist/shared/chunk-dvk4h36t.js +0 -140
- package/dist/shared/chunk-dxvnerw2.js +0 -353
- package/dist/shared/chunk-e399pzdq.js +0 -241
- package/dist/shared/chunk-e4qha9as.js +0 -180
- package/dist/shared/chunk-eb2d9v6k.js +0 -68
- package/dist/shared/chunk-ect26sp5.js +0 -353
- package/dist/shared/chunk-ev367pq3.js +0 -102
- package/dist/shared/chunk-fjykbv0v.js +0 -214
- package/dist/shared/chunk-gdddk6nh.js +0 -96
- package/dist/shared/chunk-ghkw5bjq.js +0 -55
- package/dist/shared/chunk-hfjtkytb.js +0 -310
- package/dist/shared/chunk-hpvjfj0j.js +0 -31
- package/dist/shared/chunk-jpyjk616.js +0 -52
- package/dist/shared/chunk-k6d53tne.js +0 -206
- package/dist/shared/chunk-knzg86am.js +0 -168
- package/dist/shared/chunk-ktbf6xrt.js +0 -179
- package/dist/shared/chunk-m8y2p66x.js +0 -252
- package/dist/shared/chunk-metxdt5x.js +0 -28
- package/dist/shared/chunk-mgae1d93.js +0 -157
- package/dist/shared/chunk-mtx2cfbx.js +0 -175
- package/dist/shared/chunk-n436p5cb.js +0 -260
- package/dist/shared/chunk-nj420k31.js +0 -54
- package/dist/shared/chunk-nsmvdxgp.js +0 -213
- package/dist/shared/chunk-pcms04vq.js +0 -162
- package/dist/shared/chunk-pqskzq8t.js +0 -79
- package/dist/shared/chunk-pwr60kyd.js +0 -321
- package/dist/shared/chunk-pzknpa1y.js +0 -327
- package/dist/shared/chunk-q77y3rg4.js +0 -189
- package/dist/shared/chunk-qhnany7w.js +0 -179
- package/dist/shared/chunk-r3pffzss.js +0 -13
- package/dist/shared/chunk-rdr0rtpr.js +0 -131
- package/dist/shared/chunk-rj52ty6r.js +0 -147
- package/dist/shared/chunk-rnqc7735.js +0 -125
- package/dist/shared/chunk-rtk30950.js +0 -202
- package/dist/shared/chunk-s0xgd8vg.js +0 -266
- package/dist/shared/chunk-s415735j.js +0 -357
- package/dist/shared/chunk-s62e7jf4.js +0 -30
- package/dist/shared/chunk-snd8e6r8.js +0 -418
- package/dist/shared/chunk-spng4yb9.js +0 -73
- package/dist/shared/chunk-t887wwjc.js +0 -168
- package/dist/shared/chunk-tn0m98j8.js +0 -42
- package/dist/shared/chunk-v0b5pkcq.js +0 -30
- package/dist/shared/chunk-v5tj7veh.js +0 -284
- package/dist/shared/chunk-vkscwzpr.js +0 -294
- package/dist/shared/chunk-vv187snj.js +0 -112
- package/dist/shared/chunk-xv4wd0kf.js +0 -293
- package/dist/shared/chunk-y1hpsqzy.js +0 -185
- package/dist/shared/chunk-yfzddvxc.js +0 -71
- package/dist/shared/chunk-yzgzx2dh.js +0 -311
- package/dist/shared/chunk-z5j7ztf2.js +0 -467
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDismiss
|
|
3
|
+
} from "./chunk-a6wp8c32.js";
|
|
4
|
+
import {
|
|
5
|
+
createFloatingPosition
|
|
6
|
+
} from "./chunk-vef3sepw.js";
|
|
7
|
+
import {
|
|
8
|
+
linkedIds
|
|
9
|
+
} from "./chunk-8y1jf6xr.js";
|
|
10
|
+
import {
|
|
11
|
+
Keys,
|
|
12
|
+
handleListNavigation,
|
|
13
|
+
isKey
|
|
14
|
+
} from "./chunk-7867pr13.js";
|
|
15
|
+
import {
|
|
16
|
+
setDataState,
|
|
17
|
+
setExpanded,
|
|
18
|
+
setHidden,
|
|
19
|
+
setHiddenAnimated
|
|
20
|
+
} from "./chunk-vevfhpc9.js";
|
|
21
|
+
import {
|
|
22
|
+
applyAttrs
|
|
23
|
+
} from "./chunk-2db2dnp3.js";
|
|
24
|
+
|
|
25
|
+
// src/menu/menu.tsx
|
|
26
|
+
import { jsxDEV as jsxDEV_7x81h0kn } from "@vertz/ui/jsx-dev-runtime";
|
|
27
|
+
import { signal } from "@vertz/ui";
|
|
28
|
+
function MenuRoot(options = {}) {
|
|
29
|
+
const { onSelect, onOpenChange, positioning, ...attrs } = options;
|
|
30
|
+
const ids = linkedIds("menu");
|
|
31
|
+
const state = {
|
|
32
|
+
open: signal(false),
|
|
33
|
+
activeIndex: signal(-1)
|
|
34
|
+
};
|
|
35
|
+
const items = [];
|
|
36
|
+
let floatingCleanup = null;
|
|
37
|
+
let dismissCleanup = null;
|
|
38
|
+
function handleClickOutside(event) {
|
|
39
|
+
const target = event.target;
|
|
40
|
+
if (!trigger.contains(target) && !content.contains(target)) {
|
|
41
|
+
close();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function open(activateFirst = false) {
|
|
45
|
+
state.open.value = true;
|
|
46
|
+
setExpanded(trigger, true);
|
|
47
|
+
setHidden(content, false);
|
|
48
|
+
setDataState(trigger, "open");
|
|
49
|
+
setDataState(content, "open");
|
|
50
|
+
onOpenChange?.(true);
|
|
51
|
+
if (positioning) {
|
|
52
|
+
const ref = positioning.referenceElement ?? trigger;
|
|
53
|
+
const result = createFloatingPosition(ref, content, positioning);
|
|
54
|
+
floatingCleanup = result.cleanup;
|
|
55
|
+
dismissCleanup = createDismiss({
|
|
56
|
+
onDismiss: close,
|
|
57
|
+
insideElements: [ref, trigger, content],
|
|
58
|
+
escapeKey: false
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
62
|
+
}
|
|
63
|
+
if (activateFirst && items.length > 0) {
|
|
64
|
+
state.activeIndex.value = 0;
|
|
65
|
+
updateActiveItem(0);
|
|
66
|
+
items[0]?.focus();
|
|
67
|
+
} else {
|
|
68
|
+
state.activeIndex.value = -1;
|
|
69
|
+
updateActiveItem(-1);
|
|
70
|
+
content.focus();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function close() {
|
|
74
|
+
state.open.value = false;
|
|
75
|
+
setExpanded(trigger, false);
|
|
76
|
+
setDataState(trigger, "closed");
|
|
77
|
+
setDataState(content, "closed");
|
|
78
|
+
setHiddenAnimated(content, true);
|
|
79
|
+
onOpenChange?.(false);
|
|
80
|
+
if (positioning) {
|
|
81
|
+
floatingCleanup?.();
|
|
82
|
+
floatingCleanup = null;
|
|
83
|
+
dismissCleanup?.();
|
|
84
|
+
dismissCleanup = null;
|
|
85
|
+
} else {
|
|
86
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
87
|
+
}
|
|
88
|
+
trigger.focus();
|
|
89
|
+
}
|
|
90
|
+
function updateActiveItem(index) {
|
|
91
|
+
for (let i = 0;i < items.length; i++) {
|
|
92
|
+
items[i]?.setAttribute("tabindex", i === index ? "0" : "-1");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const trigger = jsxDEV_7x81h0kn("button", {
|
|
96
|
+
type: "button",
|
|
97
|
+
id: ids.triggerId,
|
|
98
|
+
"aria-controls": ids.contentId,
|
|
99
|
+
"aria-haspopup": "menu",
|
|
100
|
+
"aria-expanded": "false",
|
|
101
|
+
"data-state": "closed",
|
|
102
|
+
onClick: () => {
|
|
103
|
+
if (state.open.peek()) {
|
|
104
|
+
close();
|
|
105
|
+
} else {
|
|
106
|
+
open();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
onKeydown: (event) => {
|
|
110
|
+
if (isKey(event, Keys.ArrowDown, Keys.Enter, Keys.Space)) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
if (!state.open.peek())
|
|
113
|
+
open(true);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}, undefined, false, undefined, this);
|
|
117
|
+
const content = jsxDEV_7x81h0kn("div", {
|
|
118
|
+
role: "menu",
|
|
119
|
+
tabindex: "-1",
|
|
120
|
+
id: ids.contentId,
|
|
121
|
+
"aria-hidden": "true",
|
|
122
|
+
"data-state": "closed",
|
|
123
|
+
style: { display: "none" },
|
|
124
|
+
onKeydown: (event) => {
|
|
125
|
+
if (isKey(event, Keys.Escape)) {
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
close();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (isKey(event, Keys.Enter, Keys.Space)) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
const active = items[state.activeIndex.peek()];
|
|
133
|
+
if (active) {
|
|
134
|
+
const val = active.getAttribute("data-value");
|
|
135
|
+
if (val !== null) {
|
|
136
|
+
onSelect?.(val);
|
|
137
|
+
close();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (state.activeIndex.peek() === -1) {
|
|
143
|
+
if (isKey(event, Keys.ArrowDown)) {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
state.activeIndex.value = 0;
|
|
146
|
+
updateActiveItem(0);
|
|
147
|
+
items[0]?.focus();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (isKey(event, Keys.ArrowUp)) {
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
const last = items.length - 1;
|
|
153
|
+
state.activeIndex.value = last;
|
|
154
|
+
updateActiveItem(last);
|
|
155
|
+
items[last]?.focus();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const result = handleListNavigation(event, items, { orientation: "vertical" });
|
|
160
|
+
if (result) {
|
|
161
|
+
const idx = items.indexOf(result);
|
|
162
|
+
if (idx >= 0) {
|
|
163
|
+
state.activeIndex.value = idx;
|
|
164
|
+
updateActiveItem(idx);
|
|
165
|
+
}
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
169
|
+
const char = event.key.toLowerCase();
|
|
170
|
+
const match = items.find((item) => item.textContent?.toLowerCase().startsWith(char));
|
|
171
|
+
if (match) {
|
|
172
|
+
const idx = items.indexOf(match);
|
|
173
|
+
state.activeIndex.value = idx;
|
|
174
|
+
updateActiveItem(idx);
|
|
175
|
+
match.focus();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}, undefined, false, undefined, this);
|
|
180
|
+
function createItem(value, label) {
|
|
181
|
+
const item = jsxDEV_7x81h0kn("div", {
|
|
182
|
+
role: "menuitem",
|
|
183
|
+
"data-value": value,
|
|
184
|
+
tabindex: "-1",
|
|
185
|
+
onClick: () => {
|
|
186
|
+
onSelect?.(value);
|
|
187
|
+
close();
|
|
188
|
+
},
|
|
189
|
+
children: label ?? value
|
|
190
|
+
}, undefined, false, undefined, this);
|
|
191
|
+
items.push(item);
|
|
192
|
+
return item;
|
|
193
|
+
}
|
|
194
|
+
function Item(value, label) {
|
|
195
|
+
return createItem(value, label);
|
|
196
|
+
}
|
|
197
|
+
function Group(label) {
|
|
198
|
+
const el = jsxDEV_7x81h0kn("div", {
|
|
199
|
+
role: "group",
|
|
200
|
+
"aria-label": label
|
|
201
|
+
}, undefined, false, undefined, this);
|
|
202
|
+
return {
|
|
203
|
+
el,
|
|
204
|
+
Item: (value, itemLabel) => createItem(value, itemLabel)
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function Separator() {
|
|
208
|
+
return jsxDEV_7x81h0kn("hr", {
|
|
209
|
+
role: "separator"
|
|
210
|
+
}, undefined, false, undefined, this);
|
|
211
|
+
}
|
|
212
|
+
function Label(text) {
|
|
213
|
+
return jsxDEV_7x81h0kn("div", {
|
|
214
|
+
role: "none",
|
|
215
|
+
children: text
|
|
216
|
+
}, undefined, false, undefined, this);
|
|
217
|
+
}
|
|
218
|
+
applyAttrs(trigger, attrs);
|
|
219
|
+
return { trigger, content, state, Item, Group, Separator, Label };
|
|
220
|
+
}
|
|
221
|
+
var Menu = {
|
|
222
|
+
Root: MenuRoot
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export { Menu };
|
|
@@ -19,57 +19,29 @@ import {
|
|
|
19
19
|
} from "./chunk-2db2dnp3.js";
|
|
20
20
|
|
|
21
21
|
// src/tooltip/tooltip.tsx
|
|
22
|
-
import {
|
|
22
|
+
import { jsxDEV as jsxDEV_7x81h0kn } from "@vertz/ui/jsx-dev-runtime";
|
|
23
23
|
import { signal } from "@vertz/ui";
|
|
24
24
|
function TooltipTrigger(show, hide) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return __el0;
|
|
39
|
-
})();
|
|
40
|
-
__flushMountFrame();
|
|
41
|
-
return __mfResult0;
|
|
42
|
-
} catch (__mfErr) {
|
|
43
|
-
__discardMountFrame(__mfDepth);
|
|
44
|
-
throw __mfErr;
|
|
45
|
-
}
|
|
25
|
+
return jsxDEV_7x81h0kn("span", {
|
|
26
|
+
onMouseenter: show,
|
|
27
|
+
onMouseleave: hide,
|
|
28
|
+
onFocus: show,
|
|
29
|
+
onBlur: hide,
|
|
30
|
+
onKeydown: (event) => {
|
|
31
|
+
if (isKey(event, Keys.Escape)) {
|
|
32
|
+
hide();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}, undefined, false, undefined, this);
|
|
46
36
|
}
|
|
47
37
|
function TooltipContent(contentId) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (__v != null && __v !== false)
|
|
56
|
-
__el0.setAttribute("id", __v === true ? "" : __v);
|
|
57
|
-
}
|
|
58
|
-
__el0.setAttribute("aria-hidden", "true");
|
|
59
|
-
__el0.setAttribute("data-state", "closed");
|
|
60
|
-
{
|
|
61
|
-
const __v = { 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
|
-
__flushMountFrame();
|
|
68
|
-
return __mfResult0;
|
|
69
|
-
} catch (__mfErr) {
|
|
70
|
-
__discardMountFrame(__mfDepth);
|
|
71
|
-
throw __mfErr;
|
|
72
|
-
}
|
|
38
|
+
return jsxDEV_7x81h0kn("div", {
|
|
39
|
+
role: "tooltip",
|
|
40
|
+
id: contentId,
|
|
41
|
+
"aria-hidden": "true",
|
|
42
|
+
"data-state": "closed",
|
|
43
|
+
style: { display: "none" }
|
|
44
|
+
}, undefined, false, undefined, this);
|
|
73
45
|
}
|
|
74
46
|
function TooltipRoot(options = {}) {
|
|
75
47
|
const { delay = 300, onOpenChange, positioning, ...attrs } = options;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-q7xbcj9q.js";
|
|
4
|
+
|
|
5
|
+
// src/skeleton/skeleton-composed.tsx
|
|
6
|
+
import { jsxDEV as jsxDEV_7x81h0kn } from "@vertz/ui/jsx-dev-runtime";
|
|
7
|
+
function ComposedSkeletonRoot(props = {}) {
|
|
8
|
+
const { classes, className, class: classProp, width, height } = props;
|
|
9
|
+
return jsxDEV_7x81h0kn("div", {
|
|
10
|
+
class: cn(classes?.root, className ?? classProp),
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
style: {
|
|
13
|
+
width: width || undefined,
|
|
14
|
+
height: height || undefined
|
|
15
|
+
}
|
|
16
|
+
}, undefined, false, undefined, this);
|
|
17
|
+
}
|
|
18
|
+
function SkeletonText(props = {}) {
|
|
19
|
+
const lineCount = props.lines ?? 3;
|
|
20
|
+
const lastWidth = props.lastLineWidth ?? "75%";
|
|
21
|
+
const lineHeight = props.height;
|
|
22
|
+
const lines = [];
|
|
23
|
+
for (let i = 0;i < lineCount; i++) {
|
|
24
|
+
lines.push(jsxDEV_7x81h0kn("div", {
|
|
25
|
+
class: cn(props.classes?.line),
|
|
26
|
+
style: {
|
|
27
|
+
width: i === lineCount - 1 ? lastWidth : undefined,
|
|
28
|
+
height: lineHeight || undefined
|
|
29
|
+
}
|
|
30
|
+
}, undefined, false, undefined, this));
|
|
31
|
+
}
|
|
32
|
+
return jsxDEV_7x81h0kn("div", {
|
|
33
|
+
class: cn(props.classes?.root, props.className ?? props.class),
|
|
34
|
+
"aria-hidden": "true",
|
|
35
|
+
style: { gap: props.gap || undefined },
|
|
36
|
+
children: lines
|
|
37
|
+
}, undefined, false, undefined, this);
|
|
38
|
+
}
|
|
39
|
+
function SkeletonCircle(props = {}) {
|
|
40
|
+
const size = props.size ?? "2.5rem";
|
|
41
|
+
return jsxDEV_7x81h0kn("div", {
|
|
42
|
+
class: cn(props.classes?.root, props.className ?? props.class),
|
|
43
|
+
"aria-hidden": "true",
|
|
44
|
+
style: { width: size, height: size }
|
|
45
|
+
}, undefined, false, undefined, this);
|
|
46
|
+
}
|
|
47
|
+
var ComposedSkeleton = Object.assign(ComposedSkeletonRoot, {
|
|
48
|
+
Text: SkeletonText,
|
|
49
|
+
Circle: SkeletonCircle
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export { ComposedSkeleton };
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ComposedCalendar
|
|
3
|
+
} from "./chunk-caba5bhd.js";
|
|
4
|
+
import {
|
|
5
|
+
createDismiss
|
|
6
|
+
} from "./chunk-a6wp8c32.js";
|
|
7
|
+
import {
|
|
8
|
+
cn
|
|
9
|
+
} from "./chunk-q7xbcj9q.js";
|
|
10
|
+
import {
|
|
11
|
+
createFloatingPosition
|
|
12
|
+
} from "./chunk-vef3sepw.js";
|
|
13
|
+
import {
|
|
14
|
+
linkedIds
|
|
15
|
+
} from "./chunk-8y1jf6xr.js";
|
|
16
|
+
|
|
17
|
+
// src/date-picker/date-picker-composed.tsx
|
|
18
|
+
import { jsxDEV as jsxDEV_7x81h0kn, Fragment as Fragment_8vg9x3sq } from "@vertz/ui/jsx-dev-runtime";
|
|
19
|
+
import { createContext, ref, useContext } from "@vertz/ui";
|
|
20
|
+
var DatePickerContext = createContext(undefined, "@vertz/ui-primitives::DatePickerContext");
|
|
21
|
+
function DatePickerTrigger({ children, className: cls, class: classProp }) {
|
|
22
|
+
const ctx = useContext(DatePickerContext);
|
|
23
|
+
if (!ctx) {
|
|
24
|
+
throw new Error("<DatePicker.Trigger> must be used inside <DatePicker>. " + "Ensure it is a direct or nested child of the DatePicker root component.");
|
|
25
|
+
}
|
|
26
|
+
const isOpen = ctx.isOpen();
|
|
27
|
+
const hasVal = ctx.hasValue();
|
|
28
|
+
const text = ctx.displayText();
|
|
29
|
+
return jsxDEV_7x81h0kn("button", {
|
|
30
|
+
ref: ctx.triggerRef,
|
|
31
|
+
type: "button",
|
|
32
|
+
"data-datepicker-trigger": "",
|
|
33
|
+
"aria-haspopup": "dialog",
|
|
34
|
+
"aria-controls": ctx.contentId,
|
|
35
|
+
"aria-expanded": isOpen ? "true" : "false",
|
|
36
|
+
"data-state": isOpen ? "open" : "closed",
|
|
37
|
+
"data-placeholder": hasVal ? undefined : "true",
|
|
38
|
+
class: cn(ctx.classes?.trigger, cls ?? classProp),
|
|
39
|
+
onClick: () => ctx.toggle(),
|
|
40
|
+
children: children ?? text
|
|
41
|
+
}, undefined, false, undefined, this);
|
|
42
|
+
}
|
|
43
|
+
function DatePickerContent({ children, className: cls, class: classProp }) {
|
|
44
|
+
const ctx = useContext(DatePickerContext);
|
|
45
|
+
if (!ctx) {
|
|
46
|
+
throw new Error("<DatePicker.Content> must be used inside <DatePicker>. " + "Ensure it is a direct or nested child of the DatePicker root component.");
|
|
47
|
+
}
|
|
48
|
+
const isOpen = ctx.isOpen();
|
|
49
|
+
return jsxDEV_7x81h0kn("div", {
|
|
50
|
+
ref: ctx.contentRef,
|
|
51
|
+
role: "dialog",
|
|
52
|
+
id: ctx.contentId,
|
|
53
|
+
"data-datepicker-content": "",
|
|
54
|
+
"aria-hidden": isOpen ? "false" : "true",
|
|
55
|
+
"data-state": isOpen ? "open" : "closed",
|
|
56
|
+
style: {
|
|
57
|
+
display: isOpen ? "" : "none",
|
|
58
|
+
zIndex: "50"
|
|
59
|
+
},
|
|
60
|
+
class: cn(ctx.classes?.content, cls ?? classProp),
|
|
61
|
+
children
|
|
62
|
+
}, undefined, false, undefined, this);
|
|
63
|
+
}
|
|
64
|
+
function _toRealDate(val) {
|
|
65
|
+
if (val instanceof Date)
|
|
66
|
+
return val;
|
|
67
|
+
if (val && typeof val === "object" && typeof val.getTime === "function") {
|
|
68
|
+
return new Date(val.getTime());
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function _defaultFormatDate(date) {
|
|
73
|
+
return date.toLocaleDateString();
|
|
74
|
+
}
|
|
75
|
+
function _getDisplayText(value, placeholder, formatDate) {
|
|
76
|
+
if (value === null)
|
|
77
|
+
return placeholder;
|
|
78
|
+
if (value instanceof Date)
|
|
79
|
+
return formatDate(value);
|
|
80
|
+
if ("from" in value)
|
|
81
|
+
return `${formatDate(value.from)} – ${formatDate(value.to)}`;
|
|
82
|
+
return placeholder;
|
|
83
|
+
}
|
|
84
|
+
function _buildCalendar(props, onCalendarValueChange) {
|
|
85
|
+
const initValue = props.defaultValue ?? null;
|
|
86
|
+
const calendarMode = (props.mode ?? "single") === "range" ? "range" : "single";
|
|
87
|
+
const calendarDefaultValue = initValue instanceof Date ? initValue : initValue && ("from" in initValue) ? initValue : undefined;
|
|
88
|
+
const defaultMonth = props.defaultMonth ?? (initValue instanceof Date ? initValue : initValue && ("from" in initValue) ? initValue.from : new Date);
|
|
89
|
+
return ComposedCalendar({
|
|
90
|
+
classes: props.classes?.calendar,
|
|
91
|
+
mode: calendarMode,
|
|
92
|
+
defaultValue: calendarDefaultValue,
|
|
93
|
+
defaultMonth,
|
|
94
|
+
minDate: props.minDate,
|
|
95
|
+
maxDate: props.maxDate,
|
|
96
|
+
disabled: props.disabled,
|
|
97
|
+
captionLayout: props.captionLayout,
|
|
98
|
+
onValueChange: onCalendarValueChange
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function ComposedDatePickerRoot({
|
|
102
|
+
children,
|
|
103
|
+
classes,
|
|
104
|
+
mode = "single",
|
|
105
|
+
defaultValue = undefined,
|
|
106
|
+
defaultMonth: defaultMonthProp,
|
|
107
|
+
minDate,
|
|
108
|
+
maxDate,
|
|
109
|
+
disabled,
|
|
110
|
+
formatDate = _defaultFormatDate,
|
|
111
|
+
placeholder = "Pick a date",
|
|
112
|
+
onValueChange,
|
|
113
|
+
onOpenChange,
|
|
114
|
+
captionLayout
|
|
115
|
+
}) {
|
|
116
|
+
const ids = linkedIds("datepicker");
|
|
117
|
+
const triggerRef = ref();
|
|
118
|
+
const contentRef = ref();
|
|
119
|
+
let isOpen = false;
|
|
120
|
+
let hasValue = defaultValue != null;
|
|
121
|
+
let displayText = _getDisplayText(defaultValue ?? null, placeholder, formatDate);
|
|
122
|
+
const state = {
|
|
123
|
+
value: defaultValue ?? null,
|
|
124
|
+
dismissCleanup: null,
|
|
125
|
+
floatingCleanup: null
|
|
126
|
+
};
|
|
127
|
+
function open() {
|
|
128
|
+
isOpen = true;
|
|
129
|
+
const triggerEl = triggerRef.current;
|
|
130
|
+
const contentEl = contentRef.current;
|
|
131
|
+
if (triggerEl && contentEl) {
|
|
132
|
+
contentEl.style.position = "fixed";
|
|
133
|
+
const result = createFloatingPosition(triggerEl, contentEl, {
|
|
134
|
+
placement: "bottom-start",
|
|
135
|
+
offset: 4
|
|
136
|
+
});
|
|
137
|
+
state.floatingCleanup = result.cleanup;
|
|
138
|
+
state.dismissCleanup = createDismiss({
|
|
139
|
+
onDismiss: close,
|
|
140
|
+
insideElements: [triggerEl, contentEl],
|
|
141
|
+
escapeKey: true
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
onOpenChange?.(true);
|
|
145
|
+
}
|
|
146
|
+
function close() {
|
|
147
|
+
isOpen = false;
|
|
148
|
+
state.floatingCleanup?.();
|
|
149
|
+
state.floatingCleanup = null;
|
|
150
|
+
state.dismissCleanup?.();
|
|
151
|
+
state.dismissCleanup = null;
|
|
152
|
+
onOpenChange?.(false);
|
|
153
|
+
}
|
|
154
|
+
function toggle() {
|
|
155
|
+
if (isOpen)
|
|
156
|
+
close();
|
|
157
|
+
else
|
|
158
|
+
open();
|
|
159
|
+
}
|
|
160
|
+
function handleCalendarValueChange(calValue) {
|
|
161
|
+
if (calValue === null)
|
|
162
|
+
return;
|
|
163
|
+
if (mode === "single") {
|
|
164
|
+
const realDate = _toRealDate(calValue);
|
|
165
|
+
if (realDate) {
|
|
166
|
+
state.value = realDate;
|
|
167
|
+
hasValue = true;
|
|
168
|
+
displayText = _getDisplayText(realDate, placeholder, formatDate);
|
|
169
|
+
onValueChange?.(realDate);
|
|
170
|
+
close();
|
|
171
|
+
}
|
|
172
|
+
} else if (mode === "range" && calValue && "from" in calValue) {
|
|
173
|
+
const raw = calValue;
|
|
174
|
+
const from = _toRealDate(raw.from);
|
|
175
|
+
const to = _toRealDate(raw.to);
|
|
176
|
+
if (from && to) {
|
|
177
|
+
const range = { from, to };
|
|
178
|
+
state.value = range;
|
|
179
|
+
hasValue = true;
|
|
180
|
+
displayText = _getDisplayText(range, placeholder, formatDate);
|
|
181
|
+
onValueChange?.(range);
|
|
182
|
+
if (from.getTime() !== to.getTime()) {
|
|
183
|
+
close();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const calendarEl = _buildCalendar({
|
|
189
|
+
mode,
|
|
190
|
+
defaultValue,
|
|
191
|
+
defaultMonth: defaultMonthProp,
|
|
192
|
+
minDate,
|
|
193
|
+
maxDate,
|
|
194
|
+
disabled,
|
|
195
|
+
classes,
|
|
196
|
+
captionLayout
|
|
197
|
+
}, handleCalendarValueChange);
|
|
198
|
+
const ctx = {
|
|
199
|
+
isOpen: () => isOpen,
|
|
200
|
+
hasValue: () => hasValue,
|
|
201
|
+
displayText: () => displayText,
|
|
202
|
+
contentId: ids.contentId,
|
|
203
|
+
triggerRef,
|
|
204
|
+
contentRef,
|
|
205
|
+
classes,
|
|
206
|
+
open,
|
|
207
|
+
close,
|
|
208
|
+
toggle
|
|
209
|
+
};
|
|
210
|
+
return jsxDEV_7x81h0kn(DatePickerContext.Provider, {
|
|
211
|
+
value: ctx,
|
|
212
|
+
children: jsxDEV_7x81h0kn("span", {
|
|
213
|
+
style: { position: "relative", display: "inline-block" },
|
|
214
|
+
"data-datepicker-root": "",
|
|
215
|
+
children: children ?? jsxDEV_7x81h0kn(Fragment_8vg9x3sq, {
|
|
216
|
+
children: [
|
|
217
|
+
jsxDEV_7x81h0kn(DatePickerTrigger, {}, undefined, false, undefined, this),
|
|
218
|
+
jsxDEV_7x81h0kn(DatePickerContent, {
|
|
219
|
+
children: calendarEl
|
|
220
|
+
}, undefined, false, undefined, this)
|
|
221
|
+
]
|
|
222
|
+
}, undefined, true, undefined, this)
|
|
223
|
+
}, undefined, false, undefined, this)
|
|
224
|
+
}, undefined, false, undefined, this);
|
|
225
|
+
}
|
|
226
|
+
var ComposedDatePicker = Object.assign(ComposedDatePickerRoot, {
|
|
227
|
+
Trigger: DatePickerTrigger,
|
|
228
|
+
Content: DatePickerContent
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export { ComposedDatePicker };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/composed/with-styles.ts
|
|
2
|
+
function withStyles(component, classes) {
|
|
3
|
+
if (!component) {
|
|
4
|
+
throw new Error("withStyles() received an undefined component. " + "This usually means a composed primitive failed to load in the client bundle. " + "Check that @vertz/ui-primitives is installed and its exports resolve correctly.");
|
|
5
|
+
}
|
|
6
|
+
const styled = (props) => {
|
|
7
|
+
const merged = Object.create(null);
|
|
8
|
+
Object.defineProperties(merged, Object.getOwnPropertyDescriptors(props));
|
|
9
|
+
merged.classes = classes;
|
|
10
|
+
return component(merged);
|
|
11
|
+
};
|
|
12
|
+
const subComponents = {};
|
|
13
|
+
for (const key of Object.getOwnPropertyNames(component)) {
|
|
14
|
+
if (key !== "length" && key !== "name" && key !== "prototype" && key !== "__classKeys" && key !== "__elementType") {
|
|
15
|
+
subComponents[key] = component[key];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return Object.assign(styled, subComponents);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { withStyles };
|