import { ReactiveController, ReactiveElement } from 'lit'; /** Minimum interface required from any element that hosts a {@link HoverController}. */ export interface HoverControllerHost extends ReactiveElement { /** Warm-up duration in milliseconds before the popover opens on hover. `0` opens immediately. */ readonly delay: number; /** * Cooldown duration in milliseconds after the pointer leaves the trigger or * popover before the popover closes. Independent of `delay` so that the * WCAG 1.4.13 pointer bridge always has enough time to cancel the close, * regardless of how quickly the popover opened. * * Defaults to `300` when omitted. */ readonly closeDelay?: number; /** When `true`, the controller skips all event wiring. */ readonly manual: boolean; /** When `true`, the controller skips all event wiring. */ readonly disabled: boolean; /** * Asks the host to open. The host owns its visibility state and is the single * source of truth; the controller never drives the Popover API directly. Must * be idempotent — calling it while already open is a no-op. */ requestOpen(): void; /** * Asks the host to close. Must be idempotent — calling it while already closed * is a no-op. */ requestClose(): void; } /** Configuration options for {@link HoverController}. */ export interface HoverControllerOptions { /** * Per-component-type key used to namespace shared warm state on `document`. * Use the element tag name (e.g. `'swc-tooltip'`). Must be static; must not * vary per instance. */ warmStateKey: string; } /** * A Lit {@link ReactiveController} that manages hover and keyboard-focus event * wiring for components that use the native Popover API. * * See the Storybook stories for full usage documentation and interactive demos. * * @example * ```ts * class SwcTooltip extends LitElement implements HoverControllerHost { * @property({ type: Number }) delay = 1500; * @property({ type: Boolean }) manual = false; * @property({ type: Boolean }) disabled = false; * * private hoverController = new HoverController(this, { warmStateKey: 'swc-tooltip' }); * * protected override updated(changes: PropertyValues): void { * super.updated(changes); * if (changes.has('triggerElement')) { * this.hoverController.setTarget(this.triggerElement ?? null); * } * } * } * ``` */ export declare class HoverController implements ReactiveController { private readonly host; private readonly warmStateKey; private target; private warmupTimer; private isBridgeWired; /** * Tracks whether the `disabled`/`manual` guard is currently active. Used by * `hostUpdated()` to skip the rewire on every Lit update when the guard state * hasn't changed. */ private isGuardActive; /** True while the trigger has keyboard focus; pointer-driven timers are suppressed. */ private hasFocusOpen; /** * Set by `pointerdown` on the trigger and cleared asynchronously after `focusin` * fires. The async reset ensures the flag is still `true` when `focusin` arrives * synchronously later in the same click event sequence. */ private hadPointerdown; private readonly boundPointerDownTrigger; private readonly boundPointerEnterTrigger; private readonly boundPointerLeaveTrigger; private readonly boundFocusin; private readonly boundFocusout; private readonly boundPointerEnterHost; private readonly boundPointerLeaveHost; constructor(host: HoverControllerHost, options: HoverControllerOptions); /** * Sets the element that receives pointer and focus listeners. Call this whenever * the resolved trigger changes (e.g. in `updated()` after a `for` attribute change). * Passing `null` detaches all listeners from the previous target. */ setTarget(trigger: HTMLElement | null): void; hostConnected(): void; hostDisconnected(): void; /** Re-evaluates `disabled` and `manual` guards whenever the host updates. */ hostUpdated(): void; private wireTarget; private unwireTarget; private wireBridge; private unwireBridge; private showWithBridge; private callHidePopover; private clearWarmupTimer; private clearCooldownTimer; private startCooldown; private handlePointerDownTrigger; private handlePointerEnterTrigger; private handlePointerLeaveTrigger; private handleFocusin; private handleFocusout; private handlePointerEnterHost; private handlePointerLeaveHost; }