Skip to content

Commit

Permalink
fix(kit): fixed trailing whitespace with not CHAR_MINUS as minus(i=mi…
Browse files Browse the repository at this point in the history
…nus,type:i123,result:i 123)
  • Loading branch information
Stanslav Zaytsev committed Mar 5, 2024
1 parent 9a06e71 commit 4fdce96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions projects/kit/src/lib/masks/number/number-mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export function maskitoNumberOptionsGenerator({
thousandSeparator,
prefix,
postfix,
minusSign,
}),
createDecimalZeroPaddingPostprocessor({
decimalSeparator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {MaskitoPostprocessor} from '@maskito/core';

import {CHAR_MINUS} from '../../../constants';
import {extractAffixes, identity} from '../../../utils';

/**
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 +
Expand Down

0 comments on commit 4fdce96

Please sign in to comment.