mirror of
https://github.com/bitwarden/browser
synced 2026-02-07 20:24:01 +00:00
finish migrating radio-button module
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component, HostBinding, Input, input } from "@angular/core";
|
||||
import { Component, HostBinding, input } from "@angular/core";
|
||||
|
||||
import { FormControlModule } from "../form-control/form-control.module";
|
||||
|
||||
@@ -11,12 +11,12 @@ let nextId = 0;
|
||||
selector: "bit-radio-button",
|
||||
templateUrl: "radio-button.component.html",
|
||||
imports: [FormControlModule, RadioInputComponent],
|
||||
host: {
|
||||
"[id]": "this.id()",
|
||||
},
|
||||
})
|
||||
export class RadioButtonComponent {
|
||||
// TODO: Skipped for migration because:
|
||||
// This input is used in combination with `@HostBinding` and migrating would
|
||||
// break.
|
||||
@HostBinding("attr.id") @Input() id = `bit-radio-button-${nextId++}`;
|
||||
readonly id = input(`bit-radio-button-${nextId++}`);
|
||||
@HostBinding("class") get classList() {
|
||||
return [this.block ? "tw-block" : "tw-inline-block", "tw-mb-1", "[&_bit-hint]:tw-mt-0"];
|
||||
}
|
||||
@@ -27,11 +27,11 @@ export class RadioButtonComponent {
|
||||
constructor(private groupComponent: RadioGroupComponent) {}
|
||||
|
||||
get inputId() {
|
||||
return `${this.id}-input`;
|
||||
return `${this.id()}-input`;
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this.groupComponent.name;
|
||||
return this.groupComponent.name();
|
||||
}
|
||||
|
||||
get selected() {
|
||||
|
||||
@@ -19,15 +19,9 @@ export class RadioGroupComponent implements ControlValueAccessor {
|
||||
selected: unknown;
|
||||
disabled = false;
|
||||
|
||||
private _name?: string;
|
||||
// TODO: Skipped for migration because:
|
||||
// Accessor inputs cannot be migrated as they are too complex.
|
||||
@Input() get name() {
|
||||
return this._name ?? this.ngControl?.name?.toString();
|
||||
}
|
||||
set name(value: string) {
|
||||
this._name = value;
|
||||
}
|
||||
readonly name = input(undefined, {
|
||||
transform: (value: string | undefined) => value ?? this.ngControl?.name?.toString(),
|
||||
});
|
||||
|
||||
readonly block = input(false);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { Component, HostBinding, Input, Optional, Self } from "@angular/core";
|
||||
import { Component, HostBinding, input, Input, Optional, Self } from "@angular/core";
|
||||
import { NgControl, Validators } from "@angular/forms";
|
||||
|
||||
import { BitFormControlAbstraction } from "../form-control";
|
||||
@@ -11,12 +11,12 @@ let nextId = 0;
|
||||
selector: "input[type=radio][bitRadio]",
|
||||
template: "",
|
||||
providers: [{ provide: BitFormControlAbstraction, useExisting: RadioInputComponent }],
|
||||
host: {
|
||||
"[id]": "this.id()",
|
||||
},
|
||||
})
|
||||
export class RadioInputComponent implements BitFormControlAbstraction {
|
||||
// TODO: Skipped for migration because:
|
||||
// This input is used in combination with `@HostBinding` and migrating would
|
||||
// break.
|
||||
@HostBinding("attr.id") @Input() id = `bit-radio-input-${nextId++}`;
|
||||
id = input(`bit-radio-input-${nextId++}`);
|
||||
|
||||
@HostBinding("class")
|
||||
protected inputClasses = [
|
||||
|
||||
Reference in New Issue
Block a user