mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(): update to Stencil One 🎉🎊
This commit is contained in:
@ -1,10 +1,14 @@
|
||||
import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Prop, QueueApi, State, Watch } from '@stencil/core';
|
||||
import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Prop, QueueApi, State, Watch, h } from '@stencil/core';
|
||||
|
||||
import { Color, Gesture, GestureDetail, Mode, StyleEventDetail, ToggleChangeEventDetail } from '../../interface';
|
||||
import { getIonMode } from '../../global/ionic-global';
|
||||
import { Color, Gesture, GestureDetail, StyleEventDetail, ToggleChangeEventDetail } from '../../interface';
|
||||
import { hapticSelection } from '../../utils/haptic';
|
||||
import { findItemLabel, renderHiddenInput } from '../../utils/helpers';
|
||||
import { createColorClasses, hostContext } from '../../utils/theme';
|
||||
|
||||
/**
|
||||
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
|
||||
*/
|
||||
@Component({
|
||||
tag: 'ion-toggle',
|
||||
styleUrls: {
|
||||
@ -28,11 +32,6 @@ export class Toggle implements ComponentInterface {
|
||||
|
||||
@State() activated = false;
|
||||
|
||||
/**
|
||||
* The mode determines which platform styles to use.
|
||||
*/
|
||||
@Prop() mode!: Mode;
|
||||
|
||||
/**
|
||||
* 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 +107,6 @@ export class Toggle implements ComponentInterface {
|
||||
async componentDidLoad() {
|
||||
this.gesture = (await import('../../utils/gesture')).createGesture({
|
||||
el: this.el,
|
||||
queue: this.queue,
|
||||
gestureName: 'toggle',
|
||||
gesturePriority: 100,
|
||||
threshold: 5,
|
||||
@ -148,7 +146,7 @@ export class Toggle implements ComponentInterface {
|
||||
}
|
||||
|
||||
private onMove(detail: GestureDetail) {
|
||||
if (shouldToggle(this.doc, this.checked, detail.deltaX, -10)) {
|
||||
if (shouldToggle(document, this.checked, detail.deltaX, -10)) {
|
||||
this.checked = !this.checked;
|
||||
hapticSelection();
|
||||
}
|
||||
@ -181,6 +179,7 @@ export class Toggle implements ComponentInterface {
|
||||
|
||||
hostData() {
|
||||
const { inputId, disabled, checked, activated, color, el } = this;
|
||||
const mode = getIonMode(this);
|
||||
const labelId = inputId + '-lbl';
|
||||
const label = findItemLabel(el);
|
||||
if (label) {
|
||||
@ -195,7 +194,7 @@ export class Toggle implements ComponentInterface {
|
||||
|
||||
class: {
|
||||
...createColorClasses(color),
|
||||
[`${this.mode}`]: true,
|
||||
[`${mode}`]: true,
|
||||
'in-item': hostContext('ion-item', el),
|
||||
'toggle-activated': activated,
|
||||
'toggle-checked': checked,
|
||||
|
Reference in New Issue
Block a user