import { FocusTrap } from "@a11y/focus-trap"; import { LitElement } from "lit-element"; import { EventListenerSubscription } from "../../util/event"; /** * Events the overlay behavior can dispatch. */ export declare enum OverlayBehaviorEvent { DID_SHOW = "didShow", DID_HIDE = "didHide" } /** * Base properties of the overlay behavior. */ export interface IOverlayBehaviorBaseProperties { open: boolean; persistent: boolean; blockScrolling: boolean; backdrop: boolean; duration: number; fixed: boolean; disableFocusTrap: boolean; scrollContainer: EventTarget; } /** * Properties of the overlay behavior. */ export interface IOverlayBehaviorProperties { open: boolean; } export declare type OverlayResolver = (result: R | null | undefined) => void; /** * Default scroll container. */ export declare const DEFAULT_OVERLAY_SCROLL_CONTAINER: HTMLElement; /** * Provides overlay behavior. * @event didshow - Dispatches after the overlay has been shown. * @event didhide - Dispatches after the overlay has been hidden. */ export declare abstract class OverlayBehavior> extends LitElement implements IOverlayBehaviorProperties { static styles: import("lit-element").CSSResult[]; /** * Whether the overlay is open or not. * @attr */ open: boolean; /** * Whether the focus trap be disabled. * @attr */ disableFocusTrap: boolean; /** * Whether the backdrop is visible or not. * @attr */ backdrop: boolean; /** * Whether the overlay is fixed or not. * @attr */ fixed: boolean; /** * Whether the overlay is persistent or not. When the overlay is persistent, ESCAPE and backdrop clicks won't close it. * @attr */ persistent: boolean; /** * Whether the overlay blocks the scrolling on the scroll container. * @attr */ blockScrolling: boolean; /** * The duration of the animations. * @attr */ duration: number; /** * The container the overlay lives in. * @attr */ scrollContainer: EventTarget; /** * Returns the scroll container as an HTMLElement. Falls back to the documentElement if the scroll * container is not blockable since the style attribute is required to set the overflow hidden. */ get $blockableScrollContainer(): HTMLElement; /** * Active in animation. */ protected activeInAnimations: Animation[]; /** * Active out animations. */ protected activeOutAnimations: Animation[]; /** * Resolvers that resolves when the overlay is closed. */ protected resolvers: OverlayResolver[]; /** * Unique ID of the overlay. */ protected overlayId: string; /** * Active event listeners. */ protected listeners: EventListenerSubscription[]; /** * Element that was active before the overlay was opened. */ protected activeElementBeforeOpen?: HTMLElement; /** * Trap where focus is going to be trapped within. */ protected abstract readonly $focusTrap?: FocusTrap; /** * Base configuration for the in and out animation. */ protected get animationConfig(): KeyframeAnimationOptions; /** * Focuses on the first element of the overlay. */ trapFocus(): void; /** * Store the current active element so we can restore * the focus on that element when the overlay is closed. */ storeCurrentActiveElement(): void; /** * Shows the overlayed component. * @param config */ show(config?: C): Promise; /** * Hides the overlayed component. * @param result */ hide(result?: R): void; /** * Reacts on the properties changed. * @param props */ protected updated(props: Map): void; /** * Updates the aria information. */ protected updateAria(): void; /** * Creates a new resolver. */ protected createResolver(): Promise; /** * Resolves a result and clears the list of resolvers. * @param result */ protected resolve(result?: R | null): void; /** * Hides the overlay if it's not persistent. */ protected clickAway(): void; /** * Dispatches an overlay event. * @param e * @param detail */ protected dispatchOverlayEvent(e: OverlayBehaviorEvent, detail?: R | null): void; /** * Sets the properties based on the configuration object. * @param config */ protected setConfig(config: C): void; /** * Pauses all ongoing animations. */ protected pauseAnimations(): void; /** * Pauses all ongoing in animations. */ protected pauseInAnimations(): void; /** * Pauses all ongoing out animations. */ protected pauseOutAnimations(): void; /** * Prepares the show animation. * @param config */ protected prepareShowAnimation(config?: C): void; /** * Prepares the hide animation. */ protected prepareHideAnimation(): void; /** * Animates the overlay in. */ protected abstract animateIn(): void; /** * Animates the overlay out. * @param result */ protected abstract animateOut(result?: R): void; /** * Hooks up listeners and traps the focus. */ protected didShow(): void; /** * Removes listeners and restores the state before the overlay was opened. * @param result */ protected didHide(result?: R): void; /** * Updates the position of the overlay.. */ protected updatePosition(): void; /** * Handles the key down event on focus. * @param {KeyboardEvent} e */ protected onKeyDown(e: KeyboardEvent): void; }