autonumeric
Advanced tools
Comparing version 4.0.0-beta.5 to 4.0.0-beta.6
### Change log for autoNumeric: | ||
### "4.0.0-beta.6" | ||
+ Fix issue #414 Changing the value of an element from negative to positive is not possible for some specific configuration of brackets, for the second time. | ||
+ Remove the need to keep an ambiguous `settings.trailingNegative` variable, that was used for other things that its names suggests. | ||
+ Extract the `_isTrailingNegative` test to its own function. | ||
+ Fix `_convertToNumericString()` to make it remove the `suffixText` as well. | ||
+ Use array destructuring to simplify the `_setValueParts()` function. | ||
+ Remove the attribute `newValue` polluting `this`, which allow to explicitly pass the needed information. | ||
+ Merge `this.settings.hasFocus` into `this.isFocused`. | ||
+ Remove the need for the `this.settings.strip` variable. | ||
+ Modify the event listener from `'focusin'` to `'focus'`, in order to prepare for the merge of `_onFocusInAndMouseEnter()` and `_onFocus()` handlers. | ||
+ Modify `_cleanLeadingTrailingZeros()` so that the trailing zeroes if correctly done, even if `leadingZero` is set to `keep`. | ||
+ Rename `_cleanLeadingTrailingZeros()` to `_trimLeadingAndTrailingZeros()`. | ||
+ Change the `_addGroupSeparators()` signature so that the focused state is explicitly passed as a parameter, instead of piggy-backing on the settings object. | ||
+ Add a `_setTrailingNegativeSignInfo()` function that parse the settings and initialize once the `this.isTrailingNegative` property if the negative sign should be trailing for negative values. | ||
+ Rename the `leftOrAll` parameter from `_stripAllNonNumberCharacters()` to a more meaningful `stripZeros`. | ||
+ Simplify a test in `_truncateDecimalPlaces()`. | ||
+ Rename `_skipAlways()` to `_processNonPrintableKeysAndShortcuts()`. | ||
+ Add cases to the helper function `isNegative()` to make it more efficient. | ||
+ Add a new `isNegativeWithBrackets()` helper function that tests if the given value is a negative with brackets. | ||
### "4.0.0-beta.5" | ||
@@ -4,0 +24,0 @@ + Fix issue #416 Add support for changing the element style based on rules |
{ | ||
"name": "autonumeric", | ||
"version": "4.0.0-beta.5", | ||
"version": "4.0.0-beta.6", | ||
"description": "autoNumeric is a standalone Javascript library that provides live *as-you-type* formatting for international numbers and currencies. It supports most International numeric formats and currencies including those used in Europe, Asia, and North and South America.", | ||
@@ -5,0 +5,0 @@ "main": "src/main.js", |
@@ -429,17 +429,29 @@ /** | ||
/** | ||
* Return `true` if the given string contains a negative sign : | ||
* Return `true` if the given number is negative, or if the given string contains a negative sign : | ||
* - everywhere in the string (by default), or | ||
* - on the first character only if the `checkEverywhere` parameter is set to `false`. | ||
* | ||
* @param {string} numericString A number represented by a string | ||
* @param {number|string} numberOrNumericString A Number, or a number represented by a string | ||
* @param {boolean} checkEverywhere If TRUE, then the negative sign is search everywhere in the numeric string (this is needed for instance if the string is '1234.56-') | ||
* @returns {boolean} | ||
*/ | ||
static isNegative(numericString, checkEverywhere = true) { | ||
static isNegative(numberOrNumericString, checkEverywhere = true) { | ||
if (numberOrNumericString === '-') { | ||
return true; | ||
} | ||
if (numberOrNumericString === '') { | ||
return false; | ||
} | ||
//TODO Use the `negativeSignCharacter` from the settings here | ||
if (AutoNumericHelper.isNumber(numberOrNumericString)) { | ||
return numberOrNumericString < 0; | ||
} | ||
if (checkEverywhere) { | ||
return this.contains(numericString, '-'); | ||
return this.contains(numberOrNumericString, '-'); | ||
} | ||
return this.isNegativeStrict(numericString); | ||
return this.isNegativeStrict(numberOrNumericString); | ||
} | ||
@@ -464,2 +476,14 @@ | ||
/** | ||
* Return `true` if the very first character is the opening bracket, and if the rest of the `valueString` also has the closing bracket. | ||
* | ||
* @param {string} valueString | ||
* @param {string} leftBracket | ||
* @param {string} rightBracket | ||
* @returns {boolean} | ||
*/ | ||
static isNegativeWithBrackets(valueString, leftBracket, rightBracket) { | ||
return valueString.charAt(0) === leftBracket && this.contains(valueString, rightBracket); | ||
} | ||
/** | ||
* Return `true` if the formatted or unformatted numeric string represent the value 0 (ie. '0,00 €'), or is empty (' €'). | ||
@@ -466,0 +490,0 @@ * This works since we test if there are any numbers from 1 to 9 in the string. If there is none, then the number is zero (or the string is empty). |
Sorry, the diff of this file is too big to display
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 too big to display
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
3423387
13863