Skip to content

Commit

Permalink
refactor(addon-commerce, addon-chart)!: remove deprecated enums (#2095)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Jul 15, 2022
1 parent 1ad3b6e commit ecdcc74
Show file tree
Hide file tree
Showing 66 changed files with 217 additions and 325 deletions.
6 changes: 3 additions & 3 deletions projects/addon-charts/components/axes/axes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Input,
} from '@angular/core';
import {TUI_ALWAYS_DASHED, TUI_ALWAYS_SOLID} from '@taiga-ui/addon-charts/constants';
import {TuiLineHandler, TuiLineTypeT} from '@taiga-ui/addon-charts/types';
import {TuiLineHandler, TuiLineType} from '@taiga-ui/addon-charts/types';
import {CHAR_NO_BREAK_SPACE, tuiDefaultProp} from '@taiga-ui/cdk';
import {MODE_PROVIDER} from '@taiga-ui/core/providers';
import {TUI_MODE} from '@taiga-ui/core/tokens';
Expand All @@ -26,15 +26,15 @@ import {Observable} from 'rxjs';
export class TuiAxesComponent {
@Input()
@tuiDefaultProp()
axisX: TuiLineTypeT = 'solid';
axisX: TuiLineType = 'solid';

@Input()
@tuiDefaultProp()
axisXLabels: ReadonlyArray<string | null> = [];

@Input()
@tuiDefaultProp()
axisY: TuiLineTypeT = 'solid';
axisY: TuiLineType = 'solid';

@Input()
@tuiDefaultProp()
Expand Down
1 change: 0 additions & 1 deletion projects/addon-charts/enums/index.ts

This file was deleted.

11 changes: 0 additions & 11 deletions projects/addon-charts/enums/line-type.ts

This file was deleted.

7 changes: 0 additions & 7 deletions projects/addon-charts/enums/package.json

This file was deleted.

1 change: 0 additions & 1 deletion projects/addon-charts/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from '@taiga-ui/addon-charts/components';
export * from '@taiga-ui/addon-charts/constants';
export * from '@taiga-ui/addon-charts/enums';
export * from '@taiga-ui/addon-charts/interfaces';
export * from '@taiga-ui/addon-charts/types';
4 changes: 2 additions & 2 deletions projects/addon-charts/types/line-handler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {TuiLineTypeT} from './line-type';
import {TuiLineType} from './line-type';

export type TuiLineHandler = (index: number, total: number) => TuiLineTypeT;
export type TuiLineHandler = (index: number, total: number) => TuiLineType;
2 changes: 1 addition & 1 deletion projects/addon-charts/types/line-type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* Native CSS border-style options
*/
export type TuiLineTypeT = 'solid' | 'dashed' | 'dotted' | 'none' | 'hidden';
export type TuiLineType = 'solid' | 'dashed' | 'dotted' | 'none' | 'hidden';
16 changes: 8 additions & 8 deletions projects/addon-commerce/components/card/card.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ChangeDetectionStrategy, Component, HostBinding, Input} from '@angular/core';
import {TuiPaymentSystem, TuiPaymentSystemT} from '@taiga-ui/addon-commerce/enums';
import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/types';
import {tuiDefaultProp} from '@taiga-ui/cdk';
import {TuiSizeS} from '@taiga-ui/core';

Expand All @@ -10,12 +10,12 @@ export function cardNumberAssertion({length}: string): boolean {

export const cardNumberAssertionMessage = 'cardNumber should contain 4 symbols';

const icons = {
[TuiPaymentSystem.Mir]: 'tuiIconMirMono',
[TuiPaymentSystem.Visa]: 'tuiIconVisaMono',
[TuiPaymentSystem.Electron]: 'tuiIconElectronMono',
[TuiPaymentSystem.Mastercard]: 'tuiIconMastercard',
[TuiPaymentSystem.Maestro]: 'tuiIconMaestro',
const icons: Record<TuiPaymentSystem, string> = {
mir: 'tuiIconMirMono',
visa: 'tuiIconVisaMono',
electron: 'tuiIconElectronMono',
mastercard: 'tuiIconMastercard',
maestro: 'tuiIconMaestro',
};

@Component({
Expand All @@ -40,7 +40,7 @@ export class TuiCardComponent {

@Input()
@tuiDefaultProp()
paymentSystem: TuiPaymentSystemT | TuiPaymentSystem | null = null;
paymentSystem: TuiPaymentSystem | null = null;

@Input()
@HostBinding('attr.data-size')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,22 @@ import {
} from '@angular/core';
import {NgControl} from '@angular/forms';
import {TUI_CARD_MASK, tuiDefaultCardValidator} from '@taiga-ui/addon-commerce/constants';
import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/enums';
import {TuiCard} from '@taiga-ui/addon-commerce/interfaces';
import {TuiCodeCVCLength} from '@taiga-ui/addon-commerce/types';
import {TuiCodeCVCLength, TuiPaymentSystem} from '@taiga-ui/addon-commerce/types';
import {
getPaymentSystem,
tuiCreateAutoCorrectedExpirePipe,
tuiGetPaymentSystem,
} from '@taiga-ui/addon-commerce/utils';
import {
AbstractTuiNullableControl,
isNativeFocusedIn,
TUI_FOCUSABLE_ITEM_ACCESSOR,
tuiAssertIsElement,
TuiBooleanHandler,
TuiCreditCardAutofillName,
tuiDefaultProp,
TuiFocusableElementAccessor,
tuiIsNativeFocused,
tuiIsNativeFocusedIn,
tuiPure,
tuiRequiredSetter,
} from '@taiga-ui/cdk';
Expand Down Expand Up @@ -64,12 +63,12 @@ const STUB: TuiCard = {
expire: '',
cvc: '',
};
const ICONS = {
[TuiPaymentSystem.Mir]: 'tuiIconMir',
[TuiPaymentSystem.Visa]: 'tuiIconVisa',
[TuiPaymentSystem.Electron]: 'tuiIconElectron',
[TuiPaymentSystem.Mastercard]: 'tuiIconMastercard',
[TuiPaymentSystem.Maestro]: 'tuiIconMaestro',
const ICONS: Record<TuiPaymentSystem, string> = {
mir: 'tuiIconMir',
visa: 'tuiIconVisa',
electron: 'tuiIconElectron',
mastercard: 'tuiIconMastercard',
maestro: 'tuiIconMaestro',
};

// @dynamic
Expand Down Expand Up @@ -195,7 +194,7 @@ export class TuiInputCardGroupedComponent
}

get focused(): boolean {
return this.open || isNativeFocusedIn(this.elementRef.nativeElement);
return this.open || tuiIsNativeFocusedIn(this.elementRef.nativeElement);
}

get card(): string {
Expand Down Expand Up @@ -436,7 +435,7 @@ export class TuiInputCardGroupedComponent
}

private get paymentSystem(): TuiPaymentSystem | null {
return this.value && getPaymentSystem(this.value.card);
return this.value && tuiGetPaymentSystem(this.value.card);
}

@tuiPure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
} from '@angular/core';
import {NgControl} from '@angular/forms';
import {TUI_CARD_MASK} from '@taiga-ui/addon-commerce/constants';
import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/enums';
import {getPaymentSystem} from '@taiga-ui/addon-commerce/utils';
import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/types';
import {tuiGetPaymentSystem} from '@taiga-ui/addon-commerce/utils';
import {
AbstractTuiControl,
TUI_FOCUSABLE_ITEM_ACCESSOR,
Expand All @@ -29,12 +29,12 @@ import {
} from '@taiga-ui/core';
import {TextMaskConfig} from 'angular2-text-mask';

const icons = {
[TuiPaymentSystem.Mir]: 'tuiIconMir',
[TuiPaymentSystem.Visa]: 'tuiIconVisa',
[TuiPaymentSystem.Electron]: 'tuiIconElectron',
[TuiPaymentSystem.Mastercard]: 'tuiIconMastercard',
[TuiPaymentSystem.Maestro]: 'tuiIconMaestro',
const icons: Record<TuiPaymentSystem, string> = {
mir: 'tuiIconMir',
visa: 'tuiIconVisa',
electron: 'tuiIconElectron',
mastercard: 'tuiIconMastercard',
maestro: 'tuiIconMaestro',
};

// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -124,7 +124,7 @@ export class TuiInputCardComponent
}

get paymentSystem(): TuiPaymentSystem | null {
return getPaymentSystem(this.value);
return tuiGetPaymentSystem(this.value);
}

get bin(): string | null {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
import {FormControl, ReactiveFormsModule} from '@angular/forms';
import {configureTestSuite} from '@taiga-ui/testing';

import {TuiPaymentSystem} from '../../../enums/payment-system';
import {TuiInputCardComponent} from '../input-card.component';
import {TuiInputCardModule} from '../input-card.module';

Expand Down Expand Up @@ -83,33 +82,31 @@ describe('InputCard', () => {
it('visa', () => {
testComponent.control.setValue('4111 1111 1111 1111');

expect(testComponent.component.paymentSystem).toBe(TuiPaymentSystem.Visa);
expect(testComponent.component.paymentSystem).toBe('visa');
});

it('electron', () => {
testComponent.control.setValue('4917300800000000');

expect(testComponent.component.paymentSystem).toBe(TuiPaymentSystem.Electron);
expect(testComponent.component.paymentSystem).toBe('electron');
});

it('mir', () => {
testComponent.control.setValue('2200654321000000');

expect(testComponent.component.paymentSystem).toBe(TuiPaymentSystem.Mir);
expect(testComponent.component.paymentSystem).toBe('mir');
});

it('mastercard', () => {
testComponent.control.setValue('5500 0000 0000 0004');

expect(testComponent.component.paymentSystem).toBe(
TuiPaymentSystem.Mastercard,
);
expect(testComponent.component.paymentSystem).toBe('mastercard');
});

it('maestro', () => {
testComponent.control.setValue('6759649826438453');

expect(testComponent.component.paymentSystem).toBe(TuiPaymentSystem.Maestro);
expect(testComponent.component.paymentSystem).toBe('maestro');
});
});

Expand Down
4 changes: 2 additions & 2 deletions projects/addon-commerce/components/money/money-options.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {InjectionToken, ValueProvider} from '@angular/core';
import {TuiCurrency} from '@taiga-ui/addon-commerce/enums';
import {TuiCurrencyVariants, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';
import {TuiCurrencyVariants, TuiMoneySign} from '@taiga-ui/addon-commerce/types';
import {TuiDecimalT} from '@taiga-ui/core';

export interface TuiMoneyOptions {
readonly decimal: TuiDecimalT;
readonly currency: TuiCurrencyVariants;
readonly sign: TuiMoneySignT;
readonly sign: TuiMoneySign;
readonly colored: boolean;
readonly precision: number;
readonly singleColor: boolean;
Expand Down
4 changes: 2 additions & 2 deletions projects/addon-commerce/components/money/money.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
} from '@angular/core';
import {
TuiCurrencyVariants,
TuiMoneySign,
TuiMoneySignSymbol,
TuiMoneySignT,
} from '@taiga-ui/addon-commerce/types';
import {CHAR_EN_DASH, CHAR_PLUS, tuiDefaultProp} from '@taiga-ui/cdk';
import {TuiDecimalT} from '@taiga-ui/core';
Expand Down Expand Up @@ -37,7 +37,7 @@ export class TuiMoneyComponent {

@Input()
@tuiDefaultProp()
sign: TuiMoneySignT = this.options.sign;
sign: TuiMoneySign = this.options.sign;

@Input()
@tuiDefaultProp()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {Pipe, PipeTransform} from '@angular/core';
import {TuiMoneySignSymbol, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';
import {TuiMoneySign, TuiMoneySignSymbol} from '@taiga-ui/addon-commerce/types';

import {tuiFormatSignSymbol} from '../utils/format-sign-symbol';

@Pipe({name: 'tuiSignSymbol'})
export class TuiSignSymbolPipe implements PipeTransform {
transform(value: number, sign: TuiMoneySignT): TuiMoneySignSymbol {
transform(value: number, sign: TuiMoneySign): TuiMoneySignSymbol {
return tuiFormatSignSymbol(value, sign);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
TuiCurrencyVariants,
TuiMoneyComponent,
TuiMoneyModule,
TuiMoneySignT,
TuiMoneySign,
} from '@taiga-ui/addon-commerce';
import {CHAR_EN_DASH} from '@taiga-ui/cdk';
import {TuiDecimalT} from '@taiga-ui/core';
Expand All @@ -32,7 +32,7 @@ describe('Money', () => {
value = 237;
decimal: TuiDecimalT = 'not-zero';
currency: TuiCurrencyVariants = null;
sign: TuiMoneySignT = 'negative-only';
sign: TuiMoneySign = 'negative-only';
colored = false;
precision = 2;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {TuiMoneySignSymbol, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';
import {TuiMoneySign, TuiMoneySignSymbol} from '@taiga-ui/addon-commerce/types';
import {CHAR_EN_DASH, CHAR_PLUS} from '@taiga-ui/cdk';

export function tuiFormatSignSymbol(
value: number,
sign: TuiMoneySignT,
sign: TuiMoneySign,
): TuiMoneySignSymbol {
if (sign === 'never' || !value || (sign === 'negative-only' && value > 0)) {
return '';
Expand Down
4 changes: 2 additions & 2 deletions projects/addon-commerce/constants/default-card-validator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {isCardLengthValid, isCardNumberValid} from '@taiga-ui/addon-commerce/utils';
import {tuiIsCardLengthValid, tuiIsCardNumberValid} from '@taiga-ui/addon-commerce/utils';
import {TuiBooleanHandler} from '@taiga-ui/cdk';

export const tuiDefaultCardValidator: TuiBooleanHandler<string> = card =>
card.length > 11 && isCardLengthValid(card) && isCardNumberValid(card);
card.length > 11 && tuiIsCardLengthValid(card) && tuiIsCardNumberValid(card);
2 changes: 0 additions & 2 deletions projects/addon-commerce/enums/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from './currency';
export * from './currency-code';
export * from './money-sign';
export * from './payment-system';
16 changes: 0 additions & 16 deletions projects/addon-commerce/enums/money-sign.ts

This file was deleted.

9 changes: 0 additions & 9 deletions projects/addon-commerce/enums/payment-system.ts

This file was deleted.

1 change: 1 addition & 0 deletions projects/addon-commerce/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './code-length';
export * from './currency-variants';
export * from './money-sign';
export * from './payment-system';
2 changes: 1 addition & 1 deletion projects/addon-commerce/types/money-sign.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CHAR_EN_DASH, CHAR_PLUS} from '@taiga-ui/cdk';

export type TuiMoneySignT =
export type TuiMoneySign =
| 'negative-only'
| 'always'
| 'never'
Expand Down
1 change: 1 addition & 0 deletions projects/addon-commerce/types/payment-system.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type TuiPaymentSystem = 'visa' | 'electron' | 'mastercard' | 'maestro' | 'mir';
Loading

0 comments on commit ecdcc74

Please sign in to comment.