{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mac-window",
  "title": "Mac Window",
  "description": "A desktop-style window frame with traffic-light controls, a title bar, an optional toolbar and a translucent sidebar.",
  "files": [
    {
      "path": "registry/tealmac/mac-window.tsx",
      "content": "// Adapted from Ballmac UI (https://github.com/vamsiy78/ballmac-ui), MIT License, Copyright (c) 2026 Ballmac.\n\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype MacWindowContextValue = {\n  active: boolean\n  onClose?: () => void\n  onMinimize?: () => void\n  onZoom?: () => void\n}\n\nconst MacWindowContext = React.createContext<MacWindowContextValue>({\n  active: true,\n})\n\ntype MacWindowProps = React.ComponentProps<\"div\"> & {\n  /** Active (key) window: colored traffic lights and full-strength title. Inactive windows gray out. */\n  active?: boolean\n  /** Called by the red close button. Without a handler the light is drawn but not focusable. */\n  onClose?: () => void\n  /** Called by the yellow minimize button. */\n  onMinimize?: () => void\n  /** Called by the green zoom (full screen) button. */\n  onZoom?: () => void\n}\n\n/**\n * A desktop-style window frame. Compose it from MacWindowTitleBar + MacWindowContent, or MacWindowSidebar +\n * MacWindowMain for a sidebar layout with vibrancy. Traffic-light colors are the --mac-close, --mac-minimize\n * and --mac-zoom CSS variables; override them on the window if you like.\n */\nfunction MacWindow({\n  active = true,\n  onClose,\n  onMinimize,\n  onZoom,\n  className,\n  style,\n  ...props\n}: MacWindowProps) {\n  const context = React.useMemo(\n    () => ({ active, onClose, onMinimize, onZoom }),\n    [active, onClose, onMinimize, onZoom]\n  )\n  return (\n    <MacWindowContext.Provider value={context}>\n      <div\n        data-slot=\"mac-window\"\n        data-state={active ? \"active\" : \"inactive\"}\n        className={cn(\n          \"group/mac-window bg-card text-card-foreground relative isolate flex min-w-0 flex-col overflow-hidden rounded-[14px] has-[[data-slot=mac-window-sidebar]]:flex-row has-[[data-slot=mac-window-sidebar]]:bg-transparent\",\n          \"shadow-[0_0_0_0.5px_rgb(0_0_0/0.22),0_24px_60px_-12px_rgb(0_0_0/0.35),0_8px_20px_-8px_rgb(0_0_0/0.2)]\",\n          \"dark:shadow-[0_0_0_0.5px_rgb(0_0_0/0.9),inset_0_0_0_0.5px_rgb(255_255_255/0.16),0_24px_60px_-12px_rgb(0_0_0/0.7)]\",\n          \"data-[state=inactive]:shadow-[0_0_0_0.5px_rgb(0_0_0/0.18),0_12px_30px_-12px_rgb(0_0_0/0.25)]\",\n          \"dark:data-[state=inactive]:shadow-[0_0_0_0.5px_rgb(0_0_0/0.9),inset_0_0_0_0.5px_rgb(255_255_255/0.1),0_12px_30px_-12px_rgb(0_0_0/0.5)]\",\n          className\n        )}\n        style={\n          {\n            \"--mac-close\": \"oklch(0.7 0.19 25)\",\n            \"--mac-minimize\": \"oklch(0.84 0.16 84)\",\n            \"--mac-zoom\": \"oklch(0.76 0.19 145)\",\n            ...style,\n          } as React.CSSProperties\n        }\n        {...props}\n      />\n    </MacWindowContext.Provider>\n  )\n}\n\nconst glyphs = {\n  close: (\n    <path d=\"M3.5 3.5l5 5m0-5l-5 5\" strokeWidth=\"1.3\" strokeLinecap=\"round\" />\n  ),\n  minimize: <path d=\"M3 6h6\" strokeWidth=\"1.4\" strokeLinecap=\"round\" />,\n  zoom: (\n    <path\n      d=\"M3.4 8.6V5l3.6 3.6zM8.6 3.4V7L5 3.4z\"\n      stroke=\"none\"\n      fill=\"currentColor\"\n    />\n  ),\n} as const\n\nfunction TrafficLight({\n  kind,\n  label,\n  onPress,\n}: {\n  kind: keyof typeof glyphs\n  label: string\n  onPress?: () => void\n}) {\n  const shared = cn(\n    \"relative flex size-3 shrink-0 items-center justify-center rounded-full text-black/60 outline-none before:absolute before:-inset-1.5 before:content-['']\",\n    \"bg-(--light) shadow-[inset_0_0_0_0.5px_rgb(0_0_0/0.18)] dark:shadow-[inset_0_0_0_0.5px_rgb(255_255_255/0.12)]\",\n    \"group-data-[state=inactive]/mac-window:bg-foreground/15 group-data-[state=inactive]/mac-window:group-hover/lights:bg-(--light)\"\n  )\n  const style = { \"--light\": `var(--mac-${kind})` } as React.CSSProperties\n  const glyph = (\n    <svg\n      viewBox=\"0 0 12 12\"\n      aria-hidden=\"true\"\n      stroke=\"currentColor\"\n      fill=\"none\"\n      className=\"size-3 opacity-0 transition-opacity duration-100 group-hover/lights:opacity-100 group-has-[:focus-visible]/lights:opacity-100\"\n    >\n      {glyphs[kind]}\n    </svg>\n  )\n  if (!onPress) {\n    return (\n      <span\n        data-slot={`mac-window-${kind}`}\n        className={shared}\n        style={style}\n        aria-hidden=\"true\"\n      >\n        {glyph}\n      </span>\n    )\n  }\n  return (\n    <button\n      type=\"button\"\n      data-slot={`mac-window-${kind}`}\n      aria-label={label}\n      onClick={onPress}\n      className={cn(\n        shared,\n        \"focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-1\",\n        // 24px pointer target around the 12px light; the light itself keeps the macOS size.\n        \"after:absolute after:-inset-1.5 after:rounded-full\"\n      )}\n      style={style}\n    >\n      {glyph}\n    </button>\n  )\n}\n\ntype MacWindowControlsProps = React.ComponentProps<\"div\"> & {\n  /** Accessible labels for the three buttons. */\n  labels?: { close?: string; minimize?: string; zoom?: string }\n}\n\n/** The red, yellow and green traffic lights. Glyphs appear when the pointer is over any of them. */\nfunction MacWindowControls({\n  labels,\n  className,\n  ...props\n}: MacWindowControlsProps) {\n  const { onClose, onMinimize, onZoom } = React.useContext(MacWindowContext)\n  return (\n    <div\n      data-slot=\"mac-window-controls\"\n      dir=\"ltr\"\n      className={cn(\"group/lights flex shrink-0 items-center gap-2\", className)}\n      {...props}\n    >\n      <TrafficLight\n        kind=\"close\"\n        label={labels?.close ?? \"Close window\"}\n        onPress={onClose}\n      />\n      <TrafficLight\n        kind=\"minimize\"\n        label={labels?.minimize ?? \"Minimize window\"}\n        onPress={onMinimize}\n      />\n      <TrafficLight\n        kind=\"zoom\"\n        label={labels?.zoom ?? \"Zoom window\"}\n        onPress={onZoom}\n      />\n    </div>\n  )\n}\n\ntype MacWindowTitleBarProps = Omit<React.ComponentProps<\"div\">, \"title\"> & {\n  /** Window title, centered in the bar. */\n  title?: React.ReactNode\n  /** Draw the traffic lights at the leading edge. Turn off when a MacWindowSidebar already shows them. */\n  controls?: boolean\n}\n\n/**\n * The title bar. With only a title it is a compact 28px bar; children render as a trailing toolbar\n * and grow it to the 52px unified-toolbar height.\n */\nfunction MacWindowTitleBar({\n  title,\n  controls = true,\n  className,\n  children,\n  ...props\n}: MacWindowTitleBarProps) {\n  const hasToolbar = React.Children.count(children) > 0\n  return (\n    <div\n      data-slot=\"mac-window-titlebar\"\n      className={cn(\n        \"border-foreground/[0.08] relative flex shrink-0 items-center gap-3 border-b px-3 select-none\",\n        hasToolbar ? \"h-[52px] px-4\" : \"h-8\",\n        className\n      )}\n      {...props}\n    >\n      {controls ? <MacWindowControls /> : null}\n      {title ? (\n        <div\n          data-slot=\"mac-window-title\"\n          className={cn(\n            \"text-foreground/85 group-data-[state=inactive]/mac-window:text-muted-foreground pointer-events-none truncate text-[13px] font-semibold\",\n            hasToolbar ? \"min-w-0\" : \"absolute inset-x-20 text-center\"\n          )}\n        >\n          {title}\n        </div>\n      ) : null}\n      {hasToolbar ? (\n        <div\n          data-slot=\"mac-window-toolbar\"\n          className=\"text-foreground/70 group-data-[state=inactive]/mac-window:text-foreground/35 ms-auto flex min-w-0 items-center gap-1\"\n        >\n          {children}\n        </div>\n      ) : null}\n    </div>\n  )\n}\n\ntype MacWindowToolbarButtonProps = React.ComponentProps<\"button\">\n\n/** A borderless toolbar button that highlights on hover, sized for 16px icons. Give icon-only buttons an aria-label. */\nfunction MacWindowToolbarButton({\n  className,\n  type = \"button\",\n  ...props\n}: MacWindowToolbarButtonProps) {\n  return (\n    <button\n      type={type}\n      data-slot=\"mac-window-toolbar-button\"\n      className={cn(\n        \"hover:bg-foreground/[0.07] hover:text-foreground focus-visible:ring-ring/50 inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-1.5 rounded-md px-1.5 text-[13px] transition-colors duration-150 outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\ntype MacWindowSidebarProps = React.ComponentProps<\"div\"> & {\n  /** Draw the traffic lights at the top of the sidebar. */\n  controls?: boolean\n}\n\n/** A translucent source-list sidebar that blurs whatever is behind the window (vibrancy). */\nfunction MacWindowSidebar({\n  controls = true,\n  className,\n  children,\n  ...props\n}: MacWindowSidebarProps) {\n  return (\n    <div\n      data-slot=\"mac-window-sidebar\"\n      className={cn(\n        \"border-foreground/[0.08] bg-background/60 dark:bg-background/50 flex w-52 shrink-0 flex-col border-e backdrop-blur-2xl backdrop-saturate-150\",\n        className\n      )}\n      {...props}\n    >\n      {controls ? (\n        <div className=\"flex h-[52px] shrink-0 items-center px-4\">\n          <MacWindowControls />\n        </div>\n      ) : null}\n      {children}\n    </div>\n  )\n}\n\ntype MacWindowSidebarItemProps = React.ComponentProps<\"button\"> & {\n  /** Marks the selected row (sets aria-current). */\n  selected?: boolean\n}\n\n/** A source-list row: icon, label and an optional trailing count. */\nfunction MacWindowSidebarItem({\n  selected = false,\n  className,\n  type = \"button\",\n  ...props\n}: MacWindowSidebarItemProps) {\n  return (\n    <button\n      type={type}\n      data-slot=\"mac-window-sidebar-item\"\n      data-selected={selected ? \"\" : undefined}\n      aria-current={selected ? \"true\" : undefined}\n      className={cn(\n        \"text-foreground/85 hover:bg-foreground/[0.05] focus-visible:ring-ring/50 data-selected:bg-foreground/[0.09] data-selected:text-foreground flex h-7 w-full items-center gap-2 rounded-md px-2 text-start text-[13px] transition-colors duration-100 outline-none focus-visible:ring-[3px] data-selected:font-medium [&_svg]:size-4 [&_svg]:shrink-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\ntype MacWindowMainProps = React.ComponentProps<\"div\">\n\n/** The opaque column next to a sidebar; holds the title bar and content. */\nfunction MacWindowMain({ className, ...props }: MacWindowMainProps) {\n  return (\n    <div\n      data-slot=\"mac-window-main\"\n      className={cn(\"bg-card flex min-w-0 flex-1 flex-col\", className)}\n      {...props}\n    />\n  )\n}\n\ntype MacWindowContentProps = React.ComponentProps<\"div\">\n\nfunction MacWindowContent({ className, ...props }: MacWindowContentProps) {\n  return (\n    <div\n      data-slot=\"mac-window-content\"\n      className={cn(\"min-h-0 flex-1 overflow-auto\", className)}\n      {...props}\n    />\n  )\n}\n\nexport {\n  MacWindow,\n  MacWindowContent,\n  MacWindowControls,\n  MacWindowMain,\n  MacWindowSidebar,\n  MacWindowSidebarItem,\n  MacWindowTitleBar,\n  MacWindowToolbarButton,\n  type MacWindowContentProps,\n  type MacWindowControlsProps,\n  type MacWindowMainProps,\n  type MacWindowProps,\n  type MacWindowSidebarItemProps,\n  type MacWindowSidebarProps,\n  type MacWindowTitleBarProps,\n  type MacWindowToolbarButtonProps,\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}