@uselets/ui 2.0.2 → 2.1.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 +8 -0
- package/dist/checkbox-group-context-HDVxTNPi.js +2 -0
- package/dist/checkbox-group-context-HDVxTNPi.js.map +1 -0
- package/dist/combobox-styles-CZ0aJayc.js +2 -0
- package/dist/combobox-styles-CZ0aJayc.js.map +1 -0
- package/dist/components/autocomplete.d.ts +46 -0
- package/dist/components/autocomplete.js +2 -0
- package/dist/components/autocomplete.js.map +1 -0
- package/dist/components/badge.js +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/checkbox-group.d.ts +19 -0
- package/dist/components/checkbox-group.js +2 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.ts +2 -2
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/combobox.js +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.js +1 -1
- package/dist/components/data-table.js +1 -1
- package/dist/components/dropzone.js +1 -1
- package/dist/components/dropzone.js.map +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/mask-input.d.ts +1 -1
- package/dist/components/mask-input.js +1 -1
- package/dist/components/meter.d.ts +21 -0
- package/dist/components/meter.js +2 -0
- package/dist/components/meter.js.map +1 -0
- package/dist/components/number-field.js +1 -1
- package/dist/components/phone-input.js +1 -1
- package/dist/components/progress.js +1 -1
- package/dist/components/progress.js.map +1 -1
- package/dist/components/radio-group.js +1 -1
- package/dist/components/ring-progress.js +1 -1
- package/dist/components/sidebar.d.ts +1 -1
- package/dist/components/sidebar.js +1 -1
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/stepper.js +1 -1
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/components/toolbar.d.ts +30 -0
- package/dist/components/toolbar.js +2 -0
- package/dist/components/toolbar.js.map +1 -0
- package/dist/index.d.ts +20 -16
- package/dist/index.js +1 -1
- package/dist/skills/uselets-ui/SKILL.md +3 -3
- package/dist/skills/uselets-ui/references/component-catalog.md +14 -2
- package/dist/skills/uselets-ui/references/package-guide.md +3 -3
- package/package.json +9 -9
- package/skills/uselets-ui/SKILL.md +3 -3
- package/skills/uselets-ui/references/component-catalog.md +14 -2
- package/skills/uselets-ui/references/package-guide.md +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{useAsChild as e}from"../lib/as-child.js";import{cn as t}from"../lib/utils.js";import{t as n}from"../resolve-class-name-BurP8ngI.js";import{Button as r}from"./button.js";import{Separator as i}from"./separator.js";import{Input as a}from"./input.js";import{Drawer as o,DrawerContent as s,DrawerDescription as c,DrawerHeader as l,DrawerTitle as u}from"./drawer.js";import{useIsMobile as d}from"../hooks/use-mobile.js";import{Skeleton as f}from"./skeleton.js";import{Tooltip as p}from"./tooltip.js";import{IconLayoutSidebar as m}from"@tabler/icons-react";import*as h from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";import{cva as y}from"class-variance-authority";const b=h.createContext(null),x=h.createContext(null);function useSidebar(){let e=h.useContext(b);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function isEditableContent(e){return e instanceof Element&&e.closest(`[contenteditable]:not([contenteditable="false"])`)!==null}function SidebarProvider({defaultOpen:e=!0,open:n,onOpenChange:r,expandOnHover:i=!1,hoverExpandOpenDelay:a=150,hoverExpandCloseDelay:o=300,className:s,style:c,children:l,...u}){let f=d(),[p,m]=h.useState(!1),[g,v]=h.useState(!1),y=h.useRef(!1),S=h.useCallback(()=>{y.current=!0,v(!1)},[]);h.useEffect(()=>{i||v(!1)},[i]);let[C,w]=h.useState(e),T=n??C,E=h.useCallback(e=>{let t=typeof e==`function`?e(T):e;T&&!t&&S(),r?r(t):w(t),document.cookie=`sidebar_state=${t}; path=/; max-age=604800`},[r,T,S]),D=h.useCallback(()=>f?m(e=>!e):E(e=>!e),[f,E]);h.useEffect(()=>{let handleKeyDown=e=>{e.defaultPrevented||isEditableContent(e.target)||e.key===`b`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),D())};return window.addEventListener(`keydown`,handleKeyDown),()=>window.removeEventListener(`keydown`,handleKeyDown)},[D]);let O=T?`expanded`:`collapsed`,k=h.useMemo(()=>({state:O,open:T,setOpen:E,isMobile:f,openMobile:p,setOpenMobile:m,toggleSidebar:D,expandOnHover:i,isHoverExpanded:g,setHoverExpanded:v,hoverExpandOpenDelay:a,hoverExpandCloseDelay:o}),[O,T,E,f,p,D,i,g,a,o]),A=h.useMemo(()=>({suppressedRef:y,dismissHoverPreview:S}),[S]);return/* @__PURE__ */ _(b.Provider,{value:k,children:/* @__PURE__ */ _(x.Provider,{value:A,children:/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":`16rem`,"--sidebar-width-icon":`3rem`,...c},className:t(`group/sidebar-wrapper relative flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,s),...u,children:l})})})}function Sidebar({side:e=`left`,variant:n=`sidebar`,collapsible:r=`offcanvas`,className:i,children:a,...d}){let{isMobile:f,state:p,openMobile:m,setOpenMobile:g,expandOnHover:y,isHoverExpanded:b,setHoverExpanded:S,hoverExpandOpenDelay:C,hoverExpandCloseDelay:w}=useSidebar(),T=y&&r===`icon`,E=T&&b,D=h.useRef(!1),O=h.useRef(!1),k=h.useRef(null),A=h.useRef(null),j=h.useRef(!1),M=h.useRef(null),N=h.useContext(x)?.suppressedRef,P=h.useCallback((e=!1)=>{k.current&&=(clearTimeout(k.current),null),A.current&&=(clearTimeout(A.current),null);let t=!N?.current&&(D.current||O.current);if(e){S(t);return}let n=t?k:A;n.current=setTimeout(()=>{n.current=null,S(t&&!N?.current)},t?C:w)},[S,C,w,N]);h.useEffect(()=>{if(!T)return;let handlePointerDown=()=>{j.current=!0},handleKeyDown=()=>{j.current=!1};return document.addEventListener(`pointerdown`,handlePointerDown,!0),document.addEventListener(`keydown`,handleKeyDown,!0),()=>{document.removeEventListener(`pointerdown`,handlePointerDown,!0),document.removeEventListener(`keydown`,handleKeyDown,!0)}},[T]),h.useEffect(()=>{let e=M.current;if(!T||f||!e)return;let handleMouseEnter=()=>{D.current=!0,N&&(N.current=!1),P()},handleMouseLeave=()=>{D.current=!1,N&&(N.current=!1),P()};return e.addEventListener(`mouseenter`,handleMouseEnter),e.addEventListener(`mouseleave`,handleMouseLeave),()=>{e.removeEventListener(`mouseenter`,handleMouseEnter),e.removeEventListener(`mouseleave`,handleMouseLeave)}},[T,f,P,N]),h.useEffect(()=>()=>{k.current&&clearTimeout(k.current),A.current&&clearTimeout(A.current),S(!1)},[S]),h.useEffect(()=>{f&&(k.current&&clearTimeout(k.current),A.current&&clearTimeout(A.current),k.current=null,A.current=null,D.current=!1,O.current=!1,S(!1))},[f,S]);let handleFocus=e=>{if(!T)return;let t=e.target;O.current=!j.current||!e.currentTarget.contains(t)||t.matches(`textarea, select, [contenteditable]:not([contenteditable="false"]), input:not([type="button"], [type="checkbox"], [type="radio"], [type="reset"], [type="submit"])`),!j.current&&N&&(N.current=!1),P()},handleBlur=e=>{T&&(e.currentTarget.contains(e.relatedTarget)||(O.current=!1,P()))},handleKeyDown=e=>{T&&e.key===`Escape`&&b&&(D.current=!1,O.current=!1,P(!0),document.activeElement?.blur?.())};return r===`none`?/* @__PURE__ */ _(`div`,{"data-slot":`sidebar`,className:t(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,i),...d,children:a}):f?/* @__PURE__ */ _(o,{open:m,onOpenChange:g,direction:e,size:`sm`,children:/* @__PURE__ */ v(s,{"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`h-full w-(--sidebar-width) rounded-none bg-sidebar p-0 text-sidebar-foreground`,style:{"--sidebar-width":`18rem`},...d,children:[/* @__PURE__ */ v(l,{className:`sr-only`,children:[/* @__PURE__ */ _(u,{children:`Sidebar`}),/* @__PURE__ */ _(c,{children:`Displays the mobile sidebar.`})]}),/* @__PURE__ */ _(`div`,{className:`flex h-full w-full flex-col`,children:a})]})}):/* @__PURE__ */ v(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":p,"data-collapsible":p===`collapsed`&&!E?r:``,"data-collapsible-raw":p===`collapsed`?r:``,"data-hover-expanded":E?`true`:void 0,"data-variant":n,"data-side":e,"data-slot":`sidebar`,ref:M,onFocus:handleFocus,onBlur:handleBlur,onKeyDown:handleKeyDown,children:[/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-gap`,className:t(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible-raw=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,n===`floating`||n===`inset`?`group-data-[collapsible-raw=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible-raw=icon]:w-(--sidebar-width-icon)`)}),/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-container`,"data-side":e,className:t(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex`,`data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:-left-(--sidebar-width)`,`data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:-right-(--sidebar-width)`,n===`floating`||n===`inset`?[`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`,`[--sidebar-menu-button-collapsed-offset:calc((var(--sidebar-width-icon)+2px-(--spacing(4))-2rem)/2)]`]:[`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,`[--sidebar-menu-button-collapsed-offset:calc((var(--sidebar-width-icon)-(--spacing(4))-2rem)/2)]`],n!==`floating`&&n!==`inset`&&`group-data-[side=left]:border-r group-data-[side=right]:border-l`,`group-data-[hover-expanded=true]:shadow-lg group-data-[hover-expanded=true]:ring-1 group-data-[hover-expanded=true]:ring-foreground/10`,i),...d,children:/* @__PURE__ */ _(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:t(`flex size-full flex-col bg-sidebar`,`group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm`,`group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`),children:a})})]})}function SidebarTrigger({className:e,onClick:n,asChild:i=!1,children:a,...o}){let{toggleSidebar:s,open:c,isHoverExpanded:l}=useSidebar(),u=h.useContext(x);return/* @__PURE__ */ _(r,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,color:`zinc`,asChild:i,className:t(e),onClick:e=>{n?.(e),!e.defaultPrevented&&(l&&!c?u?.dismissHoverPreview():s())},...o,children:i?a:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(m,{}),/* @__PURE__ */ _(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})})}function SidebarRail({className:e,...n}){let{toggleSidebar:r,open:i,setOpen:a,isHoverExpanded:o}=useSidebar(),handleClick=()=>{o&&!i?a(!0):r()};return/* @__PURE__ */ _(`button`,{"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onClick:handleClick,title:`Toggle Sidebar`,className:t(`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:s-1/2 after:w-0.5 hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,e),...n})}function SidebarInset({className:e,...n}){return/* @__PURE__ */ _(`main`,{"data-slot":`sidebar-inset`,className:t(`relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,e),...n})}function SidebarInput({className:e,...n}){return/* @__PURE__ */ _(a,{"data-slot":`sidebar-input`,"data-sidebar":`input`,className:t(`h-8 w-full bg-background shadow-none`,e),...n})}function SidebarHeader({className:e,...n}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:t(`flex flex-col gap-2 p-2`,e),...n})}function SidebarFooter({className:e,...n}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:t(`flex flex-col gap-2 p-2`,e),...n})}function SidebarSeparator({className:e,...r}){return/* @__PURE__ */ _(i,{"data-slot":`sidebar-separator`,"data-sidebar":`separator`,className:r=>t(`w-auto bg-sidebar-border`,n(e,r)),...r})}function SidebarContent({className:e,...n}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:t(`no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...n})}function SidebarGroup({className:e,...n}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:t(`relative flex w-full min-w-0 flex-col px-2`,e),...n})}function SidebarGroupLabel({className:n,...r}){return e(`div`,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:t(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:pointer-events-none group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,n),...r})}function SidebarGroupAction({className:n,...r}){return e(`button`,{"data-slot":`sidebar-group-action`,"data-sidebar":`group-action`,className:t(`absolute top-1.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,n),...r})}function SidebarGroupContent({className:e,...n}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:t(`w-full text-sm mt-2`,e),...n})}function SidebarMenu({className:e,...n}){return/* @__PURE__ */ _(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:t(`flex w-full min-w-0 flex-col gap-0`,e),...n})}function SidebarMenuItem({className:e,...n}){return/* @__PURE__ */ _(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:t(`group/menu-item relative`,e),...n})}const S=y(`peer/menu-button group/menu-button font-medium flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding,margin] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:ml-(--sidebar-menu-button-collapsed-offset) group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-popup-open:hover:bg-sidebar-accent data-popup-open:hover:text-sidebar-accent-foreground data-panel-open:hover:bg-sidebar-accent data-panel-open:hover:text-sidebar-accent-foreground data-active:[&_svg]:text-sidebar-primary data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]`},size:{md:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`md`}});function SidebarMenuButton({asChild:n=!1,isActive:r=!1,variant:i=`default`,size:a=`md`,tooltip:o,className:s,...c}){let{isMobile:l,state:u,isHoverExpanded:d}=useSidebar(),f=e(`button`,{asChild:n,"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":a,"data-active":r,className:t(S({variant:i,size:a}),s),...c});return o?(typeof o==`string`&&(o={children:o}),/* @__PURE__ */ _(p,{label:o.children,side:`right`,align:`center`,hidden:u!==`collapsed`||l||d,...o,children:f})):f}function SidebarMenuAction({className:n,showOnHover:r=!1,...i}){return e(`button`,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:t(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=md]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,r&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,n),...i})}function SidebarMenuBadge({className:e,...n}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-menu-badge`,"data-sidebar":`menu-badge`,className:t(`pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=md]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground`,e),...n})}function getSkeletonWidth(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return`${Math.abs(t)%40+50}%`}function SidebarMenuSkeleton({className:e,showIcon:n=!1,...r}){let i=h.useId(),a=h.useMemo(()=>getSkeletonWidth(i),[i]);return/* @__PURE__ */ v(`div`,{"data-slot":`sidebar-menu-skeleton`,"data-sidebar":`menu-skeleton`,className:t(`flex h-8 items-center gap-2 rounded-md px-2`,e),...r,children:[n&&/* @__PURE__ */ _(f,{className:`size-4 rounded-md`,"data-sidebar":`menu-skeleton-icon`}),/* @__PURE__ */ _(f,{className:`h-4 max-w-(--skeleton-width) flex-1`,"data-sidebar":`menu-skeleton-text`,style:{"--skeleton-width":a}})]})}function SidebarMenuSub({className:e,...n}){return/* @__PURE__ */ _(`ul`,{"data-slot":`sidebar-menu-sub`,"data-sidebar":`menu-sub`,className:t(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden`,e),...n})}function SidebarMenuSubItem({className:e,...n}){return/* @__PURE__ */ _(`li`,{"data-slot":`sidebar-menu-sub-item`,"data-sidebar":`menu-sub-item`,className:t(`group/menu-sub-item relative`,e),...n})}function SidebarMenuSubButton({size:n=`md`,isActive:r=!1,className:i,...a}){return e(`a`,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":n,"data-active":r,className:t(`flex h-7 min-w-0 -translate-x-px items-center font-medium gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,i),...a})}export{Sidebar,SidebarContent,SidebarFooter,SidebarGroup,SidebarGroupAction,SidebarGroupContent,SidebarGroupLabel,SidebarHeader,SidebarInput,SidebarInset,SidebarMenu,SidebarMenuAction,SidebarMenuBadge,SidebarMenuButton,SidebarMenuItem,SidebarMenuSkeleton,SidebarMenuSub,SidebarMenuSubButton,SidebarMenuSubItem,SidebarProvider,SidebarRail,SidebarSeparator,SidebarTrigger,useSidebar};
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{useIsMobile as e}from"../hooks/use-mobile.js";import{useAsChild as t}from"../lib/as-child.js";import{cn as n}from"../lib/utils.js";import{t as r}from"../resolve-class-name-BurP8ngI.js";import{Button as i}from"./button.js";import{Drawer as a,DrawerContent as o,DrawerDescription as s,DrawerHeader as c,DrawerTitle as l}from"./drawer.js";import{Input as u}from"./input.js";import{Separator as d}from"./separator.js";import{Skeleton as f}from"./skeleton.js";import{Tooltip as p}from"./tooltip.js";import{IconLayoutSidebar as m}from"@tabler/icons-react";import*as h from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";import{cva as y}from"class-variance-authority";const b=h.createContext(null),x=h.createContext(null);function useSidebar(){let e=h.useContext(b);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function isEditableContent(e){return e instanceof Element&&e.closest(`[contenteditable]:not([contenteditable="false"])`)!==null}function SidebarProvider({defaultOpen:t=!0,open:r,onOpenChange:i,expandOnHover:a=!1,hoverExpandOpenDelay:o=150,hoverExpandCloseDelay:s=300,className:c,style:l,children:u,...d}){let f=e(),[p,m]=h.useState(!1),[g,v]=h.useState(!1),y=h.useRef(!1),S=h.useCallback(()=>{y.current=!0,v(!1)},[]);h.useEffect(()=>{a||v(!1)},[a]);let[C,w]=h.useState(t),T=r??C,E=h.useCallback(e=>{let t=typeof e==`function`?e(T):e;T&&!t&&S(),i?i(t):w(t),document.cookie=`sidebar_state=${t}; path=/; max-age=604800`},[i,T,S]),D=h.useCallback(()=>f?m(e=>!e):E(e=>!e),[f,E]);h.useEffect(()=>{let handleKeyDown=e=>{e.defaultPrevented||isEditableContent(e.target)||e.key===`b`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),D())};return window.addEventListener(`keydown`,handleKeyDown),()=>window.removeEventListener(`keydown`,handleKeyDown)},[D]);let O=T?`expanded`:`collapsed`,k=h.useMemo(()=>({state:O,open:T,setOpen:E,isMobile:f,openMobile:p,setOpenMobile:m,toggleSidebar:D,expandOnHover:a,isHoverExpanded:g,setHoverExpanded:v,hoverExpandOpenDelay:o,hoverExpandCloseDelay:s}),[O,T,E,f,p,D,a,g,o,s]),A=h.useMemo(()=>({suppressedRef:y,dismissHoverPreview:S}),[S]);return/* @__PURE__ */ _(b.Provider,{value:k,children:/* @__PURE__ */ _(x.Provider,{value:A,children:/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":`16rem`,"--sidebar-width-icon":`3rem`,...l},className:n(`group/sidebar-wrapper relative flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,c),...d,children:u})})})}function Sidebar({side:e=`left`,variant:t=`sidebar`,collapsible:r=`offcanvas`,className:i,children:u,...d}){let{isMobile:f,state:p,openMobile:m,setOpenMobile:g,expandOnHover:y,isHoverExpanded:b,setHoverExpanded:S,hoverExpandOpenDelay:C,hoverExpandCloseDelay:w}=useSidebar(),T=y&&r===`icon`,E=T&&b,D=h.useRef(!1),O=h.useRef(!1),k=h.useRef(null),A=h.useRef(null),j=h.useRef(!1),M=h.useRef(null),N=h.useContext(x)?.suppressedRef,P=h.useCallback((e=!1)=>{k.current&&=(clearTimeout(k.current),null),A.current&&=(clearTimeout(A.current),null);let t=!N?.current&&(D.current||O.current);if(e){S(t);return}let n=t?k:A;n.current=setTimeout(()=>{n.current=null,S(t&&!N?.current)},t?C:w)},[S,C,w,N]);h.useEffect(()=>{if(!T)return;let handlePointerDown=()=>{j.current=!0},handleKeyDown=()=>{j.current=!1};return document.addEventListener(`pointerdown`,handlePointerDown,!0),document.addEventListener(`keydown`,handleKeyDown,!0),()=>{document.removeEventListener(`pointerdown`,handlePointerDown,!0),document.removeEventListener(`keydown`,handleKeyDown,!0)}},[T]),h.useEffect(()=>{let e=M.current;if(!T||f||!e)return;let handleMouseEnter=()=>{D.current=!0,N&&(N.current=!1),P()},handleMouseLeave=()=>{D.current=!1,N&&(N.current=!1),P()};return e.addEventListener(`mouseenter`,handleMouseEnter),e.addEventListener(`mouseleave`,handleMouseLeave),()=>{e.removeEventListener(`mouseenter`,handleMouseEnter),e.removeEventListener(`mouseleave`,handleMouseLeave)}},[T,f,P,N]),h.useEffect(()=>()=>{k.current&&clearTimeout(k.current),A.current&&clearTimeout(A.current),S(!1)},[S]),h.useEffect(()=>{f&&(k.current&&clearTimeout(k.current),A.current&&clearTimeout(A.current),k.current=null,A.current=null,D.current=!1,O.current=!1,S(!1))},[f,S]);let handleFocus=e=>{if(!T)return;let t=e.target;O.current=!j.current||!e.currentTarget.contains(t)||t.matches(`textarea, select, [contenteditable]:not([contenteditable="false"]), input:not([type="button"], [type="checkbox"], [type="radio"], [type="reset"], [type="submit"])`),!j.current&&N&&(N.current=!1),P()},handleBlur=e=>{T&&(e.currentTarget.contains(e.relatedTarget)||(O.current=!1,P()))},handleKeyDown=e=>{T&&e.key===`Escape`&&b&&(D.current=!1,O.current=!1,P(!0),document.activeElement?.blur?.())};return r===`none`?/* @__PURE__ */ _(`div`,{"data-slot":`sidebar`,className:n(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,i),...d,children:u}):f?/* @__PURE__ */ _(a,{open:m,onOpenChange:g,direction:e,size:`sm`,children:/* @__PURE__ */ v(o,{"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`h-full w-(--sidebar-width) rounded-none bg-sidebar p-0 text-sidebar-foreground`,style:{"--sidebar-width":`18rem`},...d,children:[/* @__PURE__ */ v(c,{className:`sr-only`,children:[/* @__PURE__ */ _(l,{children:`Sidebar`}),/* @__PURE__ */ _(s,{children:`Displays the mobile sidebar.`})]}),/* @__PURE__ */ _(`div`,{className:`flex h-full w-full flex-col`,children:u})]})}):/* @__PURE__ */ v(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":p,"data-collapsible":p===`collapsed`&&!E?r:``,"data-collapsible-raw":p===`collapsed`?r:``,"data-hover-expanded":E?`true`:void 0,"data-variant":t,"data-side":e,"data-slot":`sidebar`,ref:M,onFocus:handleFocus,onBlur:handleBlur,onKeyDown:handleKeyDown,children:[/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-gap`,className:n(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible-raw=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible-raw=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible-raw=icon]:w-(--sidebar-width-icon)`)}),/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-container`,"data-side":e,className:n(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex`,`data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:-left-(--sidebar-width)`,`data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:-right-(--sidebar-width)`,t===`floating`||t===`inset`?[`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`,`[--sidebar-menu-button-collapsed-offset:calc((var(--sidebar-width-icon)+2px-(--spacing(4))-2rem)/2)]`]:[`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,`[--sidebar-menu-button-collapsed-offset:calc((var(--sidebar-width-icon)-(--spacing(4))-2rem)/2)]`],t!==`floating`&&t!==`inset`&&`group-data-[side=left]:border-r group-data-[side=right]:border-l`,`group-data-[hover-expanded=true]:shadow-lg group-data-[hover-expanded=true]:ring-1 group-data-[hover-expanded=true]:ring-foreground/10`,i),...d,children:/* @__PURE__ */ _(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:n(`flex size-full flex-col bg-sidebar`,`group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm`,`group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`),children:u})})]})}function SidebarTrigger({className:e,onClick:t,asChild:r=!1,children:a,...o}){let{toggleSidebar:s,open:c,isHoverExpanded:l}=useSidebar(),u=h.useContext(x);return/* @__PURE__ */ _(i,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,color:`zinc`,asChild:r,className:n(e),onClick:e=>{t?.(e),e.defaultPrevented||(l&&!c?u?.dismissHoverPreview():s())},...o,children:r?a:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(m,{}),/* @__PURE__ */ _(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})})}function SidebarRail({className:e,...t}){let{toggleSidebar:r,open:i,setOpen:a,isHoverExpanded:o}=useSidebar(),handleClick=()=>{o&&!i?a(!0):r()};return/* @__PURE__ */ _(`button`,{"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onClick:handleClick,title:`Toggle Sidebar`,className:n(`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:s-1/2 after:w-0.5 hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,e),...t})}function SidebarInset({className:e,...t}){return/* @__PURE__ */ _(`main`,{"data-slot":`sidebar-inset`,className:n(`relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,e),...t})}function SidebarInput({className:e,...t}){return/* @__PURE__ */ _(u,{"data-slot":`sidebar-input`,"data-sidebar":`input`,className:n(`h-8 w-full bg-background shadow-none`,e),...t})}function SidebarHeader({className:e,...t}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:n(`flex flex-col gap-2 p-2`,e),...t})}function SidebarFooter({className:e,...t}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:n(`flex flex-col gap-2 p-2`,e),...t})}function SidebarSeparator({className:e,...t}){return/* @__PURE__ */ _(d,{"data-slot":`sidebar-separator`,"data-sidebar":`separator`,className:t=>n(`w-auto bg-sidebar-border`,r(e,t)),...t})}function SidebarContent({className:e,...t}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:n(`no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function SidebarGroup({className:e,...t}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:n(`relative flex w-full min-w-0 flex-col px-2`,e),...t})}function SidebarGroupLabel({className:e,...r}){return t(`div`,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:n(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:pointer-events-none group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,e),...r})}function SidebarGroupAction({className:e,...r}){return t(`button`,{"data-slot":`sidebar-group-action`,"data-sidebar":`group-action`,className:n(`absolute top-1.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,e),...r})}function SidebarGroupContent({className:e,...t}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:n(`w-full text-sm mt-2`,e),...t})}function SidebarMenu({className:e,...t}){return/* @__PURE__ */ _(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:n(`flex w-full min-w-0 flex-col gap-0`,e),...t})}function SidebarMenuItem({className:e,...t}){return/* @__PURE__ */ _(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:n(`group/menu-item relative`,e),...t})}const S=y(`peer/menu-button group/menu-button font-medium flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding,margin] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:ml-(--sidebar-menu-button-collapsed-offset) group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-popup-open:hover:bg-sidebar-accent data-popup-open:hover:text-sidebar-accent-foreground data-panel-open:hover:bg-sidebar-accent data-panel-open:hover:text-sidebar-accent-foreground data-active:[&_svg]:text-sidebar-primary data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]`},size:{md:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`md`}});function SidebarMenuButton({asChild:e=!1,isActive:r=!1,variant:i=`default`,size:a=`md`,tooltip:o,className:s,...c}){let{isMobile:l,state:u,isHoverExpanded:d}=useSidebar(),f=t(`button`,{asChild:e,"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":a,"data-active":r,className:n(S({variant:i,size:a}),s),...c});return o?(typeof o==`string`&&(o={children:o}),/* @__PURE__ */ _(p,{label:o.children,side:`right`,align:`center`,hidden:u!==`collapsed`||l||d,...o,children:f})):f}function SidebarMenuAction({className:e,showOnHover:r=!1,...i}){return t(`button`,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:n(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=md]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,r&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,e),...i})}function SidebarMenuBadge({className:e,...t}){return/* @__PURE__ */ _(`div`,{"data-slot":`sidebar-menu-badge`,"data-sidebar":`menu-badge`,className:n(`pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=md]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground`,e),...t})}function getSkeletonWidth(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return`${Math.abs(t)%40+50}%`}function SidebarMenuSkeleton({className:e,showIcon:t=!1,...r}){let i=h.useId(),a=h.useMemo(()=>getSkeletonWidth(i),[i]);return/* @__PURE__ */ v(`div`,{"data-slot":`sidebar-menu-skeleton`,"data-sidebar":`menu-skeleton`,className:n(`flex h-8 items-center gap-2 rounded-md px-2`,e),...r,children:[t&&/* @__PURE__ */ _(f,{className:`size-4 rounded-md`,"data-sidebar":`menu-skeleton-icon`}),/* @__PURE__ */ _(f,{className:`h-4 max-w-(--skeleton-width) flex-1`,"data-sidebar":`menu-skeleton-text`,style:{"--skeleton-width":a}})]})}function SidebarMenuSub({className:e,...t}){return/* @__PURE__ */ _(`ul`,{"data-slot":`sidebar-menu-sub`,"data-sidebar":`menu-sub`,className:n(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden`,e),...t})}function SidebarMenuSubItem({className:e,...t}){return/* @__PURE__ */ _(`li`,{"data-slot":`sidebar-menu-sub-item`,"data-sidebar":`menu-sub-item`,className:n(`group/menu-sub-item relative`,e),...t})}function SidebarMenuSubButton({size:e=`md`,isActive:r=!1,className:i,...a}){return t(`a`,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":e,"data-active":r,className:n(`flex h-7 min-w-0 -translate-x-px items-center font-medium gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,i),...a})}export{Sidebar,SidebarContent,SidebarFooter,SidebarGroup,SidebarGroupAction,SidebarGroupContent,SidebarGroupLabel,SidebarHeader,SidebarInput,SidebarInset,SidebarMenu,SidebarMenuAction,SidebarMenuBadge,SidebarMenuButton,SidebarMenuItem,SidebarMenuSkeleton,SidebarMenuSub,SidebarMenuSubButton,SidebarMenuSubItem,SidebarProvider,SidebarRail,SidebarSeparator,SidebarTrigger,useSidebar};
|
|
2
2
|
//# sourceMappingURL=sidebar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.js","names":["resolveClassName","React","SidebarContext","SidebarHoverPreviewContext","context","target","openProp","setOpenProp","props","isMobile","useIsMobile","openMobile","setOpenMobile","isHoverExpanded","setIsHoverExpanded","hoverSuppressedRef","dismissHoverPreview","expandOnHover","_open","_setOpen","defaultOpen","open","setOpen","openState","value","toggleSidebar","event","state","contextValue","hoverExpandOpenDelay","hoverExpandCloseDelay","hoverPreviewContextValue","style","cn","className","canHoverExpand","collapsible","effectiveHoverExpanded","pointerInsideRef","focusInsideRef","openTimeoutRef","closeTimeoutRef","pointerModalityRef","sidebarRef","suppressedRef","scheduleHoverExpanded","shouldExpand","immediate","setHoverExpanded","timeoutRef","sidebar","Drawer","side","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","variant","hoverPreview","Button","onClick","asChild","children","Fragment","IconLayoutSidebar","Input","Separator","useAsChild","sidebarMenuButtonVariants","cva","button","size","isActive","tooltip","Tooltip","showOnHover","hash","char","seed","id","width","showIcon","Skeleton"],"sources":["../../src/components/sidebar.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { IconLayoutSidebar } from '@tabler/icons-react'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { useIsMobile } from '../hooks/use-mobile'\nimport { type AsChildProps, useAsChild } from '../lib/as-child'\nimport { cn } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\nimport { Button } from './button'\nimport { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle } from './drawer'\nimport { Input } from './input'\nimport { Separator } from './separator'\nimport { Skeleton } from './skeleton'\nimport { Tooltip, type TooltipContent } from './tooltip'\n\nconst SIDEBAR_COOKIE_NAME = 'sidebar_state'\nconst SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7\nconst SIDEBAR_WIDTH = '16rem'\nconst SIDEBAR_WIDTH_MOBILE = '18rem'\nconst SIDEBAR_WIDTH_ICON = '3rem'\nconst SIDEBAR_KEYBOARD_SHORTCUT = 'b'\nconst SIDEBAR_HOVER_EXPAND_OPEN_DELAY = 150\nconst SIDEBAR_HOVER_EXPAND_CLOSE_DELAY = 300\nconst SIDEBAR_TEXT_FIELD_SELECTOR =\n 'textarea, select, [contenteditable]:not([contenteditable=\"false\"]), input:not([type=\"button\"], [type=\"checkbox\"], [type=\"radio\"], [type=\"reset\"], [type=\"submit\"])'\n\ntype SidebarContextProps = {\n state: 'expanded' | 'collapsed'\n open: boolean\n setOpen: (open: boolean) => void\n openMobile: boolean\n setOpenMobile: (open: boolean) => void\n isMobile: boolean\n toggleSidebar: () => void\n expandOnHover: boolean\n isHoverExpanded: boolean\n setHoverExpanded: (hoverExpanded: boolean) => void\n hoverExpandOpenDelay: number\n hoverExpandCloseDelay: number\n}\n\nconst SidebarContext = React.createContext<SidebarContextProps | null>(null)\n\n// Internal (not exposed through `useSidebar`): lets a toggle dismiss the hover preview and keep it\n// suppressed until the pointer crosses the sidebar boundary again, so it doesn't reopen right away\n// under a cursor that is still over the sidebar.\ntype SidebarHoverPreviewContextProps = {\n suppressedRef: React.RefObject<boolean>\n dismissHoverPreview: () => void\n}\n\nconst SidebarHoverPreviewContext = React.createContext<SidebarHoverPreviewContextProps | null>(null)\n\nexport type SidebarProviderProps = React.ComponentProps<'div'> & {\n /**\n * Whether the sidebar starts expanded (uncontrolled).\n * @default true\n */\n defaultOpen?: boolean\n /** Whether the sidebar is expanded (controlled). */\n open?: boolean\n /** Called when the sidebar expands or collapses. */\n onOpenChange?: (open: boolean) => void\n /**\n * With `collapsible=\"icon\"`, shows a floating preview of the collapsed sidebar on hover or focus.\n * @default false\n */\n expandOnHover?: boolean\n /**\n * Delay in ms before the hover preview opens.\n * @default 150\n */\n hoverExpandOpenDelay?: number\n /**\n * Delay in ms before the hover preview closes.\n * @default 300\n */\n hoverExpandCloseDelay?: number\n}\n\nexport type SidebarProps = React.ComponentProps<'div'> & {\n /**\n * Edge of the screen the sidebar sits on.\n * @default 'left'\n */\n side?: 'left' | 'right'\n /**\n * `floating` adds a gap and shadow; `inset` pairs with `SidebarInset` for an inset main area.\n * @default 'sidebar'\n */\n variant?: 'sidebar' | 'floating' | 'inset'\n /**\n * `offcanvas` slides the sidebar out, `icon` shrinks it to icons, `none` keeps it open.\n * @default 'offcanvas'\n */\n collapsible?: 'offcanvas' | 'icon' | 'none'\n}\n\nexport type SidebarTriggerProps = React.ComponentProps<typeof Button>\n\nexport type SidebarRailProps = React.ComponentProps<'button'>\n\nexport type SidebarInsetProps = React.ComponentProps<'main'>\n\nexport type SidebarInputProps = React.ComponentProps<typeof Input>\n\nexport type SidebarHeaderProps = React.ComponentProps<'div'>\n\nexport type SidebarFooterProps = React.ComponentProps<'div'>\n\nexport type SidebarSeparatorProps = React.ComponentProps<typeof Separator>\n\nexport type SidebarContentProps = React.ComponentProps<'div'>\n\nexport type SidebarGroupProps = React.ComponentProps<'div'>\n\nexport type SidebarGroupLabelProps = AsChildProps<'div'>\n\nexport type SidebarGroupActionProps = AsChildProps<'button'>\n\nexport type SidebarGroupContentProps = React.ComponentProps<'div'>\n\nexport type SidebarMenuProps = React.ComponentProps<'ul'>\n\nexport type SidebarMenuItemProps = React.ComponentProps<'li'>\n\nfunction useSidebar() {\n const context = React.useContext(SidebarContext)\n if (!context) {\n throw new Error('useSidebar must be used within a SidebarProvider.')\n }\n\n return context\n}\n\nfunction isEditableContent(target: EventTarget | null) {\n return target instanceof Element && target.closest('[contenteditable]:not([contenteditable=\"false\"])') !== null\n}\n\nfunction SidebarProvider({\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n expandOnHover = false,\n hoverExpandOpenDelay = SIDEBAR_HOVER_EXPAND_OPEN_DELAY,\n hoverExpandCloseDelay = SIDEBAR_HOVER_EXPAND_CLOSE_DELAY,\n className,\n style,\n children,\n ...props\n}: SidebarProviderProps) {\n const isMobile = useIsMobile()\n const [openMobile, setOpenMobile] = React.useState(false)\n const [isHoverExpanded, setIsHoverExpanded] = React.useState(false)\n const hoverSuppressedRef = React.useRef(false)\n\n const dismissHoverPreview = React.useCallback(() => {\n hoverSuppressedRef.current = true\n setIsHoverExpanded(false)\n }, [])\n\n React.useEffect(() => {\n if (!expandOnHover) setIsHoverExpanded(false)\n }, [expandOnHover])\n\n // This is the internal state of the sidebar.\n // We use openProp and setOpenProp for control from outside the component.\n const [_open, _setOpen] = React.useState(defaultOpen)\n const open = openProp ?? _open\n const setOpen = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const openState = typeof value === 'function' ? value(open) : value\n // Collapsing while hovered would otherwise fall straight back into the hover preview.\n if (open && !openState) dismissHoverPreview()\n if (setOpenProp) {\n setOpenProp(openState)\n } else {\n _setOpen(openState)\n }\n\n // This sets the cookie to keep the sidebar state.\n // biome-ignore lint/suspicious/noDocumentCookie: This package persists a simple UI preference cookie without framework-specific APIs.\n document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`\n },\n [setOpenProp, open, dismissHoverPreview]\n )\n\n // Helper to toggle the sidebar.\n const toggleSidebar = React.useCallback(() => {\n return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)\n }, [isMobile, setOpen])\n\n // Adds a keyboard shortcut to toggle the sidebar.\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n // Rich text editors use the same shortcut (bold), so leave it to them when they handle it or own the focus.\n if (event.defaultPrevented || isEditableContent(event.target)) return\n if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {\n event.preventDefault()\n toggleSidebar()\n }\n }\n\n window.addEventListener('keydown', handleKeyDown)\n return () => window.removeEventListener('keydown', handleKeyDown)\n }, [toggleSidebar])\n\n // We add a state so that we can do data-state=\"expanded\" or \"collapsed\".\n // This makes it easier to style the sidebar with Tailwind classes.\n const state = open ? 'expanded' : 'collapsed'\n\n const contextValue = React.useMemo<SidebarContextProps>(\n () => ({\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n expandOnHover,\n isHoverExpanded,\n setHoverExpanded: setIsHoverExpanded,\n hoverExpandOpenDelay,\n hoverExpandCloseDelay\n }),\n [\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n toggleSidebar,\n expandOnHover,\n isHoverExpanded,\n hoverExpandOpenDelay,\n hoverExpandCloseDelay\n ]\n )\n\n const hoverPreviewContextValue = React.useMemo<SidebarHoverPreviewContextProps>(\n () => ({ suppressedRef: hoverSuppressedRef, dismissHoverPreview }),\n [dismissHoverPreview]\n )\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <SidebarHoverPreviewContext.Provider value={hoverPreviewContextValue}>\n <div\n data-slot=\"sidebar-wrapper\"\n style={\n {\n '--sidebar-width': SIDEBAR_WIDTH,\n '--sidebar-width-icon': SIDEBAR_WIDTH_ICON,\n ...style\n } as React.CSSProperties\n }\n className={cn(\n 'group/sidebar-wrapper relative flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar',\n className\n )}\n {...props}\n >\n {children}\n </div>\n </SidebarHoverPreviewContext.Provider>\n </SidebarContext.Provider>\n )\n}\n\nfunction Sidebar({\n side = 'left',\n variant = 'sidebar',\n collapsible = 'offcanvas',\n className,\n children,\n ...props\n}: SidebarProps) {\n const {\n isMobile,\n state,\n openMobile,\n setOpenMobile,\n expandOnHover,\n isHoverExpanded,\n setHoverExpanded,\n hoverExpandOpenDelay,\n hoverExpandCloseDelay\n } = useSidebar()\n\n const canHoverExpand = expandOnHover && collapsible === 'icon'\n const effectiveHoverExpanded = canHoverExpand && isHoverExpanded\n\n const pointerInsideRef = React.useRef(false)\n const focusInsideRef = React.useRef(false)\n const openTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n const closeTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n const pointerModalityRef = React.useRef(false)\n const sidebarRef = React.useRef<HTMLDivElement>(null)\n const hoverPreview = React.useContext(SidebarHoverPreviewContext)\n const suppressedRef = hoverPreview?.suppressedRef\n\n const scheduleHoverExpanded = React.useCallback(\n (immediate = false) => {\n if (openTimeoutRef.current) {\n clearTimeout(openTimeoutRef.current)\n openTimeoutRef.current = null\n }\n if (closeTimeoutRef.current) {\n clearTimeout(closeTimeoutRef.current)\n closeTimeoutRef.current = null\n }\n\n const shouldExpand = !suppressedRef?.current && (pointerInsideRef.current || focusInsideRef.current)\n\n if (immediate) {\n setHoverExpanded(shouldExpand)\n return\n }\n\n const timeoutRef = shouldExpand ? openTimeoutRef : closeTimeoutRef\n const delay = shouldExpand ? hoverExpandOpenDelay : hoverExpandCloseDelay\n timeoutRef.current = setTimeout(() => {\n timeoutRef.current = null\n // Re-checked on fire: a toggle may have dismissed the preview after this was scheduled.\n setHoverExpanded(shouldExpand && !suppressedRef?.current)\n }, delay)\n },\n [setHoverExpanded, hoverExpandOpenDelay, hoverExpandCloseDelay, suppressedRef]\n )\n\n // Tracks whether the latest input came from a pointer or the keyboard, so focus moved by a click (or\n // returned by an overlay closed with a click) doesn't hold the preview open like keyboard focus does.\n React.useEffect(() => {\n if (!canHoverExpand) return\n const handlePointerDown = () => {\n pointerModalityRef.current = true\n }\n const handleKeyDown = () => {\n pointerModalityRef.current = false\n }\n document.addEventListener('pointerdown', handlePointerDown, true)\n document.addEventListener('keydown', handleKeyDown, true)\n return () => {\n document.removeEventListener('pointerdown', handlePointerDown, true)\n document.removeEventListener('keydown', handleKeyDown, true)\n }\n }, [canHoverExpand])\n\n // Hover is tracked with native DOM events rather than React's synthetic ones: React bubbles\n // enter/leave through portals, so hovering a portaled menu counted as hovering the sidebar, and when\n // that menu unmounted under the cursor no leave ever fired, leaving the preview stuck open.\n React.useEffect(() => {\n const sidebar = sidebarRef.current\n if (!canHoverExpand || isMobile || !sidebar) return\n // Crossing the sidebar boundary in either direction lifts a toggle's preview suppression.\n const handleMouseEnter = () => {\n pointerInsideRef.current = true\n if (suppressedRef) suppressedRef.current = false\n scheduleHoverExpanded()\n }\n const handleMouseLeave = () => {\n pointerInsideRef.current = false\n if (suppressedRef) suppressedRef.current = false\n scheduleHoverExpanded()\n }\n sidebar.addEventListener('mouseenter', handleMouseEnter)\n sidebar.addEventListener('mouseleave', handleMouseLeave)\n return () => {\n sidebar.removeEventListener('mouseenter', handleMouseEnter)\n sidebar.removeEventListener('mouseleave', handleMouseLeave)\n }\n }, [canHoverExpand, isMobile, scheduleHoverExpanded, suppressedRef])\n\n React.useEffect(() => {\n return () => {\n if (openTimeoutRef.current) clearTimeout(openTimeoutRef.current)\n if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current)\n setHoverExpanded(false)\n }\n }, [setHoverExpanded])\n\n // Switching to mobile never fires a mouse leave, so drop the preview there; otherwise the trigger would\n // treat the first tap as \"close the preview\" instead of opening the drawer.\n React.useEffect(() => {\n if (!isMobile) return\n if (openTimeoutRef.current) clearTimeout(openTimeoutRef.current)\n if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current)\n openTimeoutRef.current = null\n closeTimeoutRef.current = null\n pointerInsideRef.current = false\n focusInsideRef.current = false\n setHoverExpanded(false)\n }, [isMobile, setHoverExpanded])\n\n const handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (!canHoverExpand) return\n // Only keyboard focus holds the preview open, so clicking an item doesn't pin it after the pointer\n // leaves. Text fields always hold it (the user is about to type), and so does focus that lands\n // outside the sidebar's DOM (a portaled menu or popover opened from inside it), so the preview\n // doesn't collapse under an open overlay.\n const target = event.target as HTMLElement\n focusInsideRef.current =\n !pointerModalityRef.current ||\n !event.currentTarget.contains(target) ||\n target.matches(SIDEBAR_TEXT_FIELD_SELECTOR)\n // Keyboard focus is a deliberate way back into the sidebar, so it also lifts a toggle's suppression.\n if (!pointerModalityRef.current && suppressedRef) suppressedRef.current = false\n scheduleHoverExpanded()\n }\n const handleBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (!canHoverExpand) return\n if (event.currentTarget.contains(event.relatedTarget as Node | null)) return\n focusInsideRef.current = false\n scheduleHoverExpanded()\n }\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!canHoverExpand || event.key !== 'Escape' || !isHoverExpanded) return\n pointerInsideRef.current = false\n focusInsideRef.current = false\n scheduleHoverExpanded(true)\n ;(document.activeElement as HTMLElement | null)?.blur?.()\n }\n\n if (collapsible === 'none') {\n return (\n <div\n data-slot=\"sidebar\"\n className={cn('flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground', className)}\n {...props}\n >\n {children}\n </div>\n )\n }\n\n if (isMobile) {\n return (\n <Drawer open={openMobile} onOpenChange={setOpenMobile} direction={side} size=\"sm\">\n <DrawerContent\n data-sidebar=\"sidebar\"\n data-slot=\"sidebar\"\n data-mobile=\"true\"\n className=\"h-full w-(--sidebar-width) rounded-none bg-sidebar p-0 text-sidebar-foreground\"\n style={\n {\n '--sidebar-width': SIDEBAR_WIDTH_MOBILE\n } as React.CSSProperties\n }\n {...props}\n >\n <DrawerHeader className=\"sr-only\">\n <DrawerTitle>Sidebar</DrawerTitle>\n <DrawerDescription>Displays the mobile sidebar.</DrawerDescription>\n </DrawerHeader>\n <div className=\"flex h-full w-full flex-col\">{children}</div>\n </DrawerContent>\n </Drawer>\n )\n }\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: Tracks pointer/focus presence for the expandOnHover preview; it exposes no interaction of its own, descendants keep their own semantics/roles.\n <div\n className=\"group peer hidden text-sidebar-foreground md:block\"\n data-state={state}\n data-collapsible={state === 'collapsed' && !effectiveHoverExpanded ? collapsible : ''}\n data-collapsible-raw={state === 'collapsed' ? collapsible : ''}\n data-hover-expanded={effectiveHoverExpanded ? 'true' : undefined}\n data-variant={variant}\n data-side={side}\n data-slot=\"sidebar\"\n ref={sidebarRef}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n >\n {/* This is what handles the sidebar gap on desktop */}\n <div\n data-slot=\"sidebar-gap\"\n className={cn(\n 'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear',\n 'group-data-[collapsible-raw=offcanvas]:w-0',\n 'group-data-[side=right]:rotate-180',\n variant === 'floating' || variant === 'inset'\n ? 'group-data-[collapsible-raw=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'\n : 'group-data-[collapsible-raw=icon]:w-(--sidebar-width-icon)'\n )}\n />\n <div\n data-slot=\"sidebar-container\"\n data-side={side}\n className={cn(\n 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',\n 'data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:-left-(--sidebar-width)',\n 'data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:-right-(--sidebar-width)',\n // Adjust the padding for floating and inset variants, and the fixed (animatable) offset that\n // centers collapsed menu buttons: (menu width - button width) / 2.\n variant === 'floating' || variant === 'inset'\n ? [\n 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]',\n '[--sidebar-menu-button-collapsed-offset:calc((var(--sidebar-width-icon)+2px-(--spacing(4))-2rem)/2)]'\n ]\n : [\n 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',\n '[--sidebar-menu-button-collapsed-offset:calc((var(--sidebar-width-icon)-(--spacing(4))-2rem)/2)]'\n ],\n variant !== 'floating' &&\n variant !== 'inset' &&\n 'group-data-[side=left]:border-r group-data-[side=right]:border-l',\n 'group-data-[hover-expanded=true]:shadow-lg group-data-[hover-expanded=true]:ring-1 group-data-[hover-expanded=true]:ring-foreground/10',\n className\n )}\n {...props}\n >\n <div\n data-sidebar=\"sidebar\"\n data-slot=\"sidebar-inner\"\n className={cn(\n 'flex size-full flex-col bg-sidebar',\n 'group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm',\n 'group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border'\n )}\n >\n {children}\n </div>\n </div>\n </div>\n )\n}\n\nfunction SidebarTrigger({ className, onClick, asChild = false, children, ...props }: SidebarTriggerProps) {\n const { toggleSidebar, open, isHoverExpanded } = useSidebar()\n const hoverPreview = React.useContext(SidebarHoverPreviewContext)\n\n return (\n <Button\n data-sidebar=\"trigger\"\n data-slot=\"sidebar-trigger\"\n variant=\"ghost\"\n size=\"icon-sm\"\n color=\"zinc\"\n asChild={asChild}\n className={cn(className)}\n onClick={(event) => {\n onClick?.(event)\n if (event.defaultPrevented) return\n // During the hover preview the sidebar looks open, so the trigger closes it (the rail pins it).\n if (isHoverExpanded && !open) {\n hoverPreview?.dismissHoverPreview()\n } else {\n toggleSidebar()\n }\n }}\n {...props}\n >\n {asChild ? (\n children\n ) : (\n <>\n <IconLayoutSidebar />\n <span className=\"sr-only\">Toggle Sidebar</span>\n </>\n )}\n </Button>\n )\n}\n\nfunction SidebarRail({ className, ...props }: SidebarRailProps) {\n const { toggleSidebar, open, setOpen, isHoverExpanded } = useSidebar()\n\n const handleClick = () => {\n if (isHoverExpanded && !open) {\n setOpen(true)\n } else {\n toggleSidebar()\n }\n }\n\n return (\n <button\n data-sidebar=\"rail\"\n data-slot=\"sidebar-rail\"\n aria-label=\"Toggle Sidebar\"\n tabIndex={-1}\n onClick={handleClick}\n title=\"Toggle Sidebar\"\n className={cn(\n 'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',\n 'absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:s-1/2 after:w-0.5 hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2',\n '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',\n 'group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar',\n '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',\n '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarInset({ className, ...props }: SidebarInsetProps) {\n return (\n <main\n data-slot=\"sidebar-inset\"\n className={cn(\n 'relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarInput({ className, ...props }: SidebarInputProps) {\n return (\n <Input\n data-slot=\"sidebar-input\"\n data-sidebar=\"input\"\n className={cn('h-8 w-full bg-background shadow-none', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarHeader({ className, ...props }: SidebarHeaderProps) {\n return (\n <div\n data-slot=\"sidebar-header\"\n data-sidebar=\"header\"\n className={cn('flex flex-col gap-2 p-2', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarFooter({ className, ...props }: SidebarFooterProps) {\n return (\n <div\n data-slot=\"sidebar-footer\"\n data-sidebar=\"footer\"\n className={cn('flex flex-col gap-2 p-2', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarSeparator({ className, ...props }: SidebarSeparatorProps) {\n return (\n <Separator\n data-slot=\"sidebar-separator\"\n data-sidebar=\"separator\"\n className={(state) => cn('w-auto bg-sidebar-border', resolveClassName(className, state))}\n {...props}\n />\n )\n}\n\nfunction SidebarContent({ className, ...props }: SidebarContentProps) {\n return (\n <div\n data-slot=\"sidebar-content\"\n data-sidebar=\"content\"\n className={cn(\n 'no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarGroup({ className, ...props }: SidebarGroupProps) {\n return (\n <div\n data-slot=\"sidebar-group\"\n data-sidebar=\"group\"\n className={cn('relative flex w-full min-w-0 flex-col px-2', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarGroupLabel({ className, ...props }: SidebarGroupLabelProps) {\n return useAsChild('div', {\n 'data-slot': 'sidebar-group-label',\n 'data-sidebar': 'group-label',\n className: cn(\n 'flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:pointer-events-none group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',\n className\n ),\n ...props\n })\n}\n\nfunction SidebarGroupAction({ className, ...props }: SidebarGroupActionProps) {\n return useAsChild('button', {\n 'data-slot': 'sidebar-group-action',\n 'data-sidebar': 'group-action',\n className: cn(\n 'absolute top-1.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',\n className\n ),\n ...props\n })\n}\n\nfunction SidebarGroupContent({ className, ...props }: SidebarGroupContentProps) {\n return (\n <div\n data-slot=\"sidebar-group-content\"\n data-sidebar=\"group-content\"\n className={cn('w-full text-sm mt-2', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenu({ className, ...props }: SidebarMenuProps) {\n return (\n <ul\n data-slot=\"sidebar-menu\"\n data-sidebar=\"menu\"\n className={cn('flex w-full min-w-0 flex-col gap-0', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuItem({ className, ...props }: SidebarMenuItemProps) {\n return (\n <li\n data-slot=\"sidebar-menu-item\"\n data-sidebar=\"menu-item\"\n className={cn('group/menu-item relative', className)}\n {...props}\n />\n )\n}\n\nconst sidebarMenuButtonVariants = cva(\n 'peer/menu-button group/menu-button font-medium flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding,margin] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:ml-(--sidebar-menu-button-collapsed-offset) group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-popup-open:hover:bg-sidebar-accent data-popup-open:hover:text-sidebar-accent-foreground data-panel-open:hover:bg-sidebar-accent data-panel-open:hover:text-sidebar-accent-foreground data-active:[&_svg]:text-sidebar-primary data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate',\n {\n variants: {\n variant: {\n default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',\n outline:\n 'bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]'\n },\n size: {\n md: 'h-8 text-sm',\n sm: 'h-7 text-xs',\n lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!'\n }\n },\n defaultVariants: {\n variant: 'default',\n size: 'md'\n }\n }\n)\n\nexport type SidebarMenuButtonProps = AsChildProps<'button'> & {\n /**\n * Marks the item as the current page.\n * @default false\n */\n isActive?: boolean\n /** Label (or tooltip content props) shown when the sidebar is collapsed to icons. */\n tooltip?: string | React.ComponentProps<typeof TooltipContent>\n} & VariantProps<typeof sidebarMenuButtonVariants>\n\nexport type SidebarMenuActionProps = AsChildProps<'button'> & {\n /**\n * On desktop, hides the action until the menu item is hovered or focused.\n * @default false\n */\n showOnHover?: boolean\n}\n\nexport type SidebarMenuBadgeProps = React.ComponentProps<'div'>\n\nexport type SidebarMenuSkeletonProps = React.ComponentProps<'div'> & {\n /**\n * Adds an icon placeholder before the text.\n * @default false\n */\n showIcon?: boolean\n}\n\nexport type SidebarMenuSubProps = React.ComponentProps<'ul'>\n\nexport type SidebarMenuSubItemProps = React.ComponentProps<'li'>\n\nexport type SidebarMenuSubButtonProps = AsChildProps<'a'> & {\n /**\n * Text size of the sub-item.\n * @default 'md'\n */\n size?: 'sm' | 'md'\n /**\n * Marks the sub-item as the current page.\n * @default false\n */\n isActive?: boolean\n}\n\nfunction SidebarMenuButton({\n asChild = false,\n isActive = false,\n variant = 'default',\n size = 'md',\n tooltip,\n className,\n ...props\n}: SidebarMenuButtonProps) {\n const { isMobile, state, isHoverExpanded } = useSidebar()\n\n const button = useAsChild('button', {\n asChild,\n 'data-slot': 'sidebar-menu-button',\n 'data-sidebar': 'menu-button',\n 'data-size': size,\n 'data-active': isActive,\n className: cn(sidebarMenuButtonVariants({ variant, size }), className),\n ...props\n })\n\n if (!tooltip) {\n return button\n }\n\n if (typeof tooltip === 'string') {\n tooltip = {\n children: tooltip\n }\n }\n\n return (\n <Tooltip\n label={tooltip.children}\n side=\"right\"\n align=\"center\"\n hidden={state !== 'collapsed' || isMobile || isHoverExpanded}\n {...tooltip}\n >\n {button}\n </Tooltip>\n )\n}\n\nfunction SidebarMenuAction({ className, showOnHover = false, ...props }: SidebarMenuActionProps) {\n return useAsChild('button', {\n 'data-slot': 'sidebar-menu-action',\n 'data-sidebar': 'menu-action',\n className: cn(\n 'absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=md]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',\n showOnHover &&\n 'group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0',\n className\n ),\n ...props\n })\n}\n\nfunction SidebarMenuBadge({ className, ...props }: SidebarMenuBadgeProps) {\n return (\n <div\n data-slot=\"sidebar-menu-badge\"\n data-sidebar=\"menu-badge\"\n className={cn(\n 'pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=md]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction getSkeletonWidth(seed: string) {\n let hash = 0\n for (const char of seed) {\n hash = (hash * 31 + char.charCodeAt(0)) | 0\n }\n return `${(Math.abs(hash) % 40) + 50}%`\n}\n\nfunction SidebarMenuSkeleton({ className, showIcon = false, ...props }: SidebarMenuSkeletonProps) {\n // Width between 50 and 90%, derived from the id so the server and client render the same value.\n const id = React.useId()\n const width = React.useMemo(() => getSkeletonWidth(id), [id])\n\n return (\n <div\n data-slot=\"sidebar-menu-skeleton\"\n data-sidebar=\"menu-skeleton\"\n className={cn('flex h-8 items-center gap-2 rounded-md px-2', className)}\n {...props}\n >\n {showIcon && <Skeleton className=\"size-4 rounded-md\" data-sidebar=\"menu-skeleton-icon\" />}\n <Skeleton\n className=\"h-4 max-w-(--skeleton-width) flex-1\"\n data-sidebar=\"menu-skeleton-text\"\n style={\n {\n '--skeleton-width': width\n } as React.CSSProperties\n }\n />\n </div>\n )\n}\n\nfunction SidebarMenuSub({ className, ...props }: SidebarMenuSubProps) {\n return (\n <ul\n data-slot=\"sidebar-menu-sub\"\n data-sidebar=\"menu-sub\"\n className={cn(\n 'mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSubItem({ className, ...props }: SidebarMenuSubItemProps) {\n return (\n <li\n data-slot=\"sidebar-menu-sub-item\"\n data-sidebar=\"menu-sub-item\"\n className={cn('group/menu-sub-item relative', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSubButton({ size = 'md', isActive = false, className, ...props }: SidebarMenuSubButtonProps) {\n return useAsChild('a', {\n 'data-slot': 'sidebar-menu-sub-button',\n 'data-sidebar': 'menu-sub-button',\n 'data-size': size,\n 'data-active': isActive,\n className: cn(\n 'flex h-7 min-w-0 -translate-x-px items-center font-medium gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground',\n className\n ),\n ...props\n })\n}\n\nexport {\n Sidebar,\n SidebarContent,\n SidebarFooter,\n SidebarGroup,\n SidebarGroupAction,\n SidebarGroupContent,\n SidebarGroupLabel,\n SidebarHeader,\n SidebarInput,\n SidebarInset,\n SidebarMenu,\n SidebarMenuAction,\n SidebarMenuBadge,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarMenuSkeleton,\n SidebarMenuSub,\n SidebarMenuSubButton,\n SidebarMenuSubItem,\n SidebarProvider,\n SidebarRail,\n SidebarSeparator,\n SidebarTrigger,\n useSidebar\n}\n"],"mappings":"A,4tBAgBA,MA0BME,EAAiBD,EAAM,cAA0C,IAAI,EAUrEE,EAA6BF,EAAM,cAAsD,IAAI,EA2EnG,SAAS,YAAa,CACpB,IAAMG,EAAUH,EAAM,WAAWC,CAAc,EAC/C,GAAI,CAACE,EACH,MAAU,MAAM,mDAAmD,EAGrE,OAAOA,CACT,CAEA,SAAS,kBAAkB,EAA4B,CACrD,OAAOC,aAAkB,SAAWA,EAAO,QAAQ,kDAAkD,IAAM,IAC7G,CAEA,SAAS,gBAAgB,CACvB,cAAc,GACd,KAAMC,EACN,aAAcC,EACd,gBAAgB,GAChB,uBAAuB,IACvB,wBAAw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E,EAAQ/E,EAAM,YAAc,iBAAiB8E,CAAE,EAAG,CAACA,CAAE,CAAC,EAE5D,MACE,kBAAC,MAAD,CACE,YAAU,wBACV,eAAa,gBACb,UAAW9C,EAAG,8CAA+CC,CAAS,EACtE,GAAI1B,EAJN,SAAA,CAMGyE,GAAY,kBAACC,EAAD,CAAU,UAAU,oBAAoB,eAAa,oBAAsB,CAAA,EACxF,kBAACA,EAAD,CACE,UAAU,sCACV,eAAa,qBACb,MACE,CACE,mBAAoBF,CACtB,CAEH,CAAA,CACE,C,EAET,CAEA,SAAS,eAAe,CAAE,YAAW,GAAGxE,GAA8B,CACpE,MACE,kBAAC,KAAD,CACE,YAAU,mBACV,eAAa,WACb,UAAWyB,EACT,sIACAC,CACF,EACA,GAAI1B,CACL,CAAA,CAEL,CAEA,SAAS,mBAAmB,CAAE,YAAW,GAAGA,GAAkC,CAC5E,MACE,kBAAC,KAAD,CACE,YAAU,wBACV,eAAa,gBACb,UAAWyB,EAAG,+BAAgCC,CAAS,EACvD,GAAI1B,CACL,CAAA,CAEL,CAEA,SAAS,qBAAqB,CAAE,OAAO,KAAM,WAAW,GAAO,YAAW,GAAGA,GAAoC,CAC/G,OAAO2D,EAAW,IAAK,CACrB,YAAa,0BACb,eAAgB,kBAChB,YAAaI,EACb,cAAeC,EACf,UAAWvC,EACT,wpBACAC,CACF,EACA,GAAG1B,CACL,CAAC,CACH,C"}
|
|
1
|
+
{"version":3,"file":"sidebar.js","names":["resolveClassName","React","SidebarContext","SidebarHoverPreviewContext","context","target","openProp","setOpenProp","props","isMobile","useIsMobile","openMobile","setOpenMobile","isHoverExpanded","setIsHoverExpanded","hoverSuppressedRef","dismissHoverPreview","expandOnHover","_open","_setOpen","defaultOpen","open","setOpen","openState","value","toggleSidebar","event","state","contextValue","hoverExpandOpenDelay","hoverExpandCloseDelay","hoverPreviewContextValue","style","cn","className","canHoverExpand","collapsible","effectiveHoverExpanded","pointerInsideRef","focusInsideRef","openTimeoutRef","closeTimeoutRef","pointerModalityRef","sidebarRef","suppressedRef","scheduleHoverExpanded","shouldExpand","immediate","setHoverExpanded","timeoutRef","sidebar","Drawer","side","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","variant","hoverPreview","Button","onClick","asChild","children","Fragment","IconLayoutSidebar","Input","Separator","useAsChild","sidebarMenuButtonVariants","cva","button","size","isActive","tooltip","Tooltip","showOnHover","hash","char","seed","id","width","showIcon","Skeleton"],"sources":["../../src/components/sidebar.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { IconLayoutSidebar } from '@tabler/icons-react'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { useIsMobile } from '../hooks/use-mobile'\nimport { type AsChildProps, useAsChild } from '../lib/as-child'\nimport { cn } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\nimport { Button } from './button'\nimport { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle } from './drawer'\nimport { Input } from './input'\nimport { Separator } from './separator'\nimport { Skeleton } from './skeleton'\nimport { Tooltip, type TooltipContent } from './tooltip'\n\nconst SIDEBAR_COOKIE_NAME = 'sidebar_state'\nconst SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7\nconst SIDEBAR_WIDTH = '16rem'\nconst SIDEBAR_WIDTH_MOBILE = '18rem'\nconst SIDEBAR_WIDTH_ICON = '3rem'\nconst SIDEBAR_KEYBOARD_SHORTCUT = 'b'\nconst SIDEBAR_HOVER_EXPAND_OPEN_DELAY = 150\nconst SIDEBAR_HOVER_EXPAND_CLOSE_DELAY = 300\nconst SIDEBAR_TEXT_FIELD_SELECTOR =\n 'textarea, select, [contenteditable]:not([contenteditable=\"false\"]), input:not([type=\"button\"], [type=\"checkbox\"], [type=\"radio\"], [type=\"reset\"], [type=\"submit\"])'\n\ntype SidebarContextProps = {\n state: 'expanded' | 'collapsed'\n open: boolean\n setOpen: (open: boolean) => void\n openMobile: boolean\n setOpenMobile: (open: boolean) => void\n isMobile: boolean\n toggleSidebar: () => void\n expandOnHover: boolean\n isHoverExpanded: boolean\n setHoverExpanded: (hoverExpanded: boolean) => void\n hoverExpandOpenDelay: number\n hoverExpandCloseDelay: number\n}\n\nconst SidebarContext = React.createContext<SidebarContextProps | null>(null)\n\n// Internal (not exposed through `useSidebar`): lets a toggle dismiss the hover preview and keep it\n// suppressed until the pointer crosses the sidebar boundary again, so it doesn't reopen right away\n// under a cursor that is still over the sidebar.\ntype SidebarHoverPreviewContextProps = {\n suppressedRef: React.RefObject<boolean>\n dismissHoverPreview: () => void\n}\n\nconst SidebarHoverPreviewContext = React.createContext<SidebarHoverPreviewContextProps | null>(null)\n\nexport type SidebarProviderProps = React.ComponentProps<'div'> & {\n /**\n * Whether the sidebar starts expanded (uncontrolled).\n * @default true\n */\n defaultOpen?: boolean\n /** Whether the sidebar is expanded (controlled). */\n open?: boolean\n /** Called when the sidebar expands or collapses. */\n onOpenChange?: (open: boolean) => void\n /**\n * With `collapsible=\"icon\"`, shows a floating preview of the collapsed sidebar on hover or focus.\n * @default false\n */\n expandOnHover?: boolean\n /**\n * Delay in ms before the hover preview opens.\n * @default 150\n */\n hoverExpandOpenDelay?: number\n /**\n * Delay in ms before the hover preview closes.\n * @default 300\n */\n hoverExpandCloseDelay?: number\n}\n\nexport type SidebarProps = React.ComponentProps<'div'> & {\n /**\n * Edge of the screen the sidebar sits on.\n * @default 'left'\n */\n side?: 'left' | 'right'\n /**\n * `floating` adds a gap and shadow; `inset` pairs with `SidebarInset` for an inset main area.\n * @default 'sidebar'\n */\n variant?: 'sidebar' | 'floating' | 'inset'\n /**\n * `offcanvas` slides the sidebar out, `icon` shrinks it to icons, `none` keeps it open.\n * @default 'offcanvas'\n */\n collapsible?: 'offcanvas' | 'icon' | 'none'\n}\n\nexport type SidebarTriggerProps = React.ComponentProps<typeof Button>\n\nexport type SidebarRailProps = React.ComponentProps<'button'>\n\nexport type SidebarInsetProps = React.ComponentProps<'main'>\n\nexport type SidebarInputProps = React.ComponentProps<typeof Input>\n\nexport type SidebarHeaderProps = React.ComponentProps<'div'>\n\nexport type SidebarFooterProps = React.ComponentProps<'div'>\n\nexport type SidebarSeparatorProps = React.ComponentProps<typeof Separator>\n\nexport type SidebarContentProps = React.ComponentProps<'div'>\n\nexport type SidebarGroupProps = React.ComponentProps<'div'>\n\nexport type SidebarGroupLabelProps = AsChildProps<'div'>\n\nexport type SidebarGroupActionProps = AsChildProps<'button'>\n\nexport type SidebarGroupContentProps = React.ComponentProps<'div'>\n\nexport type SidebarMenuProps = React.ComponentProps<'ul'>\n\nexport type SidebarMenuItemProps = React.ComponentProps<'li'>\n\nfunction useSidebar() {\n const context = React.useContext(SidebarContext)\n if (!context) {\n throw new Error('useSidebar must be used within a SidebarProvider.')\n }\n\n return context\n}\n\nfunction isEditableContent(target: EventTarget | null) {\n return target instanceof Element && target.closest('[contenteditable]:not([contenteditable=\"false\"])') !== null\n}\n\nfunction SidebarProvider({\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n expandOnHover = false,\n hoverExpandOpenDelay = SIDEBAR_HOVER_EXPAND_OPEN_DELAY,\n hoverExpandCloseDelay = SIDEBAR_HOVER_EXPAND_CLOSE_DELAY,\n className,\n style,\n children,\n ...props\n}: SidebarProviderProps) {\n const isMobile = useIsMobile()\n const [openMobile, setOpenMobile] = React.useState(false)\n const [isHoverExpanded, setIsHoverExpanded] = React.useState(false)\n const hoverSuppressedRef = React.useRef(false)\n\n const dismissHoverPreview = React.useCallback(() => {\n hoverSuppressedRef.current = true\n setIsHoverExpanded(false)\n }, [])\n\n React.useEffect(() => {\n if (!expandOnHover) setIsHoverExpanded(false)\n }, [expandOnHover])\n\n // This is the internal state of the sidebar.\n // We use openProp and setOpenProp for control from outside the component.\n const [_open, _setOpen] = React.useState(defaultOpen)\n const open = openProp ?? _open\n const setOpen = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const openState = typeof value === 'function' ? value(open) : value\n // Collapsing while hovered would otherwise fall straight back into the hover preview.\n if (open && !openState) dismissHoverPreview()\n if (setOpenProp) {\n setOpenProp(openState)\n } else {\n _setOpen(openState)\n }\n\n // This sets the cookie to keep the sidebar state.\n // biome-ignore lint/suspicious/noDocumentCookie: This package persists a simple UI preference cookie without framework-specific APIs.\n document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`\n },\n [setOpenProp, open, dismissHoverPreview]\n )\n\n // Helper to toggle the sidebar.\n const toggleSidebar = React.useCallback(() => {\n return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)\n }, [isMobile, setOpen])\n\n // Adds a keyboard shortcut to toggle the sidebar.\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n // Rich text editors use the same shortcut (bold), so leave it to them when they handle it or own the focus.\n if (event.defaultPrevented || isEditableContent(event.target)) return\n if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {\n event.preventDefault()\n toggleSidebar()\n }\n }\n\n window.addEventListener('keydown', handleKeyDown)\n return () => window.removeEventListener('keydown', handleKeyDown)\n }, [toggleSidebar])\n\n // We add a state so that we can do data-state=\"expanded\" or \"collapsed\".\n // This makes it easier to style the sidebar with Tailwind classes.\n const state = open ? 'expanded' : 'collapsed'\n\n const contextValue = React.useMemo<SidebarContextProps>(\n () => ({\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n expandOnHover,\n isHoverExpanded,\n setHoverExpanded: setIsHoverExpanded,\n hoverExpandOpenDelay,\n hoverExpandCloseDelay\n }),\n [\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n toggleSidebar,\n expandOnHover,\n isHoverExpanded,\n hoverExpandOpenDelay,\n hoverExpandCloseDelay\n ]\n )\n\n const hoverPreviewContextValue = React.useMemo<SidebarHoverPreviewContextProps>(\n () => ({ suppressedRef: hoverSuppressedRef, dismissHoverPreview }),\n [dismissHoverPreview]\n )\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <SidebarHoverPreviewContext.Provider value={hoverPreviewContextValue}>\n <div\n data-slot=\"sidebar-wrapper\"\n style={\n {\n '--sidebar-width': SIDEBAR_WIDTH,\n '--sidebar-width-icon': SIDEBAR_WIDTH_ICON,\n ...style\n } as React.CSSProperties\n }\n className={cn(\n 'group/sidebar-wrapper relative flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar',\n className\n )}\n {...props}\n >\n {children}\n </div>\n </SidebarHoverPreviewContext.Provider>\n </SidebarContext.Provider>\n )\n}\n\nfunction Sidebar({\n side = 'left',\n variant = 'sidebar',\n collapsible = 'offcanvas',\n className,\n children,\n ...props\n}: SidebarProps) {\n const {\n isMobile,\n state,\n openMobile,\n setOpenMobile,\n expandOnHover,\n isHoverExpanded,\n setHoverExpanded,\n hoverExpandOpenDelay,\n hoverExpandCloseDelay\n } = useSidebar()\n\n const canHoverExpand = expandOnHover && collapsible === 'icon'\n const effectiveHoverExpanded = canHoverExpand && isHoverExpanded\n\n const pointerInsideRef = React.useRef(false)\n const focusInsideRef = React.useRef(false)\n const openTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n const closeTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n const pointerModalityRef = React.useRef(false)\n const sidebarRef = React.useRef<HTMLDivElement>(null)\n const hoverPreview = React.useContext(SidebarHoverPreviewContext)\n const suppressedRef = hoverPreview?.suppressedRef\n\n const scheduleHoverExpanded = React.useCallback(\n (immediate = false) => {\n if (openTimeoutRef.current) {\n clearTimeout(openTimeoutRef.current)\n openTimeoutRef.current = null\n }\n if (closeTimeoutRef.current) {\n clearTimeout(closeTimeoutRef.current)\n closeTimeoutRef.current = null\n }\n\n const shouldExpand = !suppressedRef?.current && (pointerInsideRef.current || focusInsideRef.current)\n\n if (immediate) {\n setHoverExpanded(shouldExpand)\n return\n }\n\n const timeoutRef = shouldExpand ? openTimeoutRef : closeTimeoutRef\n const delay = shouldExpand ? hoverExpandOpenDelay : hoverExpandCloseDelay\n timeoutRef.current = setTimeout(() => {\n timeoutRef.current = null\n // Re-checked on fire: a toggle may have dismissed the preview after this was scheduled.\n setHoverExpanded(shouldExpand && !suppressedRef?.current)\n }, delay)\n },\n [setHoverExpanded, hoverExpandOpenDelay, hoverExpandCloseDelay, suppressedRef]\n )\n\n // Tracks whether the latest input came from a pointer or the keyboard, so focus moved by a click (or\n // returned by an overlay closed with a click) doesn't hold the preview open like keyboard focus does.\n React.useEffect(() => {\n if (!canHoverExpand) return\n const handlePointerDown = () => {\n pointerModalityRef.current = true\n }\n const handleKeyDown = () => {\n pointerModalityRef.current = false\n }\n document.addEventListener('pointerdown', handlePointerDown, true)\n document.addEventListener('keydown', handleKeyDown, true)\n return () => {\n document.removeEventListener('pointerdown', handlePointerDown, true)\n document.removeEventListener('keydown', handleKeyDown, true)\n }\n }, [canHoverExpand])\n\n // Hover is tracked with native DOM events rather than React's synthetic ones: React bubbles\n // enter/leave through portals, so hovering a portaled menu counted as hovering the sidebar, and when\n // that menu unmounted under the cursor no leave ever fired, leaving the preview stuck open.\n React.useEffect(() => {\n const sidebar = sidebarRef.current\n if (!canHoverExpand || isMobile || !sidebar) return\n // Crossing the sidebar boundary in either direction lifts a toggle's preview suppression.\n const handleMouseEnter = () => {\n pointerInsideRef.current = true\n if (suppressedRef) suppressedRef.current = false\n scheduleHoverExpanded()\n }\n const handleMouseLeave = () => {\n pointerInsideRef.current = false\n if (suppressedRef) suppressedRef.current = false\n scheduleHoverExpanded()\n }\n sidebar.addEventListener('mouseenter', handleMouseEnter)\n sidebar.addEventListener('mouseleave', handleMouseLeave)\n return () => {\n sidebar.removeEventListener('mouseenter', handleMouseEnter)\n sidebar.removeEventListener('mouseleave', handleMouseLeave)\n }\n }, [canHoverExpand, isMobile, scheduleHoverExpanded, suppressedRef])\n\n React.useEffect(() => {\n return () => {\n if (openTimeoutRef.current) clearTimeout(openTimeoutRef.current)\n if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current)\n setHoverExpanded(false)\n }\n }, [setHoverExpanded])\n\n // Switching to mobile never fires a mouse leave, so drop the preview there; otherwise the trigger would\n // treat the first tap as \"close the preview\" instead of opening the drawer.\n React.useEffect(() => {\n if (!isMobile) return\n if (openTimeoutRef.current) clearTimeout(openTimeoutRef.current)\n if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current)\n openTimeoutRef.current = null\n closeTimeoutRef.current = null\n pointerInsideRef.current = false\n focusInsideRef.current = false\n setHoverExpanded(false)\n }, [isMobile, setHoverExpanded])\n\n const handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (!canHoverExpand) return\n // Only keyboard focus holds the preview open, so clicking an item doesn't pin it after the pointer\n // leaves. Text fields always hold it (the user is about to type), and so does focus that lands\n // outside the sidebar's DOM (a portaled menu or popover opened from inside it), so the preview\n // doesn't collapse under an open overlay.\n const target = event.target as HTMLElement\n focusInsideRef.current =\n !pointerModalityRef.current ||\n !event.currentTarget.contains(target) ||\n target.matches(SIDEBAR_TEXT_FIELD_SELECTOR)\n // Keyboard focus is a deliberate way back into the sidebar, so it also lifts a toggle's suppression.\n if (!pointerModalityRef.current && suppressedRef) suppressedRef.current = false\n scheduleHoverExpanded()\n }\n const handleBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (!canHoverExpand) return\n if (event.currentTarget.contains(event.relatedTarget as Node | null)) return\n focusInsideRef.current = false\n scheduleHoverExpanded()\n }\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!canHoverExpand || event.key !== 'Escape' || !isHoverExpanded) return\n pointerInsideRef.current = false\n focusInsideRef.current = false\n scheduleHoverExpanded(true)\n ;(document.activeElement as HTMLElement | null)?.blur?.()\n }\n\n if (collapsible === 'none') {\n return (\n <div\n data-slot=\"sidebar\"\n className={cn('flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground', className)}\n {...props}\n >\n {children}\n </div>\n )\n }\n\n if (isMobile) {\n return (\n <Drawer open={openMobile} onOpenChange={setOpenMobile} direction={side} size=\"sm\">\n <DrawerContent\n data-sidebar=\"sidebar\"\n data-slot=\"sidebar\"\n data-mobile=\"true\"\n className=\"h-full w-(--sidebar-width) rounded-none bg-sidebar p-0 text-sidebar-foreground\"\n style={\n {\n '--sidebar-width': SIDEBAR_WIDTH_MOBILE\n } as React.CSSProperties\n }\n {...props}\n >\n <DrawerHeader className=\"sr-only\">\n <DrawerTitle>Sidebar</DrawerTitle>\n <DrawerDescription>Displays the mobile sidebar.</DrawerDescription>\n </DrawerHeader>\n <div className=\"flex h-full w-full flex-col\">{children}</div>\n </DrawerContent>\n </Drawer>\n )\n }\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: Tracks pointer/focus presence for the expandOnHover preview; it exposes no interaction of its own, descendants keep their own semantics/roles.\n <div\n className=\"group peer hidden text-sidebar-foreground md:block\"\n data-state={state}\n data-collapsible={state === 'collapsed' && !effectiveHoverExpanded ? collapsible : ''}\n data-collapsible-raw={state === 'collapsed' ? collapsible : ''}\n data-hover-expanded={effectiveHoverExpanded ? 'true' : undefined}\n data-variant={variant}\n data-side={side}\n data-slot=\"sidebar\"\n ref={sidebarRef}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n >\n {/* This is what handles the sidebar gap on desktop */}\n <div\n data-slot=\"sidebar-gap\"\n className={cn(\n 'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear',\n 'group-data-[collapsible-raw=offcanvas]:w-0',\n 'group-data-[side=right]:rotate-180',\n variant === 'floating' || variant === 'inset'\n ? 'group-data-[collapsible-raw=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'\n : 'group-data-[collapsible-raw=icon]:w-(--sidebar-width-icon)'\n )}\n />\n <div\n data-slot=\"sidebar-container\"\n data-side={side}\n className={cn(\n 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',\n 'data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:-left-(--sidebar-width)',\n 'data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:-right-(--sidebar-width)',\n // Adjust the padding for floating and inset variants, and the fixed (animatable) offset that\n // centers collapsed menu buttons: (menu width - button width) / 2.\n variant === 'floating' || variant === 'inset'\n ? [\n 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]',\n '[--sidebar-menu-button-collapsed-offset:calc((var(--sidebar-width-icon)+2px-(--spacing(4))-2rem)/2)]'\n ]\n : [\n 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',\n '[--sidebar-menu-button-collapsed-offset:calc((var(--sidebar-width-icon)-(--spacing(4))-2rem)/2)]'\n ],\n variant !== 'floating' &&\n variant !== 'inset' &&\n 'group-data-[side=left]:border-r group-data-[side=right]:border-l',\n 'group-data-[hover-expanded=true]:shadow-lg group-data-[hover-expanded=true]:ring-1 group-data-[hover-expanded=true]:ring-foreground/10',\n className\n )}\n {...props}\n >\n <div\n data-sidebar=\"sidebar\"\n data-slot=\"sidebar-inner\"\n className={cn(\n 'flex size-full flex-col bg-sidebar',\n 'group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm',\n 'group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border'\n )}\n >\n {children}\n </div>\n </div>\n </div>\n )\n}\n\nfunction SidebarTrigger({ className, onClick, asChild = false, children, ...props }: SidebarTriggerProps) {\n const { toggleSidebar, open, isHoverExpanded } = useSidebar()\n const hoverPreview = React.useContext(SidebarHoverPreviewContext)\n\n return (\n <Button\n data-sidebar=\"trigger\"\n data-slot=\"sidebar-trigger\"\n variant=\"ghost\"\n size=\"icon-sm\"\n color=\"zinc\"\n asChild={asChild}\n className={cn(className)}\n onClick={(event) => {\n onClick?.(event)\n if (event.defaultPrevented) return\n // During the hover preview the sidebar looks open, so the trigger closes it (the rail pins it).\n if (isHoverExpanded && !open) {\n hoverPreview?.dismissHoverPreview()\n } else {\n toggleSidebar()\n }\n }}\n {...props}\n >\n {asChild ? (\n children\n ) : (\n <>\n <IconLayoutSidebar />\n <span className=\"sr-only\">Toggle Sidebar</span>\n </>\n )}\n </Button>\n )\n}\n\nfunction SidebarRail({ className, ...props }: SidebarRailProps) {\n const { toggleSidebar, open, setOpen, isHoverExpanded } = useSidebar()\n\n const handleClick = () => {\n if (isHoverExpanded && !open) {\n setOpen(true)\n } else {\n toggleSidebar()\n }\n }\n\n return (\n <button\n data-sidebar=\"rail\"\n data-slot=\"sidebar-rail\"\n aria-label=\"Toggle Sidebar\"\n tabIndex={-1}\n onClick={handleClick}\n title=\"Toggle Sidebar\"\n className={cn(\n 'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',\n 'absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:s-1/2 after:w-0.5 hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2',\n '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',\n 'group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar',\n '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',\n '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarInset({ className, ...props }: SidebarInsetProps) {\n return (\n <main\n data-slot=\"sidebar-inset\"\n className={cn(\n 'relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarInput({ className, ...props }: SidebarInputProps) {\n return (\n <Input\n data-slot=\"sidebar-input\"\n data-sidebar=\"input\"\n className={cn('h-8 w-full bg-background shadow-none', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarHeader({ className, ...props }: SidebarHeaderProps) {\n return (\n <div\n data-slot=\"sidebar-header\"\n data-sidebar=\"header\"\n className={cn('flex flex-col gap-2 p-2', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarFooter({ className, ...props }: SidebarFooterProps) {\n return (\n <div\n data-slot=\"sidebar-footer\"\n data-sidebar=\"footer\"\n className={cn('flex flex-col gap-2 p-2', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarSeparator({ className, ...props }: SidebarSeparatorProps) {\n return (\n <Separator\n data-slot=\"sidebar-separator\"\n data-sidebar=\"separator\"\n className={(state) => cn('w-auto bg-sidebar-border', resolveClassName(className, state))}\n {...props}\n />\n )\n}\n\nfunction SidebarContent({ className, ...props }: SidebarContentProps) {\n return (\n <div\n data-slot=\"sidebar-content\"\n data-sidebar=\"content\"\n className={cn(\n 'no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarGroup({ className, ...props }: SidebarGroupProps) {\n return (\n <div\n data-slot=\"sidebar-group\"\n data-sidebar=\"group\"\n className={cn('relative flex w-full min-w-0 flex-col px-2', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarGroupLabel({ className, ...props }: SidebarGroupLabelProps) {\n return useAsChild('div', {\n 'data-slot': 'sidebar-group-label',\n 'data-sidebar': 'group-label',\n className: cn(\n 'flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:pointer-events-none group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',\n className\n ),\n ...props\n })\n}\n\nfunction SidebarGroupAction({ className, ...props }: SidebarGroupActionProps) {\n return useAsChild('button', {\n 'data-slot': 'sidebar-group-action',\n 'data-sidebar': 'group-action',\n className: cn(\n 'absolute top-1.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',\n className\n ),\n ...props\n })\n}\n\nfunction SidebarGroupContent({ className, ...props }: SidebarGroupContentProps) {\n return (\n <div\n data-slot=\"sidebar-group-content\"\n data-sidebar=\"group-content\"\n className={cn('w-full text-sm mt-2', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenu({ className, ...props }: SidebarMenuProps) {\n return (\n <ul\n data-slot=\"sidebar-menu\"\n data-sidebar=\"menu\"\n className={cn('flex w-full min-w-0 flex-col gap-0', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuItem({ className, ...props }: SidebarMenuItemProps) {\n return (\n <li\n data-slot=\"sidebar-menu-item\"\n data-sidebar=\"menu-item\"\n className={cn('group/menu-item relative', className)}\n {...props}\n />\n )\n}\n\nconst sidebarMenuButtonVariants = cva(\n 'peer/menu-button group/menu-button font-medium flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding,margin] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:ml-(--sidebar-menu-button-collapsed-offset) group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-popup-open:hover:bg-sidebar-accent data-popup-open:hover:text-sidebar-accent-foreground data-panel-open:hover:bg-sidebar-accent data-panel-open:hover:text-sidebar-accent-foreground data-active:[&_svg]:text-sidebar-primary data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate',\n {\n variants: {\n variant: {\n default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',\n outline:\n 'bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]'\n },\n size: {\n md: 'h-8 text-sm',\n sm: 'h-7 text-xs',\n lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!'\n }\n },\n defaultVariants: {\n variant: 'default',\n size: 'md'\n }\n }\n)\n\nexport type SidebarMenuButtonProps = AsChildProps<'button'> & {\n /**\n * Marks the item as the current page.\n * @default false\n */\n isActive?: boolean\n /** Label (or tooltip content props) shown when the sidebar is collapsed to icons. */\n tooltip?: string | React.ComponentProps<typeof TooltipContent>\n} & VariantProps<typeof sidebarMenuButtonVariants>\n\nexport type SidebarMenuActionProps = AsChildProps<'button'> & {\n /**\n * On desktop, hides the action until the menu item is hovered or focused.\n * @default false\n */\n showOnHover?: boolean\n}\n\nexport type SidebarMenuBadgeProps = React.ComponentProps<'div'>\n\nexport type SidebarMenuSkeletonProps = React.ComponentProps<'div'> & {\n /**\n * Adds an icon placeholder before the text.\n * @default false\n */\n showIcon?: boolean\n}\n\nexport type SidebarMenuSubProps = React.ComponentProps<'ul'>\n\nexport type SidebarMenuSubItemProps = React.ComponentProps<'li'>\n\nexport type SidebarMenuSubButtonProps = AsChildProps<'a'> & {\n /**\n * Text size of the sub-item.\n * @default 'md'\n */\n size?: 'sm' | 'md'\n /**\n * Marks the sub-item as the current page.\n * @default false\n */\n isActive?: boolean\n}\n\nfunction SidebarMenuButton({\n asChild = false,\n isActive = false,\n variant = 'default',\n size = 'md',\n tooltip,\n className,\n ...props\n}: SidebarMenuButtonProps) {\n const { isMobile, state, isHoverExpanded } = useSidebar()\n\n const button = useAsChild('button', {\n asChild,\n 'data-slot': 'sidebar-menu-button',\n 'data-sidebar': 'menu-button',\n 'data-size': size,\n 'data-active': isActive,\n className: cn(sidebarMenuButtonVariants({ variant, size }), className),\n ...props\n })\n\n if (!tooltip) {\n return button\n }\n\n if (typeof tooltip === 'string') {\n tooltip = {\n children: tooltip\n }\n }\n\n return (\n <Tooltip\n label={tooltip.children}\n side=\"right\"\n align=\"center\"\n hidden={state !== 'collapsed' || isMobile || isHoverExpanded}\n {...tooltip}\n >\n {button}\n </Tooltip>\n )\n}\n\nfunction SidebarMenuAction({ className, showOnHover = false, ...props }: SidebarMenuActionProps) {\n return useAsChild('button', {\n 'data-slot': 'sidebar-menu-action',\n 'data-sidebar': 'menu-action',\n className: cn(\n 'absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=md]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',\n showOnHover &&\n 'group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0',\n className\n ),\n ...props\n })\n}\n\nfunction SidebarMenuBadge({ className, ...props }: SidebarMenuBadgeProps) {\n return (\n <div\n data-slot=\"sidebar-menu-badge\"\n data-sidebar=\"menu-badge\"\n className={cn(\n 'pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=md]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction getSkeletonWidth(seed: string) {\n let hash = 0\n for (const char of seed) {\n hash = (hash * 31 + char.charCodeAt(0)) | 0\n }\n return `${(Math.abs(hash) % 40) + 50}%`\n}\n\nfunction SidebarMenuSkeleton({ className, showIcon = false, ...props }: SidebarMenuSkeletonProps) {\n // Width between 50 and 90%, derived from the id so the server and client render the same value.\n const id = React.useId()\n const width = React.useMemo(() => getSkeletonWidth(id), [id])\n\n return (\n <div\n data-slot=\"sidebar-menu-skeleton\"\n data-sidebar=\"menu-skeleton\"\n className={cn('flex h-8 items-center gap-2 rounded-md px-2', className)}\n {...props}\n >\n {showIcon && <Skeleton className=\"size-4 rounded-md\" data-sidebar=\"menu-skeleton-icon\" />}\n <Skeleton\n className=\"h-4 max-w-(--skeleton-width) flex-1\"\n data-sidebar=\"menu-skeleton-text\"\n style={\n {\n '--skeleton-width': width\n } as React.CSSProperties\n }\n />\n </div>\n )\n}\n\nfunction SidebarMenuSub({ className, ...props }: SidebarMenuSubProps) {\n return (\n <ul\n data-slot=\"sidebar-menu-sub\"\n data-sidebar=\"menu-sub\"\n className={cn(\n 'mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSubItem({ className, ...props }: SidebarMenuSubItemProps) {\n return (\n <li\n data-slot=\"sidebar-menu-sub-item\"\n data-sidebar=\"menu-sub-item\"\n className={cn('group/menu-sub-item relative', className)}\n {...props}\n />\n )\n}\n\nfunction SidebarMenuSubButton({ size = 'md', isActive = false, className, ...props }: SidebarMenuSubButtonProps) {\n return useAsChild('a', {\n 'data-slot': 'sidebar-menu-sub-button',\n 'data-sidebar': 'menu-sub-button',\n 'data-size': size,\n 'data-active': isActive,\n className: cn(\n 'flex h-7 min-w-0 -translate-x-px items-center font-medium gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground',\n className\n ),\n ...props\n })\n}\n\nexport {\n Sidebar,\n SidebarContent,\n SidebarFooter,\n SidebarGroup,\n SidebarGroupAction,\n SidebarGroupContent,\n SidebarGroupLabel,\n SidebarHeader,\n SidebarInput,\n SidebarInset,\n SidebarMenu,\n SidebarMenuAction,\n SidebarMenuBadge,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarMenuSkeleton,\n SidebarMenuSub,\n SidebarMenuSubButton,\n SidebarMenuSubItem,\n SidebarProvider,\n SidebarRail,\n SidebarSeparator,\n SidebarTrigger,\n useSidebar\n}\n"],"mappings":"A,4tBAgBA,MA0BME,EAAiBD,EAAM,cAA0C,IAAI,EAUrEE,EAA6BF,EAAM,cAAsD,IAAI,EA2EnG,SAAS,YAAa,CACpB,IAAMG,EAAUH,EAAM,WAAWC,CAAc,EAC/C,GAAI,CAACE,EACH,MAAU,MAAM,mDAAmD,EAGrE,OAAOA,CACT,CAEA,SAAS,kBAAkB,EAA4B,CACrD,OAAOC,aAAkB,SAAWA,EAAO,QAAQ,kDAAkD,IAAM,IAC7G,CAEA,SAAS,gBAAgB,CACvB,cAAc,GACd,KAAMC,EACN,aAAcC,EACd,gBAAgB,GAChB,uBAAuB,IACvB,wBAAwB,IACxB,YACA,QACA,WACA,GAAGC,GACoB,CACvB,IAAMC,EAAWC,EAAY,EACvB,CA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D,MACE,kBAAC,MAAD,CACE,YAAU,wBACV,eAAa,gBACb,UAAW9C,EAAG,8CAA+CC,CAAS,EACtE,GAAI1B,EAJN,SAAA,CAMGyE,GAAY,kBAACC,EAAD,CAAU,UAAU,oBAAoB,eAAa,oBAAsB,CAAA,EACxF,kBAACA,EAAD,CACE,UAAU,sCACV,eAAa,qBACb,MACE,CACE,mBAAoBF,CACtB,CAEH,CAAA,CACE,C,EAET,CAEA,SAAS,eAAe,CAAE,YAAW,GAAGxE,GAA8B,CACpE,MACE,kBAAC,KAAD,CACE,YAAU,mBACV,eAAa,WACb,UAAWyB,EACT,sIACAC,CACF,EACA,GAAI1B,CACL,CAAA,CAEL,CAEA,SAAS,mBAAmB,CAAE,YAAW,GAAGA,GAAkC,CAC5E,MACE,kBAAC,KAAD,CACE,YAAU,wBACV,eAAa,gBACb,UAAWyB,EAAG,+BAAgCC,CAAS,EACvD,GAAI1B,CACL,CAAA,CAEL,CAEA,SAAS,qBAAqB,CAAE,OAAO,KAAM,WAAW,GAAO,YAAW,GAAGA,GAAoC,CAC/G,OAAO2D,EAAW,IAAK,CACrB,YAAa,0BACb,eAAgB,kBAChB,YAAaI,EACb,cAAeC,EACf,UAAWvC,EACT,wpBACAC,CACF,EACA,GAAG1B,CACL,CAAC,CACH,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{useAsChild as e}from"../lib/as-child.js";import{cn as t}from"../lib/utils.js";import{Children as n,createContext as r,isValidElement as i,useCallback as a,useContext as o,useId as s,useMemo as c,useState as l}from"react";import{jsx as u}from"react/jsx-runtime";const d=r(void 0),f=r(void 0);function useStepper(){let e=o(d);if(!e)throw Error(`useStepper must be used within a Stepper`);return e}function useStepItem(){let e=o(f);if(!e)throw Error(`useStepItem must be used within a StepperItem`);return e}function Stepper({defaultValue:e=1,value:r,onValueChange:o,orientation:f=`horizontal`,className:p,children:m,indicators:h={},...g}){let[_,v]=l(e),y=s(),b=a(e=>{r===void 0&&v(e),o?.(e)},[r,o]),x=r??_,S=a(e=>`${y}-tab-${e}`,[y]),C=a(e=>`${y}-panel-${e}`,[y]),w=c(()=>({activeStep:x,setActiveStep:b,stepsCount:n.toArray(m).filter(e=>i(e)&&e.type.displayName===`StepperItem`).length,orientation:f,indicators:h,getTriggerId:S,getContentId:C}),[x,b,m,f,h,S,C]);return/* @__PURE__ */ u(d.Provider,{value:w,children:/* @__PURE__ */ u(`div`,{role:`tablist`,"aria-orientation":f,"data-slot":`stepper`,className:t(`w-full`,p),"data-orientation":f,...g,children:m})})}function StepperItem({step:e,completed:n=!1,disabled:r=!1,loading:i=!1,className:a,children:o,...s}){let{activeStep:c}=useStepper(),l=n||e<c?`completed`:c===e?`active`:`inactive`,d=i&&e===c;return/* @__PURE__ */ u(f.Provider,{value:{step:e,state:l,isDisabled:r,isLoading:d},children:/* @__PURE__ */ u(`div`,{"data-slot":`stepper-item`,className:t(`group/step flex items-center justify-center not-last:flex-1 group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col`,a),"data-state":l,...d?{"data-loading":!0}:{},...s,children:o})})}function getStepperTriggers(e){let t=e.closest(`[data-slot="stepper"]`);return t?Array.from(t.querySelectorAll(`[data-slot="stepper-trigger"]`)).filter(e=>e.closest(`[data-slot="stepper"]`)===t&&!e.matches(`:disabled, [aria-disabled="true"]`)):[]}function StepperTrigger({asChild:n=!1,className:r,children:i,tabIndex:a,onClick:o,onKeyDown:s,...c}){let{setActiveStep:l,activeStep:u,getTriggerId:d,getContentId:f}=useStepper(),{step:p,state:m,isDisabled:h,isLoading:g}=useStepItem(),_=u===p,v=n&&h,handleClick=e=>{o?.(e)
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{useAsChild as e}from"../lib/as-child.js";import{cn as t}from"../lib/utils.js";import{Children as n,createContext as r,isValidElement as i,useCallback as a,useContext as o,useId as s,useMemo as c,useState as l}from"react";import{jsx as u}from"react/jsx-runtime";const d=r(void 0),f=r(void 0);function useStepper(){let e=o(d);if(!e)throw Error(`useStepper must be used within a Stepper`);return e}function useStepItem(){let e=o(f);if(!e)throw Error(`useStepItem must be used within a StepperItem`);return e}function Stepper({defaultValue:e=1,value:r,onValueChange:o,orientation:f=`horizontal`,className:p,children:m,indicators:h={},...g}){let[_,v]=l(e),y=s(),b=a(e=>{r===void 0&&v(e),o?.(e)},[r,o]),x=r??_,S=a(e=>`${y}-tab-${e}`,[y]),C=a(e=>`${y}-panel-${e}`,[y]),w=c(()=>({activeStep:x,setActiveStep:b,stepsCount:n.toArray(m).filter(e=>i(e)&&e.type.displayName===`StepperItem`).length,orientation:f,indicators:h,getTriggerId:S,getContentId:C}),[x,b,m,f,h,S,C]);return/* @__PURE__ */ u(d.Provider,{value:w,children:/* @__PURE__ */ u(`div`,{role:`tablist`,"aria-orientation":f,"data-slot":`stepper`,className:t(`w-full`,p),"data-orientation":f,...g,children:m})})}function StepperItem({step:e,completed:n=!1,disabled:r=!1,loading:i=!1,className:a,children:o,...s}){let{activeStep:c}=useStepper(),l=n||e<c?`completed`:c===e?`active`:`inactive`,d=i&&e===c;return/* @__PURE__ */ u(f.Provider,{value:{step:e,state:l,isDisabled:r,isLoading:d},children:/* @__PURE__ */ u(`div`,{"data-slot":`stepper-item`,className:t(`group/step flex items-center justify-center not-last:flex-1 group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col`,a),"data-state":l,...d?{"data-loading":!0}:{},...s,children:o})})}function getStepperTriggers(e){let t=e.closest(`[data-slot="stepper"]`);return t?Array.from(t.querySelectorAll(`[data-slot="stepper-trigger"]`)).filter(e=>e.closest(`[data-slot="stepper"]`)===t&&!e.matches(`:disabled, [aria-disabled="true"]`)):[]}function StepperTrigger({asChild:n=!1,className:r,children:i,tabIndex:a,onClick:o,onKeyDown:s,...c}){let{setActiveStep:l,activeStep:u,getTriggerId:d,getContentId:f}=useStepper(),{step:p,state:m,isDisabled:h,isLoading:g}=useStepItem(),_=u===p,v=n&&h,handleClick=e=>{o?.(e),e.defaultPrevented||h||l(p)},handleKeyDown=e=>{if(s?.(e),e.defaultPrevented)return;let t=getStepperTriggers(e.currentTarget),n=t.indexOf(e.currentTarget),r;switch(e.key){case`ArrowRight`:case`ArrowDown`:r=n===-1?void 0:t[(n+1)%t.length];break;case`ArrowLeft`:case`ArrowUp`:r=n===-1?void 0:t[(n-1+t.length)%t.length];break;case`Home`:r=t[0];break;case`End`:r=t[t.length-1];break;case`Enter`:case` `:e.preventDefault(),h||l(p);return;default:return}e.preventDefault(),r?.focus()};return e(`button`,{asChild:n,type:n?void 0:`button`,role:`tab`,id:d(p),"aria-selected":_,"aria-controls":f(p),"aria-disabled":v?!0:void 0,tabIndex:typeof a==`number`?a:_?0:-1,"data-slot":`stepper-trigger`,"data-state":m,"data-loading":g,disabled:n?void 0:h,className:t(`focus-visible:border-ring focus-visible:ring-ring/50 inline-flex cursor-pointer items-center outline-none focus-visible:z-10 focus-visible:ring-3 disabled:pointer-events-none disabled:opacity-60 aria-disabled:pointer-events-none aria-disabled:opacity-60`,`gap-2.5 rounded-full`,r),onClick:handleClick,onKeyDown:handleKeyDown,...c,children:i})}function StepperIndicator({children:e,className:n,...r}){let{state:i,isLoading:a}=useStepItem(),{indicators:o}=useStepper();return/* @__PURE__ */ u(`div`,{"data-slot":`stepper-indicator`,"data-state":i,className:t(`border-background bg-accent text-accent-foreground data-[state=completed]:bg-primary data-[state=completed]:text-primary-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground relative flex size-6 shrink-0 items-center justify-center overflow-hidden`,`rounded-full text-xs`,n),...r,children:/* @__PURE__ */ u(`div`,{className:`absolute`,children:o&&(a&&o.loading||i===`completed`&&o.completed||i===`active`&&o.active||i===`inactive`&&o.inactive)?a&&o.loading||i===`completed`&&o.completed||i===`active`&&o.active||i===`inactive`&&o.inactive:e})})}function StepperSeparator({className:e,...n}){let{state:r}=useStepItem();return/* @__PURE__ */ u(`div`,{"data-slot":`stepper-separator`,"data-state":r,className:t(`bg-muted rounded-sm group-data-[orientation=horizontal]/stepper-nav:h-0.5 group-data-[orientation=vertical]/stepper-nav:h-12 group-data-[orientation=vertical]/stepper-nav:w-0.5 m-0.5 group-data-[orientation=horizontal]/stepper-nav:flex-1`,e),...n})}function StepperTitle({children:e,className:n,...r}){let{state:i}=useStepItem();return/* @__PURE__ */ u(`h3`,{"data-slot":`stepper-title`,"data-state":i,className:t(`text-sm leading-none font-medium`,n),...r,children:e})}function StepperDescription({children:e,className:n,...r}){let{state:i}=useStepItem();return/* @__PURE__ */ u(`div`,{"data-slot":`stepper-description`,"data-state":i,className:t(`text-muted-foreground text-sm`,n),...r,children:e})}function StepperNav({children:e,className:n,...r}){let{activeStep:i,orientation:a}=useStepper();return/* @__PURE__ */ u(`nav`,{"data-slot":`stepper-nav`,"data-state":i,"data-orientation":a,className:t(`group/stepper-nav inline-flex data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col`,n),...r,children:e})}function StepperPanel({children:e,className:n,...r}){let{activeStep:i}=useStepper();return/* @__PURE__ */ u(`div`,{"data-slot":`stepper-panel`,"data-state":i,className:t(`w-full`,n),...r,children:e})}function StepperContent({value:e,forceMount:n,children:r,className:i,...a}){let{activeStep:o,getTriggerId:s,getContentId:c}=useStepper(),l=e===o;return!n&&!l?null:/* @__PURE__ */ u(`div`,{role:`tabpanel`,id:c(e),"aria-labelledby":s(e),"data-slot":`stepper-content`,"data-state":o,className:t(`w-full`,i,!l&&n&&`hidden`),hidden:!l&&n,...a,children:r})}export{Stepper,StepperContent,StepperDescription,StepperIndicator,StepperItem,StepperNav,StepperPanel,StepperSeparator,StepperTitle,StepperTrigger,useStepItem,useStepper};
|
|
2
2
|
//# sourceMappingURL=stepper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepper.js","names":["StepperContext","createContext","StepItemContext","ctx","useContext","props","activeStep","setActiveStep","useState","defaultValue","baseId","useId","handleSetActiveStep","useCallback","value","step","onValueChange","currentStep","getTriggerId","getContentId","contextValue","useMemo","Children","children","isValidElement","child","orientation","indicators","cn","className","state","completed","isLoading","loading","disabled","root","trigger","node","isSelected","isAriaDisabled","asChild","isDisabled","onClick","event","onKeyDown","triggers","index","target","useAsChild","tabIndex","isActive","forceMount"],"sources":["../../src/components/stepper.tsx"],"sourcesContent":["import {\n Children,\n createContext,\n isValidElement,\n type ReactElement,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState\n} from 'react'\n\nimport { type AsChildProps, useAsChild } from '../lib/as-child'\nimport { cn } from '../lib/utils'\n\n// Types\ntype StepperOrientation = 'horizontal' | 'vertical'\ntype StepState = 'active' | 'completed' | 'inactive' | 'loading'\ntype StepIndicators = {\n active?: React.ReactNode\n completed?: React.ReactNode\n inactive?: React.ReactNode\n loading?: React.ReactNode\n}\n\ninterface StepperContextValue {\n activeStep: number\n setActiveStep: (step: number) => void\n stepsCount: number\n orientation: StepperOrientation\n indicators: StepIndicators\n getTriggerId: (step: number) => string\n getContentId: (step: number) => string\n}\n\ninterface StepItemContextValue {\n step: number\n state: StepState\n isDisabled: boolean\n isLoading: boolean\n}\n\nconst StepperContext = createContext<StepperContextValue | undefined>(undefined)\nconst StepItemContext = createContext<StepItemContextValue | undefined>(undefined)\n\nfunction useStepper() {\n const ctx = useContext(StepperContext)\n if (!ctx) throw new Error('useStepper must be used within a Stepper')\n return ctx\n}\n\nfunction useStepItem() {\n const ctx = useContext(StepItemContext)\n if (!ctx) throw new Error('useStepItem must be used within a StepperItem')\n return ctx\n}\n\nexport type StepperProps = Omit<React.ComponentProps<'div'>, 'defaultValue'> & {\n /**\n * Initial step (uncontrolled), starting at `1`.\n * @default 1\n */\n defaultValue?: number\n /** Current step (controlled). */\n value?: number\n /** Called with the new step when the user moves to it. */\n onValueChange?: (value: number) => void\n /**\n * Layout of the steps.\n * @default 'horizontal'\n */\n orientation?: StepperOrientation\n /** Custom indicator content per state: `active`, `completed`, `inactive`, `loading`. */\n indicators?: StepIndicators\n}\n\nfunction Stepper({\n defaultValue = 1,\n value,\n onValueChange,\n orientation = 'horizontal',\n className,\n children,\n indicators = {},\n ...props\n}: StepperProps) {\n const [activeStep, setActiveStep] = useState(defaultValue)\n const baseId = useId()\n\n const handleSetActiveStep = useCallback(\n (step: number) => {\n if (value === undefined) {\n setActiveStep(step)\n }\n onValueChange?.(step)\n },\n [value, onValueChange]\n )\n\n const currentStep = value ?? activeStep\n\n const getTriggerId = useCallback((step: number) => `${baseId}-tab-${step}`, [baseId])\n const getContentId = useCallback((step: number) => `${baseId}-panel-${step}`, [baseId])\n\n // Context value\n const contextValue = useMemo<StepperContextValue>(\n () => ({\n activeStep: currentStep,\n setActiveStep: handleSetActiveStep,\n stepsCount: Children.toArray(children).filter(\n (child): child is ReactElement =>\n isValidElement(child) && (child.type as { displayName?: string }).displayName === 'StepperItem'\n ).length,\n orientation,\n indicators,\n getTriggerId,\n getContentId\n }),\n [currentStep, handleSetActiveStep, children, orientation, indicators, getTriggerId, getContentId]\n )\n\n return (\n <StepperContext.Provider value={contextValue}>\n <div\n role=\"tablist\"\n aria-orientation={orientation}\n data-slot=\"stepper\"\n className={cn('w-full', className)}\n data-orientation={orientation}\n {...props}\n >\n {children}\n </div>\n </StepperContext.Provider>\n )\n}\n\nexport type StepperItemProps = React.ComponentProps<'div'> & {\n /** Number of this step, starting at `1`. */\n step: number\n /**\n * Marks the step as completed.\n * @default false\n */\n completed?: boolean\n /**\n * Prevents navigating to this step.\n * @default false\n */\n disabled?: boolean\n /**\n * Shows the loading indicator for this step.\n * @default false\n */\n loading?: boolean\n}\n\nfunction StepperItem({\n step,\n completed = false,\n disabled = false,\n loading = false,\n className,\n children,\n ...props\n}: StepperItemProps) {\n const { activeStep } = useStepper()\n\n const state: StepState = completed || step < activeStep ? 'completed' : activeStep === step ? 'active' : 'inactive'\n\n const isLoading = loading && step === activeStep\n\n return (\n <StepItemContext.Provider value={{ step, state, isDisabled: disabled, isLoading }}>\n <div\n data-slot=\"stepper-item\"\n className={cn(\n 'group/step flex items-center justify-center not-last:flex-1 group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col',\n className\n )}\n data-state={state}\n {...(isLoading ? { 'data-loading': true } : {})}\n {...props}\n >\n {children}\n </div>\n </StepItemContext.Provider>\n )\n}\n\nexport type StepperTriggerProps = AsChildProps<'button'>\n\n// Enabled triggers of the closest Stepper, in DOM order (nested steppers excluded).\nfunction getStepperTriggers(trigger: HTMLElement) {\n const root = trigger.closest('[data-slot=\"stepper\"]')\n if (!root) return []\n\n return Array.from(root.querySelectorAll<HTMLElement>('[data-slot=\"stepper-trigger\"]')).filter(\n (node) => node.closest('[data-slot=\"stepper\"]') === root && !node.matches(':disabled, [aria-disabled=\"true\"]')\n )\n}\n\nfunction StepperTrigger({\n asChild = false,\n className,\n children,\n tabIndex,\n onClick,\n onKeyDown,\n ...props\n}: StepperTriggerProps) {\n const { setActiveStep, activeStep, getTriggerId, getContentId } = useStepper()\n const { step, state, isDisabled, isLoading } = useStepItem()\n const isSelected = activeStep === step\n // A non-button child can't be natively disabled, so it gets `aria-disabled` instead.\n const isAriaDisabled = asChild && isDisabled\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || isDisabled) return\n setActiveStep(step)\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented) return\n\n const triggers = getStepperTriggers(event.currentTarget)\n const index = triggers.indexOf(event.currentTarget)\n let target: HTMLElement | undefined\n\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n target = index === -1 ? undefined : triggers[(index + 1) % triggers.length]\n break\n case 'ArrowLeft':\n case 'ArrowUp':\n target = index === -1 ? undefined : triggers[(index - 1 + triggers.length) % triggers.length]\n break\n case 'Home':\n target = triggers[0]\n break\n case 'End':\n target = triggers[triggers.length - 1]\n break\n case 'Enter':\n case ' ':\n event.preventDefault()\n if (!isDisabled) setActiveStep(step)\n return\n default:\n return\n }\n\n event.preventDefault()\n target?.focus()\n }\n\n return useAsChild('button', {\n asChild,\n type: !asChild ? 'button' : undefined,\n role: 'tab',\n id: getTriggerId(step),\n 'aria-selected': isSelected,\n 'aria-controls': getContentId(step),\n 'aria-disabled': isAriaDisabled ? true : undefined,\n tabIndex: typeof tabIndex === 'number' ? tabIndex : isSelected ? 0 : -1,\n 'data-slot': 'stepper-trigger',\n 'data-state': state,\n 'data-loading': isLoading,\n disabled: asChild ? undefined : isDisabled,\n className: cn(\n 'focus-visible:border-ring focus-visible:ring-ring/50 inline-flex cursor-pointer items-center outline-none focus-visible:z-10 focus-visible:ring-3 disabled:pointer-events-none disabled:opacity-60 aria-disabled:pointer-events-none aria-disabled:opacity-60',\n 'gap-2.5 rounded-full',\n className\n ),\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n ...props,\n children\n })\n}\n\nexport type StepperIndicatorProps = React.ComponentProps<'div'>\n\nfunction StepperIndicator({ children, className, ...props }: StepperIndicatorProps) {\n const { state, isLoading } = useStepItem()\n const { indicators } = useStepper()\n\n return (\n <div\n data-slot=\"stepper-indicator\"\n data-state={state}\n className={cn(\n 'border-background bg-accent text-accent-foreground data-[state=completed]:bg-primary data-[state=completed]:text-primary-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground relative flex size-6 shrink-0 items-center justify-center overflow-hidden',\n 'rounded-full text-xs',\n className\n )}\n {...props}\n >\n <div className=\"absolute\">\n {indicators &&\n ((isLoading && indicators.loading) ||\n (state === 'completed' && indicators.completed) ||\n (state === 'active' && indicators.active) ||\n (state === 'inactive' && indicators.inactive))\n ? (isLoading && indicators.loading) ||\n (state === 'completed' && indicators.completed) ||\n (state === 'active' && indicators.active) ||\n (state === 'inactive' && indicators.inactive)\n : children}\n </div>\n </div>\n )\n}\n\nexport type StepperSeparatorProps = React.ComponentProps<'div'>\n\nfunction StepperSeparator({ className, ...props }: StepperSeparatorProps) {\n const { state } = useStepItem()\n\n return (\n <div\n data-slot=\"stepper-separator\"\n data-state={state}\n className={cn(\n 'bg-muted rounded-sm group-data-[orientation=horizontal]/stepper-nav:h-0.5 group-data-[orientation=vertical]/stepper-nav:h-12 group-data-[orientation=vertical]/stepper-nav:w-0.5 m-0.5 group-data-[orientation=horizontal]/stepper-nav:flex-1',\n className\n )}\n {...props}\n />\n )\n}\n\nexport type StepperTitleProps = React.ComponentProps<'h3'>\n\nfunction StepperTitle({ children, className, ...props }: StepperTitleProps) {\n const { state } = useStepItem()\n\n return (\n <h3\n data-slot=\"stepper-title\"\n data-state={state}\n className={cn('text-sm leading-none font-medium', className)}\n {...props}\n >\n {children}\n </h3>\n )\n}\n\nexport type StepperDescriptionProps = React.ComponentProps<'div'>\n\nfunction StepperDescription({ children, className, ...props }: StepperDescriptionProps) {\n const { state } = useStepItem()\n\n return (\n <div\n data-slot=\"stepper-description\"\n data-state={state}\n className={cn('text-muted-foreground text-sm', className)}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nexport type StepperNavProps = React.ComponentProps<'nav'>\n\nfunction StepperNav({ children, className, ...props }: StepperNavProps) {\n const { activeStep, orientation } = useStepper()\n\n return (\n <nav\n data-slot=\"stepper-nav\"\n data-state={activeStep}\n data-orientation={orientation}\n className={cn(\n 'group/stepper-nav inline-flex data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col',\n className\n )}\n {...props}\n >\n {children}\n </nav>\n )\n}\n\nexport type StepperPanelProps = React.ComponentProps<'div'>\n\nfunction StepperPanel({ children, className, ...props }: StepperPanelProps) {\n const { activeStep } = useStepper()\n\n return (\n <div data-slot=\"stepper-panel\" data-state={activeStep} className={cn('w-full', className)} {...props}>\n {children}\n </div>\n )\n}\n\nexport type StepperContentProps = React.ComponentProps<'div'> & {\n /** Step this content belongs to. */\n value: number\n /** Keeps the content mounted when its step isn’t active. */\n forceMount?: boolean\n}\n\nfunction StepperContent({ value, forceMount, children, className, ...props }: StepperContentProps) {\n const { activeStep, getTriggerId, getContentId } = useStepper()\n const isActive = value === activeStep\n\n if (!forceMount && !isActive) {\n return null\n }\n\n return (\n <div\n role=\"tabpanel\"\n id={getContentId(value)}\n aria-labelledby={getTriggerId(value)}\n data-slot=\"stepper-content\"\n data-state={activeStep}\n className={cn('w-full', className, !isActive && forceMount && 'hidden')}\n hidden={!isActive && forceMount}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nexport {\n Stepper,\n StepperContent,\n StepperDescription,\n StepperIndicator,\n StepperItem,\n StepperNav,\n StepperPanel,\n StepperSeparator,\n StepperTitle,\n StepperTrigger,\n useStepItem,\n useStepper\n}\n"],"mappings":"A,oTA0CA,MAAMA,EAAiBC,EAA+C,IAAA,EAAS,EACzEC,EAAkBD,EAAgD,IAAA,EAAS,EAEjF,SAAS,YAAa,CACpB,IAAME,EAAMC,EAAWJ,CAAc,EACrC,GAAI,CAACG,EAAK,MAAU,MAAM,0CAA0C,EACpE,OAAOA,CACT,CAEA,SAAS,aAAc,CACrB,IAAMA,EAAMC,EAAWF,CAAe,EACtC,GAAI,CAACC,EAAK,MAAU,MAAM,+CAA+C,EACzE,OAAOA,CACT,CAqBA,SAAS,QAAQ,CACf,eAAe,EACf,QACA,gBACA,cAAc,aACd,YACA,WACA,aAAa,CAAC,EACd,GAAGE,GACY,CACf,GAAM,CAACC,EAAYC,GAAiBC,EAASC,CAAY,EACnDC,EAASC,EAAM,EAEfC,EAAsBC,EACzB,GAAiB,CACZC,IAAU,IAAA,IACZP,EAAcQ,CAAI,EAEpBC,IAAgBD,CAAI,CACtB,EACA,CAACD,EAAOE,CAAa,CACvB,EAEMC,EAAcH,GAASR,EAEvBY,EAAeL,EAAa,GAAiB,GAAGH,EAAO,OAAOK,IAAQ,CAACL,CAAM,CAAC,EAC9ES,EAAeN,EAAa,GAAiB,GAAGH,EAAO,SAASK,IAAQ,CAACL,CAAM,CAAC,EAGhFU,EAAeC,OAC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YAAU,cACV,aAAYC,EACZ,mBAAkBoB,EAClB,UAAWE,EACT,iJACAC,CACF,EACA,GAAIxB,EAEH,UACE,CAAA,CAET,CAIA,SAAS,aAAa,CAAE,WAAU,YAAW,GAAGA,GAA4B,CAC1E,GAAM,CAAE,cAAe,WAAW,EAElC,MACE,kBAAC,MAAD,CAAK,YAAU,gBAAgB,aAAYC,EAAY,UAAWsB,EAAG,SAAUC,CAAS,EAAG,GAAIxB,EAC5F,UACE,CAAA,CAET,CASA,SAAS,eAAe,CAAE,QAAO,aAAY,WAAU,YAAW,GAAGA,GAA8B,CACjG,GAAM,CAAE,aAAY,eAAc,gBAAiB,WAAW,EACxD6C,EAAWpC,IAAUR,EAM3B,MAJI,CAAC6C,GAAc,CAACD,EACX,KAIP,kBAAC,MAAD,CACE,KAAK,WACL,GAAI/B,EAAaL,CAAK,EACtB,kBAAiBI,EAAaJ,CAAK,EACnC,YAAU,kBACV,aAAYR,EACZ,UAAWsB,EAAG,SAAUC,EAAW,CAACqB,GAAYC,GAAc,QAAQ,EACtE,OAAQ,CAACD,GAAYC,EACrB,GAAI9C,EAEH,UACE,CAAA,CAET,C"}
|
|
1
|
+
{"version":3,"file":"stepper.js","names":["StepperContext","createContext","StepItemContext","ctx","useContext","props","activeStep","setActiveStep","useState","defaultValue","baseId","useId","handleSetActiveStep","useCallback","value","step","onValueChange","currentStep","getTriggerId","getContentId","contextValue","useMemo","Children","children","isValidElement","child","orientation","indicators","cn","className","state","completed","isLoading","loading","disabled","root","trigger","node","isSelected","isAriaDisabled","asChild","isDisabled","onClick","event","onKeyDown","triggers","index","target","useAsChild","tabIndex","isActive","forceMount"],"sources":["../../src/components/stepper.tsx"],"sourcesContent":["import {\n Children,\n createContext,\n isValidElement,\n type ReactElement,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState\n} from 'react'\n\nimport { type AsChildProps, useAsChild } from '../lib/as-child'\nimport { cn } from '../lib/utils'\n\n// Types\ntype StepperOrientation = 'horizontal' | 'vertical'\ntype StepState = 'active' | 'completed' | 'inactive' | 'loading'\ntype StepIndicators = {\n active?: React.ReactNode\n completed?: React.ReactNode\n inactive?: React.ReactNode\n loading?: React.ReactNode\n}\n\ninterface StepperContextValue {\n activeStep: number\n setActiveStep: (step: number) => void\n stepsCount: number\n orientation: StepperOrientation\n indicators: StepIndicators\n getTriggerId: (step: number) => string\n getContentId: (step: number) => string\n}\n\ninterface StepItemContextValue {\n step: number\n state: StepState\n isDisabled: boolean\n isLoading: boolean\n}\n\nconst StepperContext = createContext<StepperContextValue | undefined>(undefined)\nconst StepItemContext = createContext<StepItemContextValue | undefined>(undefined)\n\nfunction useStepper() {\n const ctx = useContext(StepperContext)\n if (!ctx) throw new Error('useStepper must be used within a Stepper')\n return ctx\n}\n\nfunction useStepItem() {\n const ctx = useContext(StepItemContext)\n if (!ctx) throw new Error('useStepItem must be used within a StepperItem')\n return ctx\n}\n\nexport type StepperProps = Omit<React.ComponentProps<'div'>, 'defaultValue'> & {\n /**\n * Initial step (uncontrolled), starting at `1`.\n * @default 1\n */\n defaultValue?: number\n /** Current step (controlled). */\n value?: number\n /** Called with the new step when the user moves to it. */\n onValueChange?: (value: number) => void\n /**\n * Layout of the steps.\n * @default 'horizontal'\n */\n orientation?: StepperOrientation\n /** Custom indicator content per state: `active`, `completed`, `inactive`, `loading`. */\n indicators?: StepIndicators\n}\n\nfunction Stepper({\n defaultValue = 1,\n value,\n onValueChange,\n orientation = 'horizontal',\n className,\n children,\n indicators = {},\n ...props\n}: StepperProps) {\n const [activeStep, setActiveStep] = useState(defaultValue)\n const baseId = useId()\n\n const handleSetActiveStep = useCallback(\n (step: number) => {\n if (value === undefined) {\n setActiveStep(step)\n }\n onValueChange?.(step)\n },\n [value, onValueChange]\n )\n\n const currentStep = value ?? activeStep\n\n const getTriggerId = useCallback((step: number) => `${baseId}-tab-${step}`, [baseId])\n const getContentId = useCallback((step: number) => `${baseId}-panel-${step}`, [baseId])\n\n // Context value\n const contextValue = useMemo<StepperContextValue>(\n () => ({\n activeStep: currentStep,\n setActiveStep: handleSetActiveStep,\n stepsCount: Children.toArray(children).filter(\n (child): child is ReactElement =>\n isValidElement(child) && (child.type as { displayName?: string }).displayName === 'StepperItem'\n ).length,\n orientation,\n indicators,\n getTriggerId,\n getContentId\n }),\n [currentStep, handleSetActiveStep, children, orientation, indicators, getTriggerId, getContentId]\n )\n\n return (\n <StepperContext.Provider value={contextValue}>\n <div\n role=\"tablist\"\n aria-orientation={orientation}\n data-slot=\"stepper\"\n className={cn('w-full', className)}\n data-orientation={orientation}\n {...props}\n >\n {children}\n </div>\n </StepperContext.Provider>\n )\n}\n\nexport type StepperItemProps = React.ComponentProps<'div'> & {\n /** Number of this step, starting at `1`. */\n step: number\n /**\n * Marks the step as completed.\n * @default false\n */\n completed?: boolean\n /**\n * Prevents navigating to this step.\n * @default false\n */\n disabled?: boolean\n /**\n * Shows the loading indicator for this step.\n * @default false\n */\n loading?: boolean\n}\n\nfunction StepperItem({\n step,\n completed = false,\n disabled = false,\n loading = false,\n className,\n children,\n ...props\n}: StepperItemProps) {\n const { activeStep } = useStepper()\n\n const state: StepState = completed || step < activeStep ? 'completed' : activeStep === step ? 'active' : 'inactive'\n\n const isLoading = loading && step === activeStep\n\n return (\n <StepItemContext.Provider value={{ step, state, isDisabled: disabled, isLoading }}>\n <div\n data-slot=\"stepper-item\"\n className={cn(\n 'group/step flex items-center justify-center not-last:flex-1 group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col',\n className\n )}\n data-state={state}\n {...(isLoading ? { 'data-loading': true } : {})}\n {...props}\n >\n {children}\n </div>\n </StepItemContext.Provider>\n )\n}\n\nexport type StepperTriggerProps = AsChildProps<'button'>\n\n// Enabled triggers of the closest Stepper, in DOM order (nested steppers excluded).\nfunction getStepperTriggers(trigger: HTMLElement) {\n const root = trigger.closest('[data-slot=\"stepper\"]')\n if (!root) return []\n\n return Array.from(root.querySelectorAll<HTMLElement>('[data-slot=\"stepper-trigger\"]')).filter(\n (node) => node.closest('[data-slot=\"stepper\"]') === root && !node.matches(':disabled, [aria-disabled=\"true\"]')\n )\n}\n\nfunction StepperTrigger({\n asChild = false,\n className,\n children,\n tabIndex,\n onClick,\n onKeyDown,\n ...props\n}: StepperTriggerProps) {\n const { setActiveStep, activeStep, getTriggerId, getContentId } = useStepper()\n const { step, state, isDisabled, isLoading } = useStepItem()\n const isSelected = activeStep === step\n // A non-button child can't be natively disabled, so it gets `aria-disabled` instead.\n const isAriaDisabled = asChild && isDisabled\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || isDisabled) return\n setActiveStep(step)\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented) return\n\n const triggers = getStepperTriggers(event.currentTarget)\n const index = triggers.indexOf(event.currentTarget)\n let target: HTMLElement | undefined\n\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n target = index === -1 ? undefined : triggers[(index + 1) % triggers.length]\n break\n case 'ArrowLeft':\n case 'ArrowUp':\n target = index === -1 ? undefined : triggers[(index - 1 + triggers.length) % triggers.length]\n break\n case 'Home':\n target = triggers[0]\n break\n case 'End':\n target = triggers[triggers.length - 1]\n break\n case 'Enter':\n case ' ':\n event.preventDefault()\n if (!isDisabled) setActiveStep(step)\n return\n default:\n return\n }\n\n event.preventDefault()\n target?.focus()\n }\n\n return useAsChild('button', {\n asChild,\n type: !asChild ? 'button' : undefined,\n role: 'tab',\n id: getTriggerId(step),\n 'aria-selected': isSelected,\n 'aria-controls': getContentId(step),\n 'aria-disabled': isAriaDisabled ? true : undefined,\n tabIndex: typeof tabIndex === 'number' ? tabIndex : isSelected ? 0 : -1,\n 'data-slot': 'stepper-trigger',\n 'data-state': state,\n 'data-loading': isLoading,\n disabled: asChild ? undefined : isDisabled,\n className: cn(\n 'focus-visible:border-ring focus-visible:ring-ring/50 inline-flex cursor-pointer items-center outline-none focus-visible:z-10 focus-visible:ring-3 disabled:pointer-events-none disabled:opacity-60 aria-disabled:pointer-events-none aria-disabled:opacity-60',\n 'gap-2.5 rounded-full',\n className\n ),\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n ...props,\n children\n })\n}\n\nexport type StepperIndicatorProps = React.ComponentProps<'div'>\n\nfunction StepperIndicator({ children, className, ...props }: StepperIndicatorProps) {\n const { state, isLoading } = useStepItem()\n const { indicators } = useStepper()\n\n return (\n <div\n data-slot=\"stepper-indicator\"\n data-state={state}\n className={cn(\n 'border-background bg-accent text-accent-foreground data-[state=completed]:bg-primary data-[state=completed]:text-primary-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground relative flex size-6 shrink-0 items-center justify-center overflow-hidden',\n 'rounded-full text-xs',\n className\n )}\n {...props}\n >\n <div className=\"absolute\">\n {indicators &&\n ((isLoading && indicators.loading) ||\n (state === 'completed' && indicators.completed) ||\n (state === 'active' && indicators.active) ||\n (state === 'inactive' && indicators.inactive))\n ? (isLoading && indicators.loading) ||\n (state === 'completed' && indicators.completed) ||\n (state === 'active' && indicators.active) ||\n (state === 'inactive' && indicators.inactive)\n : children}\n </div>\n </div>\n )\n}\n\nexport type StepperSeparatorProps = React.ComponentProps<'div'>\n\nfunction StepperSeparator({ className, ...props }: StepperSeparatorProps) {\n const { state } = useStepItem()\n\n return (\n <div\n data-slot=\"stepper-separator\"\n data-state={state}\n className={cn(\n 'bg-muted rounded-sm group-data-[orientation=horizontal]/stepper-nav:h-0.5 group-data-[orientation=vertical]/stepper-nav:h-12 group-data-[orientation=vertical]/stepper-nav:w-0.5 m-0.5 group-data-[orientation=horizontal]/stepper-nav:flex-1',\n className\n )}\n {...props}\n />\n )\n}\n\nexport type StepperTitleProps = React.ComponentProps<'h3'>\n\nfunction StepperTitle({ children, className, ...props }: StepperTitleProps) {\n const { state } = useStepItem()\n\n return (\n <h3\n data-slot=\"stepper-title\"\n data-state={state}\n className={cn('text-sm leading-none font-medium', className)}\n {...props}\n >\n {children}\n </h3>\n )\n}\n\nexport type StepperDescriptionProps = React.ComponentProps<'div'>\n\nfunction StepperDescription({ children, className, ...props }: StepperDescriptionProps) {\n const { state } = useStepItem()\n\n return (\n <div\n data-slot=\"stepper-description\"\n data-state={state}\n className={cn('text-muted-foreground text-sm', className)}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nexport type StepperNavProps = React.ComponentProps<'nav'>\n\nfunction StepperNav({ children, className, ...props }: StepperNavProps) {\n const { activeStep, orientation } = useStepper()\n\n return (\n <nav\n data-slot=\"stepper-nav\"\n data-state={activeStep}\n data-orientation={orientation}\n className={cn(\n 'group/stepper-nav inline-flex data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col',\n className\n )}\n {...props}\n >\n {children}\n </nav>\n )\n}\n\nexport type StepperPanelProps = React.ComponentProps<'div'>\n\nfunction StepperPanel({ children, className, ...props }: StepperPanelProps) {\n const { activeStep } = useStepper()\n\n return (\n <div data-slot=\"stepper-panel\" data-state={activeStep} className={cn('w-full', className)} {...props}>\n {children}\n </div>\n )\n}\n\nexport type StepperContentProps = React.ComponentProps<'div'> & {\n /** Step this content belongs to. */\n value: number\n /** Keeps the content mounted when its step isn’t active. */\n forceMount?: boolean\n}\n\nfunction StepperContent({ value, forceMount, children, className, ...props }: StepperContentProps) {\n const { activeStep, getTriggerId, getContentId } = useStepper()\n const isActive = value === activeStep\n\n if (!forceMount && !isActive) {\n return null\n }\n\n return (\n <div\n role=\"tabpanel\"\n id={getContentId(value)}\n aria-labelledby={getTriggerId(value)}\n data-slot=\"stepper-content\"\n data-state={activeStep}\n className={cn('w-full', className, !isActive && forceMount && 'hidden')}\n hidden={!isActive && forceMount}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nexport {\n Stepper,\n StepperContent,\n StepperDescription,\n StepperIndicator,\n StepperItem,\n StepperNav,\n StepperPanel,\n StepperSeparator,\n StepperTitle,\n StepperTrigger,\n useStepItem,\n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IAAUR,EAM3B,MAJI,CAAC6C,GAAc,CAACD,EACX,KAIP,kBAAC,MAAD,CACE,KAAK,WACL,GAAI/B,EAAaL,CAAK,EACtB,kBAAiBI,EAAaJ,CAAK,EACnC,YAAU,kBACV,aAAYR,EACZ,UAAWsB,EAAG,SAAUC,EAAW,CAACqB,GAAYC,GAAc,QAAQ,EACtE,OAAQ,CAACD,GAAYC,EACrB,GAAI9C,EAEH,UACE,CAAA,CAET,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{t}from"../resolve-class-name-BurP8ngI.js";import{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{t}from"../resolve-class-name-BurP8ngI.js";import{useFieldControlId as n,useFieldInvalid as r}from"./field.js";import{Label as i}from"./label.js";import{useId as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";import{cva as c}from"class-variance-authority";import{Switch as l}from"@base-ui/react/switch";const u={primary:`[--switch-checked:var(--primary)]`,brand:`[--switch-checked:var(--brand)]`,gray:`[--switch-checked:var(--gray)]`,zinc:`[--switch-checked:var(--zinc)]`,red:`[--switch-checked:var(--red)]`,yellow:`[--switch-checked:var(--yellow)]`,blue:`[--switch-checked:var(--blue)]`,indigo:`[--switch-checked:var(--indigo)]`,pink:`[--switch-checked:var(--pink)]`,green:`[--switch-checked:var(--green)]`},d=c(``,{variants:{size:{sm:`text-xs`,md:`text-sm`,lg:`text-lg`}},defaultVariants:{size:`md`}}),f=c(`text-muted-foreground text-left leading-normal font-normal [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,{variants:{size:{sm:`text-xs`,md:`text-xs`,lg:`text-sm`}},defaultVariants:{size:`md`}});function Switch({className:c,color:p=`green`,id:m,label:h,labelProps:g,description:_,descriptionProps:v,size:y=`md`,"aria-invalid":b,...x}){let S=a(),C=n(m),w=r(b),T=h!==void 0,E=C??(T?S:void 0),{className:D,...O}=g??{},k=a(),A=_!==void 0,{className:j,...M}=v??{},N=A?M.id??k:void 0,P=/* @__PURE__ */ o(l.Root,{"data-slot":`switch`,"data-color":p,"data-size":y,id:E,"aria-describedby":N,"aria-invalid":w,className:n=>e(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none`,`after:absolute after:-inset-x-3 after:-inset-y-2`,`focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`data-[size=lg]:h-5 data-[size=lg]:w-10.5 data-[size=md]:h-4 data-[size=md]:w-8.5 data-[size=sm]:h-3.5 data-[size=sm]:w-7.5`,`data-checked:bg-(--switch-checked) data-unchecked:bg-input dark:data-unchecked:bg-input/80`,`data-disabled:cursor-not-allowed data-disabled:opacity-50`,u[p],t(c,n)),...x,children:/* @__PURE__ */ o(l.Thumb,{"data-slot":`switch-thumb`,className:e(`pointer-events-none flex items-center justify-center rounded-full bg-background ring-0 transition-transform`,`group-data-[size=lg]/switch:size-4 group-data-[size=md]/switch:size-3 group-data-[size=sm]/switch:size-2.5`,`group-data-[size=lg]/switch:data-checked:translate-x-6`,`group-data-[size=md]/switch:data-checked:translate-x-5`,`group-data-[size=sm]/switch:data-checked:translate-x-4.5`,`group-data-[size=lg]/switch:data-unchecked:translate-x-0.5`,`group-data-[size=md]/switch:data-unchecked:translate-x-0.5`,`group-data-[size=sm]/switch:data-unchecked:translate-x-0.5`,`dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground`),children:/* @__PURE__ */ o(`span`,{"data-slot":`switch-thumb-indicator`,className:e(`rounded-full transition-colors`,`group-data-[size=lg]/switch:size-2 group-data-[size=md]/switch:size-1.5 group-data-[size=sm]/switch:size-1`,`group-data-checked/switch:bg-(--switch-checked) group-data-unchecked/switch:bg-input`,`group-data-unchecked/switch:dark:bg-input/80`)})})});return!T&&!A?P:/* @__PURE__ */ s(`div`,{"data-slot":`switch-field`,className:`grid grid-cols-[auto_1fr] items-center justify-items-start gap-x-2 gap-y-0.5`,children:[P,T&&/* @__PURE__ */ o(i,{...O,htmlFor:E,className:e(d({size:y}),D),children:h}),A&&/* @__PURE__ */ o(`p`,{"data-slot":`switch-description`,...M,id:N,className:e(`col-start-2`,f({size:y}),j),children:_})]})}export{Switch};
|
|
2
2
|
//# sourceMappingURL=switch.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{toAsChildRenderProps as e}from"../lib/as-child.js";import{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{toAsChildRenderProps as e}from"../lib/as-child.js";import{buttonColorVariants as t}from"../lib/button.js";import{cn as n}from"../lib/utils.js";import{t as r}from"../resolve-class-name-BurP8ngI.js";import{jsx as i}from"react/jsx-runtime";import{cva as a}from"class-variance-authority";import{Toggle as o}from"@base-ui/react/toggle";const s=a(`group/toggle inline-flex items-center justify-center gap-1 rounded-full border border-transparent text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{secondary:`border-border bg-background hover:bg-muted hover:text-foreground data-pressed:bg-muted data-pressed:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50 dark:data-pressed:bg-input/50`,outline:`border-(--button-outline-border) bg-background text-(--button-outline-foreground) hover:bg-(--button-solid) hover:text-(--button-solid-foreground) data-pressed:bg-(--button-solid) data-pressed:text-(--button-solid-foreground)`,ghost:`text-(--button-ghost-foreground) hover:bg-(--button-ghost-hover) hover:text-(--button-ghost-foreground) data-pressed:bg-(--button-ghost-hover) data-pressed:text-(--button-ghost-foreground)`},color:t,size:{sm:`h-8 min-w-8 px-1.5 text-[0.8rem]`,md:`h-9 min-w-9 px-2`,lg:`h-10 min-w-10 px-2.5`}},defaultVariants:{variant:`ghost`,color:`primary`,size:`md`}});function Toggle({className:t,variant:a=`ghost`,color:c=`primary`,size:l=`md`,asChild:u,children:d,...f}){return/* @__PURE__ */ i(o,{"data-slot":`toggle`,"data-variant":a,"data-color":c,"data-size":l,className:e=>n(s({variant:a,color:c,size:l}),r(t,e)),...f,...e(u,d)})}export{Toggle,s as toggleVariants};
|
|
2
2
|
//# sourceMappingURL=toggle.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
+
import { t as AsChildPrimitiveProps } from "../as-child-T9W73ZYU.js";
|
|
3
|
+
import { ButtonProps } from "./button.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { Toolbar as Toolbar$1 } from "@base-ui/react/toolbar";
|
|
6
|
+
export type ToolbarProps = AsChildPrimitiveProps<typeof Toolbar$1.Root>;
|
|
7
|
+
export type ToolbarGroupProps = AsChildPrimitiveProps<typeof Toolbar$1.Group>;
|
|
8
|
+
export type ToolbarSeparatorProps = AsChildPrimitiveProps<typeof Toolbar$1.Separator>;
|
|
9
|
+
export type ToolbarButtonProps = AsChildPrimitiveProps<typeof Toolbar$1.Button> & Pick<ButtonProps, 'color' | 'loading'> & {
|
|
10
|
+
/**
|
|
11
|
+
* Visual style of the button.
|
|
12
|
+
* @default 'ghost'
|
|
13
|
+
*/
|
|
14
|
+
variant?: ButtonProps['variant'];
|
|
15
|
+
/**
|
|
16
|
+
* Height and padding of the button.
|
|
17
|
+
* @default 'sm'
|
|
18
|
+
*/
|
|
19
|
+
size?: ButtonProps['size'];
|
|
20
|
+
};
|
|
21
|
+
export type ToolbarLinkProps = AsChildPrimitiveProps<typeof Toolbar$1.Link>;
|
|
22
|
+
export type ToolbarInputProps = Omit<React.ComponentProps<typeof Toolbar$1.Input>, 'render'>;
|
|
23
|
+
declare function Toolbar({ className, asChild, children, ...props }: ToolbarProps): React.JSX.Element;
|
|
24
|
+
declare function ToolbarGroup({ className, asChild, children, ...props }: ToolbarGroupProps): React.JSX.Element;
|
|
25
|
+
declare function ToolbarSeparator({ className, asChild, children, ...props }: ToolbarSeparatorProps): React.JSX.Element;
|
|
26
|
+
declare function ToolbarButton({ className, variant, size, color, loading, asChild, children, ...props }: ToolbarButtonProps): React.JSX.Element;
|
|
27
|
+
declare function ToolbarLink({ className, asChild, children, ...props }: ToolbarLinkProps): React.JSX.Element;
|
|
28
|
+
declare function ToolbarInput({ className, ...props }: ToolbarInputProps): React.JSX.Element;
|
|
29
|
+
export { Toolbar, ToolbarButton, ToolbarGroup, ToolbarInput, ToolbarLink, ToolbarSeparator };
|
|
30
|
+
//# sourceMappingURL=toolbar.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{toAsChildRenderProps as e}from"../lib/as-child.js";import{cn as t}from"../lib/utils.js";import{t as n}from"../resolve-class-name-BurP8ngI.js";import{Button as r}from"./button.js";import{Input as i}from"./input.js";import{jsx as a}from"react/jsx-runtime";import{Toolbar as o}from"@base-ui/react/toolbar";function Toolbar({className:r,asChild:i,children:s,...c}){return/* @__PURE__ */ a(o.Root,{"data-slot":`toolbar`,className:e=>t(`group/toolbar flex items-center gap-1`,`data-vertical:flex-col data-vertical:items-stretch`,n(r,e)),...c,...e(i,s)})}function ToolbarGroup({className:r,asChild:i,children:s,...c}){return/* @__PURE__ */ a(o.Group,{"data-slot":`toolbar-group`,className:e=>t(`flex items-center gap-1`,`group-data-[orientation=vertical]/toolbar:flex-col group-data-[orientation=vertical]/toolbar:items-stretch`,n(r,e)),...c,...e(i,s)})}function ToolbarSeparator({className:r,asChild:i,children:s,...c}){return/* @__PURE__ */ a(o.Separator,{"data-slot":`toolbar-separator`,className:e=>t(`bg-border shrink-0`,`data-vertical:mx-1 data-vertical:h-5 data-vertical:w-px`,`data-horizontal:my-1 data-horizontal:h-px data-horizontal:w-full`,n(r,e)),...c,...e(i,s)})}function ToolbarButton({className:t,variant:n=`ghost`,size:i=`sm`,color:s,loading:c,asChild:l,children:u,...d}){return l?/* @__PURE__ */ a(o.Button,{"data-slot":`toolbar-button`,className:t,...d,...e(l,u)}):/* @__PURE__ */ a(o.Button,{"data-slot":`toolbar-button`,render:/* @__PURE__ */ a(r,{variant:n,size:i,color:s,loading:c}),className:t,...d,children:u})}function ToolbarLink({className:r,asChild:i,children:s,...c}){return/* @__PURE__ */ a(o.Link,{"data-slot":`toolbar-link`,className:e=>t(`inline-flex h-8 items-center rounded-md px-2 text-sm font-medium text-muted-foreground outline-none`,`hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,n(r,e)),...c,...e(i,s)})}function ToolbarInput({className:e,...r}){return/* @__PURE__ */ a(o.Input,{"data-slot":`toolbar-input`,render:/* @__PURE__ */ a(i,{}),className:r=>t(`h-8 w-auto`,n(e,r)),...r})}export{Toolbar,ToolbarButton,ToolbarGroup,ToolbarInput,ToolbarLink,ToolbarSeparator};
|
|
2
|
+
//# sourceMappingURL=toolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.js","names":["ToolbarPrimitive","resolveClassName","Toolbar$1","props","cn","className","state","toAsChildRenderProps","asChild","children","Button","Input"],"sources":["../../src/components/toolbar.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { Toolbar as ToolbarPrimitive } from '@base-ui/react/toolbar'\n\nimport { type AsChildPrimitiveProps, toAsChildRenderProps } from '../lib/as-child'\nimport { cn } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\nimport { Button, type ButtonProps } from './button'\nimport { Input } from './input'\n\nexport type ToolbarProps = AsChildPrimitiveProps<typeof ToolbarPrimitive.Root>\n\nexport type ToolbarGroupProps = AsChildPrimitiveProps<typeof ToolbarPrimitive.Group>\n\nexport type ToolbarSeparatorProps = AsChildPrimitiveProps<typeof ToolbarPrimitive.Separator>\n\nexport type ToolbarButtonProps = AsChildPrimitiveProps<typeof ToolbarPrimitive.Button> &\n Pick<ButtonProps, 'color' | 'loading'> & {\n /**\n * Visual style of the button.\n * @default 'ghost'\n */\n variant?: ButtonProps['variant']\n /**\n * Height and padding of the button.\n * @default 'sm'\n */\n size?: ButtonProps['size']\n }\n\nexport type ToolbarLinkProps = AsChildPrimitiveProps<typeof ToolbarPrimitive.Link>\n\nexport type ToolbarInputProps = Omit<React.ComponentProps<typeof ToolbarPrimitive.Input>, 'render'>\n\nfunction Toolbar({ className, asChild, children, ...props }: ToolbarProps) {\n return (\n <ToolbarPrimitive.Root\n data-slot=\"toolbar\"\n className={(state) =>\n cn(\n 'group/toolbar flex items-center gap-1',\n 'data-vertical:flex-col data-vertical:items-stretch',\n resolveClassName(className, state)\n )\n }\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nfunction ToolbarGroup({ className, asChild, children, ...props }: ToolbarGroupProps) {\n return (\n <ToolbarPrimitive.Group\n data-slot=\"toolbar-group\"\n className={(state) =>\n cn(\n 'flex items-center gap-1',\n 'group-data-[orientation=vertical]/toolbar:flex-col group-data-[orientation=vertical]/toolbar:items-stretch',\n resolveClassName(className, state)\n )\n }\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nfunction ToolbarSeparator({ className, asChild, children, ...props }: ToolbarSeparatorProps) {\n return (\n <ToolbarPrimitive.Separator\n data-slot=\"toolbar-separator\"\n className={(state) =>\n cn(\n 'bg-border shrink-0',\n 'data-vertical:mx-1 data-vertical:h-5 data-vertical:w-px',\n 'data-horizontal:my-1 data-horizontal:h-px data-horizontal:w-full',\n resolveClassName(className, state)\n )\n }\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nfunction ToolbarButton({\n className,\n variant = 'ghost',\n size = 'sm',\n color,\n loading,\n asChild,\n children,\n ...props\n}: ToolbarButtonProps) {\n if (asChild) {\n return (\n <ToolbarPrimitive.Button\n data-slot=\"toolbar-button\"\n className={className}\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n }\n\n return (\n <ToolbarPrimitive.Button\n data-slot=\"toolbar-button\"\n render={<Button variant={variant} size={size} color={color} loading={loading} />}\n className={className}\n {...props}\n >\n {children}\n </ToolbarPrimitive.Button>\n )\n}\n\nfunction ToolbarLink({ className, asChild, children, ...props }: ToolbarLinkProps) {\n return (\n <ToolbarPrimitive.Link\n data-slot=\"toolbar-link\"\n className={(state) =>\n cn(\n 'inline-flex h-8 items-center rounded-md px-2 text-sm font-medium text-muted-foreground outline-none',\n 'hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50',\n resolveClassName(className, state)\n )\n }\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nfunction ToolbarInput({ className, ...props }: ToolbarInputProps) {\n return (\n <ToolbarPrimitive.Input\n data-slot=\"toolbar-input\"\n render={<Input />}\n className={(state) => cn('h-8 w-auto', resolveClassName(className, state))}\n {...props}\n />\n )\n}\n\nexport { Toolbar, ToolbarButton, ToolbarGroup, ToolbarInput, ToolbarLink, ToolbarSeparator }\n"],"mappings":"A,8VAkCA,SAAS,QAAQ,CAAE,YAAW,UAAS,WAAU,GAAGG,GAAuB,CACzE,MACE,kBAACH,EAAiB,KAAlB,CACE,YAAU,UACV,UAAY,GACVI,EACE,wCACA,qDACAH,EAAiBI,EAAWC,CAAK,CACnC,EAEF,GAAIH,EACJ,GAAII,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL,CAEA,SAAS,aAAa,CAAE,YAAW,UAAS,WAAU,GAAGN,GAA4B,CACnF,MACE,kBAACH,EAAiB,MAAlB,CACE,YAAU,gBACV,UAAY,GACVI,EACE,0BACA,6GACAH,EAAiBI,EAAWC,CAAK,CACnC,EAEF,GAAIH,EACJ,GAAII,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL,CAEA,SAAS,iBAAiB,CAAE,YAAW,UAAS,WAAU,GAAGN,GAAgC,C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