@deepkit/desktop-ui
Version:
Library for desktop UI widgets in Angular 10+
62 lines (55 loc) • 1.58 kB
text/typescript
/*
* Deepkit Framework
* Copyright (C) 2021 Deepkit UG, Marc J. Schmidt
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the MIT License.
*
* You should have received a copy of the MIT License along with this program.
*/
import { ChangeDetectionStrategy, Component, HostBinding, HostListener } from '@angular/core';
import { ngValueAccessor, ValueAccessorBase } from '../../core/form';
import { IconComponent } from '../icon/icon.component';
/**
* Checkbox component to toggle boolean values.
*
* ```html
* <dui-checkbox [(ngModel)]="myValue">Check me!</dui-checkbox>
* ```
*/
export class CheckboxComponent extends ValueAccessorBase<boolean> {
protected get tabIndex() {
return 1;
}
protected get isChecked() {
return true === this.value();
}
protected onClick() {
if (this.isDisabled) return;
this.setValue(!this.value());
this.touch();
}
constructor() {
super();
this.value.set(false);
}
}