chore(overlays): generic for present/dismiss options (#26287)

This commit is contained in:
Sean Perkins
2022-11-21 16:57:17 -05:00
committed by GitHub
parent 8aa0aeca6b
commit c943dff5a3
7 changed files with 97 additions and 20 deletions

View File

@ -506,7 +506,7 @@ export class Modal implements ComponentInterface, OverlayInterface {
writeTask(() => this.el.classList.add('show-modal'));
this.currentTransition = present(this, 'modalEnter', iosEnterAnimation, mdEnterAnimation, {
this.currentTransition = present<ModalPresentOptions>(this, 'modalEnter', iosEnterAnimation, mdEnterAnimation, {
presentingEl: this.presentingElement,
currentBreakpoint: this.initialBreakpoint,
backdropBreakpoint: this.backdropBreakpoint,
@ -721,11 +721,19 @@ export class Modal implements ComponentInterface, OverlayInterface {
const enteringAnimation = activeAnimations.get(this) || [];
this.currentTransition = dismiss(this, data, role, 'modalLeave', iosLeaveAnimation, mdLeaveAnimation, {
presentingEl: this.presentingElement,
currentBreakpoint: this.currentBreakpoint ?? this.initialBreakpoint,
backdropBreakpoint: this.backdropBreakpoint,
});
this.currentTransition = dismiss<ModalDismissOptions>(
this,
data,
role,
'modalLeave',
iosLeaveAnimation,
mdLeaveAnimation,
{
presentingEl: this.presentingElement,
currentBreakpoint: this.currentBreakpoint ?? this.initialBreakpoint,
backdropBreakpoint: this.backdropBreakpoint,
}
);
const dismissed = await this.currentTransition;
@ -953,3 +961,22 @@ const LIFECYCLE_MAP: any = {
};
let modalIds = 0;
interface ModalOverlayOptions {
/**
* The element that presented the modal.
*/
presentingEl?: HTMLElement;
/**
* The current breakpoint of the sheet modal.
*/
currentBreakpoint?: number;
/**
* The point after which the backdrop will being
* to fade in when using a sheet modal.
*/
backdropBreakpoint: number;
}
type ModalPresentOptions = ModalOverlayOptions;
type ModalDismissOptions = ModalOverlayOptions;