refactor(): export types, import types from index.d.ts instead of direct link to module

* chore(dependencies): update the lock file

* refactor(): exported all types we're cool with exporting, updated types to be referenced from the src/index.d.ts file instead of local .ts files to prevent hard linking of files together

* chore(build): add tsc task to typecheck code

* chore(action-sheet-controller): fix import style

* fix(): removed unneeded dom controller reference and removed component element reference.
This commit is contained in:
Dan Bucholtz
2017-11-16 10:00:57 -06:00
committed by GitHub
parent 3a5e9784e4
commit ab72d92393
33 changed files with 251 additions and 316 deletions

View File

@ -24,6 +24,7 @@
},
"scripts": {
"build": "stencil build",
"tsc": "tsc -p .",
"dev": "sd concurrent \"stencil build --dev --watch\" \"stencil-dev-server\"",
"e2e": "node ./scripts/run-e2e.js",
"snapshot": "node ./scripts/e2e.js --snapshot",

View File

@ -12,6 +12,7 @@ import {
import {
AnimationBuilder,
PickerOptions,
FrameworkDelegate,
PickerColumn,
} from './index';
import {
@ -26,9 +27,6 @@ import {
GestureCallback,
GestureDetail,
} from './components/gesture/gesture.js';
import {
FrameworkDelegate,
} from './navigation/nav-interfaces';
import {
PickerButton,
PickerColumn as PickerColumn2,
@ -212,7 +210,7 @@ declare global {
import {
IonApp as IonApp
App as IonApp
} from './components/app/app';
declare global {
@ -961,7 +959,7 @@ declare global {
import {
Col as IonCol
Column as IonCol
} from './components/grid/col';
declare global {
@ -1408,7 +1406,7 @@ declare global {
import {
IonKeyboardController as IonKeyboardController
KeyboardController as IonKeyboardController
} from './components/keyboard-controller/keyboard-controller';
declare global {
@ -1604,7 +1602,7 @@ declare global {
import {
MenuController as IonMenuController
} from './components/menu/menu-controller';
} from './components/menu-controller/menu-controller';
declare global {
interface HTMLIonMenuControllerElement extends IonMenuController, HTMLElement {
@ -1741,7 +1739,7 @@ declare global {
import {
NavControllerImpl as IonNavController
NavController as IonNavController
} from './components/nav-controller/nav-controller';
declare global {
@ -1802,7 +1800,7 @@ declare global {
import {
IonNav as IonNav
Nav as IonNav
} from './components/nav/nav';
declare global {

View File

@ -274,3 +274,5 @@ export interface ActionSheetEvent extends Event {
actionSheet: ActionSheet;
};
}
export { iOSEnterAnimation, iOSLeaveAnimation };

View File

@ -475,3 +475,5 @@ export interface AlertEvent extends Event {
alert: Alert;
};
}
export { iOSEnterAnimation, iOSLeaveAnimation };

View File

@ -1,5 +0,0 @@
import { Config } from '../..';
export interface App {
element?: HTMLElement;
config?: Config;
}

View File

@ -1,7 +1,5 @@
import { Component, Element, Listen, Prop } from '@stencil/core';
import { Nav, NavContainer } from '../../navigation/nav-interfaces';
import { Config } from '../..';
import { App } from './app-interfaces';
import { Config, Nav, NavContainer } from '../../index';
import { isReady } from '../../utils/helpers';
const rootNavs = new Map<number, Nav>();
@ -16,14 +14,14 @@ const rootNavs = new Map<number, Nav>();
theme: 'app'
}
})
export class IonApp implements App {
export class App {
@Element() element: HTMLElement;
@Prop({ context: 'config' }) config: Config;
@Listen('body:navInit')
registerRootNav(event: CustomEvent) {
rootNavs.set((event.detail as Nav).id, (event.detail as Nav));
rootNavs.set((event.detail as Nav).navId, (event.detail as Nav));
}
@ -32,7 +30,7 @@ export class IonApp implements App {
componentDidLoadImpl(this);
}
getActiveNavs(rootNavId?: number): Nav[] {
getActiveNavs(rootNavId?: number): NavContainer[] {
/*const portal = portals.get(PORTAL_MODAL);
if (portal && portal.views && portal.views.length) {
return findTopNavs(portal);
@ -49,7 +47,7 @@ export class IonApp implements App {
return findTopNavs(rootNavs.values().next().value);
}
// fallback to just using all root navs
let activeNavs: Nav[] = [];
let activeNavs: NavContainer[] = [];
rootNavs.forEach(nav => {
activeNavs = activeNavs.concat(findTopNavs(nav));
});

View File

@ -270,7 +270,7 @@ export function updateDate(existingData: DatetimeData, newData: any): boolean {
} else {
// blank data, clear everything out
for (var k in existingData) {
for (let k in existingData) {
delete (<any>existingData)[k];
}
}

View File

@ -1,6 +1,22 @@
import { Component, CssClassMap, Event, EventEmitter, Prop, PropDidChange, State } from '@stencil/core';
import { DatetimeData, LocaleData, convertFormatToKey, convertToArrayOfNumbers, convertToArrayOfStrings, dateDataSortValue, dateSortValue, dateValueRange, daysInMonth, getValueFromFormat, parseDate, parseTemplate, renderDatetime, renderTextFormat, updateDate } from './datetime-util';
import {
DatetimeData,
LocaleData,
convertFormatToKey,
convertToArrayOfNumbers,
convertToArrayOfStrings,
dateDataSortValue,
dateSortValue,
dateValueRange,
daysInMonth,
getValueFromFormat,
parseDate,
parseTemplate,
renderDatetime,
renderTextFormat,
updateDate
} from './datetime-util';
import { clamp, isBlank, isObject } from '../../utils/helpers';

View File

@ -26,6 +26,6 @@ import { Component } from '@stencil/core';
@Component({
tag: 'ion-col'
})
export class Col {
export class Column {
}

View File

@ -14,10 +14,9 @@ let timeoutValue: number = null;
@Component({
tag: 'ion-keyboard-controller'
})
export class IonKeyboardController {
export class KeyboardController {
@Prop({context: 'config'}) config: Config;
@Prop({context: 'dom'}) domController: any;
/**
* @output {Event} Emitted before the keyboard has shown.
@ -53,7 +52,7 @@ export class IonKeyboardController {
}
}
export function onCloseImpl(keyboardController: IonKeyboardController, callback: Function, pollingInterval: number, maxPollingChecks: number): Promise<any> {
export function onCloseImpl(keyboardController: KeyboardController, callback: Function, pollingInterval: number, maxPollingChecks: number): Promise<any> {
let numChecks = 0;
const promise: Promise<any> = callback ? null : new Promise((resolve) => {
@ -75,7 +74,7 @@ export function onCloseImpl(keyboardController: IonKeyboardController, callback:
return promise;
}
export function componentDidLoadImpl(keyboardController: IonKeyboardController) {
export function componentDidLoadImpl(keyboardController: KeyboardController) {
focusOutline(getDocument(), keyboardController.config.get('focusOutline'));
if (keyboardController.config.getBoolean('keyboardResizes', false)) {
listenV2(getWindow(), keyboardController);
@ -84,7 +83,7 @@ export function componentDidLoadImpl(keyboardController: IonKeyboardController)
}
}
export function listenV2(win: Window, keyboardController: IonKeyboardController) {
export function listenV2(win: Window, keyboardController: KeyboardController) {
v2KeyboardWillShowHandler = () => {
keyboardController.keyboardWillShow.emit();
};
@ -106,7 +105,7 @@ export function listenV2(win: Window, keyboardController: IonKeyboardController)
win.addEventListener('keyboardDidHide', v2KeyboardDidHideHandler);
}
export function listenV1(win: Window, keyboardController: IonKeyboardController) {
export function listenV1(win: Window, keyboardController: KeyboardController) {
v1keyboardHide = () => {
blurActiveInput(true, keyboardController);
};
@ -118,7 +117,7 @@ export function listenV1(win: Window, keyboardController: IonKeyboardController)
win.addEventListener('native.keyboardshow', v1keyboardShow);
}
export function blurActiveInput(shouldBlur: boolean, keyboardController: IonKeyboardController) {
export function blurActiveInput(shouldBlur: boolean, keyboardController: KeyboardController) {
clearTimeout(timeoutValue);
if (shouldBlur) {
timeoutValue = setTimeout(() => {

View File

@ -4,7 +4,6 @@ import { Component, Element, Event, EventEmitter, Listen, Prop, State } from '@s
import iOSEnterAnimation from './animations/ios.enter';
import iOSLeaveAnimation from './animations/ios.leave';
@Component({
tag: 'ion-loading',
styleUrls: {
@ -239,3 +238,5 @@ export interface LoadingEvent extends Event {
loading: Loading;
};
}
export { iOSEnterAnimation, iOSLeaveAnimation }

View File

@ -2,8 +2,8 @@ import { Animation, AnimationBuilder, AnimationController, Menu } from '../../in
import { Component, Method, Prop } from '@stencil/core';
import MenuOverlayAnimation from './animations/overlay';
import MenuRevealAnimation from './animations/reveal';
import MenuPushAnimation from './animations/push';
import MenuRevealAnimation from './animations/reveal';
@Component({
tag: 'ion-menu-controller'
@ -260,3 +260,5 @@ export class MenuController {
}
}
export { MenuOverlayAnimation, MenuPushAnimation, MenuRevealAnimation }

View File

@ -5,7 +5,6 @@ import { createThemedClasses } from '../../utils/theme';
import iOSEnterAnimation from './animations/ios.enter';
import iOSLeaveAnimation from './animations/ios.leave';
@Component({
tag: 'ion-modal',
styleUrls: {
@ -211,3 +210,5 @@ export interface ModalEvent extends Event {
modal: Modal;
};
}
export { iOSEnterAnimation, iOSLeaveAnimation };

View File

@ -1,6 +1,6 @@
import { Component, Element, Method, Prop } from '@stencil/core';
import { Animation, AnimationController } from '../..';
import { ComponentDataPair, FrameworkDelegate, Nav, NavController, NavOptions, ViewController } from '../../navigation/nav-interfaces';
import { Animation, AnimationController, ComponentDataPair, FrameworkDelegate, Nav, NavOptions, ViewController } from '../../index';
import { isReady } from '../../utils/helpers';
@ -22,7 +22,7 @@ let defaultDelegate: FrameworkDelegate = null;
@Component({
tag: 'ion-nav-controller',
})
export class NavControllerImpl implements NavController {
export class NavController {
@Element() element: HTMLElement;
@Prop() delegate: FrameworkDelegate;

View File

@ -1,7 +1,5 @@
import { Component, Method } from '@stencil/core';
import { StencilElement } from '../..';
import { FrameworkDelegate, Nav, ViewController } from '../../navigation/nav-interfaces';
import { FrameworkDelegate, Nav, ViewController } from '../../index';
@Component({
tag: 'stencil-ion-nav-delegate'

View File

@ -1,19 +1,17 @@
import { Component, Element, Event, EventEmitter, Listen, Method, Prop } from '@stencil/core';
import { Config } from '../..';
import { ComponentDataPair, FrameworkDelegate, Nav, NavController, NavOptions, ViewController } from '../../navigation/nav-interfaces';
import { ComponentDataPair, Config, FrameworkDelegate, NavController, NavOptions, ViewController } from '../../index';
import { getActiveImpl, getFirstView, getPreviousImpl, getViews, init } from '../../navigation/nav-utils';
import { isReady } from '../../utils/helpers';
@Component({
tag: 'ion-nav',
})
export class IonNav implements Nav {
// private navId: number;
export class Nav {
@Element() element: HTMLElement;
@Event() navInit: EventEmitter;
navId: number;
parent: Nav;
views: ViewController[];
transitioning?: boolean;

View File

@ -4,7 +4,6 @@ import { Component, CssClassMap, Element, Event, EventEmitter, Listen, Method, P
import iOSEnterAnimation from './animations/ios.enter';
import iOSLeaveAnimation from './animations/ios.leave';
@Component({
tag: 'ion-picker',
styleUrls: {
@ -425,60 +424,4 @@ export interface PickerEvent extends Event {
};
}
// @ViewChildren(PickerColumnCmp) _cols: QueryList<PickerColumnCmp>;
// d: PickerOptions;
// enabled: boolean;
// id: number;
// mode: string;
// _gestureBlocker: BlockerDelegate;
// constructor() {
// this.id = (++pickerIds);
// }
// _colChange(selectedOption: PickerColumnOption) {
// // one of the columns has changed its selected index
// var picker = <Picker>this._viewCtrl;
// picker.ionChange.emit(this.getSelected());
// }
// @HostListener('body:keyup', ['$event'])
// _keyUp(ev: KeyboardEvent) {
// if (this.enabled && this._viewCtrl.isLast()) {
// if (ev.keyCode === KEY_ENTER) {
// if (this.lastClick + 1000 < Date.now()) {
// // do not fire this click if there recently was already a click
// // this can happen when the button has focus and used the enter
// // key to click the button. However, both the click handler and
// // this keyup event will fire, so only allow one of them to go.
// console.debug('picker, enter button');
// let button = this.d.buttons[this.d.buttons.length - 1];
// this.btnClick(button);
// }
// } else if (ev.keyCode === KEY_ESCAPE) {
// console.debug('picker, escape button');
// this.bdClick();
// }
// }
// }
// ionViewDidEnter() {
// this._plt.focusOutActiveElement();
// let focusableEle = this._elementRef.nativeElement.querySelector('button');
// if (focusableEle) {
// focusableEle.focus();
// }
// this.enabled = true;
// }
// ngOnDestroy() {
// assert(this._gestureBlocker.blocked === false, 'gesture blocker must be already unblocked');
// this._gestureBlocker.destroy();
// }
// }
// let pickerIds = -1;
export { iOSEnterAnimation, iOSLeaveAnimation };

View File

@ -346,3 +346,5 @@ export const POPOVER_POSITION_PROPERTIES: any = {
centerTarget: false
}
};
export { iOSEnterAnimation, iOSLeaveAnimation };

View File

@ -162,5 +162,5 @@ export class Segment {
export interface SegmentEvent extends Event {
detail: {
segment: Segment;
}
};
}

View File

@ -1,6 +1,5 @@
import { Component, Element, Event, EventEmitter, Method, Prop, PropDidChange, State } from '@stencil/core';
import { StencilElement } from '../../index';
import { ViewController } from '../../navigation/nav-interfaces';
import { StencilElement, ViewController } from '../../index';
/**
* @name Tab
@ -209,7 +208,8 @@ export class Tab {
protected componentDidUpdate() {
if (this.init && this.resolveNav) {
const nav = this.el.querySelector('ion-nav') as any as StencilElement;
nav.componentOnReady(this.resolveNav);
// TODO - fix existing typings issue
nav.componentOnReady(this.resolveNav as any);
this.resolveNav = null;
}
}

View File

@ -207,3 +207,5 @@ export interface ToastEvent {
toast: Toast;
};
}
export { iOSEnterAnimation, iOSLeaveAnimation };

View File

@ -1,49 +1,170 @@
import { Animation, AnimationBuilder, AnimationController, AnimationOptions } from './components/animation-controller/animation-interface';
import { ActionSheet, ActionSheetButton, ActionSheetEvent, ActionSheetOptions } from './components/action-sheet/action-sheet';
import { ActionSheetController } from './components/action-sheet-controller/action-sheet-controller';
import { Alert, AlertButton, AlertEvent, AlertInput, AlertOptions } from './components/alert/alert';
import { AlertController } from './components/alert-controller/alert-controller';
import { Backdrop } from './components/backdrop/backdrop';
import { Loading, LoadingEvent, LoadingOptions } from './components/loading/loading';
import { LoadingController } from './components/loading-controller/loading-controller';
import { GestureDetail, GestureCallback } from './components/gesture/gesture';
import { Menu } from './components/menu/menu';
import { MenuController } from './components/menu/menu-controller';
import { Modal, ModalOptions, ModalEvent } from './components/modal/modal';
import { ModalController } from './components/modal-controller/modal-controller';
// Components
export {
ActionSheet,
ActionSheetButton,
ActionSheetEvent,
ActionSheetOptions,
iOSEnterAnimation as ActionSheetIOSEnterAnimation,
iOSLeaveAnimation as ActionSheetIOSLeaveAnimation
} from './components/action-sheet/action-sheet';
import { Picker, PickerButton, PickerColumn, PickerColumnOption, PickerEvent, PickerOptions } from './components/picker/picker';
import { PickerController } from './components/picker-controller/picker-controller';
export { ActionSheetController } from './components/action-sheet-controller/action-sheet-controller';
export {
Alert,
AlertButton,
AlertEvent,
AlertInput,
AlertOptions,
iOSEnterAnimation as AlertIOSEnterAnimation,
iOSLeaveAnimation as AlertIOSLeaveAnimation
} from './components/alert/alert';
export { AlertController } from './components/alert-controller/alert-controller';
export {
Animation,
AnimationBuilder,
AnimationController,
AnimationOptions
} from './components/animation-controller/animation-interface';
export { App } from './components/app/app';
export { Avatar } from './components/avatar/avatar';
export { Backdrop } from './components/backdrop/backdrop';
export { Badge } from './components/badge/badge';
export { Button } from './components/button/button';
export { Buttons } from './components/buttons/buttons';
export { Card } from './components/card/card';
export { CardContent } from './components/card-content/card-content';
export { CardHeader } from './components/card-header/card-header';
export { CardTitle } from './components/card-title/card-title';
export { Checkbox } from './components/checkbox/checkbox';
export { Chip } from './components/chip/chip';
export { ChipButton } from './components/chip-button/chip-button';
export { Content } from './components/content/content';
export { Datetime } from './components/datetime/datetime';
export { FabContainer } from './components/fab/fab-container';
export { FabList } from './components/fab/fab-list';
export { FabButton } from './components/fab/fab';
export { Footer } from './components/footer/footer';
export { Gesture, GestureCallback, GestureDetail } from './components/gesture/gesture';
export { PanRecognizer } from './components/gesture/recognizers';
export {
BLOCK_ALL,
BlockerDelegate,
BlockerOptions,
GestureController,
GestureDelegate
} from './components/gesture-controller/gesture-controller';
export { Column } from './components/grid/col';
export { Grid } from './components/grid/grid';
export { Row } from './components/grid/row';
export { Header } from './components/header/header';
export { InfiniteScroll } from './components/infinite-scroll/infinite-scroll';
export { InfiniteScrollContent } from './components/infinite-scroll/infinite-scroll-content';
export { Input } from './components/input/input';
export { Item } from './components/item/item';
export { ItemDivider } from './components/item-divider/item-divider';
export { ItemOption } from './components/item-sliding/item-option';
export { ItemSliding } from './components/item-sliding/item-sliding';
export { KeyboardController } from './components/keyboard-controller/keyboard-controller';
export * from './components/keyboard-controller/keys';
export { Label } from './components/label/label';
export { List } from './components/list/list';
export { ListHeader } from './components/list-header/list-header';
export {
Loading,
LoadingEvent,
LoadingOptions,
iOSEnterAnimation as LoadingIOSEnterAnimation,
iOSLeaveAnimation as LoadingIOSLeaveAnimation
} from './components/loading/loading';
export { LoadingController } from './components/loading-controller/loading-controller';
export { Menu } from './components/menu/menu';
export {
MenuController,
MenuOverlayAnimation,
MenuPushAnimation,
MenuRevealAnimation
} from './components/menu-controller/menu-controller';
export {
Modal,
ModalOptions,
ModalEvent,
iOSEnterAnimation as ModalIOSEnterAnimation,
iOSLeaveAnimation as ModalIOSLeaveAnimation
} from './components/modal/modal';
export { ModalController } from './components/modal-controller/modal-controller';
export { Nav } from './components/nav/nav';
export { NavController } from './components/nav-controller/nav-controller';
export { Note } from './components/note/note';
export { Page } from './components/page/page';
export { PickerColumnCmp } from './components/picker/picker-column';
export {
Picker,
PickerButton,
PickerColumn,
PickerColumnOption,
PickerEvent,
PickerOptions,
iOSEnterAnimation as PickerIOSEnterAnimation,
iOSLeaveAnimation as PickerIOSLeaveAnimation
} from './components/picker/picker';
export { PickerController } from './components/picker-controller/picker-controller';
export {
Popover,
PopoverEvent,
PopoverOptions,
iOSEnterAnimation as PopoverIOSEnterAnimation,
iOSLeaveAnimation as PopoverIOSLeaveAnimation
} from './components/popover/popover';
export { PopoverController } from './components/popover-controller/popover-controller';
export { RadioGroup } from './components/radio/radio-group';
export { Radio, RadioEvent } from './components/radio/radio';
export { RangeKnob } from './components/range/range-knob';
export { Range, RangeEvent } from './components/range/range';
export { ReorderGroup } from './components/reorder/reorder-group';
export { ItemReorder } from './components/reorder/reorder';
export { Scroll, ScrollCallback, ScrollDetail } from './components/scroll/scroll';
export { Searchbar } from './components/searchbar/searchbar';
export { Segment, SegmentEvent } from './components/segment/segment';
export { SegmentButton, SegmentButtonEvent } from './components/segment-button/segment-button';
export { SelectPopoverOption, SelectPopover } from './components/select/select-popover';
export { Select } from './components/select/select';
export { SelectOption } from './components/select-option/select-option';
export { SkeletonText } from './components/skeleton-text/skeleton-text';
export { Slide } from './components/slides/slide';
export { Slides } from './components/slides/slides';
export * from './components/spinner/spinner-configs';
export { Spinner } from './components/spinner/spinner';
export { SplitPane, SplitPaneAlert } from './components/split-pane/split-pane';
export { Tab } from './components/tabs/tab';
export { Tabs } from './components/tabs/tabs';
export { Thumbnail } from './components/thumbnail/thumbnail';
export { ToolbarTitle } from './components/title/title';
export {
Toast,
ToastEvent,
ToastOptions,
iOSEnterAnimation as ToastIOSEnterAnimation,
iOSLeaveAnimation as ToastIOSLeaveAnimation
} from './components/toast/toast';
export { ToastController } from './components/toast-controller/toast-controller';
export { Toggle } from './components/toggle/toggle';
export { Navbar } from './components/toolbar/navbar';
export { Toolbar } from './components/toolbar/toolbar';
import { Popover, PopoverEvent, PopoverOptions } from './components/popover/popover';
import { PopoverController } from './components/popover-controller/popover-controller';
import { Scroll, ScrollCallback, ScrollDetail } from './components/scroll/scroll';
import { Segment } from './components/segment/segment';
import { SegmentButton, SegmentButtonEvent } from './components/segment-button/segment-button';
import { SplitPane, SplitPaneAlert } from './components/split-pane/split-pane';
import { Tab } from './components/tabs/tab';
import { Tabs } from './components/tabs/tabs';
import { Toast, ToastEvent, ToastOptions } from './components/toast/toast';
import { ToastController } from './components/toast-controller/toast-controller';
import { TransitionBuilder } from './navigation/nav-interfaces';
export * from './navigation/nav-interfaces';
export { ViewController } from './navigation/view-controller';
// export all of the component declarations that are dynamically created
export * from './components';
export interface Config {
get: (key: string, fallback?: any) => any;
getBoolean: (key: string, fallback?: boolean) => boolean;
getNumber: (key: string, fallback?: number) => number;
}
export type CssClassMap = { [className: string]: boolean };
export interface BaseInputComponent {
disabled: boolean;
hasFocus: boolean;
@ -53,69 +174,12 @@ export interface BaseInputComponent {
fireBlur: () => void;
}
export interface BooleanInputComponent extends BaseInputComponent {
checked: boolean;
toggle: (ev: UIEvent) => void;
}
export {
ActionSheet,
ActionSheetButton,
ActionSheetEvent,
ActionSheetOptions,
ActionSheetController,
Alert,
AlertButton,
AlertEvent,
AlertInput,
AlertOptions,
AlertController,
Animation,
AnimationBuilder,
AnimationController,
AnimationOptions,
Backdrop,
GestureCallback,
GestureDetail,
Loading,
LoadingOptions,
LoadingController,
LoadingEvent,
Menu,
MenuController,
Modal,
ModalController,
ModalOptions,
ModalEvent,
Picker,
PickerButton,
PickerColumn,
PickerColumnOption,
PickerController,
PickerEvent,
PickerOptions,
Popover,
PopoverController,
PopoverEvent,
PopoverOptions,
Scroll,
ScrollCallback,
ScrollDetail,
Segment,
SegmentButton,
SegmentButtonEvent,
SplitPane,
SplitPaneAlert,
TransitionBuilder,
Toast,
ToastEvent,
ToastOptions,
ToastController
}
export interface StencilElement extends HTMLElement {
componentOnReady(): Promise<HTMLElement>;
componentOnReady(done: (cmp?: HTMLElement) => void): void;

View File

@ -1,13 +1,8 @@
import { Animation, AnimationOptions, Config } from '..';
import { Animation, AnimationOptions, Config, FrameworkDelegate, Nav, NavOptions, Transition} from '../index';
import {
ComponentDataPair,
FrameworkDelegate,
Nav,
NavOptions,
NavResult,
Transition,
TransitionInstruction,
ViewController
} from './nav-interfaces';
import {
@ -28,7 +23,7 @@ import {
} from './nav-utils';
import { ViewControllerImpl } from './view-controller-impl';
import { ViewController } from './view-controller';
import { assert, focusOutActiveElement, isDef, isNumber } from '../utils/helpers';
@ -46,7 +41,7 @@ export function push(nav: Nav, delegate: FrameworkDelegate, animation: Animation
opts: opts,
nav: nav,
delegate: delegate,
id: nav.id,
id: nav.navId,
animation: animation
}, done);
}
@ -58,7 +53,7 @@ export function insert(nav: Nav, delegate: FrameworkDelegate, animation: Animati
opts: opts,
nav: nav,
delegate: delegate,
id: nav.id,
id: nav.navId,
animation: animation
}, done);
}
@ -70,7 +65,7 @@ export function insertPages(nav: Nav, delegate: FrameworkDelegate, animation: An
opts: opts,
nav: nav,
delegate: delegate,
id: nav.id,
id: nav.navId,
animation: animation
}, done);
}
@ -82,7 +77,7 @@ export function pop(nav: Nav, delegate: FrameworkDelegate, animation: Animation,
opts: opts,
nav: nav,
delegate: delegate,
id: nav.id,
id: nav.navId,
animation: animation
}, done);
}
@ -94,7 +89,7 @@ export function popToRoot(nav: Nav, delegate: FrameworkDelegate, animation: Anim
opts: opts,
nav: nav,
delegate: delegate,
id: nav.id,
id: nav.navId,
animation: animation
}, done);
}
@ -106,7 +101,7 @@ export function popTo(nav: Nav, delegate: FrameworkDelegate, animation: Animatio
opts: opts,
nav: nav,
delegate: delegate,
id: nav.id,
id: nav.navId,
animation: animation
};
if (isViewController(indexOrViewCtrl)) {
@ -125,7 +120,7 @@ export function remove(nav: Nav, delegate: FrameworkDelegate, animation: Animati
opts: opts,
nav: nav,
delegate: delegate,
id: nav.id,
id: nav.navId,
animation: animation
}, done);
}
@ -138,7 +133,7 @@ export function removeView(nav: Nav, delegate: FrameworkDelegate, animation: Ani
opts: opts,
nav: nav,
delegate: delegate,
id: nav.id,
id: nav.navId,
animation: animation
}, done);
}
@ -162,7 +157,7 @@ export function setPages(nav: Nav, delegate: FrameworkDelegate, animation: Anima
opts: opts,
nav: nav,
delegate: delegate,
id: nav.id,
id: nav.navId,
animation: animation
}, done);
}
@ -211,7 +206,7 @@ export function nextTransaction(nav: Nav): Promise<any> {
return Promise.resolve();
}
const topTransaction = getTopTransaction(nav.id);
const topTransaction = getTopTransaction(nav.navId);
if (!topTransaction) {
return Promise.resolve();
}
@ -260,14 +255,14 @@ export function successfullyTransitioned(result: NavResult, ti: TransitionInstru
}
export function transitionFailed(error: Error, ti: TransitionInstruction) {
const queue = getQueue(ti.nav.id);
const queue = getQueue(ti.nav.navId);
if (!queue) {
// TODO, make throw error in the future
return fireError(new Error('Queue is null, the nav must have been destroyed'), ti);
}
ti.nav.transitionId = null;
resetQueue(ti.nav.id);
resetQueue(ti.nav.navId);
ti.nav.transitioning = false;
@ -616,7 +611,7 @@ export function insertViewIntoNav(nav: Nav, view: ViewController, index: number)
// give this inserted view an ID
viewIds++;
if (!view.id) {
view.id = `${nav.id}-${viewIds}`;
view.id = `${nav.navId}-${viewIds}`;
}
// insert the entering view into the correct index in the stack
@ -730,7 +725,7 @@ export function convertViewsToViewControllers(views: any[]): ViewController[] {
if (isViewController(view)) {
return view as ViewController;
}
return new ViewControllerImpl(view.page, view.params);
return new ViewController(view.page, view.params);
}
return null;
}).filter(view => !!view);
@ -746,7 +741,7 @@ export function convertComponentToViewController(ti: TransitionInstruction): Vie
}
for (const viewController of viewControllers) {
if (viewController.nav && viewController.nav.id !== ti.id) {
if (viewController.nav && viewController.nav.navId !== ti.id) {
throw new Error('The view has already inserted into a different nav');
}
if (viewController.state === STATE_DESTROYED) {

View File

@ -1,11 +1,9 @@
import { EventEmitter } from '@stencil/core';
import {
Animation,
AnimationController,
AnimationOptions,
Config
} from '..';
Nav,
ViewController
} from '../index';
export interface FrameworkDelegate {
attachViewToDom(navController: Nav, enteringView: ViewController): Promise<any>;
@ -22,84 +20,6 @@ export interface NavContainer {
getSecondaryIdentifier?(): string;
}
export interface Nav {
id?: number;
element?: HTMLElement;
views?: ViewController[];
transitioning?: boolean;
destroyed?: boolean;
transitionId?: number;
isViewInitialized?: boolean;
isPortal?: boolean;
zIndexOffset?: number;
swipeToGoBackTransition?: any; // TODO Transition
navController?: NavController;
parent?: Nav;
childNavs?: Nav[]; // TODO - make nav container
root?: any;
navInit?: EventEmitter;
config?: Config;
mode?: string;
// public methods
getActive?(): ViewController;
getPrevious?(view?: ViewController): ViewController;
getViews?(): ViewController[];
push?(component: any, data?: any, opts?: NavOptions): Promise<any>;
pop?(opts?: NavOptions): Promise<any>;
setRoot?(component: any, data?: any, opts?: NavOptions): Promise<any>;
insert?(insertIndex: number, page: any, params?: any, opts?: NavOptions): Promise<any>;
insertPages?(insertIndex: number, insertPages: any[], opts?: NavOptions): Promise<any>;
popToRoot?(opts?: NavOptions): Promise<any>;
popTo?(indexOrViewCtrl: any, opts?: NavOptions): Promise<any>;
remove?(startIndex: number, removeCount?: number, opts?: NavOptions): Promise<any>;
removeView?(viewController: ViewController, opts?: NavOptions): Promise<any>;
setPages?(componentDataPairs: ComponentDataPair[], opts?: NavOptions): Promise<any>;
}
export interface NavController {
push(nav: Nav, component: any, data: any, opts: NavOptions): Promise<any>;
pop(nav: Nav, opts: NavOptions): Promise<any>;
setRoot(nav: Nav, component: any, data: any, opts: NavOptions): Promise<any>;
insert(nav: Nav, insertIndex: number, page: any, params: any, opts: NavOptions): Promise<any>;
insertPages(nav: Nav, insertIndex: number, insertPages: any[], opts?: NavOptions): Promise<any>;
popToRoot(nav: Nav, opts: NavOptions): Promise<any>;
popTo(nav: Nav, indexOrViewCtrl: any, opts?: NavOptions): Promise<any>;
removeIndex(nav: Nav, startIndex: number, removeCount: number, opts: NavOptions): Promise<any>;
removeView(nav: Nav, viewController: ViewController, opts?: NavOptions): Promise<any>;
setPages(nav: Nav, componentDataPairs: ComponentDataPair[], opts?: NavOptions): Promise<any>;
delegate?: FrameworkDelegate;
animationCtrl?: AnimationController;
}
export interface ViewController {
id: string;
component: any;
data: any;
element: HTMLElement;
instance: any;
state: number;
nav: Nav;
dismissProxy?: any;
zIndex: number;
// life cycle events
willLeave(unload: boolean): void;
didLeave(): void;
willEnter(): void;
didEnter(): void;
willLoad(): void;
didLoad(): void;
willUnload(): void;
destroy(delegate?: FrameworkDelegate): Promise<any>;
getTransitionName(direction: string): string;
onDidDismiss: (data: any, role: string) => void;
onWillDismiss: (data: any, role: string) => void;
}
export interface NavResult {
hasCompleted: boolean;
requiresTransition: boolean;

View File

@ -1,5 +1,5 @@
import { Nav, Transition, ViewController } from './nav-interfaces';
import { Animation, AnimationOptions, Config, TransitionBuilder } from '..';
import { Transition } from './nav-interfaces';
import { Animation, AnimationOptions, Config, Nav, TransitionBuilder, ViewController } from '..';
import { isDef } from '../utils/helpers';
export const STATE_NEW = 1;
@ -33,7 +33,8 @@ export function setZIndex(nav: Nav, enteringView: ViewController, leavingView: V
if (enteringView) {
if (nav.isPortal) {
if (direction === DIRECTION_FORWARD) {
updateZIndex(enteringView, nav.zIndexOffset + portalZindex);
// TODO - fix typing
updateZIndex(enteringView, (nav as any).zIndexOffset + portalZindex);
}
portalZindex++;
return;
@ -50,7 +51,8 @@ export function setZIndex(nav: Nav, enteringView: ViewController, leavingView: V
}
} else {
updateZIndex(enteringView, INIT_ZINDEX + nav.zIndexOffset);
// TODO - fix typing
updateZIndex(enteringView, INIT_ZINDEX + (nav as any).zIndexOffset);
}
}
}
@ -169,7 +171,7 @@ export function getViews(nav: Nav): ViewController[] {
}
export function init(nav: Nav) {
nav.id = getNextNavId();
nav.navId = getNextNavId();
nav.views = [];
}

View File

@ -1,7 +1,5 @@
import { AnimationOptions } from '../..';
import { Transition, ViewController } from '../nav-interfaces';
import { AnimationOptions, Transition, ViewController } from '../../index';
import { canNavGoBack } from '../nav-utils';
import { isDef } from '../../utils/helpers';
const DURATION = 500;

View File

@ -1,7 +1,5 @@
import { AnimationOptions } from '../..';
import { Transition, ViewController } from '../nav-interfaces';
import { AnimationOptions, Transition, ViewController } from '../../index';
import { canNavGoBack } from '../nav-utils';
import { isDef } from '../../utils/helpers';
const TRANSLATEY = 'translateY';

View File

@ -1,9 +1,9 @@
import { FrameworkDelegate, Nav, ViewController } from './nav-interfaces';
import { FrameworkDelegate, Nav } from '../index';
import { STATE_ATTACHED, STATE_DESTROYED, STATE_INITIALIZED, STATE_NEW } from './nav-utils';
import { assert } from '../utils/helpers';
export class ViewControllerImpl implements ViewController {
export class ViewController {
id: string;
data: any;

View File

@ -18,7 +18,7 @@
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist",
"outDir": ".tmp",
"pretty": true,
"removeComments": false,
"target": "es2015"