@blakesteve/roster 5.9.0 → 5.11.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 (42) hide show
  1. package/README.md +206 -25
  2. package/dist/components/atoms/Button/button-variants.js +1 -1
  3. package/dist/components/atoms/Eyebrow/eyebrow-variants.d.ts +2 -2
  4. package/dist/components/atoms/Input/input-variants.js +1 -1
  5. package/dist/components/atoms/PasswordInput/PasswordInput.cjs +1 -1
  6. package/dist/components/atoms/PasswordInput/PasswordInput.js +5 -5
  7. package/dist/components/atoms/Select/select-variants.cjs +1 -1
  8. package/dist/components/atoms/Select/select-variants.js +11 -2
  9. package/dist/components/atoms/Skeleton/Skeleton.cjs +1 -1
  10. package/dist/components/atoms/Skeleton/Skeleton.d.ts +19 -3
  11. package/dist/components/atoms/Skeleton/Skeleton.js +38 -33
  12. package/dist/components/atoms/ThemeToggle/ThemeToggle.d.ts +1 -1
  13. package/dist/components/molecules/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  14. package/dist/components/molecules/CheckboxGroup/checkbox-group-variants.d.ts +1 -1
  15. package/dist/components/molecules/Menu/Menu.cjs +1 -1
  16. package/dist/components/molecules/Menu/Menu.js +60 -53
  17. package/dist/components/molecules/RangeSlider/RangeSlider.cjs +1 -0
  18. package/dist/components/molecules/RangeSlider/RangeSlider.d.ts +74 -0
  19. package/dist/components/molecules/RangeSlider/RangeSlider.js +164 -0
  20. package/dist/components/molecules/SkeletonPresets/SkeletonPresets.cjs +1 -1
  21. package/dist/components/molecules/SkeletonPresets/SkeletonPresets.d.ts +13 -4
  22. package/dist/components/molecules/SkeletonPresets/SkeletonPresets.js +35 -35
  23. package/dist/components/molecules/Slider/Slider.cjs +1 -0
  24. package/dist/components/molecules/Slider/Slider.d.ts +87 -0
  25. package/dist/components/molecules/Slider/Slider.js +128 -0
  26. package/dist/components/molecules/Slider/track-parts.cjs +1 -0
  27. package/dist/components/molecules/Slider/track-parts.d.ts +64 -0
  28. package/dist/components/molecules/Slider/track-parts.js +121 -0
  29. package/dist/components/molecules/Slider/track.cjs +1 -0
  30. package/dist/components/molecules/Slider/track.d.ts +115 -0
  31. package/dist/components/molecules/Slider/track.js +152 -0
  32. package/dist/components/molecules/Toast/Toaster.d.ts +1 -1
  33. package/dist/components/organisms/Navbar/Navbar.cjs +1 -1
  34. package/dist/components/organisms/Navbar/Navbar.js +37 -37
  35. package/dist/index.d.ts +2 -0
  36. package/dist/lib/utils.cjs +1 -1
  37. package/dist/lib/utils.js +4 -1
  38. package/dist/meta.json +3 -3
  39. package/dist/roster.cjs +1 -1
  40. package/dist/roster.css +1 -1
  41. package/dist/roster.js +67 -63
  42. package/package.json +1 -1
@@ -1,80 +1,85 @@
1
1
  "use client";
2
- import { jsx as s, jsxs as p, Fragment as g } from "react/jsx-runtime";
3
- import { useState as y, useEffect as S } from "react";
4
- import { cn as a } from "../../../lib/utils.js";
5
- const f = {
2
+ import { jsx as e, jsxs as v, Fragment as g } from "react/jsx-runtime";
3
+ import { useContext as y, useState as w, useEffect as C, createContext as L } from "react";
4
+ import { cn as c } from "../../../lib/utils.js";
5
+ const p = {
6
6
  sm: "rst:text-xs",
7
7
  md: "rst:text-sm",
8
8
  lg: "rst:text-base",
9
9
  inherit: ""
10
- }, k = {
10
+ }, b = {
11
11
  xs: "rst:h-6 rst:w-6",
12
12
  sm: "rst:h-8 rst:w-8",
13
13
  md: "rst:h-10 rst:w-10",
14
14
  lg: "rst:h-12 rst:w-12",
15
15
  xl: "rst:h-16 rst:w-16"
16
- }, x = {
16
+ }, S = {
17
17
  sm: "rst:rounded-sm",
18
18
  md: "rst:rounded-md",
19
19
  lg: "rst:rounded-lg",
20
20
  xl: "rst:rounded-xl",
21
21
  full: "rst:rounded-full"
22
- }, h = "rst:animate-skeleton rst:forced-colors:outline-solid rst:forced-colors:outline-1";
23
- function E({ shape: t = "line", size: r, lines: d = 1, width: e, height: u, radius: c, className: o }) {
22
+ }, E = "rst:rounded-skeleton", N = {
23
+ shimmer: "rst:animate-skeleton rst:forced-colors:outline-solid rst:forced-colors:outline-1",
24
+ pulse: "rst:animate-skeleton-pulse rst:forced-colors:outline-solid rst:forced-colors:outline-1 rst:forced-colors:animate-none",
25
+ none: "rst:skeleton-fill rst:forced-colors:outline-solid rst:forced-colors:outline-1"
26
+ }, x = L(void 0);
27
+ function j({ shape: t = "line", size: r, lines: d = 1, width: s, height: m, radius: o, animation: h, className: n }) {
28
+ const f = y(x), l = N[h ?? f ?? "shimmer"];
24
29
  if (t === "circle") {
25
- const l = r && r in k ? r : "md";
26
- return /* @__PURE__ */ s(
30
+ const i = r && r in b ? r : "md";
31
+ return /* @__PURE__ */ e(
27
32
  "span",
28
33
  {
29
34
  "aria-hidden": "true",
30
- className: a("rst:block rst:shrink-0 rst:rounded-full rst:border rst:border-transparent", k[l], h, o),
35
+ className: c("rst:block rst:shrink-0 rst:rounded-full rst:border rst:border-transparent", b[i], l, n),
31
36
  "data-skeleton": "circle"
32
37
  }
33
38
  );
34
39
  }
35
40
  if (t === "block")
36
- return /* @__PURE__ */ s(
41
+ return /* @__PURE__ */ e(
37
42
  "span",
38
43
  {
39
44
  "aria-hidden": "true",
40
- className: a("rst:block rst:w-full", x[c ?? "lg"], h, o),
41
- style: { height: u ?? "8rem", width: e },
45
+ className: c("rst:block rst:w-full", o ? S[o] : E, l, n),
46
+ style: { height: m ?? "8rem", width: s },
42
47
  "data-skeleton": "block"
43
48
  }
44
49
  );
45
- const m = r && r in f ? r : "md", n = Math.max(1, Math.floor(d)), b = (l) => {
46
- const i = l === n - 1;
47
- return /* @__PURE__ */ p(
50
+ const k = r && r in p ? r : "md", a = Math.max(1, Math.floor(d)), I = (i) => {
51
+ const u = i === a - 1;
52
+ return /* @__PURE__ */ v(
48
53
  "span",
49
54
  {
50
- className: a("rst:relative rst:block", n > 1 && !i && "rst:w-full"),
51
- style: { width: n > 1 ? i ? e ?? "60%" : void 0 : e },
55
+ className: c("rst:relative rst:block", a > 1 && !u && "rst:w-full"),
56
+ style: { width: a > 1 ? u ? s ?? "60%" : void 0 : s },
52
57
  children: [
53
58
  " ",
54
- /* @__PURE__ */ s(
59
+ /* @__PURE__ */ e(
55
60
  "span",
56
61
  {
57
- className: a("rst:absolute rst:inset-x-0 rst:top-1/2 rst:h-[0.7em] rst:-translate-y-1/2", x[c ?? "sm"], h)
62
+ className: c("rst:absolute rst:inset-x-0 rst:top-1/2 rst:h-[0.7em] rst:-translate-y-1/2", S[o ?? "sm"], l)
58
63
  }
59
64
  )
60
65
  ]
61
66
  },
62
- l
67
+ i
63
68
  );
64
69
  };
65
- return /* @__PURE__ */ s("span", { "aria-hidden": "true", className: a("rst:block", f[m], o), "data-skeleton": "line", children: Array.from({ length: n }, (l, i) => b(i)) });
70
+ return /* @__PURE__ */ e("span", { "aria-hidden": "true", className: c("rst:block", p[k], n), "data-skeleton": "line", children: Array.from({ length: a }, (i, u) => I(u)) });
66
71
  }
67
- function L({ loading: t, skeleton: r, label: d = "Loading", announce: e = !0, children: u, className: c }) {
68
- const [o, m] = y("");
69
- return S(() => {
70
- const n = setTimeout(() => m(t && e ? d : ""), t ? 50 : 0);
71
- return () => clearTimeout(n);
72
- }, [t, d, e]), /* @__PURE__ */ p(g, { children: [
73
- /* @__PURE__ */ s("span", { role: "status", className: "rst:sr-only", "data-skeleton-status": "", children: o }),
74
- /* @__PURE__ */ s("div", { "aria-busy": t || void 0, className: c, "data-skeleton-region": t ? "loading" : "ready", children: t ? /* @__PURE__ */ s("div", { "aria-hidden": "true", children: r }) : u })
72
+ function D({ loading: t, skeleton: r, label: d = "Loading", announce: s = !0, animation: m, children: o, className: h }) {
73
+ const n = y(x), [f, l] = w("");
74
+ return C(() => {
75
+ const k = setTimeout(() => l(t && s ? d : ""), t ? 50 : 0);
76
+ return () => clearTimeout(k);
77
+ }, [t, d, s]), /* @__PURE__ */ v(g, { children: [
78
+ /* @__PURE__ */ e("span", { role: "status", className: "rst:sr-only", "data-skeleton-status": "", children: f }),
79
+ /* @__PURE__ */ e("div", { "aria-busy": t || void 0, className: h, "data-skeleton-region": t ? "loading" : "ready", children: t ? /* @__PURE__ */ e(x.Provider, { value: m ?? n, children: /* @__PURE__ */ e("div", { "aria-hidden": "true", children: r }) }) : o })
75
80
  ] });
76
81
  }
77
82
  export {
78
- E as Skeleton,
79
- L as SkeletonRegion
83
+ j as Skeleton,
84
+ D as SkeletonRegion
80
85
  };
@@ -13,7 +13,7 @@ export interface ThemeToggleProps extends Omit<ButtonProps, "onClick" | "childre
13
13
  * opposite, because a button's name should say what pressing it does.
14
14
  *
15
15
  * Both take nodes, so a product with its own vocabulary for the two states
16
- * ("Press sheet" / "Blueline", "Day" / "Night") can say so.
16
+ * ("Paper" / "Chalkboard", "Day" / "Night") can say so.
17
17
  */
18
18
  lightLabel?: React.ReactNode;
19
19
  /** Visible text when the page is dark, if `showLabel` is set. */
@@ -45,7 +45,7 @@ export interface CheckboxGroupProps extends Omit<React.HTMLAttributes<HTMLFieldS
45
45
  * Caps the options' height and scrolls past it. A number is pixels.
46
46
  *
47
47
  * Applied inline rather than as a class because the useful values here are
48
- * arbitrary — `240` is mega-squad's, yours will differ — and an arbitrary
48
+ * arbitrary — `240` is one app's, yours will differ — and an arbitrary
49
49
  * Tailwind value built from a prop is a class that does not exist at build
50
50
  * time, which is exactly what `check-classes-emit` fails the build over.
51
51
  */
@@ -5,7 +5,7 @@
5
5
  * short list of three options wants to sit on the form the way a Select's
6
6
  * label and trigger do, with no chrome of its own.
7
7
  *
8
- * `panel` is the long-list case — the grouped, scrollable list mega-squad
8
+ * `panel` is the long-list case — the grouped, scrollable list one app
9
9
  * hand-rolled for its sports picker. It deliberately does NOT read
10
10
  * `--roster-popover-*`: that family is documented as "a panel that floats over
11
11
  * the page", and this one is in the flow.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),ge=require("react"),W=require("../../../node_modules/@headlessui/react/dist/components/portal/portal.cjs"),A=require("../../../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs"),E=require("../../../lib/utils.cjs"),he=require("../../../internal/popup.cjs"),be=require("../../atoms/Button/Button.cjs"),xe=require("./menu-typeahead.cjs"),ye=require("../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.cjs");function ve(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const i=ve(ge);function we({href:e,to:r,children:n,...o}){return c.jsx("a",{href:e,...o,children:n})}const G=i.createContext(null),_=i.createContext(null),V=i.createContext(null);function R(e){const r=i.useContext(G);if(!r)throw new Error(`<${e}> must be inside a <Menu>.`);return r}function K(e){const r=i.useContext(_);if(!r)throw new Error(`<${e}> must be inside <MenuItems> or a <MenuSubmenu>.`);return r}const ke="[data-menu-item]",Y=100,Ie=75,Ee='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"])';function L(e){return e?[...e.querySelectorAll(ke)].filter(r=>r.closest("[data-menu-panel]")===e):[]}function S(e){e&&(e.focus({preventScroll:!0}),e.scrollIntoView?.({block:"nearest"}))}function $(e){return!!e&&getComputedStyle(e).direction==="rtl"}function Se(e,r){const n=[...document.querySelectorAll(Ee)].filter(t=>t===e||t.tabIndex>=0&&!t.matches(":disabled")&&!t.closest("[data-menu-panel], [inert]")&&t.getClientRects().length>0&&getComputedStyle(t).visibility!=="hidden"&&!Me(t,r)),o=n.indexOf(e);((r?n[o-1]:n[o+1])??e).focus()}function Me(e,r){if(!(e instanceof HTMLInputElement)||e.type!=="radio"||!e.name)return!1;const n=[...e.ownerDocument.querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(a=>a.form===e.form&&!a.disabled);return(n.find(a=>a.checked)??(r?n[n.length-1]:n[0]))!==e}const D={x:Number.NaN,y:Number.NaN};let H=!1;function je(){H||typeof window>"u"||(H=!0,window.addEventListener("pointermove",e=>{D.x=e.clientX,D.y=e.clientY},{passive:!0}))}function X(e){return!Number.isNaN(D.x)&&(e.clientX!==D.x||e.clientY!==D.y)}const U=e=>`radial-gradient(farthest-side at 50% ${e==="top"?"0":"100%"}, var(--menu-edge), transparent)`,J={backgroundImage:"var(--menu-edge-top, none), var(--menu-edge-bottom, none)",backgroundPosition:"top, bottom",backgroundSize:"100% 0.5rem",backgroundRepeat:"no-repeat"};function Pe(e){i.useLayoutEffect(()=>{if(!e)return;const r=()=>{const o=e.scrollTop>8,a=e.scrollTop+e.clientHeight<e.scrollHeight-8;e.toggleAttribute("data-more-above",o),e.toggleAttribute("data-more-below",a),e.style.setProperty("--menu-edge-top",o?U("top"):"none"),e.style.setProperty("--menu-edge-bottom",a?U("bottom"):"none")};r(),e.addEventListener("scroll",r,{passive:!0});const n=typeof ResizeObserver>"u"?null:new ResizeObserver(r);return n?.observe(e),()=>{e.removeEventListener("scroll",r),n?.disconnect()}},[e])}function Q(e,r){const[n,o]=e.split("-"),a=r?"right":"left",t=r?"left":"right";return n==="top"||n==="bottom"?`${n==="bottom"?"top":"bottom"} ${o==="end"?t:o==="start"?a:"center"}`:`${o==="end"?"bottom":"top"} ${n==="right"?"left":"right"}`}const Z=E.cn("rst:font-ui",he.POPUP_PANEL,"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","rst:[--menu-edge:rgb(0_0_0/0.18)] rst:dark:[--menu-edge:rgb(0_0_0/0.6)]","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");function ee(e){const[r,n]=i.useState(e),[o,a]=i.useState(!0);return i.useLayoutEffect(()=>{if(e){n(!0);const s=requestAnimationFrame(()=>a(!1));return()=>cancelAnimationFrame(s)}a(!0);const t=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,d=window.setTimeout(()=>n(!1),t?0:Ie);return()=>window.clearTimeout(d)},[e]),{mounted:r,closed:o,leaving:r&&!e}}function te(e,r,n,o,a,t=!1){const[d,s]=i.useState(null),u=A.useFloating({open:r,strategy:"fixed",transform:!1,placement:n,elements:{reference:e},whileElementsMounted:ye.autoUpdate,middleware:[A.offset(o),A.flip({padding:8}),A.shift({padding:8,crossAxis:t}),A.size({padding:8,apply({availableHeight:f,elements:l}){l.floating.style.maxHeight=`min(var(--anchor-max-height, 100vh), ${Math.max(f,96)}px)`}})]}),{setFloating:p}=u.refs,m=i.useCallback(f=>{a.current=f,s(f),p(f)},[a,p]);return Pe(d),{...u,setPanel:m,panelEl:d}}const re=500;function ne(){const e=i.useRef({text:"",at:0}),r=i.useCallback(()=>e.current.text!==""&&performance.now()-e.current.at<=re,[]);return{typedRef:e,typingAhead:r}}function oe({panelRef:e,typedRef:r,onEscape:n,onBack:o}){const a=R("MenuItems");return t=>{const d=e.current;if(!d||!d.contains(t.target)||(!t.ctrlKey&&!t.metaKey&&!t.altKey&&t.stopPropagation(),t.defaultPrevented))return;const s=L(d),u=s.indexOf(document.activeElement),p=$(d);switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation(),S(s[(u+1)%s.length]);return;case"ArrowUp":t.preventDefault(),t.stopPropagation(),S(s[u<=0?s.length-1:u-1]);return;case"Home":case"PageUp":t.preventDefault(),t.stopPropagation(),S(s[0]);return;case"End":case"PageDown":t.preventDefault(),t.stopPropagation(),S(s[s.length-1]);return;case"Escape":t.preventDefault(),t.stopPropagation(),n();return;case"Tab":{t.preventDefault(),t.stopPropagation();const m=a.triggerRef.current;a.close(!1),m&&Se(m,t.shiftKey);return}case"ArrowLeft":case"ArrowRight":o&&t.key===(p?"ArrowRight":"ArrowLeft")&&(t.preventDefault(),t.stopPropagation(),o());return}if(t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey){const m=performance.now(),f=r.current.text!==""&&m-r.current.at<=re;if(t.key===" "&&!f)return;t.preventDefault(),r.current={text:f?r.current.text+t.key:t.key,at:m};const l=s.map(w=>w.dataset.menuText??w.textContent??""),b=xe.nextByTypeahead(l,u,r.current.text);b!==-1&&S(s[b])}}}function Te({children:e,open:r,onOpenChange:n,linkComponent:o=we}){const[a,t]=i.useState(!1),d=r??a,s=i.useId(),u=i.useRef(null),[p,m]=i.useState(null),f=i.useCallback(g=>{u.current=g,m(g)},[]),l=i.useRef("panel"),b=i.useCallback(g=>{r===void 0&&t(g),n?.(g)},[r,n]),w=i.useMemo(()=>({treeId:s,open:d,openWith:g=>{l.current=g,b(!0)},close:g=>{b(!1),g&&u.current?.focus()},triggerRef:u,triggerEl:p,registerTrigger:f,triggerId:`${s}-button`,panelId:`${s}-menu`,focusOnOpen:l,linkComponent:o}),[s,d,b,o,p,f]);return i.useEffect(()=>{if(!d)return;je();const g=I=>{I.target?.closest?.(`[data-menu-tree="${s}"]`)||(b(!1),requestAnimationFrame(()=>{(document.activeElement===document.body||!document.activeElement)&&u.current?.focus({preventScroll:!0})}))};return document.addEventListener("pointerdown",g,!0),()=>document.removeEventListener("pointerdown",g,!0)},[d,s,b]),c.jsx(G.Provider,{value:w,children:e})}const Re=i.forwardRef(function({plain:r=!1,className:n,onClick:o,onKeyDown:a,children:t,...d},s){const{variant:u,colorScheme:p,size:m,isLoading:f,loadingLabel:l,startIcon:b,endIcon:w,surface:g,...I}=d,h=R("MenuButton"),{registerTrigger:M}=h,j=i.useCallback(x=>{M(x),typeof s=="function"?s(x):s&&(s.current=x)},[M,s]),P={id:h.triggerId,"aria-haspopup":"menu","aria-expanded":h.open,"aria-controls":h.open?h.panelId:void 0,"data-menu-tree":h.treeId,onClick:x=>{o?.(x),!x.defaultPrevented&&(h.open?h.close(!1):h.openWith("panel"))},onKeyDown:x=>{if(a?.(x),x.defaultPrevented)return;const y=x.key==="Enter"||x.key===" "||x.key==="ArrowDown"?"first":x.key==="ArrowUp"?"last":null;if(!y)return;x.preventDefault();const k=h.open?document.getElementById(h.panelId):null;if(k){const C=L(k);S(y==="last"?C[C.length-1]:C[0]);return}h.openWith(y)}};return r?c.jsx("button",{ref:j,type:"button",className:n,...I,...P,children:t}):c.jsx(be.Button,{ref:j,className:E.cn("rst:min-h-11 rst:min-w-11",n),variant:u,colorScheme:p,size:m,isLoading:f,loadingLabel:l,startIcon:b,endIcon:w,surface:g,...I,...P,children:t})});function Ce({children:e,align:r="start",offset:n=4,className:o,...a}){const t=R("MenuItems"),{mounted:d,closed:s,leaving:u}=ee(t.open),p=i.useRef(null),m=$(t.triggerEl),{setPanel:f,panelEl:l,floatingStyles:b,placement:w,isPositioned:g}=te(t.triggerEl,d,`bottom-${r}`,n,p),I=se(),{typedRef:h,typingAhead:M}=ne(),j=oe({panelRef:p,typedRef:h,onEscape:()=>t.close(!0)});i.useLayoutEffect(()=>{if(!t.open||!l)return;const y=L(l),k=t.focusOnOpen.current;k==="first"&&y[0]?S(y[0]):k==="last"&&y.length?S(y[y.length-1]):l.focus({preventScroll:!0})},[t.open,l,t.focusOnOpen]),i.useLayoutEffect(()=>{if(!g||!l)return;const y=document.activeElement;y&&y!==l&&l.contains(y)&&y.scrollIntoView?.({block:"nearest"})},[g,l]),i.useLayoutEffect(()=>{!t.open&&l?.contains(document.activeElement)&&t.triggerRef.current?.focus({preventScroll:!0})},[t.open,l,t.triggerRef]);const P=y=>{const k=y.relatedTarget;k&&!k.closest(`[data-menu-tree="${t.treeId}"]`)&&t.close(!1)};if(!d)return null;const x=!!t.triggerEl?.closest(".dark");return c.jsx(W.Portal,{children:c.jsx(_.Provider,{value:{...I,panelRef:p,typingAhead:M},children:c.jsx("div",{ref:f,id:t.panelId,dir:m?"rtl":"ltr",role:"menu","aria-labelledby":a["aria-label"]?void 0:t.triggerId,"aria-label":a["aria-label"],tabIndex:-1,"data-menu-panel":"","data-menu-tree":t.treeId,"data-closed":s?"":void 0,"data-leaving":u?"":void 0,onKeyDown:j,onBlur:P,style:{...b,...J,transformOrigin:Q(w,m)},className:E.cn(x&&"dark",Z,o),children:e})})})}function se(){const[e,r]=i.useState(null),n=i.useRef(!1),o=i.useRef(void 0);return i.useEffect(()=>()=>window.clearTimeout(o.current),[]),{openSubmenu:e,focusFirstInSubmenu:n,setOpenSubmenu:(a,t=!1)=>{window.clearTimeout(o.current),n.current=t,r(a)},hoverItem:a=>{window.clearTimeout(o.current),a===null&&(o.current=window.setTimeout(()=>r(null),Y))}}}const O=E.cn("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","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","rst:aria-disabled:opacity-50 rst:aria-disabled:cursor-not-allowed"),q="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",Ae=()=>c.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:c.jsx("path",{d:"M3.5 8.5 6.5 11.5 12.5 4.5"})}),De=()=>c.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true",children:c.jsx("circle",{cx:"8",cy:"8",r:"3.5",fill:"currentColor"})}),Le=()=>c.jsx("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:c.jsx("path",{d:"M6 3.5 10.5 8 6 12.5"})});function T({icon:e,shortcut:r,description:n,badge:o,children:a},t,d,s){const u=t??e;return c.jsxs(c.Fragment,{children:[u!=null&&c.jsx("span",{"aria-hidden":"true",className:E.cn("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}),c.jsxs("span",{className:"rst:min-w-0 rst:flex-1 rst:break-words","data-menu-label":"",children:[a,n!=null&&c.jsx("span",{id:s,"aria-hidden":"true",className:"rst:block rst:text-xs rst:opacity-75","data-menu-description":"",children:n})]}),o!=null&&c.jsx("span",{className:"rst:flex rst:shrink-0 rst:items-center","data-menu-badge":"",children:o}),r&&c.jsx("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}),d]})}function z({disabled:e,closeOnSelect:r,onChoose:n,spaceKeepsOpen:o}){const a=R("MenuItem"),t=K("MenuItem"),d=(s,u)=>{if(e){s.preventDefault();return}n(s),u&&a.close(!0)};return{onClick:s=>d(s,r),onKeyDown:s=>{if(s.key===" "){if(t.typingAhead())return;s.preventDefault(),d(s,r&&!o)}},onPointerMove:s=>{X(s)&&(t.hoverItem(null),document.activeElement!==s.currentTarget&&s.currentTarget.focus({preventScroll:!0}))}}}function Oe({onSelect:e,href:r,closeOnSelect:n=!0,disabled:o,destructive:a,keyshortcuts:t,textValue:d,className:s,...u}){const p=R("MenuItem"),m=K("MenuItem"),f=i.useId(),l=z({disabled:o,closeOnSelect:n,onChoose:g=>e?.(g)}),b=E.cn(O,a&&q,s),w={role:"menuitem",tabIndex:-1,"aria-disabled":o?!0:void 0,"aria-keyshortcuts":t,"aria-describedby":u.description!=null?f:void 0,"data-menu-item":"","data-menu-text":d,"data-destructive":a?"":void 0};if(r!==void 0){const g=p.linkComponent;return c.jsx(g,{href:r,to:r,className:b,...w,onClick:l.onClick,onPointerMove:l.onPointerMove,onKeyDown:I=>{if(I.key===" "){if(m.typingAhead())return;I.preventDefault(),o||I.currentTarget.click()}},children:T(u,void 0,void 0,f)})}return c.jsx("button",{type:"button",className:b,...w,...l,children:T(u,void 0,void 0,f)})}function Ne({checked:e,onCheckedChange:r,indicator:n,closeOnSelect:o=!0,disabled:a,destructive:t,keyshortcuts:d,textValue:s,className:u,...p}){const m=z({disabled:a,closeOnSelect:o,spaceKeepsOpen:!0,onChoose:()=>r(!e)}),f=i.useId();return c.jsx("button",{type:"button",role:"menuitemcheckbox","aria-checked":e,"aria-describedby":p.description!=null?f:void 0,tabIndex:-1,"aria-disabled":a||void 0,"aria-keyshortcuts":d,"data-menu-item":"","data-menu-text":s,className:E.cn(O,t&&q,u),...m,children:n===void 0?T(p,c.jsx("span",{className:e?void 0:"rst:invisible","data-menu-check":"",children:c.jsx(Ae,{})}),void 0,f):T(p,void 0,c.jsx("span",{"aria-hidden":"true",className:"rst:ms-auto rst:flex rst:shrink-0 rst:items-center",children:n}),f)})}function Be({value:e,onValueChange:r,label:n,children:o,className:a}){return c.jsx(V.Provider,{value:{value:e,onValueChange:r},children:c.jsx(ae,{label:n,className:a,children:o})})}function _e({value:e,closeOnSelect:r=!0,disabled:n,destructive:o,keyshortcuts:a,textValue:t,className:d,...s}){const u=i.useContext(V);if(!u)throw new Error("<MenuRadioItem> must be inside a <MenuRadioGroup>.");const p=u.value===e,m=z({disabled:n,closeOnSelect:r,spaceKeepsOpen:!0,onChoose:()=>u.onValueChange?.(e)}),f=i.useId();return c.jsx("button",{type:"button",role:"menuitemradio","aria-checked":p,"aria-describedby":s.description!=null?f:void 0,tabIndex:-1,"aria-disabled":n||void 0,"aria-keyshortcuts":a,"data-menu-item":"","data-menu-text":t,className:E.cn(O,o&&q,d),...m,children:T(s,c.jsx("span",{className:p?void 0:"rst:invisible","data-menu-check":"",children:c.jsx(De,{})}),void 0,f)})}function ae({label:e,children:r,className:n}){const o=i.useId();return c.jsxs("div",{role:"group","aria-labelledby":e?o:void 0,className:n,children:[e&&c.jsx("div",{id:o,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","data-menu-heading":"",children:e}),r]})}function Ke({className:e}){return c.jsx("div",{role:"separator",className:E.cn("rst:my-1 rst:h-[var(--roster-border-width,1px)] rst:bg-[var(--roster-popover-border)]",e)})}function $e({label:e,children:r,icon:n,disabled:o,textValue:a,className:t,panelClassName:d}){const s=R("MenuSubmenu"),u=K("MenuSubmenu"),p=i.useId(),m=`${p}-item`,f=`${p}-menu`,l=u.openSubmenu===m,b=i.useRef(null),[w,g]=i.useState(null),I=i.useCallback(v=>{b.current=v,g(v)},[]),h=i.useRef(null),M=i.useRef(void 0),j=i.useRef("mouse"),{mounted:P,closed:x,leaving:y}=ee(l),k=$(w),{setPanel:C,panelEl:N,floatingStyles:ie,placement:ue}=te(w,P,k?"left-start":"right-start",{mainAxis:0,alignmentAxis:-4},h,!0),ce=se();i.useEffect(()=>()=>window.clearTimeout(M.current),[]);const F=()=>{u.setOpenSubmenu(null),b.current?.focus({preventScroll:!0})},{typedRef:le,typingAhead:de}=ne(),fe=oe({panelRef:h,typedRef:le,onEscape:F,onBack:F});i.useLayoutEffect(()=>{!l||!N||u.focusFirstInSubmenu.current&&S(L(N)[0])},[l,N,u.focusFirstInSubmenu]);const B=v=>{if(!o){if(l&&v&&h.current){S(L(h.current)[0]);return}u.setOpenSubmenu(m,v)}},me=!!s.triggerEl?.closest(".dark");return c.jsxs(c.Fragment,{children:[c.jsx("button",{ref:I,id:m,type:"button",role:"menuitem",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?f:void 0,"aria-disabled":o||void 0,"data-menu-item":"","data-menu-text":a,"data-menu-tree":s.treeId,className:E.cn(O,l&&"rst:bg-gray-100 rst:dark:bg-gray-700/50",t),onPointerDown:v=>{j.current=v.pointerType},onClick:()=>l&&j.current!=="mouse"?u.setOpenSubmenu(null):B(!1),onKeyDown:v=>{const pe=k?"ArrowLeft":"ArrowRight";v.key===" "&&u.typingAhead()||(v.key===pe||v.key==="Enter"||v.key===" ")&&(v.preventDefault(),B(!0))},onPointerMove:v=>{X(v)&&(u.hoverItem(m),document.activeElement!==v.currentTarget&&v.currentTarget.focus({preventScroll:!0}),!l&&!o&&(window.clearTimeout(M.current),M.current=window.setTimeout(()=>B(!1),Y)))},onPointerLeave:()=>window.clearTimeout(M.current),children:T({icon:n,children:e},void 0,c.jsx("span",{"aria-hidden":"true",className:"rst:ms-auto rst:flex rst:shrink-0 rst:items-center rst:opacity-70","data-menu-chevron":"",children:c.jsx(Le,{})}))}),P&&c.jsx(W.Portal,{children:c.jsx(_.Provider,{value:{...ce,panelRef:h,typingAhead:de},children:c.jsx("div",{ref:C,id:f,dir:k?"rtl":"ltr",role:"menu","aria-labelledby":m,tabIndex:-1,"data-menu-panel":"","data-menu-tree":s.treeId,"data-closed":x?"":void 0,"data-leaving":y?"":void 0,onKeyDown:fe,onPointerEnter:()=>u.hoverItem(m),style:{...ie,...J,transformOrigin:Q(ue,k)},className:E.cn(me&&"dark",Z,d),children:r})})})]})}exports.Menu=Te;exports.MenuButton=Re;exports.MenuCheckboxItem=Ne;exports.MenuGroup=ae;exports.MenuItem=Oe;exports.MenuItems=Ce;exports.MenuRadioGroup=Be;exports.MenuRadioItem=_e;exports.MenuSeparator=Ke;exports.MenuSubmenu=$e;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),ge=require("react"),W=require("../../../node_modules/@headlessui/react/dist/components/portal/portal.cjs"),C=require("../../../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs"),S=require("../../../lib/utils.cjs"),he=require("../../../internal/popup.cjs"),be=require("../../atoms/Button/Button.cjs"),xe=require("./menu-typeahead.cjs"),ye=require("../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.cjs");function ve(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const i=ve(ge);function we({href:e,to:r,children:n,...o}){return c.jsx("a",{href:e,...o,children:n})}const G=i.createContext(null),_=i.createContext(null),V=i.createContext(null);function A(e){const r=i.useContext(G);if(!r)throw new Error(`<${e}> must be inside a <Menu>.`);return r}function K(e){const r=i.useContext(_);if(!r)throw new Error(`<${e}> must be inside <MenuItems> or a <MenuSubmenu>.`);return r}const ke="[data-menu-item]",Y=100,Ie=75,Ee='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"])';function L(e){return e?[...e.querySelectorAll(ke)].filter(r=>r.closest("[data-menu-panel]")===e):[]}function E(e){e&&(e.setAttribute("data-key-focus",""),e.addEventListener("blur",()=>e.removeAttribute("data-key-focus"),{once:!0}),e.focus({preventScroll:!0}),e.scrollIntoView?.({block:"nearest"}))}function $(e){return!!e&&getComputedStyle(e).direction==="rtl"}function Se(e,r){const n=[...document.querySelectorAll(Ee)].filter(t=>t===e||t.tabIndex>=0&&!t.matches(":disabled")&&!t.closest("[data-menu-panel], [inert]")&&t.getClientRects().length>0&&getComputedStyle(t).visibility!=="hidden"&&!Me(t,r)),o=n.indexOf(e);((r?n[o-1]:n[o+1])??e).focus()}function Me(e,r){if(!(e instanceof HTMLInputElement)||e.type!=="radio"||!e.name)return!1;const n=[...e.ownerDocument.querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(a=>a.form===e.form&&!a.disabled);return(n.find(a=>a.checked)??(r?n[n.length-1]:n[0]))!==e}const D={x:Number.NaN,y:Number.NaN};let H=!1;function je(){H||typeof window>"u"||(H=!0,window.addEventListener("pointermove",e=>{D.x=e.clientX,D.y=e.clientY},{passive:!0}))}function X(e){return!Number.isNaN(D.x)&&(e.clientX!==D.x||e.clientY!==D.y)}const U=e=>`radial-gradient(farthest-side at 50% ${e==="top"?"0":"100%"}, var(--menu-edge), transparent)`,J={backgroundImage:"var(--menu-edge-top, none), var(--menu-edge-bottom, none)",backgroundPosition:"top, bottom",backgroundSize:"100% 0.5rem",backgroundRepeat:"no-repeat"};function Pe(e){i.useLayoutEffect(()=>{if(!e)return;const r=()=>{const o=e.scrollTop>8,a=e.scrollTop+e.clientHeight<e.scrollHeight-8;e.toggleAttribute("data-more-above",o),e.toggleAttribute("data-more-below",a),e.style.setProperty("--menu-edge-top",o?U("top"):"none"),e.style.setProperty("--menu-edge-bottom",a?U("bottom"):"none")};r(),e.addEventListener("scroll",r,{passive:!0});const n=typeof ResizeObserver>"u"?null:new ResizeObserver(r);return n?.observe(e),()=>{e.removeEventListener("scroll",r),n?.disconnect()}},[e])}function Q(e,r){const[n,o]=e.split("-"),a=r?"right":"left",t=r?"left":"right";return n==="top"||n==="bottom"?`${n==="bottom"?"top":"bottom"} ${o==="end"?t:o==="start"?a:"center"}`:`${o==="end"?"bottom":"top"} ${n==="right"?"left":"right"}`}const Z=S.cn("rst:font-ui",he.POPUP_PANEL,"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","rst:[--menu-edge:rgb(0_0_0/0.18)] rst:dark:[--menu-edge:rgb(0_0_0/0.6)]","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");function ee(e){const[r,n]=i.useState(e),[o,a]=i.useState(!0);return i.useLayoutEffect(()=>{if(e){n(!0);const s=requestAnimationFrame(()=>a(!1));return()=>cancelAnimationFrame(s)}a(!0);const t=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,d=window.setTimeout(()=>n(!1),t?0:Ie);return()=>window.clearTimeout(d)},[e]),{mounted:r,closed:o,leaving:r&&!e}}function te(e,r,n,o,a,t=!1){const[d,s]=i.useState(null),u=C.useFloating({open:r,strategy:"fixed",transform:!1,placement:n,elements:{reference:e},whileElementsMounted:ye.autoUpdate,middleware:[C.offset(o),C.flip({padding:8}),C.shift({padding:8,crossAxis:t}),C.size({padding:8,apply({availableHeight:f,elements:l}){l.floating.style.maxHeight=`min(var(--anchor-max-height, 100vh), ${Math.max(f,96)}px)`}})]}),{setFloating:p}=u.refs,m=i.useCallback(f=>{a.current=f,s(f),p(f)},[a,p]);return Pe(d),{...u,setPanel:m,panelEl:d}}const re=500;function ne(){const e=i.useRef({text:"",at:0}),r=i.useCallback(()=>e.current.text!==""&&performance.now()-e.current.at<=re,[]);return{typedRef:e,typingAhead:r}}function oe({panelRef:e,typedRef:r,onEscape:n,onBack:o}){const a=A("MenuItems");return t=>{const d=e.current;if(!d||!d.contains(t.target)||(!t.ctrlKey&&!t.metaKey&&!t.altKey&&t.stopPropagation(),t.defaultPrevented))return;const s=L(d),u=s.indexOf(document.activeElement),p=$(d);switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation(),E(s[(u+1)%s.length]);return;case"ArrowUp":t.preventDefault(),t.stopPropagation(),E(s[u<=0?s.length-1:u-1]);return;case"Home":case"PageUp":t.preventDefault(),t.stopPropagation(),E(s[0]);return;case"End":case"PageDown":t.preventDefault(),t.stopPropagation(),E(s[s.length-1]);return;case"Escape":t.preventDefault(),t.stopPropagation(),n();return;case"Tab":{t.preventDefault(),t.stopPropagation();const m=a.triggerRef.current;a.close(!1),m&&Se(m,t.shiftKey);return}case"ArrowLeft":case"ArrowRight":o&&t.key===(p?"ArrowRight":"ArrowLeft")&&(t.preventDefault(),t.stopPropagation(),o());return}if(t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey){const m=performance.now(),f=r.current.text!==""&&m-r.current.at<=re;if(t.key===" "&&!f)return;t.preventDefault(),r.current={text:f?r.current.text+t.key:t.key,at:m};const l=s.map(w=>w.dataset.menuText??w.textContent??""),b=xe.nextByTypeahead(l,u,r.current.text);b!==-1&&E(s[b])}}}function Te({children:e,open:r,onOpenChange:n,linkComponent:o=we}){const[a,t]=i.useState(!1),d=r??a,s=i.useId(),u=i.useRef(null),[p,m]=i.useState(null),f=i.useCallback(g=>{u.current=g,m(g)},[]),l=i.useRef("panel"),b=i.useCallback(g=>{r===void 0&&t(g),n?.(g)},[r,n]),w=i.useMemo(()=>({treeId:s,open:d,openWith:g=>{l.current=g,b(!0)},close:g=>{b(!1),g&&u.current?.focus()},triggerRef:u,triggerEl:p,registerTrigger:f,triggerId:`${s}-button`,panelId:`${s}-menu`,focusOnOpen:l,linkComponent:o}),[s,d,b,o,p,f]);return i.useEffect(()=>{if(!d)return;je();const g=I=>{I.target?.closest?.(`[data-menu-tree="${s}"]`)||(b(!1),requestAnimationFrame(()=>{(document.activeElement===document.body||!document.activeElement)&&u.current?.focus({preventScroll:!0})}))};return document.addEventListener("pointerdown",g,!0),()=>document.removeEventListener("pointerdown",g,!0)},[d,s,b]),c.jsx(G.Provider,{value:w,children:e})}const Ae=i.forwardRef(function({plain:r=!1,className:n,onClick:o,onKeyDown:a,children:t,...d},s){const{variant:u,colorScheme:p,size:m,isLoading:f,loadingLabel:l,startIcon:b,endIcon:w,surface:g,...I}=d,h=A("MenuButton"),{registerTrigger:M}=h,j=i.useCallback(x=>{M(x),typeof s=="function"?s(x):s&&(s.current=x)},[M,s]),P={id:h.triggerId,"aria-haspopup":"menu","aria-expanded":h.open,"aria-controls":h.open?h.panelId:void 0,"data-menu-tree":h.treeId,onClick:x=>{o?.(x),!x.defaultPrevented&&(h.open?h.close(!1):h.openWith("panel"))},onKeyDown:x=>{if(a?.(x),x.defaultPrevented)return;const y=x.key==="Enter"||x.key===" "||x.key==="ArrowDown"?"first":x.key==="ArrowUp"?"last":null;if(!y)return;x.preventDefault();const k=h.open?document.getElementById(h.panelId):null;if(k){const R=L(k);E(y==="last"?R[R.length-1]:R[0]);return}h.openWith(y)}};return r?c.jsx("button",{ref:j,type:"button",className:n,...I,...P,children:t}):c.jsx(be.Button,{ref:j,className:S.cn("rst:min-h-11 rst:min-w-11",n),variant:u,colorScheme:p,size:m,isLoading:f,loadingLabel:l,startIcon:b,endIcon:w,surface:g,...I,...P,children:t})});function Re({children:e,align:r="start",offset:n=4,className:o,...a}){const t=A("MenuItems"),{mounted:d,closed:s,leaving:u}=ee(t.open),p=i.useRef(null),m=$(t.triggerEl),{setPanel:f,panelEl:l,floatingStyles:b,placement:w,isPositioned:g}=te(t.triggerEl,d,`bottom-${r}`,n,p),I=se(),{typedRef:h,typingAhead:M}=ne(),j=oe({panelRef:p,typedRef:h,onEscape:()=>t.close(!0)});i.useLayoutEffect(()=>{if(!t.open||!l)return;const y=L(l),k=t.focusOnOpen.current;k==="first"&&y[0]?E(y[0]):k==="last"&&y.length?E(y[y.length-1]):l.focus({preventScroll:!0})},[t.open,l,t.focusOnOpen]),i.useLayoutEffect(()=>{if(!g||!l)return;const y=document.activeElement;y&&y!==l&&l.contains(y)&&y.scrollIntoView?.({block:"nearest"})},[g,l]),i.useLayoutEffect(()=>{!t.open&&l?.contains(document.activeElement)&&t.triggerRef.current?.focus({preventScroll:!0})},[t.open,l,t.triggerRef]);const P=y=>{const k=y.relatedTarget;k&&!k.closest(`[data-menu-tree="${t.treeId}"]`)&&t.close(!1)};if(!d)return null;const x=!!t.triggerEl?.closest(".dark");return c.jsx(W.Portal,{children:c.jsx(_.Provider,{value:{...I,panelRef:p,typingAhead:M},children:c.jsx("div",{ref:f,id:t.panelId,dir:m?"rtl":"ltr",role:"menu","aria-labelledby":a["aria-label"]?void 0:t.triggerId,"aria-label":a["aria-label"],tabIndex:-1,"data-menu-panel":"","data-menu-tree":t.treeId,"data-closed":s?"":void 0,"data-leaving":u?"":void 0,onKeyDown:j,onBlur:P,style:{...b,...J,transformOrigin:Q(w,m)},className:S.cn(x&&"dark",Z,o),children:e})})})}function se(){const[e,r]=i.useState(null),n=i.useRef(!1),o=i.useRef(void 0);return i.useEffect(()=>()=>window.clearTimeout(o.current),[]),{openSubmenu:e,focusFirstInSubmenu:n,setOpenSubmenu:(a,t=!1)=>{window.clearTimeout(o.current),n.current=t,r(a)},hoverItem:a=>{window.clearTimeout(o.current),a===null&&(o.current=window.setTimeout(()=>r(null),Y))}}}const O=S.cn("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","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","rst:data-key-focus:ring-2 rst:data-key-focus:ring-inset rst:data-key-focus:ring-ring","rst:aria-disabled:opacity-50 rst:aria-disabled:cursor-not-allowed"),q="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",Ce=()=>c.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:c.jsx("path",{d:"M3.5 8.5 6.5 11.5 12.5 4.5"})}),De=()=>c.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true",children:c.jsx("circle",{cx:"8",cy:"8",r:"3.5",fill:"currentColor"})}),Le=()=>c.jsx("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:c.jsx("path",{d:"M6 3.5 10.5 8 6 12.5"})});function T({icon:e,shortcut:r,description:n,badge:o,children:a},t,d,s){const u=t??e;return c.jsxs(c.Fragment,{children:[u!=null&&c.jsx("span",{"aria-hidden":"true",className:S.cn("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}),c.jsxs("span",{className:"rst:min-w-0 rst:flex-1 rst:break-words","data-menu-label":"",children:[a,n!=null&&c.jsx("span",{id:s,"aria-hidden":"true",className:"rst:block rst:text-xs rst:opacity-75","data-menu-description":"",children:n})]}),o!=null&&c.jsx("span",{className:"rst:flex rst:shrink-0 rst:items-center","data-menu-badge":"",children:o}),r&&c.jsx("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}),d]})}function z({disabled:e,closeOnSelect:r,onChoose:n,spaceKeepsOpen:o}){const a=A("MenuItem"),t=K("MenuItem"),d=(s,u)=>{if(e){s.preventDefault();return}n(s),u&&a.close(!0)};return{onClick:s=>d(s,r),onKeyDown:s=>{if(s.key===" "){if(t.typingAhead())return;s.preventDefault(),d(s,r&&!o)}},onPointerMove:s=>{X(s)&&(t.hoverItem(null),document.activeElement!==s.currentTarget&&s.currentTarget.focus({preventScroll:!0}))}}}function Oe({onSelect:e,href:r,closeOnSelect:n=!0,disabled:o,destructive:a,keyshortcuts:t,textValue:d,className:s,...u}){const p=A("MenuItem"),m=K("MenuItem"),f=i.useId(),l=z({disabled:o,closeOnSelect:n,onChoose:g=>e?.(g)}),b=S.cn(O,a&&q,s),w={role:"menuitem",tabIndex:-1,"aria-disabled":o?!0:void 0,"aria-keyshortcuts":t,"aria-describedby":u.description!=null?f:void 0,"data-menu-item":"","data-menu-text":d,"data-destructive":a?"":void 0};if(r!==void 0){const g=p.linkComponent;return c.jsx(g,{href:r,to:r,className:b,...w,onClick:l.onClick,onPointerMove:l.onPointerMove,onKeyDown:I=>{if(I.key===" "){if(m.typingAhead())return;I.preventDefault(),o||I.currentTarget.click()}},children:T(u,void 0,void 0,f)})}return c.jsx("button",{type:"button",className:b,...w,...l,children:T(u,void 0,void 0,f)})}function Ne({checked:e,onCheckedChange:r,indicator:n,closeOnSelect:o=!0,disabled:a,destructive:t,keyshortcuts:d,textValue:s,className:u,...p}){const m=z({disabled:a,closeOnSelect:o,spaceKeepsOpen:!0,onChoose:()=>r(!e)}),f=i.useId();return c.jsx("button",{type:"button",role:"menuitemcheckbox","aria-checked":e,"aria-describedby":p.description!=null?f:void 0,tabIndex:-1,"aria-disabled":a||void 0,"aria-keyshortcuts":d,"data-menu-item":"","data-menu-text":s,className:S.cn(O,t&&q,u),...m,children:n===void 0?T(p,c.jsx("span",{className:e?void 0:"rst:invisible","data-menu-check":"",children:c.jsx(Ce,{})}),void 0,f):T(p,void 0,c.jsx("span",{"aria-hidden":"true",className:"rst:ms-auto rst:flex rst:shrink-0 rst:items-center",children:n}),f)})}function Be({value:e,onValueChange:r,label:n,children:o,className:a}){return c.jsx(V.Provider,{value:{value:e,onValueChange:r},children:c.jsx(ae,{label:n,className:a,children:o})})}function _e({value:e,closeOnSelect:r=!0,disabled:n,destructive:o,keyshortcuts:a,textValue:t,className:d,...s}){const u=i.useContext(V);if(!u)throw new Error("<MenuRadioItem> must be inside a <MenuRadioGroup>.");const p=u.value===e,m=z({disabled:n,closeOnSelect:r,spaceKeepsOpen:!0,onChoose:()=>u.onValueChange?.(e)}),f=i.useId();return c.jsx("button",{type:"button",role:"menuitemradio","aria-checked":p,"aria-describedby":s.description!=null?f:void 0,tabIndex:-1,"aria-disabled":n||void 0,"aria-keyshortcuts":a,"data-menu-item":"","data-menu-text":t,className:S.cn(O,o&&q,d),...m,children:T(s,c.jsx("span",{className:p?void 0:"rst:invisible","data-menu-check":"",children:c.jsx(De,{})}),void 0,f)})}function ae({label:e,children:r,className:n}){const o=i.useId();return c.jsxs("div",{role:"group","aria-labelledby":e?o:void 0,className:n,children:[e&&c.jsx("div",{id:o,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","data-menu-heading":"",children:e}),r]})}function Ke({className:e}){return c.jsx("div",{role:"separator",className:S.cn("rst:my-1 rst:h-[var(--roster-border-width,1px)] rst:bg-[var(--roster-popover-border)]",e)})}function $e({label:e,children:r,icon:n,disabled:o,textValue:a,className:t,panelClassName:d}){const s=A("MenuSubmenu"),u=K("MenuSubmenu"),p=i.useId(),m=`${p}-item`,f=`${p}-menu`,l=u.openSubmenu===m,b=i.useRef(null),[w,g]=i.useState(null),I=i.useCallback(v=>{b.current=v,g(v)},[]),h=i.useRef(null),M=i.useRef(void 0),j=i.useRef("mouse"),{mounted:P,closed:x,leaving:y}=ee(l),k=$(w),{setPanel:R,panelEl:N,floatingStyles:ie,placement:ue}=te(w,P,k?"left-start":"right-start",{mainAxis:0,alignmentAxis:-4},h,!0),ce=se();i.useEffect(()=>()=>window.clearTimeout(M.current),[]);const F=()=>{u.setOpenSubmenu(null),E(b.current)},{typedRef:le,typingAhead:de}=ne(),fe=oe({panelRef:h,typedRef:le,onEscape:F,onBack:F});i.useLayoutEffect(()=>{!l||!N||u.focusFirstInSubmenu.current&&E(L(N)[0])},[l,N,u.focusFirstInSubmenu]);const B=v=>{if(!o){if(l&&v&&h.current){E(L(h.current)[0]);return}u.setOpenSubmenu(m,v)}},me=!!s.triggerEl?.closest(".dark");return c.jsxs(c.Fragment,{children:[c.jsx("button",{ref:I,id:m,type:"button",role:"menuitem",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?f:void 0,"aria-disabled":o||void 0,"data-menu-item":"","data-menu-text":a,"data-menu-tree":s.treeId,className:S.cn(O,l&&"rst:bg-gray-100 rst:dark:bg-gray-700/50",t),onPointerDown:v=>{j.current=v.pointerType},onClick:()=>l&&j.current!=="mouse"?u.setOpenSubmenu(null):B(!1),onKeyDown:v=>{const pe=k?"ArrowLeft":"ArrowRight";v.key===" "&&u.typingAhead()||(v.key===pe||v.key==="Enter"||v.key===" ")&&(v.preventDefault(),B(!0))},onPointerMove:v=>{X(v)&&(u.hoverItem(m),document.activeElement!==v.currentTarget&&v.currentTarget.focus({preventScroll:!0}),!l&&!o&&(window.clearTimeout(M.current),M.current=window.setTimeout(()=>B(!1),Y)))},onPointerLeave:()=>window.clearTimeout(M.current),children:T({icon:n,children:e},void 0,c.jsx("span",{"aria-hidden":"true",className:"rst:ms-auto rst:flex rst:shrink-0 rst:items-center rst:opacity-70","data-menu-chevron":"",children:c.jsx(Le,{})}))}),P&&c.jsx(W.Portal,{children:c.jsx(_.Provider,{value:{...ce,panelRef:h,typingAhead:de},children:c.jsx("div",{ref:R,id:f,dir:k?"rtl":"ltr",role:"menu","aria-labelledby":m,tabIndex:-1,"data-menu-panel":"","data-menu-tree":s.treeId,"data-closed":x?"":void 0,"data-leaving":y?"":void 0,onKeyDown:fe,onPointerEnter:()=>u.hoverItem(m),style:{...ie,...J,transformOrigin:Q(ue,k)},className:S.cn(me&&"dark",Z,d),children:r})})})]})}exports.Menu=Te;exports.MenuButton=Ae;exports.MenuCheckboxItem=Ne;exports.MenuGroup=ae;exports.MenuItem=Oe;exports.MenuItems=Re;exports.MenuRadioGroup=Be;exports.MenuRadioItem=_e;exports.MenuSeparator=Ke;exports.MenuSubmenu=$e;
@@ -3,7 +3,7 @@ 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
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";
6
+ import { cn as S } from "../../../lib/utils.js";
7
7
  import { POPUP_PANEL as we } from "../../../internal/popup.js";
8
8
  import { Button as xe } from "../../atoms/Button/Button.js";
9
9
  import { nextByTypeahead as ke } from "./menu-typeahead.js";
@@ -23,41 +23,41 @@ function _(e) {
23
23
  return r;
24
24
  }
25
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) {
26
+ function D(e) {
27
27
  return e ? [...e.querySelectorAll(Se)].filter((r) => r.closest("[data-menu-panel]") === e) : [];
28
28
  }
29
- function S(e) {
30
- e && (e.focus({ preventScroll: !0 }), e.scrollIntoView?.({ block: "nearest" }));
29
+ function E(e) {
30
+ 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
31
  }
32
32
  function z(e) {
33
33
  return !!e && getComputedStyle(e).direction === "rtl";
34
34
  }
35
- function Te(e, r) {
35
+ function Ae(e, r) {
36
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)
37
+ (t) => t === e || t.tabIndex >= 0 && !t.matches(":disabled") && !t.closest("[data-menu-panel], [inert]") && t.getClientRects().length > 0 && getComputedStyle(t).visibility !== "hidden" && !Te(t, r)
38
38
  ), s = n.indexOf(e);
39
39
  ((r ? n[s - 1] : n[s + 1]) ?? e).focus();
40
40
  }
41
- function Ae(e, r) {
41
+ function Te(e, r) {
42
42
  if (!(e instanceof HTMLInputElement) || e.type !== "radio" || !e.name) return !1;
43
43
  const n = [...e.ownerDocument.querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(
44
44
  (a) => a.form === e.form && !a.disabled
45
45
  );
46
46
  return (n.find((a) => a.checked) ?? (r ? n[n.length - 1] : n[0])) !== e;
47
47
  }
48
- const D = { x: Number.NaN, y: Number.NaN };
48
+ const R = { x: Number.NaN, y: Number.NaN };
49
49
  let U = !1;
50
50
  function Ce() {
51
51
  U || typeof window > "u" || (U = !0, window.addEventListener(
52
52
  "pointermove",
53
53
  (e) => {
54
- D.x = e.clientX, D.y = e.clientY;
54
+ R.x = e.clientX, R.y = e.clientY;
55
55
  },
56
56
  { passive: !0 }
57
57
  ));
58
58
  }
59
59
  function J(e) {
60
- return !Number.isNaN(D.x) && (e.clientX !== D.x || e.clientY !== D.y);
60
+ return !Number.isNaN(R.x) && (e.clientX !== R.x || e.clientY !== R.y);
61
61
  }
62
62
  const V = (e) => `radial-gradient(farthest-side at 50% ${e === "top" ? "0" : "100%"}, var(--menu-edge), transparent)`, Q = {
63
63
  backgroundImage: "var(--menu-edge-top, none), var(--menu-edge-bottom, none)",
@@ -65,7 +65,7 @@ const V = (e) => `radial-gradient(farthest-side at 50% ${e === "top" ? "0" : "10
65
65
  backgroundSize: "100% 0.5rem",
66
66
  backgroundRepeat: "no-repeat"
67
67
  };
68
- function Re(e) {
68
+ function Le(e) {
69
69
  i.useLayoutEffect(() => {
70
70
  if (!e) return;
71
71
  const r = () => {
@@ -83,7 +83,7 @@ function Z(e, r) {
83
83
  const [n, s] = e.split("-"), a = r ? "right" : "left", t = r ? "left" : "right";
84
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
85
  }
86
- const ee = /* @__PURE__ */ E(
86
+ const ee = /* @__PURE__ */ S(
87
87
  "rst:font-ui",
88
88
  we,
89
89
  /* Its own width wherever it lands: a fixed panel sized by the room to its
@@ -137,7 +137,7 @@ function re(e, r, n, s, a, t = !1) {
137
137
  },
138
138
  [a, p]
139
139
  );
140
- return Re(d), { ...u, setPanel: f, panelEl: d };
140
+ return Le(d), { ...u, setPanel: f, panelEl: d };
141
141
  }
142
142
  const ne = 500;
143
143
  function oe() {
@@ -154,21 +154,21 @@ function se({
154
154
  return (t) => {
155
155
  const d = e.current;
156
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);
157
+ const o = D(d), u = o.indexOf(document.activeElement), p = z(d);
158
158
  switch (t.key) {
159
159
  case "ArrowDown":
160
- t.preventDefault(), t.stopPropagation(), S(o[(u + 1) % o.length]);
160
+ t.preventDefault(), t.stopPropagation(), E(o[(u + 1) % o.length]);
161
161
  return;
162
162
  case "ArrowUp":
163
- t.preventDefault(), t.stopPropagation(), S(o[u <= 0 ? o.length - 1 : u - 1]);
163
+ t.preventDefault(), t.stopPropagation(), E(o[u <= 0 ? o.length - 1 : u - 1]);
164
164
  return;
165
165
  case "Home":
166
166
  case "PageUp":
167
- t.preventDefault(), t.stopPropagation(), S(o[0]);
167
+ t.preventDefault(), t.stopPropagation(), E(o[0]);
168
168
  return;
169
169
  case "End":
170
170
  case "PageDown":
171
- t.preventDefault(), t.stopPropagation(), S(o[o.length - 1]);
171
+ t.preventDefault(), t.stopPropagation(), E(o[o.length - 1]);
172
172
  return;
173
173
  case "Escape":
174
174
  t.preventDefault(), t.stopPropagation(), n();
@@ -176,7 +176,7 @@ function se({
176
176
  case "Tab": {
177
177
  t.preventDefault(), t.stopPropagation();
178
178
  const f = a.triggerRef.current;
179
- a.close(!1), f && Te(f, t.shiftKey);
179
+ a.close(!1), f && Ae(f, t.shiftKey);
180
180
  return;
181
181
  }
182
182
  case "ArrowLeft":
@@ -189,7 +189,7 @@ function se({
189
189
  if (t.key === " " && !m) return;
190
190
  t.preventDefault(), r.current = { text: m ? r.current.text + t.key : t.key, at: f };
191
191
  const l = o.map((x) => x.dataset.menuText ?? x.textContent ?? ""), b = ke(l, u, r.current.text);
192
- b !== -1 && S(o[b]);
192
+ b !== -1 && E(o[b]);
193
193
  }
194
194
  };
195
195
  }
@@ -238,7 +238,7 @@ const Ve = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKe
238
238
  P(y), typeof o == "function" ? o(y) : o && (o.current = y);
239
239
  },
240
240
  [P, o]
241
- ), T = {
241
+ ), A = {
242
242
  id: h.triggerId,
243
243
  "aria-haspopup": "menu",
244
244
  "aria-expanded": h.open,
@@ -254,20 +254,20 @@ const Ve = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKe
254
254
  y.preventDefault();
255
255
  const k = h.open ? document.getElementById(h.panelId) : null;
256
256
  if (k) {
257
- const R = L(k);
258
- S(v === "last" ? R[R.length - 1] : R[0]);
257
+ const L = D(k);
258
+ E(v === "last" ? L[L.length - 1] : L[0]);
259
259
  return;
260
260
  }
261
261
  h.openWith(v);
262
262
  }
263
263
  };
264
- return r ? /* @__PURE__ */ c("button", { ref: M, type: "button", className: n, ...I, ...T, children: t }) : (
264
+ return r ? /* @__PURE__ */ c("button", { ref: M, type: "button", className: n, ...I, ...A, children: t }) : (
265
265
  /* min 44 by 44 whatever the size: the target a finger needs. */
266
266
  /* @__PURE__ */ c(
267
267
  xe,
268
268
  {
269
269
  ref: M,
270
- className: E("rst:min-h-11 rst:min-w-11", n),
270
+ className: S("rst:min-h-11 rst:min-w-11", n),
271
271
  variant: u,
272
272
  colorScheme: p,
273
273
  size: f,
@@ -277,7 +277,7 @@ const Ve = i.forwardRef(function({ plain: r = !1, className: n, onClick: s, onKe
277
277
  endIcon: x,
278
278
  surface: g,
279
279
  ...I,
280
- ...T,
280
+ ...A,
281
281
  children: t
282
282
  }
283
283
  )
@@ -287,8 +287,8 @@ function je({ children: e, align: r = "start", offset: n = 4, className: s, ...a
287
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
288
  i.useLayoutEffect(() => {
289
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 });
290
+ const v = D(l), k = t.focusOnOpen.current;
291
+ k === "first" && v[0] ? E(v[0]) : k === "last" && v.length ? E(v[v.length - 1]) : l.focus({ preventScroll: !0 });
292
292
  }, [t.open, l, t.focusOnOpen]), i.useLayoutEffect(() => {
293
293
  if (!g || !l) return;
294
294
  const v = document.activeElement;
@@ -296,7 +296,7 @@ function je({ children: e, align: r = "start", offset: n = 4, className: s, ...a
296
296
  }, [g, l]), i.useLayoutEffect(() => {
297
297
  !t.open && l?.contains(document.activeElement) && t.triggerRef.current?.focus({ preventScroll: !0 });
298
298
  }, [t.open, l, t.triggerRef]);
299
- const T = (v) => {
299
+ const A = (v) => {
300
300
  const k = v.relatedTarget;
301
301
  k && !k.closest(`[data-menu-tree="${t.treeId}"]`) && t.close(!1);
302
302
  };
@@ -317,9 +317,9 @@ function je({ children: e, align: r = "start", offset: n = 4, className: s, ...a
317
317
  "data-closed": o ? "" : void 0,
318
318
  "data-leaving": u ? "" : void 0,
319
319
  onKeyDown: M,
320
- onBlur: T,
320
+ onBlur: A,
321
321
  style: { ...b, ...Q, transformOrigin: Z(x, f) },
322
- className: E(y && "dark", ee, s),
322
+ className: S(y && "dark", ee, s),
323
323
  children: e
324
324
  }
325
325
  ) }) });
@@ -337,19 +337,26 @@ function ae() {
337
337
  }
338
338
  };
339
339
  }
340
- const O = /* @__PURE__ */ E(
340
+ const O = /* @__PURE__ */ S(
341
341
  /* A button or a link reset to a row: no border, no fill, the panel's type. */
342
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
343
  /* Focus follows the pointer, so the highlight is focus. In forced colors a
344
344
  fill is dropped, so focus draws an outline there instead. */
345
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
+ /* The tint alone isn't a focus indicator: it measures under 1.2:1 against
347
+ the panel in both themes, on the default surface and a consumer's. So
348
+ keyboard focus adds an inset ring in the focus token, which a consumer
349
+ tunes against their own surfaces, and holds 3:1 on any of them. The
350
+ pointer's focus is the tint alone: the ring follows the mark `focusItem`
351
+ leaves, which only the keyboard's paths set. */
352
+ "rst:data-key-focus:ring-2 rst:data-key-focus:ring-inset rst:data-key-focus:ring-ring",
346
353
  "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) {
354
+ ), 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", Re = () => /* @__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" }) }), De = () => /* @__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" }) });
355
+ function T({ icon: e, shortcut: r, description: n, badge: s, children: a }, t, d, o) {
349
356
  const u = t ?? e;
350
357
  return /* @__PURE__ */ N(j, { children: [
351
358
  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 }),
359
+ /* @__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
360
  /* @__PURE__ */ N("span", { className: "rst:min-w-0 rst:flex-1 rst:break-words", "data-menu-label": "", children: [
354
361
  a,
355
362
  n != null && /* @__PURE__ */ c("span", { id: o, "aria-hidden": "true", className: "rst:block rst:text-xs rst:opacity-75", "data-menu-description": "", children: n })
@@ -386,7 +393,7 @@ function F({
386
393
  };
387
394
  }
388
395
  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 = {
396
+ const p = C("MenuItem"), f = _("MenuItem"), m = i.useId(), l = F({ disabled: s, closeOnSelect: n, onChoose: (g) => e?.(g) }), b = S(O, a && H, o), x = {
390
397
  role: "menuitem",
391
398
  tabIndex: -1,
392
399
  "aria-disabled": s ? !0 : void 0,
@@ -413,11 +420,11 @@ function qe({ onSelect: e, href: r, closeOnSelect: n = !0, disabled: s, destruct
413
420
  I.preventDefault(), s || I.currentTarget.click();
414
421
  }
415
422
  },
416
- children: A(u, void 0, void 0, m)
423
+ children: T(u, void 0, void 0, m)
417
424
  }
418
425
  );
419
426
  }
420
- return /* @__PURE__ */ c("button", { type: "button", className: b, ...x, ...l, children: A(u, void 0, void 0, m) });
427
+ return /* @__PURE__ */ c("button", { type: "button", className: b, ...x, ...l, children: T(u, void 0, void 0, m) });
421
428
  }
422
429
  function Ge({ checked: e, onCheckedChange: r, indicator: n, closeOnSelect: s = !0, disabled: a, destructive: t, keyshortcuts: d, textValue: o, className: u, ...p }) {
423
430
  const f = F({ disabled: a, closeOnSelect: s, spaceKeepsOpen: !0, onChoose: () => r(!e) }), m = i.useId();
@@ -433,9 +440,9 @@ function Ge({ checked: e, onCheckedChange: r, indicator: n, closeOnSelect: s = !
433
440
  "aria-keyshortcuts": d,
434
441
  "data-menu-item": "",
435
442
  "data-menu-text": o,
436
- className: E(O, t && H, u),
443
+ className: S(O, t && H, u),
437
444
  ...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)
445
+ children: n === void 0 ? T(p, /* @__PURE__ */ c("span", { className: e ? void 0 : "rst:invisible", "data-menu-check": "", children: /* @__PURE__ */ c(Re, {}) }), 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
446
  }
440
447
  );
441
448
  }
@@ -458,9 +465,9 @@ function Xe({ value: e, closeOnSelect: r = !0, disabled: n, destructive: s, keys
458
465
  "aria-keyshortcuts": a,
459
466
  "data-menu-item": "",
460
467
  "data-menu-text": t,
461
- className: E(O, s && H, d),
468
+ className: S(O, s && H, d),
462
469
  ...f,
463
- children: A(o, /* @__PURE__ */ c("span", { className: p ? void 0 : "rst:invisible", "data-menu-check": "", children: /* @__PURE__ */ c(Le, {}) }), void 0, m)
470
+ children: T(o, /* @__PURE__ */ c("span", { className: p ? void 0 : "rst:invisible", "data-menu-check": "", children: /* @__PURE__ */ c(De, {}) }), void 0, m)
464
471
  }
465
472
  );
466
473
  }
@@ -480,14 +487,14 @@ function Oe({ label: e, children: r, className: n }) {
480
487
  ] });
481
488
  }
482
489
  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) });
490
+ 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
491
  }
485
492
  function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, className: t, panelClassName: d }) {
486
493
  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
494
  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(
495
+ }, []), h = i.useRef(null), P = i.useRef(void 0), M = i.useRef("mouse"), { mounted: A, closed: y, leaving: v } = te(l), k = z(x), { setPanel: L, panelEl: K, floatingStyles: ie, placement: ue } = re(
489
496
  x,
490
- T,
497
+ A,
491
498
  k ? "left-start" : "right-start",
492
499
  { mainAxis: 0, alignmentAxis: -4 },
493
500
  h,
@@ -495,15 +502,15 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
495
502
  ), ce = ae();
496
503
  i.useEffect(() => () => window.clearTimeout(P.current), []);
497
504
  const W = () => {
498
- u.setOpenSubmenu(null), b.current?.focus({ preventScroll: !0 });
505
+ u.setOpenSubmenu(null), E(b.current);
499
506
  }, { typedRef: le, typingAhead: de } = oe(), me = se({ panelRef: h, typedRef: le, onEscape: W, onBack: W });
500
507
  i.useLayoutEffect(() => {
501
- !l || !K || u.focusFirstInSubmenu.current && S(L(K)[0]);
508
+ !l || !K || u.focusFirstInSubmenu.current && E(D(K)[0]);
502
509
  }, [l, K, u.focusFirstInSubmenu]);
503
510
  const $ = (w) => {
504
511
  if (!s) {
505
512
  if (l && w && h.current) {
506
- S(L(h.current)[0]);
513
+ E(D(h.current)[0]);
507
514
  return;
508
515
  }
509
516
  u.setOpenSubmenu(f, w);
@@ -525,7 +532,7 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
525
532
  "data-menu-item": "",
526
533
  "data-menu-text": a,
527
534
  "data-menu-tree": o.treeId,
528
- className: E(O, l && "rst:bg-gray-100 rst:dark:bg-gray-700/50", t),
535
+ className: S(O, l && "rst:bg-gray-100 rst:dark:bg-gray-700/50", t),
529
536
  onPointerDown: (w) => {
530
537
  M.current = w.pointerType;
531
538
  },
@@ -538,13 +545,13 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
538
545
  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
546
  },
540
547
  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, {}) }))
548
+ 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(Ne, {}) }))
542
549
  }
543
550
  ),
544
- T && /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(B.Provider, { value: { ...ce, panelRef: h, typingAhead: de }, children: /* @__PURE__ */ c(
551
+ A && /* @__PURE__ */ c(q, { children: /* @__PURE__ */ c(B.Provider, { value: { ...ce, panelRef: h, typingAhead: de }, children: /* @__PURE__ */ c(
545
552
  "div",
546
553
  {
547
- ref: R,
554
+ ref: L,
548
555
  id: m,
549
556
  dir: k ? "rtl" : "ltr",
550
557
  role: "menu",
@@ -557,7 +564,7 @@ function Qe({ label: e, children: r, icon: n, disabled: s, textValue: a, classNa
557
564
  onKeyDown: me,
558
565
  onPointerEnter: () => u.hoverItem(f),
559
566
  style: { ...ie, ...Q, transformOrigin: Z(ue, k) },
560
- className: E(fe && "dark", ee, d),
567
+ className: S(fe && "dark", ee, d),
561
568
  children: r
562
569
  }
563
570
  ) }) })
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),d=require("react"),G=require("../../../lib/utils.cjs"),ge=require("../../../lib/labels.cjs"),J=require("../../../internal/field-invalid.cjs"),l=require("../Slider/track.cjs"),h=require("../Slider/track-parts.cjs"),ve={low:"Minimum",high:"Maximum",valueText:(s,i)=>i?`${s}, ${i}`:s,range:(s,i)=>`${s} – ${i}`},he=([s,i])=>s<=i?[s,i]:[i,s];function pe({value:s,defaultValue:i,onChange:Q,onCommit:B,min:g=0,max:v=100,step:M=1,pageStep:U,snapPoints:W=[],label:P,helperText:T,errorMessage:R,disabled:a=!1,name:p,formatValue:b=String,labels:X,className:Y,trackClassName:Z,thumbClassName:_,chipClassName:V,labelClassName:ee,messageClassName:te,"aria-invalid":ne,"aria-labelledby":re,"aria-describedby":se,...C}){const j=ge.withLabels(ve,X),x=d.useId(),F=`${x}-label`,N=`${x}-message`,w=[`${x}-low`,`${x}-high`],S=re??(P?F:void 0),c=l.useScale(g,v,M,U),m=s!==void 0,[O,L]=d.useState(i??[g,v]),D=m?s:O,r=he([c.clamp(D[0]),c.clamp(D[1])]),ie=J.isFieldInvalid(!!R,{...C,"aria-invalid":ne}),K=J.withoutInvalidProps(C),f=l.useCommitted(r),[,ae]=d.useReducer(e=>e+1,0),k=(e,t,o)=>{const u=f.current,q=e===0?Math.min(t,u[1]):Math.max(t,u[0]);if(q===u[e])return;const y=e===0?[q,u[1]]:[u[0],q];f.current=y,m?ae():L(y),Q?.(y),o&&B?.(y)},z=d.useRef(null),A=d.useRef(O);l.useFormReset(z,m,()=>{f.current=A.current,L(A.current)},p);const E=d.useRef(null),H=[d.useRef(null),d.useRef(null)],{dragging:I,rtl:le,handlers:oe}=l.useTrackPress({trackRef:E,disabled:a,scale:c,min:g,max:v,values:()=>f.current,set:k,focus:e=>H[e].current?.focus({preventScroll:!0}),commit:()=>B?.(f.current),own:{down:void 0,move:void 0,up:void 0,cancel:void 0,lost:void 0}}),ce=e=>t=>{if(a)return;const o=f.current,u=l.keyTarget(t,o[e],{scale:c,step:M,start:o[e],floor:e===0?g:o[0],ceiling:e===0?o[1]:v,rtl:le()});u!==void 0&&(t.preventDefault(),k(e,u,!0))},ue=e=>{const[t,o]=f.current;k(e<=t?0:e>=o?1:e-t<=o-e?0:1,e,!0)},$=l.inRange(W,g,v),de=[T||R?N:void 0,se].filter(Boolean).join(" ")||void 0,fe="rst:focus-visible:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background";return n.jsxs("div",{...K,role:"group","aria-labelledby":S,className:G.cn("rst:font-ui rst:flex rst:min-w-0 rst:flex-col rst:gap-1.5",Y),"data-range-slider":"",children:[n.jsx(h.SliderHeader,{labelId:F,label:P,readout:j.range(b(r[0]),b(r[1])),empty:!1,disabled:a,labelClassName:ee}),n.jsx("span",{id:w[0],hidden:!0,children:j.low}),n.jsx("span",{id:w[1],hidden:!0,children:j.high}),n.jsxs("div",{...oe,ref:E,"data-dragging":I?"":void 0,className:G.cn(l.trackClasses(a),Z),children:[n.jsx(h.Rail,{}),n.jsx(h.Fill,{from:c.at(r[0]),to:c.at(r[1]),dragging:I}),n.jsx(h.Marks,{points:$,at:c.at,filled:e=>e>=r[0]&&e<=r[1]}),r.map((e,t)=>n.jsx("span",{ref:H[t],role:"slider",tabIndex:a?void 0:0,"aria-labelledby":[S,w[t]].filter(Boolean).join(" "),"aria-describedby":de,"aria-valuemin":t===0?g:r[0],"aria-valuemax":t===0?r[1]:v,"aria-valuenow":e,"aria-valuetext":j.valueText(b(e),l.nearestPoint($,e)?.label),"aria-orientation":"horizontal","aria-disabled":a||void 0,"aria-invalid":ie||void 0,"data-slider-thumb":t===0?"low":"high",onKeyDown:ce(t),className:l.thumbClasses(I,fe,_),style:{insetInlineStart:l.along(c.at(e))}},t))]}),n.jsx(h.SnapChips,{points:$,labelledBy:S,label:K["aria-label"],pressed:e=>e===r[0]||e===r[1],pick:ue,disabled:a,chipClassName:V}),n.jsx(h.Message,{id:N,helperText:T,errorMessage:R,disabled:a,className:te}),p&&n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:z,type:"hidden",name:p,value:String(r[0]),disabled:a,readOnly:!0}),n.jsx("input",{type:"hidden",name:p,value:String(r[1]),disabled:a,readOnly:!0})]})]})}exports.RangeSlider=pe;