fix(): update to Stencil One 🎉🎊

This commit is contained in:
Manu MA
2019-06-19 21:33:50 +02:00
committed by GitHub
parent 7f1829eb21
commit b40f7d36d5
572 changed files with 14426 additions and 9916 deletions

View File

@ -1,26 +1,31 @@
import { proxyMethod } from './util';
export class OverlayBaseController<Opts, Overlay> {
constructor(private ctrl: string, private doc: Document) {}
interface ControllerShape<Opts, HTMLElm> {
create(options: Opts): Promise<HTMLElm>;
dismiss(data?: any, role?: string, id?: string): Promise<boolean>;
getTop(): Promise<HTMLElm | undefined>;
}
export class OverlayBaseController<Opts, Overlay> implements ControllerShape<Opts, Overlay> {
constructor(private ctrl: ControllerShape<Opts, Overlay>) {}
/**
* Creates a new overlay
*/
create(opts?: Opts): Promise<Overlay> {
return proxyMethod(this.ctrl, this.doc, 'create', opts);
create(opts: Opts) {
return this.ctrl.create(opts);
}
/**
* When `id` is not provided, it dismisses the top overlay.
*/
dismiss(data?: any, role?: string, id?: string): Promise<void> {
return proxyMethod(this.ctrl, this.doc, 'dismiss', data, role, id);
dismiss(data?: any, role?: string, id?: string) {
return this.ctrl.dismiss(data, role, id);
}
/**
* Returns the top overlay.
*/
getTop(): Promise<Overlay | undefined> {
return proxyMethod(this.ctrl, this.doc, 'getTop');
getTop() {
return this.ctrl.getTop();
}
}

View File

@ -1,3 +1,4 @@
import { HTMLStencilElement } from '../types/interfaces';
export function proxyMethod(ctrlName: string, doc: Document, methodName: string, ...args: any[]) {
const controller = ensureElementInBody(ctrlName, doc);