import { type MaybeAccessor } from "../../maybe-accessor.js"; import type { FloatingTreeStore } from "../components/floating-tree-store.js"; import type { ElementProps, FloatingContext, FloatingRootContext } from "../types.js"; type PressType = "intentional" | "sloppy"; export interface UseDismissProps { /** * Whether the Hook is enabled, including all internal Effects and event * handlers. Accepts an accessor for reactive flips (solidify.md P3). * @default true */ enabled?: MaybeAccessor | undefined; /** * Whether to dismiss the floating element upon pressing the `esc` key. * Accepts an accessor for reactive flips. * @default true */ escapeKey?: MaybeAccessor | undefined; /** * Whether to dismiss the floating element upon pressing the reference * element. You likely want to ensure the `move` option in the `useHover()` * Hook has been disabled when this is in use. * * A lazy getter invoked when handling reference press events. * @default false */ referencePress?: (() => boolean) | undefined; /** * The type of event to use to determine a "press". * - `sloppy` is `pointerdown` on mouse input, but special touch handling * on touch input. * - `intentional` is lazy on both mouse + touch input (equivalent to * `click`). * @default 'sloppy' */ referencePressEvent?: PressType | undefined; /** * Whether to dismiss the floating element upon pressing outside of the * floating element. * If you have another element, like a toast, that is rendered outside the * floating element's tree and don't want the floating element to close * when pressing it, you can guard the check like so: * ```jsx * useDismiss(context, { * outsidePress: (event) => !event.target.closest('.toast'), * }); * ``` * @default true */ outsidePress?: boolean | ((event: MouseEvent | TouchEvent) => boolean) | undefined; /** * The type of event to use to determine an outside "press". * - `intentional` requires an intentional click — mouse fires on * `pointerup`, touch requires minimal `touchmove`s. * - `sloppy` fires on `pointerdown` for mouse; touch fires on * `touchend` (within 1 s) or on scroll-away after `touchstart`. * * Can be a per-input record or a lazy getter returning either form. * @default 'sloppy' */ outsidePressEvent?: PressType | { mouse: PressType; touch: PressType; } | (() => PressType | { mouse: PressType; touch: PressType; }) | undefined; /** * Determines whether event listeners bubble upwards through a tree of * floating elements. Accepts an accessor — including accessors on the * nested `escapeKey` / `outsidePress` fields — so reactive callers can * flip submenu escape-bubbling (solidify.md P3). */ bubbles?: MaybeAccessor | undefined; outsidePress?: MaybeAccessor | undefined; }> | undefined; /** * External `FloatingTreeStore` to use when the context-provided one is * not reachable. */ externalTree?: FloatingTreeStore | undefined; } /** * Closes the floating element when a dismissal is requested — by default, * when the user presses `Escape` or outside of the floating element. * @see https://floating-ui.com/docs/useDismiss */ export declare function useDismiss(context: FloatingRootContext | FloatingContext | (() => FloatingRootContext | FloatingContext), props?: UseDismissProps): ElementProps; export {}; //# sourceMappingURL=use-dismiss.d.ts.map