baseframe-js
Version:
Baseframe JS is a comprehensive suite of modular plugins and utilities designed for front-end development
76 lines (75 loc) • 2.23 kB
TypeScript
import type { LocationTracking, StringPluginArgChoices } from './types';
import { type BaseElem, type SelectorRoot } from "base-elem-js";
import focusTrap from './fn/focusTrap';
type ModalObj = {
backdrop: HTMLDivElement;
content: HTMLElement[];
contentAppended: boolean;
dialog: HTMLDivElement;
dialogContent: HTMLDivElement;
closeBtn: HTMLButtonElement;
id: string;
modal: HTMLDivElement;
close: () => void;
show: boolean;
};
export interface IModalCss {
show: string;
dismissing: string;
open: string;
btnDismiss: string;
dialog: string;
dialogContent: string;
backdrop: string;
marker: string;
}
export interface IModalDefaults extends LocationTracking {
src: SelectorRoot | string;
modalID: string | null;
enableEvent: string;
appendTo: SelectorRoot;
ariaLabelledby: string | null;
ariaLabel: string | null;
cssPrefix: string;
closeBtnIconCss: string;
closeBtnLabel: string;
closeOutDelay: number;
backDropClose: boolean;
fromDOM: boolean;
modalCss: string | null;
focusInDelay: number | null;
onOpenOnce(components: ModalObj): void;
onOpen(components: ModalObj): void;
onClose(components: ModalObj): void;
afterClose(components: ModalObj): void;
}
export interface IModalOptions extends Partial<IModalDefaults> {
modalID: string | null;
}
export default class Modal {
#private;
element: HTMLElement;
params: IModalDefaults;
modalID: string;
components: ModalObj;
modalEvent: string;
focusTrapped: ReturnType<typeof focusTrap>;
enabledElem: Element | null;
openedOnce: boolean;
domMarker: HTMLElement | null;
cssList: IModalCss;
static defaults: IModalDefaults;
static version: string;
static pluginName: string;
constructor(element: HTMLAnchorElement | HTMLElement | HTMLButtonElement, options: IModalOptions | StringPluginArgChoices);
static remove(element: BaseElem, plugin?: Modal): void;
close(): void;
}
export interface ModalPlugin {
modal(options: IModalOptions | StringPluginArgChoices): BaseElem;
}
declare module 'base-elem-js' {
interface BaseElem extends ModalPlugin {
}
}
export {};