@bildvitta/quasar-ui-asteroid 3.14.0-beta.0 → 3.14.0-beta.2

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 (51) hide show
  1. package/package.json +1 -1
  2. package/src/components/actions-menu/QasActionsMenu.vue +16 -14
  3. package/src/components/alert/QasAlert.vue +1 -1
  4. package/src/components/app-bar/QasAppBar.vue +5 -5
  5. package/src/components/app-menu/QasAppMenu.vue +8 -8
  6. package/src/components/app-menu/private/PvAppMenuDropdown.vue +1 -1
  7. package/src/components/app-user/QasAppUser.vue +10 -10
  8. package/src/components/avatar/QasAvatar.vue +2 -2
  9. package/src/components/breakline/QasBreakline.vue +5 -6
  10. package/src/components/btn-dropdown/QasBtnDropdown.vue +74 -95
  11. package/src/components/card/QasCard.vue +55 -73
  12. package/src/components/chart-view/QasChartView.vue +37 -9
  13. package/src/components/chart-view/QasChartView.yml +6 -0
  14. package/src/components/checkbox-group/QasCheckboxGroup.vue +81 -92
  15. package/src/components/copy/QasCopy.vue +20 -27
  16. package/src/components/date/QasDate.vue +316 -355
  17. package/src/components/date/QasDate.yml +0 -5
  18. package/src/components/date/enums/DateMaskOptions.js +6 -0
  19. package/src/components/date-time-input/QasDateTimeInput.vue +198 -209
  20. package/src/components/debugger/QasDebugger.vue +20 -12
  21. package/src/components/delete/QasDelete.vue +70 -80
  22. package/src/components/dialog/QasDialog.vue +7 -7
  23. package/src/components/dialog/composables/use-cancel.js +3 -3
  24. package/src/components/dialog/composables/use-dynamic-components.js +4 -4
  25. package/src/components/dialog/composables/use-ok.js +3 -3
  26. package/src/components/dialog-router/QasDialogRouter.vue +68 -67
  27. package/src/components/empty-result-text/QasEmptyResultText.vue +8 -10
  28. package/src/components/form-generator/QasFormGenerator.vue +2 -2
  29. package/src/components/gallery/QasGallery.vue +175 -196
  30. package/src/components/gallery/composables/use-delete.js +54 -0
  31. package/src/components/gallery/private/PvGalleryCarouselDialog.vue +48 -55
  32. package/src/components/gallery/private/PvGalleryDeleteDialog.vue +41 -50
  33. package/src/components/gallery-card/QasGalleryCard.vue +90 -103
  34. package/src/components/grid-generator/QasGridGenerator.vue +2 -2
  35. package/src/components/header-actions/QasHeaderActions.vue +35 -50
  36. package/src/components/header-actions/QasHeaderActions.yml +1 -1
  37. package/src/components/infinite-scroll/QasInfiniteScroll.vue +2 -2
  38. package/src/components/label/QasLabel.vue +42 -54
  39. package/src/components/list-items/QasListItems.vue +32 -41
  40. package/src/components/map/QasMap.vue +44 -46
  41. package/src/components/numeric-input/QasNumericInput.vue +2 -2
  42. package/src/components/page-header/QasPageHeader.vue +74 -87
  43. package/src/components/pagination/QasPagination.vue +21 -21
  44. package/src/components/select-list-dialog/QasSelectListDialog.vue +4 -2
  45. package/src/components/tabs-generator/QasTabsGenerator.vue +55 -63
  46. package/src/components/timeline/QasTimeline.vue +1 -1
  47. package/src/components/uploader/private/PvUploaderGalleryCard.vue +1 -1
  48. package/src/components/whatsapp-link/QasWhatsappLink.vue +34 -0
  49. package/src/components/whatsapp-link/QasWhatsappLink.yml +18 -0
  50. package/src/composables/private/use-generator.js +0 -8
  51. package/src/vue-plugin.js +7 -1
@@ -2,8 +2,8 @@
2
2
  <div class="qas-gallery">
3
3
  <div class="q-col-gutter-md row">
4
4
  <div v-for="(image, index) in getInitialImages()" :key="index" :class="galleryColumnsClasses" :data-cy="`gallery-image-${index}`">
5
- <qas-gallery-card v-bind="getGalleryCardProps({ image, index })">
6
- <template v-for="(_, name) in $slots" #[name]="context">
5
+ <qas-gallery-card :key="galleryCardCountToReRender" v-bind="getGalleryCardProps({ image, index })">
6
+ <template v-for="(_, name) in slots" #[name]="context">
7
7
  <slot v-bind="context" :image="image" :index="index" :name="name" />
8
8
  </template>
9
9
  </qas-gallery-card>
@@ -11,7 +11,7 @@
11
11
 
12
12
  <slot>
13
13
  <div v-if="!hideShowMore" class="full-width text-center">
14
- <qas-btn color="primary" data-cy="gallery-btn-show-more" :label="showMoreLabel" variant="tertiary" @click="showMore" />
14
+ <qas-btn color="primary" data-cy="gallery-btn-show-more" :label="props.showMoreLabel" variant="tertiary" @click="showMore" />
15
15
  </div>
16
16
  </slot>
17
17
 
@@ -22,243 +22,222 @@
22
22
  </div>
23
23
  </template>
24
24
 
25
- <script>
26
- import QasBtn from '../btn/QasBtn.vue'
27
- import PvGalleryDeleteDialog from './private/PvGalleryDeleteDialog.vue'
25
+ <script setup>
28
26
  import PvGalleryCarouselDialog from './private/PvGalleryCarouselDialog.vue'
29
- import { extend } from 'quasar'
30
- import { deleteMixin } from '../../mixins'
31
-
32
- export default {
33
- name: 'QasGallery',
34
-
35
- components: {
36
- PvGalleryCarouselDialog,
37
- PvGalleryDeleteDialog,
38
- QasBtn
39
- },
40
-
41
- mixins: [deleteMixin],
42
-
43
- props: {
44
- carouselNextIcon: {
45
- type: String,
46
- default: 'sym_r_chevron_right'
47
- },
27
+ import PvGalleryDeleteDialog from './private/PvGalleryDeleteDialog.vue'
28
+ import QasBtn from '../btn/QasBtn.vue'
48
29
 
49
- carouselPreviousIcon: {
50
- type: String,
51
- default: 'sym_r_chevron_left'
52
- },
30
+ import { baseProps } from './composables/use-delete'
31
+ import { useScreen } from '../../composables'
53
32
 
54
- galleryCardProps: {
55
- type: Object,
56
- default: () => ({})
57
- },
33
+ import { extend } from 'quasar'
34
+ import { ref, computed, watch, useSlots } from 'vue'
58
35
 
59
- initialSize: {
60
- type: Number,
61
- default: 4,
62
- validator: value => {
63
- const acceptableValues = [1, 2, 3, 4, 6, 12]
36
+ defineOptions({ name: 'QasGallery' })
64
37
 
65
- return acceptableValues.includes(value)
66
- }
67
- },
38
+ const props = defineProps({
39
+ ...baseProps,
68
40
 
69
- showMoreLabel: {
70
- type: String,
71
- default: 'Ver mais'
72
- },
41
+ galleryCardProps: {
42
+ type: Object,
43
+ default: () => ({})
44
+ },
73
45
 
74
- useLoadAll: {
75
- type: Boolean
76
- },
46
+ initialSize: {
47
+ type: Number,
48
+ default: 4,
49
+ validator: value => [1, 2, 3, 4, 6, 12].includes(value)
50
+ },
77
51
 
78
- useDestroy: {
79
- type: Boolean
80
- },
52
+ showMoreLabel: {
53
+ type: String,
54
+ default: 'Ver mais'
55
+ },
81
56
 
82
- useObjectModel: {
83
- type: Boolean
84
- },
57
+ useLoadAll: {
58
+ type: Boolean
59
+ },
85
60
 
86
- modelValue: {
87
- type: Array,
88
- default: () => []
89
- },
61
+ useDestroy: {
62
+ type: Boolean
63
+ },
90
64
 
91
- modelKey: {
92
- type: String,
93
- default: ''
94
- }
65
+ useObjectModel: {
66
+ type: Boolean
95
67
  },
96
68
 
97
- emits: [
98
- 'delete-error',
99
- 'delete-success',
100
- 'update:modelValue'
101
- ],
102
-
103
- data () {
104
- return {
105
- carouselDialog: false,
106
- imageIndex: 0,
107
- displayedImages: this.initialSize,
108
- showDeleteDialog: false,
109
- currentModel: [],
110
- imageToBeDestroyed: { index: null }
111
- }
69
+ modelValue: {
70
+ type: Array,
71
+ default: () => []
112
72
  },
113
73
 
114
- computed: {
115
- galleryColumnsClasses () {
116
- const size = 12 / this.initialSize
117
- const col = `col-${size}`
74
+ modelKey: {
75
+ type: String,
76
+ default: ''
77
+ }
78
+ })
79
+
80
+ const emit = defineEmits([
81
+ 'delete-error',
82
+ 'delete-success',
83
+ 'update:modelValue'
84
+ ])
85
+
86
+ const screen = useScreen()
87
+ const slots = useSlots()
88
+
89
+ const carouselDialog = ref(false)
90
+ const imageIndex = ref(0)
91
+ const displayedImages = ref(props.initialSize)
92
+ const showDeleteDialog = ref(false)
93
+ const currentModel = ref([])
94
+ const imageToBeDestroyed = ref({ index: null })
95
+
96
+ // contador para key
97
+ const galleryCardCountToReRender = ref(1)
98
+
99
+ // computed
100
+ const galleryColumnsClasses = computed(() => {
101
+ const size = 12 / props.initialSize
102
+ const col = `col-${size}`
103
+
104
+ return screen.isSmall ? 'col-12' : col
105
+ })
106
+
107
+ const clonedImages = computed(() => extend(true, [], props.modelValue))
108
+
109
+ const normalizedImages = computed(() => {
110
+ if (props.useObjectModel) return clonedImages.value
111
+
112
+ return clonedImages.value.map(url => ({ url }))
113
+ })
114
+
115
+ const hideShowMore = computed(() => {
116
+ return (normalizedImages.value.length <= displayedImages.value) || props.useLoadAll
117
+ })
118
+
119
+ const deleteGalleryDialogProps = computed(() => {
120
+ return {
121
+ customId: props.customId,
122
+ dialogProps: props.dialogProps,
123
+ entity: props.entity,
124
+ modelKey: props.modelKey,
125
+ payload: currentModel.value,
126
+ url: props.url
127
+ }
128
+ })
118
129
 
119
- return this.$qas.screen.isSmall ? 'col-12' : col
120
- },
130
+ watch(() => normalizedImages.value, value => {
131
+ currentModel.value = extend(true, [], value)
132
+ }, { immediate: true })
121
133
 
122
- hideShowMore () {
123
- return (this.normalizedImages.length <= this.displayedImages) || this.useLoadAll
124
- },
134
+ // functions
135
+ function getActionsMenuProps ({ image, index }) {
136
+ if (!props.useDestroy) return {}
125
137
 
126
- normalizedImages () {
127
- if (!this.useObjectModel) {
128
- return this.clonedImages.map(url => ({ url }))
129
- }
138
+ return {
139
+ useLabel: false,
130
140
 
131
- return this.clonedImages
141
+ buttonProps: {
142
+ disable: isDestroyDisabled(image)
132
143
  },
133
144
 
134
- clonedImages () {
135
- return extend(true, [], this.modelValue)
136
- },
145
+ list: {
146
+ destroy: {
147
+ label: 'Excluir',
148
+ color: 'grey-10',
149
+ icon: 'sym_r_delete',
137
150
 
138
- deleteGalleryDialogProps () {
139
- return {
140
- customId: this.customId,
141
- dialogProps: this.dialogProps,
142
- entity: this.entity,
143
- modelKey: this.modelKey,
144
- payload: this.currentModel,
145
- url: this.url
151
+ handler: () => onDelete(image, index)
146
152
  }
147
153
  }
148
- },
149
-
150
- watch: {
151
- normalizedImages: {
152
- handler (value) {
153
- this.currentModel = extend(true, [], value)
154
- },
155
-
156
- immediate: true
157
- }
158
- },
159
-
160
- methods: {
161
- toggleCarouselDialog (index) {
162
- this.imageIndex = index
163
- this.carouselDialog = !this.carouselDialog
164
- },
165
-
166
- showMore () {
167
- this.displayedImages += this.displayedImages
168
- },
169
-
170
- onError (error) {
171
- const index = this.normalizedImages.findIndex(image => image.url === error)
154
+ }
155
+ }
172
156
 
173
- if (~index) {
174
- this.normalizedImages.splice(index, 1)
175
- this.$forceUpdate()
176
- }
177
- },
157
+ function getGalleryCardProps ({ image, index }) {
158
+ return {
159
+ actionsMenuProps: getActionsMenuProps({ image, index }),
160
+ card: image,
161
+ imageProps: getImageProps({ image, index }),
178
162
 
179
- getGalleryCardProps ({ image, index }) {
180
- return {
181
- card: image,
182
- imageProps: this.getImageProps({ image, index }),
183
- actionsMenuProps: this.getActionsMenuProps({ image, index }),
184
- ...this.galleryCardProps
185
- }
186
- },
163
+ ...props.galleryCardProps
164
+ }
165
+ }
187
166
 
188
- getActionsMenuProps ({ image, index }) {
189
- if (!this.useDestroy) return {}
167
+ function getImageProps ({ image, index }) {
168
+ return {
169
+ class: 'cursor-pointer',
190
170
 
191
- return {
192
- useLabel: false,
171
+ onClick: () => toggleCarouselDialog(index),
172
+ onError: () => onError(image.url)
173
+ }
174
+ }
193
175
 
194
- buttonProps: {
195
- disable: this.isDestroyDisabled(image)
196
- },
176
+ function getInitialImages () {
177
+ return props.useLoadAll
178
+ ? normalizedImages.value
179
+ : normalizedImages.value.slice(0, displayedImages.value)
180
+ }
197
181
 
198
- list: {
199
- destroy: {
200
- label: 'Excluir',
201
- color: 'grey-10',
202
- icon: 'sym_r_delete',
182
+ function isDestroyDisabled (image) {
183
+ return 'destroyable' in image && !image.destroyable
184
+ }
203
185
 
204
- handler: () => this.onDestroy(image, index)
205
- }
206
- }
207
- }
208
- },
186
+ function resetCurrentModel () {
187
+ currentModel.value = extend(true, [], normalizedImages.value)
188
+ }
209
189
 
210
- getImageProps ({ image, index }) {
211
- return {
212
- class: 'cursor-pointer',
190
+ function onError (error) {
191
+ const index = normalizedImages.value.findIndex(image => image.url === error)
213
192
 
214
- onClick: () => this.toggleCarouselDialog(index),
215
- onError: () => this.onError(image.url)
216
- }
217
- },
193
+ if (~index) {
194
+ normalizedImages.value.splice(index, 1)
218
195
 
219
- getInitialImages () {
220
- return this.useLoadAll
221
- ? this.normalizedImages
222
- : this.normalizedImages.slice(0, this.displayedImages)
223
- },
196
+ /**
197
+ * Posteriormente no Options API estava sendo usado "this.$forceUpdate()"
198
+ * porém agora estamos usando uma forma mais apropriada que é atualizar através de key
199
+ * com contadores.
200
+ */
201
+ galleryCardCountToReRender.value += 1
202
+ }
203
+ }
224
204
 
225
- onDestroy (image, index) {
226
- if (this.isDestroyDisabled(image)) return
205
+ function onDeleteError (error) {
206
+ resetCurrentModel()
227
207
 
228
- this.imageToBeDestroyed.index = index
208
+ emit(
209
+ 'delete-error',
210
+ { data: error, index: imageToBeDestroyed.value.index }
211
+ )
212
+ }
229
213
 
230
- this.currentModel.splice(this.imageToBeDestroyed.index, 1)
214
+ function onDelete (image, index) {
215
+ if (isDestroyDisabled(image)) return
231
216
 
232
- this.showDeleteDialog = !this.showDeleteDialog
233
- },
217
+ imageToBeDestroyed.value.index = index
234
218
 
235
- isDestroyDisabled (image) {
236
- return 'destroyable' in image && !image.destroyable
237
- },
219
+ currentModel.value.splice(imageToBeDestroyed.value.index, 1)
238
220
 
239
- onDeleteSuccess () {
240
- this.normalizedImages.splice(this.imageToBeDestroyed.index, 1)
221
+ showDeleteDialog.value = !showDeleteDialog.value
222
+ }
241
223
 
242
- this.$emit('update:modelValue', this.normalizedImages)
224
+ function onDeleteSuccess () {
225
+ normalizedImages.value.splice(imageToBeDestroyed.value.index, 1)
243
226
 
244
- this.$emit(
245
- 'delete-success',
246
- { data: this.normalizedImages, index: this.imageToBeDestroyed.index }
247
- )
248
- },
227
+ emit('update:modelValue', normalizedImages.value)
249
228
 
250
- resetCurrentModel () {
251
- this.currentModel = extend(true, [], this.normalizedImages)
252
- },
229
+ emit(
230
+ 'delete-success',
231
+ { data: normalizedImages.value, index: imageToBeDestroyed.value.index }
232
+ )
233
+ }
253
234
 
254
- onDeleteError (error) {
255
- this.resetCurrentModel()
235
+ function toggleCarouselDialog (index) {
236
+ imageIndex.value = index
237
+ carouselDialog.value = !carouselDialog.value
238
+ }
256
239
 
257
- this.$emit(
258
- 'delete-error',
259
- { data: error, index: this.imageToBeDestroyed.index }
260
- )
261
- }
262
- }
240
+ function showMore () {
241
+ displayedImages.value += displayedImages.value
263
242
  }
264
243
  </script>
@@ -0,0 +1,54 @@
1
+ import { computed } from 'vue'
2
+ import { useRoute } from 'vue-router'
3
+
4
+ export const baseProps = {
5
+ customId: {
6
+ default: '',
7
+ type: [Number, String]
8
+ },
9
+
10
+ dialogProps: {
11
+ default: () => ({}),
12
+ type: Object
13
+ },
14
+
15
+ entity: {
16
+ default: '',
17
+ type: String
18
+ },
19
+
20
+ url: {
21
+ default: '',
22
+ type: String
23
+ }
24
+ }
25
+
26
+ export default function useDelete ({ props, destroyFn, emit }) {
27
+ const route = useRoute()
28
+
29
+ const defaultDialogProps = computed(() => {
30
+ return {
31
+ card: {
32
+ description: 'Tem certeza que deseja excluir este item?'
33
+ },
34
+
35
+ ok: {
36
+ label: 'Excluir',
37
+ onClick: destroyFn
38
+ },
39
+
40
+ cancel: {
41
+ onClick: () => emit('cancel')
42
+ },
43
+
44
+ ...props.dialogProps
45
+ }
46
+ })
47
+
48
+ const id = computed(() => props.customId || route.params.id)
49
+
50
+ return {
51
+ defaultDialogProps,
52
+ id
53
+ }
54
+ }
@@ -8,9 +8,9 @@
8
8
  </template>
9
9
 
10
10
  <template #description>
11
- <q-carousel v-model="imageIndexModel" animated :arrows="!$qas.screen.isSmall" class="pv-gallery-carousel-dialog__carousel" control-text-color="primary" data-cy="gallery-carousel" :fullscreen="$qas.screen.isSmall" :height="carouselImageHeight" next-icon="sym_r_chevron_right" prev-icon="sym_r_chevron_left" swipeable :thumbnails="!isSingleImage">
12
- <q-carousel-slide v-for="(image, index) in images" :key="index" class="bg-no-repeat bg-size-contain" :data-cy="`gallery-carousel-slide-${index}`" :img-src="image.url" :name="index">
13
- <div v-if="$qas.screen.isSmall" class="full-width justify-end row">
11
+ <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
+ <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">
13
+ <div v-if="screen.isSmall" class="full-width justify-end row">
14
14
  <qas-btn color="grey-10" icon="sym_r_close" variant="tertiary" @click="close" />
15
15
  </div>
16
16
  </q-carousel-slide>
@@ -20,66 +20,59 @@
20
20
  </div>
21
21
  </template>
22
22
 
23
- <script>
24
- export default {
25
- name: 'PvGalleryCarouselDialog',
23
+ <script setup>
24
+ import { useScreen } from '../../../composables'
26
25
 
27
- props: {
28
- images: {
29
- type: Array,
30
- default: () => []
31
- },
26
+ import { computed } from 'vue'
32
27
 
33
- imageIndex: {
34
- type: Number,
35
- default: 0
36
- },
28
+ defineOptions({ name: 'PvGalleryCarouselDialog' })
37
29
 
38
- modelValue: {
39
- type: Boolean
40
- }
30
+ const props = defineProps({
31
+ images: {
32
+ type: Array,
33
+ default: () => []
41
34
  },
42
35
 
43
- emits: [
44
- 'update:modelValue',
45
- 'update:imageIndex'
46
- ],
47
-
48
- computed: {
49
- model: {
50
- get () {
51
- return this.modelValue
52
- },
53
-
54
- set (value) {
55
- return this.$emit('update:modelValue', value)
56
- }
57
- },
58
-
59
- imageIndexModel: {
60
- get () {
61
- return this.imageIndex
62
- },
63
-
64
- set (value) {
65
- return this.$emit('update:imageIndex', value)
66
- }
67
- },
68
-
69
- carouselImageHeight () {
70
- return 'calc((500/976) * 100vh)'
71
- },
72
-
73
- isSingleImage () {
74
- return this.images.length === 1
75
- }
36
+ imageIndex: {
37
+ type: Number,
38
+ default: 0
76
39
  },
77
40
 
78
- methods: {
79
- close () {
80
- this.$emit('update:modelValue', false)
81
- }
41
+ modelValue: {
42
+ type: Boolean
82
43
  }
44
+ })
45
+
46
+ const emit = defineEmits(['update:modelValue', 'update:imageIndex'])
47
+
48
+ const screen = useScreen()
49
+
50
+ const carouselImageHeight = 'calc((500/976) * 100vh)'
51
+
52
+ const model = computed({
53
+ get () {
54
+ return props.modelValue
55
+ },
56
+
57
+ set (value) {
58
+ emit('update:modelValue', value)
59
+ }
60
+ })
61
+
62
+ const imageIndexModel = computed({
63
+ get () {
64
+ return props.imageIndex
65
+ },
66
+
67
+ set (value) {
68
+ return emit('update:imageIndex', value)
69
+ }
70
+ })
71
+
72
+ const isSingleImage = props.images.length === 1
73
+
74
+ function close () {
75
+ emit('update:modelValue', false)
83
76
  }
84
77
  </script>
85
78