@bildvitta/quasar-ui-asteroid 3.20.0-beta.18-alpha.0 → 3.20.0-beta.19

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.18-alpha.0",
4
+ "version": "3.20.0-beta.19",
5
5
  "author": "Bild & Vitta <systemteam@bild.com.br>",
6
6
  "license": "MIT",
7
7
  "main": "./src/asteroid.js",
@@ -1280,10 +1280,7 @@ async function updatePosition ({ newHeaderKey, oldHeaderKey, itemId, event, opti
1280
1280
  : `${props.updatePositionUrl}/${itemId}/update-position`
1281
1281
 
1282
1282
  const { data, error } = await promiseHandler(
1283
- axios.patch(url, params, {
1284
- adapter: 'fetch',
1285
- fetchOptions: { priority: 'low' }
1286
- }),
1283
+ axios.patch(url, params),
1287
1284
  {
1288
1285
  errorMessage: 'Ocorreu um erro ao atualizar a posição de seu item.',
1289
1286
  useLoading: false,
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <q-dialog ref="dialogRef" v-model="model" class="qas-dialog" :class="classes" data-cy="dialog" v-bind="dialogProps">
3
- <div class="bg-white full-width q-pa-md qas-dialog__container" :style="containerStyles">
3
+ <div class="bg-white full-width q-pa-md qas-dialog__container">
4
4
  <header v-if="hasHeaderSlot" class="q-mb-md">
5
5
  <slot name="header" />
6
6
  </header>
@@ -38,7 +38,7 @@ import QasHeader from '../header/QasHeader.vue'
38
38
  import { computed, ref, useAttrs, provide, useSlots, inject } from 'vue'
39
39
  import { useDialogPluginComponent, QForm } from 'quasar'
40
40
 
41
- defineOptions({ name: 'QasDialog' })
41
+ defineOptions({ name: 'QasDialog', inheritAttrs: false })
42
42
 
43
43
  const props = defineProps({
44
44
  badges: {
@@ -128,11 +128,11 @@ const emit = defineEmits([
128
128
  const model = defineModel({ type: Boolean })
129
129
 
130
130
  // globals
131
+ const drawerProps = inject('drawerProps', null)
132
+
131
133
  provide('isDialog', true)
132
134
  provide('btnPropsDefaults', { size: 'md' }) // define o tamanho padrão para os botões dentro do dialog
133
-
134
- // necessário para pegar as props default do dialog quando usado no QasDrawer
135
- const defaultProps = inject('dialogDefaultProps', null)
135
+ provide('drawerProps', null) // quebra a cadeia para dialogs filhos usarem hasActions normalmente
136
136
 
137
137
  // refs
138
138
  const form = ref(null)
@@ -146,11 +146,6 @@ const { defaultOk, hasOk, onOk } = useOk()
146
146
  const { descriptionComponent, mainComponent } = useDynamicComponents()
147
147
 
148
148
  // computeds
149
- /**
150
- * Necessária logica via provide para controle interno no componente QasDrawer.
151
- */
152
- const hasDefaultMaxWidth = computed(() => !!defaultProps?.value.maxWidth)
153
-
154
149
  /**
155
150
  * Classes criadas para serem utilizadas quando usado com a prop "position", pois
156
151
  * o comportamento do dialog muda, e não é possível usar em conjunto com a prop
@@ -168,32 +163,27 @@ const classes = computed(() => {
168
163
  }
169
164
 
170
165
  return [
166
+ sizes[props.size],
167
+
171
168
  {
172
- [sizes[props.size]]: !hasDefaultMaxWidth.value,
173
169
  'qas-dialog--right': isRightPosition,
174
170
  'qas-dialog--left': isLeftPosition
175
171
  }
176
172
  ]
177
173
  })
178
174
 
179
- /**
180
- * TODO-ISSUE: Manter dessa forma até issue #1431 ser resolvida.
181
- */
182
- const containerStyles = computed(() => {
183
- if (!hasDefaultMaxWidth.value) return
184
-
185
- return {
186
- maxWidth: defaultProps?.value?.maxWidth
187
- }
188
- })
189
-
190
175
  const dialogProps = computed(() => {
191
176
  const { title, ...attributes } = attrs
192
177
 
193
178
  return {
194
179
  ...(!props.usePlugin && { modelValue: props.modelValue }),
195
180
  ...attributes,
196
- persistent: defaultProps?.value?.persistent ?? hasActions.value,
181
+
182
+ /**
183
+ * valida se a prop "persistent" foi passada para o drawer, caso tenha passado,
184
+ * ele respeita a prop, caso contrário é validado se tem ações para ser persistente ou não.
185
+ */
186
+ persistent: drawerProps?.value ? drawerProps?.value.persistent : hasActions.value,
197
187
 
198
188
  onHide: onDialogHide
199
189
  }
@@ -263,7 +253,7 @@ function useOk () {
263
253
  }
264
254
  })
265
255
 
266
- const hasOk = computed(() => typeof props.ok === 'boolean' ? props.ok : !!Object.keys(props.ok))
256
+ const hasOk = computed(() => typeof props.ok === 'boolean' ? props.ok : !!Object.keys(props.ok)?.length)
267
257
 
268
258
  // functions
269
259
  function onOk () {
@@ -296,7 +286,7 @@ function useCancel () {
296
286
  }
297
287
  })
298
288
 
299
- const hasCancel = computed(() => typeof props.cancel === 'boolean' ? props.cancel : !!Object.keys(props.cancel))
289
+ const hasCancel = computed(() => typeof props.cancel === 'boolean' ? props.cancel : !!Object.keys(props.cancel)?.length)
300
290
 
301
291
  // functions
302
292
  function onCancel () {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <qas-dialog v-model="model" class="qas-drawer" v-bind="attributes">
2
+ <qas-dialog v-model="model" class="qas-drawer" :class="containerDialogClasses" v-bind="attributes">
3
3
  <template #header>
4
4
  <slot name="header">
5
5
  <div class="items-center justify-between row">
@@ -17,12 +17,12 @@
17
17
  </template>
18
18
 
19
19
  <template #description>
20
- <div>
21
- <div class="relative-position" data-cy="drawer-default">
20
+ <div class="relative-position">
21
+ <div data-cy="drawer-default">
22
22
  <slot />
23
23
  </div>
24
24
 
25
- <div v-if="props.loading" class="qas-drawer__loading" :style="loadingStyle">
25
+ <div v-if="props.loading" class="qas-drawer__loading">
26
26
  <div class="full-height relative-position">
27
27
  <q-inner-loading :showing="props.loading">
28
28
  <q-spinner color="grey" size="2em" />
@@ -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, provide } from 'vue'
43
+ import { computed, inject, provide } from 'vue'
44
44
 
45
45
  defineOptions({
46
46
  name: 'QasDrawer',
@@ -53,11 +53,6 @@ const props = defineProps({
53
53
  default: () => ({})
54
54
  },
55
55
 
56
- maxWidth: {
57
- type: String,
58
- default: '60%'
59
- },
60
-
61
56
  persistent: {
62
57
  type: Boolean
63
58
  },
@@ -75,9 +70,20 @@ const props = defineProps({
75
70
 
76
71
  loading: {
77
72
  type: Boolean
73
+ },
74
+
75
+ size: {
76
+ type: String,
77
+ default: 'sm',
78
+ validator: value => !value || ['sm', 'md', 'lg', 'xl'].includes(value)
78
79
  }
79
80
  })
80
81
 
82
+ // globals
83
+ const isOverlay = inject('isOverlay', false)
84
+
85
+ provide('drawerProps', computed(() => ({ persistent: props.persistent })))
86
+
81
87
  // emits
82
88
  const model = defineModel({ type: Boolean })
83
89
 
@@ -85,12 +91,18 @@ const model = defineModel({ type: Boolean })
85
91
  const screen = useScreen()
86
92
 
87
93
  // computed
88
- const normalizedMaxWidth = computed(() => screen.isSmall ? '95%' : props.maxWidth)
89
-
90
- const loadingStyle = computed(() => {
91
- return {
92
- right: `calc(100% - ${normalizedMaxWidth.value})`
93
- }
94
+ const containerDialogClasses = computed(() => {
95
+ // tratamento para mobile, onde sempre pegará 95% da tela.
96
+ if (screen.isSmall) return 'qas-drawer--mobile'
97
+
98
+ /**
99
+ * no caso de ter passado a prop lg ou xl, mas o tamanho da tela ser médio,
100
+ * o drawer irá se comportar como md, pegando 512px de largura, caso contrário, teria o problema
101
+ * do drawer acabar pegando 100% da página, tendo o comportamento errado.
102
+ */
103
+ if (screen.isMedium && (props.size === 'lg' || props.size === 'xl')) return 'qas-drawer--md'
104
+
105
+ return isOverlay ? 'qas-drawer--overlay' : `qas-drawer--${props.size}`
94
106
  })
95
107
 
96
108
  const attributes = computed(() => {
@@ -101,20 +113,10 @@ const attributes = computed(() => {
101
113
  cancel: false,
102
114
  maximized: true,
103
115
  ok: false,
104
- position: props.position
105
- }
106
- })
107
-
108
- // globals
109
- /**
110
- * Manter dessa forma até issue #1431 ser resolvida.
111
- */
112
- provide('dialogDefaultProps', computed(() => {
113
- return {
114
- maxWidth: normalizedMaxWidth.value,
116
+ position: props.position,
115
117
  persistent: props.persistent
116
118
  }
117
- }))
119
+ })
118
120
 
119
121
  // functions
120
122
  function close () {
@@ -129,6 +131,43 @@ function close () {
129
131
  left: 0;
130
132
  position: absolute;
131
133
  top: 0;
134
+ width: 100%;
135
+ }
136
+
137
+ &--mobile {
138
+ .qas-dialog__container {
139
+ max-width: 95% !important;
140
+ }
141
+ }
142
+
143
+ &--overlay {
144
+ .qas-dialog__container {
145
+ max-width: 90% !important;
146
+ }
147
+ }
148
+
149
+ &--sm {
150
+ .qas-dialog__container {
151
+ max-width: 368px !important;
152
+ }
153
+ }
154
+
155
+ &--md {
156
+ .qas-dialog__container {
157
+ max-width: 512px !important;
158
+ }
159
+ }
160
+
161
+ &--lg {
162
+ .qas-dialog__container {
163
+ max-width: 656px !important;
164
+ }
165
+ }
166
+
167
+ &--xl {
168
+ .qas-dialog__container {
169
+ max-width: 960px !important;
170
+ }
132
171
  }
133
172
  }
134
173
  </style>
@@ -34,6 +34,11 @@ props:
34
34
  desc: Titulo do drawer.
35
35
  type: String
36
36
 
37
+ size:
38
+ desc: Tamanho do drawer.
39
+ default: sm
40
+ type: String
41
+
37
42
  slots:
38
43
  header:
39
44
  desc: Slot para conteúdo do cabeçalho.
@@ -91,7 +91,8 @@ const model = computed({
91
91
  const drawerProps = computed(() => {
92
92
  return {
93
93
  loading: isMarkingNotificationsAsRead.value,
94
- title: 'Notificações'
94
+ title: 'Notificações',
95
+ size: 'md'
95
96
  }
96
97
  })
97
98
 
@@ -62,7 +62,6 @@ const isForwardButtonDisabled = computed(() => !hasNextRoute.value || isDisabled
62
62
  const drawerProps = computed(() => {
63
63
  return {
64
64
  position: 'right',
65
- maxWidth: '90%',
66
65
  dialogProps: {
67
66
  class: 'pv-layout-overlay-drawer',
68
67
  onHide: closeOverlay,