| 568 | imports: [MatRipple, MatPseudoCheckbox], |
| 569 | }) |
| 570 | export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy { |
| 571 | private _changeDetectorRef = inject(ChangeDetectorRef); |
| 572 | private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef); |
| 573 | private _focusMonitor = inject(FocusMonitor); |
| 574 | private _idGenerator = inject(_IdGenerator); |
| 575 | private _animationDisabled = _animationsDisabled(); |
| 576 | private _checked = false; |
| 577 | |
| 578 | /** |
| 579 | * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will |
| 580 | * take precedence so this may be omitted. |
| 581 | */ |
| 582 | @Input('aria-label') ariaLabel!: string; |
| 583 | |
| 584 | /** |
| 585 | * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element |
| 586 | */ |
| 587 | @Input('aria-labelledby') ariaLabelledby: string | null = null; |
| 588 | |
| 589 | /** Underlying native `button` element. */ |
| 590 | @ViewChild('button') _buttonElement!: ElementRef<HTMLButtonElement>; |
| 591 | |
| 592 | /** The parent button toggle group (exclusive selection). Optional. */ |
| 593 | buttonToggleGroup: MatButtonToggleGroup; |
| 594 | |
| 595 | /** Unique ID for the underlying `button` element. */ |
| 596 | get buttonId(): string { |
| 597 | return `${this.id}-button`; |
| 598 | } |
| 599 | |
| 600 | /** The unique ID for this button toggle. */ |
| 601 | @Input() id!: string; |
| 602 | |
| 603 | /** HTML's 'name' attribute used to group radios for unique selection. */ |
| 604 | @Input() name!: string; |
| 605 | |
| 606 | /** MatButtonToggleGroup reads this to assign its own value. */ |
| 607 | @Input() value: any; |
| 608 | |
| 609 | /** Tabindex of the toggle. */ |
| 610 | @Input() |
| 611 | get tabIndex(): number | null { |
| 612 | return this._tabIndex(); |
| 613 | } |
| 614 | set tabIndex(value: number | null) { |
| 615 | this._tabIndex.set(value); |
| 616 | } |
| 617 | private _tabIndex: WritableSignal<number | null>; |
| 618 | |
| 619 | /** Whether ripples are disabled on the button toggle. */ |
| 620 | @Input({transform: booleanAttribute}) disableRipple: boolean = false; |
| 621 | |
| 622 | /** The appearance style of the button. */ |
| 623 | @Input() |
| 624 | get appearance(): MatButtonToggleAppearance { |
| 625 | return this.buttonToggleGroup ? this.buttonToggleGroup.appearance : this._appearance; |
| 626 | } |
| 627 | set appearance(value: MatButtonToggleAppearance) { |
nothing calls this directly
no test coverage detected