@bildvitta/quasar-ui-asteroid 3.20.0-beta.13 → 3.20.0-beta.14-alpha.1

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.20.0-beta.13",
4
+ "version": "3.20.0-beta.14-alpha.1",
5
5
  "author": "Bild & Vitta <systemteam@bild.com.br>",
6
6
  "license": "MIT",
7
7
  "main": "./src/asteroid.js",
@@ -24,7 +24,7 @@
24
24
  </div>
25
25
  </div>
26
26
 
27
- <qas-dialog v-model="showConfirmDialog" v-bind="defaultConfirmDialogProps" />
27
+ <qas-dialog v-if="props.useConfirmDialog" v-model="showConfirmDialog" v-bind="defaultConfirmDialogProps" />
28
28
  </qas-grabbable>
29
29
  </template>
30
30
 
@@ -109,6 +109,10 @@ const props = defineProps({
109
109
  default: () => ({})
110
110
  },
111
111
 
112
+ useConfirmDialog: {
113
+ type: Boolean
114
+ },
115
+
112
116
  useMarkRaw: {
113
117
  type: Boolean,
114
118
  default: true
@@ -245,8 +249,6 @@ const hasColumnsLength = computed(() => !!Object.keys(columnsResultsModel.value)
245
249
 
246
250
  const containerStyle = computed(() => `width: ${props.columnWidth};`)
247
251
 
248
- const hasConfirmDialogProps = computed(() => !!Object.keys(props.confirmDialogProps).length)
249
-
250
252
  const defaultConfirmDialogProps = computed(() => {
251
253
  const defaultProps = {
252
254
  ok: {
@@ -572,7 +574,7 @@ function onDropCard (event) {
572
574
  return
573
575
  }
574
576
 
575
- hasConfirmDialogProps.value
577
+ props.useConfirmDialog
576
578
  ? openConfirmDialog()
577
579
  : confirmDrop(event)
578
580
  }
@@ -614,7 +616,7 @@ function cancelDrop (event) {
614
616
  event.from.insertBefore(event.item, insertBeforeElement)
615
617
  }
616
618
 
617
- if (hasConfirmDialogProps.value) closeConfirmDialog()
619
+ if (props.useConfirmDialog) closeConfirmDialog()
618
620
 
619
621
  toggleIsDragging()
620
622
  }
@@ -115,6 +115,10 @@ props:
115
115
  default: "{ animation: 500, swapThreshold: 1, delay: 50, delayOnTouchOnly: true, emptyInsertThreshold: 0 }"
116
116
  debugger: true
117
117
 
118
+ use-confirm-dialog:
119
+ desc: Controla se o dialog de confirmação para o drag and drop será utilizado. Caso seja "true", o dialog é aberto utilizando as props passadas em "confirm-dialog-props" e as ações de confirmar e cancelar são feitas por padrão no componente. Caso seja "false", o drag and drop é realizado sem confirmação.
120
+ type: Boolean
121
+
118
122
  use-drag-and-drop-x:
119
123
  desc: Controla se irá ter drag and drop no eixo X (entre colunas).
120
124
  type: Boolean
@@ -0,0 +1 @@
1
+ {"version":"4.0.18","results":[[":QasCheckbox.test.js",{"duration":0,"failed":true}]]}
@@ -1,35 +1,23 @@
1
1
  <template>
2
- <q-dialog ref="dialogRef" class="qas-dialog" :class="classes" data-cy="dialog" v-bind="dialogProps" :persistent="props.persistent" @update:model-value="updateModelValue">
3
- <div class="bg-white q-pa-md" :style="style">
4
- <header v-if="hasHeader" class="q-mb-md">
5
- <slot name="header">
6
- <div class="items-center justify-between row">
7
- <qas-label data-cy="dialog-title" :label="props.card.title" margin="none" />
8
-
9
- <qas-btn v-if="isInfoDialog" v-close-popup color="grey-10" data-cy="dialog-close-btn" icon="sym_r_close" variant="tertiary" />
10
- </div>
11
- </slot>
2
+ <q-dialog ref="dialogRef" v-model="model" class="qas-dialog" :class="classes" data-cy="dialog" v-bind="dialogProps" @update:model-value="updateModelValue">
3
+ <div class="bg-white full-width q-pa-md qas-dialog__container" :style="containerStyles">
4
+ <header v-if="hasHeaderSlot" class="q-mb-md">
5
+ <slot name="header" />
12
6
  </header>
13
7
 
8
+ <qas-header v-else-if="props.title" v-bind="headerProps" />
9
+
14
10
  <section class="relative-position text-body1 text-grey-8">
15
11
  <component :is="mainComponent.is" ref="form" v-bind="mainComponent.props">
16
12
  <slot name="description">
17
- <component :is="descriptionComponent" data-cy="dialog-description">{{ props.card.description }}</component>
13
+ <div v-if="props.useHtmlDescription" data-cy="dialog-description" v-html="props.description" />
14
+
15
+ <component :is="descriptionComponent" v-else data-cy="dialog-description">
16
+ {{ props.description }}
17
+ </component>
18
18
  </slot>
19
19
 
20
- <div v-if="!isInfoDialog">
21
- <slot name="actions">
22
- <qas-actions v-bind="defaultActionsProps">
23
- <template v-if="hasOk" #primary>
24
- <qas-btn v-close-popup="!props.useForm" class="full-width" data-cy="dialog-ok-btn" size="lg" variant="primary" v-bind="defaultOk" />
25
- </template>
26
-
27
- <template v-if="hasCancel" #secondary>
28
- <qas-btn v-close-popup class="full-width" data-cy="dialog-cancel-btn" size="lg" v-bind="defaultCancel" variant="secondary" />
29
- </template>
30
- </qas-actions>
31
- </slot>
32
- </div>
20
+ <qas-actions v-if="hasActions" class="qas-dialog__actions" v-bind="defaultActionsProps" />
33
21
  </component>
34
22
  </section>
35
23
  </div>
@@ -38,23 +26,17 @@
38
26
 
39
27
  <script setup>
40
28
  import QasActions from '../actions/QasActions.vue'
41
- import QasBtn from '../btn/QasBtn.vue'
42
- import QasLabel from '../label/QasLabel.vue'
29
+ import QasHeader from '../header/QasHeader.vue'
43
30
 
44
- import useCancel from './composables/use-cancel'
45
- import useDynamicComponents from './composables/use-dynamic-components'
46
- import useOk from './composables/use-ok'
47
- import { useScreen } from '../../composables'
48
-
49
- import { computed, ref, useAttrs, useSlots, provide } from 'vue'
50
- import { useDialogPluginComponent } from 'quasar'
31
+ import { computed, ref, useAttrs, provide, useSlots, inject } from 'vue'
32
+ import { useDialogPluginComponent, QForm } from 'quasar'
51
33
 
52
34
  defineOptions({ name: 'QasDialog' })
53
35
 
54
36
  const props = defineProps({
55
- actionsProps: {
56
- default: () => ({}),
57
- type: Object
37
+ badges: {
38
+ default: () => [],
39
+ type: [Array, Object]
58
40
  },
59
41
 
60
42
  cancel: {
@@ -62,19 +44,13 @@ const props = defineProps({
62
44
  type: [Object, Boolean]
63
45
  },
64
46
 
65
- card: {
66
- default: () => ({}),
67
- type: Object
47
+ description: {
48
+ type: [String, Object],
49
+ default: ''
68
50
  },
69
51
 
70
- maxWidth: {
71
- default: '',
72
- type: String
73
- },
74
-
75
- minWidth: {
76
- default: '',
77
- type: String
52
+ disableCloseButton: {
53
+ type: Boolean
78
54
  },
79
55
 
80
56
  ok: {
@@ -82,16 +58,23 @@ const props = defineProps({
82
58
  type: [Object, Boolean]
83
59
  },
84
60
 
85
- persistent: {
86
- default: true,
87
- type: Boolean
61
+ size: {
62
+ type: String,
63
+ default: 'sm',
64
+ validator: value => ['sm', 'md', 'lg', 'xl'].includes(value)
88
65
  },
89
66
 
90
- useForm: {
91
- type: Boolean
67
+ title: {
68
+ type: String,
69
+ required: true
92
70
  },
93
71
 
94
- modelValue: {
72
+ tertiary: {
73
+ default: () => ({}),
74
+ type: Object
75
+ },
76
+
77
+ useForm: {
95
78
  type: Boolean
96
79
  },
97
80
 
@@ -99,7 +82,22 @@ const props = defineProps({
99
82
  type: Boolean
100
83
  },
101
84
 
102
- useFullMaxWidth: {
85
+ useAutoCloseOnCancel: {
86
+ type: Boolean,
87
+ default: true
88
+ },
89
+
90
+ useAutoCloseOnOk: {
91
+ type: Boolean,
92
+ default: true
93
+ },
94
+
95
+ useCloseButton: {
96
+ type: Boolean,
97
+ default: true
98
+ },
99
+
100
+ useHtmlDescription: {
103
101
  type: Boolean
104
102
  },
105
103
 
@@ -108,10 +106,8 @@ const props = defineProps({
108
106
  }
109
107
  })
110
108
 
109
+ // emtis
111
110
  const emit = defineEmits([
112
- // model
113
- 'update:modelValue',
114
-
115
111
  // actions
116
112
  'cancel',
117
113
  'ok',
@@ -121,24 +117,35 @@ const emit = defineEmits([
121
117
  ...useDialogPluginComponent.emits
122
118
  ])
123
119
 
120
+ // models
121
+ const model = defineModel({ type: Boolean })
122
+
123
+ // globals
124
124
  provide('isDialog', true)
125
+ provide('btnPropsDefaults', { size: 'md' }) // define o tamanho padrão para os botões dentro do dialog
125
126
 
126
- const attrs = useAttrs()
127
- const screen = useScreen()
128
- const slots = useSlots()
127
+ // necessário para pegar as props default do dialog quando usado no QasDrawer
128
+ const defaultProps = inject('dialogDefaultProps', null)
129
129
 
130
- // usado para o plugin
131
- const { dialogRef, onDialogHide } = useDialogPluginComponent()
130
+ // composables
131
+ const slots = useSlots()
132
+ const attrs = useAttrs()
133
+ const { dialogRef, onDialogHide } = useDialogPluginComponent() // usado para o plugin
132
134
 
133
- // QForm template
135
+ // refs
134
136
  const form = ref(null)
135
137
 
136
- const composablesParams = { emit, form, props, screen, slots }
138
+ // composables
139
+ const { defaultCancel, hasCancel } = useCancel()
140
+ const { defaultOk, hasOk, onOk } = useOk()
141
+ const { descriptionComponent, mainComponent } = useDynamicComponents()
137
142
 
138
- const { defaultCancel, hasCancel } = useCancel(composablesParams)
139
- const { defaultOk, hasOk, onOk } = useOk(composablesParams)
140
- const { descriptionComponent, mainComponent } = useDynamicComponents({ ...composablesParams, onOk, hasOk })
143
+ /**
144
+ * Necessária logica via provide para controle interno no componente QasDrawer.
145
+ */
146
+ const hasDefaultMaxWidth = computed(() => !!defaultProps?.value.maxWidth)
141
147
 
148
+ // computeds
142
149
  /**
143
150
  * Classes criadas para serem utilizadas quando usado com a prop "position", pois
144
151
  * o comportamento do dialog muda, e não é possível usar em conjunto com a prop
@@ -148,60 +155,240 @@ const classes = computed(() => {
148
155
  const isRightPosition = attrs.position === 'right'
149
156
  const isLeftPosition = attrs.position === 'left'
150
157
 
158
+ const sizes = {
159
+ sm: 'qas-dialog--sm', // 450px
160
+ md: 'qas-dialog--md', // 550px
161
+ lg: 'qas-dialog--lg', // 800px
162
+ xl: 'qas-dialog--xl' // 1100px
163
+ }
164
+
165
+ return [
166
+ {
167
+ [sizes[props.size]]: !hasDefaultMaxWidth.value,
168
+ 'qas-dialog--right': isRightPosition,
169
+ 'qas-dialog--left': isLeftPosition
170
+ }
171
+ ]
172
+ })
173
+
174
+ /**
175
+ * Manter dessa forma até issue #1431 ser resolvida.
176
+ */
177
+ const containerStyles = computed(() => {
178
+ if (!hasDefaultMaxWidth.value) return
179
+
151
180
  return {
152
- 'qas-dialog--right': isRightPosition,
153
- 'qas-dialog--left': isLeftPosition
181
+ maxWidth: defaultProps?.value?.maxWidth
154
182
  }
155
183
  })
156
184
 
157
185
  const dialogProps = computed(() => {
186
+ const { title, ...attributes } = attrs
187
+
158
188
  return {
159
189
  ...(!props.usePlugin && { modelValue: props.modelValue }),
160
- ...attrs,
190
+ ...attributes,
191
+ persistent: defaultProps?.value?.persistent ?? hasActions.value,
161
192
 
162
193
  onHide: onDialogHide
163
194
  }
164
195
  })
165
196
 
166
- const style = computed(() => {
197
+ const hasActions = computed(() => hasOk.value || hasCancel.value || !!Object.keys(props.tertiary).length)
198
+
199
+ const headerProps = computed(() => {
167
200
  return {
168
- ...(props.useFullMaxWidth && { width: '100%' }),
201
+ labelProps: {
202
+ label: props.title
203
+ },
204
+
205
+ badges: props.badges,
206
+
207
+ buttonProps: {
208
+ ...(props.useCloseButton && {
209
+ color: 'grey-10',
210
+ disable: props.disableCloseButton,
211
+ icon: 'sym_r_close',
212
+ variant: 'tertiary',
213
+ 'data-cy': 'dialog-close-btn',
214
+ onClick: () => updateModelValue(false)
215
+ })
216
+ }
217
+ }
218
+ })
219
+
220
+ const defaultActionsProps = computed(() => {
221
+ return {
222
+ ...(hasOk.value && { primaryButtonProps: defaultOk.value }),
223
+ ...(hasCancel.value && { secondaryButtonProps: defaultCancel.value }),
169
224
 
170
- maxWidth: props.maxWidth || '470px',
171
- minWidth: props.minWidth || (screen.isSmall ? '' : '366px')
225
+ tertiaryButtonProps: {
226
+ ...props.tertiary,
227
+ 'data-cy': 'dialog-tertiary-btn'
228
+ },
229
+
230
+ spacingTop: 'lg',
231
+ gutter: 'md'
172
232
  }
173
233
  })
174
234
 
175
- const hasHeader = computed(() => !!slots.header || props.card.title)
176
- const isInfoDialog = computed(() => !hasOk.value && !hasCancel.value)
235
+ const hasHeaderSlot = computed(() => !!slots.header)
177
236
 
178
- const defaultActionsProps = computed(() => {
179
- const { useFullWidth, useEqualWidth } = props.actionsProps
237
+ // functions
238
+ function updateModelValue (value) {
239
+ model.value = value
240
+ }
241
+
242
+ // composable definitions
243
+ function useOk () {
244
+ // computeds
245
+ const defaultOk = computed(() => {
246
+ const { onClick, ...attrs } = props.ok
247
+
248
+ return {
249
+ label: 'Ok',
250
+ type: (props.ok?.type || props.useForm) ? 'submit' : 'button',
251
+ 'data-cy': 'dialog-ok-btn',
252
+
253
+ ...attrs,
254
+
255
+ // adiciona somente se não estiver usando useForm pois o controle ficará no submit.
256
+ ...(!props.useForm && { onClick: onOk })
257
+ }
258
+ })
259
+
260
+ const hasOk = computed(() => typeof props.ok === 'boolean' ? props.ok : !!Object.keys(props.ok))
180
261
 
181
- if (useFullWidth || useEqualWidth) return props.actionsProps
262
+ // functions
263
+ function onOk () {
264
+ if (!props.useForm && props.useAutoCloseOnOk) {
265
+ updateModelValue(false)
266
+ }
267
+
268
+ props.ok.onClick?.()
182
269
 
183
- const hasAllActions = hasOk.value && hasCancel.value
184
- const hasSingleAction = (hasOk.value && !hasCancel.value) || (!hasOk.value && hasCancel.value)
270
+ emit('ok')
271
+ }
185
272
 
186
273
  return {
187
- useFullWidth: hasSingleAction,
188
- useEqualWidth: hasAllActions,
274
+ defaultOk,
275
+ hasOk,
276
+ onOk
277
+ }
278
+ }
279
+
280
+ function useCancel () {
281
+ // computeds
282
+ const defaultCancel = computed(() => {
283
+ return {
284
+ label: 'Cancelar',
285
+ 'data-cy': 'dialog-cancel-btn',
189
286
 
190
- ...props.actionsProps
287
+ ...props.cancel,
288
+
289
+ onClick: onCancel
290
+ }
291
+ })
292
+
293
+ const hasCancel = computed(() => typeof props.cancel === 'boolean' ? props.cancel : !!Object.keys(props.cancel))
294
+
295
+ // functions
296
+ function onCancel () {
297
+ props.cancel.onClick?.()
298
+
299
+ if (props.useAutoCloseOnAction || props.useAutoCloseOnCancel) {
300
+ updateModelValue(false)
301
+ }
302
+
303
+ emit('cancel')
191
304
  }
192
- })
193
305
 
194
- function updateModelValue (value) {
195
- emit('update:modelValue', value)
306
+ return {
307
+ defaultCancel,
308
+ hasCancel
309
+ }
310
+ }
311
+
312
+ function useDynamicComponents () {
313
+ // computeds
314
+ const mainComponent = computed(() => {
315
+ return {
316
+ is: props.useForm ? QForm : 'div',
317
+
318
+ /**
319
+ * adiciona evento de submit caso useForm seja true,
320
+ * uma vez que somente o q-form possui este evento.
321
+ */
322
+ props: {
323
+ ...(props.useForm && { onSubmit })
324
+ }
325
+ }
326
+ })
327
+
328
+ const hasRenderFunction = computed(() => {
329
+ const description = props.description
330
+
331
+ return typeof description === 'object' && description !== null && !Array.isArray(description)
332
+ })
333
+
334
+ const descriptionComponent = computed(() => hasRenderFunction.value ? props.description : 'div')
335
+
336
+ // functions
337
+ function submitHandler () {
338
+ if (!props.useForm) return
339
+
340
+ if (props.useValidationAllAtOnce) {
341
+ let isAllComponentValid = true
342
+ const components = form.value.getValidationComponents() || []
343
+
344
+ for (const component of components) {
345
+ const isValid = component?.validate?.()
346
+
347
+ if (!isValid) {
348
+ isAllComponentValid = false
349
+ }
350
+ }
351
+
352
+ emit('validate', isAllComponentValid)
353
+
354
+ return
355
+ }
356
+
357
+ emit('validate', form.value.validate())
358
+ }
359
+
360
+ /**
361
+ * Sem este método, ao clicar enter com a prop useForm ativada a tela era recarregada,
362
+ * e a ação de click do botão não era chamada pois ele não esta dentro do form.
363
+ */
364
+ function onSubmit (event) {
365
+ event.preventDefault()
366
+
367
+ if (hasOk.value) {
368
+ onOk()
369
+ submitHandler()
370
+ }
371
+ }
372
+
373
+ return {
374
+ mainComponent,
375
+ descriptionComponent
376
+ }
196
377
  }
197
378
  </script>
198
379
 
199
380
  <style lang="scss">
200
381
  .qas-dialog {
382
+ $root: &;
383
+
201
384
  .q-dialog__inner > div {
202
385
  box-shadow: $shadow-2;
203
386
  }
204
387
 
388
+ .q-dialog__inner--minimized {
389
+ padding: var(--qas-spacing-md);
390
+ }
391
+
205
392
  &--right {
206
393
  .q-dialog__inner {
207
394
  width: 100%;
@@ -214,5 +401,39 @@ function updateModelValue (value) {
214
401
  width: 100%;
215
402
  }
216
403
  }
404
+
405
+ // tamanhos
406
+ &--sm {
407
+ #{$root}__container {
408
+ max-width: 450px !important;
409
+ }
410
+ }
411
+
412
+ &--md {
413
+ #{$root}__container {
414
+ max-width: 550px !important;
415
+ }
416
+ }
417
+
418
+ &--lg {
419
+ #{$root}__container {
420
+ max-width: 800px !important;
421
+ }
422
+ }
423
+
424
+ &--xl {
425
+ #{$root}__container {
426
+ max-width: 1100px !important;
427
+ }
428
+ }
429
+
430
+ // tamanho mínimo dos botões de ação (primário e secundário)
431
+ &__actions {
432
+ .qas-btn--primary,
433
+ .qas-btn--secondary {
434
+ min-width: 120px;
435
+ width: 100%;
436
+ }
437
+ }
217
438
  }
218
439
  </style>
@@ -4,10 +4,10 @@ meta:
4
4
  desc: Componente de dialog.
5
5
 
6
6
  props:
7
- actions-props:
8
- desc: Props repassadas para o "QasActions".
9
- default: {}
10
- type: Object
7
+ badges:
8
+ desc: Badges que aparecem no canto superior direito do dialog.
9
+ type: [Array, Object]
10
+ default: []
11
11
 
12
12
  cancel:
13
13
  desc: Props para o botão de cancelar, pode ser objeto com as propriedades ou um boolean, caso for "false", remove o botão de cancelar.
@@ -15,19 +15,13 @@ props:
15
15
  type: [Object, Boolean]
16
16
  examples: ["{ label: 'Meu botão de cancelar', onClick: () => alert('fui clicado!') }"]
17
17
 
18
- card:
19
- desc: Objeto contendo as informações para serem exibidas dentro do dialog como "title" e "description".
20
- default: {}
21
- type: Object
22
- examples: ["{ title: 'Meu título', description: 'Minha descrição' }"]
23
-
24
- max-width:
25
- desc: Tamanho máximo do dialog.
26
- type: String
18
+ description:
19
+ desc: Descrição do dialog, pode ser uma string ou um componente ou uma string com HTML (passando a prop useHtmlDescription).
20
+ type: [String, Object]
27
21
 
28
- min-width:
29
- desc: Tamanho mínimo do dialog.
30
- type: String
22
+ disable-close-button:
23
+ desc: Define se o botão de fechar no canto superior direito estará desabilitado.
24
+ type: Boolean
31
25
 
32
26
  model-value:
33
27
  desc: Model do componente, abre ou fecha o dialog.
@@ -42,27 +36,49 @@ props:
42
36
  type: [Object, Boolean]
43
37
  examples: ["{ label: 'Meu botão de confirmar', onClick: () => alert('fui clicado!') }"]
44
38
 
45
- persistent:
46
- desc: Define se o dialog vai fechar ou não após clicar fora do dialog.
39
+ size:
40
+ desc: Tamanho do dialog.
41
+ type: String
42
+ default: 'md'
43
+ options: ['xs', 'sm', 'md', 'lg', 'xl']
44
+
45
+ use-auto-close-on-cancel:
46
+ desc: Define se o dialog vai fechar automaticamente ao clicar no botão de cancelar.
47
+ type: Boolean
47
48
  default: true
49
+
50
+ use-auto-close-on-ok:
51
+ desc: Define se o dialog vai fechar automaticamente ao clicar no botão de confirmar (ok).
52
+ type: Boolean
53
+ default: true
54
+
55
+ use-close-button:
56
+ desc: Define se o dialog vai ter um botão de fechar no canto superior direito.
48
57
  type: Boolean
49
58
 
50
59
  use-form:
51
60
  desc: Define se a tag onde fica a descrição no dialog vai ser um "<q-form />" ou "<div />".
52
61
  type: Boolean
53
62
 
54
- use-full-max-width:
55
- desc: propriedade para utilizar `100% do maxWidth`.
63
+ use-html-description:
64
+ desc: Define se a descrição aceita HTML (utilize com cuidado para evitar XSS).
56
65
  type: Boolean
57
66
 
58
67
  use-validation-all-at-once:
59
68
  desc: Valida todos os campos de uma única vez, ao invés de ser um por vez (que é o padrão).
60
69
  type: Boolean
61
70
 
62
- slots:
63
- actions:
64
- desc: Slot para ações (botões por exemplo).
71
+ tertiary:
72
+ desc: Props para o botão terciário
73
+ type: Object
74
+ default: {}
75
+
76
+ title:
77
+ desc: Título do dialog.
78
+ type: String
79
+ required: true
65
80
 
81
+ slots:
66
82
  description:
67
83
  desc: Slot para descrição.
68
84
 
@@ -99,6 +115,10 @@ selectors:
99
115
  desc: Seletor do botão de cancelar do componente.
100
116
  examples: ['data-cy="dialog-cancel-btn"']
101
117
 
118
+ dialog-tertiary-btn:
119
+ desc: Seletor do botão terciário do componente.
120
+ examples: ['data-cy="dialog-tertiary-btn"']
121
+
102
122
  dialog-close-btn:
103
123
  desc: Seletor do botão de fechar do componente.
104
124
  examples: ['data-cy="dialog-close-btn"']
@@ -15,7 +15,7 @@ export default function useCancel (config = {}) {
15
15
  const defaultCancel = computed(() => {
16
16
  return {
17
17
  label: 'Cancelar',
18
- outline: true,
18
+ 'data-cy': 'dialog-cancel-btn',
19
19
 
20
20
  ...props.cancel,
21
21
 
@@ -35,12 +35,12 @@ export default function useDynamicComponents (config = {}) {
35
35
  })
36
36
 
37
37
  const hasRenderFunction = computed(() => {
38
- const description = props.card.description
38
+ const description = props.description
39
39
 
40
40
  return typeof description === 'object' && description !== null && !Array.isArray(description)
41
41
  })
42
42
 
43
- const descriptionComponent = computed(() => hasRenderFunction.value ? props.card.description : 'div')
43
+ const descriptionComponent = computed(() => hasRenderFunction.value ? props.description : 'div')
44
44
 
45
45
  // métodos
46
46
  function submitHandler () {
@@ -18,6 +18,7 @@ export default function useOk (config = {}) {
18
18
  return {
19
19
  label: 'Ok',
20
20
  type: (props.ok?.type || props.useForm) ? 'submit' : 'button',
21
+ 'data-cy': 'dialog-ok-btn',
21
22
 
22
23
  ...attrs,
23
24
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <qas-dialog class="qas-drawer" v-bind="attributes" @update:model-value="onUpdateModelValue">
2
+ <qas-dialog v-model="model" class="qas-drawer" v-bind="attributes">
3
3
  <template #header>
4
4
  <slot name="header">
5
5
  <div class="items-center justify-between row">
@@ -11,7 +11,7 @@
11
11
  </slot>
12
12
  </span>
13
13
 
14
- <qas-btn v-close-popup class="z-max" color="grey-10" data-cy="drawer-close-btn" icon="sym_r_close" variant="tertiary" @click="emit('update:modelValue', false)" />
14
+ <qas-btn class="z-max" color="grey-10" data-cy="drawer-close-btn" icon="sym_r_close" variant="tertiary" @click="close" />
15
15
  </div>
16
16
  </slot>
17
17
  </template>
@@ -40,7 +40,7 @@ import QasBtn from '../btn/QasBtn.vue'
40
40
 
41
41
  import useScreen from '../../composables/use-screen.js'
42
42
 
43
- import { computed, useAttrs } from 'vue'
43
+ import { computed, provide } from 'vue'
44
44
 
45
45
  defineOptions({
46
46
  name: 'QasDrawer',
@@ -58,6 +58,10 @@ const props = defineProps({
58
58
  default: '60%'
59
59
  },
60
60
 
61
+ persistent: {
62
+ type: Boolean
63
+ },
64
+
61
65
  position: {
62
66
  type: String,
63
67
  default: 'left',
@@ -74,9 +78,10 @@ const props = defineProps({
74
78
  }
75
79
  })
76
80
 
77
- const emit = defineEmits(['update:modelValue'])
81
+ // emits
82
+ const model = defineModel({ type: Boolean })
78
83
 
79
- const attrs = useAttrs()
84
+ // composables
80
85
  const screen = useScreen()
81
86
 
82
87
  // computed
@@ -89,25 +94,31 @@ const loadingStyle = computed(() => {
89
94
  })
90
95
 
91
96
  const attributes = computed(() => {
92
- const { modelValue } = attrs
93
-
94
97
  return {
95
- persistent: false,
96
- modelValue,
97
-
98
98
  ...props.dialogProps,
99
99
 
100
+ title: props.title,
100
101
  cancel: false,
101
- maxWidth: normalizedMaxWidth.value,
102
102
  maximized: true,
103
103
  ok: false,
104
- position: props.position,
105
- useFullMaxWidth: true
104
+ position: props.position
106
105
  }
107
106
  })
108
107
 
109
- function onUpdateModelValue (value) {
110
- emit('update:modelValue', value)
108
+ // globals
109
+ /**
110
+ * Manter dessa forma até issue #1431 ser resolvida.
111
+ */
112
+ provide('dialogDefaultProps', computed(() => {
113
+ return {
114
+ maxWidth: normalizedMaxWidth.value,
115
+ persistent: props.persistent
116
+ }
117
+ }))
118
+
119
+ // functions
120
+ function close () {
121
+ model.value = false
111
122
  }
112
123
  </script>
113
124
 
@@ -20,6 +20,11 @@ props:
20
20
  examples: [v-model="value"]
21
21
  model: true
22
22
 
23
+ persistent:
24
+ desc: Define se o drawer pode ser fechado clicando fora dele ou pressionando a tecla ESC.
25
+ default: false
26
+ type: Boolean
27
+
23
28
  position:
24
29
  desc: 'Posição do drawer, sendo possível apenas 2 opções: [left, right].'
25
30
  default: left
@@ -190,9 +190,9 @@ export default {
190
190
  ignoreRouterGuard: false,
191
191
 
192
192
  defaultDialogProps: {
193
- card: {
194
- description: 'Você está deixando a página e suas alterações serão perdidas. Tem certeza que deseja sair sem salvar?'
195
- },
193
+ title: 'Alterações não salvas',
194
+ description: 'Você está deixando a página e suas alterações serão perdidas. Tem certeza que deseja sair sem salvar?',
195
+ size: 'md',
196
196
 
197
197
  ok: { label: 'Continuar editando' },
198
198
 
@@ -28,9 +28,8 @@ export default function useDelete ({ props, destroyFn, emit }) {
28
28
 
29
29
  const defaultDialogProps = computed(() => {
30
30
  return {
31
- card: {
32
- description: 'Tem certeza que deseja excluir este item?'
33
- },
31
+ title: 'Excluir',
32
+ description: 'Tem certeza que deseja excluir este item?',
34
33
 
35
34
  ok: {
36
35
  label: 'Excluir',
@@ -1,12 +1,6 @@
1
1
  <template>
2
2
  <div class="pv-gallery-carousel-dialog">
3
- <qas-dialog v-model="model" :cancel="false" class="q-pa-xl" max-width="1100px" :ok="false" :persistent="false" use-full-max-width>
4
- <template #header>
5
- <div class="text-right">
6
- <qas-btn v-close-popup color="grey-10" icon="sym_r_close" variant="tertiary" @click="close" />
7
- </div>
8
- </template>
9
-
3
+ <qas-dialog v-model="model" v-bind="dialogProps">
10
4
  <template #description>
11
5
  <q-carousel v-model="imageIndexModel" animated :arrows="!screen.isSmall" class="pv-gallery-carousel-dialog__carousel" control-text-color="primary" data-cy="gallery-carousel" :fullscreen="screen.isSmall" :height="carouselImageHeight" next-icon="sym_r_chevron_right" prev-icon="sym_r_chevron_left" swipeable :thumbnails="!isSingleImage">
12
6
  <q-carousel-slide v-for="(image, index) in props.images" :key="index" class="bg-no-repeat bg-size-contain" :data-cy="`gallery-carousel-slide-${index}`" :img-src="image.url" :name="index">
@@ -52,6 +46,13 @@ const screen = useScreen()
52
46
 
53
47
  const carouselImageHeight = 'calc((500/976) * 100vh)'
54
48
 
49
+ const dialogProps = {
50
+ cancel: false,
51
+ ok: false,
52
+ size: 'xl',
53
+ title: 'Galeria de imagens'
54
+ }
55
+
55
56
  const model = computed({
56
57
  get () {
57
58
  return props.modelValue
@@ -0,0 +1 @@
1
+ {"version":"4.0.18","results":[[":QasGridItem.test.js",{"duration":0,"failed":true}]]}
@@ -15,7 +15,7 @@
15
15
  </slot>
16
16
 
17
17
  <div v-if="hasBadges" class="col-auto items-center q-col-gutter-sm row">
18
- <div v-for="(badge, badgeIndex) in props.badges" :key="badgeIndex">
18
+ <div v-for="(badge, badgeIndex) in normalizedBadges" :key="badgeIndex">
19
19
  <qas-skeleton v-if="props.skeleton" type="QasBadge" />
20
20
 
21
21
  <qas-badge v-else v-bind="badge" />
@@ -73,7 +73,7 @@ const props = defineProps({
73
73
  },
74
74
 
75
75
  badges: {
76
- type: Array,
76
+ type: [Array, Object],
77
77
  default: () => []
78
78
  },
79
79
 
@@ -203,13 +203,15 @@ const actionsComponent = computed(() => {
203
203
  return component.true
204
204
  })
205
205
 
206
+ const normalizedBadges = computed(() => Array.isArray(props.badges) ? props.badges : [props.badges])
207
+
206
208
  const hasActionsComponent = computed(() => {
207
209
  return hasDefaultButton.value || hasDefaultActionsMenu.value || hasDefaultFilters.value
208
210
  })
209
211
 
210
212
  const hasActionsSection = computed(() => !!slots.actions || hasActionsComponent.value)
211
213
 
212
- const hasBadges = computed(() => !!props.badges.length)
214
+ const hasBadges = computed(() => !!normalizedBadges.value.length)
213
215
  const hasLabel = computed(() => !!Object.keys(props.labelProps).length)
214
216
  const hasDefaultButton = computed(() => !!Object.keys(props.buttonProps).length)
215
217
  const hasDefaultFilters = computed(() => !!Object.keys(props.filtersProps).length)
@@ -12,7 +12,7 @@ props:
12
12
  badges:
13
13
  desc: Adiciona badges ao lado do titulo (QasLabel), caso não tenha titulo fica somente as bages acima da descrição.
14
14
  default: []
15
- type: Array
15
+ type: [Array, Object]
16
16
 
17
17
  button-props:
18
18
  desc: Propriedades do QasBtn.
@@ -52,7 +52,7 @@
52
52
 
53
53
  <template #description>
54
54
  <slot name="dialog-description">
55
- <div v-if="dialogDescription" class="q-mb-xl text-center">
55
+ <div v-if="dialogDescription" class="q-mb-md">
56
56
  {{ dialogDescription }}
57
57
  </div>
58
58
 
@@ -325,8 +325,8 @@ function useSelectDialog () {
325
325
 
326
326
  const defaultDialogProps = computed(() => {
327
327
  return {
328
- useFullMaxWidth: true,
329
-
328
+ size: 'md',
329
+ title: 'Adicionar itens',
330
330
  ...props.dialogProps,
331
331
 
332
332
  onBeforeShow: event => {
@@ -3,12 +3,8 @@
3
3
  <qas-uploader ref="uploader" v-model="model" :add-button-fn="openDialog" :use-resize="false" v-bind="defaultUploaderProps" />
4
4
 
5
5
  <qas-dialog v-model="isOpenedDialog" v-bind="defaultDialogProps">
6
- <template #header>
7
- <div class="text-bold text-center">Insira sua assinatura digital no campo abaixo</div>
8
- </template>
9
-
10
6
  <template #description>
11
- <div :style="signaturePadWidth">
7
+ <div>
12
8
  <qas-signature-pad ref="signaturePadModal" v-model:empty="isEmpty" :height="signaturePadHeight" />
13
9
  </div>
14
10
  </template>
@@ -82,10 +78,11 @@ export default {
82
78
 
83
79
  defaultDialogProps () {
84
80
  return {
85
- maxWidth: '620px',
81
+ title: 'Assinatura digital',
82
+ size: 'md',
86
83
  ...this.dialogProps,
87
84
  ok: {
88
- label: 'Salvar',
85
+ label: 'Assinar',
89
86
  onClick: () => this.getSignatureData()
90
87
  }
91
88
  }
@@ -111,16 +108,6 @@ export default {
111
108
  return sizes.true
112
109
  },
113
110
 
114
- signaturePadWidth () {
115
- const sizes = {
116
- [this.$qas.screen.isSmall]: { width: '100%' },
117
- [this.$qas.screen.isMedium]: { width: '570px' },
118
- [this.$qas.screen.isLarge]: { width: '350px' }
119
- }
120
-
121
- return sizes.true
122
- },
123
-
124
111
  uploaderScope () {
125
112
  return this.$refs?.uploader?.uploader
126
113
  }
@@ -19,7 +19,7 @@
19
19
  <qas-btn v-if="hasButton" class="q-ml-xs" :label="buttonLabel" @click.stop.prevent="toggle" />
20
20
  </div>
21
21
 
22
- <qas-dialog v-model="show" v-bind="defaultProps" aria-label="Diálogo de texto completo" role="dialog">
22
+ <qas-dialog v-model="show" v-bind="defaultProps" aria-label="Diálogo de texto completo" role="dialog" size="md">
23
23
  <template v-if="showDescriptionSlot" #description>
24
24
  <component :is="dialogComponent.is" v-bind="dialogComponent.props" v-model:results="searchModel">
25
25
  <q-list separator>
@@ -225,10 +225,8 @@ function useDialog ({ props, textContent }) {
225
225
 
226
226
  ...props.dialogProps,
227
227
 
228
- card: {
229
- title: props.dialogTitle,
230
- description: description.value
231
- }
228
+ title: props.dialogTitle,
229
+ description: description.value
232
230
  }
233
231
  })
234
232
 
@@ -186,9 +186,9 @@ export default {
186
186
 
187
187
  destroyDialogConfig () {
188
188
  return {
189
- card: {
190
- description: 'Todas as informações serão perdidas. Deseja realmente continuar?'
191
- },
189
+ title: 'Excluir',
190
+ description: 'Todas as informações serão perdidas. Deseja realmente continuar?',
191
+ size: 'md',
192
192
  ok: {
193
193
  label: 'Excluir',
194
194
  onClick: this.destroy
@@ -201,9 +201,7 @@ export default {
201
201
 
202
202
  formDialogConfig () {
203
203
  return {
204
- card: {
205
- title: this.isAdd ? 'Adicionar ramo' : 'Editar ramo'
206
- },
204
+ title: this.isAdd ? 'Adicionar ramo' : 'Editar ramo',
207
205
  ok: {
208
206
  label: 'Salvar',
209
207
  loading: this.isSubmitting
@@ -317,7 +317,17 @@ export default {
317
317
  } = this.$props
318
318
 
319
319
  return {
320
- dialogProps,
320
+ dialogProps: {
321
+ title: 'Editar arquivo',
322
+
323
+ ok: {
324
+ label: 'Salvar',
325
+ ...dialogProps.ok
326
+ },
327
+
328
+ ...dialogProps
329
+ },
330
+
321
331
  fields,
322
332
  formGeneratorProps,
323
333
  galleryCardProps,
@@ -23,14 +23,10 @@ export default function (config = {}) {
23
23
  const defaultDialogProps = {
24
24
  useForm: true,
25
25
 
26
- ...dialogProps,
27
-
28
- card: {
29
- title: 'Excluir',
30
- description: 'Tem certeza que deseja excluir este item?',
26
+ title: 'Excluir',
27
+ description: 'Tem certeza que deseja excluir este item?',
31
28
 
32
- ...dialogProps.card
33
- },
29
+ ...dialogProps,
34
30
 
35
31
  ok: {
36
32
  label: 'Excluir',