stellar-ui-plus 1.16.18
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/README.md +176 -0
- package/common/css/common.scss +19 -0
- package/common/useProps.js +9 -0
- package/components/ste-animate/ATTRIBUTES.md +10 -0
- package/components/ste-animate/README.md +115 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/config.json +5 -0
- package/components/ste-animate/props.ts +9 -0
- package/components/ste-animate/ste-animate.easycom.json +39 -0
- package/components/ste-animate/ste-animate.scss +113 -0
- package/components/ste-animate/ste-animate.vue +67 -0
- package/components/ste-badge/ATTRIBUTES.md +17 -0
- package/components/ste-badge/README.md +162 -0
- package/components/ste-badge/config.json +5 -0
- package/components/ste-badge/props.ts +17 -0
- package/components/ste-badge/ste-badge.easycom.json +96 -0
- package/components/ste-badge/ste-badge.vue +157 -0
- package/components/ste-barcode/ATTRIBUTES.md +14 -0
- package/components/ste-barcode/README.md +28 -0
- package/components/ste-barcode/config.json +5 -0
- package/components/ste-barcode/encode.ts +317 -0
- package/components/ste-barcode/props.ts +7 -0
- package/components/ste-barcode/ste-barcode.easycom.json +44 -0
- package/components/ste-barcode/ste-barcode.vue +152 -0
- package/components/ste-button/ATTRIBUTES.md +32 -0
- package/components/ste-button/README.md +119 -0
- package/components/ste-button/config.json +5 -0
- package/components/ste-button/props.ts +21 -0
- package/components/ste-button/ste-button.easycom.json +168 -0
- package/components/ste-button/ste-button.vue +275 -0
- package/components/ste-calendar/ATTRIBUTES.md +31 -0
- package/components/ste-calendar/README.md +241 -0
- package/components/ste-calendar/config.json +5 -0
- package/components/ste-calendar/date.ts +110 -0
- package/components/ste-calendar/props.ts +26 -0
- package/components/ste-calendar/ste-calendar.easycom.json +172 -0
- package/components/ste-calendar/ste-calendar.vue +376 -0
- package/components/ste-calendar/useData.ts +30 -0
- package/components/ste-checkbox/ATTRIBUTES.md +25 -0
- package/components/ste-checkbox/README.md +302 -0
- package/components/ste-checkbox/config.json +5 -0
- package/components/ste-checkbox/props.ts +33 -0
- package/components/ste-checkbox/ste-checkbox.easycom.json +151 -0
- package/components/ste-checkbox/ste-checkbox.vue +206 -0
- package/components/ste-checkbox/type.d.ts +2 -0
- package/components/ste-checkbox-group/props.ts +34 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +34 -0
- package/components/ste-code-input/ATTRIBUTES.md +22 -0
- package/components/ste-code-input/README.md +56 -0
- package/components/ste-code-input/config.json +5 -0
- package/components/ste-code-input/props.ts +19 -0
- package/components/ste-code-input/ste-code-input.easycom.json +99 -0
- package/components/ste-code-input/ste-code-input.vue +222 -0
- package/components/ste-date-picker/ATTRIBUTES.md +25 -0
- package/components/ste-date-picker/README.md +119 -0
- package/components/ste-date-picker/config.json +5 -0
- package/components/ste-date-picker/props.ts +62 -0
- package/components/ste-date-picker/ste-date-picker.easycom.json +137 -0
- package/components/ste-date-picker/ste-date-picker.vue +290 -0
- package/components/ste-date-picker/types.d.ts +3 -0
- package/components/ste-drag/ATTRIBUTES.md +13 -0
- package/components/ste-drag/README.md +88 -0
- package/components/ste-drag/config.json +5 -0
- package/components/ste-drag/props.ts +10 -0
- package/components/ste-drag/ste-drag.easycom.json +50 -0
- package/components/ste-drag/ste-drag.vue +172 -0
- package/components/ste-dropdown-menu/ATTRIBUTES.md +22 -0
- package/components/ste-dropdown-menu/README.md +325 -0
- package/components/ste-dropdown-menu/config.json +5 -0
- package/components/ste-dropdown-menu/constans.ts +4 -0
- package/components/ste-dropdown-menu/props.ts +30 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.easycom.json +111 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.scss +99 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +223 -0
- package/components/ste-dropdown-menu-item/props.ts +17 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.scss +61 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +84 -0
- package/components/ste-dropdown-menu-item/type.d.ts +4 -0
- package/components/ste-icon/ATTRIBUTES.md +19 -0
- package/components/ste-icon/README.md +72 -0
- package/components/ste-icon/config.json +5 -0
- package/components/ste-icon/iconfont.css +22 -0
- package/components/ste-icon/props.ts +14 -0
- package/components/ste-icon/ste-icon.easycom.json +71 -0
- package/components/ste-icon/ste-icon.vue +80 -0
- package/components/ste-image/ATTRIBUTES.md +21 -0
- package/components/ste-image/README.md +118 -0
- package/components/ste-image/config.json +5 -0
- package/components/ste-image/props.ts +15 -0
- package/components/ste-image/ste-image.easycom.json +189 -0
- package/components/ste-image/ste-image.vue +146 -0
- package/components/ste-index-item/props.ts +4 -0
- package/components/ste-index-item/ste-index-item.vue +83 -0
- package/components/ste-index-list/ATTRIBUTES.md +15 -0
- package/components/ste-index-list/README.md +138 -0
- package/components/ste-index-list/config.json +5 -0
- package/components/ste-index-list/props.ts +17 -0
- package/components/ste-index-list/ste-index-list.easycom.json +48 -0
- package/components/ste-index-list/ste-index-list.vue +109 -0
- package/components/ste-input/ATTRIBUTES.md +37 -0
- package/components/ste-input/README.md +130 -0
- package/components/ste-input/config.json +5 -0
- package/components/ste-input/props.ts +46 -0
- package/components/ste-input/ste-input.easycom.json +282 -0
- package/components/ste-input/ste-input.scss +124 -0
- package/components/ste-input/ste-input.vue +221 -0
- package/components/ste-loading/ATTRIBUTES.md +11 -0
- package/components/ste-loading/README.md +74 -0
- package/components/ste-loading/config.json +5 -0
- package/components/ste-loading/props.ts +8 -0
- package/components/ste-loading/ste-loading.easycom.json +54 -0
- package/components/ste-loading/ste-loading.vue +127 -0
- package/components/ste-media-preview/ATTRIBUTES.md +20 -0
- package/components/ste-media-preview/README.md +252 -0
- package/components/ste-media-preview/TouchScaleing.ts +117 -0
- package/components/ste-media-preview/config.json +5 -0
- package/components/ste-media-preview/props.ts +12 -0
- package/components/ste-media-preview/ste-media-preview.easycom.json +88 -0
- package/components/ste-media-preview/ste-media-preview.vue +201 -0
- package/components/ste-media-preview/useData.ts +63 -0
- package/components/ste-message-box/ATTRIBUTES.md +6 -0
- package/components/ste-message-box/README.md +222 -0
- package/components/ste-message-box/config.json +5 -0
- package/components/ste-message-box/constants.ts +25 -0
- package/components/ste-message-box/ste-message-box.easycom.json +14 -0
- package/components/ste-message-box/ste-message-box.ts +1 -0
- package/components/ste-message-box/ste-message-box.vue +355 -0
- package/components/ste-message-box/use-message-box.ts +26 -0
- package/components/ste-message-box/useData.ts +56 -0
- package/components/ste-notice-bar/ATTRIBUTES.md +22 -0
- package/components/ste-notice-bar/README.md +124 -0
- package/components/ste-notice-bar/config.json +5 -0
- package/components/ste-notice-bar/props.ts +15 -0
- package/components/ste-notice-bar/ste-notice-bar.easycom.json +109 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +262 -0
- package/components/ste-number-keyboard/ATTRIBUTES.md +31 -0
- package/components/ste-number-keyboard/KeyboardVue.vue +142 -0
- package/components/ste-number-keyboard/README.md +192 -0
- package/components/ste-number-keyboard/config.json +5 -0
- package/components/ste-number-keyboard/props.ts +35 -0
- package/components/ste-number-keyboard/ste-number-keyboard.easycom.json +177 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +81 -0
- package/components/ste-number-keyboard/useData.ts +144 -0
- package/components/ste-picker/props.ts +16 -0
- package/components/ste-picker/ste-picker.vue +194 -0
- package/components/ste-popup/ATTRIBUTES.md +24 -0
- package/components/ste-popup/README.md +135 -0
- package/components/ste-popup/config.json +6 -0
- package/components/ste-popup/event.ts +0 -0
- package/components/ste-popup/props.ts +19 -0
- package/components/ste-popup/ste-popup.easycom.json +122 -0
- package/components/ste-popup/ste-popup.vue +253 -0
- package/components/ste-price/ATTRIBUTES.md +26 -0
- package/components/ste-price/README.md +110 -0
- package/components/ste-price/config.json +5 -0
- package/components/ste-price/props.ts +23 -0
- package/components/ste-price/ste-price.easycom.json +154 -0
- package/components/ste-price/ste-price.vue +148 -0
- package/components/ste-progress/ATTRIBUTES.md +17 -0
- package/components/ste-progress/README.md +88 -0
- package/components/ste-progress/config.json +5 -0
- package/components/ste-progress/props.ts +16 -0
- package/components/ste-progress/ste-progress.easycom.json +80 -0
- package/components/ste-progress/ste-progress.vue +135 -0
- package/components/ste-qrcode/ATTRIBUTES.md +16 -0
- package/components/ste-qrcode/README.md +34 -0
- package/components/ste-qrcode/config.json +5 -0
- package/components/ste-qrcode/props.ts +16 -0
- package/components/ste-qrcode/ste-qrcode.easycom.json +56 -0
- package/components/ste-qrcode/ste-qrcode.vue +134 -0
- package/components/ste-qrcode/uqrcode.d.ts +57 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/ATTRIBUTES.md +25 -0
- package/components/ste-radio/README.md +260 -0
- package/components/ste-radio/config.json +5 -0
- package/components/ste-radio/props.ts +33 -0
- package/components/ste-radio/ste-radio.easycom.json +150 -0
- package/components/ste-radio/ste-radio.vue +188 -0
- package/components/ste-radio/type.d.ts +2 -0
- package/components/ste-radio-group/props.ts +33 -0
- package/components/ste-radio-group/ste-radio-group.vue +34 -0
- package/components/ste-rate/ATTRIBUTES.md +21 -0
- package/components/ste-rate/README.md +97 -0
- package/components/ste-rate/config.json +5 -0
- package/components/ste-rate/props.ts +16 -0
- package/components/ste-rate/ste-rate.easycom.json +85 -0
- package/components/ste-rate/ste-rate.vue +143 -0
- package/components/ste-read-more/ATTRIBUTES.md +16 -0
- package/components/ste-read-more/README.md +93 -0
- package/components/ste-read-more/config.json +5 -0
- package/components/ste-read-more/props.ts +9 -0
- package/components/ste-read-more/ste-read-more.easycom.json +54 -0
- package/components/ste-read-more/ste-read-more.vue +106 -0
- package/components/ste-rich-text/ATTRIBUTES.md +8 -0
- package/components/ste-rich-text/README.md +26 -0
- package/components/ste-rich-text/config.json +5 -0
- package/components/ste-rich-text/props.ts +8 -0
- package/components/ste-rich-text/ste-rich-text.easycom.json +40 -0
- package/components/ste-rich-text/ste-rich-text.vue +33 -0
- package/components/ste-scroll-to/ATTRIBUTES.md +11 -0
- package/components/ste-scroll-to/README.md +47 -0
- package/components/ste-scroll-to/config.json +5 -0
- package/components/ste-scroll-to/props.ts +17 -0
- package/components/ste-scroll-to/ste-scroll-to.easycom.json +25 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +42 -0
- package/components/ste-scroll-to/useData.ts +214 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +24 -0
- package/components/ste-search/ATTRIBUTES.md +39 -0
- package/components/ste-search/README.md +232 -0
- package/components/ste-search/config.json +5 -0
- package/components/ste-search/props.ts +124 -0
- package/components/ste-search/ste-search.easycom.json +232 -0
- package/components/ste-search/ste-search.vue +379 -0
- package/components/ste-search/useData.ts +34 -0
- package/components/ste-select/ATTRIBUTES.md +39 -0
- package/components/ste-select/README.md +324 -0
- package/components/ste-select/config.json +5 -0
- package/components/ste-select/datapager.vue +54 -0
- package/components/ste-select/datetime.vue +109 -0
- package/components/ste-select/defaultDate.ts +138 -0
- package/components/ste-select/props.ts +67 -0
- package/components/ste-select/ste-select.easycom.json +287 -0
- package/components/ste-select/ste-select.vue +437 -0
- package/components/ste-select/useData.ts +471 -0
- package/components/ste-signature/ATTRIBUTES.md +18 -0
- package/components/ste-signature/README.md +97 -0
- package/components/ste-signature/config.json +5 -0
- package/components/ste-signature/props.ts +12 -0
- package/components/ste-signature/ste-signature.easycom.json +74 -0
- package/components/ste-signature/ste-signature.vue +183 -0
- package/components/ste-signature/types.d.ts +4 -0
- package/components/ste-slider/ATTRIBUTES.md +25 -0
- package/components/ste-slider/README.md +149 -0
- package/components/ste-slider/config.json +5 -0
- package/components/ste-slider/props.ts +32 -0
- package/components/ste-slider/ste-slider.easycom.json +128 -0
- package/components/ste-slider/ste-slider.scss +150 -0
- package/components/ste-slider/ste-slider.vue +293 -0
- package/components/ste-slider/type.d.ts +4 -0
- package/components/ste-slider/useData.ts +79 -0
- package/components/ste-step/props.ts +10 -0
- package/components/ste-step/ste-step.scss +104 -0
- package/components/ste-step/ste-step.vue +122 -0
- package/components/ste-stepper/ATTRIBUTES.md +33 -0
- package/components/ste-stepper/README.md +172 -0
- package/components/ste-stepper/config.json +5 -0
- package/components/ste-stepper/props.ts +41 -0
- package/components/ste-stepper/ste-stepper.easycom.json +220 -0
- package/components/ste-stepper/ste-stepper.vue +249 -0
- package/components/ste-steps/ATTRIBUTES.md +12 -0
- package/components/ste-steps/README.md +139 -0
- package/components/ste-steps/config.json +5 -0
- package/components/ste-steps/props.ts +18 -0
- package/components/ste-steps/ste-steps.easycom.json +46 -0
- package/components/ste-steps/ste-steps.vue +44 -0
- package/components/ste-sticky/ATTRIBUTES.md +15 -0
- package/components/ste-sticky/README.md +56 -0
- package/components/ste-sticky/config.json +5 -0
- package/components/ste-sticky/props.ts +7 -0
- package/components/ste-sticky/ste-sticky.easycom.json +48 -0
- package/components/ste-sticky/ste-sticky.vue +88 -0
- package/components/ste-swipe-action/ATTRIBUTES.md +16 -0
- package/components/ste-swipe-action/README.md +195 -0
- package/components/ste-swipe-action/config.json +5 -0
- package/components/ste-swipe-action/props.ts +23 -0
- package/components/ste-swipe-action/ste-swipe-action.easycom.json +74 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +138 -0
- package/components/ste-swipe-action/useData.ts +204 -0
- package/components/ste-swipe-action-group/ATTRIBUTES.md +17 -0
- package/components/ste-swipe-action-group/props.ts +22 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.easycom.json +90 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +57 -0
- package/components/ste-swiper/ATTRIBUTES.md +24 -0
- package/components/ste-swiper/README.md +156 -0
- package/components/ste-swiper/config.json +5 -0
- package/components/ste-swiper/props.ts +41 -0
- package/components/ste-swiper/ste-swiper.easycom.json +123 -0
- package/components/ste-swiper/ste-swiper.vue +98 -0
- package/components/ste-swiper/useData.ts +365 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/ATTRIBUTES.md +17 -0
- package/components/ste-switch/README.md +105 -0
- package/components/ste-switch/config.json +5 -0
- package/components/ste-switch/props.ts +9 -0
- package/components/ste-switch/ste-switch.easycom.json +60 -0
- package/components/ste-switch/ste-switch.vue +96 -0
- package/components/ste-tab/ATTRIBUTES.md +14 -0
- package/components/ste-tab/props.ts +25 -0
- package/components/ste-tab/ste-tab.easycom.json +56 -0
- package/components/ste-tab/ste-tab.vue +26 -0
- package/components/ste-table/ATTRIBUTES.md +41 -0
- package/components/ste-table/README.md +638 -0
- package/components/ste-table/config.json +5 -0
- package/components/ste-table/props.ts +72 -0
- package/components/ste-table/ste-table.easycom.json +188 -0
- package/components/ste-table/ste-table.vue +427 -0
- package/components/ste-table/types.d.ts +3 -0
- package/components/ste-table/useData.ts +233 -0
- package/components/ste-table/utils.ts +11 -0
- package/components/ste-table-column/checkbox-icon.vue +35 -0
- package/components/ste-table-column/common.scss +52 -0
- package/components/ste-table-column/props.ts +18 -0
- package/components/ste-table-column/radio-icon.vue +99 -0
- package/components/ste-table-column/ste-table-column.vue +169 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/ATTRIBUTES.md +52 -0
- package/components/ste-tabs/README.md +165 -0
- package/components/ste-tabs/config.json +5 -0
- package/components/ste-tabs/props.ts +133 -0
- package/components/ste-tabs/ste-tabs.easycom.json +278 -0
- package/components/ste-tabs/ste-tabs.vue +447 -0
- package/components/ste-tabs/useData.ts +364 -0
- package/components/ste-text/ATTRIBUTES.md +9 -0
- package/components/ste-text/README.md +58 -0
- package/components/ste-text/config.json +6 -0
- package/components/ste-text/props.ts +10 -0
- package/components/ste-text/ste-text.easycom.json +30 -0
- package/components/ste-text/ste-text.vue +46 -0
- package/components/ste-toast/ATTRIBUTES.md +15 -0
- package/components/ste-toast/README.md +222 -0
- package/components/ste-toast/config.json +5 -0
- package/components/ste-toast/props.ts +7 -0
- package/components/ste-toast/ste-toast.easycom.json +73 -0
- package/components/ste-toast/ste-toast.vue +209 -0
- package/components/ste-toast/use-toast.ts +26 -0
- package/components/ste-touch-swipe/ATTRIBUTES.md +18 -0
- package/components/ste-touch-swipe/README.md +89 -0
- package/components/ste-touch-swipe/TouchEvent.ts +79 -0
- package/components/ste-touch-swipe/config.json +5 -0
- package/components/ste-touch-swipe/props.ts +23 -0
- package/components/ste-touch-swipe/ste-touch-swipe.easycom.json +83 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +283 -0
- package/components/ste-touch-swipe/useData.ts +51 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +32 -0
- package/components/ste-tour/ATTRIBUTES.md +26 -0
- package/components/ste-tour/README.md +134 -0
- package/components/ste-tour/config.json +5 -0
- package/components/ste-tour/props.ts +45 -0
- package/components/ste-tour/ste-tour.easycom.json +120 -0
- package/components/ste-tour/ste-tour.vue +152 -0
- package/components/ste-tour/useData.ts +220 -0
- package/components/ste-tree/ATTRIBUTES.md +19 -0
- package/components/ste-tree/README.md +217 -0
- package/components/ste-tree/config.json +5 -0
- package/components/ste-tree/props.ts +24 -0
- package/components/ste-tree/ste-tree.easycom.json +106 -0
- package/components/ste-tree/ste-tree.vue +140 -0
- package/components/ste-tree/useData.ts +219 -0
- package/components/ste-upload/ATTRIBUTES.md +35 -0
- package/components/ste-upload/README.md +208 -0
- package/components/ste-upload/ReadFile.ts +305 -0
- package/components/ste-upload/config.json +5 -0
- package/components/ste-upload/props.ts +25 -0
- package/components/ste-upload/ste-upload.easycom.json +267 -0
- package/components/ste-upload/ste-upload.vue +386 -0
- package/components/ste-upload/useData.ts +46 -0
- package/components/ste-video/ATTRIBUTES.md +34 -0
- package/components/ste-video/README.md +48 -0
- package/components/ste-video/config.json +5 -0
- package/components/ste-video/props.ts +86 -0
- package/components/ste-video/ste-video.easycom.json +226 -0
- package/components/ste-video/ste-video.scss +201 -0
- package/components/ste-video/ste-video.vue +390 -0
- package/components/ste-video/types.d.ts +4 -0
- package/components/ste-video/useData.ts +140 -0
- package/composables.ts +2 -0
- package/config/color.ts +16 -0
- package/config/index.ts +48 -0
- package/index.ts +118 -0
- package/package.json +22 -0
- package/store/color.ts +24 -0
- package/store/index.ts +12 -0
- package/store/message-box.ts +54 -0
- package/store/toast.ts +50 -0
- package/types/components.d.ts +124 -0
- package/types/event.d.ts +51 -0
- package/types/index.d.ts +112 -0
- package/types/refComponents.d.ts +118 -0
- package/utils/Color.ts +66 -0
- package/utils/System.ts +114 -0
- package/utils/mixin.ts +122 -0
- package/utils/utils.ts +520 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-date-picker-root">
|
|
3
|
+
<ste-picker
|
|
4
|
+
:columns="columns"
|
|
5
|
+
:title="title"
|
|
6
|
+
:showToolbar="showToolbar"
|
|
7
|
+
:cancelText="cancelText"
|
|
8
|
+
:cancelColor="cancelColor"
|
|
9
|
+
:confirmText="confirmText"
|
|
10
|
+
:confirmColor="cmpConfirmColor"
|
|
11
|
+
:visibleItemCount="visibleItemCount"
|
|
12
|
+
:defaultIndex="innerDefaultIndex"
|
|
13
|
+
:itemHeight="itemHeight"
|
|
14
|
+
@change="change"
|
|
15
|
+
@cancel="cancel"
|
|
16
|
+
@confirm="confirm"
|
|
17
|
+
rootClass="ste-date-picker-view"
|
|
18
|
+
v-if="show"
|
|
19
|
+
></ste-picker>
|
|
20
|
+
</view>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script lang="ts" setup>
|
|
24
|
+
import { ref, onMounted, nextTick, defineOptions, computed } from 'vue';
|
|
25
|
+
import useColor from '../../config/color';
|
|
26
|
+
let color = useColor();
|
|
27
|
+
import propsData from './props';
|
|
28
|
+
import type { CloumnType } from './types';
|
|
29
|
+
import utils from '../../utils/utils';
|
|
30
|
+
const dayjs = utils.dayjs;
|
|
31
|
+
|
|
32
|
+
const componentName = 'ste-date-picker';
|
|
33
|
+
defineOptions({
|
|
34
|
+
name: componentName,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const props = defineProps(propsData);
|
|
38
|
+
|
|
39
|
+
let cmpConfirmColor = computed(() => {
|
|
40
|
+
return props.confirmColor ? props.confirmColor : color.getColor().steThemeColor;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const DEFAULT_DATE = dayjs(new Date(1970, 1, 1, 0, 0, 0));
|
|
44
|
+
const padZero = (value: string | number) => `00${value}`.slice(-2);
|
|
45
|
+
|
|
46
|
+
const times = (n: number, iteratee: (index: number) => string): string[] => {
|
|
47
|
+
let index = -1;
|
|
48
|
+
const result = Array(n < 0 ? 0 : n);
|
|
49
|
+
while (++index < n) {
|
|
50
|
+
result[index] = iteratee(index);
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const emits = defineEmits<{
|
|
56
|
+
(e: 'change', changeObj: any): void;
|
|
57
|
+
(e: 'cancel'): void;
|
|
58
|
+
(e: 'confirm', value: string | number): void;
|
|
59
|
+
}>();
|
|
60
|
+
|
|
61
|
+
const columns = ref<string[][]>([]);
|
|
62
|
+
const innerValue = ref<string | number>('');
|
|
63
|
+
const innerDefaultIndex = ref<number[]>([]);
|
|
64
|
+
|
|
65
|
+
const show = ref(false);
|
|
66
|
+
const innerFormatter = (type: string, value: string) => value;
|
|
67
|
+
|
|
68
|
+
const init = () => {
|
|
69
|
+
innerValue.value = correctValue(props.value);
|
|
70
|
+
updateColumnValue(innerValue.value);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const updateColumnValue = (value: string | number) => {
|
|
74
|
+
innerValue.value = value;
|
|
75
|
+
updateColumns();
|
|
76
|
+
updateIndexs();
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const updateColumns = () => {
|
|
80
|
+
const formatter = props.formatter || innerFormatter;
|
|
81
|
+
const result = getOriginColumns().map(column => column.values.map(value => formatter(column.type, value)));
|
|
82
|
+
columns.value = result;
|
|
83
|
+
nextTick(() => {
|
|
84
|
+
show.value = true;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const updateIndexs = () => {
|
|
89
|
+
let value = innerValue.value;
|
|
90
|
+
let values: string[] = [];
|
|
91
|
+
const formatter = props.formatter || innerFormatter;
|
|
92
|
+
|
|
93
|
+
values.push(
|
|
94
|
+
formatter('year', `${dayjs(value).year()}` as string),
|
|
95
|
+
formatter('month', padZero(dayjs(value).month() + 1) as string),
|
|
96
|
+
formatter('day', padZero(dayjs(value).date()) as string),
|
|
97
|
+
formatter('hour', padZero(dayjs(value).hour()) as string),
|
|
98
|
+
formatter('minute', padZero(dayjs(value).minute()) as string),
|
|
99
|
+
formatter('second', padZero(dayjs(value).second()) as string)
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
let startFlag = 0;
|
|
103
|
+
switch (props.mode) {
|
|
104
|
+
case 'month-day':
|
|
105
|
+
startFlag = 1;
|
|
106
|
+
break;
|
|
107
|
+
case 'time':
|
|
108
|
+
case 'hour-minute':
|
|
109
|
+
startFlag = 3;
|
|
110
|
+
break;
|
|
111
|
+
case 'minute-second':
|
|
112
|
+
startFlag = 4;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const indexs = columns.value.map((column, index) => {
|
|
116
|
+
return Math.max(
|
|
117
|
+
0,
|
|
118
|
+
column.findIndex(item => item === values[index + startFlag])
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
innerDefaultIndex.value = indexs;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const getOriginColumns = () => {
|
|
126
|
+
const results = getRanges().map(({ type, range }) => {
|
|
127
|
+
let values = times(range[1] - range[0] + 1, (index: number) => {
|
|
128
|
+
let value: string = (range[0] + index).toString();
|
|
129
|
+
value = type === 'year' ? `${value}` : padZero(value);
|
|
130
|
+
return value;
|
|
131
|
+
});
|
|
132
|
+
if (props.filter) {
|
|
133
|
+
values = props.filter(type, values);
|
|
134
|
+
}
|
|
135
|
+
return { type, values };
|
|
136
|
+
});
|
|
137
|
+
return results;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const getRanges = () => {
|
|
141
|
+
const { maxYear, maxDate, maxMonth, maxHour, maxMinute, maxSecond } = getBoundary('max', innerValue.value);
|
|
142
|
+
const { minYear, minDate, minMonth, minHour, minMinute, minSecond } = getBoundary('min', innerValue.value);
|
|
143
|
+
|
|
144
|
+
const result: { type: CloumnType; range: [number, number] }[] = [
|
|
145
|
+
{ type: 'year', range: [minYear, maxYear] },
|
|
146
|
+
{ type: 'month', range: [minMonth, maxMonth] },
|
|
147
|
+
{ type: 'day', range: [minDate, maxDate] },
|
|
148
|
+
{ type: 'hour', range: [minHour, maxHour] },
|
|
149
|
+
{ type: 'minute', range: [minMinute, maxMinute] },
|
|
150
|
+
{ type: 'second', range: [minSecond, maxSecond] },
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
let temp = result;
|
|
154
|
+
if (props.mode === 'datetime') temp = result.splice(0, 5);
|
|
155
|
+
if (props.mode === 'date') temp = result.splice(0, 3);
|
|
156
|
+
if (props.mode === 'year-month') temp = result.splice(0, 2);
|
|
157
|
+
if (props.mode === 'month-day') temp = result.splice(1, 2);
|
|
158
|
+
if (props.mode === 'time') temp = result.splice(3, 3);
|
|
159
|
+
if (props.mode === 'hour-minute') temp = result.splice(3, 2);
|
|
160
|
+
if (props.mode === 'minute-second') temp = result.splice(4, 2);
|
|
161
|
+
return temp;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const getBoundary = (type: 'min' | 'max', innerValue: string | number) => {
|
|
165
|
+
const value = dayjs(innerValue);
|
|
166
|
+
|
|
167
|
+
const boundary = type === 'min' ? dayjs(props.minDate) : dayjs(props.maxDate);
|
|
168
|
+
const year = boundary.year();
|
|
169
|
+
let month = 1;
|
|
170
|
+
let date = 1;
|
|
171
|
+
let hour = 0;
|
|
172
|
+
let minute = 0;
|
|
173
|
+
|
|
174
|
+
if (type === 'max') {
|
|
175
|
+
month = 12;
|
|
176
|
+
date = dayjs(value).daysInMonth();
|
|
177
|
+
hour = 23;
|
|
178
|
+
minute = 59;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let second = minute;
|
|
182
|
+
if (value.year() === year) {
|
|
183
|
+
month = boundary.month() + 1;
|
|
184
|
+
if (value.month() + 1 === month) {
|
|
185
|
+
date = boundary.date();
|
|
186
|
+
if (value.date() === date) {
|
|
187
|
+
hour = boundary.hour();
|
|
188
|
+
if (value.hour() === hour) {
|
|
189
|
+
minute = boundary.minute();
|
|
190
|
+
if (value.minute() === minute) second = boundary.second();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
[`${type}Year`]: year,
|
|
198
|
+
[`${type}Month`]: month,
|
|
199
|
+
[`${type}Date`]: date,
|
|
200
|
+
[`${type}Hour`]: hour,
|
|
201
|
+
[`${type}Minute`]: minute,
|
|
202
|
+
[`${type}Second`]: second,
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const correctValue = (value: string | number) => {
|
|
207
|
+
let date = dayjs(value);
|
|
208
|
+
if (date.isValid()) {
|
|
209
|
+
if (date.isBefore(dayjs(props.minDate))) {
|
|
210
|
+
date = dayjs(props.minDate);
|
|
211
|
+
} else if (date.isAfter(dayjs(props.maxDate))) {
|
|
212
|
+
date = dayjs(props.maxDate);
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
date = dayjs();
|
|
216
|
+
}
|
|
217
|
+
return date.valueOf();
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const change = (e: { indexs: number[]; values: string[][] }) => {
|
|
221
|
+
const { indexs, values } = e;
|
|
222
|
+
let selectValue: string | number = '';
|
|
223
|
+
|
|
224
|
+
let dateArr = [DEFAULT_DATE.year(), DEFAULT_DATE.month() + 1, DEFAULT_DATE.day(), DEFAULT_DATE.hour(), DEFAULT_DATE.minute(), DEFAULT_DATE.second()];
|
|
225
|
+
|
|
226
|
+
let startFlag = 0;
|
|
227
|
+
switch (props.mode) {
|
|
228
|
+
case 'month-day':
|
|
229
|
+
startFlag = 1;
|
|
230
|
+
break;
|
|
231
|
+
case 'time':
|
|
232
|
+
case 'hour-minute':
|
|
233
|
+
startFlag = 3;
|
|
234
|
+
break;
|
|
235
|
+
case 'minute-second':
|
|
236
|
+
startFlag = 4;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
values.forEach((value, index) => {
|
|
240
|
+
switch (index + startFlag) {
|
|
241
|
+
case 0:
|
|
242
|
+
dateArr[0] = +value[indexs[index]];
|
|
243
|
+
break;
|
|
244
|
+
case 1:
|
|
245
|
+
dateArr[1] = +value[indexs[index]];
|
|
246
|
+
break;
|
|
247
|
+
case 2:
|
|
248
|
+
dateArr[2] = +value[indexs[index]];
|
|
249
|
+
break;
|
|
250
|
+
case 3:
|
|
251
|
+
dateArr[3] = +value[indexs[index]];
|
|
252
|
+
break;
|
|
253
|
+
case 4:
|
|
254
|
+
dateArr[4] = +value[indexs[index]];
|
|
255
|
+
break;
|
|
256
|
+
case 5:
|
|
257
|
+
dateArr[5] = +value[indexs[index]];
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// 此月份的最大天数
|
|
262
|
+
const maxDay = dayjs(`${dateArr[0]}-${dateArr[1]}`).daysInMonth();
|
|
263
|
+
dateArr[2] = Math.min(maxDay, dateArr[2]) || 1;
|
|
264
|
+
|
|
265
|
+
selectValue = dayjs(`${dateArr[0]}/${padZero(dateArr[1])}/${padZero(dateArr[2])} ${padZero(dateArr[3])}:${padZero(dateArr[4])}:${padZero(dateArr[5])}`).valueOf();
|
|
266
|
+
|
|
267
|
+
updateColumnValue(selectValue);
|
|
268
|
+
emits('change', { value: selectValue, columnIndexs: indexs });
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const cancel = () => {
|
|
272
|
+
emits('cancel');
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const confirm = () => {
|
|
276
|
+
emits('confirm', innerValue.value);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
onMounted(init);
|
|
280
|
+
</script>
|
|
281
|
+
|
|
282
|
+
<style scoped>
|
|
283
|
+
.ste-date-picker-root {
|
|
284
|
+
width: 100%;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.ste-date-picker-view {
|
|
288
|
+
width: 100%;
|
|
289
|
+
}
|
|
290
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#### Props
|
|
2
|
+
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
3
|
+
| ----- | ----- | --- | ------- | ------ | -------- |
|
|
4
|
+
| `attract` | 是否开启自动吸边(根据 screenWidth 进行吸边) | `boolean` | `false` | - | - |
|
|
5
|
+
| `direction` | 拖拽元素的拖拽方向限制 | `string` | `all` | `all`:不限制方向<br/>`x`:横向拖拽<br/>`y`:竖向拖拽 | - |
|
|
6
|
+
| `boundary` | 拖拽元素的拖拽边界 | `object` | `屏幕为边界` | - | - |
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#### Events
|
|
10
|
+
| 事件名 | 说明 | 事件参数 | 支持版本 |
|
|
11
|
+
| ----- | ----- | ------- | -------- |
|
|
12
|
+
| `start` | 拖拽开始 | - | - |
|
|
13
|
+
| `end` | 拖拽结束 | - | - |
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Drag 拖拽
|
|
2
|
+
|
|
3
|
+
用于拖拽的容器
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
### 代码演示
|
|
8
|
+
|
|
9
|
+
#### 基础使用
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ste-drag>
|
|
13
|
+
<ste-button>拖拽按钮</ste-button>
|
|
14
|
+
</ste-drag>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
#### 固定方向
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<ste-drag direction="x">
|
|
21
|
+
<ste-button>横向固定</ste-button>
|
|
22
|
+
</ste-drag>
|
|
23
|
+
|
|
24
|
+
<ste-drag direction="y">
|
|
25
|
+
<ste-button>竖向固定</ste-button>
|
|
26
|
+
</ste-drag>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### 贴边
|
|
30
|
+
|
|
31
|
+
会根据元素移动结束时到左右边界距离来进行贴边
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<ste-drag attract>
|
|
35
|
+
<ste-button>贴边</ste-button>
|
|
36
|
+
</ste-drag>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### 边界
|
|
40
|
+
|
|
41
|
+
- 数据结构是 `{top: 0, right: 0, bottom: 0, left: 0}`,分别代表距离屏幕上、右、下、左的距离(单位px)
|
|
42
|
+
- 可按照样例中的做法,根据屏幕大小动态边界值
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<template>
|
|
46
|
+
<view style="width: 300px; height: 150px; border: solid 1px red" class="boundary-box">
|
|
47
|
+
<ste-drag :boundary="boundary">
|
|
48
|
+
<ste-button>边界</ste-button>
|
|
49
|
+
</ste-drag>
|
|
50
|
+
</view>
|
|
51
|
+
</template>
|
|
52
|
+
<script lang="ts" setup>
|
|
53
|
+
import utils from '@/common/utils.js';
|
|
54
|
+
import { ref, onMounted } from 'vue';
|
|
55
|
+
const boundary = ref({ left: 22, bottom: 0, top: 354, right: 0 });
|
|
56
|
+
onMounted(() => {
|
|
57
|
+
const systemInfo = utils.getWindowInfo();
|
|
58
|
+
boundary.value.right = systemInfo.windowWidth - 22 - 300;
|
|
59
|
+
boundary.value.bottom = systemInfo.windowHeight - 354 - 150;
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
<style>
|
|
63
|
+
.boundary-box {
|
|
64
|
+
width: 300px;
|
|
65
|
+
height: 150px;
|
|
66
|
+
border: solid 1px red;
|
|
67
|
+
|
|
68
|
+
position: fixed;
|
|
69
|
+
left: 22px;
|
|
70
|
+
top: 354px;
|
|
71
|
+
}
|
|
72
|
+
</style>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---$
|
|
76
|
+
|
|
77
|
+
### API
|
|
78
|
+
|
|
79
|
+
<!-- props -->
|
|
80
|
+
|
|
81
|
+
#### Slots
|
|
82
|
+
|
|
83
|
+
| 插槽名 | 说明 | 插槽参数 | 支持版本 |
|
|
84
|
+
| --------- | -------- | -------- | -------- |
|
|
85
|
+
| `default` | 拖拽内容 | - | - |
|
|
86
|
+
|
|
87
|
+
---$
|
|
88
|
+
{{fuyuwei}}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PropType } from 'vue'
|
|
2
|
+
|
|
3
|
+
type DirectionType = 'all' | 'x' | 'y'
|
|
4
|
+
export const DEFAULT_BOUNDARY = { top: 0, left: 0, right: 0, bottom: 0 }
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
attract: { type: Boolean, default: false },
|
|
8
|
+
direction: { type: String as PropType<DirectionType>, default: 'all' },
|
|
9
|
+
boundary: { type: Object, default: () => DEFAULT_BOUNDARY },
|
|
10
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ste-drag",
|
|
3
|
+
"description": "拖拽",
|
|
4
|
+
"example": "<ste-drag><view>拖拽内容</view></ste-drag>",
|
|
5
|
+
"tutorial": "https://stellar-ui.intecloud.com.cn/plus/#/?active=drag",
|
|
6
|
+
"attributes": [
|
|
7
|
+
{
|
|
8
|
+
"name": "attract",
|
|
9
|
+
"description": "是否开启自动吸边(根据 screenWidth 进行吸边)",
|
|
10
|
+
"type": "boolean",
|
|
11
|
+
"default": false
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "direction",
|
|
15
|
+
"description": "拖拽元素的拖拽方向限制",
|
|
16
|
+
"type": "string",
|
|
17
|
+
"values": [
|
|
18
|
+
{
|
|
19
|
+
"name": "all",
|
|
20
|
+
"description": "不限制方向"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "x",
|
|
24
|
+
"description": "横向拖拽"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "y",
|
|
28
|
+
"description": "竖向拖拽"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"default": "all"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "boundary",
|
|
35
|
+
"description": "拖拽元素的拖拽边界",
|
|
36
|
+
"type": "object",
|
|
37
|
+
"default": "屏幕为边界"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "[event]start",
|
|
41
|
+
"description": "拖拽开始",
|
|
42
|
+
"type": "(t) => void"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "[event]end",
|
|
46
|
+
"description": "拖拽结束",
|
|
47
|
+
"type": "() => void"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { watch, onMounted, reactive, defineOptions, onBeforeUnmount, getCurrentInstance } from 'vue';
|
|
3
|
+
import utils from '../../utils/utils';
|
|
4
|
+
import propsData, { DEFAULT_BOUNDARY } from './props';
|
|
5
|
+
|
|
6
|
+
const componentName = `ste-drag`;
|
|
7
|
+
defineOptions({
|
|
8
|
+
name: componentName,
|
|
9
|
+
options: {
|
|
10
|
+
virtualHost: true,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
let isMove = false;
|
|
15
|
+
const props = defineProps(propsData);
|
|
16
|
+
const emits = defineEmits<{
|
|
17
|
+
(e: 'start'): void;
|
|
18
|
+
(e: 'end'): void;
|
|
19
|
+
}>();
|
|
20
|
+
|
|
21
|
+
const SCREEN_WIDTH = utils.System.getWindowWidth();
|
|
22
|
+
const SCREEN_HEIGHT = utils.System.getWindowHeight();
|
|
23
|
+
const instance = getCurrentInstance() as unknown as ComponentPublicInstance;
|
|
24
|
+
|
|
25
|
+
const rootID = `myDrag-${utils.guid()}`;
|
|
26
|
+
const state: any = reactive({
|
|
27
|
+
elWidth: 0,
|
|
28
|
+
elHeight: 0,
|
|
29
|
+
screenWidth: SCREEN_WIDTH,
|
|
30
|
+
screenHeight: SCREEN_HEIGHT,
|
|
31
|
+
startTop: 0,
|
|
32
|
+
startLeft: 0,
|
|
33
|
+
initTop: 0,
|
|
34
|
+
initLeft: 0,
|
|
35
|
+
top: 0,
|
|
36
|
+
left: 0,
|
|
37
|
+
attractTransition: false,
|
|
38
|
+
boundary: {
|
|
39
|
+
top: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
right: 0,
|
|
42
|
+
bottom: 0,
|
|
43
|
+
} as Record<string, any>,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
onMounted(() => {
|
|
47
|
+
getInfo();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
onBeforeUnmount(() => {
|
|
51
|
+
// #ifndef MP || APP
|
|
52
|
+
removeListenner && removeListenner();
|
|
53
|
+
// #endif
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
watch(
|
|
57
|
+
() => props.boundary,
|
|
58
|
+
val => {
|
|
59
|
+
state.boundary = { ...DEFAULT_BOUNDARY, ...val };
|
|
60
|
+
},
|
|
61
|
+
{ immediate: true, deep: true }
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
async function getInfo() {
|
|
65
|
+
const rec = await utils.querySelector<false>('#' + rootID, instance);
|
|
66
|
+
state.elWidth = rec.width;
|
|
67
|
+
state.elHeight = rec.height;
|
|
68
|
+
state.initTop = rec.top;
|
|
69
|
+
state.initLeft = rec.left;
|
|
70
|
+
|
|
71
|
+
attractFn();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function touchMove(e: TouchEvent | MouseEvent) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
const touch = getMoveObj(e);
|
|
77
|
+
|
|
78
|
+
let left = touch.clientX - state.startLeft;
|
|
79
|
+
let top = touch.clientY - state.startTop;
|
|
80
|
+
|
|
81
|
+
const rightLocation = state.screenWidth - state.elWidth - state.boundary.right;
|
|
82
|
+
if (Math.abs(left + state.initLeft) > rightLocation) left = rightLocation - state.initLeft;
|
|
83
|
+
else if (left + state.initLeft <= state.boundary.left) left = state.boundary.left - state.initLeft;
|
|
84
|
+
|
|
85
|
+
if (top + state.initTop < state.boundary.top) top = state.boundary.top - state.initTop;
|
|
86
|
+
else if (top + state.initTop > state.screenHeight - state.elHeight - state.boundary.bottom) top = state.screenHeight - state.elHeight - state.boundary.bottom - state.initTop;
|
|
87
|
+
|
|
88
|
+
if (props.direction !== 'y') state.left = left;
|
|
89
|
+
if (props.direction !== 'x') state.top = top;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function attractFn() {
|
|
93
|
+
if (!props.attract || props.direction === 'y') return;
|
|
94
|
+
const screenCenterX = (state.screenWidth - state.boundary.right - state.boundary.left) / 2;
|
|
95
|
+
const centerX = screenCenterX - state.initLeft - state.elWidth / 2;
|
|
96
|
+
|
|
97
|
+
if (state.left < centerX) state.left = state.boundary.left - state.initLeft;
|
|
98
|
+
else state.left = state.screenWidth - state.elWidth - state.boundary.right - state.initLeft;
|
|
99
|
+
state.attractTransition = true;
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
state.attractTransition = false;
|
|
102
|
+
}, 400);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function touchEnd() {
|
|
106
|
+
// #ifndef MP || APP
|
|
107
|
+
removeListenner && removeListenner();
|
|
108
|
+
// #endif
|
|
109
|
+
if (isMove) {
|
|
110
|
+
emits('end');
|
|
111
|
+
isMove = false;
|
|
112
|
+
}
|
|
113
|
+
attractFn();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function touchStart(e: TouchEvent | MouseEvent) {
|
|
117
|
+
isMove = true;
|
|
118
|
+
emits('start');
|
|
119
|
+
const touch = getMoveObj(e);
|
|
120
|
+
state.startLeft = touch.clientX - state.left;
|
|
121
|
+
state.startTop = touch.clientY - state.top;
|
|
122
|
+
state.attractTransition = false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// #ifdef WEB
|
|
126
|
+
|
|
127
|
+
function mouseDown(e: MouseEvent) {
|
|
128
|
+
touchStart(e);
|
|
129
|
+
window.addEventListener('mousemove', touchMove);
|
|
130
|
+
window.addEventListener('mouseup', touchEnd);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function removeListenner() {
|
|
134
|
+
window.removeEventListener('mousemove', touchMove);
|
|
135
|
+
window.removeEventListener('mouseup', touchEnd);
|
|
136
|
+
}
|
|
137
|
+
// #endif
|
|
138
|
+
|
|
139
|
+
function getMoveObj(e: TouchEvent | MouseEvent): { clientX: number; clientY: number } {
|
|
140
|
+
if ('touches' in e) {
|
|
141
|
+
// e is UniTouchEvent
|
|
142
|
+
const touch = e.touches[0];
|
|
143
|
+
return { clientX: touch.pageX, clientY: touch.pageY };
|
|
144
|
+
} else {
|
|
145
|
+
// e is HTMLMouseEvent
|
|
146
|
+
return { clientX: e.pageX, clientY: e.pageY };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<template>
|
|
152
|
+
<view
|
|
153
|
+
:id="rootID"
|
|
154
|
+
class="ste-drag-root"
|
|
155
|
+
:style="{
|
|
156
|
+
transform: `translate(${`${state.left}px`}, ${`${state.top}px`})`,
|
|
157
|
+
transition: state.attractTransition ? 'all ease 0.3s' : 'none',
|
|
158
|
+
}"
|
|
159
|
+
@touchstart="touchStart"
|
|
160
|
+
@touchmove.stop.prevent="touchMove"
|
|
161
|
+
@touchend="touchEnd"
|
|
162
|
+
@mousedown="mouseDown"
|
|
163
|
+
>
|
|
164
|
+
<slot />
|
|
165
|
+
</view>
|
|
166
|
+
</template>
|
|
167
|
+
|
|
168
|
+
<style lang="scss" scoped>
|
|
169
|
+
.ste-drag-root {
|
|
170
|
+
display: inline-flex;
|
|
171
|
+
}
|
|
172
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#### Props
|
|
2
|
+
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
3
|
+
| ----- | ----- | --- | ------- | ------ | -------- |
|
|
4
|
+
| `title` | 菜单标题,未设置时会显示选中项的值 | `string` | - | - | - |
|
|
5
|
+
| `value` | 下拉菜单选中的值 | `string / array` | - | - | - |
|
|
6
|
+
| `inactiveColor` | 未选中颜色 | `string` | `#000000` | - | - |
|
|
7
|
+
| `activeColor` | 选中色 | `string` | `#0090FF` | - | - |
|
|
8
|
+
| `direction` | 展开方向 | `string` | `down` | `up`:向上展开<br/>`down`:向下展开 | - |
|
|
9
|
+
| `duration` | 展开动画执行时间 | `number` | `0.2` | - | - |
|
|
10
|
+
| `showMask` | 是否展示遮罩 | `boolean` | `true` | - | - |
|
|
11
|
+
| `isMaskClick` | 是否点击遮罩关闭 | `boolean` | `true` | - | - |
|
|
12
|
+
| `zIndex` | 弹窗层级z-index | `number` | - | - | - |
|
|
13
|
+
| `type` | 下拉选项的形状 | `string` | `block` | `round`:圆形<br/>`block`:块状 | - |
|
|
14
|
+
| `max` | 可选数量 | `number` | `1` | - | - |
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#### Events
|
|
18
|
+
| 事件名 | 说明 | 事件参数 | 支持版本 |
|
|
19
|
+
| ----- | ----- | ------- | -------- |
|
|
20
|
+
| `change` | 选项改变时触发 | `value`:选中的值 | - |
|
|
21
|
+
| `open` | 菜单打开 | - | - |
|
|
22
|
+
| `close` | 菜单收起 | - | - |
|