oxy-uni-ui 1.0.1
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/LICENSE +21 -0
- package/README.md +13 -0
- package/attributes.json +1 -0
- package/components/common/AbortablePromise.ts +28 -0
- package/components/common/abstracts/_config.scss +7 -0
- package/components/common/abstracts/_function.scss +89 -0
- package/components/common/abstracts/_mixin.scss +385 -0
- package/components/common/abstracts/variable.scss +974 -0
- package/components/common/base64.ts +29 -0
- package/components/common/canvasHelper.ts +49 -0
- package/components/common/clickoutside.ts +25 -0
- package/components/common/event.ts +8 -0
- package/components/common/interceptor.ts +43 -0
- package/components/common/props.ts +51 -0
- package/components/common/util.ts +778 -0
- package/components/composables/index.ts +11 -0
- package/components/composables/useCell.ts +13 -0
- package/components/composables/useChildren.ts +113 -0
- package/components/composables/useCountDown.ts +138 -0
- package/components/composables/useLockScroll.ts +37 -0
- package/components/composables/useParent.ts +41 -0
- package/components/composables/usePopover.ts +176 -0
- package/components/composables/useQueue.ts +52 -0
- package/components/composables/useRaf.ts +37 -0
- package/components/composables/useTouch.ts +43 -0
- package/components/composables/useTranslate.ts +12 -0
- package/components/composables/useUpload.ts +364 -0
- package/components/oxy-action-sheet/index.scss +204 -0
- package/components/oxy-action-sheet/oxy-action-sheet.vue +155 -0
- package/components/oxy-action-sheet/types.ts +118 -0
- package/components/oxy-backtop/index.scss +25 -0
- package/components/oxy-backtop/oxy-backtop.vue +45 -0
- package/components/oxy-backtop/types.ts +37 -0
- package/components/oxy-badge/index.scss +63 -0
- package/components/oxy-badge/oxy-badge.vue +61 -0
- package/components/oxy-badge/types.ts +41 -0
- package/components/oxy-button/index.scss +336 -0
- package/components/oxy-button/oxy-button.vue +195 -0
- package/components/oxy-button/types.ts +133 -0
- package/components/oxy-calendar/index.scss +158 -0
- package/components/oxy-calendar/oxy-calendar.vue +451 -0
- package/components/oxy-calendar/types.ts +217 -0
- package/components/oxy-calendar-view/index.scss +0 -0
- package/components/oxy-calendar-view/month/index.scss +162 -0
- package/components/oxy-calendar-view/month/month.vue +389 -0
- package/components/oxy-calendar-view/month/types.ts +20 -0
- package/components/oxy-calendar-view/monthPanel/index.scss +89 -0
- package/components/oxy-calendar-view/monthPanel/month-panel.vue +374 -0
- package/components/oxy-calendar-view/monthPanel/types.ts +48 -0
- package/components/oxy-calendar-view/oxy-calendar-view.vue +111 -0
- package/components/oxy-calendar-view/types.ts +109 -0
- package/components/oxy-calendar-view/utils.ts +429 -0
- package/components/oxy-calendar-view/year/index.scss +153 -0
- package/components/oxy-calendar-view/year/types.ts +20 -0
- package/components/oxy-calendar-view/year/year.vue +202 -0
- package/components/oxy-calendar-view/yearPanel/index.scss +24 -0
- package/components/oxy-calendar-view/yearPanel/types.ts +38 -0
- package/components/oxy-calendar-view/yearPanel/year-panel.vue +135 -0
- package/components/oxy-card/index.scss +71 -0
- package/components/oxy-card/oxy-card.vue +37 -0
- package/components/oxy-card/types.ts +30 -0
- package/components/oxy-cell/index.scss +206 -0
- package/components/oxy-cell/oxy-cell.vue +140 -0
- package/components/oxy-cell/types.ts +111 -0
- package/components/oxy-cell-group/index.scss +56 -0
- package/components/oxy-cell-group/oxy-cell-group.vue +45 -0
- package/components/oxy-cell-group/types.ts +32 -0
- package/components/oxy-checkbox/index.scss +285 -0
- package/components/oxy-checkbox/oxy-checkbox.vue +177 -0
- package/components/oxy-checkbox/types.ts +68 -0
- package/components/oxy-checkbox-group/index.scss +20 -0
- package/components/oxy-checkbox-group/oxy-checkbox-group.vue +100 -0
- package/components/oxy-checkbox-group/types.ts +59 -0
- package/components/oxy-circle/index.scss +18 -0
- package/components/oxy-circle/oxy-circle.vue +296 -0
- package/components/oxy-circle/types.ts +54 -0
- package/components/oxy-col/index.scss +19 -0
- package/components/oxy-col/oxy-col.vue +49 -0
- package/components/oxy-col/types.ts +15 -0
- package/components/oxy-col-picker/index.scss +168 -0
- package/components/oxy-col-picker/oxy-col-picker.vue +498 -0
- package/components/oxy-col-picker/types.ts +166 -0
- package/components/oxy-collapse/index.scss +55 -0
- package/components/oxy-collapse/oxy-collapse.vue +151 -0
- package/components/oxy-collapse/types.ts +58 -0
- package/components/oxy-collapse-item/index.scss +90 -0
- package/components/oxy-collapse-item/oxy-collapse-item.vue +171 -0
- package/components/oxy-collapse-item/types.ts +48 -0
- package/components/oxy-config-provider/oxy-config-provider.vue +73 -0
- package/components/oxy-config-provider/types.ts +1052 -0
- package/components/oxy-count-down/index.scss +15 -0
- package/components/oxy-count-down/oxy-count-down.vue +60 -0
- package/components/oxy-count-down/types.ts +41 -0
- package/components/oxy-count-down/utils.ts +52 -0
- package/components/oxy-count-to/index.scss +7 -0
- package/components/oxy-count-to/oxy-count-to.vue +125 -0
- package/components/oxy-count-to/types.ts +117 -0
- package/components/oxy-curtain/index.scss +85 -0
- package/components/oxy-curtain/oxy-curtain.vue +172 -0
- package/components/oxy-curtain/types.ts +73 -0
- package/components/oxy-datetime-picker/index.scss +164 -0
- package/components/oxy-datetime-picker/oxy-datetime-picker.vue +801 -0
- package/components/oxy-datetime-picker/types.ts +231 -0
- package/components/oxy-datetime-picker-view/oxy-datetime-picker-view.vue +499 -0
- package/components/oxy-datetime-picker-view/types.ts +120 -0
- package/components/oxy-datetime-picker-view/util.ts +30 -0
- package/components/oxy-design-uni/oxy-design-uni.vue +5 -0
- package/components/oxy-divider/index.scss +100 -0
- package/components/oxy-divider/oxy-divider.vue +52 -0
- package/components/oxy-divider/types.ts +35 -0
- package/components/oxy-drop-menu/index.scss +86 -0
- package/components/oxy-drop-menu/oxy-drop-menu.vue +166 -0
- package/components/oxy-drop-menu/types.ts +38 -0
- package/components/oxy-drop-menu-item/index.scss +66 -0
- package/components/oxy-drop-menu-item/oxy-drop-menu-item.vue +221 -0
- package/components/oxy-drop-menu-item/types.ts +94 -0
- package/components/oxy-fab/index.scss +116 -0
- package/components/oxy-fab/oxy-fab.vue +276 -0
- package/components/oxy-fab/types.ts +66 -0
- package/components/oxy-floating-panel/index.scss +64 -0
- package/components/oxy-floating-panel/oxy-floating-panel.vue +140 -0
- package/components/oxy-floating-panel/type.ts +32 -0
- package/components/oxy-form/oxy-form.vue +207 -0
- package/components/oxy-form/types.ts +76 -0
- package/components/oxy-form-item/index.scss +18 -0
- package/components/oxy-form-item/oxy-form-item.vue +56 -0
- package/components/oxy-form-item/types.ts +16 -0
- package/components/oxy-gap/index.scss +9 -0
- package/components/oxy-gap/oxy-gap.vue +36 -0
- package/components/oxy-gap/types.ts +17 -0
- package/components/oxy-grid/index.scss +9 -0
- package/components/oxy-grid/oxy-grid.vue +106 -0
- package/components/oxy-grid/types.ts +50 -0
- package/components/oxy-grid-item/index.scss +148 -0
- package/components/oxy-grid-item/oxy-grid-item.vue +176 -0
- package/components/oxy-grid-item/types.ts +77 -0
- package/components/oxy-icon/index.scss +1230 -0
- package/components/oxy-icon/oxy-icon.vue +53 -0
- package/components/oxy-icon/oxy-icons.ttf +0 -0
- package/components/oxy-icon/types.ts +21 -0
- package/components/oxy-img/index.scss +19 -0
- package/components/oxy-img/oxy-img.vue +81 -0
- package/components/oxy-img/types.ts +61 -0
- package/components/oxy-img-cropper/index.scss +231 -0
- package/components/oxy-img-cropper/oxy-img-cropper.vue +664 -0
- package/components/oxy-img-cropper/types.ts +76 -0
- package/components/oxy-index-anchor/index.scss +35 -0
- package/components/oxy-index-anchor/oxy-index-anchor.vue +55 -0
- package/components/oxy-index-anchor/type.ts +9 -0
- package/components/oxy-index-bar/index.scss +39 -0
- package/components/oxy-index-bar/oxy-index-bar.vue +156 -0
- package/components/oxy-index-bar/type.ts +23 -0
- package/components/oxy-input/index.scss +323 -0
- package/components/oxy-input/oxy-input.vue +300 -0
- package/components/oxy-input/placeholder.scss +21 -0
- package/components/oxy-input/types.ts +189 -0
- package/components/oxy-input-number/index.scss +132 -0
- package/components/oxy-input-number/oxy-input-number.vue +464 -0
- package/components/oxy-input-number/types.ts +101 -0
- package/components/oxy-keyboard/constants.ts +81 -0
- package/components/oxy-keyboard/index.scss +102 -0
- package/components/oxy-keyboard/key/index.scss +79 -0
- package/components/oxy-keyboard/key/index.vue +76 -0
- package/components/oxy-keyboard/key/types.ts +11 -0
- package/components/oxy-keyboard/oxy-keyboard.vue +206 -0
- package/components/oxy-keyboard/types.ts +92 -0
- package/components/oxy-loading/index.scss +37 -0
- package/components/oxy-loading/oxy-loading.vue +90 -0
- package/components/oxy-loading/types.ts +22 -0
- package/components/oxy-loadmore/index.scss +39 -0
- package/components/oxy-loadmore/oxy-loadmore.vue +59 -0
- package/components/oxy-loadmore/types.ts +30 -0
- package/components/oxy-message-box/index.scss +108 -0
- package/components/oxy-message-box/index.ts +87 -0
- package/components/oxy-message-box/oxy-message-box.vue +291 -0
- package/components/oxy-message-box/types.ts +132 -0
- package/components/oxy-navbar/index.scss +93 -0
- package/components/oxy-navbar/oxy-navbar.vue +111 -0
- package/components/oxy-navbar/types.ts +52 -0
- package/components/oxy-navbar-capsule/index.scss +66 -0
- package/components/oxy-navbar-capsule/oxy-navbar-capsule.vue +35 -0
- package/components/oxy-navbar-capsule/types.ts +8 -0
- package/components/oxy-notice-bar/index.scss +68 -0
- package/components/oxy-notice-bar/oxy-notice-bar.vue +266 -0
- package/components/oxy-notice-bar/types.ts +67 -0
- package/components/oxy-notify/index.scss +34 -0
- package/components/oxy-notify/index.ts +61 -0
- package/components/oxy-notify/oxy-notify.vue +85 -0
- package/components/oxy-notify/types.ts +66 -0
- package/components/oxy-number-keyboard/index.scss +78 -0
- package/components/oxy-number-keyboard/key/index.scss +81 -0
- package/components/oxy-number-keyboard/key/index.vue +78 -0
- package/components/oxy-number-keyboard/key/types.ts +11 -0
- package/components/oxy-number-keyboard/oxy-number-keyboard.vue +151 -0
- package/components/oxy-number-keyboard/types.ts +83 -0
- package/components/oxy-overlay/index.scss +17 -0
- package/components/oxy-overlay/oxy-overlay.vue +47 -0
- package/components/oxy-overlay/types.ts +25 -0
- package/components/oxy-pagination/index.scss +57 -0
- package/components/oxy-pagination/oxy-pagination.vue +110 -0
- package/components/oxy-pagination/types.ts +41 -0
- package/components/oxy-password-input/index.scss +124 -0
- package/components/oxy-password-input/oxy-password-input.vue +49 -0
- package/components/oxy-password-input/types.ts +33 -0
- package/components/oxy-picker/index.scss +110 -0
- package/components/oxy-picker/oxy-picker.vue +412 -0
- package/components/oxy-picker/types.ts +189 -0
- package/components/oxy-picker-view/index.scss +92 -0
- package/components/oxy-picker-view/oxy-picker-view.vue +369 -0
- package/components/oxy-picker-view/types.ts +152 -0
- package/components/oxy-popover/index.scss +116 -0
- package/components/oxy-popover/oxy-popover.vue +180 -0
- package/components/oxy-popover/types.ts +69 -0
- package/components/oxy-popup/index.scss +84 -0
- package/components/oxy-popup/oxy-popup.vue +169 -0
- package/components/oxy-popup/types.ts +95 -0
- package/components/oxy-progress/index.scss +68 -0
- package/components/oxy-progress/oxy-progress.vue +197 -0
- package/components/oxy-progress/types.ts +35 -0
- package/components/oxy-radio/index.scss +301 -0
- package/components/oxy-radio/oxy-radio.vue +118 -0
- package/components/oxy-radio/types.ts +42 -0
- package/components/oxy-radio-group/index.scss +23 -0
- package/components/oxy-radio-group/oxy-radio-group.vue +51 -0
- package/components/oxy-radio-group/types.ts +39 -0
- package/components/oxy-rate/index.scss +25 -0
- package/components/oxy-rate/oxy-rate.vue +178 -0
- package/components/oxy-rate/types.ts +103 -0
- package/components/oxy-resize/index.scss +27 -0
- package/components/oxy-resize/oxy-resize.vue +144 -0
- package/components/oxy-resize/types.ts +6 -0
- package/components/oxy-root-portal/oxy-root-portal.vue +50 -0
- package/components/oxy-row/index.scss +10 -0
- package/components/oxy-row/oxy-row.vue +42 -0
- package/components/oxy-row/types.ts +16 -0
- package/components/oxy-search/index.scss +148 -0
- package/components/oxy-search/oxy-search.vue +187 -0
- package/components/oxy-search/types.ts +93 -0
- package/components/oxy-segmented/index.scss +101 -0
- package/components/oxy-segmented/oxy-segmented.vue +143 -0
- package/components/oxy-segmented/types.ts +71 -0
- package/components/oxy-select-picker/index.scss +102 -0
- package/components/oxy-select-picker/oxy-select-picker.vue +432 -0
- package/components/oxy-select-picker/types.ts +123 -0
- package/components/oxy-sidebar/index.scss +25 -0
- package/components/oxy-sidebar/oxy-sidebar.vue +63 -0
- package/components/oxy-sidebar/types.ts +38 -0
- package/components/oxy-sidebar-item/index.scss +97 -0
- package/components/oxy-sidebar-item/oxy-sidebar-item.vue +116 -0
- package/components/oxy-sidebar-item/types.ts +31 -0
- package/components/oxy-signature/index.scss +31 -0
- package/components/oxy-signature/oxy-signature.vue +630 -0
- package/components/oxy-signature/types.ts +108 -0
- package/components/oxy-skeleton/index.scss +96 -0
- package/components/oxy-skeleton/index.ts +1 -0
- package/components/oxy-skeleton/oxy-skeleton.vue +110 -0
- package/components/oxy-skeleton/types.ts +69 -0
- package/components/oxy-slider/index.scss +98 -0
- package/components/oxy-slider/oxy-slider.vue +356 -0
- package/components/oxy-slider/types.ts +138 -0
- package/components/oxy-sort-button/index.scss +89 -0
- package/components/oxy-sort-button/oxy-sort-button.vue +69 -0
- package/components/oxy-sort-button/types.ts +43 -0
- package/components/oxy-status-tip/images/collect.png +0 -0
- package/components/oxy-status-tip/images/content.png +0 -0
- package/components/oxy-status-tip/images/network.png +0 -0
- package/components/oxy-status-tip/images/search.png +0 -0
- package/components/oxy-status-tip/index.scss +37 -0
- package/components/oxy-status-tip/oxy-status-tip.vue +71 -0
- package/components/oxy-status-tip/types.ts +50 -0
- package/components/oxy-step/index.scss +235 -0
- package/components/oxy-step/oxy-step.vue +150 -0
- package/components/oxy-step/types.ts +33 -0
- package/components/oxy-steps/index.scss +10 -0
- package/components/oxy-steps/oxy-steps.vue +28 -0
- package/components/oxy-steps/types.ts +50 -0
- package/components/oxy-sticky/index.scss +9 -0
- package/components/oxy-sticky/oxy-sticky.vue +190 -0
- package/components/oxy-sticky/types.ts +13 -0
- package/components/oxy-sticky-box/index.scss +6 -0
- package/components/oxy-sticky-box/oxy-sticky-box.vue +155 -0
- package/components/oxy-sticky-box/types.ts +11 -0
- package/components/oxy-swipe-action/index.scss +22 -0
- package/components/oxy-swipe-action/oxy-swipe-action.vue +294 -0
- package/components/oxy-swipe-action/types.ts +40 -0
- package/components/oxy-swiper/index.scss +53 -0
- package/components/oxy-swiper/oxy-swiper.vue +318 -0
- package/components/oxy-swiper/types.ts +264 -0
- package/components/oxy-swiper-nav/index.scss +159 -0
- package/components/oxy-swiper-nav/oxy-swiper-nav.vue +37 -0
- package/components/oxy-swiper-nav/types.ts +42 -0
- package/components/oxy-switch/index.scss +58 -0
- package/components/oxy-switch/oxy-switch.vue +83 -0
- package/components/oxy-switch/types.ts +58 -0
- package/components/oxy-tab/index.scss +16 -0
- package/components/oxy-tab/oxy-tab.vue +88 -0
- package/components/oxy-tab/types.ts +30 -0
- package/components/oxy-tabbar/index.scss +62 -0
- package/components/oxy-tabbar/oxy-tabbar.vue +91 -0
- package/components/oxy-tabbar/types.ts +73 -0
- package/components/oxy-tabbar-item/index.scss +55 -0
- package/components/oxy-tabbar-item/oxy-tabbar-item.vue +99 -0
- package/components/oxy-tabbar-item/types.ts +51 -0
- package/components/oxy-table/index.scss +163 -0
- package/components/oxy-table/oxy-table.vue +283 -0
- package/components/oxy-table/types.ts +58 -0
- package/components/oxy-table-col/index.scss +46 -0
- package/components/oxy-table-col/oxy-table-col.vue +149 -0
- package/components/oxy-table-col/types.ts +54 -0
- package/components/oxy-tabs/index.scss +299 -0
- package/components/oxy-tabs/oxy-tabs.vue +443 -0
- package/components/oxy-tabs/types.ts +107 -0
- package/components/oxy-tag/index.scss +115 -0
- package/components/oxy-tag/oxy-tag.vue +148 -0
- package/components/oxy-tag/types.ts +81 -0
- package/components/oxy-text/index.scss +37 -0
- package/components/oxy-text/oxy-text.vue +139 -0
- package/components/oxy-text/types.ts +98 -0
- package/components/oxy-textarea/index.scss +340 -0
- package/components/oxy-textarea/oxy-textarea.vue +296 -0
- package/components/oxy-textarea/placeholder.scss +20 -0
- package/components/oxy-textarea/types.ts +288 -0
- package/components/oxy-toast/index.scss +75 -0
- package/components/oxy-toast/index.ts +92 -0
- package/components/oxy-toast/oxy-toast.vue +198 -0
- package/components/oxy-toast/types.ts +181 -0
- package/components/oxy-tooltip/index.scss +66 -0
- package/components/oxy-tooltip/oxy-tooltip.vue +141 -0
- package/components/oxy-tooltip/types.ts +107 -0
- package/components/oxy-transition/index.scss +95 -0
- package/components/oxy-transition/oxy-transition.vue +232 -0
- package/components/oxy-transition/types.ts +98 -0
- package/components/oxy-upload/index.scss +175 -0
- package/components/oxy-upload/oxy-upload.vue +673 -0
- package/components/oxy-upload/types.ts +391 -0
- package/components/oxy-video-preview/index.scss +34 -0
- package/components/oxy-video-preview/oxy-video-preview.vue +72 -0
- package/components/oxy-video-preview/types.ts +23 -0
- package/components/oxy-watermark/index.scss +18 -0
- package/components/oxy-watermark/oxy-watermark.vue +486 -0
- package/components/oxy-watermark/types.ts +76 -0
- package/dayjs/constant.js +26 -0
- package/dayjs/index.d.ts +430 -0
- package/dayjs/index.js +542 -0
- package/dayjs/locale/en.js +13 -0
- package/dayjs/utils.js +59 -0
- package/global.d.ts +101 -0
- package/index.ts +12 -0
- package/locale/index.ts +32 -0
- package/locale/lang/ar-SA.ts +133 -0
- package/locale/lang/en-US.ts +133 -0
- package/locale/lang/zh-CN.ts +137 -0
- package/package.json +1 -0
- package/tags.json +1 -0
- package/web-types.json +1 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view>
|
|
3
|
+
<oxy-toast selector="oxy-month" />
|
|
4
|
+
<view class="month">
|
|
5
|
+
<view class="oxy-month">
|
|
6
|
+
<view class="oxy-month__title" v-if="showTitle">{{ monthTitle(date) }}</view>
|
|
7
|
+
<view class="oxy-month__days">
|
|
8
|
+
<view
|
|
9
|
+
v-for="(item, index) in days"
|
|
10
|
+
:key="index"
|
|
11
|
+
:class="`oxy-month__day ${item.disabled ? 'is-disabled' : ''} ${item.isLastRow ? 'is-last-row' : ''} ${
|
|
12
|
+
item.type ? dayTypeClass(item.type) : ''
|
|
13
|
+
}`"
|
|
14
|
+
:style="index === 0 ? firstDayStyle : ''"
|
|
15
|
+
@click="handleDateClick(index)"
|
|
16
|
+
>
|
|
17
|
+
<view class="oxy-month__day-container">
|
|
18
|
+
<view class="oxy-month__day-top">{{ item.topInfo }}</view>
|
|
19
|
+
<view class="oxy-month__day-text">
|
|
20
|
+
{{ item.text }}
|
|
21
|
+
</view>
|
|
22
|
+
<view class="oxy-month__day-bottom">{{ item.bottomInfo }}</view>
|
|
23
|
+
</view>
|
|
24
|
+
</view>
|
|
25
|
+
</view>
|
|
26
|
+
</view>
|
|
27
|
+
</view>
|
|
28
|
+
</view>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script lang="ts">
|
|
32
|
+
export default {
|
|
33
|
+
options: {
|
|
34
|
+
addGlobalClass: true,
|
|
35
|
+
virtualHost: true,
|
|
36
|
+
styleIsolation: 'shared'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<script lang="ts" setup>
|
|
42
|
+
import OxyToast from '../../oxy-toast/oxy-toast.vue'
|
|
43
|
+
import { computed, ref, watch, type CSSProperties } from 'vue'
|
|
44
|
+
import {
|
|
45
|
+
compareDate,
|
|
46
|
+
formatMonthTitle,
|
|
47
|
+
getDateByDefaultTime,
|
|
48
|
+
getDayByOffset,
|
|
49
|
+
getDayOffset,
|
|
50
|
+
getItemClass,
|
|
51
|
+
getMonthEndDay,
|
|
52
|
+
getNextDay,
|
|
53
|
+
getPrevDay,
|
|
54
|
+
getWeekRange
|
|
55
|
+
} from '../utils'
|
|
56
|
+
import { useToast } from '../../oxy-toast'
|
|
57
|
+
import { deepClone, isArray, isFunction, objToStyle } from '../../common/util'
|
|
58
|
+
import { useTranslate } from '../../composables/useTranslate'
|
|
59
|
+
import type { CalendarDayItem, CalendarDayType } from '../types'
|
|
60
|
+
import { monthProps } from './types'
|
|
61
|
+
|
|
62
|
+
const props = defineProps(monthProps)
|
|
63
|
+
const emit = defineEmits(['change'])
|
|
64
|
+
|
|
65
|
+
const { translate } = useTranslate('calendar-view')
|
|
66
|
+
|
|
67
|
+
const days = ref<Array<CalendarDayItem>>([])
|
|
68
|
+
|
|
69
|
+
const toast = useToast('oxy-month')
|
|
70
|
+
|
|
71
|
+
const offset = computed(() => {
|
|
72
|
+
const firstDayOfWeek = props.firstDayOfWeek >= 7 ? props.firstDayOfWeek % 7 : props.firstDayOfWeek
|
|
73
|
+
const offset = (7 + new Date(props.date).getDay() - firstDayOfWeek) % 7
|
|
74
|
+
return offset
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const dayTypeClass = computed(() => {
|
|
78
|
+
return (monthType: CalendarDayType) => {
|
|
79
|
+
return getItemClass(monthType, props.value, props.type)
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const monthTitle = computed(() => {
|
|
84
|
+
return (date: number) => {
|
|
85
|
+
return formatMonthTitle(date)
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const firstDayStyle = computed(() => {
|
|
90
|
+
const dayStyle: CSSProperties = {}
|
|
91
|
+
dayStyle.marginLeft = `${(100 / 7) * offset.value}%`
|
|
92
|
+
return objToStyle(dayStyle)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const isLastRow = (date: number) => {
|
|
96
|
+
const currentDate = new Date(date)
|
|
97
|
+
const currentDay = currentDate.getDate()
|
|
98
|
+
const daysInMonth = getMonthEndDay(currentDate.getFullYear(), currentDate.getMonth() + 1)
|
|
99
|
+
const totalDaysShown = offset.value + daysInMonth
|
|
100
|
+
const totalRows = Math.ceil(totalDaysShown / 7)
|
|
101
|
+
return Math.ceil((offset.value + currentDay) / 7) === totalRows
|
|
102
|
+
}
|
|
103
|
+
watch(
|
|
104
|
+
[() => props.type, () => props.date, () => props.value, () => props.minDate, () => props.maxDate, () => props.formatter],
|
|
105
|
+
() => {
|
|
106
|
+
setDays()
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
deep: true,
|
|
110
|
+
immediate: true
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
function setDays() {
|
|
115
|
+
const dayList: Array<CalendarDayItem> = []
|
|
116
|
+
const date = new Date(props.date)
|
|
117
|
+
const year = date.getFullYear()
|
|
118
|
+
const month = date.getMonth()
|
|
119
|
+
const totalDay = getMonthEndDay(year, month + 1)
|
|
120
|
+
let value = props.value
|
|
121
|
+
if ((props.type === 'week' || props.type === 'weekrange') && value) {
|
|
122
|
+
value = getWeekValue()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (let day = 1; day <= totalDay; day++) {
|
|
126
|
+
const date = new Date(year, month, day).getTime()
|
|
127
|
+
let type: CalendarDayType = getDayType(date, value as number | number[] | null)
|
|
128
|
+
if (!type && compareDate(date, Date.now()) === 0) {
|
|
129
|
+
type = 'current'
|
|
130
|
+
}
|
|
131
|
+
const dayObj = getFormatterDate(date, day, type)
|
|
132
|
+
dayList.push(dayObj)
|
|
133
|
+
}
|
|
134
|
+
days.value = dayList
|
|
135
|
+
}
|
|
136
|
+
function getDayType(date: number, value: number | number[] | null): CalendarDayType {
|
|
137
|
+
switch (props.type) {
|
|
138
|
+
case 'date':
|
|
139
|
+
case 'datetime':
|
|
140
|
+
return getDateType(date)
|
|
141
|
+
case 'dates':
|
|
142
|
+
return getDatesType(date)
|
|
143
|
+
case 'daterange':
|
|
144
|
+
case 'datetimerange':
|
|
145
|
+
return getDatetimeType(date, value)
|
|
146
|
+
case 'week':
|
|
147
|
+
return getWeektimeType(date, value)
|
|
148
|
+
case 'weekrange':
|
|
149
|
+
return getWeektimeType(date, value)
|
|
150
|
+
default:
|
|
151
|
+
return getDateType(date)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function getDateType(date: number): CalendarDayType {
|
|
155
|
+
if (props.value && compareDate(date, props.value as number) === 0) {
|
|
156
|
+
return 'selected'
|
|
157
|
+
}
|
|
158
|
+
return ''
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function getDatesType(date: number): CalendarDayType {
|
|
162
|
+
const { value } = props
|
|
163
|
+
let type: CalendarDayType = ''
|
|
164
|
+
|
|
165
|
+
if (!isArray(value)) return type
|
|
166
|
+
const isSelected = (day: number) => {
|
|
167
|
+
return value.some((item) => compareDate(day, item) === 0)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (isSelected(date)) {
|
|
171
|
+
const prevDay = getPrevDay(date)
|
|
172
|
+
const nextDay = getNextDay(date)
|
|
173
|
+
const prevSelected = isSelected(prevDay)
|
|
174
|
+
const nextSelected = isSelected(nextDay)
|
|
175
|
+
if (prevSelected && nextSelected) {
|
|
176
|
+
type = 'multiple-middle'
|
|
177
|
+
} else if (prevSelected) {
|
|
178
|
+
type = 'end'
|
|
179
|
+
} else if (nextSelected) {
|
|
180
|
+
type = 'start'
|
|
181
|
+
} else {
|
|
182
|
+
type = 'multiple-selected'
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return type
|
|
187
|
+
}
|
|
188
|
+
function getDatetimeType(date: number, value: number | number[] | null) {
|
|
189
|
+
const [startDate, endDate] = isArray(value) ? value : []
|
|
190
|
+
|
|
191
|
+
if (startDate && compareDate(date, startDate) === 0) {
|
|
192
|
+
if (props.allowSameDay && endDate && compareDate(startDate, endDate) === 0) {
|
|
193
|
+
return 'same'
|
|
194
|
+
}
|
|
195
|
+
return 'start'
|
|
196
|
+
} else if (endDate && compareDate(date, endDate) === 0) {
|
|
197
|
+
return 'end'
|
|
198
|
+
} else if (startDate && endDate && compareDate(date, startDate) === 1 && compareDate(date, endDate) === -1) {
|
|
199
|
+
return 'middle'
|
|
200
|
+
} else {
|
|
201
|
+
return ''
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function getWeektimeType(date: number, value: number | number[] | null) {
|
|
205
|
+
const [startDate, endDate] = isArray(value) ? value : []
|
|
206
|
+
|
|
207
|
+
if (startDate && compareDate(date, startDate) === 0) {
|
|
208
|
+
return 'start'
|
|
209
|
+
} else if (endDate && compareDate(date, endDate) === 0) {
|
|
210
|
+
return 'end'
|
|
211
|
+
} else if (startDate && endDate && compareDate(date, startDate) === 1 && compareDate(date, endDate) === -1) {
|
|
212
|
+
return 'middle'
|
|
213
|
+
} else {
|
|
214
|
+
return ''
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function getWeekValue() {
|
|
218
|
+
if (props.type === 'week') {
|
|
219
|
+
return getWeekRange(props.value as number, props.firstDayOfWeek)
|
|
220
|
+
} else {
|
|
221
|
+
const [startDate, endDate] = (props.value as any) || []
|
|
222
|
+
|
|
223
|
+
if (startDate) {
|
|
224
|
+
const firstWeekRange = getWeekRange(startDate, props.firstDayOfWeek)
|
|
225
|
+
|
|
226
|
+
if (endDate) {
|
|
227
|
+
const endWeekRange = getWeekRange(endDate, props.firstDayOfWeek)
|
|
228
|
+
|
|
229
|
+
return [firstWeekRange[0], endWeekRange[1]]
|
|
230
|
+
} else {
|
|
231
|
+
return firstWeekRange
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return []
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function handleDateClick(index: number) {
|
|
239
|
+
const date = days.value[index]
|
|
240
|
+
switch (props.type) {
|
|
241
|
+
case 'date':
|
|
242
|
+
case 'datetime':
|
|
243
|
+
handleDateChange(date)
|
|
244
|
+
break
|
|
245
|
+
case 'dates':
|
|
246
|
+
handleDatesChange(date)
|
|
247
|
+
break
|
|
248
|
+
case 'daterange':
|
|
249
|
+
case 'datetimerange':
|
|
250
|
+
handleDateRangeChange(date)
|
|
251
|
+
break
|
|
252
|
+
case 'week':
|
|
253
|
+
handleWeekChange(date)
|
|
254
|
+
break
|
|
255
|
+
case 'weekrange':
|
|
256
|
+
handleWeekRangeChange(date)
|
|
257
|
+
break
|
|
258
|
+
default:
|
|
259
|
+
handleDateChange(date)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function getDate(date: number, isEnd: boolean = false) {
|
|
263
|
+
date = props.defaultTime && props.defaultTime.length > 0 ? getDateByDefaultTime(date, isEnd ? props.defaultTime[1] : props.defaultTime[0]) : date
|
|
264
|
+
|
|
265
|
+
if (date < props.minDate) return props.minDate
|
|
266
|
+
|
|
267
|
+
if (date > props.maxDate) return props.maxDate
|
|
268
|
+
|
|
269
|
+
return date
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function handleDateChange(date: CalendarDayItem) {
|
|
273
|
+
if (date.disabled) return
|
|
274
|
+
|
|
275
|
+
if (date.type !== 'selected') {
|
|
276
|
+
emit('change', {
|
|
277
|
+
value: getDate(date.date),
|
|
278
|
+
type: 'start'
|
|
279
|
+
})
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function handleDatesChange(date: CalendarDayItem) {
|
|
283
|
+
if (date.disabled) return
|
|
284
|
+
const currentValue = deepClone(isArray(props.value) ? props.value : [])
|
|
285
|
+
const dateIndex = currentValue.findIndex((item) => item && compareDate(item, date.date) === 0)
|
|
286
|
+
const value = dateIndex === -1 ? [...currentValue, getDate(date.date)] : currentValue.filter((_, index) => index !== dateIndex)
|
|
287
|
+
emit('change', { value })
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function handleDateRangeChange(date: CalendarDayItem) {
|
|
291
|
+
if (date.disabled) return
|
|
292
|
+
|
|
293
|
+
let value: (number | null)[] = []
|
|
294
|
+
let type: CalendarDayType = ''
|
|
295
|
+
const [startDate, endDate] = deepClone(isArray(props.value) ? props.value : [])
|
|
296
|
+
const compare = compareDate(date.date, startDate)
|
|
297
|
+
|
|
298
|
+
// 禁止选择同个日期
|
|
299
|
+
if (!props.allowSameDay && compare === 0 && (props.type === 'daterange' || props.type === 'datetimerange') && !endDate) {
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (startDate && !endDate && compare > -1) {
|
|
304
|
+
// 不能选择超过最大范围的日期
|
|
305
|
+
if (props.maxRange && getDayOffset(date.date, startDate) > props.maxRange) {
|
|
306
|
+
const maxEndDate = getDayByOffset(startDate, props.maxRange - 1)
|
|
307
|
+
value = [startDate, getDate(maxEndDate, true)]
|
|
308
|
+
toast.show({
|
|
309
|
+
msg: props.rangePrompt || translate('rangePrompt', props.maxRange)
|
|
310
|
+
})
|
|
311
|
+
} else {
|
|
312
|
+
value = [startDate, getDate(date.date, true)]
|
|
313
|
+
}
|
|
314
|
+
} else if (props.type === 'datetimerange' && startDate && endDate) {
|
|
315
|
+
// 时间范围类型,且有开始时间和结束时间,需要支持重新点击开始日期和结束日期可以重新修改时间
|
|
316
|
+
if (compare === 0) {
|
|
317
|
+
type = 'start'
|
|
318
|
+
value = props.value as number[]
|
|
319
|
+
} else if (compareDate(date.date, endDate) === 0) {
|
|
320
|
+
type = 'end'
|
|
321
|
+
value = props.value as number[]
|
|
322
|
+
} else {
|
|
323
|
+
value = [getDate(date.date), null]
|
|
324
|
+
}
|
|
325
|
+
} else {
|
|
326
|
+
value = [getDate(date.date), null]
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
emit('change', {
|
|
330
|
+
value,
|
|
331
|
+
type: type || (value[1] ? 'end' : 'start')
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
function handleWeekChange(date: CalendarDayItem) {
|
|
335
|
+
const [weekStart] = getWeekRange(date.date, props.firstDayOfWeek)
|
|
336
|
+
|
|
337
|
+
// 周的第一天如果是禁用状态,则不可选中
|
|
338
|
+
if (getFormatterDate(weekStart, new Date(weekStart).getDate()).disabled) return
|
|
339
|
+
|
|
340
|
+
emit('change', {
|
|
341
|
+
value: getDate(weekStart) + 24 * 60 * 60 * 1000
|
|
342
|
+
})
|
|
343
|
+
}
|
|
344
|
+
function handleWeekRangeChange(date: CalendarDayItem) {
|
|
345
|
+
const [weekStartDate] = getWeekRange(date.date, props.firstDayOfWeek)
|
|
346
|
+
|
|
347
|
+
// 周的第一天如果是禁用状态,则不可选中
|
|
348
|
+
if (getFormatterDate(weekStartDate, new Date(weekStartDate).getDate()).disabled) return
|
|
349
|
+
|
|
350
|
+
let value: (number | null)[] = []
|
|
351
|
+
const [startDate, endDate] = deepClone(isArray(props.value) ? props.value : [])
|
|
352
|
+
const [startWeekStartDate] = startDate ? getWeekRange(startDate, props.firstDayOfWeek) : []
|
|
353
|
+
const compare = compareDate(weekStartDate, startWeekStartDate)
|
|
354
|
+
|
|
355
|
+
if (startDate && !endDate && compare > -1) {
|
|
356
|
+
if (!props.allowSameDay && compare === 0) return
|
|
357
|
+
|
|
358
|
+
value = [getDate(startWeekStartDate) + 24 * 60 * 60 * 1000, getDate(weekStartDate) + 24 * 60 * 60 * 1000]
|
|
359
|
+
} else {
|
|
360
|
+
value = [getDate(weekStartDate) + 24 * 60 * 60 * 1000, null]
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
emit('change', {
|
|
364
|
+
value
|
|
365
|
+
})
|
|
366
|
+
}
|
|
367
|
+
function getFormatterDate(date: number, day: string | number, type?: CalendarDayType) {
|
|
368
|
+
let dayObj: CalendarDayItem = {
|
|
369
|
+
date: date,
|
|
370
|
+
text: day,
|
|
371
|
+
topInfo: '',
|
|
372
|
+
bottomInfo: '',
|
|
373
|
+
type,
|
|
374
|
+
disabled: compareDate(date, props.minDate) === -1 || compareDate(date, props.maxDate) === 1,
|
|
375
|
+
isLastRow: isLastRow(date)
|
|
376
|
+
}
|
|
377
|
+
if (props.formatter) {
|
|
378
|
+
if (isFunction(props.formatter)) {
|
|
379
|
+
dayObj = props.formatter(dayObj)
|
|
380
|
+
} else {
|
|
381
|
+
console.error('[oxy-design] error(oxy-calendar-view): the formatter prop of oxy-calendar-view should be a function')
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return dayObj
|
|
385
|
+
}
|
|
386
|
+
</script>
|
|
387
|
+
<style lang="scss" scoped>
|
|
388
|
+
@import './index.scss';
|
|
389
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PropType } from 'vue'
|
|
2
|
+
import { makeBooleanProp, makeRequiredProp } from '../../common/props'
|
|
3
|
+
import type { CalendarFormatter, CalendarType } from '../types'
|
|
4
|
+
|
|
5
|
+
export const monthProps = {
|
|
6
|
+
type: makeRequiredProp(String as PropType<CalendarType>),
|
|
7
|
+
date: makeRequiredProp(Number),
|
|
8
|
+
value: makeRequiredProp([Number, Array, null] as PropType<number | (number | null)[] | null>),
|
|
9
|
+
minDate: makeRequiredProp(Number),
|
|
10
|
+
maxDate: makeRequiredProp(Number),
|
|
11
|
+
firstDayOfWeek: makeRequiredProp(Number),
|
|
12
|
+
formatter: Function as PropType<CalendarFormatter>,
|
|
13
|
+
maxRange: Number,
|
|
14
|
+
rangePrompt: String,
|
|
15
|
+
allowSameDay: makeBooleanProp(false),
|
|
16
|
+
defaultTime: {
|
|
17
|
+
type: [Array] as PropType<Array<number[]>>
|
|
18
|
+
},
|
|
19
|
+
showTitle: makeBooleanProp(true)
|
|
20
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
@import '../../common/abstracts/variable';
|
|
2
|
+
@import '../../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
.oxy-theme-dark {
|
|
5
|
+
@include b(month-panel) {
|
|
6
|
+
@include e(title) {
|
|
7
|
+
color: $-dark-color;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@include e(weeks) {
|
|
11
|
+
box-shadow: 0px 4px 8px 0 rgba(255, 255, 255, 0.02);
|
|
12
|
+
color: $-dark-color;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@include e(time-label) {
|
|
16
|
+
color: $-dark-color;
|
|
17
|
+
&::after{
|
|
18
|
+
background: $-dark-background4;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@include b(month-panel) {
|
|
25
|
+
font-size: $-calendar-fs;
|
|
26
|
+
|
|
27
|
+
@include e(title) {
|
|
28
|
+
padding: 5px 0;
|
|
29
|
+
text-align: center;
|
|
30
|
+
font-size: $-calendar-panel-title-fs;
|
|
31
|
+
color: $-calendar-panel-title-color;
|
|
32
|
+
padding: $-calendar-panel-padding;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@include e(weeks) {
|
|
36
|
+
display: flex;
|
|
37
|
+
height: $-calendar-week-height;
|
|
38
|
+
line-height: $-calendar-week-height;
|
|
39
|
+
box-shadow: 0px 4px 8px 0 rgba(0, 0, 0, 0.02);
|
|
40
|
+
color: $-calendar-week-color;
|
|
41
|
+
font-size: $-calendar-week-fs;
|
|
42
|
+
padding: $-calendar-panel-padding;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@include e(week) {
|
|
46
|
+
flex: 1;
|
|
47
|
+
text-align: center;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@include e(container) {
|
|
51
|
+
padding: $-calendar-panel-padding;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@include e(time) {
|
|
56
|
+
display: flex;
|
|
57
|
+
box-shadow: 0px -4px 8px 0px rgba(0, 0, 0, 0.02);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@include e(time-label) {
|
|
61
|
+
position: relative;
|
|
62
|
+
flex: 1;
|
|
63
|
+
font-size: $-picker-column-fs;
|
|
64
|
+
text-align: center;
|
|
65
|
+
line-height: 125px;
|
|
66
|
+
color: $-picker-column-color;
|
|
67
|
+
|
|
68
|
+
&::after {
|
|
69
|
+
position: absolute;
|
|
70
|
+
content: '';
|
|
71
|
+
height: 35px;
|
|
72
|
+
top: 50%;
|
|
73
|
+
left: 0;
|
|
74
|
+
right: 0;
|
|
75
|
+
transform: translateY(-50%);
|
|
76
|
+
background: $-picker-column-select-bg;
|
|
77
|
+
z-index: 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@include e(time-text) {
|
|
82
|
+
position: relative;
|
|
83
|
+
z-index: 1;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@include e(time-picker) {
|
|
87
|
+
flex: 3;
|
|
88
|
+
}
|
|
89
|
+
}
|