@bildvitta/quasar-ui-asteroid 3.17.0-beta.3 → 3.17.0-beta.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bildvitta/quasar-ui-asteroid",
3
3
  "description": "Asteroid",
4
- "version": "3.17.0-beta.3",
4
+ "version": "3.17.0-beta.4",
5
5
  "author": "Bild & Vitta <systemteam@bild.com.br>",
6
6
  "license": "MIT",
7
7
  "main": "dist/asteroid.cjs.min.js",
@@ -30,6 +30,34 @@
30
30
  </qas-badge>
31
31
  </template>
32
32
 
33
+ <template v-if="useCustomOptions" #option="scope">
34
+ <q-item v-bind="scope.itemProps" class="qas-select__option">
35
+ <q-item-section>
36
+ <div class="items-center q-gutter-x-sm row">
37
+ <q-item-label>
38
+ {{ scope.opt.label }}
39
+ </q-item-label>
40
+
41
+ <div v-for="(badge, index) in getFilteredBadgeList(scope.opt)" :key="index">
42
+ <qas-badge v-if="hasBadge(badge)" v-bind="getBadgeProps(badge)" />
43
+ </div>
44
+ </div>
45
+
46
+ <div v-if="scope.opt.caption">
47
+ <div class="items-center q-col-gutter-x-sm row">
48
+ <q-item-label v-for="(caption, index) in getCaptionArray(scope.opt.caption)" :key="index" caption class="items-center q-mt-xs row">
49
+ <div>
50
+ {{ caption }}
51
+ </div>
52
+
53
+ <q-separator v-if="hasSeparator({ caption: getCaptionArray(scope.opt.caption), index })" class="q-ml-sm" vertical />
54
+ </q-item-label>
55
+ </div>
56
+ </div>
57
+ </q-item-section>
58
+ </q-item>
59
+ </template>
60
+
33
61
  <template v-for="(_, name) in $slots" #[name]="context">
34
62
  <slot :name="name" v-bind="context || {}" />
35
63
  </template>
@@ -50,6 +78,11 @@ export default {
50
78
  mixins: [searchFilterMixin],
51
79
 
52
80
  props: {
81
+ badgeProps: {
82
+ default: () => ({}),
83
+ type: Object
84
+ },
85
+
53
86
  fuseOptions: {
54
87
  default: () => ({}),
55
88
  type: Object
@@ -83,6 +116,10 @@ export default {
83
116
  type: Boolean
84
117
  },
85
118
 
119
+ useCustomOptions: {
120
+ type: Boolean
121
+ },
122
+
86
123
  useFetchOptionsOnCreate: {
87
124
  default: true,
88
125
  type: Boolean
@@ -328,6 +365,51 @@ export default {
328
365
  : this.options[0]
329
366
 
330
367
  this.$emit('update:modelValue', modelValue)
368
+ },
369
+
370
+ getFilteredBadgeList (payload = {}) {
371
+ const { label, value, disable, caption, ...rest } = payload
372
+
373
+ const badgeList = []
374
+
375
+ /**
376
+ * Exemplo de estrutura percorrida:
377
+ *
378
+ * @example
379
+ * {
380
+ * isTester: true,
381
+ * isOwner: false
382
+ * }
383
+ */
384
+ for (const [key, val] of Object.entries(rest)) {
385
+ if (key in this.badgeProps) {
386
+ badgeList.push({ [key]: val })
387
+ }
388
+ }
389
+
390
+ return badgeList
391
+ },
392
+
393
+ getBadgeProps (badge) {
394
+ const model = Object.keys(badge)[0]
395
+
396
+ const isFunction = typeof this.badgeProps[model] === 'function'
397
+
398
+ return isFunction ? this.badgeProps[model](badge[model]).props : this.badgeProps[model]
399
+ },
400
+
401
+ hasBadge (badge) {
402
+ const model = Object.keys(badge)[0]
403
+
404
+ return badge[model] || this.badgeProps[model](badge[model]).show
405
+ },
406
+
407
+ getCaptionArray (caption) {
408
+ return Array.isArray(caption) ? caption : [caption]
409
+ },
410
+
411
+ hasSeparator ({ caption, index }) {
412
+ return index !== caption.length - 1
331
413
  }
332
414
  }
333
415
  }
@@ -353,6 +435,10 @@ export default {
353
435
  }
354
436
  }
355
437
 
438
+ &__option:hover .q-item__label--caption {
439
+ color: var(--q-primary);
440
+ }
441
+
356
442
  &--closed {
357
443
  .q-field__native span {
358
444
  white-space: nowrap;
@@ -7,6 +7,12 @@ meta:
7
7
  desc: Componente para select que implementa o "QSelect" repassando propriedades, slots e eventos.
8
8
 
9
9
  props:
10
+ badge-list:
11
+ desc: Configuração das badges no qual cada key é um callback com o valor booleano retornado pelo back.
12
+ default: {}
13
+ examples: ["{ isTester: () => { return { color: 'grey-8', label: 'Tester', textColor: 'white' }} }"]
14
+ type: Object
15
+
10
16
  entity:
11
17
  desc: Entidade enviada para a action "fetchFieldOptions" (usar somente quando "useLazyLoading" estiver habilitada).
12
18
  default: ''
@@ -27,13 +27,17 @@
27
27
 
28
28
  &--clickable:not(&--active) {
29
29
  color: $grey-10;
30
- transition: color 300ms;
30
+ transition: var(--qas-generic-transition);
31
31
 
32
32
  &:not(&.q-router-link--active):hover {
33
33
  color: var(--q-primary-contrast);
34
34
  }
35
35
  }
36
36
 
37
+ &__label--caption {
38
+ transition: var(--qas-generic-transition);
39
+ }
40
+
37
41
  &__section--avatar {
38
42
  min-width: 0;
39
43
  }