@tplc/wot 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/common/AbortablePromise.ts +36 -0
- package/components/common/abstracts/_config.scss +7 -0
- package/components/common/abstracts/_function.scss +76 -0
- package/components/common/abstracts/_mixin.scss +339 -0
- package/components/common/abstracts/variable.scss +1346 -0
- package/components/common/base64.ts +30 -0
- package/components/common/canvasHelper.ts +49 -0
- package/components/common/clickoutside.ts +34 -0
- package/components/common/dayjs.ts +157 -0
- package/components/common/event.ts +8 -0
- package/components/common/props.ts +51 -0
- package/components/common/util.ts +751 -0
- package/components/composables/useCell.ts +13 -0
- package/components/composables/useChildren.ts +122 -0
- package/components/composables/useCountDown.ts +138 -0
- package/components/composables/useLockScroll.ts +39 -0
- package/components/composables/useParent.ts +41 -0
- package/components/composables/usePopover.ts +193 -0
- package/components/composables/useQueue.ts +52 -0
- package/components/composables/useRaf.ts +37 -0
- package/components/composables/useTouch.ts +44 -0
- package/components/composables/useTranslate.ts +22 -0
- package/components/wd-action-sheet/index.scss +204 -0
- package/components/wd-action-sheet/types.ts +128 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +174 -0
- package/components/wd-backtop/index.scss +25 -0
- package/components/wd-backtop/types.ts +37 -0
- package/components/wd-backtop/wd-backtop.vue +48 -0
- package/components/wd-badge/index.scss +59 -0
- package/components/wd-badge/types.ts +53 -0
- package/components/wd-badge/wd-badge.vue +69 -0
- package/components/wd-button/index.scss +340 -0
- package/components/wd-button/types.ts +112 -0
- package/components/wd-button/wd-button.vue +176 -0
- package/components/wd-calendar/index.scss +244 -0
- package/components/wd-calendar/types.ts +235 -0
- package/components/wd-calendar/wd-calendar.vue +456 -0
- package/components/wd-calendar-view/index.scss +9 -0
- package/components/wd-calendar-view/month/index.scss +151 -0
- package/components/wd-calendar-view/month/month.vue +391 -0
- package/components/wd-calendar-view/month/types.ts +19 -0
- package/components/wd-calendar-view/monthPanel/index.scss +89 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +388 -0
- package/components/wd-calendar-view/monthPanel/types.ts +48 -0
- package/components/wd-calendar-view/types.ts +134 -0
- package/components/wd-calendar-view/utils.ts +451 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +111 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +19 -0
- package/components/wd-calendar-view/year/year.vue +220 -0
- package/components/wd-calendar-view/yearPanel/index.scss +24 -0
- package/components/wd-calendar-view/yearPanel/types.ts +38 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +140 -0
- package/components/wd-card/index.scss +70 -0
- package/components/wd-card/types.ts +30 -0
- package/components/wd-card/wd-card.vue +40 -0
- package/components/wd-cell/index.scss +189 -0
- package/components/wd-cell/types.ts +96 -0
- package/components/wd-cell/wd-cell.vue +135 -0
- package/components/wd-cell-group/index.scss +55 -0
- package/components/wd-cell-group/types.ts +41 -0
- package/components/wd-cell-group/wd-cell-group.vue +45 -0
- package/components/wd-checkbox/index.scss +285 -0
- package/components/wd-checkbox/types.ts +68 -0
- package/components/wd-checkbox/wd-checkbox.vue +185 -0
- package/components/wd-checkbox-group/index.scss +20 -0
- package/components/wd-checkbox-group/types.ts +59 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +103 -0
- package/components/wd-circle/index.scss +18 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +318 -0
- package/components/wd-col/index.scss +19 -0
- package/components/wd-col/types.ts +15 -0
- package/components/wd-col/wd-col.vue +91 -0
- package/components/wd-col-picker/index.scss +241 -0
- package/components/wd-col-picker/types.ts +170 -0
- package/components/wd-col-picker/wd-col-picker.vue +550 -0
- package/components/wd-collapse/index.scss +55 -0
- package/components/wd-collapse/types.ts +63 -0
- package/components/wd-collapse/wd-collapse.vue +160 -0
- package/components/wd-collapse-item/index.scss +79 -0
- package/components/wd-collapse-item/types.ts +36 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +182 -0
- package/components/wd-config-provider/types.ts +1023 -0
- package/components/wd-config-provider/wd-config-provider.vue +82 -0
- package/components/wd-count-down/index.scss +14 -0
- package/components/wd-count-down/types.ts +41 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +60 -0
- package/components/wd-count-to/index.scss +6 -0
- package/components/wd-count-to/types.ts +110 -0
- package/components/wd-count-to/wd-count-to.vue +134 -0
- package/components/wd-curtain/index.scss +80 -0
- package/components/wd-curtain/types.ts +45 -0
- package/components/wd-curtain/wd-curtain.vue +174 -0
- package/components/wd-datetime-picker/index.scss +243 -0
- package/components/wd-datetime-picker/types.ts +225 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +827 -0
- package/components/wd-datetime-picker-view/index.scss +0 -0
- package/components/wd-datetime-picker-view/types.ts +137 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +514 -0
- package/components/wd-divider/index.scss +32 -0
- package/components/wd-divider/types.ts +12 -0
- package/components/wd-divider/wd-divider.vue +29 -0
- package/components/wd-drop-menu/index.scss +89 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +128 -0
- package/components/wd-drop-menu-item/index.scss +66 -0
- package/components/wd-drop-menu-item/types.ts +78 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +230 -0
- package/components/wd-fab/index.scss +115 -0
- package/components/wd-fab/types.ts +61 -0
- package/components/wd-fab/wd-fab.vue +257 -0
- package/components/wd-form/index.scss +10 -0
- package/components/wd-form/types.ts +93 -0
- package/components/wd-form/wd-form.vue +185 -0
- package/components/wd-form-item/index.scss +17 -0
- package/components/wd-form-item/types.ts +22 -0
- package/components/wd-form-item/wd-form-item.vue +65 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +23 -0
- package/components/wd-gap/wd-gap.vue +39 -0
- package/components/wd-grid/index.scss +9 -0
- package/components/wd-grid/types.ts +54 -0
- package/components/wd-grid/wd-grid.vue +107 -0
- package/components/wd-grid-item/index.scss +137 -0
- package/components/wd-grid-item/types.ts +74 -0
- package/components/wd-grid-item/wd-grid-item.vue +181 -0
- package/components/wd-icon/index.scss +1222 -0
- package/components/wd-icon/types.ts +21 -0
- package/components/wd-icon/wd-icon.vue +53 -0
- package/components/wd-icon/wd-icons.ttf +0 -0
- package/components/wd-img/index.scss +19 -0
- package/components/wd-img/types.ts +53 -0
- package/components/wd-img/wd-img.vue +76 -0
- package/components/wd-img-cropper/index.scss +227 -0
- package/components/wd-img-cropper/types.ts +87 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +659 -0
- package/components/wd-index-anchor/index.scss +34 -0
- package/components/wd-index-anchor/type.ts +9 -0
- package/components/wd-index-anchor/wd-index-anchor.vue +57 -0
- package/components/wd-index-bar/index.scss +39 -0
- package/components/wd-index-bar/type.ts +28 -0
- package/components/wd-index-bar/wd-index-bar.vue +158 -0
- package/components/wd-input/index.scss +326 -0
- package/components/wd-input/types.ts +182 -0
- package/components/wd-input/wd-input.vue +327 -0
- package/components/wd-input-number/index.scss +132 -0
- package/components/wd-input-number/types.ts +78 -0
- package/components/wd-input-number/wd-input-number.vue +221 -0
- package/components/wd-loading/index.scss +34 -0
- package/components/wd-loading/types.ts +31 -0
- package/components/wd-loading/wd-loading.vue +90 -0
- package/components/wd-loadmore/index.scss +39 -0
- package/components/wd-loadmore/types.ts +24 -0
- package/components/wd-loadmore/wd-loadmore.vue +53 -0
- package/components/wd-message-box/index.scss +121 -0
- package/components/wd-message-box/index.ts +95 -0
- package/components/wd-message-box/types.ts +116 -0
- package/components/wd-message-box/wd-message-box.vue +326 -0
- package/components/wd-navbar/index.scss +103 -0
- package/components/wd-navbar/types.ts +52 -0
- package/components/wd-navbar/wd-navbar.vue +142 -0
- package/components/wd-navbar-capsule/index.scss +65 -0
- package/components/wd-navbar-capsule/types.ts +0 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +31 -0
- package/components/wd-notice-bar/index.scss +86 -0
- package/components/wd-notice-bar/types.ts +56 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +223 -0
- package/components/wd-notify/index.scss +34 -0
- package/components/wd-notify/index.ts +59 -0
- package/components/wd-notify/types.ts +62 -0
- package/components/wd-notify/wd-notify.vue +83 -0
- package/components/wd-number-keyboard/index.scss +78 -0
- package/components/wd-number-keyboard/key/index.scss +79 -0
- package/components/wd-number-keyboard/key/index.vue +76 -0
- package/components/wd-number-keyboard/key/types.ts +11 -0
- package/components/wd-number-keyboard/types.ts +79 -0
- package/components/wd-number-keyboard/wd-number-keyboard.vue +173 -0
- package/components/wd-overlay/index.scss +17 -0
- package/components/wd-overlay/types.ts +25 -0
- package/components/wd-overlay/wd-overlay.vue +46 -0
- package/components/wd-pagination/index.scss +57 -0
- package/components/wd-pagination/types.ts +41 -0
- package/components/wd-pagination/wd-pagination.vue +121 -0
- package/components/wd-password-input/index.scss +123 -0
- package/components/wd-password-input/types.ts +48 -0
- package/components/wd-password-input/wd-password-input.vue +58 -0
- package/components/wd-picker/index.scss +216 -0
- package/components/wd-picker/types.ts +186 -0
- package/components/wd-picker/wd-picker.vue +409 -0
- package/components/wd-picker-view/index.scss +91 -0
- package/components/wd-picker-view/types.ts +162 -0
- package/components/wd-picker-view/wd-picker-view.vue +361 -0
- package/components/wd-popover/index.scss +123 -0
- package/components/wd-popover/types.ts +69 -0
- package/components/wd-popover/wd-popover.vue +216 -0
- package/components/wd-popup/index.scss +112 -0
- package/components/wd-popup/types.ts +68 -0
- package/components/wd-popup/wd-popup.vue +227 -0
- package/components/wd-progress/index.scss +62 -0
- package/components/wd-progress/types.ts +40 -0
- package/components/wd-progress/wd-progress.vue +201 -0
- package/components/wd-radio/index.scss +300 -0
- package/components/wd-radio/types.ts +42 -0
- package/components/wd-radio/wd-radio.vue +136 -0
- package/components/wd-radio-group/index.scss +23 -0
- package/components/wd-radio-group/types.ts +36 -0
- package/components/wd-radio-group/wd-radio-group.vue +54 -0
- package/components/wd-rate/index.scss +24 -0
- package/components/wd-rate/types.ts +91 -0
- package/components/wd-rate/wd-rate.vue +131 -0
- package/components/wd-resize/index.scss +26 -0
- package/components/wd-resize/types.ts +6 -0
- package/components/wd-resize/wd-resize.vue +155 -0
- package/components/wd-row/index.scss +10 -0
- package/components/wd-row/types.ts +16 -0
- package/components/wd-row/wd-row.vue +63 -0
- package/components/wd-search/index.scss +148 -0
- package/components/wd-search/types.ts +83 -0
- package/components/wd-search/wd-search.vue +237 -0
- package/components/wd-segmented/index.scss +97 -0
- package/components/wd-segmented/types.ts +68 -0
- package/components/wd-segmented/wd-segmented.vue +143 -0
- package/components/wd-select-picker/index.scss +177 -0
- package/components/wd-select-picker/types.ts +116 -0
- package/components/wd-select-picker/wd-select-picker.vue +486 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +28 -0
- package/components/wd-sidebar/wd-sidebar.vue +41 -0
- package/components/wd-sidebar-item/index.scss +93 -0
- package/components/wd-sidebar-item/types.ts +31 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +114 -0
- package/components/wd-skeleton/index.scss +101 -0
- package/components/wd-skeleton/index.ts +1 -0
- package/components/wd-skeleton/types.ts +69 -0
- package/components/wd-skeleton/wd-skeleton.vue +135 -0
- package/components/wd-slider/index.scss +91 -0
- package/components/wd-slider/types.ts +104 -0
- package/components/wd-slider/wd-slider.vue +377 -0
- package/components/wd-sort-button/index.scss +86 -0
- package/components/wd-sort-button/types.ts +43 -0
- package/components/wd-sort-button/wd-sort-button.vue +76 -0
- package/components/wd-status-tip/index.scss +37 -0
- package/components/wd-status-tip/types.ts +59 -0
- package/components/wd-status-tip/wd-status-tip.vue +94 -0
- package/components/wd-step/index.scss +236 -0
- package/components/wd-step/types.ts +33 -0
- package/components/wd-step/wd-step.vue +151 -0
- package/components/wd-steps/index.scss +10 -0
- package/components/wd-steps/types.ts +59 -0
- package/components/wd-steps/wd-steps.vue +37 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +190 -0
- package/components/wd-sticky-box/index.scss +6 -0
- package/components/wd-sticky-box/types.ts +20 -0
- package/components/wd-sticky-box/wd-sticky-box.vue +154 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +43 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +307 -0
- package/components/wd-swiper/index.scss +23 -0
- package/components/wd-swiper/types.ts +189 -0
- package/components/wd-swiper/wd-swiper.vue +202 -0
- package/components/wd-swiper-nav/index.scss +153 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +37 -0
- package/components/wd-switch/index.scss +58 -0
- package/components/wd-switch/types.ts +56 -0
- package/components/wd-switch/wd-switch.vue +83 -0
- package/components/wd-tab/index.scss +8 -0
- package/components/wd-tab/types.ts +20 -0
- package/components/wd-tab/wd-tab.vue +100 -0
- package/components/wd-tabbar/index.scss +57 -0
- package/components/wd-tabbar/types.ts +88 -0
- package/components/wd-tabbar/wd-tabbar.vue +104 -0
- package/components/wd-tabbar-item/index.scss +52 -0
- package/components/wd-tabbar-item/types.ts +51 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +132 -0
- package/components/wd-table/types.ts +69 -0
- package/components/wd-table/wd-table.vue +255 -0
- package/components/wd-table-col/index.scss +44 -0
- package/components/wd-table-col/types.ts +54 -0
- package/components/wd-table-col/wd-table-col.vue +149 -0
- package/components/wd-tabs/index.scss +280 -0
- package/components/wd-tabs/types.ts +71 -0
- package/components/wd-tabs/wd-tabs.vue +528 -0
- package/components/wd-tag/index.scss +115 -0
- package/components/wd-tag/types.ts +81 -0
- package/components/wd-tag/wd-tag.vue +154 -0
- package/components/wd-text/index.scss +34 -0
- package/components/wd-text/types.ts +98 -0
- package/components/wd-text/wd-text.vue +138 -0
- package/components/wd-textarea/index.scss +343 -0
- package/components/wd-textarea/types.ts +298 -0
- package/components/wd-textarea/wd-textarea.vue +303 -0
- package/components/wd-toast/index.scss +66 -0
- package/components/wd-toast/index.ts +109 -0
- package/components/wd-toast/types.ts +76 -0
- package/components/wd-toast/wd-toast.vue +212 -0
- package/components/wd-tooltip/index.scss +61 -0
- package/components/wd-tooltip/types.ts +102 -0
- package/components/wd-tooltip/wd-tooltip.vue +167 -0
- package/components/wd-transition/index.scss +91 -0
- package/components/wd-transition/types.ts +89 -0
- package/components/wd-transition/wd-transition.vue +221 -0
- package/components/wd-upload/index.scss +173 -0
- package/components/wd-upload/types.ts +378 -0
- package/components/wd-upload/utils.ts +152 -0
- package/components/wd-upload/wd-upload.vue +737 -0
- package/components/wd-video-preview/index.scss +34 -0
- package/components/wd-video-preview/types.ts +32 -0
- package/components/wd-video-preview/wd-video-preview.vue +76 -0
- package/components/wd-watermark/index.scss +18 -0
- package/components/wd-watermark/types.ts +82 -0
- package/components/wd-watermark/wd-watermark.vue +592 -0
- package/components/wot-design-uni/wot-design-uni.vue +14 -0
- package/global.d.ts +108 -0
- package/index.ts +30 -0
- package/locale/index.ts +41 -0
- package/locale/lang/en-US.ts +128 -0
- package/locale/lang/th-TH.ts +127 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +127 -0
- package/locale/lang/zh-HK.ts +84 -0
- package/locale/lang/zh-TW.ts +84 -0
- package/package.json +20 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- #ifdef MP-DINGTALK -->
|
|
3
|
+
<view :class="`wd-index-anchor-ding ${isSticky ? 'is-sticky' : ''}`">
|
|
4
|
+
<!-- #endif -->
|
|
5
|
+
<view
|
|
6
|
+
:class="`wd-index-anchor ${isSticky ? 'is-sticky' : ''} ${customClass}`"
|
|
7
|
+
:style="customStyle"
|
|
8
|
+
:id="indexAnchorId"
|
|
9
|
+
>
|
|
10
|
+
<slot>
|
|
11
|
+
{{ index }}
|
|
12
|
+
</slot>
|
|
13
|
+
</view>
|
|
14
|
+
<!-- #ifdef MP-DINGTALK -->
|
|
15
|
+
</view>
|
|
16
|
+
<!-- #endif -->
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { indexAnchorProps } from './type'
|
|
21
|
+
import { onMounted, getCurrentInstance, ref, computed } from 'vue'
|
|
22
|
+
import { indexBarInjectionKey } from '../wd-index-bar/type'
|
|
23
|
+
import { getRect, isDef, uuid } from '../common/util'
|
|
24
|
+
import { useParent } from '../composables/useParent'
|
|
25
|
+
|
|
26
|
+
const props = defineProps(indexAnchorProps)
|
|
27
|
+
|
|
28
|
+
const { parent: indexBar } = useParent(indexBarInjectionKey)
|
|
29
|
+
|
|
30
|
+
const indexAnchorId = ref<string>(`indexBar${uuid()}`)
|
|
31
|
+
|
|
32
|
+
const { proxy } = getCurrentInstance()!
|
|
33
|
+
|
|
34
|
+
const isSticky = computed(() => {
|
|
35
|
+
return indexBar && indexBar.props.sticky && indexBar.anchorState.activeIndex === props.index
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
function getInfo() {
|
|
39
|
+
getRect(`#${indexAnchorId.value}`, false, proxy).then((res) => {
|
|
40
|
+
if (isDef(indexBar)) {
|
|
41
|
+
const anchor = indexBar.anchorState.anchorList.find((v) => v.index === props.index)!
|
|
42
|
+
anchor.top = Math.floor(res.top!)
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
onMounted(() => {
|
|
48
|
+
if (isDef(indexBar)) {
|
|
49
|
+
indexBar.anchorState.anchorList.push({ top: 0, index: props.index })
|
|
50
|
+
}
|
|
51
|
+
getInfo()
|
|
52
|
+
})
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<style lang="scss" scoped>
|
|
56
|
+
@import './index';
|
|
57
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@import './../common/abstracts/_mixin';
|
|
2
|
+
@import './../common/abstracts/variable';
|
|
3
|
+
|
|
4
|
+
.wot-theme-dark {
|
|
5
|
+
@include b(index-bar) {
|
|
6
|
+
@include e(index) {
|
|
7
|
+
color: $-color-white;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@include b(index-bar) {
|
|
13
|
+
position: relative;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
|
|
17
|
+
@include e(content) {
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@include e(sidebar) {
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: 50%;
|
|
25
|
+
right: 4px;
|
|
26
|
+
transform: translateY(-50%);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@include e(index) {
|
|
30
|
+
padding: 4px 6px;
|
|
31
|
+
font-size: 12px;
|
|
32
|
+
font-weight: $-fw-medium;
|
|
33
|
+
color: $-color-title;
|
|
34
|
+
|
|
35
|
+
@include when(active) {
|
|
36
|
+
color: $-color-theme;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Ref, InjectionKey, ExtractPropTypes } from 'vue'
|
|
2
|
+
import { makeBooleanProp } from '../common/props'
|
|
3
|
+
|
|
4
|
+
export type AnchorIndex = number | string
|
|
5
|
+
|
|
6
|
+
export interface AnchorItem {
|
|
7
|
+
top: number
|
|
8
|
+
index: AnchorIndex
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const indexBarProps = {
|
|
12
|
+
/**
|
|
13
|
+
* @description 索引是否吸顶
|
|
14
|
+
*/
|
|
15
|
+
sticky: makeBooleanProp(false),
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type IndexBarProps = ExtractPropTypes<typeof indexBarProps>
|
|
19
|
+
|
|
20
|
+
export type InderBarProvide = {
|
|
21
|
+
props: { sticky?: boolean }
|
|
22
|
+
anchorState: {
|
|
23
|
+
anchorList: AnchorItem[] // 锚点列表
|
|
24
|
+
activeIndex: AnchorIndex | null // 当前激活的索引
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const indexBarInjectionKey: InjectionKey<InderBarProvide> = Symbol('wd-index-bar')
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="wd-index-bar" :id="indexBarId">
|
|
3
|
+
<!-- #ifdef MP-DINGTALK -->
|
|
4
|
+
<view class="wd-index-bar" :id="indexBarId">
|
|
5
|
+
<!-- #endif -->
|
|
6
|
+
<scroll-view
|
|
7
|
+
:scrollTop="scrollState.scrollTop"
|
|
8
|
+
:scroll-y="true"
|
|
9
|
+
class="wd-index-bar__content"
|
|
10
|
+
@scroll="hanleScroll"
|
|
11
|
+
>
|
|
12
|
+
<slot></slot>
|
|
13
|
+
</scroll-view>
|
|
14
|
+
<view
|
|
15
|
+
class="wd-index-bar__sidebar"
|
|
16
|
+
@touchstart.stop.prevent="handleTouchStart"
|
|
17
|
+
@touchmove.stop.prevent="handleTouchMove"
|
|
18
|
+
@touchend.stop.prevent="handleTouchEnd"
|
|
19
|
+
@touchcancel.stop.prevent="handleTouchEnd"
|
|
20
|
+
>
|
|
21
|
+
<view
|
|
22
|
+
class="wd-index-bar__index"
|
|
23
|
+
:class="{ 'is-active': item.index === state.activeIndex }"
|
|
24
|
+
v-for="item in state.anchorList"
|
|
25
|
+
:key="item.index"
|
|
26
|
+
>
|
|
27
|
+
{{ item.index }}
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
30
|
+
<!-- #ifdef MP-DINGTALK -->
|
|
31
|
+
</view>
|
|
32
|
+
<!-- #endif -->
|
|
33
|
+
</view>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup lang="ts">
|
|
37
|
+
import type { AnchorItem, AnchorIndex } from './type'
|
|
38
|
+
import { indexBarInjectionKey, indexBarProps } from './type'
|
|
39
|
+
import { ref, getCurrentInstance, onMounted, reactive, nextTick } from 'vue'
|
|
40
|
+
import { getRect, isDef, uuid, requestAnimationFrame } from '../common/util'
|
|
41
|
+
import { useChildren } from '../composables/useChildren'
|
|
42
|
+
|
|
43
|
+
const props = defineProps(indexBarProps)
|
|
44
|
+
|
|
45
|
+
const indexBarId = ref<string>(`indexBar${uuid()}`)
|
|
46
|
+
|
|
47
|
+
const { proxy } = getCurrentInstance()!
|
|
48
|
+
|
|
49
|
+
const state = reactive({
|
|
50
|
+
activeIndex: null as AnchorIndex | null,
|
|
51
|
+
anchorList: [] as AnchorItem[],
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const { linkChildren } = useChildren(indexBarInjectionKey)
|
|
55
|
+
|
|
56
|
+
linkChildren({ props, anchorState: state })
|
|
57
|
+
|
|
58
|
+
const scrollState = reactive({
|
|
59
|
+
scrollTop: 0, // 即将滚动到的位置
|
|
60
|
+
prevScrollTop: 0, // 上次记录的位置
|
|
61
|
+
// 滚动距离
|
|
62
|
+
touching: false,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
// 组件距离页面顶部的高度
|
|
66
|
+
let offsetTop = 0
|
|
67
|
+
const sidebarInfo = {
|
|
68
|
+
// 侧边栏距离顶部的高度
|
|
69
|
+
offsetTop: 0,
|
|
70
|
+
// 高度固定24px
|
|
71
|
+
indexHeight: 24,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function init() {
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
state.activeIndex = state.anchorList[0]?.index
|
|
77
|
+
Promise.all([
|
|
78
|
+
getRect(`#${indexBarId.value}`, false, proxy),
|
|
79
|
+
getRect('.wd-index-bar__sidebar', false, proxy),
|
|
80
|
+
getRect('.wd-index-bar__index', false, proxy),
|
|
81
|
+
]).then(([bar, sidebar, index]) => {
|
|
82
|
+
offsetTop = bar.top!
|
|
83
|
+
sidebarInfo.offsetTop = sidebar.top!
|
|
84
|
+
sidebarInfo.indexHeight = index.height!
|
|
85
|
+
})
|
|
86
|
+
}, 100)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
onMounted(() => {
|
|
90
|
+
init()
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
function hanleScroll(scrollEvent: any) {
|
|
94
|
+
if (scrollState.touching) {
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
const { detail } = scrollEvent
|
|
98
|
+
const scrolltop = Math.floor(detail.scrollTop)
|
|
99
|
+
const anchor = state.anchorList.find((item, index) => {
|
|
100
|
+
if (!isDef(state.anchorList[index + 1])) return true
|
|
101
|
+
if (
|
|
102
|
+
item.top - offsetTop <= scrolltop &&
|
|
103
|
+
state.anchorList[index + 1].top - offsetTop > scrolltop
|
|
104
|
+
)
|
|
105
|
+
return true
|
|
106
|
+
return false
|
|
107
|
+
})!
|
|
108
|
+
if (state.activeIndex !== anchor.index) {
|
|
109
|
+
state.activeIndex = anchor.index
|
|
110
|
+
}
|
|
111
|
+
scrollState.prevScrollTop = scrolltop
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getAnchorByPageY(pageY: number) {
|
|
115
|
+
const y = pageY - sidebarInfo.offsetTop
|
|
116
|
+
let idx = Math.floor(y / sidebarInfo.indexHeight)
|
|
117
|
+
if (idx < 0) idx = 0
|
|
118
|
+
else if (idx > state.anchorList.length - 1) idx = state.anchorList.length - 1
|
|
119
|
+
return state.anchorList[idx]
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function handleTouchStart() {
|
|
123
|
+
scrollState.touching = true
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function handleTouchMove(e: TouchEvent) {
|
|
127
|
+
const clientY = e.touches[0].pageY
|
|
128
|
+
if (state.activeIndex === getAnchorByPageY(clientY).index) {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
state.activeIndex = getAnchorByPageY(clientY).index
|
|
132
|
+
setScrollTop(getAnchorByPageY(clientY).top - offsetTop)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function handleTouchEnd(e: TouchEvent) {
|
|
136
|
+
const clientY = e.changedTouches[0].pageY
|
|
137
|
+
state.activeIndex = getAnchorByPageY(clientY).index
|
|
138
|
+
setScrollTop(getAnchorByPageY(clientY).top - offsetTop)
|
|
139
|
+
requestAnimationFrame(() => {
|
|
140
|
+
scrollState.touching = false
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function setScrollTop(top: number) {
|
|
145
|
+
if (scrollState.scrollTop === top) {
|
|
146
|
+
scrollState.scrollTop = scrollState.prevScrollTop
|
|
147
|
+
nextTick(() => {
|
|
148
|
+
scrollState.scrollTop = top
|
|
149
|
+
})
|
|
150
|
+
} else {
|
|
151
|
+
scrollState.scrollTop = top
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<style lang="scss" scoped>
|
|
157
|
+
@import './index.scss';
|
|
158
|
+
</style>
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
.wot-theme-dark {
|
|
5
|
+
@include b(input) {
|
|
6
|
+
background: $-dark-background2;
|
|
7
|
+
|
|
8
|
+
&::after {
|
|
9
|
+
background: $-dark-color-gray;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@include when(not-empty) {
|
|
13
|
+
&:not(.is-disabled) {
|
|
14
|
+
&::after {
|
|
15
|
+
background-color: $-dark-color;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@include e(inner) {
|
|
21
|
+
color: $-dark-color;
|
|
22
|
+
|
|
23
|
+
&::-webkit-input-placeholder {
|
|
24
|
+
color: $-dark-color3;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@include e(placeholder) {
|
|
29
|
+
color: $-dark-color3;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include e(count) {
|
|
33
|
+
color: $-dark-color3;
|
|
34
|
+
background: transparent;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@include e(count-current) {
|
|
38
|
+
color: $-dark-color;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:deep(.wd-input__icon),
|
|
42
|
+
:deep(.wd-input__clear) {
|
|
43
|
+
color: $-dark-color;
|
|
44
|
+
background: transparent;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@include when(cell) {
|
|
48
|
+
line-height: $-cell-line-height;
|
|
49
|
+
background-color: $-dark-background2;
|
|
50
|
+
|
|
51
|
+
@include when(border) {
|
|
52
|
+
@include halfPixelBorder('top', $-input-cell-padding, $-dark-border-color);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@include when(disabled) {
|
|
57
|
+
.wd-input__inner {
|
|
58
|
+
color: $-dark-color-gray;
|
|
59
|
+
background: transparent;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@include e(label) {
|
|
64
|
+
color: $-dark-color;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@include b(input) {
|
|
70
|
+
position: relative;
|
|
71
|
+
-webkit-tap-highlight-color: transparent;
|
|
72
|
+
text-align: left;
|
|
73
|
+
background: $-input-bg;
|
|
74
|
+
|
|
75
|
+
&::after {
|
|
76
|
+
position: absolute;
|
|
77
|
+
right: 0;
|
|
78
|
+
bottom: 0;
|
|
79
|
+
left: 0;
|
|
80
|
+
height: 1px;
|
|
81
|
+
content: '';
|
|
82
|
+
background: $-input-border-color;
|
|
83
|
+
transition: background-color 0.2s ease-in-out;
|
|
84
|
+
transform: scaleY(0.5);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@include when(not-empty) {
|
|
88
|
+
&:not(.is-disabled) {
|
|
89
|
+
&::after {
|
|
90
|
+
background-color: $-input-not-empty-border-color;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@include e(label) {
|
|
96
|
+
position: relative;
|
|
97
|
+
box-sizing: border-box;
|
|
98
|
+
display: flex;
|
|
99
|
+
flex-shrink: 0;
|
|
100
|
+
width: $-input-cell-label-width;
|
|
101
|
+
margin-right: $-cell-padding;
|
|
102
|
+
font-size: $-input-fs;
|
|
103
|
+
color: $-cell-title-color;
|
|
104
|
+
|
|
105
|
+
@include when(required) {
|
|
106
|
+
padding-left: 12px;
|
|
107
|
+
|
|
108
|
+
&::after {
|
|
109
|
+
position: absolute;
|
|
110
|
+
top: 2px;
|
|
111
|
+
left: 0;
|
|
112
|
+
font-size: $-cell-required-size;
|
|
113
|
+
line-height: 1.1;
|
|
114
|
+
color: $-cell-required-color;
|
|
115
|
+
content: '*';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@include e(label-inner) {
|
|
121
|
+
display: inline-block;
|
|
122
|
+
font-size: $-input-fs;
|
|
123
|
+
line-height: $-cell-line-height;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@include e(body) {
|
|
127
|
+
flex: 1;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@include e(value) {
|
|
131
|
+
position: relative;
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: row;
|
|
134
|
+
align-items: center;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@include e(prefix) {
|
|
138
|
+
margin-right: $-input-icon-margin;
|
|
139
|
+
font-size: $-input-fs;
|
|
140
|
+
line-height: initial;
|
|
141
|
+
|
|
142
|
+
:deep(.wd-input__icon),
|
|
143
|
+
:deep(.wd-input__clear) {
|
|
144
|
+
margin-left: 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@include e(suffix) {
|
|
149
|
+
flex-shrink: 0;
|
|
150
|
+
margin-left: $-input-icon-margin;
|
|
151
|
+
line-height: initial;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@include e(error-message) {
|
|
155
|
+
font-size: $-form-item-error-message-font-size;
|
|
156
|
+
line-height: $-form-item-error-message-line-height;
|
|
157
|
+
color: $-form-item-error-message-color;
|
|
158
|
+
text-align: left;
|
|
159
|
+
vertical-align: middle;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@include when(disabled) {
|
|
163
|
+
.wd-input__inner {
|
|
164
|
+
color: $-input-disabled-color;
|
|
165
|
+
background: transparent;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@include when(error) {
|
|
170
|
+
.wd-input__inner {
|
|
171
|
+
color: $-input-error-color;
|
|
172
|
+
background: transparent;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@include when(no-border) {
|
|
177
|
+
&::after {
|
|
178
|
+
display: none;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.wd-input__inner {
|
|
182
|
+
height: $-input-inner-height-no-border;
|
|
183
|
+
padding-top: 0;
|
|
184
|
+
padding-bottom: 0;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@include when(cell) {
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: flex-start;
|
|
191
|
+
padding: $-input-cell-padding $-input-padding;
|
|
192
|
+
background-color: $-input-cell-bg;
|
|
193
|
+
|
|
194
|
+
&.is-error::after {
|
|
195
|
+
background: $-input-cell-border-color;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
:deep(.wd-input__icon),
|
|
199
|
+
:deep(.wd-input__clear) {
|
|
200
|
+
display: inline-flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
height: $-input-cell-height;
|
|
203
|
+
line-height: $-input-cell-height;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.wd-input__prefix {
|
|
207
|
+
display: inline-block;
|
|
208
|
+
margin-right: $-cell-icon-right;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.wd-input__inner {
|
|
212
|
+
height: $-input-cell-height;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
&.wd-input::after {
|
|
216
|
+
display: none;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
@include when(center) {
|
|
220
|
+
align-items: center;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@include when(border) {
|
|
224
|
+
@include halfPixelBorder('top', $-input-cell-padding);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@include when(large) {
|
|
229
|
+
padding: $-input-cell-padding-large;
|
|
230
|
+
|
|
231
|
+
.wd-input__prefix {
|
|
232
|
+
font-size: $-input-fs-large;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.wd-input__label-inner {
|
|
236
|
+
font-size: $-input-fs-large;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.wd-input__inner {
|
|
240
|
+
font-size: $-input-fs-large;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.wd-input__count {
|
|
244
|
+
font-size: $-input-count-fs-large;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
:deep(.wd-input__icon),
|
|
248
|
+
:deep(.wd-input__clear) {
|
|
249
|
+
font-size: $-input-icon-size-large;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@include e(inner) {
|
|
254
|
+
box-sizing: border-box;
|
|
255
|
+
flex: 1;
|
|
256
|
+
height: $-input-inner-height;
|
|
257
|
+
padding: 0;
|
|
258
|
+
font-size: $-input-fs;
|
|
259
|
+
color: $-input-color;
|
|
260
|
+
background: none;
|
|
261
|
+
border: none;
|
|
262
|
+
outline: none;
|
|
263
|
+
|
|
264
|
+
&::-webkit-input-placeholder {
|
|
265
|
+
color: $-input-placeholder-color;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@include when(align-right) {
|
|
269
|
+
text-align: right;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
@include e(readonly-mask) {
|
|
274
|
+
position: absolute;
|
|
275
|
+
top: 0;
|
|
276
|
+
left: 0;
|
|
277
|
+
z-index: 2;
|
|
278
|
+
width: 100%;
|
|
279
|
+
height: 100%;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@include edeep(icon) {
|
|
283
|
+
margin-left: $-input-icon-margin;
|
|
284
|
+
font-size: $-input-icon-size;
|
|
285
|
+
color: $-input-icon-color;
|
|
286
|
+
vertical-align: middle;
|
|
287
|
+
background: $-input-bg;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@include edeep(clear) {
|
|
291
|
+
margin-left: $-input-icon-margin;
|
|
292
|
+
font-size: $-input-icon-size;
|
|
293
|
+
color: $-input-clear-color;
|
|
294
|
+
vertical-align: middle;
|
|
295
|
+
background: $-input-bg;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
@include e(count) {
|
|
299
|
+
margin-left: 15px;
|
|
300
|
+
font-size: $-input-count-fs;
|
|
301
|
+
color: $-input-count-color;
|
|
302
|
+
vertical-align: middle;
|
|
303
|
+
background: $-input-bg;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
@include e(count-current) {
|
|
307
|
+
color: $-input-count-current-color;
|
|
308
|
+
|
|
309
|
+
@include when(error) {
|
|
310
|
+
color: $-input-error-color;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
@include e(placeholder) {
|
|
315
|
+
color: $-input-placeholder-color;
|
|
316
|
+
|
|
317
|
+
&.is-error {
|
|
318
|
+
color: $-input-error-color;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.wd-input__count,
|
|
323
|
+
.wd-input__count-current {
|
|
324
|
+
display: inline-flex;
|
|
325
|
+
}
|
|
326
|
+
}
|