Skip to content

Commit

Permalink
feat(kit): fix pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MillerSvt committed Nov 3, 2023
1 parent aa61465 commit 1a9c9f4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions projects/cdk/types/array-or-value.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type TuiArrayOrValue<T> = T | readonly T[];
1 change: 1 addition & 0 deletions projects/cdk/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './array-or-value';
export * from './autocomplete';
export * from './date-mode';
export * from './deep-partial';
Expand Down
1 change: 1 addition & 0 deletions projects/cdk/utils/miscellaneous/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export * from './mark-control-as-touched-and-validate';
export * from './nullable-same';
export * from './object-from-entries';
export * from './provide-options';
export * from './to-array';
export * from './uniq-by';
3 changes: 3 additions & 0 deletions projects/cdk/utils/miscellaneous/to-array.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function tuiToArray<T>(value: T | readonly T[]): readonly T[] {
return Array.isArray(value) ? value : [value];
}
8 changes: 2 additions & 6 deletions projects/kit/directives/highlight/highlight.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,23 @@ import {
} from '@angular/core';
import {
svgNodeFilter,
TuiArrayOrValue,
TuiDestroyService,
tuiIsNumber,
tuiIsString,
TuiResizeService,
tuiToArray,
} from '@taiga-ui/cdk';
import {Observable, Subject} from 'rxjs';
import {mergeAll, switchMap, takeUntil} from 'rxjs/operators';

import {TuiHighlightComponent} from './highlight.component';

type TuiArrayOrValue<T> = T | readonly T[];

interface TuiHighlightOccurrence {
index: number;
length: number;
}

function tuiToArray<T>(value: T | readonly T[]): readonly T[] {
return Array.isArray(value) ? value : [value];
}

@Directive({
selector: '[tuiHighlight]',
host: {
Expand Down

0 comments on commit 1a9c9f4

Please sign in to comment.