refactor: convierte los inputs con accessor a signals (input/model + effect)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Angular
|
||||
import { Directive, HostBinding, Input, TemplateRef, input, contentChild } from '@angular/core';
|
||||
import { Directive, HostBinding, TemplateRef, input, contentChild } from '@angular/core';
|
||||
|
||||
// Style definitions
|
||||
import { MenuEntry, MenuItemText } from './entities/menu-entry.model';
|
||||
@@ -12,16 +12,7 @@ export abstract class PiBaseMenuComponent {
|
||||
|
||||
readonly label = input<string>();
|
||||
|
||||
_menuItems: Array<MenuEntry> = [];
|
||||
|
||||
@Input()
|
||||
set menuItems(menuItems: MenuEntry[]) {
|
||||
this._menuItems = menuItems;
|
||||
}
|
||||
|
||||
get menuItems(): MenuEntry[] {
|
||||
return this._menuItems;
|
||||
}
|
||||
readonly menuItems = input<Array<MenuEntry>>([]);
|
||||
|
||||
/**
|
||||
* Parent Menu
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { Directive, OnChanges, HostBinding, Input, SimpleChanges } from '@angular/core';
|
||||
import { Directive, OnChanges, HostBinding, SimpleChanges, input } from '@angular/core';
|
||||
|
||||
@Directive({ selector: '[pi-disabled]', })
|
||||
export class PiDisabledDirective implements OnChanges {
|
||||
@HostBinding('style.opacity') get opacity(): number {
|
||||
return this.isDisabled ? 0.33 : 1;
|
||||
return this.isDisabled() ? 0.33 : 1;
|
||||
}
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isDisabled && 'is-disabled'].join(' ');
|
||||
return [this.isDisabled() && 'is-disabled'].join(' ');
|
||||
}
|
||||
|
||||
@Input() isDisabled: boolean;
|
||||
readonly isDisabled = input<boolean>();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes) {
|
||||
@@ -21,10 +21,10 @@ export class PiDisabledDirective implements OnChanges {
|
||||
@Directive({ selector: '[is-active]', })
|
||||
export class PiIsActiveDirective {
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isActive ? 'is-active' : '', 'pi-status'].join(' ');
|
||||
return [this.isActive() ? 'is-active' : '', 'pi-status'].join(' ');
|
||||
}
|
||||
|
||||
@Input() isActive!: boolean;
|
||||
readonly isActive = input.required<boolean>();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes) {
|
||||
@@ -36,10 +36,10 @@ export class PiIsActiveDirective {
|
||||
@Directive({ selector: '[is-visited]', })
|
||||
export class PiIsVisitedDirective {
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isVisited ? 'is-visited' : '', 'pi-status'].join(' ');
|
||||
return [this.isVisited() ? 'is-visited' : '', 'pi-status'].join(' ');
|
||||
}
|
||||
|
||||
@Input() isVisited!: boolean;
|
||||
readonly isVisited = input.required<boolean>();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes) {
|
||||
|
||||
Reference in New Issue
Block a user