@tagplus/components 5.2.7 → 5.2.9
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.common.lang-tp-en-js.js → tp.common.lang-en-js.js} +2 -2
- package/dist/tp.common.lang-en-js.js.map +1 -0
- package/dist/tp.umd.js +1 -1
- package/dist/tp.umd.js.map +1 -1
- package/dist/{tp.umd.lang-tp-en-js.js → tp.umd.lang-en-js.js} +2 -2
- package/dist/tp.umd.lang-en-js.js.map +1 -0
- package/dist/tp.umd.min.js +1 -1
- package/dist/tp.umd.min.js.map +1 -1
- package/dist/{tp.umd.min.lang-tp-en-js.js → tp.umd.min.lang-en-js.js} +2 -2
- package/dist/tp.umd.min.lang-en-js.js.map +1 -0
- package/package.json +2 -7
- package/dist/tp.common.lang-tp-en-js.js.map +0 -1
- package/dist/tp.umd.lang-tp-en-js.js.map +0 -1
- package/dist/tp.umd.min.lang-tp-en-js.js.map +0 -1
- package/src/assets/scss/_fonts.scss +0 -28
- package/src/assets/scss/_functions.scss +0 -22
- package/src/assets/scss/_helpers.scss +0 -116
- package/src/assets/scss/_mixins.scss +0 -69
- package/src/assets/scss/_overrides.scss +0 -22
- package/src/assets/scss/_resass.scss +0 -92
- package/src/assets/scss/_variables.scss +0 -26
- package/src/assets/scss/index.scss +0 -8
- package/src/components/Autosuggest/Autosuggest.vue +0 -362
- package/src/components/Autosuggest/Multisuggest.vue +0 -22
- package/src/components/Autosuggest/autosuggest-props.js +0 -210
- package/src/components/Autosuggest/autosuggest-style.scss +0 -127
- package/src/components/Autosuggest/core.js +0 -63
- package/src/components/Autosuggest/index.js +0 -5
- package/src/components/Autosuggest/multisuggest-props.js +0 -9
- package/src/components/Autosuggest/option.vue +0 -136
- package/src/components/Autosuggest/select-dropdown.vue +0 -64
- package/src/components/Autosuggest/useOption.js +0 -120
- package/src/components/Autosuggest/useSelect.js +0 -1133
- package/src/components/AutosuggestTest.vue +0 -56
- package/src/components/CardExemplo.vue +0 -49
- package/src/components/CodeSample.vue +0 -78
- package/src/components/Inline/Inline.vue +0 -141
- package/src/components/Inline/index.js +0 -3
- package/src/components/InputNumber/InputNumber.vue +0 -381
- package/src/components/InputNumber/index.js +0 -3
- package/src/components/InputNumber/input-number.js +0 -135
- package/src/components/Loader/Loader.vue +0 -306
- package/src/components/Loader/animations.scss +0 -81
- package/src/components/Loader/index.js +0 -3
- package/src/components/Money/Money.vue +0 -73
- package/src/components/Money/index.js +0 -3
- package/src/components/Multisuggest/index.js +0 -2
- package/src/components/MultisuggestTest.vue +0 -56
- package/src/components/OptionsList/OptionsList.vue +0 -62
- package/src/components/OptionsList/index.js +0 -3
- package/src/components/OptionsListItem/OptionsListItem.vue +0 -195
- package/src/components/OptionsListItem/index.js +0 -3
- package/src/components/Percent/Percent.vue +0 -75
- package/src/components/Percent/index.js +0 -3
- package/src/components/Skeleton/Skeleton.vue +0 -142
- package/src/components/Skeleton/index.js +0 -3
- package/src/components/Step/Step.vue +0 -237
- package/src/components/Step/index.js +0 -3
- package/src/components/Steps/Steps.vue +0 -15
- package/src/components/Steps/index.js +0 -3
- package/src/components/TesteToCurrency.vue +0 -171
- package/src/components/Tip/Tip.vue +0 -210
- package/src/components/Tip/index.js +0 -3
- package/src/components/ValueSelector.vue +0 -60
- package/src/components/autosuggestMixin.js +0 -301
- package/src/components/index.js +0 -34
- package/src/locale/i18nCreator.js +0 -169
- package/src/locale/lang/en.js +0 -35
- package/src/locale/lang/pt-br.js +0 -35
- package/src/main.js +0 -21
- package/src/mixins/floatFormatter.js +0 -49
- package/src/plugins/currency.js +0 -100
- package/src/utils/browser.js +0 -6
- package/src/utils/constants.js +0 -3
- package/src/utils/error.js +0 -22
- package/src/utils/filters.js +0 -71
- package/src/utils/helpers.js +0 -41
- package/src/utils/i18n.js +0 -2
- package/src/utils/icon.js +0 -35
- package/src/utils/index.js +0 -20
- package/src/utils/objects.js +0 -17
- package/src/utils/runtime.js +0 -86
- package/src/utils/scroll.js +0 -100
- package/src/utils/strings.js +0 -17
- package/src/utils/style.js +0 -80
- package/src/utils/types.js +0 -39
- package/src/utils/use-derived-namespace.js +0 -112
- package/src/utils/use-form-common-props.js +0 -41
- package/src/utils/use-form-item.js +0 -80
- package/src/utils/use-id.js +0 -40
- package/src/utils/use-input.js +0 -33
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<tp-autosuggest
|
|
3
|
-
:id="_id"
|
|
4
|
-
:model-value="modelValue"
|
|
5
|
-
:placeholder="$t($options.placeholder)"
|
|
6
|
-
:label-key="$options.labelKey"
|
|
7
|
-
:remote-method="remoteMethod"
|
|
8
|
-
:suggestions="list"
|
|
9
|
-
:loading="loading"
|
|
10
|
-
:load-on-create="isLoadOnCreate"
|
|
11
|
-
:disabled="_disabled"
|
|
12
|
-
:allow-create="true"
|
|
13
|
-
:multiple="false"
|
|
14
|
-
@update:model-value="autosuggestMixin_input"
|
|
15
|
-
@handleOptionClick="autosuggestMixin_handleCreate"
|
|
16
|
-
@change="autosuggestMixin_handleChange"
|
|
17
|
-
/>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
|
-
<script>
|
|
21
|
-
import { defineComponent } from 'vue'
|
|
22
|
-
import AutosuggestsMixin from '@/components/autosuggestMixin'
|
|
23
|
-
|
|
24
|
-
export default defineComponent({
|
|
25
|
-
name: 'AutosuggestTest',
|
|
26
|
-
valueKey: 'id',
|
|
27
|
-
labelKey: 'name',
|
|
28
|
-
placeholder: 'common.placeholder',
|
|
29
|
-
|
|
30
|
-
mixins: [AutosuggestsMixin],
|
|
31
|
-
|
|
32
|
-
data () {
|
|
33
|
-
return {
|
|
34
|
-
uri: 'https://jsonplaceholder.typicode.com/users',
|
|
35
|
-
loading: false
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
methods: {
|
|
40
|
-
remoteMethod (query) {
|
|
41
|
-
this.loading = true
|
|
42
|
-
this.axios
|
|
43
|
-
.get(`${this.uri}?q=${query}`)
|
|
44
|
-
.then(res => {
|
|
45
|
-
this.list = res.data
|
|
46
|
-
this.loading = false
|
|
47
|
-
})
|
|
48
|
-
.catch(err => {
|
|
49
|
-
console.log(err)
|
|
50
|
-
this.loading = false
|
|
51
|
-
this.list = []
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
</script>
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-container class="component-sample">
|
|
3
|
-
<el-header>
|
|
4
|
-
{{ title }}
|
|
5
|
-
</el-header>
|
|
6
|
-
<el-main>
|
|
7
|
-
<el-scrollbar>
|
|
8
|
-
<el-row class="scrollbar-flex-content" justify="center">
|
|
9
|
-
<slot name="default" />
|
|
10
|
-
</el-row>
|
|
11
|
-
</el-scrollbar>
|
|
12
|
-
</el-main>
|
|
13
|
-
<slot name="codeSamples" />
|
|
14
|
-
</el-container>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script>
|
|
18
|
-
export default {
|
|
19
|
-
name:'CardExemplo',
|
|
20
|
-
|
|
21
|
-
props: {
|
|
22
|
-
title: {
|
|
23
|
-
type: String,
|
|
24
|
-
required: true
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
}
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<style lang="scss" scoped>
|
|
31
|
-
.component-sample {
|
|
32
|
-
margin: 0px auto;
|
|
33
|
-
margin-bottom: 16px;
|
|
34
|
-
max-width: 700px;
|
|
35
|
-
border: 1px #ccc solid;
|
|
36
|
-
border-radius: 10px;
|
|
37
|
-
padding: 8px;
|
|
38
|
-
background-color: #919191;
|
|
39
|
-
|
|
40
|
-
header.el-header {
|
|
41
|
-
font-size: 17px;
|
|
42
|
-
font-weight: bold;
|
|
43
|
-
color: #fff;
|
|
44
|
-
border-bottom: 1px solid $--border-color-lighter;
|
|
45
|
-
text-align: center;
|
|
46
|
-
height: auto;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
</style>
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="code-sample">
|
|
3
|
-
<el-row class="code-sample-description">
|
|
4
|
-
<span v-html="description" />
|
|
5
|
-
</el-row>
|
|
6
|
-
<el-row class="code-sample-code">
|
|
7
|
-
<pre>
|
|
8
|
-
<slot>
|
|
9
|
-
{{ formattedCode }}
|
|
10
|
-
</slot>
|
|
11
|
-
</pre>
|
|
12
|
-
</el-row>
|
|
13
|
-
</div>
|
|
14
|
-
</template>
|
|
15
|
-
|
|
16
|
-
<script>
|
|
17
|
-
import { onMounted, ref, watch } from 'vue'
|
|
18
|
-
export default {
|
|
19
|
-
name: 'CodeSample',
|
|
20
|
-
props: {
|
|
21
|
-
description: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: ''
|
|
24
|
-
},
|
|
25
|
-
code: {
|
|
26
|
-
required: false
|
|
27
|
-
},
|
|
28
|
-
/**
|
|
29
|
-
* Se vai observar as alterações na variável code
|
|
30
|
-
*/
|
|
31
|
-
reactive: {
|
|
32
|
-
type: Boolean,
|
|
33
|
-
default: false
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
setup (props) {
|
|
38
|
-
let formattedCode = ref('')
|
|
39
|
-
const handler = (newValue, oldValue) => {
|
|
40
|
-
const code = props.code ?? 'undefined'
|
|
41
|
-
formattedCode.value = '\n' + JSON.stringify(code, undefined, 2).trim()
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (props.reactive){
|
|
45
|
-
watch(() => props.code, handler)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
onMounted(handler)
|
|
49
|
-
return {
|
|
50
|
-
formattedCode
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
</script>
|
|
55
|
-
|
|
56
|
-
<style lang="scss" scoped>
|
|
57
|
-
.code-sample{
|
|
58
|
-
background-color: #eee;
|
|
59
|
-
border-radius: 8px;
|
|
60
|
-
}
|
|
61
|
-
.code-sample-description {
|
|
62
|
-
font-size: 14px;
|
|
63
|
-
padding: 8px;
|
|
64
|
-
}
|
|
65
|
-
.code-sample-code {
|
|
66
|
-
pre {
|
|
67
|
-
display: inline-flex;
|
|
68
|
-
width: 100%;
|
|
69
|
-
margin: 0;
|
|
70
|
-
font-family: monospace;
|
|
71
|
-
background-color: #444;
|
|
72
|
-
color: #eee;
|
|
73
|
-
padding: 10px 10px 0 10px;
|
|
74
|
-
border-bottom-left-radius: 8px;
|
|
75
|
-
border-bottom-right-radius: 8px;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
</style>
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :id="`${_id}-wrapper`" class="tp-inline">
|
|
3
|
-
<span v-if="hideInput || readonly" data-tid="inline-span">
|
|
4
|
-
<a
|
|
5
|
-
:id="`${_id}-toggle`"
|
|
6
|
-
tabindex="0"
|
|
7
|
-
@click="toggleInput"
|
|
8
|
-
@keypress.enter="toggleInput"
|
|
9
|
-
>
|
|
10
|
-
<span data-tid="inline-value">{{ value }}</span>
|
|
11
|
-
<small v-if="!readonly" class="el-icon-edit" />
|
|
12
|
-
</a>
|
|
13
|
-
</span>
|
|
14
|
-
<el-input
|
|
15
|
-
v-else
|
|
16
|
-
:id="`${_id}-input`"
|
|
17
|
-
ref="inlineInput"
|
|
18
|
-
:model-value="value"
|
|
19
|
-
data-tid="inline-input"
|
|
20
|
-
@input="input"
|
|
21
|
-
@blur="blur"
|
|
22
|
-
@keypress.enter="toggleInput"
|
|
23
|
-
>
|
|
24
|
-
<template #append>
|
|
25
|
-
<el-button
|
|
26
|
-
:id="`${_id}-btn`"
|
|
27
|
-
:icon="ElIconCheck"
|
|
28
|
-
data-tid="inline-button"
|
|
29
|
-
@click="toggleInput"
|
|
30
|
-
>
|
|
31
|
-
{{ buttonText }}
|
|
32
|
-
</el-button>
|
|
33
|
-
</template>
|
|
34
|
-
</el-input>
|
|
35
|
-
</div>
|
|
36
|
-
</template>
|
|
37
|
-
|
|
38
|
-
<script>
|
|
39
|
-
import { defineComponent } from 'vue'
|
|
40
|
-
import { Check as ElIconCheck } from '@element-plus/icons-vue'
|
|
41
|
-
export default defineComponent({
|
|
42
|
-
name: 'TpInline',
|
|
43
|
-
props: {
|
|
44
|
-
id: {
|
|
45
|
-
type: String,
|
|
46
|
-
required: false,
|
|
47
|
-
default: null
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
value: {
|
|
51
|
-
type: [Number, String],
|
|
52
|
-
default: ''
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
readonly: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: false
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
inputHidden: {
|
|
61
|
-
type: Boolean,
|
|
62
|
-
default: true
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
buttonText: {
|
|
66
|
-
type: String,
|
|
67
|
-
default: 'Ok'
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
emits: ['input', 'change', 'blur'],
|
|
71
|
-
data () {
|
|
72
|
-
return {
|
|
73
|
-
hideInput: true,
|
|
74
|
-
ElIconCheck
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
computed: {
|
|
78
|
-
_id () {
|
|
79
|
-
return this.id || this.$options.name
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
mounted () {
|
|
83
|
-
this.hideInput = this.inputHidden
|
|
84
|
-
},
|
|
85
|
-
methods: {
|
|
86
|
-
toggleInput () {
|
|
87
|
-
const status = !this.hideInput
|
|
88
|
-
|
|
89
|
-
if (this.readonly) {
|
|
90
|
-
this.hideInput = true
|
|
91
|
-
} else if (!this.readonly) {
|
|
92
|
-
this.hideInput = status
|
|
93
|
-
|
|
94
|
-
if (!this.hideInput) {
|
|
95
|
-
this.$nextTick(function () {
|
|
96
|
-
this.$refs.inlineInput.focus()
|
|
97
|
-
})
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
input (event) {
|
|
103
|
-
this.$emit('input', event)
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
blur (event) {
|
|
107
|
-
this.$emit('blur', event)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
</script>
|
|
112
|
-
|
|
113
|
-
<style lang="scss" scoped>
|
|
114
|
-
.tp-inline {
|
|
115
|
-
.el-input-group__append,
|
|
116
|
-
.el-input-group__append button.el-button {
|
|
117
|
-
background-color: $--color-primary;
|
|
118
|
-
border-color: $--color-primary;
|
|
119
|
-
color: $--color-white;
|
|
120
|
-
height: 100%;
|
|
121
|
-
border-radius: 0;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
> span {
|
|
125
|
-
display: inline-block;
|
|
126
|
-
padding: 12px 0;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
a {
|
|
130
|
-
cursor: pointer;
|
|
131
|
-
display: inline-block;
|
|
132
|
-
color: $--color-text-primary;
|
|
133
|
-
border-bottom: 1px dotted transparent;
|
|
134
|
-
|
|
135
|
-
&:focus,
|
|
136
|
-
&:hover {
|
|
137
|
-
border-bottom-color: $--color-text-primary;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
</style>
|
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
:class="[
|
|
4
|
-
ns.b(),
|
|
5
|
-
ns.m(inputNumberSize),
|
|
6
|
-
ns.is('disabled', inputNumberDisabled),
|
|
7
|
-
ns.is('without-controls', !controls),
|
|
8
|
-
ns.is('controls-right', controlsAtRight),
|
|
9
|
-
]"
|
|
10
|
-
@dragstart.prevent
|
|
11
|
-
>
|
|
12
|
-
<span
|
|
13
|
-
v-if="controls"
|
|
14
|
-
v-repeat-click="decrease"
|
|
15
|
-
role="button"
|
|
16
|
-
:aria-label="t('el.inputNumber.decrease')"
|
|
17
|
-
:class="[ns.e('decrease'), ns.is('disabled', minDisabled)]"
|
|
18
|
-
@keydown.enter="decrease"
|
|
19
|
-
>
|
|
20
|
-
<el-icon>
|
|
21
|
-
<arrow-down v-if="controlsAtRight" />
|
|
22
|
-
<minus v-else />
|
|
23
|
-
</el-icon>
|
|
24
|
-
</span>
|
|
25
|
-
<span
|
|
26
|
-
v-if="controls"
|
|
27
|
-
v-repeat-click="increase"
|
|
28
|
-
role="button"
|
|
29
|
-
:aria-label="t('el.inputNumber.increase')"
|
|
30
|
-
:class="[ns.e('increase'), ns.is('disabled', maxDisabled)]"
|
|
31
|
-
@keydown.enter="increase"
|
|
32
|
-
>
|
|
33
|
-
<el-icon>
|
|
34
|
-
<arrow-up v-if="controlsAtRight" />
|
|
35
|
-
<plus v-else />
|
|
36
|
-
</el-icon>
|
|
37
|
-
</span>
|
|
38
|
-
<el-input
|
|
39
|
-
:id="id"
|
|
40
|
-
ref="input"
|
|
41
|
-
:key="key"
|
|
42
|
-
:step="step"
|
|
43
|
-
:model-value="displayValue"
|
|
44
|
-
:formatter="displayFormatter"
|
|
45
|
-
:parser="inputParser"
|
|
46
|
-
:placeholder="placeholder"
|
|
47
|
-
:readonly="readonly"
|
|
48
|
-
:disabled="inputNumberDisabled"
|
|
49
|
-
:size="inputNumberSize"
|
|
50
|
-
:max="max"
|
|
51
|
-
:min="min"
|
|
52
|
-
:name="name"
|
|
53
|
-
:label="label"
|
|
54
|
-
:validate-event="false"
|
|
55
|
-
@wheel.prevent
|
|
56
|
-
@keydown.up.prevent="increase"
|
|
57
|
-
@keydown.down.prevent="decrease"
|
|
58
|
-
@blur="handleBlur"
|
|
59
|
-
@focus="handleFocus"
|
|
60
|
-
@input="handleInput"
|
|
61
|
-
@change="handleInputChange"
|
|
62
|
-
/>
|
|
63
|
-
</div>
|
|
64
|
-
</template>
|
|
65
|
-
<script setup>
|
|
66
|
-
import { computed, onMounted, onUpdated, reactive, ref, watch, getCurrentInstance } from 'vue'
|
|
67
|
-
import { isNil } from 'lodash-unified'
|
|
68
|
-
import {
|
|
69
|
-
useFormDisabled,
|
|
70
|
-
useFormItem,
|
|
71
|
-
useFormSize,
|
|
72
|
-
debugWarn,
|
|
73
|
-
isNumber,
|
|
74
|
-
isString,
|
|
75
|
-
isUndefined,
|
|
76
|
-
throwError,
|
|
77
|
-
} from '@/utils'
|
|
78
|
-
import { vRepeatClick } from 'element-plus'
|
|
79
|
-
import { useLocale, useNamespace } from 'element-plus/es/hooks/index'
|
|
80
|
-
import { ArrowDown, ArrowUp, Minus, Plus } from '@element-plus/icons-vue'
|
|
81
|
-
import { inputNumberEmits, inputNumberProps } from '@/components/InputNumber/input-number'
|
|
82
|
-
const props = defineProps(inputNumberProps)
|
|
83
|
-
const emit = defineEmits(inputNumberEmits)
|
|
84
|
-
const UPDATE_MODEL_EVENT = 'update:modelValue'
|
|
85
|
-
const CHANGE_EVENT = 'change'
|
|
86
|
-
const INPUT_EVENT = 'input'
|
|
87
|
-
|
|
88
|
-
defineOptions({
|
|
89
|
-
name: 'TpInputNumber',
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
const { t } = useLocale()
|
|
93
|
-
const ns = useNamespace('input-number')
|
|
94
|
-
const input = ref()
|
|
95
|
-
const vm = getCurrentInstance().proxy
|
|
96
|
-
const key = ref(1)
|
|
97
|
-
|
|
98
|
-
// eslint-disable-next-line vue/no-setup-props-destructure
|
|
99
|
-
const data = reactive({
|
|
100
|
-
currentValue: props.modelValue,
|
|
101
|
-
userInput: null,
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
const { formItem } = useFormItem()
|
|
105
|
-
|
|
106
|
-
const minDisabled = computed(
|
|
107
|
-
() => isNumber(props.modelValue) && props.modelValue <= props.min
|
|
108
|
-
)
|
|
109
|
-
const maxDisabled = computed(
|
|
110
|
-
() => isNumber(props.modelValue) && props.modelValue >= props.max
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
const numPrecision = computed(() => {
|
|
114
|
-
const stepPrecision = getPrecision(props.step)
|
|
115
|
-
if (!isUndefined(props.precision)) {
|
|
116
|
-
if (stepPrecision > props.precision) {
|
|
117
|
-
debugWarn(
|
|
118
|
-
'InputNumber',
|
|
119
|
-
'precision should not be less than the decimal places of step'
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
return props.precision
|
|
123
|
-
} else {
|
|
124
|
-
return Math.max(getPrecision(props.modelValue), stepPrecision)
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
const controlsAtRight = computed(() => {
|
|
128
|
-
return props.controls && props.controlsPosition === 'right'
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
const inputNumberSize = useFormSize()
|
|
132
|
-
const inputNumberDisabled = useFormDisabled()
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @tagplus
|
|
136
|
-
* Modificado para permitir um valor padrão vazio ou 0 de acordo com a prop
|
|
137
|
-
*/
|
|
138
|
-
const displayValue = computed(() => {
|
|
139
|
-
if (data.userInput !== null) {
|
|
140
|
-
return data.userInput
|
|
141
|
-
}
|
|
142
|
-
let currentValue = data.currentValue
|
|
143
|
-
|
|
144
|
-
const fallbackValue = props.stringDefaultsZero ? 0 : ''
|
|
145
|
-
if (props.modelValue === '' || isNil(currentValue) || currentValue === ''){
|
|
146
|
-
return fallbackValue
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (isNumber(currentValue)) {
|
|
150
|
-
if (Number.isNaN(currentValue)) return fallbackValue
|
|
151
|
-
if (!isUndefined(props.precision)) {
|
|
152
|
-
currentValue = currentValue.toFixed(props.precision)
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return currentValue
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @tagplus
|
|
160
|
-
* Criado para simular o comportamento do type=number porque ele não deixa
|
|
161
|
-
* exibir os valores formatados no padrão pt-br 100.555,55
|
|
162
|
-
*/
|
|
163
|
-
const displayFormatter = computed(() => {
|
|
164
|
-
const decimalChar = vm.$t('locale.number.decimal')
|
|
165
|
-
const thousandsChar = vm.$t('locale.number.thousands')
|
|
166
|
-
return (value) => {
|
|
167
|
-
// Essa linha simula o comportamento do type="number" para não deixar digitar letras
|
|
168
|
-
const noLetters = value.replaceAll(/[a-zA-Z]/g, '')
|
|
169
|
-
const res = noLetters.replace('.', decimalChar).replace(/\B(?=(\d{3})+(?!\d))/g, thousandsChar)
|
|
170
|
-
return res
|
|
171
|
-
}
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @tagplus
|
|
176
|
-
* Criado em conjunto do displayFormatter para simular o type="number"
|
|
177
|
-
* @see displayFormatter
|
|
178
|
-
*/
|
|
179
|
-
const inputParser = computed(() => {
|
|
180
|
-
const decimalChar = vm.$t('locale.number.decimal')
|
|
181
|
-
const thousandsChar = vm.$t('locale.number.thousands')
|
|
182
|
-
return (value) => {
|
|
183
|
-
const regexThou = `/\$\s?|(${thousandsChar}*)/g`
|
|
184
|
-
const res = value.replace(regexThou, '').replace(decimalChar, '.')
|
|
185
|
-
return res
|
|
186
|
-
}
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
const toPrecision = (num, pre) => {
|
|
190
|
-
// eslint-disable-next-line no-param-reassign
|
|
191
|
-
if (isUndefined(pre)) pre = numPrecision.value
|
|
192
|
-
if (pre === 0) return Math.round(num)
|
|
193
|
-
let snum = String(num)
|
|
194
|
-
const pointPos = snum.indexOf('.')
|
|
195
|
-
if (pointPos === -1) return num
|
|
196
|
-
const nums = snum.replace('.', '').split('')
|
|
197
|
-
const datum = nums[pointPos + pre]
|
|
198
|
-
if (!datum) return num
|
|
199
|
-
const length = snum.length
|
|
200
|
-
if (snum.charAt(length - 1) === '5') {
|
|
201
|
-
snum = `${snum.slice(0, Math.max(0, length - 1))}6`
|
|
202
|
-
}
|
|
203
|
-
return Number.parseFloat(Number(snum).toFixed(pre))
|
|
204
|
-
}
|
|
205
|
-
const getPrecision = (value) => {
|
|
206
|
-
if (isNil(value)) return 0
|
|
207
|
-
const valueString = value.toString()
|
|
208
|
-
const dotPosition = valueString.indexOf('.')
|
|
209
|
-
let precision = 0
|
|
210
|
-
if (dotPosition !== -1) {
|
|
211
|
-
precision = valueString.length - dotPosition - 1
|
|
212
|
-
}
|
|
213
|
-
return precision
|
|
214
|
-
}
|
|
215
|
-
const ensurePrecision = (val, coefficient = 1) => {
|
|
216
|
-
if (!isNumber(val)) return data.currentValue
|
|
217
|
-
// Solve the accuracy problem of JS decimal calculation by converting the value to integer.
|
|
218
|
-
return toPrecision(val + props.step * coefficient)
|
|
219
|
-
}
|
|
220
|
-
const increase = () => {
|
|
221
|
-
if (props.readonly || inputNumberDisabled.value || maxDisabled.value) return
|
|
222
|
-
const value = Number(displayValue.value) || 0
|
|
223
|
-
const newVal = ensurePrecision(value)
|
|
224
|
-
setCurrentValue(newVal)
|
|
225
|
-
emit(INPUT_EVENT, data.currentValue)
|
|
226
|
-
setCurrentValueToModelValue()
|
|
227
|
-
}
|
|
228
|
-
const decrease = () => {
|
|
229
|
-
if (props.readonly || inputNumberDisabled.value || minDisabled.value) return
|
|
230
|
-
const value = Number(displayValue.value) || 0
|
|
231
|
-
const newVal = ensurePrecision(value, -1)
|
|
232
|
-
setCurrentValue(newVal)
|
|
233
|
-
emit(INPUT_EVENT, data.currentValue)
|
|
234
|
-
setCurrentValueToModelValue()
|
|
235
|
-
}
|
|
236
|
-
const verifyValue = (value, update) => {
|
|
237
|
-
const { max, min, step, precision, stepStrictly, valueOnClear } = props
|
|
238
|
-
if (max < min) {
|
|
239
|
-
throwError('InputNumber', 'min should not be greater than max.')
|
|
240
|
-
}
|
|
241
|
-
let newVal = Number(value)
|
|
242
|
-
if (isNil(value) || Number.isNaN(newVal)) {
|
|
243
|
-
return null
|
|
244
|
-
}
|
|
245
|
-
if (value === '') {
|
|
246
|
-
if (valueOnClear === null) {
|
|
247
|
-
return null
|
|
248
|
-
}
|
|
249
|
-
newVal = isString(valueOnClear) ? { min, max }[valueOnClear] : valueOnClear
|
|
250
|
-
}
|
|
251
|
-
if (stepStrictly) {
|
|
252
|
-
newVal = toPrecision(Math.round(newVal / step) * step, precision)
|
|
253
|
-
}
|
|
254
|
-
if (!isUndefined(precision)) {
|
|
255
|
-
newVal = toPrecision(newVal, precision)
|
|
256
|
-
}
|
|
257
|
-
if (newVal > max || newVal < min) {
|
|
258
|
-
newVal = newVal > max ? max : min
|
|
259
|
-
update && emit(UPDATE_MODEL_EVENT, newVal)
|
|
260
|
-
}
|
|
261
|
-
return newVal
|
|
262
|
-
}
|
|
263
|
-
const setCurrentValue = (value, emitChange = true) => {
|
|
264
|
-
const oldVal = data.currentValue
|
|
265
|
-
const newVal = verifyValue(value)
|
|
266
|
-
if (!emitChange) {
|
|
267
|
-
emit(UPDATE_MODEL_EVENT, newVal)
|
|
268
|
-
return
|
|
269
|
-
}
|
|
270
|
-
if (oldVal === newVal) return
|
|
271
|
-
data.userInput = null
|
|
272
|
-
emit(UPDATE_MODEL_EVENT, newVal)
|
|
273
|
-
emit(CHANGE_EVENT, newVal, oldVal)
|
|
274
|
-
if (props.validateEvent) {
|
|
275
|
-
formItem?.validate?.('change').catch((err) => debugWarn(err))
|
|
276
|
-
}
|
|
277
|
-
data.currentValue = newVal
|
|
278
|
-
}
|
|
279
|
-
const handleInput = (value) => {
|
|
280
|
-
data.userInput = value
|
|
281
|
-
const newVal = value === '' ? null : Number(value)
|
|
282
|
-
emit(INPUT_EVENT, newVal)
|
|
283
|
-
setCurrentValue(newVal, false)
|
|
284
|
-
}
|
|
285
|
-
const handleInputChange = (value) => {
|
|
286
|
-
const newVal = value !== '' ? Number(value) : ''
|
|
287
|
-
if ((isNumber(newVal) && !Number.isNaN(newVal)) || value === '') {
|
|
288
|
-
setCurrentValue(newVal)
|
|
289
|
-
}
|
|
290
|
-
setCurrentValueToModelValue()
|
|
291
|
-
data.userInput = null
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const focus = () => {
|
|
295
|
-
input.value?.focus?.()
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const blur = () => {
|
|
299
|
-
input.value?.blur?.()
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const handleFocus = (event) => {
|
|
303
|
-
emit('focus', event)
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const handleBlur = (event) => {
|
|
307
|
-
data.userInput = null
|
|
308
|
-
emit('blur', event)
|
|
309
|
-
if (props.validateEvent) {
|
|
310
|
-
formItem?.validate?.('blur').catch((err) => debugWarn(err))
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
const setCurrentValueToModelValue = () => {
|
|
315
|
-
if (data.currentValue !== props.modelValue) {
|
|
316
|
-
data.currentValue = props.modelValue
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
watch(
|
|
320
|
-
() => props.modelValue,
|
|
321
|
-
(value, oldValue) => {
|
|
322
|
-
const newValue = verifyValue(value, true)
|
|
323
|
-
if (data.userInput === null && newValue !== oldValue) {
|
|
324
|
-
data.currentValue = newValue
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
{ immediate: true }
|
|
328
|
-
)
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* @tagplus
|
|
332
|
-
* Criado para observar se a lang mudou para reformatar o displayValue
|
|
333
|
-
*/
|
|
334
|
-
watch(
|
|
335
|
-
() => vm.$i18nHelper.hooks.onLanguageChanged,
|
|
336
|
-
(value, oldValue) => {
|
|
337
|
-
key.value++
|
|
338
|
-
}
|
|
339
|
-
)
|
|
340
|
-
|
|
341
|
-
onMounted(() => {
|
|
342
|
-
const { min, max, modelValue } = props
|
|
343
|
-
const innerInput = input.value?.input
|
|
344
|
-
innerInput.setAttribute('role', 'spinbutton')
|
|
345
|
-
if (Number.isFinite(max)) {
|
|
346
|
-
innerInput.setAttribute('aria-valuemax', String(max))
|
|
347
|
-
} else {
|
|
348
|
-
innerInput.removeAttribute('aria-valuemax')
|
|
349
|
-
}
|
|
350
|
-
if (Number.isFinite(min)) {
|
|
351
|
-
innerInput.setAttribute('aria-valuemin', String(min))
|
|
352
|
-
} else {
|
|
353
|
-
innerInput.removeAttribute('aria-valuemin')
|
|
354
|
-
}
|
|
355
|
-
innerInput.setAttribute(
|
|
356
|
-
'aria-valuenow',
|
|
357
|
-
data.currentValue || data.currentValue === 0
|
|
358
|
-
? String(data.currentValue)
|
|
359
|
-
: ''
|
|
360
|
-
)
|
|
361
|
-
innerInput.setAttribute('aria-disabled', String(inputNumberDisabled.value))
|
|
362
|
-
// eslint-disable-next-line no-eq-null, eqeqeq
|
|
363
|
-
if (!isNumber(modelValue) && modelValue != null) {
|
|
364
|
-
let val = Number(modelValue)
|
|
365
|
-
if (Number.isNaN(val)) {
|
|
366
|
-
val = null
|
|
367
|
-
}
|
|
368
|
-
emit(UPDATE_MODEL_EVENT, val)
|
|
369
|
-
}
|
|
370
|
-
})
|
|
371
|
-
onUpdated(() => {
|
|
372
|
-
const innerInput = input.value?.input
|
|
373
|
-
innerInput?.setAttribute('aria-valuenow', `${data.currentValue ?? ''}`)
|
|
374
|
-
})
|
|
375
|
-
defineExpose({
|
|
376
|
-
/** @description get focus the input component */
|
|
377
|
-
focus,
|
|
378
|
-
/** @description remove focus the input component */
|
|
379
|
-
blur,
|
|
380
|
-
})
|
|
381
|
-
</script>
|