@maskito/kit
Advanced tools
Comparing version 0.15.0 to 0.16.0
@@ -1,2 +0,2 @@ | ||
import { MASKITO_DEFAULT_OPTIONS } from '@maskito/core'; | ||
import { MASKITO_DEFAULT_OPTIONS, maskitoTransform } from '@maskito/core'; | ||
@@ -497,4 +497,4 @@ const DEFAULT_MIN_DATE = new Date('0001-01-01'); | ||
function maskitoEventHandler(name, handler) { | ||
return element => { | ||
const listener = () => handler(element); | ||
return (element, options) => { | ||
const listener = () => handler(element, options); | ||
@@ -1039,2 +1039,22 @@ element.addEventListener(name, listener); | ||
/** | ||
* Convert number to string with replacing exponent part on decimals | ||
* | ||
* @param value the number | ||
* @return string representation of a number | ||
*/ | ||
function stringifyNumberWithoutExp(value) { | ||
const valueAsString = String(value); | ||
const [numberPart, expPart] = valueAsString.split(`e-`); | ||
let valueWithoutExp = valueAsString; | ||
if (expPart) { | ||
const [, fractionalPart] = numberPart.split(`.`); | ||
const decimalDigits = Number(expPart) + ((fractionalPart === null || fractionalPart === void 0 ? void 0 : fractionalPart.length) || 0); | ||
valueWithoutExp = value.toFixed(decimalDigits); | ||
} | ||
return valueWithoutExp; | ||
} | ||
/** | ||
* This plugin is connected with {@link createMinMaxPostprocessor}: | ||
@@ -1049,8 +1069,8 @@ * both validate `min`/`max` bounds of entered value (but at the different point of time). | ||
}) { | ||
return maskitoEventHandler('blur', element => { | ||
return maskitoEventHandler('blur', (element, options) => { | ||
const parsedNumber = maskitoParseNumber(element.value, decimalSeparator); | ||
const newValue = clamp(parsedNumber, min, max).toString(); | ||
const clampedNumber = clamp(parsedNumber, min, max); | ||
if (newValue !== element.value) { | ||
element.value = newValue; | ||
if (parsedNumber !== clampedNumber) { | ||
element.value = maskitoTransform(stringifyNumberWithoutExp(clampedNumber), options); | ||
element.dispatchEvent(new Event('input')); | ||
@@ -1057,0 +1077,0 @@ } |
export * from './generate-mask-expression'; | ||
export * from './get-default-pseudo-separators'; | ||
export * from './parse-number'; | ||
export * from './stringify-number-without-exp'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import { MaskitoPlugin } from '@maskito/core'; | ||
export declare function maskitoEventHandler(name: string, handler: (element: HTMLInputElement | HTMLTextAreaElement) => void): MaskitoPlugin; | ||
import { MaskitoOptions, MaskitoPlugin } from '@maskito/core'; | ||
export declare function maskitoEventHandler(name: string, handler: (element: HTMLInputElement | HTMLTextAreaElement, options: Required<MaskitoOptions>) => void): MaskitoPlugin; | ||
//# sourceMappingURL=event-handler.d.ts.map |
{ | ||
"name": "@maskito/kit", | ||
"version": "0.15.0", | ||
"version": "0.16.0", | ||
"description": "The optional framework-agnostic Maskito's package with ready-to-use masks", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@maskito/core": "^0.15.0" | ||
"@maskito/core": "^0.16.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "main": "./index.umd.js", |
Sorry, the diff of this file is too big to display
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
170125
176
3330