@vielzeug/refine 2.1.3 → 2.2.4
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/accordion.cjs +1 -1
- package/dist/accordion.cjs.map +1 -1
- package/dist/accordion.js +2 -2
- package/dist/accordion.js.map +1 -1
- package/dist/carousel.cjs +25 -24
- package/dist/carousel.cjs.map +1 -1
- package/dist/carousel.js +125 -135
- package/dist/carousel.js.map +1 -1
- package/dist/combobox.cjs +14 -14
- package/dist/combobox.cjs.map +1 -1
- package/dist/combobox.js +88 -98
- package/dist/combobox.js.map +1 -1
- package/dist/content/carousel/carousel.d.ts.map +1 -1
- package/dist/content/list/_list-item-reveal.cjs +1 -1
- package/dist/content/list/_list-item-reveal.cjs.map +1 -1
- package/dist/content/list/_list-item-reveal.d.ts +3 -3
- package/dist/content/list/_list-item-reveal.d.ts.map +1 -1
- package/dist/content/list/_list-item-reveal.js +22 -22
- package/dist/content/list/_list-item-reveal.js.map +1 -1
- package/dist/content/list/list-item.d.ts.map +1 -1
- package/dist/core/focus.cjs +1 -1
- package/dist/core/focus.cjs.map +1 -1
- package/dist/core/focus.d.ts.map +1 -1
- package/dist/core/focus.js +21 -20
- package/dist/core/focus.js.map +1 -1
- package/dist/core/index.d.ts +2 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/nav.cjs +1 -1
- package/dist/core/nav.cjs.map +1 -1
- package/dist/core/nav.d.ts +3 -62
- package/dist/core/nav.d.ts.map +1 -1
- package/dist/core/nav.js +41 -124
- package/dist/core/nav.js.map +1 -1
- package/dist/core/option-list.cjs +1 -1
- package/dist/core/option-list.cjs.map +1 -1
- package/dist/core/option-list.d.ts +5 -5
- package/dist/core/option-list.d.ts.map +1 -1
- package/dist/core/option-list.js +14 -13
- package/dist/core/option-list.js.map +1 -1
- package/dist/core/overlay.cjs +1 -1
- package/dist/core/overlay.cjs.map +1 -1
- package/dist/core/overlay.d.ts +0 -8
- package/dist/core/overlay.d.ts.map +1 -1
- package/dist/core/overlay.js +1 -3
- package/dist/core/overlay.js.map +1 -1
- package/dist/custom-elements.json +5636 -5683
- package/dist/drawer.cjs +6 -6
- package/dist/drawer.cjs.map +1 -1
- package/dist/drawer.js +65 -75
- package/dist/drawer.js.map +1 -1
- package/dist/feedback/skeleton/skeleton.css.cjs +1 -1
- package/dist/feedback/skeleton/skeleton.css.cjs.map +1 -1
- package/dist/feedback/skeleton/skeleton.css.js +1 -1
- package/dist/feedback/skeleton/skeleton.css.js.map +1 -1
- package/dist/feedback/skeleton/skeleton.d.ts.map +1 -1
- package/dist/feedback/toast/toast.d.ts.map +1 -1
- package/dist/grid.cjs +2 -2
- package/dist/grid.cjs.map +1 -1
- package/dist/grid.js +42 -41
- package/dist/grid.js.map +1 -1
- package/dist/input.cjs.map +1 -1
- package/dist/input.js.map +1 -1
- package/dist/inputs/input/input.css.cjs +1 -1
- package/dist/inputs/input/input.css.cjs.map +1 -1
- package/dist/inputs/input/input.css.js +1 -1
- package/dist/inputs/input/input.css.js.map +1 -1
- package/dist/inputs/input/input.d.ts +2 -0
- package/dist/inputs/input/input.d.ts.map +1 -1
- package/dist/inputs/select/select.d.ts +2 -2
- package/dist/inputs/select/select.d.ts.map +1 -1
- package/dist/layout/grid/grid.d.ts.map +1 -1
- package/dist/layout/navbar/navbar.d.ts.map +1 -1
- package/dist/layout/sidebar/sidebar.d.ts.map +1 -1
- package/dist/list-item.cjs +2 -6
- package/dist/list-item.cjs.map +1 -1
- package/dist/list-item.js +40 -39
- package/dist/list-item.js.map +1 -1
- package/dist/list.cjs +1 -1
- package/dist/list.cjs.map +1 -1
- package/dist/list.js +2 -2
- package/dist/list.js.map +1 -1
- package/dist/marquee.cjs +1 -1
- package/dist/marquee.cjs.map +1 -1
- package/dist/marquee.js +3 -1
- package/dist/marquee.js.map +1 -1
- package/dist/menu.cjs +5 -5
- package/dist/menu.cjs.map +1 -1
- package/dist/menu.js +59 -59
- package/dist/menu.js.map +1 -1
- package/dist/navbar.cjs +9 -9
- package/dist/navbar.cjs.map +1 -1
- package/dist/navbar.js +124 -116
- package/dist/navbar.js.map +1 -1
- package/dist/otp-input.cjs +1 -1
- package/dist/otp-input.cjs.map +1 -1
- package/dist/otp-input.js +2 -2
- package/dist/otp-input.js.map +1 -1
- package/dist/overlay/drawer/drawer.d.ts.map +1 -1
- package/dist/overlay/menu/menu.d.ts.map +1 -1
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.cjs.map +1 -1
- package/dist/radio-group.js +2 -3
- package/dist/radio-group.js.map +1 -1
- package/dist/radio.cjs +1 -1
- package/dist/radio.cjs.map +1 -1
- package/dist/radio.js +12 -11
- package/dist/radio.js.map +1 -1
- package/dist/rating.cjs +1 -1
- package/dist/rating.cjs.map +1 -1
- package/dist/rating.js +1 -1
- package/dist/rating.js.map +1 -1
- package/dist/refine.cjs +188 -195
- package/dist/refine.cjs.map +1 -1
- package/dist/refine.iife.js +212 -219
- package/dist/refine.iife.js.map +1 -1
- package/dist/refine.js +392 -399
- package/dist/refine.js.map +1 -1
- package/dist/select.cjs +1 -1
- package/dist/select.cjs.map +1 -1
- package/dist/select.js +1 -0
- package/dist/select.js.map +1 -1
- package/dist/sidebar.cjs +16 -16
- package/dist/sidebar.cjs.map +1 -1
- package/dist/sidebar.js +106 -91
- package/dist/sidebar.js.map +1 -1
- package/dist/skeleton.cjs +3 -3
- package/dist/skeleton.cjs.map +1 -1
- package/dist/skeleton.js +8 -7
- package/dist/skeleton.js.map +1 -1
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.cjs.map +1 -1
- package/dist/stepper.js +3 -3
- package/dist/stepper.js.map +1 -1
- package/dist/styles/fouc.css +22 -0
- package/dist/styles/preflight.css +2 -10
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.cjs.map +1 -1
- package/dist/tabs.js +4 -5
- package/dist/tabs.js.map +1 -1
- package/dist/toast.cjs +13 -17
- package/dist/toast.cjs.map +1 -1
- package/dist/toast.js +86 -85
- package/dist/toast.js.map +1 -1
- package/package.json +18 -11
- package/dist/core/swipe.cjs +0 -2
- package/dist/core/swipe.cjs.map +0 -1
- package/dist/core/swipe.d.ts +0 -40
- package/dist/core/swipe.d.ts.map +0 -1
- package/dist/core/swipe.js +0 -63
- package/dist/core/swipe.js.map +0 -1
- package/dist/core/typeahead.cjs +0 -2
- package/dist/core/typeahead.cjs.map +0 -1
- package/dist/core/typeahead.d.ts +0 -53
- package/dist/core/typeahead.d.ts.map +0 -1
- package/dist/core/typeahead.js +0 -23
- package/dist/core/typeahead.js.map +0 -1
package/dist/carousel.js
CHANGED
|
@@ -1,171 +1,153 @@
|
|
|
1
1
|
import { announce as e } from "./core/announcer.js";
|
|
2
|
-
import {
|
|
3
|
-
import n from "./
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { lifecycleSignal as t } from "./core/ore.js";
|
|
3
|
+
import { createListControl as n } from "./core/nav.js";
|
|
4
|
+
import r from "./content/carousel/carousel.css.js";
|
|
5
|
+
import { CAROUSEL_SLIDE_TAG as i } from "./content/carousel/carousel-slide.js";
|
|
6
|
+
import { bind as a, define as o, getHost as s, html as c, onCleanup as l, onMounted as u, prop as d, useEmit as f } from "@vielzeug/ore";
|
|
7
|
+
import { computed as p, signal as m, watch as h } from "@vielzeug/ripple";
|
|
8
|
+
import { createPanGesture as g } from "@vielzeug/gesture";
|
|
7
9
|
//#region src/content/carousel/carousel.ts
|
|
8
|
-
var
|
|
10
|
+
var _ = "ore-carousel", v = (e, t) => {
|
|
9
11
|
let n = e.length;
|
|
10
12
|
e.forEach((e, r) => {
|
|
11
13
|
let i = r === t;
|
|
12
14
|
e.toggleAttribute("data-active", i), e.setAttribute("aria-hidden", String(!i)), e.setAttribute("aria-label", e.getAttribute("aria-label") ?? `Slide ${r + 1} of ${n}`), e.removeAttribute("data-gallery-visible"), e.toggleAttribute("data-before", r < t), e.toggleAttribute("data-after", r > t);
|
|
13
15
|
});
|
|
14
|
-
},
|
|
16
|
+
}, y = (e, t) => {
|
|
15
17
|
let n = e.length;
|
|
16
18
|
e.forEach((e, r) => {
|
|
17
19
|
let i = r === t;
|
|
18
20
|
e.toggleAttribute("data-active", i), e.setAttribute("aria-hidden", String(!i)), e.setAttribute("aria-label", e.getAttribute("aria-label") ?? `Slide ${r + 1} of ${n}`), e.removeAttribute("data-gallery-visible"), e.removeAttribute("data-before"), e.removeAttribute("data-after");
|
|
19
21
|
});
|
|
20
|
-
},
|
|
22
|
+
}, b = (e, t) => {
|
|
21
23
|
let n = e.length;
|
|
22
24
|
e.forEach((e, r) => {
|
|
23
25
|
let i = r === t, a = t > 0 && r === t - 1, o = t < n - 1 && r === t + 1;
|
|
24
26
|
e.toggleAttribute("data-active", i), e.setAttribute("aria-hidden", String(!i)), e.setAttribute("aria-label", e.getAttribute("aria-label") ?? `Slide ${r + 1} of ${n}`), e.removeAttribute("data-before"), e.removeAttribute("data-after"), e.toggleAttribute("data-gallery-visible", i || a || o);
|
|
25
27
|
});
|
|
26
28
|
};
|
|
27
|
-
|
|
29
|
+
o(_, {
|
|
28
30
|
props: {
|
|
29
|
-
autoplay:
|
|
30
|
-
"autoplay-interval":
|
|
31
|
-
color:
|
|
32
|
-
label:
|
|
33
|
-
loop:
|
|
34
|
-
orientation:
|
|
35
|
-
"show-controls":
|
|
36
|
-
"show-indicators":
|
|
37
|
-
"slide-index":
|
|
38
|
-
variant:
|
|
31
|
+
autoplay: d.bool(!1),
|
|
32
|
+
"autoplay-interval": d.number(5e3),
|
|
33
|
+
color: d.string(),
|
|
34
|
+
label: d.string("Carousel"),
|
|
35
|
+
loop: d.bool(!0),
|
|
36
|
+
orientation: d.string("horizontal"),
|
|
37
|
+
"show-controls": d.bool(!0),
|
|
38
|
+
"show-indicators": d.bool(!0),
|
|
39
|
+
"slide-index": d.number(0),
|
|
40
|
+
variant: d.string("default")
|
|
39
41
|
},
|
|
40
|
-
setup(
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
let
|
|
45
|
-
if (
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
typeof e == "number" && e !==
|
|
42
|
+
setup(r) {
|
|
43
|
+
let i = s(), o = f(), d = m(r["slide-index"].value ?? 0), _ = null, x = Array.from(i.querySelectorAll(":scope > ore-carousel-slide")), S = m(x.length), C = () => {
|
|
44
|
+
x = Array.from(i.querySelectorAll(":scope > ore-carousel-slide")), S.value = x.length;
|
|
45
|
+
}, w = p(() => r.orientation.value !== "vertical"), T = p(() => r.loop.value !== !1), E = p(() => r["show-controls"].value !== !1), D = p(() => r["show-indicators"].value !== !1), O = p(() => T.value || d.value > 0), k = p(() => T.value || d.value < S.value - 1), A = (t, n = !0) => {
|
|
46
|
+
let r = S.value;
|
|
47
|
+
if (r === 0) return;
|
|
48
|
+
let a = T.value ? (t % r + r) % r : Math.max(0, Math.min(t, r - 1));
|
|
49
|
+
a !== d.value && (d.value = a, i.setAttribute("slide-index", String(a)), o("change", { index: a }), n && e(x[a]?.getAttribute("aria-label") ?? `Slide ${a + 1} of ${r}`));
|
|
50
|
+
}, j = () => A(d.value - 1), M = () => A(d.value + 1);
|
|
51
|
+
h(r["slide-index"], (e) => {
|
|
52
|
+
typeof e == "number" && e !== d.value && A(e, !1);
|
|
51
53
|
});
|
|
52
|
-
let
|
|
53
|
-
let e =
|
|
54
|
-
|
|
54
|
+
let N = () => {
|
|
55
|
+
let e = r.variant.value ?? "default", t = r.orientation.value ?? "horizontal";
|
|
56
|
+
x.forEach((n) => {
|
|
55
57
|
n.setAttribute("data-variant", e), n.setAttribute("data-orientation", t);
|
|
56
58
|
});
|
|
57
59
|
};
|
|
58
|
-
p(
|
|
59
|
-
orientation:
|
|
60
|
-
variant:
|
|
61
|
-
})),
|
|
62
|
-
let
|
|
63
|
-
default:
|
|
64
|
-
fade:
|
|
65
|
-
filmstrip:
|
|
66
|
-
gallery:
|
|
67
|
-
},
|
|
68
|
-
let e =
|
|
69
|
-
|
|
60
|
+
h(p(() => ({
|
|
61
|
+
orientation: r.orientation.value,
|
|
62
|
+
variant: r.variant.value
|
|
63
|
+
})), N, { immediate: !0 });
|
|
64
|
+
let P = {
|
|
65
|
+
default: v,
|
|
66
|
+
fade: v,
|
|
67
|
+
filmstrip: y,
|
|
68
|
+
gallery: b
|
|
69
|
+
}, F = () => {
|
|
70
|
+
let e = r.variant.value ?? "default";
|
|
71
|
+
P[e](x, d.value);
|
|
70
72
|
};
|
|
71
|
-
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
|
|
73
|
+
h(d, F, { immediate: !0 });
|
|
74
|
+
let I = () => {
|
|
75
|
+
_ === null && (_ = setInterval(M, r["autoplay-interval"].value ?? 5e3));
|
|
76
|
+
}, L = () => {
|
|
77
|
+
_ !== null && (clearInterval(_), _ = null);
|
|
76
78
|
};
|
|
77
|
-
p(
|
|
78
|
-
enabled:
|
|
79
|
-
interval:
|
|
79
|
+
h(p(() => ({
|
|
80
|
+
enabled: r.autoplay.value,
|
|
81
|
+
interval: r["autoplay-interval"].value
|
|
80
82
|
})), ({ enabled: e }) => {
|
|
81
|
-
|
|
83
|
+
L(), e && I();
|
|
82
84
|
});
|
|
83
|
-
let
|
|
84
|
-
let t =
|
|
85
|
-
e.key === n ? (e.preventDefault(),
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
let R = (e) => {
|
|
86
|
+
let t = w.value, n = t ? "ArrowLeft" : "ArrowUp", r = t ? "ArrowRight" : "ArrowDown";
|
|
87
|
+
e.key === n ? (e.preventDefault(), j()) : e.key === r ? (e.preventDefault(), M()) : e.key === "Home" ? (e.preventDefault(), A(0)) : e.key === "End" && (e.preventDefault(), A(S.value - 1));
|
|
88
|
+
}, z = n({
|
|
89
|
+
getItems: () => Array.from({ length: S.value }, (e, t) => t),
|
|
90
|
+
loop: !0,
|
|
91
|
+
onNavigate: ({ index: e }) => {
|
|
92
|
+
A(e), (i.shadowRoot?.querySelector(`.indicator[data-index="${e}"]`))?.focus();
|
|
90
93
|
},
|
|
91
|
-
|
|
94
|
+
orientation: () => w.value ? "horizontal" : "vertical",
|
|
95
|
+
signal: t(l)
|
|
92
96
|
});
|
|
93
|
-
|
|
97
|
+
a({
|
|
94
98
|
attr: {
|
|
95
|
-
"aria-label": () =>
|
|
99
|
+
"aria-label": () => r.label.value ?? "Carousel",
|
|
96
100
|
"aria-roledescription": () => "carousel",
|
|
97
|
-
orientation: () =>
|
|
101
|
+
orientation: () => r.orientation.value ?? "horizontal",
|
|
98
102
|
role: () => "region",
|
|
99
|
-
style: () => `touch-action:${
|
|
100
|
-
variant: () =>
|
|
103
|
+
style: () => `touch-action:${w.value ? "pan-y" : "pan-x"}`,
|
|
104
|
+
variant: () => r.variant.value ?? "default"
|
|
101
105
|
},
|
|
102
106
|
on: {
|
|
103
107
|
focusin: () => {
|
|
104
|
-
|
|
108
|
+
L();
|
|
105
109
|
},
|
|
106
110
|
focusout: () => {
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
keydown: F,
|
|
110
|
-
pointercancel: (e) => I.handlePointerCancel(e),
|
|
111
|
-
pointerdown: (e) => {
|
|
112
|
-
e.composedPath().some((e) => e instanceof HTMLElement && (e.tagName === "BUTTON" || e.tagName === "ORE-BUTTON" || e.tagName === "ORE-PROGRESS")) || I.handlePointerDown(e);
|
|
111
|
+
r.autoplay.value && I();
|
|
113
112
|
},
|
|
113
|
+
keydown: R,
|
|
114
114
|
pointerenter: () => {
|
|
115
|
-
|
|
115
|
+
L();
|
|
116
116
|
},
|
|
117
117
|
pointerleave: () => {
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
pointermove: (e) => I.handlePointerMove(e),
|
|
121
|
-
pointerup: (e) => I.handlePointerUp(e)
|
|
118
|
+
r.autoplay.value && I();
|
|
119
|
+
}
|
|
122
120
|
}
|
|
123
|
-
}),
|
|
124
|
-
let e =
|
|
125
|
-
|
|
121
|
+
}), u(() => {
|
|
122
|
+
let e = g(i, {
|
|
123
|
+
axis: () => w.value ? "x" : "y",
|
|
124
|
+
onEnd: ({ distance: e, reason: t }) => {
|
|
125
|
+
t !== "release" || Math.abs(e) < 48 || (e < 0 ? M() : j());
|
|
126
|
+
},
|
|
127
|
+
shouldStart: (e) => !e.composedPath().some((e) => e instanceof HTMLElement && (e.tagName === "BUTTON" || e.tagName === "ORE-BUTTON" || e.tagName === "ORE-PROGRESS"))
|
|
128
|
+
}), t = i.shadowRoot.querySelector("slot"), n = () => {
|
|
129
|
+
C(), N(), F();
|
|
126
130
|
};
|
|
127
|
-
return
|
|
128
|
-
|
|
131
|
+
return t.addEventListener("slotchange", n), r.autoplay.value && I(), () => {
|
|
132
|
+
e.dispose(), L(), t.removeEventListener("slotchange", n);
|
|
129
133
|
};
|
|
130
134
|
});
|
|
131
|
-
let
|
|
132
|
-
(r.shadowRoot?.querySelector(`.indicator[data-index="${e}"]`))?.focus();
|
|
133
|
-
}, R = (e, t) => {
|
|
134
|
-
let n = y.value, r;
|
|
135
|
-
switch (e.key) {
|
|
136
|
-
case "ArrowDown":
|
|
137
|
-
case "ArrowRight":
|
|
138
|
-
r = (t + 1) % n;
|
|
139
|
-
break;
|
|
140
|
-
case "ArrowLeft":
|
|
141
|
-
case "ArrowUp":
|
|
142
|
-
r = (t - 1 + n) % n;
|
|
143
|
-
break;
|
|
144
|
-
case "End":
|
|
145
|
-
r = n - 1;
|
|
146
|
-
break;
|
|
147
|
-
case "Home":
|
|
148
|
-
r = 0;
|
|
149
|
-
break;
|
|
150
|
-
default: return;
|
|
151
|
-
}
|
|
152
|
-
e.preventDefault(), D(r), L(r);
|
|
153
|
-
}, z = () => C.value ? s`
|
|
135
|
+
let B = () => E.value ? c`
|
|
154
136
|
<div class="controls" part="controls">
|
|
155
137
|
<ore-button
|
|
156
138
|
class="nav-btn prev-btn"
|
|
157
139
|
part="prev-btn"
|
|
158
140
|
variant="ghost"
|
|
159
|
-
color=${() =>
|
|
141
|
+
color=${() => r.color.value}
|
|
160
142
|
rounded
|
|
161
143
|
icon-only
|
|
162
144
|
aria-label="Previous slide"
|
|
163
|
-
disabled=${() => !
|
|
145
|
+
disabled=${() => !O.value || void 0}
|
|
164
146
|
@click=${(e) => {
|
|
165
|
-
e.stopPropagation(),
|
|
147
|
+
e.stopPropagation(), j();
|
|
166
148
|
}}>
|
|
167
149
|
<ore-icon
|
|
168
|
-
name=${() =>
|
|
150
|
+
name=${() => w.value ? "chevron-left" : "chevron-up"}
|
|
169
151
|
size="16"
|
|
170
152
|
stroke-width="2"
|
|
171
153
|
aria-hidden="true"></ore-icon>
|
|
@@ -174,62 +156,70 @@ a(m, {
|
|
|
174
156
|
class="nav-btn next-btn"
|
|
175
157
|
part="next-btn"
|
|
176
158
|
variant="ghost"
|
|
177
|
-
color=${() =>
|
|
159
|
+
color=${() => r.color.value}
|
|
178
160
|
rounded
|
|
179
161
|
icon-only
|
|
180
162
|
aria-label="Next slide"
|
|
181
|
-
disabled=${() => !
|
|
163
|
+
disabled=${() => !k.value || void 0}
|
|
182
164
|
@click=${(e) => {
|
|
183
|
-
e.stopPropagation(),
|
|
165
|
+
e.stopPropagation(), M();
|
|
184
166
|
}}>
|
|
185
167
|
<ore-icon
|
|
186
|
-
name=${() =>
|
|
168
|
+
name=${() => w.value ? "chevron-right" : "chevron-down"}
|
|
187
169
|
size="16"
|
|
188
170
|
stroke-width="2"
|
|
189
171
|
aria-hidden="true"></ore-icon>
|
|
190
172
|
</ore-button>
|
|
191
173
|
</div>
|
|
192
|
-
` :
|
|
193
|
-
return
|
|
194
|
-
<div class="track" part="track" aria-live=${() =>
|
|
174
|
+
` : c``;
|
|
175
|
+
return c`
|
|
176
|
+
<div class="track" part="track" aria-live=${() => r.autoplay.value ? "off" : "polite"}>
|
|
195
177
|
<slot></slot>
|
|
196
178
|
</div>
|
|
197
179
|
|
|
198
|
-
${() =>
|
|
180
|
+
${() => D.value && S.value > 1 ? c`
|
|
199
181
|
<div class="indicators" part="indicators" role="tablist" aria-label="Slide indicators">
|
|
200
|
-
${() => Array.from({ length:
|
|
182
|
+
${() => Array.from({ length: S.value }, (e, t) => c`
|
|
201
183
|
<button
|
|
202
184
|
type="button"
|
|
203
185
|
role="tab"
|
|
204
186
|
data-index="${t}"
|
|
205
|
-
class=${() => `indicator${t ===
|
|
206
|
-
aria-selected=${() => String(t ===
|
|
207
|
-
tabindex=${() => t ===
|
|
187
|
+
class=${() => `indicator${t === d.value ? " indicator-active" : ""}`}
|
|
188
|
+
aria-selected=${() => String(t === d.value)}
|
|
189
|
+
tabindex=${() => t === d.value ? "0" : "-1"}
|
|
208
190
|
aria-label="${`Go to slide ${t + 1}`}"
|
|
209
|
-
@
|
|
210
|
-
@
|
|
191
|
+
@focus=${() => z.set(t)}
|
|
192
|
+
@click=${() => A(t)}
|
|
193
|
+
@keydown=${(e) => {
|
|
194
|
+
let t = e.currentTarget;
|
|
195
|
+
if (t instanceof HTMLElement) {
|
|
196
|
+
let e = Number(t.dataset.index);
|
|
197
|
+
Number.isInteger(e) && z.set(e);
|
|
198
|
+
}
|
|
199
|
+
z.handleKeydown(e);
|
|
200
|
+
}}>
|
|
211
201
|
<ore-progress
|
|
212
202
|
aria-hidden="true"
|
|
213
203
|
tabindex="-1"
|
|
214
|
-
color=${() =>
|
|
215
|
-
type=${() =>
|
|
216
|
-
value=${() => t ===
|
|
204
|
+
color=${() => r.color.value}
|
|
205
|
+
type=${() => w.value ? "linear" : "vertical"}
|
|
206
|
+
value=${() => t === d.value ? 100 : 0}
|
|
217
207
|
style=${() => {
|
|
218
|
-
let e =
|
|
219
|
-
return `--carousel-timeout:${
|
|
208
|
+
let e = w.value ? "carousel-fill" : "carousel-fill-v";
|
|
209
|
+
return `--carousel-timeout:${r["autoplay-interval"].value ?? 5e3};--carousel-animation-name:${t === d.value && r.autoplay.value ? e : "none"}`;
|
|
220
210
|
}}></ore-progress>
|
|
221
211
|
</button>
|
|
222
212
|
`)}
|
|
223
|
-
${
|
|
213
|
+
${B}
|
|
224
214
|
</div>
|
|
225
|
-
` :
|
|
226
|
-
${
|
|
215
|
+
` : c`
|
|
216
|
+
${B}
|
|
227
217
|
`}
|
|
228
218
|
`;
|
|
229
219
|
},
|
|
230
|
-
styles: [
|
|
220
|
+
styles: [r]
|
|
231
221
|
});
|
|
232
222
|
//#endregion
|
|
233
|
-
export {
|
|
223
|
+
export { i as CAROUSEL_SLIDE_TAG, _ as CAROUSEL_TAG };
|
|
234
224
|
|
|
235
225
|
//# sourceMappingURL=carousel.js.map
|
package/dist/carousel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","names":[],"sources":["../src/content/carousel/carousel.ts"],"sourcesContent":["import { bind, define, getHost, html, onMounted, prop, useEmit } from '@vielzeug/ore';\nimport { computed, signal, watch } from '@vielzeug/ripple';\n\nimport type { ThemeColor } from '../../types';\n\nimport '../../content/icon/icon';\nimport '../../feedback/progress/progress';\nimport { announce, createSwipeControl } from '../../core';\nimport componentStyles from './carousel.css?inline';\nimport './carousel-slide';\n\nexport { CAROUSEL_SLIDE_TAG } from './carousel-slide';\n\n// ── Types ──────────────────────────────────────────────────────────────────────\n\nexport type CarouselOrientation = 'horizontal' | 'vertical';\nexport type CarouselVariant = 'default' | 'fade' | 'filmstrip' | 'gallery';\n\nexport type OreCarouselEvents = {\n /** Fired when the active slide changes. */\n change: { index: number };\n};\n\nexport type OreCarouselProps = {\n /**\n * Whether to advance slides automatically. Defaults to `false`.\n * Opt in explicitly — autoplay on by default is a WCAG 2.1 SC 2.2.2 violation for many use cases.\n */\n autoplay?: boolean;\n /** Interval in milliseconds between automatic slide advances. Defaults to `5000`. */\n 'autoplay-interval'?: number;\n /** Theme color passed to the prev/next navigation buttons. */\n color?: ThemeColor;\n /** Accessible label for the carousel region. */\n label?: string;\n /** Whether the carousel loops from the last slide back to the first. Defaults to `true`. */\n loop?: boolean;\n /** Carousel orientation. Defaults to `'horizontal'`. */\n orientation?: CarouselOrientation;\n /** Show next/prev navigation buttons. Defaults to `true`. */\n 'show-controls'?: boolean;\n /** Show dot/indicator navigation. Defaults to `true`. */\n 'show-indicators'?: boolean;\n /** Index of the currently active slide (zero-based). Defaults to `0`. */\n 'slide-index'?: number;\n /**\n * Layout variant.\n * - `'default'` — slides translate in/out (default)\n * - `'fade'` — slides crossfade; no movement\n * - `'filmstrip'` — all slides visible side-by-side; active expands\n * - `'gallery'` — active slide fills the majority; adjacent slides show as thumbnails\n */\n variant?: CarouselVariant;\n};\n\n/**\n * An accessible, keyboard-navigable carousel / slideshow with optional\n * autoplay, swipe support, and indicator dots.\n *\n * Place `<ore-carousel-slide>` elements as direct children.\n *\n * @element ore-carousel\n * @element ore-carousel-slide - Child element for individual slides\n *\n * @attr {string} color - Theme color for navigation buttons: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {boolean} autoplay - Advance slides automatically (default false)\n * @attr {number} autoplay-interval - Milliseconds between automatic advances (default 5000)\n * @attr {string} label - Accessible label for the carousel region\n * @attr {boolean} loop - Loop from last slide to first (default true)\n * @attr {string} orientation - 'horizontal' (default) | 'vertical'\n * @attr {string} variant - 'default' | 'fade' | 'filmstrip' | 'gallery'\n * @attr {boolean} show-controls - Show prev/next buttons (default true)\n * @attr {boolean} show-indicators - Show indicator dots (default true)\n * @attr {number} slide-index - Active slide index (zero-based, default 0)\n *\n * @fires change - Fires when the active slide changes. detail: { index: number }\n *\n * @slot - Place `<ore-carousel-slide>` elements here\n *\n * @cssprop --carousel-bg - Slide area background\n * @cssprop --carousel-radius - Border radius of the carousel\n * @cssprop --carousel-dot-bg - Inactive indicator color (default: var(--color-contrast-300))\n * @cssprop --carousel-dot-active-bg - Active indicator / fill color (default: var(--color-contrast-700))\n * @cssprop --carousel-transition-duration - Slide transition duration (default 0.35s; 0s under prefers-reduced-motion).\n * @cssprop --carousel-min-height - Minimum height when no explicit height is set (default 240px)\n * @cssprop --carousel-filmstrip-inactive - Width (horizontal) or height (vertical) of inactive slides in filmstrip mode\n * @cssprop --carousel-filmstrip-gap - Gap between slides in filmstrip mode\n * @cssprop --carousel-gallery-thumbnail - Width (horizontal) or height (vertical) of thumbnail slides in gallery mode (default var(--size-24))\n * @cssprop --carousel-gallery-gap - Gap between slides in gallery mode (default var(--size-2))\n *\n * @part track - The scrolling slide track element\n * @part controls - The prev/next button container\n * @part indicators - The indicator dots container\n * @part prev-btn - The previous-slide button\n * @part next-btn - The next-slide button\n *\n * @example\n * ```html\n * <ore-carousel label=\"Product highlights\" loop>\n * <ore-carousel-slide>Slide 1</ore-carousel-slide>\n * <ore-carousel-slide>Slide 2</ore-carousel-slide>\n * <ore-carousel-slide>Slide 3</ore-carousel-slide>\n * </ore-carousel>\n * ```\n */\nexport const CAROUSEL_TAG = 'ore-carousel' as const;\n\n// ── Slide-state sync helpers ──────────────────────────────────────────────────\n// Each function handles exactly one variant's attribute bookkeeping.\n// Called from a dispatch table in syncActiveState.\n\nconst syncDefaultSlides = (slides: HTMLElement[], current: number): void => {\n const count = slides.length;\n\n slides.forEach((slide, i) => {\n const active = i === current;\n\n slide.toggleAttribute('data-active', active);\n slide.setAttribute('aria-hidden', String(!active));\n slide.setAttribute('aria-label', slide.getAttribute('aria-label') ?? `Slide ${i + 1} of ${count}`);\n slide.removeAttribute('data-gallery-visible');\n slide.toggleAttribute('data-before', i < current);\n slide.toggleAttribute('data-after', i > current);\n });\n};\n\nconst syncFilmstripSlides = (slides: HTMLElement[], current: number): void => {\n const count = slides.length;\n\n slides.forEach((slide, i) => {\n const active = i === current;\n\n slide.toggleAttribute('data-active', active);\n slide.setAttribute('aria-hidden', String(!active));\n slide.setAttribute('aria-label', slide.getAttribute('aria-label') ?? `Slide ${i + 1} of ${count}`);\n slide.removeAttribute('data-gallery-visible');\n slide.removeAttribute('data-before');\n slide.removeAttribute('data-after');\n });\n};\n\nconst syncGallerySlides = (slides: HTMLElement[], current: number): void => {\n const count = slides.length;\n\n slides.forEach((slide, i) => {\n const active = i === current;\n const isPrev = current > 0 && i === current - 1;\n const isNext = current < count - 1 && i === current + 1;\n\n slide.toggleAttribute('data-active', active);\n slide.setAttribute('aria-hidden', String(!active));\n slide.setAttribute('aria-label', slide.getAttribute('aria-label') ?? `Slide ${i + 1} of ${count}`);\n slide.removeAttribute('data-before');\n slide.removeAttribute('data-after');\n slide.toggleAttribute('data-gallery-visible', active || isPrev || isNext);\n });\n};\n\n// ── ore-carousel ──────────────────────────────────────────────────────────────\n\ndefine<OreCarouselProps>(CAROUSEL_TAG, {\n props: {\n autoplay: prop.bool(false),\n 'autoplay-interval': prop.number(5000),\n color: prop.string<ThemeColor>(),\n label: prop.string('Carousel'),\n loop: prop.bool(true),\n orientation: prop.string<CarouselOrientation>('horizontal'),\n 'show-controls': prop.bool(true),\n 'show-indicators': prop.bool(true),\n 'slide-index': prop.number(0),\n variant: prop.string<CarouselVariant>('default'),\n },\n\n setup(props) {\n const el = getHost();\n const emit = useEmit<OreCarouselEvents>();\n\n // ── State ────────────────────────────────────────────────────────────────\n\n const activeIndex = signal<number>(props['slide-index'].value ?? 0);\n let autoplayTimer: ReturnType<typeof setInterval> | null = null;\n\n // Slide cache — populated immediately, refreshed on slotchange.\n let slides: HTMLElement[] = Array.from(el.querySelectorAll<HTMLElement>(':scope > ore-carousel-slide'));\n const slideCount = signal(slides.length);\n\n const refreshSlides = (): void => {\n slides = Array.from(el.querySelectorAll<HTMLElement>(':scope > ore-carousel-slide'));\n slideCount.value = slides.length;\n };\n\n const isHorizontal = computed(() => props.orientation.value !== 'vertical');\n const looping = computed(() => props.loop.value !== false);\n const showControls = computed(() => props['show-controls'].value !== false);\n const showIndicators = computed(() => props['show-indicators'].value !== false);\n\n const canGoPrev = computed(() => looping.value || activeIndex.value > 0);\n const canGoNext = computed(() => looping.value || activeIndex.value < slideCount.value - 1);\n\n // ── Navigation ───────────────────────────────────────────────────────────\n\n const goTo = (index: number, announce_: boolean = true): void => {\n const count = slideCount.value;\n\n if (count === 0) return;\n\n const next = looping.value ? ((index % count) + count) % count : Math.max(0, Math.min(index, count - 1));\n\n if (next === activeIndex.value) return;\n\n activeIndex.value = next;\n el.setAttribute('slide-index', String(next));\n emit('change', { index: next });\n\n if (announce_) {\n announce(slides[next]?.getAttribute('aria-label') ?? `Slide ${next + 1} of ${count}`);\n }\n };\n\n const prev = (): void => goTo(activeIndex.value - 1);\n const next = (): void => goTo(activeIndex.value + 1);\n\n // ── Sync prop → state ────────────────────────────────────────────────────\n\n watch(props['slide-index'], (v) => {\n if (typeof v === 'number' && v !== activeIndex.value) goTo(v, false);\n });\n\n // ── Sync variant + orientation → slides ──────────────────────────────────\n\n const syncSlideVariants = (): void => {\n const variant = props.variant.value ?? 'default';\n const orientation = props.orientation.value ?? 'horizontal';\n\n slides.forEach((slide) => {\n slide.setAttribute('data-variant', variant);\n slide.setAttribute('data-orientation', orientation);\n });\n };\n\n watch(\n computed(() => ({ orientation: props.orientation.value, variant: props.variant.value })),\n syncSlideVariants,\n { immediate: true },\n );\n\n // ── Sync active index → slides — dispatch table ───────────────────────────\n\n const syncTable: Record<CarouselVariant, (slides: HTMLElement[], current: number) => void> = {\n default: syncDefaultSlides,\n fade: syncDefaultSlides,\n filmstrip: syncFilmstripSlides,\n gallery: syncGallerySlides,\n };\n\n const syncActiveState = (): void => {\n const variant = (props.variant.value ?? 'default') as CarouselVariant;\n\n syncTable[variant](slides, activeIndex.value);\n };\n\n watch(activeIndex, syncActiveState, { immediate: true });\n\n // ── Autoplay ─────────────────────────────────────────────────────────────\n\n const startAutoplay = (): void => {\n if (autoplayTimer !== null) return;\n\n autoplayTimer = setInterval(next, props['autoplay-interval'].value ?? 5000);\n };\n\n const stopAutoplay = (): void => {\n if (autoplayTimer !== null) {\n clearInterval(autoplayTimer);\n autoplayTimer = null;\n }\n };\n\n watch(\n computed(() => ({ enabled: props.autoplay.value, interval: props['autoplay-interval'].value })),\n ({ enabled }) => {\n stopAutoplay();\n\n if (enabled) startAutoplay();\n },\n );\n\n // ── Keyboard navigation ──────────────────────────────────────────────────\n\n const handleKeydown = (e: KeyboardEvent): void => {\n const isH = isHorizontal.value;\n const prevKey = isH ? 'ArrowLeft' : 'ArrowUp';\n const nextKey = isH ? 'ArrowRight' : 'ArrowDown';\n\n if (e.key === prevKey) {\n e.preventDefault();\n prev();\n } else if (e.key === nextKey) {\n e.preventDefault();\n next();\n } else if (e.key === 'Home') {\n e.preventDefault();\n goTo(0);\n } else if (e.key === 'End') {\n e.preventDefault();\n goTo(slideCount.value - 1);\n }\n };\n\n // ── Swipe ────────────────────────────────────────────────────────────────\n\n const swipe = createSwipeControl({\n axis: () => (isHorizontal.value ? 'x' : 'y'),\n onCommit: (detail) => {\n if (detail.distance < 0) next();\n else prev();\n },\n threshold: () => 48,\n });\n\n // ── Host bindings ────────────────────────────────────────────────────────\n\n bind({\n attr: {\n 'aria-label': () => props.label.value ?? 'Carousel',\n 'aria-roledescription': () => 'carousel',\n orientation: () => props.orientation.value ?? 'horizontal',\n role: () => 'region',\n style: () => `touch-action:${isHorizontal.value ? 'pan-y' : 'pan-x'}`,\n variant: () => props.variant.value ?? 'default',\n },\n on: {\n focusin: () => {\n stopAutoplay();\n },\n focusout: () => {\n if (props.autoplay.value) startAutoplay();\n },\n keydown: handleKeydown,\n pointercancel: (e: PointerEvent) => swipe.handlePointerCancel(e),\n pointerdown: (e: PointerEvent) => {\n const path = e.composedPath();\n const onButton = path.some(\n (n) =>\n n instanceof HTMLElement &&\n (n.tagName === 'BUTTON' || n.tagName === 'ORE-BUTTON' || n.tagName === 'ORE-PROGRESS'),\n );\n\n if (!onButton) swipe.handlePointerDown(e);\n },\n pointerenter: () => {\n stopAutoplay();\n },\n pointerleave: () => {\n if (props.autoplay.value) startAutoplay();\n },\n pointermove: (e: PointerEvent) => swipe.handlePointerMove(e),\n pointerup: (e: PointerEvent) => swipe.handlePointerUp(e),\n },\n });\n\n // ── Lifecycle ────────────────────────────────────────────────────────────\n\n onMounted(() => {\n const shadowRoot = el.shadowRoot!;\n const slot = shadowRoot.querySelector<HTMLSlotElement>('slot')!;\n\n // slotchange replaces MutationObserver — fires exactly when assigned\n // nodes change, scoped to this component's slot, no polling overhead.\n const onSlotChange = (): void => {\n refreshSlides();\n syncSlideVariants();\n syncActiveState();\n };\n\n slot.addEventListener('slotchange', onSlotChange);\n\n if (props.autoplay.value) {\n startAutoplay();\n }\n\n return () => {\n stopAutoplay();\n swipe.dispose();\n slot.removeEventListener('slotchange', onSlotChange);\n };\n });\n\n // ── Template ─────────────────────────────────────────────────────────────\n\n const focusIndicator = (index: number): void => {\n const dot = el.shadowRoot?.querySelector<HTMLElement>(`.indicator[data-index=\"${index}\"]`);\n\n dot?.focus();\n };\n\n const handleIndicatorKeydown = (e: KeyboardEvent, i: number): void => {\n const count = slideCount.value;\n let target: number | undefined;\n\n switch (e.key) {\n case 'ArrowDown':\n case 'ArrowRight':\n target = (i + 1) % count;\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n target = (i - 1 + count) % count;\n break;\n case 'End':\n target = count - 1;\n break;\n case 'Home':\n target = 0;\n break;\n default:\n return;\n }\n\n e.preventDefault();\n goTo(target);\n focusIndicator(target);\n };\n\n const renderControls = () =>\n showControls.value\n ? html`\n <div class=\"controls\" part=\"controls\">\n <ore-button\n class=\"nav-btn prev-btn\"\n part=\"prev-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n aria-label=\"Previous slide\"\n disabled=${() => (!canGoPrev.value ? true : undefined)}\n @click=${(e: Event) => {\n e.stopPropagation();\n prev();\n }}>\n <ore-icon\n name=${() => (isHorizontal.value ? 'chevron-left' : 'chevron-up')}\n size=\"16\"\n stroke-width=\"2\"\n aria-hidden=\"true\"></ore-icon>\n </ore-button>\n <ore-button\n class=\"nav-btn next-btn\"\n part=\"next-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n aria-label=\"Next slide\"\n disabled=${() => (!canGoNext.value ? true : undefined)}\n @click=${(e: Event) => {\n e.stopPropagation();\n next();\n }}>\n <ore-icon\n name=${() => (isHorizontal.value ? 'chevron-right' : 'chevron-down')}\n size=\"16\"\n stroke-width=\"2\"\n aria-hidden=\"true\"></ore-icon>\n </ore-button>\n </div>\n `\n : html``;\n\n return html`\n <div class=\"track\" part=\"track\" aria-live=${() => (props.autoplay.value ? 'off' : 'polite')}>\n <slot></slot>\n </div>\n\n ${() =>\n showIndicators.value && slideCount.value > 1\n ? html`\n <div class=\"indicators\" part=\"indicators\" role=\"tablist\" aria-label=\"Slide indicators\">\n ${() =>\n Array.from(\n { length: slideCount.value },\n (_, i) => html`\n <button\n type=\"button\"\n role=\"tab\"\n data-index=\"${i}\"\n class=${() => `indicator${i === activeIndex.value ? ' indicator-active' : ''}`}\n aria-selected=${() => String(i === activeIndex.value)}\n tabindex=${() => (i === activeIndex.value ? '0' : '-1')}\n aria-label=\"${`Go to slide ${i + 1}`}\"\n @click=${() => goTo(i)}\n @keydown=${(e: KeyboardEvent) => handleIndicatorKeydown(e, i)}>\n <ore-progress\n aria-hidden=\"true\"\n tabindex=\"-1\"\n color=${() => props.color.value}\n type=${() => (isHorizontal.value ? 'linear' : 'vertical')}\n value=${() => (i === activeIndex.value ? 100 : 0)}\n style=${() => {\n const fillAnim = isHorizontal.value ? 'carousel-fill' : 'carousel-fill-v';\n\n return `--carousel-timeout:${props['autoplay-interval'].value ?? 5000};--carousel-animation-name:${i === activeIndex.value && props.autoplay.value ? fillAnim : 'none'}`;\n }}></ore-progress>\n </button>\n `,\n )}\n ${renderControls}\n </div>\n `\n : html`\n ${renderControls}\n `}\n `;\n },\n styles: [componentStyles],\n});\n"],"mappings":";;;;;;;AAyGA,IAAa,IAAe,gBAMtB,KAAqB,GAAuB,MAA0B;CAC1E,IAAM,IAAQ,EAAO;CAErB,EAAO,SAAS,GAAO,MAAM;EAC3B,IAAM,IAAS,MAAM;EAOrB,AALA,EAAM,gBAAgB,eAAe,CAAM,GAC3C,EAAM,aAAa,eAAe,OAAO,CAAC,CAAM,CAAC,GACjD,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CAAC,EAAE;;;;wCAI9C,EAAM,MAAM,MAAM;uCAClB,EAAa,QAAQ,WAAW,WAAY;wCAC3C,MAAM,EAAY,QAAQ,MAAM,EAAG;wCACpC;GACZ,IAAM,IAAW,EAAa,QAAQ,kBAAkB;GAExD,OAAO,sBAAsB,EAAM,oBAAoB,CAAC,SAAS,IAAK,6BAA6B,MAAM,EAAY,SAAS,EAAM,SAAS,QAAQ,IAAW;EAClK,EAAE;;qBAGV,EAAE;kBACF,EAAe;;gBAGrB,CAAI;gBACA,EAAe;cACjB;;CAEZ;CACA,QAAQ,CAAC,CAAe;AAC1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"carousel.js","names":[],"sources":["../src/content/carousel/carousel.ts"],"sourcesContent":["import { createPanGesture } from '@vielzeug/gesture';\nimport { bind, define, getHost, html, onCleanup, onMounted, prop, useEmit } from '@vielzeug/ore';\nimport { computed, signal, watch } from '@vielzeug/ripple';\n\nimport type { ThemeColor } from '../../types';\n\nimport '../../content/icon/icon';\nimport '../../feedback/progress/progress';\nimport { announce, createListControl, lifecycleSignal } from '../../core';\nimport componentStyles from './carousel.css?inline';\nimport './carousel-slide';\n\nexport { CAROUSEL_SLIDE_TAG } from './carousel-slide';\n\n// ── Types ──────────────────────────────────────────────────────────────────────\n\nexport type CarouselOrientation = 'horizontal' | 'vertical';\nexport type CarouselVariant = 'default' | 'fade' | 'filmstrip' | 'gallery';\n\nexport type OreCarouselEvents = {\n /** Fired when the active slide changes. */\n change: { index: number };\n};\n\nexport type OreCarouselProps = {\n /**\n * Whether to advance slides automatically. Defaults to `false`.\n * Opt in explicitly — autoplay on by default is a WCAG 2.1 SC 2.2.2 violation for many use cases.\n */\n autoplay?: boolean;\n /** Interval in milliseconds between automatic slide advances. Defaults to `5000`. */\n 'autoplay-interval'?: number;\n /** Theme color passed to the prev/next navigation buttons. */\n color?: ThemeColor;\n /** Accessible label for the carousel region. */\n label?: string;\n /** Whether the carousel loops from the last slide back to the first. Defaults to `true`. */\n loop?: boolean;\n /** Carousel orientation. Defaults to `'horizontal'`. */\n orientation?: CarouselOrientation;\n /** Show next/prev navigation buttons. Defaults to `true`. */\n 'show-controls'?: boolean;\n /** Show dot/indicator navigation. Defaults to `true`. */\n 'show-indicators'?: boolean;\n /** Index of the currently active slide (zero-based). Defaults to `0`. */\n 'slide-index'?: number;\n /**\n * Layout variant.\n * - `'default'` — slides translate in/out (default)\n * - `'fade'` — slides crossfade; no movement\n * - `'filmstrip'` — all slides visible side-by-side; active expands\n * - `'gallery'` — active slide fills the majority; adjacent slides show as thumbnails\n */\n variant?: CarouselVariant;\n};\n\n/**\n * An accessible, keyboard-navigable carousel / slideshow with optional\n * autoplay, swipe support, and indicator dots.\n *\n * Place `<ore-carousel-slide>` elements as direct children.\n *\n * @element ore-carousel\n * @element ore-carousel-slide - Child element for individual slides\n *\n * @attr {string} color - Theme color for navigation buttons: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {boolean} autoplay - Advance slides automatically (default false)\n * @attr {number} autoplay-interval - Milliseconds between automatic advances (default 5000)\n * @attr {string} label - Accessible label for the carousel region\n * @attr {boolean} loop - Loop from last slide to first (default true)\n * @attr {string} orientation - 'horizontal' (default) | 'vertical'\n * @attr {string} variant - 'default' | 'fade' | 'filmstrip' | 'gallery'\n * @attr {boolean} show-controls - Show prev/next buttons (default true)\n * @attr {boolean} show-indicators - Show indicator dots (default true)\n * @attr {number} slide-index - Active slide index (zero-based, default 0)\n *\n * @fires change - Fires when the active slide changes. detail: { index: number }\n *\n * @slot - Place `<ore-carousel-slide>` elements here\n *\n * @cssprop --carousel-bg - Slide area background\n * @cssprop --carousel-radius - Border radius of the carousel\n * @cssprop --carousel-dot-bg - Inactive indicator color (default: var(--color-contrast-300))\n * @cssprop --carousel-dot-active-bg - Active indicator / fill color (default: var(--color-contrast-700))\n * @cssprop --carousel-transition-duration - Slide transition duration (default 0.35s; 0s under prefers-reduced-motion).\n * @cssprop --carousel-min-height - Minimum height when no explicit height is set (default 240px)\n * @cssprop --carousel-filmstrip-inactive - Width (horizontal) or height (vertical) of inactive slides in filmstrip mode\n * @cssprop --carousel-filmstrip-gap - Gap between slides in filmstrip mode\n * @cssprop --carousel-gallery-thumbnail - Width (horizontal) or height (vertical) of thumbnail slides in gallery mode (default var(--size-24))\n * @cssprop --carousel-gallery-gap - Gap between slides in gallery mode (default var(--size-2))\n *\n * @part track - The scrolling slide track element\n * @part controls - The prev/next button container\n * @part indicators - The indicator dots container\n * @part prev-btn - The previous-slide button\n * @part next-btn - The next-slide button\n *\n * @example\n * ```html\n * <ore-carousel label=\"Product highlights\" loop>\n * <ore-carousel-slide>Slide 1</ore-carousel-slide>\n * <ore-carousel-slide>Slide 2</ore-carousel-slide>\n * <ore-carousel-slide>Slide 3</ore-carousel-slide>\n * </ore-carousel>\n * ```\n */\nexport const CAROUSEL_TAG = 'ore-carousel' as const;\n\n// ── Slide-state sync helpers ──────────────────────────────────────────────────\n// Each function handles exactly one variant's attribute bookkeeping.\n// Called from a dispatch table in syncActiveState.\n\nconst syncDefaultSlides = (slides: HTMLElement[], current: number): void => {\n const count = slides.length;\n\n slides.forEach((slide, i) => {\n const active = i === current;\n\n slide.toggleAttribute('data-active', active);\n slide.setAttribute('aria-hidden', String(!active));\n slide.setAttribute('aria-label', slide.getAttribute('aria-label') ?? `Slide ${i + 1} of ${count}`);\n slide.removeAttribute('data-gallery-visible');\n slide.toggleAttribute('data-before', i < current);\n slide.toggleAttribute('data-after', i > current);\n });\n};\n\nconst syncFilmstripSlides = (slides: HTMLElement[], current: number): void => {\n const count = slides.length;\n\n slides.forEach((slide, i) => {\n const active = i === current;\n\n slide.toggleAttribute('data-active', active);\n slide.setAttribute('aria-hidden', String(!active));\n slide.setAttribute('aria-label', slide.getAttribute('aria-label') ?? `Slide ${i + 1} of ${count}`);\n slide.removeAttribute('data-gallery-visible');\n slide.removeAttribute('data-before');\n slide.removeAttribute('data-after');\n });\n};\n\nconst syncGallerySlides = (slides: HTMLElement[], current: number): void => {\n const count = slides.length;\n\n slides.forEach((slide, i) => {\n const active = i === current;\n const isPrev = current > 0 && i === current - 1;\n const isNext = current < count - 1 && i === current + 1;\n\n slide.toggleAttribute('data-active', active);\n slide.setAttribute('aria-hidden', String(!active));\n slide.setAttribute('aria-label', slide.getAttribute('aria-label') ?? `Slide ${i + 1} of ${count}`);\n slide.removeAttribute('data-before');\n slide.removeAttribute('data-after');\n slide.toggleAttribute('data-gallery-visible', active || isPrev || isNext);\n });\n};\n\n// ── ore-carousel ──────────────────────────────────────────────────────────────\n\ndefine<OreCarouselProps>(CAROUSEL_TAG, {\n props: {\n autoplay: prop.bool(false),\n 'autoplay-interval': prop.number(5000),\n color: prop.string<ThemeColor>(),\n label: prop.string('Carousel'),\n loop: prop.bool(true),\n orientation: prop.string<CarouselOrientation>('horizontal'),\n 'show-controls': prop.bool(true),\n 'show-indicators': prop.bool(true),\n 'slide-index': prop.number(0),\n variant: prop.string<CarouselVariant>('default'),\n },\n\n setup(props) {\n const el = getHost();\n const emit = useEmit<OreCarouselEvents>();\n\n // ── State ────────────────────────────────────────────────────────────────\n\n const activeIndex = signal<number>(props['slide-index'].value ?? 0);\n let autoplayTimer: ReturnType<typeof setInterval> | null = null;\n\n // Slide cache — populated immediately, refreshed on slotchange.\n let slides: HTMLElement[] = Array.from(el.querySelectorAll<HTMLElement>(':scope > ore-carousel-slide'));\n const slideCount = signal(slides.length);\n\n const refreshSlides = (): void => {\n slides = Array.from(el.querySelectorAll<HTMLElement>(':scope > ore-carousel-slide'));\n slideCount.value = slides.length;\n };\n\n const isHorizontal = computed(() => props.orientation.value !== 'vertical');\n const looping = computed(() => props.loop.value !== false);\n const showControls = computed(() => props['show-controls'].value !== false);\n const showIndicators = computed(() => props['show-indicators'].value !== false);\n\n const canGoPrev = computed(() => looping.value || activeIndex.value > 0);\n const canGoNext = computed(() => looping.value || activeIndex.value < slideCount.value - 1);\n\n // ── Navigation ───────────────────────────────────────────────────────────\n\n const goTo = (index: number, announce_: boolean = true): void => {\n const count = slideCount.value;\n\n if (count === 0) return;\n\n const next = looping.value ? ((index % count) + count) % count : Math.max(0, Math.min(index, count - 1));\n\n if (next === activeIndex.value) return;\n\n activeIndex.value = next;\n el.setAttribute('slide-index', String(next));\n emit('change', { index: next });\n\n if (announce_) {\n announce(slides[next]?.getAttribute('aria-label') ?? `Slide ${next + 1} of ${count}`);\n }\n };\n\n const prev = (): void => goTo(activeIndex.value - 1);\n const next = (): void => goTo(activeIndex.value + 1);\n\n // ── Sync prop → state ────────────────────────────────────────────────────\n\n watch(props['slide-index'], (v) => {\n if (typeof v === 'number' && v !== activeIndex.value) goTo(v, false);\n });\n\n // ── Sync variant + orientation → slides ──────────────────────────────────\n\n const syncSlideVariants = (): void => {\n const variant = props.variant.value ?? 'default';\n const orientation = props.orientation.value ?? 'horizontal';\n\n slides.forEach((slide) => {\n slide.setAttribute('data-variant', variant);\n slide.setAttribute('data-orientation', orientation);\n });\n };\n\n watch(\n computed(() => ({ orientation: props.orientation.value, variant: props.variant.value })),\n syncSlideVariants,\n { immediate: true },\n );\n\n // ── Sync active index → slides — dispatch table ───────────────────────────\n\n const syncTable: Record<CarouselVariant, (slides: HTMLElement[], current: number) => void> = {\n default: syncDefaultSlides,\n fade: syncDefaultSlides,\n filmstrip: syncFilmstripSlides,\n gallery: syncGallerySlides,\n };\n\n const syncActiveState = (): void => {\n const variant = (props.variant.value ?? 'default') as CarouselVariant;\n\n syncTable[variant](slides, activeIndex.value);\n };\n\n watch(activeIndex, syncActiveState, { immediate: true });\n\n // ── Autoplay ─────────────────────────────────────────────────────────────\n\n const startAutoplay = (): void => {\n if (autoplayTimer !== null) return;\n\n autoplayTimer = setInterval(next, props['autoplay-interval'].value ?? 5000);\n };\n\n const stopAutoplay = (): void => {\n if (autoplayTimer !== null) {\n clearInterval(autoplayTimer);\n autoplayTimer = null;\n }\n };\n\n watch(\n computed(() => ({ enabled: props.autoplay.value, interval: props['autoplay-interval'].value })),\n ({ enabled }) => {\n stopAutoplay();\n\n if (enabled) startAutoplay();\n },\n );\n\n // ── Keyboard navigation ──────────────────────────────────────────────────\n\n const handleKeydown = (e: KeyboardEvent): void => {\n const isH = isHorizontal.value;\n const prevKey = isH ? 'ArrowLeft' : 'ArrowUp';\n const nextKey = isH ? 'ArrowRight' : 'ArrowDown';\n\n if (e.key === prevKey) {\n e.preventDefault();\n prev();\n } else if (e.key === nextKey) {\n e.preventDefault();\n next();\n } else if (e.key === 'Home') {\n e.preventDefault();\n goTo(0);\n } else if (e.key === 'End') {\n e.preventDefault();\n goTo(slideCount.value - 1);\n }\n };\n\n const indicatorNav = createListControl<number>({\n getItems: () => Array.from({ length: slideCount.value }, (_, index) => index),\n loop: true,\n onNavigate: ({ index }) => {\n goTo(index);\n const dot = el.shadowRoot?.querySelector<HTMLElement>(`.indicator[data-index=\"${index}\"]`);\n\n dot?.focus();\n },\n orientation: () => (isHorizontal.value ? 'horizontal' : 'vertical'),\n signal: lifecycleSignal(onCleanup),\n });\n\n // ── Host bindings ────────────────────────────────────────────────────────\n\n bind({\n attr: {\n 'aria-label': () => props.label.value ?? 'Carousel',\n 'aria-roledescription': () => 'carousel',\n orientation: () => props.orientation.value ?? 'horizontal',\n role: () => 'region',\n style: () => `touch-action:${isHorizontal.value ? 'pan-y' : 'pan-x'}`,\n variant: () => props.variant.value ?? 'default',\n },\n on: {\n focusin: () => {\n stopAutoplay();\n },\n focusout: () => {\n if (props.autoplay.value) startAutoplay();\n },\n keydown: handleKeydown,\n pointerenter: () => {\n stopAutoplay();\n },\n pointerleave: () => {\n if (props.autoplay.value) startAutoplay();\n },\n },\n });\n\n // ── Lifecycle ────────────────────────────────────────────────────────────\n\n onMounted(() => {\n const pan = createPanGesture(el, {\n axis: () => (isHorizontal.value ? 'x' : 'y'),\n onEnd: ({ distance, reason }) => {\n if (reason !== 'release' || Math.abs(distance) < 48) return;\n\n if (distance < 0) next();\n else prev();\n },\n shouldStart: (event) => {\n const path = event.composedPath();\n\n return !path.some(\n (node) =>\n node instanceof HTMLElement &&\n (node.tagName === 'BUTTON' || node.tagName === 'ORE-BUTTON' || node.tagName === 'ORE-PROGRESS'),\n );\n },\n });\n const shadowRoot = el.shadowRoot!;\n const slot = shadowRoot.querySelector<HTMLSlotElement>('slot')!;\n\n // slotchange replaces MutationObserver — fires exactly when assigned\n // nodes change, scoped to this component's slot, no polling overhead.\n const onSlotChange = (): void => {\n refreshSlides();\n syncSlideVariants();\n syncActiveState();\n };\n\n slot.addEventListener('slotchange', onSlotChange);\n\n if (props.autoplay.value) {\n startAutoplay();\n }\n\n return () => {\n pan.dispose();\n stopAutoplay();\n slot.removeEventListener('slotchange', onSlotChange);\n };\n });\n\n // ── Template ─────────────────────────────────────────────────────────────\n\n const renderControls = () =>\n showControls.value\n ? html`\n <div class=\"controls\" part=\"controls\">\n <ore-button\n class=\"nav-btn prev-btn\"\n part=\"prev-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n aria-label=\"Previous slide\"\n disabled=${() => (!canGoPrev.value ? true : undefined)}\n @click=${(e: Event) => {\n e.stopPropagation();\n prev();\n }}>\n <ore-icon\n name=${() => (isHorizontal.value ? 'chevron-left' : 'chevron-up')}\n size=\"16\"\n stroke-width=\"2\"\n aria-hidden=\"true\"></ore-icon>\n </ore-button>\n <ore-button\n class=\"nav-btn next-btn\"\n part=\"next-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n aria-label=\"Next slide\"\n disabled=${() => (!canGoNext.value ? true : undefined)}\n @click=${(e: Event) => {\n e.stopPropagation();\n next();\n }}>\n <ore-icon\n name=${() => (isHorizontal.value ? 'chevron-right' : 'chevron-down')}\n size=\"16\"\n stroke-width=\"2\"\n aria-hidden=\"true\"></ore-icon>\n </ore-button>\n </div>\n `\n : html``;\n\n return html`\n <div class=\"track\" part=\"track\" aria-live=${() => (props.autoplay.value ? 'off' : 'polite')}>\n <slot></slot>\n </div>\n\n ${() =>\n showIndicators.value && slideCount.value > 1\n ? html`\n <div class=\"indicators\" part=\"indicators\" role=\"tablist\" aria-label=\"Slide indicators\">\n ${() =>\n Array.from(\n { length: slideCount.value },\n (_, i) => html`\n <button\n type=\"button\"\n role=\"tab\"\n data-index=\"${i}\"\n class=${() => `indicator${i === activeIndex.value ? ' indicator-active' : ''}`}\n aria-selected=${() => String(i === activeIndex.value)}\n tabindex=${() => (i === activeIndex.value ? '0' : '-1')}\n aria-label=\"${`Go to slide ${i + 1}`}\"\n @focus=${() => indicatorNav.set(i)}\n @click=${() => goTo(i)}\n @keydown=${(e: KeyboardEvent) => {\n const target = e.currentTarget;\n\n if (target instanceof HTMLElement) {\n const index = Number(target.dataset.index);\n\n if (Number.isInteger(index)) indicatorNav.set(index);\n }\n\n indicatorNav.handleKeydown(e);\n }}>\n <ore-progress\n aria-hidden=\"true\"\n tabindex=\"-1\"\n color=${() => props.color.value}\n type=${() => (isHorizontal.value ? 'linear' : 'vertical')}\n value=${() => (i === activeIndex.value ? 100 : 0)}\n style=${() => {\n const fillAnim = isHorizontal.value ? 'carousel-fill' : 'carousel-fill-v';\n\n return `--carousel-timeout:${props['autoplay-interval'].value ?? 5000};--carousel-animation-name:${i === activeIndex.value && props.autoplay.value ? fillAnim : 'none'}`;\n }}></ore-progress>\n </button>\n `,\n )}\n ${renderControls}\n </div>\n `\n : html`\n ${renderControls}\n `}\n `;\n },\n styles: [componentStyles],\n});\n"],"mappings":";;;;;;;;;AA0GA,IAAa,IAAe,gBAMtB,KAAqB,GAAuB,MAA0B;CAC1E,IAAM,IAAQ,EAAO;CAErB,EAAO,SAAS,GAAO,MAAM;EAC3B,IAAM,IAAS,MAAM;EAOrB,AALA,EAAM,gBAAgB,eAAe,CAAM,GAC3C,EAAM,aAAa,eAAe,OAAO,CAAC,CAAM,CAAC,GACjD,EAAM,aAAa,cAAc,EAAM,aAAa,YAAY,KAAK,SAAS,IAAI,EAAE,MAAM,GAAO,GACjG,EAAM,gBAAgB,sBAAsB,GAC5C,EAAM,gBAAgB,e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,oBAAoB,CAAC,SAAS,IAAK,6BAA6B,MAAM,EAAY,SAAS,EAAM,SAAS,QAAQ,IAAW;EAClK,EAAE;;qBAGV,EAAE;kBACF,EAAe;;gBAGrB,CAAI;gBACA,EAAe;cACjB;;CAEZ;CACA,QAAQ,CAAC,CAAe;AAC1B,CAAC"}
|
package/dist/combobox.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./styles/mixins/accessibility.css.cjs"),t=require("./styles/mixins/shape.css.cjs"),n=require("./styles/mixins/theme.css.cjs"),r=require("./core/keyboard.cjs"),i=require("./core/choice-field.cjs"),a=require("./core/ore.cjs"),ee=require("./core/option-list.cjs"),o=require("./inputs/shared/native-field-event.cjs"),s=require("./inputs/combobox/combobox-options.cjs"),c=require("./inputs/combobox/combobox.css.cjs");let l=require("@vielzeug/ore"),u=require("@vielzeug/ripple");var d=`ore-combobox`;(0,l.define)(d,{formAssociated:!0,props:{autoclose:l.prop.bool(!1),color:l.prop.string(),creatable:l.prop.bool(!1),disabled:l.prop.bool(!1),error:l.prop.string(),fullwidth:l.prop.bool(!1),helper:l.prop.string(),label:l.prop.string(),"label-placement":l.prop.oneOf([`inset`,`outside`],`inset`),loading:l.prop.bool(!1),multiple:l.prop.bool(!1),name:l.prop.string(),"no-filter":l.prop.bool(!1),options:l.prop.data(),placeholder:l.prop.string(`Select...`),required:l.prop.bool(!1),rounded:l.prop.string(),size:l.prop.string(),success:l.prop.bool(!1),value:l.prop.string(),variant:l.prop.string()},setup(e){let t=(0,l.getHost)(),n=(0,l.useEmit)(),c=l.watchEffect,d=(0,u.signal)(``),f=null,p=null,m=null,h=null,g=(0,l.ref)(),_=a.lifecycleSignal(l.onCleanup),v=i.createChoiceField({disabled:e.disabled,error:e.error,helper:e.helper,label:e.label,labelPlacement:e[`label-placement`],multiple:e.multiple,prefix:`combobox`,required:e.required,signal:_,value:e.value}),y=(0,u.signal)([]),b=ee.createListboxDropdown({getBoundary:()=>t,getFocusedOptionElement:()=>m?.querySelector(`[data-focused]`)??null,getItems:()=>y.value,getOptionId:e=>`${v.fieldId}-opt-${e}`,getPanel:()=>m,getReference:()=>p,getTrigger:()=>f,isDisabled:()=>v.disabled.value,onClose:e=>{n(`open-change`,{open:!1,reason:e}),_.aborted||
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./styles/mixins/accessibility.css.cjs"),t=require("./styles/mixins/shape.css.cjs"),n=require("./styles/mixins/theme.css.cjs"),r=require("./core/keyboard.cjs"),i=require("./core/choice-field.cjs"),a=require("./core/ore.cjs"),ee=require("./core/option-list.cjs"),o=require("./inputs/shared/native-field-event.cjs"),s=require("./inputs/combobox/combobox-options.cjs"),c=require("./inputs/combobox/combobox.css.cjs");let l=require("@vielzeug/ore"),u=require("@vielzeug/ripple");var d=`ore-combobox`;(0,l.define)(d,{formAssociated:!0,props:{autoclose:l.prop.bool(!1),color:l.prop.string(),creatable:l.prop.bool(!1),disabled:l.prop.bool(!1),error:l.prop.string(),fullwidth:l.prop.bool(!1),helper:l.prop.string(),label:l.prop.string(),"label-placement":l.prop.oneOf([`inset`,`outside`],`inset`),loading:l.prop.bool(!1),multiple:l.prop.bool(!1),name:l.prop.string(),"no-filter":l.prop.bool(!1),options:l.prop.data(),placeholder:l.prop.string(`Select...`),required:l.prop.bool(!1),rounded:l.prop.string(),size:l.prop.string(),success:l.prop.bool(!1),value:l.prop.string(),variant:l.prop.string()},setup(e){let t=(0,l.getHost)(),n=(0,l.useEmit)(),c=l.watchEffect,d=(0,u.signal)(``),f=null,p=null,m=null,h=null,g=(0,l.ref)(),_=a.lifecycleSignal(l.onCleanup),v=i.createChoiceField({disabled:e.disabled,error:e.error,helper:e.helper,label:e.label,labelPlacement:e[`label-placement`],multiple:e.multiple,prefix:`combobox`,required:e.required,signal:_,value:e.value}),y=(0,u.signal)([]),b=ee.createListboxDropdown({getBoundary:()=>t,getFocusedOptionElement:()=>m?.querySelector(`[data-focused]`)??null,getItems:()=>y.value,getOptionId:e=>`${v.fieldId}-opt-${e}`,getPanel:()=>m,getReference:()=>p,getTrigger:()=>f,isDisabled:()=>v.disabled.value,isItemDisabled:e=>e.disabled,onClose:e=>{n(`open-change`,{open:!1,reason:e}),_.aborted||oe(),v.triggerValidation(`blur`)},onOpen:e=>n(`open-change`,{open:!0,reason:e}),restoreFocus:!1,signal:_}),{disabled:x,fieldId:S,selectedValues:C,triggerValidation:w}=v;v.attachFormField((0,l.useField)({disabled:v.disabled,onReset:v.reset,toFormValue:e=>e,validationMessage:v.validationMessage,validity:v.validity,value:v.formValue}));let{focusedIndex:T,isOpen:E,scrollFocusedIntoView:te,updatePosition:ne}=b,D=()=>!!e.multiple.value,O=()=>!!e.creatable.value,k=()=>!!e[`no-filter`].value;(0,l.bind)({attr:{open:()=>E.value?!0:void 0,size:e.size,variant:e.variant}});let A=null,j=!1,M=(0,u.computed)(()=>C.value[0]??``);Object.defineProperty(t,"value",{configurable:!0,get:()=>v.formValue.value,set:e=>{let t=e;if(Array.isArray(t)){v.setValues(t.map(e=>String(e??``)));return}if(t==null||t===``){v.clear();return}v.setValues(D()?String(t).split(`,`):[String(t)])}});let re=()=>C.value.length>0;function N(){f?.focus()}let P=(0,u.signal)([]),F=(0,u.signal)([]),ie=()=>!!e.loading.value;function I(e){return{disabled:!!e.disabled,iconEl:e.iconEl??null,label:e.label??e.value,value:e.value}}let L=(0,u.computed)(()=>{let t=e.options.value,n=Array.isArray(t)?t.map(I):P.value;return F.value.length===0?n:[...n,...F.value]}),R={clear:()=>{v.clear()},remove:e=>{v.removeValue(e)},select:e=>{v.selectValue(e)},toggle:e=>{v.toggleValue(e)}};function z(e=Array.from(t.children)){if(P.value=s.parseSlottedOptions(e),!D()){let e=L.value.find(e=>e.value===M.value);d.value=e?.label??M.value}}z(),c(()=>{let e=s.filterOptions(L.value,d.value,k());y.value=D()?e.filter(e=>!C.value.includes(e.value)):e});let B=(0,u.computed)(()=>s.getCreatableLabel(d.value,O(),y.value)),V=()=>D()&&C.value.length>0?``:e.placeholder.value||``;function H(){o.dispatchNativeFieldEvent(t,`input`),o.dispatchNativeFieldEvent(t,`change`)}function ae(e){e.stopPropagation();let t=e.detail?.value;t!==void 0&&(R.remove(t),H(),w(`change`))}function oe(){if(!D()){let e=L.value.find(e=>e.value===M.value);j=!0,d.value=e?.label??``,Promise.resolve().then(()=>{j=!1});return}d.value=``}c(()=>{if(E.value&&!D()&&M.value&&T.value===-1&&d.value===``){let e=y.value.findIndex(e=>e.value===M.value);e>=0&&b.set(e)}});function U(e=!0,t=`programmatic`){if(e&&(A=d.value,d.value=``),!D()&&M.value){let e=s.filterOptions(L.value,``,k()).findIndex(e=>e.value===M.value);e>=0&&b.set(e)}b.open(t),!D()&&M.value&&T.value>=0&&requestAnimationFrame(()=>{te()})}function W(e=`programmatic`){b.close(e)}let se=r.createInteraction({disabled:x,onPress:()=>{E.value||U(!0,`click`),N()}}),ce=r.createInteraction({disabled:x,keys:[`Enter`],onPress:e=>{let t=y.value;E.value&&T.value>=0&&T.value<t.length?G(t[T.value],e):E.value&&T.value===-1&&B.value?X(d.value,e):E.value||U(!0,`keyboard`)}});function G(t,n){t.disabled||(D()?(R.toggle(t.value),d.value=``,H(),w(`change`),e.autoclose.value&&W(),N(),requestAnimationFrame(()=>N())):(R.select(t.value),d.value=t.label,H(),w(`change`),W(),N()))}function K(e){let t=e.getAttribute(`data-option-index`),n=t?Number(t):-1;if(Number.isInteger(n)&&n>=0&&n<y.value.length)return y.value[n]??null;let r=e.getAttribute(`data-option-value`);if(r){let e=y.value.find(e=>e.value===r);if(e)return e}let i=e.querySelector(`span`)?.textContent?.trim()??e.textContent?.trim()??``;return i?y.value.find(e=>e.label===i||e.value===i)??null:null}function le(e){e.stopPropagation(),R.clear(),d.value=``,H(),w(`change`),N()}function q(e){let t=e.target,r=t.value;if(!j&&r!==d.value){if(d.value=r,!D()){let e=C.value[0],t=e?L.value.find(t=>t.value===e)?.label??e:``;r===``&&A===t&&(A=null)}b.navigate(`first`),E.value||U(!1,`keyboard`),n(`search`,{query:t.value})}}function J(){}function Y(e){if(!x.value&&!b.handleKeydown(e))switch(e.key){case`ArrowDown`:e.preventDefault(),E.value?b.navigate(`next`):(U(!0,`keyboard`),b.navigate(`first`));break;case`ArrowUp`:e.preventDefault(),E.value?b.navigate(`prev`):U(!0,`keyboard`);break;case`Backspace`:D()&&!d.value&&C.value.length>0&&(v.removeValue(C.value[C.value.length-1]??``),H(),w(`change`));break;case`Enter`:ce.handleKeydown(e);break;case`Tab`:W(`programmatic`)}}function X(e,t){let n=e.trim();if(!n)return;let r={disabled:!1,iconEl:null,label:n,value:s.makeCreatableValue(n)};F.value=[...F.value,r],G(r,t)}let ue=(()=>{let e=new MutationObserver(()=>{z()});return e.observe(t,{attributeFilter:[`disabled`,`label`,`value`],attributes:!0,childList:!0,subtree:!0}),()=>e.disconnect()})(),Z=e=>{let t=e=>{let t=e.target;if(!(t instanceof Element))return;if(t.closest(`.no-results-create`)){e.preventDefault(),e.stopPropagation(),X(d.value,e);return}let n=t.closest(`.option`);if(!n)return;e.preventDefault(),e.stopPropagation();let r=K(n);!r||r.disabled||G(r,e)},n=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`.option`);if(!n)return;let r=K(n);if(!r)return;let i=y.value.findIndex(e=>e.value===r.value);i>=0&&b.set(i)};return e.addEventListener(`click`,t),e.addEventListener(`pointermove`,n),()=>{e.removeEventListener(`click`,t),e.removeEventListener(`pointermove`,n)}},Q=null,$=null,de=e=>{h=e,$!==e&&(Q?.(),Q=null,$=null,e&&(Q=Z(e),$=e))},fe=()=>{h&&($===h&&Q||(Q?.(),Q=Z(h),$=h))};return c(()=>{fe(),E.value?(m&&`showPopover`in m&&!m.matches(`:popover-open`)&&m.showPopover(),ne()):m&&`hidePopover`in m&&m.matches(`:popover-open`)&&m.hidePopover()}),(0,l.onElement)(g,e=>{p=e;let t=e.shadowRoot?.querySelector(`input`)??null;if(!t)return;f=t,t.setAttribute(`role`,`combobox`),t.setAttribute(`autocomplete`,`off`),t.setAttribute(`aria-autocomplete`,`list`),t.setAttribute(`aria-haspopup`,`listbox`),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`aria-controls`,`${S}-listbox`);let n=()=>{E.value||U(!0,`click`),N()};return t.addEventListener(`input`,q),t.addEventListener(`keydown`,Y),t.addEventListener(`focus`,J),t.addEventListener(`click`,n),()=>{f=null,p=null,t.removeEventListener(`input`,q),t.removeEventListener(`keydown`,Y),t.removeEventListener(`focus`,J),t.removeEventListener(`click`,n)}}),c(()=>{if(!g.value)return;let t=f;t&&(t.setAttribute(`aria-expanded`,String(E.value)),x.value?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`),e.error.value?(t.setAttribute(`aria-invalid`,`true`),t.setAttribute(`aria-errormessage`,`${S}-error`)):(t.removeAttribute(`aria-invalid`),t.removeAttribute(`aria-errormessage`)))}),c(()=>{if(!g.value)return;let e=f;e&&e.value!==d.value&&(e.value=d.value)}),(0,l.onCleanup)(()=>{Q?.(),Q=null,$=null,ue()}),l.html`
|
|
2
2
|
<slot></slot>
|
|
3
3
|
<ore-input
|
|
4
4
|
class="trigger"
|
|
5
5
|
ref=${g}
|
|
6
6
|
label="${()=>e.label.value??``}"
|
|
7
|
-
placeholder="${
|
|
7
|
+
placeholder="${V}"
|
|
8
8
|
label-placement="${()=>e[`label-placement`].value??`inset`}"
|
|
9
9
|
color="${()=>e.color?.value??void 0}"
|
|
10
10
|
size="${()=>e.size?.value??void 0}"
|
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
17
17
|
?fullwidth="${()=>e.fullwidth.value?!0:void 0}"
|
|
18
18
|
?success="${()=>e.success.value}"
|
|
19
19
|
name="${()=>e.name.value??``}"
|
|
20
|
-
@click="${e=>{
|
|
20
|
+
@click="${e=>{se.handleClick(e)}}"
|
|
21
21
|
part="wrapper">
|
|
22
22
|
<div slot="prefix" class="chips-row">
|
|
23
23
|
<!-- Keep chip list diffing isolated so input node identity stays stable. -->
|
|
@@ -25,13 +25,13 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
25
25
|
${()=>(D()?C.value:[]).map(t=>l.html`
|
|
26
26
|
<ore-chip
|
|
27
27
|
value=${t}
|
|
28
|
-
label=${
|
|
28
|
+
label=${L.value.find(e=>e.value===t)?.label??t}
|
|
29
29
|
mode="removable"
|
|
30
30
|
variant="flat"
|
|
31
31
|
size="sm"
|
|
32
32
|
color="${e.color}"
|
|
33
|
-
@remove=${
|
|
34
|
-
${
|
|
33
|
+
@remove=${ae}>
|
|
34
|
+
${L.value.find(e=>e.value===t)?.label??t}
|
|
35
35
|
</ore-chip>
|
|
36
36
|
`)}
|
|
37
37
|
</span>
|
|
@@ -43,8 +43,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
43
43
|
type="button"
|
|
44
44
|
aria-label="Clear"
|
|
45
45
|
tabindex="-1"
|
|
46
|
-
?hidden=${()=>!
|
|
47
|
-
@click="${
|
|
46
|
+
?hidden=${()=>!re()}
|
|
47
|
+
@click="${le}">
|
|
48
48
|
<ore-icon name="x" size="12" stroke-width="2.5" aria-hidden="true"></ore-icon>
|
|
49
49
|
</button>
|
|
50
50
|
<span class="combobox-suffix-end">
|
|
@@ -75,12 +75,12 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
75
75
|
id="${()=>`${S}-listbox`}"
|
|
76
76
|
style="${()=>E.value&&y.value.length>0?`height:${y.value.length*36}px;`:``}"
|
|
77
77
|
aria-label="${()=>e.label.value||e.placeholder.value||`Options`}"
|
|
78
|
-
ref=${e=>{
|
|
79
|
-
${()=>E.value?
|
|
78
|
+
ref=${e=>{de(e)}}>
|
|
79
|
+
${()=>E.value?ie()?l.html`
|
|
80
80
|
<div class="dropdown-loading">Loading...</div>
|
|
81
|
-
`:y.value.length===0?
|
|
81
|
+
`:y.value.length===0?B.value?l.html`
|
|
82
82
|
<button type="button" class="no-results-create" ?data-focused=${()=>T.value===-1}>
|
|
83
|
-
${
|
|
83
|
+
${B.value}
|
|
84
84
|
</button>
|
|
85
85
|
`:l.html`
|
|
86
86
|
<div class="no-results" role="presentation">No results found</div>
|
|
@@ -91,11 +91,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
91
91
|
id="${`${S}-opt-${t}`}"
|
|
92
92
|
data-option-index="${t}"
|
|
93
93
|
data-option-value="${e.value}"
|
|
94
|
-
aria-selected="${()=>String(D()?C.value.includes(e.value):
|
|
94
|
+
aria-selected="${()=>String(D()?C.value.includes(e.value):M.value===e.value)}"
|
|
95
95
|
aria-disabled="${String(e.disabled)}"
|
|
96
96
|
style="${`position:absolute;top:0;left:0;right:0;transform:translateY(${t*36}px);`}"
|
|
97
97
|
?data-focused=${()=>T.value===t}
|
|
98
|
-
?data-selected=${()=>D()?C.value.includes(e.value):
|
|
98
|
+
?data-selected=${()=>D()?C.value.includes(e.value):M.value===e.value}
|
|
99
99
|
?data-disabled=${e.disabled}>
|
|
100
100
|
<span>${e.label}</span>
|
|
101
101
|
<span class="option-check" aria-hidden="true">
|