declare namespace FLib { namespace Popin { type AnimationFunction = ( $element: HTMLElement ) => Promise; type ResponseType = 'arrayBuffer' | 'blob' | 'json' | 'text' | 'formData'; interface Controller { load( url: string, data: RequestInit, type?: FLib.Popin.ResponseType ): Promise loadForm( $form: HTMLFormElement ): Promise loadLink( $link: HTMLAnchorElement ): Promise set( html: string, openFirst?: boolean ): Promise clear(): void; close(): Promise; open(): Promise; destroy(): this; } interface Background { isOpened: boolean; open(): Promise; close(): Promise; destroy(): void; } interface TemplatesOptions { /** @defaultValue `
` */ popinLoader: string; /** @defaultValue `
` */ popin: string; /** @defaultValue `
` */ bgLayer: string; /** @defaultValue `"
{{ message }}
"` */ errorMessage: string; } interface SelectorsOptions { /** @defaultValue .popin */ popin: string; /** @defaultValue .popin */ popinBody: string; /** @defaultValue .popin-content */ popinContent: string; /** @defaultValue a[data-popin] */ links: string; /** @defaultValue form[data-popin] */ forms: string; /** @defaultValue button[data-close-popin] */ btClosePopin: string; /** @defaultValue data-onload-popin */ openOnLoadAttribute: string; } interface AnimationsOptions { /** @defaultValue `$bg => { $bg.style.display = 'block'; return Promise.resolve(); }` */ openBg: AnimationFunction; /** @defaultValue `$bg => { $bg.style.display = 'none'; return Promise.resolve(); }` */ closeBg: AnimationFunction; /** @defaultValue `$popin => { $popin.style.display = 'block'; $popin.style.opacity = 0; return Promise.resolve(); }` */ initOpenPopin: AnimationFunction; /** @defaultValue `$popin => { $popin.style.opacity = 1; return Promise.resolve(); }` */ openPopin: AnimationFunction; /** @defaultValue `$popin => { $popin.style.display = 'none'; return Promise.resolve(); }` */ closePopin: AnimationFunction; /** @defaultValue `$loader => { $loader.style.display = 'block'; return Promise.resolve(); }` */ openLoader: AnimationFunction; /** @defaultValue `$loader => { $loader.style.display = 'none'; return Promise.resolve(); }` */ closeLoader: AnimationFunction; } interface Options { /** @defaultValue false */ modal: boolean; /** @defaultValue 20 */ marginHeight: number; /** @defaultValue false */ autoResize: boolean; /** @defaultValue "Error while loading.." */ errorMessage: string; /** @defaultValue true */ enableKeyboard: boolean; /** @defaultValue true */ isBackgroundAside: boolean; onOpen?: ( $popin: HTMLElement ) => void; onClose?: ( $popin: HTMLElement ) => void; onLoad: ( $popin: HTMLElement ) => Promise; /** @defaultValue `() => 'text'` */ setLinkResponseType: ( url: string, $link: HTMLAnchorElement, $popin: HTMLElement ) => ResponseType; /** @defaultValue `() => 'text'` */ setFormResponseType: ( $form: HTMLElement, $popin: HTMLElement ) => ResponseType; /** @defaultValue `() => true` */ checkValidity: ( $form: HTMLElement, $popin: HTMLElement ) => boolean | Promise; /** @defaultValue `(body) => { return { success: true, data: body }` */ normalize: ( body, response, isHttpError: boolean, $popin: HTMLElement ) => { success: boolean, data }; /** * If false, ajax http error (404, 500, ...) should be handled in the normalize function * @defaultValue true */ autoHandleAjaxError: boolean; templates: TemplatesOptions; selectors: SelectorsOptions; animations: AnimationsOptions; } interface ControllerOptions { controller: Controller; background: Background; } interface OptionsInit extends Partial { templates?: Partial; selectors?: Partial; animations?: Partial; } } }