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,293 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, defineOptions, getCurrentInstance, type CSSProperties, type ComponentPublicInstance, onMounted, watch, onBeforeUnmount } from 'vue';
|
|
3
|
+
import useColor from '../../config/color';
|
|
4
|
+
let color = useColor();
|
|
5
|
+
import type { UniTouchEvent, BaseEvent } from '../../types/event';
|
|
6
|
+
import utils from '../../utils/utils';
|
|
7
|
+
import propsData, { sliderEmits } from './props';
|
|
8
|
+
import useData from './useData';
|
|
9
|
+
const componentName = `ste-slider`;
|
|
10
|
+
defineOptions({
|
|
11
|
+
name: componentName,
|
|
12
|
+
options: {
|
|
13
|
+
virtualHost: true,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const default_max = 100;
|
|
18
|
+
const default_min = 0;
|
|
19
|
+
|
|
20
|
+
const props = defineProps(propsData);
|
|
21
|
+
const emits = defineEmits(sliderEmits);
|
|
22
|
+
const instance = getCurrentInstance() as unknown as ComponentPublicInstance;
|
|
23
|
+
|
|
24
|
+
let hasMarks = false;
|
|
25
|
+
let isMouseDown = false;
|
|
26
|
+
let isSecondSlider = false;
|
|
27
|
+
|
|
28
|
+
let elRoot: UniApp.NodeInfo;
|
|
29
|
+
|
|
30
|
+
let { markList, isDrag, realPercentage, realPercentage2, getRealValue, calculateStepMarks, startPosition, getPosition, startPercentage, getValueFromPercentage } = useData(props, emits, instance);
|
|
31
|
+
|
|
32
|
+
const cmpRootClass = computed(() => {
|
|
33
|
+
let classStr = '';
|
|
34
|
+
if (isDrag.value) {
|
|
35
|
+
classStr += 'ste-slider-drag ';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (props.range) {
|
|
39
|
+
classStr += 'ste-slider-range ';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (props.disabled) {
|
|
43
|
+
classStr += 'ste-slider-disabled ';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (props.vertical) {
|
|
47
|
+
classStr += 'ste-slider-vertical ';
|
|
48
|
+
} else {
|
|
49
|
+
classStr += 'ste-slider-horizontal ';
|
|
50
|
+
}
|
|
51
|
+
return classStr;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const cmpRootCssVar = computed(() => {
|
|
55
|
+
return {
|
|
56
|
+
'--progress-height': utils.addUnit(props.barHeight),
|
|
57
|
+
'--bar-size': utils.addUnit(props.buttonSize),
|
|
58
|
+
'--active-color': props.activeColor ? props.activeColor : color.getColor().steThemeColor,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const cmpInactiveStyle = computed(() => {
|
|
63
|
+
let style: CSSProperties = {};
|
|
64
|
+
if (!props.disabled) {
|
|
65
|
+
const bg = utils.bg2style(props.inactiveColor);
|
|
66
|
+
style = { ...style, ...bg };
|
|
67
|
+
}
|
|
68
|
+
return style;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const cmpActiveStyle = computed(() => {
|
|
72
|
+
let style: CSSProperties = {};
|
|
73
|
+
if (!props.disabled) {
|
|
74
|
+
const bg = utils.bg2style(props.activeColor ? props.activeColor : color.getColor().steThemeColor);
|
|
75
|
+
style = { ...style, ...bg };
|
|
76
|
+
}
|
|
77
|
+
if (props.vertical) {
|
|
78
|
+
if (props.range) {
|
|
79
|
+
style.top = realPercentage.value + '%';
|
|
80
|
+
style.height = realPercentage2.value - realPercentage.value + '%';
|
|
81
|
+
} else {
|
|
82
|
+
style.height = realPercentage.value + '%';
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
if (props.range) {
|
|
86
|
+
style.left = realPercentage.value + '%';
|
|
87
|
+
style.width = realPercentage2.value - realPercentage.value + '%';
|
|
88
|
+
} else {
|
|
89
|
+
style.width = realPercentage.value + '%';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return style;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
onMounted(() => {
|
|
96
|
+
handleWindowResize();
|
|
97
|
+
uni.onWindowResize(handleWindowResize);
|
|
98
|
+
calculateStepMarks();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
onBeforeUnmount(() => {
|
|
102
|
+
uni.offWindowResize(handleWindowResize);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
watch(
|
|
106
|
+
() => props.value,
|
|
107
|
+
val => {
|
|
108
|
+
if (Array.isArray(val)) {
|
|
109
|
+
realPercentage.value = getRealValue(Number(val[0]));
|
|
110
|
+
realPercentage2.value = getRealValue(Number(val[1]));
|
|
111
|
+
} else {
|
|
112
|
+
realPercentage.value = getRealValue(Number(val));
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{ immediate: true }
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
watch(
|
|
119
|
+
() => props.marks,
|
|
120
|
+
val => {
|
|
121
|
+
hasMarks = Object.keys(val || {}).length > 0;
|
|
122
|
+
},
|
|
123
|
+
{ immediate: true }
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
function handleWindowResize() {
|
|
127
|
+
utils.querySelector<false>('.ste-slider-root', instance).then(rect => {
|
|
128
|
+
elRoot = rect || {};
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function handleClick(e: MouseEvent | BaseEvent) {
|
|
133
|
+
if (props.readonly || props.disabled || props.range) return;
|
|
134
|
+
const { top = 0, height = 0, left = 0, width = 0 } = elRoot;
|
|
135
|
+
let offsetValue;
|
|
136
|
+
if (props.vertical) {
|
|
137
|
+
let clientY = e.detail.y || e.detail.clientY;
|
|
138
|
+
offsetValue = ((clientY - top) / height) * 100;
|
|
139
|
+
} else {
|
|
140
|
+
let clientX = e.detail.x || e.detail.clientX;
|
|
141
|
+
offsetValue = ((clientX - left) / width) * 100;
|
|
142
|
+
}
|
|
143
|
+
updateWidth(offsetValue, false);
|
|
144
|
+
emits('change', props.range ? [realPercentage.value, realPercentage2.value] : getValueFromPercentage(realPercentage.value));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function onTouchStart(e: UniTouchEvent | MouseEvent, isSecond: Boolean = false) {
|
|
148
|
+
isSecondSlider = !!isSecond;
|
|
149
|
+
|
|
150
|
+
startPosition.value = getPosition(e);
|
|
151
|
+
startPercentage.value = isSecond ? realPercentage2.value : realPercentage.value;
|
|
152
|
+
emits('dragStart', e);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function onTouchMove(e: UniTouchEvent | MouseEvent) {
|
|
156
|
+
if (props.readonly || props.disabled) return;
|
|
157
|
+
let touches = getPosition(e);
|
|
158
|
+
let distance = props.vertical ? touches.clientY - startPosition.value.clientY : touches.clientX - startPosition.value.clientX;
|
|
159
|
+
let containerLength = props.vertical ? elRoot.height : elRoot.width;
|
|
160
|
+
let offsetValue = (distance / Number(containerLength)) * 100;
|
|
161
|
+
updateWidth(offsetValue, true);
|
|
162
|
+
}
|
|
163
|
+
function onTouchEnd(e: UniTouchEvent | MouseEvent) {
|
|
164
|
+
isDrag.value = false;
|
|
165
|
+
// this.isSecondSlider = false;
|
|
166
|
+
emits('dragEnd', e);
|
|
167
|
+
emits('change', props.range ? [realPercentage.value, realPercentage2.value] : getValueFromPercentage(realPercentage.value));
|
|
168
|
+
|
|
169
|
+
// #ifdef WEB
|
|
170
|
+
removeListenner && removeListenner();
|
|
171
|
+
// #endif
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function updateWidth(value: number, drag: boolean) {
|
|
175
|
+
let realValue;
|
|
176
|
+
isDrag.value = drag;
|
|
177
|
+
if (drag) {
|
|
178
|
+
realValue = startPercentage.value + value;
|
|
179
|
+
} else {
|
|
180
|
+
realValue = value;
|
|
181
|
+
}
|
|
182
|
+
const changeValue = calculateValue(realValue);
|
|
183
|
+
if (isSecondSlider) {
|
|
184
|
+
realPercentage2.value = changeValue;
|
|
185
|
+
} else {
|
|
186
|
+
realPercentage.value = changeValue;
|
|
187
|
+
}
|
|
188
|
+
emits('input', props.range ? [realPercentage.value, realPercentage2.value] : realPercentage.value);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 根据步长和最大最小值来计算每次的滑动
|
|
192
|
+
function calculateValue(value: number) {
|
|
193
|
+
let step = hasMarks ? 1 : Number(props.step);
|
|
194
|
+
let min = Number(default_min);
|
|
195
|
+
let max = Number(default_max);
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
*当范围模式下时,两个滑块不允许交替,
|
|
199
|
+
*第一个滑块的最大值就是第二个滑块的当前值,
|
|
200
|
+
* 第二个滑块的最小是就是第一个滑块的当前值
|
|
201
|
+
*/
|
|
202
|
+
if (props.range) {
|
|
203
|
+
if (isSecondSlider) {
|
|
204
|
+
min = realPercentage.value;
|
|
205
|
+
} else {
|
|
206
|
+
max = realPercentage2.value;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// 计算出当前值相对于最小值的偏移量
|
|
211
|
+
const offset = value - Number(min);
|
|
212
|
+
// 根据步长计算出应该是哪个步长点
|
|
213
|
+
const targetValue = Math.round(offset / step) * step + min;
|
|
214
|
+
// 确保计算出的值不会超过最大值和低于最小值
|
|
215
|
+
return getRealValue(targetValue, max, min);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// #ifdef WEB
|
|
219
|
+
// 适配web端没有touch事件
|
|
220
|
+
function onDown(e: UniTouchEvent | MouseEvent, isSecond: Boolean = false) {
|
|
221
|
+
isMouseDown = true;
|
|
222
|
+
onTouchStart({ touches: [{ clientX: e.clientX, clientY: e.clientY }] } as unknown as UniTouchEvent, isSecond);
|
|
223
|
+
window.addEventListener('mousemove', onTouchMove);
|
|
224
|
+
window.addEventListener('mouseup', onTouchEnd);
|
|
225
|
+
}
|
|
226
|
+
function removeListenner() {
|
|
227
|
+
window.removeEventListener('mousemove', onTouchMove);
|
|
228
|
+
window.removeEventListener('mouseup', onTouchEnd);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// #endif
|
|
232
|
+
</script>
|
|
233
|
+
|
|
234
|
+
<template>
|
|
235
|
+
<view class="ste-slider-root" :class="cmpRootClass" :style="[cmpRootCssVar]" @click="handleClick">
|
|
236
|
+
<view class="inactive-box" :style="[cmpInactiveStyle]"></view>
|
|
237
|
+
<view class="active-box line" :style="[cmpActiveStyle]"></view>
|
|
238
|
+
|
|
239
|
+
<view
|
|
240
|
+
class="slider-bar-box"
|
|
241
|
+
:class="{ 'range-min': realPercentage == 0, 'range-max': realPercentage == 100 }"
|
|
242
|
+
@touchstart.stop="onTouchStart"
|
|
243
|
+
@touchmove.stop="onTouchMove"
|
|
244
|
+
@touchend.stop="onTouchEnd"
|
|
245
|
+
@touchcancel.stop="onTouchEnd"
|
|
246
|
+
@mousedown="onDown"
|
|
247
|
+
:style="{
|
|
248
|
+
left: vertical ? '50%' : `${realPercentage}%`,
|
|
249
|
+
top: vertical ? `${realPercentage}%` : '50%',
|
|
250
|
+
}"
|
|
251
|
+
>
|
|
252
|
+
<slot v-if="range" name="leftButton">
|
|
253
|
+
<view class="slider-bar"></view>
|
|
254
|
+
</slot>
|
|
255
|
+
<slot v-else name="button">
|
|
256
|
+
<view class="slider-bar"></view>
|
|
257
|
+
</slot>
|
|
258
|
+
</view>
|
|
259
|
+
|
|
260
|
+
<view
|
|
261
|
+
v-if="range"
|
|
262
|
+
class="slider-bar-box range"
|
|
263
|
+
:class="{ 'range-min': realPercentage2 == 0, 'range-max': realPercentage2 == 100 }"
|
|
264
|
+
@touchstart="onTouchStart($event, true)"
|
|
265
|
+
@touchmove.stop="onTouchMove($event)"
|
|
266
|
+
@touchend="onTouchEnd($event)"
|
|
267
|
+
@touchcancel="onTouchEnd($event)"
|
|
268
|
+
@mousedown="onDown($event, true)"
|
|
269
|
+
:style="{
|
|
270
|
+
left: vertical ? '50%' : `${realPercentage2}%`,
|
|
271
|
+
top: vertical ? `${realPercentage2}%` : '50%',
|
|
272
|
+
zIndex: isSecondSlider ? 10 : 8,
|
|
273
|
+
}"
|
|
274
|
+
>
|
|
275
|
+
<slot name="rightButton">
|
|
276
|
+
<view class="slider-bar"></view>
|
|
277
|
+
</slot>
|
|
278
|
+
</view>
|
|
279
|
+
|
|
280
|
+
<template v-if="showStops">
|
|
281
|
+
<template v-for="(e, i) in markList" :key="i">
|
|
282
|
+
<view class="mark-box" :style="{ left: e.left, top: e.top }">
|
|
283
|
+
<view class="dot" />
|
|
284
|
+
<view class="marks-label" :style="e.style">{{ e.label }}</view>
|
|
285
|
+
</view>
|
|
286
|
+
</template>
|
|
287
|
+
</template>
|
|
288
|
+
</view>
|
|
289
|
+
</template>
|
|
290
|
+
|
|
291
|
+
<style lang="scss" scoped>
|
|
292
|
+
@import './ste-slider.scss';
|
|
293
|
+
</style>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, SetupContext } from 'vue'
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import type { UniTouchEvent } from '../../types/event'
|
|
4
|
+
import type { SliderEmits, SliderProps } from './props'
|
|
5
|
+
import type { Position } from './type'
|
|
6
|
+
|
|
7
|
+
export default function useData(props: SliderProps, _emits: SetupContext<SliderEmits>['emit'], _instance: ComponentPublicInstance) {
|
|
8
|
+
const realPercentage = ref(0)
|
|
9
|
+
const realPercentage2 = ref(0)
|
|
10
|
+
|
|
11
|
+
const isDrag = ref(false)
|
|
12
|
+
const startPosition = ref<Position>({ clientX: 0, clientY: 0 })
|
|
13
|
+
const startPercentage = ref(0)
|
|
14
|
+
|
|
15
|
+
const markList = ref<Obj[]>([])
|
|
16
|
+
|
|
17
|
+
function getValueFromPercentage(percentage: number) {
|
|
18
|
+
const value = Number(props.min) + ((Number(props.max) - Number(props.min)) * percentage) / 100
|
|
19
|
+
return Math.round(value / Number(props.step)) * Number(props.step)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 根据传入的最大最小值来计算传入的值是否在范围内,并给出范围内的值
|
|
23
|
+
function getRealValue(value = 0, max = props.max, min = props.min) {
|
|
24
|
+
return Math.max(Math.min(value, Number(max)), Number(min))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function calculateStepMarks() {
|
|
28
|
+
if (!props.showStops)
|
|
29
|
+
return
|
|
30
|
+
markList.value = []
|
|
31
|
+
const min = Number(props.min)
|
|
32
|
+
const max = Number(props.max)
|
|
33
|
+
|
|
34
|
+
const marksKeys = Object.keys(props.marks || {})
|
|
35
|
+
if (marksKeys.length > 0) {
|
|
36
|
+
marksKeys.forEach((e) => {
|
|
37
|
+
markList.value.push({
|
|
38
|
+
left: props.vertical ? '0' : `${e}%`,
|
|
39
|
+
top: props.vertical ? `${e}%` : '0',
|
|
40
|
+
style: props.marks[e].style,
|
|
41
|
+
label: typeof props.marks[e] === 'string' ? props.marks[e] : props.marks[e].label,
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
for (let i = min; i <= max; i += Number(props.step)) {
|
|
47
|
+
// 根据自定义的 marks 对象判断是否需要显示该标记点
|
|
48
|
+
if (i === min || i === max)
|
|
49
|
+
continue // 跳过第一个和最后一个标记点
|
|
50
|
+
|
|
51
|
+
const percentage = ((i - min) / (max - min)) * 100
|
|
52
|
+
markList.value.push({
|
|
53
|
+
left: props.vertical ? '0' : `${percentage}%`,
|
|
54
|
+
top: props.vertical ? `${percentage}%` : '0',
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 为了保持web端和移动端事件参数数据结构一致
|
|
61
|
+
function getPosition(e: UniTouchEvent | MouseEvent) {
|
|
62
|
+
if ('touches' in e)
|
|
63
|
+
return e.touches[0]
|
|
64
|
+
else return { clientX: e.clientX, clientY: e.clientY }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
isDrag,
|
|
69
|
+
realPercentage,
|
|
70
|
+
realPercentage2,
|
|
71
|
+
startPosition,
|
|
72
|
+
startPercentage,
|
|
73
|
+
markList,
|
|
74
|
+
getRealValue,
|
|
75
|
+
calculateStepMarks,
|
|
76
|
+
getPosition,
|
|
77
|
+
getValueFromPercentage,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PropType } from 'vue'
|
|
2
|
+
|
|
3
|
+
const stepProps = {
|
|
4
|
+
title: { type: String, default: '' },
|
|
5
|
+
description: { type: String, default: '' },
|
|
6
|
+
icon: { type: String, default: '' },
|
|
7
|
+
status: { type: String as PropType<string | undefined>, default: undefined },
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default stepProps
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
.ste-step-row {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.ste-step-column {
|
|
6
|
+
display: flex;
|
|
7
|
+
|
|
8
|
+
.ste-step-line {
|
|
9
|
+
height: calc(4rpx + 100%) !important;
|
|
10
|
+
width: 2rpx !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ste-step-content {
|
|
14
|
+
padding-left: 6% !important;
|
|
15
|
+
text-align: left !important;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
.ste-step {
|
|
19
|
+
flex: 1;
|
|
20
|
+
font-size: 0;
|
|
21
|
+
text-align: center;
|
|
22
|
+
|
|
23
|
+
.head-is-dot {
|
|
24
|
+
top: 12rpx;
|
|
25
|
+
margin-bottom: 0 !important;
|
|
26
|
+
margin-top: 14rpx !important;
|
|
27
|
+
|
|
28
|
+
.ste-step-line {
|
|
29
|
+
top: 14rpx !important;
|
|
30
|
+
left: auto !important;
|
|
31
|
+
right: auto !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ste-step-icon {
|
|
35
|
+
box-sizing: content-box;
|
|
36
|
+
height: 16rpx !important;
|
|
37
|
+
width: 16rpx !important;
|
|
38
|
+
line-height: 16rpx !important;
|
|
39
|
+
background-color: var(---dot-color);
|
|
40
|
+
border-radius: 50%;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
.ste-step-head {
|
|
44
|
+
border-color: var(---color);
|
|
45
|
+
color: var(---num-color);
|
|
46
|
+
display: flex;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
margin-bottom: 22rpx;
|
|
49
|
+
position: relative;
|
|
50
|
+
|
|
51
|
+
.ste-step-line {
|
|
52
|
+
background: var(---line-color);
|
|
53
|
+
display: inline-block;
|
|
54
|
+
position: absolute;
|
|
55
|
+
height: 2rpx;
|
|
56
|
+
left: 50%;
|
|
57
|
+
right: -50%;
|
|
58
|
+
top: 20rpx;
|
|
59
|
+
}
|
|
60
|
+
.ste-step-icon.is-icon {
|
|
61
|
+
border-radius: 50%;
|
|
62
|
+
border-style: solid;
|
|
63
|
+
border-width: 2rpx;
|
|
64
|
+
border-color: var(---color);
|
|
65
|
+
background-color: #ffffff;
|
|
66
|
+
}
|
|
67
|
+
.ste-step-icon.is-text {
|
|
68
|
+
border-radius: 50%;
|
|
69
|
+
border-style: solid;
|
|
70
|
+
border-width: 2rpx;
|
|
71
|
+
background-color: var(---bg-color);
|
|
72
|
+
}
|
|
73
|
+
.ste-step-icon {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
position: relative;
|
|
78
|
+
font-size: var(--font-size-24, 24rpx);
|
|
79
|
+
height: 40rpx;
|
|
80
|
+
line-height: 40rpx;
|
|
81
|
+
width: 40rpx;
|
|
82
|
+
}
|
|
83
|
+
.ste-step-icon-inner {
|
|
84
|
+
align-items: center;
|
|
85
|
+
display: flex;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
.ste-step-content {
|
|
90
|
+
display: inline-block;
|
|
91
|
+
text-align: center;
|
|
92
|
+
.ste-step-title {
|
|
93
|
+
font-size: var(--font-size-32, 32rpx);
|
|
94
|
+
color: var(---color);
|
|
95
|
+
line-height: 44rpx;
|
|
96
|
+
}
|
|
97
|
+
.ste-step-desc {
|
|
98
|
+
line-height: 44rpx;
|
|
99
|
+
font-size: var(--font-size-28, 28rpx);
|
|
100
|
+
color: var(---desc-color);
|
|
101
|
+
margin-top: 8rpx;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, nextTick, ref, watch, defineOptions } from 'vue';
|
|
3
|
+
import { useInject } from '../../utils/mixin';
|
|
4
|
+
import { type StepsProps, STEPS_KEY } from '../ste-steps/props';
|
|
5
|
+
import propsData from './props';
|
|
6
|
+
import type { Obj } from '../../types';
|
|
7
|
+
import useColor from '../../config/color';
|
|
8
|
+
let color = useColor();
|
|
9
|
+
|
|
10
|
+
const componentName = `ste-step`;
|
|
11
|
+
defineOptions({
|
|
12
|
+
name: componentName,
|
|
13
|
+
options: {
|
|
14
|
+
virtualHost: true,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const props = defineProps(propsData);
|
|
19
|
+
|
|
20
|
+
const Parent = useInject<{ props: Required<StepsProps>; onClickStep: (index: number) => void }>(STEPS_KEY);
|
|
21
|
+
const parent = Parent.parent;
|
|
22
|
+
const parentProps = Parent.parent?.props as StepsProps;
|
|
23
|
+
|
|
24
|
+
const childrenLen = ref(0);
|
|
25
|
+
const stepIndex = ref(0);
|
|
26
|
+
|
|
27
|
+
const cmpDirection = computed(() => parentProps.direction);
|
|
28
|
+
const cmpDot = computed(() => parentProps.dot);
|
|
29
|
+
|
|
30
|
+
watch(
|
|
31
|
+
() => parent?.internalChildren,
|
|
32
|
+
val => {
|
|
33
|
+
stepIndex.value = val?.length || 0;
|
|
34
|
+
nextTick(() => {
|
|
35
|
+
childrenLen.value = val?.length || 0;
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
immediate: true,
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const cmpStatusObj = computed(() => {
|
|
44
|
+
let obj = {} as Obj;
|
|
45
|
+
let status = '';
|
|
46
|
+
// status不是默认配置 优先级最高
|
|
47
|
+
if (props.status) {
|
|
48
|
+
status = props.status;
|
|
49
|
+
} else {
|
|
50
|
+
status = parentProps.active >= stepIndex.value ? 'finished' : 'process';
|
|
51
|
+
}
|
|
52
|
+
obj.textColor = parentProps.active + 1 >= stepIndex.value ? color.getColor().steThemeColor : '#cccccc';
|
|
53
|
+
if (status == 'finished') {
|
|
54
|
+
obj.color = color.getColor().steThemeColor;
|
|
55
|
+
obj.icon = '';
|
|
56
|
+
}
|
|
57
|
+
if (status == 'process') {
|
|
58
|
+
obj.color = obj.textColor;
|
|
59
|
+
obj.icon = '';
|
|
60
|
+
}
|
|
61
|
+
if (status == 'error') {
|
|
62
|
+
obj.color = color.getColor().steThemeColor;
|
|
63
|
+
obj.icon = '';
|
|
64
|
+
obj.textColor = color.getColor().steThemeColor;
|
|
65
|
+
}
|
|
66
|
+
obj.icon = props.icon ? props.icon : obj.icon;
|
|
67
|
+
obj.bgColor = parentProps.active + 1 == stepIndex.value ? color.getColor().steThemeColor : '#ffffff';
|
|
68
|
+
obj.numColor = parentProps.active + 1 >= stepIndex.value ? '#ffffff' : '#cccccc';
|
|
69
|
+
obj.descColor = parentProps.active + 1 >= stepIndex.value ? '#999999' : '#cccccc';
|
|
70
|
+
obj.lineColor = parentProps.active >= stepIndex.value ? color.getColor().steThemeColor : '#EEEEEE';
|
|
71
|
+
obj.dotColor = parentProps.active + 1 >= stepIndex.value ? color.getColor().steThemeColor : '#DDDDDD';
|
|
72
|
+
return obj;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const cmpRootStyle = computed(() => ({
|
|
76
|
+
'---color': cmpStatusObj.value.textColor,
|
|
77
|
+
'---bg-color': cmpStatusObj.value.bgColor,
|
|
78
|
+
'---num-color': cmpStatusObj.value.numColor,
|
|
79
|
+
'---desc-color': cmpStatusObj.value.descColor,
|
|
80
|
+
'---line-color': cmpStatusObj.value.lineColor,
|
|
81
|
+
'---dot-color': cmpStatusObj.value.dotColor,
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
function clickStep() {
|
|
85
|
+
parent?.onClickStep(stepIndex.value);
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<template>
|
|
90
|
+
<view class="ste-step" :class="[`ste-step-${cmpDirection}`]" :style="[cmpRootStyle]">
|
|
91
|
+
<view class="ste-step-head" :class="cmpDot ? 'head-is-dot' : ''">
|
|
92
|
+
<view class="ste-step-line" v-if="stepIndex < childrenLen"></view>
|
|
93
|
+
<view class="ste-step-icon" :class="[!cmpDot ? ($slots.icon || icon ? '' : cmpStatusObj.icon ? 'is-icon' : 'is-text') : 'is-dot']" @click="clickStep">
|
|
94
|
+
<template v-if="$slots.icon">
|
|
95
|
+
<slot name="icon"></slot>
|
|
96
|
+
</template>
|
|
97
|
+
<template v-else-if="cmpDot"></template>
|
|
98
|
+
<template v-else-if="cmpStatusObj.icon">
|
|
99
|
+
<ste-icon class="ste-step-icon-inner" :code="cmpStatusObj.icon" :size="icon ? 40 : 20" :color="cmpStatusObj.color"></ste-icon>
|
|
100
|
+
</template>
|
|
101
|
+
<template v-else>
|
|
102
|
+
<view class="ste-step-inner">{{ stepIndex }}</view>
|
|
103
|
+
</template>
|
|
104
|
+
</view>
|
|
105
|
+
</view>
|
|
106
|
+
<view class="ste-step-content" :class="[`ste-step-content-${parentProps.direction}`]">
|
|
107
|
+
<view class="ste-step-title" @click="clickStep">
|
|
108
|
+
<span v-if="!$slots.title">
|
|
109
|
+
{{ title ? title : `第${stepIndex}步` }}
|
|
110
|
+
</span>
|
|
111
|
+
<slot name="title"></slot>
|
|
112
|
+
</view>
|
|
113
|
+
<view class="ste-step-desc" v-if="description || $slots.description">
|
|
114
|
+
<span v-if="!$slots.description" v-html="description"></span>
|
|
115
|
+
<slot name="description"></slot>
|
|
116
|
+
</view>
|
|
117
|
+
</view>
|
|
118
|
+
</view>
|
|
119
|
+
</template>
|
|
120
|
+
<style lang="scss" scoped>
|
|
121
|
+
@import './ste-step.scss';
|
|
122
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#### Props
|
|
2
|
+
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
3
|
+
| ----- | ----- | --- | ------- | ------ | -------- |
|
|
4
|
+
| `v-model` | 当前输入的值 | `number` | `1` | - | - |
|
|
5
|
+
| `min` | 最小值 | `number` | `0` | - | - |
|
|
6
|
+
| `max` | 最大值 | `number` | `Infinity` | - | - |
|
|
7
|
+
| `step` | 步长,每次加或减的值 | `number` | `1` | - | - |
|
|
8
|
+
| `inputWidth` | 输入框宽度,默认单位为rpx | `number / string` | `64` | - | - |
|
|
9
|
+
| `btnSize` | 按钮大小以及输入框高度,默认单位为`rpx`,`theme`为`line`时 高为宽的80% | `number / string` | `48` | - | - |
|
|
10
|
+
| `precision` | 数值精度 | `number` | `0` | - | - |
|
|
11
|
+
| `theme` | 样式风格 | `string` | `card` | `card`:面型<br/>`line`:线型<br/>`add`:纯加购按钮 | - |
|
|
12
|
+
| `mainColor` | 主色,对`theme`为`line`时无效 | `string` | `#0090FF` | - | - |
|
|
13
|
+
| `disabled` | 是否禁用步进器 | `boolean` | `false` | - | - |
|
|
14
|
+
| `disablePlus` | 是否禁用增加按钮 | `boolean` | `false` | - | - |
|
|
15
|
+
| `disableMinus` | 是否禁用减少按钮 | `boolean` | `false` | - | - |
|
|
16
|
+
| `disableInput` | 是否禁用输入框 | `boolean` | `false` | - | - |
|
|
17
|
+
| `background` | 徽标:背景 | `string` | `#ee0a24` | - | - |
|
|
18
|
+
| `showDot` | 徽标:是否展示为小红点 | `boolean` | `false` | - | - |
|
|
19
|
+
| `offsetX` | 徽标:根据徽标位置,设置x轴偏移量 | `number / string` | `auto` | - | - |
|
|
20
|
+
| `offsetY` | 徽标:根据徽标位置,设置y轴偏移量 | `number / string` | `auto` | - | - |
|
|
21
|
+
| `showZero` | 徽标:当 content 为数字 0,是否展示徽标 | `boolean` | `false` | - | - |
|
|
22
|
+
| `position` | 徽标:徽标位置 | `string` | `topRight` | `topRight`:上右<br/>`topLeft`:上左<br/>`bottomLeft`:下左<br/>`bottomRight`:下右 | - |
|
|
23
|
+
| `badgeMax` | 徽标:徽标最大显示值 | `number` | `99` | - | - |
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
#### Events
|
|
27
|
+
| 事件名 | 说明 | 事件参数 | 支持版本 |
|
|
28
|
+
| ----- | ----- | ------- | -------- |
|
|
29
|
+
| `change` | 当绑定值变化时触发的事件 `value`: 改变后的绑定值 | - | - |
|
|
30
|
+
| `plus` | 点击增加按钮时触发(可拦截change事件) | `value`:改变后的绑定值<br/>`suspend`:等待<br/>`next`:继续<br/>`stop`:停止 | - |
|
|
31
|
+
| `minus` | 点击减少按钮时触发(可拦截change事件) | `value`:改变后的绑定值<br/>`suspend`:等待<br/>`next`:继续<br/>`stop`:停止 | - |
|
|
32
|
+
| `focus` | 输入框聚焦时触发 | - | - |
|
|
33
|
+
| `blur` | 输入框失焦时触发 | - | - |
|