import type { Placement } from '@vielzeug/orbit'; import { type Readable, type Signal } from '@vielzeug/ripple'; import { type DialogCloseReason, type OverlayOpenReason } from '../../core'; export type FloatingTriggerType = 'click' | 'focus' | 'hover'; export type AriaBindFn = (triggerEl: HTMLElement) => () => void; export type FloatingTriggerOptions = { /** ARIA binding factory: called with the trigger element, returns a cleanup. */ bindTriggerAria: AriaBindFn; /** Initial uncontrolled visibility. Ignored when `openProp` is defined. */ defaultOpen: Readable; /** If true, disable all trigger interactions and close if open. */ disabled: Readable; /** Returns the host element (e.g. ore-popover) so slotted content clicks aren't treated as outside clicks. */ getHost?: () => Element | null; /** Returns the panel element, if mounted. */ getPanel: () => HTMLElement | null; /** Gap from reference to floating panel in px. Default: 8. Accepts a signal for runtime reactivity. */ offset?: Readable | number; /** Cleanup registrar from the component setup ctx. Automatically called on disconnect. */ onCleanup: (fn: () => void) => void; /** Called when the popover closes. */ onClose?: (reason: DialogCloseReason) => void; /** Called when the popover opens. */ onOpen?: (reason: OverlayOpenReason) => void; /** Callback when resolved placement changes (useful for CSS attribute). */ onPlacementChange?: (placement: Placement) => void; /** Controlled open prop. When defined, disables uncontrolled logic. */ openProp: Readable; /** Preferred placement. Default: 'bottom'. */ placement: Readable; /** Slot element or a factory to lazily find it. Resolved each time bindEvents runs. */ slot: HTMLSlotElement | null | (() => HTMLSlotElement | null); /** Slot elements signal — used to rebind when slotted elements change. */ slotElements: Readable; /** Which triggers are active. Set to empty array or omit if handling events manually. */ triggers: Readable; }; export type FloatingTriggerHandle = { /** Closes the panel. No-op if controlled. */ close: (reason?: DialogCloseReason) => void; /** * Call inside `onMounted`. Sets up slot + trigger event watchers * and returns a cleanup function to pass back to the framework. */ mount: () => () => void; /** Opens the panel. No-op if controlled. */ open: (reason?: OverlayOpenReason) => void; /** Toggles the panel. No-op if controlled. */ toggle: () => void; /** Manually trigger a position recalculation. */ updatePosition: () => void; /** Whether the panel is currently visible. */ visible: Signal; }; /** * Shared logic for floating-panel triggers (tooltip, popover). * * Handles: * - Slot-based trigger element detection and rebinding * - Event binding per trigger type (hover / focus / click) * - Floating-element positioning via `@vielzeug/orbit` * - Controlled mode via `openProp` watcher * - Keyboard escape dismissal * * ARIA binding is intentionally delegated to the caller via `bindTriggerAria` * so that tooltip (`describedby`) and popover (`expanded`/`controls`/…) can diverge. */ export declare const useFloatingTrigger: (options: FloatingTriggerOptions) => FloatingTriggerHandle; //# sourceMappingURL=use-floating-trigger.d.ts.map