diff --git a/projects/addon-charts/components/bar-chart/bar-chart.component.ts b/projects/addon-charts/components/bar-chart/bar-chart.component.ts index 87f2e3f5f798d..8aca27553231b 100644 --- a/projects/addon-charts/components/bar-chart/bar-chart.component.ts +++ b/projects/addon-charts/components/bar-chart/bar-chart.component.ts @@ -13,7 +13,7 @@ import { TuiIdService, tuiPure, tuiSum, - TypedTuiMapper, + TuiTypedMapper, } from '@taiga-ui/cdk'; import { TuiHintHoverDirective, @@ -71,7 +71,7 @@ export class TuiBarChartComponent { return this.max || this.getMax(this.value, this.collapsed); } - readonly percentMapper: TypedTuiMapper<[readonly number[], boolean, number], number> = + readonly percentMapper: TuiTypedMapper<[readonly number[], boolean, number], number> = (set, collapsed, max) => (100 * (collapsed ? tuiSum(...set) : Math.max(...set))) / max; diff --git a/projects/addon-doc/components/documentation/documentation.component.ts b/projects/addon-doc/components/documentation/documentation.component.ts index e5f1db436bdb8..3673fec6ba870 100644 --- a/projects/addon-doc/components/documentation/documentation.component.ts +++ b/projects/addon-doc/components/documentation/documentation.component.ts @@ -19,8 +19,8 @@ import { TuiDestroyService, tuiHexToRgb, tuiQueryListChanges, + TuiTypedMatcher, tuiWatch, - TypedTuiMatcher, } from '@taiga-ui/cdk'; import {merge} from 'rxjs'; import {switchMap, takeUntil} from 'rxjs/operators'; @@ -88,7 +88,7 @@ export class TuiDocDocumentationComponent implements AfterContentInit { return this.isAPI ? this.texts[0] : this.texts[1]; } - matcher: TypedTuiMatcher< + matcher: TuiTypedMatcher< [TuiDocDocumentationPropertyConnectorDirective, Set] > = (item, exclusions) => !exclusions.has(item.documentationPropertyName); diff --git a/projects/addon-mobile/components/mobile-calendar/mobile-calendar.component.ts b/projects/addon-mobile/components/mobile-calendar/mobile-calendar.component.ts index 394218d8dc2f2..bafb95e9e99f0 100644 --- a/projects/addon-mobile/components/mobile-calendar/mobile-calendar.component.ts +++ b/projects/addon-mobile/components/mobile-calendar/mobile-calendar.component.ts @@ -25,7 +25,7 @@ import { TuiInjectionTokenType, TuiMonth, tuiTypedFromEvent, - TypedTuiMapper, + TuiTypedMapper, } from '@taiga-ui/cdk'; import { TUI_ANIMATIONS_DURATION, @@ -225,7 +225,7 @@ export class TuiMobileCalendarComponent implements AfterViewInit { }); } - readonly disabledItemHandlerMapper: TypedTuiMapper< + readonly disabledItemHandlerMapper: TuiTypedMapper< [TuiBooleanHandler, TuiDay, TuiDay], TuiBooleanHandler > = (disabledItemHandler, min, max) => item => diff --git a/projects/cdk/components/alert-host/alert-host.component.ts b/projects/cdk/components/alert-host/alert-host.component.ts index a3e43ece5f3b1..e567c17c0a2e8 100644 --- a/projects/cdk/components/alert-host/alert-host.component.ts +++ b/projects/cdk/components/alert-host/alert-host.component.ts @@ -13,7 +13,7 @@ import { import {TUI_PARENT_ANIMATION} from '@taiga-ui/cdk/constants'; import {TuiDestroyService} from '@taiga-ui/cdk/services'; import {TUI_ALERTS} from '@taiga-ui/cdk/tokens'; -import {TuiDialog, TypedTuiMapper} from '@taiga-ui/cdk/types'; +import {TuiDialog, TuiTypedMapper} from '@taiga-ui/cdk/types'; import {POLYMORPHEUS_CONTEXT} from '@tinkoff/ng-polymorpheus'; import {combineLatest, Observable} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; @@ -54,7 +54,7 @@ export class TuiAlertHostComponent> }); } - readonly mapper: TypedTuiMapper<[unknown], Injector> = useValue => + readonly mapper: TuiTypedMapper<[unknown], Injector> = useValue => Injector.create({ providers: [ { diff --git a/projects/cdk/pipes/filter/filter.pipe.ts b/projects/cdk/pipes/filter/filter.pipe.ts index 493226645e3de..65ae469fcb27e 100644 --- a/projects/cdk/pipes/filter/filter.pipe.ts +++ b/projects/cdk/pipes/filter/filter.pipe.ts @@ -1,5 +1,5 @@ import {Pipe, PipeTransform} from '@angular/core'; -import {TuiMatcher, TypedTuiMatcher} from '@taiga-ui/cdk/types'; +import {TuiMatcher, TuiTypedMatcher} from '@taiga-ui/cdk/types'; @Pipe({name: `tuiFilter`}) export class TuiFilterPipe implements PipeTransform { @@ -13,7 +13,7 @@ export class TuiFilterPipe implements PipeTransform { transform(items: readonly T[], matcher: TuiMatcher, ...args: any[]): T[]; transform( items: readonly T[], - matcher: TypedTuiMatcher<[T, ...U]>, + matcher: TuiTypedMatcher<[T, ...U]>, ...args: U ): T[] { return items.filter(item => matcher(item, ...args)); diff --git a/projects/cdk/pipes/filter/test/filter.pipe.spec.ts b/projects/cdk/pipes/filter/test/filter.pipe.spec.ts index 4f5cb3b4ada7e..6e1d15ede911e 100644 --- a/projects/cdk/pipes/filter/test/filter.pipe.spec.ts +++ b/projects/cdk/pipes/filter/test/filter.pipe.spec.ts @@ -1,10 +1,10 @@ -import {TuiFilterPipe, TypedTuiMatcher} from '@taiga-ui/cdk'; +import {TuiFilterPipe, TuiTypedMatcher} from '@taiga-ui/cdk'; describe(`TuiFilter pipe`, () => { let pipe: TuiFilterPipe; const data = [`two`, `eleven`]; const args = [`two`, `four`]; - const matcher: TypedTuiMatcher<[string, number, ...string[]]> = ( + const matcher: TuiTypedMatcher<[string, number, ...string[]]> = ( item, search, ...rest diff --git a/projects/cdk/pipes/mapper/mapper.pipe.ts b/projects/cdk/pipes/mapper/mapper.pipe.ts index 7bd6b7ffca612..02e60e8353083 100644 --- a/projects/cdk/pipes/mapper/mapper.pipe.ts +++ b/projects/cdk/pipes/mapper/mapper.pipe.ts @@ -1,5 +1,5 @@ import {Pipe, PipeTransform} from '@angular/core'; -import {TuiMapper, TypedTuiMapper} from '@taiga-ui/cdk/types'; +import {TuiMapper, TuiTypedMapper} from '@taiga-ui/cdk/types'; @Pipe({name: `tuiMapper`}) export class TuiMapperPipe implements PipeTransform { @@ -13,7 +13,7 @@ export class TuiMapperPipe implements PipeTransform { transform(value: T, mapper: TuiMapper, ...args: any[]): G; transform( value: U, - mapper: TypedTuiMapper<[U, ...T], G>, + mapper: TuiTypedMapper<[U, ...T], G>, ...args: T ): G { return mapper(value, ...args); diff --git a/projects/cdk/pipes/mapper/test/mapper.pipe.spec.ts b/projects/cdk/pipes/mapper/test/mapper.pipe.spec.ts index 704e535677ff0..05990510c5f52 100644 --- a/projects/cdk/pipes/mapper/test/mapper.pipe.spec.ts +++ b/projects/cdk/pipes/mapper/test/mapper.pipe.spec.ts @@ -1,10 +1,10 @@ -import {TuiMapperPipe, TypedTuiMapper} from '@taiga-ui/cdk'; +import {TuiMapperPipe, TuiTypedMapper} from '@taiga-ui/cdk'; describe(`TuiMapper pipe`, () => { let pipe: TuiMapperPipe; const data = `test`; const args = [`three`, `eleven`]; - const mapper: TypedTuiMapper<[string, ...string[]], string> = (item, ...rest) => + const mapper: TuiTypedMapper<[string, ...string[]], string> = (item, ...rest) => item.toUpperCase() + rest.join(` `); beforeEach(() => { diff --git a/projects/cdk/types/mapper.ts b/projects/cdk/types/mapper.ts index a6df794eafc80..371d6755953d8 100644 --- a/projects/cdk/types/mapper.ts +++ b/projects/cdk/types/mapper.ts @@ -1,11 +1,11 @@ /** * Typed mapping function. * - * @deprecated Will be removed in v4.0. Use `TypedTuiMapper` instead. + * @deprecated Will be removed in v4.0. Use {@link TuiTypedMapper} instead. */ export type TuiMapper = (item: T, ...args: any[]) => G; /** * Typed mapping function. */ -export type TypedTuiMapper = (...args: T) => G; +export type TuiTypedMapper = (...args: T) => G; diff --git a/projects/cdk/types/matcher.ts b/projects/cdk/types/matcher.ts index 4dbbebc77a1b0..51ac57a7b9032 100644 --- a/projects/cdk/types/matcher.ts +++ b/projects/cdk/types/matcher.ts @@ -1,17 +1,17 @@ import {TuiStringHandler} from './handler'; -import {TuiMapper, TypedTuiMapper} from './mapper'; +import {TuiMapper, TuiTypedMapper} from './mapper'; /** * A matcher function to test items against with extra arguments. * - * @deprecated Will be removed in v4.0. Use `TypedTuiMatcher` instead. + * @deprecated Will be removed in v4.0. Use {@link TuiTypedMatcher} instead. */ export type TuiMatcher = TuiMapper; /** * A matcher function to test items against with extra arguments. */ -export type TypedTuiMatcher = TypedTuiMapper; +export type TuiTypedMatcher = TuiTypedMapper; export type TuiStringMatcher = ( item: I, diff --git a/projects/core/components/calendar/calendar.component.ts b/projects/core/components/calendar/calendar.component.ts index fbcb05b07d91e..63a0f8c2376b5 100644 --- a/projects/core/components/calendar/calendar.component.ts +++ b/projects/core/components/calendar/calendar.component.ts @@ -14,8 +14,8 @@ import { TuiDayRange, TuiMonth, tuiNullableSame, + TuiTypedMapper, TuiYear, - TypedTuiMapper, } from '@taiga-ui/cdk'; import {TUI_DEFAULT_MARKER_HANDLER} from '@taiga-ui/core/constants'; import {TuiWithOptionalMinMax} from '@taiga-ui/core/interfaces'; @@ -81,7 +81,7 @@ export class TuiCalendarComponent implements TuiWithOptionalMinMax { year: TuiYear | null = null; - readonly disabledItemHandlerMapper: TypedTuiMapper< + readonly disabledItemHandlerMapper: TuiTypedMapper< [TuiBooleanHandler, TuiDay, TuiDay], TuiBooleanHandler > = (disabledItemHandler, min, max) => item => diff --git a/projects/demo/src/modules/charts/line-days-chart/examples/2/index.ts b/projects/demo/src/modules/charts/line-days-chart/examples/2/index.ts index fc883f63f04d2..357708bd10e9b 100644 --- a/projects/demo/src/modules/charts/line-days-chart/examples/2/index.ts +++ b/projects/demo/src/modules/charts/line-days-chart/examples/2/index.ts @@ -6,8 +6,8 @@ import { TuiDayLike, TuiDayRange, tuiPure, - TypedTuiMapper, - TypedTuiMatcher, + TuiTypedMapper, + TuiTypedMatcher, } from '@taiga-ui/cdk'; import {TuiPoint} from '@taiga-ui/core'; @@ -45,12 +45,12 @@ export class TuiLineDaysChartExample2 { return day instanceof TuiDay ? day : date.append({day}); } - readonly filter: TypedTuiMatcher<[readonly [TuiDay, number], TuiDayRange]> = ( + readonly filter: TuiTypedMatcher<[readonly [TuiDay, number], TuiDayRange]> = ( [day], {from, to}, ) => day.daySameOrAfter(from) && day.daySameOrBefore(to); - readonly toNumbers: TypedTuiMapper< + readonly toNumbers: TuiTypedMapper< [ReadonlyArray, TuiDayRange], readonly TuiPoint[] > = (days, {from}) => diff --git a/projects/demo/src/modules/pipes/mapper/examples/2/component.ts b/projects/demo/src/modules/pipes/mapper/examples/2/component.ts index e8a9e39c2462a..2b96f8ddc8954 100644 --- a/projects/demo/src/modules/pipes/mapper/examples/2/component.ts +++ b/projects/demo/src/modules/pipes/mapper/examples/2/component.ts @@ -1,7 +1,7 @@ import {Component} from '@angular/core'; import {changeDetection} from '@demo/emulate/change-detection'; import {encapsulation} from '@demo/emulate/encapsulation'; -import {TypedTuiMapper} from '@taiga-ui/cdk'; +import {TuiTypedMapper} from '@taiga-ui/cdk'; @Component({ selector: `tui-mapper-example2`, @@ -12,7 +12,7 @@ import {TypedTuiMapper} from '@taiga-ui/cdk'; export class TuiMapperExample2 { numbers = [1, 2, 3, 4, 5] as const; - readonly mapper: TypedTuiMapper<[readonly number[], number], number[]> = ( + readonly mapper: TuiTypedMapper<[readonly number[], number], number[]> = ( numbers, multiplier, ) => numbers.map(number => number * multiplier); diff --git a/projects/kit/components/calendar-range/calendar-range.component.ts b/projects/kit/components/calendar-range/calendar-range.component.ts index 15896f213201b..af4a53786e520 100644 --- a/projects/kit/components/calendar-range/calendar-range.component.ts +++ b/projects/kit/components/calendar-range/calendar-range.component.ts @@ -24,8 +24,8 @@ import { tuiNullableSame, tuiObjectFromEntries, tuiPure, + TuiTypedMapper, tuiWatch, - TypedTuiMapper, } from '@taiga-ui/cdk'; import { TUI_COMMON_ICONS, @@ -118,16 +118,16 @@ export class TuiCalendarRangeComponent implements TuiWithOptionalMinMax this.value = this.previousValue; } - readonly mapper: TypedTuiMapper< + readonly mapper: TuiTypedMapper< [ readonly TuiDayRangePeriod[], TuiDay | null, TuiDay | null, TuiDayLike | null, - string, + string?, ], ReadonlyArray - > = (items, min, max, minLength, otherDateText) => [ + > = (items, min, max, minLength, otherDateText = '') => [ ...items.filter( item => (minLength === null || diff --git a/projects/kit/components/calendar-range/calendar-range.template.html b/projects/kit/components/calendar-range/calendar-range.template.html index f45a24cc6358e..04d7899a12849 100644 --- a/projects/kit/components/calendar-range/calendar-range.template.html +++ b/projects/kit/components/calendar-range/calendar-range.template.html @@ -29,7 +29,7 @@ class="t-menu" >