@tagplus/components 4.7.7 → 4.7.8
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 +1 -1
- package/src/utils/currency.js +24 -4
package/package.json
CHANGED
package/src/utils/currency.js
CHANGED
|
@@ -38,7 +38,7 @@ function unformat (input, precision = defaults.precision) {
|
|
|
38
38
|
* @returns
|
|
39
39
|
*/
|
|
40
40
|
function formatMoney (input, toString = false, locale = defaults, customPrecision = false) {
|
|
41
|
-
let inputString = removeSecondSeparator(`${input}
|
|
41
|
+
let inputString = removeSecondSeparator(`${input}`, locale)
|
|
42
42
|
|
|
43
43
|
// Impede de digitar . ou , porque o formatador já adiciona
|
|
44
44
|
if ((inputString.slice(-1).match(/[.,]/))) {
|
|
@@ -91,9 +91,29 @@ function completeZeros (customPrecision, input, locale) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
// Impede que seja adicionado um segundo separadador apos o ponto ou a virgula
|
|
94
|
-
function removeSecondSeparator (input) {
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
function removeSecondSeparator (input, locale) {
|
|
95
|
+
const decimal = locale?.number?.decimal
|
|
96
|
+
|
|
97
|
+
if (!decimal || !input) {
|
|
98
|
+
return input
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Separa a string pelo decimal
|
|
102
|
+
const newInputParts = input.split(decimal)
|
|
103
|
+
|
|
104
|
+
if (newInputParts.length > 0) {
|
|
105
|
+
let newInput = ''
|
|
106
|
+
|
|
107
|
+
// Percorre as partes dividas da string limpando tudo que nao for numerico depois do separador decimal
|
|
108
|
+
for (let i = 0; i < newInputParts.length; i++) {
|
|
109
|
+
newInputParts[i] = i >= 1 ? newInputParts[i].replace(/[^0-9]/g, '') : newInputParts[i] + decimal
|
|
110
|
+
newInput += newInputParts[i]
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return newInput
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return input
|
|
97
117
|
}
|
|
98
118
|
|
|
99
119
|
function onlyNumbers (input) {
|