dap-design-system
Version:
Official design system for the DÁP (dap.gov.hu)
122 lines (121 loc) • 5.34 kB
TypeScript
import { PropertyValueMap } from 'lit';
import { ButtonVariant } from '../../common/types';
import { DdsElement } from '../../internal/dds-hu-element';
declare const ModalBaseWithSized: typeof DdsElement & {
new (...args: any[]): import('../../internal/mixin/sizedMixin').SizedElementInterface;
prototype: import('../../internal/mixin/sizedMixin').SizedElementInterface;
};
export default class ModalBaseElement extends ModalBaseWithSized {
dialog: HTMLDialogElement;
modalBox: HTMLElement;
open?: boolean;
fullScreen?: boolean;
closeOnEsc: string;
closeOnOverlayClick: string;
closeButton: string;
title: string;
description: string;
okButtonLabel: string;
cancelButtonLabel: string;
closeButtonLabel: string;
okButtonVariant: ButtonVariant;
cancelButtonVariant: ButtonVariant;
okButtonDisabled: boolean;
cancelButtonDisabled: boolean;
cancelButtonDanger: boolean;
okButtonDanger: boolean;
hideOkButton: boolean;
hideCancelButton: boolean;
/** Override size for the default OK button; when empty uses the modal's effective size. */
okButtonSize: string;
/** Override sizeMap for the default OK button; when empty uses the modal's sizeMap. */
okButtonSizeMap: string;
/** Override size for the default Cancel button; when empty uses the modal's effective size. */
cancelButtonSize: string;
/** Override sizeMap for the default Cancel button; when empty uses the modal's sizeMap. */
cancelButtonSizeMap: string;
/** Override size for the close icon button; when empty uses the modal's effective size. */
closeButtonSize: string;
/** Override sizeMap for the close icon button; when empty uses the modal's sizeMap. */
closeButtonSizeMap: string;
/** `data-testid` for the default OK button. */
okButtonTestId: string;
/** `data-testid` for the default Cancel button. */
cancelButtonTestId: string;
/** `data-testid` for the default close icon button. */
closeButtonTestId: string;
footer: string;
header: string;
wideFooter: boolean;
bottomFooter: boolean;
useNativeFocus: boolean;
fixedHeader: boolean;
fixedFooter: boolean;
noModal: boolean;
private previouslyFocusedElement;
private focusableElements;
private canceled;
private closeEventCanceled;
static readonly styles: import('lit').CSSResult;
connectedCallback(): void;
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
protected updated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
private handleOpen;
private handleCloseAction;
/**
* Run `callback` once the dialog's transition settles -- or on a timer if no
* transition runs at all.
*
* Focus management and the `dds-opened` / `dds-closed` events used to hang directly
* off a `transitionend` listener registered `{ once: true }`. That event never fires
* when the transition is skipped (`prefers-reduced-motion: reduce`, a consumer
* zeroing `--dds-modal-transition-speed`, a backgrounded tab) or when it is
* interrupted, so focus would never enter the dialog and would never be restored on
* close. Accessibility behaviour must not depend on an animation completing.
*/
private afterTransition;
/**
* Apply a transform change to the dialog without animating it.
*
* The dialog animates its entrance with `transform` (`transition: transform ...`),
* so any later transform change would try to animate too. Suppressing the
* transition for one reflow makes the change instant -- and importantly avoids
* the unreliable "transition to `none`" interpolation, which Chrome can leave
* pinned at the start value.
*/
private setTransformInstantly;
/**
* Drop the dialog's transform once it is settled open.
*
* A settled-open dialog keeps an identity transform (`translate(0, 0)`) for the
* entrance animation. Any transform -- even the identity -- makes the dialog a
* containing block for `position: fixed` descendants, which clips
* `floatingStrategy="fixed"` dropdowns (select / combobox / tooltip) to the
* modal instead of letting them escape and overflow it. Removing it (visually a
* no-op) frees those popups. Restored in `restoreTransform` before closing.
*/
private dropTransform;
/** Undo `dropTransform` so the close animation starts from the on-screen position. */
private restoreTransform;
/** Longest transition duration + delay declared on the dialog, in milliseconds. */
private transitionDurationMs;
scrollLock: (open: boolean) => void;
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
show(): void;
hide(): void;
private handleClose;
private handleCancel;
private handleEscClose;
private handleOkButton;
private handleCancelButton;
private handleCloseButton;
private handleClick;
private handleKeyDown;
private getFocusableElements;
private getActiveElement;
private getElementFromElement;
private isElementContainedIn;
private handleFocusTrap;
renderModal(): import('lit-html').TemplateResult<1>;
}
export {};