@base-ui/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.
385 lines • 17.6 kB
text/typescript
import * as React from 'react';
import { ReactStore } from '@base-ui/utils/store';
import { type InteractionType } from '@base-ui/utils/useEnhancedClickHandler';
import { type DialogRoot } from "../root/DialogRoot.mjs";
import { PopupStoreContext, PopupStoreState } from "../../utils/popups/index.mjs";
export type State<Payload> = PopupStoreState<Payload> & {
modal: boolean | 'trap-focus';
disablePointerDismissal: boolean;
openMethod: InteractionType | null;
nested: boolean;
nestedOpenDialogCount: number;
nestedOpenDrawerCount: number;
titleElementId: string | undefined;
descriptionElementId: string | undefined;
viewportElement: HTMLElement | null;
role: 'dialog' | 'alertdialog';
};
type Context = PopupStoreContext<DialogRoot.ChangeEventDetails> & {
readonly popupRef: React.RefObject<HTMLElement | null>;
readonly backdropRef: React.RefObject<HTMLDivElement | null>;
readonly internalBackdropRef: React.RefObject<HTMLDivElement | null>;
readonly outsidePressEnabledRef: React.MutableRefObject<boolean>;
readonly onNestedDialogOpen?: ((dialogCount: number, drawerCount: number) => void) | undefined;
readonly onNestedDialogClose?: (() => void) | undefined;
};
declare const selectors: {
open: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => boolean;
mounted: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => boolean;
transitionStatus: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => import("../../floating-ui-react/components/FloatingRootStore.mjs").FloatingRootStore;
triggerCount: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => number;
preventUnmountingOnClose: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => boolean;
payload: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => unknown;
activeTriggerId: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => string | null;
activeTriggerElement: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => Element | null;
popupId: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => string | undefined;
isTriggerActive: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}, triggerId: string | undefined) => boolean;
isOpenedByTrigger: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}, triggerId: string | undefined) => boolean;
isMountedByTrigger: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}, triggerId: string | undefined) => boolean;
triggerProps: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}, isActive: boolean) => import("../../index.mjs").HTMLProps;
triggerPopupId: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}, triggerId: string | undefined) => string | undefined;
popupProps: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => import("../../index.mjs").HTMLProps;
popupElement: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => HTMLElement | null;
positionerElement: (state: {
open: boolean;
readonly openProp: boolean | undefined;
mounted: boolean;
transitionStatus: import("../../internals/useTransitionStatus.mjs").TransitionStatus;
floatingRootContext: import("../../floating-ui-react/index.mjs").FloatingRootContext;
floatingId: string | undefined;
triggerCount: number;
preventUnmountingOnClose: boolean;
payload: unknown;
activeTriggerId: string | null;
activeTriggerElement: Element | null;
readonly triggerIdProp: string | null | undefined;
popupElement: HTMLElement | null;
positionerElement: HTMLElement | null;
activeTriggerProps: import("../../index.mjs").HTMLProps;
inactiveTriggerProps: import("../../index.mjs").HTMLProps;
popupProps: import("../../index.mjs").HTMLProps;
}) => HTMLElement | null;
modal: (state: State<unknown>) => "trap-focus" | boolean;
nested: (state: State<unknown>) => boolean;
nestedOpenDialogCount: (state: State<unknown>) => number;
nestedOpenDrawerCount: (state: State<unknown>) => number;
disablePointerDismissal: (state: State<unknown>) => boolean;
openMethod: (state: State<unknown>) => InteractionType | null;
descriptionElementId: (state: State<unknown>) => string | undefined;
titleElementId: (state: State<unknown>) => string | undefined;
viewportElement: (state: State<unknown>) => HTMLElement | null;
role: (state: State<unknown>) => "alertdialog" | "dialog";
};
export declare class DialogStore<Payload> extends ReactStore<Readonly<State<Payload>>, Context, typeof selectors> {
constructor(initialState?: Partial<State<Payload>>, floatingId?: string | undefined, nested?: boolean);
setOpen: (nextOpen: boolean, eventDetails: Omit<DialogRoot.ChangeEventDetails, 'preventUnmountOnClose'>) => void;
static useStore<Payload>(externalStore: DialogStore<Payload> | undefined, initialState?: Partial<State<Payload>>): DialogStore<Payload>;
}
export {};