{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sidebar",
  "type": "registry:ui",
  "title": "Sidebar",
  "description": "Sidebar is a collapsible vertical navigation panel.",
  "dependencies": [
    "@radix-ui/react-slot@^1.2.4",
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/motion.json",
    "https://wideset.co/r/scroll-area.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/sidebar/Sidebar.context.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/Sidebar.context.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\n\nimport type { SidebarContextValue } from './Sidebar.types';\n\nexport const SidebarContext = React.createContext<SidebarContextValue | undefined>(undefined);\n\nexport const useSidebarContext = () => {\n  const context = React.useContext(SidebarContext);\n\n  if (context === undefined) {\n    throw new Error('useSidebarContext must be used within a <Sidebar>');\n  }\n\n  return context;\n};\n"
    },
    {
      "path": "src/components/sidebar/Sidebar.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/Sidebar.tsx",
      "content": "'use client';\n\nimport type * as React from 'react';\n\nimport type { SidebarProps } from './Sidebar.types';\nimport { SidebarCollapsed } from './SidebarCollapsed';\nimport { SidebarExpanded } from './SidebarExpanded';\nimport { SidebarHeader } from './SidebarHeader';\nimport { SidebarItem } from './SidebarItem';\nimport { SidebarRoot } from './SidebarRoot';\nimport { SidebarSection } from './SidebarSection';\nimport { SidebarSectionHeader } from './SidebarSectionHeader';\nimport { SidebarTrigger } from './SidebarTrigger';\n\ntype SidebarWithSubComponents = React.ForwardRefExoticComponent<\n  SidebarProps & React.RefAttributes<HTMLDivElement>\n> & {\n  Header: typeof SidebarHeader;\n  Section: typeof SidebarSection;\n  SectionHeader: typeof SidebarSectionHeader;\n  Item: typeof SidebarItem;\n  Expanded: typeof SidebarExpanded;\n  Collapsed: typeof SidebarCollapsed;\n  Trigger: typeof SidebarTrigger;\n};\n\nconst Sidebar = SidebarRoot as SidebarWithSubComponents;\n\nSidebar.displayName = 'Sidebar';\nSidebar.Header = SidebarHeader;\nSidebar.Section = SidebarSection;\nSidebar.SectionHeader = SidebarSectionHeader;\nSidebar.Item = SidebarItem;\nSidebar.Expanded = SidebarExpanded;\nSidebar.Collapsed = SidebarCollapsed;\nSidebar.Trigger = SidebarTrigger;\n\nexport { Sidebar };\n"
    },
    {
      "path": "src/components/sidebar/Sidebar.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/Sidebar.types.ts",
      "content": "import type { RemixiconComponentType } from '@remixicon/react';\nimport type * as React from 'react';\n\nimport type { MotionProps } from '@/lib/wideset/motion/Motion.types';\n\n/** Props for the root Sidebar container. Supports both controlled and uncontrolled collapsed state. */\nexport type SidebarProps = React.HTMLAttributes<HTMLDivElement> & {\n  /** Whether the sidebar starts collapsed in uncontrolled mode. Has no effect when `collapsed` is provided. */\n  defaultCollapsed?: boolean;\n  /** Controls the collapsed state. When provided, the sidebar is in controlled mode. */\n  collapsed?: boolean;\n  /** Fired when the collapsed state changes. Receives the new `collapsed` value. */\n  onCollapsedChange?: (collapsed: boolean) => void;\n} & MotionProps;\n\n/** Props for the Sidebar header — the title/branding row. Never scrolls; hidden when empty. */\nexport type SidebarHeaderProps = React.HTMLAttributes<HTMLDivElement>;\n\n/** Props for a Sidebar section. Its content stays mounted in both modes; the parts inside adapt. */\nexport type SidebarSectionProps = React.HTMLAttributes<HTMLDivElement> & {\n  /** Makes the section fill the remaining height and scroll its overflow inside a `ScrollArea`. */\n  scrollable?: boolean;\n};\n\n/** Props for the title of a group of items. Collapsed, it keeps its height and its text stays available to screen readers. */\nexport type SidebarSectionHeaderProps = React.HTMLAttributes<HTMLDivElement>;\n\n/** Props for content that exists only when the sidebar is expanded, e.g. the product name. */\nexport type SidebarExpandedProps = {\n  /** Content rendered inside the component. */\n  children?: React.ReactNode;\n};\n\n/** Props for content that exists only when the sidebar is collapsed. */\nexport type SidebarCollapsedProps = {\n  /** Content rendered inside the component. */\n  children?: React.ReactNode;\n};\n\n/** Shared options for a navigation item. */\ntype SidebarItemBaseProps = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\n  /** Leading icon. Rendered on its own when the sidebar is collapsed. */\n  icon?: RemixiconComponentType;\n  /** Row label. Hidden when the sidebar is collapsed, where it falls back to `aria-label`. */\n  label?: React.ReactNode;\n  /** Marks the row as the current page: active styling plus `aria-current=\"page\"`. */\n  active?: boolean;\n  /** Blocks navigation and applies disabled styling via `aria-disabled`. */\n  disabled?: boolean;\n} & MotionProps;\n\n/** Props for a Sidebar navigation row. Renders an `<a>`; use `asChild` for a router Link. */\nexport type SidebarItemProps = SidebarItemBaseProps &\n  (\n    | {\n        /** Merges props onto the child element instead of rendering an `<a>` — e.g. a react-router or tanstack-router `Link`. The icon and label are injected into it. */\n        asChild: true;\n        /** The element to render as, e.g. `<Link to=\"/dashboard\" />`. Required with `asChild`. */\n        children: React.ReactElement;\n      }\n    | {\n        /** Renders the built-in item element; use the slotted branch for custom links. */\n        asChild?: false;\n        children?: never;\n      }\n  );\n\n/** Props for the Sidebar toggle trigger button. */\nexport type SidebarTriggerProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n  /** Merges props onto the immediate child element instead of rendering the default icon button. */\n  asChild?: boolean;\n  /** Accessible label used when the sidebar is collapsed (button expands it). Defaults to `'Expand sidebar'`. Ignored when `aria-label` is set explicitly. */\n  expandLabel?: string;\n  /** Accessible label used when the sidebar is expanded (button collapses it). Defaults to `'Collapse sidebar'`. Ignored when `aria-label` is set explicitly. */\n  collapseLabel?: string;\n} & MotionProps;\n\nexport type SidebarContextValue = {\n  isCollapsed: boolean;\n  toggle: () => void;\n  motion: boolean;\n  /** The root element's `id`, referenced by the trigger's `aria-controls`. */\n  sidebarId: string;\n};\n"
    },
    {
      "path": "src/components/sidebar/Sidebar.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/Sidebar.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\n\nimport { sidebarCollapseMotion } from '@/lib/wideset/motion/recipes';\n\nexport const sidebarVariants = cva(\n  'bg-ws-static-foreground border-ws-static-subtle gap-ws-7 px-ws-5 py-ws-7 relative flex h-full flex-col overflow-hidden border-r',\n  {\n    variants: {\n      collapsed: {\n        true: 'w-[3.25rem] items-center',\n        false: 'w-[16.25rem]',\n      },\n    },\n    defaultVariants: { collapsed: false },\n  },\n);\n\nexport const sidebarMotionVariants = cva('', {\n  variants: {\n    enabled: { true: sidebarCollapseMotion, false: '' },\n  },\n  defaultVariants: { enabled: true },\n});\n"
    },
    {
      "path": "src/components/sidebar/SidebarCollapsed.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/SidebarCollapsed.tsx",
      "content": "'use client';\n\nimport { useSidebarContext } from './Sidebar.context';\nimport type { SidebarCollapsedProps } from './Sidebar.types';\n\nconst SidebarCollapsed = ({ children }: SidebarCollapsedProps) => {\n  const { isCollapsed } = useSidebarContext();\n\n  return isCollapsed ? children : null;\n};\n\nSidebarCollapsed.displayName = 'Sidebar.Collapsed';\n\nexport { SidebarCollapsed };\n"
    },
    {
      "path": "src/components/sidebar/SidebarExpanded.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/SidebarExpanded.tsx",
      "content": "'use client';\n\nimport { useSidebarContext } from './Sidebar.context';\nimport type { SidebarExpandedProps } from './Sidebar.types';\n\nconst SidebarExpanded = ({ children }: SidebarExpandedProps) => {\n  const { isCollapsed } = useSidebarContext();\n\n  return isCollapsed ? null : children;\n};\n\nSidebarExpanded.displayName = 'Sidebar.Expanded';\n\nexport { SidebarExpanded };\n"
    },
    {
      "path": "src/components/sidebar/SidebarHeader.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/SidebarHeader.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nimport type { SidebarHeaderProps } from './Sidebar.types';\n\nconst SidebarHeader = ({ children, className, ...props }: SidebarHeaderProps) => (\n  <div\n    data-slot=\"sidebar-header\"\n    className={cn('w-full min-w-0 shrink-0 empty:hidden', className)}\n    {...props}\n  >\n    {children}\n  </div>\n);\n\nSidebarHeader.displayName = 'Sidebar.Header';\n\nexport { SidebarHeader };\n"
    },
    {
      "path": "src/components/sidebar/SidebarItem.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/SidebarItem.tsx",
      "content": "'use client';\n\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useSidebarContext } from './Sidebar.context';\nimport type { SidebarItemProps } from './Sidebar.types';\nimport {\n  sidebarItemIconVariants,\n  sidebarItemMotionVariants,\n  sidebarItemVariants,\n} from './SidebarItem.variants';\n\nconst SidebarItem = React.forwardRef<HTMLAnchorElement, SidebarItemProps>(\n  (\n    {\n      asChild = false,\n      icon: Icon,\n      label,\n      active = false,\n      disabled = false,\n      className,\n      children,\n      onClick,\n      defaultMotion,\n      'aria-label': ariaLabelProp,\n      ...props\n    },\n    ref,\n  ) => {\n    const { isCollapsed, motion: inheritedMotion } = useSidebarContext();\n    const motion = defaultMotion ?? inheritedMotion;\n    const Comp = asChild ? Slot : 'a';\n\n    const ariaLabel =\n      ariaLabelProp ?? (isCollapsed && typeof label === 'string' ? label : undefined);\n\n    return (\n      <Comp\n        ref={ref}\n        data-slot=\"sidebar-item\"\n        className={cn(\n          sidebarItemVariants({ active, collapsed: isCollapsed }),\n          sidebarItemMotionVariants({ enabled: motion }),\n          className,\n        )}\n        aria-label={ariaLabel}\n        aria-current={active ? 'page' : undefined}\n        aria-disabled={disabled || undefined}\n        tabIndex={disabled ? -1 : undefined}\n        onClick={\n          disabled ? (e: React.MouseEvent<HTMLAnchorElement>) => e.preventDefault() : onClick\n        }\n        {...props}\n      >\n        {asChild ? <Slottable>{children}</Slottable> : null}\n        {Icon ? <Icon className={sidebarItemIconVariants({ active })} /> : null}\n        {isCollapsed ? null : (\n          <span className=\"typography-label-strong-sm min-w-0 truncate\">{label}</span>\n        )}\n      </Comp>\n    );\n  },\n);\n\nSidebarItem.displayName = 'Sidebar.Item';\n\nexport { SidebarItem };\n"
    },
    {
      "path": "src/components/sidebar/SidebarItem.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/SidebarItem.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { hoverTintMotion } from '@/lib/wideset/motion/recipes';\n\nexport const sidebarItemVariants = cva(\n  cn(\n    'rounded-ws-control-lg gap-ws-5 px-ws-5 py-ws-3 flex w-full cursor-pointer items-center no-underline',\n    // The ring is drawn inset: sidebar items sit flush against the ScrollArea\n    // viewport (collapsed rail) or under its scrollbar strip (expanded), so an\n    // outer ring would be clipped or covered on the right.\n    'focus-visible:wds-focus-visible focus-visible:-outline-offset-2 focus-visible:outline-current',\n    'hover:not-aria-disabled:bg-ws-dynamic-tertiary-alpha-strong-default hover:not-aria-disabled:text-ws-static-strong',\n    'active:not-aria-disabled:bg-ws-dynamic-tertiary-alpha-strong-pressed active:not-aria-disabled:text-ws-static-strong',\n    'aria-disabled:text-ws-dynamic-secondary-disabled aria-disabled:pointer-events-none aria-disabled:cursor-default',\n  ),\n  {\n    variants: {\n      active: {\n        true: 'text-ws-static-strong bg-ws-dynamic-tertiary-alpha-strong-default',\n        false: 'text-ws-static-base',\n      },\n      collapsed: {\n        true: 'h-ws-15 justify-center px-0',\n        false: 'h-ws-14',\n      },\n    },\n    defaultVariants: { active: false, collapsed: false },\n  },\n);\n\nexport const sidebarItemMotionVariants = cva('', {\n  variants: {\n    enabled: { true: hoverTintMotion, false: '' },\n  },\n  defaultVariants: { enabled: true },\n});\n\nexport const sidebarItemIconVariants = cva('size-ws-10 shrink-0', {\n  variants: {\n    active: { true: '', false: 'text-ws-static-subtle' },\n  },\n  defaultVariants: { active: false },\n});\n"
    },
    {
      "path": "src/components/sidebar/SidebarRoot.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/SidebarRoot.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { SidebarContext } from './Sidebar.context';\nimport type { SidebarProps } from './Sidebar.types';\nimport { sidebarMotionVariants, sidebarVariants } from './Sidebar.variants';\n\nconst SidebarRoot = React.forwardRef<HTMLDivElement, SidebarProps>(\n  (\n    {\n      defaultCollapsed,\n      collapsed,\n      onCollapsedChange,\n      defaultMotion,\n      id: idProp,\n      className,\n      children,\n      ...props\n    },\n    ref,\n  ) => {\n    const motion = useDefaultMotion(defaultMotion);\n    const [internalCollapsed, setInternalCollapsed] = React.useState(!!defaultCollapsed);\n    const isControlled = collapsed !== undefined;\n    const isCollapsed = isControlled ? !!collapsed : internalCollapsed;\n    const generatedId = React.useId();\n    const sidebarId = idProp ?? generatedId;\n\n    const toggle = React.useCallback(() => {\n      const next = !isCollapsed;\n\n      if (!isControlled) {\n        setInternalCollapsed(next);\n      }\n\n      onCollapsedChange?.(next);\n    }, [isControlled, onCollapsedChange, isCollapsed]);\n\n    const contextValue = React.useMemo(\n      () => ({ isCollapsed, toggle, motion, sidebarId }),\n      [isCollapsed, toggle, motion, sidebarId],\n    );\n\n    return (\n      <SidebarContext.Provider value={contextValue}>\n        <div\n          ref={ref}\n          id={sidebarId}\n          data-slot=\"sidebar\"\n          data-state={isCollapsed ? 'collapsed' : 'expanded'}\n          className={cn(\n            sidebarVariants({ collapsed: isCollapsed }),\n            sidebarMotionVariants({ enabled: motion }),\n            className,\n          )}\n          {...props}\n        >\n          {children}\n        </div>\n      </SidebarContext.Provider>\n    );\n  },\n);\n\nSidebarRoot.displayName = 'Sidebar';\n\nexport { SidebarRoot };\n"
    },
    {
      "path": "src/components/sidebar/SidebarSection.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/SidebarSection.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { ScrollArea } from '../scroll-area/ScrollArea';\nimport { useSidebarContext } from './Sidebar.context';\nimport type { SidebarSectionProps } from './Sidebar.types';\nimport { SidebarCollapsed } from './SidebarCollapsed';\nimport { SidebarExpanded } from './SidebarExpanded';\n\nconst SidebarSection = ({ scrollable, children, className, ...props }: SidebarSectionProps) => {\n  const { isCollapsed } = useSidebarContext();\n  const childArray = React.Children.toArray(children);\n  const isModeSlot = (child: React.ReactNode, type: React.ElementType) =>\n    React.isValidElement(child) && child.type === type;\n  const hasOnlyModeSlots = childArray.every(\n    (child) => isModeSlot(child, SidebarExpanded) || isModeSlot(child, SidebarCollapsed),\n  );\n  const hasCurrentModeSlot = childArray.some((child) =>\n    isModeSlot(child, isCollapsed ? SidebarCollapsed : SidebarExpanded),\n  );\n\n  if (hasOnlyModeSlots && !hasCurrentModeSlot) return null;\n\n  return (\n    <div\n      data-slot=\"sidebar-section\"\n      className={cn('w-full min-w-0', scrollable && 'min-h-0 flex-1', className)}\n      {...props}\n    >\n      {scrollable ? <ScrollArea className=\"h-full\">{children}</ScrollArea> : children}\n    </div>\n  );\n};\n\nSidebarSection.displayName = 'Sidebar.Section';\n\nexport { SidebarSection };\n"
    },
    {
      "path": "src/components/sidebar/SidebarSectionHeader.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/SidebarSectionHeader.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useSidebarContext } from './Sidebar.context';\nimport type { SidebarSectionHeaderProps } from './Sidebar.types';\n\nconst SidebarSectionHeader = React.forwardRef<HTMLDivElement, SidebarSectionHeaderProps>(\n  ({ children, className, ...props }, ref) => {\n    const { isCollapsed } = useSidebarContext();\n\n    return (\n      <div\n        ref={ref}\n        data-slot=\"sidebar-section-header\"\n        className={cn('h-ws-16 flex items-end', !isCollapsed && 'px-ws-5 py-ws-3', className)}\n        {...props}\n      >\n        <span\n          className={\n            isCollapsed\n              ? 'sr-only'\n              : 'typography-caption-strong-md text-ws-static-subtle min-w-0 truncate'\n          }\n        >\n          {children}\n        </span>\n      </div>\n    );\n  },\n);\n\nSidebarSectionHeader.displayName = 'Sidebar.SectionHeader';\n\nexport { SidebarSectionHeader };\n"
    },
    {
      "path": "src/components/sidebar/SidebarTrigger.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/sidebar/SidebarTrigger.tsx",
      "content": "'use client';\n\nimport { Slot } from '@radix-ui/react-slot';\nimport { RiSidebarFoldLine } from '@remixicon/react';\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { MotionProvider } from '@/lib/wideset/motion/MotionProvider';\nimport { IconButton } from '../button/IconButton';\nimport { useSidebarContext } from './Sidebar.context';\nimport type { SidebarTriggerProps } from './Sidebar.types';\n\nconst SidebarTrigger = React.forwardRef<HTMLButtonElement, SidebarTriggerProps>(\n  (\n    {\n      children,\n      asChild,\n      className,\n      onClick,\n      'aria-label': ariaLabelProp,\n      expandLabel = 'Expand sidebar',\n      collapseLabel = 'Collapse sidebar',\n      defaultMotion,\n      ...restProps\n    },\n    ref,\n  ) => {\n    const { toggle, isCollapsed, motion, sidebarId } = useSidebarContext();\n\n    const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n      onClick?.(e);\n\n      if (!e.defaultPrevented) toggle();\n    };\n\n    const ariaLabel = ariaLabelProp || (isCollapsed ? expandLabel : collapseLabel);\n\n    if (asChild) {\n      return (\n        <MotionProvider enabled={defaultMotion ?? motion}>\n          <Slot\n            data-slot=\"sidebar-trigger\"\n            aria-label={ariaLabel}\n            {...restProps}\n            ref={ref}\n            onClick={handleClick}\n            aria-expanded={!isCollapsed}\n            aria-controls={sidebarId}\n            className={cn(isCollapsed ? 'size-ws-15 mx-auto rotate-180' : 'ml-auto', className)}\n          >\n            {children}\n          </Slot>\n        </MotionProvider>\n      );\n    }\n\n    return (\n      <IconButton\n        data-slot=\"sidebar-trigger\"\n        {...restProps}\n        icon={RiSidebarFoldLine}\n        variant=\"secondary\"\n        preset=\"ghost\"\n        size=\"sm\"\n        iconClassName=\"text-ws-static-subtle size-ws-9\"\n        defaultMotion={defaultMotion ?? motion}\n        ref={ref}\n        onClick={handleClick}\n        aria-label={ariaLabel}\n        aria-expanded={!isCollapsed}\n        aria-controls={sidebarId}\n        className={cn(isCollapsed ? 'size-ws-15 mx-auto rotate-180' : 'ml-auto', className)}\n      >\n        {children}\n      </IconButton>\n    );\n  },\n);\n\nSidebarTrigger.displayName = 'Sidebar.Trigger';\n\nexport { SidebarTrigger };\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
