1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 15:23:33 +00:00

[CL-135] Migrate component library to standalone components (#12389)

* Migrate component library to standalone components

* Fix tests
This commit is contained in:
Oscar Hinton
2024-12-17 23:29:48 +01:00
committed by GitHub
parent ac13cf7ce6
commit 5a582dfc6f
101 changed files with 330 additions and 216 deletions

View File

@@ -2,6 +2,7 @@ import { Directive, HostBinding } from "@angular/core";
@Directive({
selector: "th[bitCell], td[bitCell]",
standalone: true,
})
export class CellDirective {
@HostBinding("class") get classList() {

View File

@@ -2,6 +2,7 @@ import { Directive, HostBinding, Input } from "@angular/core";
@Directive({
selector: "tr[bitRow]",
standalone: true,
})
export class RowDirective {
@Input() alignContent: "top" | "middle" | "bottom" | "baseline" = "middle";

View File

@@ -1,6 +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, HostBinding, Input, OnInit } from "@angular/core";
import type { SortDirection, SortFn } from "./table-data-source";
@@ -14,6 +15,8 @@ import { TableComponent } from "./table.component";
<i class="bwi tw-ml-2" [ngClass]="icon"></i>
</button>
`,
standalone: true,
imports: [NgClass],
})
export class SortableComponent implements OnInit {
/**

View File

@@ -1,5 +1,12 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import {
CdkVirtualScrollViewport,
CdkVirtualScrollableWindow,
CdkFixedSizeVirtualScroll,
CdkVirtualForOf,
} from "@angular/cdk/scrolling";
import { CommonModule } from "@angular/common";
import {
AfterContentChecked,
Component,
@@ -14,6 +21,7 @@ import {
TrackByFunction,
} from "@angular/core";
import { RowDirective } from "./row.directive";
import { TableComponent } from "./table.component";
/**
@@ -42,6 +50,15 @@ export class BitRowDef {
selector: "bit-table-scroll",
templateUrl: "./table-scroll.component.html",
providers: [{ provide: TableComponent, useExisting: TableScrollComponent }],
standalone: true,
imports: [
CommonModule,
CdkVirtualScrollViewport,
CdkVirtualScrollableWindow,
CdkFixedSizeVirtualScroll,
CdkVirtualForOf,
RowDirective,
],
})
export class TableScrollComponent
extends TableComponent

View File

@@ -1,6 +1,7 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { isDataSource } from "@angular/cdk/collections";
import { CommonModule } from "@angular/common";
import {
AfterContentChecked,
Component,
@@ -16,6 +17,7 @@ import { TableDataSource } from "./table-data-source";
@Directive({
selector: "ng-template[body]",
standalone: true,
})
export class TableBodyDirective {
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
@@ -25,6 +27,8 @@ export class TableBodyDirective {
@Component({
selector: "bit-table",
templateUrl: "./table.component.html",
standalone: true,
imports: [CommonModule],
})
export class TableComponent implements OnDestroy, AfterContentChecked {
@Input() dataSource: TableDataSource<any>;

View File

@@ -9,8 +9,10 @@ import { BitRowDef, TableScrollComponent } from "./table-scroll.component";
import { TableBodyDirective, TableComponent } from "./table.component";
@NgModule({
imports: [CommonModule, ScrollingModule, BitRowDef],
declarations: [
imports: [
CommonModule,
ScrollingModule,
BitRowDef,
CellDirective,
RowDirective,
SortableComponent,