diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 1f5c8c7c35..1938e4cc9e 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -5923,7 +5923,7 @@ declare global { /** * Scroll by a specified X/Y distance in the component */ - 'scrollByPoint': (x: number, y: number, duration: number, done?: Function | undefined) => Promise; + 'scrollByPoint': (x: number, y: number, duration: number) => Promise; /** * If true, the component will emit scroll events. */ @@ -5935,7 +5935,7 @@ declare global { /** * Scroll to a specified X/Y location in the component */ - 'scrollToPoint': (x: number, y: number, duration: number, done?: Function | undefined) => Promise; + 'scrollToPoint': (x: number, y: number, duration: number) => Promise; /** * Scroll to the top of the component */ diff --git a/core/src/components/action-sheet/action-sheet.tsx b/core/src/components/action-sheet/action-sheet.tsx index 0a60b0f3e1..91b2f66e60 100644 --- a/core/src/components/action-sheet/action-sheet.tsx +++ b/core/src/components/action-sheet/action-sheet.tsx @@ -98,22 +98,22 @@ export class ActionSheet implements OverlayInterface { /** * Emitted after the alert has presented. */ - @Event({eventName: 'ionActionSheetDidPresent'}) didPresent!: EventEmitter; + @Event({ eventName: 'ionActionSheetDidPresent' }) didPresent!: EventEmitter; /** * Emitted before the alert has presented. */ - @Event({eventName: 'ionActionSheetWillPresent'}) willPresent!: EventEmitter; + @Event({ eventName: 'ionActionSheetWillPresent' }) willPresent!: EventEmitter; /** * Emitted before the alert has dismissed. */ - @Event({eventName: 'ionActionSheetWillDismiss'}) willDismiss!: EventEmitter; + @Event({ eventName: 'ionActionSheetWillDismiss' }) willDismiss!: EventEmitter; /** * Emitted after the alert has dismissed. */ - @Event({eventName: 'ionActionSheetDidDismiss'}) didDismiss!: EventEmitter; + @Event({ eventName: 'ionActionSheetDidDismiss' }) didDismiss!: EventEmitter; componentDidLoad() { @@ -186,7 +186,7 @@ export class ActionSheet implements OverlayInterface { } } - private callButtonHandler(button: ActionSheetButton|undefined): boolean { + private callButtonHandler(button: ActionSheetButton | undefined): boolean { if (button && button.handler) { // a handler has been provided, execute it // pass the handler the values from the inputs diff --git a/core/src/components/action-sheet/animations/ios.enter.ts b/core/src/components/action-sheet/animations/ios.enter.ts index a9a9388572..d0fa4d362a 100644 --- a/core/src/components/action-sheet/animations/ios.enter.ts +++ b/core/src/components/action-sheet/animations/ios.enter.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * iOS Action Sheet Enter Animation */ -export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.action-sheet-wrapper')); backdropAnimation.fromTo('opacity', 0.01, 0.4); diff --git a/core/src/components/action-sheet/animations/ios.leave.ts b/core/src/components/action-sheet/animations/ios.leave.ts index 109271cb82..46aa67a5de 100644 --- a/core/src/components/action-sheet/animations/ios.leave.ts +++ b/core/src/components/action-sheet/animations/ios.leave.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * iOS Action Sheet Leave Animation */ -export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function iosLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.action-sheet-wrapper')); backdropAnimation.fromTo('opacity', 0.4, 0); diff --git a/core/src/components/action-sheet/animations/md.enter.ts b/core/src/components/action-sheet/animations/md.enter.ts index 5aa12dd735..3f2888ef05 100644 --- a/core/src/components/action-sheet/animations/md.enter.ts +++ b/core/src/components/action-sheet/animations/md.enter.ts @@ -4,13 +4,13 @@ import { Animation } from '../../../interface'; /** * MD Action Sheet Enter Animation */ -export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.action-sheet-wrapper')); backdropAnimation.fromTo('opacity', 0.01, 0.26); diff --git a/core/src/components/action-sheet/animations/md.leave.ts b/core/src/components/action-sheet/animations/md.leave.ts index 8527f99c4f..45b1f34445 100644 --- a/core/src/components/action-sheet/animations/md.leave.ts +++ b/core/src/components/action-sheet/animations/md.leave.ts @@ -3,14 +3,14 @@ import { Animation } from '../../../interface'; /** * MD Action Sheet Leave Animation */ -export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise { +export function mdLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.action-sheet-wrapper')); backdropAnimation.fromTo('opacity', 0.26, 0); diff --git a/core/src/components/alert/alert-interface.ts b/core/src/components/alert/alert-interface.ts index 3af7eaa03e..46b65f1c5e 100644 --- a/core/src/components/alert/alert-interface.ts +++ b/core/src/components/alert/alert-interface.ts @@ -6,7 +6,7 @@ export interface AlertOptions { cssClass?: string | string[]; mode?: string; inputs?: AlertInput[]; - buttons?: (AlertButton|string)[]; + buttons?: (AlertButton | string)[]; enableBackdropDismiss?: boolean; translucent?: boolean; } @@ -20,7 +20,7 @@ export interface AlertInput { checked?: boolean; disabled?: boolean; id?: string; - handler?: Function; + handler?: (input: AlertInput) => void; min?: string | number; max?: string | number; } diff --git a/core/src/components/alert/alert.tsx b/core/src/components/alert/alert.tsx index 8b4131205d..992f41263c 100644 --- a/core/src/components/alert/alert.tsx +++ b/core/src/components/alert/alert.tsx @@ -105,22 +105,22 @@ export class Alert implements OverlayInterface { /** * Emitted after the alert has presented. */ - @Event({eventName: 'ionAlertDidPresent'}) didPresent!: EventEmitter; + @Event({ eventName: 'ionAlertDidPresent' }) didPresent!: EventEmitter; /** * Emitted before the alert has presented. */ - @Event({eventName: 'ionAlertWillPresent'}) willPresent!: EventEmitter; + @Event({ eventName: 'ionAlertWillPresent' }) willPresent!: EventEmitter; /** * Emitted before the alert has dismissed. */ - @Event({eventName: 'ionAlertWillDismiss'}) willDismiss!: EventEmitter; + @Event({ eventName: 'ionAlertWillDismiss' }) willDismiss!: EventEmitter; /** * Emitted after the alert has dismissed. */ - @Event({eventName: 'ionAlertDidDismiss'}) didDismiss!: EventEmitter; + @Event({ eventName: 'ionAlertDidDismiss' }) didDismiss!: EventEmitter; @Watch('buttons') buttonsChanged() { @@ -244,16 +244,16 @@ export class Alert implements OverlayInterface { const role = button.role; const values = this.getValues(); if (isCancel(role)) { - this.dismiss({values}, role); + this.dismiss({ values }, role); return; } const returnData = this.callButtonHandler(button, values); if (returnData !== false) { - this.dismiss({values, ...returnData}, button.role); + this.dismiss({ values, ...returnData }, button.role); } } - private callButtonHandler(button: AlertButton|undefined, data: any = undefined) { + private callButtonHandler(button: AlertButton | undefined, data?: any) { if (button && button.handler) { // a handler has been provided, execute it // pass the handler the values from the inputs @@ -427,7 +427,7 @@ export class Alert implements OverlayInterface { const subHdrId = `alert-${this.overlayId}-sub-hdr`; const msgId = `alert-${this.overlayId}-msg`; - let labelledById: string|undefined = undefined; + let labelledById: string | undefined; if (this.header) { labelledById = hdrId; } else if (this.subHeader) { diff --git a/core/src/components/alert/animations/ios.enter.ts b/core/src/components/alert/animations/ios.enter.ts index ee2e4217a4..f539b29b3f 100644 --- a/core/src/components/alert/animations/ios.enter.ts +++ b/core/src/components/alert/animations/ios.enter.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * iOS Alert Enter Animation */ -export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.alert-wrapper')); backdropAnimation.fromTo('opacity', 0.01, 0.3); diff --git a/core/src/components/alert/animations/ios.leave.ts b/core/src/components/alert/animations/ios.leave.ts index 48656b0c05..ad14e0fcda 100644 --- a/core/src/components/alert/animations/ios.leave.ts +++ b/core/src/components/alert/animations/ios.leave.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * iOS Alert Leave Animation */ -export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function iosLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.alert-wrapper')); backdropAnimation.fromTo('opacity', 0.3, 0); diff --git a/core/src/components/alert/animations/md.enter.ts b/core/src/components/alert/animations/md.enter.ts index 266f8dbffc..c4a3111ed1 100644 --- a/core/src/components/alert/animations/md.enter.ts +++ b/core/src/components/alert/animations/md.enter.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * Md Alert Enter Animation */ -export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.alert-wrapper')); backdropAnimation.fromTo('opacity', 0.01, 0.5); diff --git a/core/src/components/alert/animations/md.leave.ts b/core/src/components/alert/animations/md.leave.ts index aca701cc75..a0945d4c47 100644 --- a/core/src/components/alert/animations/md.leave.ts +++ b/core/src/components/alert/animations/md.leave.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * Md Alert Leave Animation */ -export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function mdLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.alert-wrapper')); backdropAnimation.fromTo('opacity', 0.5, 0); diff --git a/core/src/components/animation-controller/animation-interface.tsx b/core/src/components/animation-controller/animation-interface.tsx index 962d49f504..8fec71d415 100644 --- a/core/src/components/animation-controller/animation-interface.tsx +++ b/core/src/components/animation-controller/animation-interface.tsx @@ -5,9 +5,9 @@ export interface AnimationController { export interface Animation { new (): any; - parent: Animation|undefined; + parent: Animation | undefined; hasChildren: boolean; - addElement(el: Node|Node[]|NodeList): Animation; + addElement(el: Node | Node[] | NodeList): Animation; add(childAnimation: Animation): Animation; duration(milliseconds: number): Animation; easing(name: string): Animation; @@ -21,8 +21,8 @@ export interface Animation { beforeRemoveClass(className: string): Animation; beforeStyles(styles: { [property: string]: any; }): Animation; beforeClearStyles(propertyNames: string[]): Animation; - beforeAddRead(domReadFn: Function): Animation; - beforeAddWrite(domWriteFn: Function): Animation; + beforeAddRead(domReadFn: () => void): Animation; + beforeAddWrite(domWriteFn: () => void): Animation; duringAddClass(className: string): Animation; afterAddClass(className: string): Animation; afterRemoveClass(className: string): Animation; @@ -43,9 +43,7 @@ export interface Animation { } -export interface AnimationBuilder { - (Animation: Animation, baseEl: HTMLElement, opts?: any): Promise; -} +export type AnimationBuilder = (Animation: Animation, baseEl: HTMLElement, opts?: any) => Promise; export interface PlayOptions { duration?: number; diff --git a/core/src/components/animation-controller/animator.tsx b/core/src/components/animation-controller/animator.tsx index 4011711a75..6330527082 100644 --- a/core/src/components/animation-controller/animator.tsx +++ b/core/src/components/animation-controller/animator.tsx @@ -23,7 +23,7 @@ export const TRANSFORM_PROPS: {[key: string]: number} = { 'perspective': 1 }; -const raf = window.requestAnimationFrame || ((f: Function) => f()); +const raf = window.requestAnimationFrame || ((f: FrameRequestCallback) => f(Date.now())); export class Animator { @@ -42,21 +42,21 @@ export class Animator { private _hasTweenEffect = false; private _isAsync = false; private _isReverse = false; - private _onFinishCallbacks?: Function[]; - private _onFinishOneTimeCallbacks?: Function[]; - private _readCallbacks?: Function[]; + private _onFinishCallbacks?: ((a: Animator) => void)[]; + private _onFinishOneTimeCallbacks?: ((a: Animator) => void)[]; + private _readCallbacks?: (() => void)[]; private _reversedEasingName?: string; private _timerId?: any; - private _unregisterTrnsEnd?: Function; - private _writeCallbacks?: Function[]; + private _unregisterTrnsEnd?: (() => void); + private _writeCallbacks?: (() => void)[]; private _destroyed = false; - parent: Animator|undefined; + parent: Animator | undefined; hasChildren = false; isPlaying = false; hasCompleted = false; - addElement(el: Node|Node[]|NodeList): Animator { + addElement(el: Node | Node[] | NodeList): Animator { if (el) { if ((el as NodeList).length) { for (let i = 0; i < (el as NodeList).length; i++) { @@ -123,7 +123,7 @@ export class Animator { * Get the easing of this animation. If this animation does * not have an easing, then it'll get the easing from its parent. */ - getEasing(): string|null { + getEasing(): string | null { if (this._isReverse && this._reversedEasingName) { return this._reversedEasingName; } @@ -205,7 +205,7 @@ export class Animator { // add from/to EffectState to the EffectProperty const fxState: EffectState = { - val: val, + val, num: 0, effectUnit: '', }; @@ -280,7 +280,7 @@ export class Animator { * Add a function which contains DOM reads, which will run * before the animation begins. */ - beforeAddRead(domReadFn: Function): Animator { + beforeAddRead(domReadFn: () => void): Animator { (this._readCallbacks = this._readCallbacks || []).push(domReadFn); return this; } @@ -289,7 +289,7 @@ export class Animator { * Add a function which contains DOM writes, which will run * before the animation begins. */ - beforeAddWrite(domWriteFn: Function): Animator { + beforeAddWrite(domWriteFn: () => void): Animator { (this._writeCallbacks = this._writeCallbacks || []).push(domWriteFn); return this; } @@ -372,7 +372,7 @@ export class Animator { playAsync(opts?: PlayOptions): Promise { return new Promise(resolve => { - this.onFinish(resolve, {oneTimeCallback: true, clearExistingCallacks: true }); + this.onFinish(resolve, { oneTimeCallback: true, clearExistingCallacks: true }); this.play(opts); return this; }); @@ -393,7 +393,7 @@ export class Animator { * DOM WRITE * RECURSION */ - private _playInit(opts: PlayOptions|undefined) { + private _playInit(opts: PlayOptions | undefined) { // always default that an animation does not tween // a tween requires that an Animation class has an element // and that it has at least one FROM/TO effect @@ -427,7 +427,7 @@ export class Animator { * NO RECURSION * ROOT ANIMATION */ - _playDomInspect(opts: PlayOptions|undefined) { + _playDomInspect(opts: PlayOptions | undefined) { const self = this; // fire off all the "before" function that have DOM READS in them // elements will be in the DOM, however visibily hidden @@ -460,7 +460,7 @@ export class Animator { * DOM WRITE * RECURSION */ - _playProgress(opts: PlayOptions|undefined) { + _playProgress(opts: PlayOptions | undefined) { const children = this._childAnimations; if (children) { for (let i = 0; i < children.length; i++) { @@ -598,7 +598,7 @@ export class Animator { * NO DOM * RECURSION */ - _hasDuration(opts: PlayOptions|undefined) { + _hasDuration(opts: PlayOptions | undefined) { if (this.getDuration(opts) > DURATION_MIN) { return true; } @@ -1257,7 +1257,7 @@ export class Animator { /** * NO DOM */ - _transEl(): HTMLElement|null { + _transEl(): HTMLElement | null { // get the lowest level element that has an Animator const children = this._childAnimations; if (children) { diff --git a/core/src/components/animation-controller/constants.ts b/core/src/components/animation-controller/constants.ts index ddafc093a7..91601b2592 100644 --- a/core/src/components/animation-controller/constants.ts +++ b/core/src/components/animation-controller/constants.ts @@ -1,4 +1,5 @@ +// tslint:disable-next-line:only-arrow-functions export const CSS_PROP = function(docEle: HTMLElement) { // transform const transformProp = [ diff --git a/core/src/components/animation-controller/transition-end.ts b/core/src/components/animation-controller/transition-end.ts index 830ccfa9cd..b2a25bfb17 100644 --- a/core/src/components/animation-controller/transition-end.ts +++ b/core/src/components/animation-controller/transition-end.ts @@ -1,7 +1,7 @@ -export function transitionEnd(el: HTMLElement|null, callback: {(ev?: TransitionEvent): void}) { - let unRegTrans: Function; +export function transitionEnd(el: HTMLElement | null, callback: (ev?: TransitionEvent) => void) { + let unRegTrans: () => void; const opts: any = { passive: true }; function unregister() { @@ -19,7 +19,7 @@ export function transitionEnd(el: HTMLElement|null, callback: {(ev?: TransitionE el.addEventListener('webkitTransitionEnd', onTransitionEnd, opts); el.addEventListener('transitionend', onTransitionEnd, opts); - unRegTrans = function() { + unRegTrans = () => { el.removeEventListener('webkitTransitionEnd', onTransitionEnd, opts); el.removeEventListener('transitionend', onTransitionEnd, opts); }; diff --git a/core/src/components/backdrop/backdrop.tsx b/core/src/components/backdrop/backdrop.tsx index 29a2d47bb9..3cee969072 100644 --- a/core/src/components/backdrop/backdrop.tsx +++ b/core/src/components/backdrop/backdrop.tsx @@ -43,13 +43,13 @@ export class Backdrop { unregisterBackdrop(this.doc, this); } - @Listen('touchstart', {passive: false, capture: true}) + @Listen('touchstart', { passive: false, capture: true }) protected onTouchStart(ev: TouchEvent) { this.lastClick = now(ev); this.emitTap(ev); } - @Listen('mousedown', {passive: false, capture: true}) + @Listen('mousedown', { passive: false, capture: true }) protected onMouseDown(ev: TouchEvent) { if (this.lastClick < now(ev) - 2500) { this.emitTap(ev); diff --git a/core/src/components/button/button.tsx b/core/src/components/button/button.tsx index 28d6114be3..27c55b2f67 100644 --- a/core/src/components/button/button.tsx +++ b/core/src/components/button/button.tsx @@ -46,14 +46,14 @@ export class Button { * Set to `"block"` for a full-width button or to `"full"` for a full-width button * without left and right borders. */ - @Prop({reflectToAttr: true}) expand?: 'full' | 'block'; + @Prop({ reflectToAttr: true }) expand?: 'full' | 'block'; /** * Set to `"clear"` for a transparent button, to `"outline"` for a transparent * button with a border, or to `"solid"`. The default style is `"solid"` except inside of * a toolbar, where the default is `"clear"`. */ - @Prop({reflectToAttr: true, mutable: true}) fill?: 'clear' | 'outline' | 'solid' | 'default'; + @Prop({ reflectToAttr: true, mutable: true }) fill?: 'clear' | 'outline' | 'solid' | 'default'; /** * When using a router, it specifies the transition direction when navigating to @@ -71,13 +71,13 @@ export class Button { * The button shape. * Possible values are: `"round"`. */ - @Prop({reflectToAttr: true}) shape?: 'round'; + @Prop({ reflectToAttr: true }) shape?: 'round'; /** * The button size. * Possible values are: `"small"`, `"default"`, `"large"`. */ - @Prop({reflectToAttr: true}) size?: 'small' | 'default' | 'large'; + @Prop({ reflectToAttr: true }) size?: 'small' | 'default' | 'large'; /** * If true, activates a button with a heavier font weight. @@ -210,7 +210,7 @@ function getButtonClassMap(buttonType: string | undefined, mode: Mode): CssClass * Get the classes based on the type * e.g. block, full, round, large */ -function getButtonTypeClassMap(buttonType: string, type: string|undefined, mode: Mode): CssClassMap { +function getButtonTypeClassMap(buttonType: string, type: string | undefined, mode: Mode): CssClassMap { if (!type) { return {}; } diff --git a/core/src/components/content/content.tsx b/core/src/components/content/content.tsx index fac47d0ea9..cfefe165f0 100644 --- a/core/src/components/content/content.tsx +++ b/core/src/components/content/content.tsx @@ -133,7 +133,7 @@ export class Content { } function getParentElement(el: any) { - if (el.parentElement ) { + if (el.parentElement) { // normal element with a parent element return el.parentElement; } diff --git a/core/src/components/datetime/datetime-util.ts b/core/src/components/datetime/datetime-util.ts index 90975c1b61..e6f5da6631 100644 --- a/core/src/components/datetime/datetime-util.ts +++ b/core/src/components/datetime/datetime-util.ts @@ -33,7 +33,7 @@ export function renderDatetime(template: string, value: DatetimeData, locale: Lo } -export function renderTextFormat(format: string, value: any, date: DatetimeData|null, locale: LocaleData): string { +export function renderTextFormat(format: string, value: any, date: DatetimeData | null, locale: LocaleData): string { if ((format === FORMAT_DDDD || format === FORMAT_DDD)) { try { @@ -153,7 +153,7 @@ export function dateValueRange(format: string, min: DatetimeData, max: DatetimeD return opts; } -export function dateSortValue(year: number|undefined, month: number|undefined, day: number|undefined, hour = 0, minute = 0): number { +export function dateSortValue(year: number | undefined, month: number | undefined, day: number | undefined, hour = 0, minute = 0): number { return parseInt(`1${fourDigit(year)}${twoDigit(month)}${twoDigit(day)}${twoDigit(hour)}${twoDigit(minute)}`, 10); } @@ -176,10 +176,10 @@ export function isLeapYear(year: number): boolean { const ISO_8601_REGEXP = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/; const TIME_REGEXP = /^((\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/; -export function parseDate(val: any): DatetimeData|null { +export function parseDate(val: any): DatetimeData | null { // manually parse IS0 cuz Date.parse cannot be trusted // ISO 8601 format: 1994-12-15T13:47:20Z - let parse: any[]|null = null; + let parse: any[] | null = null; if (val && val !== '') { // try parsing for just time first, HH:MM @@ -227,7 +227,7 @@ export function parseDate(val: any): DatetimeData|null { minute: parse[5], second: parse[6], millisecond: parse[7], - tzOffset: tzOffset, + tzOffset, }; } @@ -323,7 +323,7 @@ export function getValueFromFormat(date: DatetimeData, format: string) { } -export function convertFormatToKey(format: string): string|null { +export function convertFormatToKey(format: string): string | null { for (const k in FORMAT_KEYS) { if (FORMAT_KEYS[k].f === format) { return FORMAT_KEYS[k].k; @@ -395,7 +395,7 @@ export function convertDataToISO(data: DatetimeData): string { * Use to convert a string of comma separated strings or * an array of strings, and clean up any user input */ -export function convertToArrayOfStrings(input: string | string[] | undefined | null, type: string): string[]|undefined { +export function convertToArrayOfStrings(input: string | string[] | undefined | null, type: string): string[] | undefined { if (!input) { return undefined; } @@ -406,7 +406,7 @@ export function convertToArrayOfStrings(input: string | string[] | undefined | n input = input.replace(/\[|\]/g, '').split(','); } - let values: string[] | undefined = undefined; + let values: string[] | undefined; if (Array.isArray(input)) { // trim up each string value values = input.map(val => val.toString().trim()); diff --git a/core/src/components/datetime/datetime.tsx b/core/src/components/datetime/datetime.tsx index 7dd3be4a92..dae1acc4ff 100644 --- a/core/src/components/datetime/datetime.tsx +++ b/core/src/components/datetime/datetime.tsx @@ -266,7 +266,7 @@ export class Datetime { if (this.disabled) { return; } - const pickerOptions = {...this.pickerOptions}; + const pickerOptions = { ...this.pickerOptions }; this.picker = await this.buildPicker(pickerOptions); this.validate(); await this.picker!.present(); @@ -465,12 +465,12 @@ export class Datetime { let indexMax = 0; for (let i = 0; i < options.length; i++) { - const opt = options[i]; - const value = opt.value; - lb[index] = opt.value; - ub[index] = opt.value; + const opts = options[i]; + const value = opts.value; + lb[index] = opts.value; + ub[index] = opts.value; - const disabled = opt.disabled = ( + const disabled = opts.disabled = ( value < lowerBounds[index] || value > upperBounds[index] || dateSortValue(ub[0], ub[1], ub[2], ub[3], ub[4]) < min || diff --git a/core/src/components/gesture-controller/test/gesture-controller.spec.tsx b/core/src/components/gesture-controller/test/gesture-controller.spec.tsx index 51df2fde0f..08e1bf80db 100644 --- a/core/src/components/gesture-controller/test/gesture-controller.spec.tsx +++ b/core/src/components/gesture-controller/test/gesture-controller.spec.tsx @@ -125,9 +125,9 @@ describe('gesture controller', () => { it('should test if several gestures can be started', async () => { const c = new GestureController(); - const g1 = await c.create({name: 'swipe' }); - const g2 = await c.create({name: 'swipe1', priority: 3}); - const g3 = await c.create({name: 'swipe2', priority: 4}); + const g1 = await c.create({ name: 'swipe' }); + const g2 = await c.create({ name: 'swipe1', priority: 3 }); + const g3 = await c.create({ name: 'swipe2', priority: 4 }); for (let i = 0; i < 10; i++) { expect(g1.start()).toEqual(true); @@ -162,11 +162,11 @@ describe('gesture controller', () => { it('should test if several gestures try to capture at the same time', async () => { const c = new GestureController(); - const g1 = await c.create({name: 'swipe1'}); - const g2 = await c.create({name: 'swipe2', priority: 2 }); - const g3 = await c.create({name: 'swipe3', priority: 3 }); - const g4 = await c.create({name: 'swipe4', priority: 4 }); - const g5 = await c.create({name: 'swipe5', priority: 5 }); + const g1 = await c.create({ name: 'swipe1' }); + const g2 = await c.create({ name: 'swipe2', priority: 2 }); + const g3 = await c.create({ name: 'swipe3', priority: 3 }); + const g4 = await c.create({ name: 'swipe4', priority: 4 }); + const g5 = await c.create({ name: 'swipe5', priority: 5 }); // Low priority capture() returns false expect(g2.start()).toEqual(true); diff --git a/core/src/components/gesture/gesture-interface.ts b/core/src/components/gesture/gesture-interface.ts index 66ea937f99..1a8d0073f2 100644 --- a/core/src/components/gesture/gesture-interface.ts +++ b/core/src/components/gesture/gesture-interface.ts @@ -15,6 +15,4 @@ export interface GestureDetail { data?: any; } -export interface GestureCallback { - (detail?: GestureDetail): boolean|void; -} +export type GestureCallback = (detail?: GestureDetail) => boolean | void; diff --git a/core/src/components/infinite-scroll/infinite-scroll.tsx b/core/src/components/infinite-scroll/infinite-scroll.tsx index e808aef413..c63924a46d 100644 --- a/core/src/components/infinite-scroll/infinite-scroll.tsx +++ b/core/src/components/infinite-scroll/infinite-scroll.tsx @@ -92,7 +92,7 @@ export class InfiniteScroll { this.scrollEl = undefined; } - @Listen('scroll', {enabled: false}) + @Listen('scroll', { enabled: false }) protected onScroll() { const scrollEl = this.scrollEl; if (!scrollEl || !this.canStart()) { diff --git a/core/src/components/input/input.tsx b/core/src/components/input/input.tsx index e9dad754cf..5c9f362eed 100644 --- a/core/src/components/input/input.tsx +++ b/core/src/components/input/input.tsx @@ -1,5 +1,5 @@ import { Component, Element, Event, EventEmitter, Prop, State, Watch } from '@stencil/core'; -import { Color, InputChangeEvent, Mode, StyleEvent } from '../../interface'; +import { Color, InputChangeEvent, Mode, StyleEvent } from '../../interface'; import { debounceEvent, deferEvent, renderHiddenInput } from '../../utils/helpers'; import { createColorClasses, hostContext } from '../../utils/theme'; import { InputComponent } from './input-base'; @@ -224,7 +224,7 @@ export class Input implements InputComponent { inputEl.value = value; } this.emitStyle(); - this.ionChange.emit({value}); + this.ionChange.emit({ value }); } componentWillLoad() { diff --git a/core/src/components/item-sliding/item-sliding.tsx b/core/src/components/item-sliding/item-sliding.tsx index 2516c3462c..56606c6e50 100644 --- a/core/src/components/item-sliding/item-sliding.tsx +++ b/core/src/components/item-sliding/item-sliding.tsx @@ -29,14 +29,14 @@ const enum SlidingState { }) export class ItemSliding { - private item: HTMLIonItemElement|null = null; - private list: HTMLIonListElement|null = null; + private item: HTMLIonItemElement | null = null; + private list: HTMLIonListElement | null = null; private openAmount = 0; private initialOpenAmount = 0; private optsWidthRightSide = 0; private optsWidthLeftSide = 0; private sides = ItemSide.None; - private tmr: number|undefined; + private tmr: number | undefined; private leftOptions?: HTMLIonItemOptionsElement; private rightOptions?: HTMLIonItemOptionsElement; private optsDirty = true; diff --git a/core/src/components/item/item.tsx b/core/src/components/item/item.tsx index a08a8d4078..84d4eb54c4 100644 --- a/core/src/components/item/item.tsx +++ b/core/src/components/item/item.tsx @@ -143,7 +143,7 @@ export class Item { const clickable = this.isClickable(); const TagType = clickable ? (href ? 'a' : 'button') : 'div'; - const attrs = TagType === 'button' ? { type: type } : { href }; + const attrs = TagType === 'button' ? { type } : { href }; const showDetail = detail != null ? detail : mode === 'ios' && clickable; return ( diff --git a/core/src/components/loading/animations/ios.enter.ts b/core/src/components/loading/animations/ios.enter.ts index f3f8001152..a353118383 100644 --- a/core/src/components/loading/animations/ios.enter.ts +++ b/core/src/components/loading/animations/ios.enter.ts @@ -4,13 +4,13 @@ import { Animation } from '../../../interface'; /** * iOS Loading Enter Animation */ -export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.loading-wrapper')); backdropAnimation.fromTo('opacity', 0.01, 0.3); diff --git a/core/src/components/loading/animations/ios.leave.ts b/core/src/components/loading/animations/ios.leave.ts index 5d8901190c..e7c99e8ef0 100644 --- a/core/src/components/loading/animations/ios.leave.ts +++ b/core/src/components/loading/animations/ios.leave.ts @@ -4,13 +4,13 @@ import { Animation } from '../../../interface'; /** * iOS Loading Leave Animation */ -export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function iosLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.loading-wrapper')); backdropAnimation.fromTo('opacity', 0.3, 0); diff --git a/core/src/components/loading/animations/md.enter.ts b/core/src/components/loading/animations/md.enter.ts index 86bcc2875e..92b258c612 100644 --- a/core/src/components/loading/animations/md.enter.ts +++ b/core/src/components/loading/animations/md.enter.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * Md Loading Enter Animation */ -export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.loading-wrapper')); backdropAnimation.fromTo('opacity', 0.01, 0.5); diff --git a/core/src/components/loading/animations/md.leave.ts b/core/src/components/loading/animations/md.leave.ts index 312b2c1260..dd363ffd82 100644 --- a/core/src/components/loading/animations/md.leave.ts +++ b/core/src/components/loading/animations/md.leave.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * Md Loading Leave Animation */ -export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function mdLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.loading-wrapper')); backdropAnimation.fromTo('opacity', 0.5, 0); diff --git a/core/src/components/loading/loading.tsx b/core/src/components/loading/loading.tsx index 3f065caa46..8f9b68c321 100644 --- a/core/src/components/loading/loading.tsx +++ b/core/src/components/loading/loading.tsx @@ -78,7 +78,7 @@ export class Loading implements OverlayInterface { * The name of the spinner to display. Possible values are: `"lines"`, `"lines-small"`, `"dots"`, * `"bubbles"`, `"circles"`, `"crescent"`. */ - @Prop({mutable: true}) spinner?: string; + @Prop({ mutable: true }) spinner?: string; /** * If true, the loading indicator will be translucent. Defaults to `false`. @@ -144,7 +144,7 @@ export class Loading implements OverlayInterface { */ @Method() async present(): Promise { - await present( this, 'loadingEnter', iosEnterAnimation, mdEnterAnimation, undefined); + await present(this, 'loadingEnter', iosEnterAnimation, mdEnterAnimation, undefined); if (this.duration) { this.durationTimeout = setTimeout( diff --git a/core/src/components/menu-controller/animations/base.ts b/core/src/components/menu-controller/animations/base.ts index 3fc1817e96..80430f9e7d 100644 --- a/core/src/components/menu-controller/animations/base.ts +++ b/core/src/components/menu-controller/animations/base.ts @@ -6,7 +6,7 @@ import { Animation } from '../../../interface'; * type will provide their own animations for open and close * and registers itself with Menu. */ -export function baseAnimation(Animation: Animation): Promise { +export function baseAnimation(AnimationC: Animation): Promise { // https://material.io/guidelines/motion/movement.html#movement-movement-in-out-of-screen-bounds // https://material.io/guidelines/motion/duration-easing.html#duration-easing-natural-easing-curves @@ -14,7 +14,7 @@ export function baseAnimation(Animation: Animation): Promise { // from the same exit point. When they return, use the deceleration curve. On mobile, // this transition typically occurs over 300ms" -- MD Motion Guide return Promise.resolve( - new Animation() + new AnimationC() .easing('cubic-bezier(0.0, 0.0, 0.2, 1)') // Deceleration curve (Entering the screen) .easingReverse('cubic-bezier(0.4, 0.0, 0.6, 1)') // Sharp curve (Temporarily leaving the screen) .duration(300)); diff --git a/core/src/components/menu-controller/animations/overlay.ts b/core/src/components/menu-controller/animations/overlay.ts index f91eb87f4b..6bed0d3f3e 100644 --- a/core/src/components/menu-controller/animations/overlay.ts +++ b/core/src/components/menu-controller/animations/overlay.ts @@ -8,7 +8,7 @@ const BOX_SHADOW_WIDTH = 8; * The menu slides over the content. The content * itself, which is under the menu, does not move. */ -export function menuOverlayAnimation(Animation: Animation, _: HTMLElement, menu: Menu): Promise { +export function menuOverlayAnimation(AnimationC: Animation, _: HTMLElement, menu: Menu): Promise { let closedX: string, openedX: string; const width = menu.width + BOX_SHADOW_WIDTH; if (menu.isEndSide) { @@ -22,15 +22,15 @@ export function menuOverlayAnimation(Animation: Animation, _: HTMLElement, menu: openedX = '0px'; } - const menuAni = new Animation() + const menuAni = new AnimationC() .addElement(menu.menuInnerEl) .fromTo('translateX', closedX, openedX); - const backdropAni = new Animation() + const backdropAni = new AnimationC() .addElement(menu.backdropEl) .fromTo('opacity', 0.01, 0.3); - return baseAnimation(Animation).then(animation => { + return baseAnimation(AnimationC).then(animation => { return animation.add(menuAni) .add(backdropAni); }); diff --git a/core/src/components/menu-controller/animations/push.ts b/core/src/components/menu-controller/animations/push.ts index fcd071cf43..feb7af96c4 100644 --- a/core/src/components/menu-controller/animations/push.ts +++ b/core/src/components/menu-controller/animations/push.ts @@ -7,7 +7,7 @@ import { baseAnimation } from './base'; * The content slides over to reveal the menu underneath. * The menu itself also slides over to reveal its bad self. */ -export function menuPushAnimation(Animation: Animation, _: HTMLElement, menu: Menu): Promise { +export function menuPushAnimation(AnimationC: Animation, _: HTMLElement, menu: Menu): Promise { let contentOpenedX: string, menuClosedX: string; const width = menu.width; @@ -20,19 +20,19 @@ export function menuPushAnimation(Animation: Animation, _: HTMLElement, menu: Me contentOpenedX = width + 'px'; menuClosedX = -width + 'px'; } - const menuAni = new Animation() + const menuAni = new AnimationC() .addElement(menu.menuInnerEl) .fromTo('translateX', menuClosedX, '0px'); - const contentAni = new Animation() + const contentAni = new AnimationC() .addElement(menu.contentEl) .fromTo('translateX', '0px', contentOpenedX); - const backdropAni = new Animation() + const backdropAni = new AnimationC() .addElement(menu.backdropEl) .fromTo('opacity', 0.01, 0.2); - return baseAnimation(Animation).then((animation) => { + return baseAnimation(AnimationC).then((animation) => { return animation.add(menuAni) .add(backdropAni) .add(contentAni); diff --git a/core/src/components/menu-controller/animations/reveal.ts b/core/src/components/menu-controller/animations/reveal.ts index 626e54f55c..721031cf3d 100644 --- a/core/src/components/menu-controller/animations/reveal.ts +++ b/core/src/components/menu-controller/animations/reveal.ts @@ -7,14 +7,14 @@ import { baseAnimation } from './base'; * The content slides over to reveal the menu underneath. * The menu itself, which is under the content, does not move. */ -export function menuRevealAnimation(Animation: Animation, _: HTMLElement, menu: Menu): Promise { +export function menuRevealAnimation(AnimationC: Animation, _: HTMLElement, menu: Menu): Promise { const openedX = (menu.width * (menu.isEndSide ? -1 : 1)) + 'px'; - const contentOpen = new Animation() + const contentOpen = new AnimationC() .addElement(menu.contentEl) .fromTo('translateX', '0px', openedX); - return baseAnimation(Animation).then(animation => { + return baseAnimation(AnimationC).then(animation => { return animation.add(contentOpen); }); } diff --git a/core/src/components/menu-controller/menu-controller.ts b/core/src/components/menu-controller/menu-controller.ts index 5ceb826de3..c5d4c11bf1 100644 --- a/core/src/components/menu-controller/menu-controller.ts +++ b/core/src/components/menu-controller/menu-controller.ts @@ -1,4 +1,4 @@ -import { Component, Method, Prop } from '@stencil/core'; +import { Build, Component, Method, Prop } from '@stencil/core'; import { Animation, AnimationBuilder, Menu } from '../../interface'; import { menuOverlayAnimation } from './animations/overlay'; @@ -119,20 +119,22 @@ export class MenuController { */ @Method() get(menuId?: string): HTMLIonMenuElement | null { - if (menuId === 'left') { - console.error('menu.side=left is deprecated, use "start" instead'); - return null; - } - if (menuId === 'right') { - console.error('menu.side=right is deprecated, use "end" instead'); - return null; + if (Build.isDev) { + if (menuId === 'left') { + console.error('menu.side=left is deprecated, use "start" instead'); + return null; + } + if (menuId === 'right') { + console.error('menu.side=right is deprecated, use "end" instead'); + return null; + } } if (menuId === 'start' || menuId === 'end') { // there could be more than one menu on the same side // so first try to get the enabled one - const menu = this.find(m => m.side === menuId && !m.disabled); - if (menu) { - return menu; + const menuRef = this.find(m => m.side === menuId && !m.disabled); + if (menuRef) { + return menuRef; } // didn't find a menu side that is enabled diff --git a/core/src/components/menu-toggle/menu-toggle.tsx b/core/src/components/menu-toggle/menu-toggle.tsx index acb19a2dff..06b34b5925 100644 --- a/core/src/components/menu-toggle/menu-toggle.tsx +++ b/core/src/components/menu-toggle/menu-toggle.tsx @@ -68,7 +68,7 @@ export class MenuToggle { } } -function getMenuController(doc: Document): Promise { +function getMenuController(doc: Document): Promise { const menuControllerElement = doc.querySelector('ion-menu-controller'); if (!menuControllerElement) { return Promise.resolve(undefined); diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index f0e73f1c26..7048196b62 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -1,6 +1,6 @@ import { Component, Element, Event, EventEmitter, EventListenerEnable, Listen, Method, Prop, State, Watch } from '@stencil/core'; import { Animation, Config, GestureDetail, MenuChangeEventDetail, Mode, Side } from '../../interface'; -import { assert, isEndSide } from '../../utils/helpers'; +import { assert, isEndSide as isEnd } from '../../utils/helpers'; @Component({ tag: 'ion-menu', @@ -75,7 +75,7 @@ export class Menu { @Watch('disabled') protected disabledChanged(disabled: boolean) { this.updateState(); - this.ionMenuChange.emit({ disabled: disabled, open: this._isOpen }); + this.ionMenuChange.emit({ disabled, open: this._isOpen }); } /** @@ -85,7 +85,7 @@ export class Menu { @Watch('side') protected sideChanged() { - this.isEndSide = isEndSide(this.win, this.side); + this.isEndSide = isEnd(this.win, this.side); } /** diff --git a/core/src/components/modal/animations/ios.enter.ts b/core/src/components/modal/animations/ios.enter.ts index 29790faf07..392d45ed57 100644 --- a/core/src/components/modal/animations/ios.enter.ts +++ b/core/src/components/modal/animations/ios.enter.ts @@ -4,13 +4,13 @@ import { Animation } from '../../../interface'; /** * iOS Modal Enter Animation */ -export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.modal-wrapper')); wrapperAnimation.beforeStyles({ 'opacity': 1 }) diff --git a/core/src/components/modal/animations/ios.leave.ts b/core/src/components/modal/animations/ios.leave.ts index 8bdcd2b1d1..580ac3b10a 100644 --- a/core/src/components/modal/animations/ios.leave.ts +++ b/core/src/components/modal/animations/ios.leave.ts @@ -4,13 +4,13 @@ import { Animation } from '../../../interface'; /** * iOS Modal Leave Animation */ -export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function iosLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); const wrapperEl = baseEl.querySelector('.modal-wrapper'); wrapperAnimation.addElement(wrapperEl); const wrapperElRect = wrapperEl!.getBoundingClientRect(); diff --git a/core/src/components/modal/animations/md.enter.ts b/core/src/components/modal/animations/md.enter.ts index 6109a53f6a..e8ef77ed15 100644 --- a/core/src/components/modal/animations/md.enter.ts +++ b/core/src/components/modal/animations/md.enter.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * Md Modal Enter Animation */ -export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); wrapperAnimation.addElement(baseEl.querySelector('.modal-wrapper')); wrapperAnimation diff --git a/core/src/components/modal/animations/md.leave.ts b/core/src/components/modal/animations/md.leave.ts index 87ad21362a..0e8bd9c09b 100644 --- a/core/src/components/modal/animations/md.leave.ts +++ b/core/src/components/modal/animations/md.leave.ts @@ -3,13 +3,13 @@ import { Animation } from '../../../interface'; /** * Md Modal Leave Animation */ -export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise { - const baseAnimation = new Animation(); +export function mdLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement): Promise { + const baseAnimation = new AnimationC(); - const backdropAnimation = new Animation(); + const backdropAnimation = new AnimationC(); backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')); - const wrapperAnimation = new Animation(); + const wrapperAnimation = new AnimationC(); const wrapperEl = baseEl.querySelector('.modal-wrapper'); wrapperAnimation.addElement(wrapperEl); diff --git a/core/src/components/modal/modal.tsx b/core/src/components/modal/modal.tsx index e29adae5e1..f6e938ae64 100644 --- a/core/src/components/modal/modal.tsx +++ b/core/src/components/modal/modal.tsx @@ -22,7 +22,7 @@ export class Modal implements OverlayInterface { private usersElement?: HTMLElement; - animation: Animation|undefined; + animation: Animation | undefined; presented = false; mode!: Mode; @@ -89,22 +89,22 @@ export class Modal implements OverlayInterface { /** * Emitted after the modal has presented. */ - @Event({eventName: 'ionModalDidPresent'}) didPresent!: EventEmitter; + @Event({ eventName: 'ionModalDidPresent' }) didPresent!: EventEmitter; /** * Emitted before the modal has presented. */ - @Event({eventName: 'ionModalWillPresent'}) willPresent!: EventEmitter; + @Event({ eventName: 'ionModalWillPresent' }) willPresent!: EventEmitter; /** * Emitted before the modal has dismissed. */ - @Event({eventName: 'ionModalWillDismiss'}) willDismiss!: EventEmitter; + @Event({ eventName: 'ionModalWillDismiss' }) willDismiss!: EventEmitter; /** * Emitted after the modal has dismissed. */ - @Event({eventName: 'ionModalDidDismiss'}) didDismiss!: EventEmitter; + @Event({ eventName: 'ionModalDidDismiss' }) didDismiss!: EventEmitter; componentDidLoad() { this.ionModalDidLoad.emit(); diff --git a/core/src/components/nav/nav-interface.ts b/core/src/components/nav/nav-interface.ts index de70e99837..ee593b5cba 100644 --- a/core/src/components/nav/nav-interface.ts +++ b/core/src/components/nav/nav-interface.ts @@ -37,20 +37,14 @@ export interface Page extends Function { new (...args: any[]): any; } -export interface TransitionResolveFn { - (hasCompleted: boolean, requiresTransition: boolean, enteringName?: string, leavingName?: string, direction?: string): void; -} +export type TransitionResolveFn = (hasCompleted: boolean, requiresTransition: boolean, enteringName?: string, leavingName?: string, direction?: string) => void; -export interface TransitionRejectFn { - (rejectReason: any, transition?: Animation): void; -} +export type TransitionRejectFn = (rejectReason: any, transition?: Animation) => void; -export interface TransitionDoneFn { - (hasCompleted: boolean, requiresTransition: boolean, enteringView?: ViewController, leavingView?: ViewController, direction?: string): void; -} +export type TransitionDoneFn = (hasCompleted: boolean, requiresTransition: boolean, enteringView?: ViewController, leavingView?: ViewController, direction?: string) => void; export interface TransitionInstruction { - opts: NavOptions|undefined|null; + opts: NavOptions | undefined | null; insertStart?: number; insertViews?: any[]; removeView?: ViewController; diff --git a/core/src/components/nav/nav.tsx b/core/src/components/nav/nav.tsx index cbd0474672..a727f43425 100644 --- a/core/src/components/nav/nav.tsx +++ b/core/src/components/nav/nav.tsx @@ -127,7 +127,7 @@ export class Nav implements NavOutlet { { insertStart: -1, insertViews: [{ page: component, params: componentProps }], - opts: opts + opts }, done ); @@ -148,7 +148,7 @@ export class Nav implements NavOutlet { { insertStart: insertIndex, insertViews: [{ page: component, params: componentProps }], - opts: opts + opts }, done ); @@ -168,7 +168,7 @@ export class Nav implements NavOutlet { { insertStart: insertIndex, insertViews: insertComponents, - opts: opts + opts }, done ); @@ -183,7 +183,7 @@ export class Nav implements NavOutlet { { removeStart: -1, removeCount: 1, - opts: opts + opts }, done ); @@ -201,7 +201,7 @@ export class Nav implements NavOutlet { const config: TransitionInstruction = { removeStart: -1, removeCount: -1, - opts: opts + opts }; if (typeof indexOrViewCtrl === 'object' && (indexOrViewCtrl as ViewController).component) { config.removeView = indexOrViewCtrl; @@ -224,7 +224,7 @@ export class Nav implements NavOutlet { { removeStart: 1, removeCount: -1, - opts: opts + opts }, done ); @@ -243,8 +243,8 @@ export class Nav implements NavOutlet { return this.queueTrns( { removeStart: startIndex, - removeCount: removeCount, - opts: opts + removeCount, + opts }, done ); @@ -289,7 +289,7 @@ export class Nav implements NavOutlet { insertViews: views, removeStart: 0, removeCount: -1, - opts: opts + opts }, done ); @@ -316,8 +316,8 @@ export class Nav implements NavOutlet { const commonOpts: NavOptions = { updateURL: false, viewIsReady: enteringEl => { - let mark: Function; - const p = new Promise(r => (mark = r)); + let mark: () => void; + const p = new Promise(r => (mark = r)); resolve({ changed: true, element: enteringEl, @@ -663,7 +663,7 @@ export class Nav implements NavOutlet { const insertViews = ti.insertViews; const removeStart = ti.removeStart; const removeCount = ti.removeCount; - let destroyQueue: ViewController[] | undefined = undefined; + let destroyQueue: ViewController[] | undefined; // there are views to remove if (removeStart != null && removeCount != null) { @@ -772,12 +772,12 @@ export class Nav implements NavOutlet { } private transitionFinish( - transition: Animation | null, + trans: Animation | null, enteringView: ViewController, leavingView: ViewController | undefined, opts: NavOptions ): NavResult { - const hasCompleted = transition ? transition.hasCompleted : true; + const hasCompleted = trans ? trans.hasCompleted : true; const cleanupView = hasCompleted ? enteringView : leavingView; if (cleanupView) { @@ -786,10 +786,10 @@ export class Nav implements NavOutlet { // this is the root transition // it's safe to destroy this transition - transition && transition.destroy(); + trans && trans.destroy(); return { - hasCompleted: hasCompleted, + hasCompleted, requiresTransition: true, enteringView, leavingView, @@ -879,7 +879,7 @@ export class Nav implements NavOutlet { { removeStart: -1, removeCount: 1, - opts: opts + opts }, undefined ); diff --git a/core/src/components/nav/test/nav-controller.spec.ts b/core/src/components/nav/test/nav-controller.spec.ts index d37834512b..6e3477810d 100644 --- a/core/src/components/nav/test/nav-controller.spec.ts +++ b/core/src/components/nav/test/nav-controller.spec.ts @@ -22,7 +22,7 @@ describe('NavController', () => { // Push 1 const view1 = mockView(MockView1); - await nav.push(view1, null, {animated: false}, push1Done); + await nav.push(view1, null, { animated: false }, push1Done); const hasCompleted = true; const requiresTransition = true; @@ -34,7 +34,7 @@ describe('NavController', () => { // Push 2 const view2 = mockView(MockView2); - await nav.push(view2, null, {animated: false}, push2Done); + await nav.push(view2, null, { animated: false }, push2Done); expect(push2Done).toHaveBeenCalledWith( hasCompleted, requiresTransition, view2, view1, 'forward' @@ -46,7 +46,7 @@ describe('NavController', () => { // Push 3 const view3 = mockView(MockView3); - await nav.push(view3, null, {animated: false}, push3Done); + await nav.push(view3, null, { animated: false }, push3Done); expect(push3Done).toHaveBeenCalledWith( hasCompleted, requiresTransition, view3, view2, 'forward' @@ -58,7 +58,7 @@ describe('NavController', () => { // Push 4 const view4 = mockView(MockView4); - await nav.push(view4, null, {animated: false}, push4Done); + await nav.push(view4, null, { animated: false }, push4Done); expect(push4Done).toHaveBeenCalledWith( hasCompleted, requiresTransition, view4, view3, 'forward' ); @@ -69,7 +69,7 @@ describe('NavController', () => { expect(nav.getByIndex(3)!.component).toEqual(MockView4); // Pop 1 - await nav.pop({animated: false}, pop1Done); + await nav.pop({ animated: false }, pop1Done); expect(pop1Done).toHaveBeenCalledWith( hasCompleted, requiresTransition, view3, view4, 'back' ); @@ -79,7 +79,7 @@ describe('NavController', () => { expect(nav.getByIndex(2)!.component).toEqual(MockView3); // Pop 2 - await nav.pop({animated: false}, pop2Done); + await nav.pop({ animated: false }, pop2Done); expect(pop2Done).toHaveBeenCalledWith( hasCompleted, requiresTransition, view2, view3, 'back' ); @@ -88,7 +88,7 @@ describe('NavController', () => { expect(nav.getByIndex(1)!.component).toEqual(MockView2); // Pop 3 - await nav.pop({animated: false}, pop3Done); + await nav.pop({ animated: false }, pop3Done); expect(pop3Done).toHaveBeenCalledWith( hasCompleted, requiresTransition, view1, view2, 'back' ); @@ -830,11 +830,10 @@ describe('NavController', () => { const view4 = mockView(MockView4); const view5 = mockView(MockView5); - await nav.setPages([{ - page: view4 - }, { - page: view5 - }], null, trnsDone); + await nav.setPages([ + { page: view4 }, + { page: view5 } + ], null, trnsDone); expect(instance1.ionViewWillUnload).toHaveBeenCalled(); expect(instance2.ionViewWillUnload).toHaveBeenCalled(); @@ -941,25 +940,25 @@ describe('NavController', () => { return view; } - function mockViews(nav: Nav, views: ViewController[]) { - nav['views'] = views; + function mockViews(navI: Nav, views: ViewController[]) { + navI['views'] = views; views.forEach(v => { - v.nav = nav; + v.nav = navI; }); } function mockNavController(): Nav { - const nav = new Nav() as any; - nav.animated = false; - nav.el = win.document.createElement('ion-nav'); - nav.win = win; - nav.queue = { write: (fn: any) => fn(), read: (fn: any) => fn()}; - nav.ionNavDidChange = {emit: function() { return; } }; - nav.ionNavWillChange = {emit: function() { return; } }; + const navI = new Nav() as any; + navI.animated = false; + navI.el = win.document.createElement('ion-nav'); + navI.win = win; + navI.queue = { write: (fn: any) => fn(), read: (fn: any) => fn() }; + navI.ionNavDidChange = { emit() { return; } }; + navI.ionNavWillChange = { emit() { return; } }; - nav.animationCtrl = new AnimationControllerImpl() as any; - nav.config = new Config({animated: false}); - nav._viewInit = function (enteringView: ViewController) { + navI.animationCtrl = new AnimationControllerImpl() as any; + navI.config = new Config({ animated: false }); + navI._viewInit = (enteringView: ViewController) => { if (!enteringView.element) { console.log(enteringView.component); enteringView.element = (typeof enteringView.component === 'string') @@ -968,7 +967,7 @@ describe('NavController', () => { } enteringView.state = ViewState.Attached; }; - return nav; + return navI; } }); diff --git a/core/src/components/nav/view-controller.ts b/core/src/components/nav/view-controller.ts index f9c7b11bb2..c9995d62ee 100644 --- a/core/src/components/nav/view-controller.ts +++ b/core/src/components/nav/view-controller.ts @@ -53,7 +53,7 @@ export class ViewController { } } -export function matches(view: ViewController|undefined, id: string, params: ComponentProps): view is ViewController { +export function matches(view: ViewController | undefined, id: string, params: ComponentProps): view is ViewController { if (!view) { return false; } @@ -86,7 +86,7 @@ export function matches(view: ViewController|undefined, id: string, params: Comp return true; } -export function convertToView(page: any, params: any): ViewController|null { +export function convertToView(page: any, params: any): ViewController | null { if (!page) { return null; } diff --git a/core/src/components/picker-column/picker-column.tsx b/core/src/components/picker-column/picker-column.tsx index 41fb26d200..263327a8bb 100644 --- a/core/src/components/picker-column/picker-column.tsx +++ b/core/src/components/picker-column/picker-column.tsx @@ -407,7 +407,7 @@ export class PickerColumnCmp { if (col.prefix) { results.push( -
+
{col.prefix}
); @@ -426,10 +426,10 @@ export class PickerColumnCmp { threshold={0} attachTo="parent" >, -
+
{options.map((o, index) =>