{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "menubar",
  "title": "Menubar",
  "description": "A row of menus in one frame (Base UI Menubar): title key cells, the open title inverse, menus docked to the frame's edge with Menu's rows and checkbox and radio items.",
  "dependencies": [
    "@base-ui/react@1.9.0"
  ],
  "registryDependencies": [
    "@keyline-ui/keyline",
    "utils",
    "@keyline-ui/keyline-scope",
    "@keyline-ui/scroll-edges",
    "@keyline-ui/menu",
    "@keyline-ui/keyline-render"
  ],
  "files": [
    {
      "path": "src/registry/keyline/ui/menubar.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Menubar as MenubarPrimitive } from \"@base-ui/react/menubar\";\nimport { Menu as MenuPrimitive } from \"@base-ui/react/menu\";\n\nimport { cn } from \"@/lib/utils\";\nimport { scopeProps, useKeylineScope, useMergedRef } from \"../lib/keyline-scope\";\nimport { useScrollEdges } from \"../lib/scroll-edges\";\nimport { resolveClassName } from \"../lib/keyline-render\";\nimport { MenuSurface } from \"./menu\";\n\ntype Layout = \"control\" | \"cell\";\nconst MenubarLayout = React.createContext<Layout>(\"control\");\n\n/* a control frame of title cells; narrow, the row scrolls sideways and marks the hidden edge (scroll edges) */\nconst bar = cn(\n  \"kl-ctl kl-cells flex min-h-(--kl-ctl) w-max max-w-full justify-self-start overflow-x-auto bg-kl-cell\",\n  \"data-[kl-layout=cell]:min-h-(--kl-row) data-[kl-layout=cell]:w-auto\",\n);\n\n/**\n * A row of menus in one frame: each title is a key cell, each menu docks to the frame's edge under it.\n *\n *   ┌──────┬──────┬───────┬──────┐\n *   │ File │ Edit │ View  │ Help │   title cells (View open: the inverse cell)\n *   └──────┴──────┼───────┴──────┘\n *                 │ ☑ Status    │   the menu: Menu's rows, checkbox and radio items, submenus\n *                 │ ○ 24 rows   │\n *\n * - Behaviour is Base UI Menubar: one Tab stop, Left/Right move between titles (wrapping), Down/Enter/\n *   Space open, and while one menu is open, Left/Right and hover move to the neighbouring menu. Escape\n *   closes and returns focus to the title.\n * - The open title is the inverse cell (Select's open caret); the menu's top border lies on the frame's\n *   bottom keyline at the frame's weight, so the two read as one shape. No cut on the menu.\n * - Narrow: the row scrolls sideways and marks the hidden edge (scroll edges).\n * - The rows are Menu's: import MenuItem, MenuCheckboxItem, MenuRadioGroup, MenuRadioItem, MenuSeparator,\n *   MenuGroup(Label) and MenuSubmenuRoot* from ./menu (re-exported here under Menubar names too).\n */\nfunction Menubar({\n  className,\n  layout = \"control\",\n  ref: refProp,\n  ...props\n}: React.ComponentProps<typeof MenubarPrimitive> & { layout?: Layout }): React.ReactElement {\n  const ref = React.useRef<HTMLDivElement>(null);\n  useScrollEdges(ref);\n  const setRef = useMergedRef(ref, refProp);\n  return (\n    <MenubarLayout.Provider value={layout}>\n      <MenubarPrimitive\n        ref={setRef}\n        data-kl-layout={layout}\n        // one Tab stop: Firefox makes an overflowing scroller a Tab stop of its own, even around focusable items\n        tabIndex={-1}\n        className={resolveClassName(bar, className)}\n        {...props}\n        data-slot=\"menubar\"\n      />\n    </MenubarLayout.Provider>\n  );\n}\n\n/** One menu of the bar: Base UI's Menu.Root. */\nconst MenubarMenu = MenuPrimitive.Root;\n\n/* a title: a key cell; the first clears the frame's cut. Open, it is the inverse cell */\nconst title = cn(\n  \"kl-cell kl-key flex flex-none cursor-default items-center gap-1.5 border-y-0 border-e-0 bg-transparent bg-none px-3.5\",\n  \"font-(family-name:--kl-font) text-(length:--kl-text-body) font-(--kl-weight-strong) whitespace-nowrap text-kl-ink outline-0\",\n  \"first:ps-[calc(14px+var(--kl-c,0px)*0.35)]\",\n  \"hover:not-data-popup-open:not-data-disabled:bg-kl-tint\",\n  \"data-popup-open:bg-kl-inverse data-popup-open:text-kl-on-inverse\",\n  \"focus-visible:outline-(length:--kl-ring) focus-visible:outline-offset-(--kl-ring-in) focus-visible:outline-kl-focus focus-visible:outline-solid\",\n  \"data-disabled:cursor-not-allowed data-disabled:bg-(image:--kl-hatch) data-disabled:text-kl-dis\",\n  \"forced-colors:data-popup-open:outline-3 forced-colors:data-popup-open:outline-offset-[-4px]\",\n  \"forced-colors:data-popup-open:outline-[Highlight] forced-colors:data-popup-open:outline-solid\",\n);\n\n/** A menu's title. Rendered as another part, the element is that part's and carries its data-slot. */\nfunction MenubarTrigger({ className, ...props }: MenuPrimitive.Trigger.Props): React.ReactElement {\n  return (\n    <MenuPrimitive.Trigger className={resolveClassName(title, className)} {...props} data-slot=\"menubar-trigger\" />\n  );\n}\n\ntype PositionerProps = MenuPrimitive.Positioner.Props;\n\ntype MenubarPopupProps = React.ComponentProps<typeof MenuSurface> &\n  Pick<PositionerProps, \"anchor\" | \"side\" | \"align\" | \"sideOffset\" | \"alignOffset\" | \"collisionPadding\"> & {\n    /** Where the portal renders (defaults to <body>). */\n    container?: MenuPrimitive.Portal.Props[\"container\"];\n    /** Props for Base UI's Menu.Portal. */\n    portalProps?: Omit<MenuPrimitive.Portal.Props, \"container\" | \"children\">;\n  };\n\n/**\n * A menu of the bar: Base UI's Portal, Positioner and Popup in one part, with the positioner's placement props\n * lifted. It docks under its title: the frame's bottom keyline is the shared edge, and the menu's top border lies on\n * it at the frame's weight. The surface is Menu's (MenuSurface), so it carries `data-slot=\"menu-popup\"`.\n */\nfunction MenubarPopup({\n  anchor,\n  side = \"bottom\",\n  align = \"start\",\n  sideOffset = 0,\n  alignOffset,\n  collisionPadding = 12,\n  container,\n  portalProps,\n  className,\n  ...props\n}: MenubarPopupProps): React.ReactElement {\n  const layout = React.useContext(MenubarLayout);\n  const [marker, scope, probe] = useKeylineScope(false, container);\n  return (\n    <>\n      {marker}\n      <MenuPrimitive.Portal container={container} {...portalProps}>\n        {probe}\n        <MenuPrimitive.Positioner\n          anchor={anchor}\n          side={side}\n          align={align}\n          sideOffset={sideOffset}\n          alignOffset={alignOffset}\n          collisionPadding={collisionPadding}\n          {...scopeProps(scope, { className: \"kl-positioner\" })}\n        >\n          <MenuSurface\n            attachWeight={layout === \"cell\" ? 1 : 2}\n            className={resolveClassName(\"min-w-[max(220px,var(--anchor-width))]\", className)}\n            {...props}\n          />\n        </MenuPrimitive.Positioner>\n      </MenuPrimitive.Portal>\n    </>\n  );\n}\n\nexport { Menubar, MenubarMenu, MenubarTrigger, MenubarPopup };\n/* A submenu's popup is Menu's MenuPopup, which docks beside its row. */\nexport {\n  MenuItem as MenubarItem,\n  MenuCheckboxItem as MenubarCheckboxItem,\n  MenuRadioGroup as MenubarRadioGroup,\n  MenuRadioItem as MenubarRadioItem,\n  MenuSeparator as MenubarSeparator,\n  MenuGroup as MenubarGroup,\n  MenuGroupLabel as MenubarGroupLabel,\n  MenuSubmenuRoot as MenubarSubmenuRoot,\n  MenuSubmenuTrigger as MenubarSubmenuTrigger,\n  MenuPopup as MenubarSubmenuPopup,\n} from \"./menu\";\n",
      "type": "registry:ui",
      "target": "components/keyline/ui/menubar.tsx"
    }
  ],
  "type": "registry:ui"
}