import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; export type CarbonModalContext = Record; export type CarbonLayerContext = import("svelte/store").Readable; type $RestProps = SvelteHTMLElements["div"]; type $Props = { /** * Set the size of the modal. * Also accepts Carbon v11's `"md"`, the default width. */ size?: "xs" | "sm" | "md" | "lg" | undefined; /** * Set to `true` to open the modal. * @default false */ open?: boolean; /** * Set to `true` to use the danger variant * @default false */ danger?: boolean; /** * Set to `true` to enable alert mode * @default false */ alert?: boolean; /** * Set to `true` to use the passive variant * @default false */ passiveModal?: boolean; /** * Set to `true` to remove the modal body padding so content spans edge to edge * @default false */ fullWidth?: boolean; /** * Specify the modal heading. */ modalHeading?: string | undefined; /** * Specify the modal label. * Alternatively, use the "labelChildren" slot. */ modalLabel?: string | undefined; /** * Specify the ARIA label for the modal. */ modalAriaLabel?: string | undefined; /** * Specify the label of the close button. * It names the button and shows in its tooltip. * @default "Close the modal" */ iconDescription?: string; /** * Set to `true` if the modal contains form elements * @default false */ hasForm?: boolean; /** * Specify the ID of a form element to associate with the primary button. * This enables the primary button to submit the form from outside the form element. */ formId?: string | undefined; /** * Set to `true` if the modal contains scrolling content * @default false */ hasScrollingContent?: boolean; /** * Specify the primary button text * @default "" */ primaryButtonText?: string; /** * Set to `true` to disable the primary button * @default false */ primaryButtonDisabled?: boolean; /** * Set to `true` to show a loading state on the primary button. * While loading, the button is non-interactive and submit is suppressed. * Same as `loadingStatus="active"`, except that the secondary buttons * stay enabled. `loadingStatus` wins when it is not `"inactive"`. * @default false */ primaryButtonLoading?: boolean; /** * Set the loading status of the footer. * Any status other than `"inactive"` shows `InlineLoading` with that * status in the primary button, disables the footer buttons, and * suppresses submit. `"finished"` dispatches `loading:success` after the * success delay. * @default "inactive" */ loadingStatus?: "inactive" | "active" | "finished" | "error"; /** * Specify the description for the primary button loading state. * Passed to `InlineLoading` as `description`. * @default "Loading" */ primaryButtonLoadingDescription?: string; /** * Specify the description for the primary button loading icon. * Passed to `InlineLoading` as `iconDescription`. */ primaryButtonLoadingIconDescription?: string | undefined; /** * Specify the primary button icon. */ primaryButtonIcon?: Icon | undefined; /** * Set to `true` for the "submit" and "click:button--primary" events * to be dispatched when pressing "Enter". * @default true */ shouldSubmitOnEnter?: boolean; /** * Specify the secondary button text * @default "" */ secondaryButtonText?: string; /** * Set to `true` to show a loading state on the secondary button. * Only applies to the `secondaryButtonText` path (not `secondaryButtons`). * While loading, the button is non-interactive. * @default false */ secondaryButtonLoading?: boolean; /** * Specify the description for the secondary button loading state. * Passed to `InlineLoading` as `description`. * @default "Loading" */ secondaryButtonLoadingDescription?: string; /** * One or two secondary buttons for the modal footer. * Supersedes `secondaryButtonText`. Each entry needs `text`; optional * `kind` (defaults to `"secondary"`), `disabled`, `loading`, and * `loadingDescription` (defaults to `"Loading"`) pass through to Button / * the loading state. With two entries plus a primary button, the footer * uses the three-button layout. * @default [] */ secondaryButtons?: ReadonlyArray<{ text: string; kind?: import("../Button/Button.svelte").ButtonProps["kind"]; disabled?: boolean; loading?: boolean; loadingDescription?: string }>; /** * Specify a selector to be focused when opening the modal. * Set to `null` to skip initial focus and move focus yourself. * @default "[data-modal-primary-focus]" */ selectorPrimaryFocus?: null | string; /** * Control whether clicking outside the modal closes it. * By default, a passive modal (`passiveModal`) closes and a modal with * actions stays open, as in Carbon v11. * Set to `true` to always keep the modal open on an outside click, or * `false` to always close it. */ preventCloseOnClickOutside?: boolean | undefined; /** * Set to `true` to hide the header close button. * Provide an alternative dismiss path (footer actions or Escape). * @default false */ hideCloseButton?: boolean; /** * Set to `true` to build the modal's content the first time it opens * instead of at mount, and keep it afterwards. A closed modal is still * laid out (it is only made invisible), so this saves its nodes on pages * that hold modals most visitors never open. Content is not in the DOM, * or in server-rendered markup, until then. * @default false */ lazy?: 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; decorator?: (this: void) => void; heading?: (this: void) => void; /** * @deprecated use the `labelChildren` slot */ label?: (this: void) => void; /** Custom label content. Replaces `modalLabel`. */ labelChildren?: (this: void) => void; children?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type ModalProps = Omit<$RestProps, keyof $Props> & $Props; export default class Modal extends SvelteComponentTyped< ModalProps, { click: WindowEventMap["click"]; "click:button--primary": CustomEvent; "click:button--secondary": CustomEvent<{ text: string; }>; close: CustomEvent<{ trigger: "escape-key" | "outside-click" | "close-button" | "programmatic"; }>; keydown: WindowEventMap["keydown"]; /** Dispatched when `loadingStatus` is `"finished"`, after the `InlineLoading` success delay. */ "loading:success": CustomEvent; mouseenter: WindowEventMap["mouseenter"]; mouseleave: WindowEventMap["mouseleave"]; mouseover: WindowEventMap["mouseover"]; open: CustomEvent; submit: CustomEvent; transitionend: CustomEvent<{ open: boolean; }>; }, { default: Record; decorator: Record; heading: Record; /** * @deprecated use the `labelChildren` slot */ label: Record; /** Custom label content. Replaces `modalLabel`. */ labelChildren: Record; } > {}