@tagplus/components 1.2.16 → 1.2.19
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.css +2 -2
- 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 +1 -1
- package/src/components/InputNumber/InputNumber.vue +8 -0
- package/src/utils/currency.js +5 -13
package/package.json
CHANGED
|
@@ -308,9 +308,17 @@ export default {
|
|
|
308
308
|
this.setCurrentValue(newVal)
|
|
309
309
|
},
|
|
310
310
|
handleBlur (event) {
|
|
311
|
+
if (!this.value && this.stringDefaultsZero && !this.precision) {
|
|
312
|
+
this.currentValue = 0
|
|
313
|
+
}
|
|
314
|
+
|
|
311
315
|
this.$emit('blur', event)
|
|
312
316
|
},
|
|
313
317
|
handleFocus (event) {
|
|
318
|
+
if (!this.value && !this.precision) {
|
|
319
|
+
this.currentValue = ''
|
|
320
|
+
}
|
|
321
|
+
|
|
314
322
|
this.$emit('focus', event)
|
|
315
323
|
},
|
|
316
324
|
|
package/src/utils/currency.js
CHANGED
|
@@ -33,17 +33,11 @@ function unformat (input, precision = defaults.precision) {
|
|
|
33
33
|
* @returns
|
|
34
34
|
*/
|
|
35
35
|
function formatMoney (input, toString = false, locale = defaults) {
|
|
36
|
-
|
|
37
|
-
let inputString = ('' + input)
|
|
38
|
-
// Impede de digitar . ou , porque o formatador já adiciona
|
|
39
|
-
if ((inputString.slice(-1).match(/[.,]/))) {
|
|
40
|
-
inputString = inputString.substring(0, inputString.length - 1)
|
|
41
|
-
}
|
|
42
|
-
const negative = inputString.indexOf('-') >= 0 ? -1 : 1
|
|
36
|
+
const negative = ('' + input).indexOf('-') >= 0 ? -1 : 1
|
|
43
37
|
const precision = locale.number.precision
|
|
44
38
|
|
|
45
39
|
if (toString) {
|
|
46
|
-
input = completeZeros(
|
|
40
|
+
input = completeZeros(('' + input), precision)
|
|
47
41
|
}
|
|
48
42
|
const numbers = onlyNumbers(input, precision)
|
|
49
43
|
const currency = numbersToCurrency(numbers, precision)
|
|
@@ -60,15 +54,13 @@ function formatMoney (input, toString = false, locale = defaults) {
|
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
function completeZeros (input,
|
|
64
|
-
const
|
|
65
|
-
const decimal = locale?.number?.decimal || defaults.decimal
|
|
66
|
-
const i = input.indexOf(decimal)
|
|
57
|
+
function completeZeros (input, precision = defaults.precision) {
|
|
58
|
+
const i = input.indexOf('.')
|
|
67
59
|
const qntDecimais = i ? input.length - i - 1 : 0
|
|
68
60
|
|
|
69
61
|
// correção para decimal quebrado
|
|
70
62
|
if (i === -1) {
|
|
71
|
-
input = input +
|
|
63
|
+
input = input + '.' + '0'.repeat(precision)
|
|
72
64
|
} else if (i && qntDecimais < precision) {
|
|
73
65
|
input = input + '0'.repeat(precision - qntDecimais)
|
|
74
66
|
}
|