@tagplus/components 5.3.2 → 5.3.4
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 -0
- 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 +2 -0
- package/dist/tp.common.js.map +1 -0
- package/dist/tp.css +167 -0
- package/dist/tp.umd.js +2 -0
- package/dist/tp.umd.js.map +1 -0
- package/dist/tp.umd.min.js +2 -0
- package/dist/tp.umd.min.js.map +1 -0
- package/package.json +61 -74
- package/src/assets/scss/_fonts.scss +27 -0
- package/src/assets/scss/_functions.scss +22 -0
- package/src/assets/scss/_helpers.scss +112 -0
- package/src/assets/scss/_mixins.scss +69 -0
- package/src/assets/scss/_overrides.scss +69 -0
- package/src/assets/scss/_resass.scss +83 -0
- package/src/assets/scss/_variables.scss +27 -0
- package/src/assets/scss/index.scss +11 -0
- package/src/components/Autosuggest/Autosuggest.vue +791 -0
- package/src/components/Autosuggest/index.js +3 -0
- package/src/components/Dialog/Dialog.vue +253 -0
- package/src/components/Dialog/index.js +3 -0
- package/src/components/Inline/Inline.vue +149 -0
- package/src/components/Inline/index.js +3 -0
- package/src/components/InputNumber/InputNumber.vue +430 -0
- package/src/components/InputNumber/index.js +3 -0
- package/src/components/Loader/Loader.vue +317 -0
- package/src/components/Loader/animations.scss +68 -0
- package/src/components/Loader/index.js +3 -0
- package/src/components/Money/Money.vue +82 -0
- package/src/components/Money/index.js +3 -0
- package/src/components/Multisuggest/Multisuggest.vue +858 -0
- package/src/components/Multisuggest/index.js +3 -0
- package/src/components/OptionsList/OptionsList.vue +61 -0
- package/src/components/OptionsList/index.js +3 -0
- package/src/components/OptionsListItem/OptionsListItem.vue +191 -0
- package/src/components/OptionsListItem/index.js +3 -0
- package/src/components/Percent/Percent.vue +81 -0
- package/src/components/Percent/index.js +3 -0
- package/src/components/Skeleton/Skeleton.vue +137 -0
- package/src/components/Skeleton/index.js +3 -0
- package/src/components/Step/Step.vue +230 -0
- package/src/components/Step/index.js +3 -0
- package/src/components/Steps/Steps.vue +18 -0
- package/src/components/Steps/index.js +3 -0
- package/src/components/Tip/Tip.vue +193 -0
- package/src/components/Tip/index.js +3 -0
- package/src/components/index.js +31 -0
- package/src/locale/index.js +78 -0
- package/{dist → src/locale}/lang/en.js +2 -3
- package/{dist → src/locale}/lang/pt-br.js +2 -3
- package/src/main.js +26 -0
- package/src/mixins/floatFormatter.js +53 -0
- package/src/mixins/locale.js +9 -0
- package/src/utils/currency.js +180 -0
- package/src/utils/filters.js +84 -0
- package/dist/es/_virtual/_plugin-vue_export-helper.mjs +0 -10
- package/dist/es/components.css +0 -2391
- package/dist/es/node_modules/@element-plus/icons-vue/dist/index.mjs +0 -148
- package/dist/es/node_modules/@popperjs/core/lib/enums.mjs +0 -22
- package/dist/es/node_modules/@vue/shared/dist/shared.esm-bundler.mjs +0 -28
- package/dist/es/node_modules/@vueuse/core/index.mjs +0 -172
- package/dist/es/node_modules/@vueuse/shared/index.mjs +0 -68
- package/dist/es/node_modules/element-plus/es/constants/size.mjs +0 -4
- package/dist/es/node_modules/element-plus/es/hooks/use-focus-controller/index.mjs +0 -64
- package/dist/es/node_modules/element-plus/es/hooks/use-id/index.mjs +0 -30
- package/dist/es/node_modules/element-plus/es/hooks/use-locale/index.mjs +0 -29
- package/dist/es/node_modules/element-plus/es/hooks/use-namespace/index.mjs +0 -79
- package/dist/es/node_modules/element-plus/es/hooks/use-prop/index.mjs +0 -11
- package/dist/es/node_modules/element-plus/es/hooks/use-size/index.mjs +0 -20
- package/dist/es/node_modules/element-plus/es/locale/lang/en.mjs +0 -182
- package/dist/es/node_modules/element-plus/es/utils/error.mjs +0 -16
- package/dist/es/node_modules/element-plus/es/utils/types.mjs +0 -9
- package/dist/es/node_modules/element-plus/es/utils/vue/props/runtime.mjs +0 -42
- package/dist/es/src/components/Autosuggest/Autosuggest.vue.mjs +0 -446
- package/dist/es/src/components/Autosuggest/Multisuggest.vue.mjs +0 -17
- package/dist/es/src/components/Autosuggest/autosuggest-props.mjs +0 -204
- package/dist/es/src/components/Autosuggest/core.mjs +0 -56
- package/dist/es/src/components/Autosuggest/multisuggest-props.mjs +0 -11
- package/dist/es/src/components/Autosuggest/option.vue.mjs +0 -118
- package/dist/es/src/components/Autosuggest/select-dropdown.vue.mjs +0 -62
- package/dist/es/src/components/Autosuggest/useOption.mjs +0 -93
- package/dist/es/src/components/Autosuggest/useSelect.mjs +0 -803
- package/dist/es/src/components/Inline/Inline.vue.mjs +0 -125
- package/dist/es/src/components/Inline/index.mjs +0 -4
- package/dist/es/src/components/InputNumber/InputNumber.vue.mjs +0 -360
- package/dist/es/src/components/InputNumber/index.mjs +0 -4
- package/dist/es/src/components/InputNumber/input-number.mjs +0 -128
- package/dist/es/src/components/Loader/Loader.vue.mjs +0 -59
- package/dist/es/src/components/Loader/index.mjs +0 -4
- package/dist/es/src/components/Money/Money.vue.mjs +0 -72
- package/dist/es/src/components/Money/index.mjs +0 -4
- package/dist/es/src/components/Multisuggest/index.mjs +0 -4
- package/dist/es/src/components/OptionsList/OptionsList.vue.mjs +0 -28
- package/dist/es/src/components/OptionsList/index.mjs +0 -4
- package/dist/es/src/components/OptionsListItem/OptionsListItem.vue.mjs +0 -96
- package/dist/es/src/components/OptionsListItem/index.mjs +0 -4
- package/dist/es/src/components/Percent/Percent.vue.mjs +0 -73
- package/dist/es/src/components/Percent/index.mjs +0 -4
- package/dist/es/src/components/Skeleton/Skeleton.vue.mjs +0 -79
- package/dist/es/src/components/Skeleton/index.mjs +0 -4
- package/dist/es/src/components/Step/Step.vue.mjs +0 -206
- package/dist/es/src/components/Step/index.mjs +0 -4
- package/dist/es/src/components/Steps/Steps.vue.mjs +0 -15
- package/dist/es/src/components/Steps/index.mjs +0 -4
- package/dist/es/src/components/Tip/Tip.vue.mjs +0 -160
- package/dist/es/src/components/Tip/index.mjs +0 -4
- package/dist/es/src/components/index.mjs +0 -32
- package/dist/es/src/locale/i18nCreator.mjs +0 -93
- package/dist/es/src/locale/lang/pt-br.mjs +0 -21
- package/dist/es/src/main.mjs +0 -17
- package/dist/es/src/mixins/floatFormatter.mjs +0 -42
- package/dist/es/src/plugins/currency.mjs +0 -69
- package/dist/es/src/utils/constants.mjs +0 -6
- package/dist/es/src/utils/error.mjs +0 -22
- package/dist/es/src/utils/i18n.mjs +0 -4
- package/dist/es/src/utils/icon.mjs +0 -9
- package/dist/es/src/utils/index.mjs +0 -11
- package/dist/es/src/utils/runtime.mjs +0 -50
- package/dist/es/src/utils/scroll.mjs +0 -28
- package/dist/es/src/utils/strings.mjs +0 -4
- package/dist/es/src/utils/types.mjs +0 -9
- package/dist/es/src/utils/use-derived-namespace.mjs +0 -15
- package/dist/es/src/utils/use-form-common-props.mjs +0 -25
- package/dist/es/src/utils/use-form-item.mjs +0 -61
- package/dist/es/src/utils/use-id.mjs +0 -35
- package/dist/es/src/utils/use-input.mjs +0 -31
- package/dist/lib/_virtual/_plugin-vue_export-helper.js +0 -10
- package/dist/lib/components.css +0 -2391
- package/dist/lib/node_modules/@element-plus/icons-vue/dist/index.js +0 -148
- package/dist/lib/node_modules/@popperjs/core/lib/enums.js +0 -22
- package/dist/lib/node_modules/@vue/shared/dist/shared.esm-bundler.js +0 -28
- package/dist/lib/node_modules/@vueuse/core/index.js +0 -170
- package/dist/lib/node_modules/@vueuse/shared/index.js +0 -68
- package/dist/lib/node_modules/element-plus/es/constants/size.js +0 -4
- package/dist/lib/node_modules/element-plus/es/hooks/use-focus-controller/index.js +0 -64
- package/dist/lib/node_modules/element-plus/es/hooks/use-id/index.js +0 -30
- package/dist/lib/node_modules/element-plus/es/hooks/use-locale/index.js +0 -29
- package/dist/lib/node_modules/element-plus/es/hooks/use-namespace/index.js +0 -79
- package/dist/lib/node_modules/element-plus/es/hooks/use-prop/index.js +0 -11
- package/dist/lib/node_modules/element-plus/es/hooks/use-size/index.js +0 -20
- package/dist/lib/node_modules/element-plus/es/locale/lang/en.js +0 -182
- package/dist/lib/node_modules/element-plus/es/utils/error.js +0 -16
- package/dist/lib/node_modules/element-plus/es/utils/types.js +0 -9
- package/dist/lib/node_modules/element-plus/es/utils/vue/props/runtime.js +0 -42
- package/dist/lib/src/components/Autosuggest/Autosuggest.vue.js +0 -446
- package/dist/lib/src/components/Autosuggest/Multisuggest.vue.js +0 -17
- package/dist/lib/src/components/Autosuggest/autosuggest-props.js +0 -204
- package/dist/lib/src/components/Autosuggest/core.js +0 -56
- package/dist/lib/src/components/Autosuggest/multisuggest-props.js +0 -11
- package/dist/lib/src/components/Autosuggest/option.vue.js +0 -118
- package/dist/lib/src/components/Autosuggest/select-dropdown.vue.js +0 -62
- package/dist/lib/src/components/Autosuggest/useOption.js +0 -93
- package/dist/lib/src/components/Autosuggest/useSelect.js +0 -803
- package/dist/lib/src/components/Inline/Inline.vue.js +0 -125
- package/dist/lib/src/components/Inline/index.js +0 -4
- package/dist/lib/src/components/InputNumber/InputNumber.vue.js +0 -360
- package/dist/lib/src/components/InputNumber/index.js +0 -4
- package/dist/lib/src/components/InputNumber/input-number.js +0 -128
- package/dist/lib/src/components/Loader/Loader.vue.js +0 -59
- package/dist/lib/src/components/Loader/index.js +0 -4
- package/dist/lib/src/components/Money/Money.vue.js +0 -72
- package/dist/lib/src/components/Money/index.js +0 -4
- package/dist/lib/src/components/Multisuggest/index.js +0 -4
- package/dist/lib/src/components/OptionsList/OptionsList.vue.js +0 -28
- package/dist/lib/src/components/OptionsList/index.js +0 -4
- package/dist/lib/src/components/OptionsListItem/OptionsListItem.vue.js +0 -96
- package/dist/lib/src/components/OptionsListItem/index.js +0 -4
- package/dist/lib/src/components/Percent/Percent.vue.js +0 -73
- package/dist/lib/src/components/Percent/index.js +0 -4
- package/dist/lib/src/components/Skeleton/Skeleton.vue.js +0 -79
- package/dist/lib/src/components/Skeleton/index.js +0 -4
- package/dist/lib/src/components/Step/Step.vue.js +0 -206
- package/dist/lib/src/components/Step/index.js +0 -4
- package/dist/lib/src/components/Steps/Steps.vue.js +0 -15
- package/dist/lib/src/components/Steps/index.js +0 -4
- package/dist/lib/src/components/Tip/Tip.vue.js +0 -160
- package/dist/lib/src/components/Tip/index.js +0 -4
- package/dist/lib/src/components/index.js +0 -32
- package/dist/lib/src/locale/i18nCreator.js +0 -93
- package/dist/lib/src/locale/lang/pt-br.js +0 -21
- package/dist/lib/src/main.js +0 -17
- package/dist/lib/src/mixins/floatFormatter.js +0 -42
- package/dist/lib/src/plugins/currency.js +0 -69
- package/dist/lib/src/utils/constants.js +0 -6
- package/dist/lib/src/utils/error.js +0 -22
- package/dist/lib/src/utils/i18n.js +0 -4
- package/dist/lib/src/utils/icon.js +0 -9
- package/dist/lib/src/utils/index.js +0 -14
- package/dist/lib/src/utils/runtime.js +0 -50
- package/dist/lib/src/utils/scroll.js +0 -28
- package/dist/lib/src/utils/strings.js +0 -4
- package/dist/lib/src/utils/types.js +0 -12
- package/dist/lib/src/utils/use-derived-namespace.js +0 -15
- package/dist/lib/src/utils/use-form-common-props.js +0 -25
- package/dist/lib/src/utils/use-form-item.js +0 -61
- package/dist/lib/src/utils/use-id.js +0 -35
- package/dist/lib/src/utils/use-input.js +0 -31
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="[
|
|
4
|
+
'el-input-number',
|
|
5
|
+
inputNumberSize ? 'el-input-number--' + inputNumberSize : '',
|
|
6
|
+
{ 'is-disabled': inputNumberDisabled },
|
|
7
|
+
{ 'is-without-controls': !controls },
|
|
8
|
+
{ 'is-controls-right': controlsAtRight }
|
|
9
|
+
]"
|
|
10
|
+
@dragstart.prevent
|
|
11
|
+
>
|
|
12
|
+
<span
|
|
13
|
+
v-if="controls"
|
|
14
|
+
v-repeat-click="decrease"
|
|
15
|
+
class="el-input-number__decrease"
|
|
16
|
+
role="button"
|
|
17
|
+
:class="{'is-disabled': minDisabled}"
|
|
18
|
+
@keydown.enter="decrease"
|
|
19
|
+
>
|
|
20
|
+
<em :class="`el-icon-${controlsAtRight ? 'arrow-down' : 'minus'}`" />
|
|
21
|
+
</span>
|
|
22
|
+
<span
|
|
23
|
+
v-if="controls"
|
|
24
|
+
v-repeat-click="increase"
|
|
25
|
+
class="el-input-number__increase"
|
|
26
|
+
role="button"
|
|
27
|
+
:class="{'is-disabled': maxDisabled}"
|
|
28
|
+
@keydown.enter="increase"
|
|
29
|
+
>
|
|
30
|
+
<em :class="`el-icon-${controlsAtRight ? 'arrow-up' : 'plus'}`" />
|
|
31
|
+
</span>
|
|
32
|
+
<el-input
|
|
33
|
+
ref="input"
|
|
34
|
+
:value="displayValue"
|
|
35
|
+
:placeholder="placeholder"
|
|
36
|
+
:disabled="inputNumberDisabled"
|
|
37
|
+
:size="inputNumberSize"
|
|
38
|
+
:max="max"
|
|
39
|
+
:min="min"
|
|
40
|
+
:name="name"
|
|
41
|
+
:label="label"
|
|
42
|
+
@keydown.up.native.prevent="increase"
|
|
43
|
+
@keydown.down.native.prevent="decrease"
|
|
44
|
+
@blur="handleBlur"
|
|
45
|
+
@focus="handleFocus"
|
|
46
|
+
@input="handleInput"
|
|
47
|
+
@change="handleInputChange"
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
import ElInput from 'element-ui/packages/input'
|
|
54
|
+
import Focus from 'element-ui/src/mixins/focus'
|
|
55
|
+
import RepeatClick from 'element-ui/src/directives/repeat-click'
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
name: 'TpInputNumber',
|
|
59
|
+
|
|
60
|
+
directives: {
|
|
61
|
+
repeatClick: RepeatClick
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
components: {
|
|
65
|
+
ElInput
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
mixins: [Focus('input')],
|
|
69
|
+
inject: {
|
|
70
|
+
elForm: {
|
|
71
|
+
default: ''
|
|
72
|
+
},
|
|
73
|
+
elFormItem: {
|
|
74
|
+
default: ''
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
props: {
|
|
79
|
+
step: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: 1
|
|
82
|
+
},
|
|
83
|
+
stepStrictly: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: false
|
|
86
|
+
},
|
|
87
|
+
max: {
|
|
88
|
+
type: Number,
|
|
89
|
+
default: Infinity
|
|
90
|
+
},
|
|
91
|
+
min: {
|
|
92
|
+
type: Number,
|
|
93
|
+
default: -Infinity
|
|
94
|
+
},
|
|
95
|
+
value: {
|
|
96
|
+
type: [Number, String],
|
|
97
|
+
default: null
|
|
98
|
+
},
|
|
99
|
+
disabled: Boolean,
|
|
100
|
+
size: {
|
|
101
|
+
type: [String, Boolean],
|
|
102
|
+
default: false
|
|
103
|
+
},
|
|
104
|
+
controls: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
default: true
|
|
107
|
+
},
|
|
108
|
+
controlsPosition: {
|
|
109
|
+
type: String,
|
|
110
|
+
default: ''
|
|
111
|
+
},
|
|
112
|
+
name: {
|
|
113
|
+
type: [String, Boolean],
|
|
114
|
+
default: false
|
|
115
|
+
},
|
|
116
|
+
label: {
|
|
117
|
+
type: [String],
|
|
118
|
+
default: ''
|
|
119
|
+
},
|
|
120
|
+
placeholder: {
|
|
121
|
+
type: [String, Boolean],
|
|
122
|
+
default: false
|
|
123
|
+
},
|
|
124
|
+
precision: {
|
|
125
|
+
type: Number,
|
|
126
|
+
default: 2,
|
|
127
|
+
validator (val) {
|
|
128
|
+
return val >= 0 && val === parseInt(val, 10)
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
// Customizada
|
|
132
|
+
usarVirgula: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
default: true
|
|
135
|
+
},
|
|
136
|
+
// Customizada - Se false permite campo vazio
|
|
137
|
+
stringDefaultsZero: {
|
|
138
|
+
type: Boolean,
|
|
139
|
+
default: true
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
data () {
|
|
144
|
+
return {
|
|
145
|
+
currentValue: '',
|
|
146
|
+
userInput: null
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
computed: {
|
|
151
|
+
/**
|
|
152
|
+
* Sobrescrito do element
|
|
153
|
+
*/
|
|
154
|
+
minDisabled () {
|
|
155
|
+
return this.value < this.min
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Sobrescrito do element
|
|
160
|
+
*/
|
|
161
|
+
maxDisabled () {
|
|
162
|
+
return this.value > this.max
|
|
163
|
+
},
|
|
164
|
+
numPrecision () {
|
|
165
|
+
const { value, step, getPrecision, precision } = this
|
|
166
|
+
const stepPrecision = getPrecision(step)
|
|
167
|
+
|
|
168
|
+
if (precision !== undefined) {
|
|
169
|
+
if (stepPrecision > precision) {
|
|
170
|
+
console.warn('[Element Warn][InputNumber]precision should not be less than the decimal places of step')
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return precision
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return Math.max(getPrecision(value), stepPrecision)
|
|
177
|
+
},
|
|
178
|
+
controlsAtRight () {
|
|
179
|
+
return this.controls && this.controlsPosition === 'right'
|
|
180
|
+
},
|
|
181
|
+
_elFormItemSize () {
|
|
182
|
+
return (this.elFormItem || {}).elFormItemSize
|
|
183
|
+
},
|
|
184
|
+
inputNumberSize () {
|
|
185
|
+
return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size
|
|
186
|
+
},
|
|
187
|
+
inputNumberDisabled () {
|
|
188
|
+
return this.disabled || Boolean((this.elForm || {}).disabled)
|
|
189
|
+
},
|
|
190
|
+
/**
|
|
191
|
+
* Sobrescrito do element
|
|
192
|
+
*/
|
|
193
|
+
displayValue () {
|
|
194
|
+
if (this.userInput !== null) {
|
|
195
|
+
// corrige o bug para deixar limpar o campo
|
|
196
|
+
if (!this.stringDefaultsZero && this.userInput === '') {
|
|
197
|
+
this.currentValue = ''
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return this.userInput
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
let currentValue
|
|
204
|
+
|
|
205
|
+
if (this.value === '' && !this.stringDefaultsZero) {
|
|
206
|
+
currentValue = ''
|
|
207
|
+
} else {
|
|
208
|
+
currentValue = this.currentValue
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (typeof currentValue === 'number') {
|
|
212
|
+
if (this.stepStrictly) {
|
|
213
|
+
const stepPrecision = this.getPrecision(this.step)
|
|
214
|
+
const precisionFactor = Math.pow(10, stepPrecision)
|
|
215
|
+
|
|
216
|
+
currentValue =
|
|
217
|
+
(Math.round(currentValue / this.step) *
|
|
218
|
+
precisionFactor *
|
|
219
|
+
this.step) /
|
|
220
|
+
precisionFactor
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (this.precision !== undefined) {
|
|
224
|
+
currentValue = currentValue.toFixed(this.precision)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (this.usarVirgula) {
|
|
229
|
+
currentValue = (`${currentValue }`).replace('.', ',')
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return currentValue
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
watch: {
|
|
237
|
+
/**
|
|
238
|
+
* Sobrescrito do element
|
|
239
|
+
*/
|
|
240
|
+
value: {
|
|
241
|
+
immediate: true,
|
|
242
|
+
handler (value) {
|
|
243
|
+
let newVal
|
|
244
|
+
|
|
245
|
+
if (value === undefined) {
|
|
246
|
+
newVal = value
|
|
247
|
+
} else if (!this.stringDefaultsZero && value === '') {
|
|
248
|
+
newVal = ''
|
|
249
|
+
} else {
|
|
250
|
+
newVal = Number(value)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (newVal !== undefined) {
|
|
254
|
+
if (isNaN(newVal)) {
|
|
255
|
+
return
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (this.stepStrictly) {
|
|
259
|
+
const stepPrecision = this.getPrecision(this.step)
|
|
260
|
+
const precisionFactor = Math.pow(10, stepPrecision)
|
|
261
|
+
|
|
262
|
+
newVal = Math.round(newVal / this.step) * precisionFactor * this.step / precisionFactor
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (this.precision !== undefined) {
|
|
266
|
+
newVal = this.toPrecision(newVal, this.precision)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (newVal >= this.max) newVal = this.max
|
|
271
|
+
|
|
272
|
+
if (newVal <= this.min) newVal = this.min
|
|
273
|
+
|
|
274
|
+
this.currentValue = newVal
|
|
275
|
+
this.userInput = null
|
|
276
|
+
this.$emit('input', newVal)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
mounted () {
|
|
282
|
+
const innerInput = this.$refs.input.$refs.input
|
|
283
|
+
|
|
284
|
+
innerInput.setAttribute('role', 'spinbutton')
|
|
285
|
+
innerInput.setAttribute('aria-valuemax', this.max)
|
|
286
|
+
innerInput.setAttribute('aria-valuemin', this.min)
|
|
287
|
+
innerInput.setAttribute('aria-valuenow', this.currentValue)
|
|
288
|
+
innerInput.setAttribute('aria-disabled', this.inputNumberDisabled)
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
updated () {
|
|
292
|
+
if (!this.$refs || !this.$refs.input) return
|
|
293
|
+
|
|
294
|
+
const innerInput = this.$refs.input.$refs.input
|
|
295
|
+
|
|
296
|
+
innerInput.setAttribute('aria-valuenow', this.currentValue)
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
methods: {
|
|
300
|
+
toPrecision (num, precision) {
|
|
301
|
+
if (precision === undefined) precision = this.numPrecision
|
|
302
|
+
|
|
303
|
+
return parseFloat(Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision))
|
|
304
|
+
},
|
|
305
|
+
getPrecision (value) {
|
|
306
|
+
if (value === undefined) return 0
|
|
307
|
+
|
|
308
|
+
const valueString = value.toString()
|
|
309
|
+
const dotPosition = valueString.indexOf('.')
|
|
310
|
+
let precision = 0
|
|
311
|
+
|
|
312
|
+
if (dotPosition !== -1) {
|
|
313
|
+
precision = valueString.length - dotPosition - 1
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return precision
|
|
317
|
+
},
|
|
318
|
+
_increase (val, step) {
|
|
319
|
+
if (typeof val !== 'number' && val !== undefined) return this.currentValue
|
|
320
|
+
|
|
321
|
+
const precisionFactor = Math.pow(10, this.numPrecision)
|
|
322
|
+
|
|
323
|
+
// Solve the accuracy problem of JS decimal calculation by converting the value to integer.
|
|
324
|
+
return this.toPrecision((precisionFactor * val + precisionFactor * step) / precisionFactor)
|
|
325
|
+
},
|
|
326
|
+
_decrease (val, step) {
|
|
327
|
+
if (typeof val !== 'number' && val !== undefined) return this.currentValue
|
|
328
|
+
|
|
329
|
+
const precisionFactor = Math.pow(10, this.numPrecision)
|
|
330
|
+
|
|
331
|
+
return this.toPrecision((precisionFactor * val - precisionFactor * step) / precisionFactor)
|
|
332
|
+
},
|
|
333
|
+
increase () {
|
|
334
|
+
if (this.inputNumberDisabled || this.maxDisabled) return
|
|
335
|
+
|
|
336
|
+
const value = this.value || 0
|
|
337
|
+
const newVal = this._increase(value, this.step)
|
|
338
|
+
|
|
339
|
+
this.setCurrentValue(newVal)
|
|
340
|
+
},
|
|
341
|
+
decrease () {
|
|
342
|
+
if (this.inputNumberDisabled || this.minDisabled) return
|
|
343
|
+
|
|
344
|
+
const value = this.value || 0
|
|
345
|
+
const newVal = this._decrease(value, this.step)
|
|
346
|
+
|
|
347
|
+
this.setCurrentValue(newVal)
|
|
348
|
+
},
|
|
349
|
+
handleBlur (event) {
|
|
350
|
+
if (!this.value && this.stringDefaultsZero && !this.precision) {
|
|
351
|
+
this.currentValue = 0
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
this.$emit('blur', event)
|
|
355
|
+
},
|
|
356
|
+
handleFocus (event) {
|
|
357
|
+
if (!this.value && !this.precision) {
|
|
358
|
+
this.currentValue = ''
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
this.$emit('focus', event)
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Sobrescrito do element
|
|
366
|
+
*/
|
|
367
|
+
handleInput (value) {
|
|
368
|
+
this.userInput = value
|
|
369
|
+
let newVal
|
|
370
|
+
|
|
371
|
+
if (value === '' && this.stringDefaultsZero) {
|
|
372
|
+
newVal = Number(value.replace(',', '.'))
|
|
373
|
+
} else {
|
|
374
|
+
newVal = value
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
this.$emit('change', newVal)
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Sobrescrito do element
|
|
382
|
+
*/
|
|
383
|
+
handleInputChange (value) {
|
|
384
|
+
let newVal
|
|
385
|
+
|
|
386
|
+
if (value === '') {
|
|
387
|
+
// Por padrão converte '' para 0
|
|
388
|
+
if (this.stringDefaultsZero) {
|
|
389
|
+
newVal = 0
|
|
390
|
+
} else {
|
|
391
|
+
newVal = ''
|
|
392
|
+
}
|
|
393
|
+
} else {
|
|
394
|
+
newVal = Number(value.replace(',', '.'))
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (!isNaN(newVal) || value === '') {
|
|
398
|
+
this.setCurrentValue(newVal)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
this.userInput = null
|
|
402
|
+
},
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Sobrescrito do element
|
|
406
|
+
*/
|
|
407
|
+
setCurrentValue (newVal) {
|
|
408
|
+
const oldVal = this.currentValue
|
|
409
|
+
|
|
410
|
+
if (typeof newVal === 'number' && this.precision !== undefined) {
|
|
411
|
+
newVal = this.toPrecision(newVal, this.precision)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (newVal >= this.max) newVal = this.max
|
|
415
|
+
|
|
416
|
+
if (newVal <= this.min) newVal = this.min
|
|
417
|
+
|
|
418
|
+
if (oldVal === newVal && newVal === this.value) return
|
|
419
|
+
|
|
420
|
+
this.userInput = null
|
|
421
|
+
this.$emit('input', newVal)
|
|
422
|
+
this.$emit('change', newVal, oldVal)
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
select () {
|
|
426
|
+
this.$refs.input.select()
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
</script>
|