From aafe5e92ae8114fccf98f7d36bb1837010724c71 Mon Sep 17 00:00:00 2001 From: Barsukov Nikita Date: Mon, 1 Aug 2022 14:11:11 +0300 Subject: [PATCH] refactor!: remove deprecated functions without `tui`-prefix --- .../line-chart/line-chart.component.ts | 4 +- .../pie-chart/pie-chart.directive.ts | 4 +- projects/addon-charts/utils/control-point.ts | 16 +-- .../addon-charts/utils/describe-sector.ts | 6 +- projects/addon-charts/utils/draw-curve.ts | 14 +-- projects/addon-charts/utils/draw-line.ts | 8 +- projects/addon-charts/utils/draw.ts | 16 +-- projects/addon-charts/utils/line-angle.ts | 8 +- projects/addon-charts/utils/line-length.ts | 8 +- .../pipes/currency/currency.pipe.ts | 4 +- .../addon-commerce/utils/format-currency.ts | 8 +- .../addon-commerce/utils/is-expire-valid.ts | 8 +- .../utils/test/format-currency.spec.ts | 14 +-- .../validators/card-expire.validator.ts | 4 +- .../src/components/code/code.component.ts | 8 +- .../src/components/code/parse-code-block.ts | 8 +- ...umentation-property-connector.directive.ts | 4 +- .../documentation/documentation.component.ts | 20 ++-- .../components/example/example.component.ts | 4 +- .../navigation/navigation.component.ts | 6 +- .../scroll-into-view.directive.ts | 4 +- projects/addon-doc/src/utils/coerce-value.ts | 10 +- .../addon-doc/src/utils/color-conversion.ts | 14 +-- projects/addon-doc/src/utils/inspect.ts | 10 +- .../addon-doc/src/utils/raw-load-record.ts | 12 +- projects/addon-doc/src/utils/raw-load.ts | 8 +- .../src/utils/test/coerce-value.spec.ts | 51 ++++---- .../src/utils/test/raw-load-utils.spec.ts | 10 +- .../utils/transliterate-keyboard-layout.ts | 6 +- .../color-edit/color-edit.component.ts | 6 +- .../color-selector.component.ts | 12 +- .../input-color/input-color.component.ts | 8 +- .../tiptap-editor/tiptap-editor.service.ts | 8 +- .../tiptap-editor/utils/is-empty-paragraph.ts | 8 +- .../addon-editor/services/picker.service.ts | 10 +- .../addon-editor/utils/get-element-point.ts | 8 +- .../addon-editor/utils/get-gradient-data.ts | 8 +- projects/addon-editor/utils/get-mark-range.ts | 8 +- projects/addon-editor/utils/hex-to-rgb.ts | 6 +- .../addon-editor/utils/is-selection-in.ts | 12 +- projects/addon-editor/utils/parse-color.ts | 8 +- projects/addon-editor/utils/parse-gradient.ts | 8 +- projects/addon-editor/utils/rgb-to-hex.ts | 6 +- .../utils/test/hex-to-rgb.spec.ts | 6 +- .../utils/test/parse-color.spec.ts | 10 +- .../utils/test/parse-gradient.spec.ts | 16 ++- .../utils/test/rgb-to-hex.spec.ts | 8 +- .../utils/test/to-gradient.spec.ts | 8 +- projects/addon-editor/utils/to-gradient.ts | 14 +-- .../mobile-calendar.providers.ts | 4 +- .../elastic-sticky/elastic-sticky.service.ts | 4 +- .../components/preview/preview.component.ts | 6 +- .../table/directives/resized.directive.ts | 4 +- .../components/table/th/th.component.ts | 4 +- projects/addon-table/utils/default-sort.ts | 8 +- .../cdk/directives/drag/drag.directive.ts | 4 +- .../droppable/droppable.directive.ts | 6 +- .../focus-trap/focus-trap.directive.ts | 4 +- .../overscroll/overscroll.directive.ts | 14 +-- .../directives/pressed/pressed.directive.ts | 4 +- .../prevent-default.directive.ts | 4 +- .../cdk/observables/drag-and-drop-from.ts | 12 +- .../observables/focus-visible-observable.ts | 8 +- .../items-query-list-observable.ts | 6 +- .../cdk/observables/mouse-drag-finish-from.ts | 6 +- projects/cdk/observables/must-be-present.ts | 8 +- .../cdk/observables/pressed-observable.ts | 12 +- projects/cdk/observables/prevent-default.ts | 8 +- projects/cdk/observables/stop-propagation.ts | 8 +- .../observables/test/drag-and-drop.spec.ts | 12 +- .../test/items-query-list-observable.spec.ts | 8 +- .../observables/test/must-be-present.spec.ts | 16 +-- .../test/presssed-observable.spec.ts | 12 +- .../observables/test/prevent-default.spec.ts | 4 +- .../observables/test/stop-propagation.spec.ts | 6 +- projects/cdk/observables/test/watch.spec.ts | 6 +- projects/cdk/observables/watch.ts | 8 +- .../cdk/services/focus-visible.service.ts | 6 +- projects/cdk/services/obscured.service.ts | 4 +- projects/cdk/services/zoom.service.ts | 6 +- projects/cdk/tokens/active-element.ts | 14 +-- projects/cdk/utils/browser/is-edge.ts | 8 +- projects/cdk/utils/browser/is-firefox.ts | 8 +- projects/cdk/utils/browser/is-safari.ts | 8 +- .../cdk/utils/browser/test/browsers.spec.ts | 10 +- projects/cdk/utils/dom/can-scroll.ts | 8 +- projects/cdk/utils/dom/contains-or-after.ts | 8 +- projects/cdk/utils/dom/get-actual-target.ts | 6 +- .../cdk/utils/dom/get-clipboard-data-text.ts | 6 +- .../utils/dom/get-document-or-shadow-root.ts | 8 +- .../cdk/utils/dom/get-element-obscurers.ts | 10 +- projects/cdk/utils/dom/get-element-offset.ts | 6 +- projects/cdk/utils/dom/get-scroll-parent.ts | 8 +- projects/cdk/utils/dom/is-current-target.ts | 8 +- projects/cdk/utils/dom/is-inside-iframe.ts | 6 +- projects/cdk/utils/dom/is-node-in.ts | 6 +- .../cdk/utils/dom/test/can-scroll.spec.ts | 8 +- .../utils/dom/test/contains-or-after.spec.ts | 8 +- .../utils/dom/test/get-actual-target.spec.ts | 6 +- .../dom/test/get-clipboard-data-text.spec.ts | 6 +- .../test/get-document-or-shadow-root.spec.ts | 6 +- .../dom/test/get-element-obscurers.spec.ts | 6 +- .../utils/dom/test/get-element-offset.spec.ts | 6 +- .../utils/dom/test/get-scroll-parent.spec.ts | 12 +- .../utils/dom/test/is-current-target.spec.ts | 4 +- .../cdk/utils/dom/test/is-node-in.spec.ts | 10 +- .../data-list-dropdown-manager.directive.ts | 8 +- .../data-list/data-list.component.ts | 4 +- .../components/dialog/dialog.providers.ts | 12 +- .../components/expand/expand.component.ts | 4 +- .../components/loader/loader.component.ts | 4 +- .../scroll-controls/scrollbar.directive.ts | 10 +- .../scrollbar/scrollbar.component.ts | 12 +- projects/core/components/svg/svg.component.ts | 4 +- .../described-by/described-by.providers.ts | 4 +- .../textfield-controller.provider.ts | 4 +- projects/core/observables/smart-search.ts | 8 +- .../observables/test/smart-search.spec.ts | 18 ++- .../watched-controller-provider-factory.ts | 4 +- projects/core/tokens/icons-path.ts | 4 +- .../mask/create-auto-corrected-money-pipe.ts | 8 +- .../utils/miscellaneous/icons-path-factory.ts | 8 +- .../demo/src/modules/app/app.providers.ts | 4 +- .../stackblitz/stackblitz-resources-loader.ts | 112 ++++++++++-------- .../input-inline/examples/3/component.ts | 13 +- .../components/tooltip/examples/1/index.ts | 4 +- .../directives/dropdown/examples/3/index.ts | 4 +- .../info/changelog/changelog.component.ts | 4 +- .../modules/tables/table/examples/3/index.ts | 4 +- .../modules/tables/table/examples/4/index.ts | 6 +- .../modules/utils/browser/examples/1/index.ts | 6 +- projects/demo/test/try-parse-markdown.spec.ts | 10 +- .../accordion/accordion.component.ts | 4 +- .../calendar-range.component.ts | 4 +- .../utils/extract-value-from-event.ts | 4 +- .../input-phone/input-phone.component.ts | 4 +- .../input-tag/input-tag.component.ts | 8 +- .../line-clamp/line-clamp.component.ts | 4 +- .../multi-select-group.component.ts | 8 +- .../range/test/range.component.spec.ts | 6 +- .../kit/components/slider/slider.component.ts | 4 +- .../components/stepper/stepper.component.ts | 4 +- .../lazy-loading/lazy-loading.service.ts | 4 +- .../directives/present/present.directive.ts | 6 +- .../primitive-calendar-range.component.ts | 4 +- .../kit/utils/miscellaneous/get-precision.ts | 6 +- projects/testing/utils/active-element.ts | 4 +- projects/testing/utils/keyboard-event.ts | 8 +- .../testing/utils/native-input.page-object.ts | 4 +- 149 files changed, 511 insertions(+), 755 deletions(-) diff --git a/projects/addon-charts/components/line-chart/line-chart.component.ts b/projects/addon-charts/components/line-chart/line-chart.component.ts index 88b6ccbe4f1b..16ea1f8f4a02 100644 --- a/projects/addon-charts/components/line-chart/line-chart.component.ts +++ b/projects/addon-charts/components/line-chart/line-chart.component.ts @@ -9,7 +9,7 @@ import { Optional, } from '@angular/core'; import {TuiLineChartHintContext} from '@taiga-ui/addon-charts/interfaces'; -import {draw} from '@taiga-ui/addon-charts/utils'; +import {tuiDraw} from '@taiga-ui/addon-charts/utils'; import { tuiDefaultProp, TuiIdService, @@ -216,7 +216,7 @@ export class TuiLineChartComponent { private getD(value: readonly TuiPoint[], smoothingFactor: number): string { return value.reduce( (d, point, index) => - index ? `${d} ${draw(value, index, smoothingFactor)}` : `M ${point}`, + index ? `${d} ${tuiDraw(value, index, smoothingFactor)}` : `M ${point}`, ``, ); } diff --git a/projects/addon-charts/components/pie-chart/pie-chart.directive.ts b/projects/addon-charts/components/pie-chart/pie-chart.directive.ts index ed3cce232b82..b6f618f5af93 100644 --- a/projects/addon-charts/components/pie-chart/pie-chart.directive.ts +++ b/projects/addon-charts/components/pie-chart/pie-chart.directive.ts @@ -1,6 +1,6 @@ import {Directive, ElementRef, Inject, Input, NgZone} from '@angular/core'; import {ANIMATION_FRAME, PERFORMANCE} from '@ng-web-apis/common'; -import {describeSector} from '@taiga-ui/addon-charts/utils'; +import {tuiDescribeSector} from '@taiga-ui/addon-charts/utils'; import { clamp, easeInOutQuad, @@ -56,7 +56,7 @@ export class TuiPieChartDirective { takeUntil(destroy$), ) .subscribe(([start, end]) => { - nativeElement.setAttribute(`d`, describeSector(start, end)); + nativeElement.setAttribute(`d`, tuiDescribeSector(start, end)); }); } } diff --git a/projects/addon-charts/utils/control-point.ts b/projects/addon-charts/utils/control-point.ts index 3ce0ff121ed2..f2e7484d160e 100644 --- a/projects/addon-charts/utils/control-point.ts +++ b/projects/addon-charts/utils/control-point.ts @@ -1,13 +1,9 @@ import {TuiPoint} from '@taiga-ui/core'; -import {lineAngle} from './line-angle'; -import {lineLength} from './line-length'; +import {tuiLineAngle} from './line-angle'; +import {tuiLineLength} from './line-length'; -/** - * @deprecated: use {@link tuiControlPoint} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function controlPoint( +export function tuiControlPoint( current: TuiPoint, previous?: TuiPoint, next?: TuiPoint, @@ -16,12 +12,10 @@ export function controlPoint( ): TuiPoint { const p = previous || current; const n = next || current; - const angle = lineAngle(p, n) + (reverse ? Math.PI : 0); - const length = lineLength(p, n) * smoothing; + const angle = tuiLineAngle(p, n) + (reverse ? Math.PI : 0); + const length = tuiLineLength(p, n) * smoothing; const x = current[0] + Math.cos(angle) * length; const y = current[1] + Math.sin(angle) * length; return [x, y]; } - -export const tuiControlPoint = controlPoint; diff --git a/projects/addon-charts/utils/describe-sector.ts b/projects/addon-charts/utils/describe-sector.ts index c622b1408836..c1e6df7b85bd 100644 --- a/projects/addon-charts/utils/describe-sector.ts +++ b/projects/addon-charts/utils/describe-sector.ts @@ -3,7 +3,6 @@ import {toInt, toRadians} from '@taiga-ui/cdk'; const EMPTY = `M 100 0 A 100 100 0 1 1 100 0 L 0 0`; /** - * @deprecated: use {@link tuiDescribeSector} instead * Describes a normalized sector by angles. Normalized meaning it supposed to work with * SVG with viewBox="-1 -1 2 2" so that 0 coordinates in cartesian and polar match the same spot. * Everything is multiplied by 100 (including viewBox of SVG to host this) so IE properly @@ -12,8 +11,7 @@ const EMPTY = `M 100 0 A 100 100 0 1 1 100 0 L 0 0`; * @param startAngle starting angle in degrees * @param endAngle ending angle in degrees */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function describeSector(startAngle: number, endAngle: number): string { +export function tuiDescribeSector(startAngle: number, endAngle: number): string { const startRad = toRadians(startAngle); const endRad = toRadians(endAngle); const startX = Math.cos(startRad) * 100; @@ -35,5 +33,3 @@ export function describeSector(startAngle: number, endAngle: number): string { return isNaN(endX) ? EMPTY : result.join(` `); } - -export const tuiDescribeSector = describeSector; diff --git a/projects/addon-charts/utils/draw-curve.ts b/projects/addon-charts/utils/draw-curve.ts index 4b153dd9b475..62b7ca02de42 100644 --- a/projects/addon-charts/utils/draw-curve.ts +++ b/projects/addon-charts/utils/draw-curve.ts @@ -1,24 +1,20 @@ import {TuiPoint} from '@taiga-ui/core'; -import {controlPoint} from './control-point'; +import {tuiControlPoint} from './control-point'; -/** - * @deprecated: use {@link tuiDrawCurve} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function drawCurve( +export function tuiDrawCurve( array: readonly TuiPoint[], index: number, smoothing: number, ): string { - const [cpsX, cpsY] = controlPoint( + const [cpsX, cpsY] = tuiControlPoint( array[index - 1], array[index - 2], array[index], false, smoothing, ); - const [cpeX, cpeY] = controlPoint( + const [cpeX, cpeY] = tuiControlPoint( array[index], array[index - 1], array[index + 1], @@ -28,5 +24,3 @@ export function drawCurve( return `C ${cpsX},${cpsY} ${cpeX},${cpeY} ${array[index][0]},${array[index][1]}`; } - -export const tuiDrawCurve = drawCurve; diff --git a/projects/addon-charts/utils/draw-line.ts b/projects/addon-charts/utils/draw-line.ts index 90fe02192ea4..7a6650c14a39 100644 --- a/projects/addon-charts/utils/draw-line.ts +++ b/projects/addon-charts/utils/draw-line.ts @@ -1,9 +1,3 @@ -/** - * @deprecated: use {@link drawLine} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function drawLine(point: [number, number]): string { +export function tuiDrawLine(point: [number, number]): string { return `L ${point}`; } - -export const tuiDrawLine = drawLine; diff --git a/projects/addon-charts/utils/draw.ts b/projects/addon-charts/utils/draw.ts index f91c42a45463..a58750c30d4d 100644 --- a/projects/addon-charts/utils/draw.ts +++ b/projects/addon-charts/utils/draw.ts @@ -1,22 +1,16 @@ import {TuiPoint} from '@taiga-ui/core'; -import {drawCurve} from './draw-curve'; -import {drawLine} from './draw-line'; +import {tuiDrawCurve} from './draw-curve'; +import {tuiDrawLine} from './draw-line'; const COEFFICIENT = 500; -/** - * @deprecated: use {@link tuiDraw} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function draw( +export function tuiDraw( array: readonly TuiPoint[], index: number, smoothing: number, ): string { return smoothing - ? drawCurve(array, index, smoothing / COEFFICIENT) - : drawLine([array[index][0], array[index][1]]); + ? tuiDrawCurve(array, index, smoothing / COEFFICIENT) + : tuiDrawLine([array[index][0], array[index][1]]); } - -export const tuiDraw = draw; diff --git a/projects/addon-charts/utils/line-angle.ts b/projects/addon-charts/utils/line-angle.ts index 004c0a40eb83..46561274942b 100644 --- a/projects/addon-charts/utils/line-angle.ts +++ b/projects/addon-charts/utils/line-angle.ts @@ -1,14 +1,8 @@ import {TuiPoint} from '@taiga-ui/core'; -/** - * @deprecated: use {@link tuiLineAngle} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function lineAngle(a: TuiPoint, b: TuiPoint): number { +export function tuiLineAngle(a: TuiPoint, b: TuiPoint): number { const x = b[0] - a[0]; const y = b[1] - a[1]; return Math.atan2(y, x); } - -export const tuiLineAngle = lineAngle; diff --git a/projects/addon-charts/utils/line-length.ts b/projects/addon-charts/utils/line-length.ts index f46a086bc1cd..3008ec192ee0 100644 --- a/projects/addon-charts/utils/line-length.ts +++ b/projects/addon-charts/utils/line-length.ts @@ -1,14 +1,8 @@ import {TuiPoint} from '@taiga-ui/core'; -/** - * @deprecated: use {@link tuiLineLength} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function lineLength(a: TuiPoint, b: TuiPoint): number { +export function tuiLineLength(a: TuiPoint, b: TuiPoint): number { const x = b[0] - a[0]; const y = b[1] - a[1]; return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); } - -export const tuiLineLength = lineLength; diff --git a/projects/addon-commerce/pipes/currency/currency.pipe.ts b/projects/addon-commerce/pipes/currency/currency.pipe.ts index a68a88b22a2f..1080c57790e4 100644 --- a/projects/addon-commerce/pipes/currency/currency.pipe.ts +++ b/projects/addon-commerce/pipes/currency/currency.pipe.ts @@ -1,12 +1,12 @@ import {Pipe, PipeTransform} from '@angular/core'; import {TuiCurrencyVariants} from '@taiga-ui/addon-commerce/types'; -import {formatCurrency} from '@taiga-ui/addon-commerce/utils'; +import {tuiFormatCurrency} from '@taiga-ui/addon-commerce/utils'; @Pipe({ name: `tuiCurrency`, }) export class TuiCurrencyPipe implements PipeTransform { transform(currency: TuiCurrencyVariants): string { - return formatCurrency(currency); + return tuiFormatCurrency(currency); } } diff --git a/projects/addon-commerce/utils/format-currency.ts b/projects/addon-commerce/utils/format-currency.ts index bea247360dfe..131760731e4c 100644 --- a/projects/addon-commerce/utils/format-currency.ts +++ b/projects/addon-commerce/utils/format-currency.ts @@ -3,18 +3,12 @@ import {tuiIsString} from '@taiga-ui/cdk'; import {tuiGetCurrencySymbol} from './get-currency-symbol'; -/** - * @deprecated: use {@link tuiFormatCurrency} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function formatCurrency(currency: TuiCurrencyVariants): string { +export function tuiFormatCurrency(currency: TuiCurrencyVariants): string { const stringifiedCurrency = stringifyCurrency(currency); return tuiGetCurrencySymbol(stringifiedCurrency) || stringifiedCurrency; } -export const tuiFormatCurrency = formatCurrency; - function stringifyCurrency(currency: TuiCurrencyVariants): string { return currency === null || tuiIsString(currency) ? currency || `` diff --git a/projects/addon-commerce/utils/is-expire-valid.ts b/projects/addon-commerce/utils/is-expire-valid.ts index 2ddf57c500b6..658f264b67fd 100644 --- a/projects/addon-commerce/utils/is-expire-valid.ts +++ b/projects/addon-commerce/utils/is-expire-valid.ts @@ -1,8 +1,4 @@ -/** - * @deprecated: use {@link tuiIsExpireValid} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function isExpireValid(expire: string): boolean { +export function tuiIsExpireValid(expire: string): boolean { const today = new Date(); const currentMonth = today.getMonth(); const currentYear = today.getFullYear() - 2000; @@ -11,5 +7,3 @@ export function isExpireValid(expire: string): boolean { return year > currentYear || (year === currentYear && month >= currentMonth); } - -export const tuiIsExpireValid = isExpireValid; diff --git a/projects/addon-commerce/utils/test/format-currency.spec.ts b/projects/addon-commerce/utils/test/format-currency.spec.ts index 9201866abf7d..d16a5df6e7c7 100644 --- a/projects/addon-commerce/utils/test/format-currency.spec.ts +++ b/projects/addon-commerce/utils/test/format-currency.spec.ts @@ -1,33 +1,33 @@ -import {formatCurrency} from '../format-currency'; +import {tuiFormatCurrency} from '../format-currency'; -describe(`formatCurrency`, () => { +describe(`tuiFormatCurrency`, () => { it(`returns founded currency symbol`, () => { const usdCode = `USD`; - expect(formatCurrency(usdCode)).toBe(`$`); + expect(tuiFormatCurrency(usdCode)).toBe(`$`); }); it(`returns custom currency`, () => { const customCurrency = `CSTM`; - expect(formatCurrency(customCurrency)).toBe(customCurrency); + expect(tuiFormatCurrency(customCurrency)).toBe(customCurrency); }); it(`returns empty string if there is no value`, () => { const noCurrency = null; - expect(formatCurrency(noCurrency)).toBe(``); + expect(tuiFormatCurrency(noCurrency)).toBe(``); }); it(`returns correct currency from number currency code`, () => { const dollarCode = 840; - expect(formatCurrency(dollarCode)).toBe(`$`); + expect(tuiFormatCurrency(dollarCode)).toBe(`$`); }); it(`returns correct currency from number currency code with 2 decimal`, () => { const australianDollar = 36; - expect(formatCurrency(australianDollar)).toBe(`A$`); + expect(tuiFormatCurrency(australianDollar)).toBe(`A$`); }); }); diff --git a/projects/addon-commerce/validators/card-expire.validator.ts b/projects/addon-commerce/validators/card-expire.validator.ts index a497b004816d..fc308436c224 100644 --- a/projects/addon-commerce/validators/card-expire.validator.ts +++ b/projects/addon-commerce/validators/card-expire.validator.ts @@ -1,11 +1,11 @@ import {AbstractControl, ValidationErrors} from '@angular/forms'; -import {isExpireValid} from '@taiga-ui/addon-commerce/utils'; +import {tuiIsExpireValid} from '@taiga-ui/addon-commerce/utils'; import {TuiValidationError} from '@taiga-ui/cdk'; export function tuiCardExpireValidator({ value, }: AbstractControl): ValidationErrors | null { - return value?.expire?.length === 5 && !isExpireValid(value?.expire) + return value?.expire?.length === 5 && !tuiIsExpireValid(value?.expire) ? {expire: new TuiValidationError(`Expire date`)} : null; } diff --git a/projects/addon-doc/src/components/code/code.component.ts b/projects/addon-doc/src/components/code/code.component.ts index 41e62aabb958..40c34519e960 100644 --- a/projects/addon-doc/src/components/code/code.component.ts +++ b/projects/addon-doc/src/components/code/code.component.ts @@ -3,8 +3,8 @@ import {BehaviorSubject} from 'rxjs'; import {map, switchMap} from 'rxjs/operators'; import {RawLoaderContent} from '../../interfaces/page'; -import {rawLoad} from '../../utils/raw-load'; -import {tryParseMarkdownCodeBlock} from './parse-code-block'; +import {tuiRawLoad} from '../../utils/raw-load'; +import {tuiTryParseMarkdownCodeBlock} from './parse-code-block'; @Component({ selector: `tui-doc-code`, @@ -18,8 +18,8 @@ export class TuiDocCodeComponent { filename = ``; readonly processor$ = this.rawLoader$$.pipe( - switchMap(rawLoad), - map(tryParseMarkdownCodeBlock), + switchMap(tuiRawLoad), + map(tuiTryParseMarkdownCodeBlock), ); @Input() diff --git a/projects/addon-doc/src/components/code/parse-code-block.ts b/projects/addon-doc/src/components/code/parse-code-block.ts index b45fdacedde8..be82a6445d7b 100644 --- a/projects/addon-doc/src/components/code/parse-code-block.ts +++ b/projects/addon-doc/src/components/code/parse-code-block.ts @@ -1,11 +1,7 @@ import MarkdownIt from 'markdown-it'; import Token from 'markdown-it/lib/token'; -/** - * @deprecated: use {@link tuiTryParseMarkdownCodeBlock} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function tryParseMarkdownCodeBlock(text: string = ``): string[] { +export function tuiTryParseMarkdownCodeBlock(text: string = ``): string[] { const tokens: Token[] = new MarkdownIt().parse(text, {}); const result = tokens .filter(({tag, type}) => tag === `code` && type === `fence`) @@ -13,5 +9,3 @@ export function tryParseMarkdownCodeBlock(text: string = ``): string[] { return result.length ? result : [text]; } - -export const tuiTryParseMarkdownCodeBlock = tryParseMarkdownCodeBlock; diff --git a/projects/addon-doc/src/components/documentation/documentation-property-connector.directive.ts b/projects/addon-doc/src/components/documentation/documentation-property-connector.directive.ts index 4b6feaff1a3d..03c6ae232e07 100644 --- a/projects/addon-doc/src/components/documentation/documentation-property-connector.directive.ts +++ b/projects/addon-doc/src/components/documentation/documentation-property-connector.directive.ts @@ -12,7 +12,7 @@ import { import {ActivatedRoute, Params, UrlSerializer} from '@angular/router'; import {BehaviorSubject, Subject} from 'rxjs'; -import {coerceValue} from '../../utils/coerce-value'; +import {tuiCoerceValue} from '../../utils/coerce-value'; const SERIALIZED_SUFFIX = `$`; @@ -112,7 +112,7 @@ export class TuiDocDocumentationPropertyConnectorDirective const value = !!propertyValueWithSuffix && this.documentationPropertyValues ? this.documentationPropertyValues[propertyValueWithSuffix as number] - : coerceValue(propertyValue); + : tuiCoerceValue(propertyValue); this.onValueChange(value as T); } diff --git a/projects/addon-doc/src/components/documentation/documentation.component.ts b/projects/addon-doc/src/components/documentation/documentation.component.ts index e466c1aaa32d..5686c490323c 100644 --- a/projects/addon-doc/src/components/documentation/documentation.component.ts +++ b/projects/addon-doc/src/components/documentation/documentation.component.ts @@ -11,17 +11,17 @@ import { } from '@angular/core'; import { EMPTY_QUERY, - itemsQueryListObservable, tuiIsNumber, tuiIsString, - watch, + tuiItemsQueryListObservable, + tuiWatch, } from '@taiga-ui/cdk'; import {merge} from 'rxjs'; import {switchMap} from 'rxjs/operators'; import {TUI_DOC_DOCUMENTATION_TEXTS} from '../../tokens/i18n'; -import {hexToRgb, rgbToHex} from '../../utils/color-conversion'; -import {inspectAny} from '../../utils/inspect'; +import {tuiHexToRgb, tuiRgbToHex} from '../../utils/color-conversion'; +import {tuiInspectAny} from '../../utils/inspect'; import {TuiDocDocumentationPropertyConnectorDirective} from './documentation-property-connector.directive'; // @bad TODO subscribe propertiesConnectors changes @@ -60,10 +60,10 @@ export class TuiDocDocumentationComponent implements AfterContentInit { ) {} ngAfterContentInit(): void { - itemsQueryListObservable(this.propertiesConnectors) + tuiItemsQueryListObservable(this.propertiesConnectors) .pipe( switchMap(items => merge(...items.map(({changed$}) => changed$))), - watch(this.changeDetectorRef), + tuiWatch(this.changeDetectorRef), ) .subscribe(); } @@ -97,7 +97,7 @@ export class TuiDocDocumentationComponent implements AfterContentInit { .split(`,`) .map(v => Number.parseInt(v, 10)) as [number, number, number]; - return rgbToHex(...parsed); + return tuiRgbToHex(...parsed); } getOpacity(color: string): number { @@ -131,7 +131,7 @@ export class TuiDocDocumentationComponent implements AfterContentInit { return; } - const rgb = hexToRgb(color).join(`, `); + const rgb = tuiHexToRgb(color).join(`, `); const result = `rgba(${rgb}, ${opacity / 100})`; connector.onValueChange(result); @@ -142,7 +142,7 @@ export class TuiDocDocumentationComponent implements AfterContentInit { opacity: number, ): void { const hex = this.getColor(connector.documentationPropertyValue || ``); - const rgb = hexToRgb(hex); + const rgb = tuiHexToRgb(hex); const result = `rgba(${rgb}, ${opacity / 100})`; connector.onValueChange(result); @@ -169,6 +169,6 @@ export class TuiDocDocumentationComponent implements AfterContentInit { } inspectAny(data: unknown): string { - return inspectAny(data, 2); + return tuiInspectAny(data, 2); } } diff --git a/projects/addon-doc/src/components/example/example.component.ts b/projects/addon-doc/src/components/example/example.component.ts index fc1c3e649a48..a2ce337b4fbe 100644 --- a/projects/addon-doc/src/components/example/example.component.ts +++ b/projects/addon-doc/src/components/example/example.component.ts @@ -23,7 +23,7 @@ import {TUI_DOC_CODE_ACTIONS} from '../../tokens/code-actions'; import {TUI_DOC_CODE_EDITOR} from '../../tokens/code-editor'; import {TUI_DOC_EXAMPLE_CONTENT_PROCESSOR} from '../../tokens/example-content-processor'; import {TUI_DOC_EXAMPLE_TEXTS} from '../../tokens/i18n'; -import {rawLoadRecord} from '../../utils/raw-load-record'; +import {tuiRawLoadRecord} from '../../utils/raw-load-record'; @Component({ selector: `tui-doc-example`, @@ -57,7 +57,7 @@ export class TuiDocExampleComponent { readonly copy$ = this.copyTexts$.pipe(map(([copy]) => copy)); readonly processor$: Observable> = this.rawLoader$$.pipe( - switchMap(rawLoadRecord), + switchMap(tuiRawLoadRecord), map(value => this.processContent(value)), ); diff --git a/projects/addon-doc/src/components/navigation/navigation.component.ts b/projects/addon-doc/src/components/navigation/navigation.component.ts index fa89625ed8cc..298340544518 100644 --- a/projects/addon-doc/src/components/navigation/navigation.component.ts +++ b/projects/addon-doc/src/components/navigation/navigation.component.ts @@ -20,7 +20,7 @@ import {TUI_DOC_SEARCH_TEXT} from '../../tokens/i18n'; import {TUI_DOC_PAGE_LOADED} from '../../tokens/page-loaded'; import {TUI_DOC_SCROLL_BEHAVIOR} from '../../tokens/scroll-behavior'; import {TuiDocPages} from '../../types/pages'; -import {transliterateKeyboardLayout} from '../../utils/transliterate-keyboard-layout'; +import {tuiTransliterateKeyboardLayout} from '../../utils/transliterate-keyboard-layout'; import { NAVIGATION_ITEMS, NAVIGATION_LABELS, @@ -132,8 +132,8 @@ export class TuiDocNavigationComponent { return ( title.includes(search) || keywords.includes(search) || - title.includes(transliterateKeyboardLayout(search)) || - keywords.includes(transliterateKeyboardLayout(search)) || + title.includes(tuiTransliterateKeyboardLayout(search)) || + keywords.includes(tuiTransliterateKeyboardLayout(search)) || search.replace(/-/gi, ``).includes(title) ); }), diff --git a/projects/addon-doc/src/directives/scroll-into-view/scroll-into-view.directive.ts b/projects/addon-doc/src/directives/scroll-into-view/scroll-into-view.directive.ts index b32504090983..e94ad9b085b7 100644 --- a/projects/addon-doc/src/directives/scroll-into-view/scroll-into-view.directive.ts +++ b/projects/addon-doc/src/directives/scroll-into-view/scroll-into-view.directive.ts @@ -1,5 +1,5 @@ import {Directive, ElementRef, Inject, Input} from '@angular/core'; -import {getElementObscurers, TuiDestroyService} from '@taiga-ui/cdk'; +import {TuiDestroyService, tuiGetElementObscures} from '@taiga-ui/cdk'; import {Observable, ReplaySubject} from 'rxjs'; import {debounceTime, filter, switchMapTo, takeUntil} from 'rxjs/operators'; @@ -28,7 +28,7 @@ export class TuiScrollIntoViewLinkDirective { filter(Boolean), switchMapTo(this.scroll$), debounceTime(750), - filter(shallWe => shallWe && !!getElementObscurers(nativeElement)), + filter(shallWe => shallWe && !!tuiGetElementObscures(nativeElement)), takeUntil(destroy$), ) .subscribe(() => { diff --git a/projects/addon-doc/src/utils/coerce-value.ts b/projects/addon-doc/src/utils/coerce-value.ts index 74bf151feaa6..bf0cc606e09b 100644 --- a/projects/addon-doc/src/utils/coerce-value.ts +++ b/projects/addon-doc/src/utils/coerce-value.ts @@ -1,8 +1,6 @@ -/** - * @deprecated: use {@link tuiCoerceValue} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function coerceValue(value?: T): T | number | string | boolean | null | object { +export function tuiCoerceValue( + value?: T, +): T | number | string | boolean | null | object { const prepared = String(value).trim(); if (isEmptyParamValue(prepared)) { @@ -24,8 +22,6 @@ export function coerceValue(value?: T): T | number | string | boolean | null } } -export const tuiCoerceValue = coerceValue; - function isEmptyParamValue(value: string): boolean { return [`undefined`, `null`, `NaN`, `Infinity`].includes(value); } diff --git a/projects/addon-doc/src/utils/color-conversion.ts b/projects/addon-doc/src/utils/color-conversion.ts index 62b16374de4b..098c5b59ab74 100644 --- a/projects/addon-doc/src/utils/color-conversion.ts +++ b/projects/addon-doc/src/utils/color-conversion.ts @@ -1,20 +1,12 @@ /** * TODO: duplicate, need fix it before v3 * TODO: move another package for reuse between addon-editor and addon-doc - * @deprecated: use {@link tuiRgbToHex} instead */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function rgbToHex(r: number, g: number, b: number): string { +export function tuiRgbToHex(r: number, g: number, b: number): string { return `#${[r, g, b].map(x => x.toString(16).padStart(2, `0`)).join(``)}`; } -export const tuiRgbToHex = rgbToHex; - -/** - * @deprecated: use {@link tuiHexToRgb} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function hexToRgb(hex: string): [number, number, number] { +export function tuiHexToRgb(hex: string): [number, number, number] { const matches = hex .replace(`#`, ``) .split(``) @@ -26,5 +18,3 @@ export function hexToRgb(hex: string): [number, number, number] { ? (matches.map(x => Number.parseInt(x, 16)) as [number, number, number]) : [0, 0, 0]; } - -export const tuiHexToRgb = hexToRgb; diff --git a/projects/addon-doc/src/utils/inspect.ts b/projects/addon-doc/src/utils/inspect.ts index 37cd2781c115..2397140e546f 100644 --- a/projects/addon-doc/src/utils/inspect.ts +++ b/projects/addon-doc/src/utils/inspect.ts @@ -13,7 +13,7 @@ function inspectArray(array: readonly unknown[], depth: number): string { result += `, `; } - result += index in array ? inspectAny(array[index], depth - 1) : `empty`; + result += index in array ? tuiInspectAny(array[index], depth - 1) : `empty`; } return `[${result}]`; @@ -39,21 +39,19 @@ function inspectObject(object: {[key: string]: unknown}, depth: number): string result += `, `; } - result += `${key}: ${inspectAny(object[key], depth - 1)}`; + result += `${key}: ${tuiInspectAny(object[key], depth - 1)}`; } return `{${result}}`; } /** - * @deprecated: use {@link tuiInspectAny} instead * Returns readable JS entity * @param data * @param depth * @return readable JS entity */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function inspectAny(data: T, depth: number): string { +export function tuiInspectAny(data: T, depth: number): string { if (data === null) { return `null`; } @@ -78,5 +76,3 @@ export function inspectAny(data: T, depth: number): string { return inspectObject(data as unknown as {[key: string]: unknown}, depth); } - -export const tuiInspectAny = inspectAny; diff --git a/projects/addon-doc/src/utils/raw-load-record.ts b/projects/addon-doc/src/utils/raw-load-record.ts index da6dbf14d7da..a88662fa3605 100644 --- a/projects/addon-doc/src/utils/raw-load-record.ts +++ b/projects/addon-doc/src/utils/raw-load-record.ts @@ -1,22 +1,16 @@ import {TuiDocExample} from '../interfaces/page'; -import {rawLoad} from './raw-load'; +import {tuiRawLoad} from './raw-load'; -/** - * @deprecated: use {@link tuiRawLoadRecord} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export async function rawLoadRecord( +export async function tuiRawLoadRecord( example: TuiDocExample, ): Promise> { const processedContent: Record = {}; for (const [key, content] of Object.entries(example)) { if (content) { - processedContent[key] = await rawLoad(content); + processedContent[key] = await tuiRawLoad(content); } } return processedContent; } - -export const tuiRawLoadRecord = rawLoadRecord; diff --git a/projects/addon-doc/src/utils/raw-load.ts b/projects/addon-doc/src/utils/raw-load.ts index 6f63679851a0..f532b8eca735 100644 --- a/projects/addon-doc/src/utils/raw-load.ts +++ b/projects/addon-doc/src/utils/raw-load.ts @@ -11,14 +11,8 @@ function trimExportDefault(fileContent: string): string { : fileContent; } -/** - * @deprecated: use {@link tuiRawLoad} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export async function rawLoad(content: RawLoaderContent): Promise { +export async function tuiRawLoad(content: RawLoaderContent): Promise { const unpacked = content instanceof Promise ? (await content).default : content; return trimExportDefault(unpacked); } - -export const tuiRawLoad = rawLoad; diff --git a/projects/addon-doc/src/utils/test/coerce-value.spec.ts b/projects/addon-doc/src/utils/test/coerce-value.spec.ts index 0991e7e4b757..2575e6d295e7 100644 --- a/projects/addon-doc/src/utils/test/coerce-value.spec.ts +++ b/projects/addon-doc/src/utils/test/coerce-value.spec.ts @@ -1,54 +1,57 @@ -import {coerceValue} from '@taiga-ui/addon-doc'; +import {tuiCoerceValue} from '@taiga-ui/addon-doc'; describe(`coercing values`, () => { it(`string -> string`, () => { - expect(coerceValue(` +7965`)).toBe(`+7965`); - expect(coerceValue(`%2B7`)).toBe(`+7`); - expect(coerceValue(`%20%20%20123%20%20`)).toBe(` 123 `); - expect(coerceValue(`Hello world`)).toBe(`Hello world`); - expect(coerceValue(`2+5`)).toBe(`2+5`); - expect(coerceValue(``)).toBe(``); + expect(tuiCoerceValue(` +7965`)).toBe(`+7965`); + expect(tuiCoerceValue(`%2B7`)).toBe(`+7`); + expect(tuiCoerceValue(`%20%20%20123%20%20`)).toBe(` 123 `); + expect(tuiCoerceValue(`Hello world`)).toBe(`Hello world`); + expect(tuiCoerceValue(`2+5`)).toBe(`2+5`); + expect(tuiCoerceValue(``)).toBe(``); }); it(`string -> number`, () => { - expect(coerceValue(`123`)).toBe(123); - expect(coerceValue(`-123`)).toBe(-123); + expect(tuiCoerceValue(`123`)).toBe(123); + expect(tuiCoerceValue(`-123`)).toBe(-123); }); it(`string -> boolean`, () => { - expect(coerceValue(`true`)).toBe(true); - expect(coerceValue(`false`)).toBe(false); + expect(tuiCoerceValue(`true`)).toBe(true); + expect(tuiCoerceValue(`false`)).toBe(false); }); it(`string -> null`, () => { - expect(coerceValue(`null`)).toBe(null); - expect(coerceValue(`undefined`)).toBe(null); - expect(coerceValue(`NaN`)).toBe(null); - expect(coerceValue(`Infinity`)).toBe(null); + expect(tuiCoerceValue(`null`)).toBe(null); + expect(tuiCoerceValue(`undefined`)).toBe(null); + expect(tuiCoerceValue(`NaN`)).toBe(null); + expect(tuiCoerceValue(`Infinity`)).toBe(null); }); it(`string -> array`, () => { - expect(coerceValue(`[1,2,3]`)).toEqual([1, 2, 3]); - expect(coerceValue(`[ 1,2, 3]`)).toEqual([1, 2, 3]); - expect(coerceValue(`[ 1,2,, 3]`)).toBe(`[ 1,2,, 3]`); - expect(coerceValue(`This is array [1,2,3] inside string`)).toBe( + expect(tuiCoerceValue(`[1,2,3]`)).toEqual([1, 2, 3]); + expect(tuiCoerceValue(`[ 1,2, 3]`)).toEqual([1, 2, 3]); + expect(tuiCoerceValue(`[ 1,2,, 3]`)).toBe(`[ 1,2,, 3]`); + expect(tuiCoerceValue(`This is array [1,2,3] inside string`)).toBe( `This is array [1,2,3] inside string`, ); }); it(`string -> object`, () => { - expect(coerceValue(`{"id": 1, "name": "Taiga"}`)).toEqual({id: 1, name: `Taiga`}); - expect(coerceValue(`{"id": 1, "options": [1,2,3]}`)).toEqual({ + expect(tuiCoerceValue(`{"id": 1, "name": "Taiga"}`)).toEqual({ + id: 1, + name: `Taiga`, + }); + expect(tuiCoerceValue(`{"id": 1, "options": [1,2,3]}`)).toEqual({ id: 1, options: [1, 2, 3], }); - expect(coerceValue(`{"message": "Extra comma", "options": [1,2,,3]}`)).toBe( + expect(tuiCoerceValue(`{"message": "Extra comma", "options": [1,2,,3]}`)).toBe( `{"message": "Extra comma", "options": [1,2,,3]}`, ); - expect(coerceValue(`{"message": "No } at the end"`)).toBe( + expect(tuiCoerceValue(`{"message": "No } at the end"`)).toBe( `{"message": "No } at the end"`, ); - expect(coerceValue(`{message: "No quotes for key"`)).toBe( + expect(tuiCoerceValue(`{message: "No quotes for key"`)).toBe( `{message: "No quotes for key"`, ); }); diff --git a/projects/addon-doc/src/utils/test/raw-load-utils.spec.ts b/projects/addon-doc/src/utils/test/raw-load-utils.spec.ts index 213f4f16c8d3..b044d34a9339 100644 --- a/projects/addon-doc/src/utils/test/raw-load-utils.spec.ts +++ b/projects/addon-doc/src/utils/test/raw-load-utils.spec.ts @@ -1,9 +1,9 @@ -import {rawLoad} from '../raw-load'; -import {rawLoadRecord} from '../raw-load-record'; +import {tuiRawLoad} from '../raw-load'; +import {tuiRawLoadRecord} from '../raw-load-record'; describe(`tui-doc raw content utils`, () => { it(`rawLoadRecord`, async () => { - const result = await rawLoadRecord({ + const result = await tuiRawLoadRecord({ TypeScript: `Hello`, HTML: Promise.resolve({default: `World`}), }); @@ -15,11 +15,11 @@ describe(`tui-doc raw content utils`, () => { }); it(`rawLoad`, async () => { - let result = await rawLoad(`Hello`); + let result = await tuiRawLoad(`Hello`); expect(result).toBe(`Hello`); - result = await rawLoad(Promise.resolve({default: `World`})); + result = await tuiRawLoad(Promise.resolve({default: `World`})); expect(result).toBe(`World`); }); }); diff --git a/projects/addon-doc/src/utils/transliterate-keyboard-layout.ts b/projects/addon-doc/src/utils/transliterate-keyboard-layout.ts index 787a23eeef22..c0970f9183d3 100644 --- a/projects/addon-doc/src/utils/transliterate-keyboard-layout.ts +++ b/projects/addon-doc/src/utils/transliterate-keyboard-layout.ts @@ -34,13 +34,11 @@ const MAP: Record = { }; /** - * @deprecated: use {@link tuiTransliterateKeyboardLayout} instead * Translates text mistakenly typed in the Russian layout into English * @param string string with Russian layout characters * @return string with English layout characters */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function transliterateKeyboardLayout(string: string): string { +export function tuiTransliterateKeyboardLayout(string: string): string { let newStr = ``; for (let i = 0; i < string.length; i++) { @@ -49,5 +47,3 @@ export function transliterateKeyboardLayout(string: string): string { return newStr; } - -export const tuiTransliterateKeyboardLayout = transliterateKeyboardLayout; diff --git a/projects/addon-editor/components/color-selector/color-edit/color-edit.component.ts b/projects/addon-editor/components/color-selector/color-edit/color-edit.component.ts index 6d1f18585963..d7757e5aab03 100644 --- a/projects/addon-editor/components/color-selector/color-edit/color-edit.component.ts +++ b/projects/addon-editor/components/color-selector/color-edit/color-edit.component.ts @@ -5,7 +5,7 @@ import { Input, Output, } from '@angular/core'; -import {hexToRgb, rgbToHex} from '@taiga-ui/addon-editor/utils'; +import {tuiHexToRgb, tuiRgbToHex} from '@taiga-ui/addon-editor/utils'; import {tuiDefaultProp} from '@taiga-ui/cdk'; import {TextMaskConfig} from 'angular2-text-mask'; @@ -37,7 +37,7 @@ export class TuiColorEditComponent { } get hex(): string { - return rgbToHex(this.color[0], this.color[1], this.color[2]); + return tuiRgbToHex(this.color[0], this.color[1], this.color[2]); } get opacity(): number { @@ -49,7 +49,7 @@ export class TuiColorEditComponent { return; } - const rgb = hexToRgb(hex); + const rgb = tuiHexToRgb(hex); this.updateColor([rgb[0], rgb[1], rgb[2], this.color[3]]); } diff --git a/projects/addon-editor/components/color-selector/color-selector.component.ts b/projects/addon-editor/components/color-selector/color-selector.component.ts index 5144b920d7a4..8e29ed838a2f 100644 --- a/projects/addon-editor/components/color-selector/color-selector.component.ts +++ b/projects/addon-editor/components/color-selector/color-selector.component.ts @@ -9,7 +9,11 @@ import { import {DomSanitizer, SafeStyle} from '@angular/platform-browser'; import {TUI_EDITOR_COLOR_SELECTOR_MODE_NAMES} from '@taiga-ui/addon-editor/tokens'; import {TuiGradientDirection} from '@taiga-ui/addon-editor/types'; -import {getGradientData, parseColor, parseGradient} from '@taiga-ui/addon-editor/utils'; +import { + tuiGetGradientData, + tuiParseColor, + tuiParseGradient, +} from '@taiga-ui/addon-editor/utils'; import {tuiDefaultProp, tuiPure, tuiRequiredSetter} from '@taiga-ui/cdk'; import {TuiHostedDropdownComponent} from '@taiga-ui/core'; import {LEFT_ALIGNED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/kit/providers'; @@ -240,7 +244,7 @@ export class TuiColorSelectorComponent { return; } - const gradient = parseGradient(getGradientData(color)); + const gradient = tuiParseGradient(tuiGetGradientData(color)); this.currentMode = this.modes[1]; this.direction = gradient.side; @@ -250,7 +254,7 @@ export class TuiColorSelectorComponent { ? gradient.stops.map<[number, [number, number, number, number]]>( ({color, position}) => [ parseFloat(position) / 100, - parseColor(color), + tuiParseColor(color), ], ) : DEFAULT_STEPS, @@ -260,6 +264,6 @@ export class TuiColorSelectorComponent { private parseColor(color: string): void { this.currentMode = this.modes[0]; this.currentStop = 0; - this.color = parseColor(color); + this.color = tuiParseColor(color); } } diff --git a/projects/addon-editor/components/input-color/input-color.component.ts b/projects/addon-editor/components/input-color/input-color.component.ts index e22e14638d9b..c8455e38832d 100644 --- a/projects/addon-editor/components/input-color/input-color.component.ts +++ b/projects/addon-editor/components/input-color/input-color.component.ts @@ -11,7 +11,11 @@ import { } from '@angular/core'; import {NgControl} from '@angular/forms'; import {DomSanitizer, SafeStyle} from '@angular/platform-browser'; -import {getGradientData, parseGradient, toGradient} from '@taiga-ui/addon-editor/utils'; +import { + tuiGetGradientData, + tuiParseGradient, + tuiToGradient, +} from '@taiga-ui/addon-editor/utils'; import { AbstractTuiControl, tuiDefaultProp, @@ -111,7 +115,7 @@ export class TuiInputColorComponent private sanitize(value: string, domSanitizer: DomSanitizer): SafeStyle | string { return value.startsWith(`linear-gradient(`) ? domSanitizer.bypassSecurityTrustStyle( - toGradient(parseGradient(getGradientData(value))), + tuiToGradient(tuiParseGradient(tuiGetGradientData(value))), ) : value; } diff --git a/projects/addon-editor/directives/tiptap-editor/tiptap-editor.service.ts b/projects/addon-editor/directives/tiptap-editor/tiptap-editor.service.ts index c5c55dffabfd..f4b0920d4951 100644 --- a/projects/addon-editor/directives/tiptap-editor/tiptap-editor.service.ts +++ b/projects/addon-editor/directives/tiptap-editor/tiptap-editor.service.ts @@ -3,13 +3,13 @@ import './tiptap-editor.types'; import {Inject, Injectable} from '@angular/core'; import {AbstractTuiEditor} from '@taiga-ui/addon-editor/abstract'; import {TIPTAP_EDITOR} from '@taiga-ui/addon-editor/tokens'; -import {getMarkRange} from '@taiga-ui/addon-editor/utils'; +import {tuiGetMarkRange} from '@taiga-ui/addon-editor/utils'; import type {Editor, Range} from '@tiptap/core'; import type {EditorState} from 'prosemirror-state'; import {Observable} from 'rxjs'; import {distinctUntilChanged, map, startWith} from 'rxjs/operators'; -import {isEmptyParagraph} from './utils/is-empty-paragraph'; +import {tuiIsEmptyParagraph} from './utils/is-empty-paragraph'; type Level = 1 | 2 | 3 | 4 | 5 | 6; @@ -50,7 +50,7 @@ export class TuiTiptapEditorService extends AbstractTuiEditor { editor.on(`update`, () => { const content = editor.getHTML(); const json = editor.getJSON().content; - const value: string = isEmptyParagraph(json) ? `` : content; + const value: string = tuiIsEmptyParagraph(json) ? `` : content; this.valueChange$.next(value); }); @@ -297,7 +297,7 @@ export class TuiTiptapEditorService extends AbstractTuiEditor { selectClosest(): void { const pos = this.editor.state.selection.anchor; const {schema, doc} = this.editor.state; - const range = getMarkRange(doc.resolve(pos), schema.marks.link); + const range = tuiGetMarkRange(doc.resolve(pos), schema.marks.link); if (range) { this.editor.chain().setTextSelection(range).run(); diff --git a/projects/addon-editor/directives/tiptap-editor/utils/is-empty-paragraph.ts b/projects/addon-editor/directives/tiptap-editor/utils/is-empty-paragraph.ts index 7af24d36f0fe..1d7054057083 100644 --- a/projects/addon-editor/directives/tiptap-editor/utils/is-empty-paragraph.ts +++ b/projects/addon-editor/directives/tiptap-editor/utils/is-empty-paragraph.ts @@ -1,11 +1,5 @@ import {JSONContent} from '@tiptap/core'; -/** - * @deprecated: use {@link tuiIsEmptyParagraph} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function isEmptyParagraph(json?: JSONContent[]): boolean { +export function tuiIsEmptyParagraph(json?: JSONContent[]): boolean { return Array.isArray(json) && json.length === 1 && !json[0].hasOwnProperty(`content`); } - -export const tuiIsEmptyParagraph = isEmptyParagraph; diff --git a/projects/addon-editor/services/picker.service.ts b/projects/addon-editor/services/picker.service.ts index 26b071d9b743..d9e7fc3c641d 100644 --- a/projects/addon-editor/services/picker.service.ts +++ b/projects/addon-editor/services/picker.service.ts @@ -1,7 +1,7 @@ import {DOCUMENT} from '@angular/common'; import {ElementRef, Inject, Injectable} from '@angular/core'; -import {getElementPoint} from '@taiga-ui/addon-editor/utils'; -import {preventDefault, TuiDestroyService, typedFromEvent} from '@taiga-ui/cdk'; +import {tuiGetElementPoint} from '@taiga-ui/addon-editor/utils'; +import {TuiDestroyService, tuiPreventDefault, typedFromEvent} from '@taiga-ui/cdk'; import {TuiPoint} from '@taiga-ui/core'; import {Observable} from 'rxjs'; import {map, startWith, switchMap, takeUntil} from 'rxjs/operators'; @@ -14,11 +14,11 @@ export class TuiPickerService extends Observable { @Inject(DOCUMENT) documentRef: Document, ) { const point$ = typedFromEvent(nativeElement, `mousedown`).pipe( - preventDefault(), + tuiPreventDefault(), switchMap(event => { const mouseMove$ = typedFromEvent(documentRef, `mousemove`).pipe( map(({clientX, clientY}) => - getElementPoint(clientX, clientY, nativeElement), + tuiGetElementPoint(clientX, clientY, nativeElement), ), takeUntil(typedFromEvent(documentRef, `mouseup`)), ); @@ -26,7 +26,7 @@ export class TuiPickerService extends Observable { return event.target === nativeElement ? mouseMove$.pipe( startWith( - getElementPoint( + tuiGetElementPoint( event.clientX, event.clientY, nativeElement, diff --git a/projects/addon-editor/utils/get-element-point.ts b/projects/addon-editor/utils/get-element-point.ts index dfa2e05e8fb0..5c1c41e103cb 100644 --- a/projects/addon-editor/utils/get-element-point.ts +++ b/projects/addon-editor/utils/get-element-point.ts @@ -1,14 +1,8 @@ import {clamp} from '@taiga-ui/cdk'; import {TuiPoint} from '@taiga-ui/core'; -/** - * @deprecated: use {@link tuiGetElementPoint} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function getElementPoint(x: number, y: number, element: HTMLElement): TuiPoint { +export function tuiGetElementPoint(x: number, y: number, element: HTMLElement): TuiPoint { const {left, top, width, height} = element.getBoundingClientRect(); return [clamp(x - left, 0, width) / width, clamp(y - top, 0, height) / height]; } - -export const tuiGetElementPoint = getElementPoint; diff --git a/projects/addon-editor/utils/get-gradient-data.ts b/projects/addon-editor/utils/get-gradient-data.ts index aaa2748049fc..6d146812427f 100644 --- a/projects/addon-editor/utils/get-gradient-data.ts +++ b/projects/addon-editor/utils/get-gradient-data.ts @@ -1,11 +1,5 @@ -/** - * @deprecated: use {@link tuiGetGradientData} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function getGradientData(gradient: string): string { +export function tuiGetGradientData(gradient: string): string { return gradient .slice(0, Math.max(0, gradient.length - 1)) .replace(`linear-gradient(`, ``); } - -export const tuiGetGradientData = getGradientData; diff --git a/projects/addon-editor/utils/get-mark-range.ts b/projects/addon-editor/utils/get-mark-range.ts index 4958283a46da..c7657bbcb4fd 100644 --- a/projects/addon-editor/utils/get-mark-range.ts +++ b/projects/addon-editor/utils/get-mark-range.ts @@ -25,11 +25,7 @@ function findMarkInSet( ); } -/** - * @deprecated: use {@link tuiGetMarkRange} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function getMarkRange( +export function tuiGetMarkRange( pos?: ResolvedPos, type?: MarkType, attributes: Record = {}, @@ -75,5 +71,3 @@ export function getMarkRange( to: endPos, }; } - -export const tuiGetMarkRange = getMarkRange; diff --git a/projects/addon-editor/utils/hex-to-rgb.ts b/projects/addon-editor/utils/hex-to-rgb.ts index 9b4487d687c7..519e22c91865 100644 --- a/projects/addon-editor/utils/hex-to-rgb.ts +++ b/projects/addon-editor/utils/hex-to-rgb.ts @@ -1,10 +1,8 @@ /** * TODO: duplicate, need fix it before v3 * TODO: move another package for reuse between addon-editor and addon-doc - * @deprecated: use {@link tuiHexToRgb} instead */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function hexToRgb(hex: string): [number, number, number] { +export function tuiHexToRgb(hex: string): [number, number, number] { const matches = hex .replace(`#`, ``) .split(``) @@ -16,5 +14,3 @@ export function hexToRgb(hex: string): [number, number, number] { ? (matches.map(x => Number.parseInt(x, 16)) as [number, number, number]) : [0, 0, 0]; } - -export const tuiHexToRgb = hexToRgb; diff --git a/projects/addon-editor/utils/is-selection-in.ts b/projects/addon-editor/utils/is-selection-in.ts index 4de342bf7060..0a0c7d25b369 100644 --- a/projects/addon-editor/utils/is-selection-in.ts +++ b/projects/addon-editor/utils/is-selection-in.ts @@ -1,14 +1,12 @@ -import {isNodeIn} from '@taiga-ui/cdk'; +import {tuiIsNodeIn} from '@taiga-ui/cdk'; /** - * @deprecated: use {@link tuiIsSelectionIn} instead * Checks if selection is inside a specific selector * @param selection * @param selector * @return true if selection is completely inside a particular selector */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function isSelectionIn( +export function tuiIsSelectionIn( {anchorNode, focusNode}: Selection, selector: string, ): boolean { @@ -16,9 +14,7 @@ export function isSelectionIn( return ( !!anchorNode && !!focusNode && - isNodeIn(anchorNode, selector) && - isNodeIn(focusNode, selector) + tuiIsNodeIn(anchorNode, selector) && + tuiIsNodeIn(focusNode, selector) ); } - -export const tuiIsSelectionIn = isSelectionIn; diff --git a/projects/addon-editor/utils/parse-color.ts b/projects/addon-editor/utils/parse-color.ts index 8ab575dcac9c..ac0c66c57004 100644 --- a/projects/addon-editor/utils/parse-color.ts +++ b/projects/addon-editor/utils/parse-color.ts @@ -1,10 +1,6 @@ const DEFAULT: [number, number, number, number] = [0, 0, 0, 1]; -/** - * @deprecated: use {@link tuiParseColor} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function parseColor(color: string): [number, number, number, number] { +export function tuiParseColor(color: string): [number, number, number, number] { const stripped = color .replace(`#`, ``) .replace(`rgba(`, ``) @@ -37,5 +33,3 @@ export function parseColor(color: string): [number, number, number, number] { parsed[3] === undefined ? DEFAULT[3] : parsed[3], ]; } - -export const tuiParseColor = parseColor; diff --git a/projects/addon-editor/utils/parse-gradient.ts b/projects/addon-editor/utils/parse-gradient.ts index 04810c5fcefd..bfdd492012f6 100644 --- a/projects/addon-editor/utils/parse-gradient.ts +++ b/projects/addon-editor/utils/parse-gradient.ts @@ -38,11 +38,7 @@ const REGEXP_ARRAY = [ `\\s*)?`, ]; -/** - * @deprecated: use {@link tuiParseGradient} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function parseGradient(input: string): TuiParsedGradient { +export function tuiParseGradient(input: string): TuiParsedGradient { const stopsRegexp = new RegExp(REGEXP_ARRAY.join(``), `gi`); const stopsString = input.startsWith(`to`) || input.match(/^\d/) @@ -73,8 +69,6 @@ export function parseGradient(input: string): TuiParsedGradient { }; } -export const tuiParseGradient = parseGradient; - function getPosition(match: string, stops: number): string { const fallback = stops === 1 ? `100%` : `${stops}%`; diff --git a/projects/addon-editor/utils/rgb-to-hex.ts b/projects/addon-editor/utils/rgb-to-hex.ts index 09c651b30c41..fbbb6e20411b 100644 --- a/projects/addon-editor/utils/rgb-to-hex.ts +++ b/projects/addon-editor/utils/rgb-to-hex.ts @@ -1,10 +1,6 @@ /** - * @deprecated: use {@link tuiRgbToHex} instead * TODO: move another package for reuse between addon-editor and addon-doc */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function rgbToHex(r: number, g: number, b: number): string { +export function tuiRgbToHex(r: number, g: number, b: number): string { return [r, g, b].map(x => x.toString(16).padStart(2, `0`)).join(``); } - -export const tuiRgbToHex = rgbToHex; diff --git a/projects/addon-editor/utils/test/hex-to-rgb.spec.ts b/projects/addon-editor/utils/test/hex-to-rgb.spec.ts index f63ce5df481b..0a89caafe212 100644 --- a/projects/addon-editor/utils/test/hex-to-rgb.spec.ts +++ b/projects/addon-editor/utils/test/hex-to-rgb.spec.ts @@ -1,7 +1,7 @@ -import {hexToRgb} from '../hex-to-rgb'; +import {tuiHexToRgb} from '../hex-to-rgb'; -describe(`hexToRgb`, () => { +describe(`tuiHexToRgb`, () => { it(`works`, () => { - expect(hexToRgb(`2aed03`)).toEqual([42, 237, 3]); + expect(tuiHexToRgb(`2aed03`)).toEqual([42, 237, 3]); }); }); diff --git a/projects/addon-editor/utils/test/parse-color.spec.ts b/projects/addon-editor/utils/test/parse-color.spec.ts index 89e9eec69fa7..b7492e8be596 100644 --- a/projects/addon-editor/utils/test/parse-color.spec.ts +++ b/projects/addon-editor/utils/test/parse-color.spec.ts @@ -1,15 +1,15 @@ -import {parseColor} from '../parse-color'; +import {tuiParseColor} from '../parse-color'; -describe(`parseColor`, () => { +describe(`tuiParseColor`, () => { it(`test case 1`, () => { - expect(parseColor(`rgba(0, 255, 255, 1)`)).toEqual([0, 255, 255, 1]); + expect(tuiParseColor(`rgba(0, 255, 255, 1)`)).toEqual([0, 255, 255, 1]); }); it(`test case 2`, () => { - expect(parseColor(`rgb(1, 2, 3)`)).toEqual([1, 2, 3, 1]); + expect(tuiParseColor(`rgb(1, 2, 3)`)).toEqual([1, 2, 3, 1]); }); it(`test case 3`, () => { - expect(parseColor(`#ff00ff)`)).toEqual([255, 0, 255, 1]); + expect(tuiParseColor(`#ff00ff)`)).toEqual([255, 0, 255, 1]); }); }); diff --git a/projects/addon-editor/utils/test/parse-gradient.spec.ts b/projects/addon-editor/utils/test/parse-gradient.spec.ts index 9e19cf3d006b..6e72ad183a52 100644 --- a/projects/addon-editor/utils/test/parse-gradient.spec.ts +++ b/projects/addon-editor/utils/test/parse-gradient.spec.ts @@ -1,9 +1,11 @@ -import {parseGradient} from '../parse-gradient'; +import {tuiParseGradient} from '../parse-gradient'; -describe(`parseGradient`, () => { +describe(`tuiParseGradient`, () => { it(`test case 1`, () => { expect( - parseGradient(`to bottom right, rgba(0, 255, 255, 1), rgba(255, 0, 255, 0)`), + tuiParseGradient( + `to bottom right, rgba(0, 255, 255, 1), rgba(255, 0, 255, 0)`, + ), ).toEqual({ stops: [ { @@ -20,14 +22,16 @@ describe(`parseGradient`, () => { }); it(`test case 2`, () => { - expect(parseGradient(`red 10%, blue 20%`)).toEqual({ + expect(tuiParseGradient(`red 10%, blue 20%`)).toEqual({ stops: [], side: `to bottom`, }); }); it(`test case 3`, () => { - expect(parseGradient(`to top left, #ff0000 10%, rgb(0, 255, 255) 20%`)).toEqual({ + expect( + tuiParseGradient(`to top left, #ff0000 10%, rgb(0, 255, 255) 20%`), + ).toEqual({ stops: [ { color: `#ff0000`, @@ -44,7 +48,7 @@ describe(`parseGradient`, () => { it(`test case 4`, () => { expect( - parseGradient( + tuiParseGradient( `to top, #ff0000 10%, rgb(0, 255, 255) 20%, rgba(255, 0, 0, 0.1) 40%, #00ff00 100%`, ), ).toEqual({ diff --git a/projects/addon-editor/utils/test/rgb-to-hex.spec.ts b/projects/addon-editor/utils/test/rgb-to-hex.spec.ts index 6f18b041c15c..8074c555c275 100644 --- a/projects/addon-editor/utils/test/rgb-to-hex.spec.ts +++ b/projects/addon-editor/utils/test/rgb-to-hex.spec.ts @@ -1,9 +1,9 @@ -import {rgbToHex} from '../rgb-to-hex'; +import {tuiRgbToHex} from '../rgb-to-hex'; describe(`rgbToHex`, () => { it(`works`, () => { - expect(rgbToHex(10, 1, 0)).toBe(`0a0100`); - expect(rgbToHex(1, 1, 1)).toBe(`010101`); - expect(rgbToHex(42, 237, 3)).toBe(`2aed03`); + expect(tuiRgbToHex(10, 1, 0)).toBe(`0a0100`); + expect(tuiRgbToHex(1, 1, 1)).toBe(`010101`); + expect(tuiRgbToHex(42, 237, 3)).toBe(`2aed03`); }); }); diff --git a/projects/addon-editor/utils/test/to-gradient.spec.ts b/projects/addon-editor/utils/test/to-gradient.spec.ts index 5db840985966..45b9f4523a66 100644 --- a/projects/addon-editor/utils/test/to-gradient.spec.ts +++ b/projects/addon-editor/utils/test/to-gradient.spec.ts @@ -1,9 +1,9 @@ -import {toGradient} from '../to-gradient'; +import {tuiToGradient} from '../to-gradient'; -describe(`toGradient`, () => { +describe(`tuiToGradient`, () => { it(`test case 1`, () => { expect( - toGradient({ + tuiToGradient({ stops: [ { color: `rgba(0, 255, 0, 1)`, @@ -23,7 +23,7 @@ describe(`toGradient`, () => { it(`test case 2`, () => { expect( - toGradient({ + tuiToGradient({ stops: [ { color: `rgb(42, 237, 0)`, diff --git a/projects/addon-editor/utils/to-gradient.ts b/projects/addon-editor/utils/to-gradient.ts index cd6c4c1996ab..447ac69dc03d 100644 --- a/projects/addon-editor/utils/to-gradient.ts +++ b/projects/addon-editor/utils/to-gradient.ts @@ -1,15 +1,11 @@ import {TuiParsedGradient} from '@taiga-ui/addon-editor/interfaces'; -import {parseColor} from './parse-color'; +import {tuiParseColor} from './parse-color'; -/** - * @deprecated: use {@link tuiToGradient} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function toGradient({stops, side}: TuiParsedGradient): string { +export function tuiToGradient({stops, side}: TuiParsedGradient): string { return `linear-gradient(${side}, ${stops - .map(({color, position}) => `rgba(${parseColor(color).join(`, `)}) ${position}`) + .map( + ({color, position}) => `rgba(${tuiParseColor(color).join(`, `)}) ${position}`, + ) .join(`, `)})`; } - -export const tuiToGradient = toGradient; diff --git a/projects/addon-mobile/components/mobile-calendar/mobile-calendar.providers.ts b/projects/addon-mobile/components/mobile-calendar/mobile-calendar.providers.ts index b9f59633bc94..fae2a3bbbe30 100644 --- a/projects/addon-mobile/components/mobile-calendar/mobile-calendar.providers.ts +++ b/projects/addon-mobile/components/mobile-calendar/mobile-calendar.providers.ts @@ -5,7 +5,7 @@ import { TuiDayRange, TuiDestroyService, TuiScrollService, - watch, + tuiWatch, } from '@taiga-ui/cdk'; import {TUI_CALENDAR_DATA_STREAM} from '@taiga-ui/kit'; import {EMPTY, Observable} from 'rxjs'; @@ -41,5 +41,5 @@ export function valueStreamFactory( destroy$: Observable, changeDetectorRef: ChangeDetectorRef, ): Observable { - return (value$ || EMPTY).pipe(watch(changeDetectorRef), takeUntil(destroy$)); + return (value$ || EMPTY).pipe(tuiWatch(changeDetectorRef), takeUntil(destroy$)); } diff --git a/projects/addon-mobile/directives/elastic-sticky/elastic-sticky.service.ts b/projects/addon-mobile/directives/elastic-sticky/elastic-sticky.service.ts index e4674872daa6..da6e2a9e2558 100644 --- a/projects/addon-mobile/directives/elastic-sticky/elastic-sticky.service.ts +++ b/projects/addon-mobile/directives/elastic-sticky/elastic-sticky.service.ts @@ -1,8 +1,8 @@ import {ElementRef, Inject, Injectable, NgZone, Optional} from '@angular/core'; import {WINDOW} from '@ng-web-apis/common'; import { - getElementOffset, TuiDestroyService, + tuiGetElementOffset, tuiZoneOptimized, typedFromEvent, } from '@taiga-ui/cdk'; @@ -73,7 +73,7 @@ export class TuiElasticStickyService extends Observable { private getInitialOffset(host: Element | Window, element: HTMLElement): number { // TODO: iframe warning return host instanceof Element - ? getElementOffset(host, element).offsetTop + ? tuiGetElementOffset(host, element).offsetTop : element.getBoundingClientRect().top; } } diff --git a/projects/addon-preview/components/preview/preview.component.ts b/projects/addon-preview/components/preview/preview.component.ts index 7c4c4fe0b6d9..7be69e64f621 100644 --- a/projects/addon-preview/components/preview/preview.component.ts +++ b/projects/addon-preview/components/preview/preview.component.ts @@ -8,9 +8,9 @@ import { import {TUI_PREVIEW_TEXTS} from '@taiga-ui/addon-preview/tokens'; import { clamp, - dragAndDropFrom, tuiDefaultProp, TuiDestroyService, + tuiDragAndDropFrom, TuiDragStage, tuiPx, tuiRound, @@ -55,7 +55,7 @@ export class TuiPreviewComponent { ); readonly transitioned$ = merge( - dragAndDropFrom(this.elementRef.nativeElement).pipe( + tuiDragAndDropFrom(this.elementRef.nativeElement).pipe( map(({stage}) => stage !== TuiDragStage.Continues), ), typedFromEvent(this.elementRef.nativeElement, `touchmove`, {passive: true}).pipe( @@ -66,7 +66,7 @@ export class TuiPreviewComponent { ), ); - readonly cursor$ = dragAndDropFrom(this.elementRef.nativeElement).pipe( + readonly cursor$ = tuiDragAndDropFrom(this.elementRef.nativeElement).pipe( map(({stage}) => (stage === TuiDragStage.Continues ? `grabbing` : `initial`)), startWith(`initial`), ); diff --git a/projects/addon-table/components/table/directives/resized.directive.ts b/projects/addon-table/components/table/directives/resized.directive.ts index 599ec18a5525..5dda0cf626df 100644 --- a/projects/addon-table/components/table/directives/resized.directive.ts +++ b/projects/addon-table/components/table/directives/resized.directive.ts @@ -1,6 +1,6 @@ import {DOCUMENT} from '@angular/common'; import {Directive, ElementRef, Inject, Output} from '@angular/core'; -import {preventDefault, typedFromEvent} from '@taiga-ui/cdk'; +import {tuiPreventDefault, typedFromEvent} from '@taiga-ui/cdk'; import {TUI_ELEMENT_REF} from '@taiga-ui/core'; import {distinctUntilChanged, map, switchMap, takeUntil} from 'rxjs/operators'; @@ -10,7 +10,7 @@ import {distinctUntilChanged, map, switchMap, takeUntil} from 'rxjs/operators'; export class TuiResizedDirective { @Output() readonly tuiResized = typedFromEvent(this.elementRef.nativeElement, `mousedown`).pipe( - preventDefault(), + tuiPreventDefault(), switchMap(() => { const {width, right} = this.parentRef.nativeElement.getBoundingClientRect(); diff --git a/projects/addon-table/components/table/th/th.component.ts b/projects/addon-table/components/table/th/th.component.ts index a33714d22ac6..01f173b1f3f4 100644 --- a/projects/addon-table/components/table/th/th.component.ts +++ b/projects/addon-table/components/table/th/th.component.ts @@ -9,7 +9,7 @@ import { Optional, } from '@angular/core'; import {TuiComparator} from '@taiga-ui/addon-table/types'; -import {defaultSort} from '@taiga-ui/addon-table/utils'; +import {tuiDefaultSort} from '@taiga-ui/addon-table/utils'; import {tuiDefaultProp, TuiTableSortKeyException} from '@taiga-ui/cdk'; import {TUI_ELEMENT_REF} from '@taiga-ui/core'; @@ -32,7 +32,7 @@ export class TuiThComponent { @Input() @tuiDefaultProp() sorter: TuiComparator | null = this.head - ? (a, b) => defaultSort(a[this.key], b[this.key]) + ? (a, b) => tuiDefaultSort(a[this.key], b[this.key]) : null; @Input() diff --git a/projects/addon-table/utils/default-sort.ts b/projects/addon-table/utils/default-sort.ts index ec4199b527f1..e77298bae652 100644 --- a/projects/addon-table/utils/default-sort.ts +++ b/projects/addon-table/utils/default-sort.ts @@ -1,10 +1,6 @@ import {TuiDay, tuiIsString} from '@taiga-ui/cdk'; -/** - * @deprecated: use {@link tuiDefaultSort} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function defaultSort(x: T, y: T): number { +export function tuiDefaultSort(x: T, y: T): number { const a = x instanceof TuiDay ? Number(x.toUtcNativeDate()) : x; const b = y instanceof TuiDay ? Number(y.toUtcNativeDate()) : y; @@ -18,5 +14,3 @@ export function defaultSort(x: T, y: T): number { return a > b ? 1 : -1; } - -export const tuiDefaultSort = defaultSort; diff --git a/projects/cdk/directives/drag/drag.directive.ts b/projects/cdk/directives/drag/drag.directive.ts index 937f966d5446..6b7201b2075d 100644 --- a/projects/cdk/directives/drag/drag.directive.ts +++ b/projects/cdk/directives/drag/drag.directive.ts @@ -1,5 +1,5 @@ import {Directive, ElementRef, Inject, Output} from '@angular/core'; -import {dragAndDropFrom, TuiDragStage} from '@taiga-ui/cdk/observables'; +import {tuiDragAndDropFrom, TuiDragStage} from '@taiga-ui/cdk/observables'; import {Observable} from 'rxjs'; import {filter, map} from 'rxjs/operators'; @@ -7,7 +7,7 @@ import {filter, map} from 'rxjs/operators'; selector: `[tuiDragStart], [tuiDragContinues], [tuiDragEnd]`, }) export class TuiDragDirective { - private readonly dragAndDropFrom$ = dragAndDropFrom(this.elementRef.nativeElement); + private readonly dragAndDropFrom$ = tuiDragAndDropFrom(this.elementRef.nativeElement); @Output(`tuiDragStart`) readonly start: Observable = this.dragAndDropFrom$.pipe( diff --git a/projects/cdk/directives/droppable/droppable.directive.ts b/projects/cdk/directives/droppable/droppable.directive.ts index 65bf9b012733..c261dc015b7f 100644 --- a/projects/cdk/directives/droppable/droppable.directive.ts +++ b/projects/cdk/directives/droppable/droppable.directive.ts @@ -1,5 +1,5 @@ import {Directive, ElementRef, Inject, Output} from '@angular/core'; -import {preventDefault, typedFromEvent} from '@taiga-ui/cdk/observables'; +import {tuiPreventDefault, typedFromEvent} from '@taiga-ui/cdk/observables'; import {TuiDestroyService} from '@taiga-ui/cdk/services'; import {isPresent} from '@taiga-ui/cdk/utils/miscellaneous'; import {merge, Observable} from 'rxjs'; @@ -29,7 +29,7 @@ export class TuiDroppableDirective { @Inject(TuiDestroyService) destroy$: Observable, ) { this.tuiDroppableDropped = typedFromEvent(nativeElement, `drop`).pipe( - preventDefault(), + tuiPreventDefault(), map(event => event.dataTransfer), filter(isPresent), ); @@ -48,7 +48,7 @@ export class TuiDroppableDirective { // Required by Drag and Drop API to stop redirecting typedFromEvent(nativeElement, `dragover`) - .pipe(preventDefault(), takeUntil(destroy$)) + .pipe(tuiPreventDefault(), takeUntil(destroy$)) .subscribe(); } } diff --git a/projects/cdk/directives/focus-trap/focus-trap.directive.ts b/projects/cdk/directives/focus-trap/focus-trap.directive.ts index d55f5901d6df..2fd2dc18e1ba 100644 --- a/projects/cdk/directives/focus-trap/focus-trap.directive.ts +++ b/projects/cdk/directives/focus-trap/focus-trap.directive.ts @@ -7,7 +7,7 @@ import { OnDestroy, Renderer2, } from '@angular/core'; -import {containsOrAfter} from '@taiga-ui/cdk/utils/dom'; +import {tuiContainsOrAfter} from '@taiga-ui/cdk/utils/dom'; import { blurNativeFocused, setNativeFocused, @@ -48,7 +48,7 @@ export class TuiFocusTrapDirective implements OnDestroy { @HostListener(`window:focusin.silent`, [`$event.target`]) onFocusIn(node: Node): void { - if (containsOrAfter(this.elementRef.nativeElement, node)) { + if (tuiContainsOrAfter(this.elementRef.nativeElement, node)) { return; } diff --git a/projects/cdk/directives/overscroll/overscroll.directive.ts b/projects/cdk/directives/overscroll/overscroll.directive.ts index e2d629442c05..85420a87a238 100644 --- a/projects/cdk/directives/overscroll/overscroll.directive.ts +++ b/projects/cdk/directives/overscroll/overscroll.directive.ts @@ -2,7 +2,7 @@ import {Directive, ElementRef, HostBinding, Inject, Input, NgZone} from '@angula import {tuiZonefree, typedFromEvent} from '@taiga-ui/cdk/observables'; import {TuiDestroyService} from '@taiga-ui/cdk/services'; import {TuiEventWith, TuiOverscrollMode} from '@taiga-ui/cdk/types'; -import {canScroll, getScrollParent} from '@taiga-ui/cdk/utils/dom'; +import {tuiCanScroll, tuiGetScrollParent} from '@taiga-ui/cdk/utils/dom'; import {Observable} from 'rxjs'; import {filter, switchMap, takeUntil, tap} from 'rxjs/operators'; @@ -103,8 +103,8 @@ export class TuiOverscrollDirective { // This is all what's needed in Chrome/Firefox thanks to CSS overscroll-behavior if ( this.mode === `all` && - ((vertical && !currentTarget.contains(getScrollParent(target))) || - (!vertical && !currentTarget.contains(getScrollParent(target, false)))) + ((vertical && !currentTarget.contains(tuiGetScrollParent(target))) || + (!vertical && !currentTarget.contains(tuiGetScrollParent(target, false)))) ) { event.preventDefault(); @@ -114,8 +114,8 @@ export class TuiOverscrollDirective { // This is Safari/IE/Edge fallback if ( vertical && - ((negative && !canScroll(target, currentTarget, true, false)) || - (!negative && !canScroll(target, currentTarget, true, true))) + ((negative && !tuiCanScroll(target, currentTarget, true, false)) || + (!negative && !tuiCanScroll(target, currentTarget, true, true))) ) { event.preventDefault(); @@ -124,8 +124,8 @@ export class TuiOverscrollDirective { if ( !vertical && - ((negative && !canScroll(target, currentTarget, false, false)) || - (!negative && !canScroll(target, currentTarget, false, true))) + ((negative && !tuiCanScroll(target, currentTarget, false, false)) || + (!negative && !tuiCanScroll(target, currentTarget, false, true))) ) { event.preventDefault(); } diff --git a/projects/cdk/directives/pressed/pressed.directive.ts b/projects/cdk/directives/pressed/pressed.directive.ts index 8222b79fc52a..462e61263433 100644 --- a/projects/cdk/directives/pressed/pressed.directive.ts +++ b/projects/cdk/directives/pressed/pressed.directive.ts @@ -1,5 +1,5 @@ import {Directive, ElementRef, Inject, Output} from '@angular/core'; -import {pressedObservable} from '@taiga-ui/cdk/observables'; +import {tuiPressedObservable} from '@taiga-ui/cdk/observables'; import {TUI_TAKE_ONLY_TRUSTED_EVENTS} from '@taiga-ui/cdk/tokens'; @Directive({ @@ -7,7 +7,7 @@ import {TUI_TAKE_ONLY_TRUSTED_EVENTS} from '@taiga-ui/cdk/tokens'; }) export class TuiPressedDirective { @Output() - readonly tuiPressedChange = pressedObservable(this.elementRef.nativeElement, { + readonly tuiPressedChange = tuiPressedObservable(this.elementRef.nativeElement, { onlyTrusted: this.takeOnlyTrustedEvents, }); diff --git a/projects/cdk/directives/prevent-default/prevent-default.directive.ts b/projects/cdk/directives/prevent-default/prevent-default.directive.ts index 98c25e81fd27..1344a1c77010 100644 --- a/projects/cdk/directives/prevent-default/prevent-default.directive.ts +++ b/projects/cdk/directives/prevent-default/prevent-default.directive.ts @@ -1,5 +1,5 @@ import {Attribute, Directive, ElementRef, Inject, NgZone} from '@angular/core'; -import {preventDefault, tuiZonefree} from '@taiga-ui/cdk/observables'; +import {tuiPreventDefault, tuiZonefree} from '@taiga-ui/cdk/observables'; import {TuiDestroyService} from '@taiga-ui/cdk/services'; import {fromEvent, Observable} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; @@ -20,7 +20,7 @@ export class TuiPreventDefaultDirective { @Attribute(`tuiPreventDefault`) eventName: string, ) { fromEvent(nativeElement, eventName, {passive: false}) - .pipe(tuiZonefree(ngZone), preventDefault(), takeUntil(destroy$)) + .pipe(tuiZonefree(ngZone), tuiPreventDefault(), takeUntil(destroy$)) .subscribe(); } } diff --git a/projects/cdk/observables/drag-and-drop-from.ts b/projects/cdk/observables/drag-and-drop-from.ts index 376860d06cfb..379e20893a28 100644 --- a/projects/cdk/observables/drag-and-drop-from.ts +++ b/projects/cdk/observables/drag-and-drop-from.ts @@ -3,7 +3,7 @@ import {isPresent} from '@taiga-ui/cdk/utils/miscellaneous'; import {concat, merge, Observable} from 'rxjs'; import {endWith, map, repeat, take, takeWhile} from 'rxjs/operators'; -import {mouseDragFinishFrom} from './mouse-drag-finish-from'; +import {tuiMouseDragFinishFrom} from './mouse-drag-finish-from'; import {typedFromEvent} from './typed-from-event'; export const enum TuiDragStage { @@ -16,11 +16,7 @@ export class TuiDragState { constructor(readonly stage: TuiDragStage, readonly event: MouseEvent) {} } -/** - * @deprecated: use {@link tuiDragAndDropFrom} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function dragAndDropFrom(element: Element): Observable { +export function tuiDragAndDropFrom(element: Element): Observable { const {ownerDocument} = element; if (!ownerDocument) { @@ -36,7 +32,7 @@ export function dragAndDropFrom(element: Element): Observable { typedFromEvent(ownerDocument, `mousemove`).pipe( map(event => new TuiDragState(TuiDragStage.Continues, event)), ), - mouseDragFinishFrom(ownerDocument).pipe( + tuiMouseDragFinishFrom(ownerDocument).pipe( take(1), map(event => new TuiDragState(TuiDragStage.End, event)), endWith(null), @@ -44,5 +40,3 @@ export function dragAndDropFrom(element: Element): Observable { ).pipe(takeWhile(isPresent)), ).pipe(repeat()); } - -export const tuiDragAndDropFrom = dragAndDropFrom; diff --git a/projects/cdk/observables/focus-visible-observable.ts b/projects/cdk/observables/focus-visible-observable.ts index 47aa2c48b5e7..1829c0922455 100644 --- a/projects/cdk/observables/focus-visible-observable.ts +++ b/projects/cdk/observables/focus-visible-observable.ts @@ -20,11 +20,7 @@ import {typedFromEvent} from './typed-from-event'; let documentMouseUpIsAlive$: Observable; let documentMouseDownIsAlive$: Observable; -/** - * @deprecated: use {@link tuiFocusVisibleObservable} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function focusVisibleObservable(element: Element): Observable { +export function tuiFocusVisibleObservable(element: Element): Observable { const elementBlur$ = typedFromEvent(element, `blur`); const {ownerDocument} = element; @@ -74,5 +70,3 @@ export function focusVisibleObservable(element: Element): Observable { distinctUntilChanged(), ); } - -export const tuiFocusVisibleObservable = focusVisibleObservable; diff --git a/projects/cdk/observables/items-query-list-observable.ts b/projects/cdk/observables/items-query-list-observable.ts index 8ee6d8420770..558332b57aae 100644 --- a/projects/cdk/observables/items-query-list-observable.ts +++ b/projects/cdk/observables/items-query-list-observable.ts @@ -4,11 +4,9 @@ import {Observable} from 'rxjs'; import {map, startWith} from 'rxjs/operators'; /** - * @deprecated: use {@link tuiItemsQueryListObservable} instead * Converts changes observable of a QueryList to an Observable of arrays */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function itemsQueryListObservable( +export function tuiItemsQueryListObservable( queryList: QueryList, ): Observable { return queryList.changes.pipe( @@ -16,5 +14,3 @@ export function itemsQueryListObservable( startWith(getOriginalArrayFromQueryList(queryList)), ); } - -export const tuiItemsQueryListObservable = itemsQueryListObservable; diff --git a/projects/cdk/observables/mouse-drag-finish-from.ts b/projects/cdk/observables/mouse-drag-finish-from.ts index c61c86663419..e0633d2f9745 100644 --- a/projects/cdk/observables/mouse-drag-finish-from.ts +++ b/projects/cdk/observables/mouse-drag-finish-from.ts @@ -4,15 +4,11 @@ import {merge, Observable} from 'rxjs'; import {typedFromEvent} from './typed-from-event'; /** - * @deprecated: use {@link tuiMouseDragFinishFrom} instead * Letting go of the mouse after it was pressed * @param target */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function mouseDragFinishFrom< +export function tuiMouseDragFinishFrom< T extends TuiTypedEventTarget>, >(target: Exclude): Observable> { return merge(typedFromEvent(target, `mouseup`), typedFromEvent(target, `dragend`)); } - -export const tuiMouseDragFinishFrom = mouseDragFinishFrom; diff --git a/projects/cdk/observables/must-be-present.ts b/projects/cdk/observables/must-be-present.ts index 2be860fa8045..4edb97764bde 100644 --- a/projects/cdk/observables/must-be-present.ts +++ b/projects/cdk/observables/must-be-present.ts @@ -3,11 +3,7 @@ import {isPresent} from '@taiga-ui/cdk/utils/miscellaneous'; import {OperatorFunction} from 'rxjs'; import {map} from 'rxjs/operators'; -/** - * @deprecated: use {@link tuiMustBePresent} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function mustBePresent(): OperatorFunction { +export function tuiMustBePresent(): OperatorFunction { return map(value => { if (!isPresent(value)) { throw new TuiValuePresentException(); @@ -16,5 +12,3 @@ export function mustBePresent(): OperatorFunction { return value; }); } - -export const tuiMustBePresent = mustBePresent; diff --git a/projects/cdk/observables/pressed-observable.ts b/projects/cdk/observables/pressed-observable.ts index f50b8e90c45a..e3779837e621 100644 --- a/projects/cdk/observables/pressed-observable.ts +++ b/projects/cdk/observables/pressed-observable.ts @@ -2,18 +2,14 @@ import {TuiOwnerDocumentException} from '@taiga-ui/cdk/exceptions'; import {Observable} from 'rxjs'; import {filter, mapTo, startWith, switchMapTo, take} from 'rxjs/operators'; -import {mouseDragFinishFrom} from './mouse-drag-finish-from'; +import {tuiMouseDragFinishFrom} from './mouse-drag-finish-from'; import {typedFromEvent} from './typed-from-event'; export interface TuiPressedObservableOptions { onlyTrusted: boolean; } -/** - * @deprecated: use {@link tuiPressedObservable} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function pressedObservable( +export function tuiPressedObservable( element: Element, {onlyTrusted}: TuiPressedObservableOptions = {onlyTrusted: true}, ): Observable { @@ -26,7 +22,7 @@ export function pressedObservable( return typedFromEvent(element, `mousedown`).pipe( filter(({isTrusted}) => isTrusted || !onlyTrusted), switchMapTo( - mouseDragFinishFrom(ownerDocument).pipe( + tuiMouseDragFinishFrom(ownerDocument).pipe( mapTo(false), take(1), startWith(true), @@ -34,5 +30,3 @@ export function pressedObservable( ), ); } - -export const tuiPressedObservable = pressedObservable; diff --git a/projects/cdk/observables/prevent-default.ts b/projects/cdk/observables/prevent-default.ts index 7b5d560dc286..c34618872862 100644 --- a/projects/cdk/observables/prevent-default.ts +++ b/projects/cdk/observables/prevent-default.ts @@ -1,12 +1,6 @@ import {MonoTypeOperatorFunction} from 'rxjs'; import {tap} from 'rxjs/operators'; -/** - * @deprecated: use {@link tuiPreventDefault} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function preventDefault(): MonoTypeOperatorFunction { +export function tuiPreventDefault(): MonoTypeOperatorFunction { return tap(event => event.preventDefault()); } - -export const tuiPreventDefault = preventDefault; diff --git a/projects/cdk/observables/stop-propagation.ts b/projects/cdk/observables/stop-propagation.ts index 76cb7b461b18..f3fbdf75d72a 100644 --- a/projects/cdk/observables/stop-propagation.ts +++ b/projects/cdk/observables/stop-propagation.ts @@ -1,14 +1,8 @@ import {MonoTypeOperatorFunction} from 'rxjs'; import {tap} from 'rxjs/operators'; -/** - * @deprecated: use {@link tuiStopPropagation} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function stopPropagation(): MonoTypeOperatorFunction { +export function tuiStopPropagation(): MonoTypeOperatorFunction { return tap(e => { e.stopPropagation(); }); } - -export const tuiStopPropagation = stopPropagation; diff --git a/projects/cdk/observables/test/drag-and-drop.spec.ts b/projects/cdk/observables/test/drag-and-drop.spec.ts index f485c54f8fe0..89011c744942 100644 --- a/projects/cdk/observables/test/drag-and-drop.spec.ts +++ b/projects/cdk/observables/test/drag-and-drop.spec.ts @@ -1,13 +1,13 @@ -import {dragAndDropFrom, TuiDragStage} from '@taiga-ui/cdk'; +import {tuiDragAndDropFrom, TuiDragStage} from '@taiga-ui/cdk'; import {skip, take} from 'rxjs/operators'; -describe(`dragAndDropFrom`, () => { +describe(`tuiDragAndDropFrom`, () => { it(`throws an error if there is no document`, () => { let result: unknown; const element: Element = {ownerDocument: undefined} as unknown as Element; try { - dragAndDropFrom(element).subscribe(); + tuiDragAndDropFrom(element).subscribe(); } catch (e) { result = e; } @@ -19,7 +19,7 @@ describe(`dragAndDropFrom`, () => { let result: unknown; const element = document.createElement(`div`); - dragAndDropFrom(element) + tuiDragAndDropFrom(element) .pipe(take(1)) .subscribe(event => { result = event.stage; @@ -34,7 +34,7 @@ describe(`dragAndDropFrom`, () => { let result: unknown; const element = document.createElement(`div`); - dragAndDropFrom(element) + tuiDragAndDropFrom(element) .pipe(skip(1), take(1)) .subscribe(event => { result = event.stage; @@ -49,7 +49,7 @@ describe(`dragAndDropFrom`, () => { let result: unknown; const element = document.createElement(`div`); - dragAndDropFrom(element) + tuiDragAndDropFrom(element) .pipe(skip(2), take(1)) .subscribe(event => { result = event.stage; diff --git a/projects/cdk/observables/test/items-query-list-observable.spec.ts b/projects/cdk/observables/test/items-query-list-observable.spec.ts index 91f409bc89c7..463e9fb32f5e 100644 --- a/projects/cdk/observables/test/items-query-list-observable.spec.ts +++ b/projects/cdk/observables/test/items-query-list-observable.spec.ts @@ -1,8 +1,8 @@ import {QueryList} from '@angular/core'; -import {itemsQueryListObservable} from '../items-query-list-observable'; +import {tuiItemsQueryListObservable} from '../items-query-list-observable'; -describe(`itemsQueryListObservable`, () => { +describe(`tuiItemsQueryListObservable`, () => { let queryList: QueryList; beforeEach(() => { @@ -13,7 +13,7 @@ describe(`itemsQueryListObservable`, () => { it(`emits current array on subscription`, () => { let result: readonly number[] | null = null; - itemsQueryListObservable(queryList).subscribe(data => { + tuiItemsQueryListObservable(queryList).subscribe(data => { result = data; }); @@ -23,7 +23,7 @@ describe(`itemsQueryListObservable`, () => { it(`emits new array on changes`, () => { let result: readonly number[] | null = null; - itemsQueryListObservable(queryList).subscribe(data => { + tuiItemsQueryListObservable(queryList).subscribe(data => { result = data; }); diff --git a/projects/cdk/observables/test/must-be-present.spec.ts b/projects/cdk/observables/test/must-be-present.spec.ts index b72b784ab21d..32cad2546ef1 100644 --- a/projects/cdk/observables/test/must-be-present.spec.ts +++ b/projects/cdk/observables/test/must-be-present.spec.ts @@ -1,13 +1,13 @@ import {fakeAsync, tick} from '@angular/core/testing'; -import {mustBePresent} from '@taiga-ui/cdk/observables/must-be-present'; +import {tuiMustBePresent} from '@taiga-ui/cdk/observables/must-be-present'; import {Subject} from 'rxjs'; import {first} from 'rxjs/operators'; -describe(`mustBePresent operator function`, () => { +describe(`tuiMustBePresent operator function`, () => { it(`not throws on NaN`, fakeAsync(() => { const stream = new Subject(); - stream.pipe(first(), mustBePresent()).subscribe(); + stream.pipe(first(), tuiMustBePresent()).subscribe(); expect(() => { stream.next(NaN); @@ -18,7 +18,7 @@ describe(`mustBePresent operator function`, () => { it(`not throws on 0`, fakeAsync(() => { const stream = new Subject(); - stream.pipe(first(), mustBePresent()).subscribe(); + stream.pipe(first(), tuiMustBePresent()).subscribe(); expect(() => { stream.next(0); @@ -29,7 +29,7 @@ describe(`mustBePresent operator function`, () => { it(`not throws on false`, fakeAsync(() => { const stream = new Subject(); - stream.pipe(first(), mustBePresent()).subscribe(); + stream.pipe(first(), tuiMustBePresent()).subscribe(); expect(() => { stream.next(false); @@ -40,7 +40,7 @@ describe(`mustBePresent operator function`, () => { it(`not throws on empty string`, fakeAsync(() => { const stream = new Subject(); - stream.pipe(first(), mustBePresent()).subscribe(); + stream.pipe(first(), tuiMustBePresent()).subscribe(); expect(() => { stream.next(``); @@ -51,7 +51,7 @@ describe(`mustBePresent operator function`, () => { it(`throws on undefined`, fakeAsync(() => { const stream = new Subject(); - stream.pipe(first(), mustBePresent()).subscribe(); + stream.pipe(first(), tuiMustBePresent()).subscribe(); expect(() => { stream.next(undefined); @@ -62,7 +62,7 @@ describe(`mustBePresent operator function`, () => { it(`throws on null`, fakeAsync(() => { const stream = new Subject(); - stream.pipe(first(), mustBePresent()).subscribe(); + stream.pipe(first(), tuiMustBePresent()).subscribe(); expect(() => { stream.next(null); diff --git a/projects/cdk/observables/test/presssed-observable.spec.ts b/projects/cdk/observables/test/presssed-observable.spec.ts index 24903b6342c1..b890233e4e4e 100644 --- a/projects/cdk/observables/test/presssed-observable.spec.ts +++ b/projects/cdk/observables/test/presssed-observable.spec.ts @@ -1,5 +1,5 @@ import {fakeAsync} from '@angular/core/testing'; -import {pressedObservable} from '@taiga-ui/cdk/observables'; +import {tuiPressedObservable} from '@taiga-ui/cdk/observables'; describe(`pressedObservable operator function`, () => { const element: Element = document.createElement(`div`); @@ -7,7 +7,7 @@ describe(`pressedObservable operator function`, () => { it(`expected only trusted mousedown events without parameters`, () => { let result: boolean | null = null; - pressedObservable(element).subscribe((pressed: boolean) => { + tuiPressedObservable(element).subscribe((pressed: boolean) => { result = pressed; }); @@ -18,9 +18,11 @@ describe(`pressedObservable operator function`, () => { it(`expected any mousedown events`, fakeAsync(() => { let result: boolean | null = null; - pressedObservable(element, {onlyTrusted: false}).subscribe((pressed: boolean) => { - result = pressed; - }); + tuiPressedObservable(element, {onlyTrusted: false}).subscribe( + (pressed: boolean) => { + result = pressed; + }, + ); fireMousedownEvent(); expect(result).toBeTruthy(); diff --git a/projects/cdk/observables/test/prevent-default.spec.ts b/projects/cdk/observables/test/prevent-default.spec.ts index f099d21fd3ba..f36a4007fee3 100644 --- a/projects/cdk/observables/test/prevent-default.spec.ts +++ b/projects/cdk/observables/test/prevent-default.spec.ts @@ -2,14 +2,14 @@ import {fakeAsync} from '@angular/core/testing'; import {Subject} from 'rxjs'; import {first} from 'rxjs/operators'; -import {preventDefault} from '../prevent-default'; +import {tuiPreventDefault} from '../prevent-default'; describe(`preventDefault operator function`, () => { it(`prevents event default behavior`, fakeAsync(() => { const event = new Event(`click`, {cancelable: true}); const subject = new Subject(); - subject.pipe(preventDefault(), first()).subscribe(); + subject.pipe(tuiPreventDefault(), first()).subscribe(); subject.next(event); expect(event.defaultPrevented).toBe(true); diff --git a/projects/cdk/observables/test/stop-propagation.spec.ts b/projects/cdk/observables/test/stop-propagation.spec.ts index 5a687355d4a7..1d76d4bcd425 100644 --- a/projects/cdk/observables/test/stop-propagation.spec.ts +++ b/projects/cdk/observables/test/stop-propagation.spec.ts @@ -2,14 +2,14 @@ import {fakeAsync} from '@angular/core/testing'; import {Subject} from 'rxjs'; import {first} from 'rxjs/operators'; -import {stopPropagation} from '../stop-propagation'; +import {tuiStopPropagation} from '../stop-propagation'; -describe(`stopPropagation operator function`, () => { +describe(`tuiStopPropagation operator function`, () => { it(`stops event propagation`, fakeAsync(() => { const event = new Event(`click`); const subject = new Subject(); - subject.pipe(stopPropagation(), first()).subscribe(); + subject.pipe(tuiStopPropagation(), first()).subscribe(); subject.next(event); expect(event.cancelBubble).toBe(true); diff --git a/projects/cdk/observables/test/watch.spec.ts b/projects/cdk/observables/test/watch.spec.ts index 292d41ea02c3..f8f8da616be9 100644 --- a/projects/cdk/observables/test/watch.spec.ts +++ b/projects/cdk/observables/test/watch.spec.ts @@ -2,9 +2,9 @@ import {ChangeDetectorRef} from '@angular/core'; import {fakeAsync, tick} from '@angular/core/testing'; import {Subject} from 'rxjs'; -import {watch} from '../watch'; +import {tuiWatch} from '../watch'; -describe(`Watch operator function`, () => { +describe(`tuiWatch operator function`, () => { let $: Subject; let called = 0; @@ -18,7 +18,7 @@ describe(`Watch operator function`, () => { }); it(`initially emits nothing, after event emits "true" and after a tick emits "false"`, fakeAsync(() => { - $.pipe(watch(chrStub)).subscribe(); + $.pipe(tuiWatch(chrStub)).subscribe(); $.next(); tick(); diff --git a/projects/cdk/observables/watch.ts b/projects/cdk/observables/watch.ts index c3e777c73e72..45fe7b79b8ec 100644 --- a/projects/cdk/observables/watch.ts +++ b/projects/cdk/observables/watch.ts @@ -2,16 +2,10 @@ import {ChangeDetectorRef} from '@angular/core'; import {MonoTypeOperatorFunction} from 'rxjs'; import {tap} from 'rxjs/operators'; -/** - * @deprecated: use {@link tuiWatch} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function watch( +export function tuiWatch( changeDetectorRef: ChangeDetectorRef, ): MonoTypeOperatorFunction { return tap(() => { changeDetectorRef.markForCheck(); }); } - -export const tuiWatch = watch; diff --git a/projects/cdk/services/focus-visible.service.ts b/projects/cdk/services/focus-visible.service.ts index 7464a06aece6..3ddc4487f3c8 100644 --- a/projects/cdk/services/focus-visible.service.ts +++ b/projects/cdk/services/focus-visible.service.ts @@ -1,5 +1,5 @@ import {ChangeDetectorRef, ElementRef, Inject, Injectable} from '@angular/core'; -import {focusVisibleObservable, watch} from '@taiga-ui/cdk/observables'; +import {tuiFocusVisibleObservable, tuiWatch} from '@taiga-ui/cdk/observables'; import {Observable} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; @@ -21,8 +21,8 @@ export class TuiFocusVisibleService extends Observable { ) { super(subscriber => this.focusVisible$.subscribe(subscriber)); - this.focusVisible$ = focusVisibleObservable(nativeElement).pipe( - watch(changeDetectorRef), + this.focusVisible$ = tuiFocusVisibleObservable(nativeElement).pipe( + tuiWatch(changeDetectorRef), takeUntil(destroy$), ); } diff --git a/projects/cdk/services/obscured.service.ts b/projects/cdk/services/obscured.service.ts index fa0235a02dab..18ed0ef434a2 100644 --- a/projects/cdk/services/obscured.service.ts +++ b/projects/cdk/services/obscured.service.ts @@ -2,7 +2,7 @@ import {ElementRef, Inject, Injectable, NgZone, Self} from '@angular/core'; import {ANIMATION_FRAME, WINDOW} from '@ng-web-apis/common'; import {POLLING_TIME} from '@taiga-ui/cdk/constants'; import {tuiZoneOptimized} from '@taiga-ui/cdk/observables'; -import {getElementObscurers} from '@taiga-ui/cdk/utils/dom'; +import {tuiGetElementObscures} from '@taiga-ui/cdk/utils/dom'; import {fromEvent, merge, Observable} from 'rxjs'; import { delay, @@ -43,7 +43,7 @@ export class TuiObscuredService extends Observable { merge(parentsScroll$, fromEvent(windowRef, `resize`)).pipe(delay(0)), animationFrame$.pipe(throttleTime(POLLING_TIME)), ).pipe( - map(() => getElementObscurers(nativeElement)), + map(() => tuiGetElementObscures(nativeElement)), startWith(null), distinctUntilChanged(), tuiZoneOptimized(ngZone), diff --git a/projects/cdk/services/zoom.service.ts b/projects/cdk/services/zoom.service.ts index 99e0fbbe8560..25b87a1fea2c 100644 --- a/projects/cdk/services/zoom.service.ts +++ b/projects/cdk/services/zoom.service.ts @@ -1,6 +1,6 @@ import {ElementRef, Inject, Injectable} from '@angular/core'; import {TuiZoom, TuiZoomOptions} from '@taiga-ui/cdk/interfaces'; -import {preventDefault, typedFromEvent} from '@taiga-ui/cdk/observables'; +import {tuiPreventDefault, typedFromEvent} from '@taiga-ui/cdk/observables'; import {TUI_ZOOM_OPTIONS} from '@taiga-ui/cdk/tokens'; import {distanceBetweenTouches} from '@taiga-ui/cdk/utils'; import {merge, Observable} from 'rxjs'; @@ -22,7 +22,7 @@ export class TuiZoomService extends Observable { typedFromEvent(nativeElement, `touchmove`, { passive: true, }).pipe( - preventDefault(), + tuiPreventDefault(), scan( (prev, event) => { const distance = distanceBetweenTouches(event); @@ -58,7 +58,7 @@ export class TuiZoomService extends Observable { ), ), typedFromEvent(nativeElement, `wheel`, {passive: false}).pipe( - preventDefault(), + tuiPreventDefault(), map(wheel => ({ clientX: wheel.clientX, clientY: wheel.clientY, diff --git a/projects/cdk/tokens/active-element.ts b/projects/cdk/tokens/active-element.ts index 47c454c303b3..bffe6ad72484 100644 --- a/projects/cdk/tokens/active-element.ts +++ b/projects/cdk/tokens/active-element.ts @@ -2,7 +2,7 @@ import {DOCUMENT} from '@angular/common'; import {inject, InjectionToken} from '@angular/core'; import {WINDOW} from '@ng-web-apis/common'; import {typedFromEvent} from '@taiga-ui/cdk/observables'; -import {getActualTarget, getDocumentOrShadowRoot} from '@taiga-ui/cdk/utils'; +import {tuiGetActualTarget, tuiGetDocumentOrShadowRoot} from '@taiga-ui/cdk/utils'; import {merge, Observable, of, timer} from 'rxjs'; import { distinctUntilChanged, @@ -41,7 +41,7 @@ export const TUI_ACTIVE_ELEMENT = new InjectionToken mouseup$), withLatestFrom(removedElement$), filter(([event, removedElement]) => - isValidFocusout(getActualTarget(event), removedElement), + isValidFocusout(tuiGetActualTarget(event), removedElement), ), map(([{relatedTarget}]) => relatedTarget), ), @@ -51,8 +51,8 @@ export const TUI_ACTIVE_ELEMENT = new InjectionToken { - const target = getActualTarget(event); - const root = getDocumentOrShadowRoot(target) as Document; + const target = tuiGetActualTarget(event); + const root = tuiGetDocumentOrShadowRoot(target) as Document; return root === documentRef ? of(target) @@ -63,10 +63,10 @@ export const TUI_ACTIVE_ELEMENT = new InjectionToken !documentRef.activeElement || documentRef.activeElement === documentRef.body - ? of(getActualTarget(event)) + ? of(tuiGetActualTarget(event)) : focusout$.pipe( take(1), - mapTo(getActualTarget(event)), + mapTo(tuiGetActualTarget(event)), takeUntil(timer(0)), ), ), @@ -80,7 +80,7 @@ export const TUI_ACTIVE_ELEMENT = new InjectionToken { @@ -9,12 +9,12 @@ describe(`Browsers`, () => { }); it(`isEdge`, () => { - expect(isEdge(`edge`)).toBe(true); + expect(tuiIsEdge(`edge`)).toBe(true); }); it(`isFirefox`, () => { - expect(isFirefox(`firefox`)).toBe(true); - expect(isFirefox(`Firefox`)).toBe(true); + expect(tuiIsFirefox(`firefox`)).toBe(true); + expect(tuiIsFirefox(`Firefox`)).toBe(true); }); it(`isEdgeOlderThan`, () => { diff --git a/projects/cdk/utils/dom/can-scroll.ts b/projects/cdk/utils/dom/can-scroll.ts index c33aba087abb..60598e8a60d5 100644 --- a/projects/cdk/utils/dom/can-scroll.ts +++ b/projects/cdk/utils/dom/can-scroll.ts @@ -1,8 +1,4 @@ -/** - * @deprecated: use {@link tuiCanScroll} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function canScroll( +export function tuiCanScroll( element: Element, rootElement: Element, vertical: boolean, @@ -13,8 +9,6 @@ export function canScroll( : canScrollHorizontal(element, rootElement, scrollEnd); } -export const tuiCanScroll = canScroll; - function canScrollVertical( element: Element, rootElement: Element, diff --git a/projects/cdk/utils/dom/contains-or-after.ts b/projects/cdk/utils/dom/contains-or-after.ts index dcf016f918cf..bfc279c61cd3 100644 --- a/projects/cdk/utils/dom/contains-or-after.ts +++ b/projects/cdk/utils/dom/contains-or-after.ts @@ -1,12 +1,6 @@ -/** - * @deprecated: use {@link tuiContainsOrAfter} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function containsOrAfter(current: Node, node: Node): boolean { +export function tuiContainsOrAfter(current: Node, node: Node): boolean { return ( current.contains(node) || !!(node.compareDocumentPosition(current) & Node.DOCUMENT_POSITION_PRECEDING) ); } - -export const tuiContainsOrAfter = containsOrAfter; diff --git a/projects/cdk/utils/dom/get-actual-target.ts b/projects/cdk/utils/dom/get-actual-target.ts index 65a39bd96329..6019a81d10f2 100644 --- a/projects/cdk/utils/dom/get-actual-target.ts +++ b/projects/cdk/utils/dom/get-actual-target.ts @@ -1,14 +1,10 @@ /** - * @deprecated: use {@link tuiGetActualTarget} instead * Gets actual target from open Shadow DOM if event happened within it */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function getActualTarget(event: Event): Node { +export function tuiGetActualTarget(event: Event): Node { if (`composedPath` in event) { return (event as any).composedPath()[0]; } return (event as any).target; } - -export const tuiGetActualTarget = getActualTarget; diff --git a/projects/cdk/utils/dom/get-clipboard-data-text.ts b/projects/cdk/utils/dom/get-clipboard-data-text.ts index e063934a6d15..0eca3c23ad0a 100644 --- a/projects/cdk/utils/dom/get-clipboard-data-text.ts +++ b/projects/cdk/utils/dom/get-clipboard-data-text.ts @@ -1,11 +1,9 @@ const DEFAULT_FORMAT = `text/plain`; /** - * @deprecated: use {@link tuiGetClipboardDataText} instead * Gets text from data of clipboardEvent, it also works in IE and Edge browsers */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function getClipboardDataText( +export function tuiGetClipboardDataText( event: ClipboardEvent, format: string = DEFAULT_FORMAT, ): string { @@ -14,5 +12,3 @@ export function getClipboardDataText( event.clipboardData.getData(DEFAULT_FORMAT) : (event as any).target.ownerDocument.defaultView.clipboardData.getData(`text`); } - -export const tuiGetClipboardDataText = getClipboardDataText; diff --git a/projects/cdk/utils/dom/get-document-or-shadow-root.ts b/projects/cdk/utils/dom/get-document-or-shadow-root.ts index 9894679f895d..2b5e4f7fa4e0 100644 --- a/projects/cdk/utils/dom/get-document-or-shadow-root.ts +++ b/projects/cdk/utils/dom/get-document-or-shadow-root.ts @@ -1,11 +1,5 @@ -/** - * @deprecated: use {@link tuiGetDocumentOrShadowRoot} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function getDocumentOrShadowRoot(node: Node): DocumentOrShadowRoot { +export function tuiGetDocumentOrShadowRoot(node: Node): DocumentOrShadowRoot { return `getRootNode` in node && node.isConnected ? (node.getRootNode() as Document) : node.ownerDocument!; } - -export const tuiGetDocumentOrShadowRoot = getDocumentOrShadowRoot; diff --git a/projects/cdk/utils/dom/get-element-obscurers.ts b/projects/cdk/utils/dom/get-element-obscurers.ts index b718a25fd91d..b76e8ef1d301 100644 --- a/projects/cdk/utils/dom/get-element-obscurers.ts +++ b/projects/cdk/utils/dom/get-element-obscurers.ts @@ -1,16 +1,14 @@ import {clamp} from '@taiga-ui/cdk/utils/math'; import {isPresent} from '@taiga-ui/cdk/utils/miscellaneous'; -import {getDocumentOrShadowRoot} from './get-document-or-shadow-root'; +import {tuiGetDocumentOrShadowRoot} from './get-document-or-shadow-root'; /** - * @deprecated: use {@link tuiGetElementObscures} instead * Returns array of Elements covering edges of given element or null if at least one edge middle point is visible * * CAUTION: Empty array means element if offscreen i.e. covered by no elements, rather than not covered */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function getElementObscurers(element: Element): readonly Element[] | null { +export function tuiGetElementObscures(element: Element): readonly Element[] | null { const {ownerDocument} = element; if (!ownerDocument || !ownerDocument.defaultView) { @@ -18,7 +16,7 @@ export function getElementObscurers(element: Element): readonly Element[] | null } const {innerWidth, innerHeight} = ownerDocument.defaultView; - const documentRef = getDocumentOrShadowRoot(element); + const documentRef = tuiGetDocumentOrShadowRoot(element); const rect = element.getBoundingClientRect(); const left = clamp(Math.round(rect.left) + 2, 0, innerWidth); const top = clamp(Math.round(rect.top) + 2, 0, innerHeight); @@ -42,5 +40,3 @@ export function getElementObscurers(element: Element): readonly Element[] | null return filtered.length === 4 ? filtered : null; } - -export const tuiGetElementObscures = getElementObscurers; diff --git a/projects/cdk/utils/dom/get-element-offset.ts b/projects/cdk/utils/dom/get-element-offset.ts index 26548bf682af..d41ba1dade8e 100644 --- a/projects/cdk/utils/dom/get-element-offset.ts +++ b/projects/cdk/utils/dom/get-element-offset.ts @@ -1,15 +1,13 @@ import {tuiAssert} from '@taiga-ui/cdk/classes'; /** - * @deprecated: use {@link tuiGetElementOffset} instead * Calculates offset for an element relative to it's parent several levels above * * @param host parent element * @param element * @return object with offsetTop and offsetLeft number properties */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function getElementOffset( +export function tuiGetElementOffset( host: Element, element: HTMLElement, ): {offsetTop: number; offsetLeft: number} { @@ -26,5 +24,3 @@ export function getElementOffset( return {offsetTop, offsetLeft}; } - -export const tuiGetElementOffset = getElementOffset; diff --git a/projects/cdk/utils/dom/get-scroll-parent.ts b/projects/cdk/utils/dom/get-scroll-parent.ts index 141cdfda094f..082bfeecc656 100644 --- a/projects/cdk/utils/dom/get-scroll-parent.ts +++ b/projects/cdk/utils/dom/get-scroll-parent.ts @@ -1,12 +1,10 @@ /** - * @deprecated: use {@link tuiGetScrollParent} instead * Finds the nearest parent with scroll in it * * @param element initial element * @param vertical flag for orientation of scroll */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function getScrollParent( +export function tuiGetScrollParent( element: Element | null, vertical: boolean = true, ): Element | null { @@ -22,7 +20,5 @@ export function getScrollParent( return element; } - return getScrollParent(element.parentElement, vertical); + return tuiGetScrollParent(element.parentElement, vertical); } - -export const tuiGetScrollParent = getScrollParent; diff --git a/projects/cdk/utils/dom/is-current-target.ts b/projects/cdk/utils/dom/is-current-target.ts index e34ebae20842..8a0124dbb6b9 100644 --- a/projects/cdk/utils/dom/is-current-target.ts +++ b/projects/cdk/utils/dom/is-current-target.ts @@ -1,9 +1,3 @@ -/** - * @deprecated: use {@link tuiIsCurrentTarget} instead - */ -// eslint-disable-next-line @typescript-eslint/naming-convention -export function isCurrentTarget({target, currentTarget}: Event): boolean { +export function tuiIsCurrentTarget({target, currentTarget}: Event): boolean { return target === currentTarget; } - -export const tuiIsCurrentTarget = isCurrentTarget; diff --git a/projects/cdk/utils/dom/is-inside-iframe.ts b/projects/cdk/utils/dom/is-inside-iframe.ts index 0e5d7604b485..bcfdab767187 100644 --- a/projects/cdk/utils/dom/is-inside-iframe.ts +++ b/projects/cdk/utils/dom/is-inside-iframe.ts @@ -1,10 +1,6 @@ /** - * @deprecated: use {@link tuiIsInsideIframe} instead * Checks if an app is running inside