import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["div"]; type $Props = { /** * Set to `true` to open the modal. * @default false */ open?: boolean; /** * Set the kind of confirmation. * `"danger"` uses Modal's danger variant and `"warning"` adds a warning * icon next to the heading; both are announced as an alert dialog. * `"info"` is a plain dialog. * @default "danger" */ kind?: "danger" | "warning" | "info"; /** * Specify the modal heading. */ title: string; /** * Specify the modal label. */ label?: string | undefined; /** * Specify the confirm button text * @default "Confirm" */ confirmText?: string; /** * Specify the cancel button text * @default "Cancel" */ cancelText?: string; /** * When set, the user must type this exact phrase before the confirm * button becomes enabled. */ confirmationPhrase?: string | undefined; /** * Specify the label for the type-to-confirm input. * @default (phrase) => `Type ${phrase} to confirm` */ confirmationLabel?: (phrase: string) => string; /** * Specify the work to run on confirm. When it returns a promise, the * modal shows its loading state until the promise settles: it closes on * success, and on failure stays open and dispatches `confirm:error`. * Without it, or when it returns nothing, the modal closes on confirm. */ confirm?: undefined | (() => void | Promise); /** * Set to `true` to show a loading state on the confirm button and block * closing, for work the app tracks itself. `confirm` sets this state on * its own. * @default false */ loading?: boolean; /** * Specify the description for the confirm button loading state * @default "Working" */ loadingDescription?: string; /** * Set the size of the modal. * Also accepts Carbon v11's `"md"`, the width of a `Modal` with no size. * @default "xs" */ size?: "xs" | "sm" | "md" | "lg"; /** * Set to `false` to allow closing the modal when clicking outside * @default true */ preventCloseOnClickOutside?: boolean; /** * Set an id for the top-level element * @default uniqueId() */ id?: string; /** * Obtain a reference to the top-level HTML element. * @default null */ ref?: null | HTMLDivElement; titleChildren?: (this: void) => void; children?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type ConfirmModalProps = Omit<$RestProps, keyof $Props> & $Props; export default class ConfirmModal extends SvelteComponentTyped< ConfirmModalProps, { cancel: CustomEvent<{ trigger: "escape-key" | "outside-click" | "close-button" | "cancel-button"; }>; close: CustomEvent<{ trigger: "escape-key" | "outside-click" | "close-button" | "programmatic"; }>; confirm: CustomEvent; "confirm:error": CustomEvent<{ error: unknown }>; open: CustomEvent; transitionend: WindowEventMap["transitionend"]; }, { default: Record; titleChildren: Record; } > {}