@blakesteve/roster 5.10.0 → 5.12.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 +202 -11
- package/dist/components/atoms/Chip/chip-variants.cjs +1 -1
- package/dist/components/atoms/Chip/chip-variants.js +8 -2
- package/dist/components/atoms/Combobox/Combobox.cjs +1 -1
- package/dist/components/atoms/Combobox/Combobox.js +20 -18
- package/dist/components/atoms/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/atoms/MultiSelect/MultiSelect.js +22 -20
- package/dist/components/atoms/PasswordInput/PasswordInput.cjs +1 -1
- package/dist/components/atoms/PasswordInput/PasswordInput.js +5 -5
- package/dist/components/atoms/Select/Select.cjs +1 -1
- package/dist/components/atoms/Select/Select.js +19 -17
- package/dist/components/atoms/Select/select-variants.cjs +1 -1
- package/dist/components/atoms/Select/select-variants.js +11 -2
- package/dist/components/molecules/Carousel/Carousel.cjs +1 -1
- package/dist/components/molecules/Carousel/Carousel.js +31 -29
- package/dist/components/molecules/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/molecules/FileUpload/FileUpload.js +21 -19
- package/dist/components/molecules/LiquidTabs/LiquidTabs.cjs +1 -1
- package/dist/components/molecules/LiquidTabs/LiquidTabs.js +22 -20
- package/dist/components/molecules/Menu/Menu.cjs +1 -1
- package/dist/components/molecules/Menu/Menu.js +133 -124
- package/dist/components/molecules/RadioGroup/RadioGroup.cjs +1 -1
- package/dist/components/molecules/RadioGroup/RadioGroup.js +23 -21
- package/dist/components/molecules/RangeSlider/RangeSlider.cjs +1 -0
- package/dist/components/molecules/RangeSlider/RangeSlider.d.ts +79 -0
- package/dist/components/molecules/RangeSlider/RangeSlider.js +166 -0
- package/dist/components/molecules/Slider/Slider.cjs +1 -0
- package/dist/components/molecules/Slider/Slider.d.ts +91 -0
- package/dist/components/molecules/Slider/Slider.js +130 -0
- package/dist/components/molecules/Slider/track-parts.cjs +1 -0
- package/dist/components/molecules/Slider/track-parts.d.ts +65 -0
- package/dist/components/molecules/Slider/track-parts.js +121 -0
- package/dist/components/molecules/Slider/track.cjs +1 -0
- package/dist/components/molecules/Slider/track.d.ts +115 -0
- package/dist/components/molecules/Slider/track.js +152 -0
- package/dist/components/organisms/Dialog/Dialog.cjs +1 -1
- package/dist/components/organisms/Dialog/Dialog.js +19 -17
- package/dist/components/organisms/ModerationQueue/ModerationQueue.cjs +1 -1
- package/dist/components/organisms/ModerationQueue/ModerationQueue.js +45 -43
- package/dist/components/organisms/Navbar/Navbar.cjs +1 -1
- package/dist/components/organisms/Navbar/Navbar.js +24 -22
- package/dist/components/organisms/Sheet/Sheet.cjs +1 -1
- package/dist/components/organisms/Sheet/Sheet.js +25 -23
- package/dist/index.d.ts +2 -0
- package/dist/internal/key-focus.cjs +1 -0
- package/dist/internal/key-focus.d.ts +7 -0
- package/dist/internal/key-focus.js +60 -0
- package/dist/internal/popup.cjs +1 -1
- package/dist/internal/popup.d.ts +15 -1
- package/dist/internal/popup.js +17 -12
- package/dist/meta.json +3 -3
- package/dist/roster.cjs +1 -1
- package/dist/roster.css +1 -1
- package/dist/roster.js +67 -63
- package/package.json +1 -1
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
import { jsx as c, jsxs as N, Fragment as j } from "react/jsx-runtime";
|
|
3
3
|
import * as i from "react";
|
|
4
4
|
import { Portal as q } from "../../../node_modules/@headlessui/react/dist/components/portal/portal.js";
|
|
5
|
-
import { useFloating as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { POPUP_PANEL as
|
|
8
|
-
import { Button as
|
|
9
|
-
import { nextByTypeahead as
|
|
10
|
-
import {
|
|
11
|
-
|
|
5
|
+
import { useFloating as he, offset as be, flip as ye, shift as ve, size as we } from "../../../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js";
|
|
6
|
+
import { cn as S } from "../../../lib/utils.js";
|
|
7
|
+
import { carriesDark as G, POPUP_PANEL as xe } from "../../../internal/popup.js";
|
|
8
|
+
import { Button as ke } from "../../atoms/Button/Button.js";
|
|
9
|
+
import { nextByTypeahead as Ie } from "./menu-typeahead.js";
|
|
10
|
+
import { useKeyFocus as Ee } from "../../../internal/key-focus.js";
|
|
11
|
+
import { autoUpdate as Se } from "../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
|
|
12
|
+
function Pe({ href: e, to: r, children: n, ...s }) {
|
|
12
13
|
return /* @__PURE__ */ c("a", { href: e, ...s, children: n });
|
|
13
14
|
}
|
|
14
|
-
const
|
|
15
|
+
const Y = i.createContext(null), B = i.createContext(null), X = i.createContext(null);
|
|
15
16
|
function C(e) {
|
|
16
|
-
const r = i.useContext(
|
|
17
|
+
const r = i.useContext(Y);
|
|
17
18
|
if (!r) throw new Error(`<${e}> must be inside a <Menu>.`);
|
|
18
19
|
return r;
|
|
19
20
|
}
|
|
@@ -22,44 +23,44 @@ function _(e) {
|
|
|
22
23
|
if (!r) throw new Error(`<${e}> must be inside <MenuItems> or a <MenuSubmenu>.`);
|
|
23
24
|
return r;
|
|
24
25
|
}
|
|
25
|
-
const
|
|
26
|
-
function
|
|
27
|
-
return e ? [...e.querySelectorAll(
|
|
26
|
+
const Me = "[data-menu-item]", J = 100, Ae = 75, Te = '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"])';
|
|
27
|
+
function R(e) {
|
|
28
|
+
return e ? [...e.querySelectorAll(Me)].filter((r) => r.closest("[data-menu-panel]") === e) : [];
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
e && (e.focus({ preventScroll: !0 }), e.scrollIntoView?.({ block: "nearest" }));
|
|
30
|
+
function E(e) {
|
|
31
|
+
e && (e.setAttribute("data-key-focus", ""), e.addEventListener("blur", () => e.removeAttribute("data-key-focus"), { once: !0 }), e.focus({ preventScroll: !0 }), e.scrollIntoView?.({ block: "nearest" }));
|
|
31
32
|
}
|
|
32
33
|
function z(e) {
|
|
33
34
|
return !!e && getComputedStyle(e).direction === "rtl";
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
-
const n = [...document.querySelectorAll(
|
|
37
|
-
(t) => t === e || t.tabIndex >= 0 && !t.matches(":disabled") && !t.closest("[data-menu-panel], [inert]") && t.getClientRects().length > 0 && getComputedStyle(t).visibility !== "hidden" && !
|
|
36
|
+
function Ce(e, r) {
|
|
37
|
+
const n = [...document.querySelectorAll(Te)].filter(
|
|
38
|
+
(t) => t === e || t.tabIndex >= 0 && !t.matches(":disabled") && !t.closest("[data-menu-panel], [inert]") && t.getClientRects().length > 0 && getComputedStyle(t).visibility !== "hidden" && !De(t, r)
|
|
38
39
|
), s = n.indexOf(e);
|
|
39
40
|
((r ? n[s - 1] : n[s + 1]) ?? e).focus();
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
+
function De(e, r) {
|
|
42
43
|
if (!(e instanceof HTMLInputElement) || e.type !== "radio" || !e.name) return !1;
|
|
43
44
|
const n = [...e.ownerDocument.querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(
|
|
44
45
|
(a) => a.form === e.form && !a.disabled
|
|
45
46
|
);
|
|
46
47
|
return (n.find((a) => a.checked) ?? (r ? n[n.length - 1] : n[0])) !== e;
|
|
47
48
|
}
|
|
48
|
-
const
|
|
49
|
+
const L = { x: Number.NaN, y: Number.NaN };
|
|
49
50
|
let U = !1;
|
|
50
|
-
function
|
|
51
|
+
function Le() {
|
|
51
52
|
U || typeof window > "u" || (U = !0, window.addEventListener(
|
|
52
53
|
"pointermove",
|
|
53
54
|
(e) => {
|
|
54
|
-
|
|
55
|
+
L.x = e.clientX, L.y = e.clientY;
|
|
55
56
|
},
|
|
56
57
|
{ passive: !0 }
|
|
57
58
|
));
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
-
return !Number.isNaN(
|
|
60
|
+
function Q(e) {
|
|
61
|
+
return !Number.isNaN(L.x) && (e.clientX !== L.x || e.clientY !== L.y);
|
|
61
62
|
}
|
|
62
|
-
const V = (e) => `radial-gradient(farthest-side at 50% ${e === "top" ? "0" : "100%"}, var(--menu-edge), transparent)`,
|
|
63
|
+
const V = (e) => `radial-gradient(farthest-side at 50% ${e === "top" ? "0" : "100%"}, var(--menu-edge), transparent)`, Z = {
|
|
63
64
|
backgroundImage: "var(--menu-edge-top, none), var(--menu-edge-bottom, none)",
|
|
64
65
|
backgroundPosition: "top, bottom",
|
|
65
66
|
backgroundSize: "100% 0.5rem",
|
|
@@ -79,13 +80,13 @@ function Re(e) {
|
|
|
79
80
|
};
|
|
80
81
|
}, [e]);
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function ee(e, r) {
|
|
83
84
|
const [n, s] = e.split("-"), a = r ? "right" : "left", t = r ? "left" : "right";
|
|
84
85
|
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
|
}
|
|
86
|
-
const
|
|
87
|
+
const te = /* @__PURE__ */ S(
|
|
87
88
|
"rst:font-ui",
|
|
88
|
-
|
|
89
|
+
xe,
|
|
89
90
|
/* Its own width wherever it lands: a fixed panel sized by the room to its
|
|
90
91
|
right resizes as it's placed, and the placement runs again. */
|
|
91
92
|
"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",
|
|
@@ -97,7 +98,7 @@ const ee = /* @__PURE__ */ E(
|
|
|
97
98
|
from the corner of the screen. */
|
|
98
99
|
"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
|
);
|
|
100
|
-
function
|
|
101
|
+
function re(e) {
|
|
101
102
|
const [r, n] = i.useState(e), [s, a] = i.useState(!0);
|
|
102
103
|
return i.useLayoutEffect(() => {
|
|
103
104
|
if (e) {
|
|
@@ -106,12 +107,12 @@ function te(e) {
|
|
|
106
107
|
return () => cancelAnimationFrame(o);
|
|
107
108
|
}
|
|
108
109
|
a(!0);
|
|
109
|
-
const t = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, d = window.setTimeout(() => n(!1), t ? 0 :
|
|
110
|
+
const t = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, d = window.setTimeout(() => n(!1), t ? 0 : Ae);
|
|
110
111
|
return () => window.clearTimeout(d);
|
|
111
112
|
}, [e]), { mounted: r, closed: s, leaving: r && !e };
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
-
const [d, o] = i.useState(null), u =
|
|
114
|
+
function ne(e, r, n, s, a, t = !1) {
|
|
115
|
+
const [d, o] = i.useState(null), u = he({
|
|
115
116
|
open: r,
|
|
116
117
|
strategy: "fixed",
|
|
117
118
|
/* Placed by top and left, not a transform: the entrance's scale would
|
|
@@ -119,12 +120,12 @@ function re(e, r, n, s, a, t = !1) {
|
|
|
119
120
|
transform: !1,
|
|
120
121
|
placement: n,
|
|
121
122
|
elements: { reference: e },
|
|
122
|
-
whileElementsMounted:
|
|
123
|
+
whileElementsMounted: Se,
|
|
123
124
|
middleware: [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
be(s),
|
|
126
|
+
ye({ padding: 8 }),
|
|
127
|
+
ve({ padding: 8, crossAxis: t }),
|
|
128
|
+
we({
|
|
128
129
|
padding: 8,
|
|
129
130
|
apply({ availableHeight: m, elements: l }) {
|
|
130
131
|
l.floating.style.maxHeight = `min(var(--anchor-max-height, 100vh), ${Math.max(m, 96)}px)`;
|
|
@@ -139,12 +140,12 @@ function re(e, r, n, s, a, t = !1) {
|
|
|
139
140
|
);
|
|
140
141
|
return Re(d), { ...u, setPanel: f, panelEl: d };
|
|
141
142
|
}
|
|
142
|
-
const
|
|
143
|
-
function
|
|
144
|
-
const e = i.useRef({ text: "", at: 0 }), r = i.useCallback(() => e.current.text !== "" && performance.now() - e.current.at <=
|
|
143
|
+
const oe = 500;
|
|
144
|
+
function se() {
|
|
145
|
+
const e = i.useRef({ text: "", at: 0 }), r = i.useCallback(() => e.current.text !== "" && performance.now() - e.current.at <= oe, []);
|
|
145
146
|
return { typedRef: e, typingAhead: r };
|
|
146
147
|
}
|
|
147
|
-
function
|
|
148
|
+
function ae({
|
|
148
149
|
panelRef: e,
|
|
149
150
|
typedRef: r,
|
|
150
151
|
onEscape: n,
|
|
@@ -154,21 +155,21 @@ function se({
|
|
|
154
155
|
return (t) => {
|
|
155
156
|
const d = e.current;
|
|
156
157
|
if (!d || !d.contains(t.target) || (!t.ctrlKey && !t.metaKey && !t.altKey && t.stopPropagation(), t.defaultPrevented)) return;
|
|
157
|
-
const o =
|
|
158
|
+
const o = R(d), u = o.indexOf(document.activeElement), p = z(d);
|
|
158
159
|
switch (t.key) {
|
|
159
160
|
case "ArrowDown":
|
|
160
|
-
t.preventDefault(), t.stopPropagation(),
|
|
161
|
+
t.preventDefault(), t.stopPropagation(), E(o[(u + 1) % o.length]);
|
|
161
162
|
return;
|
|
162
163
|
case "ArrowUp":
|
|
163
|
-
t.preventDefault(), t.stopPropagation(),
|
|
164
|
+
t.preventDefault(), t.stopPropagation(), E(o[u <= 0 ? o.length - 1 : u - 1]);
|
|
164
165
|
return;
|
|
165
166
|
case "Home":
|
|
166
167
|
case "PageUp":
|
|
167
|
-
t.preventDefault(), t.stopPropagation(),
|
|
168
|
+
t.preventDefault(), t.stopPropagation(), E(o[0]);
|
|
168
169
|
return;
|
|
169
170
|
case "End":
|
|
170
171
|
case "PageDown":
|
|
171
|
-
t.preventDefault(), t.stopPropagation(),
|
|
172
|
+
t.preventDefault(), t.stopPropagation(), E(o[o.length - 1]);
|
|
172
173
|
return;
|
|
173
174
|
case "Escape":
|
|
174
175
|
t.preventDefault(), t.stopPropagation(), n();
|
|
@@ -176,7 +177,7 @@ function se({
|
|
|
176
177
|
case "Tab": {
|
|
177
178
|
t.preventDefault(), t.stopPropagation();
|
|
178
179
|
const f = a.triggerRef.current;
|
|
179
|
-
a.close(!1), f &&
|
|
180
|
+
a.close(!1), f && Ce(f, t.shiftKey);
|
|
180
181
|
return;
|
|
181
182
|
}
|
|
182
183
|
case "ArrowLeft":
|
|
@@ -185,15 +186,16 @@ function se({
|
|
|
185
186
|
return;
|
|
186
187
|
}
|
|
187
188
|
if (t.key.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey) {
|
|
188
|
-
const f = performance.now(), m = r.current.text !== "" && f - r.current.at <=
|
|
189
|
+
const f = performance.now(), m = r.current.text !== "" && f - r.current.at <= oe;
|
|
189
190
|
if (t.key === " " && !m) return;
|
|
190
191
|
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 =
|
|
192
|
-
b !== -1 &&
|
|
192
|
+
const l = o.map((x) => x.dataset.menuText ?? x.textContent ?? ""), b = Ie(l, u, r.current.text);
|
|
193
|
+
b !== -1 && E(o[b]);
|
|
193
194
|
}
|
|
194
195
|
};
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
+
function qe({ children: e, open: r, onOpenChange: n, linkComponent: s = Pe }) {
|
|
198
|
+
Ee();
|
|
197
199
|
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
200
|
u.current = g, f(g);
|
|
199
201
|
}, []), l = i.useRef("panel"), b = i.useCallback(
|
|
@@ -223,22 +225,22 @@ function Ue({ children: e, open: r, onOpenChange: n, linkComponent: s = Ee }) {
|
|
|
223
225
|
);
|
|
224
226
|
return i.useEffect(() => {
|
|
225
227
|
if (!d) return;
|
|
226
|
-
|
|
228
|
+
Le();
|
|
227
229
|
const g = (I) => {
|
|
228
230
|
I.target?.closest?.(`[data-menu-tree="${o}"]`) || (b(!1), requestAnimationFrame(() => {
|
|
229
231
|
(document.activeElement === document.body || !document.activeElement) && u.current?.focus({ preventScroll: !0 });
|
|
230
232
|
}));
|
|
231
233
|
};
|
|
232
234
|
return document.addEventListener("pointerdown", g, !0), () => document.removeEventListener("pointerdown", g, !0);
|
|
233
|
-
}, [d, o, b]), /* @__PURE__ */ c(
|
|
235
|
+
}, [d, o, b]), /* @__PURE__ */ c(Y.Provider, { value: x, children: e });
|
|
234
236
|
}
|
|
235
|
-
const
|
|
237
|
+
const Ge = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKeyDown: a, children: t, ...d }, o) {
|
|
236
238
|
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
239
|
(y) => {
|
|
238
240
|
P(y), typeof o == "function" ? o(y) : o && (o.current = y);
|
|
239
241
|
},
|
|
240
242
|
[P, o]
|
|
241
|
-
),
|
|
243
|
+
), A = {
|
|
242
244
|
id: h.triggerId,
|
|
243
245
|
"aria-haspopup": "menu",
|
|
244
246
|
"aria-expanded": h.open,
|
|
@@ -254,20 +256,20 @@ const Ve = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKe
|
|
|
254
256
|
y.preventDefault();
|
|
255
257
|
const k = h.open ? document.getElementById(h.panelId) : null;
|
|
256
258
|
if (k) {
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
+
const D = R(k);
|
|
260
|
+
E(v === "last" ? D[D.length - 1] : D[0]);
|
|
259
261
|
return;
|
|
260
262
|
}
|
|
261
263
|
h.openWith(v);
|
|
262
264
|
}
|
|
263
265
|
};
|
|
264
|
-
return r ? /* @__PURE__ */ c("button", { ref: M, type: "button", className: n, ...I, ...
|
|
266
|
+
return r ? /* @__PURE__ */ c("button", { ref: M, type: "button", className: n, ...I, ...A, children: t }) : (
|
|
265
267
|
/* min 44 by 44 whatever the size: the target a finger needs. */
|
|
266
268
|
/* @__PURE__ */ c(
|
|
267
|
-
|
|
269
|
+
ke,
|
|
268
270
|
{
|
|
269
271
|
ref: M,
|
|
270
|
-
className:
|
|
272
|
+
className: S("rst:min-h-11 rst:min-w-11", n),
|
|
271
273
|
variant: u,
|
|
272
274
|
colorScheme: p,
|
|
273
275
|
size: f,
|
|
@@ -277,18 +279,18 @@ const Ve = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKe
|
|
|
277
279
|
endIcon: x,
|
|
278
280
|
surface: g,
|
|
279
281
|
...I,
|
|
280
|
-
...
|
|
282
|
+
...A,
|
|
281
283
|
children: t
|
|
282
284
|
}
|
|
283
285
|
)
|
|
284
286
|
);
|
|
285
287
|
});
|
|
286
|
-
function
|
|
287
|
-
const t = C("MenuItems"), { mounted: d, closed: o, leaving: u } =
|
|
288
|
+
function Ye({ children: e, align: r = "start", offset: n = 4, className: s, ...a }) {
|
|
289
|
+
const t = C("MenuItems"), { mounted: d, closed: o, leaving: u } = re(t.open), p = i.useRef(null), f = z(t.triggerEl), { setPanel: m, panelEl: l, floatingStyles: b, placement: x, isPositioned: g } = ne(t.triggerEl, d, `bottom-${r}`, n, p), I = ie(), { typedRef: h, typingAhead: P } = se(), M = ae({ panelRef: p, typedRef: h, onEscape: () => t.close(!0) });
|
|
288
290
|
i.useLayoutEffect(() => {
|
|
289
291
|
if (!t.open || !l) return;
|
|
290
|
-
const v =
|
|
291
|
-
k === "first" && v[0] ?
|
|
292
|
+
const v = R(l), k = t.focusOnOpen.current;
|
|
293
|
+
k === "first" && v[0] ? E(v[0]) : k === "last" && v.length ? E(v[v.length - 1]) : l.focus({ preventScroll: !0 });
|
|
292
294
|
}, [t.open, l, t.focusOnOpen]), i.useLayoutEffect(() => {
|
|
293
295
|
if (!g || !l) return;
|
|
294
296
|
const v = document.activeElement;
|
|
@@ -296,12 +298,12 @@ function je({ children: e, align: r = "start", offset: n = 4, className: s, ...a
|
|
|
296
298
|
}, [g, l]), i.useLayoutEffect(() => {
|
|
297
299
|
!t.open && l?.contains(document.activeElement) && t.triggerRef.current?.focus({ preventScroll: !0 });
|
|
298
300
|
}, [t.open, l, t.triggerRef]);
|
|
299
|
-
const
|
|
301
|
+
const A = (v) => {
|
|
300
302
|
const k = v.relatedTarget;
|
|
301
303
|
k && !k.closest(`[data-menu-tree="${t.treeId}"]`) && t.close(!1);
|
|
302
304
|
};
|
|
303
305
|
if (!d) return null;
|
|
304
|
-
const y =
|
|
306
|
+
const y = G(t.triggerEl);
|
|
305
307
|
return /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(B.Provider, { value: { ...I, panelRef: p, typingAhead: P }, children: /* @__PURE__ */ c(
|
|
306
308
|
"div",
|
|
307
309
|
{
|
|
@@ -317,14 +319,14 @@ function je({ children: e, align: r = "start", offset: n = 4, className: s, ...a
|
|
|
317
319
|
"data-closed": o ? "" : void 0,
|
|
318
320
|
"data-leaving": u ? "" : void 0,
|
|
319
321
|
onKeyDown: M,
|
|
320
|
-
onBlur:
|
|
321
|
-
style: { ...b, ...
|
|
322
|
-
className:
|
|
322
|
+
onBlur: A,
|
|
323
|
+
style: { ...b, ...Z, transformOrigin: ee(x, f) },
|
|
324
|
+
className: S(y && "dark", te, s),
|
|
323
325
|
children: e
|
|
324
326
|
}
|
|
325
327
|
) }) });
|
|
326
328
|
}
|
|
327
|
-
function
|
|
329
|
+
function ie() {
|
|
328
330
|
const [e, r] = i.useState(null), n = i.useRef(!1), s = i.useRef(void 0);
|
|
329
331
|
return i.useEffect(() => () => window.clearTimeout(s.current), []), {
|
|
330
332
|
openSubmenu: e,
|
|
@@ -333,23 +335,30 @@ function ae() {
|
|
|
333
335
|
window.clearTimeout(s.current), n.current = t, r(a);
|
|
334
336
|
},
|
|
335
337
|
hoverItem: (a) => {
|
|
336
|
-
window.clearTimeout(s.current), a === null && (s.current = window.setTimeout(() => r(null),
|
|
338
|
+
window.clearTimeout(s.current), a === null && (s.current = window.setTimeout(() => r(null), J));
|
|
337
339
|
}
|
|
338
340
|
};
|
|
339
341
|
}
|
|
340
|
-
const O = /* @__PURE__ */
|
|
342
|
+
const O = /* @__PURE__ */ S(
|
|
341
343
|
/* A button or a link reset to a row: no border, no fill, the panel's type. */
|
|
342
344
|
"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
345
|
/* Focus follows the pointer, so the highlight is focus. In forced colors a
|
|
344
346
|
fill is dropped, so focus draws an outline there instead. */
|
|
345
347
|
"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",
|
|
348
|
+
/* The tint alone isn't a focus indicator: it measures under 1.2:1 against
|
|
349
|
+
the panel in both themes, on the default surface and a consumer's. So
|
|
350
|
+
keyboard focus adds an inset ring in the focus token, which a consumer
|
|
351
|
+
tunes against their own surfaces, and holds 3:1 on any of them. The
|
|
352
|
+
pointer's focus is the tint alone: the ring follows the mark `focusItem`
|
|
353
|
+
leaves, which only the keyboard's paths set. */
|
|
354
|
+
"rst:data-key-focus:ring-2 rst:data-key-focus:ring-inset rst:data-key-focus:ring-ring",
|
|
346
355
|
"rst:aria-disabled:opacity-50 rst:aria-disabled:cursor-not-allowed"
|
|
347
|
-
),
|
|
348
|
-
function
|
|
356
|
+
), F = "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", 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", children: /* @__PURE__ */ c("path", { d: "M3.5 8.5 6.5 11.5 12.5 4.5" }) }), Oe = () => /* @__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" }) }), Ke = () => /* @__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" }) });
|
|
357
|
+
function T({ icon: e, shortcut: r, description: n, badge: s, children: a }, t, d, o) {
|
|
349
358
|
const u = t ?? e;
|
|
350
359
|
return /* @__PURE__ */ N(j, { children: [
|
|
351
360
|
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:
|
|
361
|
+
/* @__PURE__ */ c("span", { "aria-hidden": "true", className: S("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
362
|
/* @__PURE__ */ N("span", { className: "rst:min-w-0 rst:flex-1 rst:break-words", "data-menu-label": "", children: [
|
|
354
363
|
a,
|
|
355
364
|
n != null && /* @__PURE__ */ c("span", { id: o, "aria-hidden": "true", className: "rst:block rst:text-xs rst:opacity-75", "data-menu-description": "", children: n })
|
|
@@ -359,7 +368,7 @@ function A({ icon: e, shortcut: r, description: n, badge: s, children: a }, t, d
|
|
|
359
368
|
d
|
|
360
369
|
] });
|
|
361
370
|
}
|
|
362
|
-
function
|
|
371
|
+
function H({
|
|
363
372
|
disabled: e,
|
|
364
373
|
closeOnSelect: r,
|
|
365
374
|
onChoose: n,
|
|
@@ -381,12 +390,12 @@ function F({
|
|
|
381
390
|
}
|
|
382
391
|
},
|
|
383
392
|
onPointerMove: (o) => {
|
|
384
|
-
|
|
393
|
+
Q(o) && (t.hoverItem(null), document.activeElement !== o.currentTarget && o.currentTarget.focus({ preventScroll: !0 }));
|
|
385
394
|
}
|
|
386
395
|
};
|
|
387
396
|
}
|
|
388
|
-
function
|
|
389
|
-
const p = C("MenuItem"), f = _("MenuItem"), m = i.useId(), l =
|
|
397
|
+
function Xe({ onSelect: e, href: r, closeOnSelect: n = !0, disabled: s, destructive: a, keyshortcuts: t, textValue: d, className: o, ...u }) {
|
|
398
|
+
const p = C("MenuItem"), f = _("MenuItem"), m = i.useId(), l = H({ disabled: s, closeOnSelect: n, onChoose: (g) => e?.(g) }), b = S(O, a && F, o), x = {
|
|
390
399
|
role: "menuitem",
|
|
391
400
|
tabIndex: -1,
|
|
392
401
|
"aria-disabled": s ? !0 : void 0,
|
|
@@ -413,14 +422,14 @@ function qe({ onSelect: e, href: r, closeOnSelect: n = !0, disabled: s, destruct
|
|
|
413
422
|
I.preventDefault(), s || I.currentTarget.click();
|
|
414
423
|
}
|
|
415
424
|
},
|
|
416
|
-
children:
|
|
425
|
+
children: T(u, void 0, void 0, m)
|
|
417
426
|
}
|
|
418
427
|
);
|
|
419
428
|
}
|
|
420
|
-
return /* @__PURE__ */ c("button", { type: "button", className: b, ...x, ...l, children:
|
|
429
|
+
return /* @__PURE__ */ c("button", { type: "button", className: b, ...x, ...l, children: T(u, void 0, void 0, m) });
|
|
421
430
|
}
|
|
422
|
-
function
|
|
423
|
-
const f =
|
|
431
|
+
function Je({ checked: e, onCheckedChange: r, indicator: n, closeOnSelect: s = !0, disabled: a, destructive: t, keyshortcuts: d, textValue: o, className: u, ...p }) {
|
|
432
|
+
const f = H({ disabled: a, closeOnSelect: s, spaceKeepsOpen: !0, onChoose: () => r(!e) }), m = i.useId();
|
|
424
433
|
return /* @__PURE__ */ c(
|
|
425
434
|
"button",
|
|
426
435
|
{
|
|
@@ -433,19 +442,19 @@ function Ge({ checked: e, onCheckedChange: r, indicator: n, closeOnSelect: s = !
|
|
|
433
442
|
"aria-keyshortcuts": d,
|
|
434
443
|
"data-menu-item": "",
|
|
435
444
|
"data-menu-text": o,
|
|
436
|
-
className:
|
|
445
|
+
className: S(O, t && F, u),
|
|
437
446
|
...f,
|
|
438
|
-
children: n === void 0 ?
|
|
447
|
+
children: n === void 0 ? T(p, /* @__PURE__ */ c("span", { className: e ? void 0 : "rst:invisible", "data-menu-check": "", children: /* @__PURE__ */ c(Ne, {}) }), void 0, m) : T(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
448
|
}
|
|
440
449
|
);
|
|
441
450
|
}
|
|
442
|
-
function
|
|
443
|
-
return /* @__PURE__ */ c(
|
|
451
|
+
function Qe({ value: e, onValueChange: r, label: n, children: s, className: a }) {
|
|
452
|
+
return /* @__PURE__ */ c(X.Provider, { value: { value: e, onValueChange: r }, children: /* @__PURE__ */ c($e, { label: n, className: a, children: s }) });
|
|
444
453
|
}
|
|
445
|
-
function
|
|
446
|
-
const u = i.useContext(
|
|
454
|
+
function Ze({ value: e, closeOnSelect: r = !0, disabled: n, destructive: s, keyshortcuts: a, textValue: t, className: d, ...o }) {
|
|
455
|
+
const u = i.useContext(X);
|
|
447
456
|
if (!u) throw new Error("<MenuRadioItem> must be inside a <MenuRadioGroup>.");
|
|
448
|
-
const p = u.value === e, f =
|
|
457
|
+
const p = u.value === e, f = H({ disabled: n, closeOnSelect: r, spaceKeepsOpen: !0, onChoose: () => u.onValueChange?.(e) }), m = i.useId();
|
|
449
458
|
return /* @__PURE__ */ c(
|
|
450
459
|
"button",
|
|
451
460
|
{
|
|
@@ -458,13 +467,13 @@ function Xe({ value: e, closeOnSelect: r = !0, disabled: n, destructive: s, keys
|
|
|
458
467
|
"aria-keyshortcuts": a,
|
|
459
468
|
"data-menu-item": "",
|
|
460
469
|
"data-menu-text": t,
|
|
461
|
-
className:
|
|
470
|
+
className: S(O, s && F, d),
|
|
462
471
|
...f,
|
|
463
|
-
children:
|
|
472
|
+
children: T(o, /* @__PURE__ */ c("span", { className: p ? void 0 : "rst:invisible", "data-menu-check": "", children: /* @__PURE__ */ c(Oe, {}) }), void 0, m)
|
|
464
473
|
}
|
|
465
474
|
);
|
|
466
475
|
}
|
|
467
|
-
function
|
|
476
|
+
function $e({ label: e, children: r, className: n }) {
|
|
468
477
|
const s = i.useId();
|
|
469
478
|
return /* @__PURE__ */ N("div", { role: "group", "aria-labelledby": e ? s : void 0, className: n, children: [
|
|
470
479
|
e && /* @__PURE__ */ c(
|
|
@@ -479,36 +488,36 @@ function Oe({ label: e, children: r, className: n }) {
|
|
|
479
488
|
r
|
|
480
489
|
] });
|
|
481
490
|
}
|
|
482
|
-
function
|
|
483
|
-
return /* @__PURE__ */ c("div", { role: "separator", className:
|
|
491
|
+
function et({ className: e }) {
|
|
492
|
+
return /* @__PURE__ */ c("div", { role: "separator", className: S("rst:my-1 rst:h-[var(--roster-border-width,1px)] rst:bg-[var(--roster-popover-border)]", e) });
|
|
484
493
|
}
|
|
485
|
-
function
|
|
494
|
+
function tt({ label: e, children: r, icon: n, disabled: s, textValue: a, className: t, panelClassName: d }) {
|
|
486
495
|
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
496
|
b.current = w, g(w);
|
|
488
|
-
}, []), h = i.useRef(null), P = i.useRef(void 0), M = i.useRef("mouse"), { mounted:
|
|
497
|
+
}, []), h = i.useRef(null), P = i.useRef(void 0), M = i.useRef("mouse"), { mounted: A, closed: y, leaving: v } = re(l), k = z(x), { setPanel: D, panelEl: K, floatingStyles: ue, placement: ce } = ne(
|
|
489
498
|
x,
|
|
490
|
-
|
|
499
|
+
A,
|
|
491
500
|
k ? "left-start" : "right-start",
|
|
492
501
|
{ mainAxis: 0, alignmentAxis: -4 },
|
|
493
502
|
h,
|
|
494
503
|
!0
|
|
495
|
-
),
|
|
504
|
+
), le = ie();
|
|
496
505
|
i.useEffect(() => () => window.clearTimeout(P.current), []);
|
|
497
506
|
const W = () => {
|
|
498
|
-
u.setOpenSubmenu(null), b.current
|
|
499
|
-
}, { typedRef:
|
|
507
|
+
u.setOpenSubmenu(null), E(b.current);
|
|
508
|
+
}, { typedRef: de, typingAhead: me } = se(), fe = ae({ panelRef: h, typedRef: de, onEscape: W, onBack: W });
|
|
500
509
|
i.useLayoutEffect(() => {
|
|
501
|
-
!l || !K || u.focusFirstInSubmenu.current &&
|
|
510
|
+
!l || !K || u.focusFirstInSubmenu.current && E(R(K)[0]);
|
|
502
511
|
}, [l, K, u.focusFirstInSubmenu]);
|
|
503
512
|
const $ = (w) => {
|
|
504
513
|
if (!s) {
|
|
505
514
|
if (l && w && h.current) {
|
|
506
|
-
|
|
515
|
+
E(R(h.current)[0]);
|
|
507
516
|
return;
|
|
508
517
|
}
|
|
509
518
|
u.setOpenSubmenu(f, w);
|
|
510
519
|
}
|
|
511
|
-
},
|
|
520
|
+
}, pe = G(o.triggerEl);
|
|
512
521
|
return /* @__PURE__ */ N(j, { children: [
|
|
513
522
|
/* @__PURE__ */ c(
|
|
514
523
|
"button",
|
|
@@ -525,26 +534,26 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
|
|
|
525
534
|
"data-menu-item": "",
|
|
526
535
|
"data-menu-text": a,
|
|
527
536
|
"data-menu-tree": o.treeId,
|
|
528
|
-
className:
|
|
537
|
+
className: S(O, l && "rst:bg-gray-100 rst:dark:bg-gray-700/50", t),
|
|
529
538
|
onPointerDown: (w) => {
|
|
530
539
|
M.current = w.pointerType;
|
|
531
540
|
},
|
|
532
541
|
onClick: () => l && M.current !== "mouse" ? u.setOpenSubmenu(null) : $(!1),
|
|
533
542
|
onKeyDown: (w) => {
|
|
534
|
-
const
|
|
535
|
-
w.key === " " && u.typingAhead() || (w.key ===
|
|
543
|
+
const ge = k ? "ArrowLeft" : "ArrowRight";
|
|
544
|
+
w.key === " " && u.typingAhead() || (w.key === ge || w.key === "Enter" || w.key === " ") && (w.preventDefault(), $(!0));
|
|
536
545
|
},
|
|
537
546
|
onPointerMove: (w) => {
|
|
538
|
-
|
|
547
|
+
Q(w) && (u.hoverItem(f), document.activeElement !== w.currentTarget && w.currentTarget.focus({ preventScroll: !0 }), !l && !s && (window.clearTimeout(P.current), P.current = window.setTimeout(() => $(!1), J)));
|
|
539
548
|
},
|
|
540
549
|
onPointerLeave: () => window.clearTimeout(P.current),
|
|
541
|
-
children:
|
|
550
|
+
children: T({ 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(Ke, {}) }))
|
|
542
551
|
}
|
|
543
552
|
),
|
|
544
|
-
|
|
553
|
+
A && /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(B.Provider, { value: { ...le, panelRef: h, typingAhead: me }, children: /* @__PURE__ */ c(
|
|
545
554
|
"div",
|
|
546
555
|
{
|
|
547
|
-
ref:
|
|
556
|
+
ref: D,
|
|
548
557
|
id: m,
|
|
549
558
|
dir: k ? "rtl" : "ltr",
|
|
550
559
|
role: "menu",
|
|
@@ -554,24 +563,24 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
|
|
|
554
563
|
"data-menu-tree": o.treeId,
|
|
555
564
|
"data-closed": y ? "" : void 0,
|
|
556
565
|
"data-leaving": v ? "" : void 0,
|
|
557
|
-
onKeyDown:
|
|
566
|
+
onKeyDown: fe,
|
|
558
567
|
onPointerEnter: () => u.hoverItem(f),
|
|
559
|
-
style: { ...
|
|
560
|
-
className:
|
|
568
|
+
style: { ...ue, ...Z, transformOrigin: ee(ce, k) },
|
|
569
|
+
className: S(pe && "dark", te, d),
|
|
561
570
|
children: r
|
|
562
571
|
}
|
|
563
572
|
) }) })
|
|
564
573
|
] });
|
|
565
574
|
}
|
|
566
575
|
export {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
576
|
+
qe as Menu,
|
|
577
|
+
Ge as MenuButton,
|
|
578
|
+
Je as MenuCheckboxItem,
|
|
579
|
+
$e as MenuGroup,
|
|
580
|
+
Xe as MenuItem,
|
|
581
|
+
Ye as MenuItems,
|
|
582
|
+
Qe as MenuRadioGroup,
|
|
583
|
+
Ze as MenuRadioItem,
|
|
584
|
+
et as MenuSeparator,
|
|
585
|
+
tt as MenuSubmenu
|
|
577
586
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime");require("react");const m=require("../../../node_modules/@headlessui/react/dist/components/description/description.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime");require("react");const m=require("../../../node_modules/@headlessui/react/dist/components/description/description.cjs"),L=require("../../../node_modules/@headlessui/react/dist/components/field/field.cjs"),p=require("../../../node_modules/@headlessui/react/dist/components/label/label.cjs"),v=require("../../../node_modules/@headlessui/react/dist/components/radio-group/radio-group.cjs"),r=require("../../../lib/utils.cjs"),f=require("../../../internal/field-invalid.cjs"),c=require("./radio-group-variants.cjs"),D=require("../../../internal/key-focus.cjs"),E={sm:"rst:text-xs",md:"rst:text-sm",lg:"rst:text-base"},O=({options:y,value:j,onChange:b,label:n,helperText:d,errorMessage:l,disabled:e=!1,size:h="md",orientation:i="vertical",colorScheme:q,className:N,optionsClassName:g,optionClassName:G,radioClassName:k,labelClassName:w,optionLabelClassName:z,descriptionClassName:R,messageClassName:S,"aria-invalid":V,...u})=>{D.useKeyFocus();const x=!!l,F=f.isFieldInvalid(x,{...u,"aria-invalid":V}),I=f.withoutInvalidProps(u),a=h??"md";return t.jsxs(v.RadioGroup,{value:j,onChange:b,disabled:e,className:r.cn("rst:font-ui rst:flex rst:flex-col rst:gap-1.5 rst:min-w-0",N),...I,"aria-invalid":F||void 0,"aria-orientation":i,children:[n&&t.jsx(p.Label,{className:r.cn("rst:block rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)] rst:text-left",e&&"rst:opacity-50",w),children:n}),t.jsx("div",{className:r.cn(c.radioGroupOptionsVariants({size:a,orientation:i}),g),children:y.map(s=>t.jsxs(L.Field,{disabled:e||s.disabled,className:r.cn(c.radioOptionVariants({orientation:i,size:a}),G),children:[t.jsx(v.Radio,{value:s.value,className:({checked:o})=>r.cn(c.radioVariants({colorScheme:q,size:a,checked:o}),"rst:self-start",e||s.disabled?"rst:opacity-50 rst:cursor-not-allowed":"rst:cursor-pointer",k),children:({checked:o})=>t.jsx("span",{className:r.cn(c.radioDotVariants({size:a}),o?"rst:opacity-100":"rst:opacity-0")})}),t.jsxs("div",{className:r.cn("rst:flex rst:min-w-0 rst:flex-col",i==="vertical"&&"rst:flex-1"),children:[t.jsx(p.Label,{className:r.cn("rst:cursor-pointer rst:select-none","rst:text-[var(--roster-control-text)]","rst:data-disabled:cursor-not-allowed rst:data-disabled:opacity-50",E[a],z),children:s.label}),s.description&&t.jsx(m.Description,{className:r.cn("rst:text-xs rst:text-gray-500 rst:dark:text-gray-400 rst:data-disabled:opacity-50",R),children:s.description})]})]},s.value))}),(d||l)&&t.jsx(m.Description,{as:"p",className:r.cn("rst:text-xs rst:text-left",x?"rst:text-error-600 rst:dark:text-error-400 rst:font-medium":"rst:text-gray-500 rst:dark:text-gray-400",e&&"rst:opacity-50",S),children:l||d})]})};exports.RadioGroup=O;
|