@blakesteve/roster 5.13.0 → 5.15.0
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/README.md +187 -41
- package/dist/components/molecules/Carousel/Carousel.cjs +1 -1
- package/dist/components/molecules/Carousel/Carousel.d.ts +65 -3
- package/dist/components/molecules/Carousel/Carousel.js +376 -225
- package/dist/components/molecules/Carousel/carousel-math.cjs +1 -1
- package/dist/components/molecules/Carousel/carousel-math.d.ts +16 -0
- package/dist/components/molecules/Carousel/carousel-math.js +63 -44
- package/dist/components/molecules/Carousel/carousel-selection.cjs +1 -0
- package/dist/components/molecules/Carousel/carousel-selection.d.ts +28 -0
- package/dist/components/molecules/Carousel/carousel-selection.js +23 -0
- package/dist/components/molecules/LiquidTabs/LiquidCount.d.ts +2 -2
- package/dist/components/molecules/LiquidTabs/LiquidTabPanel.cjs +1 -1
- package/dist/components/molecules/LiquidTabs/LiquidTabPanel.d.ts +10 -49
- package/dist/components/molecules/LiquidTabs/LiquidTabPanel.js +5 -28
- package/dist/components/molecules/LiquidTabs/LiquidTabs.cjs +1 -1
- package/dist/components/molecules/LiquidTabs/LiquidTabs.d.ts +13 -40
- package/dist/components/molecules/LiquidTabs/LiquidTabs.js +5 -95
- package/dist/components/molecules/LiquidTabs/liquid-count.d.ts +7 -5
- package/dist/components/molecules/LiquidTabs/liquid-tab-id.cjs +1 -1
- package/dist/components/molecules/LiquidTabs/liquid-tab-id.d.ts +4 -9
- package/dist/components/molecules/LiquidTabs/liquid-tab-id.js +3 -4
- package/dist/components/molecules/Tabs/TabPanel.cjs +1 -0
- package/dist/components/molecules/Tabs/TabPanel.d.ts +53 -0
- package/dist/components/molecules/Tabs/TabPanel.js +32 -0
- package/dist/components/molecules/Tabs/Tabs.cjs +1 -0
- package/dist/components/molecules/Tabs/Tabs.d.ts +118 -0
- package/dist/components/molecules/Tabs/Tabs.js +145 -0
- package/dist/components/molecules/Tabs/tab-id.cjs +1 -0
- package/dist/components/molecules/Tabs/tab-id.d.ts +13 -0
- package/dist/components/molecules/Tabs/tab-id.js +6 -0
- package/dist/index.d.ts +3 -0
- package/dist/internal/dev.cjs +1 -0
- package/dist/internal/dev.d.ts +10 -0
- package/dist/internal/dev.js +10 -0
- package/dist/meta.json +3 -3
- package/dist/roster.cjs +1 -1
- package/dist/roster.css +1 -1
- package/dist/roster.js +116 -110
- package/package.json +1 -1
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import * as
|
|
4
|
-
import { Button as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { withLabels as
|
|
7
|
-
import { prefersReducedMotion as
|
|
8
|
-
import { currentIndex as
|
|
9
|
-
import { perViewVars as
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import { jsx as g, jsxs as q, Fragment as Ee } from "react/jsx-runtime";
|
|
3
|
+
import * as s from "react";
|
|
4
|
+
import { Button as Te } from "../../atoms/Button/Button.js";
|
|
5
|
+
import { cn as F } from "../../../lib/utils.js";
|
|
6
|
+
import { withLabels as Ie } from "../../../lib/labels.js";
|
|
7
|
+
import { prefersReducedMotion as Ne } from "../../../internal/motion.js";
|
|
8
|
+
import { currentIndex as Ce, canScrollNext as Re, canScrollPrev as Le, overflows as Pe, pageTarget as De, revealTarget as Lt, snapPosition as ct, pageStep as Oe, nearestIndex as Me, CAROUSEL_DRAG_THRESHOLD as Ae } from "./carousel-math.js";
|
|
9
|
+
import { perViewVars as Fe, FLUID_ITEM_WIDTH as _e, FLUID_CLASSES as $e } from "./carousel-layout.js";
|
|
10
|
+
import { survivingNeighbor as Be, TYPEAHEAD_RESET_MS as He, typeaheadIndex as ze } from "./carousel-selection.js";
|
|
11
|
+
import { useKeyFocus as Ve } from "../../../internal/key-focus.js";
|
|
12
|
+
import { isDevelopment as je } from "../../../internal/dev.js";
|
|
13
|
+
const Ke = { position: (a, u) => `${a} of ${u}` }, Ue = (a) => Math.min(3e3, 500 + a * 0.35), at = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), [contenteditable]:not([contenteditable="false"])', ut = (a) => typeof a == "number" ? `${a}px` : a;
|
|
14
|
+
function Pt(a) {
|
|
15
|
+
const u = parseFloat(a);
|
|
14
16
|
return Number.isFinite(u) ? u : 0;
|
|
15
17
|
}
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
return /* @__PURE__ */
|
|
18
|
+
const qe = "rst:hidden rst:[@media(any-hover:hover)]:inline-flex", We = "rst:hidden rst:[@media(any-hover:hover)]:flex";
|
|
19
|
+
function Dt({ direction: a }) {
|
|
20
|
+
return /* @__PURE__ */ g(
|
|
19
21
|
"svg",
|
|
20
22
|
{
|
|
21
23
|
"aria-hidden": "true",
|
|
@@ -27,339 +29,488 @@ function ot({ direction: i }) {
|
|
|
27
29
|
strokeWidth: "2",
|
|
28
30
|
strokeLinecap: "round",
|
|
29
31
|
strokeLinejoin: "round",
|
|
30
|
-
children: /* @__PURE__ */
|
|
32
|
+
children: /* @__PURE__ */ g("path", { d: a === "prev" ? "M12.5 4.5 7 10l5.5 5.5" : "M7.5 4.5 13 10l-5.5 5.5" })
|
|
31
33
|
}
|
|
32
34
|
);
|
|
33
35
|
}
|
|
34
|
-
const
|
|
36
|
+
const Ge = "rst:cursor-pointer rst:in-data-dragging:cursor-grabbing rst:outline-hidden rst:focus-visible:outline-solid rst:focus-visible:outline-2 rst:focus-visible:outline-offset-2 rst:focus-visible:outline-ring", Xe = s.memo(function({ child: u, index: p, count: b, selected: N, active: S, label: R, style: _, className: $ }) {
|
|
37
|
+
return /* @__PURE__ */ g(
|
|
38
|
+
"li",
|
|
39
|
+
{
|
|
40
|
+
role: "option",
|
|
41
|
+
"aria-selected": N,
|
|
42
|
+
"aria-setsize": b,
|
|
43
|
+
"aria-posinset": p + 1,
|
|
44
|
+
"aria-label": R,
|
|
45
|
+
tabIndex: S ? 0 : -1,
|
|
46
|
+
"data-carousel-item": "",
|
|
47
|
+
"data-selected": N ? "" : void 0,
|
|
48
|
+
style: _,
|
|
49
|
+
className: $,
|
|
50
|
+
children: u
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
function Je(a) {
|
|
55
|
+
const u = [];
|
|
56
|
+
return s.Children.forEach(a, (p) => {
|
|
57
|
+
if (p == null || typeof p == "boolean") return;
|
|
58
|
+
const b = s.isValidElement(p) && p.key !== null;
|
|
59
|
+
u.push({ child: p, key: b ? String(p.key) : `#${u.length}`, keyed: b });
|
|
60
|
+
}), u;
|
|
61
|
+
}
|
|
62
|
+
const Ye = { active: null, keys: [], sig: "", selected: null, init: !1 }, W = (a, u) => Array.prototype.indexOf.call(a.children, u), Ot = {
|
|
35
63
|
overflowing: null,
|
|
36
64
|
canScrollPrev: !1,
|
|
37
65
|
canScrollNext: !1,
|
|
38
66
|
index: 0
|
|
39
|
-
},
|
|
67
|
+
}, cr = s.forwardRef(function({
|
|
40
68
|
"aria-label": u,
|
|
41
|
-
"aria-labelledby":
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
"aria-labelledby": p,
|
|
70
|
+
"aria-describedby": b,
|
|
71
|
+
children: N,
|
|
72
|
+
itemWidth: S,
|
|
73
|
+
perView: R,
|
|
74
|
+
gap: _ = 12,
|
|
75
|
+
gutter: $ = 16,
|
|
76
|
+
bleed: Mt = !1,
|
|
77
|
+
snap: G = "start",
|
|
78
|
+
snapStrictness: At = "mandatory",
|
|
79
|
+
oneAtATime: Ft = !1,
|
|
80
|
+
arrows: X = "hover",
|
|
81
|
+
arrowPlacement: J = "controls",
|
|
82
|
+
renderArrows: B,
|
|
83
|
+
prevLabel: _t,
|
|
84
|
+
nextLabel: $t,
|
|
85
|
+
prevIcon: Bt,
|
|
86
|
+
nextIcon: Ht,
|
|
87
|
+
arrowButtonProps: zt,
|
|
88
|
+
fade: Vt = !1,
|
|
89
|
+
scrollbar: jt = !1,
|
|
90
|
+
showPosition: dt = !1,
|
|
91
|
+
labels: Kt,
|
|
92
|
+
onIndexChange: ft,
|
|
93
|
+
onScrollStateChange: gt,
|
|
94
|
+
selectable: f = !1,
|
|
95
|
+
selectedKey: pt,
|
|
96
|
+
defaultSelectedKey: Ut = null,
|
|
97
|
+
onSelectionChange: qt,
|
|
98
|
+
onActivate: mt,
|
|
99
|
+
clearable: Wt = !1,
|
|
100
|
+
getOptionLabel: Y,
|
|
101
|
+
itemClassName: Gt,
|
|
102
|
+
listClassName: Xt,
|
|
103
|
+
className: Jt,
|
|
104
|
+
style: Yt,
|
|
105
|
+
...Qt
|
|
106
|
+
}, Zt) {
|
|
107
|
+
Ve();
|
|
108
|
+
const vt = Ie(Ke, Kt), y = s.useRef(null), yt = `${s.useId()}-list`, ht = s.Children.toArray(N), k = f ? Je(N) : null, L = k ? k.length : ht.length, xt = pt !== void 0, [te, ee] = s.useState(Ut), l = xt ? pt : te, [re, bt] = s.useState(!1), m = k ? k.map((t) => t.key) : [], St = m.join("\0"), [w, H] = s.useState(Ye);
|
|
109
|
+
let E = w.active;
|
|
110
|
+
if (f && (!w.init || w.sig !== St || w.selected !== l)) {
|
|
111
|
+
const t = new Set(m);
|
|
112
|
+
w.init && w.selected !== l && !re && l !== null && t.has(l) && (E = l), (E === null || !t.has(E)) && (E = Be(w.keys, t, E) ?? (l !== null && t.has(l) ? l : m[0] ?? null)), H({ active: E, keys: m, sig: St, selected: l, init: !0 });
|
|
113
|
+
}
|
|
114
|
+
const [c, ne] = s.useState(Ot), kt = s.useRef(Ot), [se, oe] = s.useState(""), [ie, le] = s.useState(!1), Q = s.useRef({ onIndexChange: ft, onScrollStateChange: gt });
|
|
115
|
+
s.useEffect(() => {
|
|
116
|
+
Q.current = { onIndexChange: ft, onScrollStateChange: gt };
|
|
75
117
|
});
|
|
76
|
-
const
|
|
77
|
-
const t =
|
|
118
|
+
const v = s.useCallback(() => {
|
|
119
|
+
const t = y.current;
|
|
78
120
|
if (!t) return null;
|
|
79
|
-
const e = t.getBoundingClientRect(), r = getComputedStyle(t),
|
|
121
|
+
const e = t.getBoundingClientRect(), r = getComputedStyle(t), n = e.left + t.clientLeft - t.scrollLeft;
|
|
80
122
|
return {
|
|
81
|
-
items: Array.from(t.children).map((
|
|
82
|
-
const
|
|
83
|
-
return { start:
|
|
123
|
+
items: Array.from(t.children).map((i) => {
|
|
124
|
+
const d = i.getBoundingClientRect();
|
|
125
|
+
return { start: d.left - n, end: d.right - n };
|
|
84
126
|
}),
|
|
85
127
|
scrollLeft: t.scrollLeft,
|
|
86
128
|
clientWidth: t.clientWidth,
|
|
87
129
|
scrollWidth: t.scrollWidth,
|
|
88
|
-
paddingStart:
|
|
89
|
-
paddingEnd:
|
|
90
|
-
align:
|
|
130
|
+
paddingStart: Pt(r.scrollPaddingInlineStart || r.scrollPaddingLeft),
|
|
131
|
+
paddingEnd: Pt(r.scrollPaddingInlineEnd || r.scrollPaddingRight),
|
|
132
|
+
align: G
|
|
91
133
|
};
|
|
92
|
-
}, [
|
|
93
|
-
const t =
|
|
134
|
+
}, [G]), P = s.useCallback(() => {
|
|
135
|
+
const t = v();
|
|
94
136
|
if (!t) return;
|
|
95
137
|
const e = {
|
|
96
|
-
overflowing:
|
|
97
|
-
canScrollPrev:
|
|
98
|
-
canScrollNext:
|
|
99
|
-
index: t.items.length ?
|
|
100
|
-
}, r =
|
|
101
|
-
r.overflowing === e.overflowing && r.canScrollPrev === e.canScrollPrev && r.canScrollNext === e.canScrollNext && r.index === e.index || (
|
|
138
|
+
overflowing: Pe(t),
|
|
139
|
+
canScrollPrev: Le(t),
|
|
140
|
+
canScrollNext: Re(t),
|
|
141
|
+
index: t.items.length ? Ce(t) : 0
|
|
142
|
+
}, r = kt.current;
|
|
143
|
+
r.overflowing === e.overflowing && r.canScrollPrev === e.canScrollPrev && r.canScrollNext === e.canScrollNext && r.index === e.index || (kt.current = e, ne(e), r.index !== e.index && Q.current.onIndexChange?.(e.index), (r.canScrollPrev !== e.canScrollPrev || r.canScrollNext !== e.canScrollNext) && Q.current.onScrollStateChange?.({
|
|
102
144
|
canScrollPrev: e.canScrollPrev,
|
|
103
145
|
canScrollNext: e.canScrollNext
|
|
104
146
|
}));
|
|
105
|
-
}, [
|
|
106
|
-
|
|
107
|
-
const t =
|
|
147
|
+
}, [v]), ce = JSON.stringify([_, $, S, R]);
|
|
148
|
+
s.useLayoutEffect(() => {
|
|
149
|
+
const t = y.current;
|
|
108
150
|
if (!t) return;
|
|
109
|
-
|
|
151
|
+
P();
|
|
110
152
|
let e = 0;
|
|
111
153
|
const r = () => {
|
|
112
154
|
e || (e = requestAnimationFrame(() => {
|
|
113
|
-
e = 0,
|
|
155
|
+
e = 0, P();
|
|
114
156
|
}));
|
|
115
157
|
};
|
|
116
158
|
t.addEventListener("scroll", r, { passive: !0 });
|
|
117
|
-
const
|
|
118
|
-
|
|
159
|
+
const n = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => P()), o = () => {
|
|
160
|
+
n?.observe(t), Array.from(t.children).forEach((d) => n?.observe(d));
|
|
119
161
|
};
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
162
|
+
o();
|
|
163
|
+
const i = typeof MutationObserver > "u" ? null : new MutationObserver(() => {
|
|
164
|
+
o(), P();
|
|
123
165
|
});
|
|
124
|
-
return
|
|
125
|
-
t.removeEventListener("scroll", r),
|
|
166
|
+
return i?.observe(t, { childList: !0 }), () => {
|
|
167
|
+
t.removeEventListener("scroll", r), n?.disconnect(), i?.disconnect(), e && cancelAnimationFrame(e);
|
|
126
168
|
};
|
|
127
|
-
}, [
|
|
128
|
-
const t =
|
|
129
|
-
if (t && (
|
|
130
|
-
const e =
|
|
131
|
-
|
|
169
|
+
}, [P, L, ce]), s.useLayoutEffect(() => {
|
|
170
|
+
const t = y.current;
|
|
171
|
+
if (t && (le(!t.querySelector(at)), p)) {
|
|
172
|
+
const e = p.split(/\s+/).map((r) => document.getElementById(r)?.textContent?.trim() ?? "").filter(Boolean).join(" ");
|
|
173
|
+
oe(e);
|
|
132
174
|
}
|
|
133
|
-
}, [
|
|
134
|
-
const
|
|
135
|
-
const t =
|
|
136
|
-
e && (
|
|
137
|
-
}, []),
|
|
175
|
+
}, [N, p]);
|
|
176
|
+
const T = s.useRef(null), I = s.useCallback(() => {
|
|
177
|
+
const t = y.current, e = T.current;
|
|
178
|
+
e && (T.current = null, window.clearTimeout(e.timer), t?.removeEventListener("scrollend", e.done), t && (t.style.scrollSnapType = "", delete t.dataset.settling));
|
|
179
|
+
}, []), h = s.useCallback(
|
|
138
180
|
(t, e) => {
|
|
139
|
-
const r =
|
|
181
|
+
const r = y.current;
|
|
140
182
|
if (!r) return;
|
|
141
|
-
if (
|
|
183
|
+
if (I(), e !== "smooth" || Ne() || Math.abs(r.scrollLeft - t) < 1) {
|
|
142
184
|
r.style.scrollSnapType = "none", r.scrollTo({ left: t, behavior: "instant" }), r.style.scrollSnapType = "";
|
|
143
185
|
return;
|
|
144
186
|
}
|
|
145
187
|
r.style.scrollSnapType = "none", r.dataset.settling = "";
|
|
146
|
-
const
|
|
147
|
-
Math.abs(r.scrollLeft -
|
|
188
|
+
const o = r.scrollLeft, i = () => {
|
|
189
|
+
Math.abs(r.scrollLeft - o) < 0.5 || I();
|
|
148
190
|
};
|
|
149
|
-
|
|
150
|
-
timer: window.setTimeout(
|
|
151
|
-
done:
|
|
191
|
+
T.current = {
|
|
192
|
+
timer: window.setTimeout(I, Ue(Math.abs(r.scrollLeft - t))),
|
|
193
|
+
done: i,
|
|
152
194
|
target: t
|
|
153
|
-
}, r.addEventListener("scrollend",
|
|
195
|
+
}, r.addEventListener("scrollend", i), r.scrollTo({ left: t, behavior: "smooth" });
|
|
154
196
|
},
|
|
155
|
-
[
|
|
156
|
-
),
|
|
197
|
+
[I]
|
|
198
|
+
), z = s.useCallback(
|
|
157
199
|
(t) => {
|
|
158
|
-
const e =
|
|
200
|
+
const e = v();
|
|
159
201
|
if (!e) return;
|
|
160
|
-
const r =
|
|
161
|
-
|
|
202
|
+
const r = T.current ? { ...e, scrollLeft: T.current.target } : e;
|
|
203
|
+
h(De(r, t), "smooth");
|
|
162
204
|
},
|
|
163
|
-
[
|
|
205
|
+
[v, h]
|
|
164
206
|
);
|
|
165
|
-
|
|
166
|
-
|
|
207
|
+
s.useImperativeHandle(
|
|
208
|
+
Zt,
|
|
167
209
|
() => ({
|
|
168
210
|
scrollToIndex: (t, e) => {
|
|
169
|
-
const r =
|
|
211
|
+
const r = v();
|
|
170
212
|
if (!r || !r.items.length) return;
|
|
171
|
-
const
|
|
172
|
-
|
|
213
|
+
const n = Math.min(Math.max(0, Math.round(t)), r.items.length - 1);
|
|
214
|
+
h(ct(r, n), e?.behavior ?? "smooth");
|
|
173
215
|
},
|
|
174
|
-
scrollPrev: () =>
|
|
175
|
-
scrollNext: () =>
|
|
216
|
+
scrollPrev: () => z(-1),
|
|
217
|
+
scrollNext: () => z(1),
|
|
218
|
+
focus: () => {
|
|
219
|
+
const t = y.current;
|
|
220
|
+
if (!t) return;
|
|
221
|
+
const e = f ? t.querySelector(':scope > [tabindex="0"]') : t.querySelector(at) ?? (t.tabIndex === 0 ? t : null);
|
|
222
|
+
if (!e) return;
|
|
223
|
+
e.focus({ preventScroll: !0 });
|
|
224
|
+
const r = e.closest("[data-carousel-item]"), n = v(), o = r && r.parentElement === t ? W(t, r) : -1, i = n && o >= 0 ? Lt(n, o, T.current?.target ?? n.scrollLeft) : null;
|
|
225
|
+
i !== null && h(i, "smooth");
|
|
226
|
+
}
|
|
176
227
|
}),
|
|
177
|
-
[
|
|
178
|
-
),
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
const t =
|
|
228
|
+
[v, z, h, f]
|
|
229
|
+
), s.useEffect(() => I, [I]);
|
|
230
|
+
const Z = s.useRef(null), tt = s.useRef(null), et = s.useRef(null);
|
|
231
|
+
s.useLayoutEffect(() => {
|
|
232
|
+
const t = et.current;
|
|
182
233
|
if (!t) return;
|
|
183
|
-
const e = t === "prev" ?
|
|
184
|
-
|
|
185
|
-
}, [
|
|
186
|
-
const
|
|
187
|
-
t.pointerType !== "mouse" || t.button !== 0 ||
|
|
234
|
+
const e = t === "prev" ? Z.current : tt.current, r = t === "prev" ? tt.current : Z.current, n = t === "prev" ? !c.canScrollPrev : !c.canScrollNext, o = document.activeElement;
|
|
235
|
+
n && (o !== e && o !== document.body && o !== null || r && !r.disabled && r.focus());
|
|
236
|
+
}, [c.canScrollPrev, c.canScrollNext]);
|
|
237
|
+
const C = s.useRef(null), D = s.useRef(!1), ae = (t) => {
|
|
238
|
+
t.pointerType !== "mouse" || t.button !== 0 || c.overflowing && (I(), D.current = !1, C.current = {
|
|
188
239
|
pointerId: t.pointerId,
|
|
189
240
|
x0: t.clientX,
|
|
190
241
|
scroll0: t.currentTarget.scrollLeft,
|
|
191
242
|
dragging: !1
|
|
192
243
|
});
|
|
193
|
-
},
|
|
194
|
-
const e =
|
|
244
|
+
}, ue = (t) => {
|
|
245
|
+
const e = C.current;
|
|
195
246
|
if (!e || t.pointerId !== e.pointerId) return;
|
|
196
|
-
const r = t.currentTarget,
|
|
247
|
+
const r = t.currentTarget, n = t.clientX - e.x0;
|
|
197
248
|
if (!e.dragging) {
|
|
198
|
-
if (Math.abs(
|
|
249
|
+
if (Math.abs(n) <= Ae) return;
|
|
199
250
|
e.dragging = !0, r.dataset.dragging = "", r.style.scrollSnapType = "none", window.getSelection?.()?.removeAllRanges();
|
|
200
251
|
try {
|
|
201
252
|
r.setPointerCapture(t.pointerId);
|
|
202
253
|
} catch {
|
|
203
254
|
}
|
|
204
255
|
}
|
|
205
|
-
r.scrollLeft = e.scroll0 -
|
|
206
|
-
},
|
|
207
|
-
const e =
|
|
208
|
-
if (!e || t.pointerId !== e.pointerId || (
|
|
256
|
+
r.scrollLeft = e.scroll0 - n;
|
|
257
|
+
}, rt = (t) => {
|
|
258
|
+
const e = C.current;
|
|
259
|
+
if (!e || t.pointerId !== e.pointerId || (C.current = null, !e.dragging)) return;
|
|
209
260
|
const r = t.currentTarget;
|
|
210
|
-
delete r.dataset.dragging,
|
|
211
|
-
|
|
261
|
+
delete r.dataset.dragging, D.current = t.type === "pointerup", window.setTimeout(() => {
|
|
262
|
+
D.current = !1;
|
|
212
263
|
}, 0);
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
},
|
|
216
|
-
!
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
},
|
|
264
|
+
const n = v();
|
|
265
|
+
n ? h(ct(n, Me(n)), "smooth") : r.style.scrollSnapType = "";
|
|
266
|
+
}, de = (t) => {
|
|
267
|
+
!D.current || t.detail === 0 || (D.current = !1, t.preventDefault(), t.stopPropagation());
|
|
268
|
+
}, fe = (t) => {
|
|
269
|
+
c.overflowing && t.preventDefault();
|
|
270
|
+
}, ge = (t) => {
|
|
271
|
+
if (f) {
|
|
272
|
+
me(t);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const e = t.currentTarget, r = t.target;
|
|
276
|
+
if (r === e || C.current?.dragging) return;
|
|
277
|
+
let n = !1;
|
|
278
|
+
try {
|
|
279
|
+
n = r.matches(":focus-visible, [data-key-focus]");
|
|
280
|
+
} catch {
|
|
281
|
+
n = !1;
|
|
282
|
+
}
|
|
283
|
+
if (!n) return;
|
|
284
|
+
const o = r.closest("[data-carousel-item]");
|
|
285
|
+
if (!o || o.parentElement !== e) return;
|
|
286
|
+
const i = v();
|
|
287
|
+
if (!i) return;
|
|
288
|
+
const d = Array.prototype.indexOf.call(e.children, o);
|
|
289
|
+
h(ct(i, d), "instant");
|
|
290
|
+
}, V = (t) => {
|
|
291
|
+
xt || ee(t), qt?.(t);
|
|
292
|
+
}, pe = (t) => {
|
|
293
|
+
const e = v();
|
|
294
|
+
if (!e) return;
|
|
295
|
+
const r = Lt(e, t, T.current?.target ?? e.scrollLeft);
|
|
296
|
+
r !== null && h(r, "smooth");
|
|
297
|
+
}, me = (t) => {
|
|
220
298
|
const e = t.currentTarget, r = t.target;
|
|
221
|
-
if (r
|
|
222
|
-
|
|
299
|
+
if (r.parentElement !== e) return;
|
|
300
|
+
const n = W(e, r), o = m[n];
|
|
301
|
+
if (o === void 0 || (H((d) => d.active === o ? d : { ...d, active: o }), bt(!0), C.current?.dragging)) return;
|
|
302
|
+
let i = !1;
|
|
223
303
|
try {
|
|
224
|
-
|
|
304
|
+
i = r.matches(":focus-visible, [data-key-focus]");
|
|
225
305
|
} catch {
|
|
226
|
-
|
|
306
|
+
i = !1;
|
|
227
307
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
308
|
+
i && pe(n);
|
|
309
|
+
}, ve = (t) => {
|
|
310
|
+
const e = t.relatedTarget;
|
|
311
|
+
e && t.currentTarget.contains(e) || (bt(!1), l !== null && m.includes(l) && H((r) => r.active === l ? r : { ...r, active: l }));
|
|
312
|
+
}, ye = (t) => {
|
|
313
|
+
const e = t.currentTarget, r = t.target.closest("[data-carousel-item]");
|
|
314
|
+
if (!r || r.parentElement !== e) return;
|
|
315
|
+
const n = m[W(e, r)];
|
|
316
|
+
n !== void 0 && (H((o) => o.active === n ? o : { ...o, active: n }), n === l ? mt?.(n) : V(n));
|
|
317
|
+
}, O = s.useRef({ text: "", at: -1 / 0 }), he = (t) => {
|
|
318
|
+
const e = t.currentTarget, r = t.target;
|
|
319
|
+
if (r.parentElement !== e || t.nativeEvent.isComposing || t.ctrlKey || t.metaKey || t.altKey) return;
|
|
320
|
+
const n = m.length - 1, o = W(e, r), i = m[o];
|
|
321
|
+
if (i === void 0) return;
|
|
322
|
+
const d = (x) => {
|
|
323
|
+
t.preventDefault();
|
|
324
|
+
const A = Math.min(n, Math.max(0, x));
|
|
325
|
+
A !== o && e.children[A].focus({ preventScroll: !0 });
|
|
326
|
+
}, Ct = t.timeStamp - O.current.at < He && O.current.text !== "";
|
|
327
|
+
switch (t.key.length !== 1 && (O.current = { text: "", at: -1 / 0 }), t.key) {
|
|
328
|
+
case "ArrowRight":
|
|
329
|
+
return d(o + 1);
|
|
330
|
+
case "ArrowLeft":
|
|
331
|
+
return d(o - 1);
|
|
332
|
+
case "Home":
|
|
333
|
+
return d(0);
|
|
334
|
+
case "End":
|
|
335
|
+
return d(n);
|
|
336
|
+
case "PageDown":
|
|
337
|
+
case "PageUp": {
|
|
338
|
+
const x = v(), A = x ? Oe(x) : 1;
|
|
339
|
+
return d(t.key === "PageDown" ? o + A : o - A);
|
|
340
|
+
}
|
|
341
|
+
case "Enter":
|
|
342
|
+
t.preventDefault(), i === l ? mt?.(i) : V(i);
|
|
343
|
+
return;
|
|
344
|
+
case " ":
|
|
345
|
+
if (Ct) break;
|
|
346
|
+
t.preventDefault(), i !== l && V(i);
|
|
347
|
+
return;
|
|
348
|
+
case "Escape":
|
|
349
|
+
if (!Wt || l === null) return;
|
|
350
|
+
t.preventDefault(), t.stopPropagation(), V(null);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (t.key.length !== 1) return;
|
|
354
|
+
const Rt = (Ct ? O.current.text : "") + t.key.toLowerCase();
|
|
355
|
+
O.current = { text: Rt, at: t.timeStamp }, t.preventDefault();
|
|
356
|
+
const we = (x) => Y ? Y(m[x], x) : e.children[x]?.textContent ?? "", lt = ze(m.length, o, Rt, we);
|
|
357
|
+
lt >= 0 && lt !== o && e.children[lt].focus({ preventScroll: !0 });
|
|
358
|
+
}, j = s.useRef({ keys: !1, interactive: !1 });
|
|
359
|
+
s.useEffect(() => {
|
|
360
|
+
if (!f || !je()) return;
|
|
361
|
+
const t = y.current;
|
|
362
|
+
!j.current.keys && k?.some((e) => !e.keyed) && (j.current.keys = !0, console.warn("Roster Carousel: selection mode needs a key on every child; it's the option's identity.")), !j.current.interactive && t?.querySelector(`[data-carousel-item] :is(${at})`) && (j.current.interactive = !0, console.warn("Roster Carousel: an option holds something that takes focus. In selection mode the keys can't reach it; put it outside the row, or use onActivate."));
|
|
363
|
+
});
|
|
364
|
+
const [xe, be] = s.useState(0);
|
|
365
|
+
s.useEffect(() => {
|
|
366
|
+
const t = window.setTimeout(() => be(c.index), 150);
|
|
238
367
|
return () => window.clearTimeout(t);
|
|
239
|
-
}, [
|
|
240
|
-
const
|
|
241
|
-
const e = t === "prev", { className: r, ...
|
|
242
|
-
return /* @__PURE__ */
|
|
243
|
-
|
|
368
|
+
}, [c.index]);
|
|
369
|
+
const wt = u ?? se, Et = (t) => wt ? `${t} ${wt}` : t, nt = X !== "none" && c.overflowing !== !1, Se = X === "hover" ? qe : "rst:inline-flex", Tt = (t) => {
|
|
370
|
+
const e = t === "prev", { className: r, ...n } = zt ?? {};
|
|
371
|
+
return /* @__PURE__ */ g(
|
|
372
|
+
Te,
|
|
244
373
|
{
|
|
245
374
|
type: "button",
|
|
246
375
|
variant: "outline",
|
|
247
376
|
colorScheme: "neutral",
|
|
248
377
|
size: "icon",
|
|
249
|
-
...
|
|
250
|
-
"aria-label": e ?
|
|
251
|
-
"aria-controls":
|
|
252
|
-
disabled: e ? !
|
|
253
|
-
onClick: () =>
|
|
254
|
-
ref: e ?
|
|
378
|
+
...n,
|
|
379
|
+
"aria-label": e ? _t ?? Et("Previous") : $t ?? Et("Next"),
|
|
380
|
+
"aria-controls": yt,
|
|
381
|
+
disabled: e ? !c.canScrollPrev : !c.canScrollNext,
|
|
382
|
+
onClick: () => z(e ? -1 : 1),
|
|
383
|
+
ref: e ? Z : tt,
|
|
255
384
|
onFocus: () => {
|
|
256
|
-
|
|
385
|
+
et.current = t;
|
|
257
386
|
},
|
|
258
|
-
onBlur: (
|
|
259
|
-
|
|
387
|
+
onBlur: (o) => {
|
|
388
|
+
o.relatedTarget && (et.current = null);
|
|
260
389
|
},
|
|
261
390
|
"data-carousel-arrow": t,
|
|
262
|
-
className:
|
|
391
|
+
className: F(
|
|
263
392
|
/* 44px, the target size, whatever the Button's own icon size is. */
|
|
264
393
|
"rst:size-11 rst:shrink-0 rst:rounded-full",
|
|
265
394
|
/* Over the row, a disabled arrow would sit on top of the first or
|
|
266
395
|
last item for nothing, so it hides. Hidden is also out of the tab
|
|
267
396
|
order and the accessibility tree, as disabled already was. */
|
|
268
|
-
|
|
269
|
-
|
|
397
|
+
J === "overlay" && !B && "rst:bg-[var(--roster-popover-bg)] rst:elevation-raised rst:hover:bg-[var(--roster-popover-bg)] rst:disabled:invisible",
|
|
398
|
+
Se,
|
|
270
399
|
r
|
|
271
400
|
),
|
|
272
|
-
children: e ?
|
|
401
|
+
children: e ? Bt ?? /* @__PURE__ */ g(Dt, { direction: "prev" }) : Ht ?? /* @__PURE__ */ g(Dt, { direction: "next" })
|
|
273
402
|
}
|
|
274
403
|
);
|
|
275
|
-
},
|
|
404
|
+
}, K = nt ? Tt("prev") : null, st = nt ? Tt("next") : null, M = dt && L ? (
|
|
276
405
|
/* `font-ui` here and not on the root: the readout is the only text the
|
|
277
406
|
carousel owns. The items are the host's content, and not Roster's to
|
|
278
407
|
restyle. */
|
|
279
|
-
/* @__PURE__ */
|
|
408
|
+
/* @__PURE__ */ g("p", { "aria-live": "polite", className: "rst:font-ui rst:m-0 rst:text-sm rst:tabular-nums rst:opacity-75", "data-carousel-position": "", children: vt.position(xe + 1, L) })
|
|
280
409
|
) : null;
|
|
281
|
-
let
|
|
282
|
-
|
|
410
|
+
let ot = null;
|
|
411
|
+
B ? ot = B({ prev: K, next: st, position: M }) : J === "controls" && (K || M) && (ot = /* @__PURE__ */ q(
|
|
283
412
|
"div",
|
|
284
413
|
{
|
|
285
|
-
className:
|
|
414
|
+
className: F(
|
|
286
415
|
"rst:mb-2 rst:items-center rst:justify-end rst:gap-2",
|
|
287
416
|
/* A line with only arrows in it takes no room where they can't show. */
|
|
288
|
-
!
|
|
417
|
+
!M && X === "hover" ? We : "rst:flex"
|
|
289
418
|
),
|
|
290
419
|
"data-carousel-controls": "",
|
|
291
420
|
children: [
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
421
|
+
M && /* @__PURE__ */ g("div", { className: "rst:mr-auto", children: M }),
|
|
422
|
+
K,
|
|
423
|
+
st
|
|
295
424
|
]
|
|
296
425
|
}
|
|
297
426
|
));
|
|
298
|
-
const
|
|
299
|
-
"--rst-cv-gap":
|
|
300
|
-
"--rst-cv-gutter":
|
|
301
|
-
...
|
|
302
|
-
...
|
|
303
|
-
},
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
427
|
+
const it = Vt && c.overflowing && (c.canScrollPrev || c.canScrollNext) ? `linear-gradient(to right, ${c.canScrollPrev ? "transparent, black 48px" : "black"}, ${c.canScrollNext ? "black calc(100% - 48px), transparent" : "black"})` : void 0, U = S === void 0 && R !== void 0, ke = {
|
|
428
|
+
"--rst-cv-gap": ut(_),
|
|
429
|
+
"--rst-cv-gutter": ut($),
|
|
430
|
+
...U ? Fe(R) : {},
|
|
431
|
+
...it ? { maskImage: it, WebkitMaskImage: it } : {}
|
|
432
|
+
}, It = s.useMemo(
|
|
433
|
+
() => S !== void 0 ? { width: ut(S) } : U ? { width: _e } : void 0,
|
|
434
|
+
[S, U]
|
|
435
|
+
), Nt = F(
|
|
436
|
+
"rst:shrink-0",
|
|
437
|
+
G === "start" ? "rst:snap-start" : "rst:snap-center",
|
|
438
|
+
Ft && "rst:snap-always",
|
|
439
|
+
f && Ge,
|
|
440
|
+
Gt
|
|
441
|
+
);
|
|
442
|
+
return /* @__PURE__ */ q("div", { className: F("rst:min-w-0", Jt), style: Yt, ...Qt, "aria-describedby": f ? void 0 : b, children: [
|
|
443
|
+
ot,
|
|
444
|
+
/* @__PURE__ */ q("div", { className: "rst:relative", children: [
|
|
445
|
+
/* @__PURE__ */ g(
|
|
308
446
|
"ul",
|
|
309
447
|
{
|
|
310
|
-
ref:
|
|
311
|
-
id:
|
|
312
|
-
role: "list",
|
|
448
|
+
ref: y,
|
|
449
|
+
id: yt,
|
|
450
|
+
role: f ? "listbox" : "list",
|
|
313
451
|
"aria-label": u,
|
|
314
|
-
"aria-labelledby": u ? void 0 :
|
|
315
|
-
|
|
316
|
-
"
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
452
|
+
"aria-labelledby": u ? void 0 : p,
|
|
453
|
+
"aria-orientation": f ? "horizontal" : void 0,
|
|
454
|
+
"aria-describedby": f ? b : void 0,
|
|
455
|
+
tabIndex: !f && ie && c.overflowing ? 0 : void 0,
|
|
456
|
+
"data-overflowing": c.overflowing ? "" : void 0,
|
|
457
|
+
onPointerDown: ae,
|
|
458
|
+
onPointerMove: ue,
|
|
459
|
+
onPointerUp: rt,
|
|
460
|
+
onPointerCancel: rt,
|
|
461
|
+
onLostPointerCapture: rt,
|
|
462
|
+
onClickCapture: de,
|
|
463
|
+
onClick: f ? ye : void 0,
|
|
464
|
+
onKeyDown: f ? he : void 0,
|
|
465
|
+
onBlur: f ? ve : void 0,
|
|
466
|
+
onDragStart: fe,
|
|
467
|
+
onFocus: ge,
|
|
468
|
+
style: ke,
|
|
469
|
+
className: F(
|
|
327
470
|
"rst:m-0 rst:flex rst:list-none rst:overflow-x-auto rst:overflow-y-hidden",
|
|
328
471
|
"rst:gap-(--rst-cv-gap) rst:px-(--rst-cv-gutter) rst:py-1 rst:scroll-px-(--rst-cv-gutter)",
|
|
329
472
|
"rst:overscroll-x-contain",
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
!
|
|
333
|
-
|
|
473
|
+
At === "mandatory" ? "rst:snap-x rst:snap-mandatory" : "rst:snap-x rst:snap-proximity",
|
|
474
|
+
Mt && "rst:-mx-(--rst-cv-gutter)",
|
|
475
|
+
!jt && "rst:[scrollbar-width:none] rst:[&::-webkit-scrollbar]:hidden",
|
|
476
|
+
U && $e,
|
|
334
477
|
"rst:data-overflowing:cursor-grab rst:data-dragging:cursor-grabbing rst:data-dragging:select-none",
|
|
335
478
|
"rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-inset",
|
|
336
|
-
|
|
479
|
+
Xt
|
|
337
480
|
),
|
|
338
|
-
children:
|
|
481
|
+
children: k ? k.map((t, e) => /* @__PURE__ */ g(
|
|
482
|
+
Xe,
|
|
483
|
+
{
|
|
484
|
+
child: t.child,
|
|
485
|
+
index: e,
|
|
486
|
+
count: L,
|
|
487
|
+
selected: t.key === l,
|
|
488
|
+
active: t.key === E,
|
|
489
|
+
label: Y?.(t.key, e),
|
|
490
|
+
style: It,
|
|
491
|
+
className: Nt
|
|
492
|
+
},
|
|
493
|
+
t.key
|
|
494
|
+
)) : ht.map((t, e) => /* @__PURE__ */ g(
|
|
339
495
|
"li",
|
|
340
496
|
{
|
|
341
497
|
"data-carousel-item": "",
|
|
342
|
-
"aria-label":
|
|
343
|
-
style:
|
|
344
|
-
className:
|
|
345
|
-
"rst:shrink-0",
|
|
346
|
-
R === "start" ? "rst:snap-start" : "rst:snap-center",
|
|
347
|
-
at && "rst:snap-always",
|
|
348
|
-
xt
|
|
349
|
-
),
|
|
498
|
+
"aria-label": dt ? vt.position(e + 1, L) : void 0,
|
|
499
|
+
style: It,
|
|
500
|
+
className: Nt,
|
|
350
501
|
children: t
|
|
351
502
|
},
|
|
352
|
-
|
|
503
|
+
s.isValidElement(t) && t.key != null ? t.key : e
|
|
353
504
|
))
|
|
354
505
|
}
|
|
355
506
|
),
|
|
356
|
-
!
|
|
357
|
-
/* @__PURE__ */
|
|
358
|
-
/* @__PURE__ */
|
|
507
|
+
!B && J === "overlay" && nt && /* @__PURE__ */ q(Ee, { children: [
|
|
508
|
+
/* @__PURE__ */ g("div", { className: "rst:pointer-events-none rst:absolute rst:inset-y-0 rst:start-1 rst:flex rst:items-center", children: /* @__PURE__ */ g("div", { className: "rst:pointer-events-auto", children: K }) }),
|
|
509
|
+
/* @__PURE__ */ g("div", { className: "rst:pointer-events-none rst:absolute rst:inset-y-0 rst:end-1 rst:flex rst:items-center", children: /* @__PURE__ */ g("div", { className: "rst:pointer-events-auto", children: st }) })
|
|
359
510
|
] })
|
|
360
511
|
] })
|
|
361
512
|
] });
|
|
362
513
|
});
|
|
363
514
|
export {
|
|
364
|
-
|
|
515
|
+
cr as Carousel
|
|
365
516
|
};
|