1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 01:33:33 +00:00

[CL-707] Migrate CL codebase to signals (#15340)

This commit is contained in:
Vicki League
2025-07-16 08:39:37 -04:00
committed by GitHub
parent 97ec9a6339
commit 6811ea4c0b
124 changed files with 944 additions and 809 deletions

View File

@@ -1,7 +1,7 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { TemplatePortal, CdkPortalOutlet } from "@angular/cdk/portal";
import { Component, HostBinding, Input } from "@angular/core";
import { Component, effect, HostBinding, input } from "@angular/core";
@Component({
selector: "bit-tab-body",
@@ -11,24 +11,22 @@ import { Component, HostBinding, Input } from "@angular/core";
export class TabBodyComponent {
private _firstRender: boolean;
@Input() content: TemplatePortal;
@Input() preserveContent = false;
readonly content = input<TemplatePortal>();
readonly preserveContent = input(false);
@HostBinding("attr.hidden") get hidden() {
return !this.active || null;
return !this.active() || null;
}
@Input()
get active() {
return this._active;
readonly active = input<boolean>();
constructor() {
effect(() => {
if (this.active()) {
this._firstRender = true;
}
});
}
set active(value: boolean) {
this._active = value;
if (this._active) {
this._firstRender = true;
}
}
private _active: boolean;
/**
* The tab content to render.
@@ -37,11 +35,11 @@ export class TabBodyComponent {
* then the content persists after the first time content is rendered.
*/
get tabContent() {
if (this.active) {
return this.content;
if (this.active()) {
return this.content();
}
if (this.preserveContent && this._firstRender) {
return this.content;
if (this.preserveContent() && this._firstRender) {
return this.content();
}
return null;
}