import { CSSResultGroup,PropertyValues } from 'lit'; import { LitElement, html} from 'lit'; import styles from './nile-slide-toggle.css'; import NileElement from '../internal/nile-element'; import { classMap } from 'lit/directives/class-map.js'; import { customElement, property } from 'lit/decorators.js'; @customElement('nile-slide-toggle') export class NileSlideToggle extends NileElement { public static styles: CSSResultGroup = styles; @property({ type: String }) label = ''; @property({ type: String }) sublabel = ''; @property({ type: String, }) textPosition:'left' | 'right' = 'right'; @property({ type: Boolean, reflect: true }) isChecked = false; @property({ type: Boolean, reflect: true }) fullWidth = false; @property({ type: Boolean, reflect: true }) disabled = false; @property({ attribute: 'help-text', reflect: true }) helpText = ''; @property({ attribute: 'error-message', reflect: true }) errorMessage = ''; connectedCallback() { super.connectedCallback(); this.emit('nile-init'); this.style.setProperty('--slide-toggle-width',this.fullWidth?'100%':'auto') } disconnectedCallback() { super.disconnectedCallback(); this.emit('nile-destroy'); } toggleValue() { this.isChecked = !this.isChecked; this.emit('change',{ checked: this.isChecked, value: this.isChecked }); this.emit('nile-change',{ checked: this.isChecked, value: this.isChecked }); } public render() { const hasHelpText = this.helpText ? true : false; const hasErrorMessage = this.errorMessage ? true : false; return html`