@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,181 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
v-if="currentStatus"
|
|
4
|
+
:class="`wd-step wd-step--${currentStatus} ${customClass} ${canAlignCenter ? 'is-center' : ''} ${vertical ? 'is-vertical' : ''}`"
|
|
5
|
+
:style="rootStyle"
|
|
6
|
+
>
|
|
7
|
+
<view :class="`wd-step__header ${dot ? 'is-dot' : ''}`">
|
|
8
|
+
<view :class="`wd-step__indicator ${dot ? 'is-dot' : !!icon || $slots.icon ? 'is-icon' : 'is-text'}`">
|
|
9
|
+
<view v-if="dot" class="wd-step__dot"></view>
|
|
10
|
+
<slot v-else-if="$slots.icon || icon" name="icon">
|
|
11
|
+
<wd-icon v-if="icon" custom-class="wd-step__icon" :name="icon" />
|
|
12
|
+
</slot>
|
|
13
|
+
<view v-else class="wd-step__circle">
|
|
14
|
+
<wd-icon custom-class="wd-step__finished-icon" v-if="currentStatus === 'finished'" name="check" />
|
|
15
|
+
<wd-icon custom-class="wd-step__error-icon" v-else-if="currentStatus === 'error'" name="close" />
|
|
16
|
+
<text class="wd-step__circle-text" v-else>{{ index + 1 }}</text>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
<view v-if="index < childrenLength - 1" class="wd-step__line"></view>
|
|
20
|
+
</view>
|
|
21
|
+
<view class="wd-step__content" v-if="$slots.title || currentTitle || $slots.description || description">
|
|
22
|
+
<slot name="title" v-if="$slots.title || currentTitle">
|
|
23
|
+
<text class="wd-step__title">{{ currentTitle }}</text>
|
|
24
|
+
</slot>
|
|
25
|
+
<slot name="description" v-if="$slots.description || description">
|
|
26
|
+
<text class="wd-step__description">{{ description }}</text>
|
|
27
|
+
</slot>
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
30
|
+
</template>
|
|
31
|
+
<script lang="ts">
|
|
32
|
+
export default {
|
|
33
|
+
name: 'wd-step',
|
|
34
|
+
options: {
|
|
35
|
+
addGlobalClass: true,
|
|
36
|
+
// #ifndef MP-TOUTIAO
|
|
37
|
+
virtualHost: true,
|
|
38
|
+
// #endif
|
|
39
|
+
styleIsolation: 'shared'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
<script lang="ts" setup>
|
|
44
|
+
import wdIcon from '../wd-icon/wd-icon.vue'
|
|
45
|
+
import { computed } from 'vue'
|
|
46
|
+
import { useParent } from '../../composables/useParent'
|
|
47
|
+
import { STEPS_KEY } from '../wd-steps/types'
|
|
48
|
+
import { isDef, objToStyle } from '../../common/util'
|
|
49
|
+
import { useTranslate } from '../../composables/useTranslate'
|
|
50
|
+
import { stepProps, type StepStatus } from './types'
|
|
51
|
+
import type { CSSProperties } from 'vue'
|
|
52
|
+
|
|
53
|
+
const props = defineProps(stepProps)
|
|
54
|
+
|
|
55
|
+
const { parent: steps, index } = useParent(STEPS_KEY)
|
|
56
|
+
|
|
57
|
+
const { translate } = useTranslate('steps')
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 获取当前步骤的状态
|
|
61
|
+
*/
|
|
62
|
+
const currentStatus = computed<StepStatus | ''>(() => {
|
|
63
|
+
return getCurrentStatus(index.value)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 获取当前步骤的标题
|
|
68
|
+
*/
|
|
69
|
+
const currentTitle = computed<string>(() => {
|
|
70
|
+
return getCurrentTitle(currentStatus.value)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 根节点样式
|
|
75
|
+
*/
|
|
76
|
+
const rootStyle = computed<string>(() => {
|
|
77
|
+
const style: CSSProperties = {}
|
|
78
|
+
if (steps.value) {
|
|
79
|
+
const { vertical, space } = steps.value.props
|
|
80
|
+
if (vertical) {
|
|
81
|
+
if (space && space !== '') {
|
|
82
|
+
style['height'] = space
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
style['width'] = space && space !== '' ? space : 100 / steps.value.children.length + '%'
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return `${objToStyle(style)}${props.customStyle}`
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 是否居中对齐
|
|
93
|
+
*/
|
|
94
|
+
const canAlignCenter = computed<boolean>(() => {
|
|
95
|
+
if (isDef(steps.value)) {
|
|
96
|
+
const { vertical, alignCenter } = steps.value.props
|
|
97
|
+
return Boolean(!vertical && alignCenter)
|
|
98
|
+
} else {
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 是否垂直布局
|
|
105
|
+
*/
|
|
106
|
+
const vertical = computed<boolean>(() => {
|
|
107
|
+
if (isDef(steps.value)) {
|
|
108
|
+
return Boolean(steps.value.props.vertical)
|
|
109
|
+
} else {
|
|
110
|
+
return false
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 是否使用点状指示器
|
|
116
|
+
*/
|
|
117
|
+
const dot = computed<boolean>(() => {
|
|
118
|
+
if (isDef(steps.value)) {
|
|
119
|
+
return Boolean(steps.value.props.dot)
|
|
120
|
+
} else {
|
|
121
|
+
return false
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 步骤总数量
|
|
127
|
+
*/
|
|
128
|
+
const childrenLength = computed<number>(() => {
|
|
129
|
+
if (isDef(steps.value)) {
|
|
130
|
+
return Number(steps.value.children.length)
|
|
131
|
+
} else {
|
|
132
|
+
return 0
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 获取状态
|
|
138
|
+
* @param index 索引
|
|
139
|
+
*/
|
|
140
|
+
function getCurrentStatus(index: number): StepStatus | '' {
|
|
141
|
+
if (props.status) {
|
|
142
|
+
return props.status
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (steps.value) {
|
|
146
|
+
const { active } = steps.value.props
|
|
147
|
+
if (Number(active) > index) {
|
|
148
|
+
return 'finished'
|
|
149
|
+
} else if (Number(active) === index) {
|
|
150
|
+
return 'process'
|
|
151
|
+
} else {
|
|
152
|
+
return 'wait'
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
return 'wait' // 默认如果不在Steps中,直接渲染等待
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 获取默认标题
|
|
161
|
+
* @param currentStatus 当前状态
|
|
162
|
+
*/
|
|
163
|
+
function getCurrentTitle(currentStatus: string): string {
|
|
164
|
+
if (props.title) return props.title
|
|
165
|
+
|
|
166
|
+
switch (currentStatus) {
|
|
167
|
+
case 'finished':
|
|
168
|
+
return translate('finished')
|
|
169
|
+
case 'error':
|
|
170
|
+
return translate('failed')
|
|
171
|
+
case 'process':
|
|
172
|
+
return translate('process')
|
|
173
|
+
case 'wait':
|
|
174
|
+
default:
|
|
175
|
+
return translate('wait')
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
</script>
|
|
179
|
+
<style lang="scss">
|
|
180
|
+
@use './index.scss';
|
|
181
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type ExtractPropTypes, type InjectionKey } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeNumberProp, makeStringProp } from '../../common/props'
|
|
3
|
+
|
|
4
|
+
export const stepsProps = {
|
|
5
|
+
...baseProps,
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 当前激活的步骤进度,以数字表示。
|
|
9
|
+
* 类型: number
|
|
10
|
+
* 默认值: 0
|
|
11
|
+
*/
|
|
12
|
+
active: makeNumberProp(0),
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 是否为垂直方向的步骤条。
|
|
16
|
+
* 类型: boolean
|
|
17
|
+
* 默认值: false
|
|
18
|
+
*/
|
|
19
|
+
vertical: makeBooleanProp(false),
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 是否为点状步骤条样式。
|
|
23
|
+
* 类型: boolean
|
|
24
|
+
* 默认值: false
|
|
25
|
+
*/
|
|
26
|
+
dot: makeBooleanProp(false),
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 步骤条之间的间距,默认为自动计算。
|
|
30
|
+
* 如果指定,则使用此值作为间距。
|
|
31
|
+
* 类型: string
|
|
32
|
+
* 默认值: ''
|
|
33
|
+
*/
|
|
34
|
+
space: makeStringProp(''),
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 是否将步骤条水平居中显示,只对横向步骤条有效。
|
|
38
|
+
* 类型: boolean
|
|
39
|
+
* 默认值: false
|
|
40
|
+
*/
|
|
41
|
+
alignCenter: makeBooleanProp(false)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type StepsProps = ExtractPropTypes<typeof stepsProps>
|
|
45
|
+
|
|
46
|
+
export type StepsProvide = {
|
|
47
|
+
props: Partial<StepsProps>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const STEPS_KEY: InjectionKey<StepsProvide> = Symbol('wd-steps')
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2026-01-09 16:05:24
|
|
4
|
+
* @LastEditTime: 2026-02-26 14:41:35
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: /wot-ui/src/uni_modules/wot-ui/components/wd-steps/wd-steps.vue
|
|
8
|
+
* 记得注释
|
|
9
|
+
-->
|
|
10
|
+
<template>
|
|
11
|
+
<view :class="`wd-steps ${customClass} ${vertical ? 'is-vertical' : ''}`" :style="customStyle">
|
|
12
|
+
<slot />
|
|
13
|
+
</view>
|
|
14
|
+
</template>
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
export default {
|
|
17
|
+
name: 'wd-steps',
|
|
18
|
+
options: {
|
|
19
|
+
addGlobalClass: true,
|
|
20
|
+
// #ifndef MP-TOUTIAO
|
|
21
|
+
virtualHost: true,
|
|
22
|
+
// #endif
|
|
23
|
+
styleIsolation: 'shared'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
<script lang="ts" setup>
|
|
28
|
+
import { useChildren } from '../../composables/useChildren'
|
|
29
|
+
import { STEPS_KEY, stepsProps } from './types'
|
|
30
|
+
|
|
31
|
+
const props = defineProps(stepsProps)
|
|
32
|
+
|
|
33
|
+
const { linkChildren } = useChildren(STEPS_KEY)
|
|
34
|
+
|
|
35
|
+
linkChildren({ props })
|
|
36
|
+
</script>
|
|
37
|
+
<style lang="scss">
|
|
38
|
+
@use './index.scss';
|
|
39
|
+
</style>
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :style="`${rootStyle};display: inline-block;`">
|
|
3
|
+
<view :class="`wd-sticky ${customClass}`" :style="stickyStyle" :id="styckyId">
|
|
4
|
+
<view class="wd-sticky__container" :style="containerStyle">
|
|
5
|
+
<wd-resize @resize="handleResize" custom-style="display: inline-block;">
|
|
6
|
+
<slot />
|
|
7
|
+
</wd-resize>
|
|
8
|
+
</view>
|
|
9
|
+
</view>
|
|
10
|
+
</view>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
export default {
|
|
15
|
+
name: 'wd-sticky',
|
|
16
|
+
options: {
|
|
17
|
+
addGlobalClass: true,
|
|
18
|
+
// #ifndef MP-TOUTIAO
|
|
19
|
+
virtualHost: true,
|
|
20
|
+
// #endif
|
|
21
|
+
styleIsolation: 'shared'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script lang="ts" setup>
|
|
27
|
+
import wdResize from '../wd-resize/wd-resize.vue'
|
|
28
|
+
import { computed, getCurrentInstance, reactive, ref, type CSSProperties } from 'vue'
|
|
29
|
+
import { addUnit, getRect, objToStyle, pause, uuid } from '../../common/util'
|
|
30
|
+
import { stickyProps } from './types'
|
|
31
|
+
import { useParent } from '../../composables/useParent'
|
|
32
|
+
import { STICKY_BOX_KEY } from '../wd-sticky-box/types'
|
|
33
|
+
|
|
34
|
+
const props = defineProps(stickyProps)
|
|
35
|
+
const styckyId = ref<string>(`wd-sticky${uuid()}`)
|
|
36
|
+
const observerList = ref<UniApp.IntersectionObserver[]>([])
|
|
37
|
+
|
|
38
|
+
const stickyState = reactive({
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
boxLeaved: false,
|
|
41
|
+
top: 0,
|
|
42
|
+
height: 0,
|
|
43
|
+
width: 0,
|
|
44
|
+
state: ''
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const { parent: stickyBox } = useParent(STICKY_BOX_KEY)
|
|
48
|
+
|
|
49
|
+
const { proxy } = getCurrentInstance() as any
|
|
50
|
+
|
|
51
|
+
const rootStyle = computed(() => {
|
|
52
|
+
const style: CSSProperties = {
|
|
53
|
+
'z-index': props.zIndex,
|
|
54
|
+
height: addUnit(stickyState.height),
|
|
55
|
+
width: addUnit(stickyState.width)
|
|
56
|
+
}
|
|
57
|
+
if (!stickyState.boxLeaved) {
|
|
58
|
+
style['position'] = 'relative'
|
|
59
|
+
}
|
|
60
|
+
return `${objToStyle(style)}${props.customStyle}`
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const stickyStyle = computed(() => {
|
|
64
|
+
const style: CSSProperties = {
|
|
65
|
+
'z-index': props.zIndex,
|
|
66
|
+
height: addUnit(stickyState.height),
|
|
67
|
+
width: addUnit(stickyState.width)
|
|
68
|
+
}
|
|
69
|
+
if (!stickyState.boxLeaved) {
|
|
70
|
+
style['position'] = 'relative'
|
|
71
|
+
}
|
|
72
|
+
return `${objToStyle(style)}`
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const containerStyle = computed(() => {
|
|
76
|
+
const style: CSSProperties = {
|
|
77
|
+
position: stickyState.position as 'static' | 'relative' | 'absolute' | 'sticky' | 'fixed',
|
|
78
|
+
top: addUnit(stickyState.top)
|
|
79
|
+
}
|
|
80
|
+
return objToStyle(style)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const innerOffsetTop = computed(() => {
|
|
84
|
+
let top: number = 0
|
|
85
|
+
// #ifdef H5
|
|
86
|
+
// H5端,导航栏为普通元素,需要将组件移动到导航栏的下边沿
|
|
87
|
+
// H5的导航栏高度为44px
|
|
88
|
+
top = 44
|
|
89
|
+
// #endif
|
|
90
|
+
|
|
91
|
+
return top + props.offsetTop
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 清除对当前组件的监听
|
|
96
|
+
*/
|
|
97
|
+
function clearObserver() {
|
|
98
|
+
while (observerList.value.length !== 0) {
|
|
99
|
+
observerList.value.pop()!.disconnect()
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 添加对当前组件的监听
|
|
104
|
+
*/
|
|
105
|
+
function createObserver() {
|
|
106
|
+
const observer = uni.createIntersectionObserver(proxy, { thresholds: [0, 0.5] })
|
|
107
|
+
observerList.value.push(observer)
|
|
108
|
+
return observer
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 当前内容高度发生变化时重置监听
|
|
112
|
+
*/
|
|
113
|
+
async function handleResize(detail: any) {
|
|
114
|
+
stickyState.width = detail.width
|
|
115
|
+
stickyState.height = detail.height
|
|
116
|
+
await pause()
|
|
117
|
+
observerContentScroll()
|
|
118
|
+
if (!stickyBox.value || !stickyBox.value.observerForChild) return
|
|
119
|
+
stickyBox.value.observerForChild(proxy)
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 监听吸顶元素滚动事件
|
|
123
|
+
*/
|
|
124
|
+
function observerContentScroll() {
|
|
125
|
+
if (stickyState.height === 0 && stickyState.width === 0) return
|
|
126
|
+
const offset = innerOffsetTop.value + stickyState.height
|
|
127
|
+
clearObserver()
|
|
128
|
+
createObserver()
|
|
129
|
+
.relativeToViewport({
|
|
130
|
+
top: -offset
|
|
131
|
+
})
|
|
132
|
+
.observe(`#${styckyId.value}`, (result) => {
|
|
133
|
+
handleRelativeTo(result)
|
|
134
|
+
})
|
|
135
|
+
getRect(`#${styckyId.value}`, false, proxy).then((res) => {
|
|
136
|
+
// #ifdef H5
|
|
137
|
+
// H5端,查询节点信息未计算导航栏高度
|
|
138
|
+
res.bottom = Number(res.bottom) + 44
|
|
139
|
+
// #endif
|
|
140
|
+
if (Number(res.bottom) <= offset) handleRelativeTo({ boundingClientRect: res })
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* @description 根据位置进行吸顶
|
|
145
|
+
*/
|
|
146
|
+
function handleRelativeTo({ boundingClientRect }: any) {
|
|
147
|
+
// sticky 高度大于或等于 wd-sticky-box,使用 wd-sticky-box 无任何意义
|
|
148
|
+
if (stickyBox.value && stickyBox.value.boxStyle && stickyState.height >= stickyBox.value.boxStyle.height) {
|
|
149
|
+
stickyState.position = 'absolute'
|
|
150
|
+
stickyState.top = 0
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let isStycky = boundingClientRect.top <= innerOffsetTop.value
|
|
155
|
+
// #ifdef H5 || APP-PLUS
|
|
156
|
+
isStycky = boundingClientRect.top < innerOffsetTop.value
|
|
157
|
+
// #endif
|
|
158
|
+
|
|
159
|
+
if (isStycky) {
|
|
160
|
+
stickyState.state = 'sticky'
|
|
161
|
+
stickyState.boxLeaved = false
|
|
162
|
+
stickyState.position = 'fixed'
|
|
163
|
+
stickyState.top = innerOffsetTop.value
|
|
164
|
+
} else {
|
|
165
|
+
stickyState.state = 'normal'
|
|
166
|
+
stickyState.boxLeaved = false
|
|
167
|
+
stickyState.position = 'absolute'
|
|
168
|
+
stickyState.top = 0
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 设置位置
|
|
174
|
+
* @param setboxLeaved
|
|
175
|
+
* @param setPosition
|
|
176
|
+
* @param setTop
|
|
177
|
+
*/
|
|
178
|
+
function setPosition(boxLeaved: boolean, position: string, top: number) {
|
|
179
|
+
stickyState.boxLeaved = boxLeaved
|
|
180
|
+
stickyState.position = position
|
|
181
|
+
stickyState.top = top
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
defineExpose({
|
|
185
|
+
setPosition,
|
|
186
|
+
stickyState,
|
|
187
|
+
offsetTop: props.offsetTop
|
|
188
|
+
})
|
|
189
|
+
</script>
|
|
190
|
+
<style lang="scss">
|
|
191
|
+
@use './index.scss';
|
|
192
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2024-04-08 22:34:01
|
|
4
|
+
* @LastEditTime: 2024-06-01 16:04:56
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: /wot-ui/src/uni_modules/wot-ui/components/wd-sticky-box/types.ts
|
|
8
|
+
* 记得注释
|
|
9
|
+
*/
|
|
10
|
+
import type { ComponentInternalInstance, InjectionKey } from 'vue'
|
|
11
|
+
|
|
12
|
+
export type stickyBoxProvide = {
|
|
13
|
+
boxStyle: {
|
|
14
|
+
height: number // 高度
|
|
15
|
+
width: number // 宽度
|
|
16
|
+
}
|
|
17
|
+
observerForChild: (child: ComponentInternalInstance) => void // 监听子组件
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const STICKY_BOX_KEY: InjectionKey<stickyBoxProvide> = Symbol('wd-sticky-box')
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view style="position: relative">
|
|
3
|
+
<view :class="`wd-sticky-box ${props.customClass}`" :style="customStyle" :id="styckyBoxId">
|
|
4
|
+
<wd-resize @resize="handleResize">
|
|
5
|
+
<slot />
|
|
6
|
+
</wd-resize>
|
|
7
|
+
</view>
|
|
8
|
+
</view>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
export default {
|
|
13
|
+
name: 'wd-sticky-box',
|
|
14
|
+
options: {
|
|
15
|
+
addGlobalClass: true,
|
|
16
|
+
// #ifndef MP-TOUTIAO
|
|
17
|
+
// virtualHost: true,
|
|
18
|
+
// #endif
|
|
19
|
+
styleIsolation: 'shared'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script lang="ts" setup>
|
|
25
|
+
import wdResize from '../wd-resize/wd-resize.vue'
|
|
26
|
+
import { getCurrentInstance, onBeforeMount, reactive, ref } from 'vue'
|
|
27
|
+
import { getRect, uuid } from '../../common/util'
|
|
28
|
+
import { baseProps } from '../../common/props'
|
|
29
|
+
import { STICKY_BOX_KEY } from './types'
|
|
30
|
+
import { useChildren } from '../../composables/useChildren'
|
|
31
|
+
|
|
32
|
+
const props = defineProps(baseProps)
|
|
33
|
+
|
|
34
|
+
const styckyBoxId = ref<string>(`wd-sticky-box${uuid()}`)
|
|
35
|
+
|
|
36
|
+
const observerMap = ref<Map<any, any>>(new Map())
|
|
37
|
+
|
|
38
|
+
const boxStyle = reactive({
|
|
39
|
+
height: 0,
|
|
40
|
+
width: 0
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const { proxy } = getCurrentInstance() as any
|
|
44
|
+
|
|
45
|
+
const { children: stickyList, linkChildren } = useChildren(STICKY_BOX_KEY)
|
|
46
|
+
linkChildren({
|
|
47
|
+
boxStyle: boxStyle,
|
|
48
|
+
observerForChild
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
onBeforeMount(() => {
|
|
52
|
+
observerMap.value = new Map()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 容器大小变化后重新监听sticky组件与box组件的交叉状态
|
|
57
|
+
* @param detail
|
|
58
|
+
*/
|
|
59
|
+
function handleResize(detail: any) {
|
|
60
|
+
// 相对的容器大小改变后,同步设置 wd-sticky-box 的大小
|
|
61
|
+
boxStyle.width = detail.width
|
|
62
|
+
boxStyle.height = detail.height
|
|
63
|
+
// wd-sticky-box 大小变化时,重新监听所有吸顶元素
|
|
64
|
+
const temp = observerMap.value
|
|
65
|
+
observerMap.value = new Map()
|
|
66
|
+
for (const [uid] of temp) {
|
|
67
|
+
const child = stickyList.find((sticky) => {
|
|
68
|
+
return sticky.$.uid === uid
|
|
69
|
+
})
|
|
70
|
+
observerForChild(child)
|
|
71
|
+
}
|
|
72
|
+
temp.forEach((observer) => {
|
|
73
|
+
observer.disconnect()
|
|
74
|
+
})
|
|
75
|
+
temp.clear()
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 删除对指定sticky的监听
|
|
79
|
+
* @param child 指定的子组件
|
|
80
|
+
*/
|
|
81
|
+
function deleteObserver(child: any) {
|
|
82
|
+
const observer = observerMap.value.get(child.$.uid)
|
|
83
|
+
if (!observer) return
|
|
84
|
+
observer.disconnect()
|
|
85
|
+
observerMap.value.delete(child.$.uid)
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 针对指定sticky添加监听
|
|
89
|
+
* @param child 指定的子组件
|
|
90
|
+
*/
|
|
91
|
+
function createObserver(child: any) {
|
|
92
|
+
const observer = uni.createIntersectionObserver(proxy, { thresholds: [0, 0.5] })
|
|
93
|
+
observerMap.value.set(child.$.uid, observer)
|
|
94
|
+
return observer
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 监听子组件
|
|
98
|
+
* @param child 子组件
|
|
99
|
+
*/
|
|
100
|
+
function observerForChild(child: any) {
|
|
101
|
+
deleteObserver(child)
|
|
102
|
+
const observer = createObserver(child)
|
|
103
|
+
const exposed = child.$.exposed
|
|
104
|
+
let offset = exposed.stickyState.height + exposed.offsetTop
|
|
105
|
+
// #ifdef H5
|
|
106
|
+
// H5端,导航栏为普通元素,需要将组件移动到导航栏的下边沿
|
|
107
|
+
// H5的导航栏高度为44px
|
|
108
|
+
offset = offset + 44
|
|
109
|
+
// #endif
|
|
110
|
+
|
|
111
|
+
if (boxStyle.height <= exposed.stickyState.height) {
|
|
112
|
+
exposed.setPosition(false, 'absolute', 0)
|
|
113
|
+
}
|
|
114
|
+
observer.relativeToViewport({ top: -offset }).observe(`#${styckyBoxId.value}`, (result) => {
|
|
115
|
+
handleRelativeTo(exposed, result)
|
|
116
|
+
})
|
|
117
|
+
// 当子组件默认处于边界外且永远不会进入边界内时,需要手动调用一次
|
|
118
|
+
getRect(`#${styckyBoxId.value}`, false, proxy)
|
|
119
|
+
.then((res) => {
|
|
120
|
+
// #ifdef H5
|
|
121
|
+
// H5端,查询节点信息未计算导航栏高度
|
|
122
|
+
res.bottom = Number(res.bottom) + 44
|
|
123
|
+
// #endif
|
|
124
|
+
if (Number(res.bottom) <= offset) handleRelativeTo(exposed, { boundingClientRect: res })
|
|
125
|
+
})
|
|
126
|
+
.catch((res) => {
|
|
127
|
+
console.log(res)
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 监听容器组件
|
|
132
|
+
* @param {Object} exposed wd-sticky实例暴露出的事件
|
|
133
|
+
* @param {Object} boundingClientRect 边界信息
|
|
134
|
+
*/
|
|
135
|
+
function handleRelativeTo(exposed: any, { boundingClientRect }: any) {
|
|
136
|
+
let childOffsetTop = exposed.offsetTop
|
|
137
|
+
// #ifdef H5
|
|
138
|
+
// H5端,导航栏为普通元素,需要将组件移动到导航栏的下边沿
|
|
139
|
+
// H5的导航栏高度为44px
|
|
140
|
+
childOffsetTop = childOffsetTop + 44
|
|
141
|
+
// #endif
|
|
142
|
+
const offset = exposed.stickyState.height + childOffsetTop
|
|
143
|
+
let isAbsolute = boundingClientRect.bottom <= offset
|
|
144
|
+
// #ifdef H5 || APP-PLUS
|
|
145
|
+
isAbsolute = boundingClientRect.bottom < offset
|
|
146
|
+
// #endif
|
|
147
|
+
if (isAbsolute) {
|
|
148
|
+
exposed.setPosition(true, 'absolute', boundingClientRect.height - exposed.stickyState.height)
|
|
149
|
+
} else if (boundingClientRect.top <= offset && !isAbsolute) {
|
|
150
|
+
if (exposed.stickyState.state === 'normal') return
|
|
151
|
+
exposed.setPosition(false, 'fixed', childOffsetTop)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
<style lang="scss">
|
|
156
|
+
@use './index.scss';
|
|
157
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@use '../../styles/mixin/mixin.scss' as *;
|
|
2
|
+
@use '../../styles/variable.scss' as *;
|
|
3
|
+
|
|
4
|
+
@include b(swipe-action) {
|
|
5
|
+
position: relative;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
@include e(left) {
|
|
8
|
+
left: 0;
|
|
9
|
+
transform: translate3d(-100%, 0, 0);
|
|
10
|
+
}
|
|
11
|
+
@include e(right) {
|
|
12
|
+
right: 0;
|
|
13
|
+
transform: translate3d(100%, 0, 0);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.wd-swipe-action__left,
|
|
18
|
+
.wd-swipe-action__right {
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: 0;
|
|
21
|
+
height: 100%;
|
|
22
|
+
}
|