/** * Stage 4.4 port of Base UI React's `useHover` hook. * * React source: * `base-ui/packages/react/src/floating-ui-react/hooks/useHover.ts` * * Single-hook variant for the common case of one reference + one * floating element sharing hover handlers. The React source still ships * this distinct from the reference / floating interaction pair (above) * because the one-off shape has noticeably less bookkeeping — no tree * `floating.closed` events, simpler close-scroll-mouseleave handling, * and a merged `isHoverOpen` predicate that short-circuits most of the * nested-tree gates. * * Consumers that need separate trigger + floating hooks (for wrapper * trigger modes, delegation, etc.) should use the `use-hover-*` pair * directly. * * ### React → Solid deviations * * Same pattern as the sibling hover hooks + `useDismiss`: * - `useRef` → plain `MutableRef` objects / closure `let`s. * - `useValueAsRef(fn)` → read options inside handlers (no wrapping * needed in Solid's non-re-rendering model). * - `useStableCallback` → `createStableCallback`. * - `useEffect` / `useIsoLayoutEffect` → `createEffect` / * `useIsoLayoutEffect` in split-compute-apply form. * - `addEventListener` + `mergeCleanups` → direct DOM-level * `addEventListener` with array-based cleanup in `onCleanup`. * - `isReactEvent` branches dropped: Solid already receives native * events. * * ### Reason strings * * Every hover-driven `setOpen` emits `REASONS.triggerHover`. This * matches React's React-source literal (`'trigger-hover'`) exactly. */ import type { Delay, ElementProps, FloatingContext, FloatingRootContext } from "../types.js"; import type { HandleClose, HandleCloseContext } from "./use-hover-shared.js"; export type { HandleClose, HandleCloseContext }; import { type MaybeAccessor } from "../../maybe-accessor.js"; export interface UseHoverProps { /** * Accepts an event handler that runs on `mousemove` to control when the * floating element closes once the cursor leaves the reference element. * @default null */ handleClose?: HandleClose | null | undefined; /** * Waits until the user's cursor is at "rest" over the reference element * before changing the `open` state. * @default 0 */ restMs?: number | (() => number) | undefined; /** * Waits for the specified time when the event listener runs before changing * the `open` state. * @default 0 */ delay?: Delay | (() => Delay) | undefined; /** * Whether moving the cursor over the floating element will open it, without * a regular hover event required. * @default true */ move?: boolean | undefined; /** * Whether the hook is enabled. When `false`, no listeners are attached * and no state is tracked. Accepts an accessor so reactive callers * can flip mid-life (solidify.md P3). * @default true */ enabled?: MaybeAccessor | undefined; /** * Whether only mouse-like pointers (`mouse`, `pen`) trigger hover-open. * Touch input still dispatches `mouseenter` / `mouseleave` on most * platforms but rarely represents a hover intent. * @default false */ mouseOnly?: boolean | undefined; } /** * Opens the floating element while hovering over the reference element, like * CSS `:hover`. * @see https://floating-ui.com/docs/useHover */ export declare function useHover(context: FloatingRootContext | FloatingContext, props?: UseHoverProps): ElementProps; //# sourceMappingURL=use-hover.d.ts.map