fix: resuelve invarianza de inputs heredados y estrictez de tipos heredada

This commit is contained in:
2026-07-27 23:49:11 +02:00
parent 779f1c1308
commit cfffdfd192
22 changed files with 42 additions and 36 deletions

View File

@@ -23,11 +23,11 @@ export abstract class PiBaseButtonComponent implements OnInit {
return `pi-color__${this.color()}`; return `pi-color__${this.color()}`;
} }
protected get sizeClass(): string { protected get sizeClass(): string | null {
return `pi-button__${this.size()}`; return `pi-button__${this.size()}`;
} }
protected get appearanceClass(): string { protected get appearanceClass(): string | null {
return `pi-button__appearance--${this.appearance()}`; return `pi-button__appearance--${this.appearance()}`;
} }

View File

@@ -31,7 +31,7 @@ export class PiSwitchButtonComponent extends PiBaseButtonComponent {
} }
readonly isActive = model(true); readonly isActive = model(true);
readonly toggledTo = output(); readonly toggledTo = output<'on' | 'off'>();
readonly contentType = input<'icon' | 'text'>('icon'); readonly contentType = input<'icon' | 'text'>('icon');
readonly content = input.required<[ readonly content = input.required<[

View File

@@ -40,7 +40,7 @@ export abstract class PiBaseCardComponent implements OnInit {
return this.hasShadow() && 'has-shadow'; return this.hasShadow() && 'has-shadow';
} }
protected get isClickableClass(): string | undefined { protected get isClickableClass(): string | false | undefined {
return this.isClickable() && 'is-clickable'; return this.isClickable() && 'is-clickable';
} }

View File

@@ -52,7 +52,7 @@ export class PiChipActionComponent extends PiBaseChipComponent {
// Skin // Skin
override readonly size = input<'small' | 'medium' | 'large'>('small'); override readonly size = input<'small' | 'medium' | 'large'>('small');
override readonly color = input<chipColor>('primary'); override readonly color = input<chipColor | undefined>('primary');
// Status // Status
readonly isActive = input.required<boolean>(); readonly isActive = input.required<boolean>();

View File

@@ -5,6 +5,7 @@ import {
input, input,
output output
} from '@angular/core'; } from '@angular/core';
import { chipColor } from '../entities/chip.model';
import { ComponentFamilyClass, theming } from '../../../styles'; import { ComponentFamilyClass, theming } from '../../../styles';
import { Date } from '../../../util/models'; import { Date } from '../../../util/models';
import { PiBaseChipComponent } from '../base-chip.component'; import { PiBaseChipComponent } from '../base-chip.component';
@@ -48,7 +49,7 @@ export class PiChipDateComponent extends PiBaseChipComponent {
readonly date = input.required<string>(); // ISO format in UTC time zone readonly date = input.required<string>(); // ISO format in UTC time zone
// Skin // Skin
override readonly color = input<theming>('primary'); override readonly color = input<chipColor | undefined>('primary');
readonly isStroked = input(false); readonly isStroked = input(false);
// Size - weekday only available in LARGE // Size - weekday only available in LARGE

View File

@@ -30,7 +30,7 @@ export class PiChipStatusComponent extends PiBaseChipComponent {
// Skin // Skin
readonly appearance = input<'ghost' | 'fill'>('fill'); readonly appearance = input<'ghost' | 'fill'>('fill');
override readonly affixPosition = input<'previous' | 'after'>('previous'); override readonly affixPosition = input<'previous' | 'after'>('previous');
override readonly size = input<'small' | 'medium'>('small'); override readonly size = input<'small' | 'medium' | 'large'>('small');
/* green | red | yellow | blue | opacity */ /* green | red | yellow | blue | opacity */
readonly status = input.required<status>(); readonly status = input.required<status>();

View File

@@ -5,6 +5,7 @@ import {
input, input,
output output
} from '@angular/core'; } from '@angular/core';
import { chipColor } from '../entities/chip.model';
import { ComponentFamilyClass } from '../../../styles'; import { ComponentFamilyClass } from '../../../styles';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
import { PiBaseChipComponent } from '../base-chip.component'; import { PiBaseChipComponent } from '../base-chip.component';
@@ -39,17 +40,17 @@ export class PiChipTimeComponent extends PiBaseChipComponent {
readonly timezone = input<string>('utc'); readonly timezone = input<string>('utc');
// Skin // Skin
override readonly color = input<chipThemingColor>('primary'); override readonly color = input<chipColor | undefined>('primary');
/** /**
* On the chip time cases, we override the affix position property because * On the chip time cases, we override the affix position property because
it will be always used by the thime input and will be always previous it will be always used by the thime input and will be always previous
*/ */
override readonly affixPosition = input<'previous'>('previous'); override readonly affixPosition = input<'previous' | 'after'>('previous');
// time - available in S and M // time - available in S and M
// time + date - available in S // time + date - available in S
override readonly size = input<'small' | 'medium'>('small'); override readonly size = input<'small' | 'medium' | 'large'>('small');
// Status // Status
readonly isActive = input.required<boolean>(); readonly isActive = input.required<boolean>();

View File

@@ -12,7 +12,7 @@ import { NgIf } from '@angular/common';
}) })
export class PiChipValueComponent extends PiBaseChipComponent { export class PiChipValueComponent extends PiBaseChipComponent {
@HostBinding('class') get valueClasses(): string { @HostBinding('class') get valueClasses(): string {
const colorClass = this.value() > 0 ? 'pi-color__success' : 'pi-color__warn'; const colorClass = Number(this.value()) > 0 ? 'pi-color__success' : 'pi-color__warn';
const hasLabelClass = !!this.label() ? 'has-label' : ''; const hasLabelClass = !!this.label() ? 'has-label' : '';
const unitPosition = this.unitPosition(); const unitPosition = this.unitPosition();
const unitPositionClass = const unitPositionClass =
@@ -26,11 +26,10 @@ export class PiChipValueComponent extends PiBaseChipComponent {
} }
// Content // Content
override readonly value = input.required<number>();
readonly unit = input.required<unit | string>(); readonly unit = input.required<unit | string>();
// Skin // Skin
override readonly size = input<'medium' | 'large'>('large'); override readonly size = input<'small' | 'medium' | 'large'>('large');
// Unit // Unit
readonly unitPosition = input<'previous' | 'after'>('after'); readonly unitPosition = input<'previous' | 'after'>('after');

View File

@@ -1,5 +1,6 @@
import { ChangeDetectionStrategy, Component, HostBinding, input } from '@angular/core'; import { ChangeDetectionStrategy, Component, HostBinding, input } from '@angular/core';
import { theming } from '../../../styles'; import { theming } from '../../../styles';
import { chipColor } from '../entities/chip.model';
import { PiBaseChipComponent } from '../base-chip.component'; import { PiBaseChipComponent } from '../base-chip.component';
import { NgIf } from '@angular/common'; import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@@ -29,5 +30,5 @@ export class PiChipComponent extends PiBaseChipComponent {
// Skin // Skin
readonly appearance = input<'outline' | 'fill'>('outline'); readonly appearance = input<'outline' | 'fill'>('outline');
override readonly color = input<theming>('primary'); override readonly color = input<chipColor | undefined>('primary');
} }

View File

@@ -90,7 +90,7 @@ export class PiListItemComponent {
return color ? `pi-color__${color}` : ''; return color ? `pi-color__${color}` : '';
} }
protected get maxWidthClass(): string { protected get maxWidthClass(): string | false {
const maxWidth = this.maxWidth(); const maxWidth = this.maxWidth();
return maxWidth !== 'full' && `pi-list-item__max-width--${maxWidth}`; return maxWidth !== 'full' && `pi-list-item__max-width--${maxWidth}`;
} }

View File

@@ -73,7 +73,7 @@ export class PiModalComponent {
return this.data as CustomModalData; return this.data as CustomModalData;
} }
get buttonColorClass(): string { get buttonColorClass(): string | null {
return this.buttonColor ? `pi-button pi-color__${this.buttonColor}` : null; return this.buttonColor ? `pi-button pi-color__${this.buttonColor}` : null;
} }

View File

@@ -105,7 +105,7 @@ export class PiNoteComponent implements OnInit {
this.noteStatus = this.getNoteStatus(); this.noteStatus = this.getNoteStatus();
} }
getNoteStatus(): NoteStatus { getNoteStatus(): NoteStatus | undefined {
const noteStatusOptions = this.noteDataService.getNoteStatusData(); const noteStatusOptions = this.noteDataService.getNoteStatusData();
return noteStatusOptions.find((noteStatus) => this.status() === noteStatus.statusType); return noteStatusOptions.find((noteStatus) => this.status() === noteStatus.statusType);
} }

View File

@@ -24,7 +24,7 @@ export class PiPaginatorComponent implements OnInit {
readonly totalPages = input.required<number>(); readonly totalPages = input.required<number>();
readonly isDisabled = input.required<boolean>(); readonly isDisabled = input.required<boolean>();
readonly changePage = output(); readonly changePage = output<number>();
firstPages!: number[]; firstPages!: number[];
@@ -101,7 +101,7 @@ export class PiPaginatorComponent implements OnInit {
if (!this.isDisabled()) { if (!this.isDisabled()) {
this.firstPagesRange = this.firstPagesRange + 3; this.firstPagesRange = this.firstPagesRange + 3;
this.firstPages = this.incrementPaginatorRangeBy(3); this.firstPages = this.incrementPaginatorRangeBy(3);
this.currentPage = this.firstPages[0]; this.currentPage.set(this.firstPages[0]);
this.changePage.emit(this.currentPage()); this.changePage.emit(this.currentPage());
} }
} }

View File

@@ -98,7 +98,7 @@ export abstract class PiBasePanelComponent implements OnInit {
return paddingValue ? `pi-panel__padding--${paddingValue}` : ''; return paddingValue ? `pi-panel__padding--${paddingValue}` : '';
} }
protected get gridClass(): string { protected get gridClass(): string | false {
const grid = this.grid(); const grid = this.grid();
return grid && `pi-panel__grid--${grid}`; return grid && `pi-panel__grid--${grid}`;
} }

View File

@@ -280,7 +280,7 @@ export class PiBaseSelectComponent extends PiFormControl {
/** /**
* Manage the Select & Select Multiple appearance property * Manage the Select & Select Multiple appearance property
*/ */
protected get appearanceClass(): string | undefined { protected get appearanceClass(): string | false | undefined {
const appearance = this.appearance(); const appearance = this.appearance();
return ( return (
this.menuType() !== 'custom-grid' && this.menuType() !== 'custom-grid' &&

View File

@@ -93,8 +93,6 @@ export class PiSelectPeriodComponent extends PiBaseSelectComponent implements Af
} }
} }
override readonly type = input<'dropdown'>();
override readonly menuType = input<'flex-wrap'>();
/** /**
* Component's constructor. Initializes the component with required services. * Component's constructor. Initializes the component with required services.

View File

@@ -39,7 +39,6 @@ export class PiTextViewerLinkComponent extends PiBaseTextViewerComponent {
readonly target = input('_self'); readonly target = input('_self');
readonly queryParams = input<Params>(); readonly queryParams = input<Params>();
override readonly color = input.required<'primary' | 'accent' | 'white' | 'highlighted' | 'grey' | undefined>();
// Skin // Skin
override readonly alignment = input<alignment>('center'); override readonly alignment = input<alignment>('center');

View File

@@ -26,7 +26,7 @@ export abstract class PiBaseGridWrapper {
return gap && `pi-wrapper__gap--${gap}`; return gap && `pi-wrapper__gap--${gap}`;
} }
protected get fillClass(): string | undefined { protected get fillClass(): string | false | undefined {
const fill = this.fill(); const fill = this.fill();
return fill !== 'fit-content' && `pi-wrapper__fill--${fill}`; return fill !== 'fit-content' && `pi-wrapper__fill--${fill}`;
} }

View File

@@ -1,5 +1,6 @@
import { ChangeDetectionStrategy, Component, Directive, HostBinding, input } from '@angular/core'; import { ChangeDetectionStrategy, Component, Directive, HostBinding, input } from '@angular/core';
import { WrapperTypeClass } from '../../../styles'; import { WrapperTypeClass } from '../../../styles';
import { gap } from '../../../styles';
import { PiBaseWrapper } from '../base.wrapper'; import { PiBaseWrapper } from '../base.wrapper';
@Directive() @Directive()
@@ -49,5 +50,5 @@ export class PiMainWrapper extends PiBaseWrapper {
readonly isCentered = input(false); readonly isCentered = input(false);
readonly type = input<'' | 'document'>(''); readonly type = input<'' | 'document'>('');
override readonly gap = input<'s' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl'>('xxl'); override readonly gap = input<gap>('xxl');
} }

View File

@@ -1,5 +1,5 @@
// Angular // Angular
import { Injectable } from '@angular/core'; import { Injectable, inject } from '@angular/core';
// Ngrx // Ngrx
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
@@ -15,6 +15,10 @@ import * as fromSelectors from '../state/device-configs.selectors';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class DeviceConfigsFacade { export class DeviceConfigsFacade {
// `inject()` en vez de parámetro de constructor: los inicializadores de
// propiedad de abajo se evalúan antes que los parámetros del constructor.
private readonly store = inject<Store<fromState.DeviceConfigsState>>(Store);
// Device // Device
readonly device$: Observable<Device> = this.store.select(fromSelectors.getDevice); readonly device$: Observable<Device> = this.store.select(fromSelectors.getDevice);
readonly size$: Observable<Size> = this.store.select(fromSelectors.getSize); readonly size$: Observable<Size> = this.store.select(fromSelectors.getSize);
@@ -23,8 +27,6 @@ export class DeviceConfigsFacade {
// Browser // Browser
readonly browser$: Observable<Browser> = this.store.select(fromSelectors.getBrowser); readonly browser$: Observable<Browser> = this.store.select(fromSelectors.getBrowser);
constructor(private store: Store<fromState.DeviceConfigsState>) {}
getBrowser(): void { getBrowser(): void {
this.store.dispatch(fromActions.BrowserActions.getBrowser()); this.store.dispatch(fromActions.BrowserActions.getBrowser());
} }

View File

@@ -1,5 +1,5 @@
// Angular // Angular
import { Injectable } from '@angular/core'; import { Injectable, inject } from '@angular/core';
// Ngrx // Ngrx
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
@@ -14,9 +14,11 @@ import * as fromState from '../state/list-configs.reducer';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class ListConfigsFacade { export class ListConfigsFacade {
readonly mode$: Observable<fromState.ListMode> = this.store.select(fromSelectors.getListMode); // `inject()` en vez de parámetro de constructor: los inicializadores de
// propiedad de abajo se evalúan antes que los parámetros del constructor.
private readonly store = inject<Store<fromState.ListConfigsState>>(Store);
constructor(private store: Store<fromState.ListConfigsState>) {} readonly mode$: Observable<fromState.ListMode> = this.store.select(fromSelectors.getListMode);
setListMode(payload: fromState.ListMode): void { setListMode(payload: fromState.ListMode): void {
this.store.dispatch(fromActions.setListMode({ payload })); this.store.dispatch(fromActions.setListMode({ payload }));

View File

@@ -1,5 +1,5 @@
// Angular // Angular
import { Injectable } from '@angular/core'; import { Injectable, inject } from '@angular/core';
// RxJS // RxJS
import { Observable, Subscribable } from 'rxjs'; import { Observable, Subscribable } from 'rxjs';
@@ -13,10 +13,12 @@ import * as LoaderActions from '../state/loader.actions';
@Injectable() @Injectable()
export class LoaderFacade { export class LoaderFacade {
loader$: Observable<boolean> = this.store.pipe(select(LoaderSelectors.getLoader)); // `inject()` en vez de parámetro de constructor: los inicializadores de
showLoader$: Observable<unknown> | Subscribable<unknown> | Promise<unknown>; // propiedad de abajo se evalúan antes que los parámetros del constructor.
private readonly store = inject(Store);
constructor(private store: Store) {} loader$: Observable<boolean> = this.store.pipe(select(LoaderSelectors.getLoader));
showLoader$?: Observable<unknown> | Subscribable<unknown> | Promise<unknown>;
showLoader() { showLoader() {
this.store.dispatch(LoaderActions.showLoader()); this.store.dispatch(LoaderActions.showLoader());