{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "component-sidebar",
  "title": "Component Sidebar",
  "description": "Navigate dense component libraries with tactile, proximity-reactive guide lines.",
  "dependencies": [
    "@rexa-developer/tiks",
    "motion",
    "web-haptics"
  ],
  "registryDependencies": [
    "badge",
    "button",
    "kbd",
    "tooltip"
  ],
  "files": [
    {
      "path": "src/registry/components/component-sidebar/component-sidebar.tsx",
      "content": "\"use client\";\n\nimport { useTiks } from \"@rexa-developer/tiks/react\";\nimport {\n\tMotionConfig,\n\ttype MotionValue,\n\tmotion,\n\tuseMotionTemplate,\n\tuseMotionValue,\n\tuseReducedMotion,\n\tuseSpring,\n\tuseTransform,\n} from \"motion/react\";\nimport * as React from \"react\";\nimport { useWebHaptics } from \"web-haptics/react\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { Kbd } from \"@/components/ui/kbd\";\nimport {\n\tTooltip,\n\tTooltipContent,\n\tTooltipTrigger,\n} from \"@/components/ui/tooltip\";\n\nimport { useMetalClickSound } from \"@/hooks/soundcn/use-metal-click-sound\";\nimport { cn } from \"@/lib/utils\";\n\nconst NORMAL_LINE_WIDTH = 24;\nconst MAX_LINE_WIDTH = 40;\nconst PROXIMITY_RADIUS = 30;\nconst GAP_LINES = [0, 1] as const;\nconst DEFAULT_CROSS_INTERVAL = 70;\n\nexport type ComponentSidebarItem = {\n\ttitle: string;\n\thref: string;\n\tisNew?: boolean;\n\tisUpdated?: boolean;\n\texternal?: boolean;\n};\n\nexport type ComponentSidebarGroup = {\n\ttitle: string;\n\titems: readonly ComponentSidebarItem[];\n\tnewCount?: number;\n};\n\nexport type ComponentSidebarLinkProps = Omit<\n\tReact.ComponentPropsWithRef<\"a\">,\n\t\"href\"\n> & {\n\thref: string;\n};\n\nexport type ComponentSidebarRenderLink = (\n\tprops: ComponentSidebarLinkProps,\n\titem: ComponentSidebarItem,\n) => React.ReactNode;\n\nexport type ComponentSidebarProps = React.ComponentPropsWithRef<\"div\"> & {\n\t/** Controlled visibility. */\n\topen?: boolean;\n\t/** Initial visibility when uncontrolled. */\n\tdefaultOpen?: boolean;\n\t/** Called after the toggle button or shortcut requests a visibility change. */\n\tonOpenChange?: (open: boolean) => void;\n\t/** Single-key shortcut used to toggle the sidebar. Pass false to disable it. */\n\tshortcutKey?: string | false;\n\t/** Accessible label and tooltip text for the toggle button. */\n\ttoggleLabel?: string;\n\t/** Classes applied to the bordered sidebar panel. */\n\tpanelClassName?: string;\n};\n\nexport function ComponentSidebar({\n\tchildren,\n\tclassName,\n\tdefaultOpen = true,\n\tonOpenChange,\n\topen,\n\tpanelClassName,\n\tref,\n\tshortcutKey = \"s\",\n\ttoggleLabel = \"Toggle sidebar\",\n\t...props\n}: ComponentSidebarProps) {\n\tconst [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n\tconst [instant, setInstant] = React.useState(false);\n\tconst isOpen = open ?? internalOpen;\n\tconst panelId = React.useId();\n\tconst shouldReduceMotion = useReducedMotion();\n\tconst [playMetalClick] = useMetalClickSound();\n\tconst { trigger: haptic } = useWebHaptics();\n\tconst normalizedShortcut =\n\t\ttypeof shortcutKey === \"string\" ? shortcutKey.trim().toLowerCase() : null;\n\n\tconst setOpen = React.useCallback(\n\t\t(nextOpen: boolean) => {\n\t\t\tif (open === undefined) setInternalOpen(nextOpen);\n\t\t\tonOpenChange?.(nextOpen);\n\t\t},\n\t\t[onOpenChange, open],\n\t);\n\n\tconst toggleSidebar = React.useCallback(\n\t\t(animate: boolean) => {\n\t\t\tconst nextOpen = !isOpen;\n\t\t\tif (!animate) setInstant(true);\n\t\t\tplayMetalClick();\n\t\t\tvoid haptic(\"selection\");\n\t\t\tsetOpen(nextOpen);\n\t\t},\n\t\t[haptic, isOpen, playMetalClick, setOpen],\n\t);\n\n\tReact.useEffect(() => {\n\t\tif (!instant) return;\n\n\t\tconst frame = requestAnimationFrame(() => setInstant(false));\n\t\treturn () => cancelAnimationFrame(frame);\n\t}, [instant]);\n\n\tReact.useEffect(() => {\n\t\tif (!normalizedShortcut) return;\n\n\t\tfunction handleKeyDown(event: KeyboardEvent) {\n\t\t\tif (\n\t\t\t\tevent.defaultPrevented ||\n\t\t\t\tevent.altKey ||\n\t\t\t\tevent.ctrlKey ||\n\t\t\t\tevent.metaKey ||\n\t\t\t\tevent.shiftKey ||\n\t\t\t\tevent.key.toLowerCase() !== normalizedShortcut\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst target = event.target;\n\t\t\tif (\n\t\t\t\ttarget instanceof HTMLElement &&\n\t\t\t\t(target.isContentEditable ||\n\t\t\t\t\t[\"INPUT\", \"SELECT\", \"TEXTAREA\"].includes(target.tagName))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\ttoggleSidebar(false);\n\t\t}\n\n\t\twindow.addEventListener(\"keydown\", handleKeyDown);\n\t\treturn () => window.removeEventListener(\"keydown\", handleKeyDown);\n\t}, [normalizedShortcut, toggleSidebar]);\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tdata-open={isOpen}\n\t\t\tdata-slot=\"component-sidebar\"\n\t\t\tclassName={cn(\n\t\t\t\t\"[--component-sidebar-height:min(34rem,calc(100svh-1rem))]\",\n\t\t\t\t\"[--component-sidebar-radius:var(--radius-xl)]\",\n\t\t\t\t\"[--component-sidebar-top:0px]\",\n\t\t\t\t\"[--component-sidebar-width:--spacing(60)]\",\n\t\t\t\t\"sticky top-(--component-sidebar-top) isolate flex flex-col overflow-x-clip\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t<Tooltip>\n\t\t\t\t<TooltipTrigger\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-controls={panelId}\n\t\t\t\t\t\t\taria-expanded={isOpen}\n\t\t\t\t\t\t\taria-keyshortcuts={\n\t\t\t\t\t\t\t\tnormalizedShortcut?.length === 1\n\t\t\t\t\t\t\t\t\t? normalizedShortcut.toUpperCase()\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taria-label={toggleLabel}\n\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\"[--trigger-inset:--spacing(1.5)]\",\n\t\t\t\t\t\t\t\t\"[--trigger-radius:calc(var(--component-sidebar-radius)-var(--trigger-inset)+1px)]\",\n\t\t\t\t\t\t\t\t\"pointer-events-auto absolute top-(--trigger-inset) left-(--trigger-inset) z-10 size-7 rounded-(--trigger-radius) border-none\",\n\t\t\t\t\t\t\t\t\"transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] active:scale-[0.97] motion-reduce:transform-none motion-reduce:transition-none\",\n\t\t\t\t\t\t\t\t\"data-[sidebar-open=false]:inset-ring-1 data-[sidebar-open=false]:inset-ring-border\",\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tdata-sidebar-open={isOpen}\n\t\t\t\t\t\t\tonClick={() => toggleSidebar(true)}\n\t\t\t\t\t\t\tsize=\"icon-sm\"\n\t\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ComponentSidebarIcon\n\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\tduration={\n\t\t\t\t\t\t\t\t\tinstant || shouldReduceMotion === true ? 0 : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\topen={isOpen}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<TooltipContent className=\"pr-2 pl-3\" side=\"right\">\n\t\t\t\t\t<div className=\"flex items-center gap-3\">\n\t\t\t\t\t\t{toggleLabel}\n\t\t\t\t\t\t{normalizedShortcut?.length === 1 ? (\n\t\t\t\t\t\t\t<Kbd>{normalizedShortcut.toUpperCase()}</Kbd>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</div>\n\t\t\t\t</TooltipContent>\n\t\t\t</Tooltip>\n\n\t\t\t<div\n\t\t\t\tid={panelId}\n\t\t\t\taria-hidden={!isOpen}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"flex h-(--component-sidebar-height) w-(--component-sidebar-width) flex-col rounded-(--component-sidebar-radius) border bg-background\",\n\t\t\t\t\t\"-translate-x-[calc(var(--component-sidebar-width)-1px)] data-open:translate-x-0\",\n\t\t\t\t\t\"transition-[translate] duration-350 ease-[cubic-bezier(0.24,0.88,0.28,0.92)] data-[instant=true]:transition-none motion-reduce:transition-none\",\n\t\t\t\t\tpanelClassName,\n\t\t\t\t)}\n\t\t\t\tdata-instant={instant || undefined}\n\t\t\t\tdata-open={isOpen}\n\t\t\t\tdata-slot=\"component-sidebar-panel\"\n\t\t\t\tinert={!isOpen}\n\t\t\t>\n\t\t\t\t<div className=\"no-scrollbar scroll-fade grow overflow-y-auto overflow-x-clip overscroll-contain pt-10.25\">\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport type ComponentSidebarContentProps = Omit<\n\tReact.ComponentPropsWithRef<\"nav\">,\n\t\"children\"\n> & {\n\tgroups: readonly ComponentSidebarGroup[];\n\tactiveHref?: string;\n\trenderLink?: ComponentSidebarRenderLink;\n\tonItemCrossCenter?: (item: ComponentSidebarItem) => void;\n\titemCrossInterval?: number;\n};\n\nexport function ComponentSidebarContent({\n\tactiveHref,\n\tclassName,\n\tgroups,\n\titemCrossInterval = DEFAULT_CROSS_INTERVAL,\n\tonItemCrossCenter,\n\tonPointerCancel,\n\tonPointerLeave,\n\tonPointerMove,\n\tref,\n\trenderLink = renderAnchor,\n\t...props\n}: ComponentSidebarContentProps) {\n\tconst activeItemRef = React.useRef<HTMLAnchorElement | null>(null);\n\tconst pointerY = useMotionValue(Number.POSITIVE_INFINITY);\n\tconst shouldReduceMotion = useReducedMotion();\n\tconst lastCrossAtRef = React.useRef(Number.NEGATIVE_INFINITY);\n\tconst { click: playClick, hover: playHover } = useTiks();\n\tconst { trigger: haptic } = useWebHaptics();\n\n\tconst handleItemCrossCenter = React.useCallback(\n\t\t(item: ComponentSidebarItem) => {\n\t\t\tconst now = performance.now();\n\t\t\tif (now - lastCrossAtRef.current < itemCrossInterval) return;\n\n\t\t\tlastCrossAtRef.current = now;\n\t\t\tplayHover();\n\t\t\tonItemCrossCenter?.(item);\n\t\t},\n\t\t[itemCrossInterval, onItemCrossCenter, playHover],\n\t);\n\n\tconst handleItemSelect = React.useCallback(() => {\n\t\tplayClick();\n\t\tvoid haptic(\"selection\");\n\t}, [haptic, playClick]);\n\n\tReact.useEffect(() => {\n\t\tif (activeHref) {\n\t\t\tactiveItemRef.current?.scrollIntoView({ block: \"center\" });\n\t\t}\n\t}, [activeHref]);\n\n\treturn (\n\t\t<MotionConfig reducedMotion=\"user\">\n\t\t\t<nav\n\t\t\t\tref={ref}\n\t\t\t\taria-label=\"Library navigation\"\n\t\t\t\tclassName={cn(\"flex flex-col py-5.25 pr-0.5 pl-3\", className)}\n\t\t\t\tdata-slot=\"component-sidebar-content\"\n\t\t\t\tonPointerCancel={(event) => {\n\t\t\t\t\tonPointerCancel?.(event);\n\t\t\t\t\tif (!event.defaultPrevented) {\n\t\t\t\t\t\tpointerY.set(Number.POSITIVE_INFINITY);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tonPointerLeave={(event) => {\n\t\t\t\t\tonPointerLeave?.(event);\n\t\t\t\t\tif (!event.defaultPrevented) {\n\t\t\t\t\t\tpointerY.set(Number.POSITIVE_INFINITY);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tonPointerMove={(event) => {\n\t\t\t\t\tonPointerMove?.(event);\n\t\t\t\t\tif (event.defaultPrevented) return;\n\n\t\t\t\t\tif (event.pointerType === \"touch\" || shouldReduceMotion === true) {\n\t\t\t\t\t\tpointerY.set(Number.POSITIVE_INFINITY);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tpointerY.set(event.clientY);\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{groups.map((group, groupIndex) => (\n\t\t\t\t\t<section\n\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\tgroupIndex > 0 ? \"mt-5 border-border/40 border-t pt-5\" : \"\"\n\t\t\t\t\t\t}\n\t\t\t\t\t\tkey={`${group.title}-${groupIndex}`}\n\t\t\t\t\t>\n\t\t\t\t\t\t{/* A label, not a heading: the sidebar usually renders before the\n\t\t\t\t\t\t    page's h1, and a fixed level would break its outline. */}\n\t\t\t\t\t\t<div className=\"mb-2.5 flex w-full items-center justify-between gap-2 pr-3 font-semibold text-[12px] text-foreground/70 uppercase tracking-widest\">\n\t\t\t\t\t\t\t<span>{group.title}</span>\n\t\t\t\t\t\t\t{group.newCount ? (\n\t\t\t\t\t\t\t\t<Badge\n\t\t\t\t\t\t\t\t\tclassName=\"h-4 rounded-sm border-border/60 bg-background/40 px-1.5 py-0 font-medium text-[9px]/4 text-muted-foreground tracking-normal shadow-none\"\n\t\t\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tNew {group.newCount}\n\t\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div className=\"flex flex-col gap-2 py-2\">\n\t\t\t\t\t\t\t{group.items.map((item, itemIndex) => (\n\t\t\t\t\t\t\t\t<ComponentSidebarMenuItem\n\t\t\t\t\t\t\t\t\tactiveRef={\n\t\t\t\t\t\t\t\t\t\titem.href === activeHref ? activeItemRef : undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tisActive={item.href === activeHref}\n\t\t\t\t\t\t\t\t\tisLast={itemIndex === group.items.length - 1}\n\t\t\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\t\t\tkey={item.href}\n\t\t\t\t\t\t\t\t\tonCrossCenter={handleItemCrossCenter}\n\t\t\t\t\t\t\t\t\tonSelect={handleItemSelect}\n\t\t\t\t\t\t\t\t\tpointerY={pointerY}\n\t\t\t\t\t\t\t\t\trenderLink={renderLink}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</section>\n\t\t\t\t))}\n\t\t\t</nav>\n\t\t</MotionConfig>\n\t);\n}\n\nexport type ComponentSidebarIconProps =\n\tReact.ComponentPropsWithoutRef<\"svg\"> & {\n\t\topen?: boolean;\n\t\tduration?: number;\n\t};\n\nexport function ComponentSidebarIcon({\n\tduration = 0.2,\n\topen = false,\n\t...props\n}: ComponentSidebarIconProps) {\n\treturn (\n\t\t// Icon designed by @ncdai.\n\t\t<svg\n\t\t\tfill=\"none\"\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t{...props}\n\t\t>\n\t\t\t<rect\n\t\t\t\theight=\"18\"\n\t\t\t\trx=\"4\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\twidth=\"20\"\n\t\t\t\tx=\"2\"\n\t\t\t\ty=\"3\"\n\t\t\t/>\n\t\t\t<motion.rect\n\t\t\t\tanimate={{ width: open ? 6 : 2 }}\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\theight=\"12\"\n\t\t\t\tinitial={false}\n\t\t\t\trx=\"1\"\n\t\t\t\ttransition={{\n\t\t\t\t\tduration,\n\t\t\t\t\tease: [0.23, 1, 0.32, 1],\n\t\t\t\t}}\n\t\t\t\tx=\"5\"\n\t\t\t\ty=\"6\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction useProximityLine(\n\tpointerY: MotionValue<number>,\n\tisExpanded = false,\n\tonCrossCenter?: (item: ComponentSidebarItem) => void,\n\titem?: ComponentSidebarItem,\n) {\n\tconst ref = React.useRef<HTMLSpanElement>(null);\n\tconst previousPointerYRef = React.useRef(Number.POSITIVE_INFINITY);\n\tconst restingScale =\n\t\t(isExpanded ? MAX_LINE_WIDTH : NORMAL_LINE_WIDTH) / MAX_LINE_WIDTH;\n\tconst targetScaleX = useTransform(pointerY, (currentPointerY) => {\n\t\tconst previousPointerY = previousPointerYRef.current;\n\t\tpreviousPointerYRef.current = currentPointerY;\n\n\t\tif (!Number.isFinite(currentPointerY)) return restingScale;\n\n\t\tconst bounds = ref.current?.getBoundingClientRect();\n\t\tif (!bounds) return restingScale;\n\n\t\tconst lineCenterY = bounds.top + bounds.height / 2;\n\t\tconst crossedCenter =\n\t\t\tNumber.isFinite(previousPointerY) &&\n\t\t\t((previousPointerY < lineCenterY && currentPointerY >= lineCenterY) ||\n\t\t\t\t(previousPointerY > lineCenterY && currentPointerY <= lineCenterY));\n\t\tif (crossedCenter && item) onCrossCenter?.(item);\n\n\t\tconst distance = Math.abs(currentPointerY - lineCenterY);\n\t\tconst proximity = 1 - Math.min(distance / PROXIMITY_RADIUS, 1);\n\n\t\treturn restingScale + (1 - restingScale) * proximity;\n\t});\n\tconst scaleX = useSpring(targetScaleX, {\n\t\tstiffness: 320,\n\t\tdamping: 34,\n\t\tmass: 0.7,\n\t});\n\tconst labelX = useTransform(\n\t\tscaleX,\n\t\t(scale) => scale * MAX_LINE_WIDTH - NORMAL_LINE_WIDTH,\n\t);\n\tconst lineTransform = useMotionTemplate`scaleX(${scaleX})`;\n\tconst labelTransform = useMotionTemplate`translateX(${labelX}px)`;\n\n\treturn { labelTransform, lineTransform, ref };\n}\n\nfunction ComponentSidebarSpacerLine({\n\tpointerY,\n}: {\n\tpointerY: MotionValue<number>;\n}) {\n\tconst { lineTransform, ref } = useProximityLine(pointerY);\n\n\treturn (\n\t\t<motion.span\n\t\t\tref={ref}\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName=\"-mr-4 block h-px w-10 origin-left bg-foreground/20\"\n\t\t\tstyle={{ transform: lineTransform }}\n\t\t/>\n\t);\n}\n\ntype ComponentSidebarMenuItemProps = {\n\tactiveRef?: React.Ref<HTMLAnchorElement>;\n\tisActive: boolean;\n\tisLast: boolean;\n\titem: ComponentSidebarItem;\n\tonCrossCenter: (item: ComponentSidebarItem) => void;\n\tonSelect: () => void;\n\tpointerY: MotionValue<number>;\n\trenderLink: ComponentSidebarRenderLink;\n};\n\nconst ComponentSidebarMenuItem = React.memo(function ComponentSidebarMenuItem({\n\tactiveRef,\n\tisActive,\n\tisLast,\n\titem,\n\tonCrossCenter,\n\tonSelect,\n\tpointerY,\n\trenderLink,\n}: ComponentSidebarMenuItemProps) {\n\tconst isExternal = item.external ?? /^https?:\\/\\//.test(item.href);\n\tconst { labelTransform, lineTransform, ref } = useProximityLine(\n\t\tpointerY,\n\t\tisActive,\n\t\tonCrossCenter,\n\t\titem,\n\t);\n\tconst link = renderLink(\n\t\t{\n\t\t\tref: activeRef,\n\t\t\t\"aria-current\": isActive ? \"page\" : undefined,\n\t\t\tclassName:\n\t\t\t\t\"group relative flex h-px items-center gap-3 after:absolute after:top-1/2 after:left-0 after:size-full after:-translate-y-1/2 after:p-3.5\",\n\t\t\thref: item.href,\n\t\t\tonClick: onSelect,\n\t\t\trel: isExternal ? \"noreferrer\" : undefined,\n\t\t\ttarget: isExternal ? \"_blank\" : undefined,\n\t\t\tchildren: (\n\t\t\t\t<>\n\t\t\t\t\t<motion.span\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName=\"-mr-4 block h-px w-10 shrink-0 origin-left bg-foreground/20 transition-[background-color] ease-out group-hover:bg-foreground group-aria-[current=page]:bg-foreground\"\n\t\t\t\t\t\tstyle={{ transform: lineTransform }}\n\t\t\t\t\t/>\n\t\t\t\t\t<motion.span\n\t\t\t\t\t\tclassName=\"inline-flex items-center gap-2 whitespace-nowrap text-muted-foreground text-sm transition-[color] ease-out group-hover:text-foreground group-aria-[current=page]:text-foreground\"\n\t\t\t\t\t\tstyle={{ transform: labelTransform }}\n\t\t\t\t\t>\n\t\t\t\t\t\t<span>{item.title}</span>\n\t\t\t\t\t\t{item.isNew ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\tclassName=\"size-1.5 shrink-0 rounded-full bg-primary\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<span className=\"sr-only\">New</span>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{item.isUpdated ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\tclassName=\"size-1.5 shrink-0 rounded-full bg-yellow-400\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<span className=\"sr-only\">Updated</span>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</motion.span>\n\t\t\t\t</>\n\t\t\t),\n\t\t},\n\t\titem,\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{link}\n\t\t\t{isLast\n\t\t\t\t? null\n\t\t\t\t: GAP_LINES.map((line) => (\n\t\t\t\t\t\t<ComponentSidebarSpacerLine key={line} pointerY={pointerY} />\n\t\t\t\t\t))}\n\t\t</>\n\t);\n});\n\nfunction renderAnchor(props: ComponentSidebarLinkProps) {\n\treturn <a {...props} />;\n}\n\nexport default ComponentSidebar;\n",
      "type": "registry:component",
      "target": "@components/component-sidebar.tsx"
    },
    {
      "path": "src/hooks/soundcn/use-metal-click-sound.ts",
      "content": "import { metalClickSound } from \"@/lib/soundcn/metal-click\";\n\nimport { useSound } from \"./use-sound\";\n\nexport function useMetalClickSound() {\n\treturn useSound(metalClickSound, { volume: 0.1 });\n}\n",
      "type": "registry:hook",
      "target": "@hooks/soundcn/use-metal-click-sound.ts"
    },
    {
      "path": "src/hooks/soundcn/use-sound.ts",
      "content": "\"use client\";\n\nimport { useReducedMotion } from \"motion/react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { decodeAudioData, getAudioContext } from \"@/lib/soundcn/sound-engine\";\nimport type {\n\tSoundAsset,\n\tUseSoundOptions,\n\tUseSoundReturn,\n} from \"@/lib/soundcn/sound-types\";\n\nexport function useSound(\n\tsound: SoundAsset,\n\toptions: UseSoundOptions = {},\n): UseSoundReturn {\n\tconst {\n\t\tvolume = 0.5,\n\t\tplaybackRate = 1,\n\t\tinterrupt = false,\n\t\tsoundEnabled: _soundEnabled = true,\n\t\tonPlay,\n\t\tonEnd,\n\t\tonPause,\n\t\tonStop,\n\t} = options;\n\n\tconst [isPlaying, setIsPlaying] = useState(false);\n\tconst [duration, setDuration] = useState<number | null>(\n\t\tsound.duration ?? null,\n\t);\n\tconst sourceRef = useRef<AudioBufferSourceNode | null>(null);\n\tconst gainRef = useRef<GainNode | null>(null);\n\tconst bufferRef = useRef<AudioBuffer | null>(null);\n\n\tconst shouldReduceMotion = useReducedMotion();\n\tconst soundEnabled = _soundEnabled && !shouldReduceMotion;\n\n\tuseEffect(() => {\n\t\tlet cancelled = false;\n\n\t\tvoid decodeAudioData(sound.dataUri)\n\t\t\t.then((buffer) => {\n\t\t\t\tif (!cancelled) {\n\t\t\t\t\tbufferRef.current = buffer;\n\t\t\t\t\tsetDuration(buffer.duration);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(() => {\n\t\t\t\tif (!cancelled) {\n\t\t\t\t\tbufferRef.current = null;\n\t\t\t\t\tsetDuration(sound.duration ?? null);\n\t\t\t\t}\n\t\t\t});\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [sound.dataUri, sound.duration]);\n\n\tconst stop = useCallback(() => {\n\t\tif (sourceRef.current) {\n\t\t\ttry {\n\t\t\t\tsourceRef.current.stop();\n\t\t\t} catch {\n\t\t\t\t// Already stopped\n\t\t\t}\n\t\t\tsourceRef.current = null;\n\t\t}\n\t\tsetIsPlaying(false);\n\t\tonStop?.();\n\t}, [onStop]);\n\n\tconst play = useCallback(\n\t\t(overrides?: { volume?: number; playbackRate?: number }) => {\n\t\t\tif (!soundEnabled || !bufferRef.current) return;\n\n\t\t\tconst ctx = getAudioContext();\n\n\t\t\tif (ctx.state === \"suspended\") {\n\t\t\t\tctx.resume();\n\t\t\t}\n\n\t\t\tif (interrupt && sourceRef.current) {\n\t\t\t\tstop();\n\t\t\t}\n\n\t\t\tconst source = ctx.createBufferSource();\n\t\t\tconst gain = ctx.createGain();\n\n\t\t\tsource.buffer = bufferRef.current;\n\t\t\tsource.playbackRate.value = overrides?.playbackRate ?? playbackRate;\n\t\t\tgain.gain.value = overrides?.volume ?? volume;\n\n\t\t\tsource.connect(gain);\n\t\t\tgain.connect(ctx.destination);\n\n\t\t\tsource.onended = () => {\n\t\t\t\tsetIsPlaying(false);\n\t\t\t\tonEnd?.();\n\t\t\t};\n\n\t\t\tsource.start(0);\n\t\t\tsourceRef.current = source;\n\t\t\tgainRef.current = gain;\n\t\t\tsetIsPlaying(true);\n\t\t\tonPlay?.();\n\t\t},\n\t\t[soundEnabled, playbackRate, volume, interrupt, stop, onPlay, onEnd],\n\t);\n\n\tconst pause = useCallback(() => {\n\t\tstop();\n\t\tonPause?.();\n\t}, [stop, onPause]);\n\n\tuseEffect(() => {\n\t\tif (gainRef.current) {\n\t\t\tgainRef.current.gain.value = volume;\n\t\t}\n\t}, [volume]);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (sourceRef.current) {\n\t\t\t\ttry {\n\t\t\t\t\tsourceRef.current.stop();\n\t\t\t\t} catch {\n\t\t\t\t\t// Already stopped\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}, []);\n\n\treturn [play, { stop, pause, isPlaying, duration, sound }] as const;\n}\n",
      "type": "registry:hook",
      "target": "@hooks/soundcn/use-sound.ts"
    },
    {
      "path": "src/lib/soundcn/metal-click.ts",
      "content": "import type { SoundAsset } from \"@/lib/soundcn/sound-types\";\n\nexport const metalClickSound: SoundAsset = {\n\tname: \"metal-click\",\n\tdataUri:\n\t\t\"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0UAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABMAABBSABkZGRkZJiYmJiYzMzMzMz8/Pz8/P0xMTExMWVlZWVlmZmZmZnNzc3Nzc39/f39/jIyMjIyZmZmZmaampqamprOzs7Ozv7+/v7/MzMzMzNnZ2dnZ2ebm5ubm8/Pz8/P//////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBnIAAAAAAAAQUsLxQHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAABgADTbQBAAH1palnHtABIARJqATlmkggBAEIIAgCBxOQggCAIOg+f3CAEOXB8Puggc1g+D7v/0/5c//5//wQpCggC///qHBqGsu280GJnQlecJWTZx2TdEHxrCYGI0KLwc0mF8vH0guSjU8XDM+5mgmtjaZILonDaYEspJjJSGtFjj2eZpKNl2qZVJS1LUX0Lsiy2Z9V7pq+zpp1LWyy4YM72RWlsz9VeZ1fPdQHM95S7h50sl789VD07m9qhiVhF0AP3YYkYS0tof/7UsQGgAu4xUfc8YABfJhoeYMJoHrQS9RrBps9mE6FdGwr6hmFoOGAg4GwZN8kZBq8Qzze+fl1jdxYu//N3Mrd+Xc/MyL+mQaMBEs/kwlIT6xOfak7saObqqbhIKYCQ5OncqVUXmTV1V2AOGEZRsGIjSDrRo22dxX2j0ufZusDUhMDBI6QHPNMHPdaNW7yoSJVWte6+zhUMh2MleWYU10BoZm/ftMpQoLGAaU3aaAHPJPAXSnvctNofirZtwa5NqantdpXd0d4N1ILiEoexI4U//tSxAYAC4ExR8YMUYGDH+k4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qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+1LEagPIqMSCIARsCAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==\",\n\tduration: 0.446,\n\tformat: \"mp3\",\n\tlicense: \"CC0\",\n\tauthor: \"Kenney\",\n};\n",
      "type": "registry:lib",
      "target": "@lib/soundcn/metal-click.ts"
    },
    {
      "path": "src/lib/soundcn/sound-engine.ts",
      "content": "let audioContext: AudioContext | null = null;\nconst bufferCache = new Map<string, AudioBuffer>();\n\nexport function getAudioContext(): AudioContext {\n\tif (!audioContext) {\n\t\taudioContext = new AudioContext();\n\t}\n\treturn audioContext;\n}\n\nexport async function decodeAudioData(dataUri: string): Promise<AudioBuffer> {\n\tconst cached = bufferCache.get(dataUri);\n\tif (cached) return cached;\n\n\tconst context = getAudioContext();\n\tconst base64 = dataUri.split(\",\")[1];\n\tif (!base64) throw new Error(\"Invalid sound data URI\");\n\n\tconst binaryString = atob(base64);\n\tconst bytes = new Uint8Array(binaryString.length);\n\tfor (let index = 0; index < binaryString.length; index++) {\n\t\tbytes[index] = binaryString.charCodeAt(index);\n\t}\n\n\tconst audioBuffer = await context.decodeAudioData(bytes.buffer.slice(0));\n\tbufferCache.set(dataUri, audioBuffer);\n\treturn audioBuffer;\n}\n",
      "type": "registry:lib",
      "target": "@lib/soundcn/sound-engine.ts"
    },
    {
      "path": "src/lib/soundcn/sound-types.ts",
      "content": "export interface SoundAsset {\n\tname: string;\n\tdataUri: string;\n\tduration: number;\n\tformat: \"mp3\" | \"wav\" | \"ogg\";\n\tlicense: \"CC0\" | \"OGA-BY\" | \"MIT\";\n\tauthor: string;\n}\n\nexport interface UseSoundOptions {\n\tvolume?: number;\n\tplaybackRate?: number;\n\tinterrupt?: boolean;\n\tsoundEnabled?: boolean;\n\tonPlay?: () => void;\n\tonEnd?: () => void;\n\tonPause?: () => void;\n\tonStop?: () => void;\n}\n\nexport type PlayFunction = (overrides?: {\n\tvolume?: number;\n\tplaybackRate?: number;\n}) => void;\n\nexport interface SoundControls {\n\tstop: () => void;\n\tpause: () => void;\n\tisPlaying: boolean;\n\tduration: number | null;\n\tsound: SoundAsset;\n}\n\nexport type UseSoundReturn = readonly [PlayFunction, SoundControls];\n",
      "type": "registry:lib",
      "target": "@lib/soundcn/sound-types.ts"
    }
  ],
  "meta": {
    "createdAt": "2026-07-26",
    "updatedAt": "2026-08-19",
    "image": "https://cdn.tentui.com/images/components/component-sidebar",
    "video": "https://cdn.tentui.com/videos/components/component-sidebar"
  },
  "docs": "https://tentui.com/components/component-sidebar",
  "categories": [
    "navigation"
  ],
  "type": "registry:component"
}