diff --git a/angular/src/util/overlay.ts b/angular/src/util/overlay.ts index e4e24d6b3c..25d95d566b 100644 --- a/angular/src/util/overlay.ts +++ b/angular/src/util/overlay.ts @@ -1,7 +1,5 @@ - import { proxyMethod } from '../util/util'; - export class OverlayBaseController { constructor(private ctrl: string) {} @@ -12,4 +10,8 @@ export class OverlayBaseController { dismiss(data?: any, role?: string, id = -1): Promise { return proxyMethod(this.ctrl, 'dismiss', data, role, id); } + + getTop(): Promise { + return proxyMethod(this.ctrl, 'getTop'); + } } diff --git a/angular/src/util/util.ts b/angular/src/util/util.ts index 3d5e5adbcc..f84b3385de 100644 --- a/angular/src/util/util.ts +++ b/angular/src/util/util.ts @@ -1,6 +1,4 @@ - - export function proxyMethod(ctrlName: string, methodName: string, ...args: any[]) { const controller = ensureElementInBody(ctrlName); return controller.componentOnReady() @@ -15,18 +13,3 @@ export function ensureElementInBody(elementName: string) { } return element as HTMLStencilElement; } - -export function removeAllNodeChildren(element: HTMLElement) { - while (element.firstChild) { - element.removeChild(element.firstChild); - } -} - -export function isString(something: any) { - return typeof something === 'string' ? true : false; -} - -export function getIonApp(): Promise { - const element = ensureElementInBody('ion-app') as HTMLIonAppElement; - return element.componentOnReady(); -} diff --git a/core/src/components/action-sheet-controller/action-sheet-controller.tsx b/core/src/components/action-sheet-controller/action-sheet-controller.tsx index 9ce34f190b..dac12c2e2f 100644 --- a/core/src/components/action-sheet-controller/action-sheet-controller.tsx +++ b/core/src/components/action-sheet-controller/action-sheet-controller.tsx @@ -1,6 +1,6 @@ import { Component, Listen, Method } from '@stencil/core'; -import { ActionSheetOptions, OverlayController } from '../../index'; -import { createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; +import { ActionSheetOptions } from '../../index'; +import { OverlayController, createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; @Component({ tag: 'ion-action-sheet-controller' diff --git a/core/src/components/alert-controller/alert-controller.tsx b/core/src/components/alert-controller/alert-controller.tsx index 2a7082bf41..8f39af92f9 100644 --- a/core/src/components/alert-controller/alert-controller.tsx +++ b/core/src/components/alert-controller/alert-controller.tsx @@ -1,6 +1,6 @@ import { Component, Listen, Method } from '@stencil/core'; -import { AlertOptions, OverlayController } from '../../index'; -import { createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; +import { AlertOptions } from '../../index'; +import { OverlayController, createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; @Component({ tag: 'ion-alert-controller' diff --git a/core/src/components/loading-controller/loading-controller.tsx b/core/src/components/loading-controller/loading-controller.tsx index c10e1f664d..c7a08c9576 100644 --- a/core/src/components/loading-controller/loading-controller.tsx +++ b/core/src/components/loading-controller/loading-controller.tsx @@ -1,6 +1,6 @@ import { Component, Listen, Method } from '@stencil/core'; -import { LoadingOptions, OverlayController } from '../../index'; -import { createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; +import { LoadingOptions } from '../../index'; +import { OverlayController, createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; @Component({ diff --git a/core/src/components/loading/loading.tsx b/core/src/components/loading/loading.tsx index bc7fce2453..fb6f086f9a 100644 --- a/core/src/components/loading/loading.tsx +++ b/core/src/components/loading/loading.tsx @@ -19,7 +19,6 @@ import mdLeaveAnimation from './animations/md.leave'; theme: 'loading' } }) - export class Loading implements OverlayInterface { private durationTimeout: any; diff --git a/core/src/components/modal-controller/modal-controller.tsx b/core/src/components/modal-controller/modal-controller.tsx index a87e89d45f..56f708da7f 100644 --- a/core/src/components/modal-controller/modal-controller.tsx +++ b/core/src/components/modal-controller/modal-controller.tsx @@ -1,6 +1,6 @@ import { Component, Listen, Method } from '@stencil/core'; -import { ModalOptions, OverlayController } from '../../index'; -import { createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; +import { ModalOptions } from '../../index'; +import { OverlayController, createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; @Component({ diff --git a/core/src/components/picker-controller/picker-controller.tsx b/core/src/components/picker-controller/picker-controller.tsx index 87f570d289..3177eca427 100644 --- a/core/src/components/picker-controller/picker-controller.tsx +++ b/core/src/components/picker-controller/picker-controller.tsx @@ -1,6 +1,6 @@ import { Component, Listen, Method } from '@stencil/core'; -import { OverlayController, PickerOptions } from '../../index'; -import { createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; +import { PickerOptions } from '../../index'; +import { OverlayController, createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; @Component({ diff --git a/core/src/components/popover-controller/popover-controller.tsx b/core/src/components/popover-controller/popover-controller.tsx index f9b46de8fe..cdfe7f4c51 100644 --- a/core/src/components/popover-controller/popover-controller.tsx +++ b/core/src/components/popover-controller/popover-controller.tsx @@ -1,6 +1,6 @@ import { Component, Listen, Method } from '@stencil/core'; -import { OverlayController, PopoverOptions } from '../../index'; -import { createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; +import { PopoverOptions } from '../../index'; +import { OverlayController, createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; @Component({ tag: 'ion-popover-controller' diff --git a/core/src/components/toast-controller/toast-controller.tsx b/core/src/components/toast-controller/toast-controller.tsx index 4756e816e6..f532b11290 100644 --- a/core/src/components/toast-controller/toast-controller.tsx +++ b/core/src/components/toast-controller/toast-controller.tsx @@ -1,6 +1,6 @@ import { Component, Listen, Method } from '@stencil/core'; -import { OverlayController, ToastOptions } from '../../index'; -import { createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; +import { ToastOptions } from '../../index'; +import { OverlayController, createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays'; @Component({ diff --git a/core/src/index.d.ts b/core/src/index.d.ts index fb6f0e8052..45240e0470 100644 --- a/core/src/index.d.ts +++ b/core/src/index.d.ts @@ -110,6 +110,7 @@ export * from './components'; export { DomController, RafCallback } from './global/dom-controller'; export { FrameworkDelegate, FrameworkMountingData } from './utils/dom-framework-delegate'; +export { OverlayEventDetail } from './utils/overlays'; export interface Config { get: (key: string, fallback?: any) => any; @@ -157,7 +158,3 @@ declare global { } } } - -export interface OverlayController { - getTop(): HTMLElement; -} diff --git a/core/src/utils/overlays.ts b/core/src/utils/overlays.ts index 4761ce1ac6..7486fd4a0f 100644 --- a/core/src/utils/overlays.ts +++ b/core/src/utils/overlays.ts @@ -200,6 +200,12 @@ export interface OverlayInterface { dismiss(data?: any, role?: string): Promise; } +export interface OverlayController { + create(opts?: any): Promise; + dismiss(data?: any, role?: string, alertId?: number): Promise; + getTop(): HTMLElement; +} + export interface HTMLIonOverlayElement extends HTMLStencilElement, OverlayInterface {} export type OverlayMap = Map;