@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
@@ -1,479 +1,440 @@
1
1
  <template>
2
2
  <q-date
3
- v-model="model"
4
3
  v-bind="attributes"
4
+ ref="parentDate"
5
+ v-model="model"
5
6
  />
6
7
  </template>
7
8
 
8
- <script>
9
- import { date } from 'quasar'
9
+ <script setup>
10
10
  import { date as asteroidDate } from '../../helpers/filters'
11
+ import { MaskOptions } from './enums/DateMaskOptions'
11
12
 
12
- const MaskOptions = {
13
- Dash: 'YYYY-MM-DD',
14
- Slash: 'YYYY/MM/DD',
15
- SlashPtBR: 'DD/MM/YYYY',
16
- SlashDateAndHourPtBR: 'DD/MM/YYYY HH:mm'
17
- }
13
+ import { date } from 'quasar'
14
+ import { ref, computed, onMounted, onUnmounted, watch, useAttrs, nextTick } from 'vue'
18
15
 
19
- export default {
16
+ defineOptions({
20
17
  name: 'QasDate',
18
+ inheritAttrs: false
19
+ })
21
20
 
22
- inheritAttrs: false,
23
-
24
- props: {
25
- events: {
26
- type: [Array, Function],
27
- default: () => []
28
- },
29
-
30
- eventColor: {
31
- type: [String, Function],
32
- default: ''
33
- },
34
-
35
- mask: {
36
- type: String,
37
- default: MaskOptions.Dash,
38
- validator: value => Object.values(MaskOptions).includes(value)
39
- },
40
-
41
- modelValue: {
42
- type: [String, Array],
43
- default: ''
44
- },
45
-
46
- multiple: {
47
- type: Boolean
48
- },
49
-
50
- options: {
51
- type: [Array, Function],
52
- default: undefined
53
- },
54
-
55
- useIso: {
56
- type: Boolean
57
- },
58
-
59
- useInactiveDates: {
60
- default: true,
61
- type: Boolean
62
- },
63
-
64
- useUnmaskEvents: {
65
- default: true,
66
- type: Boolean
67
- },
68
-
69
- useUnmaskOptions: {
70
- default: true,
71
- type: Boolean
72
- },
73
-
74
- width: {
75
- type: String,
76
- default: ''
77
- }
21
+ const props = defineProps({
22
+ events: {
23
+ type: [Array, Function],
24
+ default: () => []
78
25
  },
79
26
 
80
- emits: [
81
- 'update:modelValue',
82
- 'navigation'
83
- ],
27
+ eventColor: {
28
+ type: [String, Function],
29
+ default: ''
30
+ },
84
31
 
85
- data () {
86
- return {
87
- currentDate: {},
88
- dateElement: null,
89
- dateObserver: undefined
90
- }
32
+ mask: {
33
+ type: String,
34
+ default: MaskOptions.Dash,
35
+ validator: value => Object.values(MaskOptions).includes(value)
91
36
  },
92
37
 
93
- computed: {
94
- attributes () {
95
- const {
96
- color,
97
- minimal,
98
- textColor,
99
- ...attributes
100
- } = this.$attrs
101
-
102
- return {
103
- class: this.classes,
104
- color: 'primary',
105
- mask: this.mask,
106
- minimal: true,
107
- multiple: this.multiple,
108
- options: this.normalizedOptions,
109
- ref: 'date',
110
- style: this.styles,
111
- textColor: 'white',
112
-
113
- // events
114
- onNavigation: this.onNavigation,
115
-
116
- ...attributes
117
- }
118
- },
38
+ modelValue: {
39
+ type: [String, Array],
40
+ default: ''
41
+ },
119
42
 
120
- classes () {
121
- return ['qas-date', 'shadow-2', { 'qas-date--inative': this.useInactiveDates }]
122
- },
43
+ multiple: {
44
+ type: Boolean
45
+ },
123
46
 
124
- hasModelValue () {
125
- return this.multiple ? !!this.modelValue.length : !!this.modelValue
126
- },
47
+ options: {
48
+ type: [Array, Function],
49
+ default: undefined
50
+ },
127
51
 
128
- isEventsCallback () {
129
- return typeof this.events === 'function'
130
- },
52
+ useIso: {
53
+ type: Boolean
54
+ },
131
55
 
132
- isEventColorCallback () {
133
- return typeof this.eventColor === 'function'
134
- },
56
+ useInactiveDates: {
57
+ default: true,
58
+ type: Boolean
59
+ },
135
60
 
136
- model: {
137
- get () {
138
- return this.modelValue
139
- },
61
+ useUnmaskOptions: {
62
+ default: true,
63
+ type: Boolean
64
+ },
140
65
 
141
- set (value) {
142
- this.$emit('update:modelValue', this.useIso ? this.getISODate(value) : value)
143
- }
144
- },
66
+ width: {
67
+ type: String,
68
+ default: ''
69
+ }
70
+ })
145
71
 
146
- styles () {
147
- return {
148
- ...(this.width && { width: this.width })
149
- }
150
- },
72
+ const emit = defineEmits(['update:modelValue', 'navigation'])
151
73
 
152
- normalizedOptions () {
153
- return this.useUnmaskOptions ? this.getUnmaskedList(this.options) : this.options
154
- }
155
- },
74
+ const attrs = useAttrs()
156
75
 
157
- watch: {
158
- events () {
159
- this.setEvents(this.currentDate)
160
- }
161
- },
76
+ // template refs
77
+ const parentDate = ref(null)
78
+ const dateElement = ref(null)
162
79
 
163
- mounted () {
164
- this.dateElement = this.$refs.date.$el
80
+ const currentDate = ref({})
81
+ const dateObserver = ref(undefined)
165
82
 
166
- // muda estilo da navegação
167
- this.setNewNavigatorDisplay()
83
+ onMounted(() => {
84
+ dateElement.value = parentDate.value?.$el
168
85
 
169
- // observa as mudanças no DOM do QDate > .q-date__content
170
- this.setObserveDate()
86
+ // muda estilo da navegação
87
+ setNewNavigatorDisplay()
171
88
 
172
- // seta data atual de acordo com a view do mês atual
173
- this.setCurrentDate()
89
+ // observa as mudanças no DOM do QDate > .q-date__content
90
+ setObserveDate()
174
91
 
175
- // seta os eventos, ativos e inativos
176
- this.setEvents(this.currentDate)
177
- },
92
+ // seta data atual de acordo com a view do mês atual
93
+ setCurrentDate()
178
94
 
179
- unmounted () {
180
- this.dateObserver.disconnect()
181
- },
95
+ // seta os eventos, ativos e inativos
96
+ setEvents(currentDate.value)
97
+ })
182
98
 
183
- methods: {
184
- createActiveEventElement (dayElement, eventElement) {
185
- const buttonElement = dayElement.querySelector('.q-btn__content')
99
+ onUnmounted(() => dateObserver.value.disconnect())
186
100
 
187
- buttonElement?.appendChild?.(eventElement)
188
- },
101
+ const classes = computed(() => {
102
+ return ['qas-date', 'shadow-2', { 'qas-date--inative': props.useInactiveDates }]
103
+ })
189
104
 
190
- createCounterInactiveEventElement (dayElement, eventElement) {
191
- const spanElement = document.createElement('span')
192
- const [child] = dayElement.children
105
+ const styles = computed(() => (props.width && { width: props.width }))
193
106
 
194
- spanElement.setAttribute('data-event', true)
195
- dayElement.setAttribute('data-has-inactive-event', true)
107
+ const normalizedOptions = computed(() => {
108
+ return props.useUnmaskOptions ? getUnmaskedList(props.options) : props.options
109
+ })
196
110
 
197
- spanElement.classList.add('flex', 'items-center', 'justify-center', 'text-center')
111
+ const attributes = computed(() => {
112
+ const {
113
+ color,
114
+ minimal,
115
+ textColor,
116
+ ...restAttrs
117
+ } = attrs
198
118
 
199
- child.setAttribute('data-day-content', child.textContent)
119
+ return {
120
+ class: classes.value,
121
+ color: 'primary',
122
+ mask: props.mask,
123
+ minimal: true,
124
+ multiple: props.multiple,
125
+ options: normalizedOptions.value,
126
+ style: styles.value,
127
+ textColor: 'white',
200
128
 
201
- spanElement.appendChild(child)
202
- spanElement.appendChild(eventElement)
203
- dayElement.appendChild(spanElement)
204
- },
129
+ // events
130
+ onNavigation,
205
131
 
206
- createPointerEventElement (isInactive, currentColor, eventElement) {
207
- const eventPointerElement = document.createElement('div')
132
+ ...restAttrs
133
+ }
134
+ })
208
135
 
209
- eventPointerElement.classList.add(
210
- 'qas-date__event-pointer',
211
- `bg-${isInactive ? 'grey-4' : currentColor || 'primary'}`
212
- )
136
+ const model = computed({
137
+ get () {
138
+ return props.modelValue
139
+ },
213
140
 
214
- eventElement.appendChild(eventPointerElement)
215
- },
141
+ set (value) {
142
+ emit('update:modelValue', props.useIso ? getISODate(value) : value)
143
+ }
144
+ })
216
145
 
217
- getCurrentColor (date, color) {
218
- return (
219
- (this.isEventColorCallback ? this.eventColor(date) : this.eventColor) || color
220
- )
221
- },
146
+ const hasModelValue = computed(() => props.multiple ? !!props.modelValue.length : !!props.modelValue)
222
147
 
223
- getCurrentDate () {
224
- const modelDate = this.multiple ? this.modelValue[0] : this.modelValue
225
- const extractedDate = this.hasModelValue ? date.extractDate(modelDate, this.mask) : new Date()
148
+ const isEventColorCallback = computed(() => typeof props.eventColor === 'function')
149
+ const isEventsCallback = computed(() => typeof props.events === 'function')
226
150
 
227
- return this.getDate(extractedDate)
228
- },
151
+ watch(() => props.events, () => setEvents(currentDate.value))
229
152
 
230
- getCurrentEvent (date) {
231
- return this.events.find(event => event.date === date)
232
- },
153
+ // functions
154
+ function createActiveEventElement (dayElement, eventElement) {
155
+ const buttonElement = dayElement.querySelector('.q-btn__content')
233
156
 
234
- getDate (date) {
235
- return {
236
- year: date.getFullYear(),
237
- month: date.getMonth() + 1,
238
- day: date.getDate()
239
- }
240
- },
157
+ buttonElement?.appendChild?.(eventElement)
158
+ }
241
159
 
242
- getEventColor (currentDate) {
243
- if (!this.modelValue) return 'primary'
160
+ function createCounterInactiveEventElement (dayElement, eventElement) {
161
+ const spanElement = document.createElement('span')
162
+ const [child] = dayElement.children
244
163
 
245
- const model = this.multiple ? this.modelValue : [this.modelValue]
164
+ spanElement.setAttribute('data-event', true)
165
+ dayElement.setAttribute('data-has-inactive-event', true)
246
166
 
247
- const extractedModel = model.filter(Boolean).map(dateItem => {
248
- const extractedDate = date.extractDate(dateItem, this.mask)
249
- return asteroidDate(extractedDate, 'yyyy/MM/dd')
250
- })
167
+ spanElement.classList.add('flex', 'items-center', 'justify-center', 'text-center')
251
168
 
252
- return extractedModel.includes(currentDate) ? 'white' : 'primary'
253
- },
169
+ child.setAttribute('data-day-content', child.textContent)
254
170
 
255
- getEventClasses (currentColor, hasCounter, isInactive) {
256
- return [
257
- 'qas-date__event',
171
+ spanElement.appendChild(child)
172
+ spanElement.appendChild(eventElement)
173
+ dayElement.appendChild(spanElement)
174
+ }
258
175
 
259
- isInactive ? 'qas-date__event--inactive' : 'qas-date__event--active',
176
+ function createPointerEventElement (isInactive, currentColor, eventElement) {
177
+ const eventPointerElement = document.createElement('div')
260
178
 
261
- `text-${currentColor || (isInactive ? 'grey-4' : 'primary')}`,
179
+ eventPointerElement.classList.add(
180
+ 'qas-date__event-pointer',
181
+ `bg-${isInactive ? 'grey-4' : currentColor || 'primary'}`
182
+ )
262
183
 
263
- hasCounter ? 'qas-date__event--counter' : 'qas-date__event--pointer'
264
- ]
265
- },
184
+ eventElement.appendChild(eventPointerElement)
185
+ }
266
186
 
267
- getISODate (value) {
268
- if (!value || (this.multiple && !value.length)) return value
187
+ function getCurrentColor (date, color) {
188
+ return (isEventColorCallback.value ? props.eventColor(date) : props.eventColor) || color
189
+ }
269
190
 
270
- return this.multiple
271
- ? value.map(dateItem => date.extractDate(dateItem, this.mask).toISOString())
272
- : date.extractDate(value, this.mask).toISOString()
273
- },
191
+ function getUnmaskedList (list) {
192
+ const invalidTypes = ['function', 'undefined']
274
193
 
275
- getUnmaskedList (list) {
276
- const invalidTypes = ['function', 'undefined']
194
+ return invalidTypes.includes(typeof list)
195
+ ? list
196
+ : list.map(item => asteroidDate(item, 'yyyy/MM/dd'))
197
+ }
277
198
 
278
- return invalidTypes.includes(typeof list)
279
- ? list
280
- : list.map(item => asteroidDate(item, 'yyyy/MM/dd'))
281
- },
199
+ function getDate (date) {
200
+ return {
201
+ year: date.getFullYear(),
202
+ month: date.getMonth() + 1,
203
+ day: date.getDate()
204
+ }
205
+ }
282
206
 
283
- getStatusDay ({ currentDay, index }) {
284
- const status = {
285
- isPrevious: false,
286
- isNext: false,
287
- isActiveMonthDay: false
288
- }
207
+ function getISODate (value) {
208
+ if (!value || (props.multiple && !value.length)) return value
289
209
 
290
- if (currentDay > index) {
291
- status.isPrevious = true
210
+ return props.multiple
211
+ ? value.map(dateItem => date.extractDate(dateItem, props.mask).toISOString())
212
+ : date.extractDate(value, props.mask).toISOString()
213
+ }
292
214
 
293
- return status
294
- }
215
+ function getCurrentDate () {
216
+ const modelDate = props.multiple ? props.modelValue[0] : props.modelValue
217
+ const extractedDate = hasModelValue.value ? date.extractDate(modelDate, props.mask) : new Date()
295
218
 
296
- if (index - 7 > currentDay) {
297
- status.isNext = true
219
+ return getDate(extractedDate)
220
+ }
298
221
 
299
- return status
300
- }
222
+ function getCurrentEvent (date) {
223
+ return props.events.find(event => event.date === date)
224
+ }
301
225
 
302
- status.isActiveMonthDay = true
226
+ function getEventClasses (currentColor, hasCounter, isInactive) {
227
+ return [
228
+ 'qas-date__event',
303
229
 
304
- return status
305
- },
230
+ isInactive ? 'qas-date__event--inactive' : 'qas-date__event--active',
306
231
 
307
- getNormalizedYear ({ isNext, isPrevious, month, year }) {
308
- if (isPrevious && month === 1) return year - 1
232
+ `text-${currentColor || (isInactive ? 'grey-4' : 'primary')}`,
309
233
 
310
- if (isNext && month === 12) return year + 1
234
+ hasCounter ? 'qas-date__event--counter' : 'qas-date__event--pointer'
235
+ ]
236
+ }
311
237
 
312
- return year
313
- },
238
+ function getStatusDay ({ currentDay, index }) {
239
+ const status = {
240
+ isPrevious: false,
241
+ isNext: false,
242
+ isActiveMonthDay: false
243
+ }
314
244
 
315
- getNormalizedMonth ({ month, isPrevious, isNext }) {
316
- if (isPrevious) return month === 1 ? (month = 12) : month - 1
245
+ if (currentDay > index) {
246
+ status.isPrevious = true
317
247
 
318
- if (isNext) return month === 12 ? (month = 1) : month + 1
248
+ return status
249
+ }
319
250
 
320
- return month
321
- },
251
+ if (index - 7 > currentDay) {
252
+ status.isNext = true
322
253
 
323
- resetInactiveEvents () {
324
- const inactiveElementsToRemove = this.dateElement.querySelectorAll('[data-has-inactive-event]')
254
+ return status
255
+ }
325
256
 
326
- inactiveElementsToRemove.forEach(inactiveElement => {
327
- const [element] = inactiveElement.children
257
+ status.isActiveMonthDay = true
328
258
 
329
- const hasDayContent = element.querySelector('[data-day-content]')
259
+ return status
260
+ }
330
261
 
331
- if (hasDayContent) inactiveElement.append(hasDayContent)
332
- })
333
- },
262
+ function isJanuary (month) {
263
+ return month === 1
264
+ }
334
265
 
335
- resetEvents () {
336
- if (this.useInactiveDates) this.resetInactiveEvents()
266
+ function isDecember (month) {
267
+ return month === 12
268
+ }
337
269
 
338
- this.resetActiveEvents()
339
- },
270
+ function getNormalizedYear ({ isNext, isPrevious, month, year }) {
271
+ if (isPrevious && isJanuary(month)) return year - 1
340
272
 
341
- resetActiveEvents () {
342
- const elementsToRemove = this.dateElement.querySelectorAll('[data-event]')
273
+ if (isNext && isDecember(month)) return year + 1
343
274
 
344
- elementsToRemove.forEach(nodeElement => nodeElement.remove())
345
- },
275
+ return year
276
+ }
346
277
 
347
- setCurrentDate (date) {
348
- this.currentDate = date || this.getCurrentDate()
349
- },
278
+ function getNormalizedMonth ({ month, isPrevious, isNext }) {
279
+ if (isPrevious) return isJanuary(month) ? (month = 12) : month - 1
350
280
 
351
- setEventClasses (currentColor, eventElement, hasCounter, isInactive) {
352
- const classes = this.getEventClasses(currentColor, hasCounter, isInactive)
281
+ if (isNext) return isDecember(month) ? (month = 1) : month + 1
353
282
 
354
- eventElement.classList.add(...classes)
355
- },
283
+ return month
284
+ }
356
285
 
357
- setEvents ({ year, month }) {
358
- this.resetEvents()
286
+ function resetActiveEvents () {
287
+ const elementsToRemove = dateElement.value.querySelectorAll('[data-event]')
359
288
 
360
- if (!this.events.length || !year || !month) return
289
+ elementsToRemove.forEach(nodeElement => nodeElement.remove())
290
+ }
361
291
 
362
- const daysElement = this.dateElement.querySelectorAll('.q-date__calendar-days .q-date__calendar-item')
363
- const daysElementList = Array.from(daysElement)
292
+ function resetInactiveEvents () {
293
+ const inactiveElementsToRemove = dateElement.value.querySelectorAll('[data-has-inactive-event]')
364
294
 
365
- daysElementList.forEach((dayElement, index) => {
366
- const [child] = dayElement.children
295
+ inactiveElementsToRemove.forEach(inactiveElement => {
296
+ const [element] = inactiveElement.children
367
297
 
368
- const day = child.textContent
298
+ const hasDayContent = element.querySelector('[data-day-content]')
369
299
 
370
- const { isActiveMonthDay, isNext, isPrevious } = this.getStatusDay({ currentDay: day, index: index + 1 })
300
+ if (hasDayContent) inactiveElement.append(hasDayContent)
301
+ })
302
+ }
371
303
 
372
- const normalizedYear = this.getNormalizedYear({ isNext, month, isPrevious, year })
373
- const normalizedMonth = this.getNormalizedMonth({ isNext, isPrevious, month })
374
- const newDate = date.buildDate({ year: normalizedYear, month: normalizedMonth, day })
375
- const normalizedDate = asteroidDate(newDate, 'yyyy-MM-dd')
304
+ function resetEvents () {
305
+ if (props.useInactiveDates) resetInactiveEvents()
376
306
 
377
- const currentEvent = this.isEventsCallback ? this.events(normalizedDate) : this.getCurrentEvent(normalizedDate)
307
+ resetActiveEvents()
308
+ }
378
309
 
379
- const hasDisabledClass = dayElement.classList.contains('q-date__calendar-item--out')
380
- const isInactive = !isActiveMonthDay || hasDisabledClass
310
+ function setCurrentDate (date) {
311
+ currentDate.value = date || getCurrentDate()
312
+ }
381
313
 
382
- /*
383
- * Se não tiver evento para o dia atual no loop ou
384
- * a opção de eventos inativos estiver desabilitada e o dia atual do loop
385
- * for referente ao mês anterior ou ao mês posterior, então retorna
386
- */
387
- if (!currentEvent || (!this.useInactiveDates && !isActiveMonthDay)) return
314
+ function setEventClasses (currentColor, eventElement, hasCounter, isInactive) {
315
+ const classes = getEventClasses(currentColor, hasCounter, isInactive)
388
316
 
389
- const hasCounter = currentEvent.counter
317
+ eventElement.classList.add(...classes)
318
+ }
390
319
 
391
- const currentColor = this.getCurrentColor(normalizedDate, currentEvent?.color)
320
+ function setTextCountEvent (eventElement, currentEvent) {
321
+ eventElement.innerText = `(${currentEvent.counter})`
322
+ }
392
323
 
393
- const eventElement = document.createElement('div')
324
+ function setEvents ({ year, month }) {
325
+ resetEvents()
394
326
 
395
- eventElement.setAttribute('data-event', true)
327
+ if (!props.events.length || !year || !month) return
396
328
 
397
- dayElement.classList.add('qas-date__calendar-item-event')
329
+ const daysElement = dateElement.value.querySelectorAll('.q-date__calendar-days .q-date__calendar-item')
330
+ const daysElementList = Array.from(daysElement)
398
331
 
399
- this.setEventClasses(currentColor, eventElement, hasCounter, isInactive)
332
+ daysElementList.forEach((dayElement, index) => {
333
+ const [child] = dayElement.children
400
334
 
401
- if (hasCounter) {
402
- this.setTextCountEvent(eventElement, currentEvent)
403
- } else {
404
- this.createPointerEventElement(isInactive, currentColor, eventElement)
405
- }
335
+ const day = child.textContent
406
336
 
407
- if (isInactive) {
408
- this.createCounterInactiveEventElement(dayElement, eventElement)
337
+ const { isActiveMonthDay, isNext, isPrevious } = getStatusDay({ currentDay: day, index: index + 1 })
409
338
 
410
- return
411
- }
339
+ const normalizedYear = getNormalizedYear({ isNext, month, isPrevious, year })
340
+ const normalizedMonth = getNormalizedMonth({ isNext, isPrevious, month })
341
+ const newDate = date.buildDate({ year: normalizedYear, month: normalizedMonth, day })
342
+ const normalizedDate = asteroidDate(newDate, 'yyyy-MM-dd')
412
343
 
413
- this.createActiveEventElement(dayElement, eventElement)
414
- })
415
- },
344
+ const currentEvent = isEventsCallback.value ? props.events(normalizedDate) : getCurrentEvent(normalizedDate)
416
345
 
417
- setNewNavigatorDisplay () {
418
- const navigationElement = this.dateElement.querySelector('.q-date__navigation')
419
- const navigationChildren = navigationElement?.children || []
346
+ const hasDisabledClass = dayElement.classList.contains('q-date__calendar-item--out')
347
+ const isInactive = !isActiveMonthDay || hasDisabledClass
420
348
 
421
- const nodesList = Array.from(navigationChildren)
349
+ /*
350
+ * Se não tiver evento para o dia atual no loop ou
351
+ * a opção de eventos inativos estiver desabilitada e o dia atual do loop
352
+ * for referente ao mês anterior ou ao mês posterior, então retorna
353
+ */
354
+ if (!currentEvent || (!props.useInactiveDates && !isActiveMonthDay)) return
422
355
 
423
- if (nodesList.length <= 2) return
356
+ const hasCounter = currentEvent.counter
424
357
 
425
- const firstDivElement = document.createElement('div')
426
- const secondDivElement = document.createElement('div')
358
+ const currentColor = getCurrentColor(normalizedDate, currentEvent?.color)
427
359
 
428
- firstDivElement.classList.add('flex')
429
- secondDivElement.classList.add('flex')
360
+ const eventElement = document.createElement('div')
430
361
 
431
- const firstList = nodesList.slice(0, 3)
432
- const secondList = nodesList.slice(3, 6)
362
+ eventElement.setAttribute('data-event', true)
433
363
 
434
- const newFirstElement = navigationElement.appendChild(firstDivElement)
435
- const newSecondElement = navigationElement.appendChild(secondDivElement)
364
+ dayElement.classList.add('qas-date__calendar-item-event')
436
365
 
437
- this.$nextTick(() => firstList.forEach(node => newFirstElement.appendChild(node)))
438
- this.$nextTick(() => secondList.forEach(node => newSecondElement.appendChild(node)))
439
- },
366
+ setEventClasses(currentColor, eventElement, hasCounter, isInactive)
440
367
 
441
- setObserveDate () {
442
- const element = this.dateElement.querySelector('.q-date__content')
443
- const config = { childList: true, subtree: true }
368
+ if (hasCounter) {
369
+ setTextCountEvent(eventElement, currentEvent)
370
+ } else {
371
+ createPointerEventElement(isInactive, currentColor, eventElement)
372
+ }
444
373
 
445
- const callback = mutationList => {
446
- mutationList.forEach(({ removedNodes, target }) => {
447
- const [removedNode] = removedNodes
374
+ if (isInactive) {
375
+ createCounterInactiveEventElement(dayElement, eventElement)
448
376
 
449
- if (!removedNode) return
377
+ return
378
+ }
450
379
 
451
- const hasCalendarDaysContainer = target.classList.contains('q-date__calendar-days-container')
452
- const hasContent = target.classList.contains('q-date__content')
453
- const hasMonths = removedNode.classList.contains('q-date__months')
380
+ createActiveEventElement(dayElement, eventElement)
381
+ })
382
+ }
454
383
 
455
- if (hasCalendarDaysContainer || (hasContent && hasMonths)) {
456
- this.setEvents(this.currentDate)
457
- }
458
- })
459
- }
384
+ function setNewNavigatorDisplay () {
385
+ const navigationElement = dateElement.value.querySelector('.q-date__navigation')
386
+ const navigationChildren = navigationElement?.children || []
460
387
 
461
- this.dateObserver = new MutationObserver(callback)
462
- this.dateObserver.observe(element, config)
463
- },
388
+ const nodesList = Array.from(navigationChildren)
464
389
 
465
- setTextCountEvent (eventElement, currentEvent) {
466
- eventElement.innerText = `(${currentEvent.counter})`
467
- },
390
+ if (nodesList.length <= 2) return
468
391
 
469
- async onNavigation (date) {
470
- this.$emit('navigation', date)
392
+ const firstDivElement = document.createElement('div')
393
+ const secondDivElement = document.createElement('div')
471
394
 
472
- this.setCurrentDate(date)
395
+ firstDivElement.classList.add('flex')
396
+ secondDivElement.classList.add('flex')
473
397
 
474
- this.$nextTick(() => this.setNewNavigatorDisplay())
475
- }
398
+ const firstList = nodesList.slice(0, 3)
399
+ const secondList = nodesList.slice(3, 6)
400
+
401
+ const newFirstElement = navigationElement.appendChild(firstDivElement)
402
+ const newSecondElement = navigationElement.appendChild(secondDivElement)
403
+
404
+ nextTick(() => firstList.forEach(node => newFirstElement.appendChild(node)))
405
+ nextTick(() => secondList.forEach(node => newSecondElement.appendChild(node)))
406
+ }
407
+
408
+ function setObserveDate () {
409
+ const element = dateElement.value.querySelector('.q-date__content')
410
+ const config = { childList: true, subtree: true }
411
+
412
+ const callback = mutationList => {
413
+ mutationList.forEach(({ removedNodes, target }) => {
414
+ const [removedNode] = removedNodes
415
+
416
+ if (!removedNode) return
417
+
418
+ const hasCalendarDaysContainer = target.classList.contains('q-date__calendar-days-container')
419
+ const hasContent = target.classList.contains('q-date__content')
420
+ const hasMonths = removedNode.classList.contains('q-date__months')
421
+
422
+ if (hasCalendarDaysContainer || (hasContent && hasMonths)) {
423
+ setEvents(currentDate.value)
424
+ }
425
+ })
476
426
  }
427
+
428
+ dateObserver.value = new MutationObserver(callback)
429
+ dateObserver.value.observe(element, config)
430
+ }
431
+
432
+ function onNavigation (date) {
433
+ emit('navigation', date)
434
+
435
+ setCurrentDate(date)
436
+
437
+ nextTick(() => setNewNavigatorDisplay())
477
438
  }
478
439
  </script>
479
440