@tagplus/components 1.0.1 → 1.0.7
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/demo.html +1 -10
- package/dist/fonts/bevi-bold.7e4dcd11.woff +0 -0
- package/dist/fonts/bevi-bold.873def84.woff2 +0 -0
- package/dist/fonts/bevi-medium.6187e050.woff2 +0 -0
- package/dist/fonts/bevi-medium.65b3056d.woff +0 -0
- package/dist/fonts/bevi-regular.c89f126e.woff +0 -0
- package/dist/fonts/bevi-regular.f81e4b8f.woff2 +0 -0
- package/dist/tp.common.js +1 -1
- package/dist/tp.common.js.map +1 -1
- package/dist/tp.css +180 -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/components/Autosuggest/Autosuggest.vue +1 -0
- package/src/components/InputNumber/InputNumber.vue +95 -3
- package/src/components/OptionsListItem/OptionsListItem.vue +6 -0
- package/src/utils/filters.js +4 -1
package/package.json
CHANGED
|
@@ -10,15 +10,44 @@ export default {
|
|
|
10
10
|
usarVirgula: {
|
|
11
11
|
type: Boolean,
|
|
12
12
|
default: true
|
|
13
|
+
},
|
|
14
|
+
// Se false permite campo vazio
|
|
15
|
+
stringDefaultsZero: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: true
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
data () {
|
|
22
|
+
return {
|
|
23
|
+
currentValue: ''
|
|
13
24
|
}
|
|
14
25
|
},
|
|
15
26
|
|
|
16
27
|
computed: {
|
|
28
|
+
minDisabled () {
|
|
29
|
+
return this.value < this.min
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
maxDisabled () {
|
|
33
|
+
return this.value > this.max
|
|
34
|
+
},
|
|
35
|
+
|
|
17
36
|
displayValue () {
|
|
18
37
|
if (this.userInput !== null) {
|
|
38
|
+
// corrige o bug para deixar limpar o campo
|
|
39
|
+
if (!this.stringDefaultsZero && this.userInput === '') {
|
|
40
|
+
this.currentValue = ''
|
|
41
|
+
}
|
|
19
42
|
return this.userInput
|
|
20
43
|
}
|
|
21
|
-
|
|
44
|
+
|
|
45
|
+
let currentValue
|
|
46
|
+
if (this.value === '' && !this.stringDefaultsZero) {
|
|
47
|
+
currentValue = ''
|
|
48
|
+
} else {
|
|
49
|
+
currentValue = this.currentValue
|
|
50
|
+
}
|
|
22
51
|
|
|
23
52
|
if (typeof currentValue === 'number') {
|
|
24
53
|
if (this.stepStrictly) {
|
|
@@ -43,16 +72,65 @@ export default {
|
|
|
43
72
|
}
|
|
44
73
|
},
|
|
45
74
|
|
|
75
|
+
watch: {
|
|
76
|
+
value: {
|
|
77
|
+
immediate: true,
|
|
78
|
+
handler (value) {
|
|
79
|
+
let newVal
|
|
80
|
+
if (value === undefined) {
|
|
81
|
+
newVal = value
|
|
82
|
+
} else if (!this.stringDefaultsZero && value === '') {
|
|
83
|
+
newVal = ''
|
|
84
|
+
} else {
|
|
85
|
+
newVal = Number(value)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (newVal !== undefined) {
|
|
89
|
+
if (isNaN(newVal)) {
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.stepStrictly) {
|
|
94
|
+
const stepPrecision = this.getPrecision(this.step)
|
|
95
|
+
const precisionFactor = Math.pow(10, stepPrecision)
|
|
96
|
+
newVal = Math.round(newVal / this.step) * precisionFactor * this.step / precisionFactor
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.precision !== undefined) {
|
|
100
|
+
newVal = this.toPrecision(newVal, this.precision)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (newVal >= this.max) newVal = this.max
|
|
104
|
+
if (newVal <= this.min) newVal = this.min
|
|
105
|
+
this.currentValue = newVal
|
|
106
|
+
this.userInput = null
|
|
107
|
+
this.$emit('input', newVal)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
46
112
|
methods: {
|
|
47
113
|
handleInput (value) {
|
|
48
114
|
this.userInput = value
|
|
49
|
-
|
|
115
|
+
let newVal
|
|
116
|
+
if (value === '' && this.stringDefaultsZero) {
|
|
117
|
+
newVal = Number(value.replace(',', '.'))
|
|
118
|
+
} else {
|
|
119
|
+
newVal = value
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.$emit('change', newVal)
|
|
50
123
|
},
|
|
51
124
|
|
|
52
125
|
handleInputChange (value) {
|
|
53
126
|
let newVal
|
|
54
127
|
if (value === '') {
|
|
55
|
-
|
|
128
|
+
// Por padrão converte '' para 0
|
|
129
|
+
if (this.stringDefaultsZero) {
|
|
130
|
+
newVal = 0
|
|
131
|
+
} else {
|
|
132
|
+
newVal = ''
|
|
133
|
+
}
|
|
56
134
|
} else {
|
|
57
135
|
newVal = Number(value.replace(',', '.'))
|
|
58
136
|
}
|
|
@@ -61,6 +139,20 @@ export default {
|
|
|
61
139
|
this.setCurrentValue(newVal)
|
|
62
140
|
}
|
|
63
141
|
this.userInput = null
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
setCurrentValue (newVal) {
|
|
145
|
+
const oldVal = this.currentValue
|
|
146
|
+
if (typeof newVal === 'number' && this.precision !== undefined) {
|
|
147
|
+
newVal = this.toPrecision(newVal, this.precision)
|
|
148
|
+
}
|
|
149
|
+
if (newVal >= this.max) newVal = this.max
|
|
150
|
+
if (newVal <= this.min) newVal = this.min
|
|
151
|
+
if (oldVal === newVal && newVal !== '') return
|
|
152
|
+
this.userInput = null
|
|
153
|
+
this.$emit('input', newVal)
|
|
154
|
+
this.$emit('change', newVal, oldVal)
|
|
155
|
+
this.currentValue = newVal
|
|
64
156
|
}
|
|
65
157
|
}
|
|
66
158
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
<li
|
|
3
3
|
:id="id"
|
|
4
4
|
:class="['tp-options-list-item', itemType, active == optValue ? 'active' : '']"
|
|
5
|
+
tabindex="0"
|
|
5
6
|
@click="updateOption"
|
|
7
|
+
@keyup.enter="updateOption"
|
|
6
8
|
>
|
|
7
9
|
<div :class="['icon', direction]">
|
|
8
10
|
<i :class="[icon, 'options-icon']" />
|
|
@@ -171,6 +173,10 @@ export default {
|
|
|
171
173
|
|
|
172
174
|
}
|
|
173
175
|
|
|
176
|
+
.tp-options-list-item:focus{
|
|
177
|
+
border: 1px solid #437cf9;
|
|
178
|
+
}
|
|
179
|
+
|
|
174
180
|
.option-item-badge{
|
|
175
181
|
background-color: #F56C6C;
|
|
176
182
|
border: 1px solid #FFF;
|
package/src/utils/filters.js
CHANGED
|
@@ -19,7 +19,10 @@ import { t } from 'tp-ui/locale'
|
|
|
19
19
|
* @param {Number} val
|
|
20
20
|
*/
|
|
21
21
|
export const toCurrency = (val) => {
|
|
22
|
-
return (parseInt(val * 100) / 100).toLocaleString(t('locale.prefix')
|
|
22
|
+
return (parseInt(val * 100) / 100).toLocaleString(t('locale.prefix'), {
|
|
23
|
+
minimumFractionDigits: 2,
|
|
24
|
+
maximumFractionDigits: 2
|
|
25
|
+
})
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
/**
|