Files
ionic-framework/core/src/components/menu/menu-interface.ts
Brandy Carney ee2fa19a1e feat(menu): pass role to ionWillClose and ionDidClose events (#29954)
- Adds the `MenuCloseEventDetail` interface which includes an optional `role` property
- The `ionWillClose` and `ionDidClose` emit the `role` property for the following scenarios:
  - A role of `'gesture'` when dragging the menu closed
- A role of `'backdrop'` when clicking on the backdrop to close the menu
- A role of `'backdrop'` when the the menu is closed using the escape key
- A role of `undefined` when the menu is closed from a button inside of
the menu
2024-11-04 16:10:57 -05:00

63 lines
2.1 KiB
TypeScript

import type { Animation, AnimationBuilder } from '@utils/animation/animation-interface';
export type Side = 'start' | 'end';
export interface MenuI {
el: HTMLIonMenuElement;
side: Side;
menuId?: string;
disabled: boolean;
isAnimating: boolean;
width: number;
isEndSide: boolean;
_isOpen: boolean;
backdropEl?: HTMLElement;
menuInnerEl?: HTMLElement;
contentEl?: HTMLElement;
menuCtrl?: MenuControllerI;
isActive(): Promise<boolean>;
open(animated?: boolean): Promise<boolean>;
close(animated?: boolean): Promise<boolean>;
toggle(animated?: boolean): Promise<boolean>;
setOpen(shouldOpen: boolean, animated?: boolean): Promise<boolean>;
_setOpen(shouldOpen: boolean, animated?: boolean, role?: string): Promise<boolean>;
}
export interface MenuControllerI {
registerAnimation(name: string, animation: AnimationBuilder): void;
get(menu?: string | null, logOnMultipleSideMenus?: boolean): Promise<HTMLIonMenuElement | undefined>;
getMenus(): Promise<HTMLIonMenuElement[]>;
getOpen(): Promise<HTMLIonMenuElement | undefined>;
isEnabled(menu?: string | null): Promise<boolean>;
swipeGesture(shouldEnable: boolean, menu?: string | null): Promise<HTMLIonMenuElement | undefined>;
isAnimating(): Promise<boolean>;
isOpen(menu?: string | null): Promise<boolean>;
enable(shouldEnable: boolean, menu?: string | null): Promise<HTMLIonMenuElement | undefined>;
toggle(menu?: string | null): Promise<boolean>;
close(menu?: string | null): Promise<boolean>;
open(menu?: string | null): Promise<boolean>;
_getOpenSync(): HTMLIonMenuElement | undefined;
_createAnimation(type: string, menuCmp: MenuI): Promise<Animation>;
_register(menu: MenuI): void;
_unregister(menu: MenuI): void;
_setOpen(menu: MenuI, shouldOpen: boolean, animated: boolean, role?: string): Promise<boolean>;
}
export interface MenuChangeEventDetail {
disabled: boolean;
open: boolean;
}
export interface MenuCloseEventDetail {
role?: string;
}
export interface MenuCustomEvent<T = any> extends CustomEvent {
detail: T;
target: HTMLIonMenuElement;
}
export type MenuType = 'overlay' | 'reveal' | 'push';