declare module 'sweetalert2' { /** * A namespace inside the default function, containing utility function for controlling the currently-displayed popup. * * Example: * ``` * Swal.fire('Hey user!', 'You are the rockstar!', 'info'); * * Swal.update({ * icon: 'success' * }) * ``` */ namespace Swal { /** * Function to display a SweetAlert2 popup, with an object of options, all being optional. * See the `SweetAlertOptions` interface for the list of accepted fields and values. * * Example: * ``` * Swal.fire({ * title: 'Auto close alert!', * text: 'I will close in 2 seconds.', * timer: 2000 * }) * ``` */ function fire(options: SweetAlertOptions): Promise>> /** * Function to display a simple SweetAlert2 popup. * * Example: * ``` * Swal.fire('The Internet?', 'That thing is still around?', 'question'); * ``` */ function fire(title?: string, html?: string, icon?: SweetAlertIcon): Promise>> /** * Reuse configuration by creating a `Swal` instance. * * Example: * ``` * const Toast = Swal.mixin({ * toast: true, * position: 'top-end', * timer: 3000, * timerProgressBar: true * }) * Toast.fire('Something interesting happened', '', 'info') * ``` * * @param options the default options to set for this instance. */ function mixin(options: SweetAlertOptions): typeof Swal /** * Determines if a popup is shown. */ function isVisible(): boolean /** * Updates popup options. * See the `SweetAlertOptions` interface for the list of accepted fields and values. * * Example: * ``` * Swal.update({ * icon: 'error' * }) * ``` */ function update(options: Pick): void /** * Closes the currently open SweetAlert2 popup programmatically. * * @param result The promise originally returned by `Swal.fire()` will be resolved with this value. * If no object is given, the promise is resolved with an empty `SweetAlertResult` object. */ function close(result?: Partial): void /** * Gets the popup container which contains the backdrop and the popup itself. */ function getContainer(): HTMLElement | null /** * Gets the popup. */ function getPopup(): HTMLElement | null /** * Gets the popup title. */ function getTitle(): HTMLElement | null /** * Gets progress steps. */ function getProgressSteps(): HTMLElement | null /** * Gets the DOM element where the `html`/`text` parameter is rendered to. */ function getHtmlContainer(): HTMLElement | null /** * Gets the image. */ function getImage(): HTMLElement | null /** * Gets the close button. */ function getCloseButton(): HTMLButtonElement | null /** * Gets the icon. */ function getIcon(): HTMLElement | null /** * Gets the icon content (without border). */ function getIconContent(): HTMLElement | null /** * Gets the "Confirm" button. */ function getConfirmButton(): HTMLButtonElement | null /** * Gets the "Deny" button. */ function getDenyButton(): HTMLButtonElement | null /** * Gets the "Cancel" button. */ function getCancelButton(): HTMLButtonElement | null /** * Gets actions (buttons) wrapper. */ function getActions(): HTMLElement | null /** * Gets the popup footer. */ function getFooter(): HTMLElement | null /** * Gets the timer progress bar (see the `timerProgressBar` param). */ function getTimerProgressBar(): HTMLElement | null /** * Gets all focusable elements in the popup. */ function getFocusableElements(): readonly HTMLElement[] /** * Enables "Confirm" and "Cancel" buttons. */ function enableButtons(): void /** * Disables "Confirm" and "Cancel" buttons. */ function disableButtons(): void /** * Shows loader (spinner), this is useful with AJAX requests. * * By default the loader be shown instead of the "Confirm" button, but if you want * another button to be replaced with a loader, just pass it like this: * ``` * Swal.showLoading(Swal.getDenyButton()) * ``` */ function showLoading(buttonToReplace?: HTMLButtonElement): void /** * Hides loader and shows back the button which was hidden by .showLoading() */ function hideLoading(): void /** * Determines if popup is in the loading state. */ function isLoading(): boolean /** * Clicks the "Confirm" button programmatically. */ function clickConfirm(): void /** * Clicks the "Deny" button programmatically. */ function clickDeny(): void /** * Clicks the "Cancel" button programmatically. */ function clickCancel(): void /** * Shows a validation message. * * @param validationMessage The validation message. */ function showValidationMessage(validationMessage: string): void /** * Hides validation message. */ function resetValidationMessage(): void /** * Gets the input DOM node, this method works with input parameter. */ function getInput(): HTMLInputElement | null /** * Disables the popup input. A disabled input element is unusable and un-clickable. */ function disableInput(): void /** * Enables the popup input. */ function enableInput(): void /** * Gets the validation message container. */ function getValidationMessage(): HTMLElement | null /** * If `timer` parameter is set, returns number of milliseconds of timer remained. * Otherwise, returns undefined. */ function getTimerLeft(): number | undefined /** * Stop timer. Returns number of milliseconds of timer remained. * If `timer` parameter isn't set, returns `undefined`. */ function stopTimer(): number | undefined /** * Resume timer. Returns number of milliseconds of timer remained. * If `timer` parameter isn't set, returns `undefined`. */ function resumeTimer(): number | undefined /** * Toggle timer. Returns number of milliseconds of timer remained. * If `timer` parameter isn't set, returns `undefined`. */ function toggleTimer(): number | undefined /** * Check if timer is running. Returns true if timer is running, * and false is timer is paused / stopped. * If `timer` parameter isn't set, returns `undefined`. */ function isTimerRunning(): boolean | undefined /** * Increase timer. Returns number of milliseconds of an updated timer. * If `timer` parameter isn't set, returns `undefined`. * * @param n The number of milliseconds to add to the currect timer */ function increaseTimer(n: number): number | undefined /** * Determines if a given parameter name is valid. * * @param paramName The parameter to check */ function isValidParameter(paramName: string): paramName is keyof SweetAlertOptions /** * Determines if a given parameter name is valid for `Swal.update()` method. * * @param paramName The parameter to check */ function isUpdatableParameter(paramName: string): paramName is SweetAlertUpdatableParameters /** * Normalizes the arguments you can give to Swal.fire() in an object of type SweetAlertOptions. * * Example: * ``` * Swal.argsToParams(['title', 'text']); //=> { title: 'title', text: 'text' } * Swal.argsToParams([{ title: 'title', text: 'text' }]); //=> { title: 'title', text: 'text' } * ``` * * @param params The array of arguments to normalize. */ function argsToParams(params: SweetAlertArrayOptions | readonly [SweetAlertOptions]): SweetAlertOptions /** * An enum of possible reasons that can explain an alert dismissal. */ enum DismissReason { cancel, backdrop, close, esc, timer, } /** * SweetAlert2's version */ const version: string } interface SweetAlertHideShowClass { backdrop?: string | readonly string[] icon?: string | readonly string[] popup?: string | readonly string[] } type Awaited = T extends Promise ? U : T type SyncOrAsync = T | Promise | { toPromise: () => T } type ValueOrThunk = T | (() => T) export type SweetAlertArrayOptions = readonly [string?, string?, SweetAlertIcon?] export type SweetAlertGrow = 'row' | 'column' | 'fullscreen' | false export type SweetAlertHideClass = SweetAlertHideShowClass export type SweetAlertShowClass = Readonly export type SweetAlertIcon = 'success' | 'error' | 'warning' | 'info' | 'question' export type SweetAlertInput = | 'text' | 'email' | 'password' | 'number' | 'tel' | 'range' | 'textarea' | 'select' | 'radio' | 'checkbox' | 'file' | 'url' export type SweetAlertPosition = | 'top' | 'top-start' | 'top-end' | 'top-left' | 'top-right' | 'center' | 'center-start' | 'center-end' | 'center-left' | 'center-right' | 'bottom' | 'bottom-start' | 'bottom-end' | 'bottom-left' | 'bottom-right' export type SweetAlertUpdatableParameters = | 'allowEscapeKey' | 'allowOutsideClick' | 'background' | 'buttonsStyling' | 'cancelButtonAriaLabel' | 'cancelButtonColor' | 'cancelButtonText' | 'closeButtonAriaLabel' | 'closeButtonHtml' | 'confirmButtonAriaLabel' | 'confirmButtonColor' | 'confirmButtonText' | 'currentProgressStep' | 'customClass' | 'denyButtonAriaLabel' | 'denyButtonColor' | 'denyButtonText' | 'didClose' | 'didDestroy' | 'footer' | 'hideClass' | 'html' | 'icon' | 'iconColor' | 'imageAlt' | 'imageHeight' | 'imageUrl' | 'imageWidth' | 'preConfirm' | 'preDeny' | 'progressSteps' | 'reverseButtons' | 'showCancelButton' | 'showCloseButton' | 'showConfirmButton' | 'showDenyButton' | 'text' | 'title' | 'titleText' | 'willClose' export interface SweetAlertCustomClass { container?: string | readonly string[] popup?: string | readonly string[] title?: string | readonly string[] closeButton?: string | readonly string[] icon?: string | readonly string[] image?: string | readonly string[] htmlContainer?: string | readonly string[] input?: string | readonly string[] inputLabel?: string | readonly string[] validationMessage?: string | readonly string[] actions?: string | readonly string[] confirmButton?: string | readonly string[] denyButton?: string | readonly string[] cancelButton?: string | readonly string[] loader?: string | readonly string[] footer?: string | readonly string[] timerProgressBar?: string | readonly string[] } export interface SweetAlertResult { readonly isConfirmed: boolean readonly isDenied: boolean readonly isDismissed: boolean readonly value?: T readonly dismiss?: Swal.DismissReason } export interface SweetAlertOptions { /** * The title of the popup, as HTML. * It can either be added to the object under the key `title` or passed as the first parameter of `Swal.fire()`. * * @default '' */ title?: string | HTMLElement | JQuery /** * The title of the popup, as text. Useful to avoid HTML injection. * * @default '' */ titleText?: string /** * A description for the popup. * If `text` and `html` parameters are provided in the same time, `html` will be used. * * @default '' */ text?: string /** * A HTML description for the popup. * If `text` and `html` parameters are provided in the same time, `html` will be used. * * [Security] SweetAlert2 does NOT sanitize this parameter. It is the developer's responsibility * to escape any user input when using the `html` option, so XSS attacks would be prevented. * * @default '' */ html?: string | HTMLElement | JQuery /** * The icon of the popup. * SweetAlert2 comes with 5 built-in icons which will show a corresponding icon animation: * `'warning'`, `'error'`, `'success'`, `'info'` and `'question'`. * It can either be put to the object under the key `icon` or passed as the third parameter of `Swal.fire()`. * * @default undefined */ icon?: SweetAlertIcon /** * Use this to change the color of the icon. * * @default undefined */ iconColor?: string /** * The custom HTML content for an icon. * * Example: * ``` * Swal.fire({ * icon: 'error', * iconHtml: '' * }) * ``` * * @default undefined */ iconHtml?: string /** * The footer of the popup, as HTML. * * @default '' */ footer?: string | HTMLElement | JQuery /** * The declarative