New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue-currency-input

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-currency-input - npm Package Compare versions

Comparing version 1.19.1 to 1.20.0

30

dist/vue-currency-input.esm.js
/**
* Vue Currency Input 1.19.1
* Vue Currency Input 1.20.0
* (c) 2018-2020 Matthias Stiller

@@ -25,2 +25,3 @@ * @license MIT

var DECIMAL_SYMBOLS = [',', '.', '٫'];
var NumberFormat = function NumberFormat (options) {

@@ -95,3 +96,3 @@ var currency = options.currency;

NumberFormat.prototype.isFractionIncomplete = function isFractionIncomplete (str) {
return this.normalizeDigits(str).match(new RegExp(("" + (this.integerPattern()) + (escapeRegExp(this.decimalSymbol)) + "$")))
return !!this.normalizeDigits(str).match(new RegExp(("^" + (this.integerPattern()) + (escapeRegExp(this.decimalSymbol)) + "$")))
};

@@ -110,2 +111,9 @@ NumberFormat.prototype.isNegative = function isNegative (str) {

};
NumberFormat.prototype.normalizeDecimalSymbol = function normalizeDecimalSymbol (str, from) {
var this$1 = this;
DECIMAL_SYMBOLS.forEach(function (s) {
str = str.substr(0, from) + str.substr(from).replace(s, this$1.decimalSymbol);
});
return str
};
NumberFormat.prototype.normalizeDigits = function normalizeDigits (str) {

@@ -323,2 +331,3 @@ if (this.digits[0] !== '0') {

var focus = ref.focus;
var decimalSymbolInsertedAt = ref.decimalSymbolInsertedAt;
var options = ref.options;

@@ -330,2 +339,6 @@ var numberMask = ref.numberMask;

var distractionFree = options.distractionFree;
if (decimalSymbolInsertedAt !== undefined) {
value = currencyFormat.normalizeDecimalSymbol(value, decimalSymbolInsertedAt);
el.$ci.decimalSymbolInserted = undefined;
}
var conformedValue = numberMask.conformToMask(value, previousConformedValue);

@@ -389,2 +402,7 @@ var formattedValue;

}, { capture: true });
el.addEventListener('keypress', function (e) {
if (DECIMAL_SYMBOLS.includes(e.key)) {
el.$ci.decimalSymbolInsertedAt = el.selectionStart;
}
});
el.addEventListener('format', function (e) {

@@ -411,3 +429,5 @@ var ref = el.$ci;

var selectionEnd = el.selectionEnd;
format(el, el.value, hideNegligibleDecimalDigits);
if (value) {
format(el, value, hideNegligibleDecimalDigits);
}
if (Math.abs(selectionStart - selectionEnd) > 0) {

@@ -423,3 +443,5 @@ el.setSelectionRange(0, el.value.length);

el.$ci.focus = false;
applyFixedFractionFormat(el, el.$ci.numberValue);
if (el.$ci.numberValue) {
applyFixedFractionFormat(el, el.$ci.numberValue);
}
});

@@ -426,0 +448,0 @@ el.addEventListener('change', function (e) {

/**
* Vue Currency Input 1.19.1
* Vue Currency Input 1.20.0
* (c) 2018-2020 Matthias Stiller

@@ -31,2 +31,3 @@ * @license MIT

var DECIMAL_SYMBOLS = [',', '.', '٫'];
var NumberFormat = function NumberFormat (options) {

@@ -101,3 +102,3 @@ var currency = options.currency;

NumberFormat.prototype.isFractionIncomplete = function isFractionIncomplete (str) {
return this.normalizeDigits(str).match(new RegExp(("" + (this.integerPattern()) + (escapeRegExp(this.decimalSymbol)) + "$")))
return !!this.normalizeDigits(str).match(new RegExp(("^" + (this.integerPattern()) + (escapeRegExp(this.decimalSymbol)) + "$")))
};

@@ -116,2 +117,9 @@ NumberFormat.prototype.isNegative = function isNegative (str) {

};
NumberFormat.prototype.normalizeDecimalSymbol = function normalizeDecimalSymbol (str, from) {
var this$1 = this;
DECIMAL_SYMBOLS.forEach(function (s) {
str = str.substr(0, from) + str.substr(from).replace(s, this$1.decimalSymbol);
});
return str
};
NumberFormat.prototype.normalizeDigits = function normalizeDigits (str) {

@@ -329,2 +337,3 @@ if (this.digits[0] !== '0') {

var focus = ref.focus;
var decimalSymbolInsertedAt = ref.decimalSymbolInsertedAt;
var options = ref.options;

@@ -336,2 +345,6 @@ var numberMask = ref.numberMask;

var distractionFree = options.distractionFree;
if (decimalSymbolInsertedAt !== undefined) {
value = currencyFormat.normalizeDecimalSymbol(value, decimalSymbolInsertedAt);
el.$ci.decimalSymbolInserted = undefined;
}
var conformedValue = numberMask.conformToMask(value, previousConformedValue);

@@ -395,2 +408,7 @@ var formattedValue;

}, { capture: true });
el.addEventListener('keypress', function (e) {
if (DECIMAL_SYMBOLS.includes(e.key)) {
el.$ci.decimalSymbolInsertedAt = el.selectionStart;
}
});
el.addEventListener('format', function (e) {

@@ -417,3 +435,5 @@ var ref = el.$ci;

var selectionEnd = el.selectionEnd;
format(el, el.value, hideNegligibleDecimalDigits);
if (value) {
format(el, value, hideNegligibleDecimalDigits);
}
if (Math.abs(selectionStart - selectionEnd) > 0) {

@@ -429,3 +449,5 @@ el.setSelectionRange(0, el.value.length);

el.$ci.focus = false;
applyFixedFractionFormat(el, el.$ci.numberValue);
if (el.$ci.numberValue) {
applyFixedFractionFormat(el, el.$ci.numberValue);
}
});

@@ -432,0 +454,0 @@ el.addEventListener('change', function (e) {

2

package.json
{
"name": "vue-currency-input",
"description": "Easy input of currency formatted numbers for Vue.js.",
"version": "1.19.1",
"version": "1.20.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "unpkg": "dist/vue-currency-input.umd.js",

@@ -6,3 +6,3 @@ import { DEFAULT_OPTIONS } from './api'

import { toExternalNumberModel, toInternalNumberModel } from './utils/numberUtils'
import NumberFormat from './numberFormat'
import NumberFormat, { DECIMAL_SYMBOLS } from './numberFormat'
import { AutoDecimalModeNumberMask, DefaultNumberMask } from './numberMask'

@@ -74,4 +74,8 @@

if (value != null) {
const { focus, options, numberMask, currencyFormat, previousConformedValue } = el.$ci
const { focus, decimalSymbolInsertedAt, options, numberMask, currencyFormat, previousConformedValue } = el.$ci
const { allowNegative, distractionFree } = options
if (decimalSymbolInsertedAt !== undefined) {
value = currencyFormat.normalizeDecimalSymbol(value, decimalSymbolInsertedAt)
el.$ci.decimalSymbolInserted = undefined
}
const conformedValue = numberMask.conformToMask(value, previousConformedValue)

@@ -121,4 +125,4 @@ let formattedValue

const addEventListener = (el) => {
el.addEventListener('input', (e) => {
const addEventListener = el => {
el.addEventListener('input', e => {
if (!e.detail) {

@@ -133,3 +137,9 @@ const { value, selectionStart, $ci: { currencyFormat, options } } = el

el.addEventListener('format', (e) => {
el.addEventListener('keypress', e => {
if (DECIMAL_SYMBOLS.includes(e.key)) {
el.$ci.decimalSymbolInsertedAt = el.selectionStart
}
})
el.addEventListener('format', e => {
const { currencyFormat, options, numberValue } = el.$ci

@@ -148,3 +158,5 @@ const value = toInternalNumberModel(e.detail.value, options.valueAsInteger, currencyFormat.maximumFractionDigits)

const { value, selectionStart, selectionEnd } = el
format(el, el.value, hideNegligibleDecimalDigits)
if (value) {
format(el, value, hideNegligibleDecimalDigits)
}
if (Math.abs(selectionStart - selectionEnd) > 0) {

@@ -161,6 +173,8 @@ el.setSelectionRange(0, el.value.length)

el.$ci.focus = false
applyFixedFractionFormat(el, el.$ci.numberValue)
if (el.$ci.numberValue) {
applyFixedFractionFormat(el, el.$ci.numberValue)
}
})
el.addEventListener('change', (e) => {
el.addEventListener('change', e => {
if (!e.detail) {

@@ -167,0 +181,0 @@ triggerEvent(el, 'change')

import { count, escapeRegExp, startsWith, substringBefore } from './utils/stringUtils'
export const DECIMAL_SYMBOLS = [',', '.', '٫']
export default class NumberFormat {

@@ -78,3 +80,3 @@ constructor (options) {

isFractionIncomplete (str) {
return this.normalizeDigits(str).match(new RegExp(`${this.integerPattern()}${escapeRegExp(this.decimalSymbol)}$`))
return !!this.normalizeDigits(str).match(new RegExp(`^${this.integerPattern()}${escapeRegExp(this.decimalSymbol)}$`))
}

@@ -98,2 +100,9 @@

normalizeDecimalSymbol (str, from) {
DECIMAL_SYMBOLS.forEach(s => {
str = str.substr(0, from) + str.substr(from).replace(s, this.decimalSymbol)
})
return str
}
normalizeDigits (str) {

@@ -100,0 +109,0 @@ if (this.digits[0] !== '0') {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc