UNPKG

dialog-lite

Version:

DialogLite is designed to control a dialog box (modal window) on a web page, providing the functionality to open, close and apply custom styles through a simple interface.

66 lines (65 loc) 1.99 kB
export declare const dialogLiteCssText: string; export declare function injectDialogLiteCss(options?: { target?: Document | ShadowRoot; cssText?: string; id?: string; }): HTMLStyleElement; export type DialogLiteOptions = { closingButton?: boolean; closingBackdrop?: boolean; dialog?: HTMLElement | string; mainContent?: HTMLElement | string | null; closeButtonSelector?: string; backdropSelector?: string; debounceMs?: number; hideDelayMs?: number; focusOnOpenSelector?: string; lockScroll?: boolean; trapFocus?: boolean; role?: string; ariaModal?: boolean; emitEvents?: boolean; }; interface OpenOptions { stylingClass?: string; } export type DialogLiteInstance = Pick<DialogLite, 'init' | 'open' | 'close' | 'destroy'>; declare class DialogLite { private readonly options; private dialogEl; private dialogCloseEl; private dialogBackdropEl; private mainContentEl; private currentExtraClass; private previouslyFocusedElement; private lastActionTime; private isOpen; private abortController; private hideTimeout; private removeExtraClassTimeout; private prevBodyOverflow; private prevBodyPaddingRight; constructor(options?: DialogLiteOptions); private resolveHTMLElement; private resolveElementsOrThrow; private emit; private lockScroll; private unlockScroll; private getFocusableElements; private handleFocusTrapKeydown; private clearTimers; private ensureInitialized; init(): void; destroy(): void; open({ stylingClass }?: OpenOptions): void; close(): void; private updateClassList; private isDebounced; } export declare function createDialogLite(options?: DialogLiteOptions): DialogLiteInstance; export declare function initDialogLite(options?: DialogLiteOptions & { injectCss?: boolean; cssText?: string; cssTarget?: Document | ShadowRoot; }): DialogLiteInstance; export { DialogLite };