{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "retro-control-strip",
  "title": "RetroControlStrip",
  "description": "The Mac OS 9 Control Strip: a collapsible strip of module buttons with a ridged end tab and pop-up module menus. Exports RetroControlStrip, RetroControlStripModule and RetroControlStripTab (aliased ControlStrip, ControlStripModule, ControlStripTab).",
  "registryDependencies": [
    "https://nostalgia-ui.com/r/nostalgia-theme.json",
    "https://nostalgia-ui.com/r/retro-dropdown-menu.json"
  ],
  "files": [
    {
      "path": "registry/new-york/ui/retro-control-strip.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport {\n  RetroDropdownMenu,\n  RetroDropdownMenuContent,\n  RetroDropdownMenuTrigger,\n} from \"@/registry/new-york/ui/retro-dropdown-menu\"\n\n/* ------------------------------------------------------------------ */\n/*  Context                                                            */\n/* ------------------------------------------------------------------ */\n\ninterface ControlStripContextValue {\n  open: boolean\n  setOpen: (open: boolean) => void\n  side: \"left\" | \"right\"\n  contentId: string\n}\n\nconst ControlStripContext =\n  React.createContext<ControlStripContextValue | null>(null)\n\nfunction useControlStrip(component: string) {\n  const ctx = React.useContext(ControlStripContext)\n  if (!ctx) throw new Error(`${component} must be used inside <RetroControlStrip>`)\n  return ctx\n}\n\n/* ------------------------------------------------------------------ */\n/*  RetroControlStripTab                                               */\n/* ------------------------------------------------------------------ */\n\nexport type RetroControlStripTabProps =\n  React.ButtonHTMLAttributes<HTMLButtonElement>\n\n/**\n * The ridged tab at the free end of the strip. Clicking it collapses or\n * expands the strip. Rendered automatically by RetroControlStrip unless you\n * place one yourself (or pass `tab={false}`).\n */\nconst RetroControlStripTab = React.forwardRef<\n  HTMLButtonElement,\n  RetroControlStripTabProps\n>(function RetroControlStripTab({ className, onClick, ...props }, ref) {\n  const { open, setOpen, side, contentId } = useControlStrip(\"RetroControlStripTab\")\n  return (\n    <button\n      ref={ref}\n      type=\"button\"\n      aria-expanded={open}\n      aria-controls={contentId}\n      aria-label={open ? \"Collapse Control Strip\" : \"Expand Control Strip\"}\n      onClick={(e) => {\n        onClick?.(e)\n        if (!e.defaultPrevented) setOpen(!open)\n      }}\n      className={cn(\n        \"relative flex h-full w-[12px] shrink-0 cursor-default items-center justify-center gap-[1px]\",\n        \"border-os9-black bg-os9-gray-400\",\n        side === \"left\" ? \"border-l\" : \"border-r\",\n        \"shadow-[var(--os9-shadow-raised)]\",\n        \"active:bg-os9-gray-600 active:shadow-[var(--os9-shadow-pressed)]\",\n        \"focus-visible:os9-focus-ring focus-visible:z-10\",\n        className\n      )}\n      {...props}\n    >\n      {/* Vertical grip ridges */}\n      {[0, 1, 2].map((i) => (\n        <span\n          key={i}\n          aria-hidden=\"true\"\n          className=\"h-[12px] w-[1px] bg-os9-gray-700 shadow-[1px_0_0_var(--os9-white)] mr-[1px]\"\n        />\n      ))}\n    </button>\n  )\n})\nRetroControlStripTab.displayName = \"RetroControlStripTab\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroControlStrip                                                  */\n/* ------------------------------------------------------------------ */\n\nexport interface RetroControlStripProps\n  extends React.HTMLAttributes<HTMLDivElement> {\n  /** Controlled expanded state. */\n  open?: boolean\n  /** Uncontrolled initial state. Defaults to true. */\n  defaultOpen?: boolean\n  onOpenChange?: (open: boolean) => void\n  /**\n   * Screen edge the strip is anchored to. The tab sits on the opposite end.\n   * Defaults to \"left\" (the classic bottom-left placement).\n   */\n  side?: \"left\" | \"right\"\n  /** Render the built-in tab. Defaults to true. */\n  tab?: boolean\n}\n\n/**\n * Mac OS 9 Control Strip. Position it yourself, e.g.\n * `className=\"absolute bottom-4 left-0\"` or `\"fixed bottom-4 left-0\"`.\n */\nconst RetroControlStrip = React.forwardRef<HTMLDivElement, RetroControlStripProps>(\n  function RetroControlStrip(\n    {\n      open: openProp,\n      defaultOpen = true,\n      onOpenChange,\n      side = \"left\",\n      tab = true,\n      className,\n      children,\n      ...props\n    },\n    ref\n  ) {\n    const [internalOpen, setInternalOpen] = React.useState(defaultOpen)\n    const open = openProp ?? internalOpen\n    const setOpen = React.useCallback(\n      (next: boolean) => {\n        if (openProp === undefined) setInternalOpen(next)\n        onOpenChange?.(next)\n      },\n      [openProp, onOpenChange]\n    )\n    const contentId = React.useId()\n\n    const ctx = React.useMemo(\n      () => ({ open, setOpen, side, contentId }),\n      [open, setOpen, side, contentId]\n    )\n\n    // Separate a user-provided tab from modules.\n    const childArray = React.Children.toArray(children)\n    const userTab = childArray.find(\n      (c) => React.isValidElement(c) && c.type === RetroControlStripTab\n    )\n    const modules = childArray.filter((c) => c !== userTab)\n    const tabEl = userTab ?? (tab ? <RetroControlStripTab /> : null)\n\n    return (\n      <ControlStripContext.Provider value={ctx}>\n        <div\n          ref={ref}\n          role=\"group\"\n          aria-label=\"Control Strip\"\n          data-state={open ? \"open\" : \"closed\"}\n          className={cn(\n            \"inline-flex h-[24px] items-stretch\",\n            \"border border-os9-black bg-os9-gray-300\",\n            \"shadow-[1px_1px_0_var(--os9-black)]\",\n            side === \"right\" && \"flex-row-reverse\",\n            className\n          )}\n          {...props}\n        >\n          {/* Collapsible module well: animates grid track 0fr ↔ 1fr */}\n          <div\n            className={cn(\n              \"grid transition-[grid-template-columns] duration-200 ease-out motion-reduce:transition-none\",\n              open ? \"grid-cols-[1fr]\" : \"grid-cols-[0fr]\"\n            )}\n          >\n            <div\n              id={contentId}\n              inert={!open}\n              className=\"flex min-w-0 items-stretch overflow-hidden\"\n            >\n              <div\n                className={cn(\n                  \"flex items-stretch\",\n                  side === \"right\" && \"flex-row-reverse\"\n                )}\n              >\n                {modules}\n              </div>\n            </div>\n          </div>\n          {tabEl}\n        </div>\n      </ControlStripContext.Provider>\n    )\n  }\n)\nRetroControlStrip.displayName = \"RetroControlStrip\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroControlStripModule                                            */\n/* ------------------------------------------------------------------ */\n\nexport interface RetroControlStripModuleProps\n  extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n  /** 16x16 icon artwork. */\n  icon: React.ReactNode\n  /** Accessible name and tooltip. */\n  label: string\n  /**\n   * Pop-up menu contents (RetroDropdownMenuItem, RetroDropdownMenuCheckboxItem,\n   * RetroDropdownMenuSeparator, …). When set, the module opens a menu above\n   * the strip and shows a small pop-up indicator.\n   */\n  menu?: React.ReactNode\n  /** Props forwarded to the menu content (e.g. `className`, `align`). */\n  menuContentProps?: React.ComponentPropsWithoutRef<typeof RetroDropdownMenuContent>\n  /** Optional short text shown next to the icon (e.g. a clock readout). */\n  text?: React.ReactNode\n}\n\nconst moduleClasses = cn(\n  \"group/module relative flex h-full shrink-0 cursor-default items-center gap-[3px] px-[4px]\",\n  \"border-r border-os9-gray-700 shadow-[inset_1px_0_0_var(--os9-white),1px_0_0_var(--os9-white)]\",\n  \"text-os9-black outline-none\",\n  \"active:bg-os9-gray-600 data-open:bg-os9-gray-600\",\n  \"active:shadow-[var(--os9-shadow-pressed)] data-open:shadow-[var(--os9-shadow-pressed)]\",\n  \"focus-visible:os9-focus-ring focus-visible:z-10\",\n  \"disabled:opacity-50 disabled:pointer-events-none\"\n)\n\nconst RetroControlStripModule = React.forwardRef<\n  HTMLButtonElement,\n  RetroControlStripModuleProps\n>(function RetroControlStripModule(\n  { icon, label, menu, menuContentProps, text, className, ...props },\n  ref\n) {\n  const content = (\n    <>\n      <span className=\"flex size-[16px] items-center justify-center\" aria-hidden=\"true\">\n        {icon}\n      </span>\n      {text != null && (\n        <span className=\"font-[family-name:var(--os9-font-sans)] text-[10px] whitespace-nowrap\">\n          {text}\n        </span>\n      )}\n      {menu && (\n        /* Pop-up indicator */\n        <svg width=\"5\" height=\"3\" viewBox=\"0 0 5 3\" aria-hidden=\"true\" className=\"self-end mb-[4px]\">\n          <path d=\"M0 3L2.5 0L5 3Z\" fill=\"currentColor\" />\n        </svg>\n      )}\n    </>\n  )\n\n  if (!menu) {\n    return (\n      <button\n        ref={ref}\n        type=\"button\"\n        aria-label={label}\n        title={label}\n        className={cn(moduleClasses, className)}\n        {...props}\n      >\n        {content}\n      </button>\n    )\n  }\n\n  return (\n    <RetroDropdownMenu modal={false}>\n      <RetroDropdownMenuTrigger\n        render={\n          <button\n            ref={ref}\n            type=\"button\"\n            aria-label={label}\n            title={label}\n            className={cn(moduleClasses, className)}\n            {...props}\n          />\n        }\n      >\n        {content}\n      </RetroDropdownMenuTrigger>\n      <RetroDropdownMenuContent\n        side=\"top\"\n        align=\"start\"\n        sideOffset={2}\n        {...menuContentProps}\n      >\n        {menu}\n      </RetroDropdownMenuContent>\n    </RetroDropdownMenu>\n  )\n})\nRetroControlStripModule.displayName = \"RetroControlStripModule\"\n\n/* ------------------------------------------------------------------ */\n/*  Exports                                                            */\n/* ------------------------------------------------------------------ */\n\nexport {\n  RetroControlStrip,\n  RetroControlStripModule,\n  RetroControlStripTab,\n  // Short aliases\n  RetroControlStrip as ControlStrip,\n  RetroControlStripModule as ControlStripModule,\n  RetroControlStripTab as ControlStripTab,\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}