28 lines
1020 B
TypeScript
28 lines
1020 B
TypeScript
import { booleanAttribute, ChangeDetectionStrategy, Component, ElementRef, HostBinding, Input, OnInit, ViewChild } from '@angular/core';
|
|
import { MatIconModule } from '@angular/material/icon';
|
|
import { NgIf } from '@angular/common';
|
|
|
|
@Component({
|
|
selector: 'iqser-round-checkbox',
|
|
templateUrl: './round-checkbox.component.html',
|
|
styleUrls: ['./round-checkbox.component.scss'],
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
standalone: true,
|
|
imports: [MatIconModule, NgIf],
|
|
})
|
|
export class RoundCheckboxComponent implements OnInit {
|
|
@Input() size = 20;
|
|
@Input({ transform: booleanAttribute }) active = false;
|
|
@Input() indeterminate = false;
|
|
@Input() type: 'default' | 'with-bg' = 'default';
|
|
@HostBinding('class.disabled')
|
|
@Input()
|
|
disabled = false;
|
|
|
|
@ViewChild('wrapper', { static: true }) private readonly _wrapper!: ElementRef;
|
|
|
|
ngOnInit(): void {
|
|
(this._wrapper.nativeElement as HTMLElement).style.setProperty('--size', `${this.size}px`);
|
|
}
|
|
}
|