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.9.0 to 1.9.1

47

dist/vue-currency-input.esm.js
/**
* Vue Currency Input 1.9.0
* Vue Currency Input 1.9.1
* (c) 2019 Matthias Stiller

@@ -138,12 +138,12 @@ * @license MIT

};
var checkIncompleteValue = function (value, negative, previousConformedValue, currencyFormat) {
var prefix = currencyFormat.prefix;
var negativePrefix = currencyFormat.negativePrefix;
var suffix = currencyFormat.suffix;
var decimalSymbol = currencyFormat.decimalSymbol;
var decimalLength = currencyFormat.decimalLength;
var checkIncompleteValue = function (value, negative, previousConformedValue, formatConfig) {
var prefix = formatConfig.prefix;
var negativePrefix = formatConfig.negativePrefix;
var suffix = formatConfig.suffix;
var decimalSymbol = formatConfig.decimalSymbol;
var decimalLength = formatConfig.decimalLength;
if (value === '' && negative && previousConformedValue !== negativePrefix) {
return ("" + negativePrefix + suffix)
} else if (decimalLength > 0) {
if (isFractionIncomplete(value, currencyFormat)) {
if (isFractionIncomplete(value, formatConfig)) {
return ("" + (negative ? negativePrefix : prefix) + value + suffix)

@@ -186,25 +186,25 @@ } else if (startsWith(value, decimalSymbol)) {

};
function conformToMask (str, currencyFormat, autoDecimalMode, previousConformedValue) {
function conformToMask (str, formatConfig, options, previousConformedValue) {
if ( previousConformedValue === void 0 ) previousConformedValue = '';
if (typeof str === 'string') {
str = str.trim();
if (autoDecimalMode) {
return getAutoDecimalModeConformedValue(str, previousConformedValue, currencyFormat)
if (options.autoDecimalMode) {
return getAutoDecimalModeConformedValue(str, previousConformedValue, formatConfig)
}
var numberValue = checkNumberValue(str, currencyFormat);
var numberValue = checkNumberValue(str, formatConfig);
if (numberValue != null) {
return numberValue
}
var ref = stripCurrencySymbolAndMinusSign(str, currencyFormat);
var ref = stripCurrencySymbolAndMinusSign(str, formatConfig);
var value = ref.value;
var negative = ref.negative;
var incompleteValue = checkIncompleteValue(value, negative, previousConformedValue, currencyFormat);
var incompleteValue = checkIncompleteValue(value, negative, previousConformedValue, formatConfig);
if (incompleteValue != null) {
return { conformedValue: incompleteValue }
}
var ref$1 = value.split(currencyFormat.decimalSymbol);
var ref$1 = value.split(formatConfig.decimalSymbol);
var integer = ref$1[0];
var fraction = ref$1.slice(1);
var integerDigits = removeLeadingZeros(onlyDigits(integer));
var fractionDigits = onlyDigits(fraction.join('')).substr(0, currencyFormat.decimalLength);
var fractionDigits = onlyDigits(fraction.join('')).substr(0, formatConfig.decimalLength);
if (isFractionInvalid(fraction, fractionDigits.length)) {

@@ -225,3 +225,3 @@ return { conformedValue: previousConformedValue }

}
} else if (number === '-' && previousConformedValue !== currencyFormat.negativePrefix) {
} else if (number === '-' && previousConformedValue !== formatConfig.negativePrefix) {
return { conformedValue: previousConformedValue }

@@ -355,3 +355,7 @@ } else {

{options: options,
currencyFormat: currencyFormat});
currencyFormat: currencyFormat,
decimalFormat: Object.assign({}, currencyFormat,
{prefix: '',
negativePrefix: '-',
suffix: ''})});
return inputElement

@@ -399,2 +403,3 @@ };

var options = ref.options;
var decimalFormat = ref.decimalFormat;
var currencyFormat = ref.currencyFormat;

@@ -404,3 +409,5 @@ var focus = ref.focus;

if (value != null) {
var ref$1 = conformToMask(value, currencyFormat, options.autoDecimalMode, previousConformedValue);
var hideCurrencySymbol = focus && options.hideCurrencySymbol;
var formatConfig = hideCurrencySymbol ? decimalFormat : currencyFormat;
var ref$1 = conformToMask(value, formatConfig, options, previousConformedValue);
var conformedValue = ref$1.conformedValue;

@@ -410,3 +417,3 @@ var fractionDigits = ref$1.fractionDigits;

el.value = new Intl.NumberFormat(options.locale, {
style: focus && options.hideCurrencySymbol ? 'decimal' : 'currency',
style: hideCurrencySymbol ? 'decimal' : 'currency',
useGrouping: !(focus && options.hideGroupingSymbol),

@@ -413,0 +420,0 @@ currency: options.currency,

/**
* Vue Currency Input 1.9.0
* Vue Currency Input 1.9.1
* (c) 2019 Matthias Stiller

@@ -144,12 +144,12 @@ * @license MIT

};
var checkIncompleteValue = function (value, negative, previousConformedValue, currencyFormat) {
var prefix = currencyFormat.prefix;
var negativePrefix = currencyFormat.negativePrefix;
var suffix = currencyFormat.suffix;
var decimalSymbol = currencyFormat.decimalSymbol;
var decimalLength = currencyFormat.decimalLength;
var checkIncompleteValue = function (value, negative, previousConformedValue, formatConfig) {
var prefix = formatConfig.prefix;
var negativePrefix = formatConfig.negativePrefix;
var suffix = formatConfig.suffix;
var decimalSymbol = formatConfig.decimalSymbol;
var decimalLength = formatConfig.decimalLength;
if (value === '' && negative && previousConformedValue !== negativePrefix) {
return ("" + negativePrefix + suffix)
} else if (decimalLength > 0) {
if (isFractionIncomplete(value, currencyFormat)) {
if (isFractionIncomplete(value, formatConfig)) {
return ("" + (negative ? negativePrefix : prefix) + value + suffix)

@@ -192,25 +192,25 @@ } else if (startsWith(value, decimalSymbol)) {

};
function conformToMask (str, currencyFormat, autoDecimalMode, previousConformedValue) {
function conformToMask (str, formatConfig, options, previousConformedValue) {
if ( previousConformedValue === void 0 ) previousConformedValue = '';
if (typeof str === 'string') {
str = str.trim();
if (autoDecimalMode) {
return getAutoDecimalModeConformedValue(str, previousConformedValue, currencyFormat)
if (options.autoDecimalMode) {
return getAutoDecimalModeConformedValue(str, previousConformedValue, formatConfig)
}
var numberValue = checkNumberValue(str, currencyFormat);
var numberValue = checkNumberValue(str, formatConfig);
if (numberValue != null) {
return numberValue
}
var ref = stripCurrencySymbolAndMinusSign(str, currencyFormat);
var ref = stripCurrencySymbolAndMinusSign(str, formatConfig);
var value = ref.value;
var negative = ref.negative;
var incompleteValue = checkIncompleteValue(value, negative, previousConformedValue, currencyFormat);
var incompleteValue = checkIncompleteValue(value, negative, previousConformedValue, formatConfig);
if (incompleteValue != null) {
return { conformedValue: incompleteValue }
}
var ref$1 = value.split(currencyFormat.decimalSymbol);
var ref$1 = value.split(formatConfig.decimalSymbol);
var integer = ref$1[0];
var fraction = ref$1.slice(1);
var integerDigits = removeLeadingZeros(onlyDigits(integer));
var fractionDigits = onlyDigits(fraction.join('')).substr(0, currencyFormat.decimalLength);
var fractionDigits = onlyDigits(fraction.join('')).substr(0, formatConfig.decimalLength);
if (isFractionInvalid(fraction, fractionDigits.length)) {

@@ -231,3 +231,3 @@ return { conformedValue: previousConformedValue }

}
} else if (number === '-' && previousConformedValue !== currencyFormat.negativePrefix) {
} else if (number === '-' && previousConformedValue !== formatConfig.negativePrefix) {
return { conformedValue: previousConformedValue }

@@ -361,3 +361,7 @@ } else {

{options: options,
currencyFormat: currencyFormat});
currencyFormat: currencyFormat,
decimalFormat: Object.assign({}, currencyFormat,
{prefix: '',
negativePrefix: '-',
suffix: ''})});
return inputElement

@@ -405,2 +409,3 @@ };

var options = ref.options;
var decimalFormat = ref.decimalFormat;
var currencyFormat = ref.currencyFormat;

@@ -410,3 +415,5 @@ var focus = ref.focus;

if (value != null) {
var ref$1 = conformToMask(value, currencyFormat, options.autoDecimalMode, previousConformedValue);
var hideCurrencySymbol = focus && options.hideCurrencySymbol;
var formatConfig = hideCurrencySymbol ? decimalFormat : currencyFormat;
var ref$1 = conformToMask(value, formatConfig, options, previousConformedValue);
var conformedValue = ref$1.conformedValue;

@@ -416,3 +423,3 @@ var fractionDigits = ref$1.fractionDigits;

el.value = new Intl.NumberFormat(options.locale, {
style: focus && options.hideCurrencySymbol ? 'decimal' : 'currency',
style: hideCurrencySymbol ? 'decimal' : 'currency',
useGrouping: !(focus && options.hideGroupingSymbol),

@@ -419,0 +426,0 @@ currency: options.currency,

{
"name": "vue-currency-input",
"description": "Easy input of currency formatted numbers for Vue.js.",
"version": "1.9.0",
"version": "1.9.1",
"license": "MIT",

@@ -40,22 +40,22 @@ "unpkg": "dist/vue-currency-input.umd.js",

"devDependencies": {
"@vue/cli-plugin-babel": "^3.7.0",
"@vue/cli-plugin-eslint": "^3.7.0",
"@vue/cli-plugin-unit-jest": "^3.7.0",
"@vue/cli-service": "^3.7.0",
"@vue/cli-plugin-babel": "^3.11.0",
"@vue/cli-plugin-eslint": "^3.11.0",
"@vue/cli-plugin-unit-jest": "^3.11.0",
"@vue/cli-service": "^3.11.0",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/test-utils": "^1.0.0-beta.29",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^24.8.0",
"babel-jest": "^24.9.0",
"intl": "^1.2.5",
"node-sass": "^4.12.0",
"rollup": "^1.12.3",
"rollup-plugin-buble": "^0.19.6",
"rollup": "^1.21.3",
"rollup-plugin-buble": "^0.19.8",
"rollup-plugin-cleanup": "^3.1.1",
"rollup-plugin-clear": "^2.0.7",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.0",
"sass-loader": "^7.1.0",
"vue": "2.6.8",
"vue-template-compiler": "2.6.8",
"vuepress": "^0.14.11"
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"sass-loader": "^8.0.0",
"vue": "^2.6.10",
"vue-template-compiler": "^2.6.10",
"vuepress": "^1.1.0"
},

@@ -62,0 +62,0 @@ "eslintConfig": {

[![Build Status](https://travis-ci.com/dm4t2/vue-currency-input.svg?branch=master)](https://travis-ci.com/dm4t2/vue-currency-input)
[![codecov](https://codecov.io/gh/dm4t2/vue-currency-input/branch/master/graph/badge.svg)](https://codecov.io/gh/dm4t2/vue-currency-input)
[![npm version](https://badge.fury.io/js/vue-currency-input.svg)](https://badge.fury.io/js/vue-currency-input)

@@ -3,0 +4,0 @@ ![](https://img.shields.io/npm/l/vue-currency-input.svg)

@@ -91,3 +91,9 @@ import Vue from 'vue'

options,
currencyFormat
currencyFormat,
decimalFormat: {
...currencyFormat,
prefix: '',
negativePrefix: '-',
suffix: ''
}
}

@@ -127,8 +133,10 @@ return inputElement

const format = (el, value = el.value) => {
const { options, currencyFormat, focus, previousConformedValue } = el.$ci
const { options, decimalFormat, currencyFormat, focus, previousConformedValue } = el.$ci
if (value != null) {
const { conformedValue, fractionDigits } = conformToMask(value, currencyFormat, options.autoDecimalMode, previousConformedValue)
const hideCurrencySymbol = focus && options.hideCurrencySymbol
const formatConfig = hideCurrencySymbol ? decimalFormat : currencyFormat
const { conformedValue, fractionDigits } = conformToMask(value, formatConfig, options, previousConformedValue)
if (typeof conformedValue === 'number') {
el.value = new Intl.NumberFormat(options.locale, {
style: focus && options.hideCurrencySymbol ? 'decimal' : 'currency',
style: hideCurrencySymbol ? 'decimal' : 'currency',
useGrouping: !(focus && options.hideGroupingSymbol),

@@ -135,0 +143,0 @@ currency: options.currency,

@@ -10,8 +10,8 @@ import { endsWith, isNumber, onlyDigits, removeLeadingZeros, startsWith, stripCurrencySymbolAndMinusSign } from './formatHelper'

const checkIncompleteValue = (value, negative, previousConformedValue, currencyFormat) => {
const { prefix, negativePrefix, suffix, decimalSymbol, decimalLength } = currencyFormat
const checkIncompleteValue = (value, negative, previousConformedValue, formatConfig) => {
const { prefix, negativePrefix, suffix, decimalSymbol, decimalLength } = formatConfig
if (value === '' && negative && previousConformedValue !== negativePrefix) {
return `${negativePrefix}${suffix}`
} else if (decimalLength > 0) {
if (isFractionIncomplete(value, currencyFormat)) {
if (isFractionIncomplete(value, formatConfig)) {
return `${negative ? negativePrefix : prefix}${value}${suffix}`

@@ -54,11 +54,11 @@ } else if (startsWith(value, decimalSymbol)) {

export default (str, currencyFormat, autoDecimalMode, previousConformedValue = '') => {
export default (str, formatConfig, options, previousConformedValue = '') => {
if (typeof str === 'string') {
str = str.trim()
if (autoDecimalMode) {
return getAutoDecimalModeConformedValue(str, previousConformedValue, currencyFormat)
if (options.autoDecimalMode) {
return getAutoDecimalModeConformedValue(str, previousConformedValue, formatConfig)
}
const numberValue = checkNumberValue(str, currencyFormat)
const numberValue = checkNumberValue(str, formatConfig)
if (numberValue != null) {

@@ -68,4 +68,4 @@ return numberValue

const { value, negative } = stripCurrencySymbolAndMinusSign(str, currencyFormat)
const incompleteValue = checkIncompleteValue(value, negative, previousConformedValue, currencyFormat)
const { value, negative } = stripCurrencySymbolAndMinusSign(str, formatConfig)
const incompleteValue = checkIncompleteValue(value, negative, previousConformedValue, formatConfig)
if (incompleteValue != null) {

@@ -75,5 +75,5 @@ return { conformedValue: incompleteValue }

const [integer, ...fraction] = value.split(currencyFormat.decimalSymbol)
const [integer, ...fraction] = value.split(formatConfig.decimalSymbol)
const integerDigits = removeLeadingZeros(onlyDigits(integer))
const fractionDigits = onlyDigits(fraction.join('')).substr(0, currencyFormat.decimalLength)
const fractionDigits = onlyDigits(fraction.join('')).substr(0, formatConfig.decimalLength)

@@ -96,3 +96,3 @@ if (isFractionInvalid(fraction, fractionDigits.length)) {

}
} else if (number === '-' && previousConformedValue !== currencyFormat.negativePrefix) {
} else if (number === '-' && previousConformedValue !== formatConfig.negativePrefix) {
return { conformedValue: previousConformedValue }

@@ -99,0 +99,0 @@ } else {

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