vue-currency-input
Advanced tools
Comparing version 1.11.2 to 1.11.3
/** | ||
* Vue Currency Input 1.11.2 | ||
* Vue Currency Input 1.11.3 | ||
* (c) 2019 Matthias Stiller | ||
@@ -285,3 +285,2 @@ * @license MIT | ||
var applyFixedFractionFormat = function (el, value) { | ||
if ( value === void 0 ) value = parse(el.value, el.$ci.currencyFormat); | ||
var ref = el.$ci; | ||
@@ -328,7 +327,9 @@ var ref_options = ref.options; | ||
el.value = "" + (isNegativeZero || conformedValue < 0 ? formatConfig.negativePrefix : formatConfig.prefix) + formattedValue + (formatConfig.suffix); | ||
el.$ci.numberValue = conformedValue; | ||
} else { | ||
el.value = conformedValue; | ||
el.$ci.numberValue = parse(el.value, formatConfig); | ||
} | ||
} else { | ||
el.value = null; | ||
el.value = el.$ci.numberValue = null; | ||
} | ||
@@ -338,17 +339,12 @@ el.$ci.previousConformedValue = el.value; | ||
var format = function (el, value) { | ||
if ( value === void 0 ) value = el.value; | ||
updateInputValue(el, value); | ||
var numberValue = parse(el.value, el.$ci.currencyFormat); | ||
el.$ci.numberValue = numberValue; | ||
dispatchEvent(el, 'format-complete', { numberValue: numberValue }); | ||
dispatchEvent(el, 'format-complete', { numberValue: el.$ci.numberValue }); | ||
}; | ||
var addEventListener = function (el) { | ||
el.addEventListener('input', function () { | ||
var value = el.value; | ||
var selectionStart = el.selectionStart; | ||
format(el, value); | ||
if (el.$ci.focus) { | ||
var value = el.value; | ||
var selectionStart = el.selectionStart; | ||
format(el); | ||
setCaretPosition(el, getCaretPositionAfterFormat(el, value, selectionStart)); | ||
} else { | ||
format(el); | ||
} | ||
@@ -387,3 +383,3 @@ }, { capture: true }); | ||
el.$ci.focus = false; | ||
applyFixedFractionFormat(el); | ||
applyFixedFractionFormat(el, el.$ci.numberValue); | ||
}); | ||
@@ -398,3 +394,3 @@ }; | ||
if (inputElement.value) { | ||
applyFixedFractionFormat(inputElement); | ||
applyFixedFractionFormat(inputElement, parse(inputElement.value, inputElement.$ci.currencyFormat)); | ||
} | ||
@@ -401,0 +397,0 @@ }); |
/** | ||
* Vue Currency Input 1.11.2 | ||
* Vue Currency Input 1.11.3 | ||
* (c) 2019 Matthias Stiller | ||
@@ -291,3 +291,2 @@ * @license MIT | ||
var applyFixedFractionFormat = function (el, value) { | ||
if ( value === void 0 ) value = parse(el.value, el.$ci.currencyFormat); | ||
var ref = el.$ci; | ||
@@ -334,7 +333,9 @@ var ref_options = ref.options; | ||
el.value = "" + (isNegativeZero || conformedValue < 0 ? formatConfig.negativePrefix : formatConfig.prefix) + formattedValue + (formatConfig.suffix); | ||
el.$ci.numberValue = conformedValue; | ||
} else { | ||
el.value = conformedValue; | ||
el.$ci.numberValue = parse(el.value, formatConfig); | ||
} | ||
} else { | ||
el.value = null; | ||
el.value = el.$ci.numberValue = null; | ||
} | ||
@@ -344,17 +345,12 @@ el.$ci.previousConformedValue = el.value; | ||
var format = function (el, value) { | ||
if ( value === void 0 ) value = el.value; | ||
updateInputValue(el, value); | ||
var numberValue = parse(el.value, el.$ci.currencyFormat); | ||
el.$ci.numberValue = numberValue; | ||
dispatchEvent(el, 'format-complete', { numberValue: numberValue }); | ||
dispatchEvent(el, 'format-complete', { numberValue: el.$ci.numberValue }); | ||
}; | ||
var addEventListener = function (el) { | ||
el.addEventListener('input', function () { | ||
var value = el.value; | ||
var selectionStart = el.selectionStart; | ||
format(el, value); | ||
if (el.$ci.focus) { | ||
var value = el.value; | ||
var selectionStart = el.selectionStart; | ||
format(el); | ||
setCaretPosition(el, getCaretPositionAfterFormat(el, value, selectionStart)); | ||
} else { | ||
format(el); | ||
} | ||
@@ -393,3 +389,3 @@ }, { capture: true }); | ||
el.$ci.focus = false; | ||
applyFixedFractionFormat(el); | ||
applyFixedFractionFormat(el, el.$ci.numberValue); | ||
}); | ||
@@ -404,3 +400,3 @@ }; | ||
if (inputElement.value) { | ||
applyFixedFractionFormat(inputElement); | ||
applyFixedFractionFormat(inputElement, parse(inputElement.value, inputElement.$ci.currencyFormat)); | ||
} | ||
@@ -407,0 +403,0 @@ }); |
{ | ||
"name": "vue-currency-input", | ||
"description": "Easy input of currency formatted numbers for Vue.js.", | ||
"version": "1.11.2", | ||
"version": "1.11.3", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "unpkg": "dist/vue-currency-input.umd.js", |
@@ -43,3 +43,3 @@ import Vue from 'vue' | ||
const applyFixedFractionFormat = (el, value = parse(el.value, el.$ci.currencyFormat)) => { | ||
const applyFixedFractionFormat = (el, value) => { | ||
const { options: { min, max, locale }, currencyFormat: { decimalLength } } = el.$ci | ||
@@ -74,7 +74,9 @@ if (value != null) { | ||
el.value = `${isNegativeZero || conformedValue < 0 ? formatConfig.negativePrefix : formatConfig.prefix}${formattedValue}${formatConfig.suffix}` | ||
el.$ci.numberValue = conformedValue | ||
} else { | ||
el.value = conformedValue | ||
el.$ci.numberValue = parse(el.value, formatConfig) | ||
} | ||
} else { | ||
el.value = null | ||
el.value = el.$ci.numberValue = null | ||
} | ||
@@ -84,7 +86,5 @@ el.$ci.previousConformedValue = el.value | ||
const format = (el, value = el.value) => { | ||
const format = (el, value) => { | ||
updateInputValue(el, value) | ||
const numberValue = parse(el.value, el.$ci.currencyFormat) | ||
el.$ci.numberValue = numberValue | ||
dispatchEvent(el, 'format-complete', { numberValue }) | ||
dispatchEvent(el, 'format-complete', { numberValue: el.$ci.numberValue }) | ||
} | ||
@@ -94,8 +94,6 @@ | ||
el.addEventListener('input', () => { | ||
const { value, selectionStart } = el | ||
format(el, value) | ||
if (el.$ci.focus) { | ||
const { value, selectionStart } = el | ||
format(el) | ||
setCaretPosition(el, getCaretPositionAfterFormat(el, value, selectionStart)) | ||
} else { | ||
format(el) | ||
} | ||
@@ -129,3 +127,3 @@ }, { capture: true }) | ||
el.$ci.focus = false | ||
applyFixedFractionFormat(el) | ||
applyFixedFractionFormat(el, el.$ci.numberValue) | ||
}) | ||
@@ -139,3 +137,3 @@ } | ||
if (inputElement.value) { | ||
applyFixedFractionFormat(inputElement) | ||
applyFixedFractionFormat(inputElement, parse(inputElement.value, inputElement.$ci.currencyFormat)) | ||
} | ||
@@ -142,0 +140,0 @@ }) |
63906
1512