fix: adapta escrituras internas a model() y signal queries (toObservable)
This commit is contained in:
@@ -1,49 +1,36 @@
|
||||
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;
|
||||
}
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isDisabled() && 'is-disabled'].join(' ');
|
||||
}
|
||||
|
||||
readonly isDisabled = input<boolean>();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes) {
|
||||
this.isDisabled = changes['isDisabled'].currentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({ selector: '[is-active]', })
|
||||
export class PiIsActiveDirective {
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isActive() ? 'is-active' : '', 'pi-status'].join(' ');
|
||||
}
|
||||
|
||||
readonly isActive = input.required<boolean>();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes) {
|
||||
this.isActive = changes['isActive'].currentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({ selector: '[is-visited]', })
|
||||
export class PiIsVisitedDirective {
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isVisited() ? 'is-visited' : '', 'pi-status'].join(' ');
|
||||
}
|
||||
|
||||
readonly isVisited = input.required<boolean>();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes) {
|
||||
this.isVisited = changes['isVisited'].currentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
import { Directive, HostBinding, input } from '@angular/core';
|
||||
|
||||
/**
|
||||
* Los `ngOnChanges` originales sólo reasignaban a la entrada su propio
|
||||
* `currentValue`, es decir, eran no-ops. Con signal inputs sobran.
|
||||
*/
|
||||
|
||||
@Directive({ selector: '[pi-disabled]', })
|
||||
export class PiDisabledDirective {
|
||||
@HostBinding('style.opacity') get opacity(): number {
|
||||
return this.isDisabled() ? 0.33 : 1;
|
||||
}
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isDisabled() && 'is-disabled'].join(' ');
|
||||
}
|
||||
|
||||
readonly isDisabled = input<boolean>();
|
||||
}
|
||||
|
||||
@Directive({ selector: '[is-active]', })
|
||||
export class PiIsActiveDirective {
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isActive() ? 'is-active' : '', 'pi-status'].join(' ');
|
||||
}
|
||||
|
||||
readonly isActive = input.required<boolean>();
|
||||
}
|
||||
|
||||
@Directive({ selector: '[is-visited]', })
|
||||
export class PiIsVisitedDirective {
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isVisited() ? 'is-visited' : '', 'pi-status'].join(' ');
|
||||
}
|
||||
|
||||
readonly isVisited = input.required<boolean>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user