Skip to content

Commit

Permalink
fix: make all components and pipes standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjalmers committed Oct 31, 2022
1 parent 4c4c3c4 commit 45ef299
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 6 deletions.
32 changes: 30 additions & 2 deletions projects/core/src/lib/core.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ import {
Subject,
} from 'rxjs';
import { TableConfig } from './models/table-config.interface';
import { KeyValue } from '@angular/common';
import {
AsyncPipe,
KeyValue,
KeyValuePipe,
NgClass,
NgForOf,
NgIf,
NgTemplateOutlet,
SlicePipe,
} from '@angular/common';
import {
debounceTime,
distinctUntilChanged,
Expand All @@ -38,12 +47,31 @@ import {
GtRowClickEvent,
GtRowHoverEvent,
} from './models/table-events.interface';
import { CapitalCasePipe } from './pipes/capital-case.pipe';
import { SortClassPipe } from './pipes/sort-class.pipe';
import { DashCasePipe } from './pipes/dash-case.pipe';
import { DynamicPipe } from './pipes/dynamic.pipe';
import { HighlightPipe } from './pipes/highlight.pipe';

@Component({
selector: 'angular-generic-table',
templateUrl: './core.component.html',
styles: [],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
CapitalCasePipe,
KeyValuePipe,
SortClassPipe,
DashCasePipe,
AsyncPipe,
NgTemplateOutlet,
SlicePipe,
DynamicPipe,
HighlightPipe,
NgClass,
NgIf,
NgForOf,
],
})
export class CoreComponent {
@Input() set loading(isLoading: Observable<boolean> | boolean) {
Expand Down
4 changes: 2 additions & 2 deletions projects/core/src/lib/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { DynamicPipe } from './pipes/dynamic.pipe';
import { GtDeltaComponent } from './gt-delta/gt-delta.component';

@NgModule({
declarations: [
imports: [
CommonModule,
CoreComponent,
SortClassPipe,
DashCasePipe,
Expand All @@ -19,7 +20,6 @@ import { GtDeltaComponent } from './gt-delta/gt-delta.component';
DynamicPipe,
GtDeltaComponent,
],
imports: [CommonModule],
exports: [CoreComponent, GtDeltaComponent],
})
export class GenericTableCoreModule {}
3 changes: 3 additions & 0 deletions projects/core/src/lib/gt-delta/gt-delta.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { TableRow } from '../models/table-row.interface';
import { NgIf, PercentPipe } from '@angular/common';

@Component({
selector: 'gt-delta',
Expand Down Expand Up @@ -44,6 +45,8 @@ import { TableRow } from '../models/table-row.interface';
`,
],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [PercentPipe, NgIf],
})
export class GtDeltaComponent {
constructor() {}
Expand Down
3 changes: 3 additions & 0 deletions projects/core/src/lib/pagination/pagination.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import {
GtPaginationAriaLabels,
GtPaginationClasses,
} from '../models/gt-pagination';
import { AsyncPipe, NgForOf, NgIf } from '@angular/common';

@Component({
selector: 'angular-generic-table-pagination',
templateUrl: './pagination.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [AsyncPipe, NgIf, NgForOf],
})
export class PaginationComponent {
get paginationLength(): number {
Expand Down
3 changes: 1 addition & 2 deletions projects/core/src/lib/pagination/pagination.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { CommonModule } from '@angular/common';
import { PaginationComponent } from './pagination.component';

@NgModule({
declarations: [PaginationComponent],
imports: [CommonModule],
imports: [CommonModule, PaginationComponent],
exports: [PaginationComponent],
})
export class GenericTablePaginationModule {}
1 change: 1 addition & 0 deletions projects/core/src/lib/pipes/capital-case.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { capitalize } from '../utilities/utilities';

@Pipe({
name: 'capitalCase',
standalone: true,
})
export class CapitalCasePipe implements PipeTransform {
transform(s: string): any {
Expand Down
1 change: 1 addition & 0 deletions projects/core/src/lib/pipes/dash-case.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { dashed } from '../utilities/utilities';

@Pipe({
name: 'dashCase',
standalone: true,
})
export class DashCasePipe implements PipeTransform {
transform(s: string): any {
Expand Down
1 change: 1 addition & 0 deletions projects/core/src/lib/pipes/dynamic.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injector, Pipe, PipeTransform, Type } from '@angular/core';

@Pipe({
name: 'dynamicPipe',
standalone: true,
})
export class DynamicPipe implements PipeTransform {
constructor(private injector: Injector) {}
Expand Down
1 change: 1 addition & 0 deletions projects/core/src/lib/pipes/highlight.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'highlight',
standalone: true,
})
export class HighlightPipe implements PipeTransform {
transform(text: any, searchTerm: string | null): string {
Expand Down
1 change: 1 addition & 0 deletions projects/core/src/lib/pipes/sort-class.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Order } from '../enums/order.enum';

@Pipe({
name: 'sortClass',
standalone: true,
})
export class SortClassPipe implements PipeTransform {
transform(
Expand Down

0 comments on commit 45ef299

Please sign in to comment.