import * as Stacks from "../../stacks"; export declare abstract class BasePopoverController extends Stacks.StacksController { private popper; protected popoverElement: HTMLElement; protected referenceElement: HTMLElement; /** * An attribute containing the ID of the popover element to render, e.g. aria-controls or aria-describedby. */ protected abstract popoverSelectorAttribute: string; /** * Binds events to the document on element show */ protected abstract bindDocumentEvents(): void; /** * Unbinds events on the document on element hide */ protected abstract unbindDocumentEvents(): void; /** * Returns true if the if the popover is currently visible. */ get isVisible(): boolean; /** * Gets whether the element is visible in the browser's viewport. */ get isInViewport(): boolean; protected get shouldHideOnOutsideClick(): boolean; /** * Only menu popovers dismiss when focus leaves the reference/popover pair. */ protected get shouldHideOnFocusLeave(): boolean; /** * Initializes and validates controller variables */ connect(): void; /** * Cleans up popper.js elements and disconnects all added event listeners */ disconnect(): void; /** * Toggles the visibility of the popover */ toggle(dispatcher?: Event | Element | null): void; /** * Shows the popover if not already visible */ show(dispatcher?: Event | Element | null): void; /** * Hides the popover if not already hidden */ hide(dispatcher?: Event | Element | null): void; /** * Binds document events for this popover and fires the shown event */ protected shown(dispatcher?: Element | null): void; /** * Unbinds document events for this popover and fires the hidden event */ protected hidden(dispatcher?: Element | null): void; /** * Generates the popover if not found during initialization */ protected generatePopover(): HTMLElement | null; /** * Initializes the Popper for this instance */ private initializePopper; /** * Validates the popover settings and attempts to set necessary internal variables */ private validate; /** * Determines the correct dispatching element from a potential input * @param dispatcher The event or element to get the dispatcher from */ protected getDispatcher(dispatcher?: Event | Element | null): Element; /** * Schedules the popover to update on the next animation frame if visible */ protected scheduleUpdate(): void; } export declare class PopoverController extends BasePopoverController { static targets: never[]; protected popoverSelectorAttribute: string; private boundHideOnOutsideClick; private boundHideOnEscapePress; private boundHideOnFocusOut; /** * Toggles optional classes and accessibility attributes in addition to BasePopoverController.shown */ protected shown(dispatcher?: Element | null): void; /** * Toggles optional classes and accessibility attributes in addition to BasePopoverController.hidden */ protected hidden(dispatcher?: Element | null): void; /** * Initializes accessibility attributes in addition to BasePopoverController.connect */ connect(): void; /** * Binds global events to the document for hiding popovers on user interaction */ protected bindDocumentEvents(): void; /** * Unbinds global events to the document for hiding popovers on user interaction */ protected unbindDocumentEvents(): void; /** * Forces the popover to hide if a user clicks outside of it or its reference element * @param {Event} e - The document click event */ private hideOnOutsideClick; /** * Forces the popover to hide if the user presses escape while it, one of its childen, or the reference element are focused * @param {Event} e - The document keyup event */ private hideOnEscapePress; /** * Forces the popover to hide if keyboard focus leaves both the reference element and the popover. * @param {FocusEvent} e - The focusout event from the reference or popover element */ private hideOnFocusOut; /** * Toggles all classes on the originating element based on the `class-toggle` data * @param {boolean=} show - A boolean indicating whether this is being triggered by a show or hide. */ private toggleOptionalClasses; /** * Toggles accessibility attributes based on whether the popover is shown or not * @param {boolean=} show - A boolean indicating whether this is being triggered by a show or hide. */ private toggleAccessibilityAttributes; } /** * Helper to manually show an s-popover element via external JS * @param element the element the `data-controller="s-popover"` attribute is on */ export declare function showPopover(element: HTMLElement): void; /** * Helper to manually hide an s-popover element via external JS * @param element the element the `data-controller="s-popover"` attribute is on */ export declare function hidePopover(element: Element): void; /** * Options to use when attaching a popover via `Stacks.attachPopover`. * @see Stacks.attachPopover */ export interface PopoverOptions { /** * When true, the `click->s-popover#toggle` action will be attached to the controller element or reference element. */ toggleOnClick?: boolean; /** * When set, `data-s-popover-placement` will be set to this value on the controller element. */ placement?: string; /** * When true, the popover will appear immediately when the controller connects. */ autoShow?: boolean; } /** * Attaches a popover to an element and performs additional configuration. * @param element the element that will receive the `data-controller="s-popover"` attribute. * @param popover an element with the `.s-popover` class or HTML string containing a single element with the `.s-popover` class. * If the popover does not have a parent element, it will be inserted as a immediately after the reference element. * @param options an optional collection of options to use when configuring the popover. */ export declare function attachPopover(element: Element, popover: Element | string, options?: PopoverOptions): void; /** * Removes the popover controller from an element and removes the popover from the DOM. * @param element the element that has the `data-controller="s-popover"` attribute. * @returns The popover that was attached to the element. */ export declare function detachPopover(element: Element): HTMLElement | null;