@maskito/kit
Advanced tools
Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "@maskito/kit", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "The optional framework-agnostic Maskito's package with ready-to-use masks", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@maskito/core": "^0.5.0" | ||
"@maskito/core": "^0.6.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "main": "./src/index.js", |
import { maskitoPipe } from '@maskito/core'; | ||
import { CHAR_EM_DASH, CHAR_EN_DASH, CHAR_HYPHEN, CHAR_MINUS, CHAR_NO_BREAK_SPACE, } from '../../constants'; | ||
import { createDecimalZeroPaddingPostprocessor, createLeadingZeroesValidationPostprocessor, createMaxValidationPostprocessor, createNotEmptyIntegerPartPreprocessor, createPseudoCharactersPreprocessor, createSeparatorDeletionPreprocessor, createThousandSeparatorPostprocessor, } from './processors'; | ||
import { createDecimalZeroPaddingPostprocessor, createLeadingZeroesValidationPostprocessor, createMaxValidationPostprocessor, createNotEmptyIntegerPartPreprocessor, createPseudoCharactersPreprocessor, createSeparatorDeletionPreprocessor, createThousandSeparatorPostprocessor, createZeroPrecisionPreprocessor, } from './processors'; | ||
import { generateMaskExpression, getDefaultPseudoSeparators } from './utils'; | ||
export function maskitoNumberOptionsGenerator({ max = Number.MAX_SAFE_INTEGER, isNegativeAllowed = true, precision = 0, thousandSeparator = CHAR_NO_BREAK_SPACE, decimalSeparator = ',', decimalPseudoSeparators = getDefaultPseudoSeparators({ | ||
decimalSeparator, | ||
thousandSeparator, | ||
}), decimalZeroPadding = false, } = {}) { | ||
export function maskitoNumberOptionsGenerator({ max = Number.MAX_SAFE_INTEGER, isNegativeAllowed = true, precision = 0, thousandSeparator = CHAR_NO_BREAK_SPACE, decimalSeparator = '.', decimalPseudoSeparators = getDefaultPseudoSeparators(decimalSeparator, thousandSeparator), decimalZeroPadding = false, } = {}) { | ||
const pseudoMinuses = [CHAR_HYPHEN, CHAR_EN_DASH, CHAR_EM_DASH].filter(char => char !== thousandSeparator && char !== decimalSeparator); | ||
@@ -21,3 +18,3 @@ return { | ||
thousandSeparator, | ||
})), | ||
}), createZeroPrecisionPreprocessor(precision, decimalSeparator)), | ||
postprocessor: maskitoPipe(createLeadingZeroesValidationPostprocessor(decimalSeparator), createMaxValidationPostprocessor({ decimalSeparator, max }), createThousandSeparatorPostprocessor({ decimalSeparator, thousandSeparator }), createDecimalZeroPaddingPostprocessor({ | ||
@@ -24,0 +21,0 @@ decimalSeparator, |
@@ -8,2 +8,3 @@ export * from './decimal-zero-padding-postprocessor'; | ||
export * from './thousand-separator-postprocessor'; | ||
export * from './zero-precision-preprocessor'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,2 +8,3 @@ export * from './decimal-zero-padding-postprocessor'; | ||
export * from './thousand-separator-postprocessor'; | ||
export * from './zero-precision-preprocessor'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,2 @@ | ||
export declare function getDefaultPseudoSeparators({ decimalSeparator, thousandSeparator, }: { | ||
decimalSeparator: string; | ||
thousandSeparator: string; | ||
}): string[]; | ||
export declare function getDefaultPseudoSeparators(decimalSeparator: string, thousandSeparator: string): string[]; | ||
//# sourceMappingURL=get-default-pseudo-separators.d.ts.map |
@@ -1,7 +0,6 @@ | ||
export function getDefaultPseudoSeparators({ decimalSeparator, thousandSeparator, }) { | ||
if (decimalSeparator === ',' || decimalSeparator === '.') { | ||
return ['.', ',', 'б', 'ю'].filter(char => char !== thousandSeparator && char !== decimalSeparator); | ||
} | ||
return []; | ||
export function getDefaultPseudoSeparators(decimalSeparator, thousandSeparator) { | ||
return decimalSeparator === ',' || decimalSeparator === '.' | ||
? ['.', ',', 'б', 'ю'].filter(char => char !== thousandSeparator && char !== decimalSeparator) | ||
: []; | ||
} | ||
//# sourceMappingURL=get-default-pseudo-separators.js.map |
@@ -0,6 +1,9 @@ | ||
import { CHAR_EM_DASH, CHAR_EN_DASH, CHAR_HYPHEN, CHAR_MINUS } from '../../../constants'; | ||
export function maskitoParseNumber(maskedNumber, decimalSeparator = '.') { | ||
return Number(maskedNumber | ||
.replace(new RegExp(`[^\\d\\${decimalSeparator}]`, 'g'), '') | ||
.replace(decimalSeparator, '.')); | ||
const negativeSign = maskedNumber.match(new RegExp(`^[${CHAR_MINUS}\\${CHAR_HYPHEN}${CHAR_EN_DASH}${CHAR_EM_DASH}]`)); | ||
return Number((negativeSign ? CHAR_HYPHEN : '') + | ||
maskedNumber | ||
.replace(new RegExp(`[^\\d\\${decimalSeparator}]`, 'g'), '') | ||
.replace(decimalSeparator, '.')); | ||
} | ||
//# sourceMappingURL=parse-number.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
198504
286
1318