@bildvitta/quasar-ui-asteroid 3.0.0-beta.9 → 3.0.0

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.
Files changed (102) hide show
  1. package/dist/api/QasAppBar.json +0 -4
  2. package/dist/api/QasBtn.json +2 -1
  3. package/dist/api/QasCard.json +13 -9
  4. package/dist/api/QasDateTimeInput.json +12 -12
  5. package/dist/api/QasDialog.json +6 -2
  6. package/dist/api/QasFilters.json +4 -4
  7. package/dist/api/QasFormGenerator.json +33 -2
  8. package/dist/api/QasFormView.json +26 -9
  9. package/dist/api/QasGridGenerator.json +5 -4
  10. package/dist/api/QasInput.json +1 -1
  11. package/dist/api/QasListItems.json +18 -17
  12. package/dist/api/QasListView.json +21 -7
  13. package/dist/api/QasNestedFields.json +13 -3
  14. package/dist/api/QasNumericInput.json +10 -10
  15. package/dist/api/QasPasswordInput.json +1 -1
  16. package/dist/api/QasSearchBox.json +80 -1
  17. package/dist/api/QasSelect.json +79 -6
  18. package/dist/api/QasSelectList.json +16 -14
  19. package/dist/api/QasSignaturePad.json +1 -1
  20. package/dist/api/QasSingleView.json +13 -4
  21. package/dist/api/QasTabsGenerator.json +5 -2
  22. package/dist/api/QasUploader.json +5 -0
  23. package/dist/asteroid.cjs.css +1 -1
  24. package/dist/asteroid.cjs.js +1463 -663
  25. package/dist/asteroid.cjs.min.js +2 -2
  26. package/dist/asteroid.esm.css +1 -1
  27. package/dist/asteroid.esm.js +1466 -666
  28. package/dist/asteroid.esm.min.js +2 -2
  29. package/dist/asteroid.umd.css +1 -1
  30. package/dist/asteroid.umd.js +1466 -667
  31. package/dist/asteroid.umd.min.js +2 -2
  32. package/dist/vetur/asteroid-attributes.json +162 -94
  33. package/dist/vetur/asteroid-tags.json +54 -37
  34. package/package.json +1 -1
  35. package/src/components/actions-menu/QasActionsMenu.vue +2 -8
  36. package/src/components/app-bar/QasAppBar.vue +16 -12
  37. package/src/components/app-bar/QasAppBar.yml +0 -4
  38. package/src/components/avatar/QasAvatar.vue +0 -4
  39. package/src/components/btn/QasBtn.vue +5 -8
  40. package/src/components/btn/QasBtn.yml +2 -1
  41. package/src/components/card/QasCard.vue +18 -9
  42. package/src/components/card/QasCard.yml +13 -9
  43. package/src/components/date-time-input/QasDateTimeInput.vue +39 -41
  44. package/src/components/date-time-input/QasDateTimeInput.yml +11 -12
  45. package/src/components/delete/QasDelete.vue +15 -1
  46. package/src/components/dialog/QasDialog.vue +26 -3
  47. package/src/components/dialog/QasDialog.yml +6 -3
  48. package/src/components/dialog-router/QasDialogRouter.vue +1 -1
  49. package/src/components/field/QasField.vue +15 -14
  50. package/src/components/filters/QasFilters.vue +27 -10
  51. package/src/components/filters/QasFilters.yml +4 -4
  52. package/src/components/form-generator/QasFormGenerator.vue +87 -12
  53. package/src/components/form-generator/QasFormGenerator.yml +16 -2
  54. package/src/components/form-view/QasFormView.vue +99 -39
  55. package/src/components/form-view/QasFormView.yml +22 -9
  56. package/src/components/grid-generator/QasGridGenerator.vue +23 -7
  57. package/src/components/grid-generator/QasGridGenerator.yml +5 -4
  58. package/src/components/input/QasInput.vue +37 -21
  59. package/src/components/input/QasInput.yml +1 -1
  60. package/src/components/layout/QasLayout.vue +4 -0
  61. package/src/components/list-items/QasListItems.vue +15 -23
  62. package/src/components/list-items/QasListItems.yml +14 -15
  63. package/src/components/list-view/QasListView.vue +45 -24
  64. package/src/components/list-view/QasListView.yml +19 -7
  65. package/src/components/map/QasMap.vue +5 -5
  66. package/src/components/nested-fields/QasNestedFields.vue +29 -21
  67. package/src/components/nested-fields/QasNestedFields.yml +9 -3
  68. package/src/components/numeric-input/QasNumericInput.vue +14 -14
  69. package/src/components/numeric-input/QasNumericInput.yml +10 -10
  70. package/src/components/page-header/QasPageHeader.vue +14 -11
  71. package/src/components/password-input/QasPasswordInput.vue +17 -16
  72. package/src/components/password-input/QasPasswordInput.yml +1 -1
  73. package/src/components/profile/QasProfile.vue +1 -1
  74. package/src/components/search-box/QasSearchBox.vue +137 -36
  75. package/src/components/search-box/QasSearchBox.yml +66 -1
  76. package/src/components/select/QasSelect.vue +62 -46
  77. package/src/components/select/QasSelect.yml +63 -6
  78. package/src/components/select-list/QasSelectList.vue +11 -27
  79. package/src/components/select-list/QasSelectList.yml +13 -14
  80. package/src/components/signature-pad/QasSignaturePad.yml +1 -1
  81. package/src/components/signature-uploader/QasSignatureUploader.vue +7 -5
  82. package/src/components/single-view/QasSingleView.vue +22 -6
  83. package/src/components/single-view/QasSingleView.yml +11 -4
  84. package/src/components/table-generator/QasTableGenerator.vue +11 -1
  85. package/src/components/tabs-generator/QasTabsGenerator.vue +2 -2
  86. package/src/components/tabs-generator/QasTabsGenerator.yml +2 -2
  87. package/src/components/text-truncate/QasTextTruncate.vue +1 -1
  88. package/src/components/uploader/QasUploader.vue +62 -15
  89. package/src/components/uploader/QasUploader.yml +5 -0
  90. package/src/helpers/camelize-fields-name.js +15 -0
  91. package/src/helpers/filters.js +2 -0
  92. package/src/helpers/get-normalized-options.js +20 -0
  93. package/src/helpers/handle-process.js +13 -0
  94. package/src/helpers/index.js +3 -0
  95. package/src/mixins/generator.js +10 -2
  96. package/src/mixins/index.js +2 -0
  97. package/src/mixins/search-filter.js +227 -0
  98. package/src/mixins/view.js +32 -12
  99. package/src/plugins/index.js +4 -2
  100. package/src/plugins/logger/Logger.js +44 -0
  101. package/src/plugins/logger/Logger.yml +9 -0
  102. package/src/vue-plugin.js +6 -3
@@ -4,13 +4,13 @@
4
4
  <slot name="header" />
5
5
  </header>
6
6
 
7
- <q-form ref="form" @submit="submit">
7
+ <q-form ref="form" @submit="submitHandler">
8
8
  <slot />
9
9
 
10
10
  <slot v-if="useActions" name="actions">
11
11
  <div class="justify-end q-col-gutter-md q-my-lg row">
12
12
  <div v-if="hasCancelButton" class="col-12 col-sm-2" :class="cancelButtonClass">
13
- <qas-btn v-close-popup="dialog" class="full-width" :data-cy="`btnCancel-${entity}`" :disable="isCancelButtonDisabled" :label="cancelButtonLabel" outline type="button" @click="cancel" />
13
+ <qas-btn v-close-popup class="full-width" :data-cy="`btnCancel-${entity}`" :disable="isCancelButtonDisabled" :label="cancelButtonLabel" outline type="button" @click="cancel" />
14
14
  </div>
15
15
 
16
16
  <div v-if="useSubmitButton" class="col-12 col-sm-2" :class="submitButtonClass">
@@ -85,7 +85,7 @@ export default {
85
85
  type: Object
86
86
  },
87
87
 
88
- showDialogOnUnsavedChanges: {
88
+ useDialogOnUnsavedChanges: {
89
89
  default: true,
90
90
  type: Boolean
91
91
  },
@@ -122,6 +122,11 @@ export default {
122
122
  useSubmitButton: {
123
123
  default: true,
124
124
  type: Boolean
125
+ },
126
+
127
+ beforeSubmit: {
128
+ default: null,
129
+ type: Function
125
130
  }
126
131
  },
127
132
 
@@ -138,7 +143,6 @@ export default {
138
143
  data () {
139
144
  return {
140
145
  cachedResult: {},
141
- hasResult: false,
142
146
  isSubmitting: false,
143
147
  showDialog: false,
144
148
  ignoreRouterGuard: false,
@@ -195,25 +199,17 @@ export default {
195
199
  },
196
200
 
197
201
  watch: {
198
- mx_fields (fields) {
199
- const models = { ...this.getModelsByFields(fields), ...this.modelValue }
200
-
201
- this.$emit('update:modelValue', models)
202
-
203
- if (!this.hasResult && this.showDialogOnUnsavedChanges) {
204
- this.cachedResult = extend(true, {}, models)
205
- }
206
- },
207
-
208
202
  isSubmitting (value) {
209
203
  this.$emit('update:submitting', value)
210
204
  }
211
205
  },
212
206
 
213
207
  created () {
214
- onBeforeRouteLeave(this.beforeRouteLeave)
208
+ this.useDialogOnUnsavedChanges && onBeforeRouteLeave(this.beforeRouteLeave)
209
+
215
210
  window.addEventListener('delete-success', this.setIgnoreRouterGuard)
216
- this.fetch()
211
+
212
+ this.mx_fetchHandler({ form: true, id: this.id, url: this.fetchURL }, this.fetchSingle)
217
213
  },
218
214
 
219
215
  onUnmounted () {
@@ -226,13 +222,13 @@ export default {
226
222
  const clonedCachedResult = extend(true, {}, this.cachedResult)
227
223
 
228
224
  /**
229
- * Se a propriedade "showDialogOnUnsavedChanges" for false ou a variável
225
+ * Se a propriedade "useDialogOnUnsavedChanges" for false ou a variável
230
226
  * "ignoreRouterGuard" for true, então **não** iremos checar se o usuário
231
227
  * alterou algum campo antes de sair da pagina, senão iremos validar pela função isEqualWith
232
228
  * e mostrar um dialog antes do usuário sair da página.
233
229
  */
234
230
  if (
235
- !this.showDialogOnUnsavedChanges ||
231
+ !this.useDialogOnUnsavedChanges ||
236
232
  this.ignoreRouterGuard ||
237
233
  isEqualWith(
238
234
  clonedModelValue,
@@ -243,6 +239,11 @@ export default {
243
239
  return next()
244
240
  }
245
241
 
242
+ this.$qas.logger.group(
243
+ 'QasFormView - beforeRouteLeave -> dialog chamado, modelValue diferente do cachedResult',
244
+ [{ modelValue: clonedModelValue, cachedResult: clonedCachedResult }]
245
+ )
246
+
246
247
  this.handleDialog(() => {
247
248
  this.ignoreRouterGuard = true
248
249
  next()
@@ -250,45 +251,64 @@ export default {
250
251
  },
251
252
 
252
253
  cancel () {
253
- if (!this.dialog) {
254
- this.handleCancelRoute()
255
- }
254
+ this.handleCancelRoute()
256
255
  },
257
256
 
258
- async fetch (params) {
257
+ async fetchSingle (externalPayload = {}) {
259
258
  this.mx_isFetching = true
260
259
 
261
260
  try {
262
- const response = await this.$store.dispatch(
263
- `${this.entity}/fetchSingle`, { form: true, id: this.id, params, url: this.fetchURL }
261
+ const payload = {
262
+ form: true,
263
+ id: this.id,
264
+ url: this.fetchURL,
265
+ ...externalPayload
266
+ }
267
+
268
+ this.$qas.logger.group(
269
+ `QasFormView - fetchSingle -> payload do parâmetro do ${this.entity}/fetchSingle`, [payload]
264
270
  )
265
271
 
272
+ const response = await this.$store.dispatch(`${this.entity}/fetchSingle`, payload)
273
+
266
274
  const { errors, fields, metadata, result } = response.data
267
275
 
276
+ const modelValue = { ...this.getModelsByFields(fields), ...this.modelValue }
277
+
268
278
  this.mx_setErrors(errors)
269
279
  this.mx_setFields(fields)
270
280
  this.mx_setMetadata(metadata)
271
281
 
272
282
  this.mx_updateModels({
273
- errors: errors,
283
+ errors,
274
284
  fields: this.mx_fields,
275
285
  metadata
276
286
  })
277
287
 
278
- if (result) {
279
- this.hasResult = true
288
+ result && Object.assign(modelValue, result)
280
289
 
281
- this.$nextTick(() => {
282
- this.$emit('update:modelValue', { ...this.modelValue, ...result })
283
- })
290
+ this.$qas.logger.group(
291
+ `QasFormView - fetchSingle -> resposta da action ${this.entity}/fetchSingle`, [response]
292
+ )
284
293
 
285
- this.cachedResult = this.showDialogOnUnsavedChanges && extend(true, {}, result)
294
+ if (this.useDialogOnUnsavedChanges) {
295
+ this.cachedResult = extend(true, {}, result || modelValue)
296
+ this.$qas.logger.group('QasFormView - fetchSingle -> cachedResult', [this.cachedResult])
286
297
  }
287
298
 
299
+ this.$emit('update:modelValue', modelValue)
288
300
  this.$emit('fetch-success', response, this.modelValue)
301
+
302
+ this.$qas.logger.group('QasFormView - fetchSingle -> modelValue', [modelValue])
289
303
  } catch (error) {
290
304
  this.mx_fetchError(error)
291
305
  this.$emit('fetch-error', error)
306
+
307
+ this.$qas.logger.group(
308
+ `QasFormView - fetchSingle -> exceção da action ${this.entity}/fetchSingle`,
309
+ [error],
310
+ { error: true }
311
+ )
292
312
  } finally {
293
313
  this.mx_isFetching = false
294
314
  }
@@ -325,6 +345,7 @@ export default {
325
345
  const { addRoute } = useHistory()
326
346
 
327
347
  this.defaultDialogProps.ok.onClick = () => addRoute(this.$route)
348
+
328
349
  this.defaultDialogProps.cancel.onClick = next
329
350
  },
330
351
 
@@ -344,33 +365,66 @@ export default {
344
365
  })
345
366
  },
346
367
 
347
- async submit (event) {
348
- if (this.disable) return null
349
-
368
+ /**
369
+ * Se existe a propriedade com callback "beforeSubmit", então o controle de quando e como chamar o método "submit"
370
+ * está sendo controlado fora do QasFormView, se não existir a propriedade "beforeSubmit", então o controle do método
371
+ * submit é feito pelo próprio QasFormView, chamado pelo evento @submit.
372
+ */
373
+ submitHandler (event) {
350
374
  if (event) {
351
375
  event.preventDefault()
352
376
  }
353
377
 
378
+ const hasBeforeSubmit = typeof this.beforeSubmit === 'function'
379
+
380
+ if (hasBeforeSubmit) {
381
+ return this.beforeSubmit({
382
+ payload: { id: this.id, payload: this.modelValue, url: this.url },
383
+ resolve: payload => this.submit(payload)
384
+ })
385
+ }
386
+
387
+ this.submit()
388
+ },
389
+
390
+ async submit (externalPayload = {}) {
391
+ if (this.disable) return null
392
+
354
393
  this.isSubmitting = true
355
394
 
356
395
  try {
357
- const response = await this.$store.dispatch(
358
- `${this.entity}/${this.mode}`,
359
- { id: this.id, payload: this.modelValue, url: this.url }
396
+ const payload = {
397
+ id: this.id,
398
+ payload: this.modelValue,
399
+ url: this.url,
400
+ ...externalPayload
401
+ }
402
+
403
+ this.$qas.logger.group(
404
+ `QasFormView - submit -> payload do ${this.entity}/${this.mode}`, [payload]
360
405
  )
361
406
 
362
- if (this.showDialogOnUnsavedChanges) {
407
+ const response = await this.$store.dispatch(`${this.entity}/${this.mode}`, payload)
408
+
409
+ if (this.useDialogOnUnsavedChanges) {
363
410
  this.cachedResult = extend(true, {}, this.modelValue)
364
411
  }
365
412
 
366
413
  this.mx_setErrors()
367
414
  NotifySuccess(response.data.status.text || 'Item salvo com sucesso!')
368
415
  this.$emit('submit-success', response, this.modelValue)
416
+
417
+ this.$qas.logger.group(
418
+ `QasFormView - submit -> resposta da action ${this.entity}/${this.mode}`, [response]
419
+ )
369
420
  } catch (error) {
370
421
  const errors = error?.response?.data?.errors
371
422
  const message = error?.response?.data?.status?.text
372
423
  const exceptionResponse = error?.response?.data?.exception
373
- const exception = errors ? 'Existem erros de validação no formulário.' : exceptionResponse || error.message
424
+
425
+ const exception = errors
426
+ ? 'Existem erros de validação no formulário.'
427
+ : exceptionResponse || error.message
374
428
 
375
429
  this.mx_setErrors(errors)
376
430
  this.$emit('update:errors', this.mx_errors)
@@ -378,6 +432,12 @@ export default {
378
432
  NotifyError(message || 'Ops! Erro ao salvar item.', exception)
379
433
 
380
434
  this.$emit('submit-error', error)
435
+
436
+ this.$qas.logger.group(
437
+ `QasFormView - submit -> exceção da action ${this.entity}/${this.mode}`,
438
+ [error],
439
+ { error: true }
440
+ )
381
441
  } finally {
382
442
  this.isSubmitting = false
383
443
  }
@@ -4,6 +4,18 @@ meta:
4
4
  desc: Componente para C.R.U.D. responsável pela pela criação (Create) e edição (Update).
5
5
 
6
6
  props:
7
+ before-fetch:
8
+ desc: Callback para controlar como funciona o comportamento do fetch.
9
+ default: null
10
+ type: Function
11
+ examples: ['beforeFetch({ payload, resolve })']
12
+
13
+ before-submit:
14
+ desc: Callback para controlar como funciona o comportamento do submit.
15
+ default: null
16
+ type: Function
17
+ examples: ['beforeSubmit({ payload, resolve })']
18
+
7
19
  cancel-button-label:
8
20
  desc: Rótulo do botão "cancelar".
9
21
  default: Cancelar
@@ -25,10 +37,6 @@ props:
25
37
  type: String
26
38
  examples: ['my-custom-id']
27
39
 
28
- dialog:
29
- desc: Este componente pode ser utilizado dentro de um dialog, neste caso o componente pai não pode ser um "QPage" e sim uma "div", esta prop cuida disto.
30
- type: Boolean
31
-
32
40
  disable:
33
41
  desc: Desabilita o submit.
34
42
  type: Boolean
@@ -89,11 +97,6 @@ props:
89
97
  default: {}
90
98
  type: Object
91
99
 
92
- show-dialog-on-unsaved-changes:
93
- desc: Vamos imaginar um cenário onde o usuário entra na nossa tela de editar/criar, faz tudo o que precisa e sem querer clica no menu para ir para outra tela, caso essa prop esteja "true", vai aparece um modal perguntando se ele quer continuar editando ou ir para a tela no qual foi inicialmente redirecionado.
94
- default: true
95
- type: Boolean
96
-
97
100
  submit-button-label:
98
101
  desc: Rótulo do botão "salvar".
99
102
  default: Salvar
@@ -114,11 +117,21 @@ props:
114
117
  default: true
115
118
  type: Boolean
116
119
 
120
+ use-boundary:
121
+ desc: Controla o limite que o FormView terá, quando é "false", a tag pai deixa de ser um "QPage" para ser uma "div" e é removido as classes "container" e "spaced", comumente utilizando quando precisa usar o QasFormView dentro de um dialog.
122
+ default: true
123
+ type: Boolean
124
+
117
125
  use-cancel-button:
118
126
  desc: Controla se vai ter ou não botão de "cancelar".
119
127
  default: true
120
128
  type: Boolean
121
129
 
130
+ use-dialog-on-unsaved-changes:
131
+ desc: Vamos imaginar um cenário onde o usuário entra na nossa tela de editar/criar, faz tudo o que precisa e sem querer clica no menu para ir para outra tela, caso essa prop esteja "true", vai aparece um modal perguntando se ele quer continuar editando ou ir para a tela no qual foi inicialmente redirecionado.
132
+ default: true
133
+ type: Boolean
134
+
122
135
  use-submit-button:
123
136
  desc: Controla se vai ter ou não botão de submit.
124
137
  default: true
@@ -36,10 +36,6 @@ export default {
36
36
  type: [Array, Object, String]
37
37
  },
38
38
 
39
- hideEmptyResult: {
40
- type: Boolean
41
- },
42
-
43
39
  emptyResultText: {
44
40
  default: '-',
45
41
  type: String
@@ -48,6 +44,11 @@ export default {
48
44
  result: {
49
45
  default: () => ({}),
50
46
  type: Object
47
+ },
48
+
49
+ useEmptyResult: {
50
+ default: true,
51
+ type: Boolean
51
52
  }
52
53
  },
53
54
 
@@ -59,7 +60,12 @@ export default {
59
60
 
60
61
  computed: {
61
62
  formattedFields () {
62
- if (!this.hideEmptyResult) {
63
+ if (this.useEmptyResult) {
64
+ this.$qas.logger.group(
65
+ 'QasGridGenerator - formattedFields -> this.useEmptyResult tem valor "true"',
66
+ [this.fields]
67
+ )
68
+
63
69
  return this.fields
64
70
  }
65
71
 
@@ -77,6 +83,8 @@ export default {
77
83
  }
78
84
  }
79
85
 
86
+ this.$qas.logger.group('QasGridGenerator - formattedFields', [fields])
87
+
80
88
  return fields
81
89
  },
82
90
 
@@ -92,11 +100,19 @@ export default {
92
100
 
93
101
  for (const key in result) {
94
102
  if (this.formattedFields[key]?.type) {
95
- formattedResult[key] = humanize(this.formattedFields[key], result[key]) || this.emptyResultText
96
- this.slotValue[key] = { ...this.formattedFields[key], formattedResult: formattedResult[key] }
103
+ formattedResult[key] = (
104
+ humanize(this.formattedFields[key], result[key]) || this.emptyResultText
105
+ )
106
+
107
+ this.slotValue[key] = {
108
+ ...this.formattedFields[key],
109
+ formattedResult: formattedResult[key]
110
+ }
97
111
  }
98
112
  }
99
113
 
114
+ this.$qas.logger.group('QasGridGenerator - getResultsByFields', [formattedResult])
115
+
100
116
  return formattedResult
101
117
  }
102
118
  }
@@ -37,16 +37,17 @@ props:
37
37
  default: 'text-bold'
38
38
  type: [Array, Object, String]
39
39
 
40
- hide-empty-result:
41
- desc: Se o resultado de algum campo for vazio, ele remove todo o campo.
42
- type: Boolean
43
-
44
40
  result:
45
41
  desc: Resultado contendo todas informações para serem exibidas na tela.
46
42
  default: {}
47
43
  type: Object
48
44
  examples: ["{ 'joah@examples.com' }"]
49
45
 
46
+ use-empty-result:
47
+ desc: Se o resultado de algum campo for vazio e esta propriedade for "false", ele remove todo o campo.
48
+ default: true
49
+ type: Boolean
50
+
50
51
  slots:
51
52
  content:
52
53
  desc: Slot para o conteúdo (content).
@@ -1,11 +1,9 @@
1
1
  <template>
2
- <div>
3
- <q-input ref="input" v-model="model" bottom-slots :error="errorData" v-bind="$attrs" :error-message="errorMessageData" :mask="mask" :outlined="outlined" :unmasked-value="unmaskedValue">
4
- <template v-for="(_, name) in $slots" #[name]="context">
5
- <slot :name="name" v-bind="context || {}" />
6
- </template>
7
- </q-input>
8
- </div>
2
+ <q-input ref="input" v-model="model" bottom-slots :error="errorData" v-bind="$attrs" :error-message="errorMessageData" :mask="mask" :outlined="outlined" :unmasked-value="unmaskedValue" @paste="onPaste">
3
+ <template v-for="(_, name) in $slots" #[name]="context">
4
+ <slot :name="name" v-bind="context || {}" />
5
+ </template>
6
+ </q-input>
9
7
  </template>
10
8
 
11
9
  <script>
@@ -15,32 +13,32 @@ export default {
15
13
  inheritAttrs: false,
16
14
 
17
15
  props: {
16
+ error: {
17
+ type: Boolean
18
+ },
19
+
20
+ errorMessage: {
21
+ type: String,
22
+ default: ''
23
+ },
24
+
18
25
  modelValue: {
19
26
  default: '',
20
27
  type: [String, Number]
21
28
  },
22
29
 
23
- unmaskedValue: {
24
- default: true,
25
- type: Boolean
26
- },
27
-
28
30
  outlined: {
29
31
  default: true,
30
32
  type: Boolean
31
33
  },
32
34
 
33
- removeErrorOnType: {
35
+ unmaskedValue: {
36
+ default: true,
34
37
  type: Boolean
35
38
  },
36
39
 
37
- error: {
40
+ useRemoveErrorOnType: {
38
41
  type: Boolean
39
- },
40
-
41
- errorMessage: {
42
- type: String,
43
- default: ''
44
42
  }
45
43
  },
46
44
 
@@ -85,7 +83,7 @@ export default {
85
83
  },
86
84
 
87
85
  set (value) {
88
- if (this.removeErrorOnType && this.error) {
86
+ if (this.useRemoveErrorOnType && this.error) {
89
87
  this.errorData = false
90
88
  this.errorMessageData = ''
91
89
  }
@@ -97,7 +95,7 @@ export default {
97
95
 
98
96
  watch: {
99
97
  mask () {
100
- const input = this.inputReference.$el?.querySelector('input')
98
+ const input = this.getInput()
101
99
 
102
100
  requestAnimationFrame(() => {
103
101
  input.selectionStart = input.value ? input.value.length : ''
@@ -131,12 +129,30 @@ export default {
131
129
  },
132
130
 
133
131
  toggleMask (first, second) {
132
+ if (!this.modelValue?.length) return
133
+
134
134
  const length = first.split('#').length - 2
135
135
  return this.modelValue?.length > length ? second : first
136
136
  },
137
137
 
138
138
  validate (value) {
139
139
  return this.inputReference.validate(value)
140
+ },
141
+
142
+ onPaste (event) {
143
+ if (!this.mask) return
144
+
145
+ const value = event.clipboardData.getData('text')
146
+ const input = this.getInput()
147
+
148
+ requestAnimationFrame(() => {
149
+ this.$emit('update:modelValue', value)
150
+ input.selectionStart = input.value ? input.value.length : ''
151
+ })
152
+ },
153
+
154
+ getInput () {
155
+ return this.inputReference.$el?.querySelector('input')
140
156
  }
141
157
  }
142
158
  }
@@ -26,7 +26,7 @@ props:
26
26
  default: true
27
27
  type: Boolean
28
28
 
29
- remove-error-on-type:
29
+ use-remove-error-on-type:
30
30
  desc: Limpa os erros do campo caso os mesmos existam toda vez que o model atualiza.
31
31
  type: Boolean
32
32
 
@@ -71,6 +71,10 @@ export default {
71
71
  }
72
72
  },
73
73
 
74
+ mounted () {
75
+ this.menuDrawer = !this.$qas.screen.untilMedium
76
+ },
77
+
74
78
  methods: {
75
79
  toggleMenuDrawer () {
76
80
  this.menuDrawer = !this.menuDrawer
@@ -1,15 +1,15 @@
1
1
  <template>
2
2
  <div class="qas-list-items shadow-14">
3
3
  <q-list bordered class="rounded-borders" separator>
4
- <q-item v-for="(item, index) in list" :key="index" v-ripple :clickable="!redirectOnIcon" :to="redirect(item)">
4
+ <q-item v-for="(item, index) in list" :key="index" v-ripple :clickable="useClickableItem" @click="onClick({ item, index }, true)">
5
5
  <slot :index="index" :item="item" name="item">
6
6
  <q-item-section>
7
- <slot :index="index" :item="item" name="item-section-left" />
7
+ <slot :index="index" :item="item" name="item-section" />
8
8
  </q-item-section>
9
9
 
10
10
  <q-item-section v-if="useSectionActions" side>
11
11
  <slot :index="index" :item="item" name="item-section-side">
12
- <qas-btn flat round :to="getRedirectPayload(item)">
12
+ <qas-btn flat round @click="onClick({ item, index })">
13
13
  <q-icon v-bind="iconProps" />
14
14
  </qas-btn>
15
15
  </slot>
@@ -41,37 +41,29 @@ export default {
41
41
  type: Array
42
42
  },
43
43
 
44
- redirectKey: {
45
- default: 'uuid',
46
- type: String
47
- },
48
-
49
- redirectOnIcon: {
50
- default: true,
44
+ useClickableItem: {
51
45
  type: Boolean
52
46
  },
53
47
 
54
- to: {
55
- default: () => ({}),
56
- type: Object
57
- },
58
-
59
48
  useSectionActions: {
60
49
  default: true,
61
50
  type: Boolean
62
51
  }
63
52
  },
64
53
 
54
+ emits: ['click-item'],
55
+
65
56
  methods: {
66
- getRedirectPayload (item) {
67
- return {
68
- params: { [this.redirectKey]: item[this.redirectKey] },
69
- ...this.to
70
- }
71
- },
57
+ onClick ({ item, index }, fromItem) {
58
+ /**
59
+ * se o click veio do q-item e "useClickableItem" for "false", ou
60
+ * se o click não veio do q-item e "useClickableItem" for "true", então retorna sem emitir.
61
+ */
62
+ if (
63
+ (fromItem && !this.useClickableItem) || (!fromItem && this.useClickableItem)
64
+ ) return
72
65
 
73
- redirect (item) {
74
- return this.redirectOnIcon ? undefined : this.getRedirectPayload(item)
66
+ this.$emit('click-item', { item, index })
75
67
  }
76
68
  }
77
69
  }
@@ -14,29 +14,17 @@ props:
14
14
  default: []
15
15
  type: Array
16
16
 
17
- redirect-key:
18
- desc: Você pode enviar qualquer chave/valor dentro do array de objeto da prop "list", esta prop serve para você identificar qual vai ser a chave que vai redirecionar ao clicar no botão.
19
- default: uuid
20
- type: String
21
-
22
- redirect-on-icon:
23
- desc: Controla se o redirecionamento vai acontecer quando clicar no item inteiro ou somente no icon.
24
- default: true
17
+ use-clickable-item:
18
+ desc: Controla se o item inteiro é clicável ou somente o button dentro do item.
25
19
  type: Boolean
26
20
 
27
- to:
28
- desc: Configuração passada para o vue-router.
29
- default: {}
30
- type: Object
31
- examples: ["{ name: 'Root' }"]
32
-
33
21
  use-section-actions:
34
22
  desc: Controla se exibe ou não seção de actions, onde fica o Ícone de redirecionamento.
35
23
  default: true
36
24
  type: Boolean
37
25
 
38
26
  slots:
39
- item-section-left:
27
+ item-section:
40
28
  desc: Slot para acessar seção da esquerda.
41
29
  scope:
42
30
  item:
@@ -55,3 +43,14 @@ slots:
55
43
  index:
56
44
  desc: Posição do item na lista.
57
45
  type: Number
46
+
47
+ events:
48
+ '@click-item -> function ({ item, index })':
49
+ desc: Dispara toda vez que o item ou button (dependendo da prop "use-section-actions") é clicado.
50
+ params:
51
+ item:
52
+ desc: Item clicado
53
+ type: Object
54
+ index:
55
+ desc: Posição do item
56
+ type: Number