@blakesteve/roster 5.6.0 → 5.8.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 +190 -5
- package/dist/components/atoms/Avatar/Avatar.cjs +1 -1
- package/dist/components/atoms/Avatar/Avatar.d.ts +4 -0
- package/dist/components/atoms/Avatar/Avatar.js +1 -1
- package/dist/components/atoms/AvatarStrip/AvatarStrip.cjs +1 -1
- package/dist/components/atoms/AvatarStrip/AvatarStrip.d.ts +10 -1
- package/dist/components/atoms/AvatarStrip/AvatarStrip.js +34 -30
- package/dist/components/atoms/Button/button-variants.cjs +1 -1
- package/dist/components/atoms/Button/button-variants.js +5 -3
- package/dist/components/atoms/Eyebrow/eyebrow-variants.cjs +1 -1
- package/dist/components/atoms/Eyebrow/eyebrow-variants.js +8 -4
- package/dist/components/atoms/LoadingDots/LoadingDots.cjs +1 -0
- package/dist/components/atoms/LoadingDots/LoadingDots.d.ts +20 -0
- package/dist/components/atoms/LoadingDots/LoadingDots.js +43 -0
- package/dist/components/atoms/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/atoms/MultiSelect/MultiSelect.d.ts +3 -1
- package/dist/components/atoms/MultiSelect/MultiSelect.js +87 -89
- package/dist/components/atoms/Progress/Progress.cjs +1 -0
- package/dist/components/atoms/Progress/Progress.d.ts +62 -0
- package/dist/components/atoms/Progress/Progress.js +107 -0
- package/dist/components/atoms/Progress/progress-values.cjs +1 -0
- package/dist/components/atoms/Progress/progress-values.d.ts +26 -0
- package/dist/components/atoms/Progress/progress-values.js +12 -0
- package/dist/components/atoms/Skeleton/Skeleton.cjs +1 -0
- package/dist/components/atoms/Skeleton/Skeleton.d.ts +79 -0
- package/dist/components/atoms/Skeleton/Skeleton.js +80 -0
- package/dist/components/atoms/Stat/Stat.cjs +1 -1
- package/dist/components/atoms/Stat/Stat.js +19 -19
- package/dist/components/atoms/Stat/stat-variants.cjs +1 -1
- package/dist/components/atoms/Stat/stat-variants.d.ts +1 -0
- package/dist/components/atoms/Stat/stat-variants.js +10 -7
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.d.ts +10 -1
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.js +31 -29
- package/dist/components/molecules/CallToAction/CallToAction.cjs +1 -1
- package/dist/components/molecules/CallToAction/CallToAction.d.ts +8 -1
- package/dist/components/molecules/CallToAction/CallToAction.js +34 -29
- package/dist/components/molecules/Carousel/Carousel.cjs +1 -1
- package/dist/components/molecules/Carousel/Carousel.d.ts +7 -0
- package/dist/components/molecules/Carousel/Carousel.js +155 -155
- package/dist/components/molecules/ErrorState/ErrorState.cjs +1 -1
- package/dist/components/molecules/ErrorState/ErrorState.d.ts +8 -1
- package/dist/components/molecules/ErrorState/ErrorState.js +44 -39
- package/dist/components/molecules/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/molecules/FileUpload/FileUpload.js +122 -142
- package/dist/components/molecules/MediaPreview/MediaPreview.cjs +1 -1
- package/dist/components/molecules/MediaPreview/MediaPreview.d.ts +3 -1
- package/dist/components/molecules/MediaPreview/MediaPreview.js +13 -12
- package/dist/components/molecules/Pagination/Pagination.cjs +1 -1
- package/dist/components/molecules/Pagination/Pagination.d.ts +1 -0
- package/dist/components/molecules/Pagination/Pagination.js +47 -46
- package/dist/components/molecules/ProgressField/ProgressField.cjs +1 -0
- package/dist/components/molecules/ProgressField/ProgressField.d.ts +24 -0
- package/dist/components/molecules/ProgressField/ProgressField.js +32 -0
- package/dist/components/molecules/SkeletonPresets/SkeletonPresets.cjs +1 -0
- package/dist/components/molecules/SkeletonPresets/SkeletonPresets.d.ts +55 -0
- package/dist/components/molecules/SkeletonPresets/SkeletonPresets.js +45 -0
- package/dist/components/molecules/StepProgress/StepProgress.cjs +1 -0
- package/dist/components/molecules/StepProgress/StepProgress.d.ts +37 -0
- package/dist/components/molecules/StepProgress/StepProgress.js +90 -0
- package/dist/components/organisms/Countdown/Countdown.cjs +1 -1
- package/dist/components/organisms/Countdown/Countdown.d.ts +13 -0
- package/dist/components/organisms/Countdown/Countdown.js +54 -47
- package/dist/components/organisms/DataTable/DataTable.cjs +1 -1
- package/dist/components/organisms/DataTable/DataTable.d.ts +5 -3
- package/dist/components/organisms/DataTable/DataTable.js +27 -26
- package/dist/components/organisms/Dialog/Dialog.cjs +1 -1
- package/dist/components/organisms/Dialog/Dialog.d.ts +9 -2
- package/dist/components/organisms/Dialog/Dialog.js +25 -23
- package/dist/components/organisms/Footer/Footer.cjs +1 -1
- package/dist/components/organisms/Footer/Footer.d.ts +9 -0
- package/dist/components/organisms/Footer/Footer.js +21 -23
- package/dist/components/organisms/ModerationQueue/ModerationQueue.cjs +1 -1
- package/dist/components/organisms/ModerationQueue/ModerationQueue.d.ts +40 -1
- package/dist/components/organisms/ModerationQueue/ModerationQueue.js +262 -237
- package/dist/components/organisms/ModerationQueue/QueueEditDialog.cjs +1 -1
- package/dist/components/organisms/ModerationQueue/QueueEditDialog.d.ts +1 -1
- package/dist/components/organisms/ModerationQueue/QueueEditDialog.js +23 -21
- package/dist/components/organisms/ModerationQueue/QueueEditSheet.cjs +1 -1
- package/dist/components/organisms/ModerationQueue/QueueEditSheet.d.ts +1 -1
- package/dist/components/organisms/ModerationQueue/QueueEditSheet.js +22 -20
- package/dist/components/organisms/ModerationQueue/queue-actions.d.ts +29 -10
- package/dist/components/organisms/Navbar/Navbar.cjs +1 -1
- package/dist/components/organisms/Navbar/Navbar.d.ts +38 -3
- package/dist/components/organisms/Navbar/Navbar.js +210 -187
- package/dist/components/organisms/Navbar/navbar-variants.cjs +1 -1
- package/dist/components/organisms/Navbar/navbar-variants.js +4 -2
- package/dist/components/organisms/Sheet/Sheet.cjs +1 -1
- package/dist/components/organisms/Sheet/Sheet.d.ts +8 -1
- package/dist/components/organisms/Sheet/Sheet.js +65 -63
- package/dist/index.d.ts +6 -0
- package/dist/lib/labels.cjs +1 -0
- package/dist/lib/labels.d.ts +7 -0
- package/dist/lib/labels.js +12 -0
- package/dist/meta.json +3 -3
- package/dist/roster.cjs +1 -1
- package/dist/roster.css +1 -1
- package/dist/roster.js +174 -157
- package/package.json +1 -1
|
@@ -25,6 +25,11 @@ export interface CarouselArrowsRender {
|
|
|
25
25
|
/** The "2 of 5" readout when `showPosition` is on, otherwise `null`. */
|
|
26
26
|
position: React.ReactNode;
|
|
27
27
|
}
|
|
28
|
+
/** Every word Carousel shows or says of its own, past its arrows' names. Pass any of them in `labels` to replace it. */
|
|
29
|
+
export interface CarouselLabels {
|
|
30
|
+
/** Where you are, with `showPosition`: the readout, and each item's name. "2 of 5". */
|
|
31
|
+
position: (current: number, total: number) => string;
|
|
32
|
+
}
|
|
28
33
|
export interface CarouselProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "aria-label" | "aria-labelledby"> {
|
|
29
34
|
/** The row's name. One of this or `aria-labelledby` is required. */
|
|
30
35
|
"aria-label"?: string;
|
|
@@ -103,6 +108,8 @@ export interface CarouselProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
103
108
|
* name, and a change is announced politely.
|
|
104
109
|
*/
|
|
105
110
|
showPosition?: boolean;
|
|
111
|
+
/** The component's own words, replaced; any left out stay English. */
|
|
112
|
+
labels?: Partial<CarouselLabels>;
|
|
106
113
|
/** The first item wholly in view, whenever it changes. */
|
|
107
114
|
onIndexChange?: (index: number) => void;
|
|
108
115
|
/** Whether the row can move each way, whenever that changes. */
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as c, jsxs as C, Fragment as Ht } from "react/jsx-runtime";
|
|
3
3
|
import * as n from "react";
|
|
4
|
-
import { Button as
|
|
5
|
-
import { cn as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { Button as jt } from "../../atoms/Button/Button.js";
|
|
5
|
+
import { cn as y } from "../../../lib/utils.js";
|
|
6
|
+
import { withLabels as zt } from "../../../lib/labels.js";
|
|
7
|
+
import { prefersReducedMotion as Ut } from "../../../internal/motion.js";
|
|
8
|
+
import { currentIndex as Vt, canScrollNext as Wt, canScrollPrev as qt, overflows as Xt, pageTarget as Gt, snapPosition as U, nearestIndex as Jt, CAROUSEL_DRAG_THRESHOLD as Kt } from "./carousel-math.js";
|
|
9
|
+
import { perViewVars as Qt, FLUID_ITEM_WIDTH as Yt, FLUID_CLASSES as Zt } from "./carousel-layout.js";
|
|
10
|
+
const te = { position: (i, u) => `${i} of ${u}` }, ee = (i) => Math.min(3e3, 500 + i * 0.35), re = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), [contenteditable]:not([contenteditable="false"])', V = (i) => typeof i == "number" ? `${i}px` : i;
|
|
11
|
+
function st(i) {
|
|
12
|
+
const u = parseFloat(i);
|
|
13
|
+
return Number.isFinite(u) ? u : 0;
|
|
13
14
|
}
|
|
14
|
-
const
|
|
15
|
-
function
|
|
15
|
+
const ne = "rst:hidden rst:[@media(any-hover:hover)]:inline-flex", se = "rst:hidden rst:[@media(any-hover:hover)]:flex";
|
|
16
|
+
function ot({ direction: i }) {
|
|
16
17
|
return /* @__PURE__ */ c(
|
|
17
18
|
"svg",
|
|
18
19
|
{
|
|
@@ -25,82 +26,83 @@ function st({ direction: a }) {
|
|
|
25
26
|
strokeWidth: "2",
|
|
26
27
|
strokeLinecap: "round",
|
|
27
28
|
strokeLinejoin: "round",
|
|
28
|
-
children: /* @__PURE__ */ c("path", { d:
|
|
29
|
+
children: /* @__PURE__ */ c("path", { d: i === "prev" ? "M12.5 4.5 7 10l5.5 5.5" : "M7.5 4.5 13 10l-5.5 5.5" })
|
|
29
30
|
}
|
|
30
31
|
);
|
|
31
32
|
}
|
|
32
|
-
const
|
|
33
|
+
const lt = {
|
|
33
34
|
overflowing: null,
|
|
34
35
|
canScrollPrev: !1,
|
|
35
36
|
canScrollNext: !1,
|
|
36
37
|
index: 0
|
|
37
|
-
},
|
|
38
|
-
"aria-label":
|
|
39
|
-
"aria-labelledby":
|
|
38
|
+
}, fe = n.forwardRef(function({
|
|
39
|
+
"aria-label": u,
|
|
40
|
+
"aria-labelledby": w,
|
|
40
41
|
children: W,
|
|
41
|
-
itemWidth:
|
|
42
|
-
perView:
|
|
42
|
+
itemWidth: N,
|
|
43
|
+
perView: k,
|
|
43
44
|
gap: q = 12,
|
|
44
45
|
gutter: X = 16,
|
|
45
|
-
bleed:
|
|
46
|
-
snap:
|
|
47
|
-
snapStrictness:
|
|
46
|
+
bleed: ct = !1,
|
|
47
|
+
snap: R = "start",
|
|
48
|
+
snapStrictness: it = "mandatory",
|
|
48
49
|
oneAtATime: at = !1,
|
|
49
50
|
arrows: P = "hover",
|
|
50
51
|
arrowPlacement: M = "controls",
|
|
51
|
-
renderArrows:
|
|
52
|
-
prevLabel:
|
|
53
|
-
nextLabel:
|
|
54
|
-
prevIcon:
|
|
55
|
-
nextIcon:
|
|
56
|
-
arrowButtonProps:
|
|
52
|
+
renderArrows: I,
|
|
53
|
+
prevLabel: ut,
|
|
54
|
+
nextLabel: dt,
|
|
55
|
+
prevIcon: ft,
|
|
56
|
+
nextIcon: gt,
|
|
57
|
+
arrowButtonProps: pt,
|
|
57
58
|
fade: vt = !1,
|
|
58
|
-
scrollbar:
|
|
59
|
+
scrollbar: mt = !1,
|
|
59
60
|
showPosition: G = !1,
|
|
61
|
+
labels: bt,
|
|
60
62
|
onIndexChange: J,
|
|
61
63
|
onScrollStateChange: K,
|
|
62
|
-
itemClassName:
|
|
63
|
-
listClassName:
|
|
64
|
-
className:
|
|
65
|
-
style:
|
|
66
|
-
...
|
|
67
|
-
},
|
|
68
|
-
const
|
|
64
|
+
itemClassName: xt,
|
|
65
|
+
listClassName: ht,
|
|
66
|
+
className: St,
|
|
67
|
+
style: yt,
|
|
68
|
+
...wt
|
|
69
|
+
}, Nt) {
|
|
70
|
+
const Q = zt(te, bt), g = n.useRef(null), Y = `${n.useId()}-list`, Z = n.Children.toArray(W), T = Z.length, [o, It] = n.useState(lt), tt = n.useRef(lt), [Tt, Et] = n.useState(""), [Lt, Ct] = n.useState(!1), A = n.useRef({ onIndexChange: J, onScrollStateChange: K });
|
|
69
71
|
n.useEffect(() => {
|
|
70
|
-
|
|
72
|
+
A.current = { onIndexChange: J, onScrollStateChange: K };
|
|
71
73
|
});
|
|
72
|
-
const
|
|
73
|
-
const t =
|
|
74
|
+
const d = n.useCallback(() => {
|
|
75
|
+
const t = g.current;
|
|
74
76
|
if (!t) return null;
|
|
75
77
|
const e = t.getBoundingClientRect(), r = getComputedStyle(t), s = e.left + t.clientLeft - t.scrollLeft;
|
|
76
78
|
return {
|
|
77
|
-
items: Array.from(t.children).map((
|
|
78
|
-
const
|
|
79
|
-
return { start:
|
|
79
|
+
items: Array.from(t.children).map((a) => {
|
|
80
|
+
const v = a.getBoundingClientRect();
|
|
81
|
+
return { start: v.left - s, end: v.right - s };
|
|
80
82
|
}),
|
|
81
83
|
scrollLeft: t.scrollLeft,
|
|
82
84
|
clientWidth: t.clientWidth,
|
|
83
85
|
scrollWidth: t.scrollWidth,
|
|
84
|
-
paddingStart:
|
|
85
|
-
paddingEnd:
|
|
86
|
-
align:
|
|
86
|
+
paddingStart: st(r.scrollPaddingInlineStart || r.scrollPaddingLeft),
|
|
87
|
+
paddingEnd: st(r.scrollPaddingInlineEnd || r.scrollPaddingRight),
|
|
88
|
+
align: R
|
|
87
89
|
};
|
|
88
|
-
}, [
|
|
89
|
-
const t =
|
|
90
|
+
}, [R]), m = n.useCallback(() => {
|
|
91
|
+
const t = d();
|
|
90
92
|
if (!t) return;
|
|
91
93
|
const e = {
|
|
92
|
-
overflowing:
|
|
93
|
-
canScrollPrev:
|
|
94
|
-
canScrollNext:
|
|
95
|
-
index: t.items.length ?
|
|
96
|
-
}, r =
|
|
97
|
-
r.overflowing === e.overflowing && r.canScrollPrev === e.canScrollPrev && r.canScrollNext === e.canScrollNext && r.index === e.index || (
|
|
94
|
+
overflowing: Xt(t),
|
|
95
|
+
canScrollPrev: qt(t),
|
|
96
|
+
canScrollNext: Wt(t),
|
|
97
|
+
index: t.items.length ? Vt(t) : 0
|
|
98
|
+
}, r = tt.current;
|
|
99
|
+
r.overflowing === e.overflowing && r.canScrollPrev === e.canScrollPrev && r.canScrollNext === e.canScrollNext && r.index === e.index || (tt.current = e, It(e), r.index !== e.index && A.current.onIndexChange?.(e.index), (r.canScrollPrev !== e.canScrollPrev || r.canScrollNext !== e.canScrollNext) && A.current.onScrollStateChange?.({
|
|
98
100
|
canScrollPrev: e.canScrollPrev,
|
|
99
101
|
canScrollNext: e.canScrollNext
|
|
100
102
|
}));
|
|
101
|
-
}, [
|
|
103
|
+
}, [d]), kt = JSON.stringify([q, X, N, k]);
|
|
102
104
|
n.useLayoutEffect(() => {
|
|
103
|
-
const t =
|
|
105
|
+
const t = g.current;
|
|
104
106
|
if (!t) return;
|
|
105
107
|
m();
|
|
106
108
|
let e = 0;
|
|
@@ -111,85 +113,87 @@ const ot = {
|
|
|
111
113
|
};
|
|
112
114
|
t.addEventListener("scroll", r, { passive: !0 });
|
|
113
115
|
const s = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => m()), l = () => {
|
|
114
|
-
s?.observe(t), Array.from(t.children).forEach((
|
|
116
|
+
s?.observe(t), Array.from(t.children).forEach((v) => s?.observe(v));
|
|
115
117
|
};
|
|
116
118
|
l();
|
|
117
|
-
const
|
|
119
|
+
const a = typeof MutationObserver > "u" ? null : new MutationObserver(() => {
|
|
118
120
|
l(), m();
|
|
119
121
|
});
|
|
120
|
-
return
|
|
121
|
-
t.removeEventListener("scroll", r), s?.disconnect(),
|
|
122
|
+
return a?.observe(t, { childList: !0 }), () => {
|
|
123
|
+
t.removeEventListener("scroll", r), s?.disconnect(), a?.disconnect(), e && cancelAnimationFrame(e);
|
|
122
124
|
};
|
|
123
|
-
}, [m,
|
|
124
|
-
const t =
|
|
125
|
-
if (t && (
|
|
126
|
-
const e =
|
|
127
|
-
|
|
125
|
+
}, [m, T, kt]), n.useLayoutEffect(() => {
|
|
126
|
+
const t = g.current;
|
|
127
|
+
if (t && (Ct(!t.querySelector(re)), w)) {
|
|
128
|
+
const e = w.split(/\s+/).map((r) => document.getElementById(r)?.textContent?.trim() ?? "").filter(Boolean).join(" ");
|
|
129
|
+
Et(e);
|
|
128
130
|
}
|
|
129
|
-
}, [W,
|
|
130
|
-
const b = n.useRef(null),
|
|
131
|
-
const t =
|
|
131
|
+
}, [W, w]);
|
|
132
|
+
const b = n.useRef(null), f = n.useCallback(() => {
|
|
133
|
+
const t = g.current, e = b.current;
|
|
132
134
|
e && (b.current = null, window.clearTimeout(e.timer), t?.removeEventListener("scrollend", e.done), t && (t.style.scrollSnapType = "", delete t.dataset.settling));
|
|
133
|
-
}, []),
|
|
135
|
+
}, []), p = n.useCallback(
|
|
134
136
|
(t, e) => {
|
|
135
|
-
const r =
|
|
137
|
+
const r = g.current;
|
|
136
138
|
if (!r) return;
|
|
137
|
-
if (
|
|
139
|
+
if (f(), e !== "smooth" || Ut() || Math.abs(r.scrollLeft - t) < 1) {
|
|
138
140
|
r.style.scrollSnapType = "none", r.scrollTo({ left: t, behavior: "instant" }), r.style.scrollSnapType = "";
|
|
139
141
|
return;
|
|
140
142
|
}
|
|
141
143
|
r.style.scrollSnapType = "none", r.dataset.settling = "";
|
|
142
|
-
const l = () =>
|
|
144
|
+
const l = r.scrollLeft, a = () => {
|
|
145
|
+
Math.abs(r.scrollLeft - l) < 0.5 || f();
|
|
146
|
+
};
|
|
143
147
|
b.current = {
|
|
144
|
-
timer: window.setTimeout(
|
|
145
|
-
done:
|
|
148
|
+
timer: window.setTimeout(f, ee(Math.abs(r.scrollLeft - t))),
|
|
149
|
+
done: a,
|
|
146
150
|
target: t
|
|
147
|
-
}, r.addEventListener("scrollend",
|
|
151
|
+
}, r.addEventListener("scrollend", a), r.scrollTo({ left: t, behavior: "smooth" });
|
|
148
152
|
},
|
|
149
|
-
[
|
|
150
|
-
),
|
|
153
|
+
[f]
|
|
154
|
+
), E = n.useCallback(
|
|
151
155
|
(t) => {
|
|
152
|
-
const e =
|
|
156
|
+
const e = d();
|
|
153
157
|
if (!e) return;
|
|
154
158
|
const r = b.current ? { ...e, scrollLeft: b.current.target } : e;
|
|
155
|
-
|
|
159
|
+
p(Gt(r, t), "smooth");
|
|
156
160
|
},
|
|
157
|
-
[
|
|
161
|
+
[d, p]
|
|
158
162
|
);
|
|
159
163
|
n.useImperativeHandle(
|
|
160
|
-
|
|
164
|
+
Nt,
|
|
161
165
|
() => ({
|
|
162
166
|
scrollToIndex: (t, e) => {
|
|
163
|
-
const r =
|
|
167
|
+
const r = d();
|
|
164
168
|
if (!r || !r.items.length) return;
|
|
165
169
|
const s = Math.min(Math.max(0, Math.round(t)), r.items.length - 1);
|
|
166
|
-
|
|
170
|
+
p(U(r, s), e?.behavior ?? "smooth");
|
|
167
171
|
},
|
|
168
|
-
scrollPrev: () =>
|
|
169
|
-
scrollNext: () =>
|
|
172
|
+
scrollPrev: () => E(-1),
|
|
173
|
+
scrollNext: () => E(1)
|
|
170
174
|
}),
|
|
171
|
-
[
|
|
172
|
-
), n.useEffect(() =>
|
|
173
|
-
const
|
|
175
|
+
[d, E, p]
|
|
176
|
+
), n.useEffect(() => f, [f]);
|
|
177
|
+
const D = n.useRef(null), O = n.useRef(null), F = n.useRef(null);
|
|
174
178
|
n.useLayoutEffect(() => {
|
|
175
179
|
const t = F.current;
|
|
176
180
|
if (!t) return;
|
|
177
|
-
const e = t === "prev" ?
|
|
181
|
+
const e = t === "prev" ? D.current : O.current, r = t === "prev" ? O.current : D.current, s = t === "prev" ? !o.canScrollPrev : !o.canScrollNext, l = document.activeElement;
|
|
178
182
|
s && (l !== e && l !== document.body && l !== null || r && !r.disabled && r.focus());
|
|
179
183
|
}, [o.canScrollPrev, o.canScrollNext]);
|
|
180
|
-
const x = n.useRef(null), h = n.useRef(!1),
|
|
181
|
-
t.pointerType !== "mouse" || t.button !== 0 || o.overflowing && (
|
|
184
|
+
const x = n.useRef(null), h = n.useRef(!1), Rt = (t) => {
|
|
185
|
+
t.pointerType !== "mouse" || t.button !== 0 || o.overflowing && (f(), h.current = !1, x.current = {
|
|
182
186
|
pointerId: t.pointerId,
|
|
183
187
|
x0: t.clientX,
|
|
184
188
|
scroll0: t.currentTarget.scrollLeft,
|
|
185
189
|
dragging: !1
|
|
186
190
|
});
|
|
187
|
-
},
|
|
191
|
+
}, Pt = (t) => {
|
|
188
192
|
const e = x.current;
|
|
189
193
|
if (!e || t.pointerId !== e.pointerId) return;
|
|
190
194
|
const r = t.currentTarget, s = t.clientX - e.x0;
|
|
191
195
|
if (!e.dragging) {
|
|
192
|
-
if (Math.abs(s) <=
|
|
196
|
+
if (Math.abs(s) <= Kt) return;
|
|
193
197
|
e.dragging = !0, r.dataset.dragging = "", r.style.scrollSnapType = "none", window.getSelection?.()?.removeAllRanges();
|
|
194
198
|
try {
|
|
195
199
|
r.setPointerCapture(t.pointerId);
|
|
@@ -204,13 +208,13 @@ const ot = {
|
|
|
204
208
|
delete r.dataset.dragging, h.current = t.type === "pointerup", window.setTimeout(() => {
|
|
205
209
|
h.current = !1;
|
|
206
210
|
}, 0);
|
|
207
|
-
const s =
|
|
208
|
-
s ?
|
|
209
|
-
},
|
|
211
|
+
const s = d();
|
|
212
|
+
s ? p(U(s, Jt(s)), "smooth") : r.style.scrollSnapType = "";
|
|
213
|
+
}, Mt = (t) => {
|
|
210
214
|
!h.current || t.detail === 0 || (h.current = !1, t.preventDefault(), t.stopPropagation());
|
|
211
|
-
},
|
|
215
|
+
}, At = (t) => {
|
|
212
216
|
o.overflowing && t.preventDefault();
|
|
213
|
-
},
|
|
217
|
+
}, Dt = (t) => {
|
|
214
218
|
const e = t.currentTarget, r = t.target;
|
|
215
219
|
if (r === e || x.current?.dragging) return;
|
|
216
220
|
let s = !1;
|
|
@@ -222,30 +226,30 @@ const ot = {
|
|
|
222
226
|
if (!s) return;
|
|
223
227
|
const l = r.closest("[data-carousel-item]");
|
|
224
228
|
if (!l || l.parentElement !== e) return;
|
|
225
|
-
const
|
|
226
|
-
if (!
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
}, [
|
|
229
|
+
const a = d();
|
|
230
|
+
if (!a) return;
|
|
231
|
+
const v = Array.prototype.indexOf.call(e.children, l);
|
|
232
|
+
p(U(a, v), "instant");
|
|
233
|
+
}, [Ot, Ft] = n.useState(0);
|
|
230
234
|
n.useEffect(() => {
|
|
231
|
-
const t = window.setTimeout(() =>
|
|
235
|
+
const t = window.setTimeout(() => Ft(o.index), 150);
|
|
232
236
|
return () => window.clearTimeout(t);
|
|
233
237
|
}, [o.index]);
|
|
234
|
-
const
|
|
235
|
-
const e = t === "prev", { className: r, ...s } =
|
|
238
|
+
const et = u ?? Tt, rt = (t) => et ? `${t} ${et}` : t, $ = P !== "none" && o.overflowing !== !1, _t = P === "hover" ? ne : "rst:inline-flex", nt = (t) => {
|
|
239
|
+
const e = t === "prev", { className: r, ...s } = pt ?? {};
|
|
236
240
|
return /* @__PURE__ */ c(
|
|
237
|
-
|
|
241
|
+
jt,
|
|
238
242
|
{
|
|
239
243
|
type: "button",
|
|
240
244
|
variant: "outline",
|
|
241
245
|
colorScheme: "neutral",
|
|
242
246
|
size: "icon",
|
|
243
247
|
...s,
|
|
244
|
-
"aria-label": e ?
|
|
245
|
-
"aria-controls":
|
|
248
|
+
"aria-label": e ? ut ?? rt("Previous") : dt ?? rt("Next"),
|
|
249
|
+
"aria-controls": Y,
|
|
246
250
|
disabled: e ? !o.canScrollPrev : !o.canScrollNext,
|
|
247
|
-
onClick: () =>
|
|
248
|
-
ref: e ?
|
|
251
|
+
onClick: () => E(e ? -1 : 1),
|
|
252
|
+
ref: e ? D : O,
|
|
249
253
|
onFocus: () => {
|
|
250
254
|
F.current = t;
|
|
251
255
|
},
|
|
@@ -253,97 +257,93 @@ const ot = {
|
|
|
253
257
|
l.relatedTarget && (F.current = null);
|
|
254
258
|
},
|
|
255
259
|
"data-carousel-arrow": t,
|
|
256
|
-
className:
|
|
260
|
+
className: y(
|
|
257
261
|
/* 44px, the target size, whatever the Button's own icon size is. */
|
|
258
262
|
"rst:size-11 rst:shrink-0 rst:rounded-full",
|
|
259
263
|
/* Over the row, a disabled arrow would sit on top of the first or
|
|
260
264
|
last item for nothing, so it hides. Hidden is also out of the tab
|
|
261
265
|
order and the accessibility tree, as disabled already was. */
|
|
262
|
-
M === "overlay" && !
|
|
263
|
-
|
|
266
|
+
M === "overlay" && !I && "rst:bg-[var(--roster-popover-bg)] rst:elevation-raised rst:hover:bg-[var(--roster-popover-bg)] rst:disabled:invisible",
|
|
267
|
+
_t,
|
|
264
268
|
r
|
|
265
269
|
),
|
|
266
|
-
children: e ?
|
|
270
|
+
children: e ? ft ?? /* @__PURE__ */ c(ot, { direction: "prev" }) : gt ?? /* @__PURE__ */ c(ot, { direction: "next" })
|
|
267
271
|
}
|
|
268
272
|
);
|
|
269
|
-
},
|
|
273
|
+
}, L = $ ? nt("prev") : null, B = $ ? nt("next") : null, S = G && T ? (
|
|
270
274
|
/* `font-ui` here and not on the root: the readout is the only text the
|
|
271
275
|
carousel owns. The items are the host's content, and not Roster's to
|
|
272
276
|
restyle. */
|
|
273
|
-
/* @__PURE__ */
|
|
274
|
-
Dt + 1,
|
|
275
|
-
" of ",
|
|
276
|
-
E
|
|
277
|
-
] })
|
|
277
|
+
/* @__PURE__ */ c("p", { "aria-live": "polite", className: "rst:font-ui rst:m-0 rst:text-sm rst:tabular-nums rst:opacity-75", "data-carousel-position": "", children: Q.position(Ot + 1, T) })
|
|
278
278
|
) : null;
|
|
279
279
|
let H = null;
|
|
280
|
-
|
|
280
|
+
I ? H = I({ prev: L, next: B, position: S }) : M === "controls" && (L || S) && (H = /* @__PURE__ */ C(
|
|
281
281
|
"div",
|
|
282
282
|
{
|
|
283
|
-
className:
|
|
283
|
+
className: y(
|
|
284
284
|
"rst:mb-2 rst:items-center rst:justify-end rst:gap-2",
|
|
285
285
|
/* A line with only arrows in it takes no room where they can't show. */
|
|
286
|
-
!S && P === "hover" ?
|
|
286
|
+
!S && P === "hover" ? se : "rst:flex"
|
|
287
287
|
),
|
|
288
288
|
"data-carousel-controls": "",
|
|
289
289
|
children: [
|
|
290
290
|
S && /* @__PURE__ */ c("div", { className: "rst:mr-auto", children: S }),
|
|
291
|
-
|
|
291
|
+
L,
|
|
292
292
|
B
|
|
293
293
|
]
|
|
294
294
|
}
|
|
295
295
|
));
|
|
296
|
-
const j = vt && o.overflowing && (o.canScrollPrev || o.canScrollNext) ? `linear-gradient(to right, ${o.canScrollPrev ? "transparent, black 48px" : "black"}, ${o.canScrollNext ? "black calc(100% - 48px), transparent" : "black"})` : void 0, z =
|
|
296
|
+
const j = vt && o.overflowing && (o.canScrollPrev || o.canScrollNext) ? `linear-gradient(to right, ${o.canScrollPrev ? "transparent, black 48px" : "black"}, ${o.canScrollNext ? "black calc(100% - 48px), transparent" : "black"})` : void 0, z = N === void 0 && k !== void 0, $t = {
|
|
297
297
|
"--rst-cv-gap": V(q),
|
|
298
298
|
"--rst-cv-gutter": V(X),
|
|
299
|
-
...z ?
|
|
299
|
+
...z ? Qt(k) : {},
|
|
300
300
|
...j ? { maskImage: j, WebkitMaskImage: j } : {}
|
|
301
|
-
},
|
|
302
|
-
return /* @__PURE__ */
|
|
301
|
+
}, Bt = N !== void 0 ? { width: V(N) } : z ? { width: Yt } : void 0;
|
|
302
|
+
return /* @__PURE__ */ C("div", { className: y("rst:min-w-0", St), style: yt, ...wt, children: [
|
|
303
303
|
H,
|
|
304
|
-
/* @__PURE__ */
|
|
304
|
+
/* @__PURE__ */ C("div", { className: "rst:relative", children: [
|
|
305
305
|
/* @__PURE__ */ c(
|
|
306
306
|
"ul",
|
|
307
307
|
{
|
|
308
|
-
ref:
|
|
309
|
-
id:
|
|
308
|
+
ref: g,
|
|
309
|
+
id: Y,
|
|
310
310
|
role: "list",
|
|
311
|
-
"aria-label":
|
|
312
|
-
"aria-labelledby":
|
|
313
|
-
tabIndex:
|
|
311
|
+
"aria-label": u,
|
|
312
|
+
"aria-labelledby": u ? void 0 : w,
|
|
313
|
+
tabIndex: Lt && o.overflowing ? 0 : void 0,
|
|
314
314
|
"data-overflowing": o.overflowing ? "" : void 0,
|
|
315
|
-
onPointerDown:
|
|
316
|
-
onPointerMove:
|
|
315
|
+
onPointerDown: Rt,
|
|
316
|
+
onPointerMove: Pt,
|
|
317
317
|
onPointerUp: _,
|
|
318
318
|
onPointerCancel: _,
|
|
319
319
|
onLostPointerCapture: _,
|
|
320
|
-
onClickCapture:
|
|
321
|
-
onDragStart:
|
|
322
|
-
onFocus:
|
|
323
|
-
style:
|
|
324
|
-
className:
|
|
320
|
+
onClickCapture: Mt,
|
|
321
|
+
onDragStart: At,
|
|
322
|
+
onFocus: Dt,
|
|
323
|
+
style: $t,
|
|
324
|
+
className: y(
|
|
325
325
|
"rst:m-0 rst:flex rst:list-none rst:overflow-x-auto rst:overflow-y-hidden",
|
|
326
326
|
"rst:gap-(--rst-cv-gap) rst:px-(--rst-cv-gutter) rst:py-1 rst:scroll-px-(--rst-cv-gutter)",
|
|
327
327
|
"rst:overscroll-x-contain",
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
!
|
|
331
|
-
z &&
|
|
328
|
+
it === "mandatory" ? "rst:snap-x rst:snap-mandatory" : "rst:snap-x rst:snap-proximity",
|
|
329
|
+
ct && "rst:-mx-(--rst-cv-gutter)",
|
|
330
|
+
!mt && "rst:[scrollbar-width:none] rst:[&::-webkit-scrollbar]:hidden",
|
|
331
|
+
z && Zt,
|
|
332
332
|
"rst:data-overflowing:cursor-grab rst:data-dragging:cursor-grabbing rst:data-dragging:select-none",
|
|
333
333
|
"rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-inset",
|
|
334
|
-
|
|
334
|
+
ht
|
|
335
335
|
),
|
|
336
|
-
children:
|
|
336
|
+
children: Z.map((t, e) => /* @__PURE__ */ c(
|
|
337
337
|
"li",
|
|
338
338
|
{
|
|
339
339
|
"data-carousel-item": "",
|
|
340
|
-
"aria-label": G ?
|
|
341
|
-
style:
|
|
342
|
-
className:
|
|
340
|
+
"aria-label": G ? Q.position(e + 1, T) : void 0,
|
|
341
|
+
style: Bt,
|
|
342
|
+
className: y(
|
|
343
343
|
"rst:shrink-0",
|
|
344
|
-
|
|
344
|
+
R === "start" ? "rst:snap-start" : "rst:snap-center",
|
|
345
345
|
at && "rst:snap-always",
|
|
346
|
-
|
|
346
|
+
xt
|
|
347
347
|
),
|
|
348
348
|
children: t
|
|
349
349
|
},
|
|
@@ -351,13 +351,13 @@ const ot = {
|
|
|
351
351
|
))
|
|
352
352
|
}
|
|
353
353
|
),
|
|
354
|
-
!
|
|
355
|
-
/* @__PURE__ */ c("div", { className: "rst:pointer-events-none rst:absolute rst:inset-y-0 rst:start-1 rst:flex rst:items-center", children: /* @__PURE__ */ c("div", { className: "rst:pointer-events-auto", children:
|
|
354
|
+
!I && M === "overlay" && $ && /* @__PURE__ */ C(Ht, { children: [
|
|
355
|
+
/* @__PURE__ */ c("div", { className: "rst:pointer-events-none rst:absolute rst:inset-y-0 rst:start-1 rst:flex rst:items-center", children: /* @__PURE__ */ c("div", { className: "rst:pointer-events-auto", children: L }) }),
|
|
356
356
|
/* @__PURE__ */ c("div", { className: "rst:pointer-events-none rst:absolute rst:inset-y-0 rst:end-1 rst:flex rst:items-center", children: /* @__PURE__ */ c("div", { className: "rst:pointer-events-auto", children: B }) })
|
|
357
357
|
] })
|
|
358
358
|
] })
|
|
359
359
|
] });
|
|
360
360
|
});
|
|
361
361
|
export {
|
|
362
|
-
|
|
362
|
+
fe as Carousel
|
|
363
363
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime");require("react");const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime");require("react");const x=require("../../../node_modules/@fortawesome/react-fontawesome/dist/index.cjs"),m=require("../../../node_modules/@fortawesome/free-solid-svg-icons/index.cjs"),l=require("../../../lib/utils.cjs"),h=require("../../../lib/labels.cjs"),g=require("./error-state-variants.cjs"),j=require("../../atoms/Button/Button.cjs"),f={retry:"Try Again"},b=({title:n="An Error Occurred",description:c,onRetry:e,action:s,icon:i,labels:a,variant:t,className:o,...d})=>{const u=h.withLabels(f,a);return r.jsxs("div",{className:l.cn(g.errorStateVariants({variant:t}),o),...d,children:[r.jsx("div",{className:"rst:mb-4 rst:flex rst:h-12 rst:w-12 rst:items-center rst:justify-center rst:rounded-full rst:bg-error-100 rst:text-error-600 rst:dark:bg-error-500/15 rst:dark:text-error-400",children:r.jsx("div",{className:"rst:h-6 rst:w-6 rst:flex rst:items-center rst:justify-center",children:i||r.jsx(x.FontAwesomeIcon,{icon:m.faTriangleExclamation,className:"rst:h-full rst:w-full"})})}),r.jsx("h3",{className:"rst:text-lg rst:font-bold rst:tracking-tight",children:n}),r.jsx("p",{className:l.cn("rst:mt-2 rst:text-sm rst:leading-relaxed",t==="card"?"rst:text-error-800/80 rst:dark:text-error-200/80":"rst:text-gray-500 rst:dark:text-gray-400"),children:c}),r.jsx("div",{className:"rst:mt-6",children:s||(e?r.jsx(j.Button,{onClick:e,colorScheme:"error",variant:t==="card"?"outline":"solid",children:u.retry}):null)})]})};exports.ErrorState=b;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { VariantProps } from 'class-variance-authority';
|
|
3
3
|
import { errorStateVariants } from './error-state-variants';
|
|
4
|
+
/** Every word ErrorState shows of its own, past its `title`. Pass any of them in `labels` to replace it. */
|
|
5
|
+
export interface ErrorStateLabels {
|
|
6
|
+
/** The retry button, with `onRetry`. */
|
|
7
|
+
retry: string;
|
|
8
|
+
}
|
|
4
9
|
export interface ErrorStateProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof errorStateVariants> {
|
|
5
10
|
title?: string;
|
|
6
11
|
description: string;
|
|
7
12
|
onRetry?: () => void;
|
|
8
13
|
action?: React.ReactNode;
|
|
9
14
|
icon?: React.ReactNode;
|
|
15
|
+
/** The component's own words, replaced; any left out stay English. */
|
|
16
|
+
labels?: Partial<ErrorStateLabels>;
|
|
10
17
|
}
|
|
11
|
-
declare const ErrorState: ({ title, description, onRetry, action, icon, variant, className, ...props }: ErrorStateProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare const ErrorState: ({ title, description, onRetry, action, icon, labels, variant, className, ...props }: ErrorStateProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
19
|
export { ErrorState };
|