From cd373835315e9c5eed1fb638ce19557244f4e211 Mon Sep 17 00:00:00 2001 From: Nikita Barsukov Date: Fri, 2 Feb 2024 16:27:30 +0300 Subject: [PATCH] feat!: delete all utils for legacy `text-mask` library --- .../constants/card-holder-mask.ts | 19 -- .../create-auto-corrected-expire-pipe.ts | 53 ----- projects/addon-commerce/utils/index.ts | 1 - .../textfield/textfield.component.ts | 15 +- projects/core/index.ts | 1 - projects/core/mask/index.ts | 8 - projects/core/mask/ng-package.json | 5 - projects/core/mask/number-mask-options.ts | 12 -- projects/core/mask/text-mask-config.ts | 10 - .../core/mask/text-mask-correction-handler.ts | 4 - projects/core/mask/text-mask-list-handler.ts | 10 - projects/core/mask/text-mask-list.ts | 5 - projects/core/mask/text-mask-options.ts | 39 ---- projects/core/mask/text-mask-pipe-handler.ts | 12 -- projects/core/mask/text-mask-pipe-result.ts | 9 - projects/core/tokens/index.ts | 1 - projects/core/tokens/legacy-mask.ts | 8 - projects/core/utils/index.ts | 1 - .../mask/create-auto-corrected-money-pipe.ts | 158 -------------- .../core/utils/mask/create-correction-mask.ts | 50 ----- .../core/utils/mask/create-number-mask.ts | 200 ------------------ .../enable-auto-correct-decimal-symbol.ts | 12 -- projects/core/utils/mask/index.ts | 6 - .../utils/mask/masked-money-value-is-empty.ts | 20 -- .../mask/masked-number-string-to-number.ts | 15 -- projects/core/utils/mask/ng-package.json | 5 - .../mask/test/create-correction-mask.spec.ts | 37 ---- .../masked-number-string-to-number.spec.ts | 29 --- ...-create-auto-corrected-number-pipe.spec.ts | 51 ----- projects/kit/constants/empty-mask.ts | 11 - projects/kit/constants/index.ts | 2 - projects/kit/constants/masks.ts | 33 --- projects/kit/directives/index.ts | 1 - projects/kit/directives/mask/index.ts | 1 - projects/kit/directives/mask/legacy-mask.ts | 177 ---------------- projects/kit/directives/mask/ng-package.json | 5 - 36 files changed, 3 insertions(+), 1023 deletions(-) delete mode 100644 projects/addon-commerce/utils/create-auto-corrected-expire-pipe.ts delete mode 100644 projects/core/mask/index.ts delete mode 100644 projects/core/mask/ng-package.json delete mode 100644 projects/core/mask/number-mask-options.ts delete mode 100644 projects/core/mask/text-mask-config.ts delete mode 100644 projects/core/mask/text-mask-correction-handler.ts delete mode 100644 projects/core/mask/text-mask-list-handler.ts delete mode 100644 projects/core/mask/text-mask-list.ts delete mode 100644 projects/core/mask/text-mask-options.ts delete mode 100644 projects/core/mask/text-mask-pipe-handler.ts delete mode 100644 projects/core/mask/text-mask-pipe-result.ts delete mode 100644 projects/core/tokens/legacy-mask.ts delete mode 100644 projects/core/utils/mask/create-auto-corrected-money-pipe.ts delete mode 100644 projects/core/utils/mask/create-correction-mask.ts delete mode 100644 projects/core/utils/mask/create-number-mask.ts delete mode 100644 projects/core/utils/mask/enable-auto-correct-decimal-symbol.ts delete mode 100644 projects/core/utils/mask/index.ts delete mode 100644 projects/core/utils/mask/masked-money-value-is-empty.ts delete mode 100644 projects/core/utils/mask/masked-number-string-to-number.ts delete mode 100644 projects/core/utils/mask/ng-package.json delete mode 100644 projects/core/utils/mask/test/create-correction-mask.spec.ts delete mode 100644 projects/core/utils/mask/test/masked-number-string-to-number.spec.ts delete mode 100644 projects/core/utils/mask/test/tui-create-auto-corrected-number-pipe.spec.ts delete mode 100644 projects/kit/constants/empty-mask.ts delete mode 100644 projects/kit/constants/masks.ts delete mode 100644 projects/kit/directives/mask/index.ts delete mode 100644 projects/kit/directives/mask/legacy-mask.ts delete mode 100644 projects/kit/directives/mask/ng-package.json diff --git a/projects/addon-commerce/constants/card-holder-mask.ts b/projects/addon-commerce/constants/card-holder-mask.ts index 99f2caa25f4d0..fcc1ece22be00 100644 --- a/projects/addon-commerce/constants/card-holder-mask.ts +++ b/projects/addon-commerce/constants/card-holder-mask.ts @@ -1,7 +1,5 @@ import {MaskitoOptions} from '@maskito/core'; -import {tuiCreateCorrectionMask, TuiTextMaskListHandler} from '@taiga-ui/core'; -const ALLOWED_REGEXP = /[A-Z]| /; const MAP: Record = { А: 'F', В: 'D', @@ -31,14 +29,6 @@ const MAP: Record = { Я: 'Z', }; -// TODO: delete in v4.0 -function toEnglishUppercaseLegacy(char: string): string | null { - const uppercase = char.toUpperCase(); - const result = ALLOWED_REGEXP.test(uppercase) ? uppercase : MAP[uppercase]; - - return result || null; -} - function toEnglishUppercase(value: string): string { return value .toUpperCase() @@ -63,12 +53,3 @@ export const TUI_CARD_HOLDER_MASK: MaskitoOptions = { }, ], }; - -/** - * @deprecated Use {@link TUI_CARD_HOLDER_MASK} with {@link https://github.com/taiga-family/maskito Maskito} - * TODO: delete in v4.0 - */ -export const cardHolderMask: TuiTextMaskListHandler = tuiCreateCorrectionMask( - ALLOWED_REGEXP, - toEnglishUppercaseLegacy, -); diff --git a/projects/addon-commerce/utils/create-auto-corrected-expire-pipe.ts b/projects/addon-commerce/utils/create-auto-corrected-expire-pipe.ts deleted file mode 100644 index c3f7d510cbf1e..0000000000000 --- a/projects/addon-commerce/utils/create-auto-corrected-expire-pipe.ts +++ /dev/null @@ -1,53 +0,0 @@ -import {TUI_NON_DIGIT_REGEXP, TuiTextMaskPipeHandler} from '@taiga-ui/core'; - -const TUI_EXP_YEAR_MONTH = /^\d{2}[/|.]\d{4}$/; -const TUI_EXP_SAFARI = /^\d{1,4}.\d{1,2}.\d{1,4}$/; - -/** - * @deprecated Use {@link https://maskito.dev/kit/date Date} from {@link https://github.com/taiga-family/maskito Maskito} instead - * TODO: delete in v4.0 - * Correct expiration date text allowing only valid months - * @internal - * - * @returns MM/YY - */ -export function tuiCreateAutoCorrectedExpirePipe(): TuiTextMaskPipeHandler { - return (conformedValue, {rawValue}) => { - // Autofilled with MM/YYYY format - if (TUI_EXP_YEAR_MONTH.test(rawValue)) { - conformedValue = `${rawValue.slice(0, 2)}/${rawValue.slice(5)}`; - } - - // Autofilled with Safari crazy format - if ( - rawValue.length > 7 && - rawValue.length < 11 && - TUI_EXP_SAFARI.test(rawValue) - ) { - const array = rawValue.split(TUI_NON_DIGIT_REGEXP); - - // TODO: investigate why the month is sometimes more than 2-length in safari - const month = array[1].slice(2); - const year = array.find(({length}) => length === 4); - - conformedValue = `${'0'.repeat(2 - month.length)}${month}/${ - year ? year.slice(2) : '' - }`; - } - - const indexesOfPipedChars: number[] = []; - const conformedValueArr = conformedValue.split(''); - - if (parseInt(conformedValueArr[0], 10) > 1) { - conformedValueArr[2] = '/'; - conformedValueArr[1] = conformedValueArr[0]; - conformedValueArr[0] = '0'; - indexesOfPipedChars.push(0); - } - - return { - value: conformedValueArr.join(''), - indexesOfPipedChars, - }; - }; -} diff --git a/projects/addon-commerce/utils/index.ts b/projects/addon-commerce/utils/index.ts index 465b438ff8005..0054dc9ac0df4 100644 --- a/projects/addon-commerce/utils/index.ts +++ b/projects/addon-commerce/utils/index.ts @@ -1,4 +1,3 @@ -export * from './create-auto-corrected-expire-pipe'; export * from './format-currency'; export * from './get-code-by-currency'; export * from './get-currency-by-code'; diff --git a/projects/core/components/primitive-textfield/textfield/textfield.component.ts b/projects/core/components/primitive-textfield/textfield/textfield.component.ts index 269297526ce39..ceb4368425bb6 100644 --- a/projects/core/components/primitive-textfield/textfield/textfield.component.ts +++ b/projects/core/components/primitive-textfield/textfield/textfield.component.ts @@ -1,10 +1,4 @@ -import { - ChangeDetectionStrategy, - Component, - ElementRef, - Inject, - Optional, -} from '@angular/core'; +import {ChangeDetectionStrategy, Component, ElementRef, Inject} from '@angular/core'; import {TuiIdService} from '@taiga-ui/cdk'; import { TEXTFIELD_CONTROLLER_PROVIDER, @@ -12,7 +6,7 @@ import { TuiTextfieldController, } from '@taiga-ui/core/directives'; import {TuiTextfieldHost} from '@taiga-ui/core/interfaces'; -import {TUI_LEGACY_MASK, TUI_TEXTFIELD_HOST} from '@taiga-ui/core/tokens'; +import {TUI_TEXTFIELD_HOST} from '@taiga-ui/core/tokens'; @Component({ selector: 'input[tuiTextfield], textarea[tuiTextfield]', @@ -29,7 +23,7 @@ import {TUI_LEGACY_MASK, TUI_TEXTFIELD_HOST} from '@taiga-ui/core/tokens'; '[tabIndex]': 'host.focusable ? 0 : -1', '[readOnly]': 'host.readOnly', '[value]': 'host.value', - '(input)': '!legacyMask && host.onValueChange($event.target.value)', + '(input)': 'host.onValueChange($event.target.value)', }, }) export class TuiTextfieldComponent { @@ -40,9 +34,6 @@ export class TuiTextfieldComponent { @Inject(ElementRef) private readonly el: ElementRef, @Inject(TuiIdService) private readonly idService: TuiIdService, - @Optional() - @Inject(TUI_LEGACY_MASK) - readonly legacyMask: boolean | null, ) { this.host.process(this.el.nativeElement); } diff --git a/projects/core/index.ts b/projects/core/index.ts index 0517cb3177e46..09674f7ad7e05 100644 --- a/projects/core/index.ts +++ b/projects/core/index.ts @@ -6,7 +6,6 @@ export * from '@taiga-ui/core/directives'; export * from '@taiga-ui/core/enums'; export * from '@taiga-ui/core/interfaces'; export * from '@taiga-ui/core/internal'; -export * from '@taiga-ui/core/mask'; export * from '@taiga-ui/core/observables'; export * from '@taiga-ui/core/pipes'; export * from '@taiga-ui/core/providers'; diff --git a/projects/core/mask/index.ts b/projects/core/mask/index.ts deleted file mode 100644 index 5e4dda291e62e..0000000000000 --- a/projects/core/mask/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './number-mask-options'; -export * from './text-mask-config'; -export * from './text-mask-correction-handler'; -export * from './text-mask-list'; -export * from './text-mask-list-handler'; -export * from './text-mask-options'; -export * from './text-mask-pipe-handler'; -export * from './text-mask-pipe-result'; diff --git a/projects/core/mask/ng-package.json b/projects/core/mask/ng-package.json deleted file mode 100644 index bebf62dcb5e51..0000000000000 --- a/projects/core/mask/ng-package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "lib": { - "entryFile": "index.ts" - } -} diff --git a/projects/core/mask/number-mask-options.ts b/projects/core/mask/number-mask-options.ts deleted file mode 100644 index 6d9b663d65f53..0000000000000 --- a/projects/core/mask/number-mask-options.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {TuiDecimalSymbol} from '@taiga-ui/core/types'; - -export interface TuiNumberMaskOptions { - readonly allowDecimal?: boolean; - readonly allowNegative?: boolean; - readonly autoCorrectDecimalSymbol?: boolean; - readonly decimalLimit?: number; - readonly decimalSymbol?: TuiDecimalSymbol; - readonly integerLimit?: number; - readonly requireDecimal?: boolean; - readonly thousandSymbol?: string; -} diff --git a/projects/core/mask/text-mask-config.ts b/projects/core/mask/text-mask-config.ts deleted file mode 100644 index 3f3e51685a8b2..0000000000000 --- a/projects/core/mask/text-mask-config.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} - * Link lies about config object having all the same configurations so separate interface is required - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#pipe} - */ -export interface TuiTextMaskConfig { - readonly currentCaretPosition?: number; - readonly previousConformedValue?: string; - readonly rawValue: string; -} diff --git a/projects/core/mask/text-mask-correction-handler.ts b/projects/core/mask/text-mask-correction-handler.ts deleted file mode 100644 index d5de69b6a7cb9..0000000000000 --- a/projects/core/mask/text-mask-correction-handler.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} - */ -export type TuiTextMaskCorrectionHandler = (char: string, index: number) => string | null; diff --git a/projects/core/mask/text-mask-list-handler.ts b/projects/core/mask/text-mask-list-handler.ts deleted file mode 100644 index 88cfb444da358..0000000000000 --- a/projects/core/mask/text-mask-list-handler.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {TuiTextMaskConfig} from './text-mask-config'; -import {TuiTextMaskList} from './text-mask-list'; - -/** - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} - */ -export type TuiTextMaskListHandler = ( - rawValue: string, - config: TuiTextMaskConfig, -) => TuiTextMaskList | false; diff --git a/projects/core/mask/text-mask-list.ts b/projects/core/mask/text-mask-list.ts deleted file mode 100644 index 599c51260fd9f..0000000000000 --- a/projects/core/mask/text-mask-list.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#mask-array} - */ -export type TuiTextMaskList = ReadonlyArray; diff --git a/projects/core/mask/text-mask-options.ts b/projects/core/mask/text-mask-options.ts deleted file mode 100644 index acbb30642a9de..0000000000000 --- a/projects/core/mask/text-mask-options.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type {TuiTextMaskList} from './text-mask-list'; -import type {TuiTextMaskListHandler} from './text-mask-list-handler'; -import type {TuiTextMaskPipeHandler} from './text-mask-pipe-handler'; - -/** - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md} - */ -export interface TuiTextMaskOptions { - /** - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#guide} - */ - guide?: boolean; - - /** - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#keepcharpositions} - */ - keepCharPositions?: boolean; - - /** - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#mask} - */ - mask: TuiTextMaskList | TuiTextMaskListHandler | false; - - /** - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#pipe} - */ - pipe?: TuiTextMaskPipeHandler; - - /** - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#placeholderchar} - */ - placeholderChar?: string; - - /** - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#showmask} - */ - showMask?: boolean; -} diff --git a/projects/core/mask/text-mask-pipe-handler.ts b/projects/core/mask/text-mask-pipe-handler.ts deleted file mode 100644 index 7cad3d85236ca..0000000000000 --- a/projects/core/mask/text-mask-pipe-handler.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type {TuiTextMaskConfig} from './text-mask-config'; -import type {TuiTextMaskOptions} from './text-mask-options'; -import type {TuiTextMaskPipeResult} from './text-mask-pipe-result'; - -/** - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#pipe} - */ -export type TuiTextMaskPipeHandler = ( - conformedValue: string, - config: TuiTextMaskConfig & TuiTextMaskOptions, -) => TuiTextMaskPipeResult | string | false; diff --git a/projects/core/mask/text-mask-pipe-result.ts b/projects/core/mask/text-mask-pipe-result.ts deleted file mode 100644 index 2fee35c0d64a4..0000000000000 --- a/projects/core/mask/text-mask-pipe-result.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} - * {@link https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#pipe} - */ -export interface TuiTextMaskPipeResult { - indexesOfPipedChars?: readonly number[]; - - value: string; -} diff --git a/projects/core/tokens/index.ts b/projects/core/tokens/index.ts index b2b2a0c7d592d..8a171dc097b90 100644 --- a/projects/core/tokens/index.ts +++ b/projects/core/tokens/index.ts @@ -13,7 +13,6 @@ export * from './icon-resolver'; export * from './icons'; export * from './icons-path'; export * from './is-mobile-resolution'; -export * from './legacy-mask'; export * from './media'; export * from './mode'; export * from './notification-options'; diff --git a/projects/core/tokens/legacy-mask.ts b/projects/core/tokens/legacy-mask.ts deleted file mode 100644 index d1497f2f3b62c..0000000000000 --- a/projects/core/tokens/legacy-mask.ts +++ /dev/null @@ -1,8 +0,0 @@ -import {InjectionToken} from '@angular/core'; - -/** - * @internal - * @deprecated - * Don't use it! Will be removed after changing the mask. - */ -export const TUI_LEGACY_MASK = new InjectionToken('[TUI_LEGACY_MASK]'); diff --git a/projects/core/utils/index.ts b/projects/core/utils/index.ts index e8a2ef3988c16..f2a7672663468 100644 --- a/projects/core/utils/index.ts +++ b/projects/core/utils/index.ts @@ -1,5 +1,4 @@ export * from '@taiga-ui/core/utils/dom'; export * from '@taiga-ui/core/utils/format'; -export * from '@taiga-ui/core/utils/mask'; export * from '@taiga-ui/core/utils/miscellaneous'; export * from '@taiga-ui/core/utils/mobile'; diff --git a/projects/core/utils/mask/create-auto-corrected-money-pipe.ts b/projects/core/utils/mask/create-auto-corrected-money-pipe.ts deleted file mode 100644 index 633f6d0b0e7e9..0000000000000 --- a/projects/core/utils/mask/create-auto-corrected-money-pipe.ts +++ /dev/null @@ -1,158 +0,0 @@ -/// -import { - CHAR_HYPHEN, - CHAR_NO_BREAK_SPACE, - tuiAssert, - tuiGetDocumentOrShadowRoot, - tuiIsNativeFocused, - tuiIsSafari, -} from '@taiga-ui/cdk'; -import {TuiTextMaskPipeHandler} from '@taiga-ui/core/mask'; -import {TuiDecimalSymbol} from '@taiga-ui/core/types'; - -function addDecimalSymbolIfNeeded( - value: string, - decimalSymbol: TuiDecimalSymbol = ',', -): string { - return !value.includes(decimalSymbol) ? value + decimalSymbol : value; -} - -function calculateSafariCaret( - previousValue: string = '', - current: string, - previousCaret: number, - decimalSymbol: string = ',', -): number { - const tailRegex = new RegExp(`${decimalSymbol}.+`); - const previousWithoutTail = previousValue.replace(tailRegex, ''); - const currentWithoutTail = current.replace(tailRegex, ''); - - const pasteOrCutOperation = - Math.abs(previousWithoutTail.length - currentWithoutTail.length) > 2; - - if (pasteOrCutOperation) { - return current.length; - } - - if (previousValue.length === current.length) { - if (previousValue.indexOf(decimalSymbol) <= previousCaret) { - return calculateChangedTailIndex(previousValue, current); - } - - return previousWithoutTail === currentWithoutTail - ? previousCaret - 1 - : previousCaret + 1; - } - - if (previousValue.length === 0) { - return 1; - } - - const changeLength = current.length - previousValue.length; - - return previousCaret + changeLength; -} - -function calculateChangedTailIndex(previous: string, current: string): number { - for (let i = 0; i < current.length; i++) { - if (previous[i] !== current[i]) { - return current[i] === '0' ? i : i + 1; - } - } - - return current.length; -} - -function calculateCaretGap( - previousValue: string = '', - current: string, - thousandSymbol: string, -): number { - const pasteOrCutOperation = Math.abs(previousValue.length - current.length) > 2; - - if (pasteOrCutOperation) { - return 0; - } - - const wereSpaces = previousValue.split(thousandSymbol).length; - const nowSpaces = current.split(thousandSymbol).length; - - return nowSpaces - wereSpaces; -} - -/** - * TODO: delete in v4.0 - * @deprecated Use {@link https://maskito.dev/kit/number Number} from {@link https://github.com/taiga-family/maskito Maskito} instead
- * Used to finish a number with zeros to a given precision - */ -export function tuiCreateAutoCorrectedNumberPipe( - decimalLimit: number = 0, - decimalSymbol: TuiDecimalSymbol = ',', - thousandSymbol: string = CHAR_NO_BREAK_SPACE, - nativeInput?: HTMLInputElement | null, - allowNegative?: boolean, - isIOS = false, -): TuiTextMaskPipeHandler { - ngDevMode && tuiAssert.assert(decimalLimit >= 0); - - // Guess for which browser I need this :) - let previousCaret = -1; - const unlucky = (!!nativeInput && tuiIsSafari(nativeInput)) || isIOS; - - if (nativeInput && unlucky) { - nativeInput.addEventListener('beforeinput', () => { - previousCaret = nativeInput.selectionStart || 0; - }); - } - - return (conformedValue, config) => { - // Removing everything by selecting and pressing '-' - if (!conformedValue && config.rawValue === CHAR_HYPHEN && allowNegative) { - return CHAR_HYPHEN; - } - - // remove these hacks after text mask library has changed - if (nativeInput && unlucky && tuiIsNativeFocused(nativeInput)) { - const caret = calculateSafariCaret( - config.previousConformedValue, - conformedValue, - previousCaret, - ); - - setTimeout(() => { - nativeInput.setSelectionRange(caret, caret); - }); - } - - if ( - nativeInput && - nativeInput.ownerDocument !== tuiGetDocumentOrShadowRoot(nativeInput) && - tuiIsNativeFocused(nativeInput) && - config.currentCaretPosition - ) { - const realCaretPosition = - config.currentCaretPosition + - calculateCaretGap( - config.previousConformedValue, - conformedValue, - thousandSymbol, - ); - - setTimeout(() => { - nativeInput.setSelectionRange(realCaretPosition, realCaretPosition); - }); - } - - if (conformedValue === '' || !decimalLimit || !Number.isInteger(decimalLimit)) { - return {value: conformedValue}; - } - - const withDecimalSymbol = addDecimalSymbolIfNeeded(conformedValue, decimalSymbol); - const decimalPart = withDecimalSymbol.split(decimalSymbol)[1]; - const zeroPaddingSize = decimalLimit - decimalPart.length; - - return { - value: withDecimalSymbol + '0'.repeat(zeroPaddingSize), - }; - }; -} diff --git a/projects/core/utils/mask/create-correction-mask.ts b/projects/core/utils/mask/create-correction-mask.ts deleted file mode 100644 index a8e54b860f956..0000000000000 --- a/projects/core/utils/mask/create-correction-mask.ts +++ /dev/null @@ -1,50 +0,0 @@ -/// -import {tuiAssert} from '@taiga-ui/cdk'; -import {MASK_CARET_TRAP} from '@taiga-ui/core/constants'; -import { - TuiTextMaskCorrectionHandler, - TuiTextMaskList, - TuiTextMaskListHandler, -} from '@taiga-ui/core/mask'; - -const ASSERTION = 'Correction function must return single char or null'; - -/** - * TODO: delete in v4.0 - * @deprecated Use {@link https://maskito.dev/core-concepts/processors processors} from {@link https://github.com/taiga-family/maskito Maskito} - */ -export function tuiCreateCorrectionMask( - allowed: RegExp, - correctionHandler: TuiTextMaskCorrectionHandler, -): TuiTextMaskListHandler { - return rawValue => { - const mask = rawValue.split('').reduce((result, char, index) => { - const corrected = correctionHandler(char, index); - - ngDevMode && - tuiAssert.assert(corrected === null || corrected.length === 1, ASSERTION); - - if (!allowed.test(char) && !corrected) { - return result; - } - - if (allowed.test(char)) { - return [...result, allowed]; - } - - if (corrected) { - return [...result, corrected, MASK_CARET_TRAP]; - } - - return result; - }, []); - const lastIndex = mask.lastIndexOf(MASK_CARET_TRAP); - const filtered = mask.filter( - (item, index) => item !== MASK_CARET_TRAP || index === lastIndex, - ); - - return filtered.some(item => item !== allowed) - ? [...filtered, allowed] - : filtered; - }; -} diff --git a/projects/core/utils/mask/create-number-mask.ts b/projects/core/utils/mask/create-number-mask.ts deleted file mode 100644 index dbb2e623b6367..0000000000000 --- a/projects/core/utils/mask/create-number-mask.ts +++ /dev/null @@ -1,200 +0,0 @@ -/// -import {CHAR_EN_DASH, CHAR_HYPHEN, CHAR_NO_BREAK_SPACE, tuiAssert} from '@taiga-ui/cdk'; -import { - MASK_CARET_TRAP, - TUI_DIGIT_REGEXP, - TUI_LEADING_ZEROES_REGEXP, - TUI_NON_DIGITS_REGEXP, -} from '@taiga-ui/core/constants'; -import {TuiNumberMaskOptions, TuiTextMaskListHandler} from '@taiga-ui/core/mask'; -import {TuiDecimalSymbol} from '@taiga-ui/core/types'; -import {tuiOtherDecimalSymbol} from '@taiga-ui/core/utils/format'; - -const NON_ZERO_DIGIT = /[1-9]/; - -function preventLeadingZeroes( - mask: Array, - isOnlyZeroDigit: boolean = false, - leadingZerosAmount: number = 0, -): Array { - if (isOnlyZeroDigit || leadingZerosAmount === 0) { - return mask; - } - - const firstDigitIndex = mask.indexOf(TUI_DIGIT_REGEXP); - - if (firstDigitIndex === -1) { - return mask; - } - - const secondMaskDigit = mask[firstDigitIndex + 1]; - const isCaretTrap = secondMaskDigit === MASK_CARET_TRAP; - - if (isCaretTrap && leadingZerosAmount === 1) { - return mask; - } - - if (isCaretTrap) { - mask.unshift(NON_ZERO_DIGIT); - - return mask; - } - - mask[firstDigitIndex] = NON_ZERO_DIGIT; - - return mask; -} - -function getDecimalSymbolIndex( - str: string, - decimalSymbol: TuiDecimalSymbol, - autoCorrectDecimalSymbol: boolean, -): number { - if (!autoCorrectDecimalSymbol) { - return str.lastIndexOf(decimalSymbol); - } - - return Math.max( - str.lastIndexOf(decimalSymbol), - str.lastIndexOf(tuiOtherDecimalSymbol(decimalSymbol)), - ); -} - -function isDecimalSymbol( - str: string, - decimalSymbol: TuiDecimalSymbol, - autoCorrectDecimalSymbol: boolean, -): boolean { - if (autoCorrectDecimalSymbol) { - return /^[,.]$/.test(str); - } - - return str === decimalSymbol; -} - -function convertToMask(strNumber: string): Array { - return strNumber - .split('') - .map(char => (TUI_DIGIT_REGEXP.test(char) ? TUI_DIGIT_REGEXP : char)); -} - -function addThousandsSeparator(strNumber: string, thousandSymbol: string): string { - return strNumber.length > 3 - ? // TODO: investigate to disallow potentially catastrophic exponential-time regular expressions. - // eslint-disable-next-line unicorn/no-unsafe-regex - strNumber.replace(/\B(?=(\d{3})+(?!\d))/g, thousandSymbol) - : strNumber; -} - -/** - * TODO: delete in v4.0 - * @deprecated Use {@link https://maskito.dev/kit/number Number} from {@link https://github.com/taiga-family/maskito Maskito} instead
- * Adaptation for {@link https://github.com/text-mask/text-mask/tree/master/addons#createnumbermask `createNumberMask`} - */ -export function tuiCreateNumberMask({ - allowDecimal = false, - decimalSymbol = ',', - thousandSymbol = CHAR_NO_BREAK_SPACE, - autoCorrectDecimalSymbol = true, - decimalLimit = 2, - requireDecimal = false, - allowNegative = false, - integerLimit = 0, -}: TuiNumberMaskOptions = {}): TuiTextMaskListHandler { - ngDevMode && tuiAssert.assert(decimalLimit >= 0); - ngDevMode && tuiAssert.assert(Number.isInteger(integerLimit)); - ngDevMode && tuiAssert.assert(integerLimit >= 0); - - return (rawValue, {previousConformedValue}) => { - if (previousConformedValue && requireDecimal) { - const conformedWithoutSeparator = rawValue.split(thousandSymbol).join(''); - const previousConformedValueWithoutDecimalSymbolAndSeparator = - previousConformedValue - .split(thousandSymbol) - .join('') - .split(decimalSymbol) - .join(''); - - // Forbid removal of decimal separator if decimal part is required - if ( - conformedWithoutSeparator === - previousConformedValueWithoutDecimalSymbolAndSeparator - ) { - rawValue = previousConformedValue; - } - } - - const isNegative = - (rawValue?.startsWith(CHAR_HYPHEN) || rawValue?.startsWith(CHAR_EN_DASH)) && - allowNegative; - - if ( - isDecimalSymbol(rawValue, decimalSymbol, autoCorrectDecimalSymbol) && - allowDecimal - ) { - return ['0', decimalSymbol, TUI_DIGIT_REGEXP]; - } - - if (isNegative) { - rawValue = rawValue.slice(1); - } - - const decimalIndex = getDecimalSymbolIndex( - rawValue, - decimalSymbol, - autoCorrectDecimalSymbol, - ); - const hasDecimal = decimalIndex !== -1; - const integer = hasDecimal ? rawValue.slice(0, decimalIndex) : rawValue; - const thousandSeparators = integer.match(new RegExp(thousandSymbol, 'g')) || []; - const integerCapped = integerLimit - ? integer.slice(0, integerLimit + thousandSeparators.length) - : integer; - const integerCappedClean = integerCapped.replace(TUI_NON_DIGITS_REGEXP, ''); - const [leadingZerosMatch] = integerCappedClean.match( - TUI_LEADING_ZEROES_REGEXP, - ) || ['']; - const leadingZerosAmount = leadingZerosMatch.length; - const integerCappedZerosClean = integerCappedClean - .replace(/^0+(?!\.|$)/, '') - .trim(); - const withSeparator = addThousandsSeparator( - integerCappedZerosClean, - thousandSymbol, - ); - const mask = convertToMask(withSeparator); - - if ((hasDecimal && allowDecimal) || requireDecimal) { - const fraction = hasDecimal - ? convertToMask( - rawValue.slice(decimalIndex + 1).replace(TUI_NON_DIGITS_REGEXP, ''), - ) - : []; - const fractionCapped = decimalLimit - ? fraction.slice(0, decimalLimit) - : fraction; - - if (rawValue[decimalIndex] !== tuiOtherDecimalSymbol(decimalSymbol)) { - mask.push(MASK_CARET_TRAP); - } - - mask.push(decimalSymbol, MASK_CARET_TRAP, ...fractionCapped); - - for (let i = 0; i < Math.min(decimalLimit - fractionCapped.length, 20); i++) { - mask.push(TUI_DIGIT_REGEXP); - } - } - - const isOnlyZeroDigit = mask.length === 1 && integerCappedZerosClean === '0'; - - if (isNegative) { - if (mask.length === 0) { - mask.push(TUI_DIGIT_REGEXP); - } - - mask.unshift(CHAR_HYPHEN); - } - - return preventLeadingZeroes(mask, isOnlyZeroDigit, leadingZerosAmount); - }; -} diff --git a/projects/core/utils/mask/enable-auto-correct-decimal-symbol.ts b/projects/core/utils/mask/enable-auto-correct-decimal-symbol.ts deleted file mode 100644 index 9c8b04ff8a47b..0000000000000 --- a/projects/core/utils/mask/enable-auto-correct-decimal-symbol.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {TUI_DECIMAL_SYMBOLS} from '@taiga-ui/core/constants'; -import {TuiNumberFormatSettings} from '@taiga-ui/core/interfaces'; - -/** - * TODO: delete in v4.0 - * @deprecated Use {@link https://maskito.dev/kit/number Number} from {@link https://github.com/taiga-family/maskito Maskito} instead - */ -export function tuiEnableAutoCorrectDecimalSymbol({ - thousandSeparator, -}: TuiNumberFormatSettings): boolean { - return !TUI_DECIMAL_SYMBOLS.includes(thousandSeparator); -} diff --git a/projects/core/utils/mask/index.ts b/projects/core/utils/mask/index.ts deleted file mode 100644 index 6d1a4f3d5f9b1..0000000000000 --- a/projects/core/utils/mask/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './create-auto-corrected-money-pipe'; -export * from './create-correction-mask'; -export * from './create-number-mask'; -export * from './enable-auto-correct-decimal-symbol'; -export * from './masked-money-value-is-empty'; -export * from './masked-number-string-to-number'; diff --git a/projects/core/utils/mask/masked-money-value-is-empty.ts b/projects/core/utils/mask/masked-money-value-is-empty.ts deleted file mode 100644 index b2b527f0dfbf3..0000000000000 --- a/projects/core/utils/mask/masked-money-value-is-empty.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {CHAR_HYPHEN} from '@taiga-ui/cdk'; - -/** - * TODO: delete in v4.0 - * @deprecated use {@link https://maskito.dev/kit/number maskitoParseNumber} instead - * ```ts - * Number.isNaN(maskitoParseNumber(value, decimalSeparator)) - * ``` - */ -export function tuiMaskedMoneyValueIsEmpty(value: string): boolean { - switch (value) { - case '': - case CHAR_HYPHEN: - case ',': - case `${CHAR_HYPHEN},`: - return true; - default: - return false; - } -} diff --git a/projects/core/utils/mask/masked-number-string-to-number.ts b/projects/core/utils/mask/masked-number-string-to-number.ts deleted file mode 100644 index aa1b9c040ef54..0000000000000 --- a/projects/core/utils/mask/masked-number-string-to-number.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {TuiDecimalSymbol} from '@taiga-ui/core/types'; - -/** - * TODO: delete in v4.0 - * @deprecated use {@link https://maskito.dev/kit/number maskitoParseNumber} instead - */ -export function tuiMaskedNumberStringToNumber( - value: string, - decimalsSymbol: TuiDecimalSymbol, - thousandSymbol: string, -): number { - return parseFloat( - value.split(thousandSymbol).join('').split(decimalsSymbol).join('.'), - ); -} diff --git a/projects/core/utils/mask/ng-package.json b/projects/core/utils/mask/ng-package.json deleted file mode 100644 index bebf62dcb5e51..0000000000000 --- a/projects/core/utils/mask/ng-package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "lib": { - "entryFile": "index.ts" - } -} diff --git a/projects/core/utils/mask/test/create-correction-mask.spec.ts b/projects/core/utils/mask/test/create-correction-mask.spec.ts deleted file mode 100644 index 98c23a393173b..0000000000000 --- a/projects/core/utils/mask/test/create-correction-mask.spec.ts +++ /dev/null @@ -1,37 +0,0 @@ -import {MASK_CARET_TRAP} from '../../../constants/mask-caret-trap'; -import {TuiTextMaskCorrectionHandler} from '../../../mask'; -import {tuiCreateCorrectionMask} from '../create-correction-mask'; - -const REGEXP = /[0-9]/; -const HANDLER: TuiTextMaskCorrectionHandler = char => (char === 'q' ? '3' : null); -const MASK = tuiCreateCorrectionMask(REGEXP, HANDLER); - -describe('tuiCreateCorrectionMask return', () => { - it('regex if characters are valid', () => { - expect(MASK('123', {rawValue: '123'})).toEqual([REGEXP, REGEXP, REGEXP]); - }); - - it('corrected character, caret trap and a regex if character can be fixed', () => { - expect(MASK('12q', {rawValue: '12q'})).toEqual([ - REGEXP, - REGEXP, - '3', - MASK_CARET_TRAP, - REGEXP, - ]); - }); - - it('discards a char if it cannot be fixed', () => { - expect(MASK('12w', {rawValue: '12w'})).toEqual([REGEXP, REGEXP]); - }); - - it('adds only one caret trap after last fixed character', () => { - expect(MASK('q2q', {rawValue: 'q2q'})).toEqual([ - '3', - REGEXP, - '3', - MASK_CARET_TRAP, - REGEXP, - ]); - }); -}); diff --git a/projects/core/utils/mask/test/masked-number-string-to-number.spec.ts b/projects/core/utils/mask/test/masked-number-string-to-number.spec.ts deleted file mode 100644 index 63c5c1fe76ca6..0000000000000 --- a/projects/core/utils/mask/test/masked-number-string-to-number.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import {CHAR_NO_BREAK_SPACE} from '@taiga-ui/cdk'; - -import {tuiMaskedNumberStringToNumber} from '../masked-number-string-to-number'; - -describe('Converts the text value of a number obtained from a mask into a number', () => { - it('the separator works correctly', () => { - expect( - tuiMaskedNumberStringToNumber( - `12${CHAR_NO_BREAK_SPACE}345${CHAR_NO_BREAK_SPACE}678`, - ',', - CHAR_NO_BREAK_SPACE, - ), - ).toBe(12345678); - }); - - it('correctly handles the fractional part', () => { - expect(tuiMaskedNumberStringToNumber('1,23', ',', ' ')).toBe(1.23); - }); - - it('correctly handles custom decimals and thousand symbols', () => { - expect(tuiMaskedNumberStringToNumber('200/000/000.50', '.', '/')).toBe( - 200_000_000.5, - ); - }); - - it('returns NaN if the string cannot be converted to a number', () => { - expect(tuiMaskedNumberStringToNumber('Дичь', ',', ' ')).toBeNaN(); - }); -}); diff --git a/projects/core/utils/mask/test/tui-create-auto-corrected-number-pipe.spec.ts b/projects/core/utils/mask/test/tui-create-auto-corrected-number-pipe.spec.ts deleted file mode 100644 index 96909a41b2ce8..0000000000000 --- a/projects/core/utils/mask/test/tui-create-auto-corrected-number-pipe.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import {TuiTextMaskPipeResult} from '../../../mask/text-mask-pipe-result'; -import {tuiCreateAutoCorrectedNumberPipe} from '../create-auto-corrected-money-pipe'; - -const DUMMY: any = 'any'; - -function wrapper( - rawString: string, - decimalLimit?: number, - decimalSymbol?: ',' | '.', -): string { - return ( - tuiCreateAutoCorrectedNumberPipe(decimalLimit, decimalSymbol)( - rawString, - DUMMY, - ) as TuiTextMaskPipeResult - ).value; -} - -describe('tuiCreateAutoCorrectedNumberPipe returns', () => { - describe('the original string if it', () => { - it('is blank', () => { - expect(wrapper('')).toBe(''); - }); - - it('does not contain a comma and it is not needed (by default)', () => { - expect(wrapper('-123')).toBe('-123'); - }); - - it('if the fractional part matches the format', () => { - expect(wrapper('123,45', 2)).toBe('123,45'); - }); - - it('if there is a dot and a delimiter character - dot', () => { - expect(wrapper('123.45', 2, '.')).toBe('123.45'); - }); - }); - - describe('the corrected string if the fractional part is', () => { - it('shorter than the given one', () => { - expect(wrapper('123,00', 4)).toBe('123,0000'); - }); - - it('not available at all, but needed', () => { - expect(wrapper('123', 2)).toBe('123,00'); - }); - - it('not present at all, but needed, with a dot separator', () => { - expect(wrapper('123', 2, '.')).toBe('123.00'); - }); - }); -}); diff --git a/projects/kit/constants/empty-mask.ts b/projects/kit/constants/empty-mask.ts deleted file mode 100644 index ab36773bff31c..0000000000000 --- a/projects/kit/constants/empty-mask.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {TuiTextMaskOptions} from '@taiga-ui/core'; - -/** - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} instead - * TODO: delete in v4.0 - */ -export const EMPTY_MASK: TuiTextMaskOptions = { - mask(): false { - return false; - }, -}; diff --git a/projects/kit/constants/index.ts b/projects/kit/constants/index.ts index 774c03a77b041..cca8cbb07d357 100644 --- a/projects/kit/constants/index.ts +++ b/projects/kit/constants/index.ts @@ -1,9 +1,7 @@ export * from './date-mode-maskito-adapter'; export * from './date-time-separator'; -export * from './empty-mask'; export * from './group-class-names'; export * from './mask-after-code-regexp'; -export * from './masks'; export * from './math'; export * from './max-day-range-length-mapper'; export * from './max-time-values'; diff --git a/projects/kit/constants/masks.ts b/projects/kit/constants/masks.ts deleted file mode 100644 index ccd381691754c..0000000000000 --- a/projects/kit/constants/masks.ts +++ /dev/null @@ -1,33 +0,0 @@ -import {CHAR_HYPHEN, CHAR_PLUS} from '@taiga-ui/cdk'; -import {TUI_DIGIT_REGEXP, TuiTextMaskList} from '@taiga-ui/core'; - -export const TUI_PHONE_MASK: TuiTextMaskList = [ - CHAR_PLUS, - '7', - ' ', - TUI_DIGIT_REGEXP, - TUI_DIGIT_REGEXP, - TUI_DIGIT_REGEXP, - ' ', - TUI_DIGIT_REGEXP, - TUI_DIGIT_REGEXP, - TUI_DIGIT_REGEXP, - CHAR_HYPHEN, - TUI_DIGIT_REGEXP, - TUI_DIGIT_REGEXP, - CHAR_HYPHEN, - TUI_DIGIT_REGEXP, - TUI_DIGIT_REGEXP, -]; - -/** - * @deprecated Use {@link https://maskito.dev/kit/time Time} from {@link https://github.com/taiga-family/maskito Maskito} instead - * TODO: delete in v4.0 - */ -export const TUI_TIME_MASK: TuiTextMaskList = [ - TUI_DIGIT_REGEXP, - TUI_DIGIT_REGEXP, - ':', - TUI_DIGIT_REGEXP, - TUI_DIGIT_REGEXP, -]; diff --git a/projects/kit/directives/index.ts b/projects/kit/directives/index.ts index 8d8b83cd37c21..a31f01f7c4988 100644 --- a/projects/kit/directives/index.ts +++ b/projects/kit/directives/index.ts @@ -1,7 +1,6 @@ export * from '@taiga-ui/kit/directives/data-list-dropdown-manager'; export * from '@taiga-ui/kit/directives/highlight'; export * from '@taiga-ui/kit/directives/lazy-loading'; -export * from '@taiga-ui/kit/directives/mask'; export * from '@taiga-ui/kit/directives/present'; export * from '@taiga-ui/kit/directives/project-class'; export * from '@taiga-ui/kit/directives/unfinished-validator'; diff --git a/projects/kit/directives/mask/index.ts b/projects/kit/directives/mask/index.ts deleted file mode 100644 index c65230d5a14c6..0000000000000 --- a/projects/kit/directives/mask/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './legacy-mask'; diff --git a/projects/kit/directives/mask/legacy-mask.ts b/projects/kit/directives/mask/legacy-mask.ts deleted file mode 100644 index e8935463b06a5..0000000000000 --- a/projects/kit/directives/mask/legacy-mask.ts +++ /dev/null @@ -1,177 +0,0 @@ -/* eslint-disable */ -/** - * Copied from - * {@link https://github.com/text-mask/text-mask/blob/master/angular2/src/angular2TextMask.ts angular2-text-mask} - * ___ - * "angular2-text-mask" is a legacy not-maintained library. It is published using legacy View Engine distribution. - * Stackblitz fails to run "View Engine"-libraries in Ivy application. - * See {@link https://github.com/taiga-family/taiga-ui/issues/2541#issuecomment-1235516443 this comment}. - */ -import { - Directive, - ElementRef, - forwardRef, - Inject, - Input, - NgModule, - OnChanges, - Optional, - Renderer2, -} from '@angular/core'; -import { - COMPOSITION_BUFFER_MODE, - ControlValueAccessor, - NG_VALUE_ACCESSOR, -} from '@angular/forms'; -import {ɵgetDOM as getDOM} from '@angular/platform-browser'; -import {TUI_LEGACY_MASK, TuiTextMaskOptions} from '@taiga-ui/core'; -import {createTextMaskInputElement} from 'text-mask-core'; - -/** - * We must check whether the agent is Android because composition events - * behave differently between iOS and Android. - */ -function _isAndroid(): boolean { - const userAgent = getDOM() ? getDOM().getUserAgent() : ''; - return /android (\d+)/.test(userAgent.toLowerCase()); -} - -/** - * @internal - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} - * Don't use it! - * TODO: delete in v4.0 - */ -@Directive({ - host: { - '(input)': '_handleInput($event.target.value)', - '(blur)': 'onTouched()', - '(compositionstart)': '_compositionStart()', - '(compositionend)': '_compositionEnd($event.target.value)', - }, - selector: '[textMask]', - exportAs: 'textMask', - providers: [ - { - provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => MaskedInputDirective), - multi: true, - }, - { - provide: TUI_LEGACY_MASK, - useExisting: forwardRef(() => MaskedInputDirective), - }, - ], -}) -export class MaskedInputDirective implements ControlValueAccessor, OnChanges { - @Input('textMask') textMaskConfig: TuiTextMaskOptions = { - mask: [], - guide: true, - placeholderChar: '_', - pipe: undefined, - keepCharPositions: false, - }; - - onChange = (_: any) => {}; - onTouched = () => {}; - - private textMaskInputElement: any; - private inputElement!: HTMLInputElement; - - /** Whether the user is creating a composition string (IME events). */ - private _composing = false; - - constructor( - private _renderer: Renderer2, - private _elementRef: ElementRef, - @Optional() @Inject(COMPOSITION_BUFFER_MODE) private _compositionMode: boolean, - ) { - if (this._compositionMode == null) { - this._compositionMode = !_isAndroid(); - } - } - - ngOnChanges() { - this._setupMask(true); - if (this.textMaskInputElement !== undefined) { - this.textMaskInputElement.update(this.inputElement.value); - } - } - - writeValue(value: any) { - this._setupMask(); - - // set the initial value for cases where the mask is disabled - const normalizedValue = value == null ? '' : value; - this._renderer.setProperty(this.inputElement, 'value', normalizedValue); - - if (this.textMaskInputElement !== undefined) { - this.textMaskInputElement.update(value); - } - } - - registerOnChange(fn: (_: any) => void): void { - this.onChange = fn; - } - registerOnTouched(fn: () => void): void { - this.onTouched = fn; - } - - setDisabledState(isDisabled: boolean): void { - this._renderer.setProperty(this.inputElement, 'disabled', isDisabled); - } - - _handleInput(value: any) { - if (!this._compositionMode || (this._compositionMode && !this._composing)) { - this._setupMask(); - - if (this.textMaskInputElement !== undefined) { - this.textMaskInputElement.update(value); - - // get the updated value - value = this.inputElement.value; - this.onChange(value); - } - } - } - - _setupMask(create = false) { - if (!this.inputElement) { - if (this._elementRef.nativeElement.tagName.toUpperCase() === 'INPUT') { - // `textMask` directive is used directly on an input element - this.inputElement = this._elementRef.nativeElement; - } else { - // `textMask` directive is used on an abstracted input element, `md-input-container`, etc - this.inputElement = - this._elementRef.nativeElement.getElementsByTagName('INPUT')[0]; - } - } - - if (this.inputElement && create) { - this.textMaskInputElement = createTextMaskInputElement( - Object.assign({inputElement: this.inputElement}, this.textMaskConfig), - ); - } - } - - _compositionStart(): void { - this._composing = true; - } - - _compositionEnd(value: any): void { - this._composing = false; - this._compositionMode && this._handleInput(value); - } -} - -/** - * @internal - * @deprecated Use {@link https://github.com/taiga-family/maskito Maskito} - * Don't use it! - * TODO: delete in v4.0 - */ -@NgModule({ - declarations: [MaskedInputDirective], - exports: [MaskedInputDirective], -}) -export class TextMaskModule {} diff --git a/projects/kit/directives/mask/ng-package.json b/projects/kit/directives/mask/ng-package.json deleted file mode 100644 index bebf62dcb5e51..0000000000000 --- a/projects/kit/directives/mask/ng-package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "lib": { - "entryFile": "index.ts" - } -}