@blakesteve/roster 5.7.0 → 5.9.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.
Files changed (106) hide show
  1. package/README.md +169 -5
  2. package/dist/components/atoms/Avatar/Avatar.cjs +1 -1
  3. package/dist/components/atoms/Avatar/Avatar.d.ts +4 -0
  4. package/dist/components/atoms/Avatar/Avatar.js +1 -1
  5. package/dist/components/atoms/AvatarStrip/AvatarStrip.cjs +1 -1
  6. package/dist/components/atoms/AvatarStrip/AvatarStrip.d.ts +10 -1
  7. package/dist/components/atoms/AvatarStrip/AvatarStrip.js +34 -30
  8. package/dist/components/atoms/Button/button-variants.cjs +1 -1
  9. package/dist/components/atoms/Button/button-variants.js +5 -3
  10. package/dist/components/atoms/Eyebrow/eyebrow-variants.cjs +1 -1
  11. package/dist/components/atoms/Eyebrow/eyebrow-variants.js +8 -4
  12. package/dist/components/atoms/MultiSelect/MultiSelect.cjs +1 -1
  13. package/dist/components/atoms/MultiSelect/MultiSelect.d.ts +3 -1
  14. package/dist/components/atoms/MultiSelect/MultiSelect.js +87 -89
  15. package/dist/components/atoms/Progress/Progress.cjs +1 -1
  16. package/dist/components/atoms/Progress/Progress.d.ts +1 -0
  17. package/dist/components/atoms/Progress/Progress.js +28 -27
  18. package/dist/components/atoms/Stat/Stat.cjs +1 -1
  19. package/dist/components/atoms/Stat/Stat.js +5 -5
  20. package/dist/components/atoms/Stat/stat-variants.cjs +1 -1
  21. package/dist/components/atoms/Stat/stat-variants.js +10 -8
  22. package/dist/components/molecules/Breadcrumbs/Breadcrumbs.cjs +1 -1
  23. package/dist/components/molecules/Breadcrumbs/Breadcrumbs.d.ts +10 -1
  24. package/dist/components/molecules/Breadcrumbs/Breadcrumbs.js +31 -29
  25. package/dist/components/molecules/CallToAction/CallToAction.cjs +1 -1
  26. package/dist/components/molecules/CallToAction/CallToAction.d.ts +8 -1
  27. package/dist/components/molecules/CallToAction/CallToAction.js +34 -29
  28. package/dist/components/molecules/Carousel/Carousel.cjs +1 -1
  29. package/dist/components/molecules/Carousel/Carousel.d.ts +7 -0
  30. package/dist/components/molecules/Carousel/Carousel.js +155 -155
  31. package/dist/components/molecules/ErrorState/ErrorState.cjs +1 -1
  32. package/dist/components/molecules/ErrorState/ErrorState.d.ts +8 -1
  33. package/dist/components/molecules/ErrorState/ErrorState.js +44 -39
  34. package/dist/components/molecules/FileUpload/FileUpload.cjs +1 -1
  35. package/dist/components/molecules/FileUpload/FileUpload.js +23 -22
  36. package/dist/components/molecules/MediaPreview/MediaPreview.cjs +1 -1
  37. package/dist/components/molecules/MediaPreview/MediaPreview.d.ts +3 -1
  38. package/dist/components/molecules/MediaPreview/MediaPreview.js +13 -12
  39. package/dist/components/molecules/Menu/Menu.cjs +1 -0
  40. package/dist/components/molecules/Menu/Menu.d.ts +169 -0
  41. package/dist/components/molecules/Menu/Menu.js +577 -0
  42. package/dist/components/molecules/Menu/menu-typeahead.cjs +1 -0
  43. package/dist/components/molecules/Menu/menu-typeahead.d.ts +7 -0
  44. package/dist/components/molecules/Menu/menu-typeahead.js +13 -0
  45. package/dist/components/molecules/Pagination/Pagination.cjs +1 -1
  46. package/dist/components/molecules/Pagination/Pagination.d.ts +1 -0
  47. package/dist/components/molecules/Pagination/Pagination.js +47 -46
  48. package/dist/components/molecules/ProgressField/ProgressField.d.ts +1 -0
  49. package/dist/components/molecules/SkeletonPresets/SkeletonPresets.cjs +1 -1
  50. package/dist/components/molecules/SkeletonPresets/SkeletonPresets.d.ts +2 -2
  51. package/dist/components/molecules/SkeletonPresets/SkeletonPresets.js +17 -17
  52. package/dist/components/molecules/StepProgress/StepProgress.cjs +1 -1
  53. package/dist/components/molecules/StepProgress/StepProgress.d.ts +1 -0
  54. package/dist/components/molecules/StepProgress/StepProgress.js +9 -8
  55. package/dist/components/organisms/Countdown/Countdown.cjs +1 -1
  56. package/dist/components/organisms/Countdown/Countdown.d.ts +13 -0
  57. package/dist/components/organisms/Countdown/Countdown.js +54 -47
  58. package/dist/components/organisms/DataTable/DataTable.cjs +1 -1
  59. package/dist/components/organisms/DataTable/DataTable.d.ts +5 -3
  60. package/dist/components/organisms/DataTable/DataTable.js +27 -26
  61. package/dist/components/organisms/Dialog/Dialog.cjs +1 -1
  62. package/dist/components/organisms/Dialog/Dialog.d.ts +8 -1
  63. package/dist/components/organisms/Dialog/Dialog.js +25 -23
  64. package/dist/components/organisms/Footer/Footer.cjs +1 -1
  65. package/dist/components/organisms/Footer/Footer.d.ts +9 -0
  66. package/dist/components/organisms/Footer/Footer.js +21 -23
  67. package/dist/components/organisms/ModerationQueue/ModerationQueue.cjs +1 -1
  68. package/dist/components/organisms/ModerationQueue/ModerationQueue.d.ts +40 -1
  69. package/dist/components/organisms/ModerationQueue/ModerationQueue.js +262 -237
  70. package/dist/components/organisms/ModerationQueue/QueueEditDialog.cjs +1 -1
  71. package/dist/components/organisms/ModerationQueue/QueueEditDialog.d.ts +1 -1
  72. package/dist/components/organisms/ModerationQueue/QueueEditDialog.js +23 -21
  73. package/dist/components/organisms/ModerationQueue/QueueEditSheet.cjs +1 -1
  74. package/dist/components/organisms/ModerationQueue/QueueEditSheet.d.ts +1 -1
  75. package/dist/components/organisms/ModerationQueue/QueueEditSheet.js +22 -20
  76. package/dist/components/organisms/ModerationQueue/queue-actions.d.ts +29 -10
  77. package/dist/components/organisms/Navbar/Navbar.cjs +1 -1
  78. package/dist/components/organisms/Navbar/Navbar.d.ts +39 -4
  79. package/dist/components/organisms/Navbar/Navbar.js +297 -301
  80. package/dist/components/organisms/Navbar/navbar-variants.cjs +1 -1
  81. package/dist/components/organisms/Navbar/navbar-variants.js +4 -2
  82. package/dist/components/organisms/Sheet/Sheet.cjs +1 -1
  83. package/dist/components/organisms/Sheet/Sheet.d.ts +8 -1
  84. package/dist/components/organisms/Sheet/Sheet.js +65 -63
  85. package/dist/index.d.ts +1 -0
  86. package/dist/lib/labels.cjs +1 -0
  87. package/dist/lib/labels.d.ts +7 -0
  88. package/dist/lib/labels.js +12 -0
  89. package/dist/meta.json +3 -3
  90. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +7 -7
  91. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +2 -2
  92. package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +5 -5
  93. package/dist/node_modules/@headlessui/react/dist/components/portal/portal.js +6 -6
  94. package/dist/node_modules/@headlessui/react/dist/utils/focus-management.cjs +1 -1
  95. package/dist/node_modules/@headlessui/react/dist/utils/focus-management.js +52 -61
  96. package/dist/node_modules/@radix-ui/react-popper/dist/index.js +6 -6
  97. package/dist/roster.cjs +1 -1
  98. package/dist/roster.css +1 -1
  99. package/dist/roster.js +127 -116
  100. package/package.json +2 -1
  101. package/dist/node_modules/@headlessui/react/dist/components/menu/menu-machine-glue.cjs +0 -1
  102. package/dist/node_modules/@headlessui/react/dist/components/menu/menu-machine-glue.js +0 -21
  103. package/dist/node_modules/@headlessui/react/dist/components/menu/menu-machine.cjs +0 -1
  104. package/dist/node_modules/@headlessui/react/dist/components/menu/menu-machine.js +0 -120
  105. package/dist/node_modules/@headlessui/react/dist/components/menu/menu.cjs +0 -1
  106. package/dist/node_modules/@headlessui/react/dist/components/menu/menu.js +0 -197
@@ -0,0 +1,577 @@
1
+ "use client";
2
+ import { jsx as c, jsxs as N, Fragment as j } from "react/jsx-runtime";
3
+ import * as i from "react";
4
+ import { Portal as q } from "../../../node_modules/@headlessui/react/dist/components/portal/portal.js";
5
+ import { useFloating as ge, offset as he, flip as be, shift as ye, size as ve } from "../../../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js";
6
+ import { cn as E } from "../../../lib/utils.js";
7
+ import { POPUP_PANEL as we } from "../../../internal/popup.js";
8
+ import { Button as xe } from "../../atoms/Button/Button.js";
9
+ import { nextByTypeahead as ke } from "./menu-typeahead.js";
10
+ import { autoUpdate as Ie } from "../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
11
+ function Ee({ href: e, to: r, children: n, ...s }) {
12
+ return /* @__PURE__ */ c("a", { href: e, ...s, children: n });
13
+ }
14
+ const G = i.createContext(null), B = i.createContext(null), Y = i.createContext(null);
15
+ function C(e) {
16
+ const r = i.useContext(G);
17
+ if (!r) throw new Error(`<${e}> must be inside a <Menu>.`);
18
+ return r;
19
+ }
20
+ function _(e) {
21
+ const r = i.useContext(B);
22
+ if (!r) throw new Error(`<${e}> must be inside <MenuItems> or a <MenuSubmenu>.`);
23
+ return r;
24
+ }
25
+ const Se = "[data-menu-item]", X = 100, Pe = 75, Me = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"]), [contenteditable]:not([contenteditable="false"])';
26
+ function L(e) {
27
+ return e ? [...e.querySelectorAll(Se)].filter((r) => r.closest("[data-menu-panel]") === e) : [];
28
+ }
29
+ function S(e) {
30
+ e && (e.focus({ preventScroll: !0 }), e.scrollIntoView?.({ block: "nearest" }));
31
+ }
32
+ function z(e) {
33
+ return !!e && getComputedStyle(e).direction === "rtl";
34
+ }
35
+ function Te(e, r) {
36
+ const n = [...document.querySelectorAll(Me)].filter(
37
+ (t) => t === e || t.tabIndex >= 0 && !t.matches(":disabled") && !t.closest("[data-menu-panel], [inert]") && t.getClientRects().length > 0 && getComputedStyle(t).visibility !== "hidden" && !Ae(t, r)
38
+ ), s = n.indexOf(e);
39
+ ((r ? n[s - 1] : n[s + 1]) ?? e).focus();
40
+ }
41
+ function Ae(e, r) {
42
+ if (!(e instanceof HTMLInputElement) || e.type !== "radio" || !e.name) return !1;
43
+ const n = [...e.ownerDocument.querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(
44
+ (a) => a.form === e.form && !a.disabled
45
+ );
46
+ return (n.find((a) => a.checked) ?? (r ? n[n.length - 1] : n[0])) !== e;
47
+ }
48
+ const D = { x: Number.NaN, y: Number.NaN };
49
+ let U = !1;
50
+ function Ce() {
51
+ U || typeof window > "u" || (U = !0, window.addEventListener(
52
+ "pointermove",
53
+ (e) => {
54
+ D.x = e.clientX, D.y = e.clientY;
55
+ },
56
+ { passive: !0 }
57
+ ));
58
+ }
59
+ function J(e) {
60
+ return !Number.isNaN(D.x) && (e.clientX !== D.x || e.clientY !== D.y);
61
+ }
62
+ const V = (e) => `radial-gradient(farthest-side at 50% ${e === "top" ? "0" : "100%"}, var(--menu-edge), transparent)`, Q = {
63
+ backgroundImage: "var(--menu-edge-top, none), var(--menu-edge-bottom, none)",
64
+ backgroundPosition: "top, bottom",
65
+ backgroundSize: "100% 0.5rem",
66
+ backgroundRepeat: "no-repeat"
67
+ };
68
+ function Re(e) {
69
+ i.useLayoutEffect(() => {
70
+ if (!e) return;
71
+ const r = () => {
72
+ const s = e.scrollTop > 8, a = e.scrollTop + e.clientHeight < e.scrollHeight - 8;
73
+ e.toggleAttribute("data-more-above", s), e.toggleAttribute("data-more-below", a), e.style.setProperty("--menu-edge-top", s ? V("top") : "none"), e.style.setProperty("--menu-edge-bottom", a ? V("bottom") : "none");
74
+ };
75
+ r(), e.addEventListener("scroll", r, { passive: !0 });
76
+ const n = typeof ResizeObserver > "u" ? null : new ResizeObserver(r);
77
+ return n?.observe(e), () => {
78
+ e.removeEventListener("scroll", r), n?.disconnect();
79
+ };
80
+ }, [e]);
81
+ }
82
+ function Z(e, r) {
83
+ const [n, s] = e.split("-"), a = r ? "right" : "left", t = r ? "left" : "right";
84
+ return n === "top" || n === "bottom" ? `${n === "bottom" ? "top" : "bottom"} ${s === "end" ? t : s === "start" ? a : "center"}` : `${s === "end" ? "bottom" : "top"} ${n === "right" ? "left" : "right"}`;
85
+ }
86
+ const ee = /* @__PURE__ */ E(
87
+ "rst:font-ui",
88
+ we,
89
+ /* Its own width wherever it lands: a fixed panel sized by the room to its
90
+ right resizes as it's placed, and the placement runs again. */
91
+ "rst:w-max rst:min-w-48 rst:max-w-[min(20rem,calc(100vw-1rem))] rst:overflow-y-auto rst:overscroll-contain rst:custom-scrollbar",
92
+ /* The scroll shadows' color: stronger on a dark panel, where a faint one vanishes. */
93
+ "rst:[--menu-edge:rgb(0_0_0/0.18)] rst:dark:[--menu-edge:rgb(0_0_0/0.6)]",
94
+ /* The entrance: a fade and a slight grow from the corner nearest the
95
+ button. Leaving is quicker. Neither moves under reduced motion. Opacity
96
+ and scale only: a transition on the position would fly the panel in
97
+ from the corner of the screen. */
98
+ "rst:transition-[opacity,scale] rst:duration-100 rst:ease-out rst:data-closed:opacity-0 rst:data-closed:scale-95 rst:data-leaving:duration-75 rst:data-leaving:ease-in rst:data-closed:pointer-events-none rst:motion-reduce:transition-none"
99
+ );
100
+ function te(e) {
101
+ const [r, n] = i.useState(e), [s, a] = i.useState(!0);
102
+ return i.useLayoutEffect(() => {
103
+ if (e) {
104
+ n(!0);
105
+ const o = requestAnimationFrame(() => a(!1));
106
+ return () => cancelAnimationFrame(o);
107
+ }
108
+ a(!0);
109
+ const t = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, d = window.setTimeout(() => n(!1), t ? 0 : Pe);
110
+ return () => window.clearTimeout(d);
111
+ }, [e]), { mounted: r, closed: s, leaving: r && !e };
112
+ }
113
+ function re(e, r, n, s, a, t = !1) {
114
+ const [d, o] = i.useState(null), u = ge({
115
+ open: r,
116
+ strategy: "fixed",
117
+ /* Placed by top and left, not a transform: the entrance's scale would
118
+ scale a transform's translation too, and slide the panel in. */
119
+ transform: !1,
120
+ placement: n,
121
+ elements: { reference: e },
122
+ whileElementsMounted: Ie,
123
+ middleware: [
124
+ he(s),
125
+ be({ padding: 8 }),
126
+ ye({ padding: 8, crossAxis: t }),
127
+ ve({
128
+ padding: 8,
129
+ apply({ availableHeight: m, elements: l }) {
130
+ l.floating.style.maxHeight = `min(var(--anchor-max-height, 100vh), ${Math.max(m, 96)}px)`;
131
+ }
132
+ })
133
+ ]
134
+ }), { setFloating: p } = u.refs, f = i.useCallback(
135
+ (m) => {
136
+ a.current = m, o(m), p(m);
137
+ },
138
+ [a, p]
139
+ );
140
+ return Re(d), { ...u, setPanel: f, panelEl: d };
141
+ }
142
+ const ne = 500;
143
+ function oe() {
144
+ const e = i.useRef({ text: "", at: 0 }), r = i.useCallback(() => e.current.text !== "" && performance.now() - e.current.at <= ne, []);
145
+ return { typedRef: e, typingAhead: r };
146
+ }
147
+ function se({
148
+ panelRef: e,
149
+ typedRef: r,
150
+ onEscape: n,
151
+ onBack: s
152
+ }) {
153
+ const a = C("MenuItems");
154
+ return (t) => {
155
+ const d = e.current;
156
+ if (!d || !d.contains(t.target) || (!t.ctrlKey && !t.metaKey && !t.altKey && t.stopPropagation(), t.defaultPrevented)) return;
157
+ const o = L(d), u = o.indexOf(document.activeElement), p = z(d);
158
+ switch (t.key) {
159
+ case "ArrowDown":
160
+ t.preventDefault(), t.stopPropagation(), S(o[(u + 1) % o.length]);
161
+ return;
162
+ case "ArrowUp":
163
+ t.preventDefault(), t.stopPropagation(), S(o[u <= 0 ? o.length - 1 : u - 1]);
164
+ return;
165
+ case "Home":
166
+ case "PageUp":
167
+ t.preventDefault(), t.stopPropagation(), S(o[0]);
168
+ return;
169
+ case "End":
170
+ case "PageDown":
171
+ t.preventDefault(), t.stopPropagation(), S(o[o.length - 1]);
172
+ return;
173
+ case "Escape":
174
+ t.preventDefault(), t.stopPropagation(), n();
175
+ return;
176
+ case "Tab": {
177
+ t.preventDefault(), t.stopPropagation();
178
+ const f = a.triggerRef.current;
179
+ a.close(!1), f && Te(f, t.shiftKey);
180
+ return;
181
+ }
182
+ case "ArrowLeft":
183
+ case "ArrowRight":
184
+ s && t.key === (p ? "ArrowRight" : "ArrowLeft") && (t.preventDefault(), t.stopPropagation(), s());
185
+ return;
186
+ }
187
+ if (t.key.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey) {
188
+ const f = performance.now(), m = r.current.text !== "" && f - r.current.at <= ne;
189
+ if (t.key === " " && !m) return;
190
+ t.preventDefault(), r.current = { text: m ? r.current.text + t.key : t.key, at: f };
191
+ const l = o.map((x) => x.dataset.menuText ?? x.textContent ?? ""), b = ke(l, u, r.current.text);
192
+ b !== -1 && S(o[b]);
193
+ }
194
+ };
195
+ }
196
+ function Ue({ children: e, open: r, onOpenChange: n, linkComponent: s = Ee }) {
197
+ const [a, t] = i.useState(!1), d = r ?? a, o = i.useId(), u = i.useRef(null), [p, f] = i.useState(null), m = i.useCallback((g) => {
198
+ u.current = g, f(g);
199
+ }, []), l = i.useRef("panel"), b = i.useCallback(
200
+ (g) => {
201
+ r === void 0 && t(g), n?.(g);
202
+ },
203
+ [r, n]
204
+ ), x = i.useMemo(
205
+ () => ({
206
+ treeId: o,
207
+ open: d,
208
+ openWith: (g) => {
209
+ l.current = g, b(!0);
210
+ },
211
+ close: (g) => {
212
+ b(!1), g && u.current?.focus();
213
+ },
214
+ triggerRef: u,
215
+ triggerEl: p,
216
+ registerTrigger: m,
217
+ triggerId: `${o}-button`,
218
+ panelId: `${o}-menu`,
219
+ focusOnOpen: l,
220
+ linkComponent: s
221
+ }),
222
+ [o, d, b, s, p, m]
223
+ );
224
+ return i.useEffect(() => {
225
+ if (!d) return;
226
+ Ce();
227
+ const g = (I) => {
228
+ I.target?.closest?.(`[data-menu-tree="${o}"]`) || (b(!1), requestAnimationFrame(() => {
229
+ (document.activeElement === document.body || !document.activeElement) && u.current?.focus({ preventScroll: !0 });
230
+ }));
231
+ };
232
+ return document.addEventListener("pointerdown", g, !0), () => document.removeEventListener("pointerdown", g, !0);
233
+ }, [d, o, b]), /* @__PURE__ */ c(G.Provider, { value: x, children: e });
234
+ }
235
+ const Ve = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKeyDown: a, children: t, ...d }, o) {
236
+ const { variant: u, colorScheme: p, size: f, isLoading: m, loadingLabel: l, startIcon: b, endIcon: x, surface: g, ...I } = d, h = C("MenuButton"), { registerTrigger: P } = h, M = i.useCallback(
237
+ (y) => {
238
+ P(y), typeof o == "function" ? o(y) : o && (o.current = y);
239
+ },
240
+ [P, o]
241
+ ), T = {
242
+ id: h.triggerId,
243
+ "aria-haspopup": "menu",
244
+ "aria-expanded": h.open,
245
+ "aria-controls": h.open ? h.panelId : void 0,
246
+ "data-menu-tree": h.treeId,
247
+ onClick: (y) => {
248
+ s?.(y), !y.defaultPrevented && (h.open ? h.close(!1) : h.openWith("panel"));
249
+ },
250
+ onKeyDown: (y) => {
251
+ if (a?.(y), y.defaultPrevented) return;
252
+ const v = y.key === "Enter" || y.key === " " || y.key === "ArrowDown" ? "first" : y.key === "ArrowUp" ? "last" : null;
253
+ if (!v) return;
254
+ y.preventDefault();
255
+ const k = h.open ? document.getElementById(h.panelId) : null;
256
+ if (k) {
257
+ const R = L(k);
258
+ S(v === "last" ? R[R.length - 1] : R[0]);
259
+ return;
260
+ }
261
+ h.openWith(v);
262
+ }
263
+ };
264
+ return r ? /* @__PURE__ */ c("button", { ref: M, type: "button", className: n, ...I, ...T, children: t }) : (
265
+ /* min 44 by 44 whatever the size: the target a finger needs. */
266
+ /* @__PURE__ */ c(
267
+ xe,
268
+ {
269
+ ref: M,
270
+ className: E("rst:min-h-11 rst:min-w-11", n),
271
+ variant: u,
272
+ colorScheme: p,
273
+ size: f,
274
+ isLoading: m,
275
+ loadingLabel: l,
276
+ startIcon: b,
277
+ endIcon: x,
278
+ surface: g,
279
+ ...I,
280
+ ...T,
281
+ children: t
282
+ }
283
+ )
284
+ );
285
+ });
286
+ function je({ children: e, align: r = "start", offset: n = 4, className: s, ...a }) {
287
+ const t = C("MenuItems"), { mounted: d, closed: o, leaving: u } = te(t.open), p = i.useRef(null), f = z(t.triggerEl), { setPanel: m, panelEl: l, floatingStyles: b, placement: x, isPositioned: g } = re(t.triggerEl, d, `bottom-${r}`, n, p), I = ae(), { typedRef: h, typingAhead: P } = oe(), M = se({ panelRef: p, typedRef: h, onEscape: () => t.close(!0) });
288
+ i.useLayoutEffect(() => {
289
+ if (!t.open || !l) return;
290
+ const v = L(l), k = t.focusOnOpen.current;
291
+ k === "first" && v[0] ? S(v[0]) : k === "last" && v.length ? S(v[v.length - 1]) : l.focus({ preventScroll: !0 });
292
+ }, [t.open, l, t.focusOnOpen]), i.useLayoutEffect(() => {
293
+ if (!g || !l) return;
294
+ const v = document.activeElement;
295
+ v && v !== l && l.contains(v) && v.scrollIntoView?.({ block: "nearest" });
296
+ }, [g, l]), i.useLayoutEffect(() => {
297
+ !t.open && l?.contains(document.activeElement) && t.triggerRef.current?.focus({ preventScroll: !0 });
298
+ }, [t.open, l, t.triggerRef]);
299
+ const T = (v) => {
300
+ const k = v.relatedTarget;
301
+ k && !k.closest(`[data-menu-tree="${t.treeId}"]`) && t.close(!1);
302
+ };
303
+ if (!d) return null;
304
+ const y = !!t.triggerEl?.closest(".dark");
305
+ return /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(B.Provider, { value: { ...I, panelRef: p, typingAhead: P }, children: /* @__PURE__ */ c(
306
+ "div",
307
+ {
308
+ ref: m,
309
+ id: t.panelId,
310
+ dir: f ? "rtl" : "ltr",
311
+ role: "menu",
312
+ "aria-labelledby": a["aria-label"] ? void 0 : t.triggerId,
313
+ "aria-label": a["aria-label"],
314
+ tabIndex: -1,
315
+ "data-menu-panel": "",
316
+ "data-menu-tree": t.treeId,
317
+ "data-closed": o ? "" : void 0,
318
+ "data-leaving": u ? "" : void 0,
319
+ onKeyDown: M,
320
+ onBlur: T,
321
+ style: { ...b, ...Q, transformOrigin: Z(x, f) },
322
+ className: E(y && "dark", ee, s),
323
+ children: e
324
+ }
325
+ ) }) });
326
+ }
327
+ function ae() {
328
+ const [e, r] = i.useState(null), n = i.useRef(!1), s = i.useRef(void 0);
329
+ return i.useEffect(() => () => window.clearTimeout(s.current), []), {
330
+ openSubmenu: e,
331
+ focusFirstInSubmenu: n,
332
+ setOpenSubmenu: (a, t = !1) => {
333
+ window.clearTimeout(s.current), n.current = t, r(a);
334
+ },
335
+ hoverItem: (a) => {
336
+ window.clearTimeout(s.current), a === null && (s.current = window.setTimeout(() => r(null), X));
337
+ }
338
+ };
339
+ }
340
+ const O = /* @__PURE__ */ E(
341
+ /* A button or a link reset to a row: no border, no fill, the panel's type. */
342
+ "rst:relative rst:flex rst:w-full rst:min-h-11 rst:items-center rst:gap-2.5 rst:border-0 rst:bg-transparent rst:px-3 rst:py-2 rst:text-start rst:text-sm rst:text-inherit rst:no-underline rst:[font-family:inherit] rst:cursor-pointer rst:select-none rst:outline-none rst:transition-colors",
343
+ /* Focus follows the pointer, so the highlight is focus. In forced colors a
344
+ fill is dropped, so focus draws an outline there instead. */
345
+ "rst:focus:bg-primary-100 rst:focus:text-primary-900 rst:dark:focus:bg-primary-900/30 rst:dark:focus:text-primary-100 rst:forced-colors:focus:outline-solid rst:forced-colors:focus:outline-2 rst:forced-colors:focus:-outline-offset-2",
346
+ "rst:aria-disabled:opacity-50 rst:aria-disabled:cursor-not-allowed"
347
+ ), H = "rst:text-error-600 rst:dark:text-error-400 rst:focus:bg-error-50 rst:focus:text-error-700 rst:dark:focus:bg-error-900/30 rst:dark:focus:text-error-300", De = () => /* @__PURE__ */ c("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ c("path", { d: "M3.5 8.5 6.5 11.5 12.5 4.5" }) }), Le = () => /* @__PURE__ */ c("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", children: /* @__PURE__ */ c("circle", { cx: "8", cy: "8", r: "3.5", fill: "currentColor" }) }), Ne = () => /* @__PURE__ */ c("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", className: "rst:rtl:rotate-180", children: /* @__PURE__ */ c("path", { d: "M6 3.5 10.5 8 6 12.5" }) });
348
+ function A({ icon: e, shortcut: r, description: n, badge: s, children: a }, t, d, o) {
349
+ const u = t ?? e;
350
+ return /* @__PURE__ */ N(j, { children: [
351
+ u != null && /* With a description, the icon lines up with the label, not the middle of both lines. */
352
+ /* @__PURE__ */ c("span", { "aria-hidden": "true", className: E("rst:flex rst:size-4 rst:shrink-0 rst:items-center rst:justify-center", n != null && "rst:self-start rst:mt-0.5"), "data-menu-lead": "", children: u }),
353
+ /* @__PURE__ */ N("span", { className: "rst:min-w-0 rst:flex-1 rst:break-words", "data-menu-label": "", children: [
354
+ a,
355
+ n != null && /* @__PURE__ */ c("span", { id: o, "aria-hidden": "true", className: "rst:block rst:text-xs rst:opacity-75", "data-menu-description": "", children: n })
356
+ ] }),
357
+ s != null && /* @__PURE__ */ c("span", { className: "rst:flex rst:shrink-0 rst:items-center", "data-menu-badge": "", children: s }),
358
+ r && /* @__PURE__ */ c("span", { "aria-hidden": "true", className: "rst:ms-auto rst:shrink-0 rst:ps-4 rst:text-xs rst:tracking-wide rst:opacity-70", "data-menu-shortcut": "", children: r }),
359
+ d
360
+ ] });
361
+ }
362
+ function F({
363
+ disabled: e,
364
+ closeOnSelect: r,
365
+ onChoose: n,
366
+ spaceKeepsOpen: s
367
+ }) {
368
+ const a = C("MenuItem"), t = _("MenuItem"), d = (o, u) => {
369
+ if (e) {
370
+ o.preventDefault();
371
+ return;
372
+ }
373
+ n(o), u && a.close(!0);
374
+ };
375
+ return {
376
+ onClick: (o) => d(o, r),
377
+ onKeyDown: (o) => {
378
+ if (o.key === " ") {
379
+ if (t.typingAhead()) return;
380
+ o.preventDefault(), d(o, r && !s);
381
+ }
382
+ },
383
+ onPointerMove: (o) => {
384
+ J(o) && (t.hoverItem(null), document.activeElement !== o.currentTarget && o.currentTarget.focus({ preventScroll: !0 }));
385
+ }
386
+ };
387
+ }
388
+ function qe({ onSelect: e, href: r, closeOnSelect: n = !0, disabled: s, destructive: a, keyshortcuts: t, textValue: d, className: o, ...u }) {
389
+ const p = C("MenuItem"), f = _("MenuItem"), m = i.useId(), l = F({ disabled: s, closeOnSelect: n, onChoose: (g) => e?.(g) }), b = E(O, a && H, o), x = {
390
+ role: "menuitem",
391
+ tabIndex: -1,
392
+ "aria-disabled": s ? !0 : void 0,
393
+ "aria-keyshortcuts": t,
394
+ "aria-describedby": u.description != null ? m : void 0,
395
+ "data-menu-item": "",
396
+ "data-menu-text": d,
397
+ "data-destructive": a ? "" : void 0
398
+ };
399
+ if (r !== void 0) {
400
+ const g = p.linkComponent;
401
+ return /* @__PURE__ */ c(
402
+ g,
403
+ {
404
+ href: r,
405
+ to: r,
406
+ className: b,
407
+ ...x,
408
+ onClick: l.onClick,
409
+ onPointerMove: l.onPointerMove,
410
+ onKeyDown: (I) => {
411
+ if (I.key === " ") {
412
+ if (f.typingAhead()) return;
413
+ I.preventDefault(), s || I.currentTarget.click();
414
+ }
415
+ },
416
+ children: A(u, void 0, void 0, m)
417
+ }
418
+ );
419
+ }
420
+ return /* @__PURE__ */ c("button", { type: "button", className: b, ...x, ...l, children: A(u, void 0, void 0, m) });
421
+ }
422
+ function Ge({ checked: e, onCheckedChange: r, indicator: n, closeOnSelect: s = !0, disabled: a, destructive: t, keyshortcuts: d, textValue: o, className: u, ...p }) {
423
+ const f = F({ disabled: a, closeOnSelect: s, spaceKeepsOpen: !0, onChoose: () => r(!e) }), m = i.useId();
424
+ return /* @__PURE__ */ c(
425
+ "button",
426
+ {
427
+ type: "button",
428
+ role: "menuitemcheckbox",
429
+ "aria-checked": e,
430
+ "aria-describedby": p.description != null ? m : void 0,
431
+ tabIndex: -1,
432
+ "aria-disabled": a || void 0,
433
+ "aria-keyshortcuts": d,
434
+ "data-menu-item": "",
435
+ "data-menu-text": o,
436
+ className: E(O, t && H, u),
437
+ ...f,
438
+ children: n === void 0 ? A(p, /* @__PURE__ */ c("span", { className: e ? void 0 : "rst:invisible", "data-menu-check": "", children: /* @__PURE__ */ c(De, {}) }), void 0, m) : A(p, void 0, /* @__PURE__ */ c("span", { "aria-hidden": "true", className: "rst:ms-auto rst:flex rst:shrink-0 rst:items-center", children: n }), m)
439
+ }
440
+ );
441
+ }
442
+ function Ye({ value: e, onValueChange: r, label: n, children: s, className: a }) {
443
+ return /* @__PURE__ */ c(Y.Provider, { value: { value: e, onValueChange: r }, children: /* @__PURE__ */ c(Oe, { label: n, className: a, children: s }) });
444
+ }
445
+ function Xe({ value: e, closeOnSelect: r = !0, disabled: n, destructive: s, keyshortcuts: a, textValue: t, className: d, ...o }) {
446
+ const u = i.useContext(Y);
447
+ if (!u) throw new Error("<MenuRadioItem> must be inside a <MenuRadioGroup>.");
448
+ const p = u.value === e, f = F({ disabled: n, closeOnSelect: r, spaceKeepsOpen: !0, onChoose: () => u.onValueChange?.(e) }), m = i.useId();
449
+ return /* @__PURE__ */ c(
450
+ "button",
451
+ {
452
+ type: "button",
453
+ role: "menuitemradio",
454
+ "aria-checked": p,
455
+ "aria-describedby": o.description != null ? m : void 0,
456
+ tabIndex: -1,
457
+ "aria-disabled": n || void 0,
458
+ "aria-keyshortcuts": a,
459
+ "data-menu-item": "",
460
+ "data-menu-text": t,
461
+ className: E(O, s && H, d),
462
+ ...f,
463
+ children: A(o, /* @__PURE__ */ c("span", { className: p ? void 0 : "rst:invisible", "data-menu-check": "", children: /* @__PURE__ */ c(Le, {}) }), void 0, m)
464
+ }
465
+ );
466
+ }
467
+ function Oe({ label: e, children: r, className: n }) {
468
+ const s = i.useId();
469
+ return /* @__PURE__ */ N("div", { role: "group", "aria-labelledby": e ? s : void 0, className: n, children: [
470
+ e && /* @__PURE__ */ c(
471
+ "div",
472
+ {
473
+ id: s,
474
+ className: "rst:px-3 rst:pt-2 rst:pb-1 rst:text-xs rst:font-semibold rst:text-gray-600 rst:dark:text-gray-400",
475
+ "data-menu-heading": "",
476
+ children: e
477
+ }
478
+ ),
479
+ r
480
+ ] });
481
+ }
482
+ function Je({ className: e }) {
483
+ return /* @__PURE__ */ c("div", { role: "separator", className: E("rst:my-1 rst:h-[var(--roster-border-width,1px)] rst:bg-[var(--roster-popover-border)]", e) });
484
+ }
485
+ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, className: t, panelClassName: d }) {
486
+ const o = C("MenuSubmenu"), u = _("MenuSubmenu"), p = i.useId(), f = `${p}-item`, m = `${p}-menu`, l = u.openSubmenu === f, b = i.useRef(null), [x, g] = i.useState(null), I = i.useCallback((w) => {
487
+ b.current = w, g(w);
488
+ }, []), h = i.useRef(null), P = i.useRef(void 0), M = i.useRef("mouse"), { mounted: T, closed: y, leaving: v } = te(l), k = z(x), { setPanel: R, panelEl: K, floatingStyles: ie, placement: ue } = re(
489
+ x,
490
+ T,
491
+ k ? "left-start" : "right-start",
492
+ { mainAxis: 0, alignmentAxis: -4 },
493
+ h,
494
+ !0
495
+ ), ce = ae();
496
+ i.useEffect(() => () => window.clearTimeout(P.current), []);
497
+ const W = () => {
498
+ u.setOpenSubmenu(null), b.current?.focus({ preventScroll: !0 });
499
+ }, { typedRef: le, typingAhead: de } = oe(), me = se({ panelRef: h, typedRef: le, onEscape: W, onBack: W });
500
+ i.useLayoutEffect(() => {
501
+ !l || !K || u.focusFirstInSubmenu.current && S(L(K)[0]);
502
+ }, [l, K, u.focusFirstInSubmenu]);
503
+ const $ = (w) => {
504
+ if (!s) {
505
+ if (l && w && h.current) {
506
+ S(L(h.current)[0]);
507
+ return;
508
+ }
509
+ u.setOpenSubmenu(f, w);
510
+ }
511
+ }, fe = !!o.triggerEl?.closest(".dark");
512
+ return /* @__PURE__ */ N(j, { children: [
513
+ /* @__PURE__ */ c(
514
+ "button",
515
+ {
516
+ ref: I,
517
+ id: f,
518
+ type: "button",
519
+ role: "menuitem",
520
+ tabIndex: -1,
521
+ "aria-haspopup": "menu",
522
+ "aria-expanded": l,
523
+ "aria-controls": l ? m : void 0,
524
+ "aria-disabled": s || void 0,
525
+ "data-menu-item": "",
526
+ "data-menu-text": a,
527
+ "data-menu-tree": o.treeId,
528
+ className: E(O, l && "rst:bg-gray-100 rst:dark:bg-gray-700/50", t),
529
+ onPointerDown: (w) => {
530
+ M.current = w.pointerType;
531
+ },
532
+ onClick: () => l && M.current !== "mouse" ? u.setOpenSubmenu(null) : $(!1),
533
+ onKeyDown: (w) => {
534
+ const pe = k ? "ArrowLeft" : "ArrowRight";
535
+ w.key === " " && u.typingAhead() || (w.key === pe || w.key === "Enter" || w.key === " ") && (w.preventDefault(), $(!0));
536
+ },
537
+ onPointerMove: (w) => {
538
+ J(w) && (u.hoverItem(f), document.activeElement !== w.currentTarget && w.currentTarget.focus({ preventScroll: !0 }), !l && !s && (window.clearTimeout(P.current), P.current = window.setTimeout(() => $(!1), X)));
539
+ },
540
+ onPointerLeave: () => window.clearTimeout(P.current),
541
+ children: A({ icon: n, children: e }, void 0, /* @__PURE__ */ c("span", { "aria-hidden": "true", className: "rst:ms-auto rst:flex rst:shrink-0 rst:items-center rst:opacity-70", "data-menu-chevron": "", children: /* @__PURE__ */ c(Ne, {}) }))
542
+ }
543
+ ),
544
+ T && /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(B.Provider, { value: { ...ce, panelRef: h, typingAhead: de }, children: /* @__PURE__ */ c(
545
+ "div",
546
+ {
547
+ ref: R,
548
+ id: m,
549
+ dir: k ? "rtl" : "ltr",
550
+ role: "menu",
551
+ "aria-labelledby": f,
552
+ tabIndex: -1,
553
+ "data-menu-panel": "",
554
+ "data-menu-tree": o.treeId,
555
+ "data-closed": y ? "" : void 0,
556
+ "data-leaving": v ? "" : void 0,
557
+ onKeyDown: me,
558
+ onPointerEnter: () => u.hoverItem(f),
559
+ style: { ...ie, ...Q, transformOrigin: Z(ue, k) },
560
+ className: E(fe && "dark", ee, d),
561
+ children: r
562
+ }
563
+ ) }) })
564
+ ] });
565
+ }
566
+ export {
567
+ Ue as Menu,
568
+ Ve as MenuButton,
569
+ Ge as MenuCheckboxItem,
570
+ Oe as MenuGroup,
571
+ qe as MenuItem,
572
+ je as MenuItems,
573
+ Ye as MenuRadioGroup,
574
+ Xe as MenuRadioItem,
575
+ Je as MenuSeparator,
576
+ Qe as MenuSubmenu
577
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function h(r,n,s){const e=s.toLocaleLowerCase();if(!e||r.length===0)return-1;const o=[...e].every(t=>t===e[0]),c=o?e[0]:e,i=o?n+1:n;for(let t=0;t<r.length;t++){const a=(Math.max(i,0)+t)%r.length;if(r[a].trim().toLocaleLowerCase().startsWith(c))return a}return-1}exports.nextByTypeahead=h;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The item typeahead lands on: the next one, after `current`, whose label
3
+ * starts with what's been typed, wrapping round to the start. Typing the same
4
+ * letter again cycles through the items starting with it. `-1` when nothing
5
+ * matches, so focus stays put.
6
+ */
7
+ export declare function nextByTypeahead(labels: string[], current: number, typed: string): number;
@@ -0,0 +1,13 @@
1
+ function i(r, n, s) {
2
+ const t = s.toLocaleLowerCase();
3
+ if (!t || r.length === 0) return -1;
4
+ const o = [...t].every((e) => e === t[0]), c = o ? t[0] : t, h = o ? n + 1 : n;
5
+ for (let e = 0; e < r.length; e++) {
6
+ const a = (Math.max(h, 0) + e) % r.length;
7
+ if (r[a].trim().toLocaleLowerCase().startsWith(c)) return a;
8
+ }
9
+ return -1;
10
+ }
11
+ export {
12
+ i as nextByTypeahead
13
+ };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("react"),v=require("../../../lib/utils.cjs"),ee=require("../../atoms/Button/Button.cjs"),te=require("../../atoms/Button/button-variants.cjs"),se=require("../../atoms/Select/select-variants.cjs"),Q=require("./page-items.cjs"),re={nav:"Pagination",page:t=>`Page ${t}`,number:t=>String(t),previous:"Previous",next:"Next",previousPage:t=>t===null?"Previous page":`Previous page (${t})`,nextPage:t=>t===null?"Next page":`Next page (${t})`,firstPage:t=>t===null?"First page":`First page (${t})`,lastPage:t=>t===null?"Last page":`Last page (${t})`,gap:"…",picker:"Page",of:t=>`of ${t}`,status:(t,i)=>`Page ${t} of ${i}`};function ae({href:t,className:i,children:c,onClick:o,...d}){return e.jsx("a",{href:t,className:i,onClick:o,"aria-label":d["aria-label"],"aria-current":d["aria-current"],"aria-disabled":d["aria-disabled"],children:c})}const ne="rst:h-11 rst:min-w-11 rst:px-2",ie="rst:cursor-not-allowed rst:opacity-50",le="rst:forced-colors:border-2 rst:forced-colors:underline rst:forced-colors:decoration-2 rst:forced-colors:underline-offset-4",X={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},F=({dir:t,double:i=!1})=>e.jsx("svg",{...X,className:"rst:shrink-0",children:t==="left"?i?e.jsx("path",{d:"m11 17-5-5 5-5M18 17l-5-5 5-5"}):e.jsx("path",{d:"m15 18-6-6 6-6"}):i?e.jsx("path",{d:"m13 17 5-5-5-5M6 17l5-5-5-5"}):e.jsx("path",{d:"m9 18 6-6-6-6"})});function oe({id:t,describedBy:i,page:c,pageCount:o,number:d,onCommit:k}){const[u,j]=w.useState(null),p=w.useRef(!1),x=u&&u.page===c?u.value:null,b=l=>{j(null),l!==c&&k(l)},P=w.useMemo(()=>Array.from({length:o},(l,f)=>e.jsx("option",{value:f+1,children:d(f+1)},f+1)),[o,d]);return e.jsx("select",{id:t,value:x??c,"aria-describedby":i,disabled:o<1,onKeyDown:l=>{if(l.key==="Enter"){x!==null&&(l.preventDefault(),b(x));return}if(l.key==="Escape"){j(null);return}p.current=!0,setTimeout(()=>{p.current=!1},0)},onChange:l=>{const f=Number(l.currentTarget.value);p.current?j({page:c,value:f}):b(f)},onBlur:()=>{x!==null&&b(x)},className:v.cn(se.selectTriggerVariants({variant:"outline"}),"rst:h-11 rst:w-auto rst:min-w-16 rst:appearance-none rst:pl-3 rst:pr-8 rst:text-base rst:tabular-nums"),"data-pagination-picker":"",children:P})}function ce({page:t,pageCount:i,onPageChange:c,getPageHref:o,linkComponent:d,navigate:k,layout:u="auto",siblings:j=1,edges:p=!0,align:x="center",variant:b="ghost",announce:P=!0,labels:l,className:f}){const a={...re,...l},m=Number.isFinite(i)?Math.max(0,Math.floor(i)):0,n=Q.clampPage(t,m),C=w.useId(),Y=d??ae,[E,Z]=w.useState({page:n,text:""});E.page!==n&&Z({page:n,text:P?a.status(n,m):""});const L=s=>{s!==Math.floor(t)&&c?.(s)},y=(s,r,N,A)=>{const h=s==="page"&&r===n,$=r===null,U=v.cn(ne,$&&ie,h&&le,A.className),W=s==="page"?`page-${r}`:s;if(o){const J=o(r??n);return e.jsx(Y,{href:J,to:J,className:v.cn(te.buttonVariants({variant:h?"solid":b,colorScheme:h?"primary":"neutral"}),U),"aria-label":A.label,"aria-current":h?"page":void 0,"aria-disabled":$?!0:void 0,onClick:g=>{if($){g.preventDefault();return}!g.defaultPrevented&&g.button===0&&!g.metaKey&&!g.ctrlKey&&!g.shiftKey&&!g.altKey&&r!==null&&L(r)},children:N},W)}return e.jsx(ee.Button,{type:"button",variant:h?"solid":b,colorScheme:h?"primary":"neutral",className:U,"aria-label":A.label,"aria-current":h?"page":void 0,"aria-disabled":$||void 0,onClick:()=>{r!==null&&L(r)},children:N},W)},I=n>1?n-1:null,R=n<m?n+1:null,T=n>1?1:null,B=n<m?m:null,M=s=>y("previous",I,e.jsxs(e.Fragment,{children:[e.jsx(F,{dir:"left"}),s&&e.jsx("span",{className:"rst:hidden rst:pr-1 rst:@[36rem]:inline",children:a.previous})]}),{label:a.previousPage(I)}),S=s=>y("next",R,e.jsxs(e.Fragment,{children:[s&&e.jsx("span",{className:"rst:hidden rst:pl-1 rst:@[36rem]:inline",children:a.next}),e.jsx(F,{dir:"right"})]}),{label:a.nextPage(R)}),K=s=>y("first",T,e.jsx(F,{dir:"left",double:!0}),{label:a.firstPage(T),className:s?"rst:hidden rst:@[24rem]:inline-flex":void 0}),V=s=>y("last",B,e.jsx(F,{dir:"right",double:!0}),{label:a.lastPage(B),className:s?"rst:hidden rst:@[24rem]:inline-flex":void 0}),D="rst:flex rst:flex-wrap rst:items-center rst:gap-1",q={start:"rst:justify-start",center:"rst:justify-center",end:"rst:justify-end"}[x],O=s=>e.jsxs("div",{className:v.cn(D,q,s),"data-pagination-layout":"pages",children:[M(!0),Q.pageItems(n,m,j).map(r=>typeof r=="number"?y("page",r,a.number(r),{label:a.page(r)}):e.jsx("span",{"aria-hidden":"true",className:"rst:inline-flex rst:h-11 rst:w-11 rst:items-center rst:justify-center rst:text-sm rst:text-gray-500 rst:dark:text-gray-400",children:a.gap},r)),S(!0)]}),_=`${C}-picker`,z=`${C}-of`,G=s=>e.jsxs("div",{className:v.cn(D,q,s),"data-pagination-layout":"compact",children:[p&&K(!0),M(!1),e.jsxs("div",{className:"rst:flex rst:items-center rst:gap-2 rst:px-1 rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]",children:[e.jsx("label",{htmlFor:_,children:a.picker}),e.jsxs("span",{className:"rst:relative rst:inline-flex",children:[e.jsx(oe,{id:_,describedBy:z,page:n,pageCount:m,number:a.number,onCommit:r=>{if(o){c?.(r);const N=o(r);k?k(N):window.location.assign(N)}else L(r)}}),e.jsx("svg",{...X,width:16,height:16,className:"rst:pointer-events-none rst:absolute rst:right-2.5 rst:top-1/2 rst:-translate-y-1/2 rst:text-gray-500 rst:dark:text-gray-400",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),e.jsx("span",{id:z,className:"rst:tabular-nums",children:a.of(m)})]}),S(!1),p&&V(!0)]}),H=e.jsxs("div",{className:v.cn(D,q),"data-pagination-layout":"arrows",children:[p&&K(!1),M(!1),S(!1),p&&V(!1)]});return e.jsxs("nav",{"aria-label":a.nav,className:v.cn("rst:font-ui",u==="arrows"?"rst:w-fit":"rst:@container rst:w-full rst:[contain-intrinsic-inline-size:18rem]",f),"data-pagination":"",children:[u==="pages"&&O(),u==="compact"&&G(),u==="arrows"&&H,u==="auto"&&e.jsxs(e.Fragment,{children:[O("rst:hidden rst:@[28rem]:flex"),G("rst:@[28rem]:hidden")]}),P&&e.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"rst:sr-only","data-pagination-live":"",children:E.text})]})}exports.Pagination=ce;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("react"),b=require("../../../lib/utils.cjs"),ee=require("../../../lib/labels.cjs"),te=require("../../atoms/Button/Button.cjs"),se=require("../../atoms/Button/button-variants.cjs"),re=require("../../atoms/Select/select-variants.cjs"),Q=require("./page-items.cjs"),ae={nav:"Pagination",page:t=>`Page ${t}`,number:t=>String(t),previous:"Previous",next:"Next",previousPage:t=>t===null?"Previous page":`Previous page (${t})`,nextPage:t=>t===null?"Next page":`Next page (${t})`,firstPage:t=>t===null?"First page":`First page (${t})`,lastPage:t=>t===null?"Last page":`Last page (${t})`,gap:"…",picker:"Page",of:t=>`of ${t}`,status:(t,i)=>`Page ${t} of ${i}`};function ne({href:t,className:i,children:c,onClick:o,...d}){return e.jsx("a",{href:t,className:i,onClick:o,"aria-label":d["aria-label"],"aria-current":d["aria-current"],"aria-disabled":d["aria-disabled"],children:c})}const ie="rst:h-11 rst:min-w-11 rst:px-2",le="rst:cursor-not-allowed rst:opacity-50",oe="rst:forced-colors:border-2 rst:forced-colors:underline rst:forced-colors:decoration-2 rst:forced-colors:underline-offset-4",X={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},L=({dir:t,double:i=!1})=>e.jsx("svg",{...X,className:"rst:shrink-0",children:t==="left"?i?e.jsx("path",{d:"m11 17-5-5 5-5M18 17l-5-5 5-5"}):e.jsx("path",{d:"m15 18-6-6 6-6"}):i?e.jsx("path",{d:"m13 17 5-5-5-5M6 17l5-5-5-5"}):e.jsx("path",{d:"m9 18 6-6-6-6"})});function ce({id:t,describedBy:i,page:c,pageCount:o,number:d,onCommit:k}){const[u,j]=w.useState(null),p=w.useRef(!1),x=u&&u.page===c?u.value:null,v=l=>{j(null),l!==c&&k(l)},P=w.useMemo(()=>Array.from({length:o},(l,f)=>e.jsx("option",{value:f+1,children:d(f+1)},f+1)),[o,d]);return e.jsx("select",{id:t,value:x??c,"aria-describedby":i,disabled:o<1,onKeyDown:l=>{if(l.key==="Enter"){x!==null&&(l.preventDefault(),v(x));return}if(l.key==="Escape"){j(null);return}p.current=!0,setTimeout(()=>{p.current=!1},0)},onChange:l=>{const f=Number(l.currentTarget.value);p.current?j({page:c,value:f}):v(f)},onBlur:()=>{x!==null&&v(x)},className:b.cn(re.selectTriggerVariants({variant:"outline"}),"rst:h-11 rst:w-auto rst:min-w-16 rst:appearance-none rst:pl-3 rst:pr-8 rst:text-base rst:tabular-nums"),"data-pagination-picker":"",children:P})}function ue({page:t,pageCount:i,onPageChange:c,getPageHref:o,linkComponent:d,navigate:k,layout:u="auto",siblings:j=1,edges:p=!0,align:x="center",variant:v="ghost",announce:P=!0,labels:l,className:f}){const a=ee.withLabels(ae,l),m=Number.isFinite(i)?Math.max(0,Math.floor(i)):0,n=Q.clampPage(t,m),C=w.useId(),Y=d??ne,[E,Z]=w.useState({page:n,text:""});E.page!==n&&Z({page:n,text:P?a.status(n,m):""});const F=s=>{s!==Math.floor(t)&&c?.(s)},y=(s,r,N,A)=>{const h=s==="page"&&r===n,$=r===null,U=b.cn(ie,$&&le,h&&oe,A.className),W=s==="page"?`page-${r}`:s;if(o){const J=o(r??n);return e.jsx(Y,{href:J,to:J,className:b.cn(se.buttonVariants({variant:h?"solid":v,colorScheme:h?"primary":"neutral"}),U),"aria-label":A.label,"aria-current":h?"page":void 0,"aria-disabled":$?!0:void 0,onClick:g=>{if($){g.preventDefault();return}!g.defaultPrevented&&g.button===0&&!g.metaKey&&!g.ctrlKey&&!g.shiftKey&&!g.altKey&&r!==null&&F(r)},children:N},W)}return e.jsx(te.Button,{type:"button",variant:h?"solid":v,colorScheme:h?"primary":"neutral",className:U,"aria-label":A.label,"aria-current":h?"page":void 0,"aria-disabled":$||void 0,onClick:()=>{r!==null&&F(r)},children:N},W)},I=n>1?n-1:null,R=n<m?n+1:null,T=n>1?1:null,B=n<m?m:null,M=s=>y("previous",I,e.jsxs(e.Fragment,{children:[e.jsx(L,{dir:"left"}),s&&e.jsx("span",{className:"rst:hidden rst:pr-1 rst:@[36rem]:inline",children:a.previous})]}),{label:a.previousPage(I)}),S=s=>y("next",R,e.jsxs(e.Fragment,{children:[s&&e.jsx("span",{className:"rst:hidden rst:pl-1 rst:@[36rem]:inline",children:a.next}),e.jsx(L,{dir:"right"})]}),{label:a.nextPage(R)}),K=s=>y("first",T,e.jsx(L,{dir:"left",double:!0}),{label:a.firstPage(T),className:s?"rst:hidden rst:@[24rem]:inline-flex":void 0}),V=s=>y("last",B,e.jsx(L,{dir:"right",double:!0}),{label:a.lastPage(B),className:s?"rst:hidden rst:@[24rem]:inline-flex":void 0}),q="rst:flex rst:flex-wrap rst:items-center rst:gap-1",D={start:"rst:justify-start",center:"rst:justify-center",end:"rst:justify-end"}[x],O=s=>e.jsxs("div",{className:b.cn(q,D,s),"data-pagination-layout":"pages",children:[M(!0),Q.pageItems(n,m,j).map(r=>typeof r=="number"?y("page",r,a.number(r),{label:a.page(r)}):e.jsx("span",{"aria-hidden":"true",className:"rst:inline-flex rst:h-11 rst:w-11 rst:items-center rst:justify-center rst:text-sm rst:text-gray-500 rst:dark:text-gray-400",children:a.gap},r)),S(!0)]}),_=`${C}-picker`,z=`${C}-of`,G=s=>e.jsxs("div",{className:b.cn(q,D,s),"data-pagination-layout":"compact",children:[p&&K(!0),M(!1),e.jsxs("div",{className:"rst:flex rst:items-center rst:gap-2 rst:px-1 rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]",children:[e.jsx("label",{htmlFor:_,children:a.picker}),e.jsxs("span",{className:"rst:relative rst:inline-flex",children:[e.jsx(ce,{id:_,describedBy:z,page:n,pageCount:m,number:a.number,onCommit:r=>{if(o){c?.(r);const N=o(r);k?k(N):window.location.assign(N)}else F(r)}}),e.jsx("svg",{...X,width:16,height:16,className:"rst:pointer-events-none rst:absolute rst:right-2.5 rst:top-1/2 rst:-translate-y-1/2 rst:text-gray-500 rst:dark:text-gray-400",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),e.jsx("span",{id:z,className:"rst:tabular-nums",children:a.of(m)})]}),S(!1),p&&V(!0)]}),H=e.jsxs("div",{className:b.cn(q,D),"data-pagination-layout":"arrows",children:[p&&K(!1),M(!1),S(!1),p&&V(!1)]});return e.jsxs("nav",{"aria-label":a.nav,className:b.cn("rst:font-ui",u==="arrows"?"rst:w-fit":"rst:@container rst:w-full rst:[contain-intrinsic-inline-size:18rem]",f),"data-pagination":"",children:[u==="pages"&&O(),u==="compact"&&G(),u==="arrows"&&H,u==="auto"&&e.jsxs(e.Fragment,{children:[O("rst:hidden rst:@[28rem]:flex"),G("rst:@[28rem]:hidden")]}),P&&e.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"rst:sr-only","data-pagination-live":"",children:E.text})]})}exports.Pagination=ue;
@@ -96,6 +96,7 @@ export interface PaginationProps {
96
96
  variant?: "ghost" | "outline";
97
97
  /** Say the new page in a polite live region when it changes. */
98
98
  announce?: boolean;
99
+ /** The component's own words, replaced; any left out stay English. */
99
100
  labels?: Partial<PaginationLabels>;
100
101
  className?: string;
101
102
  }