mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
[CL-135] Migrate component library to standalone components (#12389)
* Migrate component library to standalone components * Fix tests
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import { Component, HostBinding, Input } from "@angular/core";
|
||||
|
||||
import { FormControlModule } from "../form-control/form-control.module";
|
||||
|
||||
import { RadioGroupComponent } from "./radio-group.component";
|
||||
import { RadioInputComponent } from "./radio-input.component";
|
||||
|
||||
let nextId = 0;
|
||||
|
||||
@Component({
|
||||
selector: "bit-radio-button",
|
||||
templateUrl: "radio-button.component.html",
|
||||
standalone: true,
|
||||
imports: [FormControlModule, RadioInputComponent],
|
||||
})
|
||||
export class RadioButtonComponent {
|
||||
@HostBinding("attr.id") @Input() id = `bit-radio-button-${nextId++}`;
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { NgModule } from "@angular/core";
|
||||
|
||||
import { FormControlModule } from "../form-control";
|
||||
import { SharedModule } from "../shared";
|
||||
|
||||
import { RadioButtonComponent } from "./radio-button.component";
|
||||
import { RadioGroupComponent } from "./radio-group.component";
|
||||
import { RadioInputComponent } from "./radio-input.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, SharedModule, FormControlModule],
|
||||
declarations: [RadioInputComponent, RadioButtonComponent, RadioGroupComponent],
|
||||
imports: [FormControlModule, RadioInputComponent, RadioButtonComponent, RadioGroupComponent],
|
||||
exports: [FormControlModule, RadioInputComponent, RadioButtonComponent, RadioGroupComponent],
|
||||
})
|
||||
export class RadioButtonModule {}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { NgIf, NgTemplateOutlet } from "@angular/common";
|
||||
import { Component, ContentChild, HostBinding, Input, Optional, Self } from "@angular/core";
|
||||
import { ControlValueAccessor, NgControl, Validators } from "@angular/forms";
|
||||
|
||||
import { BitLabel } from "../form-control/label.component";
|
||||
import { I18nPipe } from "../shared/i18n.pipe";
|
||||
|
||||
let nextId = 0;
|
||||
|
||||
@Component({
|
||||
selector: "bit-radio-group",
|
||||
templateUrl: "radio-group.component.html",
|
||||
standalone: true,
|
||||
imports: [NgIf, NgTemplateOutlet, I18nPipe],
|
||||
})
|
||||
export class RadioGroupComponent implements ControlValueAccessor {
|
||||
selected: unknown;
|
||||
|
||||
@@ -11,6 +11,7 @@ let nextId = 0;
|
||||
selector: "input[type=radio][bitRadio]",
|
||||
template: "",
|
||||
providers: [{ provide: BitFormControlAbstraction, useExisting: RadioInputComponent }],
|
||||
standalone: true,
|
||||
})
|
||||
export class RadioInputComponent implements BitFormControlAbstraction {
|
||||
@HostBinding("attr.id") @Input() id = `bit-radio-input-${nextId++}`;
|
||||
|
||||
Reference in New Issue
Block a user