@tplc/wot 0.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/components/common/AbortablePromise.ts +36 -0
- package/components/common/abstracts/_config.scss +7 -0
- package/components/common/abstracts/_function.scss +76 -0
- package/components/common/abstracts/_mixin.scss +339 -0
- package/components/common/abstracts/variable.scss +1346 -0
- package/components/common/base64.ts +30 -0
- package/components/common/canvasHelper.ts +49 -0
- package/components/common/clickoutside.ts +34 -0
- package/components/common/dayjs.ts +157 -0
- package/components/common/event.ts +8 -0
- package/components/common/props.ts +51 -0
- package/components/common/util.ts +751 -0
- package/components/composables/useCell.ts +13 -0
- package/components/composables/useChildren.ts +122 -0
- package/components/composables/useCountDown.ts +138 -0
- package/components/composables/useLockScroll.ts +39 -0
- package/components/composables/useParent.ts +41 -0
- package/components/composables/usePopover.ts +193 -0
- package/components/composables/useQueue.ts +52 -0
- package/components/composables/useRaf.ts +37 -0
- package/components/composables/useTouch.ts +44 -0
- package/components/composables/useTranslate.ts +22 -0
- package/components/wd-action-sheet/index.scss +204 -0
- package/components/wd-action-sheet/types.ts +128 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +174 -0
- package/components/wd-backtop/index.scss +25 -0
- package/components/wd-backtop/types.ts +37 -0
- package/components/wd-backtop/wd-backtop.vue +48 -0
- package/components/wd-badge/index.scss +59 -0
- package/components/wd-badge/types.ts +53 -0
- package/components/wd-badge/wd-badge.vue +69 -0
- package/components/wd-button/index.scss +340 -0
- package/components/wd-button/types.ts +112 -0
- package/components/wd-button/wd-button.vue +176 -0
- package/components/wd-calendar/index.scss +244 -0
- package/components/wd-calendar/types.ts +235 -0
- package/components/wd-calendar/wd-calendar.vue +456 -0
- package/components/wd-calendar-view/index.scss +9 -0
- package/components/wd-calendar-view/month/index.scss +151 -0
- package/components/wd-calendar-view/month/month.vue +391 -0
- package/components/wd-calendar-view/month/types.ts +19 -0
- package/components/wd-calendar-view/monthPanel/index.scss +89 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +388 -0
- package/components/wd-calendar-view/monthPanel/types.ts +48 -0
- package/components/wd-calendar-view/types.ts +134 -0
- package/components/wd-calendar-view/utils.ts +451 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +111 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +19 -0
- package/components/wd-calendar-view/year/year.vue +220 -0
- package/components/wd-calendar-view/yearPanel/index.scss +24 -0
- package/components/wd-calendar-view/yearPanel/types.ts +38 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +140 -0
- package/components/wd-card/index.scss +70 -0
- package/components/wd-card/types.ts +30 -0
- package/components/wd-card/wd-card.vue +40 -0
- package/components/wd-cell/index.scss +189 -0
- package/components/wd-cell/types.ts +96 -0
- package/components/wd-cell/wd-cell.vue +135 -0
- package/components/wd-cell-group/index.scss +55 -0
- package/components/wd-cell-group/types.ts +41 -0
- package/components/wd-cell-group/wd-cell-group.vue +45 -0
- package/components/wd-checkbox/index.scss +285 -0
- package/components/wd-checkbox/types.ts +68 -0
- package/components/wd-checkbox/wd-checkbox.vue +185 -0
- package/components/wd-checkbox-group/index.scss +20 -0
- package/components/wd-checkbox-group/types.ts +59 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +103 -0
- package/components/wd-circle/index.scss +18 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +318 -0
- package/components/wd-col/index.scss +19 -0
- package/components/wd-col/types.ts +15 -0
- package/components/wd-col/wd-col.vue +91 -0
- package/components/wd-col-picker/index.scss +241 -0
- package/components/wd-col-picker/types.ts +170 -0
- package/components/wd-col-picker/wd-col-picker.vue +550 -0
- package/components/wd-collapse/index.scss +55 -0
- package/components/wd-collapse/types.ts +63 -0
- package/components/wd-collapse/wd-collapse.vue +160 -0
- package/components/wd-collapse-item/index.scss +79 -0
- package/components/wd-collapse-item/types.ts +36 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +182 -0
- package/components/wd-config-provider/types.ts +1023 -0
- package/components/wd-config-provider/wd-config-provider.vue +82 -0
- package/components/wd-count-down/index.scss +14 -0
- package/components/wd-count-down/types.ts +41 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +60 -0
- package/components/wd-count-to/index.scss +6 -0
- package/components/wd-count-to/types.ts +110 -0
- package/components/wd-count-to/wd-count-to.vue +134 -0
- package/components/wd-curtain/index.scss +80 -0
- package/components/wd-curtain/types.ts +45 -0
- package/components/wd-curtain/wd-curtain.vue +174 -0
- package/components/wd-datetime-picker/index.scss +243 -0
- package/components/wd-datetime-picker/types.ts +225 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +827 -0
- package/components/wd-datetime-picker-view/index.scss +0 -0
- package/components/wd-datetime-picker-view/types.ts +137 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +514 -0
- package/components/wd-divider/index.scss +32 -0
- package/components/wd-divider/types.ts +12 -0
- package/components/wd-divider/wd-divider.vue +29 -0
- package/components/wd-drop-menu/index.scss +89 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +128 -0
- package/components/wd-drop-menu-item/index.scss +66 -0
- package/components/wd-drop-menu-item/types.ts +78 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +230 -0
- package/components/wd-fab/index.scss +115 -0
- package/components/wd-fab/types.ts +61 -0
- package/components/wd-fab/wd-fab.vue +257 -0
- package/components/wd-form/index.scss +10 -0
- package/components/wd-form/types.ts +93 -0
- package/components/wd-form/wd-form.vue +185 -0
- package/components/wd-form-item/index.scss +17 -0
- package/components/wd-form-item/types.ts +22 -0
- package/components/wd-form-item/wd-form-item.vue +65 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +23 -0
- package/components/wd-gap/wd-gap.vue +39 -0
- package/components/wd-grid/index.scss +9 -0
- package/components/wd-grid/types.ts +54 -0
- package/components/wd-grid/wd-grid.vue +107 -0
- package/components/wd-grid-item/index.scss +137 -0
- package/components/wd-grid-item/types.ts +74 -0
- package/components/wd-grid-item/wd-grid-item.vue +181 -0
- package/components/wd-icon/index.scss +1222 -0
- package/components/wd-icon/types.ts +21 -0
- package/components/wd-icon/wd-icon.vue +53 -0
- package/components/wd-icon/wd-icons.ttf +0 -0
- package/components/wd-img/index.scss +19 -0
- package/components/wd-img/types.ts +53 -0
- package/components/wd-img/wd-img.vue +76 -0
- package/components/wd-img-cropper/index.scss +227 -0
- package/components/wd-img-cropper/types.ts +87 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +659 -0
- package/components/wd-index-anchor/index.scss +34 -0
- package/components/wd-index-anchor/type.ts +9 -0
- package/components/wd-index-anchor/wd-index-anchor.vue +57 -0
- package/components/wd-index-bar/index.scss +39 -0
- package/components/wd-index-bar/type.ts +28 -0
- package/components/wd-index-bar/wd-index-bar.vue +158 -0
- package/components/wd-input/index.scss +326 -0
- package/components/wd-input/types.ts +182 -0
- package/components/wd-input/wd-input.vue +327 -0
- package/components/wd-input-number/index.scss +132 -0
- package/components/wd-input-number/types.ts +78 -0
- package/components/wd-input-number/wd-input-number.vue +221 -0
- package/components/wd-loading/index.scss +34 -0
- package/components/wd-loading/types.ts +31 -0
- package/components/wd-loading/wd-loading.vue +90 -0
- package/components/wd-loadmore/index.scss +39 -0
- package/components/wd-loadmore/types.ts +24 -0
- package/components/wd-loadmore/wd-loadmore.vue +53 -0
- package/components/wd-message-box/index.scss +121 -0
- package/components/wd-message-box/index.ts +95 -0
- package/components/wd-message-box/types.ts +116 -0
- package/components/wd-message-box/wd-message-box.vue +326 -0
- package/components/wd-navbar/index.scss +103 -0
- package/components/wd-navbar/types.ts +52 -0
- package/components/wd-navbar/wd-navbar.vue +142 -0
- package/components/wd-navbar-capsule/index.scss +65 -0
- package/components/wd-navbar-capsule/types.ts +0 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +31 -0
- package/components/wd-notice-bar/index.scss +86 -0
- package/components/wd-notice-bar/types.ts +56 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +223 -0
- package/components/wd-notify/index.scss +34 -0
- package/components/wd-notify/index.ts +59 -0
- package/components/wd-notify/types.ts +62 -0
- package/components/wd-notify/wd-notify.vue +83 -0
- package/components/wd-number-keyboard/index.scss +78 -0
- package/components/wd-number-keyboard/key/index.scss +79 -0
- package/components/wd-number-keyboard/key/index.vue +76 -0
- package/components/wd-number-keyboard/key/types.ts +11 -0
- package/components/wd-number-keyboard/types.ts +79 -0
- package/components/wd-number-keyboard/wd-number-keyboard.vue +173 -0
- package/components/wd-overlay/index.scss +17 -0
- package/components/wd-overlay/types.ts +25 -0
- package/components/wd-overlay/wd-overlay.vue +46 -0
- package/components/wd-pagination/index.scss +57 -0
- package/components/wd-pagination/types.ts +41 -0
- package/components/wd-pagination/wd-pagination.vue +121 -0
- package/components/wd-password-input/index.scss +123 -0
- package/components/wd-password-input/types.ts +48 -0
- package/components/wd-password-input/wd-password-input.vue +58 -0
- package/components/wd-picker/index.scss +216 -0
- package/components/wd-picker/types.ts +186 -0
- package/components/wd-picker/wd-picker.vue +409 -0
- package/components/wd-picker-view/index.scss +91 -0
- package/components/wd-picker-view/types.ts +162 -0
- package/components/wd-picker-view/wd-picker-view.vue +361 -0
- package/components/wd-popover/index.scss +123 -0
- package/components/wd-popover/types.ts +69 -0
- package/components/wd-popover/wd-popover.vue +216 -0
- package/components/wd-popup/index.scss +112 -0
- package/components/wd-popup/types.ts +68 -0
- package/components/wd-popup/wd-popup.vue +227 -0
- package/components/wd-progress/index.scss +62 -0
- package/components/wd-progress/types.ts +40 -0
- package/components/wd-progress/wd-progress.vue +201 -0
- package/components/wd-radio/index.scss +300 -0
- package/components/wd-radio/types.ts +42 -0
- package/components/wd-radio/wd-radio.vue +136 -0
- package/components/wd-radio-group/index.scss +23 -0
- package/components/wd-radio-group/types.ts +36 -0
- package/components/wd-radio-group/wd-radio-group.vue +54 -0
- package/components/wd-rate/index.scss +24 -0
- package/components/wd-rate/types.ts +91 -0
- package/components/wd-rate/wd-rate.vue +131 -0
- package/components/wd-resize/index.scss +26 -0
- package/components/wd-resize/types.ts +6 -0
- package/components/wd-resize/wd-resize.vue +155 -0
- package/components/wd-row/index.scss +10 -0
- package/components/wd-row/types.ts +16 -0
- package/components/wd-row/wd-row.vue +63 -0
- package/components/wd-search/index.scss +148 -0
- package/components/wd-search/types.ts +83 -0
- package/components/wd-search/wd-search.vue +237 -0
- package/components/wd-segmented/index.scss +97 -0
- package/components/wd-segmented/types.ts +68 -0
- package/components/wd-segmented/wd-segmented.vue +143 -0
- package/components/wd-select-picker/index.scss +177 -0
- package/components/wd-select-picker/types.ts +116 -0
- package/components/wd-select-picker/wd-select-picker.vue +486 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +28 -0
- package/components/wd-sidebar/wd-sidebar.vue +41 -0
- package/components/wd-sidebar-item/index.scss +93 -0
- package/components/wd-sidebar-item/types.ts +31 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +114 -0
- package/components/wd-skeleton/index.scss +101 -0
- package/components/wd-skeleton/index.ts +1 -0
- package/components/wd-skeleton/types.ts +69 -0
- package/components/wd-skeleton/wd-skeleton.vue +135 -0
- package/components/wd-slider/index.scss +91 -0
- package/components/wd-slider/types.ts +104 -0
- package/components/wd-slider/wd-slider.vue +377 -0
- package/components/wd-sort-button/index.scss +86 -0
- package/components/wd-sort-button/types.ts +43 -0
- package/components/wd-sort-button/wd-sort-button.vue +76 -0
- package/components/wd-status-tip/index.scss +37 -0
- package/components/wd-status-tip/types.ts +59 -0
- package/components/wd-status-tip/wd-status-tip.vue +94 -0
- package/components/wd-step/index.scss +236 -0
- package/components/wd-step/types.ts +33 -0
- package/components/wd-step/wd-step.vue +151 -0
- package/components/wd-steps/index.scss +10 -0
- package/components/wd-steps/types.ts +59 -0
- package/components/wd-steps/wd-steps.vue +37 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +190 -0
- package/components/wd-sticky-box/index.scss +6 -0
- package/components/wd-sticky-box/types.ts +20 -0
- package/components/wd-sticky-box/wd-sticky-box.vue +154 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +43 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +307 -0
- package/components/wd-swiper/index.scss +23 -0
- package/components/wd-swiper/types.ts +189 -0
- package/components/wd-swiper/wd-swiper.vue +202 -0
- package/components/wd-swiper-nav/index.scss +153 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +37 -0
- package/components/wd-switch/index.scss +58 -0
- package/components/wd-switch/types.ts +56 -0
- package/components/wd-switch/wd-switch.vue +83 -0
- package/components/wd-tab/index.scss +8 -0
- package/components/wd-tab/types.ts +20 -0
- package/components/wd-tab/wd-tab.vue +100 -0
- package/components/wd-tabbar/index.scss +57 -0
- package/components/wd-tabbar/types.ts +88 -0
- package/components/wd-tabbar/wd-tabbar.vue +104 -0
- package/components/wd-tabbar-item/index.scss +52 -0
- package/components/wd-tabbar-item/types.ts +51 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +132 -0
- package/components/wd-table/types.ts +69 -0
- package/components/wd-table/wd-table.vue +255 -0
- package/components/wd-table-col/index.scss +44 -0
- package/components/wd-table-col/types.ts +54 -0
- package/components/wd-table-col/wd-table-col.vue +149 -0
- package/components/wd-tabs/index.scss +280 -0
- package/components/wd-tabs/types.ts +71 -0
- package/components/wd-tabs/wd-tabs.vue +528 -0
- package/components/wd-tag/index.scss +115 -0
- package/components/wd-tag/types.ts +81 -0
- package/components/wd-tag/wd-tag.vue +154 -0
- package/components/wd-text/index.scss +34 -0
- package/components/wd-text/types.ts +98 -0
- package/components/wd-text/wd-text.vue +138 -0
- package/components/wd-textarea/index.scss +343 -0
- package/components/wd-textarea/types.ts +298 -0
- package/components/wd-textarea/wd-textarea.vue +303 -0
- package/components/wd-toast/index.scss +66 -0
- package/components/wd-toast/index.ts +109 -0
- package/components/wd-toast/types.ts +76 -0
- package/components/wd-toast/wd-toast.vue +212 -0
- package/components/wd-tooltip/index.scss +61 -0
- package/components/wd-tooltip/types.ts +102 -0
- package/components/wd-tooltip/wd-tooltip.vue +167 -0
- package/components/wd-transition/index.scss +91 -0
- package/components/wd-transition/types.ts +89 -0
- package/components/wd-transition/wd-transition.vue +221 -0
- package/components/wd-upload/index.scss +173 -0
- package/components/wd-upload/types.ts +378 -0
- package/components/wd-upload/utils.ts +152 -0
- package/components/wd-upload/wd-upload.vue +737 -0
- package/components/wd-video-preview/index.scss +34 -0
- package/components/wd-video-preview/types.ts +32 -0
- package/components/wd-video-preview/wd-video-preview.vue +76 -0
- package/components/wd-watermark/index.scss +18 -0
- package/components/wd-watermark/types.ts +82 -0
- package/components/wd-watermark/wd-watermark.vue +592 -0
- package/components/wot-design-uni/wot-design-uni.vue +14 -0
- package/global.d.ts +108 -0
- package/index.ts +30 -0
- package/locale/index.ts +41 -0
- package/locale/lang/en-US.ts +128 -0
- package/locale/lang/th-TH.ts +127 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +127 -0
- package/locale/lang/zh-HK.ts +84 -0
- package/locale/lang/zh-TW.ts +84 -0
- package/package.json +20 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<wd-toast selector="wd-year" />
|
|
3
|
+
|
|
4
|
+
<view class="wd-year year">
|
|
5
|
+
<view class="wd-year__title">{{ yearTitle(date) }}</view>
|
|
6
|
+
<view class="wd-year__months">
|
|
7
|
+
<view
|
|
8
|
+
v-for="(item, index) in months"
|
|
9
|
+
:key="index"
|
|
10
|
+
:class="`wd-year__month ${item.disabled ? 'is-disabled' : ''} ${item.type ? itemClass(item.type, value!, type) : ''}`"
|
|
11
|
+
@click="handleDateClick(index)"
|
|
12
|
+
>
|
|
13
|
+
<view class="wd-year__month-top">{{ item.topInfo }}</view>
|
|
14
|
+
<view class="wd-year__month-text">{{ getMonthLabel(item.date) }}</view>
|
|
15
|
+
<view class="wd-year__month-bottom">{{ item.bottomInfo }}</view>
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</template>
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
export default {
|
|
22
|
+
options: {
|
|
23
|
+
addGlobalClass: true,
|
|
24
|
+
virtualHost: true,
|
|
25
|
+
styleIsolation: 'shared',
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script lang="ts" setup>
|
|
31
|
+
import { computed, ref, watch } from 'vue'
|
|
32
|
+
import { deepClone, isArray, isFunction } from '../../common/util'
|
|
33
|
+
import {
|
|
34
|
+
compareMonth,
|
|
35
|
+
formatYearTitle,
|
|
36
|
+
getDateByDefaultTime,
|
|
37
|
+
getItemClass,
|
|
38
|
+
getMonthByOffset,
|
|
39
|
+
getMonthOffset,
|
|
40
|
+
} from '../utils'
|
|
41
|
+
import { useToast } from '../../wd-toast'
|
|
42
|
+
import { useTranslate } from '../../composables/useTranslate'
|
|
43
|
+
import { dayjs } from '../../common/dayjs'
|
|
44
|
+
import { yearProps } from './types'
|
|
45
|
+
import type { CalendarDayItem, CalendarDayType, CalendarType } from '../types'
|
|
46
|
+
|
|
47
|
+
const props = defineProps(yearProps)
|
|
48
|
+
const emit = defineEmits(['change'])
|
|
49
|
+
|
|
50
|
+
const toast = useToast('wd-year')
|
|
51
|
+
const { translate } = useTranslate('calendar-view')
|
|
52
|
+
|
|
53
|
+
const months = ref<CalendarDayItem[]>([])
|
|
54
|
+
|
|
55
|
+
const itemClass = computed(() => {
|
|
56
|
+
return (monthType: CalendarDayType, value: number | (number | null)[], type: CalendarType) => {
|
|
57
|
+
return getItemClass(monthType, value, type)
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const yearTitle = computed(() => {
|
|
62
|
+
return (date: number) => {
|
|
63
|
+
return formatYearTitle(date)
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
watch(
|
|
68
|
+
[
|
|
69
|
+
() => props.type,
|
|
70
|
+
() => props.date,
|
|
71
|
+
() => props.value,
|
|
72
|
+
() => props.minDate,
|
|
73
|
+
() => props.maxDate,
|
|
74
|
+
() => props.formatter,
|
|
75
|
+
],
|
|
76
|
+
() => {
|
|
77
|
+
setMonths()
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
deep: true,
|
|
81
|
+
immediate: true,
|
|
82
|
+
},
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
function getMonthLabel(date: number) {
|
|
86
|
+
return dayjs(date).format(translate('month', date))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function setMonths() {
|
|
90
|
+
const monthList: CalendarDayItem[] = []
|
|
91
|
+
const date = new Date(props.date)
|
|
92
|
+
const year = date.getFullYear()
|
|
93
|
+
const value = props.value
|
|
94
|
+
|
|
95
|
+
if (props.type.indexOf('range') > -1 && value && !isArray(value)) {
|
|
96
|
+
console.error('[wot-design] value should be array when type is range')
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for (let month = 0; month < 12; month++) {
|
|
101
|
+
const date = new Date(year, month, 1).getTime()
|
|
102
|
+
let type: CalendarDayType = getMonthType(date)
|
|
103
|
+
if (!type && compareMonth(date, Date.now()) === 0) {
|
|
104
|
+
type = 'current'
|
|
105
|
+
}
|
|
106
|
+
const monthObj = getFormatterDate(date, month, type)
|
|
107
|
+
monthList.push(monthObj)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
months.value = deepClone(monthList)
|
|
111
|
+
}
|
|
112
|
+
function getMonthType(date: number) {
|
|
113
|
+
if (props.type === 'monthrange' && isArray(props.value)) {
|
|
114
|
+
const [startDate, endDate] = props.value || []
|
|
115
|
+
|
|
116
|
+
if (startDate && compareMonth(date, startDate) === 0) {
|
|
117
|
+
if (endDate && compareMonth(startDate, endDate) === 0) {
|
|
118
|
+
return 'same'
|
|
119
|
+
}
|
|
120
|
+
return 'start'
|
|
121
|
+
} else if (endDate && compareMonth(date, endDate) === 0) {
|
|
122
|
+
return 'end'
|
|
123
|
+
} else if (
|
|
124
|
+
startDate &&
|
|
125
|
+
endDate &&
|
|
126
|
+
compareMonth(date, startDate) === 1 &&
|
|
127
|
+
compareMonth(date, endDate) === -1
|
|
128
|
+
) {
|
|
129
|
+
return 'middle'
|
|
130
|
+
} else {
|
|
131
|
+
return ''
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
if (props.value && compareMonth(date, props.value as number) === 0) {
|
|
135
|
+
return 'selected'
|
|
136
|
+
} else {
|
|
137
|
+
return ''
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function handleDateClick(index: number) {
|
|
142
|
+
const date = months.value[index]
|
|
143
|
+
|
|
144
|
+
if (date.disabled) return
|
|
145
|
+
|
|
146
|
+
switch (props.type) {
|
|
147
|
+
case 'month':
|
|
148
|
+
handleMonthChange(date)
|
|
149
|
+
break
|
|
150
|
+
case 'monthrange':
|
|
151
|
+
handleMonthRangeChange(date)
|
|
152
|
+
break
|
|
153
|
+
default:
|
|
154
|
+
handleMonthChange(date)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function getDate(date: number) {
|
|
158
|
+
return props.defaultTime && props.defaultTime.length > 0
|
|
159
|
+
? getDateByDefaultTime(date, props.defaultTime[0])
|
|
160
|
+
: date
|
|
161
|
+
}
|
|
162
|
+
function handleMonthChange(date: CalendarDayItem) {
|
|
163
|
+
if (date.type !== 'selected') {
|
|
164
|
+
emit('change', {
|
|
165
|
+
value: getDate(date.date),
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function handleMonthRangeChange(date: CalendarDayItem) {
|
|
170
|
+
let value: (number | null)[] = []
|
|
171
|
+
const [startDate, endDate] = isArray(props.value) ? props.value || [] : []
|
|
172
|
+
const compare = compareMonth(date.date, startDate!)
|
|
173
|
+
|
|
174
|
+
// 禁止选择同个日期
|
|
175
|
+
if (!props.allowSameDay && !endDate && compare === 0) return
|
|
176
|
+
|
|
177
|
+
if (startDate && !endDate && compare > -1) {
|
|
178
|
+
if (props.maxRange && getMonthOffset(date.date, startDate) > props.maxRange) {
|
|
179
|
+
const maxEndDate = getMonthByOffset(startDate, props.maxRange - 1)
|
|
180
|
+
value = [startDate, getDate(maxEndDate)]
|
|
181
|
+
toast.show({
|
|
182
|
+
msg: props.rangePrompt || translate('rangePromptMonth', props.maxRange),
|
|
183
|
+
})
|
|
184
|
+
} else {
|
|
185
|
+
value = [startDate, getDate(date.date)]
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
value = [getDate(date.date), null]
|
|
189
|
+
}
|
|
190
|
+
emit('change', {
|
|
191
|
+
value,
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function getFormatterDate(date: number, month: number, type?: CalendarDayType) {
|
|
196
|
+
let monthObj: CalendarDayItem = {
|
|
197
|
+
date,
|
|
198
|
+
text: month + 1,
|
|
199
|
+
topInfo: '',
|
|
200
|
+
bottomInfo: '',
|
|
201
|
+
type,
|
|
202
|
+
disabled: compareMonth(date, props.minDate) === -1 || compareMonth(date, props.maxDate) === 1,
|
|
203
|
+
}
|
|
204
|
+
if (props.formatter) {
|
|
205
|
+
if (isFunction(props.formatter)) {
|
|
206
|
+
monthObj = props.formatter(monthObj)
|
|
207
|
+
} else {
|
|
208
|
+
console.error(
|
|
209
|
+
'[wot-design] error(wd-calendar-view): the formatter prop of wd-calendar-view should be a function',
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return monthObj
|
|
215
|
+
}
|
|
216
|
+
</script>
|
|
217
|
+
|
|
218
|
+
<style lang="scss" scoped>
|
|
219
|
+
@import './index.scss';
|
|
220
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@import '../../common/abstracts/variable';
|
|
2
|
+
@import '../../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
.wot-theme-dark {
|
|
5
|
+
@include b(year-panel) {
|
|
6
|
+
@include e(title) {
|
|
7
|
+
color: $-dark-color;
|
|
8
|
+
box-shadow: 0px 4px 8px 0 rgba(255, 255, 255, 0.02);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@include b(year-panel) {
|
|
14
|
+
padding: $-calendar-panel-padding;
|
|
15
|
+
font-size: $-calendar-fs;
|
|
16
|
+
|
|
17
|
+
@include e(title) {
|
|
18
|
+
padding: 5px 0;
|
|
19
|
+
font-size: $-calendar-panel-title-fs;
|
|
20
|
+
color: $-calendar-panel-title-color;
|
|
21
|
+
text-align: center;
|
|
22
|
+
box-shadow: 0px 4px 8px 0 rgba(0, 0, 0, 0.02);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { makeBooleanProp, makeRequiredProp } from '../../common/props'
|
|
3
|
+
import type { CalendarFormatter, CalendarType } from '../types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 月份信息
|
|
7
|
+
*/
|
|
8
|
+
export interface YearInfo {
|
|
9
|
+
date: number
|
|
10
|
+
height: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const yearPanelProps = {
|
|
14
|
+
type: makeRequiredProp(String as PropType<CalendarType>),
|
|
15
|
+
value: makeRequiredProp([Number, Array] as PropType<number | (number | null)[] | null>),
|
|
16
|
+
minDate: makeRequiredProp(Number),
|
|
17
|
+
maxDate: makeRequiredProp(Number),
|
|
18
|
+
formatter: Function as PropType<CalendarFormatter>,
|
|
19
|
+
maxRange: Number,
|
|
20
|
+
rangePrompt: String,
|
|
21
|
+
allowSameDay: makeBooleanProp(false),
|
|
22
|
+
showPanelTitle: makeBooleanProp(false),
|
|
23
|
+
defaultTime: {
|
|
24
|
+
type: [Array] as PropType<Array<number[]>>,
|
|
25
|
+
},
|
|
26
|
+
panelHeight: makeRequiredProp(Number),
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type YearPanelProps = ExtractPropTypes<typeof yearPanelProps>
|
|
30
|
+
|
|
31
|
+
export type YearPanelExpose = {
|
|
32
|
+
/**
|
|
33
|
+
* 使当前日期或者选中日期滚动到可视区域
|
|
34
|
+
*/
|
|
35
|
+
scrollIntoView: () => void
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type YearPanelInstance = ComponentPublicInstance<YearPanelProps, YearPanelExpose>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="wd-year-panel">
|
|
3
|
+
<view v-if="showPanelTitle" class="wd-year-panel__title">{{ title }}</view>
|
|
4
|
+
<scroll-view
|
|
5
|
+
class="wd-year-panel__container"
|
|
6
|
+
:style="`height: ${scrollHeight}px`"
|
|
7
|
+
scroll-y
|
|
8
|
+
@scroll="yearScroll"
|
|
9
|
+
:scroll-top="scrollTop"
|
|
10
|
+
>
|
|
11
|
+
<view v-for="(item, index) in years" :key="index" :id="`year${index}`">
|
|
12
|
+
<year
|
|
13
|
+
:type="type"
|
|
14
|
+
:date="item.date"
|
|
15
|
+
:value="value"
|
|
16
|
+
:min-date="minDate"
|
|
17
|
+
:max-date="maxDate"
|
|
18
|
+
:max-range="maxRange"
|
|
19
|
+
:formatter="formatter"
|
|
20
|
+
:range-prompt="rangePrompt"
|
|
21
|
+
:allow-same-day="allowSameDay"
|
|
22
|
+
:default-time="defaultTime"
|
|
23
|
+
@change="handleDateChange"
|
|
24
|
+
/>
|
|
25
|
+
</view>
|
|
26
|
+
</scroll-view>
|
|
27
|
+
</view>
|
|
28
|
+
</template>
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
export default {
|
|
31
|
+
options: {
|
|
32
|
+
addGlobalClass: true,
|
|
33
|
+
virtualHost: true,
|
|
34
|
+
styleIsolation: 'shared',
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<script lang="ts" setup>
|
|
40
|
+
import { computed, ref, onMounted } from 'vue'
|
|
41
|
+
import { compareYear, formatYearTitle, getYears } from '../utils'
|
|
42
|
+
import { isArray, isNumber, requestAnimationFrame } from '../../common/util'
|
|
43
|
+
import Year from '../year/year.vue'
|
|
44
|
+
import { yearPanelProps, type YearInfo, type YearPanelExpose } from './types'
|
|
45
|
+
|
|
46
|
+
const props = defineProps(yearPanelProps)
|
|
47
|
+
const emit = defineEmits(['change'])
|
|
48
|
+
|
|
49
|
+
const scrollTop = ref<number>(0) // 滚动位置
|
|
50
|
+
const scrollIndex = ref<number>(0) // 当前显示的年份索引
|
|
51
|
+
|
|
52
|
+
// 滚动区域的高度
|
|
53
|
+
const scrollHeight = computed(() => {
|
|
54
|
+
const scrollHeight: number = (props.panelHeight || 378) + (props.showPanelTitle ? 26 : 16)
|
|
55
|
+
return scrollHeight
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
// 年份信息
|
|
59
|
+
const years = computed<YearInfo[]>(() => {
|
|
60
|
+
return getYears(props.minDate, props.maxDate).map((year) => {
|
|
61
|
+
return {
|
|
62
|
+
date: year,
|
|
63
|
+
height: 237,
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// 标题
|
|
69
|
+
const title = computed(() => {
|
|
70
|
+
return formatYearTitle(years.value[scrollIndex.value].date)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
onMounted(() => {
|
|
74
|
+
scrollIntoView()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
function scrollIntoView() {
|
|
78
|
+
requestAnimationFrame(() => {
|
|
79
|
+
let activeDate: number | null = null
|
|
80
|
+
if (isArray(props.value)) {
|
|
81
|
+
activeDate = props.value![0]
|
|
82
|
+
} else if (isNumber(props.value)) {
|
|
83
|
+
activeDate = props.value
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!activeDate) {
|
|
87
|
+
activeDate = Date.now()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let top: number = 0
|
|
91
|
+
for (let index = 0; index < years.value.length; index++) {
|
|
92
|
+
if (compareYear(years.value[index].date, activeDate) === 0) {
|
|
93
|
+
break
|
|
94
|
+
}
|
|
95
|
+
top += years.value[index] ? Number(years.value[index].height) : 0
|
|
96
|
+
}
|
|
97
|
+
scrollTop.value = 0
|
|
98
|
+
requestAnimationFrame(() => {
|
|
99
|
+
scrollTop.value = top
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const yearScroll = (e: Event) => {
|
|
105
|
+
if (years.value.length <= 1) {
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
const scrollTop = Math.max(0, (e.target as Element).scrollTop)
|
|
109
|
+
doSetSubtitle(scrollTop)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 设置小标题
|
|
114
|
+
* scrollTop 滚动条位置
|
|
115
|
+
*/
|
|
116
|
+
function doSetSubtitle(scrollTop: number) {
|
|
117
|
+
let height: number = 0 // 月份高度和
|
|
118
|
+
for (let index = 0; index < years.value.length; index++) {
|
|
119
|
+
height = height + years.value[index].height
|
|
120
|
+
if (scrollTop < height + 45) {
|
|
121
|
+
scrollIndex.value = index
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function handleDateChange({ value }: { value: number[] }) {
|
|
128
|
+
emit('change', {
|
|
129
|
+
value,
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
defineExpose<YearPanelExpose>({
|
|
134
|
+
scrollIntoView,
|
|
135
|
+
})
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
<style lang="scss" scoped>
|
|
139
|
+
@import './index';
|
|
140
|
+
</style>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/_mixin';
|
|
3
|
+
.wot-theme-dark {
|
|
4
|
+
@include b(card) {
|
|
5
|
+
background-color: $-dark-background2;
|
|
6
|
+
|
|
7
|
+
@include when(rectangle) {
|
|
8
|
+
.wd-card__content {
|
|
9
|
+
@include halfPixelBorder('top', 0, $-dark-border-color);
|
|
10
|
+
}
|
|
11
|
+
.wd-card__footer {
|
|
12
|
+
@include halfPixelBorder('top', 0, $-dark-border-color);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@include e(title-content) {
|
|
17
|
+
color: $-dark-color;
|
|
18
|
+
}
|
|
19
|
+
@include e(content) {
|
|
20
|
+
color: $-dark-color3;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@include b(card) {
|
|
26
|
+
padding: $-card-padding;
|
|
27
|
+
margin: $-card-margin;
|
|
28
|
+
margin-bottom: 12px;
|
|
29
|
+
font-size: $-card-fs;
|
|
30
|
+
line-height: $-card-line-height;
|
|
31
|
+
background-color: $-card-bg;
|
|
32
|
+
border-radius: $-card-radius;
|
|
33
|
+
box-shadow: $-card-shadow-color;
|
|
34
|
+
|
|
35
|
+
@include when(rectangle) {
|
|
36
|
+
margin-right: 0;
|
|
37
|
+
margin-left: 0;
|
|
38
|
+
border-radius: 0;
|
|
39
|
+
box-shadow: none;
|
|
40
|
+
|
|
41
|
+
.wd-card__title-content {
|
|
42
|
+
font-size: $-card-fs;
|
|
43
|
+
}
|
|
44
|
+
.wd-card__content {
|
|
45
|
+
position: relative;
|
|
46
|
+
padding: $-card-rectangle-content-padding;
|
|
47
|
+
|
|
48
|
+
@include halfPixelBorder('top', 0, $-card-content-border-color);
|
|
49
|
+
}
|
|
50
|
+
.wd-card__footer {
|
|
51
|
+
position: relative;
|
|
52
|
+
padding: $-card-rectangle-footer-padding;
|
|
53
|
+
|
|
54
|
+
@include halfPixelBorder('top', 0, $-card-content-border-color);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
@include e(title-content) {
|
|
58
|
+
padding: 16px 0;
|
|
59
|
+
font-size: $-card-title-fs;
|
|
60
|
+
color: $-card-title-color;
|
|
61
|
+
}
|
|
62
|
+
@include e(content) {
|
|
63
|
+
line-height: $-card-content-line-height;
|
|
64
|
+
color: $-card-content-color;
|
|
65
|
+
}
|
|
66
|
+
@include e(footer) {
|
|
67
|
+
padding: $-card-footer-padding;
|
|
68
|
+
text-align: right;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { baseProps, makeStringProp } from '../common/props'
|
|
3
|
+
|
|
4
|
+
export type CardType = 'rectangle'
|
|
5
|
+
|
|
6
|
+
export const cardProps = {
|
|
7
|
+
...baseProps,
|
|
8
|
+
/**
|
|
9
|
+
* 卡片类型
|
|
10
|
+
*/
|
|
11
|
+
type: String as PropType<CardType>,
|
|
12
|
+
/**
|
|
13
|
+
* 卡片标题
|
|
14
|
+
*/
|
|
15
|
+
title: String,
|
|
16
|
+
/**
|
|
17
|
+
* 标题自定义样式
|
|
18
|
+
*/
|
|
19
|
+
customTitleClass: makeStringProp(''),
|
|
20
|
+
/**
|
|
21
|
+
* 内容自定义样式
|
|
22
|
+
*/
|
|
23
|
+
customContentClass: makeStringProp(''),
|
|
24
|
+
/**
|
|
25
|
+
* 底部自定义样式
|
|
26
|
+
*/
|
|
27
|
+
customFooterClass: makeStringProp(''),
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type CardProps = ExtractPropTypes<typeof cardProps>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
:class="['wd-card', type == 'rectangle' ? 'is-rectangle' : '', customClass]"
|
|
4
|
+
:style="customStyle"
|
|
5
|
+
>
|
|
6
|
+
<view :class="['wd-card__title-content', customTitleClass]">
|
|
7
|
+
<view class="wd-card__title">
|
|
8
|
+
<text v-if="title">{{ title }}</text>
|
|
9
|
+
<slot v-else name="title"></slot>
|
|
10
|
+
</view>
|
|
11
|
+
</view>
|
|
12
|
+
<view :class="`wd-card__content ${customContentClass}`">
|
|
13
|
+
<slot></slot>
|
|
14
|
+
</view>
|
|
15
|
+
<view :class="`wd-card__footer ${customFooterClass}`">
|
|
16
|
+
<slot name="footer"></slot>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
export default {
|
|
23
|
+
name: 'wd-card',
|
|
24
|
+
options: {
|
|
25
|
+
addGlobalClass: true,
|
|
26
|
+
virtualHost: true,
|
|
27
|
+
styleIsolation: 'shared',
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script lang="ts" setup>
|
|
33
|
+
import { cardProps } from './types'
|
|
34
|
+
|
|
35
|
+
defineProps(cardProps)
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<style lang="scss" scoped>
|
|
39
|
+
@import './index';
|
|
40
|
+
</style>
|