{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "core-mega-menu",
  "type": "registry:lib",
  "title": "core/mega-menu",
  "description": "Framework-free behaviour shared by the ui-* components (mega-menu); no DOM, no lit. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/core/mega-menu.ts",
      "type": "registry:lib",
      "target": "components/ui/core/mega-menu.ts",
      "content": "/**\n * The header mega menu's rules (Lit `<ui-header-mega-menu>` and React `HeaderMegaMenu` share them): how a panel\n * opens and closes by hover (Vercel's header: a short delay before opening, a grace period before closing, switching\n * between top items at once), and what a click on the top item does to a panel the pointer opened. No DOM, no timers:\n * the renderers run the delays.\n */\n\n/** How the panel was opened: by the pointer resting on the top item, a click, or the keyboard. */\nexport type MegaOpenedBy = 'hover' | 'click' | 'keyboard';\n\n/** The open state a renderer keeps. */\nexport interface MegaState {\n    readonly open: boolean;\n    /** null while closed. */\n    readonly openedBy: MegaOpenedBy | null;\n}\n\n/** The pointer rests this long on a top item before its panel opens (an accidental pass across the header doesn't). */\nexport const MEGA_HOVER_OPEN_MS = 150;\n\n/** Leaving the top item and the panel closes a hover-opened panel after this long (a diagonal path to the panel is fine). */\nexport const MEGA_HOVER_CLOSE_MS = 300;\n\nexport const megaClosed: MegaState = { open: false, openedBy: null };\n\n/** The delay before a hover opens the panel: none while another top item's panel is open, so moving along switches at once. */\nexport const megaHoverDelay = (anotherOpen: boolean) => (anotherOpen ? 0 : MEGA_HOVER_OPEN_MS);\n\n/**\n * A click (or Enter / Space) on the top item. A panel the pointer opened stays open and is now held by the click (the\n * user clicked what they were already looking at); otherwise the click toggles it.\n */\nexport function megaTriggerPress(state: MegaState, by: 'click' | 'keyboard'): MegaState {\n    if (state.open && state.openedBy === 'hover') return { open: true, openedBy: by };\n    return state.open ? megaClosed : { open: true, openedBy: by };\n}\n\n/** Whether the pointer leaving the top item and the panel closes it: only when the pointer opened it. */\nexport const megaClosesOnLeave = (state: MegaState) => state.open && state.openedBy === 'hover';\n\n/** Whether a pointer can open panels by hover: a mouse (a finger has no hover; a tap is a click). */\nexport const megaHoverPointer = (pointerType: string) => pointerType === 'mouse';\n"
    }
  ]
}
