refactor: migra a control flow nativo (@if/@for/@switch) y elimina CommonModule

This commit is contained in:
2026-07-28 17:57:26 +02:00
parent c65e9f1cbd
commit 83af63ae5c
105 changed files with 1273 additions and 1268 deletions

View File

@@ -22,10 +22,12 @@ Construir: `nx build ui` · Lint: `nx lint ui`
| NgModules | 41 → 4 (sólo quedan los que aportan providers: `icon-registry`, `loaders`, `router-store`, `scroll-to`) | | NgModules | 41 → 4 (sólo quedan los que aportan providers: `icon-registry`, `loaders`, `router-store`, `scroll-to`) |
| Componentes | 70, **todos** con `ChangeDetectionStrategy.OnPush` | | Componentes | 70, **todos** con `ChangeDetectionStrategy.OnPush` |
| Decoradores | 0 restantes: 460 `input()`, 6 `model()`, 20 `output()`, 8 `viewChild()`, 2 `viewChildren()`, 17 `contentChild()`, 6 `contentChildren()` | | Decoradores | 0 restantes: 460 `input()`, 6 `model()`, 20 `output()`, 8 `viewChild()`, 2 `viewChildren()`, 17 `contentChild()`, 6 `contentChildren()` |
| Control flow | `*ngIf`/`*ngFor`/`*ngSwitch` → `@if`/`@for`/`@switch` (110 `@if`, 26 `@for`, 3 `@switch`). Ya no se importa ninguna directiva de `CommonModule` |
Se usaron las migraciones oficiales de Angular (`@angular/core:standalone`, Se usaron las migraciones oficiales de Angular (`@angular/core:standalone`,
`signal-input-migration`, `output-migration`, `signal-queries-migration`) y se `signal-input-migration`, `output-migration`, `signal-queries-migration`,
resolvió a mano lo que no cubren. `control-flow-migration`, `cleanup-unused-imports`) y se resolvió a mano lo que
no cubren.
## Decisiones que cambian comportamiento ## Decisiones que cambian comportamiento
@@ -79,6 +81,17 @@ Mantiene el runtime idéntico al original. Se pueden eliminar migrando a
`truncate : (33 || …)`, así que el fallback nunca se aplicaba. Ahora está `truncate : (33 || …)`, así que el fallback nunca se aplicaba. Ahora está
parentizado como se pretendía. parentizado como se pretendía.
**8. Los 3 selects se convirtieron a control flow a mano.**
La migración automática se rindió con ellos: tenían un `*ngIf ... else` que
apuntaba a un `<ng-template>` con un `[ngSwitch]` dentro. Al reescribirlos hubo
que renombrar plantillas duplicadas (`#defaultSelected` aparecía dos veces en
ramas distintas del switch) a `#defaultSelectedFill`/`#defaultSelectedOutline`,
y en select-period `#defaultOption` → `#defaultMonthOption`/`#defaultYearOption`.
Los `*ngFor` sin `trackBy` pasaron a `track <item>`, que es lo que hacía `ngFor`
por defecto. En data-grid y select-carousel la migración generó
`track trackByFn(i, item)` pero esos `trackByFn` sólo declaran `index`: se
corrigió la aridad a `track trackByFn(i)`.
## Colisiones de nombres en el barrel ## Colisiones de nombres en el barrel
El origen tiene símbolos duplicados. En `index.ts` gana el primero y el otro se El origen tiene símbolos duplicados. En `index.ts` gana el primero y el otro se
@@ -104,7 +117,8 @@ omite (queda anotado en el fichero). Siguen siendo accesibles por ruta directa:
- **`Sector`** vivía en `deale-saas/util/models` (lib de aplicación, fuera de alcance); se trajo la interfaz a `util/models`. - **`Sector`** vivía en `deale-saas/util/models` (lib de aplicación, fuera de alcance); se trajo la interfaz a `util/models`.
- **ngrx 21 con Angular 22**: instalado con `--legacy-peer-deps` (aún no declara soporte para 22). - **ngrx 21 con Angular 22**: instalado con `--legacy-peer-deps` (aún no declara soporte para 22).
- **Lint**: `nx lint ui` falla con avisos heredados del código original — - **Lint**: `nx lint ui` falla con avisos heredados del código original —
`prefer-control-flow` (104: `*ngIf`/`*ngFor` en vez de `@if`/`@for`), `prefer-inject` (51), `directive-selector` (46), `no-explicit-any` (35),
`directive-selector` (40), `prefer-inject` (33), a11y y `no-unused-vars`. `no-unused-expressions` (33), a11y (`click-events-have-key-events`,
Nada bloquea el build. Hay migraciones oficiales para los dos primeros grupos: `interactive-supports-focus`, `label-has-associated-control`) y
`nx g @angular/core:control-flow-migration` y `nx g @angular/core:inject-migration`. `no-unused-vars`. Nada bloquea el build. Para el primer grupo hay migración
oficial: `nx g @angular/core:inject-migration`.

View File

@@ -1,9 +1,9 @@
<!-- HEADER OF THE WHOLE ACCORDION --> <!-- HEADER OF THE WHOLE ACCORDION -->
<ng-content select="pi-accordion-header"></ng-content> <ng-content select="pi-accordion-header"></ng-content>
<ng-container *ngIf="direction() === 'default'; else horizontal"> @if (direction() === 'default') {
@for (item of items(); track item; let i = $index) {
<section <section
*ngFor="let item of items(); index as i"
[class]=" [class]="
!!item.status() && item.status() === 'disabled' !!item.status() && item.status() === 'disabled'
? 'is-disabled' ? 'is-disabled'
@@ -12,8 +12,8 @@
class="pi-accordion-item" class="pi-accordion-item"
> >
<!-- TOPBAR --> <!-- TOPBAR -->
@if (item.isConfidential() === true) {
<div <div
*ngIf="item.isConfidential() === true"
class="pi-accordion-item-content pi-accordion-item-content__topbar" class="pi-accordion-item-content pi-accordion-item-content__topbar"
pi-dynamic-color pi-dynamic-color
[color]="isItemExpanded(i) ? 'highlighted' : 'grey'" [color]="isItemExpanded(i) ? 'highlighted' : 'grey'"
@@ -31,7 +31,7 @@
fontWeight="400" fontWeight="400"
></pi-text-viewer> ></pi-text-viewer>
</div> </div>
}
<!-- HEADER --> <!-- HEADER -->
<header <header
(click)="toggleState(item, i)" (click)="toggleState(item, i)"
@@ -42,7 +42,9 @@
" "
> >
<ng-container <ng-container
[ngTemplateOutlet]="item?.customHeader()?.templateRef || defaultHeader" [ngTemplateOutlet]="
item?.customHeader()?.templateRef || defaultHeader
"
[ngTemplateOutletContext]="{ [ngTemplateOutletContext]="{
$implicit: item, $implicit: item,
index: i, index: i,
@@ -52,14 +54,17 @@
<aside <aside
class="pi-accordion-item-header-content pi-accordion-item-header-content__right" class="pi-accordion-item-header-content pi-accordion-item-header-content__right"
> >
@if (item.status()) {
<pi-chip-status <pi-chip-status
*ngIf="item.status()"
[status]="item.status()" [status]="item.status()"
[label]="item.statusLabel()" [label]="item.statusLabel()"
[icon]="item.statusIcon()" [icon]="item.statusIcon()"
></pi-chip-status> ></pi-chip-status>
<span *ngIf="item.status()"></span> }
<ng-container *ngIf="hasForm(); else defaultIcon"> @if (item.status()) {
<span></span>
}
@if (hasForm()) {
<pi-icon-button <pi-icon-button
(execute)="toggleState(item, i)" (execute)="toggleState(item, i)"
appearance="ghost" appearance="ghost"
@@ -71,20 +76,18 @@
[class]="isItemExpanded(i) ? 'is-expanded' : 'is-collapsed'" [class]="isItemExpanded(i) ? 'is-expanded' : 'is-collapsed'"
[disabled]="!!item.status() && item.status() === 'disabled'" [disabled]="!!item.status() && item.status() === 'disabled'"
></pi-icon-button> ></pi-icon-button>
</ng-container> } @else {
<ng-template #defaultIcon>
<pi-icon <pi-icon
icon="chevron-forward" icon="chevron-forward"
[size]="appearance() === 'outline' ? 'x-small' : 'small'" [size]="appearance() === 'outline' ? 'x-small' : 'small'"
[color]="color() === 'white' ? 'grey' : color()" [color]="color() === 'white' ? 'grey' : color()"
></pi-icon> ></pi-icon>
</ng-template> }
</aside> </aside>
</header> </header>
<!-- SUMMARY --> <!-- SUMMARY -->
@if (!!item?.summaryContent() && !isItemExpanded(i)) {
<section <section
*ngIf="!!item?.summaryContent() && !isItemExpanded(i)"
class="pi-accordion-item-content pi-accordion-item-content__summary" class="pi-accordion-item-content pi-accordion-item-content__summary"
> >
<ng-container <ng-container
@@ -96,7 +99,7 @@
}" }"
></ng-container> ></ng-container>
</section> </section>
}
<!-- MAIN --> <!-- MAIN -->
<main <main
class="pi-accordion-item-content pi-accordion-item-content__expandable" class="pi-accordion-item-content pi-accordion-item-content__expandable"
@@ -106,26 +109,11 @@
></ng-container> ></ng-container>
</main> </main>
</section> </section>
</ng-container> }
} @else {
<!-- FOOTER OF THE WHOLE ACCORDION -->
<ng-content select="pi-accordion-footer"></ng-content>
<ng-template #defaultHeader let-item>
<pi-text-viewer
[label]="item?.title"
[value]="item?.subtitle"
flexDirection="column"
fontWeight="600-300"
fontSize="m-xs"
[color]="getHeaderTextColor()"
></pi-text-viewer>
</ng-template>
<ng-template #horizontal>
<section class="pi-accordion-item-content pi-accordion-item-content__left"> <section class="pi-accordion-item-content pi-accordion-item-content__left">
<!-- HEADER --> <!-- HEADER -->
<ng-container *ngFor="let item of items(); index as i"> @for (item of items(); track item; let i = $index) {
<header <header
[class]=" [class]="
setAccordionItemClasses(item, i) + setAccordionItemClasses(item, i) +
@@ -144,26 +132,31 @@
isExpanded: isItemExpanded(i), isExpanded: isItemExpanded(i),
}" }"
></ng-container> ></ng-container>
<aside *ngIf="hasChevron()"> @if (hasChevron()) {
<aside>
@if (item.status() && !isItemExpanded(i)) {
<pi-chip-status <pi-chip-status
*ngIf="item.status() && !isItemExpanded(i)"
[status]="item.status()" [status]="item.status()"
icon="exclamation" icon="exclamation"
></pi-chip-status> ></pi-chip-status>
<span *ngIf="item.status() && !isItemExpanded(i)"></span> }
@if (item.status() && !isItemExpanded(i)) {
<span></span>
}
<pi-icon <pi-icon
icon="chevron-forward" icon="chevron-forward"
[size]="appearance() === 'outline' ? 'x-small' : 'small'" [size]="appearance() === 'outline' ? 'x-small' : 'small'"
[color]="color() === 'white' ? 'grey' : color()" [color]="color() === 'white' ? 'grey' : color()"
></pi-icon> ></pi-icon>
</aside> </aside>
}
</header> </header>
</ng-container> }
</section> </section>
<section class="pi-accordion-item-content pi-accordion-item-content__right"> <section class="pi-accordion-item-content pi-accordion-item-content__right">
<!-- MAIN --> <!-- MAIN -->
@for (item of items(); track item; let i = $index) {
<main <main
*ngFor="let item of items(); index as i"
[class]=" [class]="
setAccordionItemClasses(item, i) + setAccordionItemClasses(item, i) +
' ' + ' ' +
@@ -174,5 +167,20 @@
*ngTemplateOutlet="item?.content()?.templateRef" *ngTemplateOutlet="item?.content()?.templateRef"
></ng-container> ></ng-container>
</main> </main>
}
</section> </section>
}
<!-- FOOTER OF THE WHOLE ACCORDION -->
<ng-content select="pi-accordion-footer"></ng-content>
<ng-template #defaultHeader let-item>
<pi-text-viewer
[label]="item?.title"
[value]="item?.subtitle"
flexDirection="column"
fontWeight="600-300"
fontSize="m-xs"
[color]="getHeaderTextColor()"
></pi-text-viewer>
</ng-template> </ng-template>

View File

@@ -8,7 +8,7 @@ import {
} from '@angular/core'; } from '@angular/core';
import { padding, styleType, textColor } from '../../../styles'; import { padding, styleType, textColor } from '../../../styles';
import { PiAccordionItemDirective } from '../directives/accordion-content.directive'; import { PiAccordionItemDirective } from '../directives/accordion-content.directive';
import { NgIf, NgFor, NgTemplateOutlet } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
import { PiDynamicColorDirective } from '../../../util/color/directives/colors.directive'; import { PiDynamicColorDirective } from '../../../util/color/directives/colors.directive';
import { PiTextViewerComponent } from '../../text/text-viewer/text-viewer.component'; import { PiTextViewerComponent } from '../../text/text-viewer/text-viewer.component';
import { PiChipStatusComponent } from '../../chip/chip-status/chip-status.component'; import { PiChipStatusComponent } from '../../chip/chip-status/chip-status.component';
@@ -22,8 +22,6 @@ import { TranslatePipe } from '@ngx-translate/core';
styleUrls: ['../styles/accordion.component.scss'], styleUrls: ['../styles/accordion.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ imports: [
NgIf,
NgFor,
PiDynamicColorDirective, PiDynamicColorDirective,
PiTextViewerComponent, PiTextViewerComponent,
NgTemplateOutlet, NgTemplateOutlet,

View File

@@ -10,11 +10,13 @@
<section> <section>
<header> <header>
<h3 bold>{{ title() }}</h3> <h3 bold>{{ title() }}</h3>
<span *ngIf="message()">{{ message() }}</span> @if (message()) {
<span>{{ message() }}</span>
}
</header> </header>
<!-- Action --> <!-- Action -->
@if (buttonText()) {
<pi-icon-button <pi-icon-button
*ngIf="buttonText()"
(execute)="execute.emit($event)" (execute)="execute.emit($event)"
icon="chevron-forward" icon="chevron-forward"
iconColor="white" iconColor="white"
@@ -23,5 +25,6 @@
[hasPadding]="false" [hasPadding]="false"
>{{ buttonText() }}</pi-icon-button >{{ buttonText() }}</pi-icon-button
> >
}
</section> </section>
</main> </main>

View File

@@ -7,7 +7,7 @@ import {
} from '@angular/core'; } from '@angular/core';
import { PiBackgroundImageDirective } from '../../image/background-image.directive'; import { PiBackgroundImageDirective } from '../../image/background-image.directive';
import { PiTextWeightBoldDirective } from '../../text/directives/text-weights.directive'; import { PiTextWeightBoldDirective } from '../../text/directives/text-weights.directive';
import { NgIf } from '@angular/common';
import { PiIconButtonComponent } from '../../button/icon-button/icon-button.component'; import { PiIconButtonComponent } from '../../button/icon-button/icon-button.component';
@Component({ @Component({
@@ -18,7 +18,6 @@ import { PiIconButtonComponent } from '../../button/icon-button/icon-button.comp
imports: [ imports: [
PiBackgroundImageDirective, PiBackgroundImageDirective,
PiTextWeightBoldDirective, PiTextWeightBoldDirective,
NgIf,
PiIconButtonComponent, PiIconButtonComponent,
], ],
}) })

View File

@@ -14,14 +14,12 @@
appearanceClass, appearanceClass,
]" ]"
> >
<span *ngIf="text()">{{ text() }}</span> @if (text()) {
<span>{{ text() }}</span>
}
<svg @if (hasIcon()) {
*ngIf="hasIcon()" <svg viewBox="0 0 6 9" fill="none" xmlns="http://www.w3.org/2000/svg">
viewBox="0 0 6 9"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g> <g>
<path <path
d="M1 1C4.5 4 5 4.38484 5 4.5C5 4.61516 4.5 5 1 8" d="M1 1C4.5 4 5 4.38484 5 4.5C5 4.61516 4.5 5 1 8"
@@ -33,4 +31,5 @@
<path d="M4.5 4.5H0" stroke="currentColor" stroke-width="1" /> <path d="M4.5 4.5H0" stroke="currentColor" stroke-width="1" />
</g> </g>
</svg> </svg>
}
</button> </button>

View File

@@ -6,14 +6,13 @@ import {
} from '@angular/core'; } from '@angular/core';
import { buttonSize, mode } from '../../../styles'; import { buttonSize, mode } from '../../../styles';
import { PiBaseButtonComponent } from '../base-button.component'; import { PiBaseButtonComponent } from '../base-button.component';
import { NgIf } from '@angular/common';
@Component({ @Component({
selector: 'pi-action-button', selector: 'pi-action-button',
templateUrl: './action-button.component.html', templateUrl: './action-button.component.html',
styleUrls: ['./action-button.component.scss'], styleUrls: ['./action-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf], imports: [],
}) })
export class PiActionButtonComponent extends PiBaseButtonComponent { export class PiActionButtonComponent extends PiBaseButtonComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,5 +1,5 @@
<ng-container *ngIf="iconType() === 'custom'; else defaultIcon" @if (iconType() === 'custom') {
><button <button
#content #content
(click)="onClickHandler($event)" (click)="onClickHandler($event)"
previous="previous" previous="previous"
@@ -20,13 +20,14 @@
modeClass, modeClass,
]" ]"
> >
<span *ngIf="text()">{{ text() }}</span> @if (text()) {
<span>{{ text() }}</span>
}
<ng-content></ng-content> <ng-content></ng-content>
<img src="/assets/icons/{{ icon() }}.svg" /></button <img src="/assets/icons/{{ icon() }}.svg" />
></ng-container> </button>
} @else {
<ng-template #defaultIcon <button
><button
#content #content
(click)="onClickHandler($event)" (click)="onClickHandler($event)"
previous="previous" previous="previous"
@@ -47,12 +48,15 @@
modeClass, modeClass,
]" ]"
> >
<mat-icon *ngIf="previous()" [svgIcon]="icon()!" alt="icon"></mat-icon> @if (previous()) {
<span *ngIf="text()">{{ text() }}</span> <mat-icon [svgIcon]="icon()!" alt="icon"></mat-icon>
}
@if (text()) {
<span>{{ text() }}</span>
}
<ng-content></ng-content> <ng-content></ng-content>
<mat-icon @if (!previous()) {
*ngIf="!previous()" <mat-icon [svgIcon]="icon()!" alt="icon"></mat-icon>
[svgIcon]="icon()!" }
alt="icon" </button>
></mat-icon></button }
></ng-template>

View File

@@ -8,7 +8,7 @@ import {
} from '@angular/core'; } from '@angular/core';
import { buttonSize, mode } from '../../../styles'; import { buttonSize, mode } from '../../../styles';
import { PiBaseButtonComponent } from '../base-button.component'; import { PiBaseButtonComponent } from '../base-button.component';
import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -16,7 +16,7 @@ import { MatIcon } from '@angular/material/icon';
templateUrl: './icon-button.component.html', templateUrl: './icon-button.component.html',
styleUrls: ['./icon-button.component.scss'], styleUrls: ['./icon-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, MatIcon], imports: [MatIcon],
}) })
export class PiIconButtonComponent extends PiBaseButtonComponent { export class PiIconButtonComponent extends PiBaseButtonComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,13 +1,10 @@
<span @if (icon() !== 'check') {
*ngIf="icon() !== 'check'; else checkIconTemplate" <span (click)="execute.emit($event)"></span>
(click)="execute.emit($event)" } @else {
></span> <mat-icon
<ng-template #checkIconTemplate
><mat-icon
size="size" size="size"
svgIcon="check" svgIcon="check"
color="color" color="color"
(click)="execute.emit($event)" (click)="execute.emit($event)"
></mat-icon ></mat-icon>
></ng-template> }

View File

@@ -5,7 +5,7 @@ import {
input, input,
} from '@angular/core'; } from '@angular/core';
import { PiBaseButtonComponent } from '../base-button.component'; import { PiBaseButtonComponent } from '../base-button.component';
import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -13,7 +13,7 @@ import { MatIcon } from '@angular/material/icon';
templateUrl: './radio-button.component.html', templateUrl: './radio-button.component.html',
styleUrls: ['./radio-button.component.scss'], styleUrls: ['./radio-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, MatIcon], imports: [MatIcon],
}) })
export class PiRadioButtonComponent extends PiBaseButtonComponent { export class PiRadioButtonComponent extends PiBaseButtonComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -3,11 +3,15 @@
[disabled]="isDisabled()" [disabled]="isDisabled()"
class="pi-button__toggle" class="pi-button__toggle"
> >
<mat-icon *ngIf="icon()" [svgIcon]="icon()!" [color]="color()"></mat-icon> @if (icon()) {
<mat-icon [svgIcon]="icon()!" [color]="color()"></mat-icon>
}
<span>{{ text() }}</span> <span>{{ text() }}</span>
<ng-content></ng-content> <ng-content></ng-content>
</button> </button>
<span *ngIf="amount()" @if (amount()) {
<span
><small>{{ amount() }}</small></span ><small>{{ amount() }}</small></span
> >
}

View File

@@ -6,7 +6,7 @@ import {
} from '@angular/core'; } from '@angular/core';
import { buttonSize } from '../../../styles'; import { buttonSize } from '../../../styles';
import { PiBaseButtonComponent } from '../base-button.component'; import { PiBaseButtonComponent } from '../base-button.component';
import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -14,7 +14,7 @@ import { MatIcon } from '@angular/material/icon';
templateUrl: './toggle-button.component.html', templateUrl: './toggle-button.component.html',
styleUrls: ['./toggle-button.component.scss'], styleUrls: ['./toggle-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, MatIcon], imports: [MatIcon],
}) })
export class PiToggleButtonComponent extends PiBaseButtonComponent { export class PiToggleButtonComponent extends PiBaseButtonComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -5,9 +5,11 @@
<ng-content select="pi-card-left-content"> </ng-content> <ng-content select="pi-card-left-content"> </ng-content>
<ng-content select="pi-card-right-content"></ng-content> <ng-content select="pi-card-right-content"></ng-content>
<span *ngIf="isClickable() && !!linkLabel()" (click)="execute.emit()"> @if (isClickable() && !!linkLabel()) {
<span (click)="execute.emit()">
<a> <a>
{{ linkLabel() }} {{ linkLabel() }}
<pi-icon icon="open-details" color="primary"></pi-icon> <pi-icon icon="open-details" color="primary"></pi-icon>
</a> </a>
</span> </span>
}

View File

@@ -3,14 +3,14 @@ import { ChangeDetectionStrategy, Component, HostBinding } from '@angular/core';
// Components // Components
import { PiBaseCardComponent } from '../base-card.component'; import { PiBaseCardComponent } from '../base-card.component';
import { NgIf } from '@angular/common';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
@Component({ @Component({
selector: 'pi-card', selector: 'pi-card',
templateUrl: './card.component.html', templateUrl: './card.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, PiIconComponent], imports: [PiIconComponent],
}) })
export class PiCardComponent extends PiBaseCardComponent { export class PiCardComponent extends PiBaseCardComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,33 +1,34 @@
<main> <main>
@if (hasOverflow && !hideSwipeButtons()) {
<pi-icon-button <pi-icon-button
*ngIf="hasOverflow && !hideSwipeButtons()"
[icon]="prevIcon" [icon]="prevIcon"
(execute)="prev()" (execute)="prev()"
[disabled]="!canSwipePrev" [disabled]="!canSwipePrev"
appearance="ghost" appearance="ghost"
></pi-icon-button> ></pi-icon-button>
}
<section [class]="hasOverflow ? 'has-overflow' : ''" #carouselContentWrapper> <section [class]="hasOverflow ? 'has-overflow' : ''" #carouselContentWrapper>
<ng-container @for (item of carouselItems(); track trackByFn(i, item); let i = $index) {
*ngFor="let item of carouselItems(); index as i; trackBy: trackByFn"
>
<section [class]="getItemClass(i)" (click)="selectItem(i)"> <section [class]="getItemClass(i)" (click)="selectItem(i)">
<ng-container *ngTemplateOutlet="item.templateRef"> </ng-container> <ng-container *ngTemplateOutlet="item.templateRef"> </ng-container>
</section> </section>
</ng-container> }
</section> </section>
@if (hasOverflow && !hideSwipeButtons()) {
<pi-icon-button <pi-icon-button
*ngIf="hasOverflow && !hideSwipeButtons()"
[icon]="nextIcon" [icon]="nextIcon"
(execute)="next()" (execute)="next()"
[disabled]="!canSwipeNext" [disabled]="!canSwipeNext"
appearance="ghost" appearance="ghost"
></pi-icon-button> ></pi-icon-button>
}
</main> </main>
<!-- Paginator --> <!-- Paginator -->
<footer *ngIf="hasOverflow && !hidePaginator()"> @if (hasOverflow && !hidePaginator()) {
<div <footer>
*ngFor="let i of pages; index as index" @for (i of pages; track i; let index = $index) {
[class]="index === currentPageIndex ? 'is-active' : ''" <div [class]="index === currentPageIndex ? 'is-active' : ''"></div>
></div> }
</footer> </footer>
}

View File

@@ -23,7 +23,7 @@ import { ComponentFamilyClass, justify, theming } from '../../../styles';
import { Device, DeviceConfigsFacade } from '../../../util/device-configs'; import { Device, DeviceConfigsFacade } from '../../../util/device-configs';
import { PiCarouselItemDirective } from '../carousel.directive'; import { PiCarouselItemDirective } from '../carousel.directive';
import { Subject, combineLatest, skip, takeUntil } from 'rxjs'; import { Subject, combineLatest, skip, takeUntil } from 'rxjs';
import { NgIf, NgFor, NgTemplateOutlet } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
import { PiIconButtonComponent } from '../../button/icon-button/icon-button.component'; import { PiIconButtonComponent } from '../../button/icon-button/icon-button.component';
@Component({ @Component({
@@ -31,7 +31,7 @@ import { PiIconButtonComponent } from '../../button/icon-button/icon-button.comp
templateUrl: './carousel.component.html', templateUrl: './carousel.component.html',
styleUrls: ['./carousel.component.scss'], styleUrls: ['./carousel.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, PiIconButtonComponent, NgFor, NgTemplateOutlet], imports: [PiIconButtonComponent, NgTemplateOutlet],
}) })
export class PiCarouselComponent export class PiCarouselComponent
implements OnInit, OnChanges, AfterViewInit, AfterViewChecked, OnDestroy implements OnInit, OnChanges, AfterViewInit, AfterViewChecked, OnDestroy

View File

@@ -1,4 +1,4 @@
<ng-container *ngFor="let dataset of datasets(); let index = index"> @for (dataset of datasets(); track dataset; let index = $index) {
<section <section
[class]="hoveredDatasetIndex() === index ? 'is-hovered' : ''" [class]="hoveredDatasetIndex() === index ? 'is-hovered' : ''"
(mouseenter)="triggerDatasetHover.emit(index)" (mouseenter)="triggerDatasetHover.emit(index)"
@@ -14,6 +14,6 @@
{{ dataset.label | translate }} {{ dataset.label | translate }}
</label> </label>
</section> </section>
</ng-container> }
<span>{{ 'common.legend' | translate }}</span> <span>{{ 'common.legend' | translate }}</span>

View File

@@ -6,7 +6,7 @@ import {
output, output,
} from '@angular/core'; } from '@angular/core';
import { Dataset } from '../../../util/models'; import { Dataset } from '../../../util/models';
import { NgFor } from '@angular/common';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -14,7 +14,7 @@ import { TranslatePipe } from '@ngx-translate/core';
templateUrl: './chart-legend.component.html', templateUrl: './chart-legend.component.html',
styleUrls: ['./chart-legend.component.scss'], styleUrls: ['./chart-legend.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgFor, TranslatePipe], imports: [TranslatePipe],
}) })
export class PiChartLegendComponent { export class PiChartLegendComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,21 +1,27 @@
<span (click)="execute.emit()"> <span (click)="execute.emit()">
<div> <div>
<span class="pi-chip-label"> {{ label() }}</span> <span class="pi-chip-label"> {{ label() }}</span>
<span class="pi-chip-affix" *ngIf="value() || icon()"> @if (value() || icon()) {
<span class="pi-chip-affix">
@if (icon()) {
<mat-icon <mat-icon
*ngIf="icon()"
class="pi-chip-affix__icon" class="pi-chip-affix__icon"
[svgIcon]="icon()!" [svgIcon]="icon()!"
[color]="color()" [color]="color()"
></mat-icon> ></mat-icon>
<span *ngIf="value()" class="pi-chip-affix__value">{{ value() }}</span> }
@if (value()) {
<span class="pi-chip-affix__value">{{ value() }}</span>
}
</span> </span>
}
</div> </div>
@if (isClosable()) {
<mat-icon <mat-icon
*ngIf="isClosable()"
svgIcon="close" svgIcon="close"
[color]="color()" [color]="color()"
class="pi-chip-close-icon" class="pi-chip-close-icon"
></mat-icon> ></mat-icon>
}
</span> </span>

View File

@@ -8,7 +8,7 @@ import {
import { ComponentFamilyClass, mode, styleType } from '../../../styles'; import { ComponentFamilyClass, mode, styleType } from '../../../styles';
import { PiBaseChipComponent } from '../base-chip.component'; import { PiBaseChipComponent } from '../base-chip.component';
import { chipColor } from '../entities/chip.model'; import { chipColor } from '../entities/chip.model';
import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -19,7 +19,7 @@ import { MatIcon } from '@angular/material/icon';
'../styles/base-chip.component.scss', '../styles/base-chip.component.scss',
], ],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, MatIcon], imports: [MatIcon],
}) })
export class PiChipActionComponent extends PiBaseChipComponent { export class PiChipActionComponent extends PiBaseChipComponent {
@HostBinding('class') get actionClasses(): string { @HostBinding('class') get actionClasses(): string {

View File

@@ -1,7 +1,7 @@
<span (click)="isClickable() ? click.emit() : null"> <span (click)="isClickable() ? click.emit() : null">
<span class="pi-chip-date__weekday" *ngIf="size() === 'large'">{{ @if (size() === 'large') {
dateValue?.weekDay <span class="pi-chip-date__weekday">{{ dateValue?.weekDay }}</span>
}}</span> }
<span class="pi-chip-date__day">{{ dateValue?.day }}</span> <span class="pi-chip-date__day">{{ dateValue?.day }}</span>
<span class="pi-chip-date__month">{{ dateValue?.month.toUpperCase() }}</span> <span class="pi-chip-date__month">{{ dateValue?.month.toUpperCase() }}</span>
</span> </span>

View File

@@ -11,7 +11,6 @@ import { Date } from '../../../util/models';
import { PiBaseChipComponent } from '../base-chip.component'; import { PiBaseChipComponent } from '../base-chip.component';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
import _ from 'lodash'; import _ from 'lodash';
import { NgIf } from '@angular/common';
@Component({ @Component({
selector: 'pi-chip-date', selector: 'pi-chip-date',
@@ -21,7 +20,7 @@ import { NgIf } from '@angular/common';
'../styles/base-chip.component.scss', '../styles/base-chip.component.scss',
], ],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf], imports: [],
}) })
export class PiChipDateComponent extends PiBaseChipComponent { export class PiChipDateComponent extends PiBaseChipComponent {
@HostBinding('class') get dateClasses(): string { @HostBinding('class') get dateClasses(): string {

View File

@@ -1,11 +1,14 @@
<span> <span>
<span class="pi-chip-label" *ngIf="label()">{{ label() }}</span> @if (label()) {
<span class="pi-chip-label">{{ label() }}</span>
}
<span class="pi-chip-affix"> <span class="pi-chip-affix">
@if (icon()) {
<mat-icon <mat-icon
*ngIf="icon()"
[svgIcon]="icon()!" [svgIcon]="icon()!"
[color]="color()" [color]="color()"
class="pi-chip-affix__icon" class="pi-chip-affix__icon"
></mat-icon> ></mat-icon>
}
</span> </span>
</span> </span>

View File

@@ -8,7 +8,7 @@ import {
// Shared // Shared
import { status } from '../../../util/status'; import { status } from '../../../util/status';
import { PiBaseChipComponent } from '../base-chip.component'; import { PiBaseChipComponent } from '../base-chip.component';
import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -19,7 +19,7 @@ import { MatIcon } from '@angular/material/icon';
'../styles/base-chip.component.scss', '../styles/base-chip.component.scss',
], ],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, MatIcon], imports: [MatIcon],
}) })
export class PiChipStatusComponent extends PiBaseChipComponent { export class PiChipStatusComponent extends PiBaseChipComponent {
@HostBinding('class') get statusClasses(): string { @HostBinding('class') get statusClasses(): string {

View File

@@ -1,33 +1,29 @@
<span @if (time() && date()) {
(click)="isClosable() ? execute.emit() : null" <span (click)="isClosable() ? execute.emit() : null">
*ngIf="time() && date(); else singleContentTemplate"
>
<div> <div>
<span class="pi-chip-affix"> <span class="pi-chip-affix">
<span class="pi-chip-affix__time"> {{ timeValue }}h </span> <span class="pi-chip-affix__time"> {{ timeValue }}h </span>
</span> </span>
<span>{{ dateValue }}</span> <span>{{ dateValue }}</span>
</div> </div>
@if (isClosable()) {
<mat-icon <mat-icon
*ngIf="isClosable()"
svgIcon="close" svgIcon="close"
[color]="color()" [color]="color()"
class="pi-chip-close-icon" class="pi-chip-close-icon"
></mat-icon> ></mat-icon>
}
</span> </span>
} @else {
<ng-template #singleContentTemplate>
<span (click)="isClosable() ? execute.emit() : null"> <span (click)="isClosable() ? execute.emit() : null">
<div> <div>
<span class="pi-chip-affix"> <span class="pi-chip-affix">
<span *ngIf="time(); else dateTemplate" class="pi-chip-affix__time"> @if (time()) {
{{ timeValue }}h <span class="pi-chip-affix__time"> {{ timeValue }}h </span>
</span> } @else {
<ng-template #dateTemplate>
<span class="pi-chip-affix__date"> {{ dateValue }} </span> <span class="pi-chip-affix__date"> {{ dateValue }} </span>
</ng-template> }
</span> </span>
</div> </div>
</span> </span>
</ng-template> }

View File

@@ -10,7 +10,7 @@ import { ComponentFamilyClass } from '../../../styles';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
import { PiBaseChipComponent } from '../base-chip.component'; import { PiBaseChipComponent } from '../base-chip.component';
import { chipThemingColor } from '../entities/chip.model'; import { chipThemingColor } from '../entities/chip.model';
import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -21,7 +21,7 @@ import { MatIcon } from '@angular/material/icon';
'../styles/base-chip.component.scss', '../styles/base-chip.component.scss',
], ],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, MatIcon], imports: [MatIcon],
}) })
export class PiChipTimeComponent extends PiBaseChipComponent { export class PiChipTimeComponent extends PiBaseChipComponent {
@HostBinding('class') get dateClasses(): string { @HostBinding('class') get dateClasses(): string {

View File

@@ -1,11 +1,15 @@
<span> <span>
<!--left --> <!--left -->
<label class="pi-chip-label" *ngIf="label()">{{ label() }}</label> @if (label()) {
<label class="pi-chip-label">{{ label() }}</label>
}
<!--right --> <!--right -->
<aside> <aside>
<div class="pi-chip-affix"> <div class="pi-chip-affix">
<span class="pi-chip-affix__value">{{ value() ? value() : 'N/A' }}</span> <span class="pi-chip-affix__value">{{ value() ? value() : 'N/A' }}</span>
<span *ngIf="!!value()" class="pi-chip-affix__unit">{{ unit() }}</span> @if (!!value()) {
<span class="pi-chip-affix__unit">{{ unit() }}</span>
}
</div> </div>
</aside> </aside>
</span> </span>

View File

@@ -6,7 +6,6 @@ import {
} from '@angular/core'; } from '@angular/core';
import { PiBaseChipComponent } from '../base-chip.component'; import { PiBaseChipComponent } from '../base-chip.component';
import { unit } from '../../../util/models'; import { unit } from '../../../util/models';
import { NgIf } from '@angular/common';
@Component({ @Component({
selector: 'pi-chip-value', selector: 'pi-chip-value',
@@ -16,7 +15,7 @@ import { NgIf } from '@angular/common';
'../styles/base-chip.component.scss', '../styles/base-chip.component.scss',
], ],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf], imports: [],
}) })
export class PiChipValueComponent extends PiBaseChipComponent { export class PiChipValueComponent extends PiBaseChipComponent {
@HostBinding('class') get valueClasses(): string { @HostBinding('class') get valueClasses(): string {

View File

@@ -1,23 +1,27 @@
<span> <span>
<span class="pi-chip-label" *ngIf="label()">{{ label() }}</span> @if (label()) {
<span class="pi-chip-label">{{ label() }}</span>
}
<span class="pi-chip-affix" *ngIf="icon() || value()"> @if (icon() || value()) {
<ng-container *ngIf="icon()"> <span class="pi-chip-affix">
@if (icon()) {
@if (iconType() === 'custom') {
<img <img
*ngIf="iconType() === 'custom'; else defaultIcon"
src="/assets/icons/{{ icon() }}.svg" src="/assets/icons/{{ icon() }}.svg"
class="pi-chip-affix__icon" class="pi-chip-affix__icon"
/> />
} @else {
<ng-template #defaultIcon <mat-icon
><mat-icon
[svgIcon]="icon()!" [svgIcon]="icon()!"
[color]="appearance() !== 'fill' ? color() : ''" [color]="appearance() !== 'fill' ? color() : ''"
class="pi-chip-affix__icon" class="pi-chip-affix__icon"
></mat-icon ></mat-icon>
></ng-template> }
</ng-container> }
@if (value()) {
<span *ngIf="value()" class="pi-chip-affix__value">{{ value() }}</span> <span class="pi-chip-affix__value">{{ value() }}</span>
}
</span> </span>
}
</span> </span>

View File

@@ -7,7 +7,7 @@ import {
import { theming } from '../../../styles'; import { theming } from '../../../styles';
import { chipColor } from '../entities/chip.model'; import { chipColor } from '../entities/chip.model';
import { PiBaseChipComponent } from '../base-chip.component'; import { PiBaseChipComponent } from '../base-chip.component';
import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -15,7 +15,7 @@ import { MatIcon } from '@angular/material/icon';
templateUrl: './chip.component.html', templateUrl: './chip.component.html',
styleUrls: ['./chip.component.scss', '../styles/base-chip.component.scss'], styleUrls: ['./chip.component.scss', '../styles/base-chip.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, MatIcon], imports: [MatIcon],
}) })
export class PiChipComponent extends PiBaseChipComponent { export class PiChipComponent extends PiBaseChipComponent {
@HostBinding('class') get chipClasses(): string { @HostBinding('class') get chipClasses(): string {

View File

@@ -1,15 +1,14 @@
<header> <header>
<div> <div>
<mat-icon @if (icon()) {
*ngIf="icon(); else valueTemplate" <mat-icon [svgIcon]="icon()!" [color]="color()"></mat-icon>
[svgIcon]="icon()!" } @else {
[color]="color()"
></mat-icon>
<ng-template #valueTemplate>
<span>{{ value() }}</span> <span>{{ value() }}</span>
</ng-template> }
</div> </div>
<span *ngIf="icon() && value()">{{ value() }}</span> @if (icon() && value()) {
<span>{{ value() }}</span>
}
</header> </header>
<label>{{ label() }}</label> <label>{{ label() }}</label>

View File

@@ -5,7 +5,7 @@ import {
input, input,
} from '@angular/core'; } from '@angular/core';
import { ComponentFamilyClass, theming } from '../../../styles'; import { ComponentFamilyClass, theming } from '../../../styles';
import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -13,7 +13,7 @@ import { MatIcon } from '@angular/material/icon';
templateUrl: './tile.component.html', templateUrl: './tile.component.html',
styleUrls: ['./tile.component.scss'], styleUrls: ['./tile.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, MatIcon], imports: [MatIcon],
}) })
export class PiTileComponent { export class PiTileComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,24 +1,20 @@
<!-- <!--
KEYS: KEYS:
--> -->
<header @if (keysTemplateRef() && mode() === 'list') {
*ngIf="keysTemplateRef() && mode() === 'list'" <header pi-grid-item context="keys">
pi-grid-item
context="keys"
>
<ng-container *ngTemplateOutlet="keysTemplateRef() || defaultErrorTemplate"> <ng-container *ngTemplateOutlet="keysTemplateRef() || defaultErrorTemplate">
</ng-container> </ng-container>
</header> </header>
}
<!-- <!--
Data Direction: Data Direction:
COLUMN COLUMN
--> -->
<ng-container @if (dataDirection() === 'column') {
*ngIf="dataDirection() === 'column'; else dataDirectionRowTemplate"
>
<!-- DataGrid (each iteration)--> <!-- DataGrid (each iteration)-->
<ng-container *ngFor="let value of data(); index as i; trackBy: trackByFn"> @for (value of data(); track trackByFn(i); let i = $index) {
<div <div
pi-grid-item pi-grid-item
#gridItem #gridItem
@@ -33,7 +29,6 @@
" "
> >
</ng-container> </ng-container>
<!-- Values --> <!-- Values -->
<ng-container <ng-container
[ngTemplateOutlet]="valuesTemplateRef() || null" [ngTemplateOutlet]="valuesTemplateRef() || null"
@@ -41,19 +36,13 @@
> >
</ng-container> </ng-container>
</div> </div>
</ng-container> }
</ng-container> } @else {
<!--
Data Direction:
ROW
-->
<ng-template #dataDirectionRowTemplate>
<!-- DataGrid (each iteration)--> <!-- DataGrid (each iteration)-->
<section class="pi-data-grid__content"> <section class="pi-data-grid__content">
@for (value of data(); track value; let i = $index) {
<div <div
id="pi-grid-item-{{ i }}" id="pi-grid-item-{{ i }}"
*ngFor="let value of data(); index as i"
pi-grid-item pi-grid-item
#gridItem #gridItem
[class.pi-card]="mode() === 'grid'" [class.pi-card]="mode() === 'grid'"
@@ -65,7 +54,6 @@
*ngTemplateOutlet="(mode() === 'grid' && keysTemplateRef()) || null" *ngTemplateOutlet="(mode() === 'grid' && keysTemplateRef()) || null"
> >
</ng-container> </ng-container>
<!-- Values --> <!-- Values -->
<ng-container <ng-container
[ngTemplateOutlet]="valuesTemplateRef() || null" [ngTemplateOutlet]="valuesTemplateRef() || null"
@@ -74,7 +62,8 @@
</ng-container> </ng-container>
</section> </section>
<!-- Expandable Content --> <!-- Expandable Content -->
<aside *ngIf="isExpandable()"> @if (isExpandable()) {
<aside>
<!-- Keys --> <!-- Keys -->
<header <header
class="pi-grid-item pi-grid-item__expandable-content pi-grid-item__expandable-content--keys-template" class="pi-grid-item pi-grid-item__expandable-content pi-grid-item__expandable-content--keys-template"
@@ -86,7 +75,6 @@
> >
</ng-container> </ng-container>
</header> </header>
<div <div
class="pi-grid-item pi-grid-item__expandable-content pi-grid-item__expandable-content--values-template" class="pi-grid-item pi-grid-item__expandable-content pi-grid-item__expandable-content--values-template"
> >
@@ -97,9 +85,16 @@
</ng-container> </ng-container>
</div> </div>
</aside> </aside>
}
</div> </div>
}
</section> </section>
</ng-template> }
<!--
Data Direction:
ROW
-->
<ng-template #defaultErrorTemplate> <ng-template #defaultErrorTemplate>
<!-- Add data grid skeleton template --> <!-- Add data grid skeleton template -->

View File

@@ -17,14 +17,14 @@ import {
columnsNumber, columnsNumber,
rowsNumber, rowsNumber,
} from '../entities/data-grid.model'; } from '../entities/data-grid.model';
import { NgIf, NgTemplateOutlet, NgFor } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
import { PiGridItemDirective } from '../directives/grid-item.directive'; import { PiGridItemDirective } from '../directives/grid-item.directive';
@Component({ @Component({
selector: 'pi-data-grid', selector: 'pi-data-grid',
templateUrl: './data-grid.component.html', templateUrl: './data-grid.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, PiGridItemDirective, NgTemplateOutlet, NgFor], imports: [PiGridItemDirective, NgTemplateOutlet],
}) })
export class PiDataGridComponent<T> { export class PiDataGridComponent<T> {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,22 +1,20 @@
<ng-container [ngSwitch]="type()"> @switch (type()) {
<ng-container *ngSwitchCase="'amount'" [ngTemplateOutlet]="amount"> @case ('amount') {
</ng-container> <ng-container [ngTemplateOutlet]="amount"> </ng-container>
}
<ng-container *ngSwitchCase="'text'" [ngTemplateOutlet]="text"> @case ('text') {
</ng-container> <ng-container [ngTemplateOutlet]="text"> </ng-container>
}
<ng-container *ngSwitchCase="'date'" [ngTemplateOutlet]="date"></ng-container> @case ('date') {
<ng-container [ngTemplateOutlet]="date"></ng-container>
<ng-container }
*ngSwitchCase="'input'" @case ('input') {
[ngTemplateOutlet]="input" <ng-container [ngTemplateOutlet]="input"></ng-container>
></ng-container> }
@case ('action') {
<ng-container <ng-container [ngTemplateOutlet]="action"></ng-container>
*ngSwitchCase="'action'" }
[ngTemplateOutlet]="action" }
></ng-container>
</ng-container>
<ng-template #amount> <ng-template #amount>
<span> <span>

View File

@@ -4,8 +4,7 @@ import {
HostBinding, HostBinding,
input, input,
} from '@angular/core'; } from '@angular/core';
import { NgSwitch, NgSwitchCase, NgTemplateOutlet } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
import { PiBaseDataTableComponent } from '../base-data-table/base-data-table.component';
export type PiDropdownSelectorTemplateType = export type PiDropdownSelectorTemplateType =
'text' | 'date' | 'amount' | 'input' | 'action'; 'text' | 'date' | 'amount' | 'input' | 'action';
@@ -14,7 +13,7 @@ export type PiDropdownSelectorTemplateType =
templateUrl: './cell-type.component.html', templateUrl: './cell-type.component.html',
styleUrls: ['./cell-type.component.scss'], styleUrls: ['./cell-type.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgSwitch, NgSwitchCase, NgTemplateOutlet, PiBaseDataTableComponent], imports: [NgTemplateOutlet],
}) })
export class PiCellTypeComponent { export class PiCellTypeComponent {
@HostBinding('class') className = 'pi-cell-type'; @HostBinding('class') className = 'pi-cell-type';

View File

@@ -1,8 +1,8 @@
<h4>{{ heading() }}</h4> <h4>{{ heading() }}</h4>
<article #componentItem> <article #componentItem>
<ng-container *ngFor="let value of values(); let i = index"> @for (value of values(); track value; let i = $index) {
<ng-content <ng-content
*ngTemplateOutlet="item(); context: { value: value, index: i }" *ngTemplateOutlet="item(); context: { value: value, index: i }"
></ng-content> ></ng-content>
</ng-container> }
</article> </article>

View File

@@ -20,13 +20,13 @@ import {
// RxJS // RxJS
import { take } from 'rxjs/operators'; import { take } from 'rxjs/operators';
import { NgFor, NgTemplateOutlet } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
@Component({ @Component({
selector: 'pi-data-table-item', selector: 'pi-data-table-item',
templateUrl: './data-table-item.component.html', templateUrl: './data-table-item.component.html',
styleUrls: ['./data-table-item.component.scss'], styleUrls: ['./data-table-item.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgFor, NgTemplateOutlet], imports: [NgTemplateOutlet],
}) })
export class PiDataTableItemComponent implements AfterViewInit { export class PiDataTableItemComponent implements AfterViewInit {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,15 +1,14 @@
<ng-container *ngIf="!label(); else labelDividerTemplate"> @if (!label()) {
@if (icon()) {
<pi-icon <pi-icon
*ngIf="icon()"
[icon]="icon()" [icon]="icon()"
[appearance]="iconType()" [appearance]="iconType()"
[isStroked]="isStroked()" [isStroked]="isStroked()"
></pi-icon> ></pi-icon>
}
<hr align="center" />
} @else {
<hr align="center" /> <hr align="center" />
</ng-container>
<ng-template #labelDividerTemplate
><hr align="center" />
<span>{{ label() }}</span> <span>{{ label() }}</span>
<hr align="center" /> <hr align="center" />
</ng-template> }

View File

@@ -7,7 +7,7 @@ import {
// Shared // Shared
import { alignment, gap, iconSize, textColor } from '../../../styles'; import { alignment, gap, iconSize, textColor } from '../../../styles';
import { NgIf } from '@angular/common';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
@Component({ @Component({
@@ -15,7 +15,7 @@ import { PiIconComponent } from '../../icon/icon/icon.component';
templateUrl: './divider.component.html', templateUrl: './divider.component.html',
styleUrls: ['./divider.component.scss'], styleUrls: ['./divider.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, PiIconComponent], imports: [PiIconComponent],
}) })
export class PiDividerComponent { export class PiDividerComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -9,8 +9,8 @@
<ng-content select="pi-suffix"></ng-content> <ng-content select="pi-suffix"></ng-content>
</ng-container> </ng-container>
@if (control) {
<input <input
*ngIf="control"
[formControl]="control" [formControl]="control"
[placeholder]="placeholder()!" [placeholder]="placeholder()!"
matInput matInput
@@ -19,10 +19,13 @@
currencyMask currencyMask
[options]="customCurrencyMaskConfig" [options]="customCurrencyMaskConfig"
/> />
}
<mat-error *ngIf="enableErrorMessage() && control.errors"> @if (enableErrorMessage() && control.errors) {
<ng-container *ngFor="let text of control.errors['message']"> <mat-error>
@for (text of control.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
}
</mat-form-field> </mat-form-field>

View File

@@ -15,7 +15,7 @@ import {
MatSuffix, MatSuffix,
MatError, MatError,
} from '@angular/material/form-field'; } from '@angular/material/form-field';
import { NgIf, NgFor } from '@angular/common';
import { MatInput } from '@angular/material/input'; import { MatInput } from '@angular/material/input';
import { PiAutofocusDirective } from '../directives/autofocus.directive'; import { PiAutofocusDirective } from '../directives/autofocus.directive';
@@ -36,13 +36,11 @@ import { TranslatePipe } from '@ngx-translate/core';
MatFormField, MatFormField,
MatLabel, MatLabel,
MatSuffix, MatSuffix,
NgIf,
MatInput, MatInput,
NgxCurrencyDirective, NgxCurrencyDirective,
ReactiveFormsModule, ReactiveFormsModule,
PiAutofocusDirective, PiAutofocusDirective,
MatError, MatError,
NgFor,
forwardRef(() => PiCurrencyFieldComponent), forwardRef(() => PiCurrencyFieldComponent),
TranslatePipe, TranslatePipe,
], ],

View File

@@ -15,9 +15,11 @@
[isAutofocusSelected]="isAutofocus()" [isAutofocusSelected]="isAutofocus()"
/> />
<mat-error *ngIf="control.errors"> @if (control.errors) {
<ng-container *ngFor="let text of control.errors['message']"> <mat-error>
@for (text of control.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
}
</mat-form-field> </mat-form-field>

View File

@@ -10,8 +10,7 @@ import {
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { MatInput } from '@angular/material/input'; import { MatInput } from '@angular/material/input';
import { PiAutofocusDirective } from '../directives/autofocus.directive'; import { PiAutofocusDirective } from '../directives/autofocus.directive';
import { NgIf, NgFor } from '@angular/common';
import { PiCurrencyFieldComponent } from '../currency-field/currency-field.component';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -33,10 +32,7 @@ import { TranslatePipe } from '@ngx-translate/core';
MatInput, MatInput,
ReactiveFormsModule, ReactiveFormsModule,
PiAutofocusDirective, PiAutofocusDirective,
NgIf,
MatError, MatError,
NgFor,
PiCurrencyFieldComponent,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -17,8 +17,10 @@
/> />
</mat-form-field> </mat-form-field>
</section> </section>
<mat-error *ngIf="control.errors && enableErrorMessage()"> @if (control.errors && enableErrorMessage()) {
<ng-container *ngFor="let text of control.errors['message']"> <mat-error>
@for (text of control.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
}

View File

@@ -11,7 +11,7 @@ import { PiIconComponent } from '../../icon/icon/icon.component';
import { MatFormField, MatLabel, MatError } from '@angular/material/form-field'; import { MatFormField, MatLabel, MatError } from '@angular/material/form-field';
import { MatInput } from '@angular/material/input'; import { MatInput } from '@angular/material/input';
import { PiAutofocusDirective } from '../directives/autofocus.directive'; import { PiAutofocusDirective } from '../directives/autofocus.directive';
import { NgIf, NgFor } from '@angular/common';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -33,9 +33,7 @@ import { TranslatePipe } from '@ngx-translate/core';
MatInput, MatInput,
ReactiveFormsModule, ReactiveFormsModule,
PiAutofocusDirective, PiAutofocusDirective,
NgIf,
MatError, MatError,
NgFor,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -2,8 +2,8 @@
<mat-label><ng-content select="pi-label"></ng-content></mat-label> <mat-label><ng-content select="pi-label"></ng-content></mat-label>
<pi-prefix [unit]="this.unit() === '$' ? this.unit() : undefined" matPrefix> <pi-prefix [unit]="this.unit() === '$' ? this.unit() : undefined" matPrefix>
@if (showIncrementButtons()) {
<pi-icon <pi-icon
*ngIf="showIncrementButtons()"
(click)="decrementValue()" (click)="decrementValue()"
[class.is-disabled]="isDecrementButtonDisabled()" [class.is-disabled]="isDecrementButtonDisabled()"
icon="substract" icon="substract"
@@ -11,11 +11,12 @@
size="small" size="small"
color="primary" color="primary"
></pi-icon> ></pi-icon>
}
</pi-prefix> </pi-prefix>
<pi-suffix [unit]="this.unit() !== '$' ? this.unit() : undefined" matSuffix> <pi-suffix [unit]="this.unit() !== '$' ? this.unit() : undefined" matSuffix>
@if (showIncrementButtons()) {
<pi-icon <pi-icon
*ngIf="showIncrementButtons()"
(click)="incrementValue()" (click)="incrementValue()"
[class.is-disabled]="isIncrementButtonDisabled()" [class.is-disabled]="isIncrementButtonDisabled()"
icon="add" icon="add"
@@ -23,6 +24,7 @@
size="small" size="small"
color="primary" color="primary"
></pi-icon> ></pi-icon>
}
</pi-suffix> </pi-suffix>
<input <input
@@ -34,9 +36,11 @@
[isAutofocusSelected]="isAutofocus()" [isAutofocusSelected]="isAutofocus()"
/> />
<mat-error *ngIf="control.errors"> @if (control.errors) {
<ng-container *ngFor="let text of control.errors['message']"> <mat-error>
@for (text of control.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
}
</mat-form-field> </mat-form-field>

View File

@@ -19,11 +19,11 @@ import {
PiPrefixDirective, PiPrefixDirective,
PiSuffixDirective, PiSuffixDirective,
} from '../../../util/affix/affix.directive'; } from '../../../util/affix/affix.directive';
import { NgIf, NgFor } from '@angular/common';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { MatInput } from '@angular/material/input'; import { MatInput } from '@angular/material/input';
import { PiAutofocusDirective } from '../directives/autofocus.directive'; import { PiAutofocusDirective } from '../directives/autofocus.directive';
import { PiCurrencyFieldComponent } from '../currency-field/currency-field.component';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -42,7 +42,6 @@ import { TranslatePipe } from '@ngx-translate/core';
MatLabel, MatLabel,
PiPrefixDirective, PiPrefixDirective,
MatPrefix, MatPrefix,
NgIf,
PiIconComponent, PiIconComponent,
PiSuffixDirective, PiSuffixDirective,
MatSuffix, MatSuffix,
@@ -50,8 +49,6 @@ import { TranslatePipe } from '@ngx-translate/core';
ReactiveFormsModule, ReactiveFormsModule,
PiAutofocusDirective, PiAutofocusDirective,
MatError, MatError,
NgFor,
PiCurrencyFieldComponent,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -30,9 +30,11 @@
> >
</pi-incremental-number-field> </pi-incremental-number-field>
</div> </div>
<mat-error *ngIf="form.errors && showError()"> @if (form.errors && showError()) {
<ng-container *ngFor="let text of form.errors['message']"> <mat-error>
@for (text of form.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
}
</form> </form>

View File

@@ -13,9 +13,9 @@ import { unit } from '../../../util/models';
import { PiLabelDirective } from '../directives/label.directive'; import { PiLabelDirective } from '../directives/label.directive';
import { PiIncrementalNumberFieldComponent } from '../incremental-number-field/incremental-number-field.component'; import { PiIncrementalNumberFieldComponent } from '../incremental-number-field/incremental-number-field.component';
import { PiDividerComponent } from '../../divider/divider/divider.component'; import { PiDividerComponent } from '../../divider/divider/divider.component';
import { NgIf, NgFor } from '@angular/common';
import { MatError } from '@angular/material/form-field'; import { MatError } from '@angular/material/form-field';
import { PiCurrencyFieldComponent } from '../currency-field/currency-field.component';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -27,10 +27,7 @@ import { TranslatePipe } from '@ngx-translate/core';
PiLabelDirective, PiLabelDirective,
PiIncrementalNumberFieldComponent, PiIncrementalNumberFieldComponent,
PiDividerComponent, PiDividerComponent,
NgIf,
MatError, MatError,
NgFor,
PiCurrencyFieldComponent,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -18,9 +18,11 @@
[isAutofocusSelected]="isAutofocus()" [isAutofocusSelected]="isAutofocus()"
/> />
<mat-error *ngIf="control.errors"> @if (control.errors) {
<ng-container *ngFor="let text of control.errors['message']"> <mat-error>
@for (text of control.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
}
</mat-form-field> </mat-form-field>

View File

@@ -15,8 +15,7 @@ import {
} from '@angular/material/form-field'; } from '@angular/material/form-field';
import { MatInput } from '@angular/material/input'; import { MatInput } from '@angular/material/input';
import { PiAutofocusDirective } from '../directives/autofocus.directive'; import { PiAutofocusDirective } from '../directives/autofocus.directive';
import { NgIf, NgFor } from '@angular/common';
import { PiCurrencyFieldComponent } from '../currency-field/currency-field.component';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -38,10 +37,7 @@ import { TranslatePipe } from '@ngx-translate/core';
MatInput, MatInput,
ReactiveFormsModule, ReactiveFormsModule,
PiAutofocusDirective, PiAutofocusDirective,
NgIf,
MatError, MatError,
NgFor,
PiCurrencyFieldComponent,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -22,9 +22,11 @@
[isAutofocusSelected]="isAutofocus()" [isAutofocusSelected]="isAutofocus()"
/> />
<mat-error *ngIf="control.errors"> @if (control.errors) {
<ng-container *ngFor="let text of control.errors['message']"> <mat-error>
@for (text of control.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
}
</mat-form-field> </mat-form-field>

View File

@@ -11,8 +11,7 @@ import { PiSuffixDirective } from '../../../util/affix/affix.directive';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { MatInput } from '@angular/material/input'; import { MatInput } from '@angular/material/input';
import { PiAutofocusDirective } from '../directives/autofocus.directive'; import { PiAutofocusDirective } from '../directives/autofocus.directive';
import { NgIf, NgFor } from '@angular/common';
import { PiCurrencyFieldComponent } from '../currency-field/currency-field.component';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -35,10 +34,7 @@ import { TranslatePipe } from '@ngx-translate/core';
MatInput, MatInput,
ReactiveFormsModule, ReactiveFormsModule,
PiAutofocusDirective, PiAutofocusDirective,
NgIf,
MatError, MatError,
NgFor,
PiCurrencyFieldComponent,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -14,9 +14,11 @@
[isAutofocusSelected]="isAutofocus()" [isAutofocusSelected]="isAutofocus()"
/> />
<mat-error *ngIf="control.errors"> @if (control.errors) {
<ng-container *ngFor="let text of control.errors['message']"> <mat-error>
@for (text of control.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
}
</mat-form-field> </mat-form-field>

View File

@@ -10,8 +10,7 @@ import {
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { MatInput } from '@angular/material/input'; import { MatInput } from '@angular/material/input';
import { PiAutofocusDirective } from '../directives/autofocus.directive'; import { PiAutofocusDirective } from '../directives/autofocus.directive';
import { NgIf, NgFor } from '@angular/common';
import { PiCurrencyFieldComponent } from '../currency-field/currency-field.component';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -33,10 +32,7 @@ import { TranslatePipe } from '@ngx-translate/core';
MatInput, MatInput,
ReactiveFormsModule, ReactiveFormsModule,
PiAutofocusDirective, PiAutofocusDirective,
NgIf,
MatError, MatError,
NgFor,
PiCurrencyFieldComponent,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -14,11 +14,12 @@
type="search" type="search"
/> />
</fieldset> </fieldset>
@if (isClosable()) {
<pi-icon <pi-icon
*ngIf="isClosable()"
(click)="closeField()" (click)="closeField()"
icon="close" icon="close"
size="small" size="small"
color="primary" color="primary"
animation="clickable" animation="clickable"
></pi-icon> ></pi-icon>
}

View File

@@ -14,7 +14,6 @@ import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
import { OnInit } from '@angular/core'; import { OnInit } from '@angular/core';
import { PiBaseFormFieldComponent } from '../base-form-field.component'; import { PiBaseFormFieldComponent } from '../base-form-field.component';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { NgIf } from '@angular/common';
@Component({ @Component({
selector: 'pi-search-field', selector: 'pi-search-field',
@@ -28,7 +27,7 @@ import { NgIf } from '@angular/common';
multi: true, multi: true,
}, },
], ],
imports: [PiIconComponent, ReactiveFormsModule, NgIf], imports: [PiIconComponent, ReactiveFormsModule],
}) })
export class PiSearchFieldComponent export class PiSearchFieldComponent
extends PiBaseFormFieldComponent extends PiBaseFormFieldComponent

View File

@@ -13,9 +13,11 @@
[isAutofocusSelected]="isAutofocus()" [isAutofocusSelected]="isAutofocus()"
/> />
<mat-error *ngIf="control.errors"> @if (control.errors) {
<ng-container *ngFor="let text of control.errors['message']"> <mat-error>
@for (text of control.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
}
</mat-form-field> </mat-form-field>

View File

@@ -9,8 +9,7 @@ import {
} from '@angular/material/form-field'; } from '@angular/material/form-field';
import { MatInput } from '@angular/material/input'; import { MatInput } from '@angular/material/input';
import { PiAutofocusDirective } from '../directives/autofocus.directive'; import { PiAutofocusDirective } from '../directives/autofocus.directive';
import { NgIf, NgFor } from '@angular/common';
import { PiCurrencyFieldComponent } from '../currency-field/currency-field.component';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -31,10 +30,7 @@ import { TranslatePipe } from '@ngx-translate/core';
MatInput, MatInput,
ReactiveFormsModule, ReactiveFormsModule,
PiAutofocusDirective, PiAutofocusDirective,
NgIf,
MatError, MatError,
NgFor,
PiCurrencyFieldComponent,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -15,11 +15,13 @@
[isAutofocusSelected]="isAutofocus()" [isAutofocusSelected]="isAutofocus()"
></textarea> ></textarea>
</mat-form-field> </mat-form-field>
<mat-error *ngIf="control.errors && enableErrorMessage()"> @if (control.errors && enableErrorMessage()) {
<ng-container *ngFor="let text of control.errors['message']"> <mat-error>
@for (text of control.errors['message']; track text) {
{{ text | translate }} {{ text | translate }}
</ng-container> }
</mat-error> </mat-error>
<span *ngIf="maxLength() !== 1e6" }
>{{ control.value?.length || 0 }} / {{ maxLength() }}</span @if (maxLength() !== 1e6) {
> <span>{{ control.value?.length || 0 }} / {{ maxLength() }}</span>
}

View File

@@ -10,8 +10,7 @@ import { MatFormField, MatLabel, MatError } from '@angular/material/form-field';
import { MatInput } from '@angular/material/input'; import { MatInput } from '@angular/material/input';
import { CdkTextareaAutosize } from '@angular/cdk/text-field'; import { CdkTextareaAutosize } from '@angular/cdk/text-field';
import { PiAutofocusDirective } from '../directives/autofocus.directive'; import { PiAutofocusDirective } from '../directives/autofocus.directive';
import { NgIf, NgFor } from '@angular/common';
import { PiCurrencyFieldComponent } from '../currency-field/currency-field.component';
import { TranslatePipe } from '@ngx-translate/core'; import { TranslatePipe } from '@ngx-translate/core';
@Component({ @Component({
@@ -32,10 +31,7 @@ import { TranslatePipe } from '@ngx-translate/core';
CdkTextareaAutosize, CdkTextareaAutosize,
ReactiveFormsModule, ReactiveFormsModule,
PiAutofocusDirective, PiAutofocusDirective,
NgIf,
MatError, MatError,
NgFor,
PiCurrencyFieldComponent,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -1,8 +1,5 @@
<img @if (type() === 'custom') {
*ngIf="type() === 'custom'; else defaultIcon" <img src="/assets/icons/{{ icon() }}.svg" />
src="/assets/icons/{{ icon() }}.svg" } @else {
/> <mat-icon size="size" [svgIcon]="icon()!" color="color"></mat-icon>
}
<ng-template #defaultIcon
><mat-icon size="size" [svgIcon]="icon()!" color="color"></mat-icon
></ng-template>

View File

@@ -13,7 +13,7 @@ import {
iconSize, iconSize,
styleType, styleType,
} from '../../../styles'; } from '../../../styles';
import { NgIf } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -21,7 +21,7 @@ import { MatIcon } from '@angular/material/icon';
templateUrl: './icon.component.html', templateUrl: './icon.component.html',
styleUrls: ['./icon.component.scss'], styleUrls: ['./icon.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, MatIcon], imports: [MatIcon],
}) })
export class PiIconComponent { export class PiIconComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,21 +1,26 @@
<figure> <figure>
<a *ngIf="link(); else image" [href]="link()" target="_blank" @if (link()) {
<a [href]="link()" target="_blank"
><img ><img
src="https://d2m4265u67f2xu.cloudfront.net/assets/images/{{ pathImg() }}" src="https://d2m4265u67f2xu.cloudfront.net/assets/images/{{
pathImg()
}}"
[alt]="pathImg()! | sanitizerAltImage" [alt]="pathImg()! | sanitizerAltImage"
width="100%" width="100%"
height="auto" height="auto"
/></a> /></a>
<ng-template #image> } @else {
<img <img
src="https://d2m4265u67f2xu.cloudfront.net/assets/images/{{ pathImg() }}" src="https://d2m4265u67f2xu.cloudfront.net/assets/images/{{ pathImg() }}"
[alt]="pathImg()! | sanitizerAltImage" [alt]="pathImg()! | sanitizerAltImage"
width="100%" width="100%"
height="auto" height="auto"
/> />
</ng-template> }
</figure> </figure>
<aside *ngIf="hasContent()"> @if (hasContent()) {
<aside>
<ng-content select="pi-headline-label-content"></ng-content> <ng-content select="pi-headline-label-content"></ng-content>
<ng-content select="pi-headline-description-content"></ng-content> <ng-content select="pi-headline-description-content"></ng-content>
</aside> </aside>
}

View File

@@ -14,7 +14,7 @@ import {
flexDirection, flexDirection,
gap, gap,
} from '../../../styles'; } from '../../../styles';
import { NgIf } from '@angular/common';
import { SanitizerAltImagePipe } from '../../../util/pipes/pipes'; import { SanitizerAltImagePipe } from '../../../util/pipes/pipes';
@Directive({ @Directive({
@@ -34,7 +34,7 @@ export class PiHeadlineDescriptionContentDirective {}
templateUrl: './headline.component.html', templateUrl: './headline.component.html',
styleUrls: ['./headline.component.scss'], styleUrls: ['./headline.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, SanitizerAltImagePipe], imports: [SanitizerAltImagePipe],
}) })
export class PiHeadlineComponent { export class PiHeadlineComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,17 +1,22 @@
<header> <header>
<span> <span>
<h3 bold l *ngIf="title"> @if (title) {
<h3 bold l>
{{ title }} {{ title }}
<span pi-primary *ngIf="subtitle">{{ subtitle }}</span> @if (subtitle) {
<span pi-primary>{{ subtitle }}</span>
}
</h3> </h3>
}
</span> </span>
@if (!dialogRef.disableClose) {
<pi-close-button <pi-close-button
size="small" size="small"
[hasLabel]="false" [hasLabel]="false"
*ngIf="!dialogRef.disableClose"
(click)="closeModal()" (click)="closeModal()"
></pi-close-button> ></pi-close-button>
}
</header> </header>
<ng-container <ng-container
@@ -23,40 +28,39 @@
<main class="pi-modal__main-content pi-modal__main-content--dialog-template"> <main class="pi-modal__main-content pi-modal__main-content--dialog-template">
<!-- Top --> <!-- Top -->
<pi-headline [pathImg]="dialogModalData.pathImg"> <pi-headline [pathImg]="dialogModalData.pathImg">
<pi-headline-label-content *ngIf="dialogModalData.label"> @if (dialogModalData.label) {
<pi-headline-label-content>
<span l bold>{{ dialogModalData.label }}</span> <span l bold>{{ dialogModalData.label }}</span>
</pi-headline-label-content> </pi-headline-label-content>
<pi-headline-description-content *ngIf="dialogModalData.description">{{ }
@if (dialogModalData.description) {
<pi-headline-description-content>{{
dialogModalData.description dialogModalData.description
}}</pi-headline-description-content> }}</pi-headline-description-content>
}
</pi-headline> </pi-headline>
<section *ngIf="dialogModalData.template"> @if (dialogModalData.template) {
<section>
<ng-container [ngTemplateOutlet]="dialogModalData.template"> <ng-container [ngTemplateOutlet]="dialogModalData.template">
</ng-container> </ng-container>
</section> </section>
}
</main> </main>
<!-- Bottom --> <!-- Bottom -->
<pi-action-wrapper @if (dialogModalData.buttonText) {
*ngIf="dialogModalData.buttonText" <pi-action-wrapper flexDirection="row" gap="s">
flexDirection="row" @if (dialogModalData.buttonText.secondaryAction) {
gap="s" <button (click)="secondaryAction()" [class]="buttonColorClass" pi-ghost>
>
<button
*ngIf="dialogModalData.buttonText.secondaryAction"
(click)="secondaryAction()"
[class]="buttonColorClass"
pi-ghost
>
{{ dialogModalData.buttonText.secondaryAction }} {{ dialogModalData.buttonText.secondaryAction }}
</button> </button>
<button }
*ngIf="dialogModalData.buttonText.primaryAction" @if (dialogModalData.buttonText.primaryAction) {
(click)="primaryAction()" <button (click)="primaryAction()" [class]="buttonColorClass">
[class]="buttonColorClass"
>
{{ dialogModalData.buttonText.primaryAction }} {{ dialogModalData.buttonText.primaryAction }}
</button> </button>
}
</pi-action-wrapper> </pi-action-wrapper>
}
</ng-template> </ng-template>
<ng-template #customTemplate> <ng-template #customTemplate>

View File

@@ -11,7 +11,7 @@ import {
ModalStyleType, ModalStyleType,
ModalType, ModalType,
} from '../entities/modal.model'; } from '../entities/modal.model';
import { NgIf, NgTemplateOutlet } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
import { PiTextWeightBoldDirective } from '../../text/directives/text-weights.directive'; import { PiTextWeightBoldDirective } from '../../text/directives/text-weights.directive';
import { PiTextLargeDirective } from '../../text/directives/text-sizes.directive'; import { PiTextLargeDirective } from '../../text/directives/text-sizes.directive';
import { PiColorPrimaryDirective } from '../../../util/color/directives/colors.directive'; import { PiColorPrimaryDirective } from '../../../util/color/directives/colors.directive';
@@ -30,7 +30,6 @@ import { PiGhostButtonDirective } from '../../button/button.directive';
styleUrls: ['./modal.component.scss'], styleUrls: ['./modal.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ imports: [
NgIf,
PiTextWeightBoldDirective, PiTextWeightBoldDirective,
PiTextLargeDirective, PiTextLargeDirective,
PiColorPrimaryDirective, PiColorPrimaryDirective,

View File

@@ -1,7 +1,11 @@
<div> <div>
<mat-icon [svgIcon]="noteStatus?.icon!"></mat-icon> <mat-icon [svgIcon]="noteStatus?.icon!"></mat-icon>
<h5 s *ngIf="title()">{{ title() }}</h5> @if (title()) {
<small xs *ngIf="text()">{{ text() }}</small> <h5 s>{{ title() }}</h5>
}
@if (text()) {
<small xs>{{ text() }}</small>
}
<span><ng-content select="pi-note-label-content"></ng-content></span> <span><ng-content select="pi-note-label-content"></ng-content></span>
</div> </div>
<ng-content select="pi-note-action-content"></ng-content> <ng-content select="pi-note-action-content"></ng-content>

View File

@@ -12,7 +12,7 @@ import { NoteStatus } from '../entities/note.model';
import { status } from '../../../util/status'; import { status } from '../../../util/status';
import { gap, alignment } from '../../../styles'; import { gap, alignment } from '../../../styles';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
import { NgIf } from '@angular/common';
import { import {
PiTextSmallDirective, PiTextSmallDirective,
PiTextXSmallDirective, PiTextXSmallDirective,
@@ -35,7 +35,7 @@ export class PiNoteActionContentDirective {}
templateUrl: './note.component.html', templateUrl: './note.component.html',
styleUrls: ['./note.component.scss'], styleUrls: ['./note.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [MatIcon, NgIf, PiTextSmallDirective, PiTextXSmallDirective], imports: [MatIcon, PiTextSmallDirective, PiTextXSmallDirective],
}) })
export class PiNoteComponent implements OnInit { export class PiNoteComponent implements OnInit {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,17 +1,15 @@
<section> <section>
<pi-icon @if (icon()) {
*ngIf="icon(); else button" <pi-icon [icon]="icon()" [color]="iconColor" size="large"></pi-icon>
[icon]="icon()" } @else {
[color]="iconColor"
size="large"
></pi-icon>
<div>
<h5 medium m>{{ message() }}</h5>
<span *ngIf="description()" xs>{{ description() }}</span>
</div>
</section>
<ng-template #button>
<button (click)="dismiss()" pi-ghost> <button (click)="dismiss()" pi-ghost>
{{ text() }} {{ text() }}
</button> </button>
</ng-template> }
<div>
<h5 medium m>{{ message() }}</h5>
@if (description()) {
<span xs>{{ description() }}</span>
}
</div>
</section>

View File

@@ -12,7 +12,7 @@ import {
MAT_SNACK_BAR_DATA, MAT_SNACK_BAR_DATA,
} from '@angular/material/snack-bar'; } from '@angular/material/snack-bar';
import { styleType } from '../../../styles'; import { styleType } from '../../../styles';
import { NgIf } from '@angular/common';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { import {
PiMediumButtonDirective, PiMediumButtonDirective,
@@ -30,7 +30,6 @@ import {
styleUrls: ['./snack-bar.component.scss'], styleUrls: ['./snack-bar.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ imports: [
NgIf,
PiIconComponent, PiIconComponent,
PiMediumButtonDirective, PiMediumButtonDirective,
PiTextWeightMediumDirective, PiTextWeightMediumDirective,

View File

@@ -21,9 +21,43 @@
> >
<footer> <footer>
<ng-container @if (totalPages() < 5) {
*ngIf="totalPages() < 5; then defaultPaginator; else advancedPaginator" @for (page of pages; track page; let i = $index) {
></ng-container> <span
[class.is-active]="page === currentPage()"
(click)="paginateTo(page)"
>
{{ page }}</span
>
}
} @else {
@for (page of firstPages; track page; let i = $index) {
<div>
<span
[class.is-active]="page === currentPage()"
(click)="paginateTo(page)"
>
{{ page }}
</span>
</div>
}
<!-- when total pages > 6 || the difference is > 6 -->
@if (
totalPages() > 6 && totalPages() - firstPages[firstPages.length - 1] > 6
) {
<pi-icon (click)="movePages()" icon="more"></pi-icon>
}
@for (page of lastPages; track page; let i = $index) {
<div>
<span
[class.is-active]="page === currentPage()"
(click)="paginateTo(page)"
>
{{ page }}
</span>
</div>
}
}
</footer> </footer>
<pi-icon-button <pi-icon-button
@@ -37,34 +71,3 @@
> >
Next Next
</pi-icon-button> </pi-icon-button>
<ng-template #defaultPaginator>
<span
*ngFor="let page of pages; let i = index"
[class.is-active]="page === currentPage()"
(click)="paginateTo(page)"
>
{{ page }}</span
>
</ng-template>
<ng-template #advancedPaginator>
<div *ngFor="let page of firstPages; let i = index">
<span [class.is-active]="page === currentPage()" (click)="paginateTo(page)">
{{ page }}
</span>
</div>
<!-- when total pages > 6 || the difference is > 6 -->
<pi-icon
*ngIf="
totalPages() > 6 && totalPages() - firstPages[firstPages.length - 1] > 6
"
(click)="movePages()"
icon="more"
></pi-icon>
<div *ngFor="let page of lastPages; let i = index">
<span [class.is-active]="page === currentPage()" (click)="paginateTo(page)">
{{ page }}
</span>
</div>
</ng-template>

View File

@@ -9,7 +9,7 @@ import {
output, output,
} from '@angular/core'; } from '@angular/core';
import { PiIconButtonComponent } from '../../button/icon-button/icon-button.component'; import { PiIconButtonComponent } from '../../button/icon-button/icon-button.component';
import { NgIf, NgFor } from '@angular/common';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
@Component({ @Component({
@@ -19,8 +19,6 @@ import { PiIconComponent } from '../../icon/icon/icon.component';
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ imports: [
PiIconButtonComponent, PiIconButtonComponent,
NgIf,
NgFor,
PiIconComponent, PiIconComponent,
forwardRef(() => PiPaginatorComponent), forwardRef(() => PiPaginatorComponent),
], ],

View File

@@ -1,14 +1,15 @@
<ng-container *ngIf="type() === 'form'; else customPanelTemplate"> @if (type() === 'form') {
<form [formGroup]="formGroup()"> <form [formGroup]="formGroup()">
<!-- Top --> <!-- Top -->
<header> <header>
<div> <div>
<h2 m medium>{{ title() }}</h2> <h2 m medium>{{ title() }}</h2>
<h4 pi-grey light xs *ngIf="subtitle()">{{ subtitle() }}</h4> @if (subtitle()) {
<h4 pi-grey light xs>{{ subtitle() }}</h4>
}
</div> </div>
<aside> <aside>
<ng-content select="pi-panel-top-content"></ng-content> <ng-content select="pi-panel-top-content"></ng-content>
<pi-divider <pi-divider
direction="vertical" direction="vertical"
color="grey" color="grey"
@@ -27,19 +28,14 @@
></pi-icon-button> ></pi-icon-button>
</aside> </aside>
</header> </header>
<!-- Center | Summary --> <!-- Center | Summary -->
<ng-content select="pi-panel-center-content"></ng-content> <ng-content select="pi-panel-center-content"></ng-content>
<!-- Bottom & Expansion --> <!-- Bottom & Expansion -->
<section [class]="isCollapsed() ? 'is-collapsed' : 'is-expanded'"> <section [class]="isCollapsed() ? 'is-collapsed' : 'is-expanded'">
<ng-content select="pi-panel-expandable-content"></ng-content> <ng-content select="pi-panel-expandable-content"></ng-content>
</section> </section>
</form> </form>
</ng-container> } @else {
<!-- Custom Panel -->
<ng-template #customPanelTemplate>
<!-- Top --> <!-- Top -->
<header class="pi-panel-content pi-panel-content__top"> <header class="pi-panel-content pi-panel-content__top">
<ng-container *ngTemplateOutlet="topContentRef()"></ng-container> <ng-container *ngTemplateOutlet="topContentRef()"></ng-container>
@@ -57,10 +53,8 @@
></pi-icon> ></pi-icon>
</aside> </aside>
</header> </header>
<!-- Center --> <!-- Center -->
<ng-container *ngTemplateOutlet="centerContentRef()"></ng-container> <ng-container *ngTemplateOutlet="centerContentRef()"></ng-container>
<!-- Bottom & Expansion --> <!-- Bottom & Expansion -->
<section <section
[class]="isCollapsed() ? 'is-collapsed' : 'is-expanded'" [class]="isCollapsed() ? 'is-collapsed' : 'is-expanded'"
@@ -68,4 +62,6 @@
> >
<ng-container *ngTemplateOutlet="expandableContentRef()"> </ng-container> <ng-container *ngTemplateOutlet="expandableContentRef()"> </ng-container>
</section> </section>
</ng-template> }
<!-- Custom Panel -->

View File

@@ -14,7 +14,7 @@ import {
import { FormGroup, ReactiveFormsModule } from '@angular/forms'; import { FormGroup, ReactiveFormsModule } from '@angular/forms';
import { ComponentFamilyClass } from '../../../styles'; import { ComponentFamilyClass } from '../../../styles';
import { PiBasePanelComponent } from '../base-panel.component'; import { PiBasePanelComponent } from '../base-panel.component';
import { NgIf, NgTemplateOutlet } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
import { import {
PiTextMediumDirective, PiTextMediumDirective,
PiTextXSmallDirective, PiTextXSmallDirective,
@@ -36,7 +36,6 @@ import { TranslatePipe } from '@ngx-translate/core';
styleUrls: ['./expansion-panel.component.scss'], styleUrls: ['./expansion-panel.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ imports: [
NgIf,
ReactiveFormsModule, ReactiveFormsModule,
PiTextMediumDirective, PiTextMediumDirective,
PiTextWeightMediumDirective, PiTextWeightMediumDirective,

View File

@@ -1,12 +1,16 @@
<section> <section>
<!-- Top --> <!-- Top -->
<header *ngIf="title()"> @if (title()) {
<header>
<div> <div>
<h2 m medium>{{ title() }}</h2> <h2 m medium>{{ title() }}</h2>
<h4 pi-grey light xs *ngIf="subtitle()">{{ subtitle() }}</h4> @if (subtitle()) {
<h4 pi-grey light xs>{{ subtitle() }}</h4>
}
</div> </div>
<ng-content select="pi-panel-top-content"></ng-content> <ng-content select="pi-panel-top-content"></ng-content>
</header> </header>
}
<ng-content></ng-content> <ng-content></ng-content>
<ng-content select="pi-panel-top-content"></ng-content> <ng-content select="pi-panel-top-content"></ng-content>
<!-- Center --> <!-- Center -->

View File

@@ -6,7 +6,7 @@ import {
} from '@angular/core'; } from '@angular/core';
import { ComponentFamilyClass } from '../../../styles'; import { ComponentFamilyClass } from '../../../styles';
import { PiBasePanelComponent } from '../base-panel.component'; import { PiBasePanelComponent } from '../base-panel.component';
import { NgIf } from '@angular/common';
import { import {
PiTextMediumDirective, PiTextMediumDirective,
PiTextXSmallDirective, PiTextXSmallDirective,
@@ -24,7 +24,6 @@ import { PiColorGreyDirective } from '../../../util/color/directives/colors.dire
styleUrls: ['./panel.component.scss'], styleUrls: ['./panel.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ imports: [
NgIf,
PiTextMediumDirective, PiTextMediumDirective,
PiTextWeightMediumDirective, PiTextWeightMediumDirective,
PiMediumButtonDirective, PiMediumButtonDirective,

View File

@@ -8,8 +8,8 @@
</mat-progress-spinner> </mat-progress-spinner>
<!-- Value --> <!-- Value -->
@if (appearance() === 'compact') {
<span <span
*ngIf="appearance() === 'compact'; else defaultValue"
[style.width]="diameter() + 'px'" [style.width]="diameter() + 'px'"
[style.height]="diameter() + 'px'" [style.height]="diameter() + 'px'"
[style.margin-top]="-diameter() + 'px'" [style.margin-top]="-diameter() + 'px'"
@@ -18,12 +18,12 @@
<span>{{ value() }}</span <span>{{ value() }}</span
><span>%</span> ><span>%</span>
</span> </span>
} @else {
<!-- Value -->
<ng-template #defaultValue>
<span> <span>
<span>{{ value() }}</span <span>{{ value() }}</span
><span>%</span> ><span>%</span>
</span> </span>
<span>{{ label() }}</span> <span>{{ label() }}</span>
</ng-template> }
<!-- Value -->

View File

@@ -5,14 +5,13 @@ import {
input, input,
} from '@angular/core'; } from '@angular/core';
import { MatProgressSpinner } from '@angular/material/progress-spinner'; import { MatProgressSpinner } from '@angular/material/progress-spinner';
import { NgIf } from '@angular/common';
import { PiProgressBarComponent } from '../progress-bar/progress-bar.component';
@Component({ @Component({
selector: 'pi-progress-spinner', selector: 'pi-progress-spinner',
templateUrl: './progress-spinner.component.html', templateUrl: './progress-spinner.component.html',
styleUrls: ['./progress-spinner.component.scss'], styleUrls: ['./progress-spinner.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [MatProgressSpinner, NgIf, PiProgressBarComponent], imports: [MatProgressSpinner],
}) })
export class PiProgressSpinnerComponent { export class PiProgressSpinnerComponent {
@HostBinding('class') @HostBinding('class')

View File

@@ -12,10 +12,8 @@
[justify]="justifyCarousel()" [justify]="justifyCarousel()"
(itemChanged)="onItemChanged($event)" (itemChanged)="onItemChanged($event)"
> >
<ng-template @for (option of options(); track trackByFn(i); let i = $index) {
pi-carousel-item <ng-template pi-carousel-item>
*ngFor="let option of options(); index as i; trackBy: trackByFn"
>
<span class="pi-select__carousel--option"> <span class="pi-select__carousel--option">
<!-- Default options template menu for static data --> <!-- Default options template menu for static data -->
<ng-template #defaultOption> <ng-template #defaultOption>
@@ -38,4 +36,5 @@
</ng-container> </ng-container>
</span> </span>
</ng-template> </ng-template>
}
</pi-carousel> </pi-carousel>

View File

@@ -19,7 +19,7 @@ import { PiSelectOptionComponent } from '../select-option/select-option.componen
import { Device } from '../../../util/device-configs'; import { Device } from '../../../util/device-configs';
import { justify } from '../../../styles'; import { justify } from '../../../styles';
import { PiCarouselComponent } from '../../carousel/carousel/carousel.component'; import { PiCarouselComponent } from '../../carousel/carousel/carousel.component';
import { NgFor, NgTemplateOutlet } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
import { PiCarouselItemDirective } from '../../carousel/carousel.directive'; import { PiCarouselItemDirective } from '../../carousel/carousel.directive';
@Component({ @Component({
@@ -36,7 +36,6 @@ import { PiCarouselItemDirective } from '../../carousel/carousel.directive';
], ],
imports: [ imports: [
PiCarouselComponent, PiCarouselComponent,
NgFor,
PiCarouselItemDirective, PiCarouselItemDirective,
PiSelectOptionComponent, PiSelectOptionComponent,
NgTemplateOutlet, NgTemplateOutlet,

View File

@@ -1,13 +1,11 @@
<input hidden [formControl]="control" /> <input hidden [formControl]="control" />
<ng-container *ngIf="type() === 'dropdown'"> @if (type() === 'dropdown') {
<ng-container @if (pickedOptionType() === 'button') {
*ngIf="pickedOptionType() === 'button'; else pickedOptionInputTemplate"
>
<fieldset (click)="onToggleDropdown()" class="pi-select-picked-option"> <fieldset (click)="onToggleDropdown()" class="pi-select-picked-option">
<!-- Button --> <!-- Button -->
<div> <div>
@if (icon()) {
<pi-icon <pi-icon
*ngIf="icon()"
[icon]="icon()" [icon]="icon()"
class="pi-select-picked-option__custom-icon" class="pi-select-picked-option__custom-icon"
color="primary" color="primary"
@@ -16,6 +14,7 @@
pi-disabled pi-disabled
[isDisabled]="disabled" [isDisabled]="disabled"
></pi-icon> ></pi-icon>
}
<span class="pi-select-picked-option__label">{{ <span class="pi-select-picked-option__label">{{
(selectedOptionsNames?.join(', ') | truncate: 33) || (selectedOptionsNames?.join(', ') | truncate: 33) ||
(label() | translate) (label() | translate)
@@ -27,11 +26,10 @@
size="small" size="small"
></pi-icon> ></pi-icon>
</fieldset> </fieldset>
</ng-container> } @else {
<ng-template #pickedOptionInputTemplate> @switch (appearance()) {
<ng-container [ngSwitch]="appearance()">
<!-- Input Fill Appearance --> <!-- Input Fill Appearance -->
<ng-container *ngSwitchCase="'fill'"> @case ('fill') {
<fieldset (click)="onToggleDropdown()" class="pi-select-picked-option"> <fieldset (click)="onToggleDropdown()" class="pi-select-picked-option">
<pi-icon <pi-icon
[icon]="icon()" [icon]="icon()"
@@ -48,14 +46,16 @@
<label class="pi-select-picked-option__label">{{ <label class="pi-select-picked-option__label">{{
label() | translate label() | translate
}}</label> }}</label>
<ng-template #defaultSelected> <ng-template #defaultSelectedFill>
<span class="pi-select-picked-option__placeholder">{{ <span class="pi-select-picked-option__placeholder">{{
(selectedOptionsNames?.join(', ') | truncate: 33) || (selectedOptionsNames?.join(', ') | truncate: 33) ||
(placeholder() | translate) (placeholder() | translate)
}}</span> }}</span>
</ng-template> </ng-template>
<ng-container <ng-container
[ngTemplateOutlet]="selectedTemplateRef() || defaultSelected" [ngTemplateOutlet]="
selectedTemplateRef() || defaultSelectedFill
"
[ngTemplateOutletContext]="{ $implicit: controlValue }" [ngTemplateOutletContext]="{ $implicit: controlValue }"
> >
</ng-container> </ng-container>
@@ -68,10 +68,10 @@
></pi-icon> ></pi-icon>
</div> </div>
</fieldset> </fieldset>
</ng-container> }
<!-- Input Outline Appearance --> <!-- Input Outline Appearance -->
<ng-container *ngSwitchCase="'outline'"> @case ('outline') {
<fieldset (click)="onToggleDropdown()" class="pi-select-picked-option"> <fieldset (click)="onToggleDropdown()" class="pi-select-picked-option">
<!-- Input field --> <!-- Input field -->
<label class="pi-select-picked-option__label">{{ <label class="pi-select-picked-option__label">{{
@@ -79,14 +79,16 @@
}}</label> }}</label>
<div> <div>
<span> <span>
<ng-template #defaultSelected> <ng-template #defaultSelectedOutline>
<span class="pi-select-picked-option__placeholder">{{ <span class="pi-select-picked-option__placeholder">{{
(selectedOptionsNames?.join(', ') | truncate: 33) || (selectedOptionsNames?.join(', ') | truncate: 33) ||
(placeholder() | translate) (placeholder() | translate)
}}</span> }}</span>
</ng-template> </ng-template>
<ng-container <ng-container
[ngTemplateOutlet]="selectedTemplateRef() || defaultSelected" [ngTemplateOutlet]="
selectedTemplateRef() || defaultSelectedOutline
"
[ngTemplateOutletContext]="{ $implicit: controlValue }" [ngTemplateOutletContext]="{ $implicit: controlValue }"
> >
</ng-container> </ng-container>
@@ -99,18 +101,16 @@
></pi-icon> ></pi-icon>
</div> </div>
</fieldset> </fieldset>
</ng-container> }
</ng-container> }
</ng-template> }
</ng-container> }
<!-- Options menu --> <!-- Options menu -->
<nav class="pi-select-options-menu"> <nav class="pi-select-options-menu">
<!-- Select All Options --> <!-- Select All Options -->
<fieldset @if (hasSelectAllOptions()) {
*ngIf="hasSelectAllOptions()" <fieldset class="pi-select-options-menu__select-all">
class="pi-select-options-menu__select-all"
>
<mat-checkbox <mat-checkbox
pi-dynamic-color pi-dynamic-color
[color]="color()" [color]="color()"
@@ -122,15 +122,14 @@
{{ selectAllLabel() }} {{ selectAllLabel() }}
</label> </label>
</fieldset> </fieldset>
}
<header @if (pickedOptionType() === 'button') {
*ngIf="pickedOptionType() === 'button'" <header class="pi-select-options-menu__picked-option">
class="pi-select-options-menu__picked-option"
>
<!-- Only visible in a header of Button --> <!-- Only visible in a header of Button -->
@if (icon()) {
<pi-icon <pi-icon
*ngIf="icon()"
[icon]="icon()" [icon]="icon()"
class="pi-select-options-menu-picked-option__custom-icon" class="pi-select-options-menu-picked-option__custom-icon"
[color]="color()" [color]="color()"
@@ -138,6 +137,7 @@
pi-disabled pi-disabled
[isDisabled]="disabled" [isDisabled]="disabled"
></pi-icon> ></pi-icon>
}
<span class="pi-select-options-menu-picked-option__placeholder">{{ <span class="pi-select-options-menu-picked-option__placeholder">{{
(selectedOptionsNames?.join(', ') | truncate: 33) || (selectedOptionsNames?.join(', ') | truncate: 33) ||
@@ -154,12 +154,11 @@
size="small" size="small"
></pi-icon> ></pi-icon>
</header> </header>
}
<!-- List of options --> <!-- List of options -->
<div class="pi-select-options-menu__options"> <div class="pi-select-options-menu__options">
<span @for (option of options(); track option; let i = $index) {
*ngFor="let option of options(); index as i" <span (click)="onSelectOption(option)">
(click)="onSelectOption(option)"
>
<!-- Default options template menu for static data --> <!-- Default options template menu for static data -->
<ng-template #defaultOption> <ng-template #defaultOption>
<pi-select-option <pi-select-option
@@ -179,12 +178,17 @@
> >
</ng-container> </ng-container>
</span> </span>
}
</div> </div>
<footer *ngIf="type() === 'dropdown'"> @if (type() === 'dropdown') {
<footer>
<span> <span>
<button (click)="onClickReset()" pi-ghost pi-primary w100>Borrar</button> <button (click)="onClickReset()" pi-ghost pi-primary w100>
Borrar
</button>
<button (click)="onClickSave()" pi-primary w100>Guardar</button> <button (click)="onClickSave()" pi-primary w100>Guardar</button>
</span> </span>
</footer> </footer>
}
</nav> </nav>

View File

@@ -19,13 +19,7 @@ import { PiBaseSelectComponent } from '../base-select.component';
import { PiSelectOptionComponent } from '../select-option/select-option.component'; import { PiSelectOptionComponent } from '../select-option/select-option.component';
import _ from 'lodash'; import _ from 'lodash';
import { MatCheckboxChange, MatCheckbox } from '@angular/material/checkbox'; import { MatCheckboxChange, MatCheckbox } from '@angular/material/checkbox';
import { import { NgTemplateOutlet } from '@angular/common';
NgIf,
NgSwitch,
NgSwitchCase,
NgTemplateOutlet,
NgFor,
} from '@angular/common';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { PiDisabledDirective } from '../../../util/status/directives/status.directive'; import { PiDisabledDirective } from '../../../util/status/directives/status.directive';
import { PiDisabledDirective as PiDisabledDirective_1 } from '../../text/directives/text-styles.directive'; import { PiDisabledDirective as PiDisabledDirective_1 } from '../../text/directives/text-styles.directive';
@@ -53,16 +47,12 @@ import { TruncatePipe } from '../../../util/pipes/pipes';
], ],
imports: [ imports: [
ReactiveFormsModule, ReactiveFormsModule,
NgIf,
PiIconComponent, PiIconComponent,
PiDisabledDirective, PiDisabledDirective,
PiDisabledDirective_1, PiDisabledDirective_1,
NgSwitch,
NgSwitchCase,
NgTemplateOutlet, NgTemplateOutlet,
MatCheckbox, MatCheckbox,
PiDynamicColorDirective, PiDynamicColorDirective,
NgFor,
PiSelectOptionComponent, PiSelectOptionComponent,
PiGhostButtonDirective, PiGhostButtonDirective,
PiColorPrimaryDirective, PiColorPrimaryDirective,

View File

@@ -1,9 +1,9 @@
<ng-container [ngSwitch]="type()"> @switch (type()) {
<!-- Column single --> <!-- Column single -->
<ng-container *ngSwitchCase="'single'"> @case ('single') {
<div> <div>
@if (hasRadio()) {
<pi-radio-button <pi-radio-button
*ngIf="hasRadio()"
class="pi-select-option__radio-button" class="pi-select-option__radio-button"
size="x-small" size="x-small"
icon="bullet" icon="bullet"
@@ -11,23 +11,28 @@
[color]="color()" [color]="color()"
[isDisabled]="isDisabled()!" [isDisabled]="isDisabled()!"
></pi-radio-button> ></pi-radio-button>
}
<span> <span>
<span class="pi-select-option__label">{{ label() | translate }}</span> <span class="pi-select-option__label">{{ label() | translate }}</span>
<span class="pi-select-option__description" *ngIf="description()">{{ @if (description()) {
<span class="pi-select-option__description">{{
description() | translate description() | translate
}}</span> }}</span>
}
</span> </span>
</div> </div>
<!-- initials and icon cannot coexist --> <!-- initials and icon cannot coexist -->
<span *ngIf="initials()" class="pi-select-option__initials">{{ @if (initials()) {
<span class="pi-select-option__initials">{{
initials() | translate initials() | translate
}}</span> }}</span>
<mat-icon *ngIf="icon()" [svgIcon]="icon()!" [color]="color()"></mat-icon> }
</ng-container> @if (icon()) {
<mat-icon [svgIcon]="icon()!" [color]="color()"></mat-icon>
}
}
<!-- Column multiple --> <!-- Column multiple -->
<ng-container *ngSwitchCase="'multiple'"> @case ('multiple') {
<div> <div>
<mat-checkbox <mat-checkbox
class="pi-select-option__checkbox" class="pi-select-option__checkbox"
@@ -36,36 +41,42 @@
></mat-checkbox> ></mat-checkbox>
<span class="pi-select-option__label">{{ label() | translate }}</span> <span class="pi-select-option__label">{{ label() | translate }}</span>
</div> </div>
<span *ngIf="initials()" class="pi-select-option__initials">{{ @if (initials()) {
<span class="pi-select-option__initials">{{
initials() | translate initials() | translate
}}</span> }}</span>
}
@if (icon()) {
<mat-icon <mat-icon
class="pi-select-option__icon" class="pi-select-option__icon"
*ngIf="icon()"
[svgIcon]="icon()!" [svgIcon]="icon()!"
[color]="color()" [color]="color()"
></mat-icon> ></mat-icon>
</ng-container> }
}
<!-- Flex wrap (No Picked Option) --> <!-- Flex wrap (No Picked Option) -->
<ng-container *ngSwitchCase="'flex-wrap'"> @case ('flex-wrap') {
@if (icon()) {
<mat-icon <mat-icon
*ngIf="icon()"
class="pi-select-option__icon" class="pi-select-option__icon"
[svgIcon]="icon()!" [svgIcon]="icon()!"
[color]="color()" [color]="color()"
></mat-icon> ></mat-icon>
}
<span class="pi-select-option__label">{{ label() | translate }}</span> <span class="pi-select-option__label">{{ label() | translate }}</span>
<span class="pi-select-option__initials" *ngIf="initials()">{{ @if (initials()) {
<span class="pi-select-option__initials">{{
initials() | translate initials() | translate
}}</span> }}</span>
}
@if (hasRadio()) {
<pi-radio-button <pi-radio-button
*ngIf="hasRadio()"
class="pi-select-option__radio-button" class="pi-select-option__radio-button"
icon="check" icon="check"
[isActive]="isSelected()" [isActive]="isSelected()"
[color]="isSelected() ? color() : 'white'" [color]="isSelected() ? color() : 'white'"
[isDisabled]="isDisabled()!" [isDisabled]="isDisabled()!"
></pi-radio-button> ></pi-radio-button>
</ng-container> }
</ng-container> }
}

View File

@@ -10,7 +10,7 @@ import {
SelectOptionFlexDirection, SelectOptionFlexDirection,
actionIcon, actionIcon,
} from '../entities/select.model'; } from '../entities/select.model';
import { NgSwitch, NgSwitchCase, NgIf } from '@angular/common';
import { PiRadioButtonComponent } from '../../button/radio-button/radio-button.component'; import { PiRadioButtonComponent } from '../../button/radio-button/radio-button.component';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
import { MatCheckbox } from '@angular/material/checkbox'; import { MatCheckbox } from '@angular/material/checkbox';
@@ -21,15 +21,7 @@ import { TranslatePipe } from '@ngx-translate/core';
templateUrl: './select-option.component.html', templateUrl: './select-option.component.html',
styleUrls: ['./select-option.component.scss'], styleUrls: ['./select-option.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ imports: [PiRadioButtonComponent, MatIcon, MatCheckbox, TranslatePipe],
NgSwitch,
NgSwitchCase,
NgIf,
PiRadioButtonComponent,
MatIcon,
MatCheckbox,
TranslatePipe,
],
}) })
export class PiSelectOptionComponent { export class PiSelectOptionComponent {
@HostBinding('class') get classes(): string { @HostBinding('class') get classes(): string {

View File

@@ -1,10 +1,8 @@
<!-- Picked option --> <!-- Picked option -->
<input hidden [formControl]="control" /> <input hidden [formControl]="control" />
<!-- Picked option Appearance field template --> <!-- Picked option Appearance field template -->
<ng-container *ngIf="type() === 'dropdown'"> @if (type() === 'dropdown') {
<ng-container @if (pickedOptionType() === 'button') {
*ngIf="pickedOptionType() === 'button'; else pickedOptionInputTemplate"
>
<fieldset class="pi-select-picked-option"> <fieldset class="pi-select-picked-option">
<!-- Input field --> <!-- Input field -->
<div> <div>
@@ -18,11 +16,10 @@
size="small" size="small"
></pi-icon> ></pi-icon>
</fieldset> </fieldset>
</ng-container> } @else {
<ng-template #pickedOptionInputTemplate> @switch (appearance()) {
<ng-container [ngSwitch]="appearance()">
<!-- Fill --> <!-- Fill -->
<ng-container *ngSwitchCase="'fill'"> @case ('fill') {
<fieldset class="pi-select-picked-option"> <fieldset class="pi-select-picked-option">
<pi-icon <pi-icon
[icon]="icon()" [icon]="icon()"
@@ -38,13 +35,15 @@
<label class="pi-select-picked-option__label">{{ <label class="pi-select-picked-option__label">{{
label() | translate label() | translate
}}</label> }}</label>
<ng-template #defaultSelected> <ng-template #defaultSelectedFill>
<span class="pi-select-picked-option__placeholder">{{ <span class="pi-select-picked-option__placeholder">{{
selectedOption?.name || placeholder() | translate selectedOption?.name || placeholder() | translate
}}</span> }}</span>
</ng-template> </ng-template>
<ng-container <ng-container
[ngTemplateOutlet]="selectedTemplateRef() || defaultSelected" [ngTemplateOutlet]="
selectedTemplateRef() || defaultSelectedFill
"
[ngTemplateOutletContext]="{ $implicit: selectedOption }" [ngTemplateOutletContext]="{ $implicit: selectedOption }"
> >
</ng-container> </ng-container>
@@ -57,10 +56,10 @@
></pi-icon> ></pi-icon>
</div> </div>
</fieldset> </fieldset>
</ng-container> }
<!-- Outline --> <!-- Outline -->
<ng-container *ngSwitchCase="'outline'"> @case ('outline') {
<fieldset class="pi-select-picked-option"> <fieldset class="pi-select-picked-option">
<!-- Input field --> <!-- Input field -->
<label class="pi-select-picked-option__label">{{ <label class="pi-select-picked-option__label">{{
@@ -68,13 +67,15 @@
}}</label> }}</label>
<div> <div>
<span> <span>
<ng-template #defaultSelected> <ng-template #defaultSelectedOutline>
<span class="pi-select-picked-option__placeholder">{{ <span class="pi-select-picked-option__placeholder">{{
selectedOption?.name || placeholder() | translate selectedOption?.name || placeholder() | translate
}}</span> }}</span>
</ng-template> </ng-template>
<ng-container <ng-container
[ngTemplateOutlet]="selectedTemplateRef() || defaultSelected" [ngTemplateOutlet]="
selectedTemplateRef() || defaultSelectedOutline
"
[ngTemplateOutletContext]="{ $implicit: selectedOption }" [ngTemplateOutletContext]="{ $implicit: selectedOption }"
> >
</ng-container> </ng-container>
@@ -87,20 +88,18 @@
></pi-icon> ></pi-icon>
</div> </div>
</fieldset> </fieldset>
</ng-container> }
</ng-container> }
</ng-template> }
</ng-container> }
<!-- Options menu --> <!-- Options menu -->
<nav class="pi-select-options-menu"> <nav class="pi-select-options-menu">
<header @if (pickedOptionType() === 'button') {
*ngIf="pickedOptionType() === 'button'" <header class="pi-select-options-menu__picked-option">
class="pi-select-options-menu__picked-option"
>
<!-- Only visible in a header of Button --> <!-- Only visible in a header of Button -->
@if (icon()) {
<pi-icon <pi-icon
*ngIf="icon()"
[icon]="icon()" [icon]="icon()"
class="pi-select-options-menu-picked-option__custom-icon" class="pi-select-options-menu-picked-option__custom-icon"
color="primary" color="primary"
@@ -108,6 +107,7 @@
pi-disabled pi-disabled
[isDisabled]="disabled" [isDisabled]="disabled"
></pi-icon> ></pi-icon>
}
<span class="pi-select-picked-option__label">{{ <span class="pi-select-picked-option__label">{{
selectedOption?.name || label() | translate selectedOption?.name || label() | translate
@@ -122,15 +122,14 @@
size="small" size="small"
></pi-icon> ></pi-icon>
</header> </header>
}
<!-- Add a tab component with --> <!-- Add a tab component with -->
<!-- TODO: replace for months menu --> <!-- TODO: replace for months menu -->
<div class="pi-select-options-menu__options"> <div class="pi-select-options-menu__options">
<span @for (option of options(); track option; let i = $index) {
*ngFor="let option of options(); index as i" <span (click)="onSelectOption(option)">
(click)="onSelectOption(option)"
>
<!-- Default options template menu for static data --> <!-- Default options template menu for static data -->
<ng-template #defaultOption> <ng-template #defaultMonthOption>
<pi-select-option <pi-select-option
[id]="option?.[keyIdProperty()] || option?.id" [id]="option?.[keyIdProperty()] || option?.id"
[label]="option?.name | translate" [label]="option?.name | translate"
@@ -144,21 +143,20 @@
</ng-template> </ng-template>
<!-- Default options template menu for server data --> <!-- Default options template menu for server data -->
<ng-container <ng-container
[ngTemplateOutlet]="optionTemplateRef() || defaultOption" [ngTemplateOutlet]="optionTemplateRef() || defaultMonthOption"
[ngTemplateOutletContext]="{ $implicit: option, index: i }" [ngTemplateOutletContext]="{ $implicit: option, index: i }"
> >
</ng-container> </ng-container>
</span> </span>
}
</div> </div>
<!-- TODO: replace for years menu --> <!-- TODO: replace for years menu -->
<div class="pi-select-options-menu__options"> <div class="pi-select-options-menu__options">
<span @for (option of options(); track option; let i = $index) {
*ngFor="let option of options(); index as i" <span (click)="onSelectOption(option)">
(click)="onSelectOption(option)"
>
<!-- Default options template menu for static data --> <!-- Default options template menu for static data -->
<ng-template #defaultOption> <ng-template #defaultYearOption>
<pi-select-option <pi-select-option
[id]="option?.[keyIdProperty()] || option?.id" [id]="option?.[keyIdProperty()] || option?.id"
[label]="option?.name | translate" [label]="option?.name | translate"
@@ -173,10 +171,11 @@
</ng-template> </ng-template>
<!-- Default options template menu for server data --> <!-- Default options template menu for server data -->
<ng-container <ng-container
[ngTemplateOutlet]="optionTemplateRef() || defaultOption" [ngTemplateOutlet]="optionTemplateRef() || defaultYearOption"
[ngTemplateOutletContext]="{ $implicit: option, index: i }" [ngTemplateOutletContext]="{ $implicit: option, index: i }"
> >
</ng-container> </ng-container>
</span> </span>
}
</div> </div>
</nav> </nav>

View File

@@ -17,17 +17,10 @@ import { merge } from 'rxjs';
import { PiBaseSelectComponent } from '../base-select.component'; import { PiBaseSelectComponent } from '../base-select.component';
import { PiSelectOptionComponent } from '../select-option/select-option.component'; import { PiSelectOptionComponent } from '../select-option/select-option.component';
import _ from 'lodash'; import _ from 'lodash';
import { import { NgTemplateOutlet } from '@angular/common';
NgIf,
NgSwitch,
NgSwitchCase,
NgTemplateOutlet,
NgFor,
} from '@angular/common';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { PiDisabledDirective } from '../../../util/status/directives/status.directive'; import { PiDisabledDirective } from '../../../util/status/directives/status.directive';
import { PiDisabledDirective as PiDisabledDirective_1 } from '../../text/directives/text-styles.directive'; import { PiDisabledDirective as PiDisabledDirective_1 } from '../../text/directives/text-styles.directive';
import { PiSelectComponent } from '../select/select.component';
@Component({ @Component({
selector: 'pi-select-period', selector: 'pi-select-period',
@@ -43,16 +36,11 @@ import { PiSelectComponent } from '../select/select.component';
], ],
imports: [ imports: [
ReactiveFormsModule, ReactiveFormsModule,
NgIf,
PiIconComponent, PiIconComponent,
NgSwitch,
NgSwitchCase,
NgTemplateOutlet, NgTemplateOutlet,
PiDisabledDirective, PiDisabledDirective,
PiDisabledDirective_1, PiDisabledDirective_1,
NgFor,
PiSelectOptionComponent, PiSelectOptionComponent,
PiSelectComponent,
TranslatePipe, TranslatePipe,
], ],
}) })

View File

@@ -1,10 +1,8 @@
<!-- Picked option --> <!-- Picked option -->
<input hidden [formControl]="control" /> <input hidden [formControl]="control" />
<!-- Picked option Appearance field template --> <!-- Picked option Appearance field template -->
<ng-container *ngIf="type() === 'dropdown'"> @if (type() === 'dropdown') {
<ng-container @if (pickedOptionType() === 'button') {
*ngIf="pickedOptionType() === 'button'; else pickedOptionInputTemplate"
>
<fieldset class="pi-select-picked-option"> <fieldset class="pi-select-picked-option">
<!-- Input field --> <!-- Input field -->
<div> <div>
@@ -18,11 +16,10 @@
size="small" size="small"
></pi-icon> ></pi-icon>
</fieldset> </fieldset>
</ng-container> } @else {
<ng-template #pickedOptionInputTemplate> @switch (appearance()) {
<ng-container [ngSwitch]="appearance()">
<!-- Fill --> <!-- Fill -->
<ng-container *ngSwitchCase="'fill'"> @case ('fill') {
<fieldset class="pi-select-picked-option"> <fieldset class="pi-select-picked-option">
<pi-icon <pi-icon
[icon]="icon()" [icon]="icon()"
@@ -38,13 +35,15 @@
<label class="pi-select-picked-option__label">{{ <label class="pi-select-picked-option__label">{{
label() | translate label() | translate
}}</label> }}</label>
<ng-template #defaultSelected> <ng-template #defaultSelectedFill>
<span class="pi-select-picked-option__placeholder">{{ <span class="pi-select-picked-option__placeholder">{{
selectedOption?.name || placeholder() | translate selectedOption?.name || placeholder() | translate
}}</span> }}</span>
</ng-template> </ng-template>
<ng-container <ng-container
[ngTemplateOutlet]="selectedTemplateRef() || defaultSelected" [ngTemplateOutlet]="
selectedTemplateRef() || defaultSelectedFill
"
[ngTemplateOutletContext]="{ $implicit: selectedOption }" [ngTemplateOutletContext]="{ $implicit: selectedOption }"
> >
</ng-container> </ng-container>
@@ -57,10 +56,10 @@
></pi-icon> ></pi-icon>
</div> </div>
</fieldset> </fieldset>
</ng-container> }
<!-- Outline --> <!-- Outline -->
<ng-container *ngSwitchCase="'outline'"> @case ('outline') {
<fieldset class="pi-select-picked-option"> <fieldset class="pi-select-picked-option">
<!-- Input field --> <!-- Input field -->
<label class="pi-select-picked-option__label">{{ <label class="pi-select-picked-option__label">{{
@@ -68,13 +67,15 @@
}}</label> }}</label>
<div> <div>
<span> <span>
<ng-template #defaultSelected> <ng-template #defaultSelectedOutline>
<span class="pi-select-picked-option__placeholder">{{ <span class="pi-select-picked-option__placeholder">{{
selectedOption?.name || placeholder() | translate selectedOption?.name || placeholder() | translate
}}</span> }}</span>
</ng-template> </ng-template>
<ng-container <ng-container
[ngTemplateOutlet]="selectedTemplateRef() || defaultSelected" [ngTemplateOutlet]="
selectedTemplateRef() || defaultSelectedOutline
"
[ngTemplateOutletContext]="{ $implicit: selectedOption }" [ngTemplateOutletContext]="{ $implicit: selectedOption }"
> >
</ng-container> </ng-container>
@@ -87,20 +88,18 @@
></pi-icon> ></pi-icon>
</div> </div>
</fieldset> </fieldset>
</ng-container> }
</ng-container> }
</ng-template> }
</ng-container> }
<!-- Options menu --> <!-- Options menu -->
<nav class="pi-select-options-menu"> <nav class="pi-select-options-menu">
<header @if (pickedOptionType() === 'button') {
*ngIf="pickedOptionType() === 'button'" <header class="pi-select-options-menu__picked-option">
class="pi-select-options-menu__picked-option"
>
<!-- Only visible in a header of Button --> <!-- Only visible in a header of Button -->
@if (icon()) {
<pi-icon <pi-icon
*ngIf="icon()"
[icon]="icon()" [icon]="icon()"
class="pi-select-options-menu-picked-option__custom-icon" class="pi-select-options-menu-picked-option__custom-icon"
color="primary" color="primary"
@@ -108,6 +107,7 @@
pi-disabled pi-disabled
[isDisabled]="disabled" [isDisabled]="disabled"
></pi-icon> ></pi-icon>
}
<span class="pi-select-options-menu-picked-option__placeholder">{{ <span class="pi-select-options-menu-picked-option__placeholder">{{
placeholder() | translate placeholder() | translate
@@ -122,11 +122,10 @@
size="small" size="small"
></pi-icon> ></pi-icon>
</header> </header>
}
<div class="pi-select-options-menu__options"> <div class="pi-select-options-menu__options">
<span @for (option of options(); track option; let i = $index) {
*ngFor="let option of options(); index as i" <span (click)="onSelectOption(option)">
(click)="onSelectOption(option)"
>
<!-- Default options template menu for static data --> <!-- Default options template menu for static data -->
<ng-template #defaultOption> <ng-template #defaultOption>
<pi-select-option <pi-select-option
@@ -149,5 +148,6 @@
> >
</ng-container> </ng-container>
</span> </span>
}
</div> </div>
</nav> </nav>

View File

@@ -19,13 +19,7 @@ import { merge } from 'rxjs';
import { PiBaseSelectComponent } from '../base-select.component'; import { PiBaseSelectComponent } from '../base-select.component';
import { PiSelectOptionComponent } from '../select-option/select-option.component'; import { PiSelectOptionComponent } from '../select-option/select-option.component';
import _ from 'lodash'; import _ from 'lodash';
import { import { NgTemplateOutlet } from '@angular/common';
NgIf,
NgSwitch,
NgSwitchCase,
NgTemplateOutlet,
NgFor,
} from '@angular/common';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { PiDisabledDirective } from '../../../util/status/directives/status.directive'; import { PiDisabledDirective } from '../../../util/status/directives/status.directive';
import { PiDisabledDirective as PiDisabledDirective_1 } from '../../text/directives/text-styles.directive'; import { PiDisabledDirective as PiDisabledDirective_1 } from '../../text/directives/text-styles.directive';
@@ -44,14 +38,10 @@ import { PiDisabledDirective as PiDisabledDirective_1 } from '../../text/directi
], ],
imports: [ imports: [
ReactiveFormsModule, ReactiveFormsModule,
NgIf,
PiIconComponent, PiIconComponent,
NgSwitch,
NgSwitchCase,
NgTemplateOutlet, NgTemplateOutlet,
PiDisabledDirective, PiDisabledDirective,
PiDisabledDirective_1, PiDisabledDirective_1,
NgFor,
PiSelectOptionComponent, PiSelectOptionComponent,
forwardRef(() => PiSelectComponent), forwardRef(() => PiSelectComponent),
TranslatePipe, TranslatePipe,

View File

@@ -1,7 +1,9 @@
<span *ngIf="label()"> @if (label()) {
<span>
<label>{{ label() }}</label> <label>{{ label() }}</label>
<span>{{ control?.value }} {{ unit() }}</span> <span>{{ control?.value }} {{ unit() }}</span>
</span> </span>
}
<mat-slider <mat-slider
[min]="minValue()" [min]="minValue()"
[max]="maxValue()" [max]="maxValue()"

View File

@@ -14,7 +14,7 @@ import {
// Component // Component
import { PiBaseSliderComponent } from '../base-slider.component'; import { PiBaseSliderComponent } from '../base-slider.component';
import { NgIf } from '@angular/common';
import { MatSlider, MatSliderThumb } from '@angular/material/slider'; import { MatSlider, MatSliderThumb } from '@angular/material/slider';
@Component({ @Component({
@@ -29,7 +29,7 @@ import { MatSlider, MatSliderThumb } from '@angular/material/slider';
multi: true, multi: true,
}, },
], ],
imports: [NgIf, MatSlider, MatSliderThumb, ReactiveFormsModule], imports: [MatSlider, MatSliderThumb, ReactiveFormsModule],
}) })
export class PiSliderComponent extends PiBaseSliderComponent implements OnInit { export class PiSliderComponent extends PiBaseSliderComponent implements OnInit {
readonly formControlName = input<string>(); readonly formControlName = input<string>();

View File

@@ -1,6 +1,6 @@
<header> <header>
@if (isTabWrapperOverflowing && !isSmallDevice()) {
<pi-icon <pi-icon
*ngIf="isTabWrapperOverflowing && !isSmallDevice()"
(click)="isTabWrapperScrolledToStart ? null : scrollTabWrapper('prev')" (click)="isTabWrapperScrolledToStart ? null : scrollTabWrapper('prev')"
icon="chevron-back" icon="chevron-back"
[isStroked]="true" [isStroked]="true"
@@ -12,32 +12,34 @@
pi-disabled pi-disabled
[isDisabled]="isTabWrapperScrolledToStart" [isDisabled]="isTabWrapperScrolledToStart"
></pi-icon> ></pi-icon>
}
<section #tabWrapper> <section #tabWrapper>
<ng-container *ngIf="tabButtons(); else customTabElements"> @if (tabButtons()) {
<ng-container *ngFor="let tab of tabButtons(); let i = index"> @for (tab of tabButtons(); track tab; let i = $index) {
<article <article
[class]="getTabElementClass(i, tab)" [class]="getTabElementClass(i, tab)"
(click)="tab.isDisabled ? null : onTabChange(i)" (click)="tab.isDisabled ? null : onTabChange(i)"
pi-disabled pi-disabled
[isDisabled]="tab.isDisabled" [isDisabled]="tab.isDisabled"
> >
<pi-icon *ngIf="tab.icon" [icon]="tab.icon" size="large"></pi-icon> @if (tab.icon) {
<pi-icon [icon]="tab.icon" size="large"></pi-icon>
}
<span> <span>
{{ tab.label | translate }} {{ tab.label | translate }}
</span> </span>
</article> </article>
</ng-container> }
</ng-container> } @else {
</section> @for (tab of tabElementItems(); track tab; let i = $index) {
<ng-template #customTabElements>
<ng-container *ngFor="let tab of tabElementItems(); let i = index">
<article [class]="getTabElementClass(i)" (click)="onTabChange(i)"> <article [class]="getTabElementClass(i)" (click)="onTabChange(i)">
<ng-container *ngTemplateOutlet="tab.templateRef"> </ng-container> <ng-container *ngTemplateOutlet="tab.templateRef"> </ng-container>
</article> </article>
</ng-container> }
</ng-template> }
</section>
@if (isTabWrapperOverflowing && !isSmallDevice()) {
<pi-icon <pi-icon
*ngIf="isTabWrapperOverflowing && !isSmallDevice()"
(click)="isTabWrapperScrolledToEnd ? null : scrollTabWrapper('next')" (click)="isTabWrapperScrolledToEnd ? null : scrollTabWrapper('next')"
icon="chevron-forward" icon="chevron-forward"
[isStroked]="true" [isStroked]="true"
@@ -49,11 +51,12 @@
pi-disabled pi-disabled
[isDisabled]="isTabWrapperScrolledToEnd" [isDisabled]="isTabWrapperScrolledToEnd"
></pi-icon> ></pi-icon>
}
</header> </header>
<main> <main>
<ng-container *ngFor="let tab of tabContentItems(); let i = index"> @for (tab of tabContentItems(); track tab; let i = $index) {
<section [class]="getTabContentClass(i)"> <section [class]="getTabContentClass(i)">
<ng-container *ngTemplateOutlet="tab.templateRef"> </ng-container> <ng-container *ngTemplateOutlet="tab.templateRef"> </ng-container>
</section> </section>
</ng-container> }
</main> </main>

View File

@@ -15,7 +15,7 @@ import {
} from '@angular/core'; } from '@angular/core';
import { TabButton } from '../entities/tab.model'; import { TabButton } from '../entities/tab.model';
import { PiTabContentDirective, PiTabElementDirective } from '../tab.directive'; import { PiTabContentDirective, PiTabElementDirective } from '../tab.directive';
import { NgIf, NgFor, NgTemplateOutlet } from '@angular/common'; import { NgTemplateOutlet } from '@angular/common';
import { PiIconComponent } from '../../icon/icon/icon.component'; import { PiIconComponent } from '../../icon/icon/icon.component';
import { PiDisabledDirective } from '../../../util/status/directives/status.directive'; import { PiDisabledDirective } from '../../../util/status/directives/status.directive';
import { PiDisabledDirective as PiDisabledDirective_1 } from '../../text/directives/text-styles.directive'; import { PiDisabledDirective as PiDisabledDirective_1 } from '../../text/directives/text-styles.directive';
@@ -27,11 +27,9 @@ import { TranslatePipe } from '@ngx-translate/core';
styleUrls: ['./tab.component.scss'], styleUrls: ['./tab.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ imports: [
NgIf,
PiIconComponent, PiIconComponent,
PiDisabledDirective, PiDisabledDirective,
PiDisabledDirective_1, PiDisabledDirective_1,
NgFor,
NgTemplateOutlet, NgTemplateOutlet,
TranslatePipe, TranslatePipe,
], ],

View File

@@ -1,18 +1,19 @@
<article> <article>
<span> <span>
{{ isLongText ? (text() | slice: 0 : characterLimit()) : text() {{ isLongText ? (text() | slice: 0 : characterLimit()) : text() }}
}}<span *ngIf="isLongText && isCollapsed">...</span> @if (isLongText && isCollapsed) {
<span>...</span>
}
</span> </span>
<section *ngIf="!isCollapsed"> @if (!isCollapsed) {
<section>
{{ text() | slice: characterLimit() : text()?.length }} {{ text() | slice: characterLimit() : text()?.length }}
</section> </section>
}
</article> </article>
<button @if (isLongText) {
pi-ghost <button pi-ghost [hasPadding]="false" (click)="alterToggle()">
[hasPadding]="false"
*ngIf="isLongText"
(click)="alterToggle()"
>
{{ isCollapsed ? 'Leer más' : 'Leer menos' }} {{ isCollapsed ? 'Leer más' : 'Leer menos' }}
</button> </button>
}

View File

@@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component, input } from '@angular/core'; import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { DURATION, transitionAnimation } from '../../../styles'; import { DURATION, transitionAnimation } from '../../../styles';
import { NgIf, SlicePipe } from '@angular/common'; import { SlicePipe } from '@angular/common';
import { PiGhostButtonDirective } from '../../button/button.directive'; import { PiGhostButtonDirective } from '../../button/button.directive';
@Component({ @Component({
@@ -9,7 +9,7 @@ import { PiGhostButtonDirective } from '../../button/button.directive';
styleUrls: ['./text-area-expansion.component.scss'], styleUrls: ['./text-area-expansion.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
animations: transitionAnimation(DURATION.Medium), animations: transitionAnimation(DURATION.Medium),
imports: [NgIf, PiGhostButtonDirective, SlicePipe], imports: [PiGhostButtonDirective, SlicePipe],
}) })
export class PiTextAreaExpansionComponent { export class PiTextAreaExpansionComponent {
readonly text = input(''); readonly text = input('');

View File

@@ -1,10 +1,14 @@
<mat-icon *ngIf="icon()" [svgIcon]="icon()!" alt="icon" size="size"></mat-icon> @if (icon()) {
<mat-icon [svgIcon]="icon()!" alt="icon" size="size"></mat-icon>
}
<article> <article>
<label *ngIf="label()">{{ label() }}</label> @if (label()) {
<ng-container [ngSwitch]="getTemplate()"> <label>{{ label() }}</label>
}
@switch (getTemplate()) {
<!-- Route template --> <!-- Route template -->
@case ('route') {
<a <a
*ngSwitchCase="'route'"
[routerLink]="route()" [routerLink]="route()"
[routerLinkActive]="['isActive']" [routerLinkActive]="['isActive']"
[routerLinkActiveOptions]="{ exact: true }" [routerLinkActiveOptions]="{ exact: true }"
@@ -13,13 +17,18 @@
> >
{{ value() }} {{ value() }}
</a> </a>
}
<!-- Link template --> <!-- Link template -->
<a *ngSwitchCase="'link'" [href]="link()" [target]="target()"> @case ('link') {
<a [href]="link()" [target]="target()">
<span>{{ value() }}</span> <span>{{ value() }}</span>
</a> </a>
}
<!-- OnClick template --> <!-- OnClick template -->
<a *ngSwitchCase="'onClick'"> @case ('onClick') {
<a>
<span>{{ value() }}</span> <span>{{ value() }}</span>
</a> </a>
</ng-container> }
}
</article> </article>

View File

@@ -13,7 +13,7 @@ import {
justify, justify,
} from '../../../styles'; } from '../../../styles';
import { PiBaseTextViewerComponent } from '../base-text-viewer.component'; import { PiBaseTextViewerComponent } from '../base-text-viewer.component';
import { NgIf, NgSwitch, NgSwitchCase } from '@angular/common';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
@Component({ @Component({
@@ -24,14 +24,7 @@ import { MatIcon } from '@angular/material/icon';
'../styles/base-text-viewer.component.scss', '../styles/base-text-viewer.component.scss',
], ],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ imports: [MatIcon, RouterLink, RouterLinkActive],
NgIf,
MatIcon,
NgSwitch,
NgSwitchCase,
RouterLink,
RouterLinkActive,
],
}) })
export class PiTextViewerLinkComponent extends PiBaseTextViewerComponent { export class PiTextViewerLinkComponent extends PiBaseTextViewerComponent {
@HostBinding('class') get textViewerLinkClasses(): string { @HostBinding('class') get textViewerLinkClasses(): string {

View File

@@ -1,13 +1,16 @@
@if (icon()) {
<mat-icon <mat-icon
*ngIf="icon()"
[svgIcon]="icon()!" [svgIcon]="icon()!"
alt="icon" alt="icon"
size="size" size="size"
[color]="iconColor()" [color]="iconColor()"
></mat-icon> ></mat-icon>
}
<article> <article>
<label>{{ label() }}</label> <label>{{ label() }}</label>
<span *ngIf="value()"> @if (value()) {
<span>
{{ value() }} {{ value() }}
</span> </span>
}
</article> </article>

Some files were not shown because too many files have changed in this diff Show More