@tagplus/components 4.7.3 → 4.7.5
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 +2 -1
- package/dist/tp.common.js.LICENSE.txt +9 -0
- package/dist/tp.common.js.map +1 -1
- package/dist/tp.common.lang-en-js.js +2 -0
- package/dist/tp.common.lang-en-js.js.map +1 -0
- package/dist/tp.css +12 -167
- package/dist/tp.umd.js +2 -1
- package/dist/tp.umd.js.LICENSE.txt +9 -0
- package/dist/tp.umd.js.map +1 -1
- package/dist/tp.umd.lang-en-js.js +2 -0
- package/dist/tp.umd.lang-en-js.js.map +1 -0
- package/dist/tp.umd.min.js +2 -1
- package/dist/tp.umd.min.js.LICENSE.txt +9 -0
- package/dist/tp.umd.min.js.map +1 -1
- package/dist/tp.umd.min.lang-en-js.js +2 -0
- package/dist/tp.umd.min.lang-en-js.js.map +1 -0
- package/package.json +39 -41
- package/src/assets/scss/_fonts.scss +24 -23
- package/src/assets/scss/_helpers.scss +4 -12
- package/src/assets/scss/_mixins.scss +2 -2
- package/src/assets/scss/_overrides.scss +5 -52
- package/src/assets/scss/_resass.scss +21 -12
- package/src/assets/scss/_variables.scss +0 -1
- package/src/assets/scss/index.scss +1 -4
- package/src/components/Autosuggest/Autosuggest.vue +340 -762
- package/src/components/Autosuggest/Multisuggest.vue +22 -0
- package/src/components/Autosuggest/autosuggest-props.js +210 -0
- package/src/components/Autosuggest/autosuggest-style.scss +127 -0
- package/src/components/Autosuggest/core.js +63 -0
- package/src/components/Autosuggest/index.js +2 -0
- package/src/components/Autosuggest/multisuggest-props.js +9 -0
- package/src/components/Autosuggest/option.vue +136 -0
- package/src/components/Autosuggest/select-dropdown.vue +64 -0
- package/src/components/Autosuggest/useOption.js +120 -0
- package/src/components/Autosuggest/useSelect.js +1133 -0
- package/src/components/AutosuggestTest.vue +56 -0
- package/src/components/CardExemplo.vue +49 -0
- package/src/components/CodeSample.vue +78 -0
- package/src/components/Inline/Inline.vue +24 -32
- package/src/components/InputNumber/InputNumber.vue +329 -378
- package/src/components/InputNumber/input-number.js +135 -0
- package/src/components/Loader/Loader.vue +42 -53
- package/src/components/Loader/animations.scss +13 -0
- package/src/components/Money/Money.vue +11 -20
- package/src/components/Multisuggest/index.js +2 -3
- package/src/components/MultisuggestTest.vue +56 -0
- package/src/components/OptionsList/OptionsList.vue +7 -6
- package/src/components/OptionsListItem/OptionsListItem.vue +46 -42
- package/src/components/Percent/Percent.vue +8 -14
- package/src/components/Skeleton/Skeleton.vue +16 -11
- package/src/components/Step/Step.vue +42 -35
- package/src/components/Steps/Steps.vue +4 -7
- package/src/components/TesteToCurrency.vue +171 -0
- package/src/components/Tip/Tip.vue +63 -77
- package/src/components/ValueSelector.vue +60 -0
- package/src/components/autosuggestMixin.js +301 -0
- package/src/components/index.js +4 -1
- package/src/locale/i18n.js +114 -0
- package/src/locale/lang/en.js +3 -2
- package/src/locale/lang/pt-br.js +3 -2
- package/src/main.js +11 -13
- package/src/mixins/floatFormatter.js +12 -16
- package/src/{utils → plugins}/currency.js +10 -64
- package/src/utils/browser.js +6 -0
- package/src/utils/constants.js +3 -0
- package/src/utils/error.js +22 -0
- package/src/utils/filters.js +1 -14
- package/src/utils/helpers.js +41 -0
- package/src/utils/i18n.js +2 -0
- package/src/utils/icon.js +35 -0
- package/src/utils/index.js +20 -0
- package/src/utils/objects.js +17 -0
- package/src/utils/runtime.js +86 -0
- package/src/utils/scroll.js +100 -0
- package/src/utils/strings.js +17 -0
- package/src/utils/style.js +80 -0
- package/src/utils/types.js +39 -0
- package/src/utils/use-derived-namespace.js +112 -0
- package/src/utils/use-form-common-props.js +41 -0
- package/src/utils/use-form-item.js +80 -0
- package/src/utils/use-id.js +40 -0
- package/src/utils/use-input.js +33 -0
- package/src/components/Dialog/Dialog.vue +0 -253
- package/src/components/Dialog/index.js +0 -3
- package/src/components/Multisuggest/Multisuggest.vue +0 -858
- package/src/locale/index.js +0 -78
- package/src/mixins/locale.js +0 -9
|
@@ -6,68 +6,64 @@
|
|
|
6
6
|
align="middle"
|
|
7
7
|
:class="tptipclasses"
|
|
8
8
|
>
|
|
9
|
-
<el-col
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
<el-col :sm="24" :lg="3">
|
|
10
|
+
<div
|
|
11
|
+
style="
|
|
12
|
+
display: flex;
|
|
13
|
+
min-width: 25px;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
margin: 15px;
|
|
16
|
+
padding: auto;
|
|
17
|
+
"
|
|
18
|
+
>
|
|
14
19
|
<em class="far fa-lightbulb-on" />
|
|
15
20
|
</div>
|
|
16
21
|
</el-col>
|
|
17
22
|
|
|
18
|
-
<el-col
|
|
19
|
-
:sm="24"
|
|
20
|
-
:lg="21"
|
|
21
|
-
>
|
|
23
|
+
<el-col :sm="24" :lg="21">
|
|
22
24
|
<div
|
|
23
25
|
:id="`${_id}-text`"
|
|
24
|
-
style="margin:15px; margin-left:
|
|
26
|
+
style="margin: 15px; margin-left: 0"
|
|
25
27
|
v-html="text"
|
|
26
28
|
/>
|
|
27
29
|
</el-col>
|
|
28
30
|
</el-row>
|
|
29
|
-
<
|
|
31
|
+
<el-row
|
|
30
32
|
v-else
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
:id="`${_id}`"
|
|
34
|
+
type="flex"
|
|
35
|
+
align="middle"
|
|
36
|
+
justify="space-between"
|
|
37
|
+
:class="tptipclasses"
|
|
33
38
|
>
|
|
34
|
-
<el-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
:class="tptipclasses"
|
|
40
|
-
>
|
|
41
|
-
<!-- Titulo -->
|
|
42
|
-
<el-col
|
|
43
|
-
:span="17"
|
|
39
|
+
<el-col :span="17">
|
|
40
|
+
<el-row
|
|
41
|
+
align="middle"
|
|
42
|
+
type="flex"
|
|
43
|
+
style="min-width: 25px; margin: 15px; padding: auto"
|
|
44
44
|
>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
style="margin:15px; margin-left:0px"
|
|
62
|
-
v-html="text"
|
|
63
|
-
/>
|
|
64
|
-
</el-col>
|
|
65
|
-
</el-row>
|
|
66
|
-
</div>
|
|
45
|
+
<em class="far fa-lightbulb-on" />
|
|
46
|
+
<b class="tp-title">{{ title }}</b>
|
|
47
|
+
</el-row>
|
|
48
|
+
</el-col>
|
|
49
|
+
<el-col :span="3" class="flexContent justify-content-end">
|
|
50
|
+
<em class="fa fa-ellipsis-h tp-close-button" @click="closed = !closed" />
|
|
51
|
+
</el-col>
|
|
52
|
+
|
|
53
|
+
<el-col :class="'tp-text ' + (closed ? 'tp-vanish' : '')" :span="24">
|
|
54
|
+
<div
|
|
55
|
+
:id="`${_id}-text`"
|
|
56
|
+
style="margin: 15px; margin-left: 0"
|
|
57
|
+
v-html="text"
|
|
58
|
+
/>
|
|
59
|
+
</el-col>
|
|
60
|
+
</el-row>
|
|
67
61
|
</template>
|
|
68
62
|
|
|
69
63
|
<script>
|
|
70
|
-
|
|
64
|
+
import { defineComponent } from 'vue'
|
|
65
|
+
|
|
66
|
+
export default defineComponent({
|
|
71
67
|
name: 'TpTip',
|
|
72
68
|
props: {
|
|
73
69
|
id: {
|
|
@@ -121,23 +117,8 @@ export default {
|
|
|
121
117
|
|
|
122
118
|
return classes
|
|
123
119
|
}
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
methods: {
|
|
127
|
-
onClick (evt) {
|
|
128
|
-
// Permite clicar em link sem fechar Tip
|
|
129
|
-
const isLink = evt.target?.nodeName === 'A'
|
|
130
|
-
// Permite copiar texto sem fechar Tip
|
|
131
|
-
const isContent = evt.target?.closest('[data-tp-tip-content]')
|
|
132
|
-
|
|
133
|
-
if (isLink || isContent) {
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
this.closed = !this.closed
|
|
138
|
-
}
|
|
139
120
|
}
|
|
140
|
-
}
|
|
121
|
+
})
|
|
141
122
|
</script>
|
|
142
123
|
|
|
143
124
|
<style lang="scss" scoped>
|
|
@@ -147,20 +128,15 @@ export default {
|
|
|
147
128
|
|
|
148
129
|
.grid-content {
|
|
149
130
|
flex-wrap: wrap;
|
|
131
|
+
background-color: rgb(76 135 251 / 10%);
|
|
150
132
|
border-radius: 4px;
|
|
151
|
-
|
|
152
|
-
border-radius: 4px;
|
|
153
|
-
border: solid 1px rgba(76, 135, 251, 0.2);
|
|
133
|
+
border: solid 1px rgb(76 135 251 / 20%);
|
|
154
134
|
padding: 1rem;
|
|
155
135
|
font-size: 14px;
|
|
156
136
|
line-height: 24px;
|
|
157
137
|
color: #586d93;
|
|
158
138
|
}
|
|
159
139
|
|
|
160
|
-
[data-tp-tip-content] {
|
|
161
|
-
cursor: initial
|
|
162
|
-
}
|
|
163
|
-
|
|
164
140
|
.info-text {
|
|
165
141
|
font-size: 12px;
|
|
166
142
|
font-stretch: normal;
|
|
@@ -173,8 +149,11 @@ export default {
|
|
|
173
149
|
.tp-tip-error {
|
|
174
150
|
background: #f56c6c1a 0% 0% no-repeat padding-box;
|
|
175
151
|
border: 1px solid #ff6077;
|
|
176
|
-
|
|
177
|
-
|
|
152
|
+
|
|
153
|
+
:deep() {
|
|
154
|
+
strong,
|
|
155
|
+
b,
|
|
156
|
+
em {
|
|
178
157
|
color: #ff425f;
|
|
179
158
|
}
|
|
180
159
|
}
|
|
@@ -183,8 +162,11 @@ export default {
|
|
|
183
162
|
.tp-tip-warning {
|
|
184
163
|
background: #fff9ea 0% 0% no-repeat padding-box;
|
|
185
164
|
border: 1px solid #ffc437;
|
|
186
|
-
|
|
187
|
-
|
|
165
|
+
|
|
166
|
+
:deep() {
|
|
167
|
+
strong,
|
|
168
|
+
b,
|
|
169
|
+
em {
|
|
188
170
|
color: #ffc437;
|
|
189
171
|
}
|
|
190
172
|
}
|
|
@@ -193,8 +175,11 @@ export default {
|
|
|
193
175
|
.tp-tip-success {
|
|
194
176
|
background: #f3fcfc 0% 0% no-repeat padding-box;
|
|
195
177
|
border: 1px solid #08a19e;
|
|
196
|
-
|
|
197
|
-
|
|
178
|
+
|
|
179
|
+
:deep() {
|
|
180
|
+
strong,
|
|
181
|
+
b,
|
|
182
|
+
em {
|
|
198
183
|
color: #08a19e;
|
|
199
184
|
}
|
|
200
185
|
}
|
|
@@ -202,6 +187,7 @@ export default {
|
|
|
202
187
|
|
|
203
188
|
.tp-close-button {
|
|
204
189
|
padding: 10px;
|
|
190
|
+
cursor: pointer;
|
|
205
191
|
}
|
|
206
192
|
|
|
207
193
|
.tp-title {
|
|
@@ -216,9 +202,9 @@ export default {
|
|
|
216
202
|
|
|
217
203
|
.tp-vanish {
|
|
218
204
|
position: absolute;
|
|
219
|
-
max-height:0;
|
|
205
|
+
max-height: 0;
|
|
220
206
|
transform: scale(0);
|
|
221
|
-
opacity:0;
|
|
207
|
+
opacity: 0;
|
|
222
208
|
transition: 0s opacity linear;
|
|
223
209
|
}
|
|
224
210
|
</style>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-row justify="center" align="middle" class="value-selector-row">
|
|
3
|
+
<el-button
|
|
4
|
+
v-for="item in formattedValues"
|
|
5
|
+
:key="item.value"
|
|
6
|
+
:type="type"
|
|
7
|
+
class="value-selector-btn"
|
|
8
|
+
@click="$emit('input', item.value)">
|
|
9
|
+
{{item.label}}
|
|
10
|
+
</el-button>
|
|
11
|
+
</el-row>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
name: 'ValueSelector',
|
|
17
|
+
|
|
18
|
+
props: {
|
|
19
|
+
modelValue: {
|
|
20
|
+
type: Array,
|
|
21
|
+
default: () => []
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
type: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'primary'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
emits: ['input'],
|
|
31
|
+
|
|
32
|
+
computed: {
|
|
33
|
+
formattedValues () {
|
|
34
|
+
return this.modelValue.map(item => {
|
|
35
|
+
let label = item
|
|
36
|
+
if (typeof item === 'string'){
|
|
37
|
+
label = `'${item}'`
|
|
38
|
+
} else if (item === null){
|
|
39
|
+
label = 'null'
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
label,
|
|
43
|
+
value: item
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<style lang="scss" scoped>
|
|
52
|
+
.value-selector-row {
|
|
53
|
+
flex-wrap: nowrap;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.value-selector-btn {
|
|
57
|
+
flex-shrink: 0;
|
|
58
|
+
min-width: 50px;
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mixin contendo metodos para autosuggests
|
|
3
|
+
*/
|
|
4
|
+
export default {
|
|
5
|
+
props: {
|
|
6
|
+
/**
|
|
7
|
+
* @vuese
|
|
8
|
+
* id do css para teste unitário
|
|
9
|
+
*/
|
|
10
|
+
id: {
|
|
11
|
+
type: String
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
modelValue: {
|
|
15
|
+
type: [Number, String, Object, Boolean, Array],
|
|
16
|
+
default: ''
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// Desativa o loader global ao carregar lista
|
|
20
|
+
disableLoader: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
// Indica se primeiro item da lista deve ser retornado por padrão
|
|
26
|
+
noDefault: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Se a lista vai ser carregada no create ou o labelKey não venha por padrão na requisição loadOnCreate = true,
|
|
33
|
+
* caso deva ser carregada quando o usuário clica deixar vazio ou false.
|
|
34
|
+
*/
|
|
35
|
+
loadOnCreate: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: null
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
// Indicia se o campo deve ser desabilitado
|
|
41
|
+
disabled: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// Se o valor desse autosuggest for obrigatório se o value for vazio o after get vai selecionar a primeira opção
|
|
47
|
+
isRequired: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
allowCreate: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: true
|
|
55
|
+
},
|
|
56
|
+
valueKey: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: 'id'
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
disableForm: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
data () {
|
|
68
|
+
return {
|
|
69
|
+
config: {
|
|
70
|
+
params: {}
|
|
71
|
+
},
|
|
72
|
+
doEmptyRequest: false,
|
|
73
|
+
list: [],
|
|
74
|
+
loading: true,
|
|
75
|
+
isLoadOnCreate: true,
|
|
76
|
+
modal: false,
|
|
77
|
+
autosuggest: false, // endpoint /autosuggest/*
|
|
78
|
+
customEndpoint: false // buscar em qualquer endpoint
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
computed: {
|
|
83
|
+
_id () {
|
|
84
|
+
return this.id || this.$options.name
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
/** desabilita o componente quando recebe disable true ou não tem permissão no form de incluir ou alterar */
|
|
88
|
+
_disabled () {
|
|
89
|
+
if (this.disabled) {
|
|
90
|
+
return true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.disableForm) {
|
|
94
|
+
return true
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return false
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
/** @vuese
|
|
101
|
+
* Action para buscar em stores customizadas/dinâmicas, por padrão pega do $options.listAction
|
|
102
|
+
*/
|
|
103
|
+
listAction () {
|
|
104
|
+
return this.customAction ? this.customAction : this.$options.listAction
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
/** @vuese
|
|
108
|
+
* Retorna a URL a ser usada para buscar a lista caso não esteja definida no $options
|
|
109
|
+
* Passam aqui as urls customizadas, do /autosuggests, /entidade/categorias etc
|
|
110
|
+
*/
|
|
111
|
+
customUrl () {
|
|
112
|
+
if (this.customEndpoint) {
|
|
113
|
+
return this.customEndpoint
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (this.autosuggest) {
|
|
117
|
+
return `/autosuggests/${this.$options.autosuggest}`
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return false
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
_valueKey () {
|
|
124
|
+
return this.$options.valueKey || 'id'
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
_labelKey () {
|
|
128
|
+
return this.$options.labelKey || 'descricao'
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Ao montar componente, inicia o loading
|
|
134
|
+
*/
|
|
135
|
+
mounted () {
|
|
136
|
+
if (!this.disableLoader && this.isLoadOnCreate) {
|
|
137
|
+
this.startLoading(this.$options.name)
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
created () {
|
|
142
|
+
if (this.$parent.$options.name.substring(0, 6) === 'Filtro') {
|
|
143
|
+
this.isLoadOnCreate = false
|
|
144
|
+
} else if (this.loadOnCreate !== null) { // Se recebeu loadOnCreate via prop leva precedência
|
|
145
|
+
// Se for campo obrigatório e não vier o value inicial força a busca na api
|
|
146
|
+
if (this.isRequired && typeof this.value === 'undefined') {
|
|
147
|
+
this.isLoadOnCreate = true
|
|
148
|
+
} else {
|
|
149
|
+
this.isLoadOnCreate = this.loadOnCreate
|
|
150
|
+
}
|
|
151
|
+
} else if (this.$route && !isNaN(this.$route.params.id)) {
|
|
152
|
+
// Se está num form com ID só carrega lista quando clica
|
|
153
|
+
this.isLoadOnCreate = false
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Caso tenha value no created a primeira busca quando clica é vazia
|
|
157
|
+
this.doEmptyRequest = (typeof this.value !== 'undefined')
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
methods: {
|
|
161
|
+
/**
|
|
162
|
+
* HOOK executado quando getList é chamado
|
|
163
|
+
*/
|
|
164
|
+
autosuggestMixin_beforeGet () { },
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* HOOK executado quando getList é chamado
|
|
168
|
+
*/
|
|
169
|
+
autosuggestMixin_afterGet () { },
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* HOOK executado quando handleClose é chamado
|
|
173
|
+
*/
|
|
174
|
+
autosuggestMixin_beforeHandleClose () { },
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Realiza chamada da action no endpoint
|
|
178
|
+
* @param {*} busca valor recebido no autosuggest
|
|
179
|
+
*/
|
|
180
|
+
async autosuggestMixin_getList (busca) {
|
|
181
|
+
busca ||= ''
|
|
182
|
+
|
|
183
|
+
if (!Array.isArray(busca) && (busca !== '' || this.config.params.q !== busca)) {
|
|
184
|
+
this.config.params.q = busca
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Tratamento caso clique no primeiro autosuggest daquele tipo com loadOnCreate false e tenha um valor padrão
|
|
188
|
+
if (this.doEmptyRequest) {
|
|
189
|
+
this.config.params.q = ''
|
|
190
|
+
this.doEmptyRequest = false
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Hook executado antes de recuperar a lista
|
|
194
|
+
this.autosuggestMixin_beforeGet()
|
|
195
|
+
|
|
196
|
+
this.loading = true
|
|
197
|
+
|
|
198
|
+
// Se buscar em /autosuggest ou url dinâmica/customizada pega a url aqui
|
|
199
|
+
this.config.customUrl = this.customUrl
|
|
200
|
+
|
|
201
|
+
/* try {
|
|
202
|
+
await this.axios
|
|
203
|
+
.get(`${this.params.uri}?q=${busca}`)
|
|
204
|
+
.then(res => {
|
|
205
|
+
this.list = res.data
|
|
206
|
+
})
|
|
207
|
+
// eslint-disable-next-line no-unused-vars
|
|
208
|
+
.catch(_err => {
|
|
209
|
+
this.list = []
|
|
210
|
+
}).finally(() => {
|
|
211
|
+
this.loading = false
|
|
212
|
+
})
|
|
213
|
+
} catch (err) {
|
|
214
|
+
// this.$TpError(err)
|
|
215
|
+
} finally {
|
|
216
|
+
// this.finishLoading(this.$options.name)
|
|
217
|
+
} */
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Metodo para lidar com a criação de um novo registro
|
|
222
|
+
* Exibe o modal por padrão
|
|
223
|
+
* @param {*} evt Evento de criação
|
|
224
|
+
*/
|
|
225
|
+
autosuggestMixin_handleCreate (evt) {
|
|
226
|
+
if (evt.created) {
|
|
227
|
+
this.modal = true
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Método para lidar com o fechamento do modal
|
|
233
|
+
* Por padrão recarrega a lista e recupera o valor criado no modal, caso haja
|
|
234
|
+
* @param {*} val Valor recebido do modal
|
|
235
|
+
*/
|
|
236
|
+
async autosuggestMixin_handleClose (val) {
|
|
237
|
+
// Fecha o modal primeiro para diminuir tempo de transição
|
|
238
|
+
this.modal = false
|
|
239
|
+
|
|
240
|
+
if (val.id !== 0) {
|
|
241
|
+
const id = val.id?.id !== undefined ? val.id.id : val.id
|
|
242
|
+
|
|
243
|
+
await this.autosuggestMixin_getList('')
|
|
244
|
+
|
|
245
|
+
this.$emit('update:model-value', val.id)
|
|
246
|
+
|
|
247
|
+
const item = this.list.filter((value) => {
|
|
248
|
+
return id === value.id
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
this.$emit('change', item[0])
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Evento para tratamento do valor
|
|
257
|
+
* Devolve o valor recebido para o v-model no componente pai
|
|
258
|
+
* @param {*} evt
|
|
259
|
+
*/
|
|
260
|
+
autosuggestMixin_input (evt) {
|
|
261
|
+
this.$emit('update:model-value', evt)
|
|
262
|
+
this.autosuggestMixin_inputFullItem(evt)
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Evento Input com os dados completos do item selecionado
|
|
267
|
+
* @param {*} evt
|
|
268
|
+
*/
|
|
269
|
+
autosuggestMixin_inputFullItem (evt) {
|
|
270
|
+
let res = []
|
|
271
|
+
|
|
272
|
+
if (Array.isArray(evt)) {
|
|
273
|
+
evt.map((idValue) => {
|
|
274
|
+
this.list.map((item2) => {
|
|
275
|
+
if (idValue === item2[this._valueKey]) {
|
|
276
|
+
res.push(item2)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return item2
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
} else {
|
|
283
|
+
res = evt
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
this.$emit('inputFullItem', res)
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
autosuggestMixin_handleChange (val) {
|
|
290
|
+
if (val !== null && val !== undefined) {
|
|
291
|
+
const item = this.list.filter((value) => {
|
|
292
|
+
return val === value.id
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
this.$emit('change', item[0])
|
|
296
|
+
} else {
|
|
297
|
+
this.$emit('change', val)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
package/src/components/index.js
CHANGED
|
@@ -11,7 +11,10 @@ import Multisuggest from './Multisuggest'
|
|
|
11
11
|
import Step from './Step'
|
|
12
12
|
import Steps from './Steps'
|
|
13
13
|
import InputNumber from './InputNumber'
|
|
14
|
-
import
|
|
14
|
+
import { ElDialog } from 'element-plus'
|
|
15
|
+
// hack para não ter que substituir todos tp-dialog de uma vez no nuxt
|
|
16
|
+
ElDialog.name = 'TpDialog'
|
|
17
|
+
const Dialog = ElDialog
|
|
15
18
|
|
|
16
19
|
export {
|
|
17
20
|
Autosuggest,
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { createI18n } from 'vue-i18n'
|
|
2
|
+
import { reactive } from 'vue'
|
|
3
|
+
|
|
4
|
+
let i18n
|
|
5
|
+
/**
|
|
6
|
+
* Eventos que podem ser observados com watch
|
|
7
|
+
*/
|
|
8
|
+
const hooks = reactive({
|
|
9
|
+
onLanguageChanged: ''
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const loadedLanguages = []
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Função padrão para importar arquivos de language
|
|
16
|
+
* caminho padrão src/locale/lang/*.js
|
|
17
|
+
* @param {String} filename
|
|
18
|
+
* @returns {Promise}
|
|
19
|
+
*/
|
|
20
|
+
let importLangFile = (filename) => {
|
|
21
|
+
return import(/* webpackChunkName: "lang-[request]" */ `@src/locale/lang/${filename}.js`)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Executa após trocar a lang, pode ser usado para salvar nos cookies ou session
|
|
26
|
+
* @param {String} locale
|
|
27
|
+
*/
|
|
28
|
+
let onLanguageSet = (locale) => {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Seta a linguagem atual
|
|
34
|
+
* @param {String} locale 'pt-br', 'en'
|
|
35
|
+
* @returns {String} locale
|
|
36
|
+
*/
|
|
37
|
+
export function setI18nLanguage (locale) {
|
|
38
|
+
if (i18n.mode === 'legacy') {
|
|
39
|
+
i18n.global.locale = locale
|
|
40
|
+
} else {
|
|
41
|
+
i18n.global.locale.value = locale
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
hooks.onLanguageChanged = locale
|
|
45
|
+
document.querySelector('html').setAttribute('lang', locale)
|
|
46
|
+
onLanguageSet(locale)
|
|
47
|
+
return locale
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {String} locale 'pt-br', 'en'
|
|
53
|
+
* @returns {String} locale
|
|
54
|
+
*/
|
|
55
|
+
export async function loadLanguageAsync (locale) {
|
|
56
|
+
if (i18n.global.locale === locale) {
|
|
57
|
+
return locale
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// If the language was already loaded
|
|
61
|
+
if (loadedLanguages.includes(locale)) {
|
|
62
|
+
return locale
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// load locale messages with dynamic import
|
|
66
|
+
const messages = await importLangFile(locale)
|
|
67
|
+
// set locale and locale message
|
|
68
|
+
i18n.global.setLocaleMessage(locale, messages.default)
|
|
69
|
+
loadedLanguages.push(locale)
|
|
70
|
+
return locale
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Essa função cria a instância do i18n
|
|
75
|
+
* Exporta isso para poder importar do projeto nuxt sem ter que reimplementar toda a lib
|
|
76
|
+
* @param {Object} options
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
export async function setupI18n (options = {}) {
|
|
80
|
+
if (!i18n) {
|
|
81
|
+
const locale = options.locale || 'pt-br'
|
|
82
|
+
|
|
83
|
+
i18n = createI18n({
|
|
84
|
+
legacy: false,
|
|
85
|
+
locale,
|
|
86
|
+
missing: (locale, key) => {
|
|
87
|
+
console.warn(`translation missing: locale=${locale}, key=${key}`)
|
|
88
|
+
},
|
|
89
|
+
...options
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
await loadLanguageAsync(locale)
|
|
93
|
+
setI18nLanguage(locale)
|
|
94
|
+
}
|
|
95
|
+
return i18n
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default (options) => {
|
|
99
|
+
// Sobrescreve a função de importar arquivos
|
|
100
|
+
if (typeof options.importLangFile === 'function') {
|
|
101
|
+
importLangFile = options.importLangFile
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (typeof options.onLanguageSet === 'function') {
|
|
105
|
+
onLanguageSet = options.onLanguageSet
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
setupI18n,
|
|
110
|
+
loadLanguageAsync,
|
|
111
|
+
setI18nLanguage,
|
|
112
|
+
hooks
|
|
113
|
+
}
|
|
114
|
+
}
|