@bildvitta/quasar-ui-asteroid 3.12.0-beta.3 → 3.12.0-beta.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bildvitta/quasar-ui-asteroid",
3
3
  "description": "Asteroid",
4
- "version": "3.12.0-beta.3",
4
+ "version": "3.12.0-beta.5",
5
5
  "author": "Bild & Vitta <systemteam@bild.com.br>",
6
6
  "license": "MIT",
7
7
  "main": "dist/asteroid.cjs.min.js",
@@ -1,87 +1,111 @@
1
1
  <template>
2
- <div v-if="model" class="bg-white q-pa-lg qas-alert relative-position rounded-borders" :class="classes">
3
- <qas-btn class="absolute-top-right q-mr-md q-mt-sm" color="grey-9" icon="sym_r_close" variant="tertiary" @click="close" />
4
-
5
- <div class="q-gutter-md q-mr-lg">
6
- <slot name="header">
7
- <h5 v-if="title" class="text-bold text-h5" data-test="alert-title">{{ title }}</h5>
8
- </slot>
2
+ <div
3
+ v-if="show"
4
+ class="bg-dark flex justify-between no-wrap q-pa-md qas-alert relative-position"
5
+ >
6
+ <div class="qas-alert__border-left" :class="borderClass" />
9
7
 
8
+ <div class="text-body1 text-white">
10
9
  <slot>
11
- <qas-breakline tag="p" :text="text" />
10
+ {{ text }}
12
11
  </slot>
13
12
  </div>
13
+
14
+ <qas-btn
15
+ class="q-ml-xs qas-alert__close"
16
+ color="white"
17
+ icon="sym_r_close"
18
+ :use-hover-on-white-color="false"
19
+ @click="close"
20
+ />
14
21
  </div>
15
22
  </template>
16
23
 
17
- <script>
18
- import QasBreakline from '../breakline/QasBreakline.vue'
19
- import QasBtn from '../btn/QasBtn.vue'
24
+ <script setup>
25
+ import { LocalStorage } from 'quasar'
26
+ import { Status, StatusColor } from '../../enums/Status'
27
+ import { computed, watch, ref } from 'vue'
20
28
 
21
- export default {
22
- name: 'QasAlert',
29
+ defineOptions({ name: 'QasAlert' })
23
30
 
24
- components: {
25
- QasBreakline,
26
- QasBtn
31
+ const props = defineProps({
32
+ modelValue: {
33
+ type: Boolean,
34
+ default: true
27
35
  },
28
36
 
29
- props: {
30
- modelValue: {
31
- default: true,
32
- type: Boolean
33
- },
34
-
35
- text: {
36
- default: '',
37
- type: String
38
- },
39
-
40
- color: {
41
- type: String,
42
- default: 'primary'
43
- },
44
-
45
- title: {
46
- default: '',
47
- type: String
48
- }
37
+ text: {
38
+ type: String,
39
+ default: ''
49
40
  },
50
41
 
51
- emits: ['update:modelValue'],
52
-
53
- data () {
54
- return {
55
- model: true
56
- }
42
+ storageKey: {
43
+ type: String,
44
+ default: ''
57
45
  },
58
46
 
59
- computed: {
60
- classes () {
61
- return `text-${this.color}`
62
- }
47
+ status: {
48
+ type: String,
49
+ default: Status.Info,
50
+ validator: value => Object.values(Status).includes(value)
63
51
  },
64
52
 
65
- watch: {
66
- modelValue: {
67
- handler (value) {
68
- this.model = value
69
- },
70
- immediate: true
71
- }
72
- },
53
+ usePersistentModelOnClose: {
54
+ type: Boolean
55
+ }
56
+ })
57
+
58
+ const emit = defineEmits(['update:modelValue'])
59
+
60
+ const model = ref(props.modelValue)
61
+
62
+ watch(() => props.modelValue, value => {
63
+ model.value = value
64
+ })
65
+
66
+ const colorByStatus = computed(() => {
67
+ const status = Object.keys(Status).find(key => Status[key] === props.status)
68
+ return StatusColor[status]
69
+ })
70
+
71
+ const borderClass = computed(() => `bg-${colorByStatus.value}`)
73
72
 
74
- methods: {
75
- close () {
76
- this.$emit('update:modelValue', false)
77
- }
73
+ const storageClosedKey = computed(() => `alert-${props.storageKey}-closed`)
74
+
75
+ const isClosed = computed(() => {
76
+ return props.usePersistentModelOnClose && LocalStorage.getItem(storageClosedKey.value)
77
+ })
78
+
79
+ const show = computed(() => !isClosed.value && model.value)
80
+
81
+ function close () {
82
+ if (props.usePersistentModelOnClose) {
83
+ LocalStorage.set(storageClosedKey.value, true)
78
84
  }
85
+
86
+ model.value = false
87
+
88
+ emit('update:modelValue', model.value)
79
89
  }
90
+
80
91
  </script>
81
92
 
82
93
  <style lang="scss">
83
94
  .qas-alert {
84
- border-style: solid;
85
- border-width: 0 10px;
95
+ border-radius: var(--qas-generic-border-radius);
96
+
97
+ &__border-left {
98
+ border-radius: var(--qas-generic-border-radius) 0 0 var(--qas-generic-border-radius);
99
+ bottom: 0;
100
+ content: '';
101
+ left: 0;
102
+ position: absolute;
103
+ top: 0;
104
+ width: 4px;
105
+ }
106
+
107
+ &__close {
108
+ top: calc(var(--qas-spacing-sm) * -1);
109
+ }
86
110
  }
87
111
  </style>
@@ -9,21 +9,27 @@ props:
9
9
  default: true
10
10
  type: Boolean
11
11
 
12
- title:
13
- desc: Título do componente.
14
- type: String
15
-
16
12
  text:
17
13
  desc: Texto do componente.
18
14
  type: String
19
15
 
16
+ status:
17
+ desc: Status do alerta.
18
+ type: String
19
+ examples: ['error', 'info']
20
+
21
+ storage-key:
22
+ desc: Chave a ser salva no localStorage, necessário caso esteja usando mais de um QasAlert na aplicação e ambos estejam com a prop "use-persist-model-on-close" ativada.
23
+ type: String
24
+
25
+ use-persistent-model-on-close:
26
+ desc: Habilita salvar o model em localStorage ao fechar o alerta para não aparecer novamente.
27
+ type: Boolean
28
+
20
29
  slots:
21
30
  default:
22
31
  desc: 'Slot para acessar o conteúdo gerado pela prop "text"'
23
32
 
24
- header:
25
- desc: 'Slot para acessar o conteúdo gerado pela prop "title"'
26
-
27
33
  events:
28
34
  '@update:model-value -> function(value)':
29
35
  desc: Dispara quando o model-value altera, também usado para v-model.
@@ -130,7 +130,7 @@ export default {
130
130
  },
131
131
 
132
132
  disabledRows: {
133
- type: [Array, Boolean],
133
+ type: [Array, Boolean, Function],
134
134
  default: false
135
135
  },
136
136
 
@@ -449,6 +449,8 @@ export default {
449
449
  isDisabledRow (row) {
450
450
  if (!this.disabledRows) return false
451
451
 
452
+ if (typeof this.disabledRows === 'function') return this.disabledRows(row)
453
+
452
454
  if (typeof this.disabledRows === 'boolean') return true
453
455
 
454
456
  return this.disabledRows.includes(row[this.identifierItemKey])
@@ -37,10 +37,10 @@ props:
37
37
  type: String
38
38
 
39
39
  disabled-rows:
40
- desc: Com esta propriedade é possível desabilitar rows (linhas) especificas passando um array com chaves identificadoras, ou caso queira desativar todas passando um boolean "true" (isto vai remover todos os botões da linha, duplicar e excluir).
40
+ desc: Com esta propriedade é possível desabilitar rows (linhas) especificas passando um array com chaves identificadoras, caso queira desativar todas passe um valor boolean "true", ou também é possível utilizar uma função de callback, que receberá a "row" como parâmetro. (Isto vai remover todos os botões da linha, como por exemplo, o duplicar e excluir).
41
41
  default: "false"
42
- type: [Array, Boolean]
43
- examples: ["['my-uuid-from-row-1']", true]
42
+ type: [Array, Boolean, Function]
43
+ examples: ["['my-uuid-from-row-1']", true, "row => row.disable"]
44
44
 
45
45
  errors:
46
46
  desc: Propriedade de erros para mostrar nos campos gerados.
@@ -178,6 +178,12 @@ export default {
178
178
  if (this.hasFuse) this.setFuse()
179
179
  },
180
180
 
181
+ mx_isFetching (value) {
182
+ if (!this.isPopupContentOpen || !this.useLazyLoading) return
183
+
184
+ this.togglePopupContentClass(value)
185
+ },
186
+
181
187
  options: {
182
188
  handler () {
183
189
  if (this.useLazyLoading && this.mx_hasFilteredOptions) return
@@ -193,7 +199,6 @@ export default {
193
199
 
194
200
  created () {
195
201
  this.setSearchMethod()
196
- this.setIsFetchingWatcher()
197
202
  },
198
203
 
199
204
  methods: {
@@ -238,16 +243,6 @@ export default {
238
243
  }
239
244
  },
240
245
 
241
- setIsFetchingWatcher () {
242
- if (this.useLazyLoading) {
243
- this.$watch('mx_isFetching', value => {
244
- if (!this.isPopupContentOpen) return
245
-
246
- this.togglePopupContentClass(value)
247
- })
248
- }
249
- },
250
-
251
246
  setLazyLoading () {
252
247
  this.mx_setCachedOptions('options')
253
248
 
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Cores por status
3
+ *
4
+ * @property
5
+ * @name Spacing
6
+ * @readonly
7
+ * @enum
8
+ * @type {{
9
+ * Info: 'yellow-14',
10
+ * Error: 'red-14'
11
+ * }}
12
+ */
13
+ export const StatusColor = {
14
+ Info: 'yellow-14',
15
+ Error: 'red-14'
16
+ }
17
+
18
+ /**
19
+ * Status
20
+ *
21
+ * @property
22
+ * @name Spacing
23
+ * @readonly
24
+ * @enum
25
+ * @type {{
26
+ * Info: 'info',
27
+ * Error: 'error'
28
+ * }}
29
+ */
30
+ export const Status = {
31
+ Info: 'info',
32
+ Error: 'error'
33
+ }