import type { Orientation } from "@kobalte/utils"; import { type Accessor, type Setter, createContext, useContext, } from "solid-js"; export interface MenubarDataSet { "data-expanded": string | undefined; "data-closed": string | undefined; } export interface MenubarContextValue { dataset: Accessor; value: Accessor; setValue: ( next: | string | ((prev: string | undefined | null) => string | undefined) | undefined | null, ) => void; menus: Accessor>; menuRefs: Accessor>; menuRefMap: Accessor>>; lastValue: Accessor; setLastValue: ( next: | string | ((prev: string | undefined) => string | undefined) | undefined, ) => void; registerMenu: (value: string, refs: Array) => void; unregisterMenu: (value: string) => void; nextMenu: () => void; previousMenu: () => void; closeMenu: () => void; setAutoFocusMenu: Setter; autoFocusMenu: Accessor; generateId: (part: string) => string; orientation: Accessor; } export const MenubarContext = createContext(); export function useOptionalMenubarContext() { return useContext(MenubarContext); } export function useMenubarContext() { const context = useOptionalMenubarContext(); if (context === undefined) { throw new Error( "[kobalte]: `useMenubarContext` must be used within a `Menubar` component", ); } return context; }