@tagplus/components 4.0.1 → 4.0.2

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/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "email": "bruno@tagplus.com.br"
9
9
  }
10
10
  ],
11
- "version": "4.0.1",
11
+ "version": "4.0.2",
12
12
  "main": "./dist/tp.common.js",
13
13
  "directories": {
14
14
  "lib": "src/lib"
@@ -1,4 +1,3 @@
1
-
2
1
  <script>
3
2
  import { Steps } from 'element-ui'
4
3
 
@@ -16,9 +16,9 @@ export default {
16
16
  default: false
17
17
  },
18
18
 
19
- valorCusto: {
20
- type: Boolean,
21
- default: false
19
+ customPrecision: {
20
+ type: Number,
21
+ default: 2
22
22
  }
23
23
  },
24
24
 
@@ -33,21 +33,21 @@ export default {
33
33
  immediate: true,
34
34
  handler (newValue, oldValue) {
35
35
  if (newValue === '' && this.allowEmpty) { this.formattedValue = ''; return }
36
- this.formattedValue = formatMoney(newValue, true, this.locale, this.valorCusto)
36
+ this.formattedValue = formatMoney(newValue, true, this.locale, this.customPrecision)
37
37
  }
38
38
  }
39
39
  },
40
40
 
41
41
  methods: {
42
42
  input (evt) {
43
- this.formattedValue = formatMoney(evt, true, this.locale, this.valorCusto)
44
- const moneyFormatado = formatMoney(evt, false, this.locale, this.valorCusto)
43
+ this.formattedValue = formatMoney(evt, true, this.locale, this.customPrecision)
44
+ const moneyFormatado = formatMoney(evt, false, this.locale, this.customPrecision)
45
45
 
46
46
  this.$emit('input', moneyFormatado)
47
47
  },
48
48
 
49
49
  handleChange (evt) {
50
- this.$emit('change', formatMoney(evt, false, this.locale, this.valorCusto))
50
+ this.$emit('change', formatMoney(evt, false, this.locale, this.customPrecision))
51
51
  }
52
52
  }
53
53
 
@@ -36,7 +36,7 @@ function unformat (input, precision = defaults.precision) {
36
36
  * @param {Object} locale Configuração de localidade para saber número de casas decimais (precision) e caracter de decimal (decimal)
37
37
  * @returns
38
38
  */
39
- function formatMoney (input, toString = false, locale = defaults, valorCusto = false) {
39
+ function formatMoney (input, toString = false, locale = defaults, customPrecision = false) {
40
40
  let inputString = (`${input}`)
41
41
 
42
42
  // Impede de digitar . ou , porque o formatador já adiciona
@@ -50,7 +50,7 @@ function formatMoney (input, toString = false, locale = defaults, valorCusto = f
50
50
  input = completeZeros(inputString, locale)
51
51
  }
52
52
 
53
- const precision = valorCusto ? 3 : locale.number.precision
53
+ const precision = customPrecision || locale.number.precision
54
54
  const numbers = onlyNumbers(input, precision)
55
55
  const currency = numbersToCurrency(numbers, precision)
56
56