diff --git a/lib/core/src/lib/pipes/date-time.pipe.ts b/lib/core/src/lib/pipes/date-time.pipe.ts index 81462cb6ef4..298c3681380 100644 --- a/lib/core/src/lib/pipes/date-time.pipe.ts +++ b/lib/core/src/lib/pipes/date-time.pipe.ts @@ -18,7 +18,10 @@ import { Pipe, PipeTransform } from '@angular/core'; import { addMinutes, fromUnixTime, parse } from 'date-fns'; -@Pipe({ name: 'adfDateTime' }) +@Pipe({ + name: 'adfDateTime', + standalone: true +}) export class DateTimePipe implements PipeTransform { transform(value: string | Date | number, dateFormat: string): Date { let parsedValue: Date; diff --git a/lib/core/src/lib/pipes/decimal-number.pipe.ts b/lib/core/src/lib/pipes/decimal-number.pipe.ts index 8a3c02ff029..f62399084b5 100644 --- a/lib/core/src/lib/pipes/decimal-number.pipe.ts +++ b/lib/core/src/lib/pipes/decimal-number.pipe.ts @@ -25,7 +25,8 @@ import { takeUntil } from 'rxjs/operators'; @Pipe({ name: 'adfDecimalNumber', - pure: false + pure: false, + standalone: true }) export class DecimalNumberPipe implements PipeTransform, OnDestroy { static DEFAULT_LOCALE = 'en-US'; diff --git a/lib/core/src/lib/pipes/file-size.pipe.ts b/lib/core/src/lib/pipes/file-size.pipe.ts index f1337c128a6..d0b2f1767ad 100644 --- a/lib/core/src/lib/pipes/file-size.pipe.ts +++ b/lib/core/src/lib/pipes/file-size.pipe.ts @@ -20,12 +20,11 @@ import { TranslationService } from '../translation/translation.service'; @Pipe({ name: 'adfFileSize', - pure: false + pure: false, + standalone: true }) export class FileSizePipe implements PipeTransform { - - constructor(private translation: TranslationService) { - } + constructor(private translation: TranslationService) {} transform(paramByte: any, decimals: number = 2): string { if (paramByte == null) { @@ -49,5 +48,4 @@ export class FileSizePipe implements PipeTransform { return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + i18nSize; } - } diff --git a/lib/core/src/lib/pipes/file-type.pipe.ts b/lib/core/src/lib/pipes/file-type.pipe.ts index 5b1c55f0024..6574e602582 100644 --- a/lib/core/src/lib/pipes/file-type.pipe.ts +++ b/lib/core/src/lib/pipes/file-type.pipe.ts @@ -19,18 +19,16 @@ import { PipeTransform, Pipe } from '@angular/core'; @Pipe({ name: 'fileType', - pure: true + pure: true, + standalone: true }) export class FileTypePipe implements PipeTransform { - transform(value: string) { - - if ( value == null ) { + if (value == null) { return ''; } else { const fileInfo = value.substring(value.lastIndexOf('/') + 1).replace(/\.[a-z]+/, ''); return fileInfo.split('_').pop(); } } - } diff --git a/lib/core/src/lib/pipes/filter-out-every-object-by-prop.pipe.ts b/lib/core/src/lib/pipes/filter-out-every-object-by-prop.pipe.ts index f4e3311f0a1..69343c64b3a 100644 --- a/lib/core/src/lib/pipes/filter-out-every-object-by-prop.pipe.ts +++ b/lib/core/src/lib/pipes/filter-out-every-object-by-prop.pipe.ts @@ -17,9 +17,12 @@ import { Pipe, PipeTransform } from '@angular/core'; -@Pipe({ name: 'filterOutEvery' }) +@Pipe({ + name: 'filterOutEvery', + standalone: true +}) export class FilterOutArrayObjectsByPropPipe implements PipeTransform { transform(values: T[], filterKey: string, filterValue: any): T[] { - return (values ?? []).filter(value => value[filterKey] !== filterValue); + return (values ?? []).filter((value) => value[filterKey] !== filterValue); } } diff --git a/lib/core/src/lib/pipes/filter-string.pipe.ts b/lib/core/src/lib/pipes/filter-string.pipe.ts index fd6f3a1f7bc..c40dcb52336 100644 --- a/lib/core/src/lib/pipes/filter-string.pipe.ts +++ b/lib/core/src/lib/pipes/filter-string.pipe.ts @@ -17,13 +17,13 @@ import { Pipe, PipeTransform } from '@angular/core'; -@Pipe({ name: 'filterString' }) +@Pipe({ + name: 'filterString', + standalone: true +}) export class FilterStringPipe implements PipeTransform { - transform(value: string = '', filterBy: string = ''): string { - const testResult = filterBy ? - value.toLowerCase().indexOf(filterBy.toLowerCase()) > -1 : - true; + const testResult = filterBy ? value.toLowerCase().indexOf(filterBy.toLowerCase()) > -1 : true; return testResult ? value : ''; } diff --git a/lib/core/src/lib/pipes/format-space.pipe.ts b/lib/core/src/lib/pipes/format-space.pipe.ts index 27616996381..ce56c391030 100644 --- a/lib/core/src/lib/pipes/format-space.pipe.ts +++ b/lib/core/src/lib/pipes/format-space.pipe.ts @@ -18,17 +18,17 @@ import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ - name: 'formatSpace' + name: 'formatSpace', + standalone: true }) export class FormatSpacePipe implements PipeTransform { - transform(inputValue: string, replaceChar: string = '_', lowerCase: boolean = true): string { let transformedString = ''; if (inputValue) { - transformedString = lowerCase ? inputValue.trim().split(' ').join(replaceChar).toLocaleLowerCase() : - inputValue.trim().split(' ').join(replaceChar); + transformedString = lowerCase + ? inputValue.trim().split(' ').join(replaceChar).toLocaleLowerCase() + : inputValue.trim().split(' ').join(replaceChar); } return transformedString; } - } diff --git a/lib/core/src/lib/pipes/full-name.pipe.ts b/lib/core/src/lib/pipes/full-name.pipe.ts index d2af5a3e52b..67c26b83de9 100644 --- a/lib/core/src/lib/pipes/full-name.pipe.ts +++ b/lib/core/src/lib/pipes/full-name.pipe.ts @@ -18,9 +18,11 @@ import { Pipe, PipeTransform } from '@angular/core'; import { UserLike } from './user-like.interface'; -@Pipe({ name: 'fullName' }) +@Pipe({ + name: 'fullName', + standalone: true +}) export class FullNamePipe implements PipeTransform { - transform(user: UserLike): string { return this.buildFullName(user) ? this.buildFullName(user) : this.buildFromUsernameOrEmail(user); } @@ -35,6 +37,6 @@ export class FullNamePipe implements PipeTransform { } buildFromUsernameOrEmail(user: UserLike): string { - return (user?.username || user?.email) ?? '' ; + return (user?.username || user?.email) ?? ''; } } diff --git a/lib/core/src/lib/pipes/localized-role.pipe.ts b/lib/core/src/lib/pipes/localized-role.pipe.ts index ef15957a3d2..1de3a9691a5 100644 --- a/lib/core/src/lib/pipes/localized-role.pipe.ts +++ b/lib/core/src/lib/pipes/localized-role.pipe.ts @@ -19,11 +19,11 @@ import { Pipe, PipeTransform } from '@angular/core'; import { TranslationService } from '../translation/translation.service'; @Pipe({ - name: 'adfLocalizedRole' + name: 'adfLocalizedRole', + standalone: true }) export class LocalizedRolePipe implements PipeTransform { - constructor(private translationService: TranslationService) { - } + constructor(private translationService: TranslationService) {} transform(value: string): any { if (value) { diff --git a/lib/core/src/lib/pipes/mime-type-icon.pipe.ts b/lib/core/src/lib/pipes/mime-type-icon.pipe.ts index 44411611e7d..86a5f8b722d 100644 --- a/lib/core/src/lib/pipes/mime-type-icon.pipe.ts +++ b/lib/core/src/lib/pipes/mime-type-icon.pipe.ts @@ -19,11 +19,11 @@ import { Pipe, PipeTransform } from '@angular/core'; import { ThumbnailService } from '../common/services/thumbnail.service'; @Pipe({ - name: 'adfMimeTypeIcon' + name: 'adfMimeTypeIcon', + standalone: true }) export class MimeTypeIconPipe implements PipeTransform { - - constructor(private thumbnailService: ThumbnailService) { } + constructor(private thumbnailService: ThumbnailService) {} transform(text: string): string { return this.thumbnailService.getMimeTypeIcon(text); diff --git a/lib/core/src/lib/pipes/moment-date.pipe.ts b/lib/core/src/lib/pipes/moment-date.pipe.ts index 012c5103491..9af0df1bf25 100644 --- a/lib/core/src/lib/pipes/moment-date.pipe.ts +++ b/lib/core/src/lib/pipes/moment-date.pipe.ts @@ -22,7 +22,10 @@ declare let moment: any; /** * @deprecated this pipe is deprecated and should no longer be used */ -@Pipe({ name: 'adfMomentDate' }) +@Pipe({ + name: 'adfMomentDate', + standalone: true +}) export class MomentDatePipe implements PipeTransform { transform(value: any, dateFormat: string): any { return moment(value, dateFormat); diff --git a/lib/core/src/lib/pipes/moment-datetime.pipe.ts b/lib/core/src/lib/pipes/moment-datetime.pipe.ts index 4c2eba9b18d..7753dbe1392 100644 --- a/lib/core/src/lib/pipes/moment-datetime.pipe.ts +++ b/lib/core/src/lib/pipes/moment-datetime.pipe.ts @@ -21,7 +21,10 @@ declare let moment: any; /** * @deprecated this pipe is deprecated and should no longer be used */ -@Pipe({ name: 'adfMomentDateTime' }) +@Pipe({ + name: 'adfMomentDateTime', + standalone: true +}) export class MomentDateTimePipe implements PipeTransform { transform(value: any, dateFormat: string): any { return moment(value, dateFormat).add(moment(value, dateFormat).utcOffset(), 'minutes'); diff --git a/lib/core/src/lib/pipes/multi-value.pipe.spec.ts b/lib/core/src/lib/pipes/multi-value.pipe.spec.ts index 5977cb180a1..a5c5337d2c5 100644 --- a/lib/core/src/lib/pipes/multi-value.pipe.spec.ts +++ b/lib/core/src/lib/pipes/multi-value.pipe.spec.ts @@ -18,21 +18,16 @@ import { MultiValuePipe } from './multi-value.pipe'; import { TestBed } from '@angular/core/testing'; import { CoreTestingModule } from '../testing/core.testing.module'; -import { TranslateModule } from '@ngx-translate/core'; - -describe('FullNamePipe', () => { +describe('MultiValuePipe', () => { let pipe: MultiValuePipe; beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - CoreTestingModule - ] + imports: [CoreTestingModule, MultiValuePipe] }); pipe = TestBed.inject(MultiValuePipe); - }); + }); it('should add the separator when a string list is provided', () => { const values = ['cat', 'house', 'dog']; diff --git a/lib/core/src/lib/pipes/multi-value.pipe.ts b/lib/core/src/lib/pipes/multi-value.pipe.ts index 40c16b0845f..23b04435007 100644 --- a/lib/core/src/lib/pipes/multi-value.pipe.ts +++ b/lib/core/src/lib/pipes/multi-value.pipe.ts @@ -17,13 +17,14 @@ import { Pipe, PipeTransform } from '@angular/core'; -@Pipe({ name: 'multiValue' }) +@Pipe({ + name: 'multiValue', + standalone: true +}) export class MultiValuePipe implements PipeTransform { - static DEFAULT_SEPARATOR = ', '; transform(values: any | any[], valueSeparator: string = MultiValuePipe.DEFAULT_SEPARATOR): string { - if (values && values instanceof Array) { return values.join(valueSeparator); } diff --git a/lib/core/src/lib/pipes/pipe.module.ts b/lib/core/src/lib/pipes/pipe.module.ts index 5719ce2e6f0..badd75d0d1a 100644 --- a/lib/core/src/lib/pipes/pipe.module.ts +++ b/lib/core/src/lib/pipes/pipe.module.ts @@ -15,7 +15,6 @@ * limitations under the License. */ -import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FileSizePipe } from './file-size.pipe'; @@ -30,73 +29,39 @@ import { MultiValuePipe } from './multi-value.pipe'; import { LocalizedDatePipe } from './localized-date.pipe'; import { DecimalNumberPipe } from './decimal-number.pipe'; import { LocalizedRolePipe } from './localized-role.pipe'; -import { TranslateModule } from '@ngx-translate/core'; import { MomentDatePipe } from './moment-date.pipe'; import { MomentDateTimePipe } from './moment-datetime.pipe'; import { FilterStringPipe } from './filter-string.pipe'; import { FilterOutArrayObjectsByPropPipe } from './filter-out-every-object-by-prop.pipe'; import { DateTimePipe } from './date-time.pipe'; +export const CORE_PIPES = [ + LocalizedDatePipe, + TimeAgoPipe, + FileSizePipe, + HighlightPipe, + MimeTypeIconPipe, + FullNamePipe, + FormatSpacePipe, + FileTypePipe, + MultiValuePipe, + DecimalNumberPipe, + LocalizedRolePipe, + MomentDatePipe, + MomentDateTimePipe, + DateTimePipe, + FilterStringPipe, + FilterOutArrayObjectsByPropPipe, + InitialUsernamePipe +] as const; + +/** + * @deprecated this Module is deprecated and should no longer be used. + * Consider importing CORE_PIPES or individual pipes directly. + */ @NgModule({ - imports: [ - CommonModule, - TranslateModule, - LocalizedDatePipe, - TimeAgoPipe - ], - declarations: [ - FileSizePipe, - HighlightPipe, - MimeTypeIconPipe, - InitialUsernamePipe, - FullNamePipe, - FormatSpacePipe, - FileTypePipe, - MultiValuePipe, - DecimalNumberPipe, - LocalizedRolePipe, - MomentDatePipe, - MomentDateTimePipe, - DateTimePipe, - FilterStringPipe, - FilterOutArrayObjectsByPropPipe - ], - providers: [ - FileSizePipe, - HighlightPipe, - TimeAgoPipe, - MimeTypeIconPipe, - InitialUsernamePipe, - FormatSpacePipe, - FileTypePipe, - MultiValuePipe, - DecimalNumberPipe, - LocalizedRolePipe, - MomentDatePipe, - MomentDateTimePipe, - DateTimePipe, - FilterStringPipe, - FilterOutArrayObjectsByPropPipe, - LocalizedDatePipe - ], - exports: [ - FileSizePipe, - HighlightPipe, - TimeAgoPipe, - MimeTypeIconPipe, - InitialUsernamePipe, - FullNamePipe, - FormatSpacePipe, - FileTypePipe, - MultiValuePipe, - DecimalNumberPipe, - LocalizedRolePipe, - MomentDatePipe, - MomentDateTimePipe, - DateTimePipe, - FilterStringPipe, - FilterOutArrayObjectsByPropPipe - ] + imports: [...CORE_PIPES], + providers: [...CORE_PIPES], + exports: [...CORE_PIPES] }) -export class PipeModule { -} +export class PipeModule {} diff --git a/lib/core/src/lib/pipes/text-highlight.pipe.ts b/lib/core/src/lib/pipes/text-highlight.pipe.ts index a3cc024d9ad..27db9a3a6db 100644 --- a/lib/core/src/lib/pipes/text-highlight.pipe.ts +++ b/lib/core/src/lib/pipes/text-highlight.pipe.ts @@ -19,11 +19,11 @@ import { Pipe, PipeTransform } from '@angular/core'; import { HighlightTransformService, HighlightTransformResult } from '../common/services/highlight-transform.service'; @Pipe({ - name: 'highlight' + name: 'highlight', + standalone: true }) export class HighlightPipe implements PipeTransform { - - constructor(private highlightTransformService: HighlightTransformService) { } + constructor(private highlightTransformService: HighlightTransformService) {} transform(text: string, search: string): string { const highlightTransformResult: HighlightTransformResult = this.highlightTransformService.highlight(text, search); diff --git a/lib/core/src/lib/pipes/user-initial.pipe.ts b/lib/core/src/lib/pipes/user-initial.pipe.ts index 41ce157daef..5ed5b46ef83 100644 --- a/lib/core/src/lib/pipes/user-initial.pipe.ts +++ b/lib/core/src/lib/pipes/user-initial.pipe.ts @@ -20,12 +20,11 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { UserLike } from './user-like.interface'; @Pipe({ - name: 'usernameInitials' + name: 'usernameInitials', + standalone: true }) export class InitialUsernamePipe implements PipeTransform { - - constructor(private sanitized: DomSanitizer) { - } + constructor(private sanitized: DomSanitizer) {} transform(user: UserLike & { displayName?: string }, className: string = '', delimiter: string = ''): SafeHtml { let safeHtml: SafeHtml = ''; @@ -42,8 +41,8 @@ export class InitialUsernamePipe implements PipeTransform { } getInitialUserName(firstName: string, lastName: string, delimiter: string): string { - firstName = (firstName ? firstName[0] : ''); - lastName = (lastName ? lastName[0] : ''); + firstName = firstName ? firstName[0] : ''; + lastName = lastName ? lastName[0] : ''; return firstName + delimiter + lastName; } }