-
Notifications
You must be signed in to change notification settings - Fork 13.5k
/
popover-controller.tsx
51 lines (45 loc) · 1.77 KB
/
popover-controller.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Build, Component, ComponentInterface, Method } from '@stencil/core';
import { ComponentRef, OverlayController, PopoverOptions } from '../../interface';
import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays';
@Component({
tag: 'ion-popover-controller',
})
export class PopoverController implements ComponentInterface, OverlayController {
constructor() {
if (Build.isDev) {
console.warn(`[DEPRECATED][ion-popover-controller] Use the popoverController export from @ionic/core:
import { popoverController } from '@ionic/core';
const popover = await popoverController.create({...});`);
}
}
/**
* Create a popover overlay with popover options.
*
* @param options The options to use to create the popover.
*/
@Method()
create<T extends ComponentRef>(options: PopoverOptions<T>): Promise<HTMLIonPopoverElement> {
return createOverlay('ion-popover', options);
}
/**
* Dismiss the open popover overlay.
*
* @param data Any data to emit in the dismiss events.
* @param role The role of the element that is dismissing the popover.
* This can be useful in a button handler for determining which button was
* clicked to dismiss the popover.
* Some examples include: ``"cancel"`, `"destructive"`, "selected"`, and `"backdrop"`.
* @param id The id of the popover to dismiss. If an id is not provided, it will dismiss the most recently opened popover.
*/
@Method()
dismiss(data?: any, role?: string, id?: string) {
return dismissOverlay(document, data, role, 'ion-popover', id);
}
/**
* Get the most recently opened popover overlay.
*/
@Method()
async getTop(): Promise<HTMLIonPopoverElement | undefined> {
return getOverlay(document, 'ion-popover') as HTMLIonPopoverElement;
}
}