mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
fix(ts): ts strict fixes
This commit is contained in:
8
packages/core/src/components.d.ts
vendored
8
packages/core/src/components.d.ts
vendored
@ -315,7 +315,7 @@ declare global {
|
||||
namespace JSXElements {
|
||||
export interface IonBackButtonAttributes extends HTMLAttributes {
|
||||
mode?: 'ios' | 'md';
|
||||
text?: string;
|
||||
text?: string|undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1033,7 +1033,6 @@ declare global {
|
||||
export interface IonGestureAttributes extends HTMLAttributes {
|
||||
attachTo?: ElementRef;
|
||||
autoBlockAll?: boolean;
|
||||
block?: string;
|
||||
canStart?: GestureCallback;
|
||||
direction?: string;
|
||||
disabled?: boolean;
|
||||
@ -1712,7 +1711,6 @@ declare global {
|
||||
export interface IonMenuButtonAttributes extends HTMLAttributes {
|
||||
autoHide?: boolean;
|
||||
menu?: string;
|
||||
mode?: 'ios' | 'md';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2845,7 +2843,7 @@ declare global {
|
||||
export interface IonSelectOptionAttributes extends HTMLAttributes {
|
||||
disabled?: boolean;
|
||||
selected?: boolean;
|
||||
value?: string;
|
||||
value?: string|null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2917,7 +2915,7 @@ declare global {
|
||||
okText?: string;
|
||||
placeholder?: string;
|
||||
selectedText?: string;
|
||||
value?: string | string[];
|
||||
value?: string | string[] | null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, Element, Prop, State } from '@stencil/core';
|
||||
import { Component, Element, Prop } from '@stencil/core';
|
||||
import { Config } from '../../index';
|
||||
|
||||
@Component({
|
||||
@ -13,7 +13,7 @@ import { Config } from '../../index';
|
||||
})
|
||||
export class BackButton {
|
||||
|
||||
@State() custom: boolean;
|
||||
private custom = true;
|
||||
|
||||
/**
|
||||
* The mode determines which platform styles to use.
|
||||
@ -26,7 +26,7 @@ export class BackButton {
|
||||
* The text property is used to provide custom text for the back button while using the
|
||||
* default look-and-feel
|
||||
*/
|
||||
@Prop() text: string = null;
|
||||
@Prop() text: string|undefined;
|
||||
|
||||
@Prop({ context: 'config' }) config: Config;
|
||||
|
||||
|
@ -66,7 +66,7 @@ For more information, see [Platform Styles](/docs/theming/platform-specific-styl
|
||||
|
||||
#### text
|
||||
|
||||
string
|
||||
|
||||
|
||||
The text property is used to provide custom text for the back button while using the
|
||||
default look-and-feel
|
||||
@ -85,7 +85,7 @@ For more information, see [Platform Styles](/docs/theming/platform-specific-styl
|
||||
|
||||
#### text
|
||||
|
||||
string
|
||||
|
||||
|
||||
The text property is used to provide custom text for the back button while using the
|
||||
default look-and-feel
|
||||
|
@ -8,10 +8,10 @@ import { getPageElement } from '../../utils/helpers';
|
||||
})
|
||||
export class Content {
|
||||
|
||||
private cTop = 0;
|
||||
private cBottom = 0;
|
||||
private cTop = -1;
|
||||
private cBottom = -1;
|
||||
private dirty = false;
|
||||
private scrollEl: HTMLIonScrollElement|null;
|
||||
private scrollEl: HTMLIonScrollElement;
|
||||
|
||||
mode: string;
|
||||
color: string;
|
||||
@ -44,12 +44,11 @@ export class Content {
|
||||
}
|
||||
|
||||
componentDidLoad() {
|
||||
this.scrollEl = this.el.querySelector('ion-scroll');
|
||||
this.resize();
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
this.scrollEl = null;
|
||||
this.scrollEl = undefined as any;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +93,7 @@ export class Content {
|
||||
this.dom.write(this.writeDimensions.bind(this));
|
||||
});
|
||||
} else {
|
||||
this.cTop = this.cBottom = null;
|
||||
this.cTop = this.cBottom = -1;
|
||||
this.dom.write(() => this.scrollEl && this.scrollEl.removeAttribute('style'));
|
||||
}
|
||||
}
|
||||
@ -132,6 +131,7 @@ export class Content {
|
||||
|
||||
return [
|
||||
<ion-scroll
|
||||
ref={el => this.scrollEl = el as any}
|
||||
mode={this.mode}
|
||||
scrollEvents={this.scrollEvents}
|
||||
forceOverscroll={this.forceOverscroll}>
|
||||
|
@ -24,8 +24,10 @@ export class Fab {
|
||||
|
||||
render() {
|
||||
const fab = this.el.querySelector('ion-fab-button');
|
||||
fab.toggleActive = this.toggleActive;
|
||||
fab.activated = this.activated;
|
||||
if (fab) {
|
||||
fab.toggleActive = this.toggleActive;
|
||||
fab.activated = this.activated;
|
||||
}
|
||||
|
||||
const lists = this.el.querySelectorAll('ion-fab-list');
|
||||
for (let i = 0, length = lists.length; i < length; i += 1) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { GestureController } from './gesture-controller';
|
||||
import { GestureController } from '../..';
|
||||
|
||||
export class GestureDelegate {
|
||||
private ctrl: GestureController|null;
|
||||
private ctrl: GestureController|undefined;
|
||||
|
||||
constructor(
|
||||
ctrl: any,
|
||||
@ -54,14 +54,14 @@ export class GestureDelegate {
|
||||
|
||||
destroy() {
|
||||
this.release();
|
||||
this.ctrl = null;
|
||||
this.ctrl = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlockerDelegate {
|
||||
|
||||
private ctrl: any|null;
|
||||
private ctrl: GestureController|undefined;
|
||||
|
||||
constructor(
|
||||
private id: number,
|
||||
@ -103,7 +103,7 @@ export class BlockerDelegate {
|
||||
|
||||
destroy() {
|
||||
this.unblock();
|
||||
this.ctrl = null;
|
||||
this.ctrl = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Component, Event, EventEmitter, EventListenerEnable, Listen, Prop, Watch } from '@stencil/core';
|
||||
import { ElementRef, assert, now, updateDetail } from '../../utils/helpers';
|
||||
import { BlockerConfig, BlockerDelegate, DomController, GestureDelegate } from '../../index';
|
||||
import { BlockerDelegate, DomController, GestureDelegate } from '../../index';
|
||||
import { BLOCK_ALL } from '../gesture-controller/gesture-controller-utils';
|
||||
import { PanRecognizer } from './recognizers';
|
||||
|
||||
@ -10,7 +10,7 @@ import { PanRecognizer } from './recognizers';
|
||||
})
|
||||
export class Gesture {
|
||||
|
||||
private detail: GestureDetail = {};
|
||||
private detail: GestureDetail;
|
||||
private positions: number[] = [];
|
||||
private gesture: GestureDelegate;
|
||||
private lastTouch = 0;
|
||||
@ -20,7 +20,7 @@ export class Gesture {
|
||||
private hasStartedPan = false;
|
||||
private hasFiredStart = true;
|
||||
private isMoveQueued = false;
|
||||
private blocker: BlockerDelegate;
|
||||
private blocker: BlockerDelegate|undefined;
|
||||
|
||||
@Prop({ connect: 'ion-gesture-controller' }) gestureCtrl: HTMLIonGestureControllerElement;
|
||||
@Prop({ context: 'dom' }) dom: DomController;
|
||||
@ -29,7 +29,6 @@ export class Gesture {
|
||||
@Prop() disabled = false;
|
||||
@Prop() attachTo: ElementRef = 'child';
|
||||
@Prop() autoBlockAll = false;
|
||||
@Prop() block: string = null;
|
||||
@Prop() disableScroll = false;
|
||||
@Prop() direction = 'x';
|
||||
@Prop() gestureName = '';
|
||||
@ -72,6 +71,24 @@ export class Gesture {
|
||||
*/
|
||||
@Event() ionPress: EventEmitter;
|
||||
|
||||
constructor() {
|
||||
this.detail = {
|
||||
type: 'pan',
|
||||
startX: 0,
|
||||
startY: 0,
|
||||
startTimeStamp: 0,
|
||||
currentX: 0,
|
||||
currentY: 0,
|
||||
velocityX: 0,
|
||||
velocityY: 0,
|
||||
deltaX: 0,
|
||||
deltaY: 0,
|
||||
timeStamp: 0,
|
||||
event: undefined as any,
|
||||
data: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
componentWillLoad() {
|
||||
return this.gestureCtrl.create({
|
||||
name: this.gestureName,
|
||||
@ -94,7 +111,9 @@ export class Gesture {
|
||||
this.disabledChanged(this.disabled);
|
||||
|
||||
if (this.autoBlockAll) {
|
||||
this.setBlocker(BLOCK_ALL).then(b => b.block());
|
||||
this.gestureCtrl.componentOnReady()
|
||||
.then(ctrl => ctrl.createBlocker(BLOCK_ALL))
|
||||
.then(blocker => this.blocker = blocker);
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,23 +128,6 @@ export class Gesture {
|
||||
}
|
||||
}
|
||||
|
||||
@Watch('block')
|
||||
protected blockChanged(block: string) {
|
||||
this.setBlocker({ disable: block.split(',')});
|
||||
}
|
||||
|
||||
private setBlocker(config: BlockerConfig) {
|
||||
if (this.blocker) {
|
||||
this.blocker.destroy();
|
||||
}
|
||||
if (config) {
|
||||
return this.gestureCtrl.componentOnReady()
|
||||
.then(ctrl => ctrl.createBlocker(config))
|
||||
.then(blocker => this.blocker = blocker);
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
// DOWN *************************
|
||||
|
||||
@Listen('touchstart', { passive: true, enabled: false })
|
||||
@ -296,7 +298,7 @@ export class Gesture {
|
||||
}
|
||||
|
||||
private tryToCapturePan(): boolean {
|
||||
if (this.gesture && !this.gesture.capture()) {
|
||||
if (!this.gesture.capture()) {
|
||||
return false;
|
||||
}
|
||||
this.hasCapturedPan = true;
|
||||
@ -449,10 +451,9 @@ export class Gesture {
|
||||
componentDidUnload() {
|
||||
if (this.blocker) {
|
||||
this.blocker.destroy();
|
||||
this.blocker = null;
|
||||
this.blocker = undefined;
|
||||
}
|
||||
this.gesture && this.gesture.destroy();
|
||||
this.gesture = this.pan = this.detail = this.detail.event = null;
|
||||
this.gesture.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
@ -462,18 +463,18 @@ const MOUSE_WAIT = 2500;
|
||||
|
||||
|
||||
export interface GestureDetail {
|
||||
type?: string;
|
||||
event?: UIEvent;
|
||||
startX?: number;
|
||||
startY?: number;
|
||||
startTimeStamp?: number;
|
||||
currentX?: number;
|
||||
currentY?: number;
|
||||
velocityX?: number;
|
||||
velocityY?: number;
|
||||
deltaX?: number;
|
||||
deltaY?: number;
|
||||
timeStamp?: number;
|
||||
type: string;
|
||||
startX: number;
|
||||
startY: number;
|
||||
startTimeStamp: number;
|
||||
currentX: number;
|
||||
currentY: number;
|
||||
velocityX: number;
|
||||
velocityY: number;
|
||||
deltaX: number;
|
||||
deltaY: number;
|
||||
timeStamp: number;
|
||||
event: UIEvent;
|
||||
data?: any;
|
||||
}
|
||||
|
||||
|
@ -17,11 +17,6 @@
|
||||
boolean
|
||||
|
||||
|
||||
#### block
|
||||
|
||||
string
|
||||
|
||||
|
||||
#### canStart
|
||||
|
||||
|
||||
@ -114,11 +109,6 @@ string
|
||||
boolean
|
||||
|
||||
|
||||
#### block
|
||||
|
||||
string
|
||||
|
||||
|
||||
#### can-start
|
||||
|
||||
|
||||
|
@ -34,16 +34,16 @@ export const enum SlidingState {
|
||||
}
|
||||
})
|
||||
export class ItemSliding {
|
||||
private item: HTMLIonItemElement;
|
||||
private list: HTMLIonListElement;
|
||||
private item: HTMLIonItemElement|null;
|
||||
private list: HTMLIonListElement|null;
|
||||
private openAmount = 0;
|
||||
private initialOpenAmount = 0;
|
||||
private optsWidthRightSide = 0;
|
||||
private optsWidthLeftSide = 0;
|
||||
private sides: ItemSide;
|
||||
private tmr: number;
|
||||
private leftOptions: ItemOptions;
|
||||
private rightOptions: ItemOptions;
|
||||
private leftOptions: ItemOptions|null;
|
||||
private rightOptions: ItemOptions|null;
|
||||
private optsDirty = true;
|
||||
|
||||
@Element() private el: HTMLElement;
|
||||
@ -106,7 +106,7 @@ export class ItemSliding {
|
||||
*/
|
||||
@Method()
|
||||
closeOpened(): boolean {
|
||||
return this.list && this.list.closeSlidingItems();
|
||||
return !!(this.list && this.list.closeSlidingItems());
|
||||
}
|
||||
|
||||
private updateOptions() {
|
||||
|
@ -14,7 +14,7 @@ import { ItemSliding } from '../item-sliding/item-sliding';
|
||||
}
|
||||
})
|
||||
export class List {
|
||||
private openedItem: ItemSliding;
|
||||
private openedItem: ItemSliding|null;
|
||||
|
||||
@Method()
|
||||
getOpenedItem() {
|
||||
@ -22,7 +22,7 @@ export class List {
|
||||
}
|
||||
|
||||
@Method()
|
||||
setOpenedItem(itemSliding: ItemSliding) {
|
||||
setOpenedItem(itemSliding: ItemSliding|null) {
|
||||
this.openedItem = itemSliding;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, Element, Prop, State } from '@stencil/core';
|
||||
import { Component, Element, Prop } from '@stencil/core';
|
||||
import { Config } from '../../index';
|
||||
|
||||
@Component({
|
||||
@ -13,14 +13,7 @@ import { Config } from '../../index';
|
||||
})
|
||||
export class MenuButton {
|
||||
|
||||
@State() custom: boolean;
|
||||
|
||||
/**
|
||||
* The mode determines which platform styles to use.
|
||||
* Possible values are: `"ios"` or `"md"`.
|
||||
* For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
|
||||
*/
|
||||
@Prop() mode: 'ios' | 'md';
|
||||
private custom = true;
|
||||
|
||||
/**
|
||||
* Optional property that maps to a Menu's `menuId` prop. Can also be `left` or `right` for the menu side. This is used to find the correct menu to toggle
|
||||
@ -33,34 +26,24 @@ export class MenuButton {
|
||||
*/
|
||||
@Prop() autoHide = true;
|
||||
|
||||
|
||||
@Prop({ context: 'config' }) config: Config;
|
||||
|
||||
@Element() el: HTMLElement;
|
||||
|
||||
componentWillLoad() {
|
||||
this.custom = this.el.childElementCount > 0;
|
||||
const closestNav = this.el.closest('ion-nav');
|
||||
closestNav.canGoBack() ? this.el.hidden = true : this.el.hidden = false;
|
||||
}
|
||||
|
||||
render() {
|
||||
const menuIcon = this.config.get('menuIcon', 'menu');
|
||||
|
||||
if (this.custom) {
|
||||
return (
|
||||
<ion-menu-toggle menu={this.menu} autoHide={this.autoHide}>
|
||||
<slot />
|
||||
</ion-menu-toggle>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<ion-menu-toggle menu={this.menu} autoHide={this.autoHide}>
|
||||
<ion-button>
|
||||
<ion-icon slot='icon-only' name={menuIcon}></ion-icon>
|
||||
</ion-button>
|
||||
</ion-menu-toggle>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<ion-menu-toggle menu={this.menu} autoHide={this.autoHide}>
|
||||
<ion-button>
|
||||
{this.custom
|
||||
? <slot/>
|
||||
: <ion-icon slot='icon-only' name={menuIcon}/>}
|
||||
</ion-button>
|
||||
</ion-menu-toggle>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +22,6 @@ string
|
||||
Optional property that maps to a Menu's `menuId` prop. Can also be `left` or `right` for the menu side. This is used to find the correct menu to toggle
|
||||
|
||||
|
||||
#### mode
|
||||
|
||||
|
||||
|
||||
The mode determines which platform styles to use.
|
||||
Possible values are: `"ios"` or `"md"`.
|
||||
For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
|
||||
|
||||
|
||||
## Attributes
|
||||
|
||||
#### auto-hide
|
||||
@ -48,15 +39,6 @@ string
|
||||
Optional property that maps to a Menu's `menuId` prop. Can also be `left` or `right` for the menu side. This is used to find the correct menu to toggle
|
||||
|
||||
|
||||
#### mode
|
||||
|
||||
|
||||
|
||||
The mode determines which platform styles to use.
|
||||
Possible values are: `"ios"` or `"md"`.
|
||||
For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, Element, State } from '@stencil/core';
|
||||
import { Component, Element } from '@stencil/core';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -13,9 +13,9 @@ import { Component, Element, State } from '@stencil/core';
|
||||
})
|
||||
export class Reorder {
|
||||
|
||||
@Element() private el: HTMLElement;
|
||||
private custom = true;
|
||||
|
||||
@State() custom: boolean;
|
||||
@Element() private el: HTMLElement;
|
||||
|
||||
componentWillLoad() {
|
||||
this.custom = this.el.childElementCount > 0;
|
||||
@ -32,14 +32,9 @@ export class Reorder {
|
||||
}
|
||||
|
||||
render() {
|
||||
// TODO: https://github.com/ionic-team/stencil/issues/171
|
||||
if (this.custom === true) {
|
||||
return <slot></slot>;
|
||||
} else if (this.custom === false) {
|
||||
return <ion-icon class='reorder-icon' name='reorder'></ion-icon>;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
return (this.custom)
|
||||
? <slot/>
|
||||
: <ion-icon class='reorder-icon' name='reorder'/>;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,7 +72,8 @@ export class Scroll {
|
||||
deltaX: 0,
|
||||
deltaY: 0,
|
||||
timeStamp: 0,
|
||||
data: undefined
|
||||
data: undefined,
|
||||
isScrolling: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -317,13 +318,13 @@ function updateScrollDetail(
|
||||
}
|
||||
|
||||
export interface ScrollDetail extends GestureDetail, ScrollBaseDetail {
|
||||
positions?: number[];
|
||||
scrollTop?: number;
|
||||
scrollLeft?: number;
|
||||
positions: number[];
|
||||
scrollTop: number;
|
||||
scrollLeft: number;
|
||||
}
|
||||
|
||||
export interface ScrollBaseDetail {
|
||||
isScrolling?: boolean;
|
||||
isScrolling: boolean;
|
||||
}
|
||||
|
||||
export interface ScrollCallback {
|
||||
|
@ -322,7 +322,7 @@ export class Searchbar {
|
||||
this.showCancelButton
|
||||
? <button
|
||||
type='button'
|
||||
tabindex={this.mode === 'ios' && !this.activated ? -1 : null}
|
||||
tabindex={this.mode === 'ios' && !this.activated ? -1 : undefined}
|
||||
onClick={this.cancelSearchbar.bind(this)}
|
||||
onMouseDown={this.cancelSearchbar.bind(this)}
|
||||
class={cancelButtonClasses}>
|
||||
@ -356,7 +356,7 @@ export class Searchbar {
|
||||
</div>
|
||||
];
|
||||
|
||||
if (this.mode === 'ios') {
|
||||
if (cancelButton && this.mode === 'ios') {
|
||||
searchbar.push(cancelButton);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ If true, the element is selected.
|
||||
|
||||
#### value
|
||||
|
||||
string
|
||||
|
||||
|
||||
The text value of the option.
|
||||
|
||||
@ -46,7 +46,7 @@ If true, the element is selected.
|
||||
|
||||
#### value
|
||||
|
||||
string
|
||||
|
||||
|
||||
The text value of the option.
|
||||
|
||||
|
@ -25,7 +25,7 @@ export class SelectOption {
|
||||
/**
|
||||
* The text value of the option.
|
||||
*/
|
||||
@Prop({ mutable: true }) value: string;
|
||||
@Prop({ mutable: true }) value: string|null = null;
|
||||
|
||||
/**
|
||||
* Emitted when the select option loads.
|
||||
|
@ -27,7 +27,7 @@ export class Select {
|
||||
private childOpts: HTMLIonSelectOptionElement[] = [];
|
||||
private selectId: string;
|
||||
private labelId: string;
|
||||
private overlay: ActionSheet | Alert | Popover;
|
||||
private overlay: ActionSheet | Alert | Popover | null;
|
||||
private styleTmr: any;
|
||||
private mode: string;
|
||||
|
||||
@ -40,9 +40,7 @@ export class Select {
|
||||
@State() text: string;
|
||||
|
||||
@Prop({ connect: 'ion-action-sheet-controller' }) actionSheetCtrl: ActionSheetController;
|
||||
|
||||
@Prop({ connect: 'ion-alert-controller' }) alertCtrl: AlertController;
|
||||
|
||||
@Prop({ connect: 'ion-popover-controller' }) popoverCtrl: PopoverController;
|
||||
|
||||
/**
|
||||
@ -97,7 +95,7 @@ export class Select {
|
||||
/**
|
||||
* the value of the select.
|
||||
*/
|
||||
@Prop({ mutable: true }) value: string | string[];
|
||||
@Prop({ mutable: true }) value: string | string[] | null = null;
|
||||
|
||||
/**
|
||||
* Emitted when the value has changed.
|
||||
|
@ -16,11 +16,11 @@ export class ShowWhen implements DisplayWhen {
|
||||
@Prop({ context: 'config' }) config: Config;
|
||||
@Prop({ context: 'platforms' }) calculatedPlatforms: PlatformConfig[];
|
||||
|
||||
@Prop() orientation: string = null;
|
||||
@Prop() mediaQuery: string = null;
|
||||
@Prop() size: string = null;
|
||||
@Prop() mode: string = null;
|
||||
@Prop() platform: string = null;
|
||||
@Prop() orientation: string;
|
||||
@Prop() mediaQuery: string;
|
||||
@Prop() size: string;
|
||||
@Prop() mode: string;
|
||||
@Prop() platform: string;
|
||||
@Prop() or = false;
|
||||
|
||||
@State() passesTest = false;
|
||||
|
1
packages/core/src/index.d.ts
vendored
1
packages/core/src/index.d.ts
vendored
@ -33,6 +33,7 @@ export { FabButton } from './components/fab-button/fab-button';
|
||||
export { Footer } from './components/footer/footer';
|
||||
export { Gesture, GestureCallback, GestureDetail } from './components/gesture/gesture';
|
||||
export { PanRecognizer } from './components/gesture/recognizers';
|
||||
export { GestureController } from './components/gesture-controller/gesture-controller';
|
||||
export * from './components/gesture-controller/gesture-controller-utils';
|
||||
export { Grid } from './components/grid/grid';
|
||||
export { Header } from './components/header/header';
|
||||
|
@ -53,7 +53,7 @@ export function assert(actual: any, reason: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export function autoFocus(containerEl: HTMLElement): HTMLElement {
|
||||
export function autoFocus(containerEl: HTMLElement): HTMLElement|null {
|
||||
const focusableEls = containerEl.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');
|
||||
if (focusableEls.length > 0) {
|
||||
const el = focusableEls[0] as HTMLInputElement;
|
||||
@ -335,7 +335,7 @@ export function isParentTab(element: HTMLElement) {
|
||||
return element.parentElement.tagName.toLowerCase() === 'ion-tab';
|
||||
}
|
||||
|
||||
export function getIonApp(): Promise<HTMLIonAppElement> {
|
||||
export function getIonApp(): Promise<HTMLIonAppElement|null> {
|
||||
const appElement = document.querySelector('ion-app');
|
||||
if (!appElement) {
|
||||
return Promise.resolve(null);
|
||||
|
@ -30,7 +30,7 @@ export function createOverlay
|
||||
return element.componentOnReady();
|
||||
}
|
||||
|
||||
export function dismissOverlay(data: any, role: string, overlays: OverlayMap, id: number): Promise<void> {
|
||||
export function dismissOverlay(data: any, role: string|undefined, overlays: OverlayMap, id: number): Promise<void> {
|
||||
id = id >= 0 ? id : getHighestId(overlays);
|
||||
const overlay = overlays.get(id);
|
||||
if (!overlay) {
|
||||
@ -67,7 +67,7 @@ export function overlayAnimation(
|
||||
): Promise<void> {
|
||||
if (overlay.animation) {
|
||||
overlay.animation.destroy();
|
||||
overlay.animation = null;
|
||||
overlay.animation = undefined;
|
||||
}
|
||||
return overlay.animationCtrl.create(animationBuilder, baseEl, opts).then(animation => {
|
||||
overlay.animation = animation;
|
||||
@ -77,13 +77,13 @@ export function overlayAnimation(
|
||||
return playAnimationAsync(animation);
|
||||
}).then((animation) => {
|
||||
animation.destroy();
|
||||
overlay.animation = null;
|
||||
overlay.animation = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
export interface OverlayInterface {
|
||||
overlayId: number;
|
||||
animation: Animation;
|
||||
animation: Animation|undefined;
|
||||
animationCtrl: HTMLIonAnimationControllerElement;
|
||||
|
||||
present(): Promise<void>;
|
||||
|
@ -19,12 +19,8 @@ export function isPlatformMatch(platforms: string[], multiPlatformString: string
|
||||
export function isModeMatch(config: Config, multiModeString: string) {
|
||||
// you can only ever be in one mode, so if an entry from the list matches, return true
|
||||
const modes = multiModeString.replace(/\s/g, '').split(',');
|
||||
for (const mode of modes) {
|
||||
if (config.get('mode') === mode) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
const currentMode = config.get('mode');
|
||||
return modes.indexOf(currentMode) >= 0;
|
||||
}
|
||||
|
||||
|
||||
@ -34,16 +30,13 @@ export function isMediaQueryMatch(mediaQuery: string) {
|
||||
|
||||
export function isSizeMatch(multiSizeString: string) {
|
||||
const sizes = multiSizeString.replace(/\s/g, '').split(',');
|
||||
|
||||
const booleans = sizes.map(size => {
|
||||
const mediaQuery = sizeToMediaQueryMap.get(size);
|
||||
if (!mediaQuery) {
|
||||
return false;
|
||||
for (const size of sizes) {
|
||||
const mediaQuery = SIZE_TO_MEDIA[size];
|
||||
if (mediaQuery && window.matchMedia(mediaQuery).matches) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return window.matchMedia(mediaQuery).matches;
|
||||
});
|
||||
return booleans.reduce((prev, current) => prev || current);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getTestResult(displayWhen: DisplayWhen) {
|
||||
@ -93,12 +86,13 @@ export function isPortrait(): boolean {
|
||||
return window.matchMedia('(orientation: portrait)').matches;
|
||||
}
|
||||
|
||||
const sizeToMediaQueryMap = new Map<string, string>();
|
||||
sizeToMediaQueryMap.set('xs', '(min-width: 0px)');
|
||||
sizeToMediaQueryMap.set('sm', '(min-width: 576px)');
|
||||
sizeToMediaQueryMap.set('md', '(min-width: 768px)');
|
||||
sizeToMediaQueryMap.set('lg', '(min-width: 992px)');
|
||||
sizeToMediaQueryMap.set('xl', '(min-width: 1200px)');
|
||||
const SIZE_TO_MEDIA: any = {
|
||||
'xs': '(min-width: 0px)',
|
||||
'sm': '(min-width: 576px)',
|
||||
'md': '(min-width: 768px)',
|
||||
'lg': '(min-width: 992px)',
|
||||
'xl': '(min-width: 1200px)'
|
||||
};
|
||||
|
||||
export interface DisplayWhen {
|
||||
calculatedPlatforms: PlatformConfig[];
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"alwaysStrict": true,
|
||||
"strictPropertyInitialization": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"allowUnreachableCode": false,
|
||||
"declaration": true,
|
||||
|
Reference in New Issue
Block a user