@vertz/ui-primitives 0.2.23 → 0.2.25
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-pzx0vpq1.js → chunk-00fqgnq1.js} +6 -11
- package/dist/shared/chunk-1dx23qnr.js +232 -0
- package/dist/shared/chunk-1hm0mbke.js +258 -0
- package/dist/shared/{chunk-ww7k2azn.js → chunk-20kwns82.js} +5 -9
- package/dist/shared/chunk-3jack97k.js +509 -0
- package/dist/shared/{chunk-xs6gp369.js → chunk-455p0jbk.js} +3 -7
- package/dist/shared/chunk-4z006v1j.js +467 -0
- package/dist/shared/{chunk-b25npqer.js → chunk-585ysr70.js} +1 -1
- package/dist/shared/chunk-5964gmv0.js +416 -0
- package/dist/shared/chunk-75pegjs7.js +26 -0
- package/dist/shared/{chunk-mr1tb0dp.js → chunk-7a2nqmeh.js} +1 -1
- package/dist/shared/chunk-7wem1bhb.js +252 -0
- package/dist/shared/{chunk-7cb3z0s8.js → chunk-8evj43jn.js} +5 -8
- package/dist/shared/chunk-8t0nm721.js +152 -0
- package/dist/shared/chunk-94twh4s4.js +28 -0
- package/dist/shared/chunk-98y1sw9y.js +398 -0
- package/dist/shared/chunk-9eedsnnk.js +164 -0
- package/dist/shared/{chunk-8c01c8mb.js → chunk-9hv3vc72.js} +0 -2
- package/dist/shared/{chunk-4894pmy6.js → chunk-9ydd4pn3.js} +6 -1
- package/dist/shared/chunk-aa3w85hn.js +321 -0
- package/dist/shared/chunk-axpbdpgx.js +177 -0
- package/dist/shared/chunk-b4zzg457.js +410 -0
- package/dist/shared/chunk-bc2qqkhr.js +194 -0
- package/dist/shared/chunk-brk0drrk.js +202 -0
- package/dist/shared/chunk-czv0kqj4.js +107 -0
- package/dist/shared/chunk-d83ag07h.js +189 -0
- package/dist/shared/{chunk-3kwh27dv.js → chunk-de18ashk.js} +0 -1
- package/dist/shared/{chunk-cgb2j94g.js → chunk-dvk4h36t.js} +0 -1
- package/dist/shared/chunk-e6660g7e.js +179 -0
- package/dist/shared/{chunk-3h1mxp95.js → chunk-eq4d9b0w.js} +0 -1
- package/dist/shared/chunk-ev367pq3.js +102 -0
- package/dist/shared/chunk-fjykbv0v.js +214 -0
- package/dist/shared/chunk-ghkw5bjq.js +55 -0
- package/dist/shared/chunk-gqb1n1hj.js +60 -0
- package/dist/shared/chunk-hfjtkytb.js +310 -0
- package/dist/shared/chunk-hpvjfj0j.js +31 -0
- package/dist/shared/chunk-hxmxvp56.js +67 -0
- package/dist/shared/chunk-j9m2f0rd.js +162 -0
- package/dist/shared/chunk-jpyjk616.js +52 -0
- package/dist/shared/{chunk-ttb2tt03.js → chunk-jsa3byag.js} +1 -1
- package/dist/shared/{chunk-9gfp3ffv.js → chunk-jzy1bkdk.js} +0 -1
- package/dist/shared/{chunk-f2vx4tpw.js → chunk-knzg86am.js} +5 -5
- package/dist/shared/chunk-metxdt5x.js +28 -0
- package/dist/shared/chunk-mhn2aazf.js +353 -0
- package/dist/shared/chunk-mtx2cfbx.js +175 -0
- package/dist/shared/chunk-nsmvdxgp.js +213 -0
- package/dist/shared/{chunk-pn6shbcs.js → chunk-pdzmg245.js} +1 -5
- package/dist/shared/chunk-pzknpa1y.js +327 -0
- package/dist/shared/chunk-q1ff3xp3.js +95 -0
- package/dist/shared/chunk-q7xbcj9q.js +7 -0
- package/dist/shared/{chunk-p0x7hgv6.js → chunk-qhnany7w.js} +0 -2
- package/dist/shared/chunk-qrm43tr3.js +357 -0
- package/dist/shared/{chunk-xa1b96mb.js → chunk-qsp7sfhp.js} +2 -2
- package/dist/shared/{chunk-j902w020.js → chunk-qwqnjjg8.js} +1 -1
- package/dist/shared/{chunk-h3v10x04.js → chunk-r0rz7z03.js} +6 -11
- package/dist/shared/chunk-r3ngaa64.js +418 -0
- package/dist/shared/chunk-r3pffzss.js +13 -0
- package/dist/shared/chunk-rrt62bp0.js +353 -0
- package/dist/shared/chunk-s24gkmna.js +131 -0
- package/dist/shared/chunk-s62e7jf4.js +30 -0
- package/dist/shared/chunk-spng4yb9.js +73 -0
- package/dist/shared/chunk-v0b5pkcq.js +30 -0
- package/dist/shared/chunk-v11kd39k.js +162 -0
- package/dist/shared/{chunk-0mcr52hc.js → chunk-vef3sepw.js} +17 -1
- package/dist/shared/chunk-vkscwzpr.js +294 -0
- package/dist/shared/chunk-vv187snj.js +112 -0
- package/dist/shared/chunk-wqsek87j.js +311 -0
- package/dist/shared/chunk-wtkxz2te.js +157 -0
- package/dist/shared/chunk-y1hpsqzy.js +185 -0
- package/dist/shared/chunk-yfzddvxc.js +71 -0
- package/dist/src/accordion/accordion-composed.d.ts +30 -0
- package/dist/src/accordion/accordion-composed.js +6 -0
- package/dist/src/accordion/accordion.js +1 -1
- package/dist/src/alert/alert-composed.d.ts +26 -0
- package/dist/src/alert/alert-composed.js +6 -0
- package/dist/src/alert-dialog/alert-dialog-composed.d.ts +40 -0
- package/dist/src/alert-dialog/alert-dialog-composed.js +6 -0
- package/dist/src/avatar/avatar-composed.d.ts +33 -0
- package/dist/src/avatar/avatar-composed.js +6 -0
- package/dist/src/badge/badge-composed.d.ts +33 -0
- package/dist/src/badge/badge-composed.js +6 -0
- package/dist/src/breadcrumb/breadcrumb-composed.d.ts +34 -0
- package/dist/src/breadcrumb/breadcrumb-composed.js +6 -0
- package/dist/src/button/button-composed.d.ts +34 -0
- package/dist/src/button/button-composed.js +6 -0
- package/dist/src/calendar/calendar-composed.d.ts +42 -0
- package/dist/src/calendar/calendar-composed.js +6 -0
- package/dist/src/calendar/calendar.js +1 -1
- package/dist/src/card/card-composed.d.ts +34 -0
- package/dist/src/card/card-composed.js +6 -0
- package/dist/src/carousel/carousel-composed.d.ts +32 -0
- package/dist/src/carousel/carousel-composed.js +6 -0
- package/dist/src/carousel/carousel.js +1 -1
- package/dist/src/checkbox/checkbox-composed.d.ts +18 -0
- package/dist/src/checkbox/checkbox-composed.js +6 -0
- package/dist/src/collapsible/collapsible-composed.d.ts +26 -0
- package/dist/src/collapsible/collapsible-composed.js +6 -0
- package/dist/src/combobox/combobox-composed.d.ts +30 -0
- package/dist/src/combobox/combobox-composed.js +6 -0
- package/dist/src/combobox/combobox.js +1 -1
- package/dist/src/command/command-composed.d.ts +67 -0
- package/dist/src/command/command-composed.js +6 -0
- package/dist/src/command/command.js +1 -1
- package/dist/src/composed/with-styles.d.ts +38 -0
- package/dist/src/composed/with-styles.js +6 -0
- package/dist/src/context-menu/context-menu-composed.d.ts +51 -0
- package/dist/src/context-menu/context-menu-composed.js +6 -0
- package/dist/src/context-menu/context-menu.js +1 -1
- package/dist/src/date-picker/date-picker-composed.d.ts +77 -0
- package/dist/src/date-picker/date-picker-composed.js +6 -0
- package/dist/src/date-picker/date-picker.js +1 -1
- package/dist/src/dialog/dialog-composed.d.ts +36 -0
- package/dist/src/dialog/dialog-composed.js +6 -0
- package/dist/src/dialog/dialog-stack-parts.d.ts +16 -0
- package/dist/src/dialog/dialog-stack-parts.js +18 -0
- package/dist/src/dropdown-menu/dropdown-menu-composed.d.ts +51 -0
- package/dist/src/dropdown-menu/dropdown-menu-composed.js +6 -0
- package/dist/src/dropdown-menu/dropdown-menu.js +1 -1
- package/dist/src/empty-state/empty-state-composed.d.ts +30 -0
- package/dist/src/empty-state/empty-state-composed.js +6 -0
- package/dist/src/form-group/form-group-composed.d.ts +24 -0
- package/dist/src/form-group/form-group-composed.js +6 -0
- package/dist/src/hover-card/hover-card-composed.d.ts +38 -0
- package/dist/src/hover-card/hover-card-composed.js +6 -0
- package/dist/src/hover-card/hover-card.js +1 -1
- package/dist/src/index.d.ts +1312 -812
- package/dist/src/index.js +79 -6566
- package/dist/src/input/input-composed.d.ts +35 -0
- package/dist/src/input/input-composed.js +6 -0
- package/dist/src/label/label-composed.d.ts +32 -0
- package/dist/src/label/label-composed.js +6 -0
- package/dist/src/list/list-composed.d.ts +34 -0
- package/dist/src/list/list-composed.js +6 -0
- package/dist/src/menu/menu-composed.d.ts +51 -0
- package/dist/src/menu/menu-composed.js +6 -0
- package/dist/src/menu/menu.js +1 -1
- package/dist/src/menubar/menubar-composed.d.ts +56 -0
- package/dist/src/menubar/menubar-composed.js +6 -0
- package/dist/src/menubar/menubar.js +1 -1
- package/dist/src/navigation-menu/navigation-menu-composed.d.ts +56 -0
- package/dist/src/navigation-menu/navigation-menu-composed.js +6 -0
- package/dist/src/navigation-menu/navigation-menu.js +1 -1
- package/dist/src/pagination/pagination-composed.d.ts +30 -0
- package/dist/src/pagination/pagination-composed.js +6 -0
- package/dist/src/popover/popover-composed.d.ts +36 -0
- package/dist/src/popover/popover-composed.js +6 -0
- package/dist/src/popover/popover.js +1 -1
- package/dist/src/progress/progress-composed.d.ts +17 -0
- package/dist/src/progress/progress-composed.js +6 -0
- package/dist/src/radio/radio-composed.d.ts +24 -0
- package/dist/src/radio/radio-composed.js +6 -0
- package/dist/src/radio/radio.js +1 -1
- package/dist/src/resizable-panel/resizable-panel-composed.d.ts +33 -0
- package/dist/src/resizable-panel/resizable-panel-composed.js +6 -0
- package/dist/src/resizable-panel/resizable-panel.js +1 -1
- package/dist/src/scroll-area/scroll-area-composed.d.ts +17 -0
- package/dist/src/scroll-area/scroll-area-composed.js +6 -0
- package/dist/src/scroll-area/scroll-area.js +1 -1
- package/dist/src/select/select-composed.d.ts +53 -0
- package/dist/src/select/select-composed.js +6 -0
- package/dist/src/select/select.js +1 -1
- package/dist/src/separator/separator-composed.d.ts +32 -0
- package/dist/src/separator/separator-composed.js +6 -0
- package/dist/src/sheet/sheet-composed.d.ts +34 -0
- package/dist/src/sheet/sheet-composed.js +6 -0
- package/dist/src/skeleton/skeleton-composed.d.ts +65 -0
- package/dist/src/skeleton/skeleton-composed.js +6 -0
- package/dist/src/slider/slider-composed.d.ts +22 -0
- package/dist/src/slider/slider-composed.js +6 -0
- package/dist/src/switch/switch-composed.d.ts +17 -0
- package/dist/src/switch/switch-composed.js +6 -0
- package/dist/src/table/table-composed.d.ts +34 -0
- package/dist/src/table/table-composed.js +6 -0
- package/dist/src/tabs/tabs-composed.d.ts +33 -0
- package/dist/src/tabs/tabs-composed.js +6 -0
- package/dist/src/tabs/tabs.js +1 -1
- package/dist/src/textarea/textarea-composed.d.ts +35 -0
- package/dist/src/textarea/textarea-composed.js +6 -0
- package/dist/src/toast/toast.js +1 -1
- package/dist/src/toggle/toggle-composed.d.ts +16 -0
- package/dist/src/toggle/toggle-composed.js +6 -0
- package/dist/src/toggle-group/toggle-group-composed.d.ts +24 -0
- package/dist/src/toggle-group/toggle-group-composed.js +6 -0
- package/dist/src/toggle-group/toggle-group.js +1 -1
- package/dist/src/tooltip/tooltip-composed.d.ts +36 -0
- package/dist/src/tooltip/tooltip-composed.js +6 -0
- package/dist/src/tooltip/tooltip.js +1 -1
- package/dist/src/utils.js +1 -1
- package/package.json +3 -3
- package/dist/shared/chunk-56reyd5r.js +0 -64
- package/dist/shared/chunk-mgr904ap.js +0 -370
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-q7xbcj9q.js";
|
|
4
|
+
import {
|
|
5
|
+
Keys,
|
|
6
|
+
isKey
|
|
7
|
+
} from "./chunk-7867pr13.js";
|
|
8
|
+
import {
|
|
9
|
+
uniqueId
|
|
10
|
+
} from "./chunk-8y1jf6xr.js";
|
|
11
|
+
|
|
12
|
+
// src/toggle-group/toggle-group-composed.tsx
|
|
13
|
+
import { computed, signal } from "@vertz/ui";
|
|
14
|
+
import { __append, __attr, __child, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __on, __pushMountFrame } from "@vertz/ui/internals";
|
|
15
|
+
import { createContext, useContext } from "@vertz/ui";
|
|
16
|
+
var ToggleGroupContext = createContext(undefined, "@vertz/ui-primitives::ToggleGroupContext");
|
|
17
|
+
function useToggleGroupContext(componentName) {
|
|
18
|
+
const ctx = useContext(ToggleGroupContext);
|
|
19
|
+
if (!ctx) {
|
|
20
|
+
throw new Error(`<ToggleGroup.${componentName}> must be used inside <ToggleGroup>. ` + "Ensure it is a direct or nested child of the ToggleGroup root component.");
|
|
21
|
+
}
|
|
22
|
+
return ctx;
|
|
23
|
+
}
|
|
24
|
+
function ToggleGroupItem(__props) {
|
|
25
|
+
const __mfDepth = __pushMountFrame();
|
|
26
|
+
try {
|
|
27
|
+
const ctx = useToggleGroupContext("Item");
|
|
28
|
+
const isOn = computed(() => ctx.selectedValues.includes(__props.value));
|
|
29
|
+
const isFirst = ctx.claimFirstItem();
|
|
30
|
+
const __mfResult0 = (() => {
|
|
31
|
+
const __el0 = __element("button");
|
|
32
|
+
__el0.setAttribute("type", "button");
|
|
33
|
+
__el0.setAttribute("data-togglegroup-item", "");
|
|
34
|
+
__attr(__el0, "data-value", () => __props.value);
|
|
35
|
+
__attr(__el0, "aria-pressed", () => isOn.value ? "true" : "false");
|
|
36
|
+
__attr(__el0, "data-state", () => isOn.value ? "on" : "off");
|
|
37
|
+
{
|
|
38
|
+
const __v = ctx.disabled;
|
|
39
|
+
if (__v != null && __v !== false)
|
|
40
|
+
__el0.setAttribute("disabled", __v === true ? "" : __v);
|
|
41
|
+
}
|
|
42
|
+
{
|
|
43
|
+
const __v = ctx.disabled ? "true" : undefined;
|
|
44
|
+
if (__v != null && __v !== false)
|
|
45
|
+
__el0.setAttribute("aria-disabled", __v === true ? "" : __v);
|
|
46
|
+
}
|
|
47
|
+
{
|
|
48
|
+
const __v = isFirst ? "0" : "-1";
|
|
49
|
+
if (__v != null && __v !== false)
|
|
50
|
+
__el0.setAttribute("tabindex", __v === true ? "" : __v);
|
|
51
|
+
}
|
|
52
|
+
{
|
|
53
|
+
const __v = cn(ctx.classes?.item);
|
|
54
|
+
if (__v != null && __v !== false)
|
|
55
|
+
__el0.setAttribute("class", __v === true ? "" : __v);
|
|
56
|
+
}
|
|
57
|
+
__on(__el0, "click", () => ctx.toggle(__props.value));
|
|
58
|
+
__enterChildren(__el0);
|
|
59
|
+
__append(__el0, __child(() => __props.children));
|
|
60
|
+
__exitChildren();
|
|
61
|
+
return __el0;
|
|
62
|
+
})();
|
|
63
|
+
__flushMountFrame();
|
|
64
|
+
return __mfResult0;
|
|
65
|
+
} catch (__mfErr) {
|
|
66
|
+
__discardMountFrame(__mfDepth);
|
|
67
|
+
throw __mfErr;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function ComposedToggleGroupRoot(__props) {
|
|
71
|
+
const __mfDepth = __pushMountFrame();
|
|
72
|
+
try {
|
|
73
|
+
let toggle = function(itemValue) {
|
|
74
|
+
if (__props.disabled ?? false)
|
|
75
|
+
return;
|
|
76
|
+
const current = [...selectedValues.value];
|
|
77
|
+
const idx = current.indexOf(itemValue);
|
|
78
|
+
if ((__props.type ?? "single") === "single") {
|
|
79
|
+
if (idx >= 0) {
|
|
80
|
+
current.length = 0;
|
|
81
|
+
} else {
|
|
82
|
+
current.length = 0;
|
|
83
|
+
current.push(itemValue);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
if (idx >= 0) {
|
|
87
|
+
current.splice(idx, 1);
|
|
88
|
+
} else {
|
|
89
|
+
current.push(itemValue);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
selectedValues.value = current;
|
|
93
|
+
__props.onValueChange?.(current);
|
|
94
|
+
};
|
|
95
|
+
const selectedValues = signal([...__props.defaultValue ?? []], "selectedValues");
|
|
96
|
+
const _state = { firstItemClaimed: false };
|
|
97
|
+
const ctx = {
|
|
98
|
+
selectedValues,
|
|
99
|
+
classes: __props.classes,
|
|
100
|
+
disabled: __props.disabled ?? false,
|
|
101
|
+
toggle,
|
|
102
|
+
claimFirstItem: () => {
|
|
103
|
+
if (_state.firstItemClaimed)
|
|
104
|
+
return false;
|
|
105
|
+
_state.firstItemClaimed = true;
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const __mfResult0 = ToggleGroupContext.Provider({ get value() {
|
|
110
|
+
return ctx;
|
|
111
|
+
}, children: () => (() => {
|
|
112
|
+
const __el0 = __element("div");
|
|
113
|
+
__el0.setAttribute("role", "group");
|
|
114
|
+
{
|
|
115
|
+
const __v = uniqueId("toggle-group");
|
|
116
|
+
if (__v != null && __v !== false)
|
|
117
|
+
__el0.setAttribute("id", __v === true ? "" : __v);
|
|
118
|
+
}
|
|
119
|
+
__attr(__el0, "data-orientation", () => __props.orientation ?? "horizontal");
|
|
120
|
+
__el0.setAttribute("data-togglegroup-root", "");
|
|
121
|
+
__attr(__el0, "class", () => cn(__props.classes?.root));
|
|
122
|
+
__on(__el0, "keydown", (event) => {
|
|
123
|
+
if (!isKey(event, Keys.ArrowLeft, Keys.ArrowRight, Keys.ArrowUp, Keys.ArrowDown, Keys.Home, Keys.End)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
const root = event.currentTarget;
|
|
128
|
+
const items = [...root.querySelectorAll("[data-togglegroup-item]")];
|
|
129
|
+
const currentIdx = items.indexOf(document.activeElement);
|
|
130
|
+
if (currentIdx < 0)
|
|
131
|
+
return;
|
|
132
|
+
const len = items.length;
|
|
133
|
+
let nextIdx;
|
|
134
|
+
if (isKey(event, Keys.ArrowRight, Keys.ArrowDown)) {
|
|
135
|
+
nextIdx = (currentIdx + 1) % len;
|
|
136
|
+
} else if (isKey(event, Keys.ArrowLeft, Keys.ArrowUp)) {
|
|
137
|
+
nextIdx = (currentIdx - 1 + len) % len;
|
|
138
|
+
} else if (isKey(event, Keys.Home)) {
|
|
139
|
+
nextIdx = 0;
|
|
140
|
+
} else if (isKey(event, Keys.End)) {
|
|
141
|
+
nextIdx = len - 1;
|
|
142
|
+
} else {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
items.forEach((el, j) => el.setAttribute("tabindex", j === nextIdx ? "0" : "-1"));
|
|
146
|
+
items[nextIdx]?.focus();
|
|
147
|
+
});
|
|
148
|
+
__enterChildren(__el0);
|
|
149
|
+
__append(__el0, __child(() => __props.children));
|
|
150
|
+
__exitChildren();
|
|
151
|
+
return __el0;
|
|
152
|
+
})() });
|
|
153
|
+
__flushMountFrame();
|
|
154
|
+
return __mfResult0;
|
|
155
|
+
} catch (__mfErr) {
|
|
156
|
+
__discardMountFrame(__mfDepth);
|
|
157
|
+
throw __mfErr;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
var ComposedToggleGroup = Object.assign(ComposedToggleGroupRoot, {
|
|
161
|
+
Item: ToggleGroupItem
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
export { ComposedToggleGroup };
|
|
@@ -197,8 +197,6 @@ function TabsRoot(options = {}) {
|
|
|
197
197
|
triggers.push(trig);
|
|
198
198
|
panels.push(panel);
|
|
199
199
|
tabValues.push(value);
|
|
200
|
-
list.appendChild(trig);
|
|
201
|
-
root.appendChild(panel);
|
|
202
200
|
setRovingTabindex(triggers, triggers.findIndex((t) => tabValues[triggers.indexOf(t)] === state.value.peek()));
|
|
203
201
|
return { trigger: trig, panel };
|
|
204
202
|
}
|
|
@@ -27,6 +27,7 @@ function AccordionRoot(options = {}) {
|
|
|
27
27
|
if (!entry)
|
|
28
28
|
return;
|
|
29
29
|
const { trigger: t, content: c } = entry;
|
|
30
|
+
c.removeAttribute("data-initial");
|
|
30
31
|
if (open) {
|
|
31
32
|
setHidden(c, false);
|
|
32
33
|
}
|
|
@@ -123,6 +124,11 @@ function AccordionRoot(options = {}) {
|
|
|
123
124
|
if (__v != null && __v !== false)
|
|
124
125
|
__el2.setAttribute("data-state", __v === true ? "" : __v);
|
|
125
126
|
}
|
|
127
|
+
{
|
|
128
|
+
const __v = isOpen ? "" : undefined;
|
|
129
|
+
if (__v != null && __v !== false)
|
|
130
|
+
__el2.setAttribute("data-initial", __v === true ? "" : __v);
|
|
131
|
+
}
|
|
126
132
|
{
|
|
127
133
|
const __v = { display: isOpen ? "" : "none" };
|
|
128
134
|
if (__v != null && __v !== false)
|
|
@@ -145,7 +151,6 @@ function AccordionRoot(options = {}) {
|
|
|
145
151
|
})();
|
|
146
152
|
itemMap.set(value, { trigger, content });
|
|
147
153
|
triggers.push(trigger);
|
|
148
|
-
root.appendChild(item);
|
|
149
154
|
if (isOpen) {
|
|
150
155
|
requestAnimationFrame(() => {
|
|
151
156
|
const height = content.scrollHeight;
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-q7xbcj9q.js";
|
|
4
|
+
import {
|
|
5
|
+
createDismiss
|
|
6
|
+
} from "./chunk-a6wp8c32.js";
|
|
7
|
+
import {
|
|
8
|
+
createFloatingPosition,
|
|
9
|
+
virtualElement
|
|
10
|
+
} from "./chunk-vef3sepw.js";
|
|
11
|
+
import {
|
|
12
|
+
Keys,
|
|
13
|
+
handleListNavigation,
|
|
14
|
+
isKey
|
|
15
|
+
} from "./chunk-7867pr13.js";
|
|
16
|
+
import {
|
|
17
|
+
linkedIds
|
|
18
|
+
} from "./chunk-8y1jf6xr.js";
|
|
19
|
+
|
|
20
|
+
// src/context-menu/context-menu-composed.tsx
|
|
21
|
+
import { computed, signal } from "@vertz/ui";
|
|
22
|
+
import { __append, __attr, __child, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __on, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
|
|
23
|
+
import { createContext, onMount, ref, useContext } from "@vertz/ui";
|
|
24
|
+
var ContextMenuContext = createContext(undefined, "@vertz/ui-primitives::ContextMenuContext");
|
|
25
|
+
function useContextMenuContext(componentName) {
|
|
26
|
+
const ctx = useContext(ContextMenuContext);
|
|
27
|
+
if (!ctx) {
|
|
28
|
+
throw new Error(`<ContextMenu.${componentName}> must be used inside <ContextMenu>. ` + "Ensure it is a direct or nested child of the ContextMenu root component.");
|
|
29
|
+
}
|
|
30
|
+
return ctx;
|
|
31
|
+
}
|
|
32
|
+
function ContextMenuTrigger(__props) {
|
|
33
|
+
const __mfDepth = __pushMountFrame();
|
|
34
|
+
try {
|
|
35
|
+
const ctx = useContextMenuContext("Trigger");
|
|
36
|
+
const el = computed(() => (() => {
|
|
37
|
+
const __el0 = __element("div");
|
|
38
|
+
{
|
|
39
|
+
const __v = { display: "contents" };
|
|
40
|
+
if (__v != null && __v !== false)
|
|
41
|
+
__el0.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
|
|
42
|
+
}
|
|
43
|
+
__el0.setAttribute("data-part", "trigger");
|
|
44
|
+
__el0.setAttribute("data-contextmenu-trigger", "");
|
|
45
|
+
__enterChildren(__el0);
|
|
46
|
+
__append(__el0, __child(() => __props.children));
|
|
47
|
+
__exitChildren();
|
|
48
|
+
return __el0;
|
|
49
|
+
})());
|
|
50
|
+
onMount(() => {
|
|
51
|
+
const triggerEl = el.value;
|
|
52
|
+
function handleContextMenu(e) {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
ctx.open(e.clientX, e.clientY);
|
|
55
|
+
}
|
|
56
|
+
triggerEl.addEventListener("contextmenu", handleContextMenu);
|
|
57
|
+
return () => triggerEl.removeEventListener("contextmenu", handleContextMenu);
|
|
58
|
+
});
|
|
59
|
+
const __mfResult0 = el.value;
|
|
60
|
+
__flushMountFrame();
|
|
61
|
+
return __mfResult0;
|
|
62
|
+
} catch (__mfErr) {
|
|
63
|
+
__discardMountFrame(__mfDepth);
|
|
64
|
+
throw __mfErr;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function ContextMenuContent(__props) {
|
|
68
|
+
const __mfDepth = __pushMountFrame();
|
|
69
|
+
try {
|
|
70
|
+
const ctx = useContextMenuContext("Content");
|
|
71
|
+
const instanceIndex = ctx._contentCount.value++;
|
|
72
|
+
if (instanceIndex > 0) {
|
|
73
|
+
console.warn("Duplicate <ContextMenu.Content> detected – only the first is used");
|
|
74
|
+
}
|
|
75
|
+
const el = computed(() => (() => {
|
|
76
|
+
const __el0 = __element("div");
|
|
77
|
+
ctx.contentRef.current = __el0;
|
|
78
|
+
__el0.setAttribute("role", "menu");
|
|
79
|
+
__el0.setAttribute("tabindex", "-1");
|
|
80
|
+
{
|
|
81
|
+
const __v = ctx.contentId;
|
|
82
|
+
if (__v != null && __v !== false)
|
|
83
|
+
__el0.setAttribute("id", __v === true ? "" : __v);
|
|
84
|
+
}
|
|
85
|
+
__el0.setAttribute("data-contextmenu-content", "");
|
|
86
|
+
__el0.setAttribute("aria-hidden", "true");
|
|
87
|
+
__el0.setAttribute("data-state", "closed");
|
|
88
|
+
{
|
|
89
|
+
const __v = { display: "none" };
|
|
90
|
+
if (__v != null && __v !== false)
|
|
91
|
+
__el0.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
|
|
92
|
+
}
|
|
93
|
+
__attr(__el0, "class", () => cn(ctx.classes?.content, __props.className ?? __props.class));
|
|
94
|
+
__on(__el0, "keydown", (event) => {
|
|
95
|
+
if (isKey(event, Keys.Escape, Keys.Tab)) {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
ctx.close();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const el2 = event.currentTarget ?? event.target;
|
|
101
|
+
const items = [...el2.querySelectorAll('[role="menuitem"]')];
|
|
102
|
+
const focusedIdx = items.indexOf(document.activeElement);
|
|
103
|
+
if (isKey(event, Keys.Enter, Keys.Space)) {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
const active = items[focusedIdx];
|
|
106
|
+
if (active) {
|
|
107
|
+
const val = active.getAttribute("data-value");
|
|
108
|
+
if (val !== null) {
|
|
109
|
+
ctx.onSelect?.(val);
|
|
110
|
+
ctx.close();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
handleListNavigation(event, items, { orientation: "vertical" });
|
|
116
|
+
});
|
|
117
|
+
__enterChildren(__el0);
|
|
118
|
+
__append(__el0, __child(() => __props.children));
|
|
119
|
+
__exitChildren();
|
|
120
|
+
return __el0;
|
|
121
|
+
})());
|
|
122
|
+
const __mfResult0 = el.value;
|
|
123
|
+
__flushMountFrame();
|
|
124
|
+
return __mfResult0;
|
|
125
|
+
} catch (__mfErr) {
|
|
126
|
+
__discardMountFrame(__mfDepth);
|
|
127
|
+
throw __mfErr;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function ContextMenuItem(__props) {
|
|
131
|
+
const __mfDepth = __pushMountFrame();
|
|
132
|
+
try {
|
|
133
|
+
const ctx = useContextMenuContext("Item");
|
|
134
|
+
const __mfResult0 = (() => {
|
|
135
|
+
const __el0 = __element("div");
|
|
136
|
+
__el0.setAttribute("role", "menuitem");
|
|
137
|
+
__attr(__el0, "data-value", () => __props.value);
|
|
138
|
+
__el0.setAttribute("tabindex", "-1");
|
|
139
|
+
__attr(__el0, "class", () => cn(ctx.classes?.item, __props.className ?? __props.class));
|
|
140
|
+
__on(__el0, "click", () => {
|
|
141
|
+
ctx.onSelect?.(__props.value);
|
|
142
|
+
ctx.close();
|
|
143
|
+
});
|
|
144
|
+
__enterChildren(__el0);
|
|
145
|
+
__append(__el0, __child(() => __props.children));
|
|
146
|
+
__exitChildren();
|
|
147
|
+
return __el0;
|
|
148
|
+
})();
|
|
149
|
+
__flushMountFrame();
|
|
150
|
+
return __mfResult0;
|
|
151
|
+
} catch (__mfErr) {
|
|
152
|
+
__discardMountFrame(__mfDepth);
|
|
153
|
+
throw __mfErr;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function ContextMenuGroup(__props) {
|
|
157
|
+
const __mfDepth = __pushMountFrame();
|
|
158
|
+
try {
|
|
159
|
+
const ctx = useContextMenuContext("Group");
|
|
160
|
+
const __mfResult0 = (() => {
|
|
161
|
+
const __el0 = __element("div");
|
|
162
|
+
__el0.setAttribute("role", "group");
|
|
163
|
+
__attr(__el0, "aria-label", () => __props.label);
|
|
164
|
+
__attr(__el0, "class", () => cn(ctx.classes?.group, __props.className ?? __props.class));
|
|
165
|
+
__enterChildren(__el0);
|
|
166
|
+
__append(__el0, __child(() => __props.children));
|
|
167
|
+
__exitChildren();
|
|
168
|
+
return __el0;
|
|
169
|
+
})();
|
|
170
|
+
__flushMountFrame();
|
|
171
|
+
return __mfResult0;
|
|
172
|
+
} catch (__mfErr) {
|
|
173
|
+
__discardMountFrame(__mfDepth);
|
|
174
|
+
throw __mfErr;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function ContextMenuLabel(__props) {
|
|
178
|
+
const __mfDepth = __pushMountFrame();
|
|
179
|
+
try {
|
|
180
|
+
const { classes } = useContextMenuContext("Label");
|
|
181
|
+
const __mfResult0 = (() => {
|
|
182
|
+
const __el0 = __element("div");
|
|
183
|
+
__el0.setAttribute("role", "none");
|
|
184
|
+
__attr(__el0, "class", () => cn(classes?.label, __props.className ?? __props.class));
|
|
185
|
+
__enterChildren(__el0);
|
|
186
|
+
__append(__el0, __child(() => __props.children));
|
|
187
|
+
__exitChildren();
|
|
188
|
+
return __el0;
|
|
189
|
+
})();
|
|
190
|
+
__flushMountFrame();
|
|
191
|
+
return __mfResult0;
|
|
192
|
+
} catch (__mfErr) {
|
|
193
|
+
__discardMountFrame(__mfDepth);
|
|
194
|
+
throw __mfErr;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function ContextMenuSeparator(__props) {
|
|
198
|
+
const __mfDepth = __pushMountFrame();
|
|
199
|
+
try {
|
|
200
|
+
const { classes } = useContextMenuContext("Separator");
|
|
201
|
+
const __mfResult0 = (() => {
|
|
202
|
+
const __el0 = __element("hr");
|
|
203
|
+
__el0.setAttribute("role", "separator");
|
|
204
|
+
__attr(__el0, "class", () => cn(classes?.separator, __props.className ?? __props.class));
|
|
205
|
+
return __el0;
|
|
206
|
+
})();
|
|
207
|
+
__flushMountFrame();
|
|
208
|
+
return __mfResult0;
|
|
209
|
+
} catch (__mfErr) {
|
|
210
|
+
__discardMountFrame(__mfDepth);
|
|
211
|
+
throw __mfErr;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function updateContentDOM(el, isOpen) {
|
|
215
|
+
el.setAttribute("data-state", isOpen ? "open" : "closed");
|
|
216
|
+
el.setAttribute("aria-hidden", isOpen ? "false" : "true");
|
|
217
|
+
el.style.display = isOpen ? "" : "none";
|
|
218
|
+
}
|
|
219
|
+
function ComposedContextMenuRoot(__props) {
|
|
220
|
+
const __mfDepth = __pushMountFrame();
|
|
221
|
+
try {
|
|
222
|
+
let getContentEl = function() {
|
|
223
|
+
return contentRef.current ?? null;
|
|
224
|
+
}, getItems = function() {
|
|
225
|
+
const content = getContentEl();
|
|
226
|
+
if (!content)
|
|
227
|
+
return [];
|
|
228
|
+
return [...content.querySelectorAll('[role="menuitem"]')];
|
|
229
|
+
}, updateActiveItem = function(items, index) {
|
|
230
|
+
items.forEach((item, i) => {
|
|
231
|
+
item.setAttribute("tabindex", i === index ? "0" : "-1");
|
|
232
|
+
});
|
|
233
|
+
}, open = function(x, y) {
|
|
234
|
+
isOpen.value = true;
|
|
235
|
+
state.activeIndex = -1;
|
|
236
|
+
__props.onOpenChange?.(true);
|
|
237
|
+
const contentEl = getContentEl();
|
|
238
|
+
if (contentEl) {
|
|
239
|
+
updateContentDOM(contentEl, true);
|
|
240
|
+
}
|
|
241
|
+
queueMicrotask(() => {
|
|
242
|
+
const el = contentEl ?? getContentEl();
|
|
243
|
+
if (!el)
|
|
244
|
+
return;
|
|
245
|
+
const effectivePositioning = {
|
|
246
|
+
...__props.positioning ?? {},
|
|
247
|
+
placement: __props.positioning?.placement ?? "bottom-start"
|
|
248
|
+
};
|
|
249
|
+
const result = createFloatingPosition(virtualElement(x, y), el, effectivePositioning);
|
|
250
|
+
state.floatingCleanup = result.cleanup;
|
|
251
|
+
state.dismissCleanup = createDismiss({
|
|
252
|
+
onDismiss: close,
|
|
253
|
+
insideElements: [el],
|
|
254
|
+
escapeKey: false
|
|
255
|
+
});
|
|
256
|
+
const items = getItems();
|
|
257
|
+
updateActiveItem(items, -1);
|
|
258
|
+
el.focus();
|
|
259
|
+
});
|
|
260
|
+
}, close = function() {
|
|
261
|
+
isOpen.value = false;
|
|
262
|
+
state.floatingCleanup?.();
|
|
263
|
+
state.floatingCleanup = null;
|
|
264
|
+
state.dismissCleanup?.();
|
|
265
|
+
state.dismissCleanup = null;
|
|
266
|
+
__props.onOpenChange?.(false);
|
|
267
|
+
const contentEl = getContentEl();
|
|
268
|
+
if (contentEl) {
|
|
269
|
+
updateContentDOM(contentEl, false);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
const ids = linkedIds("ctxmenu");
|
|
273
|
+
const contentRef = ref();
|
|
274
|
+
const isOpen = signal(false, "isOpen");
|
|
275
|
+
const state = { activeIndex: -1, floatingCleanup: null, dismissCleanup: null };
|
|
276
|
+
const ctx = {
|
|
277
|
+
isOpen,
|
|
278
|
+
contentId: ids.contentId,
|
|
279
|
+
contentRef,
|
|
280
|
+
classes: __props.classes,
|
|
281
|
+
onSelect: __props.onSelect,
|
|
282
|
+
open,
|
|
283
|
+
close,
|
|
284
|
+
_contentCount: { value: 0 }
|
|
285
|
+
};
|
|
286
|
+
const __mfResult0 = ContextMenuContext.Provider({ get value() {
|
|
287
|
+
return ctx;
|
|
288
|
+
}, children: () => (() => {
|
|
289
|
+
const __el0 = __element("span");
|
|
290
|
+
{
|
|
291
|
+
const __v = { display: "contents" };
|
|
292
|
+
if (__v != null && __v !== false)
|
|
293
|
+
__el0.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
|
|
294
|
+
}
|
|
295
|
+
{
|
|
296
|
+
const __v = ids.contentId;
|
|
297
|
+
if (__v != null && __v !== false)
|
|
298
|
+
__el0.setAttribute("data-contextmenu-root", __v === true ? "" : __v);
|
|
299
|
+
}
|
|
300
|
+
__enterChildren(__el0);
|
|
301
|
+
__append(__el0, __child(() => __props.children));
|
|
302
|
+
__exitChildren();
|
|
303
|
+
return __el0;
|
|
304
|
+
})() });
|
|
305
|
+
__flushMountFrame();
|
|
306
|
+
return __mfResult0;
|
|
307
|
+
} catch (__mfErr) {
|
|
308
|
+
__discardMountFrame(__mfDepth);
|
|
309
|
+
throw __mfErr;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
var ComposedContextMenu = Object.assign(ComposedContextMenuRoot, {
|
|
313
|
+
Trigger: ContextMenuTrigger,
|
|
314
|
+
Content: ContextMenuContent,
|
|
315
|
+
Item: ContextMenuItem,
|
|
316
|
+
Group: ContextMenuGroup,
|
|
317
|
+
Label: ContextMenuLabel,
|
|
318
|
+
Separator: ContextMenuSeparator
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
export { ComposedContextMenu };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-q7xbcj9q.js";
|
|
4
|
+
|
|
5
|
+
// src/carousel/carousel-composed.tsx
|
|
6
|
+
import { computed, signal } from "@vertz/ui";
|
|
7
|
+
import { __append, __attr, __child, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __on, __pushMountFrame } from "@vertz/ui/internals";
|
|
8
|
+
import { createContext, useContext } from "@vertz/ui";
|
|
9
|
+
var CarouselContext = createContext(undefined, "@vertz/ui-primitives::CarouselContext");
|
|
10
|
+
function CarouselSlide(__props) {
|
|
11
|
+
const __mfDepth = __pushMountFrame();
|
|
12
|
+
try {
|
|
13
|
+
const ctx = useContext(CarouselContext);
|
|
14
|
+
if (!ctx) {
|
|
15
|
+
throw new Error("<Carousel.Slide> must be used inside <Carousel>. " + "Ensure it is a direct or nested child of the Carousel root component.");
|
|
16
|
+
}
|
|
17
|
+
const index = computed(() => ctx.registerSlide());
|
|
18
|
+
const __mfResult0 = (() => {
|
|
19
|
+
const __el0 = __element("div");
|
|
20
|
+
__el0.setAttribute("role", "group");
|
|
21
|
+
__el0.setAttribute("aria-roledescription", "slide");
|
|
22
|
+
__el0.setAttribute("data-carousel-slide", "");
|
|
23
|
+
__attr(__el0, "aria-hidden", () => String(index.value !== ctx.currentIndex));
|
|
24
|
+
__attr(__el0, "aria-label", () => `Slide ${index.value + 1} of ${ctx.getSlideCount()}`);
|
|
25
|
+
__attr(__el0, "data-state", () => index.value === ctx.currentIndex ? "active" : "inactive");
|
|
26
|
+
__attr(__el0, "class", () => cn(ctx.classes?.slide, __props.className ?? __props.class));
|
|
27
|
+
__enterChildren(__el0);
|
|
28
|
+
__append(__el0, __child(() => __props.children));
|
|
29
|
+
__exitChildren();
|
|
30
|
+
return __el0;
|
|
31
|
+
})();
|
|
32
|
+
__flushMountFrame();
|
|
33
|
+
return __mfResult0;
|
|
34
|
+
} catch (__mfErr) {
|
|
35
|
+
__discardMountFrame(__mfDepth);
|
|
36
|
+
throw __mfErr;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function CarouselPrevious(__props) {
|
|
40
|
+
const __mfDepth = __pushMountFrame();
|
|
41
|
+
try {
|
|
42
|
+
const ctx = useContext(CarouselContext);
|
|
43
|
+
if (!ctx) {
|
|
44
|
+
throw new Error("<Carousel.Previous> must be used inside <Carousel>. " + "Ensure it is a direct or nested child of the Carousel root component.");
|
|
45
|
+
}
|
|
46
|
+
const __mfResult0 = (() => {
|
|
47
|
+
const __el0 = __element("button");
|
|
48
|
+
__el0.setAttribute("type", "button");
|
|
49
|
+
__el0.setAttribute("aria-label", "Previous slide");
|
|
50
|
+
__el0.setAttribute("data-carousel-prev", "");
|
|
51
|
+
__attr(__el0, "disabled", () => !ctx.loop && ctx.currentIndex <= 0);
|
|
52
|
+
__attr(__el0, "class", () => cn(ctx.classes?.prevButton));
|
|
53
|
+
__enterChildren(__el0);
|
|
54
|
+
__append(__el0, __child(() => __props.children ?? "‹"));
|
|
55
|
+
__exitChildren();
|
|
56
|
+
return __el0;
|
|
57
|
+
})();
|
|
58
|
+
__flushMountFrame();
|
|
59
|
+
return __mfResult0;
|
|
60
|
+
} catch (__mfErr) {
|
|
61
|
+
__discardMountFrame(__mfDepth);
|
|
62
|
+
throw __mfErr;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function CarouselNext(__props) {
|
|
66
|
+
const __mfDepth = __pushMountFrame();
|
|
67
|
+
try {
|
|
68
|
+
const ctx = useContext(CarouselContext);
|
|
69
|
+
if (!ctx) {
|
|
70
|
+
throw new Error("<Carousel.Next> must be used inside <Carousel>. " + "Ensure it is a direct or nested child of the Carousel root component.");
|
|
71
|
+
}
|
|
72
|
+
const __mfResult0 = (() => {
|
|
73
|
+
const __el0 = __element("button");
|
|
74
|
+
__el0.setAttribute("type", "button");
|
|
75
|
+
__el0.setAttribute("aria-label", "Next slide");
|
|
76
|
+
__el0.setAttribute("data-carousel-next", "");
|
|
77
|
+
__attr(__el0, "disabled", () => !ctx.loop && ctx.currentIndex >= ctx.getSlideCount() - 1);
|
|
78
|
+
__attr(__el0, "class", () => cn(ctx.classes?.nextButton));
|
|
79
|
+
__enterChildren(__el0);
|
|
80
|
+
__append(__el0, __child(() => __props.children ?? "›"));
|
|
81
|
+
__exitChildren();
|
|
82
|
+
return __el0;
|
|
83
|
+
})();
|
|
84
|
+
__flushMountFrame();
|
|
85
|
+
return __mfResult0;
|
|
86
|
+
} catch (__mfErr) {
|
|
87
|
+
__discardMountFrame(__mfDepth);
|
|
88
|
+
throw __mfErr;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function ComposedCarouselRoot(__props) {
|
|
92
|
+
const __mfDepth = __pushMountFrame();
|
|
93
|
+
try {
|
|
94
|
+
let registerSlide = function() {
|
|
95
|
+
const idx = _reg.nextIdx++;
|
|
96
|
+
slideCount.value = _reg.nextIdx;
|
|
97
|
+
return idx;
|
|
98
|
+
}, goTo = function(index) {
|
|
99
|
+
const count = _reg.nextIdx;
|
|
100
|
+
if (count === 0)
|
|
101
|
+
return;
|
|
102
|
+
let next = index;
|
|
103
|
+
if (__props.loop ?? false) {
|
|
104
|
+
next = (index % count + count) % count;
|
|
105
|
+
} else {
|
|
106
|
+
next = Math.max(0, Math.min(count - 1, index));
|
|
107
|
+
}
|
|
108
|
+
if (next === currentIndex.value)
|
|
109
|
+
return;
|
|
110
|
+
currentIndex.value = next;
|
|
111
|
+
__props.onSlideChange?.(next);
|
|
112
|
+
}, handleClick = function(e) {
|
|
113
|
+
const target = e.target;
|
|
114
|
+
if (target.closest("[data-carousel-prev]"))
|
|
115
|
+
goTo(currentIndex.value - 1);
|
|
116
|
+
if (target.closest("[data-carousel-next]"))
|
|
117
|
+
goTo(currentIndex.value + 1);
|
|
118
|
+
}, handleKeydown = function(e) {
|
|
119
|
+
const prevKey = (__props.orientation ?? "horizontal") === "horizontal" ? "ArrowLeft" : "ArrowUp";
|
|
120
|
+
const nextKey = (__props.orientation ?? "horizontal") === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
121
|
+
if (e.key === prevKey) {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
goTo(currentIndex.value - 1);
|
|
124
|
+
}
|
|
125
|
+
if (e.key === nextKey) {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
goTo(currentIndex.value + 1);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const currentIndex = signal(__props.defaultIndex ?? 0, "currentIndex");
|
|
131
|
+
const _reg = { nextIdx: 0 };
|
|
132
|
+
const slideCount = signal(0, "slideCount");
|
|
133
|
+
const ctx = {
|
|
134
|
+
registerSlide,
|
|
135
|
+
currentIndex,
|
|
136
|
+
getSlideCount: () => slideCount.value,
|
|
137
|
+
loop: __props.loop ?? false,
|
|
138
|
+
classes: __props.classes
|
|
139
|
+
};
|
|
140
|
+
const __mfResult0 = CarouselContext.Provider({ get value() {
|
|
141
|
+
return ctx;
|
|
142
|
+
}, children: () => (() => {
|
|
143
|
+
const __el0 = __element("div");
|
|
144
|
+
__el0.setAttribute("role", "region");
|
|
145
|
+
__el0.setAttribute("aria-roledescription", "carousel");
|
|
146
|
+
__el0.setAttribute("data-carousel-root", "");
|
|
147
|
+
__attr(__el0, "data-orientation", () => __props.orientation ?? "horizontal");
|
|
148
|
+
__attr(__el0, "class", () => cn(__props.classes?.root));
|
|
149
|
+
__on(__el0, "click", handleClick);
|
|
150
|
+
__on(__el0, "keydown", handleKeydown);
|
|
151
|
+
__enterChildren(__el0);
|
|
152
|
+
__append(__el0, (() => {
|
|
153
|
+
const __el1 = __element("div");
|
|
154
|
+
__el1.setAttribute("data-carousel-viewport", "");
|
|
155
|
+
__attr(__el1, "class", () => cn(__props.classes?.viewport));
|
|
156
|
+
__enterChildren(__el1);
|
|
157
|
+
__append(__el1, __child(() => __props.children));
|
|
158
|
+
__exitChildren();
|
|
159
|
+
return __el1;
|
|
160
|
+
})());
|
|
161
|
+
__exitChildren();
|
|
162
|
+
return __el0;
|
|
163
|
+
})() });
|
|
164
|
+
__flushMountFrame();
|
|
165
|
+
return __mfResult0;
|
|
166
|
+
} catch (__mfErr) {
|
|
167
|
+
__discardMountFrame(__mfDepth);
|
|
168
|
+
throw __mfErr;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
var ComposedCarousel = Object.assign(ComposedCarouselRoot, {
|
|
172
|
+
Slide: CarouselSlide,
|
|
173
|
+
Previous: CarouselPrevious,
|
|
174
|
+
Next: CarouselNext
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export { ComposedCarousel };
|