{"version":3,"file":"Menubar.context.mjs","names":[],"sources":["../../../src/components/Menubar/Menubar.context.ts"],"sourcesContent":["import { createSafeContext, GetStylesApi } from '../../core';\nimport type { FloatingPosition } from '../../utils/Floating';\nimport type { MenubarFactory } from './Menubar';\n\nexport interface MenubarContextValue {\n  getStyles: GetStylesApi<MenubarFactory>;\n\n  /** Unique id of the menubar instance, used to scope dropdown lookups across multiple menubars */\n  id: string;\n\n  /** Index of the currently opened menu, `null` when all menus are closed */\n  openIndex: number | null;\n\n  /** Opens the menu at the given index, `null` closes all menus */\n  setOpenIndex: (index: number | null) => void;\n\n  /** Opens the menu at the given index and records whether it was opened by click or hover */\n  openMenu: (index: number, source: 'click' | 'hover') => void;\n\n  /** Closes all menus */\n  closeMenu: () => void;\n\n  /** Schedules a delayed close, used by hover trigger when the pointer leaves the bar */\n  scheduleClose: () => void;\n\n  /** Cancels a pending delayed close */\n  cancelClose: () => void;\n\n  /** Returns how the currently opened menu was opened */\n  getOpenSource: () => 'click' | 'hover' | null;\n\n  /** Returns the previously opened menu index, used to skip transitions when switching menus */\n  getPreviousOpenIndex: () => number | null;\n\n  /** Index of the menu that currently holds the single menubar tab stop */\n  activeIndex: number;\n\n  /** Sets the roving tabindex to the given menu index */\n  setActiveIndex: (index: number) => void;\n\n  trigger: 'click' | 'hover';\n  loop: boolean;\n  position: FloatingPosition;\n  unstyled: boolean | undefined;\n\n  /** Returns the DOM-order index of a `Menubar.Menu` by its id */\n  getMenuIndex: (id: string) => number;\n\n  /** Returns all top-level target buttons in DOM order */\n  getTargets: () => HTMLButtonElement[];\n\n  /** Returns the indexes of the enabled top-level targets in DOM order */\n  getEnabledIndexes: () => number[];\n\n  /** Returns the index of the next/previous enabled target relative to `current` */\n  getAdjacentIndex: (current: number, direction: 1 | -1) => number;\n\n  /** Focuses the top-level target at the given index */\n  focusTarget: (index: number) => void;\n\n  /** Focuses the first or last item of the (opened) menu at the given index */\n  focusMenuItem: (index: number, position: 'first' | 'last') => void;\n}\n\nexport const [MenubarContextProvider, useMenubarContext] = createSafeContext<MenubarContextValue>(\n  'Menubar component was not found in the tree'\n);\n\nexport interface MenubarMenuContextValue {\n  id: string;\n  index: number;\n  opened: boolean;\n}\n\nexport const [MenubarMenuContextProvider, useMenubarMenuContext] =\n  createSafeContext<MenubarMenuContextValue>('Menubar.Menu component was not found in the tree');\n"],"mappings":";;;AAgEA,MAAa,CAAC,wBAAwB,qBAAqB,kBACzD,6CACF;AAQA,MAAa,CAAC,4BAA4B,yBACxC,kBAA2C,kDAAkD"}