mirror of
https://github.com/bitwarden/browser
synced 2026-02-11 05:53:42 +00:00
Angular 6 changed the default to not preserve whitespaces. We've continued to opt into this pattern for backwards compatibility but we're experiencing issues with the new control flow syntax and would therefore like to switch and not preserve whitespace any longer.
36 lines
814 B
TypeScript
36 lines
814 B
TypeScript
import {
|
|
booleanAttribute,
|
|
Component,
|
|
EventEmitter,
|
|
HostBinding,
|
|
Input,
|
|
Output,
|
|
} from "@angular/core";
|
|
|
|
let nextId = 0;
|
|
|
|
@Component({
|
|
selector: "bit-toggle-group",
|
|
templateUrl: "./toggle-group.component.html",
|
|
standalone: true,
|
|
})
|
|
export class ToggleGroupComponent<TValue = unknown> {
|
|
private id = nextId++;
|
|
name = `bit-toggle-group-${this.id}`;
|
|
|
|
@Input({ transform: booleanAttribute }) fullWidth?: boolean;
|
|
@Input() selected?: TValue;
|
|
@Output() selectedChange = new EventEmitter<TValue>();
|
|
|
|
@HostBinding("attr.role") role = "radiogroup";
|
|
@HostBinding("class")
|
|
get classList() {
|
|
return ["tw-flex"].concat(this.fullWidth ? ["tw-w-full", "[&>*]:tw-flex-1"] : []);
|
|
}
|
|
|
|
onInputInteraction(value: TValue) {
|
|
this.selected = value;
|
|
this.selectedChange.emit(value);
|
|
}
|
|
}
|