Files
ionic-framework/core/src/components/popover-controller/popover-controller.tsx
Manu MA 34dfc3ce98 refactor(all): updating to newest stencil apis (#18578)
* chore(): update ionicons

* refactor(all): updating to newest stencil apis

* fix lint issues

* more changes

* moreee

* fix treeshaking

* fix config

* fix checkbox

* fix stuff

* chore(): update ionicons

* fix linting errors
2019-06-23 11:26:42 +02:00

44 lines
1.5 KiB
TypeScript

import { 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 {
/**
* 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;
}
}