@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.
- package/package.json +1 -1
- package/src/components/actions-menu/QasActionsMenu.vue +16 -14
- package/src/components/alert/QasAlert.vue +1 -1
- package/src/components/app-bar/QasAppBar.vue +5 -5
- package/src/components/app-menu/QasAppMenu.vue +8 -8
- package/src/components/app-menu/private/PvAppMenuDropdown.vue +1 -1
- package/src/components/app-user/QasAppUser.vue +10 -10
- package/src/components/avatar/QasAvatar.vue +2 -2
- package/src/components/breakline/QasBreakline.vue +5 -6
- package/src/components/btn-dropdown/QasBtnDropdown.vue +74 -95
- package/src/components/card/QasCard.vue +55 -73
- package/src/components/chart-view/QasChartView.vue +37 -9
- package/src/components/chart-view/QasChartView.yml +6 -0
- package/src/components/checkbox-group/QasCheckboxGroup.vue +81 -92
- package/src/components/copy/QasCopy.vue +20 -27
- package/src/components/date/QasDate.vue +316 -355
- package/src/components/date/QasDate.yml +0 -5
- package/src/components/date/enums/DateMaskOptions.js +6 -0
- package/src/components/date-time-input/QasDateTimeInput.vue +198 -209
- package/src/components/debugger/QasDebugger.vue +20 -12
- package/src/components/delete/QasDelete.vue +70 -80
- package/src/components/dialog/QasDialog.vue +7 -7
- package/src/components/dialog/composables/use-cancel.js +3 -3
- package/src/components/dialog/composables/use-dynamic-components.js +4 -4
- package/src/components/dialog/composables/use-ok.js +3 -3
- package/src/components/dialog-router/QasDialogRouter.vue +68 -67
- package/src/components/empty-result-text/QasEmptyResultText.vue +8 -10
- package/src/components/form-generator/QasFormGenerator.vue +2 -2
- package/src/components/gallery/QasGallery.vue +175 -196
- package/src/components/gallery/composables/use-delete.js +54 -0
- package/src/components/gallery/private/PvGalleryCarouselDialog.vue +48 -55
- package/src/components/gallery/private/PvGalleryDeleteDialog.vue +41 -50
- package/src/components/gallery-card/QasGalleryCard.vue +90 -103
- package/src/components/grid-generator/QasGridGenerator.vue +2 -2
- package/src/components/header-actions/QasHeaderActions.vue +35 -50
- package/src/components/header-actions/QasHeaderActions.yml +1 -1
- package/src/components/infinite-scroll/QasInfiniteScroll.vue +2 -2
- package/src/components/label/QasLabel.vue +42 -54
- package/src/components/list-items/QasListItems.vue +32 -41
- package/src/components/map/QasMap.vue +44 -46
- package/src/components/numeric-input/QasNumericInput.vue +2 -2
- package/src/components/page-header/QasPageHeader.vue +74 -87
- package/src/components/pagination/QasPagination.vue +21 -21
- package/src/components/select-list-dialog/QasSelectListDialog.vue +4 -2
- package/src/components/tabs-generator/QasTabsGenerator.vue +55 -63
- package/src/components/timeline/QasTimeline.vue +1 -1
- package/src/components/uploader/private/PvUploaderGalleryCard.vue +1 -1
- package/src/components/whatsapp-link/QasWhatsappLink.vue +34 -0
- package/src/components/whatsapp-link/QasWhatsappLink.yml +18 -0
- package/src/composables/private/use-generator.js +0 -8
- 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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
16
|
+
defineOptions({
|
|
20
17
|
name: 'QasDate',
|
|
18
|
+
inheritAttrs: false
|
|
19
|
+
})
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
'
|
|
83
|
-
|
|
27
|
+
eventColor: {
|
|
28
|
+
type: [String, Function],
|
|
29
|
+
default: ''
|
|
30
|
+
},
|
|
84
31
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
43
|
+
multiple: {
|
|
44
|
+
type: Boolean
|
|
45
|
+
},
|
|
123
46
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
47
|
+
options: {
|
|
48
|
+
type: [Array, Function],
|
|
49
|
+
default: undefined
|
|
50
|
+
},
|
|
127
51
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
52
|
+
useIso: {
|
|
53
|
+
type: Boolean
|
|
54
|
+
},
|
|
131
55
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
56
|
+
useInactiveDates: {
|
|
57
|
+
default: true,
|
|
58
|
+
type: Boolean
|
|
59
|
+
},
|
|
135
60
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
61
|
+
useUnmaskOptions: {
|
|
62
|
+
default: true,
|
|
63
|
+
type: Boolean
|
|
64
|
+
},
|
|
140
65
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
66
|
+
width: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: ''
|
|
69
|
+
}
|
|
70
|
+
})
|
|
145
71
|
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
...(this.width && { width: this.width })
|
|
149
|
-
}
|
|
150
|
-
},
|
|
72
|
+
const emit = defineEmits(['update:modelValue', 'navigation'])
|
|
151
73
|
|
|
152
|
-
|
|
153
|
-
return this.useUnmaskOptions ? this.getUnmaskedList(this.options) : this.options
|
|
154
|
-
}
|
|
155
|
-
},
|
|
74
|
+
const attrs = useAttrs()
|
|
156
75
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
},
|
|
76
|
+
// template refs
|
|
77
|
+
const parentDate = ref(null)
|
|
78
|
+
const dateElement = ref(null)
|
|
162
79
|
|
|
163
|
-
|
|
164
|
-
|
|
80
|
+
const currentDate = ref({})
|
|
81
|
+
const dateObserver = ref(undefined)
|
|
165
82
|
|
|
166
|
-
|
|
167
|
-
|
|
83
|
+
onMounted(() => {
|
|
84
|
+
dateElement.value = parentDate.value?.$el
|
|
168
85
|
|
|
169
|
-
|
|
170
|
-
|
|
86
|
+
// muda estilo da navegação
|
|
87
|
+
setNewNavigatorDisplay()
|
|
171
88
|
|
|
172
|
-
|
|
173
|
-
|
|
89
|
+
// observa as mudanças no DOM do QDate > .q-date__content
|
|
90
|
+
setObserveDate()
|
|
174
91
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
},
|
|
92
|
+
// seta data atual de acordo com a view do mês atual
|
|
93
|
+
setCurrentDate()
|
|
178
94
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
95
|
+
// seta os eventos, ativos e inativos
|
|
96
|
+
setEvents(currentDate.value)
|
|
97
|
+
})
|
|
182
98
|
|
|
183
|
-
|
|
184
|
-
createActiveEventElement (dayElement, eventElement) {
|
|
185
|
-
const buttonElement = dayElement.querySelector('.q-btn__content')
|
|
99
|
+
onUnmounted(() => dateObserver.value.disconnect())
|
|
186
100
|
|
|
187
|
-
|
|
188
|
-
|
|
101
|
+
const classes = computed(() => {
|
|
102
|
+
return ['qas-date', 'shadow-2', { 'qas-date--inative': props.useInactiveDates }]
|
|
103
|
+
})
|
|
189
104
|
|
|
190
|
-
|
|
191
|
-
const spanElement = document.createElement('span')
|
|
192
|
-
const [child] = dayElement.children
|
|
105
|
+
const styles = computed(() => (props.width && { width: props.width }))
|
|
193
106
|
|
|
194
|
-
|
|
195
|
-
|
|
107
|
+
const normalizedOptions = computed(() => {
|
|
108
|
+
return props.useUnmaskOptions ? getUnmaskedList(props.options) : props.options
|
|
109
|
+
})
|
|
196
110
|
|
|
197
|
-
|
|
111
|
+
const attributes = computed(() => {
|
|
112
|
+
const {
|
|
113
|
+
color,
|
|
114
|
+
minimal,
|
|
115
|
+
textColor,
|
|
116
|
+
...restAttrs
|
|
117
|
+
} = attrs
|
|
198
118
|
|
|
199
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
dayElement.appendChild(spanElement)
|
|
204
|
-
},
|
|
129
|
+
// events
|
|
130
|
+
onNavigation,
|
|
205
131
|
|
|
206
|
-
|
|
207
|
-
|
|
132
|
+
...restAttrs
|
|
133
|
+
}
|
|
134
|
+
})
|
|
208
135
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
136
|
+
const model = computed({
|
|
137
|
+
get () {
|
|
138
|
+
return props.modelValue
|
|
139
|
+
},
|
|
213
140
|
|
|
214
|
-
|
|
215
|
-
|
|
141
|
+
set (value) {
|
|
142
|
+
emit('update:modelValue', props.useIso ? getISODate(value) : value)
|
|
143
|
+
}
|
|
144
|
+
})
|
|
216
145
|
|
|
217
|
-
|
|
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
|
-
|
|
224
|
-
|
|
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
|
-
|
|
228
|
-
},
|
|
151
|
+
watch(() => props.events, () => setEvents(currentDate.value))
|
|
229
152
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
153
|
+
// functions
|
|
154
|
+
function createActiveEventElement (dayElement, eventElement) {
|
|
155
|
+
const buttonElement = dayElement.querySelector('.q-btn__content')
|
|
233
156
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
year: date.getFullYear(),
|
|
237
|
-
month: date.getMonth() + 1,
|
|
238
|
-
day: date.getDate()
|
|
239
|
-
}
|
|
240
|
-
},
|
|
157
|
+
buttonElement?.appendChild?.(eventElement)
|
|
158
|
+
}
|
|
241
159
|
|
|
242
|
-
|
|
243
|
-
|
|
160
|
+
function createCounterInactiveEventElement (dayElement, eventElement) {
|
|
161
|
+
const spanElement = document.createElement('span')
|
|
162
|
+
const [child] = dayElement.children
|
|
244
163
|
|
|
245
|
-
|
|
164
|
+
spanElement.setAttribute('data-event', true)
|
|
165
|
+
dayElement.setAttribute('data-has-inactive-event', true)
|
|
246
166
|
|
|
247
|
-
|
|
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
|
-
|
|
253
|
-
},
|
|
169
|
+
child.setAttribute('data-day-content', child.textContent)
|
|
254
170
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
171
|
+
spanElement.appendChild(child)
|
|
172
|
+
spanElement.appendChild(eventElement)
|
|
173
|
+
dayElement.appendChild(spanElement)
|
|
174
|
+
}
|
|
258
175
|
|
|
259
|
-
|
|
176
|
+
function createPointerEventElement (isInactive, currentColor, eventElement) {
|
|
177
|
+
const eventPointerElement = document.createElement('div')
|
|
260
178
|
|
|
261
|
-
|
|
179
|
+
eventPointerElement.classList.add(
|
|
180
|
+
'qas-date__event-pointer',
|
|
181
|
+
`bg-${isInactive ? 'grey-4' : currentColor || 'primary'}`
|
|
182
|
+
)
|
|
262
183
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
},
|
|
184
|
+
eventElement.appendChild(eventPointerElement)
|
|
185
|
+
}
|
|
266
186
|
|
|
267
|
-
|
|
268
|
-
|
|
187
|
+
function getCurrentColor (date, color) {
|
|
188
|
+
return (isEventColorCallback.value ? props.eventColor(date) : props.eventColor) || color
|
|
189
|
+
}
|
|
269
190
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
: date.extractDate(value, this.mask).toISOString()
|
|
273
|
-
},
|
|
191
|
+
function getUnmaskedList (list) {
|
|
192
|
+
const invalidTypes = ['function', 'undefined']
|
|
274
193
|
|
|
275
|
-
|
|
276
|
-
|
|
194
|
+
return invalidTypes.includes(typeof list)
|
|
195
|
+
? list
|
|
196
|
+
: list.map(item => asteroidDate(item, 'yyyy/MM/dd'))
|
|
197
|
+
}
|
|
277
198
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
284
|
-
|
|
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
|
-
|
|
291
|
-
|
|
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
|
-
|
|
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
|
-
|
|
297
|
-
|
|
219
|
+
return getDate(extractedDate)
|
|
220
|
+
}
|
|
298
221
|
|
|
299
|
-
|
|
300
|
-
|
|
222
|
+
function getCurrentEvent (date) {
|
|
223
|
+
return props.events.find(event => event.date === date)
|
|
224
|
+
}
|
|
301
225
|
|
|
302
|
-
|
|
226
|
+
function getEventClasses (currentColor, hasCounter, isInactive) {
|
|
227
|
+
return [
|
|
228
|
+
'qas-date__event',
|
|
303
229
|
|
|
304
|
-
|
|
305
|
-
},
|
|
230
|
+
isInactive ? 'qas-date__event--inactive' : 'qas-date__event--active',
|
|
306
231
|
|
|
307
|
-
|
|
308
|
-
if (isPrevious && month === 1) return year - 1
|
|
232
|
+
`text-${currentColor || (isInactive ? 'grey-4' : 'primary')}`,
|
|
309
233
|
|
|
310
|
-
|
|
234
|
+
hasCounter ? 'qas-date__event--counter' : 'qas-date__event--pointer'
|
|
235
|
+
]
|
|
236
|
+
}
|
|
311
237
|
|
|
312
|
-
|
|
313
|
-
|
|
238
|
+
function getStatusDay ({ currentDay, index }) {
|
|
239
|
+
const status = {
|
|
240
|
+
isPrevious: false,
|
|
241
|
+
isNext: false,
|
|
242
|
+
isActiveMonthDay: false
|
|
243
|
+
}
|
|
314
244
|
|
|
315
|
-
|
|
316
|
-
|
|
245
|
+
if (currentDay > index) {
|
|
246
|
+
status.isPrevious = true
|
|
317
247
|
|
|
318
|
-
|
|
248
|
+
return status
|
|
249
|
+
}
|
|
319
250
|
|
|
320
|
-
|
|
321
|
-
|
|
251
|
+
if (index - 7 > currentDay) {
|
|
252
|
+
status.isNext = true
|
|
322
253
|
|
|
323
|
-
|
|
324
|
-
|
|
254
|
+
return status
|
|
255
|
+
}
|
|
325
256
|
|
|
326
|
-
|
|
327
|
-
const [element] = inactiveElement.children
|
|
257
|
+
status.isActiveMonthDay = true
|
|
328
258
|
|
|
329
|
-
|
|
259
|
+
return status
|
|
260
|
+
}
|
|
330
261
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
262
|
+
function isJanuary (month) {
|
|
263
|
+
return month === 1
|
|
264
|
+
}
|
|
334
265
|
|
|
335
|
-
|
|
336
|
-
|
|
266
|
+
function isDecember (month) {
|
|
267
|
+
return month === 12
|
|
268
|
+
}
|
|
337
269
|
|
|
338
|
-
|
|
339
|
-
|
|
270
|
+
function getNormalizedYear ({ isNext, isPrevious, month, year }) {
|
|
271
|
+
if (isPrevious && isJanuary(month)) return year - 1
|
|
340
272
|
|
|
341
|
-
|
|
342
|
-
const elementsToRemove = this.dateElement.querySelectorAll('[data-event]')
|
|
273
|
+
if (isNext && isDecember(month)) return year + 1
|
|
343
274
|
|
|
344
|
-
|
|
345
|
-
|
|
275
|
+
return year
|
|
276
|
+
}
|
|
346
277
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
},
|
|
278
|
+
function getNormalizedMonth ({ month, isPrevious, isNext }) {
|
|
279
|
+
if (isPrevious) return isJanuary(month) ? (month = 12) : month - 1
|
|
350
280
|
|
|
351
|
-
|
|
352
|
-
const classes = this.getEventClasses(currentColor, hasCounter, isInactive)
|
|
281
|
+
if (isNext) return isDecember(month) ? (month = 1) : month + 1
|
|
353
282
|
|
|
354
|
-
|
|
355
|
-
|
|
283
|
+
return month
|
|
284
|
+
}
|
|
356
285
|
|
|
357
|
-
|
|
358
|
-
|
|
286
|
+
function resetActiveEvents () {
|
|
287
|
+
const elementsToRemove = dateElement.value.querySelectorAll('[data-event]')
|
|
359
288
|
|
|
360
|
-
|
|
289
|
+
elementsToRemove.forEach(nodeElement => nodeElement.remove())
|
|
290
|
+
}
|
|
361
291
|
|
|
362
|
-
|
|
363
|
-
|
|
292
|
+
function resetInactiveEvents () {
|
|
293
|
+
const inactiveElementsToRemove = dateElement.value.querySelectorAll('[data-has-inactive-event]')
|
|
364
294
|
|
|
365
|
-
|
|
366
|
-
|
|
295
|
+
inactiveElementsToRemove.forEach(inactiveElement => {
|
|
296
|
+
const [element] = inactiveElement.children
|
|
367
297
|
|
|
368
|
-
|
|
298
|
+
const hasDayContent = element.querySelector('[data-day-content]')
|
|
369
299
|
|
|
370
|
-
|
|
300
|
+
if (hasDayContent) inactiveElement.append(hasDayContent)
|
|
301
|
+
})
|
|
302
|
+
}
|
|
371
303
|
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
307
|
+
resetActiveEvents()
|
|
308
|
+
}
|
|
378
309
|
|
|
379
|
-
|
|
380
|
-
|
|
310
|
+
function setCurrentDate (date) {
|
|
311
|
+
currentDate.value = date || getCurrentDate()
|
|
312
|
+
}
|
|
381
313
|
|
|
382
|
-
|
|
383
|
-
|
|
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
|
-
|
|
317
|
+
eventElement.classList.add(...classes)
|
|
318
|
+
}
|
|
390
319
|
|
|
391
|
-
|
|
320
|
+
function setTextCountEvent (eventElement, currentEvent) {
|
|
321
|
+
eventElement.innerText = `(${currentEvent.counter})`
|
|
322
|
+
}
|
|
392
323
|
|
|
393
|
-
|
|
324
|
+
function setEvents ({ year, month }) {
|
|
325
|
+
resetEvents()
|
|
394
326
|
|
|
395
|
-
|
|
327
|
+
if (!props.events.length || !year || !month) return
|
|
396
328
|
|
|
397
|
-
|
|
329
|
+
const daysElement = dateElement.value.querySelectorAll('.q-date__calendar-days .q-date__calendar-item')
|
|
330
|
+
const daysElementList = Array.from(daysElement)
|
|
398
331
|
|
|
399
|
-
|
|
332
|
+
daysElementList.forEach((dayElement, index) => {
|
|
333
|
+
const [child] = dayElement.children
|
|
400
334
|
|
|
401
|
-
|
|
402
|
-
this.setTextCountEvent(eventElement, currentEvent)
|
|
403
|
-
} else {
|
|
404
|
-
this.createPointerEventElement(isInactive, currentColor, eventElement)
|
|
405
|
-
}
|
|
335
|
+
const day = child.textContent
|
|
406
336
|
|
|
407
|
-
|
|
408
|
-
this.createCounterInactiveEventElement(dayElement, eventElement)
|
|
337
|
+
const { isActiveMonthDay, isNext, isPrevious } = getStatusDay({ currentDay: day, index: index + 1 })
|
|
409
338
|
|
|
410
|
-
|
|
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
|
-
|
|
414
|
-
})
|
|
415
|
-
},
|
|
344
|
+
const currentEvent = isEventsCallback.value ? props.events(normalizedDate) : getCurrentEvent(normalizedDate)
|
|
416
345
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const navigationChildren = navigationElement?.children || []
|
|
346
|
+
const hasDisabledClass = dayElement.classList.contains('q-date__calendar-item--out')
|
|
347
|
+
const isInactive = !isActiveMonthDay || hasDisabledClass
|
|
420
348
|
|
|
421
|
-
|
|
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
|
-
|
|
356
|
+
const hasCounter = currentEvent.counter
|
|
424
357
|
|
|
425
|
-
|
|
426
|
-
const secondDivElement = document.createElement('div')
|
|
358
|
+
const currentColor = getCurrentColor(normalizedDate, currentEvent?.color)
|
|
427
359
|
|
|
428
|
-
|
|
429
|
-
secondDivElement.classList.add('flex')
|
|
360
|
+
const eventElement = document.createElement('div')
|
|
430
361
|
|
|
431
|
-
|
|
432
|
-
const secondList = nodesList.slice(3, 6)
|
|
362
|
+
eventElement.setAttribute('data-event', true)
|
|
433
363
|
|
|
434
|
-
|
|
435
|
-
const newSecondElement = navigationElement.appendChild(secondDivElement)
|
|
364
|
+
dayElement.classList.add('qas-date__calendar-item-event')
|
|
436
365
|
|
|
437
|
-
|
|
438
|
-
this.$nextTick(() => secondList.forEach(node => newSecondElement.appendChild(node)))
|
|
439
|
-
},
|
|
366
|
+
setEventClasses(currentColor, eventElement, hasCounter, isInactive)
|
|
440
367
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
368
|
+
if (hasCounter) {
|
|
369
|
+
setTextCountEvent(eventElement, currentEvent)
|
|
370
|
+
} else {
|
|
371
|
+
createPointerEventElement(isInactive, currentColor, eventElement)
|
|
372
|
+
}
|
|
444
373
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
const [removedNode] = removedNodes
|
|
374
|
+
if (isInactive) {
|
|
375
|
+
createCounterInactiveEventElement(dayElement, eventElement)
|
|
448
376
|
|
|
449
|
-
|
|
377
|
+
return
|
|
378
|
+
}
|
|
450
379
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
380
|
+
createActiveEventElement(dayElement, eventElement)
|
|
381
|
+
})
|
|
382
|
+
}
|
|
454
383
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
})
|
|
459
|
-
}
|
|
384
|
+
function setNewNavigatorDisplay () {
|
|
385
|
+
const navigationElement = dateElement.value.querySelector('.q-date__navigation')
|
|
386
|
+
const navigationChildren = navigationElement?.children || []
|
|
460
387
|
|
|
461
|
-
|
|
462
|
-
this.dateObserver.observe(element, config)
|
|
463
|
-
},
|
|
388
|
+
const nodesList = Array.from(navigationChildren)
|
|
464
389
|
|
|
465
|
-
|
|
466
|
-
eventElement.innerText = `(${currentEvent.counter})`
|
|
467
|
-
},
|
|
390
|
+
if (nodesList.length <= 2) return
|
|
468
391
|
|
|
469
|
-
|
|
470
|
-
|
|
392
|
+
const firstDivElement = document.createElement('div')
|
|
393
|
+
const secondDivElement = document.createElement('div')
|
|
471
394
|
|
|
472
|
-
|
|
395
|
+
firstDivElement.classList.add('flex')
|
|
396
|
+
secondDivElement.classList.add('flex')
|
|
473
397
|
|
|
474
|
-
|
|
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
|
|