From f23cef5366ec70e1a98f9c8ea1af579fd442ade1 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 11:21:30 +0300
Subject: [PATCH 01/32] feat(kit): added support of custom minus sign for
number
---
.../kit/src/lib/masks/number/number-mask.ts | 25 +++++++++++++------
.../initialization-only-preprocessor.ts | 3 +++
.../number/utils/generate-mask-expression.ts | 5 ++--
3 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/projects/kit/src/lib/masks/number/number-mask.ts b/projects/kit/src/lib/masks/number/number-mask.ts
index c05f1a2e3..437393349 100644
--- a/projects/kit/src/lib/masks/number/number-mask.ts
+++ b/projects/kit/src/lib/masks/number/number-mask.ts
@@ -43,6 +43,7 @@ export function maskitoNumberOptionsGenerator({
decimalZeroPadding = false,
prefix: unsafePrefix = '',
postfix = '',
+ minusSign = CHAR_MINUS,
}: {
min?: number;
max?: number;
@@ -53,13 +54,21 @@ export function maskitoNumberOptionsGenerator({
thousandSeparator?: string;
prefix?: string;
postfix?: string;
+ minusSign?: string;
} = {}): Required {
- const pseudoMinuses = [
- CHAR_HYPHEN,
- CHAR_EN_DASH,
- CHAR_EM_DASH,
- CHAR_JP_HYPHEN,
- ].filter(char => char !== thousandSeparator && char !== decimalSeparator);
+ const pseudoMinuses: string[] = [
+ ...new Set([
+ CHAR_HYPHEN,
+ CHAR_EN_DASH,
+ CHAR_EM_DASH,
+ CHAR_JP_HYPHEN,
+ CHAR_MINUS,
+ minusSign,
+ ]),
+ ].filter(
+ char =>
+ char !== thousandSeparator && char !== decimalSeparator && char !== minusSign,
+ );
const validatedDecimalPseudoSeparators = validateDecimalPseudoSeparators({
decimalSeparator,
thousandSeparator,
@@ -79,6 +88,7 @@ export function maskitoNumberOptionsGenerator({
prefix,
postfix,
isNegativeAllowed: min < 0,
+ minusSign,
}),
preprocessors: [
createFullWidthToHalfWidthPreprocessor(),
@@ -88,10 +98,11 @@ export function maskitoNumberOptionsGenerator({
pseudoMinuses,
prefix,
postfix,
+ minusSign,
}),
createAffixesFilterPreprocessor({prefix, postfix}),
createPseudoCharactersPreprocessor({
- validCharacter: CHAR_MINUS,
+ validCharacter: minusSign,
pseudoCharacters: pseudoMinuses,
prefix,
postfix,
diff --git a/projects/kit/src/lib/masks/number/processors/initialization-only-preprocessor.ts b/projects/kit/src/lib/masks/number/processors/initialization-only-preprocessor.ts
index e2e8bdece..b00257cb5 100644
--- a/projects/kit/src/lib/masks/number/processors/initialization-only-preprocessor.ts
+++ b/projects/kit/src/lib/masks/number/processors/initialization-only-preprocessor.ts
@@ -19,12 +19,14 @@ export function createInitializationOnlyPreprocessor({
pseudoMinuses,
prefix,
postfix,
+ minusSign,
}: {
decimalSeparator: string;
decimalPseudoSeparators: readonly string[];
pseudoMinuses: readonly string[];
prefix: string;
postfix: string;
+ minusSign: string;
}): MaskitoPreprocessor {
let isInitializationPhase = true;
const cleanNumberMask = generateMaskExpression({
@@ -36,6 +38,7 @@ export function createInitializationOnlyPreprocessor({
thousandSeparator: '',
precision: Infinity,
isNegativeAllowed: true,
+ minusSign,
});
return ({elementState, data}) => {
diff --git a/projects/kit/src/lib/masks/number/utils/generate-mask-expression.ts b/projects/kit/src/lib/masks/number/utils/generate-mask-expression.ts
index b89348765..6688d6e15 100644
--- a/projects/kit/src/lib/masks/number/utils/generate-mask-expression.ts
+++ b/projects/kit/src/lib/masks/number/utils/generate-mask-expression.ts
@@ -1,6 +1,5 @@
import {MaskitoMask} from '@maskito/core';
-import {CHAR_MINUS} from '../../../constants';
import {escapeRegExp} from '../../../utils';
export function generateMaskExpression({
@@ -12,6 +11,7 @@ export function generateMaskExpression({
postfix,
decimalPseudoSeparators = [],
pseudoMinuses = [],
+ minusSign,
}: {
decimalSeparator: string;
isNegativeAllowed: boolean;
@@ -21,11 +21,12 @@ export function generateMaskExpression({
postfix: string;
decimalPseudoSeparators?: readonly string[];
pseudoMinuses?: readonly string[];
+ minusSign: string;
}): MaskitoMask {
const computedPrefix = computeAllOptionalCharsRegExp(prefix);
const digit = '\\d';
const optionalMinus = isNegativeAllowed
- ? `[${CHAR_MINUS}${pseudoMinuses.map(x => `\\${x}`).join('')}]?`
+ ? `[${minusSign}${pseudoMinuses.map(x => `\\${x}`).join('')}]?`
: '';
const integerPart = thousandSeparator
? `[${digit}${escapeRegExp(thousandSeparator).replaceAll(/\s/g, '\\s')}]*`
From a187ea20fa6fa74fc181fa22fcdd60cc64422e45 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 11:23:20 +0300
Subject: [PATCH 02/32] fix(demo): added minusSign property with default value
CHAR_MINUS
---
projects/demo/src/pages/kit/number/number-mask-doc.component.ts | 2 ++
1 file changed, 2 insertions(+)
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
index 7cedb6704..958a6a10f 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
@@ -12,6 +12,7 @@ import {
import {TuiAddonDocModule, TuiDocExample} from '@taiga-ui/addon-doc';
import {TuiNotificationModule} from '@taiga-ui/core';
import {tuiInputCountOptionsProvider, TuiInputModule} from '@taiga-ui/kit';
+import {CHAR_MINUS} from 'projects/kit/src/lib/constants';
import {NumberMaskDocExample1} from './examples/1-high-precision/component';
import {NumberMaskDocExample2} from './examples/2-separators/component';
@@ -97,6 +98,7 @@ export class NumberMaskDocComponent implements GeneratorOptions {
public thousandSeparator = ' ';
public prefix = '';
public postfix = '';
+ public minusSign = CHAR_MINUS;
protected maskitoOptions: MaskitoOptions = this.calculateMask(this);
From c94d0d79d2a515a77fd21a9dff6ec6c7789dfc08 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 13:30:51 +0300
Subject: [PATCH 03/32] docs(demo): added component and mask for minusSign
documentation
---
.../6-custom-minus-sign/components.ts | 28 +++++++++++++++++++
.../examples/6-custom-minus-sign/mask.ts | 9 ++++++
2 files changed, 37 insertions(+)
create mode 100644 projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
create mode 100644 projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts
diff --git a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
new file mode 100644
index 000000000..a51115ff0
--- /dev/null
+++ b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
@@ -0,0 +1,28 @@
+import {Component} from '@angular/core';
+import {MaskitoDirective} from '@maskito/angular';
+import {MaskitoOptions} from '@maskito/core';
+import {TuiTextfieldControllerModule} from '@taiga-ui/core';
+import {TuiInputModule} from '@taiga-ui/kit';
+
+import {getMaskitoOptions} from './mask';
+
+@Component({
+ standalone: true,
+ selector: 'number-mask-doc-example-6',
+ imports: [TuiInputModule, TuiTextfieldControllerModule, MaskitoDirective],
+ template: `
+
+
+
+ `,
+})
+export class NumberMaskDocExample6 {
+ protected minusSign = '\u30FC';
+
+ protected getMaskOptions(minusSign: string): MaskitoOptions {
+ return getMaskitoOptions(minusSign);
+ }
+}
diff --git a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts
new file mode 100644
index 000000000..ae96b52e0
--- /dev/null
+++ b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts
@@ -0,0 +1,9 @@
+import {MaskitoOptions} from '@maskito/core';
+import {maskitoNumberOptionsGenerator} from '@maskito/kit';
+
+export function getMaskitoOptions(minusSign: string): MaskitoOptions {
+ return maskitoNumberOptionsGenerator({
+ thousandSeparator: '',
+ minusSign,
+ });
+}
From 8cc911ee7b307940b379c16320e24f6e5e5e9055 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 13:32:28 +0300
Subject: [PATCH 04/32] docs(demo): added minusSign example to docs page
---
.../kit/number/number-mask-doc.component.ts | 11 ++++++++++
.../kit/number/number-mask-doc.template.html | 22 +++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
index 958a6a10f..8f5039def 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
@@ -19,6 +19,7 @@ import {NumberMaskDocExample2} from './examples/2-separators/component';
import {NumberMaskDocExample3} from './examples/3-postfix/component';
import {NumberMaskDocExample4} from './examples/4-decimal-zero-padding/component';
import {NumberMaskDocExample5} from './examples/5-dynamic-decimal-zero-padding/component';
+import {NumberMaskDocExample6} from './examples/6-custom-minus-sign/components';
type GeneratorOptions = Required<
NonNullable[0]>
@@ -38,6 +39,7 @@ type GeneratorOptions = Required<
NumberMaskDocExample3,
NumberMaskDocExample4,
NumberMaskDocExample5,
+ NumberMaskDocExample6,
],
templateUrl: './number-mask-doc.template.html',
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -79,6 +81,15 @@ export class NumberMaskDocComponent implements GeneratorOptions {
),
};
+ protected readonly customMinusSignExample6: TuiDocExample = {
+ [DocExamplePrimaryTab.MaskitoOptions]: import(
+ './examples/6-custom-minus-sign/mask.ts?raw'
+ ),
+ [DocExamplePrimaryTab.Angular]: import(
+ './examples/6-custom-minus-sign/components.ts?raw'
+ ),
+ };
+
protected apiPageControl = new FormControl('');
protected readonly decimalPseudoSeparatorsOptions = [
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.template.html b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
index 66290f20e..153b79a0a 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.template.html
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
@@ -118,6 +118,28 @@
+
+
+
+
+ You can use
+ minusSign
+ option for your convenience in working with negative numbers.
+
+
+ In this exapmle
+ Katakana-Hiragana Prolonged Sound Mark
+ is used as
+ minusSign
+
+
+
+
From a845be8bfd43adc95c6171b9503aa146969571d9 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 13:40:11 +0300
Subject: [PATCH 05/32] docs(demo): added initianl value for custom minus sign
example
---
.../examples/6-custom-minus-sign/components.ts | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
index a51115ff0..1aaf895e4 100644
--- a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
+++ b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
@@ -1,4 +1,5 @@
import {Component} from '@angular/core';
+import {FormsModule} from '@angular/forms';
import {MaskitoDirective} from '@maskito/angular';
import {MaskitoOptions} from '@maskito/core';
import {TuiTextfieldControllerModule} from '@taiga-ui/core';
@@ -9,9 +10,17 @@ import {getMaskitoOptions} from './mask';
@Component({
standalone: true,
selector: 'number-mask-doc-example-6',
- imports: [TuiInputModule, TuiTextfieldControllerModule, MaskitoDirective],
+ imports: [
+ TuiInputModule,
+ TuiTextfieldControllerModule,
+ MaskitoDirective,
+ FormsModule,
+ ],
template: `
-
+
Date: Mon, 4 Mar 2024 13:47:43 +0300
Subject: [PATCH 06/32] docs(demo): added minus sign to api docs
---
.../pages/kit/number/number-mask-doc.template.html | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.template.html b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
index 153b79a0a..bbccc569a 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.template.html
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
@@ -308,6 +308,20 @@
empty string (no postfix).
+
+ A minus symbol.
+
+
+ Default:
+ \u2212
+
+
From b9907350cbb858373d6d9a43f8c960a8eb39d5ad Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 14:29:31 +0300
Subject: [PATCH 07/32] test(kit): added unit tests for minus sign
---
.../masks/number/tests/number-mask.spec.ts | 48 +++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts b/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
index 28e94e7e3..bee38a200 100644
--- a/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
+++ b/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
@@ -318,4 +318,52 @@ describe('Number (maskitoTransform)', () => {
});
});
});
+
+ describe('applies `minusSign` property correctly', () => {
+ let options = MASKITO_DEFAULT_OPTIONS;
+
+ describe('correctly applies ⁻ as minus sign', () => {
+ beforeEach(() => {
+ options = maskitoNumberOptionsGenerator({minusSign: '⁻'});
+ });
+
+ it('-32412 => ⁻32 412', () => {
+ expect(maskitoTransform('-32412', options)).toBe('⁻32 412');
+ });
+
+ it('\u002D32413 => ⁻32 413', () => {
+ expect(maskitoTransform('\u002D32413', options)).toBe('⁻32 413');
+ });
+
+ it('-32411 => ⁻32 411', () => {
+ expect(maskitoTransform('-32411', options)).toBe('⁻32 411');
+ });
+
+ it('\u201332411 => ⁻32 411', () => {
+ expect(maskitoTransform('\u201332411', options)).toBe('⁻32 411');
+ });
+ });
+
+ describe('correctly applies i as minus sign', () => {
+ beforeEach(() => {
+ options = maskitoNumberOptionsGenerator({minusSign: 'i'});
+ });
+
+ it('-32412 => i32 412', () => {
+ expect(maskitoTransform('-32412', options)).toBe('i32 412');
+ });
+
+ it('\u002D32413 => i32 413', () => {
+ expect(maskitoTransform('\u002D32413', options)).toBe('i32 413');
+ });
+
+ it('-32411 => i32 411', () => {
+ expect(maskitoTransform('-32411', options)).toBe('i32 411');
+ });
+
+ it('\u201332411 => i32 411', () => {
+ expect(maskitoTransform('\u201332411', options)).toBe('i32 411');
+ });
+ });
+ });
});
From 2129290d355b0f828ca8316235e0ef8a356ffeea Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 15:15:44 +0300
Subject: [PATCH 08/32] test(demo-integrations): added e2e tests for number
minus sign prop
---
.../tests/kit/number/number-minus-sign.cy.ts | 47 +++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
diff --git a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
new file mode 100644
index 000000000..8b5df75cb
--- /dev/null
+++ b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
@@ -0,0 +1,47 @@
+import {openNumberPage} from './utils';
+
+describe('Properly using custom minus sign', () => {
+ describe('correctly applies \u002D as minus sign', () => {
+ beforeEach(() => {
+ openNumberPage('minusSign=\u002D');
+ });
+
+ it('-32412 => \u002D32 412', () => {
+ cy.get('@input').type('-32412').should('have.value', '\u002D32 412');
+ });
+
+ it('\u002D32412 => \u002D32 412', () => {
+ cy.get('@input').type('-32412').should('have.value', '\u002D32 412');
+ });
+
+ it('\u30FC32412 => \u002D32 412', () => {
+ cy.get('@input').type('\u30FC32412').should('have.value', '\u002D32 412');
+ });
+
+ it('\u201332412 => \u002D32 412', () => {
+ cy.get('@input').type('\u201332412').should('have.value', '\u002D32 412');
+ });
+ });
+
+ describe('correctly works with decimal, and minus sign is i', () => {
+ beforeEach(() => {
+ openNumberPage('minusSign=i&precision=Infinity');
+ });
+
+ it('-324,12 => i324.12', () => {
+ cy.get('@input').type('-324,12').should('have.value', 'i 324.12');
+ });
+
+ it('\u002D324,12 => i324.12', () => {
+ cy.get('@input').type('\u002D324,12').should('have.value', 'i 324.12');
+ });
+
+ it('\u30FC324,12 => i324.12', () => {
+ cy.get('@input').type('\u30FC324,12').should('have.value', 'i 324.12');
+ });
+
+ it('\u2013324,12 => i324.12', () => {
+ cy.get('@input').type('\u2013324,12').should('have.value', 'i 324.12');
+ });
+ });
+});
From b512ab088cd6f1bbdce58e2b8df4667fd2ff9380 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 15:28:18 +0300
Subject: [PATCH 09/32] fix(demo): incorrectly spelled word corrected
---
.../demo/src/pages/kit/number/number-mask-doc.template.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.template.html b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
index bbccc569a..a5b00e9dd 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.template.html
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
@@ -132,7 +132,7 @@
option for your convenience in working with negative numbers.
- In this exapmle
+ In this example
Katakana-Hiragana Prolonged Sound Mark
is used as
minusSign
From ab80b15e879ff5cdf3c155df45be857ce502f78a Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 15:43:21 +0300
Subject: [PATCH 10/32] refactor(kit): replaced defenition of pseudoMinus
---
projects/kit/src/lib/masks/number/number-mask.ts | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/projects/kit/src/lib/masks/number/number-mask.ts b/projects/kit/src/lib/masks/number/number-mask.ts
index 437393349..197a009c5 100644
--- a/projects/kit/src/lib/masks/number/number-mask.ts
+++ b/projects/kit/src/lib/masks/number/number-mask.ts
@@ -57,14 +57,12 @@ export function maskitoNumberOptionsGenerator({
minusSign?: string;
} = {}): Required {
const pseudoMinuses: string[] = [
- ...new Set([
- CHAR_HYPHEN,
- CHAR_EN_DASH,
- CHAR_EM_DASH,
- CHAR_JP_HYPHEN,
- CHAR_MINUS,
- minusSign,
- ]),
+ CHAR_HYPHEN,
+ CHAR_EN_DASH,
+ CHAR_EM_DASH,
+ CHAR_JP_HYPHEN,
+ CHAR_MINUS,
+ minusSign,
].filter(
char =>
char !== thousandSeparator && char !== decimalSeparator && char !== minusSign,
From 4ded341bf2703cee1a5b061dfc0a1afd40fb3f90 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 15:49:44 +0300
Subject: [PATCH 11/32] docs(demo): changed minus sign of the example, and
refactored example componenet
---
.../examples/6-custom-minus-sign/components.ts | 12 ++++--------
.../pages/kit/number/number-mask-doc.template.html | 6 +++---
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
index 1aaf895e4..85a055b33 100644
--- a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
+++ b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
@@ -1,12 +1,12 @@
import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {MaskitoDirective} from '@maskito/angular';
-import {MaskitoOptions} from '@maskito/core';
import {TuiTextfieldControllerModule} from '@taiga-ui/core';
import {TuiInputModule} from '@taiga-ui/kit';
import {getMaskitoOptions} from './mask';
+const mask = getMaskitoOptions('-');
@Component({
standalone: true,
selector: 'number-mask-doc-example-6',
@@ -23,16 +23,12 @@ import {getMaskitoOptions} from './mask';
>
`,
})
export class NumberMaskDocExample6 {
- protected value = '\u30FC42';
- protected minusSign = '\u30FC';
-
- protected getMaskOptions(minusSign: string): MaskitoOptions {
- return getMaskitoOptions(minusSign);
- }
+ protected value = '-42';
+ protected options = mask;
}
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.template.html b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
index a5b00e9dd..c47676a34 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.template.html
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
@@ -120,8 +120,8 @@
@@ -133,7 +133,7 @@
In this example
- Katakana-Hiragana Prolonged Sound Mark
+ Hyphen-Minus
is used as
minusSign
From 9c8856e39976b0f2915ba1f4670674ea7b5b3e80 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 15:52:06 +0300
Subject: [PATCH 12/32] refactor(demo): added readonly modifer for options
---
.../pages/kit/number/examples/6-custom-minus-sign/components.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
index 85a055b33..12c4541a2 100644
--- a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
+++ b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
@@ -30,5 +30,5 @@ const mask = getMaskitoOptions('-');
})
export class NumberMaskDocExample6 {
protected value = '-42';
- protected options = mask;
+ protected readonly options = mask;
}
From c2f9bf043c867d52b48ff59029c9ad5670297cdd Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 16:13:38 +0300
Subject: [PATCH 13/32] refactor(demo): refactored mask.ts and component.ts to
be as all other examples
---
.../number/examples/6-custom-minus-sign/components.ts | 3 +--
.../kit/number/examples/6-custom-minus-sign/mask.ts | 11 ++++-------
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
index 12c4541a2..f2ee2d17e 100644
--- a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
+++ b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
@@ -4,9 +4,8 @@ import {MaskitoDirective} from '@maskito/angular';
import {TuiTextfieldControllerModule} from '@taiga-ui/core';
import {TuiInputModule} from '@taiga-ui/kit';
-import {getMaskitoOptions} from './mask';
+import mask from './mask';
-const mask = getMaskitoOptions('-');
@Component({
standalone: true,
selector: 'number-mask-doc-example-6',
diff --git a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts
index ae96b52e0..8c9b3858f 100644
--- a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts
+++ b/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts
@@ -1,9 +1,6 @@
-import {MaskitoOptions} from '@maskito/core';
import {maskitoNumberOptionsGenerator} from '@maskito/kit';
-export function getMaskitoOptions(minusSign: string): MaskitoOptions {
- return maskitoNumberOptionsGenerator({
- thousandSeparator: '',
- minusSign,
- });
-}
+export default maskitoNumberOptionsGenerator({
+ minusSign: '-',
+ thousandSeparator: '',
+});
From e8ec10ac08b41676872b898c02f8b9b4ca8b04a5 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 16:21:17 +0300
Subject: [PATCH 14/32] refactor(kit): added using constants in unit tests
---
.../masks/number/tests/number-mask.spec.ts | 23 +++++++++++--------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts b/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
index bee38a200..25955a3c0 100644
--- a/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
+++ b/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
@@ -1,7 +1,12 @@
import {MASKITO_DEFAULT_OPTIONS, MaskitoOptions, maskitoTransform} from '@maskito/core';
import {maskitoParseNumber} from '@maskito/kit';
-import {CHAR_NO_BREAK_SPACE, CHAR_ZERO_WIDTH_SPACE} from '../../../constants';
+import {
+ CHAR_EN_DASH,
+ CHAR_HYPHEN,
+ CHAR_NO_BREAK_SPACE,
+ CHAR_ZERO_WIDTH_SPACE,
+} from '../../../constants';
import {maskitoNumberOptionsGenerator} from '../number-mask';
describe('Number (maskitoTransform)', () => {
@@ -331,16 +336,16 @@ describe('Number (maskitoTransform)', () => {
expect(maskitoTransform('-32412', options)).toBe('⁻32 412');
});
- it('\u002D32413 => ⁻32 413', () => {
- expect(maskitoTransform('\u002D32413', options)).toBe('⁻32 413');
+ it(`${CHAR_HYPHEN}32413 => ⁻32 413`, () => {
+ expect(maskitoTransform(`${CHAR_HYPHEN}32413`, options)).toBe('⁻32 413');
});
it('-32411 => ⁻32 411', () => {
expect(maskitoTransform('-32411', options)).toBe('⁻32 411');
});
- it('\u201332411 => ⁻32 411', () => {
- expect(maskitoTransform('\u201332411', options)).toBe('⁻32 411');
+ it(`${CHAR_EN_DASH}32411 => ⁻32 411`, () => {
+ expect(maskitoTransform(`${CHAR_EN_DASH}32411`, options)).toBe('⁻32 411');
});
});
@@ -353,16 +358,16 @@ describe('Number (maskitoTransform)', () => {
expect(maskitoTransform('-32412', options)).toBe('i32 412');
});
- it('\u002D32413 => i32 413', () => {
- expect(maskitoTransform('\u002D32413', options)).toBe('i32 413');
+ it(`${CHAR_HYPHEN}32413 => i32 413`, () => {
+ expect(maskitoTransform(`${CHAR_HYPHEN}32413`, options)).toBe('i32 413');
});
it('-32411 => i32 411', () => {
expect(maskitoTransform('-32411', options)).toBe('i32 411');
});
- it('\u201332411 => i32 411', () => {
- expect(maskitoTransform('\u201332411', options)).toBe('i32 411');
+ it(`${CHAR_EN_DASH}32411 => i32 411`, () => {
+ expect(maskitoTransform(`${CHAR_EN_DASH}32411`, options)).toBe('i32 411');
});
});
});
From 9c0efc6eff8625f30977b9337e611bcd45535854 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 16:37:21 +0300
Subject: [PATCH 15/32] refactor(demo-integrations): added using constants in
CT
---
.../tests/kit/number/number-minus-sign.cy.ts | 50 ++++++++++++-------
1 file changed, 31 insertions(+), 19 deletions(-)
diff --git a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
index 8b5df75cb..2fe07edee 100644
--- a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
+++ b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
@@ -1,47 +1,59 @@
+import {CHAR_EN_DASH, CHAR_HYPHEN, CHAR_JP_HYPHEN} from 'projects/kit/src/lib/constants';
+
import {openNumberPage} from './utils';
describe('Properly using custom minus sign', () => {
- describe('correctly applies \u002D as minus sign', () => {
+ describe(`correctly applies ${CHAR_HYPHEN} as minus sign`, () => {
beforeEach(() => {
- openNumberPage('minusSign=\u002D');
+ openNumberPage('minusSign=\u002D&thousandSeparator=_');
});
- it('-32412 => \u002D32 412', () => {
- cy.get('@input').type('-32412').should('have.value', '\u002D32 412');
+ it(`-32412 => ${CHAR_HYPHEN}32_412`, () => {
+ cy.get('@input').type('-32412').should('have.value', `${CHAR_HYPHEN}32_412`);
});
- it('\u002D32412 => \u002D32 412', () => {
- cy.get('@input').type('-32412').should('have.value', '\u002D32 412');
+ it(`${CHAR_HYPHEN}32412 => ${CHAR_HYPHEN}32_412`, () => {
+ cy.get('@input').type('-32412').should('have.value', `${CHAR_HYPHEN}32_412`);
});
- it('\u30FC32412 => \u002D32 412', () => {
- cy.get('@input').type('\u30FC32412').should('have.value', '\u002D32 412');
+ it(`${CHAR_JP_HYPHEN}32412 => ${CHAR_HYPHEN}32_412`, () => {
+ cy.get('@input')
+ .type(`${CHAR_JP_HYPHEN}32412`)
+ .should('have.value', `${CHAR_HYPHEN}32_412`);
});
- it('\u201332412 => \u002D32 412', () => {
- cy.get('@input').type('\u201332412').should('have.value', '\u002D32 412');
+ it(`${CHAR_EN_DASH}32412 => ${CHAR_HYPHEN}32_412`, () => {
+ cy.get('@input')
+ .type(`${CHAR_EN_DASH}32412`)
+ .should('have.value', `${CHAR_HYPHEN}32_412`);
});
});
describe('correctly works with decimal, and minus sign is i', () => {
beforeEach(() => {
- openNumberPage('minusSign=i&precision=Infinity');
+ openNumberPage('minusSign=i&precision=Infinity&thousandSeparator=_');
});
- it('-324,12 => i324.12', () => {
- cy.get('@input').type('-324,12').should('have.value', 'i 324.12');
+ it('-324,12 => i_324.12', () => {
+ cy.get('@input').type('-324,12').should('have.value', 'i_324.12');
});
- it('\u002D324,12 => i324.12', () => {
- cy.get('@input').type('\u002D324,12').should('have.value', 'i 324.12');
+ it(`${CHAR_HYPHEN}324,12 => i_324.12`, () => {
+ cy.get('@input')
+ .type(`${CHAR_HYPHEN}324,12`)
+ .should('have.value', 'i_324.12');
});
- it('\u30FC324,12 => i324.12', () => {
- cy.get('@input').type('\u30FC324,12').should('have.value', 'i 324.12');
+ it(`${CHAR_JP_HYPHEN}324,12 => i_324.12`, () => {
+ cy.get('@input')
+ .type(`${CHAR_JP_HYPHEN}324,12`)
+ .should('have.value', 'i_324.12');
});
- it('\u2013324,12 => i324.12', () => {
- cy.get('@input').type('\u2013324,12').should('have.value', 'i 324.12');
+ it(`${CHAR_EN_DASH}324,12 => i_324.12`, () => {
+ cy.get('@input')
+ .type(`${CHAR_EN_DASH}324,12`)
+ .should('have.value', 'i_324.12');
});
});
});
From 9a06e71240d1b4d0f845774aa36f3ac4c110483a Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Mon, 4 Mar 2024 17:15:38 +0300
Subject: [PATCH 16/32] test(demo-integrations): added using unicode constats
---
.../src/tests/kit/number/number-minus-sign.cy.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
index 2fe07edee..9840da941 100644
--- a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
+++ b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
@@ -5,7 +5,7 @@ import {openNumberPage} from './utils';
describe('Properly using custom minus sign', () => {
describe(`correctly applies ${CHAR_HYPHEN} as minus sign`, () => {
beforeEach(() => {
- openNumberPage('minusSign=\u002D&thousandSeparator=_');
+ openNumberPage(`minusSign=${CHAR_HYPHEN}&thousandSeparator=_`);
});
it(`-32412 => ${CHAR_HYPHEN}32_412`, () => {
From 4fdce9605094c7f685d6166a2e029e617bd0dc5e Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Tue, 5 Mar 2024 16:32:31 +0300
Subject: [PATCH 17/32] fix(kit): fixed trailing whitespace with not CHAR_MINUS
as minus(i=minus,type:i123,result:i 123)
---
projects/kit/src/lib/masks/number/number-mask.ts | 1 +
.../number/processors/thousand-separator-postprocessor.ts | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/projects/kit/src/lib/masks/number/number-mask.ts b/projects/kit/src/lib/masks/number/number-mask.ts
index 197a009c5..910cde2a1 100644
--- a/projects/kit/src/lib/masks/number/number-mask.ts
+++ b/projects/kit/src/lib/masks/number/number-mask.ts
@@ -143,6 +143,7 @@ export function maskitoNumberOptionsGenerator({
thousandSeparator,
prefix,
postfix,
+ minusSign,
}),
createDecimalZeroPaddingPostprocessor({
decimalSeparator,
diff --git a/projects/kit/src/lib/masks/number/processors/thousand-separator-postprocessor.ts b/projects/kit/src/lib/masks/number/processors/thousand-separator-postprocessor.ts
index 64ba8c508..bb1b516e2 100644
--- a/projects/kit/src/lib/masks/number/processors/thousand-separator-postprocessor.ts
+++ b/projects/kit/src/lib/masks/number/processors/thousand-separator-postprocessor.ts
@@ -1,6 +1,5 @@
import {MaskitoPostprocessor} from '@maskito/core';
-import {CHAR_MINUS} from '../../../constants';
import {extractAffixes, identity} from '../../../utils';
/**
@@ -12,11 +11,13 @@ export function createThousandSeparatorPostprocessor({
decimalSeparator,
prefix,
postfix,
+ minusSign,
}: {
thousandSeparator: string;
decimalSeparator: string;
prefix: string;
postfix: string;
+ minusSign: string;
}): MaskitoPostprocessor {
if (!thousandSeparator) {
return identity;
@@ -31,7 +32,7 @@ export function createThousandSeparatorPostprocessor({
});
const [integerPart, decimalPart = ''] = cleanValue
- .replace(CHAR_MINUS, '')
+ .replace(minusSign, '')
.split(decimalSeparator);
const [initialFrom, initialTo] = selection;
let [from, to] = selection;
@@ -83,7 +84,7 @@ export function createThousandSeparatorPostprocessor({
return {
value:
extractedPrefix +
- (cleanValue.includes(CHAR_MINUS) ? CHAR_MINUS : '') +
+ (cleanValue.includes(minusSign) ? minusSign : '') +
processedIntegerPart +
(cleanValue.includes(decimalSeparator) ? decimalSeparator : '') +
decimalPart +
From ac55a1f323ad599da2fe81c21a9f035a2ed7cd4f Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Tue, 5 Mar 2024 17:58:26 +0300
Subject: [PATCH 18/32] test(kit): refactored unit tests
---
.../masks/number/tests/number-mask.spec.ts | 76 ++++++++-----------
1 file changed, 33 insertions(+), 43 deletions(-)
diff --git a/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts b/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
index 25955a3c0..79bb8f1b8 100644
--- a/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
+++ b/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
@@ -2,8 +2,11 @@ import {MASKITO_DEFAULT_OPTIONS, MaskitoOptions, maskitoTransform} from '@maskit
import {maskitoParseNumber} from '@maskito/kit';
import {
+ CHAR_EM_DASH,
CHAR_EN_DASH,
CHAR_HYPHEN,
+ CHAR_JP_HYPHEN,
+ CHAR_MINUS,
CHAR_NO_BREAK_SPACE,
CHAR_ZERO_WIDTH_SPACE,
} from '../../../constants';
@@ -325,49 +328,36 @@ describe('Number (maskitoTransform)', () => {
});
describe('applies `minusSign` property correctly', () => {
- let options = MASKITO_DEFAULT_OPTIONS;
-
- describe('correctly applies ⁻ as minus sign', () => {
- beforeEach(() => {
- options = maskitoNumberOptionsGenerator({minusSign: '⁻'});
- });
-
- it('-32412 => ⁻32 412', () => {
- expect(maskitoTransform('-32412', options)).toBe('⁻32 412');
- });
-
- it(`${CHAR_HYPHEN}32413 => ⁻32 413`, () => {
- expect(maskitoTransform(`${CHAR_HYPHEN}32413`, options)).toBe('⁻32 413');
- });
-
- it('-32411 => ⁻32 411', () => {
- expect(maskitoTransform('-32411', options)).toBe('⁻32 411');
- });
-
- it(`${CHAR_EN_DASH}32411 => ⁻32 411`, () => {
- expect(maskitoTransform(`${CHAR_EN_DASH}32411`, options)).toBe('⁻32 411');
- });
- });
-
- describe('correctly applies i as minus sign', () => {
- beforeEach(() => {
- options = maskitoNumberOptionsGenerator({minusSign: 'i'});
- });
-
- it('-32412 => i32 412', () => {
- expect(maskitoTransform('-32412', options)).toBe('i32 412');
- });
-
- it(`${CHAR_HYPHEN}32413 => i32 413`, () => {
- expect(maskitoTransform(`${CHAR_HYPHEN}32413`, options)).toBe('i32 413');
- });
-
- it('-32411 => i32 411', () => {
- expect(maskitoTransform('-32411', options)).toBe('i32 411');
- });
-
- it(`${CHAR_EN_DASH}32411 => i32 411`, () => {
- expect(maskitoTransform(`${CHAR_EN_DASH}32411`, options)).toBe('i32 411');
+ const minuses = [
+ {value: CHAR_HYPHEN, name: 'hyphen'},
+ {value: CHAR_MINUS, name: 'unicode minus sign'},
+ {value: 'i', name: 'i'},
+ ];
+
+ const numbers = ['23', '321', '2 432'];
+
+ const pseudoMinuses = [
+ {value: CHAR_HYPHEN, name: 'hyphen'},
+ {value: CHAR_EN_DASH, name: 'en-dash'},
+ {value: CHAR_EM_DASH, name: 'em-dash'},
+ {value: CHAR_JP_HYPHEN, name: 'japanese prolonged sound mark'},
+ {value: CHAR_MINUS, name: 'unicode minus sign'},
+ ];
+
+ minuses.forEach(minus => {
+ const options = maskitoNumberOptionsGenerator({
+ minusSign: minus.value,
+ thousandSeparator: ' ',
+ });
+
+ pseudoMinuses.forEach(pseudoMinus => {
+ numbers.forEach(number => {
+ it(`transforms ${pseudoMinus.name} into ${minus.name}`, () => {
+ expect(
+ maskitoTransform(`${pseudoMinus.value}${number}`, options),
+ ).toBe(`${minus.value}${number}`);
+ });
+ });
});
});
});
From b7dac00377ac8771c55f4c6b60ce5b112a08647e Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 09:02:59 +0300
Subject: [PATCH 19/32] test(demo-integrations): refactored tests for custom
minus sign in number
---
.../tests/kit/number/number-minus-sign.cy.ts | 90 ++++++++-----------
1 file changed, 38 insertions(+), 52 deletions(-)
diff --git a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
index 9840da941..32b6d3db8 100644
--- a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
+++ b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
@@ -1,59 +1,45 @@
-import {CHAR_EN_DASH, CHAR_HYPHEN, CHAR_JP_HYPHEN} from 'projects/kit/src/lib/constants';
+import {
+ CHAR_EM_DASH,
+ CHAR_EN_DASH,
+ CHAR_HYPHEN,
+ CHAR_JP_HYPHEN,
+ CHAR_MINUS,
+} from 'projects/kit/src/lib/constants';
import {openNumberPage} from './utils';
describe('Properly using custom minus sign', () => {
- describe(`correctly applies ${CHAR_HYPHEN} as minus sign`, () => {
- beforeEach(() => {
- openNumberPage(`minusSign=${CHAR_HYPHEN}&thousandSeparator=_`);
- });
-
- it(`-32412 => ${CHAR_HYPHEN}32_412`, () => {
- cy.get('@input').type('-32412').should('have.value', `${CHAR_HYPHEN}32_412`);
- });
-
- it(`${CHAR_HYPHEN}32412 => ${CHAR_HYPHEN}32_412`, () => {
- cy.get('@input').type('-32412').should('have.value', `${CHAR_HYPHEN}32_412`);
- });
-
- it(`${CHAR_JP_HYPHEN}32412 => ${CHAR_HYPHEN}32_412`, () => {
- cy.get('@input')
- .type(`${CHAR_JP_HYPHEN}32412`)
- .should('have.value', `${CHAR_HYPHEN}32_412`);
- });
-
- it(`${CHAR_EN_DASH}32412 => ${CHAR_HYPHEN}32_412`, () => {
- cy.get('@input')
- .type(`${CHAR_EN_DASH}32412`)
- .should('have.value', `${CHAR_HYPHEN}32_412`);
- });
- });
-
- describe('correctly works with decimal, and minus sign is i', () => {
- beforeEach(() => {
- openNumberPage('minusSign=i&precision=Infinity&thousandSeparator=_');
- });
-
- it('-324,12 => i_324.12', () => {
- cy.get('@input').type('-324,12').should('have.value', 'i_324.12');
- });
-
- it(`${CHAR_HYPHEN}324,12 => i_324.12`, () => {
- cy.get('@input')
- .type(`${CHAR_HYPHEN}324,12`)
- .should('have.value', 'i_324.12');
- });
-
- it(`${CHAR_JP_HYPHEN}324,12 => i_324.12`, () => {
- cy.get('@input')
- .type(`${CHAR_JP_HYPHEN}324,12`)
- .should('have.value', 'i_324.12');
- });
-
- it(`${CHAR_EN_DASH}324,12 => i_324.12`, () => {
- cy.get('@input')
- .type(`${CHAR_EN_DASH}324,12`)
- .should('have.value', 'i_324.12');
+ const minuses: Array<{value: string; name: string; asQueryParam: string}> = [
+ {value: CHAR_HYPHEN, name: 'hyphen', asQueryParam: '-'},
+ {value: 'i', name: 'i', asQueryParam: 'i'},
+ ];
+
+ const numbers = ['321', '2_432'];
+
+ const pseudoMinuses: Array<{value: string; name: string}> = [
+ {value: CHAR_HYPHEN, name: 'hyphen'},
+ {value: CHAR_EN_DASH, name: 'en-dash'},
+ {value: CHAR_EM_DASH, name: 'em-dash'},
+ {value: CHAR_JP_HYPHEN, name: 'japanese prolonged sound mark'},
+ {value: CHAR_MINUS, name: 'unicode minus sign'},
+ ];
+
+ minuses.forEach(minus => {
+ if (minus.value === 'i') {
+ pseudoMinuses.push(minus);
+ }
+
+ pseudoMinuses.forEach(pseudoMinus => {
+ numbers.forEach(number => {
+ it(`transforms ${pseudoMinus.name} into ${minus.name}`, () => {
+ openNumberPage(
+ `precision=Infinity&thousandSeparator=_&minusSign=${minus.asQueryParam}`,
+ );
+ cy.get('@input')
+ .type(`${pseudoMinus.value}${number}`)
+ .should('have.value', `${minus.value}${number}`);
+ });
+ });
});
});
});
From 6174d0531708088351398debcf6720e74bf5894a Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 09:13:06 +0300
Subject: [PATCH 20/32] refactor(demo): swaped 5th and 6th examples
---
.../components.ts | 4 +--
.../mask.ts | 0
.../component.ts | 4 +--
.../mask.ts | 0
.../kit/number/number-mask-doc.component.ts | 16 ++++-----
.../kit/number/number-mask-doc.template.html | 36 +++++++++----------
6 files changed, 30 insertions(+), 30 deletions(-)
rename projects/demo/src/pages/kit/number/examples/{6-custom-minus-sign => 5-custom-minus-sign}/components.ts (90%)
rename projects/demo/src/pages/kit/number/examples/{6-custom-minus-sign => 5-custom-minus-sign}/mask.ts (100%)
rename projects/demo/src/pages/kit/number/examples/{5-dynamic-decimal-zero-padding => 6-dynamic-decimal-zero-padding}/component.ts (97%)
rename projects/demo/src/pages/kit/number/examples/{5-dynamic-decimal-zero-padding => 6-dynamic-decimal-zero-padding}/mask.ts (100%)
diff --git a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts b/projects/demo/src/pages/kit/number/examples/5-custom-minus-sign/components.ts
similarity index 90%
rename from projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
rename to projects/demo/src/pages/kit/number/examples/5-custom-minus-sign/components.ts
index f2ee2d17e..988cc4fd5 100644
--- a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/components.ts
+++ b/projects/demo/src/pages/kit/number/examples/5-custom-minus-sign/components.ts
@@ -8,7 +8,7 @@ import mask from './mask';
@Component({
standalone: true,
- selector: 'number-mask-doc-example-6',
+ selector: 'number-mask-doc-example-5',
imports: [
TuiInputModule,
TuiTextfieldControllerModule,
@@ -27,7 +27,7 @@ import mask from './mask';
`,
})
-export class NumberMaskDocExample6 {
+export class NumberMaskDocExample5 {
protected value = '-42';
protected readonly options = mask;
}
diff --git a/projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts b/projects/demo/src/pages/kit/number/examples/5-custom-minus-sign/mask.ts
similarity index 100%
rename from projects/demo/src/pages/kit/number/examples/6-custom-minus-sign/mask.ts
rename to projects/demo/src/pages/kit/number/examples/5-custom-minus-sign/mask.ts
diff --git a/projects/demo/src/pages/kit/number/examples/5-dynamic-decimal-zero-padding/component.ts b/projects/demo/src/pages/kit/number/examples/6-dynamic-decimal-zero-padding/component.ts
similarity index 97%
rename from projects/demo/src/pages/kit/number/examples/5-dynamic-decimal-zero-padding/component.ts
rename to projects/demo/src/pages/kit/number/examples/6-dynamic-decimal-zero-padding/component.ts
index 1f1f6f2af..f34f2060e 100644
--- a/projects/demo/src/pages/kit/number/examples/5-dynamic-decimal-zero-padding/component.ts
+++ b/projects/demo/src/pages/kit/number/examples/6-dynamic-decimal-zero-padding/component.ts
@@ -16,7 +16,7 @@ import {getMaskitoOptions} from './mask';
@Component({
standalone: true,
- selector: 'number-mask-doc-example-5',
+ selector: 'number-mask-doc-example-6',
imports: [
TuiLabelModule,
TuiInputModule,
@@ -42,7 +42,7 @@ import {getMaskitoOptions} from './mask';
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class NumberMaskDocExample5 {
+export class NumberMaskDocExample6 {
protected value = '42';
protected decimalZeroPadding = this.value.includes('.');
diff --git a/projects/demo/src/pages/kit/number/examples/5-dynamic-decimal-zero-padding/mask.ts b/projects/demo/src/pages/kit/number/examples/6-dynamic-decimal-zero-padding/mask.ts
similarity index 100%
rename from projects/demo/src/pages/kit/number/examples/5-dynamic-decimal-zero-padding/mask.ts
rename to projects/demo/src/pages/kit/number/examples/6-dynamic-decimal-zero-padding/mask.ts
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
index 8f5039def..425d7afe5 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
@@ -18,8 +18,8 @@ import {NumberMaskDocExample1} from './examples/1-high-precision/component';
import {NumberMaskDocExample2} from './examples/2-separators/component';
import {NumberMaskDocExample3} from './examples/3-postfix/component';
import {NumberMaskDocExample4} from './examples/4-decimal-zero-padding/component';
-import {NumberMaskDocExample5} from './examples/5-dynamic-decimal-zero-padding/component';
-import {NumberMaskDocExample6} from './examples/6-custom-minus-sign/components';
+import {NumberMaskDocExample5} from './examples/5-custom-minus-sign/components';
+import {NumberMaskDocExample6} from './examples/6-dynamic-decimal-zero-padding/component';
type GeneratorOptions = Required<
NonNullable[0]>
@@ -72,21 +72,21 @@ export class NumberMaskDocComponent implements GeneratorOptions {
),
};
- protected readonly dynamicDecimalZeroPaddingExample5: TuiDocExample = {
+ protected readonly customMinusSignExample5: TuiDocExample = {
[DocExamplePrimaryTab.MaskitoOptions]: import(
- './examples/5-dynamic-decimal-zero-padding/mask.ts?raw'
+ './examples/5-custom-minus-sign/mask.ts?raw'
),
[DocExamplePrimaryTab.Angular]: import(
- './examples/5-dynamic-decimal-zero-padding/component.ts?raw'
+ './examples/5-custom-minus-sign/components.ts?raw'
),
};
- protected readonly customMinusSignExample6: TuiDocExample = {
+ protected readonly dynamicDecimalZeroPaddingExample6: TuiDocExample = {
[DocExamplePrimaryTab.MaskitoOptions]: import(
- './examples/6-custom-minus-sign/mask.ts?raw'
+ './examples/6-dynamic-decimal-zero-padding/mask.ts?raw'
),
[DocExamplePrimaryTab.Angular]: import(
- './examples/6-custom-minus-sign/components.ts?raw'
+ './examples/6-dynamic-decimal-zero-padding/component.ts?raw'
),
};
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.template.html b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
index c47676a34..dfa6c780e 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.template.html
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
@@ -102,27 +102,10 @@
-
-
- You can change options on the fly to build complex logic.
-
- This example shows how to initially disable
- decimalZeroPadding
- and enable it only after user inserts decimal separator.
-
-
-
-
-
@@ -140,6 +123,23 @@
+
+
+
+ You can change options on the fly to build complex logic.
+
+ This example shows how to initially disable
+ decimalZeroPadding
+ and enable it only after user inserts decimal separator.
+
+
+
+
From 72200c1e22fe0f7186c0aa125ec9f7cc2e73df01 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 09:24:34 +0300
Subject: [PATCH 21/32] docs(demo): changed documentation for minus sign
---
.../kit/number/number-mask-doc.template.html | 22 +++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.template.html b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
index dfa6c780e..3f357d1f4 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.template.html
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
@@ -110,13 +110,20 @@
>
- You can use
+ Use
minusSign
- option for your convenience in working with negative numbers.
+ parameter to configure the character which indicates that a number is negative.
In this example
- Hyphen-Minus
+
+ hyphen
+
is used as
minusSign
@@ -319,7 +326,14 @@
Default:
- \u2212
+
+ \u2212
+
From c8182e06c022a894d4474fa9354c6490882c785c Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 09:27:04 +0300
Subject: [PATCH 22/32] refactor(kit): removed minusSign from pseudoMinuses and
type annotation for this array
---
projects/kit/src/lib/masks/number/number-mask.ts | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/projects/kit/src/lib/masks/number/number-mask.ts b/projects/kit/src/lib/masks/number/number-mask.ts
index 910cde2a1..0cdeaa2d3 100644
--- a/projects/kit/src/lib/masks/number/number-mask.ts
+++ b/projects/kit/src/lib/masks/number/number-mask.ts
@@ -56,13 +56,12 @@ export function maskitoNumberOptionsGenerator({
postfix?: string;
minusSign?: string;
} = {}): Required {
- const pseudoMinuses: string[] = [
+ const pseudoMinuses = [
CHAR_HYPHEN,
CHAR_EN_DASH,
CHAR_EM_DASH,
CHAR_JP_HYPHEN,
CHAR_MINUS,
- minusSign,
].filter(
char =>
char !== thousandSeparator && char !== decimalSeparator && char !== minusSign,
From 1e3276eeb77e7529ae3f7237a5c3a10f019b5c3c Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 09:30:07 +0300
Subject: [PATCH 23/32] docs(demo): changed import of CHAR_MINUS and deleted
importing component
---
.../demo/src/pages/kit/number/number-mask-doc.component.ts | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
index 425d7afe5..762c8ded5 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
@@ -9,10 +9,10 @@ import {
maskitoNumberOptionsGenerator,
maskitoRemoveOnBlurPlugin,
} from '@maskito/kit';
+import {CHAR_MINUS} from '@maskito/kit/src/lib/constants';
import {TuiAddonDocModule, TuiDocExample} from '@taiga-ui/addon-doc';
import {TuiNotificationModule} from '@taiga-ui/core';
import {tuiInputCountOptionsProvider, TuiInputModule} from '@taiga-ui/kit';
-import {CHAR_MINUS} from 'projects/kit/src/lib/constants';
import {NumberMaskDocExample1} from './examples/1-high-precision/component';
import {NumberMaskDocExample2} from './examples/2-separators/component';
@@ -76,9 +76,6 @@ export class NumberMaskDocComponent implements GeneratorOptions {
[DocExamplePrimaryTab.MaskitoOptions]: import(
'./examples/5-custom-minus-sign/mask.ts?raw'
),
- [DocExamplePrimaryTab.Angular]: import(
- './examples/5-custom-minus-sign/components.ts?raw'
- ),
};
protected readonly dynamicDecimalZeroPaddingExample6: TuiDocExample = {
From 957f8e9f778303fd2c1c010a88b19b8234c59353 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 14:54:21 +0300
Subject: [PATCH 24/32] fix(demo): swaped example inputs
---
.../demo/src/pages/kit/number/number-mask-doc.template.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.template.html b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
index 3f357d1f4..6d40ed529 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.template.html
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.template.html
@@ -128,7 +128,7 @@
minusSign
-
+
-
+
From a477de09c8dd4681986d1d866f3d98bf3a14d0bb Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 15:43:47 +0300
Subject: [PATCH 25/32] docs(demo): added tuiLinkModule for number example
---
.../demo/src/pages/kit/number/number-mask-doc.component.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
index 762c8ded5..c60d60c2c 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
@@ -11,7 +11,7 @@ import {
} from '@maskito/kit';
import {CHAR_MINUS} from '@maskito/kit/src/lib/constants';
import {TuiAddonDocModule, TuiDocExample} from '@taiga-ui/addon-doc';
-import {TuiNotificationModule} from '@taiga-ui/core';
+import {TuiLinkModule, TuiNotificationModule} from '@taiga-ui/core';
import {tuiInputCountOptionsProvider, TuiInputModule} from '@taiga-ui/kit';
import {NumberMaskDocExample1} from './examples/1-high-precision/component';
@@ -34,6 +34,7 @@ type GeneratorOptions = Required<
TuiAddonDocModule,
TuiInputModule,
TuiNotificationModule,
+ TuiLinkModule,
NumberMaskDocExample1,
NumberMaskDocExample2,
NumberMaskDocExample3,
From a6e54791fa62b55394457bf67ce0822ea045c110 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 17:01:04 +0300
Subject: [PATCH 26/32] refactor(demo): changed width of minus example input
---
.../pages/kit/number/examples/5-custom-minus-sign/components.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/projects/demo/src/pages/kit/number/examples/5-custom-minus-sign/components.ts b/projects/demo/src/pages/kit/number/examples/5-custom-minus-sign/components.ts
index 988cc4fd5..134b3faf4 100644
--- a/projects/demo/src/pages/kit/number/examples/5-custom-minus-sign/components.ts
+++ b/projects/demo/src/pages/kit/number/examples/5-custom-minus-sign/components.ts
@@ -17,6 +17,7 @@ import mask from './mask';
],
template: `
From 0fb572818b6dad4b993f66fc77276d4b0d3ef746 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 17:11:52 +0300
Subject: [PATCH 27/32] fix(kit): fixed error with parsing min-max value with
custom minus
---
projects/kit/src/lib/masks/number/number-mask.ts | 2 +-
.../lib/masks/number/processors/min-max-postprocessor.ts | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/projects/kit/src/lib/masks/number/number-mask.ts b/projects/kit/src/lib/masks/number/number-mask.ts
index 0cdeaa2d3..f643320bf 100644
--- a/projects/kit/src/lib/masks/number/number-mask.ts
+++ b/projects/kit/src/lib/masks/number/number-mask.ts
@@ -134,7 +134,7 @@ export function maskitoNumberOptionsGenerator({
}),
],
postprocessors: [
- createMinMaxPostprocessor({decimalSeparator, min, max}),
+ createMinMaxPostprocessor({decimalSeparator, min, max, minusSign}),
maskitoPrefixPostprocessorGenerator(prefix),
maskitoPostfixPostprocessorGenerator(postfix),
createThousandSeparatorPostprocessor({
diff --git a/projects/kit/src/lib/masks/number/processors/min-max-postprocessor.ts b/projects/kit/src/lib/masks/number/processors/min-max-postprocessor.ts
index 3ceaf474f..3feee98c1 100644
--- a/projects/kit/src/lib/masks/number/processors/min-max-postprocessor.ts
+++ b/projects/kit/src/lib/masks/number/processors/min-max-postprocessor.ts
@@ -1,6 +1,6 @@
import {MaskitoPostprocessor} from '@maskito/core';
-import {CHAR_HYPHEN, CHAR_MINUS} from '../../../constants';
+import {CHAR_HYPHEN} from '../../../constants';
import {maskitoParseNumber} from '../utils';
/**
@@ -11,10 +11,12 @@ export function createMinMaxPostprocessor({
min,
max,
decimalSeparator,
+ minusSign,
}: {
min: number;
max: number;
decimalSeparator: string;
+ minusSign: string;
}): MaskitoPostprocessor {
return ({value, selection}) => {
const parsedNumber = maskitoParseNumber(value, decimalSeparator);
@@ -34,7 +36,7 @@ export function createMinMaxPostprocessor({
if (!Number.isNaN(parsedNumber) && limitedValue !== parsedNumber) {
const newValue = `${limitedValue}`
.replace('.', decimalSeparator)
- .replace(CHAR_HYPHEN, CHAR_MINUS);
+ .replace(CHAR_HYPHEN, minusSign);
return {
value: newValue,
From 2a222bda6cf9fe1c82788389f02703935293d08d Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Wed, 6 Mar 2024 17:29:43 +0300
Subject: [PATCH 28/32] test(kit): added test with custom minus and min value
---
.../masks/number/tests/number-mask.spec.ts | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts b/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
index 79bb8f1b8..6148c2586 100644
--- a/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
+++ b/projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
@@ -361,4 +361,37 @@ describe('Number (maskitoTransform)', () => {
});
});
});
+
+ describe('custom minus should properly work with min(max) value', () => {
+ let options = MASKITO_DEFAULT_OPTIONS;
+
+ [
+ {value: CHAR_HYPHEN, name: 'hyphen'},
+ {value: CHAR_EN_DASH, name: 'en-dash'},
+ {value: CHAR_EM_DASH, name: 'em-dash'},
+ {value: CHAR_JP_HYPHEN, name: 'japanese prolonged sound mark'},
+ {value: CHAR_MINUS, name: 'unicode minus sign'},
+ ].forEach(minus => {
+ describe(`applies ${minus.name} properly`, () => {
+ beforeEach(() => {
+ options = maskitoNumberOptionsGenerator({
+ min: -123,
+ minusSign: minus.value,
+ });
+ });
+
+ it(`-94 => ${minus.value}94`, () => {
+ expect(maskitoTransform(`${minus.value}94`, options)).toBe(
+ `${minus.value}94`,
+ );
+ });
+
+ it(`-432 => ${minus.value}123`, () => {
+ expect(maskitoTransform(`${minus.value}432`, options)).toBe(
+ `${minus.value}123`,
+ );
+ });
+ });
+ });
+ });
});
From 8a3b3f73748798e3a287cba211e0722bdedf1ce4 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Thu, 7 Mar 2024 08:12:20 +0300
Subject: [PATCH 29/32] test(demo-integrations): added e2e tests for min value
with custom minus
---
.../tests/kit/number/number-minus-sign.cy.ts | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
index 32b6d3db8..a29104d49 100644
--- a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
+++ b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
@@ -43,3 +43,37 @@ describe('Properly using custom minus sign', () => {
});
});
});
+
+describe('custom minus should work properly with min(max) value', () => {
+ [
+ {value: CHAR_HYPHEN, name: 'hyphen', asQueryParam: '-'},
+ {value: CHAR_EN_DASH, name: 'en-dash', asQueryParam: '%E2%80%93'},
+ {value: CHAR_EM_DASH, name: 'em-dash', asQueryParam: '%E2%80%94'},
+ {
+ value: CHAR_JP_HYPHEN,
+ name: 'japanese prolonged sound mark',
+ asQueryParam: '%E3%83%BC',
+ },
+ {value: CHAR_MINUS, name: 'unicode minus sign', asQueryParam: '%E2%88%92'},
+ ].forEach(minus => {
+ describe(`applies ${minus.name} properly`, () => {
+ beforeEach(() => {
+ openNumberPage(
+ `min=-123&thousandSeparator=_&minusSign=${minus.asQueryParam}`,
+ );
+ });
+
+ it(`-94 => ${minus.value}94`, () => {
+ cy.get('@input')
+ .type(`${minus.value}94`)
+ .should('have.value', `${minus.value}94`);
+ });
+
+ it(`-432 => ${minus.value}123`, () => {
+ cy.get('@input')
+ .type(`${minus.value}432`)
+ .should('have.value', `${minus.value}123`);
+ });
+ });
+ });
+});
From c1ea1456012381eabd462e97a1c1f6ae170e27e7 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Thu, 7 Mar 2024 08:22:13 +0300
Subject: [PATCH 30/32] test(demo-integrations): refactored first block of
tests, and added some more
---
.../tests/kit/number/number-minus-sign.cy.ts | 25 +++++++++++++++----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
index a29104d49..046b63f1e 100644
--- a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
+++ b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
@@ -11,7 +11,8 @@ import {openNumberPage} from './utils';
describe('Properly using custom minus sign', () => {
const minuses: Array<{value: string; name: string; asQueryParam: string}> = [
{value: CHAR_HYPHEN, name: 'hyphen', asQueryParam: '-'},
- {value: 'i', name: 'i', asQueryParam: 'i'},
+ {value: CHAR_EN_DASH, name: 'en-dash', asQueryParam: '%E2%80%93'},
+ {value: CHAR_EM_DASH, name: 'em-dash', asQueryParam: '%E2%80%94'},
];
const numbers = ['321', '2_432'];
@@ -25,10 +26,6 @@ describe('Properly using custom minus sign', () => {
];
minuses.forEach(minus => {
- if (minus.value === 'i') {
- pseudoMinuses.push(minus);
- }
-
pseudoMinuses.forEach(pseudoMinus => {
numbers.forEach(number => {
it(`transforms ${pseudoMinus.name} into ${minus.name}`, () => {
@@ -42,6 +39,24 @@ describe('Properly using custom minus sign', () => {
});
});
});
+
+ describe('can use letters as minus sign', () => {
+ beforeEach(() => {
+ openNumberPage('precision=Infinity&thousandSeparator=_&minusSign=i');
+ });
+
+ it('transforms i into i', () => {
+ cy.get('@input').type('i1234').should('have.value', 'i1_234');
+ });
+
+ pseudoMinuses.forEach(pseudoMinus => {
+ it(`transforms ${pseudoMinus.name} into i`, () => {
+ cy.get('@input')
+ .type(`${pseudoMinus.value}1234`)
+ .should('have.value', 'i1_234');
+ });
+ });
+ });
});
describe('custom minus should work properly with min(max) value', () => {
From 9a158ee6a97ffa022d52037d27f0b21460b105b2 Mon Sep 17 00:00:00 2001
From: Stanslav Zaytsev
Date: Thu, 7 Mar 2024 10:58:30 +0300
Subject: [PATCH 31/32] test(demo-integrations): refactored encodeing chars for
queryString
---
.../tests/kit/number/number-minus-sign.cy.ts | 30 ++++++++++++-------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
index 046b63f1e..38eb6d300 100644
--- a/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
+++ b/projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
@@ -9,10 +9,19 @@ import {
import {openNumberPage} from './utils';
describe('Properly using custom minus sign', () => {
- const minuses: Array<{value: string; name: string; asQueryParam: string}> = [
- {value: CHAR_HYPHEN, name: 'hyphen', asQueryParam: '-'},
- {value: CHAR_EN_DASH, name: 'en-dash', asQueryParam: '%E2%80%93'},
- {value: CHAR_EM_DASH, name: 'em-dash', asQueryParam: '%E2%80%94'},
+ const minuses: Array<{value: string; name: string}> = [
+ {
+ value: CHAR_HYPHEN,
+ name: 'hyphen',
+ },
+ {
+ value: CHAR_EN_DASH,
+ name: 'en-dash',
+ },
+ {
+ value: CHAR_EM_DASH,
+ name: 'em-dash',
+ },
];
const numbers = ['321', '2_432'];
@@ -30,7 +39,7 @@ describe('Properly using custom minus sign', () => {
numbers.forEach(number => {
it(`transforms ${pseudoMinus.name} into ${minus.name}`, () => {
openNumberPage(
- `precision=Infinity&thousandSeparator=_&minusSign=${minus.asQueryParam}`,
+ `precision=Infinity&thousandSeparator=_&minusSign=${encodeURIComponent(minus.value)}`,
);
cy.get('@input')
.type(`${pseudoMinus.value}${number}`)
@@ -61,20 +70,19 @@ describe('Properly using custom minus sign', () => {
describe('custom minus should work properly with min(max) value', () => {
[
- {value: CHAR_HYPHEN, name: 'hyphen', asQueryParam: '-'},
- {value: CHAR_EN_DASH, name: 'en-dash', asQueryParam: '%E2%80%93'},
- {value: CHAR_EM_DASH, name: 'em-dash', asQueryParam: '%E2%80%94'},
+ {value: CHAR_HYPHEN, name: 'hyphen'},
+ {value: CHAR_EN_DASH, name: 'en-dash'},
+ {value: CHAR_EM_DASH, name: 'em-dash'},
{
value: CHAR_JP_HYPHEN,
name: 'japanese prolonged sound mark',
- asQueryParam: '%E3%83%BC',
},
- {value: CHAR_MINUS, name: 'unicode minus sign', asQueryParam: '%E2%88%92'},
+ {value: CHAR_MINUS, name: 'unicode minus sign'},
].forEach(minus => {
describe(`applies ${minus.name} properly`, () => {
beforeEach(() => {
openNumberPage(
- `min=-123&thousandSeparator=_&minusSign=${minus.asQueryParam}`,
+ `min=-123&thousandSeparator=_&minusSign=${encodeURIComponent(minus.value)}`,
);
});
From c5cf0a0bb1da1949cec8cecde3d1426ac05ff717 Mon Sep 17 00:00:00 2001
From: taiga-family-bot
Date: Thu, 7 Mar 2024 08:40:52 +0000
Subject: [PATCH 32/32] chore: apply changes after linting [bot]
---
.../demo/src/pages/kit/number/number-mask-doc.component.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
index da35b55dc..90b018e73 100644
--- a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
+++ b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts
@@ -10,7 +10,8 @@ import {
maskitoRemoveOnBlurPlugin,
} from '@maskito/kit';
import {CHAR_MINUS} from '@maskito/kit/src/lib/constants';
-import {TuiAddonDocModule, TuiDocExample} from '@taiga-ui/addon-doc';
+import type {TuiDocExample} from '@taiga-ui/addon-doc';
+import {TuiAddonDocModule} from '@taiga-ui/addon-doc';
import {TuiLinkModule, TuiNotificationModule} from '@taiga-ui/core';
import {tuiInputCountOptionsProvider, TuiInputModule} from '@taiga-ui/kit';