Skip to content

Commit

Permalink
fix: review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Frequency21 committed Oct 6, 2023
1 parent a8ef912 commit 60ae19b
Show file tree
Hide file tree
Showing 21 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
TuiIdService,
tuiPure,
tuiSum,
TypedTuiMapper,
TuiTypedMapper,
} from '@taiga-ui/cdk';
import {
TuiHintHoverDirective,
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -88,7 +88,7 @@ export class TuiDocDocumentationComponent implements AfterContentInit {
return this.isAPI ? this.texts[0] : this.texts[1];
}

matcher: TypedTuiMatcher<
matcher: TuiTypedMatcher<
[TuiDocDocumentationPropertyConnectorDirective<any>, Set<string>]
> = (item, exclusions) => !exclusions.has(item.documentationPropertyName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
TuiInjectionTokenType,
TuiMonth,
tuiTypedFromEvent,
TypedTuiMapper,
TuiTypedMapper,
} from '@taiga-ui/cdk';
import {
TUI_ANIMATIONS_DURATION,
Expand Down Expand Up @@ -225,7 +225,7 @@ export class TuiMobileCalendarComponent implements AfterViewInit {
});
}

readonly disabledItemHandlerMapper: TypedTuiMapper<
readonly disabledItemHandlerMapper: TuiTypedMapper<
[TuiBooleanHandler<TuiDay>, TuiDay, TuiDay],
TuiBooleanHandler<TuiDay>
> = (disabledItemHandler, min, max) => item =>
Expand Down
4 changes: 2 additions & 2 deletions projects/cdk/components/alert-host/alert-host.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -54,7 +54,7 @@ export class TuiAlertHostComponent<T extends TuiDialog<unknown, unknown>>
});
}

readonly mapper: TypedTuiMapper<[unknown], Injector> = useValue =>
readonly mapper: TuiTypedMapper<[unknown], Injector> = useValue =>
Injector.create({
providers: [
{
Expand Down
4 changes: 2 additions & 2 deletions projects/cdk/pipes/filter/filter.pipe.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -13,7 +13,7 @@ export class TuiFilterPipe implements PipeTransform {
transform<T>(items: readonly T[], matcher: TuiMatcher<T>, ...args: any[]): T[];
transform<T, U extends unknown[]>(
items: readonly T[],
matcher: TypedTuiMatcher<[T, ...U]>,
matcher: TuiTypedMatcher<[T, ...U]>,
...args: U
): T[] {
return items.filter(item => matcher(item, ...args));
Expand Down
4 changes: 2 additions & 2 deletions projects/cdk/pipes/filter/test/filter.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions projects/cdk/pipes/mapper/mapper.pipe.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -13,7 +13,7 @@ export class TuiMapperPipe implements PipeTransform {
transform<T, G>(value: T, mapper: TuiMapper<T, G>, ...args: any[]): G;
transform<T extends unknown[], U, G>(
value: U,
mapper: TypedTuiMapper<[U, ...T], G>,
mapper: TuiTypedMapper<[U, ...T], G>,
...args: T
): G {
return mapper(value, ...args);
Expand Down
4 changes: 2 additions & 2 deletions projects/cdk/pipes/mapper/test/mapper.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand Down
4 changes: 2 additions & 2 deletions projects/cdk/types/mapper.ts
Original file line number Diff line number Diff line change
@@ -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<T, G> = (item: T, ...args: any[]) => G;

/**
* Typed mapping function.
*/
export type TypedTuiMapper<T extends unknown[], G> = (...args: T) => G;
export type TuiTypedMapper<T extends unknown[], G> = (...args: T) => G;
6 changes: 3 additions & 3 deletions projects/cdk/types/matcher.ts
Original file line number Diff line number Diff line change
@@ -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<I> = TuiMapper<I, boolean>;

/**
* A matcher function to test items against with extra arguments.
*/
export type TypedTuiMatcher<I extends unknown[]> = TypedTuiMapper<I, boolean>;
export type TuiTypedMatcher<I extends unknown[]> = TuiTypedMapper<I, boolean>;

export type TuiStringMatcher<I> = (
item: I,
Expand Down
4 changes: 2 additions & 2 deletions projects/core/components/calendar/calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -81,7 +81,7 @@ export class TuiCalendarComponent implements TuiWithOptionalMinMax<TuiDay> {

year: TuiYear | null = null;

readonly disabledItemHandlerMapper: TypedTuiMapper<
readonly disabledItemHandlerMapper: TuiTypedMapper<
[TuiBooleanHandler<TuiDay>, TuiDay, TuiDay],
TuiBooleanHandler<TuiDay>
> = (disabledItemHandler, min, max) => item =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
TuiDayLike,
TuiDayRange,
tuiPure,
TypedTuiMapper,
TypedTuiMatcher,
TuiTypedMapper,
TuiTypedMatcher,
} from '@taiga-ui/cdk';
import {TuiPoint} from '@taiga-ui/core';

Expand Down Expand Up @@ -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<readonly [TuiDay, number]>, TuiDayRange],
readonly TuiPoint[]
> = (days, {from}) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -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`,
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {
tuiNullableSame,
tuiObjectFromEntries,
tuiPure,
TuiTypedMapper,
tuiWatch,
TypedTuiMapper,
} from '@taiga-ui/cdk';
import {
TUI_COMMON_ICONS,
Expand Down Expand Up @@ -118,16 +118,16 @@ export class TuiCalendarRangeComponent implements TuiWithOptionalMinMax<TuiDay>
this.value = this.previousValue;
}

readonly mapper: TypedTuiMapper<
readonly mapper: TuiTypedMapper<
[
readonly TuiDayRangePeriod[],
TuiDay | null,
TuiDay | null,
TuiDayLike | null,
string,
string?,
],
ReadonlyArray<TuiDayRangePeriod | string>
> = (items, min, max, minLength, otherDateText) => [
> = (items, min, max, minLength, otherDateText = '') => [
...items.filter(
item =>
(minLength === null ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class="t-menu"
>
<button
*ngFor="let item of items | tuiMapper: mapper : min : max : minLength : (otherDateText$ | async) || ''"
*ngFor="let item of items | tuiMapper: mapper : min : max : minLength : (otherDateText$ | async)"
automation-id="tui-calendar-range__menu__item"
role="menuitemradio"
tuiOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
TuiMonth,
tuiNullableSame,
tuiPure,
TypedTuiMapper,
TuiTypedMapper,
} from '@taiga-ui/cdk';
import {
TUI_DEFAULT_MARKER_HANDLER,
Expand Down Expand Up @@ -114,7 +114,7 @@ export class TuiInputDateRangeComponent

open = false;

readonly maxLengthMapper: TypedTuiMapper<
readonly maxLengthMapper: TuiTypedMapper<
[TuiDay, TuiDayRange | null, TuiDayLike | null, boolean],
TuiDay
> = MAX_DAY_RANGE_LENGTH_MAPPER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
TuiContextWithImplicit,
TuiFocusableElementAccessor,
tuiPure,
TypedTuiMapper,
TuiTypedMapper,
} from '@taiga-ui/cdk';
import {
TUI_MASK_SYMBOLS_REGEXP,
Expand Down Expand Up @@ -187,7 +187,7 @@ export class TuiInputPhoneInternationalComponent
this.value = `${CHAR_PLUS}${value}`;
}

readonly isoToCountryCodeMapper: TypedTuiMapper<[TuiCountryIsoCode], string> = item =>
readonly isoToCountryCodeMapper: TuiTypedMapper<[TuiCountryIsoCode], string> = item =>
tuiIsoToCountryCode(this.countriesMasks, item);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
tuiIsString,
tuiPure,
TuiStringHandler,
TypedTuiMapper,
TuiTypedMapper,
} from '@taiga-ui/cdk';
import {
TEXTFIELD_CONTROLLER_PROVIDER,
Expand Down Expand Up @@ -199,15 +199,15 @@ export class TuiMultiSelectComponent<T>
return ({$implicit}) => stringify($implicit);
}

readonly valueMapper: TypedTuiMapper<
readonly valueMapper: TuiTypedMapper<
[readonly T[], TuiStringHandler<T>, boolean?],
ReadonlyArray<TuiStringifiableItem<T>>
> = (value, stringify, group) =>
group
? EMPTY_ARRAY
: value.map(item => new TuiStringifiableItem(item, stringify));

readonly disabledItemHandlerWrapper: TypedTuiMapper<
readonly disabledItemHandlerWrapper: TuiTypedMapper<
[TuiBooleanHandler<T>],
TuiBooleanHandler<TuiStringifiableItem<T> | string>
> = handler => stringifiable =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Directive} from '@angular/core';
import {TypedTuiMapper} from '@taiga-ui/cdk';
import {TuiTypedMapper} from '@taiga-ui/cdk';
import {AbstractTuiNativeSelect} from '@taiga-ui/kit/abstract';
import {TuiItemsHandlers} from '@taiga-ui/kit/tokens';

Expand All @@ -10,7 +10,7 @@ export abstract class AbstractTuiNativeMultiSelect<T> extends AbstractTuiNativeS
TuiMultiSelectDirective<T>,
T
> {
selectedMapper: TypedTuiMapper<[T, ...any[]], boolean> = (option, value) =>
selectedMapper: TuiTypedMapper<[T, ...any[]], boolean> = (option, value) =>
value.includes(option);

get stringify(): TuiItemsHandlers<T>['stringify'] {
Expand Down
4 changes: 2 additions & 2 deletions projects/kit/constants/max-day-range-length-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {
TuiDayLike,
TuiDayRange,
tuiObjectFromEntries,
TypedTuiMapper,
TuiTypedMapper,
} from '@taiga-ui/cdk';

export const MAX_DAY_RANGE_LENGTH_MAPPER: TypedTuiMapper<
export const MAX_DAY_RANGE_LENGTH_MAPPER: TuiTypedMapper<
[TuiDay, TuiDayRange | null, TuiDayLike | null, boolean],
TuiDay
> = (min, value, maxLength, backwards) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
TuiDayRange,
TuiDestroyService,
TuiMonth,
TuiTypedMapper,
tuiWatch,
TypedTuiMapper,
} from '@taiga-ui/cdk';
import {TUI_DEFAULT_MARKER_HANDLER, TuiMarkerHandler} from '@taiga-ui/core';
import {TUI_CALENDAR_DATE_STREAM} from '@taiga-ui/kit/tokens';
Expand Down Expand Up @@ -96,7 +96,7 @@ export class TuiPrimitiveCalendarRangeComponent implements OnInit {
: this.userViewedMonthSecond;
}

monthOffset: TypedTuiMapper<[TuiMonth, number], TuiMonth> = (value, offset) =>
monthOffset: TuiTypedMapper<[TuiMonth, number], TuiMonth> = (value, offset) =>
value.append({month: offset});

ngOnInit(): void {
Expand Down

0 comments on commit 60ae19b

Please sign in to comment.