vue-currency-input
Advanced tools
Comparing version 1.14.2 to 1.14.3
/** | ||
* Vue Currency Input 1.14.2 | ||
* Vue Currency Input 1.14.3 | ||
* (c) 2019 Matthias Stiller | ||
@@ -305,11 +305,7 @@ * @license MIT | ||
var applyFixedFractionFormat = function (el, value) { | ||
var ref = el.$ci; | ||
var ref_options = ref.options; | ||
var min = ref_options.min; | ||
var max = ref_options.max; | ||
var locale = ref_options.locale; | ||
var ref_currencyFormat = ref.currencyFormat; | ||
var minimumFractionDigits = ref_currencyFormat.minimumFractionDigits; | ||
var maximumFractionDigits = ref_currencyFormat.maximumFractionDigits; | ||
if (value != null) { | ||
var ref = el.$ci.options; | ||
var min = ref.min; | ||
var max = ref.max; | ||
var locale = ref.locale; | ||
if (min != null && value < min) { | ||
@@ -321,2 +317,5 @@ value = min; | ||
} | ||
var ref$1 = el.$ci.currencyFormat; | ||
var maximumFractionDigits = ref$1.maximumFractionDigits; | ||
var minimumFractionDigits = ref$1.minimumFractionDigits; | ||
value = new Intl.NumberFormat(locale, { minimumFractionDigits: minimumFractionDigits, maximumFractionDigits: maximumFractionDigits }).format(value); | ||
@@ -329,13 +328,15 @@ } | ||
}; | ||
var hideCurrencySymbolOnFocus = function (el) { return el.$ci.focus && el.$ci.options.distractionFree.hideCurrencySymbol; }; | ||
var hideGroupingSymbolOnFocus = function (el) { return el.$ci.focus && el.$ci.options.distractionFree.hideGroupingSymbol; }; | ||
var hideNegligibleDecimalDigitsOnFocus = function (el) { return el.$ci.focus && el.$ci.options.distractionFree.hideNegligibleDecimalDigits; }; | ||
var updateInputValue = function (el, value) { | ||
var updateInputValue = function (el, value, hideNegligibleDecimalDigits) { | ||
if ( hideNegligibleDecimalDigits === void 0 ) hideNegligibleDecimalDigits = false; | ||
if (value != null) { | ||
var ref = el.$ci; | ||
var focus = ref.focus; | ||
var options = ref.options; | ||
var currencyFormat = ref.currencyFormat; | ||
var previousConformedValue = ref.previousConformedValue; | ||
var ref$1 = options.distractionFree; | ||
var hideCurrencySymbol = ref$1.hideCurrencySymbol; | ||
var hideGroupingSymbol = ref$1.hideGroupingSymbol; | ||
var formatConfig = Object.assign({}, currencyFormat); | ||
if (hideCurrencySymbolOnFocus(el)) { | ||
if (focus && hideCurrencySymbol) { | ||
formatConfig.prefix = ''; | ||
@@ -345,9 +346,9 @@ formatConfig.negativePrefix = '-'; | ||
} | ||
var ref$1 = conformToMask(value, formatConfig, options, previousConformedValue); | ||
var conformedValue = ref$1.conformedValue; | ||
var fractionDigits = ref$1.fractionDigits; | ||
var ref$2 = conformToMask(value, formatConfig, options, previousConformedValue); | ||
var conformedValue = ref$2.conformedValue; | ||
var fractionDigits = ref$2.fractionDigits; | ||
if (typeof conformedValue === 'number') { | ||
var formattedValue = new Intl.NumberFormat(options.locale, { | ||
useGrouping: !hideGroupingSymbolOnFocus(el), | ||
minimumFractionDigits: hideNegligibleDecimalDigitsOnFocus(el) ? fractionDigits.replace(/0+$/, '').length : Math.min(formatConfig.minimumFractionDigits, fractionDigits.length), | ||
useGrouping: !(focus && hideGroupingSymbol), | ||
minimumFractionDigits: hideNegligibleDecimalDigits ? fractionDigits.replace(/0+$/, '').length : Math.min(formatConfig.minimumFractionDigits, fractionDigits.length), | ||
maximumFractionDigits: formatConfig.maximumFractionDigits | ||
@@ -405,3 +406,7 @@ }).format(Math.abs(conformedValue)); | ||
el.$ci.focus = true; | ||
if (hideCurrencySymbolOnFocus(el) || hideGroupingSymbolOnFocus(el) || hideNegligibleDecimalDigitsOnFocus(el)) { | ||
var ref = el.$ci.options.distractionFree; | ||
var hideCurrencySymbol = ref.hideCurrencySymbol; | ||
var hideGroupingSymbol = ref.hideGroupingSymbol; | ||
var hideNegligibleDecimalDigits = ref.hideNegligibleDecimalDigits; | ||
if (hideCurrencySymbol || hideGroupingSymbol || hideNegligibleDecimalDigits) { | ||
setTimeout(function () { | ||
@@ -411,3 +416,3 @@ var value = el.value; | ||
var selectionEnd = el.selectionEnd; | ||
updateInputValue(el, el.value); | ||
updateInputValue(el, el.value, hideNegligibleDecimalDigits); | ||
if (Math.abs(selectionStart - selectionEnd) > 0) { | ||
@@ -414,0 +419,0 @@ el.setSelectionRange(0, el.value.length); |
/** | ||
* Vue Currency Input 1.14.2 | ||
* Vue Currency Input 1.14.3 | ||
* (c) 2019 Matthias Stiller | ||
@@ -311,11 +311,7 @@ * @license MIT | ||
var applyFixedFractionFormat = function (el, value) { | ||
var ref = el.$ci; | ||
var ref_options = ref.options; | ||
var min = ref_options.min; | ||
var max = ref_options.max; | ||
var locale = ref_options.locale; | ||
var ref_currencyFormat = ref.currencyFormat; | ||
var minimumFractionDigits = ref_currencyFormat.minimumFractionDigits; | ||
var maximumFractionDigits = ref_currencyFormat.maximumFractionDigits; | ||
if (value != null) { | ||
var ref = el.$ci.options; | ||
var min = ref.min; | ||
var max = ref.max; | ||
var locale = ref.locale; | ||
if (min != null && value < min) { | ||
@@ -327,2 +323,5 @@ value = min; | ||
} | ||
var ref$1 = el.$ci.currencyFormat; | ||
var maximumFractionDigits = ref$1.maximumFractionDigits; | ||
var minimumFractionDigits = ref$1.minimumFractionDigits; | ||
value = new Intl.NumberFormat(locale, { minimumFractionDigits: minimumFractionDigits, maximumFractionDigits: maximumFractionDigits }).format(value); | ||
@@ -335,13 +334,15 @@ } | ||
}; | ||
var hideCurrencySymbolOnFocus = function (el) { return el.$ci.focus && el.$ci.options.distractionFree.hideCurrencySymbol; }; | ||
var hideGroupingSymbolOnFocus = function (el) { return el.$ci.focus && el.$ci.options.distractionFree.hideGroupingSymbol; }; | ||
var hideNegligibleDecimalDigitsOnFocus = function (el) { return el.$ci.focus && el.$ci.options.distractionFree.hideNegligibleDecimalDigits; }; | ||
var updateInputValue = function (el, value) { | ||
var updateInputValue = function (el, value, hideNegligibleDecimalDigits) { | ||
if ( hideNegligibleDecimalDigits === void 0 ) hideNegligibleDecimalDigits = false; | ||
if (value != null) { | ||
var ref = el.$ci; | ||
var focus = ref.focus; | ||
var options = ref.options; | ||
var currencyFormat = ref.currencyFormat; | ||
var previousConformedValue = ref.previousConformedValue; | ||
var ref$1 = options.distractionFree; | ||
var hideCurrencySymbol = ref$1.hideCurrencySymbol; | ||
var hideGroupingSymbol = ref$1.hideGroupingSymbol; | ||
var formatConfig = Object.assign({}, currencyFormat); | ||
if (hideCurrencySymbolOnFocus(el)) { | ||
if (focus && hideCurrencySymbol) { | ||
formatConfig.prefix = ''; | ||
@@ -351,9 +352,9 @@ formatConfig.negativePrefix = '-'; | ||
} | ||
var ref$1 = conformToMask(value, formatConfig, options, previousConformedValue); | ||
var conformedValue = ref$1.conformedValue; | ||
var fractionDigits = ref$1.fractionDigits; | ||
var ref$2 = conformToMask(value, formatConfig, options, previousConformedValue); | ||
var conformedValue = ref$2.conformedValue; | ||
var fractionDigits = ref$2.fractionDigits; | ||
if (typeof conformedValue === 'number') { | ||
var formattedValue = new Intl.NumberFormat(options.locale, { | ||
useGrouping: !hideGroupingSymbolOnFocus(el), | ||
minimumFractionDigits: hideNegligibleDecimalDigitsOnFocus(el) ? fractionDigits.replace(/0+$/, '').length : Math.min(formatConfig.minimumFractionDigits, fractionDigits.length), | ||
useGrouping: !(focus && hideGroupingSymbol), | ||
minimumFractionDigits: hideNegligibleDecimalDigits ? fractionDigits.replace(/0+$/, '').length : Math.min(formatConfig.minimumFractionDigits, fractionDigits.length), | ||
maximumFractionDigits: formatConfig.maximumFractionDigits | ||
@@ -411,3 +412,7 @@ }).format(Math.abs(conformedValue)); | ||
el.$ci.focus = true; | ||
if (hideCurrencySymbolOnFocus(el) || hideGroupingSymbolOnFocus(el) || hideNegligibleDecimalDigitsOnFocus(el)) { | ||
var ref = el.$ci.options.distractionFree; | ||
var hideCurrencySymbol = ref.hideCurrencySymbol; | ||
var hideGroupingSymbol = ref.hideGroupingSymbol; | ||
var hideNegligibleDecimalDigits = ref.hideNegligibleDecimalDigits; | ||
if (hideCurrencySymbol || hideGroupingSymbol || hideNegligibleDecimalDigits) { | ||
setTimeout(function () { | ||
@@ -417,3 +422,3 @@ var value = el.value; | ||
var selectionEnd = el.selectionEnd; | ||
updateInputValue(el, el.value); | ||
updateInputValue(el, el.value, hideNegligibleDecimalDigits); | ||
if (Math.abs(selectionStart - selectionEnd) > 0) { | ||
@@ -420,0 +425,0 @@ el.setSelectionRange(0, el.value.length); |
{ | ||
"name": "vue-currency-input", | ||
"description": "Easy input of currency formatted numbers for Vue.js.", | ||
"version": "1.14.2", | ||
"version": "1.14.3", | ||
"license": "MIT", | ||
@@ -52,3 +52,2 @@ "unpkg": "dist/vue-currency-input.umd.js", | ||
"eslint-plugin-vue": "^5.0.0", | ||
"intl": "^1.2.5", | ||
"node-sass": "^4.12.0", | ||
@@ -58,5 +57,2 @@ "rollup": "^1.21.3", | ||
"rollup-plugin-cleanup": "^3.1.1", | ||
"rollup-plugin-clear": "^2.0.7", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"sass-loader": "^8.0.0", | ||
@@ -63,0 +59,0 @@ "vue": "^2.6.10", |
@@ -42,4 +42,4 @@ import Vue from 'vue' | ||
const applyFixedFractionFormat = (el, value) => { | ||
const { options: { min, max, locale }, currencyFormat: { minimumFractionDigits, maximumFractionDigits } } = el.$ci | ||
if (value != null) { | ||
const { min, max, locale } = el.$ci.options | ||
if (min != null && value < min) { | ||
@@ -51,2 +51,3 @@ value = min | ||
} | ||
const { maximumFractionDigits, minimumFractionDigits } = el.$ci.currencyFormat | ||
value = new Intl.NumberFormat(locale, { minimumFractionDigits, maximumFractionDigits }).format(value) | ||
@@ -60,13 +61,8 @@ } | ||
const hideCurrencySymbolOnFocus = el => el.$ci.focus && el.$ci.options.distractionFree.hideCurrencySymbol | ||
const hideGroupingSymbolOnFocus = el => el.$ci.focus && el.$ci.options.distractionFree.hideGroupingSymbol | ||
const hideNegligibleDecimalDigitsOnFocus = el => el.$ci.focus && el.$ci.options.distractionFree.hideNegligibleDecimalDigits | ||
const updateInputValue = (el, value) => { | ||
const updateInputValue = (el, value, hideNegligibleDecimalDigits = false) => { | ||
if (value != null) { | ||
const { options, currencyFormat, previousConformedValue } = el.$ci | ||
const { focus, options, currencyFormat, previousConformedValue } = el.$ci | ||
const { hideCurrencySymbol, hideGroupingSymbol } = options.distractionFree | ||
const formatConfig = { ...currencyFormat } | ||
if (hideCurrencySymbolOnFocus(el)) { | ||
if (focus && hideCurrencySymbol) { | ||
formatConfig.prefix = '' | ||
@@ -79,4 +75,4 @@ formatConfig.negativePrefix = '-' | ||
const formattedValue = new Intl.NumberFormat(options.locale, { | ||
useGrouping: !hideGroupingSymbolOnFocus(el), | ||
minimumFractionDigits: hideNegligibleDecimalDigitsOnFocus(el) ? fractionDigits.replace(/0+$/, '').length : Math.min(formatConfig.minimumFractionDigits, fractionDigits.length), | ||
useGrouping: !(focus && hideGroupingSymbol), | ||
minimumFractionDigits: hideNegligibleDecimalDigits ? fractionDigits.replace(/0+$/, '').length : Math.min(formatConfig.minimumFractionDigits, fractionDigits.length), | ||
maximumFractionDigits: formatConfig.maximumFractionDigits | ||
@@ -127,6 +123,7 @@ }).format(Math.abs(conformedValue)) | ||
el.$ci.focus = true | ||
if (hideCurrencySymbolOnFocus(el) || hideGroupingSymbolOnFocus(el) || hideNegligibleDecimalDigitsOnFocus(el)) { | ||
const { hideCurrencySymbol, hideGroupingSymbol, hideNegligibleDecimalDigits } = el.$ci.options.distractionFree | ||
if (hideCurrencySymbol || hideGroupingSymbol || hideNegligibleDecimalDigits) { | ||
setTimeout(() => { | ||
const { value, selectionStart, selectionEnd } = el | ||
updateInputValue(el, el.value) | ||
updateInputValue(el, el.value, hideNegligibleDecimalDigits) | ||
if (Math.abs(selectionStart - selectionEnd) > 0) { | ||
@@ -133,0 +130,0 @@ el.setSelectionRange(0, el.value.length) |
18
1706
70712
78053