Skip to content

Commit

Permalink
refactor!: remove date-time related deprecations, EMPTY_VALIDATOR (#2164
Browse files Browse the repository at this point in the history
)
  • Loading branch information
vladimirpotekhin authored and splincode committed Aug 1, 2022
1 parent 23c0cc5 commit d68b6bb
Show file tree
Hide file tree
Showing 49 changed files with 818 additions and 1,453 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
import {TuiLineChartHintContext} from '@taiga-ui/addon-charts/interfaces';
import {draw} from '@taiga-ui/addon-charts/utils';
import {
inRange,
tuiDefaultProp,
TuiIdService,
tuiInRange,
tuiPure,
TuiStringHandler,
tuiZoneOptimized,
Expand All @@ -27,7 +27,7 @@ import {TuiLineChartHintDirective} from './line-chart-hint.directive';

// eslint-disable-next-line @typescript-eslint/naming-convention
export function smoothingAssertion(smoothingFactor: number): boolean {
return inRange(smoothingFactor, 0, 100);
return tuiInRange(smoothingFactor, 0, 100);
}

const SMOOTHING_MESSAGE = `smoothingFactor must be between 0 and 100`;
Expand Down
47 changes: 20 additions & 27 deletions projects/addon-commerce/enums/currency-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: RUB
* @description Countries and territories: Russia
*/
Ruble = `643`,
Ruble = '643',

/**
* Euro
Expand All @@ -23,7 +23,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: EUR
* @description Countries and territories: Åland Islands (AX), European Union (EU), Andorra (AD), Austria (AT), Belgium (BE), Cyprus (CY), Estonia (EE), Finland (FI), France (FR), French Southern and Antarctic Lands (TF), Germany (DE), Greece (GR), Guadeloupe (GP), Ireland (IE), Italy (IT), Latvia (LV), Lithuania (LT), Luxembourg (LU), Malta (MT), French Guiana (GF), Martinique (MQ), Mayotte (YT), Monaco (MC), Montenegro (ME), Netherlands (NL), Portugal (PT), Réunion (RE), Saint Barthélemy (BL), Saint Martin (MF), Saint Pierre and Miquelon (PM), San Marino (SM), Slovakia (SK), Slovenia (SI), Spain (ES), Vatican City (VA)
*/
Euro = `978`,
Euro = '978',

/**
* United States dollar
Expand All @@ -32,7 +32,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: USD
* @description Countries and territories: United States, American Samoa (AS), British Indian Ocean Territory (IO) (also uses GBP), British Virgin Islands (VG), Caribbean Netherlands (BQ – Bonaire, Sint Eustatius and Saba), Ecuador (EC), El Salvador (SV), Guam (GU), Marshall Islands (MH), Federated States of Micronesia (FM), Northern Mariana Islands (MP), Palau (PW), Panama (PA) (as well as Panamanian Balboa), Puerto Rico (PR), Timor-Leste (TL), Turks and Caicos Islands (TC), U.S. Virgin Islands (VI), United States Minor Outlying Islands (UM)
*/
Dollar = `840`,
Dollar = '840',

/**
* Pound sterling
Expand All @@ -41,7 +41,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: GBP
* @description Countries and territories: United Kingdom, Isle of Man (IM, see Manx pound), Jersey (JE, see Jersey pound), Guernsey (GG, see Guernsey pound), Tristan da Cunha (SH-TA)
*/
Pound = `826`,
Pound = '826',

/**
* Thai baht
Expand All @@ -50,7 +50,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: THB
* @description Countries and territories: Thailand
*/
Baht = `764`,
Baht = '764',

/**
* Turkish lira
Expand All @@ -59,7 +59,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: TRY
* @description Countries and territories: Turkey
*/
TurkishLira = `949`,
TurkishLira = '949',

/**
* Chinese yuan
Expand All @@ -68,7 +68,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: CNY
* @description Countries and territories: China
*/
YuanRenminbi = `156`,
YuanRenminbi = '156',

/**
* Kazakhstani tenge
Expand All @@ -77,7 +77,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: KZT
* @description Countries and territories: Kazakhstan
*/
Tenge = `398`,
Tenge = '398',

/**
* Israeli new shekel
Expand All @@ -86,7 +86,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: ILS
* @description Countries and territories: Israel
*/
IsraeliShekel = `376`,
IsraeliShekel = '376',

/**
* Indian rupee
Expand All @@ -95,7 +95,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: INR
* @description Countries and territories: India, Bhutan
*/
IndianRupee = `356`,
IndianRupee = '356',

/**
* Japanese yen
Expand All @@ -104,7 +104,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: JPY
* @description Countries and territories: Japan
*/
Yen = `392`,
Yen = '392',

/**
* South Korean won
Expand All @@ -113,7 +113,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: KRW
* @description Countries and territories: South Korea
*/
Won = `410`,
Won = '410',

/**
* Swiss franc
Expand All @@ -122,7 +122,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: CHF
* @description Countries and territories: Switzerland, Liechtenstein (LI)
*/
SwissFranc = `756`,
SwissFranc = '756',

/**
* Singapore dollar
Expand All @@ -131,7 +131,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: SGD
* @description Countries and territories: Singapore
*/
SingaporeDollar = `702`,
SingaporeDollar = '702',

/**
* Australian dollar
Expand All @@ -140,7 +140,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: AUD
* @description Countries and territories: Australia, Christmas Island (CX), Cocos (Keeling) Islands (CC), Heard Island and McDonald Islands (HM), Kiribati (KI), Nauru (NR), Norfolk Island (NF), Tuvalu (TV)
*/
AustralianDollar = `036`,
AustralianDollar = '036',

/**
* Hong Kong dollar
Expand All @@ -149,14 +149,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: HKD
* @description Countries and territories: Hong Kong
*/
HongKongDollar = `344`,

/**
* @deprecated
* TODO: 3.0 replace with {@link HongKongDollar}
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
HongKong_dollar = `344`,
HongKongDollar = '344',

/**
* Canadian dollar
Expand All @@ -165,7 +158,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: CAD
* @description Countries and territories: Canada
*/
CanadianDollar = `124`,
CanadianDollar = '124',

/**
* Armenian dram
Expand All @@ -174,7 +167,7 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: AMD
* @description Countries and territories: Armenia
*/
ArmenianDram = `051`,
ArmenianDram = '051',

/**
* Ukrainian hryvnia
Expand All @@ -183,6 +176,6 @@ export const enum TuiCurrencyCode {
* @description Alphabetic code: UAH
* @description Countries and territories: Ukraine
*/
Hryvnia = `980`,
MexicanPeso = `484`,
Hryvnia = '980',
MexicanPeso = '484',
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Directive, ElementRef, HostListener, Inject} from '@angular/core';
import {
clamp,
getClosestFocusable,
isNativeMouseFocusable,
setNativeFocused,
tuiGetClosestFocusable,
tuiIsNativeFocusedIn,
tuiIsNativeMouseFocusable,
TuiNativeFocusableElement,
} from '@taiga-ui/cdk';

Expand Down Expand Up @@ -49,9 +49,9 @@ export class TuiToolbarNavigationManagerDirective {
: this.toolsContainers;

for (const el of tools) {
const focusableElement = isNativeMouseFocusable(el)
const focusableElement = tuiIsNativeMouseFocusable(el)
? el
: getClosestFocusable(el, false, el, false);
: tuiGetClosestFocusable(el, false, el, false);

if (focusableElement) {
return focusableElement;
Expand All @@ -62,21 +62,26 @@ export class TuiToolbarNavigationManagerDirective {
}

private findPreviousTool(wrapper: HTMLElement): HTMLElement | null {
if (isNativeMouseFocusable(wrapper)) {
if (tuiIsNativeMouseFocusable(wrapper)) {
return wrapper;
}

const lookedInside = getClosestFocusable(wrapper, false, wrapper, false);
const lookedInside = tuiGetClosestFocusable(wrapper, false, wrapper, false);

return (
lookedInside ||
getClosestFocusable(wrapper, true, this.elementRef.nativeElement, false)
tuiGetClosestFocusable(wrapper, true, this.elementRef.nativeElement, false)
);
}

private findNextTool(wrapper: HTMLElement): HTMLElement | null {
return isNativeMouseFocusable(wrapper)
return tuiIsNativeMouseFocusable(wrapper)
? wrapper
: getClosestFocusable(wrapper, false, this.elementRef.nativeElement, false);
: tuiGetClosestFocusable(
wrapper,
false,
this.elementRef.nativeElement,
false,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import {tuiInsertHtml} from '@taiga-ui/addon-editor/utils';
import {
EMPTY_FUNCTION,
getClipboardDataText,
getClosestFocusable,
preventDefault,
setNativeFocused,
TUI_FOCUSABLE_ITEM_ACCESSOR,
TuiComputedDocumentException,
TuiDestroyService,
TuiEventWith,
TuiFocusableElementAccessor,
tuiGetClosestFocusable,
TuiHandler,
tuiIsNativeFocused,
tuiRequiredSetter,
Expand Down Expand Up @@ -219,7 +219,7 @@ export class TuiDesignModeDirective

event.preventDefault();

const element = getClosestFocusable(
const element = tuiGetClosestFocusable(
this.elementRef.nativeElement,
event.shiftKey,
this.elementRef.nativeElement.ownerDocument.body,
Expand Down
5 changes: 2 additions & 3 deletions projects/addon-mobile/components/sheet/sheet-options.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {inject, InjectionToken} from '@angular/core';
import {InjectionToken} from '@angular/core';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';

import {TuiSheet} from './sheet';
import {TUI_SHEET_OFFSET} from './sheet-tokens';

export interface TuiSheetOptions<I = undefined, O = unknown> {
readonly image: PolymorpheusContent<TuiSheet<O, I>>;
Expand All @@ -28,6 +27,6 @@ export const TUI_SHEET_DEFAULT_OPTIONS: Omit<TuiSheetOptions, 'data'> = {
export const TUI_SHEET_OPTIONS = new InjectionToken<Omit<TuiSheetOptions, 'data'>>(
`Default parameters for sheet component`,
{
factory: () => ({...TUI_SHEET_DEFAULT_OPTIONS, offset: inject(TUI_SHEET_OFFSET)}),
factory: () => ({...TUI_SHEET_DEFAULT_OPTIONS}),
},
);
8 changes: 0 additions & 8 deletions projects/addon-mobile/components/sheet/sheet-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,3 @@ export const TUI_SHEET_SCROLL = new InjectionToken<number>(
export const TUI_SHEET_DRAGGED = new InjectionToken<boolean>(
'The sheet is being dragged',
);

/** @deprecated use option argument for each Sheet */
export const TUI_SHEET_OFFSET = new InjectionToken<number>(
'Offset from the top at which the sheet stops',
{
factory: () => 16,
},
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Directive, ElementRef, Inject, Input, Optional, Renderer2} from '@angular/core';
import {TuiTouchMode} from '@taiga-ui/addon-mobile/types';
import {findTouchIndex} from '@taiga-ui/addon-mobile/utils';
import {tuiFindTouchIndex} from '@taiga-ui/addon-mobile/utils';
import {
TUI_IS_IOS,
tuiDefaultProp,
Expand Down Expand Up @@ -74,7 +74,7 @@ export class TuiTouchableDirective {
identifier: number,
): boolean {
const {ownerDocument} = element;
const id = findTouchIndex(touches, identifier);
const id = tuiFindTouchIndex(touches, identifier);

if (!ownerDocument || id === -1) {
return true;
Expand Down
8 changes: 1 addition & 7 deletions projects/addon-mobile/utils/find-touch-index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/**
* @deprecated: use {@link tuiFindTouchIndex} instead
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export function findTouchIndex(touches: TouchList, id: number): number {
export function tuiFindTouchIndex(touches: TouchList, id: number): number {
for (let i = 0; i < touches.length; i++) {
const {identifier} = touches[i];

Expand All @@ -13,5 +9,3 @@ export function findTouchIndex(touches: TouchList, id: number): number {

return -1;
}

export const tuiFindTouchIndex = findTouchIndex;
3 changes: 0 additions & 3 deletions projects/cdk/constants/empty.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {QueryList} from '@angular/core';
import {ValidatorFn} from '@angular/forms';

/**
* For type safety when using @ContentChildren and @ViewChildren
Expand All @@ -9,8 +8,6 @@ import {ValidatorFn} from '@angular/forms';
export const EMPTY_QUERY = new QueryList<any>();
export const EMPTY_ARRAY: [] = [];
export const EMPTY_FUNCTION: (...args: any[]) => void = () => {};
/** @deprecated use Validators.nullValidator */
export const EMPTY_VALIDATOR: ValidatorFn = () => null;
export const EMPTY_CLIENT_RECT: ClientRect = {
bottom: 0,
height: 0,
Expand Down
13 changes: 3 additions & 10 deletions projects/cdk/constants/test/handler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import {AbstractControl} from '@angular/forms';

import {ALWAYS_FALSE_HANDLER} from '../always-false-handler';
import {ALWAYS_TRUE_HANDLER} from '../always-true-handler';
import {EMPTY_VALIDATOR} from '../empty';

describe(`Handler functions`, () => {
it(`Always false`, () => {
describe('Handler functions', () => {
it('Always false', () => {
expect(ALWAYS_FALSE_HANDLER()).toBe(false);
});

it(`Always true`, () => {
it('Always true', () => {
expect(ALWAYS_TRUE_HANDLER()).toBe(true);
});

it(`EMPTY_VALIDATOR`, () => {
expect(EMPTY_VALIDATOR({} as unknown as AbstractControl)).toBe(null);
});
});
Loading

0 comments on commit d68b6bb

Please sign in to comment.