@tagplus/components 0.2.80 → 0.2.84
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 +404 -271
- package/dist/tp.common.js.map +1 -1
- package/dist/tp.css +1 -1
- package/dist/tp.umd.js +404 -271
- 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 +89 -52
- package/src/components/OptionsList/OptionsList.vue +5 -2
- package/src/components/OptionsListItem/OptionsListItem.vue +31 -42
package/package.json
CHANGED
|
@@ -256,8 +256,8 @@ export default {
|
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
258
|
* Método que realiza a busca dos registros remotos para as opções.
|
|
259
|
-
*
|
|
260
|
-
* *IMPORTANTE*: deve considerar o "valueKey" nas consultas
|
|
259
|
+
*
|
|
260
|
+
* *IMPORTANTE*: deve considerar o "valueKey" nas consultas
|
|
261
261
|
* pois o valor selecionado será baseado nas opções remotas carregadas ao criar o componente.
|
|
262
262
|
*/
|
|
263
263
|
remoteMethod: {
|
|
@@ -266,32 +266,34 @@ export default {
|
|
|
266
266
|
}
|
|
267
267
|
},
|
|
268
268
|
|
|
269
|
-
data
|
|
269
|
+
data() {
|
|
270
270
|
return {
|
|
271
271
|
tooltipVisible: false
|
|
272
272
|
}
|
|
273
273
|
},
|
|
274
274
|
|
|
275
275
|
computed: {
|
|
276
|
-
_id
|
|
276
|
+
_id() {
|
|
277
277
|
return this.id || this.$options.name
|
|
278
278
|
},
|
|
279
279
|
|
|
280
280
|
/**
|
|
281
281
|
* Trata o caso que o autosuggest recebe um objeto com o valueKey e labelKey
|
|
282
282
|
*/
|
|
283
|
-
formatedValue
|
|
283
|
+
formatedValue() {
|
|
284
284
|
let newVal = ''
|
|
285
285
|
if (typeof this.value === 'boolean') {
|
|
286
286
|
newVal = ''
|
|
287
|
-
}
|
|
288
|
-
else if (Array.isArray(this.value)) {
|
|
287
|
+
} else if (Array.isArray(this.value)) {
|
|
289
288
|
newVal = this.value
|
|
290
|
-
}
|
|
291
|
-
else if (this.value && typeof this.value === 'object') {
|
|
289
|
+
} else if (this.value && typeof this.value === 'object') {
|
|
292
290
|
if (!this.value[this.valueKey]) {
|
|
293
291
|
if (process.env.DEBUG === 'true') {
|
|
294
|
-
throw new TypeError(
|
|
292
|
+
throw new TypeError(
|
|
293
|
+
'Autosuggest this.value doesn\'t have a valueKey \'' +
|
|
294
|
+
this.valueKey +
|
|
295
|
+
'\' key'
|
|
296
|
+
)
|
|
295
297
|
}
|
|
296
298
|
} else {
|
|
297
299
|
newVal = this.value[this.valueKey]
|
|
@@ -300,22 +302,26 @@ export default {
|
|
|
300
302
|
|
|
301
303
|
return newVal
|
|
302
304
|
},
|
|
303
|
-
iconClass
|
|
304
|
-
return
|
|
305
|
+
iconClass() {
|
|
306
|
+
return this.visible ? 'arrow-up is-reverse' : 'arrow-up'
|
|
305
307
|
},
|
|
306
|
-
showNewOption
|
|
307
|
-
let hasExistingOption = this.options
|
|
308
|
+
showNewOption() {
|
|
309
|
+
let hasExistingOption = this.options
|
|
310
|
+
.filter(option => !option.created)
|
|
308
311
|
.some(option => option.currentLabel === this.query)
|
|
309
312
|
return this.filterable && this.allowCreate && !hasExistingOption
|
|
310
313
|
},
|
|
311
314
|
// Monta a lista com ou sem "Cadastrar Novo Item"
|
|
312
|
-
suggestionsList
|
|
315
|
+
suggestionsList() {
|
|
313
316
|
if (this.loading) return []
|
|
314
317
|
//transformando em Array
|
|
315
|
-
let list =
|
|
318
|
+
let list =
|
|
319
|
+
typeof this.suggestions === 'object'
|
|
320
|
+
? Object.values(this.suggestions)
|
|
321
|
+
: this.suggestions
|
|
316
322
|
if (this.allowCreate) {
|
|
317
323
|
let createdSuggestion = { created: true }
|
|
318
|
-
createdSuggestion[this.valueKey] =
|
|
324
|
+
createdSuggestion[this.valueKey] = this.query !== '' ? this.query : null
|
|
319
325
|
createdSuggestion[this.labelKey] = ''
|
|
320
326
|
list.push(createdSuggestion)
|
|
321
327
|
}
|
|
@@ -323,19 +329,19 @@ export default {
|
|
|
323
329
|
}
|
|
324
330
|
},
|
|
325
331
|
|
|
326
|
-
created
|
|
332
|
+
created() {
|
|
327
333
|
this.doRequest = false
|
|
328
334
|
|
|
329
335
|
if (this.loadOnCreate) {
|
|
330
336
|
this.previousQuery = false
|
|
331
337
|
// Chama função do element-ui select que faz o remote method
|
|
332
|
-
this.handleQueryChange(
|
|
338
|
+
this.handleQueryChange('')
|
|
333
339
|
} else {
|
|
334
340
|
// Marca para fazer a requisição no primeiro clique
|
|
335
341
|
this.doRequest = true
|
|
336
342
|
}
|
|
337
343
|
|
|
338
|
-
this.debouncedOnInputChange = debounce(this.debounce,
|
|
344
|
+
this.debouncedOnInputChange = debounce(this.debounce, e => {
|
|
339
345
|
// Correção para mobile ativar a busca enquanto digita
|
|
340
346
|
if (e.isComposing) {
|
|
341
347
|
// Se está apagando
|
|
@@ -350,7 +356,7 @@ export default {
|
|
|
350
356
|
})
|
|
351
357
|
},
|
|
352
358
|
|
|
353
|
-
mounted
|
|
359
|
+
mounted() {
|
|
354
360
|
this.$nextTick(() => {
|
|
355
361
|
// Componente tooltip -> autosuggest -> input
|
|
356
362
|
var componenteInputInterno = this.$children[1].$refs['input']
|
|
@@ -366,7 +372,6 @@ export default {
|
|
|
366
372
|
})
|
|
367
373
|
},
|
|
368
374
|
|
|
369
|
-
|
|
370
375
|
methods: {
|
|
371
376
|
/**
|
|
372
377
|
* Adiciona um evento no elemento dinamicamente
|
|
@@ -374,22 +379,26 @@ export default {
|
|
|
374
379
|
* @args ev {String} Nome do listener (mouseenter, click, etc)
|
|
375
380
|
* @args func {Function} Função a ser executada
|
|
376
381
|
*/
|
|
377
|
-
createHandler
|
|
382
|
+
createHandler(el, ev, func) {
|
|
378
383
|
if (el) {
|
|
379
|
-
el.addEventListener(
|
|
380
|
-
|
|
381
|
-
|
|
384
|
+
el.addEventListener(
|
|
385
|
+
ev,
|
|
386
|
+
function() {
|
|
387
|
+
func()
|
|
388
|
+
},
|
|
389
|
+
false
|
|
390
|
+
)
|
|
382
391
|
}
|
|
383
392
|
},
|
|
384
393
|
|
|
385
|
-
onInputChange
|
|
394
|
+
onInputChange() {
|
|
386
395
|
if (this.filterable && this.query !== this.selectedLabel) {
|
|
387
396
|
this.query = this.selectedLabel
|
|
388
397
|
this.handleQueryChange(this.query)
|
|
389
398
|
}
|
|
390
399
|
},
|
|
391
400
|
|
|
392
|
-
emitChange
|
|
401
|
+
emitChange(val) {
|
|
393
402
|
if (!valueEquals(this.formatedValue, val)) {
|
|
394
403
|
this.$nextTick(() => {
|
|
395
404
|
this.$emit('change', val, this.createdSelected)
|
|
@@ -398,7 +407,7 @@ export default {
|
|
|
398
407
|
},
|
|
399
408
|
|
|
400
409
|
// eslint-disable-next-line no-unused-vars
|
|
401
|
-
clearTags
|
|
410
|
+
clearTags(event) {
|
|
402
411
|
this.selectedLabel = ''
|
|
403
412
|
// Faz uma requisição limpa
|
|
404
413
|
this.query = ''
|
|
@@ -418,21 +427,23 @@ export default {
|
|
|
418
427
|
/**
|
|
419
428
|
* Sobrescreve o getOption do select para mostrar o labelValue em vez do idValue
|
|
420
429
|
*/
|
|
421
|
-
getOption
|
|
430
|
+
getOption(val) {
|
|
422
431
|
let value = ''
|
|
423
432
|
let initialLabel = false
|
|
424
433
|
|
|
425
434
|
if (typeof this.value === 'boolean') {
|
|
426
435
|
value = ''
|
|
427
|
-
}
|
|
428
|
-
else if (Array.isArray(val)) {
|
|
436
|
+
} else if (Array.isArray(val)) {
|
|
429
437
|
value = val
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// Se val for Object converte para outro tipo
|
|
438
|
+
} else if (val && typeof val === 'object') {
|
|
439
|
+
// Se val for Object converte para outro tipo
|
|
433
440
|
if (!this.value[this.valueKey]) {
|
|
434
441
|
// eslint-disable-next-line
|
|
435
|
-
console.log(
|
|
442
|
+
console.log(
|
|
443
|
+
'Autosuggest this.value doesn\'t have a valueKey \'' +
|
|
444
|
+
this.valueKey +
|
|
445
|
+
'\' key'
|
|
446
|
+
)
|
|
436
447
|
} else {
|
|
437
448
|
// Se mandou a label no objeto value
|
|
438
449
|
if (this.value[this.labelKey]) {
|
|
@@ -445,13 +456,19 @@ export default {
|
|
|
445
456
|
}
|
|
446
457
|
|
|
447
458
|
let option
|
|
448
|
-
const isObject =
|
|
449
|
-
|
|
450
|
-
|
|
459
|
+
const isObject =
|
|
460
|
+
Object.prototype.toString.call(value).toLowerCase() ===
|
|
461
|
+
'[object object]'
|
|
462
|
+
const isNull =
|
|
463
|
+
Object.prototype.toString.call(value).toLowerCase() === '[object null]'
|
|
464
|
+
const isUndefined =
|
|
465
|
+
Object.prototype.toString.call(value).toLowerCase() ===
|
|
466
|
+
'[object undefined]'
|
|
451
467
|
for (let i = 0; i <= this.cachedOptions.length - 1; i++) {
|
|
452
468
|
const cachedOption = this.cachedOptions[i]
|
|
453
469
|
const isEqual = isObject
|
|
454
|
-
? getValueByPath(cachedOption.value, this.valueKey) ===
|
|
470
|
+
? getValueByPath(cachedOption.value, this.valueKey) ===
|
|
471
|
+
getValueByPath(value, this.valueKey)
|
|
455
472
|
: cachedOption.value === value
|
|
456
473
|
if (isEqual) {
|
|
457
474
|
option = cachedOption
|
|
@@ -459,8 +476,7 @@ export default {
|
|
|
459
476
|
}
|
|
460
477
|
}
|
|
461
478
|
if (option) return option
|
|
462
|
-
const label =
|
|
463
|
-
? value : ''
|
|
479
|
+
const label = !isObject && !isNull && !isUndefined ? value : ''
|
|
464
480
|
let newOption = {
|
|
465
481
|
value: value,
|
|
466
482
|
currentLabel: initialLabel ? initialLabel : label
|
|
@@ -470,7 +486,7 @@ export default {
|
|
|
470
486
|
}
|
|
471
487
|
return newOption
|
|
472
488
|
},
|
|
473
|
-
checkDefaultFirstOption
|
|
489
|
+
checkDefaultFirstOption() {
|
|
474
490
|
this.$nextTick(() => {
|
|
475
491
|
this.hoverIndex = -1
|
|
476
492
|
|
|
@@ -495,8 +511,9 @@ export default {
|
|
|
495
511
|
/**
|
|
496
512
|
* Sobrescreve a função de abrir menu do select para fazer a busca quando loadOnCreate = false
|
|
497
513
|
*/
|
|
498
|
-
toggleMenu
|
|
514
|
+
toggleMenu() {
|
|
499
515
|
if (!this.selectDisabled) {
|
|
516
|
+
// Se mantem visivel quando clica nele aberto
|
|
500
517
|
if (this.menuVisibleOnFocus) {
|
|
501
518
|
this.menuVisibleOnFocus = false
|
|
502
519
|
} else {
|
|
@@ -505,7 +522,7 @@ export default {
|
|
|
505
522
|
// Se está visivel
|
|
506
523
|
if (this.visible) {
|
|
507
524
|
if (this.doRequest) {
|
|
508
|
-
this.handleQueryChange(this.
|
|
525
|
+
this.handleQueryChange(this.query)
|
|
509
526
|
this.doRequest = false
|
|
510
527
|
}
|
|
511
528
|
(this.$refs.input || this.$refs.reference).focus()
|
|
@@ -513,26 +530,42 @@ export default {
|
|
|
513
530
|
}
|
|
514
531
|
},
|
|
515
532
|
|
|
533
|
+
handleClose() {
|
|
534
|
+
this.visible = false
|
|
535
|
+
// Limpa busca quando fecha
|
|
536
|
+
this.doRequest = true
|
|
537
|
+
},
|
|
538
|
+
|
|
516
539
|
/**
|
|
517
540
|
* Sobrescreve função do select
|
|
518
541
|
*/
|
|
519
|
-
handleQueryChange
|
|
542
|
+
handleQueryChange(val) {
|
|
520
543
|
var _this6 = this
|
|
521
544
|
// Correção aqui para forçar primeeira request com createOnLoad = false
|
|
522
|
-
if (
|
|
523
|
-
|
|
545
|
+
if (
|
|
546
|
+
(!this.doRequest && this.previousQuery === val) ||
|
|
547
|
+
this.isOnComposition
|
|
548
|
+
)
|
|
549
|
+
return
|
|
550
|
+
if (
|
|
551
|
+
this.previousQuery === null &&
|
|
552
|
+
(typeof this.filterMethod === 'function' ||
|
|
553
|
+
typeof this.remoteMethod === 'function')
|
|
554
|
+
) {
|
|
524
555
|
this.previousQuery = val
|
|
525
556
|
return
|
|
526
557
|
}
|
|
527
558
|
this.previousQuery = val
|
|
528
|
-
this.$nextTick(function
|
|
559
|
+
this.$nextTick(function() {
|
|
529
560
|
if (_this6.visible) _this6.broadcast('ElSelectDropdown', 'updatePopper')
|
|
530
561
|
})
|
|
531
562
|
this.hoverIndex = -1
|
|
532
563
|
if (this.multiple && this.filterable) {
|
|
533
|
-
this.$nextTick(function
|
|
564
|
+
this.$nextTick(function() {
|
|
534
565
|
var length = _this6.$refs.input.value.length * 15 + 20
|
|
535
|
-
_this6.inputLength = _this6.collapseTags
|
|
566
|
+
_this6.inputLength = _this6.collapseTags
|
|
567
|
+
? Math.min(50, length)
|
|
568
|
+
: length
|
|
536
569
|
_this6.managePlaceholder()
|
|
537
570
|
_this6.resetInputHeight()
|
|
538
571
|
})
|
|
@@ -548,7 +581,11 @@ export default {
|
|
|
548
581
|
this.broadcast('ElOption', 'queryChange', val)
|
|
549
582
|
this.broadcast('ElOptionGroup', 'queryChange')
|
|
550
583
|
}
|
|
551
|
-
if (
|
|
584
|
+
if (
|
|
585
|
+
this.defaultFirstOption &&
|
|
586
|
+
(this.filterable || this.remote) &&
|
|
587
|
+
this.filteredOptionsCount
|
|
588
|
+
) {
|
|
552
589
|
this.checkDefaultFirstOption()
|
|
553
590
|
}
|
|
554
591
|
}
|
|
@@ -36,6 +36,10 @@ export default {
|
|
|
36
36
|
justify-content: space-between;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
&.center {
|
|
40
|
+
justify-content: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
&.disabled {
|
|
40
44
|
pointer-events: none;
|
|
41
45
|
cursor: default;
|
|
@@ -43,8 +47,7 @@ export default {
|
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
li {
|
|
46
|
-
|
|
47
|
-
margin: 15px 0 0 15px;
|
|
50
|
+
margin-right: 15px;
|
|
48
51
|
|
|
49
52
|
&:last-child {
|
|
50
53
|
margin-right: 0;
|
|
@@ -5,16 +5,7 @@
|
|
|
5
5
|
@click="updateOption"
|
|
6
6
|
>
|
|
7
7
|
<div :class="['icon', direction]">
|
|
8
|
-
<
|
|
9
|
-
<el-col :xs="16" :sm="18" :md="20">
|
|
10
|
-
<i :class="[icon, 'options-icon']" />
|
|
11
|
-
</el-col>
|
|
12
|
-
<el-col :xs="8" :sm="6" :md="4">
|
|
13
|
-
<div v-if="miniIcon !== ''" class="mini-icon-wrapper">
|
|
14
|
-
<i :class="[miniIcon, 'options-mini-icon']" />
|
|
15
|
-
</div>
|
|
16
|
-
</el-col>
|
|
17
|
-
</el-row>
|
|
8
|
+
<i :class="[icon, 'options-icon']" />
|
|
18
9
|
<p class="text">
|
|
19
10
|
<span
|
|
20
11
|
v-for="(text, index) in texts"
|
|
@@ -24,6 +15,7 @@
|
|
|
24
15
|
</span>
|
|
25
16
|
</p>
|
|
26
17
|
</div>
|
|
18
|
+
<sup v-if="badge" class="option-item-badge" />
|
|
27
19
|
</li>
|
|
28
20
|
</template>
|
|
29
21
|
|
|
@@ -47,9 +39,9 @@ export default {
|
|
|
47
39
|
type: String,
|
|
48
40
|
default: ''
|
|
49
41
|
},
|
|
50
|
-
|
|
51
|
-
type:
|
|
52
|
-
default:
|
|
42
|
+
badge: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
53
45
|
},
|
|
54
46
|
direction: {
|
|
55
47
|
type: String,
|
|
@@ -88,20 +80,19 @@ export default {
|
|
|
88
80
|
<style lang="scss" scoped>
|
|
89
81
|
.tp-options-list-item {
|
|
90
82
|
position: relative;
|
|
83
|
+
height: 84px;
|
|
91
84
|
border: 1px solid #dde5ee;
|
|
92
85
|
border-radius: 6px;
|
|
93
86
|
cursor: pointer;
|
|
87
|
+
white-space: nowrap;
|
|
94
88
|
display: flex;
|
|
95
89
|
align-items: center;
|
|
96
90
|
justify-content: center;
|
|
97
91
|
background: #fff;
|
|
98
92
|
transition: border-color 150ms ease-in-out;
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
margin-right: 15px;
|
|
94
|
+
margin-top: 15px;
|
|
101
95
|
|
|
102
|
-
li{
|
|
103
|
-
height: 84px;
|
|
104
|
-
}
|
|
105
96
|
&.entrada {
|
|
106
97
|
@include option-list-item-hover(#67c23a);
|
|
107
98
|
@include option-list-item-checked(#67c23a);
|
|
@@ -128,10 +119,10 @@ export default {
|
|
|
128
119
|
color: #565b66;
|
|
129
120
|
display: flex;
|
|
130
121
|
align-items: center;
|
|
131
|
-
text-align: center;
|
|
132
|
-
flex: 1;
|
|
122
|
+
// text-align: center;
|
|
133
123
|
transition: color 150ms ease-in-out;
|
|
134
124
|
line-height: 1.75em;
|
|
125
|
+
min-width: 120px;
|
|
135
126
|
|
|
136
127
|
&.horizontal {
|
|
137
128
|
justify-content: space-around;
|
|
@@ -155,21 +146,15 @@ export default {
|
|
|
155
146
|
|
|
156
147
|
&.vertical {
|
|
157
148
|
flex-direction: column;
|
|
158
|
-
.icon__wrapper{
|
|
159
|
-
width: 100%;
|
|
160
|
-
flex-wrap:no-wrap;
|
|
161
|
-
|
|
162
|
-
.options-icon {
|
|
163
|
-
padding-top: 1rem;
|
|
164
|
-
padding-left: 2rem;
|
|
165
|
-
font-size: 24px;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
149
|
.text {
|
|
169
150
|
span {
|
|
170
151
|
font-size: 14px;
|
|
171
152
|
}
|
|
172
153
|
}
|
|
154
|
+
|
|
155
|
+
.options-icon {
|
|
156
|
+
font-size: 24px;
|
|
157
|
+
}
|
|
173
158
|
}
|
|
174
159
|
|
|
175
160
|
.text {
|
|
@@ -177,20 +162,24 @@ export default {
|
|
|
177
162
|
display: block;
|
|
178
163
|
}
|
|
179
164
|
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.mini-icon-wrapper{
|
|
183
|
-
margin-top: 0.3rem;
|
|
184
|
-
display: flex;
|
|
185
|
-
height: 100%;
|
|
186
|
-
width: 25px;
|
|
187
|
-
transition: color 150ms ease-in-out;
|
|
188
165
|
|
|
189
|
-
.options-
|
|
190
|
-
|
|
191
|
-
font-size:
|
|
192
|
-
align-self: flex-start;
|
|
166
|
+
.options-icon {
|
|
167
|
+
padding-top: 1rem;
|
|
168
|
+
font-size: 24px;
|
|
193
169
|
}
|
|
194
170
|
}
|
|
171
|
+
|
|
195
172
|
}
|
|
173
|
+
|
|
174
|
+
.option-item-badge{
|
|
175
|
+
background-color: #F56C6C;
|
|
176
|
+
border: 1px solid #FFF;
|
|
177
|
+
position: absolute;
|
|
178
|
+
top: 0;
|
|
179
|
+
transform: translateY(-50%) translateX(100%);
|
|
180
|
+
height: 12px;
|
|
181
|
+
width: 12px;
|
|
182
|
+
right: 5px;
|
|
183
|
+
border-radius: 50%;
|
|
184
|
+
}
|
|
196
185
|
</style>
|