From c0d2b57f0198abba27cc228164e320ec598d6c4a Mon Sep 17 00:00:00 2001 From: Fahri Gedik <53567152+fahrigedik@users.noreply.github.com> Date: Fri, 30 Jan 2026 23:22:03 +0300 Subject: [PATCH 01/10] Refactor to use Angular input signals across components Replaces traditional @Input() properties with Angular's new input() signal API in multiple components, directives, and templates. Updates all usages to call input signal functions, ensuring compatibility and reactivity. This change modernizes the codebase, improves type safety, and prepares for future Angular features. --- .../chart.js/src/chart.component.ts | 97 +++++++++---------- .../abstract-actions.component.ts | 5 +- .../extensible-form-prop.component.html | 2 +- .../extensible-form-prop.component.ts | 19 ++-- .../extensible-table.component.html | 12 +-- .../extensible-table.component.ts | 45 +++++---- .../grid-actions/grid-actions.component.html | 2 +- .../grid-actions/grid-actions.component.ts | 5 +- .../src/lib/directives/prop-data.directive.ts | 21 ++-- .../extensible/src/lib/models/actions.ts | 20 ++-- .../page/src/page-part.directive.ts | 35 +++---- .../components/page/src/page.component.html | 2 +- .../components/page/src/page.component.ts | 6 +- .../src/lib/abstracts/ng-model.component.ts | 17 ++-- .../src/lib/directives/debounce.directive.ts | 6 +- .../core/src/lib/directives/for.directive.ts | 63 ++++++------ .../lib/directives/form-submit.directive.ts | 31 +++--- .../lib/directives/permission.directive.ts | 10 +- .../replaceable-template.directive.ts | 70 ++++++------- .../packages/setting-management/package.json | 2 +- .../components/routes/routes.component.html | 6 +- .../lib/components/routes/routes.component.ts | 4 +- .../lib/components/button/button.component.ts | 44 ++++----- .../components/card/card-body.component.ts | 8 +- .../components/card/card-footer.component.ts | 8 +- .../components/card/card-header.component.ts | 8 +- .../src/lib/components/card/card.component.ts | 8 +- .../components/checkbox/checkbox.component.ts | 29 +++--- .../form-input/form-input.component.ts | 33 +++---- .../loader-bar/loader-bar.component.ts | 14 ++- .../password/password.component.html | 2 +- .../components/password/password.component.ts | 6 +- .../toast-container.component.html | 6 +- .../toast-container.component.ts | 18 ++-- .../lib/components/toast/toast.component.html | 6 +- .../lib/components/toast/toast.component.ts | 20 ++-- .../src/lib/directives/disabled.directive.ts | 5 +- .../src/lib/directives/ellipsis.directive.ts | 30 +++--- .../src/lib/directives/loading.directive.ts | 32 +++--- .../ngx-datatable-default.directive.ts | 6 +- .../ngx-datatable-list.directive.ts | 33 ++++--- 41 files changed, 393 insertions(+), 403 deletions(-) diff --git a/npm/ng-packs/packages/components/chart.js/src/chart.component.ts b/npm/ng-packs/packages/components/chart.js/src/chart.component.ts index 9ab84aedcd..d4e697b48d 100644 --- a/npm/ng-packs/packages/components/chart.js/src/chart.component.ts +++ b/npm/ng-packs/packages/components/chart.js/src/chart.component.ts @@ -1,17 +1,17 @@ -import { - AfterViewInit, - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - ElementRef, - EventEmitter, - Input, - OnChanges, - OnDestroy, - Output, - SimpleChanges, - ViewChild, - inject +import { + AfterViewInit, + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ElementRef, + EventEmitter, + OnDestroy, + Output, + ViewChild, + effect, + inject, + input, + untracked, } from '@angular/core'; let Chart: any; @@ -21,13 +21,13 @@ let Chart: any; template: `
@@ -35,32 +35,39 @@ let Chart: any; changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'abpChart', }) -export class ChartComponent implements AfterViewInit, OnDestroy, OnChanges { +export class ChartComponent implements AfterViewInit, OnDestroy { el = inject(ElementRef); private cdr = inject(ChangeDetectorRef); - @Input() type!: string; - - @Input() data: any = {}; - - @Input() options: any = {}; - - @Input() plugins: any[] = []; - - @Input() width?: string; - - @Input() height?: string; - - @Input() responsive = true; + readonly type = input.required(); + readonly data = input({}); + readonly options = input({}); + readonly plugins = input([]); + readonly width = input(); + readonly height = input(); + readonly responsive = input(true); @Output() dataSelect = new EventEmitter(); - @Output() initialized = new EventEmitter(); @ViewChild('canvas') canvas!: ElementRef; chart: any; + constructor() { + effect(() => { + const data = this.data(); + const options = this.options(); + + untracked(() => { + if (this.chart) { + this.chart.destroy(); + this.initChart(); + } + }); + }); + } + ngAfterViewInit() { import('chart.js/auto').then(module => { Chart = module.default; @@ -91,19 +98,19 @@ export class ChartComponent implements AfterViewInit, OnDestroy, OnChanges { } private initChart = () => { - const opts = this.options || {}; - opts.responsive = this.responsive; + const opts = this.options() || {}; + opts.responsive = this.responsive(); // allows chart to resize in responsive mode - if (opts.responsive && (this.height || this.width)) { + if (opts.responsive && (this.height() || this.width())) { opts.maintainAspectRatio = false; } this.chart = new Chart(this.canvas.nativeElement, { - type: this.type as any, - data: this.data, - options: this.options, - plugins: this.plugins, + type: this.type() as any, + data: this.data(), + options: this.options(), + plugins: this.plugins(), }); }; @@ -140,13 +147,5 @@ export class ChartComponent implements AfterViewInit, OnDestroy, OnChanges { this.chart = null; } } - - ngOnChanges(changes: SimpleChanges) { - if (!this.chart) return; - - if (changes.data?.currentValue || changes.options?.currentValue) { - this.chart.destroy(); - this.initChart(); - } - } } + diff --git a/npm/ng-packs/packages/components/extensible/src/lib/components/abstract-actions/abstract-actions.component.ts b/npm/ng-packs/packages/components/extensible/src/lib/components/abstract-actions/abstract-actions.component.ts index 465a18b813..e162310044 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/components/abstract-actions/abstract-actions.component.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/components/abstract-actions/abstract-actions.component.ts @@ -1,4 +1,4 @@ -import { Directive, Injector, Input, inject } from '@angular/core'; +import { Directive, Injector, inject, input } from '@angular/core'; import { ActionData, ActionList, InferredAction } from '../../models/actions'; import { ExtensionsService } from '../../services/extensions.service'; import { EXTENSIONS_ACTION_TYPE, EXTENSIONS_IDENTIFIER } from '../../tokens/extensions.token'; @@ -14,7 +14,7 @@ export abstract class AbstractActionsComponent< readonly getInjected: InferredData['getInjected']; - @Input() record!: InferredData['record']; + record = input.required>(); protected constructor() { const injector = inject(Injector); @@ -27,3 +27,4 @@ export abstract class AbstractActionsComponent< this.actionList = extensions[type].get(name).actions as unknown as L; } } + diff --git a/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.html b/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.html index 2f9df1ae00..60af79b0ec 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.html +++ b/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.html @@ -95,7 +95,7 @@