@wot-ui/ui 1.0.0 → 2.0.0-alpha.3
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 +134 -0
- package/attributes.json +1 -0
- package/changelog.md +53 -0
- package/common/AbortablePromise.ts +28 -0
- package/common/canvasHelper.ts +49 -0
- package/common/clickoutside.ts +25 -0
- package/common/event.ts +8 -0
- package/common/formatDate.ts +68 -0
- package/common/interceptor.ts +43 -0
- package/common/props.ts +53 -0
- package/common/util.ts +836 -0
- package/components/wd-action-sheet/index.scss +232 -0
- package/components/wd-action-sheet/types.ts +155 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +176 -0
- package/components/wd-avatar/index.scss +150 -0
- package/components/wd-avatar/types.ts +98 -0
- package/components/wd-avatar/wd-avatar.vue +184 -0
- package/components/wd-avatar-group/index.scss +11 -0
- package/components/wd-avatar-group/types.ts +61 -0
- package/components/wd-avatar-group/wd-avatar-group.vue +115 -0
- package/components/wd-backtop/index.scss +67 -0
- package/components/wd-backtop/types.ts +66 -0
- package/components/wd-backtop/wd-backtop.vue +57 -0
- package/components/wd-badge/index.scss +116 -0
- package/components/wd-badge/types.ts +94 -0
- package/components/wd-badge/wd-badge.vue +78 -0
- package/components/wd-button/index.scss +436 -0
- package/components/wd-button/types.ts +204 -0
- package/components/wd-button/wd-button.vue +210 -0
- package/components/wd-calendar/index.scss +97 -0
- package/components/wd-calendar/types.ts +221 -0
- package/components/wd-calendar/wd-calendar.vue +339 -0
- package/components/wd-calendar-view/index.scss +41 -0
- package/components/wd-calendar-view/month/index.scss +144 -0
- package/components/wd-calendar-view/month/month.vue +389 -0
- package/components/wd-calendar-view/month/types.ts +70 -0
- package/components/wd-calendar-view/monthPanel/index.scss +84 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +541 -0
- package/components/wd-calendar-view/monthPanel/types.ts +151 -0
- package/components/wd-calendar-view/types.ts +166 -0
- package/components/wd-calendar-view/utils.ts +318 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +117 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +74 -0
- package/components/wd-calendar-view/year/year.vue +206 -0
- package/components/wd-calendar-view/yearPanel/index.scss +42 -0
- package/components/wd-calendar-view/yearPanel/types.ts +96 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +249 -0
- package/components/wd-card/index.scss +104 -0
- package/components/wd-card/types.ts +47 -0
- package/components/wd-card/wd-card.vue +38 -0
- package/components/wd-cascader/index.scss +154 -0
- package/components/wd-cascader/types.ts +191 -0
- package/components/wd-cascader/wd-cascader.vue +589 -0
- package/components/wd-cell/index.scss +244 -0
- package/components/wd-cell/types.ts +205 -0
- package/components/wd-cell/wd-cell.vue +172 -0
- package/components/wd-cell-group/index.scss +53 -0
- package/components/wd-cell-group/types.ts +97 -0
- package/components/wd-cell-group/wd-cell-group.vue +48 -0
- package/components/wd-checkbox/index.scss +166 -0
- package/components/wd-checkbox/types.ts +118 -0
- package/components/wd-checkbox/wd-checkbox.vue +216 -0
- package/components/wd-checkbox-group/index.scss +5 -0
- package/components/wd-checkbox-group/types.ts +93 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +148 -0
- package/components/wd-circle/index.scss +28 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +306 -0
- package/components/wd-col/index.scss +5 -0
- package/components/wd-col/types.ts +16 -0
- package/components/wd-col/wd-col.vue +83 -0
- package/components/wd-collapse/index.scss +71 -0
- package/components/wd-collapse/types.ts +68 -0
- package/components/wd-collapse/wd-collapse.vue +165 -0
- package/components/wd-collapse-item/index.scss +86 -0
- package/components/wd-collapse-item/types.ts +62 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +184 -0
- package/components/wd-config-provider/index.scss +10 -0
- package/components/wd-config-provider/types.ts +2063 -0
- package/components/wd-config-provider/wd-config-provider.vue +61 -0
- package/components/wd-count-down/index.scss +16 -0
- package/components/wd-count-down/types.ts +58 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +62 -0
- package/components/wd-count-to/index.scss +25 -0
- package/components/wd-count-to/types.ts +121 -0
- package/components/wd-count-to/wd-count-to.vue +126 -0
- package/components/wd-curtain/index.scss +96 -0
- package/components/wd-curtain/types.ts +82 -0
- package/components/wd-curtain/wd-curtain.vue +172 -0
- package/components/wd-datetime-picker/index.scss +133 -0
- package/components/wd-datetime-picker/types.ts +198 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +526 -0
- package/components/wd-datetime-picker-view/types.ts +171 -0
- package/components/wd-datetime-picker-view/util.ts +30 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +402 -0
- package/components/wd-dialog/index.scss +281 -0
- package/components/wd-dialog/index.ts +168 -0
- package/components/wd-dialog/types.ts +452 -0
- package/components/wd-dialog/wd-dialog.vue +586 -0
- package/components/wd-divider/index.scss +122 -0
- package/components/wd-divider/types.ts +50 -0
- package/components/wd-divider/wd-divider.vue +54 -0
- package/components/wd-drop-menu/index.scss +90 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +168 -0
- package/components/wd-drop-menu-item/index.scss +96 -0
- package/components/wd-drop-menu-item/types.ts +93 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +205 -0
- package/components/wd-empty/index.scss +46 -0
- package/components/wd-empty/types.ts +37 -0
- package/components/wd-empty/wd-empty.vue +47 -0
- package/components/wd-fab/index.scss +124 -0
- package/components/wd-fab/types.ts +119 -0
- package/components/wd-fab/wd-fab.vue +322 -0
- package/components/wd-floating-panel/index.scss +73 -0
- package/components/wd-floating-panel/type.ts +32 -0
- package/components/wd-floating-panel/wd-floating-panel.vue +142 -0
- package/components/wd-form/adapters/zod.ts +56 -0
- package/components/wd-form/types.ts +147 -0
- package/components/wd-form/wd-form.vue +121 -0
- package/components/wd-form-item/index.scss +26 -0
- package/components/wd-form-item/types.ts +134 -0
- package/components/wd-form-item/wd-form-item.vue +182 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +26 -0
- package/components/wd-gap/wd-gap.vue +38 -0
- package/components/wd-grid/index.scss +11 -0
- package/components/wd-grid/types.ts +97 -0
- package/components/wd-grid/wd-grid.vue +48 -0
- package/components/wd-grid-item/index.scss +187 -0
- package/components/wd-grid-item/types.ts +98 -0
- package/components/wd-grid-item/wd-grid-item.vue +295 -0
- package/components/wd-icon/index.scss +46 -0
- package/components/wd-icon/types.ts +44 -0
- package/components/wd-icon/wd-icon.vue +66 -0
- package/components/wd-image-preview/index.scss +94 -0
- package/components/wd-image-preview/index.ts +95 -0
- package/components/wd-image-preview/types.ts +165 -0
- package/components/wd-image-preview/wd-image-preview.vue +233 -0
- package/components/wd-img/index.scss +82 -0
- package/components/wd-img/types.ts +96 -0
- package/components/wd-img/wd-img.vue +91 -0
- package/components/wd-img-cropper/index.scss +259 -0
- package/components/wd-img-cropper/types.ts +101 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +653 -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 +55 -0
- package/components/wd-index-bar/index.scss +68 -0
- package/components/wd-index-bar/type.ts +23 -0
- package/components/wd-index-bar/wd-index-bar.vue +157 -0
- package/components/wd-input/index.scss +129 -0
- package/components/wd-input/types.ts +165 -0
- package/components/wd-input/wd-input.vue +237 -0
- package/components/wd-input-number/index.scss +233 -0
- package/components/wd-input-number/types.ts +131 -0
- package/components/wd-input-number/wd-input-number.vue +473 -0
- package/components/wd-keyboard/constants.ts +81 -0
- package/components/wd-keyboard/index.scss +104 -0
- package/components/wd-keyboard/key/index.scss +103 -0
- package/components/wd-keyboard/key/index.vue +84 -0
- package/components/wd-keyboard/key/types.ts +44 -0
- package/components/wd-keyboard/types.ts +138 -0
- package/components/wd-keyboard/wd-keyboard.vue +236 -0
- package/components/wd-loading/index.scss +205 -0
- package/components/wd-loading/types.ts +61 -0
- package/components/wd-loading/wd-loading.vue +70 -0
- package/components/wd-loadmore/index.scss +62 -0
- package/components/wd-loadmore/types.ts +42 -0
- package/components/wd-loadmore/wd-loadmore.vue +68 -0
- package/components/wd-navbar/index.scss +96 -0
- package/components/wd-navbar/types.ts +74 -0
- package/components/wd-navbar/wd-navbar.vue +136 -0
- package/components/wd-navbar-capsule/index.scss +70 -0
- package/components/wd-navbar-capsule/types.ts +11 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +48 -0
- package/components/wd-notice-bar/index.scss +94 -0
- package/components/wd-notice-bar/types.ts +97 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +270 -0
- package/components/wd-notify/index.scss +114 -0
- package/components/wd-notify/index.ts +63 -0
- package/components/wd-notify/types.ts +130 -0
- package/components/wd-notify/wd-notify.vue +162 -0
- package/components/wd-overlay/index.scss +14 -0
- package/components/wd-overlay/types.ts +42 -0
- package/components/wd-overlay/wd-overlay.vue +55 -0
- package/components/wd-pagination/index.scss +71 -0
- package/components/wd-pagination/types.ts +69 -0
- package/components/wd-pagination/wd-pagination.vue +118 -0
- package/components/wd-password-input/index.scss +134 -0
- package/components/wd-password-input/types.ts +42 -0
- package/components/wd-password-input/wd-password-input.vue +51 -0
- package/components/wd-picker/index.scss +72 -0
- package/components/wd-picker/types.ts +141 -0
- package/components/wd-picker/wd-picker.vue +220 -0
- package/components/wd-picker-view/index.scss +93 -0
- package/components/wd-picker-view/types.ts +145 -0
- package/components/wd-picker-view/useSelection.ts +385 -0
- package/components/wd-picker-view/wd-picker-view.vue +227 -0
- package/components/wd-popover/index.scss +117 -0
- package/components/wd-popover/types.ts +106 -0
- package/components/wd-popover/wd-popover.vue +212 -0
- package/components/wd-popup/index.scss +89 -0
- package/components/wd-popup/types.ts +110 -0
- package/components/wd-popup/wd-popup.vue +174 -0
- package/components/wd-progress/index.scss +155 -0
- package/components/wd-progress/types.ts +94 -0
- package/components/wd-progress/wd-progress.vue +249 -0
- package/components/wd-radio/index.scss +189 -0
- package/components/wd-radio/types.ts +64 -0
- package/components/wd-radio/wd-radio.vue +164 -0
- package/components/wd-radio-group/index.scss +5 -0
- package/components/wd-radio-group/types.ts +70 -0
- package/components/wd-radio-group/wd-radio-group.vue +53 -0
- package/components/wd-rate/index.scss +57 -0
- package/components/wd-rate/types.ts +86 -0
- package/components/wd-rate/wd-rate.vue +168 -0
- package/components/wd-resize/index.scss +31 -0
- package/components/wd-resize/types.ts +14 -0
- package/components/wd-resize/wd-resize.vue +157 -0
- package/components/wd-root-portal/wd-root-portal.vue +77 -0
- package/components/wd-row/index.scss +6 -0
- package/components/wd-row/types.ts +36 -0
- package/components/wd-row/wd-row.vue +88 -0
- package/components/wd-search/index.scss +171 -0
- package/components/wd-search/types.ts +107 -0
- package/components/wd-search/wd-search.vue +198 -0
- package/components/wd-segmented/index.scss +155 -0
- package/components/wd-segmented/types.ts +81 -0
- package/components/wd-segmented/wd-segmented.vue +169 -0
- package/components/wd-select-picker/index.scss +72 -0
- package/components/wd-select-picker/types.ts +72 -0
- package/components/wd-select-picker/wd-select-picker.vue +371 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +34 -0
- package/components/wd-sidebar/wd-sidebar.vue +57 -0
- package/components/wd-sidebar-item/index.scss +91 -0
- package/components/wd-sidebar-item/types.ts +28 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +118 -0
- package/components/wd-signature/index.scss +42 -0
- package/components/wd-signature/types.ts +295 -0
- package/components/wd-signature/wd-signature.vue +664 -0
- package/components/wd-skeleton/index.scss +112 -0
- package/components/wd-skeleton/types.ts +124 -0
- package/components/wd-skeleton/wd-skeleton.vue +110 -0
- package/components/wd-slide-verify/index.scss +112 -0
- package/components/wd-slide-verify/types.ts +98 -0
- package/components/wd-slide-verify/wd-slide-verify.vue +222 -0
- package/components/wd-slider/index.scss +485 -0
- package/components/wd-slider/types.ts +166 -0
- package/components/wd-slider/wd-slider.vue +529 -0
- package/components/wd-sort-button/index.scss +126 -0
- package/components/wd-sort-button/types.ts +68 -0
- package/components/wd-sort-button/wd-sort-button.vue +67 -0
- package/components/wd-step/index.scss +366 -0
- package/components/wd-step/types.ts +43 -0
- package/components/wd-step/wd-step.vue +181 -0
- package/components/wd-steps/index.scss +7 -0
- package/components/wd-steps/types.ts +50 -0
- package/components/wd-steps/wd-steps.vue +39 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +192 -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 +157 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +87 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +320 -0
- package/components/wd-swiper/index.scss +69 -0
- package/components/wd-swiper/types.ts +275 -0
- package/components/wd-swiper/wd-swiper.vue +332 -0
- package/components/wd-swiper-nav/index.scss +179 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +42 -0
- package/components/wd-switch/index.scss +177 -0
- package/components/wd-switch/types.ts +93 -0
- package/components/wd-switch/wd-switch.vue +107 -0
- package/components/wd-tab/index.scss +16 -0
- package/components/wd-tab/types.ts +45 -0
- package/components/wd-tab/wd-tab.vue +99 -0
- package/components/wd-tabbar/index.scss +71 -0
- package/components/wd-tabbar/types.ts +79 -0
- package/components/wd-tabbar/wd-tabbar.vue +109 -0
- package/components/wd-tabbar-item/index.scss +50 -0
- package/components/wd-tabbar-item/types.ts +45 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +128 -0
- package/components/wd-table/types.ts +160 -0
- package/components/wd-table/wd-table.vue +331 -0
- package/components/wd-table-column/index.scss +15 -0
- package/components/wd-table-column/types.ts +81 -0
- package/components/wd-table-column/wd-table-column.vue +198 -0
- package/components/wd-tabs/index.scss +332 -0
- package/components/wd-tabs/types.ts +155 -0
- package/components/wd-tabs/wd-tabs.vue +508 -0
- package/components/wd-tag/index.scss +325 -0
- package/components/wd-tag/types.ts +90 -0
- package/components/wd-tag/wd-tag.vue +158 -0
- package/components/wd-text/index.scss +52 -0
- package/components/wd-text/types.ts +107 -0
- package/components/wd-text/wd-text.vue +141 -0
- package/components/wd-textarea/index.scss +112 -0
- package/components/wd-textarea/types.ts +151 -0
- package/components/wd-textarea/wd-textarea.vue +212 -0
- package/components/wd-toast/index.scss +92 -0
- package/components/wd-toast/index.ts +97 -0
- package/components/wd-toast/types.ts +190 -0
- package/components/wd-toast/wd-toast.vue +158 -0
- package/components/wd-tooltip/index.scss +77 -0
- package/components/wd-tooltip/types.ts +105 -0
- package/components/wd-tooltip/wd-tooltip.vue +169 -0
- package/components/wd-tour/index.scss +106 -0
- package/components/wd-tour/types.ts +268 -0
- package/components/wd-tour/wd-tour.vue +518 -0
- package/components/wd-transition/index.scss +67 -0
- package/components/wd-transition/types.ts +106 -0
- package/components/wd-transition/wd-transition.vue +238 -0
- package/components/wd-upload/index.scss +204 -0
- package/components/wd-upload/types.ts +390 -0
- package/components/wd-upload/wd-upload.vue +565 -0
- package/components/wd-video-preview/index.scss +54 -0
- package/components/wd-video-preview/index.ts +64 -0
- package/components/wd-video-preview/types.ts +66 -0
- package/components/wd-video-preview/wd-video-preview.vue +141 -0
- package/components/wd-watermark/index.scss +21 -0
- package/components/wd-watermark/types.ts +130 -0
- package/components/wd-watermark/wd-watermark.vue +718 -0
- package/components/wot-ui/wot-ui.vue +5 -0
- package/composables/index.ts +12 -0
- package/composables/useCell.ts +34 -0
- package/composables/useChildren.ts +120 -0
- package/composables/useConfigProvider.ts +45 -0
- package/composables/useCountDown.ts +138 -0
- package/composables/useDeviceInfo.ts +136 -0
- package/composables/useLockScroll.ts +37 -0
- package/composables/useParent.ts +51 -0
- package/composables/usePopover.ts +212 -0
- package/composables/useQueue.ts +52 -0
- package/composables/useRaf.ts +37 -0
- package/composables/useTouch.ts +43 -0
- package/composables/useTranslate.ts +12 -0
- package/composables/useUpload.ts +366 -0
- package/global.d.ts +106 -0
- package/index.ts +11 -0
- package/locale/index.ts +32 -0
- package/locale/lang/ar-SA.ts +150 -0
- package/locale/lang/de-DE.ts +150 -0
- package/locale/lang/en-US.ts +150 -0
- package/locale/lang/es-ES.ts +150 -0
- package/locale/lang/fr-FR.ts +150 -0
- package/locale/lang/ja-JP.ts +150 -0
- package/locale/lang/ko-KR.ts +150 -0
- package/locale/lang/pt-PT.ts +150 -0
- package/locale/lang/ru-RU.ts +150 -0
- package/locale/lang/th-TH.ts +150 -0
- package/locale/lang/tr-TR.ts +155 -0
- package/locale/lang/ug-CN.ts +154 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +154 -0
- package/locale/lang/zh-HK.ts +78 -0
- package/locale/lang/zh-TW.ts +78 -0
- package/package.json +1 -11
- package/styles/iconfont/iconfont.scss +1243 -0
- package/styles/mixin/_config.scss +7 -0
- package/styles/mixin/_function.scss +44 -0
- package/styles/mixin/_mixin.scss +473 -0
- package/styles/theme/base/color.scss +210 -0
- package/styles/theme/base/font.scss +13 -0
- package/styles/theme/base/index.scss +8 -0
- package/styles/theme/base/insets.scss +32 -0
- package/styles/theme/base/number.scss +36 -0
- package/styles/theme/base/opacity.scss +9 -0
- package/styles/theme/base/radius.scss +13 -0
- package/styles/theme/base/stroke.scss +9 -0
- package/styles/theme/base/typography.scss +44 -0
- package/styles/theme/dark.scss +101 -0
- package/styles/theme/index.scss +16 -0
- package/styles/theme/light.scss +101 -0
- package/styles/variable.scss +472 -0
- package/tags.json +1 -0
- package/web-types.json +1 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeNumberProp, makeRequiredProp, makeStringProp } from '../../common/props'
|
|
3
|
+
import { type DatetimePickerViewFormatter, type DatetimePickerViewFilter } from '../wd-datetime-picker-view/types'
|
|
4
|
+
|
|
5
|
+
const now = new Date()
|
|
6
|
+
const defaultMinDate = new Date(now.getFullYear(), now.getMonth() - 6, now.getDate()).getTime()
|
|
7
|
+
const defaultMaxDate = new Date(now.getFullYear(), now.getMonth() + 6, now.getDate(), 23, 59, 59).getTime()
|
|
8
|
+
|
|
9
|
+
export type CalendarType = 'date' | 'dates' | 'datetime' | 'week' | 'month' | 'daterange' | 'datetimerange' | 'weekrange' | 'monthrange'
|
|
10
|
+
|
|
11
|
+
export const calendarViewProps = {
|
|
12
|
+
...baseProps,
|
|
13
|
+
/**
|
|
14
|
+
* 选中值,为 13 位时间戳或时间戳数组
|
|
15
|
+
* 类型: number | number[] | null
|
|
16
|
+
* 默认值: null
|
|
17
|
+
*/
|
|
18
|
+
modelValue: makeRequiredProp([Number, Array, null] as PropType<number | number[] | null>),
|
|
19
|
+
/**
|
|
20
|
+
* 日期类型
|
|
21
|
+
* 类型: CalendarType
|
|
22
|
+
* 可选值: 'date' | 'dates' | 'datetime' | 'week' | 'month' | 'daterange' | 'datetimerange' | 'weekrange' | 'monthrange'
|
|
23
|
+
* 默认值: 'date'
|
|
24
|
+
*/
|
|
25
|
+
type: makeStringProp<CalendarType>('date'),
|
|
26
|
+
/**
|
|
27
|
+
* 最小日期,为 13 位时间戳
|
|
28
|
+
* 类型: number
|
|
29
|
+
* 默认值: 当前日期 - 6个月
|
|
30
|
+
*/
|
|
31
|
+
minDate: makeNumberProp(defaultMinDate),
|
|
32
|
+
/**
|
|
33
|
+
* 最大日期,为 13 位时间戳
|
|
34
|
+
* 类型: number
|
|
35
|
+
* 默认值: 当前日期 + 6个月
|
|
36
|
+
*/
|
|
37
|
+
maxDate: makeNumberProp(defaultMaxDate),
|
|
38
|
+
/**
|
|
39
|
+
* 周起始天
|
|
40
|
+
* 类型: number
|
|
41
|
+
* 默认值: 0
|
|
42
|
+
*/
|
|
43
|
+
firstDayOfWeek: makeNumberProp(0),
|
|
44
|
+
/**
|
|
45
|
+
* 日期格式化函数
|
|
46
|
+
* 类型: CalendarFormatter
|
|
47
|
+
*/
|
|
48
|
+
formatter: Function as PropType<CalendarFormatter>,
|
|
49
|
+
/**
|
|
50
|
+
* type 为范围选择时有效,最大日期范围
|
|
51
|
+
* 类型: number
|
|
52
|
+
*/
|
|
53
|
+
maxRange: Number,
|
|
54
|
+
/**
|
|
55
|
+
* type 为范围选择时有效,选择超出最大日期范围时的错误提示文案
|
|
56
|
+
* 类型: string
|
|
57
|
+
*/
|
|
58
|
+
rangePrompt: String,
|
|
59
|
+
/**
|
|
60
|
+
* type 为范围选择时有效,是否允许选择同一天
|
|
61
|
+
* 类型: boolean
|
|
62
|
+
* 默认值: false
|
|
63
|
+
*/
|
|
64
|
+
allowSameDay: makeBooleanProp(false),
|
|
65
|
+
/**
|
|
66
|
+
* 是否展示面板标题,自动计算当前滚动的日期月份
|
|
67
|
+
* 类型: boolean
|
|
68
|
+
* 默认值: true
|
|
69
|
+
*/
|
|
70
|
+
showPanelTitle: makeBooleanProp(true),
|
|
71
|
+
/**
|
|
72
|
+
* 选中日期所使用的当日内具体时刻
|
|
73
|
+
* 类型: string | string[]
|
|
74
|
+
* 默认值: '00:00:00'
|
|
75
|
+
*/
|
|
76
|
+
defaultTime: {
|
|
77
|
+
type: [String, Array] as PropType<string | string[]>,
|
|
78
|
+
default: '00:00:00'
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* 可滚动面板的高度
|
|
82
|
+
* 类型: number
|
|
83
|
+
* 默认值: 316
|
|
84
|
+
*/
|
|
85
|
+
panelHeight: makeNumberProp(316),
|
|
86
|
+
/**
|
|
87
|
+
* type 为 'datetime' 或 'datetimerange' 时有效,用于过滤时间选择器的数据
|
|
88
|
+
* 类型: CalendarTimeFilter
|
|
89
|
+
*/
|
|
90
|
+
timeFilter: Function as PropType<CalendarTimeFilter>,
|
|
91
|
+
/**
|
|
92
|
+
* 选项高度
|
|
93
|
+
* 类型: number
|
|
94
|
+
* 默认值: 44
|
|
95
|
+
*/
|
|
96
|
+
timeItemHeight: makeNumberProp(44),
|
|
97
|
+
/**
|
|
98
|
+
* 可见选项数量
|
|
99
|
+
* 类型: number
|
|
100
|
+
* 默认值: 3
|
|
101
|
+
*/
|
|
102
|
+
timeVisibleItemCount: makeNumberProp(3),
|
|
103
|
+
/**
|
|
104
|
+
* type 为 'datetime' 或 'datetimerange' 时有效,是否不展示秒修改
|
|
105
|
+
* 类型: boolean
|
|
106
|
+
* 默认值: false
|
|
107
|
+
*/
|
|
108
|
+
hideSecond: makeBooleanProp(false),
|
|
109
|
+
/**
|
|
110
|
+
* 是否在手指松开时立即触发picker-view的 change 事件。若不开启则会在滚动动画结束后触发 change 事件,1.2.25版本起提供,仅微信小程序和支付宝小程序支持。
|
|
111
|
+
* 类型: boolean
|
|
112
|
+
* 默认值: false
|
|
113
|
+
*/
|
|
114
|
+
immediateChange: makeBooleanProp(false),
|
|
115
|
+
/**
|
|
116
|
+
* 切换模式
|
|
117
|
+
* 类型: 'none' | 'month' | 'year-month'
|
|
118
|
+
* 可选值: none 平铺展示所有月份/年份,不展示切换按钮 | month 支持按月切换,展示上个月/下个月按钮 | year-month 支持按年切换,也支持按月切换,展示上一年/下一年,上个月/下个月按钮
|
|
119
|
+
* 默认值: 'none'
|
|
120
|
+
*/
|
|
121
|
+
switchMode: makeStringProp<'none' | 'month' | 'year-month'>('none')
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type CalendarViewProps = ExtractPropTypes<typeof calendarViewProps>
|
|
125
|
+
|
|
126
|
+
export type CalendarDayType = '' | 'start' | 'middle' | 'end' | 'selected' | 'same' | 'current' | 'multiple-middle' | 'multiple-selected'
|
|
127
|
+
|
|
128
|
+
export type CalendarDayItem = {
|
|
129
|
+
/** 日期时间戳 */
|
|
130
|
+
date: number
|
|
131
|
+
/** 日期显示文本 */
|
|
132
|
+
text?: number | string
|
|
133
|
+
/** 顶部信息 */
|
|
134
|
+
topInfo?: string
|
|
135
|
+
/** 底部信息 */
|
|
136
|
+
bottomInfo?: string
|
|
137
|
+
/** 日期类型 */
|
|
138
|
+
type?: CalendarDayType
|
|
139
|
+
/** 是否禁用 */
|
|
140
|
+
disabled?: boolean
|
|
141
|
+
/** 是否是这行的最后一个日期 */
|
|
142
|
+
isLastRow?: boolean
|
|
143
|
+
/** 自定义类名 */
|
|
144
|
+
customClass?: string
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export type CalendarFormatter = (day: CalendarDayItem) => CalendarDayItem
|
|
148
|
+
|
|
149
|
+
export type CalendarTimeFilter = DatetimePickerViewFilter
|
|
150
|
+
|
|
151
|
+
export type CalendarTimeFormatter = DatetimePickerViewFormatter
|
|
152
|
+
|
|
153
|
+
export type CalendarItem = {
|
|
154
|
+
label: string
|
|
155
|
+
value: number
|
|
156
|
+
disabled: boolean
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type CalendarViewExpose = {
|
|
160
|
+
/**
|
|
161
|
+
* 使当前日期或者选中日期滚动到可视区域
|
|
162
|
+
*/
|
|
163
|
+
scrollIntoView: () => void
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type CalendarViewInstance = ComponentPublicInstance<CalendarViewProps, CalendarViewExpose>
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { computed } from 'vue'
|
|
2
|
+
import { formatDate } from '../../common/formatDate'
|
|
3
|
+
import { isArray } from '../../common/util'
|
|
4
|
+
import { useTranslate } from '../../composables/useTranslate'
|
|
5
|
+
import type { CalendarDayType, CalendarType } from './types'
|
|
6
|
+
const { translate } = useTranslate('calendar-view')
|
|
7
|
+
|
|
8
|
+
const weeks = computed(() => {
|
|
9
|
+
return [
|
|
10
|
+
translate('weeks.sun'),
|
|
11
|
+
translate('weeks.mon'),
|
|
12
|
+
translate('weeks.tue'),
|
|
13
|
+
translate('weeks.wed'),
|
|
14
|
+
translate('weeks.thu'),
|
|
15
|
+
translate('weeks.fri'),
|
|
16
|
+
translate('weeks.sat')
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 比较两个时间的日期是否相等
|
|
22
|
+
* @param {number} date1 时间戳1
|
|
23
|
+
* @param {number | null} date2 时间戳2
|
|
24
|
+
* @returns {number} 0: 相等, 1: date1 > date2, -1: date1 < date2
|
|
25
|
+
*/
|
|
26
|
+
export function compareDate(date1: number, date2: number | null) {
|
|
27
|
+
const dateValue1 = new Date(date1)
|
|
28
|
+
const dateValue2 = new Date(date2 || '')
|
|
29
|
+
|
|
30
|
+
const year1 = dateValue1.getFullYear()
|
|
31
|
+
const year2 = dateValue2.getFullYear()
|
|
32
|
+
const month1 = dateValue1.getMonth()
|
|
33
|
+
const month2 = dateValue2.getMonth()
|
|
34
|
+
const day1 = dateValue1.getDate()
|
|
35
|
+
const day2 = dateValue2.getDate()
|
|
36
|
+
|
|
37
|
+
if (year1 === year2) {
|
|
38
|
+
if (month1 === month2) {
|
|
39
|
+
return day1 === day2 ? 0 : day1 > day2 ? 1 : -1
|
|
40
|
+
}
|
|
41
|
+
return month1 === month2 ? 0 : month1 > month2 ? 1 : -1
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return year1 > year2 ? 1 : -1
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 判断是否是范围选择
|
|
49
|
+
* @param {CalendarType} type 日期类型
|
|
50
|
+
* @returns {boolean}
|
|
51
|
+
*/
|
|
52
|
+
export function isRange(type: CalendarType) {
|
|
53
|
+
return type.indexOf('range') > -1
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 比较两个日期的月份是否相等
|
|
58
|
+
* @param {number} date1 时间戳1
|
|
59
|
+
* @param {number} date2 时间戳2
|
|
60
|
+
* @returns {number} 0: 相等, 1: date1 > date2, -1: date1 < date2
|
|
61
|
+
*/
|
|
62
|
+
export function compareMonth(date1: number, date2: number) {
|
|
63
|
+
const dateValue1 = new Date(date1)
|
|
64
|
+
const dateValue2 = new Date(date2)
|
|
65
|
+
|
|
66
|
+
const year1 = dateValue1.getFullYear()
|
|
67
|
+
const year2 = dateValue2.getFullYear()
|
|
68
|
+
const month1 = dateValue1.getMonth()
|
|
69
|
+
const month2 = dateValue2.getMonth()
|
|
70
|
+
|
|
71
|
+
if (year1 === year2) {
|
|
72
|
+
return month1 === month2 ? 0 : month1 > month2 ? 1 : -1
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return year1 > year2 ? 1 : -1
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 比较两个日期的年份是否一致
|
|
80
|
+
* @param {number} date1 时间戳1
|
|
81
|
+
* @param {number} date2 时间戳2
|
|
82
|
+
* @returns {number} 0: 相等, 1: date1 > date2, -1: date1 < date2
|
|
83
|
+
*/
|
|
84
|
+
export function compareYear(date1: number, date2: number) {
|
|
85
|
+
const dateValue1 = new Date(date1)
|
|
86
|
+
const dateValue2 = new Date(date2)
|
|
87
|
+
|
|
88
|
+
const year1 = dateValue1.getFullYear()
|
|
89
|
+
const year2 = dateValue2.getFullYear()
|
|
90
|
+
|
|
91
|
+
return year1 === year2 ? 0 : year1 > year2 ? 1 : -1
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 获取一个月的最后一天
|
|
96
|
+
* @param {number} year 年份
|
|
97
|
+
* @param {number} month 月份
|
|
98
|
+
* @returns {number} 当月天数
|
|
99
|
+
*/
|
|
100
|
+
export function getMonthEndDay(year: number, month: number) {
|
|
101
|
+
return 32 - new Date(year, month - 1, 32).getDate()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 格式化年月
|
|
106
|
+
* @param {number} date 时间戳
|
|
107
|
+
* @returns {string} FMYY-MM
|
|
108
|
+
*/
|
|
109
|
+
export function formatMonthTitle(date: number) {
|
|
110
|
+
return formatDate(date, translate('monthTitle'))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 根据下标获取星期
|
|
115
|
+
* @param {number} index 星期下标
|
|
116
|
+
* @returns {string} 星期几
|
|
117
|
+
*/
|
|
118
|
+
export function getWeekLabel(index: number) {
|
|
119
|
+
if (index >= 7) {
|
|
120
|
+
index = index % 7
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return weeks.value[index]
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 格式化年份
|
|
128
|
+
* @param {number} date 时间戳
|
|
129
|
+
* @returns {string} YYYY年
|
|
130
|
+
*/
|
|
131
|
+
export function formatYearTitle(date: number) {
|
|
132
|
+
return formatDate(date, translate('yearTitle'))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 根据最小日期和最大日期获取这之间总共有几个月份
|
|
137
|
+
* @param {number} minDate 最小日期时间戳
|
|
138
|
+
* @param {number} maxDate 最大日期时间戳
|
|
139
|
+
* @returns {number[]} 月份时间戳数组
|
|
140
|
+
*/
|
|
141
|
+
export function getMonths(minDate: number, maxDate: number) {
|
|
142
|
+
const months: number[] = []
|
|
143
|
+
const month = new Date(minDate)
|
|
144
|
+
month.setDate(1)
|
|
145
|
+
|
|
146
|
+
while (compareMonth(month.getTime(), maxDate) < 1) {
|
|
147
|
+
months.push(month.getTime())
|
|
148
|
+
month.setMonth(month.getMonth() + 1)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return months
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 根据最小日期和最大日期获取这之间总共有几年
|
|
156
|
+
* @param {number} minDate 最小日期时间戳
|
|
157
|
+
* @param {number} maxDate 最大日期时间戳
|
|
158
|
+
* @returns {number[]} 年份时间戳数组
|
|
159
|
+
*/
|
|
160
|
+
export function getYears(minDate: number, maxDate: number) {
|
|
161
|
+
const years: number[] = []
|
|
162
|
+
const year = new Date(minDate)
|
|
163
|
+
year.setMonth(0)
|
|
164
|
+
year.setDate(1)
|
|
165
|
+
|
|
166
|
+
while (compareYear(year.getTime(), maxDate) < 1) {
|
|
167
|
+
years.push(year.getTime())
|
|
168
|
+
year.setFullYear(year.getFullYear() + 1)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return years
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 获取一个日期所在周的第一天和最后一天
|
|
176
|
+
* @param {number} date 日期
|
|
177
|
+
* @param {number} firstDayOfWeek 周起始天
|
|
178
|
+
* @returns {number[]} [周第一天时间戳, 周最后一天时间戳]
|
|
179
|
+
*/
|
|
180
|
+
export function getWeekRange(date: number, firstDayOfWeek: number) {
|
|
181
|
+
if (firstDayOfWeek >= 7) {
|
|
182
|
+
firstDayOfWeek = firstDayOfWeek % 7
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const dateValue = new Date(date)
|
|
186
|
+
dateValue.setHours(0, 0, 0, 0)
|
|
187
|
+
const year = dateValue.getFullYear()
|
|
188
|
+
const month = dateValue.getMonth()
|
|
189
|
+
const day = dateValue.getDate()
|
|
190
|
+
const week = dateValue.getDay()
|
|
191
|
+
|
|
192
|
+
const weekStart = new Date(year, month, day - ((7 + week - firstDayOfWeek) % 7))
|
|
193
|
+
const weekEnd = new Date(year, month, day + 6 - ((7 + week - firstDayOfWeek) % 7))
|
|
194
|
+
|
|
195
|
+
return [weekStart.getTime(), weekEnd.getTime()]
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 获取日期偏移量
|
|
200
|
+
* @param {number} date1 时间戳1
|
|
201
|
+
* @param {number} date2 时间戳2
|
|
202
|
+
* @returns {number} 偏移天数
|
|
203
|
+
*/
|
|
204
|
+
export function getDayOffset(date1: number, date2: number) {
|
|
205
|
+
return (date1 - date2) / (24 * 60 * 60 * 1000) + 1
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 获取偏移日期
|
|
210
|
+
* @param {number} date 时间戳
|
|
211
|
+
* @param {number} offset 偏移天数
|
|
212
|
+
* @returns {number} 偏移后的时间戳
|
|
213
|
+
*/
|
|
214
|
+
export function getDayByOffset(date: number, offset: number) {
|
|
215
|
+
const dateValue = new Date(date)
|
|
216
|
+
dateValue.setDate(dateValue.getDate() + offset)
|
|
217
|
+
|
|
218
|
+
return dateValue.getTime()
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export const getPrevDay = (date: number) => getDayByOffset(date, -1)
|
|
222
|
+
export const getNextDay = (date: number) => getDayByOffset(date, 1)
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* 获取月份偏移量
|
|
226
|
+
* @param {number} date1 时间戳1
|
|
227
|
+
* @param {number} date2 时间戳2
|
|
228
|
+
* @returns {number} 偏移月数
|
|
229
|
+
*/
|
|
230
|
+
export function getMonthOffset(date1: number, date2: number) {
|
|
231
|
+
const dateValue1 = new Date(date1)
|
|
232
|
+
const dateValue2 = new Date(date2)
|
|
233
|
+
|
|
234
|
+
const year1 = dateValue1.getFullYear()
|
|
235
|
+
const year2 = dateValue2.getFullYear()
|
|
236
|
+
let month1 = dateValue1.getMonth()
|
|
237
|
+
const month2 = dateValue2.getMonth()
|
|
238
|
+
|
|
239
|
+
month1 = (year1 - year2) * 12 + month1
|
|
240
|
+
|
|
241
|
+
return month1 - month2 + 1
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* 获取偏移月份
|
|
246
|
+
* @param {number} date 时间戳
|
|
247
|
+
* @param {number} offset 偏移月数
|
|
248
|
+
* @returns {number} 偏移后的时间戳
|
|
249
|
+
*/
|
|
250
|
+
export function getMonthByOffset(date: number, offset: number) {
|
|
251
|
+
const dateValue = new Date(date)
|
|
252
|
+
dateValue.setMonth(dateValue.getMonth() + offset)
|
|
253
|
+
|
|
254
|
+
return dateValue.getTime()
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 获取默认时间,格式化为数组
|
|
259
|
+
* @param {string[] | string | null} defaultTime 默认时间
|
|
260
|
+
* @returns {number[][]} [[时, 分, 秒], [时, 分, 秒]]
|
|
261
|
+
*/
|
|
262
|
+
export function getDefaultTime(defaultTime: string[] | string | null) {
|
|
263
|
+
if (isArray(defaultTime)) {
|
|
264
|
+
const startTime = (defaultTime[0] || '00:00:00').split(':').map((item: string) => {
|
|
265
|
+
return parseInt(item)
|
|
266
|
+
})
|
|
267
|
+
const endTime = (defaultTime[1] || '00:00:00').split(':').map((item) => {
|
|
268
|
+
return parseInt(item)
|
|
269
|
+
})
|
|
270
|
+
return [startTime, endTime]
|
|
271
|
+
} else {
|
|
272
|
+
const time = (defaultTime || '00:00:00').split(':').map((item) => {
|
|
273
|
+
return parseInt(item)
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
return [time, time]
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 根据默认时间获取日期
|
|
282
|
+
* @param {number} date 时间戳
|
|
283
|
+
* @param {number[]} defaultTime [时, 分, 秒]
|
|
284
|
+
* @returns {number} 设置时间后的时间戳
|
|
285
|
+
*/
|
|
286
|
+
export function getDateByDefaultTime(date: number, defaultTime: number[]) {
|
|
287
|
+
const dateValue = new Date(date)
|
|
288
|
+
dateValue.setHours(defaultTime[0])
|
|
289
|
+
dateValue.setMinutes(defaultTime[1])
|
|
290
|
+
dateValue.setSeconds(defaultTime[2])
|
|
291
|
+
|
|
292
|
+
return dateValue.getTime()
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 获取当前是第几周
|
|
297
|
+
* @param {number | Date} date 日期
|
|
298
|
+
* @returns {number} 周数
|
|
299
|
+
*/
|
|
300
|
+
export function getWeekNumber(date: number | Date) {
|
|
301
|
+
date = new Date(date)
|
|
302
|
+
date.setHours(0, 0, 0, 0)
|
|
303
|
+
date.setDate(date.getDate() + 3 - ((date.getDay() + 6) % 7))
|
|
304
|
+
const week = new Date(date.getFullYear(), 0, 4)
|
|
305
|
+
return 1 + Math.round(((date.getTime() - week.getTime()) / 86400000 - 3 + ((week.getDay() + 6) % 7)) / 7)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function getItemClass(monthType: CalendarDayType, value: number | null | (number | null)[], type: CalendarType) {
|
|
309
|
+
const classList = ['is-' + monthType]
|
|
310
|
+
|
|
311
|
+
if (type.indexOf('range') > -1 && isArray(value)) {
|
|
312
|
+
if (!value || !value[1]) {
|
|
313
|
+
classList.push('is-without-end')
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return classList.join(' ')
|
|
318
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="`wd-calendar-view ${customClass}`">
|
|
3
|
+
<year-panel
|
|
4
|
+
v-if="type === 'month' || type === 'monthrange'"
|
|
5
|
+
ref="yearPanelRef"
|
|
6
|
+
:type="type"
|
|
7
|
+
:value="modelValue"
|
|
8
|
+
:min-date="minDate"
|
|
9
|
+
:max-date="maxDate"
|
|
10
|
+
:formatter="formatter"
|
|
11
|
+
:max-range="maxRange"
|
|
12
|
+
:range-prompt="rangePrompt"
|
|
13
|
+
:allow-same-day="allowSameDay"
|
|
14
|
+
:show-panel-title="showPanelTitle"
|
|
15
|
+
:default-time="formatDefauleTime"
|
|
16
|
+
:panel-height="panelHeight"
|
|
17
|
+
:switch-mode="switchMode"
|
|
18
|
+
@change="handleChange"
|
|
19
|
+
/>
|
|
20
|
+
<month-panel
|
|
21
|
+
v-else
|
|
22
|
+
ref="monthPanelRef"
|
|
23
|
+
:type="type"
|
|
24
|
+
:value="modelValue"
|
|
25
|
+
:min-date="minDate"
|
|
26
|
+
:max-date="maxDate"
|
|
27
|
+
:first-day-of-week="firstDayOfWeek"
|
|
28
|
+
:formatter="formatter"
|
|
29
|
+
:max-range="maxRange"
|
|
30
|
+
:range-prompt="rangePrompt"
|
|
31
|
+
:allow-same-day="allowSameDay"
|
|
32
|
+
:show-panel-title="showPanelTitle"
|
|
33
|
+
:default-time="formatDefauleTime"
|
|
34
|
+
:panel-height="panelHeight"
|
|
35
|
+
:immediate-change="immediateChange"
|
|
36
|
+
:time-filter="timeFilter"
|
|
37
|
+
:hide-second="hideSecond"
|
|
38
|
+
:item-height="timeItemHeight"
|
|
39
|
+
:visible-item-count="timeVisibleItemCount"
|
|
40
|
+
:switch-mode="switchMode"
|
|
41
|
+
@change="handleChange"
|
|
42
|
+
@pickstart="handlePickStart"
|
|
43
|
+
@pickend="handlePickEnd"
|
|
44
|
+
/>
|
|
45
|
+
</view>
|
|
46
|
+
</template>
|
|
47
|
+
<script lang="ts">
|
|
48
|
+
export default {
|
|
49
|
+
name: 'wd-calendar-view',
|
|
50
|
+
options: {
|
|
51
|
+
addGlobalClass: true,
|
|
52
|
+
// #ifndef MP-TOUTIAO
|
|
53
|
+
virtualHost: true,
|
|
54
|
+
// #endif
|
|
55
|
+
styleIsolation: 'shared'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<script lang="ts" setup>
|
|
61
|
+
import { ref, watch } from 'vue'
|
|
62
|
+
import { getDefaultTime } from './utils'
|
|
63
|
+
import yearPanel from './yearPanel/year-panel.vue'
|
|
64
|
+
import MonthPanel from './monthPanel/month-panel.vue'
|
|
65
|
+
import { calendarViewProps, type CalendarViewExpose } from './types'
|
|
66
|
+
|
|
67
|
+
const props = defineProps(calendarViewProps)
|
|
68
|
+
const emit = defineEmits(['change', 'update:modelValue', 'pickstart', 'pickend'])
|
|
69
|
+
const formatDefauleTime = ref<number[][]>([])
|
|
70
|
+
|
|
71
|
+
const yearPanelRef = ref()
|
|
72
|
+
const monthPanelRef = ref()
|
|
73
|
+
|
|
74
|
+
watch(
|
|
75
|
+
() => props.defaultTime,
|
|
76
|
+
(newValue) => {
|
|
77
|
+
formatDefauleTime.value = getDefaultTime(newValue)
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
deep: true,
|
|
81
|
+
immediate: true
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 使当前日期或者选中日期滚动到可视区域
|
|
87
|
+
*/
|
|
88
|
+
function scrollIntoView() {
|
|
89
|
+
const panel = getPanel()
|
|
90
|
+
panel.scrollIntoView && panel.scrollIntoView()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function getPanel() {
|
|
94
|
+
return props.type.indexOf('month') > -1 ? yearPanelRef.value : monthPanelRef.value
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function handleChange({ value }: { value: number | number[] | null }) {
|
|
98
|
+
emit('update:modelValue', value)
|
|
99
|
+
emit('change', {
|
|
100
|
+
value
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
function handlePickStart() {
|
|
104
|
+
emit('pickstart')
|
|
105
|
+
}
|
|
106
|
+
function handlePickEnd() {
|
|
107
|
+
emit('pickend')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
defineExpose<CalendarViewExpose>({
|
|
111
|
+
scrollIntoView
|
|
112
|
+
})
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<style lang="scss">
|
|
116
|
+
@use './index.scss';
|
|
117
|
+
</style>
|