UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

75 lines 4.33 kB
import * as React from 'react'; import { ReactStore } from '@base-ui-components/utils/store'; import { MenuParent, MenuRoot } from "../root/MenuRoot.js"; import { FloatingTreeStore } from "../../floating-ui-react/index.js"; import { HTMLProps } from "../../utils/types.js"; import { PopupStoreContext, PopupStoreState } from "../../utils/popups/index.js"; export type State<Payload> = PopupStoreState<Payload> & { disabled: boolean; modal: boolean; allowMouseEnter: boolean; parent: MenuParent; rootId: string | undefined; activeIndex: number | null; hoverEnabled: boolean; stickIfOpen: boolean; instantType: 'dismiss' | 'click' | 'group' | undefined; openChangeReason: MenuRoot.ChangeEventReason | null; floatingTreeRoot: FloatingTreeStore; floatingNodeId: string | undefined; floatingParentNodeId: string | null; itemProps: HTMLProps; closeDelay: number; keyboardEventRelay: ((event: React.KeyboardEvent<any>) => void) | undefined; }; type Context = PopupStoreContext<MenuRoot.ChangeEventDetails> & { readonly positionerRef: React.RefObject<HTMLElement | null>; readonly popupRef: React.RefObject<HTMLElement | null>; readonly typingRef: React.RefObject<boolean>; readonly itemDomElements: React.RefObject<(HTMLElement | null)[]>; readonly itemLabels: React.RefObject<(string | null)[]>; allowMouseUpTriggerRef: React.RefObject<boolean>; readonly triggerFocusTargetRef: React.RefObject<HTMLElement | null>; readonly beforeContentFocusGuardRef: React.RefObject<HTMLElement | null>; }; declare const selectors: { disabled: (state: State<unknown>) => boolean; modal: (state: State<unknown>) => boolean; allowMouseEnter: (state: State<unknown>) => boolean; stickIfOpen: (state: State<unknown>) => boolean; parent: (state: State<unknown>) => MenuParent; rootId: (state: State<unknown>) => string | undefined; activeIndex: (state: State<unknown>) => number | null; isActive: (state: State<unknown>, itemIndex: number) => boolean; hoverEnabled: (state: State<unknown>) => boolean; instantType: (state: State<unknown>) => "group" | "click" | "dismiss" | undefined; lastOpenChangeReason: (state: State<unknown>) => import("../index.js").MenuRootChangeEventReason | null; floatingTreeRoot: (state: State<unknown>) => FloatingTreeStore; floatingNodeId: (state: State<unknown>) => string | undefined; floatingParentNodeId: (state: State<unknown>) => string | null; itemProps: (state: State<unknown>) => HTMLProps; closeDelay: (state: State<unknown>) => number; keyboardEventRelay: (state: State<unknown>) => React.KeyboardEventHandler<any> | undefined; open: (state: PopupStoreState<unknown>) => boolean; mounted: (state: PopupStoreState<unknown>) => boolean; transitionStatus: (state: PopupStoreState<unknown>) => import("../../utils/useTransitionStatus.js").TransitionStatus; floatingRootContext: (state: PopupStoreState<unknown>) => import("../../floating-ui-react/components/FloatingRootStore.js").FloatingRootStore; preventUnmountingOnClose: (state: PopupStoreState<unknown>) => boolean; payload: (state: PopupStoreState<unknown>) => unknown; activeTriggerId: (state: PopupStoreState<unknown>) => string | null; activeTriggerElement: (state: PopupStoreState<unknown>) => Element | null; isTriggerActive: (state: PopupStoreState<unknown>, triggerId: string | undefined) => boolean; isOpenedByTrigger: (state: PopupStoreState<unknown>, triggerId: string | undefined) => boolean; isMountedByTrigger: (state: PopupStoreState<unknown>, triggerId: string | undefined) => boolean; triggerProps: (state: PopupStoreState<unknown>, isActive: boolean) => HTMLProps; popupProps: (state: PopupStoreState<unknown>) => HTMLProps; popupElement: (state: PopupStoreState<unknown>) => HTMLElement | null; positionerElement: (state: PopupStoreState<unknown>) => HTMLElement | null; }; export declare class MenuStore<Payload> extends ReactStore<Readonly<State<Payload>>, Context, typeof selectors> { constructor(initialState?: Partial<State<Payload>>); setOpen(open: boolean, eventDetails: Omit<MenuRoot.ChangeEventDetails, 'preventUnmountOnClose'>): void; static useStore<Payload>(externalStore: MenuStore<Payload> | undefined, initialState: Partial<State<Payload>>): MenuStore<Payload>; private unsubscribeParentListener; } export {};