From 10739ff2d7bf5816f69dfc7895d3205349086993 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Wed, 17 May 2017 22:33:52 +0200 Subject: [PATCH] chore(core): update core files --- src/themes/ionic.mixins.scss | 29 ----------- src/util/helpers.ts | 44 +++------------- src/util/interfaces.ts | 97 +++++++++++++++++++++++------------- 3 files changed, 70 insertions(+), 100 deletions(-) diff --git a/src/themes/ionic.mixins.scss b/src/themes/ionic.mixins.scss index 5063b48a6a..03e5e38e61 100644 --- a/src/themes/ionic.mixins.scss +++ b/src/themes/ionic.mixins.scss @@ -156,32 +156,3 @@ @content; } } - - -// Based on a selector, apply the content to that selector and the :host -@mixin host($selector: null) { - @at-root { - @if ($selector) { - :host(#{$selector}), - #{&} { - @content; - } - } @else { - :host, - #{&} { - @content; - } - } - } -} - - -// Based on a selector, apply the content to that selector and the :host-context -@mixin host-context() { - @at-root { - :host-context(#{&}), - #{&} { - @content; - } - } -} \ No newline at end of file diff --git a/src/util/helpers.ts b/src/util/helpers.ts index 38d3c080b4..81504cf6e3 100644 --- a/src/util/helpers.ts +++ b/src/util/helpers.ts @@ -64,14 +64,7 @@ export function getElementReference(elm: any, ref: string) { return elm.firstElementChild; } if (ref === 'parent') { - if (elm.parentElement ) { - // normal element with a parent element - return elm.parentElement; - } - if (elm.parentNode && elm.parentNode.host) { - // shadow dom's document fragment - return elm.parentNode.host; - } + return getParentElement(elm) || elm; } if (ref === 'body') { return elm.ownerDocument.body; @@ -85,18 +78,14 @@ export function getElementReference(elm: any, ref: string) { return elm; } -export function getKeyCodeByName(keyName: string) { - if (keyName === 'enter') { - return 13; +export function getParentElement(elm: any) { + if (elm.parentElement ) { + // normal element with a parent element + return elm.parentElement; } - if (keyName === 'escape') { - return 27; - } - if (keyName === 'space') { - return 32; - } - if (keyName === 'tab') { - return 9; + if (elm.parentNode && elm.parentNode.host) { + // shadow dom's document fragment + return elm.parentNode.host; } return null; } @@ -108,20 +97,3 @@ export function applyStyles(elm: HTMLElement, styles: {[styleProp: string]: stri (elm.style)[styleProps[i]] = styles[styleProps[i]]; } } - -export function asyncFn(queue: Function[], cb: Function) { - if (queue === null) { - cb(); - } else { - queue.push(cb); - } -} - -export function drainAsyncFns(queue: Function[]): any { - if (queue) { - for (var i = 0; i < queue.length; i++) { - queue[i](); - } - } - return null; -} diff --git a/src/util/interfaces.ts b/src/util/interfaces.ts index 520acf7d68..40403131d8 100644 --- a/src/util/interfaces.ts +++ b/src/util/interfaces.ts @@ -6,41 +6,52 @@ export interface Ionic { add: AddEventListenerApi; }; theme: IonicTheme; - controllers: { - gesture?: any; - }; + controllers: {[ctrlName: string]: any}; + overlay: IonicOverlay; dom: DomControllerApi; config: ConfigApi; - modal: ModalControllerApi; Animation: Animation; } +export interface OverlayApi { + load: (opts?: any) => Promise; +} + + +export interface IonicOverlay { + (ctrlName: 'modal', opts: ModalOptions): Promise; + (ctrlName: string, opts?: any): Promise; +} + + +export interface IonicControllerLoaded { + (ctrlName: string): void; +} + + export interface IonicGlobal { staticDir?: string; components?: LoadComponents; loadComponents?: (coreVersion: number, bundleId: string, modulesImporterFn: ModulesImporterFn, cmp0?: ComponentModeData, cmp1?: ComponentModeData, cmp2?: ComponentModeData) => void; eventNameFn?: (eventName: string) => string; config?: Object; + loadController?: (ctrlName: string, ctrl: any) => any; ConfigCtrl?: ConfigApi; DomCtrl?: DomControllerApi; - NextTickCtrl?: NextTickApi; - Animation: any; + QueueCtrl?: QueueApi; + Animation?: any; } -export interface ModalControllerApi { - create: (component: string, params?: any, opts?: ModalOptions) => Promise; -} +export interface ModalController { - -export interface ModalControllerInternalApi extends ModalControllerApi { - _create?: any[]; } export interface Modal { component: string; + componentProps?: any; id: string; style?: { zIndex: number; @@ -50,13 +61,14 @@ export interface Modal { enterAnimation: AnimationBuilder; exitAnimation: AnimationBuilder; cssClass: string; - params: any; present: (done?: Function) => void; dismiss: (done?: Function) => void; } export interface ModalOptions { + component: string; + componentProps?: any; showBackdrop?: boolean; enableBackdropDismiss?: boolean; enterAnimation?: AnimationBuilder; @@ -164,13 +176,9 @@ export interface ContentDimensions { } -export interface NextTickApi { - nextTick: NextTick; -} - - -export interface NextTick { - (cb: Function): void; +export interface QueueApi { + add: (cb: Function) => void; + flush: Function; } @@ -204,32 +212,37 @@ export interface ComponentModeData { /** * methods */ - [1]: Methods; + [1]: MethodMeta[]; + + /** + * states + */ + [2]: StateMeta[]; /** * listeners */ - [2]: ComponentListenersData[]; + [3]: ComponentListenersData[]; /** * watchers */ - [3]: ComponentWatchersData[]; + [4]: ComponentWatchersData[]; /** * shadow */ - [4]: boolean; + [5]: boolean; /** * mode name (ios, md, wp) */ - [5]: string; + [6]: number; /** * component mode styles */ - [6]: string; + [7]: string; } @@ -303,7 +316,7 @@ export interface PropMeta { } -export type Methods = string[]; +export type MethodMeta = string; export interface MethodDecorator { @@ -332,6 +345,14 @@ export interface ListenMeta extends ListenOptions { } +export interface StateDecorator { + (): any; +} + + +export type StateMeta = string; + + export interface WatchDecorator { (propName: string): any; } @@ -361,10 +382,11 @@ export interface ConfigApi { export interface ComponentMeta { tag?: string; - methods?: Methods; + methods?: MethodMeta[]; props?: PropMeta[]; listeners?: ListenMeta[]; watchers?: WatchMeta[]; + states?: StateMeta[]; modes: ModeMeta[]; shadow?: boolean; namedSlots?: string[]; @@ -385,7 +407,7 @@ export interface ModeMeta { export interface Component { ionViewDidLoad?: () => void; - ionViewWillUnload?: () => void; + ionViewDidUnload?: () => void; render?: () => VNode; @@ -447,14 +469,17 @@ export interface ProxyElement extends HTMLElement { connectedCallback: () => void; attributeChangedCallback: (attrName: string, oldVal: string, newVal: string, namespace: string) => void; disconnectedCallback: () => void; - $queueUpdate: () => void; + $queueUpdate: () => void; + $initLoadComponent: () => void; $queued?: boolean; $instance?: Component; $hostContent?: HostContentNodes; - $tmpDisconnected?: boolean; - - [memberName: string]: any; + $isLoaded?: boolean; + $hasConnected?: boolean; + $hasRendered?: boolean; + $awaitLoads?: ProxyElement[]; + $depth?: number; } @@ -515,10 +540,11 @@ export interface VNodeData { export interface PlatformApi { - registerComponent: (tag: string, data: any[]) => ComponentMeta; + registerComponents: (components: LoadComponents) => ComponentMeta[]; + defineComponent: (tag: string, constructor: Function) => void; getComponentMeta: (tag: string) => ComponentMeta; loadBundle: (bundleId: string, priority: string, cb: Function) => void; - nextTick: NextTick; + queue: QueueApi; isElement: (node: Node) => node is Element; isText: (node: Node) => node is Text; @@ -538,6 +564,7 @@ export interface PlatformApi { $getTextContent: (node: Node) => string | null; $getAttribute: (elm: Element, attrName: string) => string; $attachComponent: (elm: Element, cmpMeta: ComponentMeta, instance: Component) => void; + $tmpDisconnected: boolean; }