@tagplus/components 0.2.105 → 0.2.106

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
@@ -7,7 +7,7 @@
7
7
  "email": "bruno@tagplus.com.br"
8
8
  }
9
9
  ],
10
- "version": "0.2.105",
10
+ "version": "0.2.106",
11
11
  "main": "./dist/tp.common.js",
12
12
  "directories": {
13
13
  "lib": "src/lib"
@@ -6,10 +6,61 @@ export default {
6
6
 
7
7
  extends: InputNumber,
8
8
 
9
+ props: {
10
+ usarVirgula: {
11
+ type: Boolean,
12
+ default: true
13
+ }
14
+ },
15
+
16
+ computed: {
17
+ displayValue() {
18
+ if (this.userInput !== null) {
19
+ return this.userInput
20
+ }
21
+ let currentValue = this.currentValue
22
+
23
+ if (typeof currentValue === 'number') {
24
+ if (this.stepStrictly) {
25
+ const stepPrecision = this.getPrecision(this.step)
26
+ const precisionFactor = Math.pow(10, stepPrecision)
27
+ currentValue =
28
+ (Math.round(currentValue / this.step) *
29
+ precisionFactor *
30
+ this.step) /
31
+ precisionFactor
32
+ }
33
+
34
+ if (this.precision !== undefined) {
35
+ currentValue = currentValue.toFixed(this.precision)
36
+ }
37
+ }
38
+
39
+ if (this.usarVirgula) {
40
+ currentValue = (currentValue + '').replace('.', ',')
41
+ }
42
+ return currentValue
43
+ }
44
+ },
45
+
9
46
  methods: {
10
47
  handleInput(value) {
11
48
  this.userInput = value
12
- this.$emit('change', value)
49
+ this.$emit('change', Number(value.replace(',', '.')))
50
+ },
51
+
52
+ handleInputChange(value) {
53
+ let newVal
54
+ if (value === '') {
55
+ newVal = undefined
56
+ } else {
57
+ newVal = Number(value.replace(',', '.'))
58
+ }
59
+
60
+ if (!isNaN(newVal) || value === '') {
61
+ this.setCurrentValue(newVal)
62
+ }
63
+ this.userInput = null
13
64
  }
14
65
  }
15
66
  }