mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[CL-707] Migrate CL codebase to signals (#15340)
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
||||
import { NgClass } from "@angular/common";
|
||||
import { Component, ContentChild, HostBinding, Input } from "@angular/core";
|
||||
import { booleanAttribute, Component, ContentChild, HostBinding, input } from "@angular/core";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { I18nPipe } from "@bitwarden/ui-common";
|
||||
@@ -17,30 +16,18 @@ import { BitFormControlAbstraction } from "./form-control.abstraction";
|
||||
imports: [NgClass, TypographyDirective, I18nPipe],
|
||||
})
|
||||
export class FormControlComponent {
|
||||
@Input() label: string;
|
||||
readonly label = input<string>();
|
||||
|
||||
private _inline = false;
|
||||
@Input() get inline() {
|
||||
return this._inline;
|
||||
}
|
||||
set inline(value: boolean | "") {
|
||||
this._inline = coerceBooleanProperty(value);
|
||||
}
|
||||
readonly inline = input(false, { transform: booleanAttribute });
|
||||
|
||||
private _disableMargin = false;
|
||||
@Input() set disableMargin(value: boolean | "") {
|
||||
this._disableMargin = coerceBooleanProperty(value);
|
||||
}
|
||||
get disableMargin() {
|
||||
return this._disableMargin;
|
||||
}
|
||||
readonly disableMargin = input(false, { transform: booleanAttribute });
|
||||
|
||||
@ContentChild(BitFormControlAbstraction) protected formControl: BitFormControlAbstraction;
|
||||
|
||||
@HostBinding("class") get classes() {
|
||||
return []
|
||||
.concat(this.inline ? ["tw-inline-block", "tw-me-4"] : ["tw-block"])
|
||||
.concat(this.disableMargin ? [] : ["tw-mb-4"]);
|
||||
.concat(this.inline() ? ["tw-inline-block", "tw-me-4"] : ["tw-block"])
|
||||
.concat(this.disableMargin() ? [] : ["tw-mb-4"]);
|
||||
}
|
||||
|
||||
constructor(private i18nService: I18nService) {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, ElementRef, HostBinding, Input, Optional } from "@angular/core";
|
||||
import { Component, ElementRef, HostBinding, input, Optional } from "@angular/core";
|
||||
|
||||
import { FormControlComponent } from "./form-control.component";
|
||||
|
||||
@@ -12,6 +12,10 @@ let nextId = 0;
|
||||
selector: "bit-label",
|
||||
templateUrl: "label.component.html",
|
||||
imports: [CommonModule],
|
||||
host: {
|
||||
"[class]": "classList",
|
||||
"[id]": "id()",
|
||||
},
|
||||
})
|
||||
export class BitLabel {
|
||||
constructor(
|
||||
@@ -19,15 +23,19 @@ export class BitLabel {
|
||||
@Optional() private parentFormControl: FormControlComponent,
|
||||
) {}
|
||||
|
||||
@HostBinding("class") @Input() get classList() {
|
||||
return ["tw-inline-flex", "tw-gap-1", "tw-items-baseline", "tw-flex-row", "tw-min-w-0"];
|
||||
}
|
||||
readonly classList = [
|
||||
"tw-inline-flex",
|
||||
"tw-gap-1",
|
||||
"tw-items-baseline",
|
||||
"tw-flex-row",
|
||||
"tw-min-w-0",
|
||||
];
|
||||
|
||||
@HostBinding("title") get title() {
|
||||
return this.elementRef.nativeElement.textContent.trim();
|
||||
}
|
||||
|
||||
@HostBinding() @Input() id = `bit-label-${nextId++}`;
|
||||
readonly id = input(`bit-label-${nextId++}`);
|
||||
|
||||
get isInsideFormControl() {
|
||||
return !!this.parentFormControl;
|
||||
|
||||
Reference in New Issue
Block a user