/** * Reactive composables that observe specific DOM targets (1.14+). * * Includes `useScroll`, `useElementSize`, `useElementBounding`, * `useElementVisibility`, `useHover`, `useFocus`, `useFocusWithin`, * `useActiveElement`, and `usePointer`. * * @module bquery/media */ import { type AbortableOptions } from './internal'; import type { MediaSignalHandle } from './types'; type ScrollTarget = Window | Element | null | undefined; /** * State exposed by {@link useScroll}. */ export interface ScrollState { /** Current horizontal scroll position. */ x: number; /** Current vertical scroll position. */ y: number; /** `1` for right, `-1` for left, `0` when not moving horizontally. */ directionX: -1 | 0 | 1; /** `1` for down, `-1` for up, `0` when not moving vertically. */ directionY: -1 | 0 | 1; /** True while the user is actively scrolling. */ isScrolling: boolean; /** Edge flags — true when the scroll position is at the corresponding edge. */ arrived: { top: boolean; bottom: boolean; left: boolean; right: boolean; }; } /** * Options for {@link useScroll}. */ export interface UseScrollOptions extends AbortableOptions { /** Milliseconds without scroll events before `isScrolling` resets. @default 100 */ idleTimeoutMs?: number; /** Pixel tolerance for edge detection (`arrived.*`). @default 0 */ arrivedTolerance?: number; } /** * Reactive scroll position with direction tracking and edge detection. * * @param target - Element or `window` (default). */ export declare const useScroll: (target?: ScrollTarget, options?: UseScrollOptions) => MediaSignalHandle; /** Result of {@link useElementSize}. */ export interface ElementSize { width: number; height: number; } /** * Reactive `{ width, height }` of an element via `ResizeObserver`. */ export declare const useElementSize: (el: Element | null | undefined, options?: AbortableOptions) => MediaSignalHandle; /** Result of {@link useElementBounding}. */ export interface ElementBoundingRect { width: number; height: number; top: number; right: number; bottom: number; left: number; x: number; y: number; } /** * Reactive `getBoundingClientRect()` value, updated on scroll, resize, and * `ResizeObserver` callbacks. */ export declare const useElementBounding: (el: Element | null | undefined, options?: AbortableOptions) => MediaSignalHandle; /** * Reactive boolean — `true` when the element is intersecting the viewport. */ export declare const useElementVisibility: (el: Element | null | undefined, options?: AbortableOptions & { threshold?: number | number[]; rootMargin?: string; }) => MediaSignalHandle; /** * Reactive boolean — true while the pointer is hovering the element. */ export declare const useHover: (el: Element | null | undefined, options?: AbortableOptions) => MediaSignalHandle; /** * Reactive boolean — true while the element matches `:focus`. */ export declare const useFocus: (el: Element | null | undefined, options?: AbortableOptions) => MediaSignalHandle; /** * Reactive boolean — true while the element matches `:focus-within`. */ export declare const useFocusWithin: (el: Element | null | undefined, options?: AbortableOptions) => MediaSignalHandle; /** * Reactive `document.activeElement` reference. */ export declare const useActiveElement: (options?: AbortableOptions) => MediaSignalHandle; /** State exposed by {@link usePointer}. */ export interface PointerState { x: number; y: number; pressure: number; type: 'mouse' | 'pen' | 'touch' | 'unknown'; isInside: boolean; } /** * Reactive pointer position tracked from `window` `pointermove` / * `pointerleave` events. The `isInside` flag toggles based on whether the * pointer is over the document. */ export declare const usePointer: (options?: AbortableOptions) => MediaSignalHandle; export {}; //# sourceMappingURL=dom-targets.d.ts.map