@bildvitta/quasar-ui-asteroid 3.17.0-beta.21 → 3.17.0-beta.22
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/asteroid.js +4 -4
- package/src/components/actions/QasActions.vue +81 -81
- package/src/components/actions/QasActions.yml +34 -34
- package/src/components/actions-menu/QasActionsMenu.vue +251 -251
- package/src/components/actions-menu/QasActionsMenu.yml +89 -89
- package/src/components/actions-menu/composables/use-delete.js +30 -30
- package/src/components/actions-menu/composables/use-double-split-actions.js +42 -42
- package/src/components/actions-menu/composables/use-options-actions.js +27 -27
- package/src/components/actions-menu/composables/use-single-action.js +17 -17
- package/src/components/actions-menu/composables/use-single-split-actions.js +35 -35
- package/src/components/actions-menu/composables/use-tooltips.js +43 -43
- package/src/components/actions-menu/utils/get-label.js +3 -3
- package/src/components/actions-menu/utils/set-click-handler.js +6 -6
- package/src/components/alert/QasAlert.test.js +43 -43
- package/src/components/alert/QasAlert.vue +110 -110
- package/src/components/alert/QasAlert.yml +39 -39
- package/src/components/app-bar/QasAppBar.vue +119 -119
- package/src/components/app-bar/QasAppBar.yml +44 -44
- package/src/components/app-menu/QasAppMenu.vue +392 -392
- package/src/components/app-menu/QasAppMenu.yml +73 -73
- package/src/components/app-menu/composables/use-app-menu-dropdown.js +71 -71
- package/src/components/app-menu/composables/use-app-user.js +49 -49
- package/src/components/app-menu/composables/use-development-badge.js +23 -23
- package/src/components/app-menu/private/PvAppMenuDropdown.vue +71 -71
- package/src/components/app-menu/private/PvAppMenuHelpChat.vue +222 -222
- package/src/components/app-user/QasAppUser.vue +281 -281
- package/src/components/app-user/QasAppUser.yml +56 -56
- package/src/components/avatar/QasAvatar.vue +95 -95
- package/src/components/avatar/QasAvatar.yml +38 -38
- package/src/components/avatar/enums/AvatarColors.js +10 -10
- package/src/components/badge/QasBadge.vue +87 -87
- package/src/components/badge/QasBadge.yml +55 -55
- package/src/components/board-generator/QasBoardGenerator.vue +712 -712
- package/src/components/board-generator/QasBoardGenerator.yml +167 -167
- package/src/components/box/QasBox.vue +51 -51
- package/src/components/box/QasBox.yml +29 -29
- package/src/components/breakline/QasBreakline.vue +38 -38
- package/src/components/breakline/QasBreakline.yml +25 -25
- package/src/components/btn/QasBtn.vue +148 -148
- package/src/components/btn/QasBtn.yml +48 -48
- package/src/components/btn-dropdown/QasBtnDropdown.vue +146 -146
- package/src/components/btn-dropdown/QasBtnDropdown.yml +59 -59
- package/src/components/card/QasCard.vue +132 -132
- package/src/components/card/QasCard.yml +44 -44
- package/src/components/card-image/QasCardImage.vue +95 -95
- package/src/components/card-image/QasCardImage.yml +48 -48
- package/src/components/chart-view/QasChartView.vue +441 -441
- package/src/components/chart-view/QasChartView.yml +109 -109
- package/src/components/chart-view/config/charts/bar.js +45 -45
- package/src/components/chart-view/config/charts/doughnut.js +43 -43
- package/src/components/chart-view/config/charts/index.js +9 -9
- package/src/components/chart-view/config/charts/line.js +57 -57
- package/src/components/chart-view/config/defaults/colors.js +19 -19
- package/src/components/chart-view/config/defaults/font.js +5 -5
- package/src/components/chart-view/config/defaults/index.js +2 -2
- package/src/components/chart-view/config/index.js +3 -3
- package/src/components/chart-view/config/plugins/index.js +3 -3
- package/src/components/chart-view/config/plugins/legend.js +9 -9
- package/src/components/chart-view/config/plugins/tooltip.js +15 -15
- package/src/components/chart-view/config/plugins/zoom.js +31 -31
- package/src/components/checkbox/QasCheckbox.vue +150 -150
- package/src/components/checkbox/QasCheckbox.yml +36 -36
- package/src/components/copy/QasCopy.vue +46 -46
- package/src/components/copy/QasCopy.yml +23 -23
- package/src/components/date/QasDate.vue +600 -600
- package/src/components/date/QasDate.yml +69 -69
- package/src/components/date/enums/DateMaskOptions.js +6 -6
- package/src/components/date-time-input/QasDateTimeInput.vue +269 -269
- package/src/components/date-time-input/QasDateTimeInput.yml +64 -64
- package/src/components/debugger/QasDebugger.vue +31 -31
- package/src/components/debugger/QasDebugger.yml +10 -10
- package/src/components/delete/QasDelete.vue +100 -100
- package/src/components/delete/QasDelete.yml +60 -60
- package/src/components/dialog/QasDialog.vue +217 -217
- package/src/components/dialog/QasDialog.yml +117 -117
- package/src/components/dialog/composables/use-cancel.js +40 -40
- package/src/components/dialog/composables/use-dynamic-components.js +86 -86
- package/src/components/dialog/composables/use-ok.js +45 -45
- package/src/components/dialog-router/QasDialogRouter.vue +86 -86
- package/src/components/dialog-router/QasDialogRouter.yml +23 -23
- package/src/components/drawer/QasDrawer.vue +118 -118
- package/src/components/drawer/QasDrawer.yml +58 -58
- package/src/components/empty-result-text/QasEmptyResultText.vue +18 -18
- package/src/components/empty-result-text/QasEmptyResultText.yml +14 -14
- package/src/components/expansion-item/QasExpansionItem.vue +291 -291
- package/src/components/expansion-item/QasExpansionItem.yml +76 -76
- package/src/components/field/QasField.vue +220 -220
- package/src/components/field/QasField.yml +36 -36
- package/src/components/filters/QasFilters.vue +472 -472
- package/src/components/filters/QasFilters.yml +171 -171
- package/src/components/filters/private/PvFiltersButton.vue +101 -101
- package/src/components/form-generator/QasFormGenerator.vue +274 -274
- package/src/components/form-generator/QasFormGenerator.yml +109 -109
- package/src/components/form-view/QasFormView.vue +484 -484
- package/src/components/form-view/QasFormView.yml +253 -253
- package/src/components/gallery/QasGallery.vue +243 -243
- package/src/components/gallery/QasGallery.yml +188 -188
- package/src/components/gallery/composables/use-delete.js +54 -54
- package/src/components/gallery/private/PvGalleryCarouselDialog.vue +92 -92
- package/src/components/gallery/private/PvGalleryDeleteDialog.vue +54 -54
- package/src/components/gallery-card/QasGalleryCard.vue +153 -153
- package/src/components/gallery-card/QasGalleryCard.yml +61 -61
- package/src/components/grabbable/QasGrabbable.vue +185 -185
- package/src/components/grabbable/QasGrabbable.yml +26 -26
- package/src/components/grid-generator/QasGridGenerator.vue +210 -210
- package/src/components/grid-generator/QasGridGenerator.yml +127 -127
- package/src/components/grid-item/QasGridItem.vue +89 -89
- package/src/components/grid-item/QasGridItem.yml +22 -22
- package/src/components/header/QasHeader.vue +152 -152
- package/src/components/header/QasHeader.yml +50 -50
- package/src/components/infinite-scroll/QasInfiniteScroll.vue +168 -168
- package/src/components/infinite-scroll/QasInfiniteScroll.yml +78 -78
- package/src/components/info/QasInfo.vue +155 -155
- package/src/components/info/QasInfo.yml +34 -34
- package/src/components/input/QasInput.vue +252 -252
- package/src/components/input/QasInput.yml +65 -65
- package/src/components/label/QasLabel.vue +61 -61
- package/src/components/label/QasLabel.yml +44 -44
- package/src/components/layout/QasLayout.vue +101 -101
- package/src/components/layout/QasLayout.yml +46 -46
- package/src/components/layout/private/PvLayoutNotificationCard.vue +86 -86
- package/src/components/layout/private/PvLayoutNotificationsDrawer.vue +140 -140
- package/src/components/list-items/QasListItems.vue +125 -125
- package/src/components/list-items/QasListItems.yml +71 -71
- package/src/components/list-view/QasListView.vue +302 -302
- package/src/components/list-view/QasListView.yml +169 -169
- package/src/components/map/QasMap.vue +75 -75
- package/src/components/map/QasMap.yml +33 -33
- package/src/components/nested-fields/QasNestedFields.vue +584 -584
- package/src/components/nested-fields/QasNestedFields.yml +296 -296
- package/src/components/numeric-input/QasNumericInput.vue +206 -206
- package/src/components/numeric-input/QasNumericInput.yml +85 -85
- package/src/components/option-group/QasOptionGroup.vue +54 -54
- package/src/components/option-group/QasOptionGroup.yml +30 -30
- package/src/components/page-header/QasPageHeader.vue +143 -143
- package/src/components/page-header/QasPageHeader.yml +42 -42
- package/src/components/pagination/QasPagination.vue +71 -71
- package/src/components/pagination/QasPagination.yml +4 -4
- package/src/components/password-input/QasPasswordInput.vue +110 -110
- package/src/components/password-input/QasPasswordInput.yml +111 -111
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.vue +71 -71
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.yml +103 -103
- package/src/components/profile/QasProfile.vue +98 -98
- package/src/components/profile/QasProfile.yml +60 -60
- package/src/components/radio/QasRadio.vue +62 -62
- package/src/components/radio/QasRadio.yml +11 -11
- package/src/components/resizer/QasResizer.vue +90 -90
- package/src/components/resizer/QasResizer.yml +24 -24
- package/src/components/search-box/QasSearchBox.vue +294 -294
- package/src/components/search-box/QasSearchBox.yml +154 -154
- package/src/components/search-input/QasSearchInput.vue +106 -106
- package/src/components/search-input/QasSearchInput.yml +48 -48
- package/src/components/select/QasSelect.vue +514 -514
- package/src/components/select/QasSelect.yml +157 -157
- package/src/components/select-list/QasSelectList.vue +238 -238
- package/src/components/select-list/QasSelectList.yml +108 -108
- package/src/components/select-list/private/PvSelectListCheckbox.vue +31 -31
- package/src/components/select-list-dialog/QasSelectListDialog.vue +395 -395
- package/src/components/select-list-dialog/QasSelectListDialog.yml +108 -108
- package/src/components/signature-pad/QasSignaturePad.vue +122 -122
- package/src/components/signature-pad/QasSignaturePad.yml +53 -53
- package/src/components/signature-uploader/QasSignatureUploader.vue +164 -164
- package/src/components/signature-uploader/QasSignatureUploader.yml +37 -37
- package/src/components/single-view/QasSingleView.vue +175 -175
- package/src/components/single-view/QasSingleView.yml +131 -131
- package/src/components/sortable/QasSortable.vue +151 -151
- package/src/components/sortable/QasSortable.yml +65 -65
- package/src/components/status/QasStatus.test.js +11 -11
- package/src/components/status/QasStatus.vue +29 -29
- package/src/components/status/QasStatus.yml +10 -10
- package/src/components/stepper/QasStepper.vue +199 -152
- package/src/components/stepper/QasStepper.yml +35 -35
- package/src/components/stepper-form-view/QasStepperFormView.vue +86 -84
- package/src/components/stepper-form-view/QasStepperFormView.yml +58 -58
- package/src/components/table-generator/QasTableGenerator.vue +416 -416
- package/src/components/table-generator/QasTableGenerator.yml +94 -94
- package/src/components/tabs-generator/QasTabsGenerator.vue +196 -196
- package/src/components/tabs-generator/QasTabsGenerator.yml +53 -53
- package/src/components/text-truncate/QasTextTruncate.vue +274 -274
- package/src/components/text-truncate/QasTextTruncate.yml +60 -60
- package/src/components/timeline/QasTimeline.vue +140 -140
- package/src/components/timeline/QasTimeline.yml +36 -36
- package/src/components/toggle/QasToggle.vue +14 -14
- package/src/components/toggle/QasToggle.yml +5 -5
- package/src/components/toggle-visibility/QasToggleVisibility.vue +79 -79
- package/src/components/toggle-visibility/QasToggleVisibility.yml +30 -30
- package/src/components/transfer/QasTransfer.vue +239 -239
- package/src/components/transfer/QasTransfer.yml +60 -60
- package/src/components/tree-generator/QasTreeForm.vue +62 -62
- package/src/components/tree-generator/QasTreeGenerator.vue +488 -488
- package/src/components/tree-generator/QasTreeGenerator.yml +81 -81
- package/src/components/uploader/QasUploader.vue +691 -645
- package/src/components/uploader/QasUploader.yml +206 -192
- package/src/components/uploader/private/PvUploaderGalleryCard.vue +357 -357
- package/src/components/welcome/QasWelcome.vue +125 -125
- package/src/components/welcome/QasWelcome.yml +23 -23
- package/src/components/welcome/private/PvWelcomeShortcutCard.vue +58 -58
- package/src/components/whatsapp-link/QasWhatsappLink.vue +34 -34
- package/src/components/whatsapp-link/QasWhatsappLink.yml +18 -18
- package/src/composables/index.js +8 -8
- package/src/composables/private/index.js +3 -3
- package/src/composables/private/use-generator.js +174 -174
- package/src/composables/private/use-toggle-visibility.js +48 -48
- package/src/composables/private/use-view.js +186 -186
- package/src/composables/use-context.js +15 -15
- package/src/composables/use-form.js +32 -32
- package/src/composables/use-history.js +46 -46
- package/src/composables/use-notifications.js +128 -128
- package/src/composables/use-query-cache.js +60 -60
- package/src/composables/use-screen.js +42 -42
- package/src/css/base/font-face.scss +28 -28
- package/src/css/base/index.scss +1 -1
- package/src/css/components/base.scss +12 -12
- package/src/css/components/button.scss +116 -116
- package/src/css/components/checkbox.scss +14 -14
- package/src/css/components/editor.scss +7 -7
- package/src/css/components/field.scss +88 -88
- package/src/css/components/index.scss +10 -10
- package/src/css/components/item.scss +52 -52
- package/src/css/components/radio.scss +18 -18
- package/src/css/components/scrollbar.scss +20 -20
- package/src/css/components/tabs.scss +3 -3
- package/src/css/components/toggle.scss +13 -13
- package/src/css/mixins/index.scss +3 -3
- package/src/css/mixins/set-brand.scss +15 -15
- package/src/css/mixins/set-button.scss +26 -26
- package/src/css/mixins/set-typography.scss +8 -8
- package/src/css/plugins/index.scss +2 -2
- package/src/css/plugins/loading.scss +5 -5
- package/src/css/plugins/notify.scss +100 -100
- package/src/css/utils/background.scss +34 -34
- package/src/css/utils/border-radius.scss +29 -29
- package/src/css/utils/border.scss +42 -42
- package/src/css/utils/container.scss +36 -36
- package/src/css/utils/fonts.scss +5 -5
- package/src/css/utils/index.scss +10 -10
- package/src/css/utils/line-height.scss +19 -19
- package/src/css/utils/opacity.scss +5 -5
- package/src/css/utils/scroll.scss +21 -21
- package/src/css/utils/text.scss +15 -15
- package/src/css/utils/unset.scss +8 -8
- package/src/css/variables/button.scss +4 -4
- package/src/css/variables/index.scss +6 -6
- package/src/css/variables/scrollbar.scss +11 -11
- package/src/css/variables/separator.scss +2 -2
- package/src/css/variables/shadow.scss +3 -3
- package/src/css/variables/spacing.scss +98 -98
- package/src/css/variables/typography.scss +149 -149
- package/src/directives/Test.js +13 -13
- package/src/enums/Align.js +7 -7
- package/src/enums/Spacing.js +98 -98
- package/src/enums/Status.js +33 -33
- package/src/helpers/add-counter-suffix.js +3 -3
- package/src/helpers/base-64-to-blob.js +21 -21
- package/src/helpers/camelize-fields-name.js +15 -15
- package/src/helpers/construct-object.js +29 -29
- package/src/helpers/copy-to-clipboard.js +15 -15
- package/src/helpers/destroy-nested-children-by-key.js +33 -33
- package/src/helpers/download-file.js +21 -21
- package/src/helpers/filter-list-by-handle.js +31 -31
- package/src/helpers/filter-object-to-array.js +29 -29
- package/src/helpers/filter-object.js +34 -34
- package/src/helpers/filters.js +163 -163
- package/src/helpers/find-children-by-key.js +14 -14
- package/src/helpers/get-greatest-common-divisor.js +16 -16
- package/src/helpers/get-normalized-options.js +20 -20
- package/src/helpers/get-placeholder.js +19 -19
- package/src/helpers/get-required-label.js +3 -3
- package/src/helpers/get-slot-children-text.js +15 -15
- package/src/helpers/handle-process.js +13 -13
- package/src/helpers/images.js +28 -28
- package/src/helpers/index.js +25 -25
- package/src/helpers/is-empty.js +3 -3
- package/src/helpers/is-local-development.js +3 -3
- package/src/helpers/private/gutter-validator.js +15 -15
- package/src/helpers/private/has-parent-by-class-name.js +15 -15
- package/src/helpers/promise-handler.js +40 -40
- package/src/helpers/rules.js +7 -7
- package/src/helpers/set-scroll-on-grab.js +128 -128
- package/src/index.cjs.js +1 -1
- package/src/index.esm.js +4 -4
- package/src/index.scss +38 -38
- package/src/index.umd.js +2 -2
- package/src/mixins/context.js +8 -8
- package/src/mixins/delete.js +48 -48
- package/src/mixins/dialog-router.js +17 -17
- package/src/mixins/form.js +11 -11
- package/src/mixins/generator.js +94 -94
- package/src/mixins/index.js +17 -17
- package/src/mixins/password.js +86 -86
- package/src/mixins/search-filter.js +354 -354
- package/src/mixins/view.js +156 -156
- package/src/pages/ErrorComponent.vue +74 -74
- package/src/pages/Forbidden.vue +29 -29
- package/src/pages/NotFound.vue +29 -29
- package/src/pages/ServerError.vue +29 -29
- package/src/pages/Unauthorized.vue +29 -29
- package/src/plugins/delete/Delete.js +107 -107
- package/src/plugins/delete/Delete.yml +75 -75
- package/src/plugins/dialog/Dialog.js +14 -14
- package/src/plugins/dialog/Dialog.yml +10 -10
- package/src/plugins/index.js +13 -13
- package/src/plugins/notify-error/NotifyError.js +13 -13
- package/src/plugins/notify-error/NotifyError.yml +11 -11
- package/src/plugins/notify-success/NotifySuccess.js +13 -13
- package/src/plugins/notify-success/NotifySuccess.yml +11 -11
- package/src/plugins/screen/Screen.js +35 -35
- package/src/plugins/screen/Screen.yml +16 -16
- package/src/shared/date-config.js +26 -26
- package/src/shared/fuse-config.js +4 -4
- package/src/shared/notify-config.js +7 -7
- package/src/vue-plugin/third-party-component-handler.js +29 -29
- package/src/vue-plugin.js +282 -282
|
@@ -1,600 +1,600 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<q-date
|
|
3
|
-
v-bind="attributes"
|
|
4
|
-
ref="parentDate"
|
|
5
|
-
v-model="model"
|
|
6
|
-
/>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup>
|
|
10
|
-
import { date as asteroidDate } from '../../helpers/filters'
|
|
11
|
-
import { MaskOptions } from './enums/DateMaskOptions'
|
|
12
|
-
|
|
13
|
-
import { date } from 'quasar'
|
|
14
|
-
import { ref, computed, onMounted, onUnmounted, watch, useAttrs, nextTick } from 'vue'
|
|
15
|
-
|
|
16
|
-
defineOptions({
|
|
17
|
-
name: 'QasDate',
|
|
18
|
-
inheritAttrs: false
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const props = defineProps({
|
|
22
|
-
events: {
|
|
23
|
-
type: [Array, Function],
|
|
24
|
-
default: () => []
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
eventColor: {
|
|
28
|
-
type: [String, Function],
|
|
29
|
-
default: ''
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
mask: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: MaskOptions.Dash,
|
|
35
|
-
validator: value => Object.values(MaskOptions).includes(value)
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
modelValue: {
|
|
39
|
-
type: [String, Array],
|
|
40
|
-
default: ''
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
multiple: {
|
|
44
|
-
type: Boolean
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
options: {
|
|
48
|
-
type: [Array, Function],
|
|
49
|
-
default: undefined
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
useIso: {
|
|
53
|
-
type: Boolean
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
useInactiveDates: {
|
|
57
|
-
default: true,
|
|
58
|
-
type: Boolean
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
useUnmaskOptions: {
|
|
62
|
-
default: true,
|
|
63
|
-
type: Boolean
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
width: {
|
|
67
|
-
type: String,
|
|
68
|
-
default: ''
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
const emit = defineEmits(['update:modelValue', 'navigation'])
|
|
73
|
-
|
|
74
|
-
const attrs = useAttrs()
|
|
75
|
-
|
|
76
|
-
// template refs
|
|
77
|
-
const parentDate = ref(null)
|
|
78
|
-
const dateElement = ref(null)
|
|
79
|
-
|
|
80
|
-
const currentDate = ref({})
|
|
81
|
-
const dateObserver = ref(undefined)
|
|
82
|
-
|
|
83
|
-
onMounted(() => {
|
|
84
|
-
dateElement.value = parentDate.value?.$el
|
|
85
|
-
|
|
86
|
-
// muda estilo da navegação
|
|
87
|
-
setNewNavigatorDisplay()
|
|
88
|
-
|
|
89
|
-
// observa as mudanças no DOM do QDate > .q-date__content
|
|
90
|
-
setObserveDate()
|
|
91
|
-
|
|
92
|
-
// seta data atual de acordo com a view do mês atual
|
|
93
|
-
setCurrentDate()
|
|
94
|
-
|
|
95
|
-
// seta os eventos, ativos e inativos
|
|
96
|
-
setEvents(currentDate.value)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
onUnmounted(() => dateObserver.value.disconnect())
|
|
100
|
-
|
|
101
|
-
const classes = computed(() => {
|
|
102
|
-
return ['qas-date', 'shadow-2', { 'qas-date--inative': props.useInactiveDates }]
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
const styles = computed(() => (props.width && { width: props.width }))
|
|
106
|
-
|
|
107
|
-
const normalizedOptions = computed(() => {
|
|
108
|
-
return props.useUnmaskOptions ? getUnmaskedList(props.options) : props.options
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
const attributes = computed(() => {
|
|
112
|
-
const {
|
|
113
|
-
color,
|
|
114
|
-
minimal,
|
|
115
|
-
textColor,
|
|
116
|
-
...restAttrs
|
|
117
|
-
} = attrs
|
|
118
|
-
|
|
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',
|
|
128
|
-
|
|
129
|
-
// events
|
|
130
|
-
onNavigation,
|
|
131
|
-
|
|
132
|
-
...restAttrs
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
const model = computed({
|
|
137
|
-
get () {
|
|
138
|
-
return props.modelValue
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
set (value) {
|
|
142
|
-
emit('update:modelValue', props.useIso ? getISODate(value) : value)
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
const hasModelValue = computed(() => props.multiple ? !!props.modelValue.length : !!props.modelValue)
|
|
147
|
-
|
|
148
|
-
const isEventColorCallback = computed(() => typeof props.eventColor === 'function')
|
|
149
|
-
const isEventsCallback = computed(() => typeof props.events === 'function')
|
|
150
|
-
|
|
151
|
-
watch(() => props.events, () => setEvents(currentDate.value))
|
|
152
|
-
|
|
153
|
-
// functions
|
|
154
|
-
function createActiveEventElement (dayElement, eventElement) {
|
|
155
|
-
const buttonElement = dayElement.querySelector('.q-btn__content')
|
|
156
|
-
|
|
157
|
-
buttonElement?.appendChild?.(eventElement)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function createCounterInactiveEventElement (dayElement, eventElement) {
|
|
161
|
-
const spanElement = document.createElement('span')
|
|
162
|
-
const [child] = dayElement.children
|
|
163
|
-
|
|
164
|
-
spanElement.setAttribute('data-event', true)
|
|
165
|
-
dayElement.setAttribute('data-has-inactive-event', true)
|
|
166
|
-
|
|
167
|
-
spanElement.classList.add('flex', 'items-center', 'justify-center', 'text-center')
|
|
168
|
-
|
|
169
|
-
child.setAttribute('data-day-content', child.textContent)
|
|
170
|
-
|
|
171
|
-
spanElement.appendChild(child)
|
|
172
|
-
spanElement.appendChild(eventElement)
|
|
173
|
-
dayElement.appendChild(spanElement)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function createPointerEventElement (isInactive, currentColor, eventElement) {
|
|
177
|
-
const eventPointerElement = document.createElement('div')
|
|
178
|
-
|
|
179
|
-
eventPointerElement.classList.add(
|
|
180
|
-
'qas-date__event-pointer',
|
|
181
|
-
`bg-${isInactive ? 'grey-4' : currentColor || 'primary'}`
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
eventElement.appendChild(eventPointerElement)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function getCurrentColor (date, color) {
|
|
188
|
-
return (isEventColorCallback.value ? props.eventColor(date) : props.eventColor) || color
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function getUnmaskedList (list) {
|
|
192
|
-
const invalidTypes = ['function', 'undefined']
|
|
193
|
-
|
|
194
|
-
return invalidTypes.includes(typeof list)
|
|
195
|
-
? list
|
|
196
|
-
: list.map(item => asteroidDate(item, 'yyyy/MM/dd'))
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function getDate (date) {
|
|
200
|
-
return {
|
|
201
|
-
year: date.getFullYear(),
|
|
202
|
-
month: date.getMonth() + 1,
|
|
203
|
-
day: date.getDate()
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function getISODate (value) {
|
|
208
|
-
if (!value || (props.multiple && !value.length)) return value
|
|
209
|
-
|
|
210
|
-
return props.multiple
|
|
211
|
-
? value.map(dateItem => date.extractDate(dateItem, props.mask).toISOString())
|
|
212
|
-
: date.extractDate(value, props.mask).toISOString()
|
|
213
|
-
}
|
|
214
|
-
|
|
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()
|
|
218
|
-
|
|
219
|
-
return getDate(extractedDate)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function getCurrentEvent (date) {
|
|
223
|
-
return props.events.find(event => event.date === date)
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function getEventClasses (currentColor, hasCounter, isInactive) {
|
|
227
|
-
return [
|
|
228
|
-
'qas-date__event',
|
|
229
|
-
|
|
230
|
-
isInactive ? 'qas-date__event--inactive' : 'qas-date__event--active',
|
|
231
|
-
|
|
232
|
-
`text-${currentColor || (isInactive ? 'grey-4' : 'primary')}`,
|
|
233
|
-
|
|
234
|
-
hasCounter ? 'qas-date__event--counter' : 'qas-date__event--pointer'
|
|
235
|
-
]
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function getStatusDay ({ currentDay, index }) {
|
|
239
|
-
const status = {
|
|
240
|
-
isPrevious: false,
|
|
241
|
-
isNext: false,
|
|
242
|
-
isActiveMonthDay: false
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (currentDay > index) {
|
|
246
|
-
status.isPrevious = true
|
|
247
|
-
|
|
248
|
-
return status
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (index - 7 > currentDay) {
|
|
252
|
-
status.isNext = true
|
|
253
|
-
|
|
254
|
-
return status
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
status.isActiveMonthDay = true
|
|
258
|
-
|
|
259
|
-
return status
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function isJanuary (month) {
|
|
263
|
-
return month === 1
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function isDecember (month) {
|
|
267
|
-
return month === 12
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function getNormalizedYear ({ isNext, isPrevious, month, year }) {
|
|
271
|
-
if (isPrevious && isJanuary(month)) return year - 1
|
|
272
|
-
|
|
273
|
-
if (isNext && isDecember(month)) return year + 1
|
|
274
|
-
|
|
275
|
-
return year
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function getNormalizedMonth ({ month, isPrevious, isNext }) {
|
|
279
|
-
if (isPrevious) return isJanuary(month) ? (month = 12) : month - 1
|
|
280
|
-
|
|
281
|
-
if (isNext) return isDecember(month) ? (month = 1) : month + 1
|
|
282
|
-
|
|
283
|
-
return month
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function resetActiveEvents () {
|
|
287
|
-
const elementsToRemove = dateElement.value.querySelectorAll('[data-event]')
|
|
288
|
-
|
|
289
|
-
elementsToRemove.forEach(nodeElement => nodeElement.remove())
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function resetInactiveEvents () {
|
|
293
|
-
const inactiveElementsToRemove = dateElement.value.querySelectorAll('[data-has-inactive-event]')
|
|
294
|
-
|
|
295
|
-
inactiveElementsToRemove.forEach(inactiveElement => {
|
|
296
|
-
const [element] = inactiveElement.children
|
|
297
|
-
|
|
298
|
-
const hasDayContent = element.querySelector('[data-day-content]')
|
|
299
|
-
|
|
300
|
-
if (hasDayContent) inactiveElement.append(hasDayContent)
|
|
301
|
-
})
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
function resetEvents () {
|
|
305
|
-
if (props.useInactiveDates) resetInactiveEvents()
|
|
306
|
-
|
|
307
|
-
resetActiveEvents()
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function setCurrentDate (date) {
|
|
311
|
-
currentDate.value = date || getCurrentDate()
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function setEventClasses (currentColor, eventElement, hasCounter, isInactive) {
|
|
315
|
-
const classes = getEventClasses(currentColor, hasCounter, isInactive)
|
|
316
|
-
|
|
317
|
-
eventElement.classList.add(...classes)
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function setTextCountEvent (eventElement, currentEvent) {
|
|
321
|
-
eventElement.innerText = `(${currentEvent.counter})`
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
function setEvents ({ year, month }) {
|
|
325
|
-
resetEvents()
|
|
326
|
-
|
|
327
|
-
if (!props.events.length || !year || !month) return
|
|
328
|
-
|
|
329
|
-
const daysElement = dateElement.value.querySelectorAll('.q-date__calendar-days .q-date__calendar-item')
|
|
330
|
-
const daysElementList = Array.from(daysElement)
|
|
331
|
-
|
|
332
|
-
daysElementList.forEach((dayElement, index) => {
|
|
333
|
-
const [child] = dayElement.children
|
|
334
|
-
|
|
335
|
-
const day = child.textContent
|
|
336
|
-
|
|
337
|
-
const { isActiveMonthDay, isNext, isPrevious } = getStatusDay({ currentDay: day, index: index + 1 })
|
|
338
|
-
|
|
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')
|
|
343
|
-
|
|
344
|
-
const currentEvent = isEventsCallback.value ? props.events(normalizedDate) : getCurrentEvent(normalizedDate)
|
|
345
|
-
|
|
346
|
-
const hasDisabledClass = dayElement.classList.contains('q-date__calendar-item--out')
|
|
347
|
-
const isInactive = !isActiveMonthDay || hasDisabledClass
|
|
348
|
-
|
|
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
|
|
355
|
-
|
|
356
|
-
const hasCounter = currentEvent.counter
|
|
357
|
-
|
|
358
|
-
const currentColor = getCurrentColor(normalizedDate, currentEvent?.color)
|
|
359
|
-
|
|
360
|
-
const eventElement = document.createElement('div')
|
|
361
|
-
|
|
362
|
-
eventElement.setAttribute('data-event', true)
|
|
363
|
-
|
|
364
|
-
dayElement.classList.add('qas-date__calendar-item-event')
|
|
365
|
-
|
|
366
|
-
setEventClasses(currentColor, eventElement, hasCounter, isInactive)
|
|
367
|
-
|
|
368
|
-
if (hasCounter) {
|
|
369
|
-
setTextCountEvent(eventElement, currentEvent)
|
|
370
|
-
} else {
|
|
371
|
-
createPointerEventElement(isInactive, currentColor, eventElement)
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (isInactive) {
|
|
375
|
-
createCounterInactiveEventElement(dayElement, eventElement)
|
|
376
|
-
|
|
377
|
-
return
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
createActiveEventElement(dayElement, eventElement)
|
|
381
|
-
})
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function setNewNavigatorDisplay () {
|
|
385
|
-
const navigationElement = dateElement.value.querySelector('.q-date__navigation')
|
|
386
|
-
const navigationChildren = navigationElement?.children || []
|
|
387
|
-
|
|
388
|
-
const nodesList = Array.from(navigationChildren)
|
|
389
|
-
|
|
390
|
-
if (nodesList.length <= 2) return
|
|
391
|
-
|
|
392
|
-
const firstDivElement = document.createElement('div')
|
|
393
|
-
const secondDivElement = document.createElement('div')
|
|
394
|
-
|
|
395
|
-
firstDivElement.classList.add('flex')
|
|
396
|
-
secondDivElement.classList.add('flex')
|
|
397
|
-
|
|
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
|
-
})
|
|
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())
|
|
438
|
-
}
|
|
439
|
-
</script>
|
|
440
|
-
|
|
441
|
-
<style lang="scss">
|
|
442
|
-
.qas-date {
|
|
443
|
-
// $
|
|
444
|
-
min-width: 100%;
|
|
445
|
-
width: 100%;
|
|
446
|
-
|
|
447
|
-
&__event {
|
|
448
|
-
@include set-typography($caption);
|
|
449
|
-
|
|
450
|
-
color: $primary;
|
|
451
|
-
font-size: 10px !important;
|
|
452
|
-
line-height: 1;
|
|
453
|
-
transition: color var(--qas-generic-transition);
|
|
454
|
-
width: 100%;
|
|
455
|
-
|
|
456
|
-
&--pointer {
|
|
457
|
-
bottom: -6px;
|
|
458
|
-
display: flex;
|
|
459
|
-
justify-content: center;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
&__event-pointer {
|
|
464
|
-
border-radius: 100%;
|
|
465
|
-
display: flex;
|
|
466
|
-
height: 6px;
|
|
467
|
-
justify-content: center;
|
|
468
|
-
margin-top: var(--qas-spacing-xs);
|
|
469
|
-
width: 6px;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
.q-date__calendar-item {
|
|
473
|
-
vertical-align: initial;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
&--inative {
|
|
477
|
-
.q-date {
|
|
478
|
-
&__calendar-item--out,
|
|
479
|
-
&__calendar-item--fill {
|
|
480
|
-
@include set-typography($subtitle2);
|
|
481
|
-
|
|
482
|
-
color: $grey-4;
|
|
483
|
-
line-height: 1;
|
|
484
|
-
visibility: unset;
|
|
485
|
-
|
|
486
|
-
span {
|
|
487
|
-
height: auto;
|
|
488
|
-
padding: var(--qas-spacing-xs);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
.qas-date__event--inactive.qas-date__event--counter {
|
|
494
|
-
color: $grey-4 !important;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
.q-date {
|
|
499
|
-
&__navigation {
|
|
500
|
-
justify-content: space-between;
|
|
501
|
-
|
|
502
|
-
> div:last-child,
|
|
503
|
-
> div:first-child {
|
|
504
|
-
min-width: auto;
|
|
505
|
-
width: auto;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
> div:first-child {
|
|
509
|
-
min-width: 120px;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
.q-btn {
|
|
513
|
-
@include set-button(tertiary, false, false, grey-10);
|
|
514
|
-
@include set-typography($subtitle2);
|
|
515
|
-
|
|
516
|
-
.q-icon {
|
|
517
|
-
@include set-typography($subtitle1, true);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
&__calendar-weekdays {
|
|
523
|
-
color: $grey-8;
|
|
524
|
-
|
|
525
|
-
> div {
|
|
526
|
-
@include set-typography($caption);
|
|
527
|
-
|
|
528
|
-
opacity: 1;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
&__calendar-item--out {
|
|
533
|
-
color: $grey-4;
|
|
534
|
-
opacity: 1;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
&__months,
|
|
538
|
-
&__years {
|
|
539
|
-
.q-btn {
|
|
540
|
-
background-color: white !important;
|
|
541
|
-
|
|
542
|
-
&.bg-primary {
|
|
543
|
-
color: $primary !important;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
@include set-button(tertiary, false, false, grey-10);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
&__view {
|
|
551
|
-
min-height: 230px;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
&__calendar-days-container {
|
|
555
|
-
color: $grey-10;
|
|
556
|
-
min-height: auto;
|
|
557
|
-
|
|
558
|
-
.q-btn {
|
|
559
|
-
@include set-typography($subtitle2);
|
|
560
|
-
|
|
561
|
-
border: 1px solid transparent;
|
|
562
|
-
border-radius: $generic-border-radius;
|
|
563
|
-
box-shadow: none;
|
|
564
|
-
height: auto !important;
|
|
565
|
-
line-height: 1;
|
|
566
|
-
min-width: min-content;
|
|
567
|
-
transition: color var(--qas-generic-transition);
|
|
568
|
-
|
|
569
|
-
.q-ripple,
|
|
570
|
-
.q-focus-helper {
|
|
571
|
-
display: none !important;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
&.bg-primary .qas-date__event--active {
|
|
575
|
-
color: white !important;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
&.bg-primary .qas-date__event--active .qas-date__event-pointer {
|
|
579
|
-
background-color: white !important;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
&:hover {
|
|
583
|
-
color: var(--q-primary-contrast);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
&.bg-primary,
|
|
587
|
-
&.q-date__today {
|
|
588
|
-
border-color: $primary;
|
|
589
|
-
border-radius: $generic-border-radius;
|
|
590
|
-
font-weight: 700;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
&.q-date__today {
|
|
594
|
-
color: $primary;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<q-date
|
|
3
|
+
v-bind="attributes"
|
|
4
|
+
ref="parentDate"
|
|
5
|
+
v-model="model"
|
|
6
|
+
/>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
import { date as asteroidDate } from '../../helpers/filters'
|
|
11
|
+
import { MaskOptions } from './enums/DateMaskOptions'
|
|
12
|
+
|
|
13
|
+
import { date } from 'quasar'
|
|
14
|
+
import { ref, computed, onMounted, onUnmounted, watch, useAttrs, nextTick } from 'vue'
|
|
15
|
+
|
|
16
|
+
defineOptions({
|
|
17
|
+
name: 'QasDate',
|
|
18
|
+
inheritAttrs: false
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const props = defineProps({
|
|
22
|
+
events: {
|
|
23
|
+
type: [Array, Function],
|
|
24
|
+
default: () => []
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
eventColor: {
|
|
28
|
+
type: [String, Function],
|
|
29
|
+
default: ''
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
mask: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: MaskOptions.Dash,
|
|
35
|
+
validator: value => Object.values(MaskOptions).includes(value)
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
modelValue: {
|
|
39
|
+
type: [String, Array],
|
|
40
|
+
default: ''
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
multiple: {
|
|
44
|
+
type: Boolean
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
options: {
|
|
48
|
+
type: [Array, Function],
|
|
49
|
+
default: undefined
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
useIso: {
|
|
53
|
+
type: Boolean
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
useInactiveDates: {
|
|
57
|
+
default: true,
|
|
58
|
+
type: Boolean
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
useUnmaskOptions: {
|
|
62
|
+
default: true,
|
|
63
|
+
type: Boolean
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
width: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: ''
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const emit = defineEmits(['update:modelValue', 'navigation'])
|
|
73
|
+
|
|
74
|
+
const attrs = useAttrs()
|
|
75
|
+
|
|
76
|
+
// template refs
|
|
77
|
+
const parentDate = ref(null)
|
|
78
|
+
const dateElement = ref(null)
|
|
79
|
+
|
|
80
|
+
const currentDate = ref({})
|
|
81
|
+
const dateObserver = ref(undefined)
|
|
82
|
+
|
|
83
|
+
onMounted(() => {
|
|
84
|
+
dateElement.value = parentDate.value?.$el
|
|
85
|
+
|
|
86
|
+
// muda estilo da navegação
|
|
87
|
+
setNewNavigatorDisplay()
|
|
88
|
+
|
|
89
|
+
// observa as mudanças no DOM do QDate > .q-date__content
|
|
90
|
+
setObserveDate()
|
|
91
|
+
|
|
92
|
+
// seta data atual de acordo com a view do mês atual
|
|
93
|
+
setCurrentDate()
|
|
94
|
+
|
|
95
|
+
// seta os eventos, ativos e inativos
|
|
96
|
+
setEvents(currentDate.value)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
onUnmounted(() => dateObserver.value.disconnect())
|
|
100
|
+
|
|
101
|
+
const classes = computed(() => {
|
|
102
|
+
return ['qas-date', 'shadow-2', { 'qas-date--inative': props.useInactiveDates }]
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const styles = computed(() => (props.width && { width: props.width }))
|
|
106
|
+
|
|
107
|
+
const normalizedOptions = computed(() => {
|
|
108
|
+
return props.useUnmaskOptions ? getUnmaskedList(props.options) : props.options
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const attributes = computed(() => {
|
|
112
|
+
const {
|
|
113
|
+
color,
|
|
114
|
+
minimal,
|
|
115
|
+
textColor,
|
|
116
|
+
...restAttrs
|
|
117
|
+
} = attrs
|
|
118
|
+
|
|
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',
|
|
128
|
+
|
|
129
|
+
// events
|
|
130
|
+
onNavigation,
|
|
131
|
+
|
|
132
|
+
...restAttrs
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const model = computed({
|
|
137
|
+
get () {
|
|
138
|
+
return props.modelValue
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
set (value) {
|
|
142
|
+
emit('update:modelValue', props.useIso ? getISODate(value) : value)
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const hasModelValue = computed(() => props.multiple ? !!props.modelValue.length : !!props.modelValue)
|
|
147
|
+
|
|
148
|
+
const isEventColorCallback = computed(() => typeof props.eventColor === 'function')
|
|
149
|
+
const isEventsCallback = computed(() => typeof props.events === 'function')
|
|
150
|
+
|
|
151
|
+
watch(() => props.events, () => setEvents(currentDate.value))
|
|
152
|
+
|
|
153
|
+
// functions
|
|
154
|
+
function createActiveEventElement (dayElement, eventElement) {
|
|
155
|
+
const buttonElement = dayElement.querySelector('.q-btn__content')
|
|
156
|
+
|
|
157
|
+
buttonElement?.appendChild?.(eventElement)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function createCounterInactiveEventElement (dayElement, eventElement) {
|
|
161
|
+
const spanElement = document.createElement('span')
|
|
162
|
+
const [child] = dayElement.children
|
|
163
|
+
|
|
164
|
+
spanElement.setAttribute('data-event', true)
|
|
165
|
+
dayElement.setAttribute('data-has-inactive-event', true)
|
|
166
|
+
|
|
167
|
+
spanElement.classList.add('flex', 'items-center', 'justify-center', 'text-center')
|
|
168
|
+
|
|
169
|
+
child.setAttribute('data-day-content', child.textContent)
|
|
170
|
+
|
|
171
|
+
spanElement.appendChild(child)
|
|
172
|
+
spanElement.appendChild(eventElement)
|
|
173
|
+
dayElement.appendChild(spanElement)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function createPointerEventElement (isInactive, currentColor, eventElement) {
|
|
177
|
+
const eventPointerElement = document.createElement('div')
|
|
178
|
+
|
|
179
|
+
eventPointerElement.classList.add(
|
|
180
|
+
'qas-date__event-pointer',
|
|
181
|
+
`bg-${isInactive ? 'grey-4' : currentColor || 'primary'}`
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
eventElement.appendChild(eventPointerElement)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function getCurrentColor (date, color) {
|
|
188
|
+
return (isEventColorCallback.value ? props.eventColor(date) : props.eventColor) || color
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function getUnmaskedList (list) {
|
|
192
|
+
const invalidTypes = ['function', 'undefined']
|
|
193
|
+
|
|
194
|
+
return invalidTypes.includes(typeof list)
|
|
195
|
+
? list
|
|
196
|
+
: list.map(item => asteroidDate(item, 'yyyy/MM/dd'))
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function getDate (date) {
|
|
200
|
+
return {
|
|
201
|
+
year: date.getFullYear(),
|
|
202
|
+
month: date.getMonth() + 1,
|
|
203
|
+
day: date.getDate()
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function getISODate (value) {
|
|
208
|
+
if (!value || (props.multiple && !value.length)) return value
|
|
209
|
+
|
|
210
|
+
return props.multiple
|
|
211
|
+
? value.map(dateItem => date.extractDate(dateItem, props.mask).toISOString())
|
|
212
|
+
: date.extractDate(value, props.mask).toISOString()
|
|
213
|
+
}
|
|
214
|
+
|
|
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()
|
|
218
|
+
|
|
219
|
+
return getDate(extractedDate)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function getCurrentEvent (date) {
|
|
223
|
+
return props.events.find(event => event.date === date)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function getEventClasses (currentColor, hasCounter, isInactive) {
|
|
227
|
+
return [
|
|
228
|
+
'qas-date__event',
|
|
229
|
+
|
|
230
|
+
isInactive ? 'qas-date__event--inactive' : 'qas-date__event--active',
|
|
231
|
+
|
|
232
|
+
`text-${currentColor || (isInactive ? 'grey-4' : 'primary')}`,
|
|
233
|
+
|
|
234
|
+
hasCounter ? 'qas-date__event--counter' : 'qas-date__event--pointer'
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function getStatusDay ({ currentDay, index }) {
|
|
239
|
+
const status = {
|
|
240
|
+
isPrevious: false,
|
|
241
|
+
isNext: false,
|
|
242
|
+
isActiveMonthDay: false
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (currentDay > index) {
|
|
246
|
+
status.isPrevious = true
|
|
247
|
+
|
|
248
|
+
return status
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (index - 7 > currentDay) {
|
|
252
|
+
status.isNext = true
|
|
253
|
+
|
|
254
|
+
return status
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
status.isActiveMonthDay = true
|
|
258
|
+
|
|
259
|
+
return status
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function isJanuary (month) {
|
|
263
|
+
return month === 1
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function isDecember (month) {
|
|
267
|
+
return month === 12
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function getNormalizedYear ({ isNext, isPrevious, month, year }) {
|
|
271
|
+
if (isPrevious && isJanuary(month)) return year - 1
|
|
272
|
+
|
|
273
|
+
if (isNext && isDecember(month)) return year + 1
|
|
274
|
+
|
|
275
|
+
return year
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function getNormalizedMonth ({ month, isPrevious, isNext }) {
|
|
279
|
+
if (isPrevious) return isJanuary(month) ? (month = 12) : month - 1
|
|
280
|
+
|
|
281
|
+
if (isNext) return isDecember(month) ? (month = 1) : month + 1
|
|
282
|
+
|
|
283
|
+
return month
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function resetActiveEvents () {
|
|
287
|
+
const elementsToRemove = dateElement.value.querySelectorAll('[data-event]')
|
|
288
|
+
|
|
289
|
+
elementsToRemove.forEach(nodeElement => nodeElement.remove())
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function resetInactiveEvents () {
|
|
293
|
+
const inactiveElementsToRemove = dateElement.value.querySelectorAll('[data-has-inactive-event]')
|
|
294
|
+
|
|
295
|
+
inactiveElementsToRemove.forEach(inactiveElement => {
|
|
296
|
+
const [element] = inactiveElement.children
|
|
297
|
+
|
|
298
|
+
const hasDayContent = element.querySelector('[data-day-content]')
|
|
299
|
+
|
|
300
|
+
if (hasDayContent) inactiveElement.append(hasDayContent)
|
|
301
|
+
})
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function resetEvents () {
|
|
305
|
+
if (props.useInactiveDates) resetInactiveEvents()
|
|
306
|
+
|
|
307
|
+
resetActiveEvents()
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function setCurrentDate (date) {
|
|
311
|
+
currentDate.value = date || getCurrentDate()
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function setEventClasses (currentColor, eventElement, hasCounter, isInactive) {
|
|
315
|
+
const classes = getEventClasses(currentColor, hasCounter, isInactive)
|
|
316
|
+
|
|
317
|
+
eventElement.classList.add(...classes)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function setTextCountEvent (eventElement, currentEvent) {
|
|
321
|
+
eventElement.innerText = `(${currentEvent.counter})`
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function setEvents ({ year, month }) {
|
|
325
|
+
resetEvents()
|
|
326
|
+
|
|
327
|
+
if (!props.events.length || !year || !month) return
|
|
328
|
+
|
|
329
|
+
const daysElement = dateElement.value.querySelectorAll('.q-date__calendar-days .q-date__calendar-item')
|
|
330
|
+
const daysElementList = Array.from(daysElement)
|
|
331
|
+
|
|
332
|
+
daysElementList.forEach((dayElement, index) => {
|
|
333
|
+
const [child] = dayElement.children
|
|
334
|
+
|
|
335
|
+
const day = child.textContent
|
|
336
|
+
|
|
337
|
+
const { isActiveMonthDay, isNext, isPrevious } = getStatusDay({ currentDay: day, index: index + 1 })
|
|
338
|
+
|
|
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')
|
|
343
|
+
|
|
344
|
+
const currentEvent = isEventsCallback.value ? props.events(normalizedDate) : getCurrentEvent(normalizedDate)
|
|
345
|
+
|
|
346
|
+
const hasDisabledClass = dayElement.classList.contains('q-date__calendar-item--out')
|
|
347
|
+
const isInactive = !isActiveMonthDay || hasDisabledClass
|
|
348
|
+
|
|
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
|
|
355
|
+
|
|
356
|
+
const hasCounter = currentEvent.counter
|
|
357
|
+
|
|
358
|
+
const currentColor = getCurrentColor(normalizedDate, currentEvent?.color)
|
|
359
|
+
|
|
360
|
+
const eventElement = document.createElement('div')
|
|
361
|
+
|
|
362
|
+
eventElement.setAttribute('data-event', true)
|
|
363
|
+
|
|
364
|
+
dayElement.classList.add('qas-date__calendar-item-event')
|
|
365
|
+
|
|
366
|
+
setEventClasses(currentColor, eventElement, hasCounter, isInactive)
|
|
367
|
+
|
|
368
|
+
if (hasCounter) {
|
|
369
|
+
setTextCountEvent(eventElement, currentEvent)
|
|
370
|
+
} else {
|
|
371
|
+
createPointerEventElement(isInactive, currentColor, eventElement)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (isInactive) {
|
|
375
|
+
createCounterInactiveEventElement(dayElement, eventElement)
|
|
376
|
+
|
|
377
|
+
return
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
createActiveEventElement(dayElement, eventElement)
|
|
381
|
+
})
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function setNewNavigatorDisplay () {
|
|
385
|
+
const navigationElement = dateElement.value.querySelector('.q-date__navigation')
|
|
386
|
+
const navigationChildren = navigationElement?.children || []
|
|
387
|
+
|
|
388
|
+
const nodesList = Array.from(navigationChildren)
|
|
389
|
+
|
|
390
|
+
if (nodesList.length <= 2) return
|
|
391
|
+
|
|
392
|
+
const firstDivElement = document.createElement('div')
|
|
393
|
+
const secondDivElement = document.createElement('div')
|
|
394
|
+
|
|
395
|
+
firstDivElement.classList.add('flex')
|
|
396
|
+
secondDivElement.classList.add('flex')
|
|
397
|
+
|
|
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
|
+
})
|
|
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())
|
|
438
|
+
}
|
|
439
|
+
</script>
|
|
440
|
+
|
|
441
|
+
<style lang="scss">
|
|
442
|
+
.qas-date {
|
|
443
|
+
// $
|
|
444
|
+
min-width: 100%;
|
|
445
|
+
width: 100%;
|
|
446
|
+
|
|
447
|
+
&__event {
|
|
448
|
+
@include set-typography($caption);
|
|
449
|
+
|
|
450
|
+
color: $primary;
|
|
451
|
+
font-size: 10px !important;
|
|
452
|
+
line-height: 1;
|
|
453
|
+
transition: color var(--qas-generic-transition);
|
|
454
|
+
width: 100%;
|
|
455
|
+
|
|
456
|
+
&--pointer {
|
|
457
|
+
bottom: -6px;
|
|
458
|
+
display: flex;
|
|
459
|
+
justify-content: center;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
&__event-pointer {
|
|
464
|
+
border-radius: 100%;
|
|
465
|
+
display: flex;
|
|
466
|
+
height: 6px;
|
|
467
|
+
justify-content: center;
|
|
468
|
+
margin-top: var(--qas-spacing-xs);
|
|
469
|
+
width: 6px;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.q-date__calendar-item {
|
|
473
|
+
vertical-align: initial;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
&--inative {
|
|
477
|
+
.q-date {
|
|
478
|
+
&__calendar-item--out,
|
|
479
|
+
&__calendar-item--fill {
|
|
480
|
+
@include set-typography($subtitle2);
|
|
481
|
+
|
|
482
|
+
color: $grey-4;
|
|
483
|
+
line-height: 1;
|
|
484
|
+
visibility: unset;
|
|
485
|
+
|
|
486
|
+
span {
|
|
487
|
+
height: auto;
|
|
488
|
+
padding: var(--qas-spacing-xs);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.qas-date__event--inactive.qas-date__event--counter {
|
|
494
|
+
color: $grey-4 !important;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.q-date {
|
|
499
|
+
&__navigation {
|
|
500
|
+
justify-content: space-between;
|
|
501
|
+
|
|
502
|
+
> div:last-child,
|
|
503
|
+
> div:first-child {
|
|
504
|
+
min-width: auto;
|
|
505
|
+
width: auto;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
> div:first-child {
|
|
509
|
+
min-width: 120px;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.q-btn {
|
|
513
|
+
@include set-button(tertiary, false, false, grey-10);
|
|
514
|
+
@include set-typography($subtitle2);
|
|
515
|
+
|
|
516
|
+
.q-icon {
|
|
517
|
+
@include set-typography($subtitle1, true);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
&__calendar-weekdays {
|
|
523
|
+
color: $grey-8;
|
|
524
|
+
|
|
525
|
+
> div {
|
|
526
|
+
@include set-typography($caption);
|
|
527
|
+
|
|
528
|
+
opacity: 1;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
&__calendar-item--out {
|
|
533
|
+
color: $grey-4;
|
|
534
|
+
opacity: 1;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
&__months,
|
|
538
|
+
&__years {
|
|
539
|
+
.q-btn {
|
|
540
|
+
background-color: white !important;
|
|
541
|
+
|
|
542
|
+
&.bg-primary {
|
|
543
|
+
color: $primary !important;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
@include set-button(tertiary, false, false, grey-10);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
&__view {
|
|
551
|
+
min-height: 230px;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
&__calendar-days-container {
|
|
555
|
+
color: $grey-10;
|
|
556
|
+
min-height: auto;
|
|
557
|
+
|
|
558
|
+
.q-btn {
|
|
559
|
+
@include set-typography($subtitle2);
|
|
560
|
+
|
|
561
|
+
border: 1px solid transparent;
|
|
562
|
+
border-radius: $generic-border-radius;
|
|
563
|
+
box-shadow: none;
|
|
564
|
+
height: auto !important;
|
|
565
|
+
line-height: 1;
|
|
566
|
+
min-width: min-content;
|
|
567
|
+
transition: color var(--qas-generic-transition);
|
|
568
|
+
|
|
569
|
+
.q-ripple,
|
|
570
|
+
.q-focus-helper {
|
|
571
|
+
display: none !important;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
&.bg-primary .qas-date__event--active {
|
|
575
|
+
color: white !important;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
&.bg-primary .qas-date__event--active .qas-date__event-pointer {
|
|
579
|
+
background-color: white !important;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
&:hover {
|
|
583
|
+
color: var(--q-primary-contrast);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
&.bg-primary,
|
|
587
|
+
&.q-date__today {
|
|
588
|
+
border-color: $primary;
|
|
589
|
+
border-radius: $generic-border-radius;
|
|
590
|
+
font-weight: 700;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
&.q-date__today {
|
|
594
|
+
color: $primary;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
</style>
|