import { Component, EventEmitter, Input, Output } from '@angular/core'; @Component({ selector: 'vsp-switch', template: ``, }) export class VspSwitch { @Input() checked = false; @Output() checkedChange = new EventEmitter(); @Input() size?: 'sm'; @Input() disabled = false; get cls(): string { return ['ui-switch', this.size === 'sm' && 'sm', this.checked && 'on'] .filter(Boolean) .join(' '); } toggle(): void { this.checked = !this.checked; this.checkedChange.emit(this.checked); } } @Component({ selector: 'vsp-checkbox', template: ``, }) export class VspCheckbox { @Input() checked = false; @Output() checkedChange = new EventEmitter(); @Input() label?: string; @Input() sub?: string; @Input() disabled = false; @Input() indeterminate = false; @Input() invalid = false; @Input() id?: string; get checkCls(): string { return ( 'ui-check' + (this.checked || this.indeterminate ? ' on' : '') + (this.indeterminate ? ' mixed' : '') + (this.invalid ? ' invalid' : '') ); } toggle(): void { this.checked = !this.checked; this.checkedChange.emit(this.checked); } }