refactor: migra NgModules a componentes standalone
This commit is contained in:
@@ -23,18 +23,12 @@ export abstract class PiBaseAffixDirective implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: 'pi-prefix',
|
||||
})
|
||||
@Directive({ selector: 'pi-prefix', })
|
||||
export class PiPrefixDirective extends PiBaseAffixDirective {
|
||||
@HostBinding('class') className = 'pi-affix__prefix';
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: 'pi-suffix',
|
||||
})
|
||||
@Directive({ selector: 'pi-suffix', })
|
||||
export class PiSuffixDirective extends PiBaseAffixDirective {
|
||||
@HostBinding('class') className = 'pi-affix__suffix';
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './affix.directive';
|
||||
|
||||
export * from './util-affix.module';
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { PiPrefixDirective, PiSuffixDirective } from './affix.directive';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule],
|
||||
declarations: [PiPrefixDirective, PiSuffixDirective],
|
||||
exports: [PiPrefixDirective, PiSuffixDirective],
|
||||
})
|
||||
export class PiSharedUtilAffixModule {}
|
||||
@@ -21,10 +21,7 @@ export abstract class PiBaseColor implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-dynamic-color]',
|
||||
})
|
||||
@Directive({ selector: '[pi-dynamic-color]', })
|
||||
export class PiDynamicColorDirective extends PiBaseColor {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return this.colorClass;
|
||||
@@ -37,78 +34,54 @@ export class PiDynamicColorDirective extends PiBaseColor {
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-primary]',
|
||||
})
|
||||
@Directive({ selector: '[pi-primary]', })
|
||||
export class PiColorPrimaryDirective extends PiBaseColor {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return 'pi-color__primary';
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-accent]',
|
||||
})
|
||||
@Directive({ selector: '[pi-accent]', })
|
||||
export class PiColorAccentDirective extends PiBaseColor {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return 'pi-color__accent';
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-warn]',
|
||||
})
|
||||
@Directive({ selector: '[pi-warn]', })
|
||||
export class PiColorWarnDirective extends PiBaseColor {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return 'pi-color__warn';
|
||||
}
|
||||
}
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-success]',
|
||||
})
|
||||
@Directive({ selector: '[pi-success]', })
|
||||
export class PiColorSuccessDirective extends PiBaseColor {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return 'pi-color__success';
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-highlighted]',
|
||||
})
|
||||
@Directive({ selector: '[pi-highlighted]', })
|
||||
export class PiColorHighlightedDirective extends PiBaseColor {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return 'pi-color__highlighted';
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-white]',
|
||||
})
|
||||
@Directive({ selector: '[pi-white]', })
|
||||
export class PiColorWhiteDirective extends PiBaseColor {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return 'pi-color__white';
|
||||
}
|
||||
}
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-grey]',
|
||||
})
|
||||
@Directive({ selector: '[pi-grey]', })
|
||||
export class PiColorGreyDirective extends PiBaseColor {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return 'pi-color__grey';
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-black]',
|
||||
})
|
||||
@Directive({ selector: '[pi-black]', })
|
||||
export class PiColorBlackDirective {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return 'pi-color__black';
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './util-color.module';
|
||||
|
||||
|
||||
export * from './directives/colors.directive';
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import {
|
||||
PiColorAccentDirective,
|
||||
PiColorBlackDirective,
|
||||
PiColorWarnDirective,
|
||||
PiColorGreyDirective,
|
||||
PiColorHighlightedDirective,
|
||||
PiColorPrimaryDirective,
|
||||
PiColorSuccessDirective,
|
||||
PiColorWhiteDirective,
|
||||
PiDynamicColorDirective,
|
||||
} from './directives/colors.directive';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, RouterModule],
|
||||
declarations: [
|
||||
PiDynamicColorDirective,
|
||||
PiColorPrimaryDirective,
|
||||
PiColorAccentDirective,
|
||||
PiColorSuccessDirective,
|
||||
PiColorWarnDirective,
|
||||
PiColorHighlightedDirective,
|
||||
PiColorWhiteDirective,
|
||||
PiColorGreyDirective,
|
||||
PiColorBlackDirective,
|
||||
],
|
||||
exports: [
|
||||
PiDynamicColorDirective,
|
||||
PiColorPrimaryDirective,
|
||||
PiColorAccentDirective,
|
||||
PiColorSuccessDirective,
|
||||
PiColorWarnDirective,
|
||||
PiColorHighlightedDirective,
|
||||
PiColorWhiteDirective,
|
||||
PiColorGreyDirective,
|
||||
PiColorBlackDirective,
|
||||
],
|
||||
})
|
||||
export class PiSharedUtilColorModule {}
|
||||
@@ -1,9 +1,6 @@
|
||||
import { Directive, ElementRef, HostBinding, HostListener, Renderer2 } from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-menu-event-children]',
|
||||
})
|
||||
@Directive({ selector: '[pi-menu-event-children]', })
|
||||
export class PiMenuEventChildrenDirective {
|
||||
@HostBinding('class') className = 'pi-menu pi-menu__children';
|
||||
constructor(private el: ElementRef, private renderer: Renderer2) {}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { Directive, HostBinding, Input } from '@angular/core';
|
||||
import { MenuEntryContext } from '../entities/menu-entry.model';
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-menu-entry]',
|
||||
})
|
||||
@Directive({ selector: '[pi-menu-entry]', })
|
||||
export class PiMenuEntryDirective {
|
||||
@HostBinding('class') get classes(): string {
|
||||
const contextClass = this.context && `pi-menu-entry__context--${this.context}`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from './ui-menu.module';
|
||||
|
||||
|
||||
export * from './entities/menu-entry.model';
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// Angular
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { TranslatePipe, TranslateDirective } from '@ngx-translate/core';
|
||||
|
||||
// Directives
|
||||
import { PiMenuEventChildrenDirective } from './directives/menu-children.directive';
|
||||
import { PiMenuEntryDirective } from './directives/menu-entry.directive';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, TranslatePipe, TranslateDirective],
|
||||
declarations: [
|
||||
PiMenuEventChildrenDirective,
|
||||
PiMenuEntryDirective,
|
||||
],
|
||||
exports: [PiMenuEventChildrenDirective, PiMenuEntryDirective],
|
||||
})
|
||||
export class PiSharedUtilMenuModule {}
|
||||
@@ -1,4 +1,4 @@
|
||||
// pipes
|
||||
export * from './util-pipes.module';
|
||||
|
||||
|
||||
export * from './pipes';
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
standalone: false,
|
||||
name: 'numberFormat',
|
||||
})
|
||||
@Pipe({ name: 'numberFormat', })
|
||||
export class NumberFormatPipe implements PipeTransform {
|
||||
transform(value: unknown, ...args: Array<unknown>): unknown {
|
||||
return new Intl.NumberFormat('de-DE').format(+value);
|
||||
}
|
||||
}
|
||||
|
||||
@Pipe({
|
||||
standalone: false, name: 'replace' })
|
||||
@Pipe({ name: 'replace' })
|
||||
export class ReplacePipe implements PipeTransform {
|
||||
transform(value: string, strToReplace: string, replacementStr: string): string {
|
||||
if (!value || !strToReplace || !replacementStr) {
|
||||
@@ -22,10 +18,7 @@ export class ReplacePipe implements PipeTransform {
|
||||
}
|
||||
}
|
||||
|
||||
@Pipe({
|
||||
standalone: false,
|
||||
name: 'sanitizerAltImage',
|
||||
})
|
||||
@Pipe({ name: 'sanitizerAltImage', })
|
||||
export class SanitizerAltImagePipe implements PipeTransform {
|
||||
transform(name: string): string {
|
||||
return this.sanitizeAltImage(name);
|
||||
@@ -36,10 +29,7 @@ export class SanitizerAltImagePipe implements PipeTransform {
|
||||
}
|
||||
}
|
||||
|
||||
@Pipe({
|
||||
standalone: false,
|
||||
name: 'firstWord',
|
||||
})
|
||||
@Pipe({ name: 'firstWord', })
|
||||
export class FirstWordPipe implements PipeTransform {
|
||||
transform(value: string): string {
|
||||
if (!value) {
|
||||
@@ -49,8 +39,7 @@ export class FirstWordPipe implements PipeTransform {
|
||||
}
|
||||
}
|
||||
|
||||
@Pipe({
|
||||
standalone: false, name: 'truncate' })
|
||||
@Pipe({ name: 'truncate' })
|
||||
export class TruncatePipe implements PipeTransform {
|
||||
transform(text: string, length: number = 20, suffix: string = '...'): string {
|
||||
if (text.length > length) {
|
||||
@@ -61,16 +50,14 @@ export class TruncatePipe implements PipeTransform {
|
||||
}
|
||||
}
|
||||
|
||||
@Pipe({
|
||||
standalone: false, name: 'maxTwoDecimals' })
|
||||
@Pipe({ name: 'maxTwoDecimals' })
|
||||
export class MaxTwoDecimalsPipe implements PipeTransform {
|
||||
transform(value: unknown, ...args: Array<unknown>): unknown {
|
||||
return Math.round(+value * 100) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
@Pipe({
|
||||
standalone: false, name: 'anonymize' })
|
||||
@Pipe({ name: 'anonymize' })
|
||||
export class AnonymizePipe implements PipeTransform {
|
||||
transform(text?: string, length = 1, char = '*') {
|
||||
return text?.split(' ').map(word =>
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// Angular
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
// Pipes
|
||||
import { AnonymizePipe, FirstWordPipe, MaxTwoDecimalsPipe, NumberFormatPipe, SanitizerAltImagePipe, TruncatePipe } from './pipes';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule],
|
||||
declarations: [AnonymizePipe, FirstWordPipe, NumberFormatPipe, SanitizerAltImagePipe, TruncatePipe, MaxTwoDecimalsPipe ],
|
||||
exports: [AnonymizePipe, FirstWordPipe, NumberFormatPipe, SanitizerAltImagePipe, TruncatePipe, MaxTwoDecimalsPipe],
|
||||
})
|
||||
export class PiSharedUtilPipesModule {}
|
||||
@@ -3,10 +3,7 @@ import {
|
||||
HostBinding
|
||||
} from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-scroll-to-element]',
|
||||
})
|
||||
@Directive({ selector: '[pi-scroll-to-element]', })
|
||||
export class PiScrollToElementDirective {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return 'pi-scroll-to pi-scroll-to__element';
|
||||
|
||||
@@ -3,10 +3,9 @@ import { CommonModule } from '@angular/common';
|
||||
import { PiScrollToElementDirective } from './scroll-to.directive';
|
||||
import { PiSharedUtilScrollService } from './scroll-to.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule],
|
||||
declarations: [PiScrollToElementDirective],
|
||||
exports: [PiScrollToElementDirective],
|
||||
providers: [PiSharedUtilScrollService],
|
||||
@NgModule({
|
||||
imports: [CommonModule, PiScrollToElementDirective],
|
||||
exports: [PiScrollToElementDirective],
|
||||
providers: [PiSharedUtilScrollService],
|
||||
})
|
||||
export class PiSharedUtilScrollToModule {}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { Directive, OnChanges, HostBinding, Input, SimpleChanges } from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-disabled]',
|
||||
})
|
||||
@Directive({ selector: '[pi-disabled]', })
|
||||
export class PiDisabledDirective implements OnChanges {
|
||||
@HostBinding('style.opacity') get opacity(): number {
|
||||
return this.isDisabled ? 0.33 : 1;
|
||||
@@ -21,10 +18,7 @@ export class PiDisabledDirective implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[is-active]',
|
||||
})
|
||||
@Directive({ selector: '[is-active]', })
|
||||
export class PiIsActiveDirective {
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isActive ? 'is-active' : '', 'pi-status'].join(' ');
|
||||
@@ -39,10 +33,7 @@ export class PiIsActiveDirective {
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[is-visited]',
|
||||
})
|
||||
@Directive({ selector: '[is-visited]', })
|
||||
export class PiIsVisitedDirective {
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return [this.isVisited ? 'is-visited' : '', 'pi-status'].join(' ');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from './shared-util-status.module';
|
||||
|
||||
|
||||
export * from './directives/status.directive';
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
PiDisabledDirective,
|
||||
PiIsActiveDirective,
|
||||
PiIsVisitedDirective,
|
||||
} from './directives/status.directive';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule],
|
||||
declarations: [
|
||||
PiDisabledDirective,
|
||||
PiIsActiveDirective,
|
||||
PiIsVisitedDirective
|
||||
],
|
||||
exports: [
|
||||
PiDisabledDirective,
|
||||
PiIsActiveDirective,
|
||||
PiIsVisitedDirective,
|
||||
],
|
||||
})
|
||||
export class PiSharedUtilStatusModule {}
|
||||
@@ -1,9 +1,6 @@
|
||||
import { Directive, HostBinding, Input } from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
standalone: false,
|
||||
selector: '[pi-value]',
|
||||
})
|
||||
@Directive({ selector: '[pi-value]', })
|
||||
export class PiValueDirective {
|
||||
@HostBinding('class') get classes(): string | boolean {
|
||||
return ['pi-value', this.value > 0 ? 'is-positive' : 'is-negative'].join(' ');
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './util-value.module';
|
||||
|
||||
|
||||
export * from './directives/value.directive';
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { PiValueDirective } from './directives/value.directive';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule],
|
||||
declarations: [PiValueDirective],
|
||||
exports: [PiValueDirective],
|
||||
|
||||
})
|
||||
export class PiSharedUtilValueModule {}
|
||||
Reference in New Issue
Block a user