{"version":3,"names":["createContext","useContext","MenuRootContext","useMenuRootContext","optional","ctx","Error"],"sources":["menu-root-context.ts"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\n/**\n * Context plumbing for `<Menu.Root>` → descendants. Mirrors\n * `packages/react/src/menu/root/MenuRootContext.ts` but threads reactive\n * accessors (Solid-native) instead of the React source's store + selector pair.\n *\n * `createContext<T | null>(null)` + `== null` sentinel — menu\n * nests recursively via `<Menu.SubmenuRoot>` so parents must tolerate reads\n * from above a provider.\n */\nimport { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tREASONS,\n} from \"../../internals/change-event-details\";\nimport type { FloatingRootStore } from \"../../internals/floating-ui/components/floating-root-store\";\nimport type { FloatingTreeStore } from \"../../internals/floating-ui/components/floating-tree-store\";\nimport type { UseInteractionsReturn } from \"../../internals/floating-ui/hooks/use-interactions\";\nimport type { MutableRef } from \"../../internals/floating-ui/types\";\nimport type { PropsLike } from \"../../internals/merge-props-n\";\nimport type { InteractionType } from \"../../internals/use-enhanced-click-handler\";\nimport type { TransitionStatus } from \"../../internals/use-transition-status/use-transition-status\";\nimport type { MenuStore } from \"../store/menu-store\";\n\n/**\n * Change-reason union for `Menu.Root`. Mirrors React 1:1.\n */\nexport type MenuRootChangeEventReason =\n\t| typeof REASONS.triggerHover\n\t| typeof REASONS.triggerFocus\n\t| typeof REASONS.triggerPress\n\t| typeof REASONS.outsidePress\n\t| typeof REASONS.focusOut\n\t| typeof REASONS.listNavigation\n\t| typeof REASONS.escapeKey\n\t| typeof REASONS.itemPress\n\t| typeof REASONS.closePress\n\t| typeof REASONS.siblingOpen\n\t| typeof REASONS.cancelOpen\n\t| typeof REASONS.imperativeAction\n\t| typeof REASONS.none;\n\nexport type MenuRootChangeEventDetails =\n\tBaseUIChangeEventDetails<MenuRootChangeEventReason> & {\n\t\t/** Keeps the popup mounted across a close for exit animations. */\n\t\tpreventUnmountOnClose?: () => void;\n\t};\n\nexport type MenuRootOrientation = \"horizontal\" | \"vertical\";\n\nexport type MenuInstantType =\n\t| \"dismiss\"\n\t| \"click\"\n\t| \"group\"\n\t| \"trigger-change\"\n\t| undefined;\n\nexport interface MenuRootContextValue<Payload = unknown> {\n\t/** Whether this root is nested inside another menu (i.e. a submenu). */\n\tnested: Accessor<boolean>;\n\t/** Parent menu context if nested, else null. */\n\tparent: Accessor<MenuRootContextValue<unknown> | null>;\n\n\t/** Reactive open state. */\n\topen: Accessor<boolean>;\n\t/** Whether the popup subtree is currently mounted (open OR animating out). */\n\tmounted: Accessor<boolean>;\n\t/** Enter/exit transition phase, or undefined when settled. */\n\ttransitionStatus: Accessor<TransitionStatus>;\n\n\t/** Whether the menu is in modal mode (top-level only). */\n\tmodal: Accessor<boolean>;\n\t/** Whether the menu is disabled. */\n\tdisabled: Accessor<boolean>;\n\t/** Visual/keyboard orientation. @default \"vertical\" */\n\torientation: Accessor<MenuRootOrientation>;\n\t/** Whether arrow keys loop focus at the ends. */\n\tloopFocus: Accessor<boolean>;\n\t/** Whether hovering items highlights them (drives `data-highlighted`). */\n\thighlightItemOnHover: Accessor<boolean>;\n\n\t/** Highlighted item index for keyboard navigation. */\n\tactiveIndex: Accessor<number | null>;\n\tsetActiveIndex: (index: number | null) => void;\n\n\t/** The current payload attached to the open trigger (when using `handle`). */\n\tpayload: Accessor<Payload | undefined>;\n\tsetPayload: (payload: Payload | undefined) => void;\n\n\t/** The trigger element that opened the menu. */\n\tactiveTriggerElement: Accessor<HTMLElement | null>;\n\tsetActiveTriggerElement: (el: HTMLElement | null) => void;\n\n\t/** The trigger id that opened the menu (for imperative workflows). */\n\tactiveTriggerId: Accessor<string | null>;\n\tsetActiveTriggerId: (id: string | null) => void;\n\n\t/** Last open-change reason, useful for derived styling. */\n\tlastOpenChangeReason: Accessor<MenuRootChangeEventReason | null>;\n\t/** Instant transition hint for skipping entry animations. */\n\tinstantType: Accessor<MenuInstantType>;\n\n\t/** Setters. */\n\tsetOpen: (next: boolean, details: MenuRootChangeEventDetails) => void;\n\n\t/** Floating-UI root context for interaction hooks + positioning. */\n\tfloatingRootContext: FloatingRootStore;\n\t/** Interaction prop-getter bundle (click + dismiss + listnav + typeahead). */\n\tinteractions: UseInteractionsReturn;\n\n\t/** Parallel listRef + labelsRef used by listnav / typeahead. */\n\tlistRef: MutableRef<Array<HTMLElement | null>>;\n\tlabelsRef: MutableRef<Array<string | null>>;\n\t/** Whether typeahead is currently active (suppresses space → click). */\n\ttypingRef: MutableRef<boolean>;\n\t/**\n\t * Delay (ms) before this menu closes when a sibling item of its trigger is\n\t * hovered. Set by `<Menu.SubmenuTrigger>`'s `closeDelay`.\n\t */\n\tcloseDelayRef: MutableRef<number>;\n\n\t/** Popup element ref (filled by `<Menu.Popup>`). */\n\tpopupRef: MutableRef<HTMLElement | null>;\n\t/** Positioner element ref (filled by `<Menu.Positioner>`). */\n\tpositionerRef: MutableRef<HTMLElement | null>;\n\n\t/** Callback fired after open/close transitions settle. */\n\tonOpenChangeComplete?: ((open: boolean) => void) | undefined;\n\n\t/** Optional floating-tree node id for this root. */\n\tfloatingNodeId: Accessor<string | undefined>;\n\n\t/** Whether `closeParentOnEsc` is enabled for submenu escape bubbling. */\n\tcloseParentOnEsc: Accessor<boolean>;\n\n\t/**\n\t * Context-menu root id when this menu is an inner menu of\n\t * `<ContextMenu.Root>`. Threaded onto the popup as `data-rootownerid`\n\t * so nested-menu mouseups can be attributed back to their owning root.\n\t */\n\trootId: Accessor<string | undefined>;\n\n\t/**\n\t * Parent type — mirrors React's `parent.type`. `undefined` for a\n\t * top-level menu, `\"menu\"` for a submenu, `\"menubar\"` when mounted\n\t * inside `<Menubar>`, `\"context-menu\"` when mounted inside\n\t * `<ContextMenu.Root>`, `\"nested-context-menu\"` when the parent is\n\t * itself an inner context-menu.\n\t */\n\tparentType: Accessor<\n\t\t\"menu\" | \"menubar\" | \"context-menu\" | \"nested-context-menu\" | undefined\n\t>;\n\n\t/**\n\t * Underlying `MenuStore` instance. Carries the trigger registry +\n\t * imperative setOpen slot. When the consumer passes a `handle` prop to\n\t * `<Menu.Root>`, the handle's store is adopted here.\n\t */\n\tstore: MenuStore<Payload>;\n\n\t/**\n\t * Interaction type that opened the menu, or `null` when closed. Mirrors\n\t * React's `openMethod` state from `useOpenInteractionType`.\n\t */\n\topenMethod: Accessor<InteractionType | null>;\n\n\t/**\n\t * Extra props emitted by `useOpenInteractionType` that the trigger must\n\t * spread to capture the interaction type on open.\n\t */\n\topenInteractionTypeProps: PropsLike;\n\n\t/**\n\t * Focus-guard refs used by `<Menu.Trigger>`'s `useTriggerFocusGuards`\n\t * integration.\n\t */\n\tbeforeContentFocusGuardRef: MutableRef<HTMLElement | null>;\n\ttriggerFocusTargetRef: MutableRef<HTMLElement | null>;\n\n\t/**\n\t * The floating tree store (if any). Submenus read through to their\n\t * root to emit/subscribe cross-menu events.\n\t */\n\tfloatingTreeRoot: Accessor<FloatingTreeStore | null>;\n\n\t/** Parent floating-tree node id (`null` for top-level roots). */\n\tfloatingParentNodeId: Accessor<string | null>;\n}\n\n/** Wraps a payload child-render function. */\nexport type MenuPayloadChildRenderFunction<Payload> = (details: {\n\tpayload: Payload | undefined;\n}) => JSX.Element;\n\nexport const MenuRootContext = createContext<MenuRootContextValue | null>(null);\n\nexport function useMenuRootContext(): MenuRootContextValue;\nexport function useMenuRootContext(optional: true): MenuRootContextValue | null;\nexport function useMenuRootContext(\n\toptional?: boolean,\n): MenuRootContextValue | null {\n\tconst ctx = useContext(MenuRootContext);\n\tif (ctx == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: MenuRootContext is missing. Menu parts must be placed within <Menu.Root>.\",\n\t\t);\n\t}\n\treturn ctx;\n}\n"],"mappings":"AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAcnE;AACA;AACA;;AAmKA;;AAKA,OAAO,MAAMC,eAAe,GAAGF,aAAa,CAA8B,IAAI,CAAC;AAI/E,OAAO,SAASG,kBAAkBA,CACjCC,QAAkB,EACY;EAC9B,MAAMC,GAAG,GAAGJ,UAAU,CAACC,eAAe,CAAC;EACvC,IAAIG,GAAG,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IAC7B,MAAM,IAAIE,KAAK,CACd,oFACD,CAAC;EACF;EACA,OAAOD,GAAG;AACX","ignoreList":[]}