@tagplus/components 1.2.15 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tp.common.js +1 -1
- package/dist/tp.common.js.map +1 -1
- package/dist/tp.umd.js +1 -1
- package/dist/tp.umd.js.map +1 -1
- package/dist/tp.umd.min.js +1 -1
- package/dist/tp.umd.min.js.map +1 -1
- package/package.json +13 -12
- package/src/utils/currency.js +17 -6
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"email": "bruno@tagplus.com.br"
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
|
-
"version": "1.2.
|
|
11
|
+
"version": "1.2.18",
|
|
12
12
|
"main": "./dist/tp.common.js",
|
|
13
13
|
"directories": {
|
|
14
14
|
"lib": "src/lib"
|
|
@@ -43,25 +43,26 @@
|
|
|
43
43
|
"test:unit": "vue-cli-service test:unit"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"
|
|
46
|
+
"@vue/babel-preset-app": "^5.0.8",
|
|
47
|
+
"axios": "^0.27.2",
|
|
47
48
|
"core-js": "^3.21.1",
|
|
48
49
|
"element-theme-chalk": "^2.13",
|
|
49
50
|
"element-ui": "2.15.8",
|
|
50
51
|
"js-cookie": "^3.0.1",
|
|
51
|
-
"vue": "^2.
|
|
52
|
+
"vue": "^2.7.10",
|
|
52
53
|
"vue-axios": "^2.1.5",
|
|
53
54
|
"vue-i18n": "^8.14.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
|
-
"@babel/core": "^7.18.
|
|
57
|
-
"@babel/eslint-parser": "^7.
|
|
58
|
-
"@vue/cli-plugin-babel": "^5.0.
|
|
59
|
-
"@vue/cli-plugin-unit-jest": "^5.0.
|
|
60
|
-
"@vue/cli-service": "^5.0.
|
|
57
|
+
"@babel/core": "^7.18.13",
|
|
58
|
+
"@babel/eslint-parser": "^7.18.9",
|
|
59
|
+
"@vue/cli-plugin-babel": "^5.0.8",
|
|
60
|
+
"@vue/cli-plugin-unit-jest": "^5.0.8",
|
|
61
|
+
"@vue/cli-service": "^5.0.8",
|
|
61
62
|
"@vue/test-utils": "^1.0.0-beta.31",
|
|
62
63
|
"@vuese/cli": "^2.10.0",
|
|
63
64
|
"babel-jest": "^24.9.0",
|
|
64
|
-
"babel-plugin-module-resolver": "^
|
|
65
|
+
"babel-plugin-module-resolver": "^4.1.0",
|
|
65
66
|
"babel-plugin-require-context-hook": "^1.0.0",
|
|
66
67
|
"eslint": "^8.9.0",
|
|
67
68
|
"eslint-config-prettier": "^8.4.0",
|
|
@@ -73,10 +74,10 @@
|
|
|
73
74
|
"eslint-plugin-promise": "^6.0.0",
|
|
74
75
|
"eslint-plugin-vue": "^9.1.1",
|
|
75
76
|
"node-sass": "^4.14.1",
|
|
76
|
-
"nodemon": "^2.0.
|
|
77
|
-
"prettier": "^2.
|
|
77
|
+
"nodemon": "^2.0.19",
|
|
78
|
+
"prettier": "^2.7.1",
|
|
78
79
|
"sass-loader": "^7.1.0",
|
|
79
|
-
"vue-template-compiler": "^2.
|
|
80
|
+
"vue-template-compiler": "^2.7.10",
|
|
80
81
|
"webpack": "4.46.0"
|
|
81
82
|
}
|
|
82
83
|
}
|
package/src/utils/currency.js
CHANGED
|
@@ -33,12 +33,19 @@ function unformat (input, precision = defaults.precision) {
|
|
|
33
33
|
* @returns
|
|
34
34
|
*/
|
|
35
35
|
function formatMoney (input, toString = false, locale = defaults) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
let inputString = ('' + input)
|
|
37
|
+
// Impede de digitar . ou , porque o formatador já adiciona
|
|
38
|
+
if ((inputString.slice(-1).match(/[.,]/))) {
|
|
39
|
+
inputString = inputString.substring(0, inputString.length - 1)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const negative = inputString.indexOf('-') >= 0 ? -1 : 1
|
|
38
43
|
|
|
39
44
|
if (toString) {
|
|
40
|
-
input = completeZeros(
|
|
45
|
+
input = completeZeros(inputString, locale)
|
|
41
46
|
}
|
|
47
|
+
|
|
48
|
+
const precision = locale.number.precision
|
|
42
49
|
const numbers = onlyNumbers(input, precision)
|
|
43
50
|
const currency = numbersToCurrency(numbers, precision)
|
|
44
51
|
if (toString) {
|
|
@@ -54,13 +61,17 @@ function formatMoney (input, toString = false, locale = defaults) {
|
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
function completeZeros (input,
|
|
58
|
-
const
|
|
64
|
+
function completeZeros (input, locale) {
|
|
65
|
+
const precision = locale?.number?.precision || defaults.precision
|
|
66
|
+
const decimal = locale?.number?.decimal || defaults.decimal
|
|
67
|
+
let i = input.lastIndexOf('.')
|
|
68
|
+
const j = input.lastIndexOf(',')
|
|
69
|
+
i = i > j ? i : j
|
|
59
70
|
const qntDecimais = i ? input.length - i - 1 : 0
|
|
60
71
|
|
|
61
72
|
// correção para decimal quebrado
|
|
62
73
|
if (i === -1) {
|
|
63
|
-
input = input +
|
|
74
|
+
input = input + decimal + '0'.repeat(precision)
|
|
64
75
|
} else if (i && qntDecimais < precision) {
|
|
65
76
|
input = input + '0'.repeat(precision - qntDecimais)
|
|
66
77
|
}
|