diff --git a/angular/test/test-app/src/app/providers/providers.component.ts b/angular/test/test-app/src/app/providers/providers.component.ts index a56a5dcb2b..005bcd80e8 100644 --- a/angular/test/test-app/src/app/providers/providers.component.ts +++ b/angular/test/test-app/src/app/providers/providers.component.ts @@ -1,8 +1,8 @@ import { Component } from '@angular/core'; import { - Platform, Config, ModalController, AlertController, ActionSheetController, - PopoverController, ToastController, Events, PickerController, MenuController, - LoadingController, NavController, DomController + Platform, ModalController, AlertController, ActionSheetController, + PopoverController, ToastController, Events, PickerController, MenuController, + LoadingController, NavController, DomController, Config } from '@ionic/angular'; @Component({ diff --git a/core/package.json b/core/package.json index 578940a1cf..78bf0c54ed 100644 --- a/core/package.json +++ b/core/package.json @@ -30,13 +30,12 @@ "loader/" ], "dependencies": { - "ionicons": "4.5.10-0", + "ionicons": "4.5.10-1", "tslib": "^1.10.0" }, "devDependencies": { "@stencil/core": "1.0.7", - "@stencil/sass": "latest", - "@stencil/utils": "latest", + "@stencil/sass": "1.0.0", "@types/jest": "24.0.13", "@types/node": "10.12.18", "@types/puppeteer": "1.12.4", @@ -44,18 +43,18 @@ "aws-sdk": "^2.320.0", "chromedriver": "^2.38.3", "clean-css-cli": "^4.1.11", - "fs-extra": "^7.0.0", + "fs-extra": "^8.0.1", "jest": "24.8.0", "jest-cli": "24.8.0", "np": "^3.0.4", "pixelmatch": "4.0.2", "puppeteer": "1.17.0", - "rollup": "1.1.2", - "rollup-plugin-node-resolve": "4.0.0", + "rollup": "1.15.2", + "rollup-plugin-node-resolve": "5.0.2", "rollup-plugin-virtual": "^1.0.1", - "sass": "^1.20.1", - "stylelint": "9.10.1", - "stylelint-order": "2.0.0", + "sass": "^1.21.0", + "stylelint": "10.1.0", + "stylelint-order": "3.0.0", "swiper": "4.4.6", "tslint": "^5.10.0", "tslint-ionic-rules": "0.0.21", diff --git a/core/src/components/action-sheet-controller/action-sheet-controller.tsx b/core/src/components/action-sheet-controller/action-sheet-controller.tsx index 9af7d0221e..1ece5497b0 100644 --- a/core/src/components/action-sheet-controller/action-sheet-controller.tsx +++ b/core/src/components/action-sheet-controller/action-sheet-controller.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Method, Prop } from '@stencil/core'; +import { Component, ComponentInterface, Method } from '@stencil/core'; import { ActionSheetOptions, OverlayController } from '../../interface'; import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays'; @@ -8,8 +8,6 @@ import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays' }) export class ActionSheetController implements ComponentInterface, OverlayController { - @Prop({ context: 'document' }) doc!: Document; - /** * Create an action sheet overlay with action sheet options. * diff --git a/core/src/components/action-sheet/action-sheet.tsx b/core/src/components/action-sheet/action-sheet.tsx index 022888ed6a..0b567c9f81 100644 --- a/core/src/components/action-sheet/action-sheet.tsx +++ b/core/src/components/action-sheet/action-sheet.tsx @@ -1,7 +1,7 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Method, Prop, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; -import { ActionSheetButton, Animation, AnimationBuilder, Config, CssClassMap, OverlayEventDetail, OverlayInterface } from '../../interface'; +import { ActionSheetButton, Animation, AnimationBuilder, CssClassMap, OverlayEventDetail, OverlayInterface } from '../../interface'; import { BACKDROP, dismiss, eventMethod, isCancel, present } from '../../utils/overlays'; import { getClassMap } from '../../utils/theme'; @@ -29,7 +29,6 @@ export class ActionSheet implements ComponentInterface, OverlayInterface { @Element() el!: HTMLElement; - @Prop({ context: 'config' }) config!: Config; /** @internal */ @Prop() overlayIndex!: number; @@ -204,7 +203,7 @@ export class ActionSheet implements ComponentInterface, OverlayInterface { zIndex: 20000 + this.overlayIndex, }, class: { - [`${mode}`]: true, + [mode]: true, ...getClassMap(this.cssClass), 'action-sheet-translucent': this.translucent diff --git a/core/src/components/alert-controller/alert-controller.tsx b/core/src/components/alert-controller/alert-controller.tsx index 9bd62144f4..2d10588249 100644 --- a/core/src/components/alert-controller/alert-controller.tsx +++ b/core/src/components/alert-controller/alert-controller.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Method, Prop } from '@stencil/core'; +import { Component, ComponentInterface, Method } from '@stencil/core'; import { AlertOptions, OverlayController } from '../../interface'; import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays'; @@ -8,8 +8,6 @@ import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays' }) export class AlertController implements ComponentInterface, OverlayController { - @Prop({ context: 'document' }) doc!: Document; - /** * Create an alert overlay with alert options. * diff --git a/core/src/components/alert/alert.tsx b/core/src/components/alert/alert.tsx index 953cede147..f5d306ff35 100644 --- a/core/src/components/alert/alert.tsx +++ b/core/src/components/alert/alert.tsx @@ -1,7 +1,7 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Method, Prop, Watch, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; -import { AlertButton, AlertInput, Animation, AnimationBuilder, Config, CssClassMap, OverlayEventDetail, OverlayInterface } from '../../interface'; +import { AlertButton, AlertInput, Animation, AnimationBuilder, CssClassMap, OverlayEventDetail, OverlayInterface } from '../../interface'; import { BACKDROP, dismiss, eventMethod, isCancel, present } from '../../utils/overlays'; import { sanitizeDOMString } from '../../utils/sanitization'; import { getClassMap } from '../../utils/theme'; @@ -35,8 +35,6 @@ export class Alert implements ComponentInterface, OverlayInterface { @Element() el!: HTMLIonAlertElement; - @Prop({ context: 'config' }) config!: Config; - /** @internal */ @Prop() overlayIndex!: number; @@ -406,7 +404,7 @@ export class Alert implements ComponentInterface, OverlayInterface { }, class: { ...getClassMap(this.cssClass), - [`${mode}`]: true, + [mode]: true, 'alert-translucent': this.translucent } }; diff --git a/core/src/components/anchor/anchor.tsx b/core/src/components/anchor/anchor.tsx index c0ffbd8809..3ff445f568 100644 --- a/core/src/components/anchor/anchor.tsx +++ b/core/src/components/anchor/anchor.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Listen, Prop, h } from '@stencil/core'; +import { Component, ComponentInterface, Host, Prop, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { Color, RouterDirection } from '../../interface'; @@ -12,8 +12,6 @@ import { createColorClasses, openURL } from '../../utils/theme'; }) export class Anchor implements ComponentInterface, AnchorInterface { - @Prop({ context: 'window' }) win!: Window; - /** * The color to use from your application's color palette. * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. @@ -54,35 +52,31 @@ export class Anchor implements ComponentInterface, AnchorInterface { */ @Prop() target: string | undefined; - @Listen('click') - onClick(ev: Event) { - openURL(this.win, this.href, ev, this.routerDirection); - } - - hostData() { - const mode = getIonMode(this); - console.log('anchor', mode); - return { - class: { - ...createColorClasses(this.color), - [`${mode}`]: true, - 'ion-activatable': true - } - }; + private onClick = (ev: Event) => { + openURL(this.href, ev, this.routerDirection); } render() { + const mode = getIonMode(this); const attrs = { download: this.download, href: this.href, rel: this.rel, target: this.target }; - return ( - - - + + + + + ); } } diff --git a/core/src/components/app/app.tsx b/core/src/components/app/app.tsx index e882c1637b..c6e8d6db82 100644 --- a/core/src/components/app/app.tsx +++ b/core/src/components/app/app.tsx @@ -1,7 +1,7 @@ -import { Component, ComponentInterface, Element, Prop } from '@stencil/core'; +import { Component, ComponentInterface, Element } from '@stencil/core'; +import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; -import { Config } from '../../interface'; import { rIC } from '../../utils/helpers'; import { isPlatform } from '../../utils/platform'; @@ -13,21 +13,16 @@ export class App implements ComponentInterface { @Element() el!: HTMLElement; - @Prop({ context: 'window' }) win!: Window; - @Prop({ context: 'config' }) config!: Config; - componentDidLoad() { rIC(() => { - const { win, config } = this; - if (!config.getBoolean('_testing')) { - importTapClick(win, config); + importTapClick(); } - importInputShims(win, config); - importStatusTap(win, config); - importHardwareBackButton(win, config); - importFocusVisible(win); + importInputShims(); + importStatusTap(); + importHardwareBackButton(); + importFocusVisible(); }); } @@ -36,43 +31,43 @@ export class App implements ComponentInterface { return { class: { - [`${mode}`]: true, + [mode]: true, 'ion-page': true, - 'force-statusbar-padding': this.config.getBoolean('_forceStatusbarPadding') + 'force-statusbar-padding': config.getBoolean('_forceStatusbarPadding') } }; } } -function importHardwareBackButton(win: Window, config: Config) { - const hardwareBackConfig = config.getBoolean('hardwareBackButton', isPlatform(win, 'hybrid')); +function importHardwareBackButton() { + const hardwareBackConfig = config.getBoolean('hardwareBackButton', isPlatform(window, 'hybrid')); if (hardwareBackConfig) { - import('../../utils/hardware-back-button').then(module => module.startHardwareBackButton(win)); + import('../../utils/hardware-back-button').then(module => module.startHardwareBackButton()); } } -function importStatusTap(win: Window, config: Config) { - const statusTap = config.getBoolean('statusTap', isPlatform(win, 'hybrid')); +function importStatusTap() { + const statusTap = config.getBoolean('statusTap', isPlatform(window, 'hybrid')); if (statusTap) { - import('../../utils/status-tap').then(module => module.startStatusTap(win)); + import('../../utils/status-tap').then(module => module.startStatusTap()); } } -function importFocusVisible(win: Window) { - import('../../utils/focus-visible').then(module => module.startFocusVisible(win.document)); +function importFocusVisible() { + import('../../utils/focus-visible').then(module => module.startFocusVisible()); } -function importTapClick(win: Window, config: Config) { - import('../../utils/tap-click').then(module => module.startTapClick(win.document, config)); +function importTapClick() { + import('../../utils/tap-click').then(module => module.startTapClick(config)); } -function importInputShims(win: Window, config: Config) { - const inputShims = config.getBoolean('inputShims', needInputShims(win)); +function importInputShims() { + const inputShims = config.getBoolean('inputShims', needInputShims()); if (inputShims) { - import('../../utils/input-shims/input-shims').then(module => module.startInputShims(win.document, config)); + import('../../utils/input-shims/input-shims').then(module => module.startInputShims(config)); } } -function needInputShims(win: Window) { - return isPlatform(win, 'ios') && isPlatform(win, 'mobile'); +function needInputShims() { + return isPlatform(window, 'ios') && isPlatform(window, 'mobile'); } diff --git a/core/src/components/avatar/avatar.tsx b/core/src/components/avatar/avatar.tsx index 99aa6acc57..b356cf69c3 100644 --- a/core/src/components/avatar/avatar.tsx +++ b/core/src/components/avatar/avatar.tsx @@ -17,7 +17,7 @@ export class Avatar implements ComponentInterface { return { class: { - [`${mode}`]: true, + [mode]: true, } }; } diff --git a/core/src/components/back-button/back-button.tsx b/core/src/components/back-button/back-button.tsx index e340b37c51..cc11529436 100644 --- a/core/src/components/back-button/back-button.tsx +++ b/core/src/components/back-button/back-button.tsx @@ -1,7 +1,8 @@ -import { Component, ComponentInterface, Element, Listen, Prop, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Host, Prop, h } from '@stencil/core'; +import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; -import { Color, Config } from '../../interface'; +import { Color } from '../../interface'; import { ButtonInterface } from '../../utils/element-interface'; import { createColorClasses, openURL } from '../../utils/theme'; @@ -21,9 +22,6 @@ export class BackButton implements ComponentInterface, ButtonInterface { private mode = getIonMode(this); @Element() el!: HTMLElement; - @Prop({ context: 'config' }) config!: Config; - @Prop({ context: 'window' }) win!: Window; - /** * The color to use from your application's color palette. * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. @@ -56,24 +54,13 @@ export class BackButton implements ComponentInterface, ButtonInterface { */ @Prop() type: 'submit' | 'reset' | 'button' = 'button'; - @Listen('click') - async onClick(ev: Event) { - const nav = this.el.closest('ion-nav'); - ev.preventDefault(); - - if (nav && await nav.canGoBack()) { - return nav.pop({ skipIfBusy: true }); - } - return openURL(this.win, this.defaultHref, ev, 'back'); - } - private get backButtonIcon() { - return this.icon != null ? this.icon : this.config.get('backButtonIcon', 'arrow-back'); + return this.icon != null ? this.icon : config.get('backButtonIcon', 'arrow-back'); } private get backButtonText() { const defaultBackButtonText = this.mode === 'ios' ? 'Back' : null; - return this.text != null ? this.text : this.config.get('backButtonText', defaultBackButtonText); + return this.text != null ? this.text : config.get('backButtonText', defaultBackButtonText); } private get hasIconOnly() { @@ -90,42 +77,43 @@ export class BackButton implements ComponentInterface, ButtonInterface { return 'bounded'; } - hostData() { - const { color, defaultHref, disabled, mode, hasIconOnly } = this; + private onClick = async (ev: Event) => { + const nav = this.el.closest('ion-nav'); + ev.preventDefault(); - const showBackButton = defaultHref !== undefined; - - return { - 'aria-disabled': disabled ? 'true' : null, - class: { - ...createColorClasses(color), - [`${mode}`]: true, - - 'button': true, // ion-buttons target .button - 'back-button-disabled': disabled, - 'back-button-has-icon-only': hasIconOnly, - 'ion-activatable': true, - 'ion-focusable': true, - 'show-back-button': showBackButton - } - }; + if (nav && await nav.canGoBack()) { + return nav.pop({ skipIfBusy: true }); + } + return openURL(this.defaultHref, ev, 'back'); } render() { - const { backButtonIcon, backButtonText } = this; - - const attrs = { - type: this.type - }; + const { color, defaultHref, disabled, type, mode, hasIconOnly, backButtonIcon, backButtonText } = this; + const showBackButton = defaultHref !== undefined; return ( - + + + ); } } diff --git a/core/src/components/backdrop/backdrop.tsx b/core/src/components/backdrop/backdrop.tsx index fe4bf1927d..4a53417cdd 100644 --- a/core/src/components/backdrop/backdrop.tsx +++ b/core/src/components/backdrop/backdrop.tsx @@ -19,8 +19,6 @@ export class Backdrop implements ComponentInterface { disableScroll: true }); - @Prop({ context: 'document' }) doc!: Document; - /** * If `true`, the backdrop will be visible. */ @@ -81,7 +79,7 @@ export class Backdrop implements ComponentInterface { return { tabindex: '-1', class: { - [`${mode}`]: true, + [mode]: true, 'backdrop-hide': !this.visible, 'backdrop-no-tappable': !this.tappable, } diff --git a/core/src/components/badge/badge.tsx b/core/src/components/badge/badge.tsx index 19b3b37f0a..9c148db1a1 100644 --- a/core/src/components/badge/badge.tsx +++ b/core/src/components/badge/badge.tsx @@ -29,7 +29,7 @@ export class Badge implements ComponentInterface { return { class: { ...createColorClasses(this.color), - [`${mode}`]: true + [mode]: true } }; } diff --git a/core/src/components/button/button.tsx b/core/src/components/button/button.tsx index fbeff8f310..3bfaac269c 100644 --- a/core/src/components/button/button.tsx +++ b/core/src/components/button/button.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Prop, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Prop, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { Color, RouterDirection } from '../../interface'; @@ -29,8 +29,6 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf @Element() el!: HTMLElement; - @Prop({ context: 'window' }) win!: Window; - /** * The color to use from your application's color palette. * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. @@ -129,29 +127,6 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf this.inItem = !!this.el.closest('ion-item') || !!this.el.closest('ion-item-divider'); } - @Listen('click') - onClick(ev: Event) { - if (this.type === 'button') { - openURL(this.win, this.href, ev, this.routerDirection); - - } else if (hasShadowDom(this.el)) { - // this button wants to specifically submit a form - // climb up the dom to see if we're in a
- // and if so, then use JS to submit it - const form = this.el.closest('form'); - if (form) { - ev.preventDefault(); - - const fakeButton = this.win.document.createElement('button'); - fakeButton.type = this.type; - fakeButton.style.display = 'none'; - form.appendChild(fakeButton); - fakeButton.click(); - fakeButton.remove(); - } - } - } - private get hasIconOnly() { return !!this.el.querySelector('ion-icon[slot="icon-only"]'); } @@ -168,6 +143,28 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf return 'bounded'; } + private handleClick = (ev: Event) => { + if (this.type === 'button') { + openURL(this.href, ev, this.routerDirection); + + } else if (hasShadowDom(this.el)) { + // this button wants to specifically submit a form + // climb up the dom to see if we're in a + // and if so, then use JS to submit it + const form = this.el.closest('form'); + if (form) { + ev.preventDefault(); + + const fakeButton = document.createElement('button'); + fakeButton.type = this.type; + fakeButton.style.display = 'none'; + form.appendChild(fakeButton); + fakeButton.click(); + fakeButton.remove(); + } + } + } + private onFocus = () => { this.ionFocus.emit(); } @@ -176,62 +173,60 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf this.ionBlur.emit(); } - hostData() { + render() { const mode = getIonMode(this); - const { buttonType, disabled, color, expand, hasIconOnly, shape, strong } = this; + const { buttonType, type, disabled, rel, target, size, href, color, expand, hasIconOnly, shape, strong } = this; + const finalSize = size === undefined && this.inItem ? 'small' : size; + const TagType = href === undefined ? 'button' : 'a' as any; + const attrs = (TagType === 'button') + ? { type } + : { + download: this.download, + href, + rel, + target + }; + let fill = this.fill; if (fill === undefined) { fill = this.inToolbar ? 'clear' : 'solid'; } - const size = this.size === undefined && this.inItem ? 'small' : this.size; - return { - 'aria-disabled': disabled ? 'true' : null, - class: { - ...createColorClasses(color), - [`${mode}`]: true, - [buttonType]: true, - [`${buttonType}-${expand}`]: expand !== undefined, - [`${buttonType}-${size}`]: size !== undefined, - [`${buttonType}-${shape}`]: shape !== undefined, - [`${buttonType}-${fill}`]: true, - [`${buttonType}-strong`]: strong, - - 'button-has-icon-only': hasIconOnly, - 'button-disabled': disabled, - 'ion-activatable': true, - 'ion-focusable': true, - } - }; - } - - render() { - const mode = getIonMode(this); - const TagType = this.href === undefined ? 'button' : 'a' as any; - const attrs = (TagType === 'button') - ? { type: this.type } - : { - download: this.download, - href: this.href, - rel: this.rel, - target: this.target - }; - return ( - - - - - - - - {mode === 'md' && } - + + + + + + + + {mode === 'md' && } + + ); } } diff --git a/core/src/components/buttons/buttons.tsx b/core/src/components/buttons/buttons.tsx index e62ef48106..b74e1955f5 100644 --- a/core/src/components/buttons/buttons.tsx +++ b/core/src/components/buttons/buttons.tsx @@ -16,7 +16,7 @@ export class Buttons implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true + [mode]: true } }; } diff --git a/core/src/components/card-content/card-content.tsx b/core/src/components/card-content/card-content.tsx index 40220185c7..93bca5445b 100644 --- a/core/src/components/card-content/card-content.tsx +++ b/core/src/components/card-content/card-content.tsx @@ -18,7 +18,7 @@ export class CardContent implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, // Used internally for styling [`card-content-${mode}`]: true diff --git a/core/src/components/card-header/card-header.tsx b/core/src/components/card-header/card-header.tsx index 9cb3b18ce5..dd2c703799 100644 --- a/core/src/components/card-header/card-header.tsx +++ b/core/src/components/card-header/card-header.tsx @@ -34,7 +34,7 @@ export class CardHeader implements ComponentInterface { class: { ...createColorClasses(this.color), 'card-header-translucent': this.translucent, - [`${mode}`]: true + [mode]: true } }; } diff --git a/core/src/components/card-subtitle/card-subtitle.tsx b/core/src/components/card-subtitle/card-subtitle.tsx index f23f722248..1a56b70980 100644 --- a/core/src/components/card-subtitle/card-subtitle.tsx +++ b/core/src/components/card-subtitle/card-subtitle.tsx @@ -28,7 +28,7 @@ export class CardSubtitle implements ComponentInterface { return { class: { ...createColorClasses(this.color), - [`${mode}`]: true + [mode]: true }, 'role': 'heading', 'aria-level': '3' diff --git a/core/src/components/card-title/card-title.tsx b/core/src/components/card-title/card-title.tsx index b97ce98891..8baf2f1b5c 100644 --- a/core/src/components/card-title/card-title.tsx +++ b/core/src/components/card-title/card-title.tsx @@ -28,7 +28,7 @@ export class CardTitle implements ComponentInterface { return { class: { ...createColorClasses(this.color), - [`${mode}`]: true + [mode]: true }, 'role': 'heading', 'aria-level': '2' diff --git a/core/src/components/card/card.tsx b/core/src/components/card/card.tsx index 4bd22ab4af..dbf73ca39e 100644 --- a/core/src/components/card/card.tsx +++ b/core/src/components/card/card.tsx @@ -18,8 +18,6 @@ import { createColorClasses, openURL } from '../../utils/theme'; }) export class Card implements ComponentInterface, AnchorInterface, ButtonInterface { - @Prop({ context: 'window' }) win!: Window; - /** * The color to use from your application's color palette. * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. @@ -83,7 +81,7 @@ export class Card implements ComponentInterface, AnchorInterface, ButtonInterfac const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, ...createColorClasses(this.color), 'card-disabled': this.disabled, @@ -101,7 +99,7 @@ export class Card implements ComponentInterface, AnchorInterface, ButtonInterfac ]; } const mode = getIonMode(this); - const { href, win, routerDirection } = this; + const { href, routerDirection } = this; const TagType = clickable ? (href === undefined ? 'button' : 'a') : 'div' as any; const attrs = (TagType === 'button') ? { type: this.type } @@ -117,7 +115,7 @@ export class Card implements ComponentInterface, AnchorInterface, ButtonInterfac {...attrs} class="card-native" disabled={this.disabled} - onClick={(ev: Event) => openURL(win, href, ev, routerDirection)} + onClick={(ev: Event) => openURL(href, ev, routerDirection)} > {clickable && mode === 'md' && } diff --git a/core/src/components/checkbox/checkbox.tsx b/core/src/components/checkbox/checkbox.tsx index 6286d9c5b7..fe6e1757e0 100644 --- a/core/src/components/checkbox/checkbox.tsx +++ b/core/src/components/checkbox/checkbox.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Prop, Watch, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Prop, Watch, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { CheckboxChangeEventDetail, Color, StyleEventDetail } from '../../interface'; @@ -101,19 +101,18 @@ export class Checkbox implements ComponentInterface { }); } - @Listen('click') - onClick() { - this.setFocus(); - this.checked = !this.checked; - this.indeterminate = false; - } - private setFocus() { if (this.buttonEl) { this.buttonEl.focus(); } } + private onClick = () => { + this.setFocus(); + this.checked = !this.checked; + this.indeterminate = false; + } + private onFocus = () => { this.ionFocus.emit(); } @@ -122,59 +121,56 @@ export class Checkbox implements ComponentInterface { this.ionBlur.emit(); } - hostData() { - const { inputId, disabled, checked, color, el } = this; + render() { + const { inputId, indeterminate, disabled, checked, value, color, el } = this; const labelId = inputId + '-lbl'; const mode = getIonMode(this); const label = findItemLabel(el); if (label) { label.id = labelId; } - return { - 'role': 'checkbox', - 'aria-disabled': disabled ? 'true' : null, - 'aria-checked': `${checked}`, - 'aria-labelledby': labelId, - class: { - ...createColorClasses(color), - [`${mode}`]: true, - 'in-item': hostContext('ion-item', el), - 'checkbox-checked': checked, - 'checkbox-disabled': disabled, - 'checkbox-indeterminate': this.indeterminate, - 'interactive': true - } - }; - } + renderHiddenInput(true, el, this.name, (checked ? value : ''), disabled); - render() { - const mode = getIonMode(this); - - renderHiddenInput(true, this.el, this.name, (this.checked ? this.value : ''), this.disabled); - - let path = this.indeterminate + let path = indeterminate ? : ; if (mode === 'md') { - path = this.indeterminate + path = indeterminate ? : ; } - return [ - - {path} - , - - ]; + + {path} + + + + ); } } diff --git a/core/src/components/chip/chip.tsx b/core/src/components/chip/chip.tsx index 1f8ff5d4ea..28af49d98a 100644 --- a/core/src/components/chip/chip.tsx +++ b/core/src/components/chip/chip.tsx @@ -33,7 +33,7 @@ export class Chip implements ComponentInterface { return { class: { ...createColorClasses(this.color), - [`${mode}`]: true, + [mode]: true, 'chip-outline': this.outline, 'ion-activatable': true, } diff --git a/core/src/components/col/col.tsx b/core/src/components/col/col.tsx index 7649999abb..9bd4409f4d 100644 --- a/core/src/components/col/col.tsx +++ b/core/src/components/col/col.tsx @@ -14,8 +14,6 @@ const BREAKPOINTS = ['', 'xs', 'sm', 'md', 'lg', 'xl']; }) export class Col implements ComponentInterface { - @Prop({ context: 'window' }) win!: Window; - @Element() el!: HTMLIonColElement; /** @@ -169,7 +167,7 @@ export class Col implements ComponentInterface { let matched; for (const breakpoint of BREAKPOINTS) { - const matches = matchBreakpoint(this.win, breakpoint); + const matches = matchBreakpoint(breakpoint); // Grab the value of the property, if it exists and our // media query matches we return the value @@ -247,11 +245,11 @@ export class Col implements ComponentInterface { } hostData() { - const isRTL = this.win.document.dir === 'rtl'; + const isRTL = document.dir === 'rtl'; const mode = getIonMode(this); return { class: { - [`${mode}`]: true + [mode]: true }, style: { ...this.calculateOffset(isRTL), diff --git a/core/src/components/content/content.tsx b/core/src/components/content/content.tsx index 60843fd25a..92471727cf 100644 --- a/core/src/components/content/content.tsx +++ b/core/src/components/content/content.tsx @@ -1,7 +1,7 @@ -import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Method, Prop, QueueApi, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Listen, Method, Prop, h, readTask } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; -import { Color, Config, ScrollBaseDetail, ScrollDetail } from '../../interface'; +import { Color, ScrollBaseDetail, ScrollDetail } from '../../interface'; import { isPlatform } from '../../utils/platform'; import { createColorClasses, hostContext } from '../../utils/theme'; @@ -48,10 +48,6 @@ export class Content implements ComponentInterface { @Element() el!: HTMLIonContentElement; - @Prop({ context: 'config' }) config!: Config; - @Prop({ context: 'queue' }) queue!: QueueApi; - @Prop({ context: 'window' }) win!: Window; - /** * The color to use from your application's color palette. * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. @@ -108,7 +104,7 @@ export class Content implements ComponentInterface { componentWillLoad() { if (this.forceOverscroll === undefined) { const mode = getIonMode(this); - this.forceOverscroll = mode === 'ios' && isPlatform(this.win, 'mobile'); + this.forceOverscroll = mode === 'ios' && isPlatform(window, 'mobile'); } } @@ -130,7 +126,7 @@ export class Content implements ComponentInterface { private resize() { if (this.fullscreen) { - this.queue.read(this.readDimensions.bind(this)); + readTask(this.readDimensions.bind(this)); } else if (this.cTop !== 0 || this.cBottom !== 0) { this.cTop = this.cBottom = 0; this.el.forceUpdate(); @@ -159,7 +155,7 @@ export class Content implements ComponentInterface { } if (!this.queued && this.scrollEvents) { this.queued = true; - this.queue.read(ts => { + readTask(ts => { this.queued = false; this.detail.event = ev; updateScrollDetail(this.detail, this.scrollEl, ts, shouldStart); @@ -301,42 +297,40 @@ export class Content implements ComponentInterface { } } - hostData() { - const mode = getIonMode(this); - return { - class: { - ...createColorClasses(this.color), - [`${mode}`]: true, - 'content-sizing': hostContext('ion-popover', this.el), - 'overscroll': !!this.forceOverscroll, - }, - style: { - '--offset-top': `${this.cTop}px`, - '--offset-bottom': `${this.cBottom}px`, - } - }; - } - render() { + const mode = getIonMode(this); const { scrollX, scrollY, forceOverscroll } = this; this.resize(); - return [ -
this.scrollEl = el!} - onScroll={ev => this.onScroll(ev)} > - -
, - - ]; +
this.scrollEl = el!} + onScroll={ev => this.onScroll(ev)} + > + +
+ + + ); } } diff --git a/core/src/components/datetime/datetime.tsx b/core/src/components/datetime/datetime.tsx index c6951bf6e8..389d7a88bc 100644 --- a/core/src/components/datetime/datetime.tsx +++ b/core/src/components/datetime/datetime.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Method, Prop, State, Watch, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Method, Prop, State, Watch, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { DatetimeChangeEventDetail, DatetimeOptions, PickerColumn, PickerColumnOption, PickerOptions, StyleEventDetail } from '../../interface'; @@ -242,12 +242,6 @@ export class Datetime implements ComponentInterface { this.emitStyle(); } - @Listen('click') - onClick() { - this.setFocus(); - this.open(); - } - /** * Opens the datetime overlay. */ @@ -557,7 +551,7 @@ export class Datetime implements ComponentInterface { return 0; } - private getText() { + private get text() { // create the text of the formatted data const template = this.displayFormat || this.pickerFormat || DEFAULT_FORMAT; @@ -581,6 +575,11 @@ export class Datetime implements ComponentInterface { } } + private onClick = () => { + this.setFocus(); + this.open(); + } + private onFocus = () => { this.ionFocus.emit(); } @@ -589,54 +588,52 @@ export class Datetime implements ComponentInterface { this.ionBlur.emit(); } - hostData() { - const { inputId, disabled, readonly, isExpanded, el, placeholder } = this; + render() { + const { inputId, text, disabled, readonly, isExpanded, el, placeholder } = this; const mode = getIonMode(this); - const addPlaceholderClass = - (this.getText() === undefined && placeholder != null) ? true : false; - const labelId = inputId + '-lbl'; const label = findItemLabel(el); + const addPlaceholderClass = (text === undefined && placeholder != null) ? true : false; + + // If selected text has been passed in, use that first + // otherwise use the placeholder + const datetimeText = text === undefined + ? (placeholder != null ? placeholder : '') + : text; + if (label) { label.id = labelId; } - return { - 'role': 'combobox', - 'aria-disabled': disabled ? 'true' : null, - 'aria-expanded': `${isExpanded}`, - 'aria-haspopup': 'true', - 'aria-labelledby': labelId, - class: { - [`${mode}`]: true, - 'datetime-disabled': disabled, - 'datetime-readonly': readonly, - 'datetime-placeholder': addPlaceholderClass, - 'in-item': hostContext('ion-item', el) - } - }; - } + renderHiddenInput(true, el, this.name, this.value, this.disabled); - render() { - // If selected text has been passed in, use that first - // otherwise use the placeholder - let datetimeText = this.getText(); - if (datetimeText === undefined) { - datetimeText = this.placeholder != null ? this.placeholder : ''; - } - renderHiddenInput(true, this.el, this.name, this.value, this.disabled); - - return [ -
{datetimeText}
, - - ]; +
{datetimeText}
+ + + ); } } diff --git a/core/src/components/fab-button/fab-button.tsx b/core/src/components/fab-button/fab-button.tsx index 3bf215e117..30f9176e35 100755 --- a/core/src/components/fab-button/fab-button.tsx +++ b/core/src/components/fab-button/fab-button.tsx @@ -19,8 +19,6 @@ import { createColorClasses, hostContext, openURL } from '../../utils/theme'; export class FabButton implements ComponentInterface, AnchorInterface, ButtonInterface { @Element() el!: HTMLElement; - @Prop({ context: 'window' }) win!: Window; - /** * The color to use from your application's color palette. * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. @@ -117,7 +115,7 @@ export class FabButton implements ComponentInterface, AnchorInterface, ButtonInt 'aria-disabled': disabled ? 'true' : null, class: { ...createColorClasses(color), - [`${mode}`]: true, + [mode]: true, 'fab-button-in-list': inList, 'fab-button-translucent-in-list': inList && translucent, 'fab-button-close-active': activated, @@ -150,7 +148,7 @@ export class FabButton implements ComponentInterface, AnchorInterface, ButtonInt disabled={this.disabled} onFocus={this.onFocus} onBlur={this.onBlur} - onClick={(ev: Event) => openURL(this.win, this.href, ev, this.routerDirection)} + onClick={(ev: Event) => openURL(this.href, ev, this.routerDirection)} > diff --git a/core/src/components/fab-list/fab-list.tsx b/core/src/components/fab-list/fab-list.tsx index d8ae9855f7..f5a1937c1e 100644 --- a/core/src/components/fab-list/fab-list.tsx +++ b/core/src/components/fab-list/fab-list.tsx @@ -36,7 +36,7 @@ export class FabList implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, 'fab-list-active': this.activated, [`fab-list-side-${this.side}`]: true } diff --git a/core/src/components/fab/fab.tsx b/core/src/components/fab/fab.tsx index b1d495995a..c3585eada7 100644 --- a/core/src/components/fab/fab.tsx +++ b/core/src/components/fab/fab.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Listen, Method, Prop, Watch, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Host, Method, Prop, Watch, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; @@ -50,13 +50,19 @@ export class Fab implements ComponentInterface { this.activatedChanged(); } } + /** + * Close an active FAB list container. + */ + @Method() + async close() { + this.activated = false; + } - getFab() { + private getFab() { return this.el.querySelector('ion-fab-button'); } - @Listen('click') - onClick() { + private onClick = () => { const hasList = !!this.el.querySelector('ion-fab-list'); const getButton = this.getFab(); const isButtonDisabled = getButton && getButton.disabled; @@ -66,28 +72,22 @@ export class Fab implements ComponentInterface { } } - /** - * Close an active FAB list container. - */ - @Method() - async close() { - this.activated = false; - } - - hostData() { - const mode = getIonMode(this); - return { - class: { - [`${mode}`]: true, - [`fab-horizontal-${this.horizontal}`]: this.horizontal !== undefined, - [`fab-vertical-${this.vertical}`]: this.vertical !== undefined, - 'fab-edge': this.edge - } - }; - } - render() { - return ; + const { horizontal, vertical, edge } = this; + const mode = getIonMode(this); + return ( + + + + ); } } diff --git a/core/src/components/footer/footer.tsx b/core/src/components/footer/footer.tsx index 6fd2e9c59c..3be14b88c4 100644 --- a/core/src/components/footer/footer.tsx +++ b/core/src/components/footer/footer.tsx @@ -25,7 +25,7 @@ export class Footer implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, // Used internally for styling [`footer-${mode}`]: true, diff --git a/core/src/components/grid/grid.tsx b/core/src/components/grid/grid.tsx index 854cbc1049..dfe6d0e01c 100644 --- a/core/src/components/grid/grid.tsx +++ b/core/src/components/grid/grid.tsx @@ -18,7 +18,7 @@ export class Grid implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, 'grid-fixed': this.fixed } }; diff --git a/core/src/components/header/header.tsx b/core/src/components/header/header.tsx index f5cd174470..a0712b2b90 100644 --- a/core/src/components/header/header.tsx +++ b/core/src/components/header/header.tsx @@ -25,7 +25,7 @@ export class Header implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, // Used internally for styling [`header-${mode}`]: true, diff --git a/core/src/components/img/img.tsx b/core/src/components/img/img.tsx index fdc829a5f7..845333e0ee 100644 --- a/core/src/components/img/img.tsx +++ b/core/src/components/img/img.tsx @@ -94,7 +94,7 @@ export class Img implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, } }; } diff --git a/core/src/components/infinite-scroll-content/infinite-scroll-content.tsx b/core/src/components/infinite-scroll-content/infinite-scroll-content.tsx index b5fcc8e770..24b321fbd3 100644 --- a/core/src/components/infinite-scroll-content/infinite-scroll-content.tsx +++ b/core/src/components/infinite-scroll-content/infinite-scroll-content.tsx @@ -1,7 +1,8 @@ import { Component, ComponentInterface, Prop, h } from '@stencil/core'; +import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; -import { Config, SpinnerTypes } from '../../interface'; +import { SpinnerTypes } from '../../interface'; import { sanitizeDOMString } from '../../utils/sanitization'; @Component({ @@ -13,8 +14,6 @@ import { sanitizeDOMString } from '../../utils/sanitization'; }) export class InfiniteScrollContent implements ComponentInterface { - @Prop({ context: 'config' }) config!: Config; - /** * An animated SVG spinner that shows while loading. */ @@ -34,9 +33,9 @@ export class InfiniteScrollContent implements ComponentInterface { componentDidLoad() { if (this.loadingSpinner === undefined) { const mode = getIonMode(this); - this.loadingSpinner = this.config.get( + this.loadingSpinner = config.get( 'infiniteLoadingSpinner', - this.config.get('spinner', mode === 'ios' ? 'lines' : 'crescent') + config.get('spinner', mode === 'ios' ? 'lines' : 'crescent') ); } } @@ -45,7 +44,7 @@ export class InfiniteScrollContent implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, // Used internally for styling [`infinite-scroll-content-${mode}`]: true diff --git a/core/src/components/input/input.tsx b/core/src/components/input/input.tsx index 54a57d49a0..1cfa716632 100644 --- a/core/src/components/input/input.tsx +++ b/core/src/components/input/input.tsx @@ -341,7 +341,7 @@ export class Input implements ComponentInterface { 'aria-disabled': this.disabled ? 'true' : null, class: { ...createColorClasses(this.color), - [`${mode}`]: true, + [mode]: true, 'has-value': this.hasValue(), 'has-focus': this.hasFocus } diff --git a/core/src/components/item-divider/item-divider.tsx b/core/src/components/item-divider/item-divider.tsx index 7fa6aa77a8..b426d3c4a2 100644 --- a/core/src/components/item-divider/item-divider.tsx +++ b/core/src/components/item-divider/item-divider.tsx @@ -44,7 +44,7 @@ export class ItemDivider implements ComponentInterface { return { class: { ...createColorClasses(this.color), - [`${mode}`]: true, + [mode]: true, 'item-divider-sticky': this.sticky, 'item': true, } diff --git a/core/src/components/item-group/item-group.tsx b/core/src/components/item-group/item-group.tsx index 7f58f3fd34..5ab45bd266 100644 --- a/core/src/components/item-group/item-group.tsx +++ b/core/src/components/item-group/item-group.tsx @@ -16,7 +16,7 @@ export class ItemGroup implements ComponentInterface { return { 'role': 'group', class: { - [`${mode}`]: true, + [mode]: true, // Used internally for styling [`item-group-${mode}`]: true, diff --git a/core/src/components/item-option/item-option.tsx b/core/src/components/item-option/item-option.tsx index eab03a02e0..ea42479900 100644 --- a/core/src/components/item-option/item-option.tsx +++ b/core/src/components/item-option/item-option.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Listen, Prop, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Host, Prop, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { Color } from '../../interface'; @@ -76,58 +76,55 @@ export class ItemOption implements ComponentInterface, AnchorInterface, ButtonIn */ @Prop() type: 'submit' | 'reset' | 'button' = 'button'; - @Listen('click') - onClick(ev: Event) { + private onClick = (ev: Event) => { const el = (ev.target as HTMLElement).closest('ion-item-option'); if (el) { ev.preventDefault(); } } - hostData() { - const mode = getIonMode(this); - const { disabled, expandable } = this; - return { - class: { - ...createColorClasses(this.color), - [`${mode}`]: true, - - 'item-option-disabled': disabled, - 'item-option-expandable': expandable, - 'ion-activatable': true, - } - }; - } - render() { - const TagType = this.href === undefined ? 'button' : 'a' as any; + const { disabled, expandable, href } = this; + const TagType = href === undefined ? 'button' : 'a' as any; const mode = getIonMode(this); const attrs = (TagType === 'button') - ? { type: this.type } - : { - download: this.download, - href: this.href, - target: this.target - }; + ? { type: this.type } + : { + download: this.download, + href: this.href, + target: this.target + }; return ( - - - -
- - - - -
- -
- {mode === 'md' && } -
+ + + +
+ + + + +
+ +
+ {mode === 'md' && } +
+ ); } } diff --git a/core/src/components/item-options/item-options.tsx b/core/src/components/item-options/item-options.tsx index 5fde6a0c74..945519877a 100644 --- a/core/src/components/item-options/item-options.tsx +++ b/core/src/components/item-options/item-options.tsx @@ -15,8 +15,6 @@ export class ItemOptions implements ComponentInterface { @Element() el!: HTMLElement; - @Prop({ context: 'window' }) win!: Window; - /** * The side the option button should be on. Possible values: `"start"` and `"end"`. If you have multiple `ion-item-options`, a side must be provided for each. * @@ -38,11 +36,11 @@ export class ItemOptions implements ComponentInterface { hostData() { const mode = getIonMode(this); - const isEnd = isEndSide(this.win, this.side); + const isEnd = isEndSide(this.side); return { class: { - [`${mode}`]: true, + [mode]: true, // Used internally for styling [`item-options-${mode}`]: true, diff --git a/core/src/components/item-sliding/item-sliding.tsx b/core/src/components/item-sliding/item-sliding.tsx index 8798dfe4e7..a01d79ba32 100644 --- a/core/src/components/item-sliding/item-sliding.tsx +++ b/core/src/components/item-sliding/item-sliding.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Event, EventEmitter, Method, Prop, QueueApi, State, Watch } from '@stencil/core'; +import { Component, ComponentInterface, Element, Event, EventEmitter, Method, Prop, State, Watch } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { Gesture, GestureDetail, Side } from '../../interface'; @@ -48,8 +48,6 @@ export class ItemSliding implements ComponentInterface { @State() state: SlidingState = SlidingState.Disabled; - @Prop({ context: 'queue' }) queue!: QueueApi; - /** * If `true`, the user cannot interact with the sliding item. */ @@ -138,7 +136,7 @@ export class ItemSliding implements ComponentInterface { } // In RTL we want to switch the sides - side = isEndSide(window, side) ? 'end' : 'start'; + side = isEndSide(side) ? 'end' : 'start'; const isStartOpen = this.openAmount < 0; const isEndOpen = this.openAmount > 0; @@ -213,7 +211,7 @@ export class ItemSliding implements ComponentInterface { for (let i = 0; i < options.length; i++) { const option = await options.item(i).componentOnReady(); - const side = isEndSide(window, option.side) ? 'end' : 'start'; + const side = isEndSide(option.side) ? 'end' : 'start'; if (side === 'start') { this.leftOptions = option; @@ -380,7 +378,7 @@ export class ItemSliding implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, 'item-sliding-active-slide': (this.state !== SlidingState.Disabled), 'item-sliding-active-options-end': (this.state & SlidingState.End) !== 0, 'item-sliding-active-options-start': (this.state & SlidingState.Start) !== 0, diff --git a/core/src/components/item/item.tsx b/core/src/components/item/item.tsx index f350b1e7b4..fb79706284 100644 --- a/core/src/components/item/item.tsx +++ b/core/src/components/item/item.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Listen, Prop, State, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Host, Listen, Prop, State, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { Color, CssClassMap, RouterDirection, StyleEventDetail } from '../../interface'; @@ -28,8 +28,6 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac @State() multipleInputs = false; - @Prop({ context: 'window' }) win!: Window; - /** * The color to use from your application's color palette. * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. @@ -139,65 +137,60 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac return (this.href !== undefined || this.button); } - hostData() { - const mode = getIonMode(this); + render() { + const { detail, detailIcon, download, lines, disabled, href, rel, target, routerDirection } = this; const childStyles = {}; + const mode = getIonMode(this); + const clickable = this.isClickable(); + const TagType = clickable ? (href === undefined ? 'button' : 'a') : 'div' as any; + const attrs = (TagType === 'button') + ? { type: this.type } + : { + download, + href, + rel, + target + }; + const showDetail = detail !== undefined ? detail : mode === 'ios' && clickable; this.itemStyles.forEach(value => { Object.assign(childStyles, value); }); - return { - 'aria-disabled': this.disabled ? 'true' : null, - class: { - ...childStyles, - ...createColorClasses(this.color), - 'item': true, - [`${mode}`]: true, - [`item-lines-${this.lines}`]: this.lines !== undefined, - 'item-disabled': this.disabled, - 'in-list': hostContext('ion-list', this.el), - 'item-multiple-inputs': this.multipleInputs, - 'ion-activatable': this.isClickable(), - 'ion-focusable': true, - } - }; - } - - render() { - const mode = getIonMode(this); - const { detail, win, detailIcon, routerDirection } = this; - - const clickable = this.isClickable(); - const TagType = clickable ? (this.href === undefined ? 'button' : 'a') : 'div' as any; - const attrs = (TagType === 'button') - ? { type: this.type } - : { - download: this.download, - href: this.href, - rel: this.rel, - target: this.target - }; - const showDetail = detail !== undefined ? detail : mode === 'ios' && clickable; - - return [ - openURL(win, this.href, ev, routerDirection)} + return ( + - -
-
- -
- - {showDetail && } -
-
- {clickable && mode === 'md' && } -
, -
- ]; + openURL(href, ev, routerDirection)} + > + +
+
+ +
+ + {showDetail && } +
+
+ {clickable && mode === 'md' && } +
+
+ + ); } } diff --git a/core/src/components/label/label.tsx b/core/src/components/label/label.tsx index 95b59fd17c..10f7fd3e93 100644 --- a/core/src/components/label/label.tsx +++ b/core/src/components/label/label.tsx @@ -70,7 +70,7 @@ export class Label implements ComponentInterface { return { class: { ...createColorClasses(this.color), - [`${mode}`]: true, + [mode]: true, [`label-${position}`]: position !== undefined, [`label-no-animate`]: (this.noAnimate) } diff --git a/core/src/components/list-header/list-header.tsx b/core/src/components/list-header/list-header.tsx index 027706d7dd..b44c2eb5b7 100644 --- a/core/src/components/list-header/list-header.tsx +++ b/core/src/components/list-header/list-header.tsx @@ -29,7 +29,7 @@ export class ListHeader implements ComponentInterface { return { class: { ...createColorClasses(this.color), - [`${mode}`]: true, + [mode]: true, } }; } diff --git a/core/src/components/list/list.tsx b/core/src/components/list/list.tsx index c91fc3ea8e..213669df8b 100644 --- a/core/src/components/list/list.tsx +++ b/core/src/components/list/list.tsx @@ -45,7 +45,7 @@ export class List implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, // Used internally for styling [`list-${mode}`]: true, diff --git a/core/src/components/loading-controller/loading-controller.tsx b/core/src/components/loading-controller/loading-controller.tsx index 7beec386e2..e091eba9ac 100644 --- a/core/src/components/loading-controller/loading-controller.tsx +++ b/core/src/components/loading-controller/loading-controller.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Method, Prop } from '@stencil/core'; +import { Component, ComponentInterface, Method } from '@stencil/core'; import { LoadingOptions, OverlayController } from '../../interface'; import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays'; @@ -8,8 +8,6 @@ import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays' }) export class LoadingController implements ComponentInterface, OverlayController { - @Prop({ context: 'document' }) doc!: Document; - /** * Create a loading overlay with loading options. * diff --git a/core/src/components/loading/loading.tsx b/core/src/components/loading/loading.tsx index bb25499fb3..a328303c1b 100644 --- a/core/src/components/loading/loading.tsx +++ b/core/src/components/loading/loading.tsx @@ -1,7 +1,8 @@ -import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Method, Prop, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Method, Prop, h } from '@stencil/core'; +import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; -import { Animation, AnimationBuilder, Config, OverlayEventDetail, OverlayInterface, SpinnerTypes } from '../../interface'; +import { Animation, AnimationBuilder, OverlayEventDetail, OverlayInterface, SpinnerTypes } from '../../interface'; import { BACKDROP, dismiss, eventMethod, present } from '../../utils/overlays'; import { sanitizeDOMString } from '../../utils/sanitization'; import { getClassMap } from '../../utils/theme'; @@ -31,8 +32,6 @@ export class Loading implements ComponentInterface, OverlayInterface { @Element() el!: HTMLElement; - @Prop({ context: 'config' }) config!: Config; - /** @internal */ @Prop() overlayIndex!: number; @@ -115,18 +114,13 @@ export class Loading implements ComponentInterface, OverlayInterface { componentWillLoad() { if (this.spinner === undefined) { const mode = getIonMode(this); - this.spinner = this.config.get( + this.spinner = config.get( 'loadingSpinner', - this.config.get('spinner', mode === 'ios' ? 'lines' : 'crescent') + config.get('spinner', mode === 'ios' ? 'lines' : 'crescent') ); } } - @Listen('ionBackdropTap') - protected onBackdropTap() { - this.dismiss(undefined, BACKDROP); - } - /** * Present the loading overlay after it has been created. */ @@ -175,32 +169,36 @@ export class Loading implements ComponentInterface, OverlayInterface { return eventMethod(this.el, 'ionLoadingWillDismiss'); } - hostData() { - const mode = getIonMode(this); - return { - style: { - zIndex: 40000 + this.overlayIndex - }, - class: { - ...getClassMap(this.cssClass), - [`${mode}`]: true, - 'loading-translucent': this.translucent - } - }; + private onBackdropTap = () => { + this.dismiss(undefined, BACKDROP); } render() { - return [ - , - + + ); } } diff --git a/core/src/components/menu-button/menu-button.tsx b/core/src/components/menu-button/menu-button.tsx index 2a198be4d6..8173d88db5 100644 --- a/core/src/components/menu-button/menu-button.tsx +++ b/core/src/components/menu-button/menu-button.tsx @@ -1,7 +1,8 @@ import { Component, ComponentInterface, Prop, h } from '@stencil/core'; +import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; -import { Color, Config } from '../../interface'; +import { Color } from '../../interface'; import { ButtonInterface } from '../../utils/element-interface'; import { createColorClasses } from '../../utils/theme'; @@ -15,8 +16,6 @@ import { createColorClasses } from '../../utils/theme'; }) export class MenuButton implements ComponentInterface, ButtonInterface { - @Prop({ context: 'config' }) config!: Config; - /** * The color to use from your application's color palette. * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. @@ -53,7 +52,7 @@ export class MenuButton implements ComponentInterface, ButtonInterface { class: { ...createColorClasses(color), - [`${mode}`]: true, + [mode]: true, 'button': true, // ion-buttons target .button 'menu-button-disabled': disabled, @@ -65,7 +64,7 @@ export class MenuButton implements ComponentInterface, ButtonInterface { render() { const mode = getIonMode(this); - const menuIcon = this.config.get('menuIcon', 'menu'); + const menuIcon = config.get('menuIcon', 'menu'); const attrs = { type: this.type diff --git a/core/src/components/menu-controller/menu-controller.ts b/core/src/components/menu-controller/menu-controller.ts index f91b65fbd5..1baeabc98b 100644 --- a/core/src/components/menu-controller/menu-controller.ts +++ b/core/src/components/menu-controller/menu-controller.ts @@ -1,6 +1,7 @@ -import { Build, Component, Method, Prop } from '@stencil/core'; +import { Build, Component, Method } from '@stencil/core'; -import { Animation, AnimationBuilder, Config, MenuControllerI, MenuI } from '../../interface'; +import { config } from '../../global/config'; +import { Animation, AnimationBuilder, MenuControllerI, MenuI } from '../../interface'; import { menuOverlayAnimation } from './animations/overlay'; import { menuPushAnimation } from './animations/push'; @@ -15,9 +16,6 @@ export class MenuController implements MenuControllerI { private menus: MenuI[] = []; private menuAnimations = new Map(); - @Prop({ context: 'document' }) doc!: Document; - @Prop({ context: 'config' }) config!: Config; - constructor() { this.registerAnimation('reveal', menuRevealAnimation); this.registerAnimation('push', menuPushAnimation); @@ -287,7 +285,7 @@ export class MenuController implements MenuControllerI { } const animation = await import('../../utils/animation') .then(mod => mod.create(animationBuilder, null, menuCmp)); - if (!this.config.getBoolean('animated', true)) { + if (!config.getBoolean('animated', true)) { animation.duration(0); } return animation; diff --git a/core/src/components/menu-toggle/menu-toggle.tsx b/core/src/components/menu-toggle/menu-toggle.tsx index 879ec61d25..1482696759 100644 --- a/core/src/components/menu-toggle/menu-toggle.tsx +++ b/core/src/components/menu-toggle/menu-toggle.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Listen, Prop, State, h } from '@stencil/core'; +import { Component, ComponentInterface, Host, Listen, Prop, State, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; @@ -9,8 +9,6 @@ import { getIonMode } from '../../global/ionic-global'; }) export class MenuToggle implements ComponentInterface { - @Prop({ context: 'document' }) doc!: Document; - @State() visible = false; /** @@ -35,17 +33,6 @@ export class MenuToggle implements ComponentInterface { return this.updateVisibility(); } - @Listen('click') - async onClick() { - const menuCtrl = await getMenuController(document); - if (menuCtrl) { - const menu = await menuCtrl.get(this.menu); - if (menu) { - menuCtrl.toggle(this.menu); - } - } - } - @Listen('ionMenuChange', { target: 'body' }) @Listen('ionSplitPaneVisible', { target: 'body' }) async updateVisibility() { @@ -60,20 +47,31 @@ export class MenuToggle implements ComponentInterface { this.visible = false; } - hostData() { + private onClick = async () => { + const menuCtrl = await getMenuController(document); + if (menuCtrl) { + const menu = await menuCtrl.get(this.menu); + if (menu) { + menuCtrl.toggle(this.menu); + } + } + } + render() { const mode = getIonMode(this); const hidden = this.autoHide && !this.visible; - return { - 'aria-hidden': hidden ? 'true' : null, - class: { - [`${mode}`]: true, - 'menu-toggle-hidden': hidden, - } - }; - } - render() { - return ; + return ( + + + + ); } } diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index 1b34f58163..a20ab5d8b4 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -1,6 +1,7 @@ import { Build, Component, ComponentInterface, Element, Event, EventEmitter, Listen, Method, Prop, State, Watch, h } from '@stencil/core'; -import { config, getIonMode } from '../../global/ionic-global'; +import { config } from '../../global/config'; +import { getIonMode } from '../../global/ionic-global'; import { Animation, Gesture, GestureDetail, MenuChangeEventDetail, MenuControllerI, MenuI, Side } from '../../interface'; import { GESTURE_CONTROLLER } from '../../utils/gesture'; import { assert, isEndSide as isEnd } from '../../utils/helpers'; @@ -93,7 +94,7 @@ export class Menu implements ComponentInterface, MenuI { @Watch('side') protected sideChanged() { - this.isEndSide = isEnd(window, this.side); + this.isEndSide = isEnd(this.side); } /** diff --git a/core/src/components/modal-controller/modal-controller.tsx b/core/src/components/modal-controller/modal-controller.tsx index 0fff1d3443..2e5a8261e1 100644 --- a/core/src/components/modal-controller/modal-controller.tsx +++ b/core/src/components/modal-controller/modal-controller.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Method, Prop } from '@stencil/core'; +import { Component, ComponentInterface, Method } from '@stencil/core'; import { ComponentRef, ModalOptions, OverlayController } from '../../interface'; import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays'; @@ -8,8 +8,6 @@ import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays' }) export class ModalController implements ComponentInterface, OverlayController { - @Prop({ context: 'document' }) doc!: Document; - /** * Create a modal overlay with modal options. * diff --git a/core/src/components/modal/modal.tsx b/core/src/components/modal/modal.tsx index 60bfad299c..2e8b691f33 100644 --- a/core/src/components/modal/modal.tsx +++ b/core/src/components/modal/modal.tsx @@ -1,7 +1,7 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Method, Prop, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; -import { Animation, AnimationBuilder, ComponentProps, ComponentRef, Config, FrameworkDelegate, OverlayEventDetail, OverlayInterface } from '../../interface'; +import { Animation, AnimationBuilder, ComponentProps, ComponentRef, FrameworkDelegate, OverlayEventDetail, OverlayInterface } from '../../interface'; import { attachComponent, detachComponent } from '../../utils/framework-delegate'; import { BACKDROP, dismiss, eventMethod, present } from '../../utils/overlays'; import { getClassMap } from '../../utils/theme'; @@ -33,8 +33,6 @@ export class Modal implements ComponentInterface, OverlayInterface { @Element() el!: HTMLElement; - @Prop({ context: 'config' }) config!: Config; - /** @internal */ @Prop() overlayIndex!: number; @@ -195,7 +193,7 @@ export class Modal implements ComponentInterface, OverlayInterface { 'no-router': true, 'aria-modal': 'true', class: { - [`${mode}`]: true, + [mode]: true, ...getClassMap(this.cssClass) }, style: { @@ -208,7 +206,7 @@ export class Modal implements ComponentInterface, OverlayInterface { const mode = getIonMode(this); const dialogClasses = { [`modal-wrapper`]: true, - [`${mode}`]: true, + [mode]: true, }; return [ diff --git a/core/src/components/nav-pop/nav-pop.tsx b/core/src/components/nav-pop/nav-pop.tsx index 944a6ec7f0..1a377610cd 100644 --- a/core/src/components/nav-pop/nav-pop.tsx +++ b/core/src/components/nav-pop/nav-pop.tsx @@ -7,7 +7,7 @@ export class NavPop implements ComponentInterface { @Element() el!: HTMLElement; - @Listen('child:click') + @Listen('click') pop() { const nav = this.el.closest('ion-nav'); if (nav) { diff --git a/core/src/components/nav-push/nav-push.tsx b/core/src/components/nav-push/nav-push.tsx index af5dd24b4f..fe18e10ba1 100644 --- a/core/src/components/nav-push/nav-push.tsx +++ b/core/src/components/nav-push/nav-push.tsx @@ -18,7 +18,7 @@ export class NavPush implements ComponentInterface { */ @Prop() componentProps?: ComponentProps; - @Listen('child:click') + @Listen('click') push() { const nav = this.el.closest('ion-nav'); const toPush = this.component; diff --git a/core/src/components/nav-set-root/nav-set-root.tsx b/core/src/components/nav-set-root/nav-set-root.tsx index 0b72ac0499..9effae9c3a 100644 --- a/core/src/components/nav-set-root/nav-set-root.tsx +++ b/core/src/components/nav-set-root/nav-set-root.tsx @@ -19,7 +19,7 @@ export class NavSetRoot implements ComponentInterface { */ @Prop() componentProps?: ComponentProps; - @Listen('child:click') + @Listen('click') push() { const nav = this.el.closest('ion-nav'); const toPush = this.component; diff --git a/core/src/components/nav/nav.tsx b/core/src/components/nav/nav.tsx index e13983a78b..56ef070bc4 100644 --- a/core/src/components/nav/nav.tsx +++ b/core/src/components/nav/nav.tsx @@ -1,7 +1,8 @@ -import { Build, Component, Element, Event, EventEmitter, Method, Prop, QueueApi, Watch, h } from '@stencil/core'; +import { Build, Component, Element, Event, EventEmitter, Method, Prop, Watch, h } from '@stencil/core'; +import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; -import { Animation, AnimationBuilder, ComponentProps, Config, FrameworkDelegate, Gesture, NavComponent, NavOptions, NavOutlet, NavResult, RouteID, RouteWrite, RouterDirection, TransitionDoneFn, TransitionInstruction, ViewController } from '../../interface'; +import { Animation, AnimationBuilder, ComponentProps, FrameworkDelegate, Gesture, NavComponent, NavOptions, NavOutlet, NavResult, RouteID, RouteWrite, RouterDirection, TransitionDoneFn, TransitionInstruction, ViewController } from '../../interface'; import { assert } from '../../utils/helpers'; import { TransitionOptions, lifecycle, setPageHidden, transition } from '../../utils/transition'; @@ -25,10 +26,6 @@ export class Nav implements NavOutlet { @Element() el!: HTMLElement; - @Prop({ context: 'queue' }) queue!: QueueApi; - @Prop({ context: 'config' }) config!: Config; - @Prop({ context: 'window' }) win!: Window; - /** @internal */ @Prop() delegate?: FrameworkDelegate; @@ -94,12 +91,12 @@ export class Nav implements NavOutlet { componentWillLoad() { this.useRouter = - !!this.win.document.querySelector('ion-router') && + !!document.querySelector('ion-router') && !this.el.closest('[no-router]'); if (this.swipeGesture === undefined) { const mode = getIonMode(this); - this.swipeGesture = this.config.getBoolean( + this.swipeGesture = config.getBoolean( 'swipeBackEnabled', mode === 'ios' ); @@ -251,18 +248,18 @@ export class Nav implements NavOutlet { opts?: NavOptions | null, done?: TransitionDoneFn ): Promise { - const config: TransitionInstruction = { + const tiConfig: TransitionInstruction = { removeStart: -1, removeCount: -1, opts }; if (typeof indexOrViewCtrl === 'object' && (indexOrViewCtrl as ViewController).component) { - config.removeView = indexOrViewCtrl; - config.removeStart = 1; + tiConfig.removeView = indexOrViewCtrl; + tiConfig.removeStart = 1; } else if (typeof indexOrViewCtrl === 'number') { - config.removeStart = indexOrViewCtrl + 1; + tiConfig.removeStart = indexOrViewCtrl + 1; } - return this.queueTrns(config, done); + return this.queueTrns(tiConfig, done); } /** @@ -555,7 +552,7 @@ export class Nav implements NavOutlet { ti.resolve!(result.hasCompleted); if (ti.opts!.updateURL !== false && this.useRouter) { - const router = this.win.document.querySelector('ion-router'); + const router = document.querySelector('ion-router'); if (router) { const direction = result.direction === 'back' ? 'back' : 'forward'; router.navChanged(direction); @@ -834,11 +831,10 @@ export class Nav implements NavOutlet { const animationOpts: TransitionOptions = { mode, showGoBack: this.canGoBackSync(enteringView), - window: this.win, baseEl: this.el, - animationBuilder: this.animation || opts.animationBuilder || this.config.get('navAnimation'), + animationBuilder: this.animation || opts.animationBuilder || config.get('navAnimation'), progressCallback, - animated: this.animated && this.config.getBoolean('animated', true), + animated: this.animated && config.getBoolean('animated', true), enteringEl, leavingEl, diff --git a/core/src/components/note/note.tsx b/core/src/components/note/note.tsx index c3e8488a80..1d58ffe873 100644 --- a/core/src/components/note/note.tsx +++ b/core/src/components/note/note.tsx @@ -28,7 +28,7 @@ export class Note implements ComponentInterface { return { class: { ...createColorClasses(this.color), - [`${mode}`]: true, + [mode]: true, } }; } diff --git a/core/src/components/picker-column/picker-column.tsx b/core/src/components/picker-column/picker-column.tsx index 2424ec5f5e..5ec3332444 100644 --- a/core/src/components/picker-column/picker-column.tsx +++ b/core/src/components/picker-column/picker-column.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Event, EventEmitter, Prop, QueueApi, Watch, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Event, EventEmitter, Prop, Watch, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { Gesture, GestureDetail, PickerColumn } from '../../interface'; @@ -34,8 +34,6 @@ export class PickerColumnCmp implements ComponentInterface { @Element() el!: HTMLElement; - @Prop({ context: 'queue' }) queue!: QueueApi; - /** * Emitted when the selected value has changed * @internal @@ -351,7 +349,7 @@ export class PickerColumnCmp implements ComponentInterface { const mode = getIonMode(this); return { class: { - [`${mode}`]: true, + [mode]: true, 'picker-col': true, 'picker-opts-left': this.col.align === 'left', 'picker-opts-right': this.col.align === 'right' diff --git a/core/src/components/picker-controller/picker-controller.tsx b/core/src/components/picker-controller/picker-controller.tsx index 5fdbdefc87..7e4c4a534a 100644 --- a/core/src/components/picker-controller/picker-controller.tsx +++ b/core/src/components/picker-controller/picker-controller.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Method, Prop } from '@stencil/core'; +import { Component, ComponentInterface, Method } from '@stencil/core'; import { OverlayController, PickerOptions } from '../../interface'; import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays'; @@ -8,8 +8,6 @@ import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays' }) export class PickerController implements ComponentInterface, OverlayController { - @Prop({ context: 'document' }) doc!: Document; - /** * Create a picker overlay with picker options. * diff --git a/core/src/components/picker/picker.tsx b/core/src/components/picker/picker.tsx index 02859d0033..dd72851c34 100644 --- a/core/src/components/picker/picker.tsx +++ b/core/src/components/picker/picker.tsx @@ -1,7 +1,7 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Method, Prop, State, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; -import { Animation, AnimationBuilder, Config, CssClassMap, OverlayEventDetail, OverlayInterface, PickerButton, PickerColumn } from '../../interface'; +import { Animation, AnimationBuilder, CssClassMap, OverlayEventDetail, OverlayInterface, PickerButton, PickerColumn } from '../../interface'; import { dismiss, eventMethod, present } from '../../utils/overlays'; import { getClassMap } from '../../utils/theme'; @@ -28,8 +28,6 @@ export class Picker implements ComponentInterface, OverlayInterface { @Element() el!: HTMLElement; - @Prop({ context: 'config' }) config!: Config; - @State() presented = false; /** @internal */ @@ -214,7 +212,7 @@ export class Picker implements ComponentInterface, OverlayInterface { return { 'aria-modal': 'true', class: { - [`${mode}`]: true, + [mode]: true, // Used internally for styling [`picker-${mode}`]: true, diff --git a/core/src/components/popover-controller/popover-controller.tsx b/core/src/components/popover-controller/popover-controller.tsx index 06a0b85b17..6cf6357a0c 100644 --- a/core/src/components/popover-controller/popover-controller.tsx +++ b/core/src/components/popover-controller/popover-controller.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Method, Prop } from '@stencil/core'; +import { Component, ComponentInterface, Method } from '@stencil/core'; import { ComponentRef, OverlayController, PopoverOptions } from '../../interface'; import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays'; @@ -8,8 +8,6 @@ import { createOverlay, dismissOverlay, getOverlay } from '../../utils/overlays' }) export class PopoverController implements ComponentInterface, OverlayController { - @Prop({ context: 'document' }) doc!: Document; - /** * Create a popover overlay with popover options. * diff --git a/core/src/components/popover/popover.tsx b/core/src/components/popover/popover.tsx index ba0c2ba446..1dbff2bfd1 100644 --- a/core/src/components/popover/popover.tsx +++ b/core/src/components/popover/popover.tsx @@ -1,7 +1,7 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Method, Prop, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; -import { Animation, AnimationBuilder, ComponentProps, ComponentRef, Config, FrameworkDelegate, OverlayEventDetail, OverlayInterface } from '../../interface'; +import { Animation, AnimationBuilder, ComponentProps, ComponentRef, FrameworkDelegate, OverlayEventDetail, OverlayInterface } from '../../interface'; import { attachComponent, detachComponent } from '../../utils/framework-delegate'; import { BACKDROP, dismiss, eventMethod, present } from '../../utils/overlays'; import { getClassMap } from '../../utils/theme'; @@ -33,8 +33,6 @@ export class Popover implements ComponentInterface, OverlayInterface { @Element() el!: HTMLElement; - @Prop({ context: 'config' }) config!: Config; - /** @internal */ @Prop() delegate?: FrameworkDelegate; @@ -209,7 +207,7 @@ export class Popover implements ComponentInterface, OverlayInterface { }, class: { ...getClassMap(this.cssClass), - [`${mode}`]: true, + [mode]: true, 'popover-translucent': this.translucent } }; diff --git a/core/src/components/progress-bar/progress-bar.tsx b/core/src/components/progress-bar/progress-bar.tsx index e6381a4a8b..7b1e21168f 100644 --- a/core/src/components/progress-bar/progress-bar.tsx +++ b/core/src/components/progress-bar/progress-bar.tsx @@ -1,7 +1,8 @@ import { Component, ComponentInterface, Prop, h } from '@stencil/core'; +import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; -import { Color, Config } from '../../interface'; +import { Color } from '../../interface'; import { clamp } from '../../utils/helpers'; import { createColorClasses } from '../../utils/theme'; @@ -18,8 +19,6 @@ import { createColorClasses } from '../../utils/theme'; }) export class ProgressBar implements ComponentInterface { - @Prop({ context: 'config' }) config!: Config; - /** * The state of the progress bar, based on if the time the process takes is known or not. * Default options are: `"determinate"` (no animation), `"indeterminate"` (animate from left to right). @@ -53,7 +52,7 @@ export class ProgressBar implements ComponentInterface { hostData() { const { color, type, reversed, value } = this; - const paused = this.config.getBoolean('_testing'); + const paused = config.getBoolean('_testing'); const mode = getIonMode(this); return { 'role': 'progressbar', @@ -62,7 +61,7 @@ export class ProgressBar implements ComponentInterface { 'aria-valuemax': 1, class: { ...createColorClasses(color), - [`${mode}`]: true, + [mode]: true, [`progress-bar-${type}`]: true, 'progress-paused': paused, 'progress-bar-reversed': document.dir === 'rtl' ? !reversed : reversed diff --git a/core/src/components/radio-group/radio-group.tsx b/core/src/components/radio-group/radio-group.tsx index 69c79c5773..45e596368b 100644 --- a/core/src/components/radio-group/radio-group.tsx +++ b/core/src/components/radio-group/radio-group.tsx @@ -126,7 +126,7 @@ export class RadioGroup implements ComponentInterface { 'role': 'radiogroup', 'aria-labelledby': this.labelId, class: { - [`${mode}`]: true, + [mode]: true, } }; } diff --git a/core/src/components/radio/radio.tsx b/core/src/components/radio/radio.tsx index 600aad369c..9ccdaa17c2 100644 --- a/core/src/components/radio/radio.tsx +++ b/core/src/components/radio/radio.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Prop, Watch, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Prop, Watch, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { Color, RadioChangeEventDetail, StyleEventDetail } from '../../interface'; @@ -124,15 +124,6 @@ export class Radio implements ComponentInterface { this.ionRadioDidUnload.emit(); } - @Listen('click') - onClick() { - if (this.checked) { - this.ionDeselect.emit(); - } else { - this.checked = true; - } - } - private emitStyle() { this.ionStyle.emit({ 'radio-checked': this.checked, @@ -148,7 +139,15 @@ export class Radio implements ComponentInterface { this.ionBlur.emit(); } - hostData() { + private onClick = () => { + if (this.checked) { + this.ionDeselect.emit(); + } else { + this.checked = true; + } + } + + render() { const { inputId, disabled, checked, color, el } = this; const mode = getIonMode(this); const labelId = inputId + '-lbl'; @@ -156,35 +155,34 @@ export class Radio implements ComponentInterface { if (label) { label.id = labelId; } - return { - 'role': 'radio', - 'aria-disabled': disabled ? 'true' : null, - 'aria-checked': `${checked}`, - 'aria-labelledby': labelId, - class: { - ...createColorClasses(color), - [`${mode}`]: true, - 'in-item': hostContext('ion-item', el), - 'interactive': true, - 'radio-checked': checked, - 'radio-disabled': disabled, - } - }; - } - - render() { - return [ -
-
-
, - , - ]; +
+
+
+ + + ); } } diff --git a/core/src/components/range/range.tsx b/core/src/components/range/range.tsx index 20b873c40d..7530d4664d 100644 --- a/core/src/components/range/range.tsx +++ b/core/src/components/range/range.tsx @@ -1,4 +1,4 @@ -import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Prop, QueueApi, State, Watch, h } from '@stencil/core'; +import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Prop, State, Watch, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { Color, Gesture, GestureDetail, KnobName, RangeChangeEventDetail, RangeValue, StyleEventDetail } from '../../interface'; @@ -29,9 +29,6 @@ export class Range implements ComponentInterface { @Element() el!: HTMLIonRangeElement; - @Prop({ context: 'queue' }) queue!: QueueApi; - @Prop({ context: 'document' }) doc!: Document; - @State() private ratioA = 0; @State() private ratioB = 0; @State() private pressedKnob: KnobName; @@ -172,24 +169,6 @@ export class Range implements ComponentInterface { */ @Event() ionBlur!: EventEmitter; - @Listen('focusout') - onBlur() { - if (this.hasFocus) { - this.hasFocus = false; - this.ionBlur.emit(); - this.emitStyle(); - } - } - - @Listen('focusin') - onFocus() { - if (!this.hasFocus) { - this.hasFocus = true; - this.ionFocus.emit(); - this.emitStyle(); - } - } - componentWillLoad() { this.updateRatio(); this.debounceChanged(); @@ -372,23 +351,26 @@ export class Range implements ComponentInterface { } } - hostData() { - const mode = getIonMode(this); - return { - class: { - ...createColorClasses(this.color), - [`${mode}`]: true, - 'in-item': hostContext('ion-item', this.el), - 'range-disabled': this.disabled, - 'range-pressed': this.pressedKnob !== undefined, - 'range-has-pin': this.pin - } - }; + private onBlur = () => { + if (this.hasFocus) { + this.hasFocus = false; + this.ionBlur.emit(); + this.emitStyle(); + } + } + + private onFocus = () => { + if (!this.hasFocus) { + this.hasFocus = true; + this.ionFocus.emit(); + this.emitStyle(); + } } render() { - const { min, max, step, ratioLower, ratioUpper } = this; + const { min, max, step, el, handleKeyboard, pressedKnob, disabled, pin, ratioLower, ratioUpper } = this; + const mode = getIonMode(this); const barStart = `${ratioLower * 100}%`; const barEnd = `${100 - ratioUpper * 100}%`; @@ -397,6 +379,17 @@ export class Range implements ComponentInterface { const start = isRTL ? 'right' : 'left'; const end = isRTL ? 'left' : 'right'; + const tickStyle = (tick: any) => { + return { + [start]: tick[start] + }; + }; + + const barStyle = { + [start]: barStart, + [end]: barEnd + }; + const ticks = []; if (this.snaps && this.ticks) { for (let value = min; value <= max; value += step) { @@ -413,70 +406,67 @@ export class Range implements ComponentInterface { } } - const tickStyle = (tick: any) => { - const style: any = {}; + return ( + - style[start] = tick[start]; + +
this.rangeSlider = rangeEl}> + {ticks.map(tick => ( +