hy-app 0.5.12 → 0.5.14
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/hy-button/index.scss +3 -0
- package/components/hy-cell-item/hy-cell-item.vue +161 -161
- package/components/hy-cell-item/props.ts +59 -66
- package/components/hy-config-provider/index.scss +5 -8
- package/components/hy-coupon/index.scss +12 -11
- package/components/hy-coupon/props.ts +5 -5
- package/components/hy-folding-panel/hy-folding-panel-group.vue +163 -0
- package/components/hy-index-bar/hy-index-bar.vue +197 -0
- package/components/hy-index-bar/index.scss +65 -0
- package/components/hy-index-bar/props.ts +94 -0
- package/components/hy-index-bar/typing.d.ts +36 -0
- package/components/hy-number-step/hy-number-step.vue +367 -367
- package/components/hy-number-step/index.scss +14 -5
- package/components/hy-qrcode/qrcode.js.bak +1434 -0
- package/components/hy-table/hy-table.vue +30 -13
- package/components/hy-table/index.scss +6 -1
- package/components/hy-table/props.ts +1 -1
- package/components/hy-tag/index.scss +5 -13
- package/components/hy-text/hy-text.vue +1 -1
- package/global.d.ts +92 -91
- package/libs/utils/utils.ts +503 -521
- package/package.json +2 -2
- package/web-types.json +1 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-folding-panel-group">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
export default {
|
|
9
|
+
name: "hy-folding-panel-group"
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { provide, ref, watch, onMounted, nextTick, getCurrentInstance } from 'vue';
|
|
15
|
+
import type { Ref } from 'vue';
|
|
16
|
+
|
|
17
|
+
// Props定义
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
/**
|
|
20
|
+
* 当前激活的面板索引,支持v-model
|
|
21
|
+
*/
|
|
22
|
+
modelValue: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: -1
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* 是否手风琴模式,默认true
|
|
28
|
+
*/
|
|
29
|
+
accordion: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* 是否禁用整个折叠面板组
|
|
35
|
+
*/
|
|
36
|
+
disabled: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// 事件定义
|
|
43
|
+
const emit = defineEmits<{
|
|
44
|
+
(e: 'update:modelValue', value: number): void;
|
|
45
|
+
(e: 'change', index: number): void;
|
|
46
|
+
(e: 'open', index: number): void;
|
|
47
|
+
(e: 'close', index: number): void;
|
|
48
|
+
}>();
|
|
49
|
+
|
|
50
|
+
// 内部激活索引
|
|
51
|
+
const activeIndex = ref(props.modelValue);
|
|
52
|
+
|
|
53
|
+
// 监听v-model变化
|
|
54
|
+
watch(() => props.modelValue, (newVal) => {
|
|
55
|
+
activeIndex.value = newVal;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// 监听内部激活索引变化
|
|
59
|
+
watch(activeIndex, (newVal) => {
|
|
60
|
+
emit('update:modelValue', newVal);
|
|
61
|
+
emit('change', newVal);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// 提供给子组件的方法
|
|
65
|
+
const updateActiveIndex = (index: number) => {
|
|
66
|
+
if (props.disabled) return;
|
|
67
|
+
|
|
68
|
+
if (props.accordion) {
|
|
69
|
+
// 手风琴模式下,如果点击的是当前激活的索引,则关闭(设为-1)
|
|
70
|
+
const wasActive = activeIndex.value === index;
|
|
71
|
+
activeIndex.value = wasActive ? -1 : index;
|
|
72
|
+
|
|
73
|
+
// 触发相应的事件
|
|
74
|
+
if (!wasActive) {
|
|
75
|
+
emit('open', index);
|
|
76
|
+
} else {
|
|
77
|
+
emit('close', index);
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
// 非手风琴模式下,这里不做特殊处理,由子组件自己控制
|
|
81
|
+
activeIndex.value = index;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// 提供给子组件的配置
|
|
86
|
+
provide('hy-folding-panel-group', {
|
|
87
|
+
accordion: props.accordion,
|
|
88
|
+
disabled: props.disabled,
|
|
89
|
+
activeIndex,
|
|
90
|
+
updateActiveIndex
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// 自动为子组件设置索引
|
|
94
|
+
onMounted(() => {
|
|
95
|
+
nextTick(() => {
|
|
96
|
+
const children = getCurrentInstance()?.proxy?.$el?.querySelectorAll('.hy-folding-panel-item');
|
|
97
|
+
children?.forEach((child, index) => {
|
|
98
|
+
const vueComponent = (child as any).__vueParentComponent?.proxy;
|
|
99
|
+
if (vueComponent && vueComponent.$options.name === 'hy-folding-panel-item') {
|
|
100
|
+
vueComponent.index = index;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// 对外暴露的方法
|
|
107
|
+
defineExpose({
|
|
108
|
+
/**
|
|
109
|
+
* 打开指定索引的面板
|
|
110
|
+
*/
|
|
111
|
+
open: (index: number) => {
|
|
112
|
+
if (props.disabled) return;
|
|
113
|
+
activeIndex.value = index;
|
|
114
|
+
emit('open', index);
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 关闭所有面板
|
|
119
|
+
*/
|
|
120
|
+
closeAll: () => {
|
|
121
|
+
if (props.disabled) return;
|
|
122
|
+
const prevIndex = activeIndex.value;
|
|
123
|
+
activeIndex.value = -1;
|
|
124
|
+
if (prevIndex !== -1) {
|
|
125
|
+
emit('close', prevIndex);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 切换指定索引面板的状态
|
|
131
|
+
*/
|
|
132
|
+
toggle: (index: number) => {
|
|
133
|
+
if (props.disabled) return;
|
|
134
|
+
updateActiveIndex(index);
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 关闭指定索引的面板
|
|
139
|
+
*/
|
|
140
|
+
close: (index: number) => {
|
|
141
|
+
if (props.disabled) return;
|
|
142
|
+
if (activeIndex.value === index) {
|
|
143
|
+
activeIndex.value = -1;
|
|
144
|
+
emit('close', index);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
</script>
|
|
149
|
+
|
|
150
|
+
<style lang="scss" scoped>
|
|
151
|
+
.hy-folding-panel-group {
|
|
152
|
+
width: 100%;
|
|
153
|
+
background-color: #ffffff;
|
|
154
|
+
border-radius: 8px;
|
|
155
|
+
overflow: hidden;
|
|
156
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.hy-folding-panel-group--disabled {
|
|
160
|
+
opacity: 0.6;
|
|
161
|
+
pointer-events: none;
|
|
162
|
+
}
|
|
163
|
+
</style>
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-index-bar" :class="indexBarClass" :style="indexBarStyle">
|
|
3
|
+
<view class="hy-index-bar__index--list">
|
|
4
|
+
<view
|
|
5
|
+
v-for="(item, index) in indexList"
|
|
6
|
+
:key="index"
|
|
7
|
+
class="hy-index-bar__index--list__item"
|
|
8
|
+
:class="{ 'is-active': modelValue === indexValue(item) }"
|
|
9
|
+
:style="getIndexItemStyle(indexValue(item))"
|
|
10
|
+
@click="handleIndexClick(indexValue(item), $event)"
|
|
11
|
+
@touchstart="handleTouchStart($event)"
|
|
12
|
+
@touchmove="handleTouchMove($event)"
|
|
13
|
+
@touchend="handleTouchEnd"
|
|
14
|
+
>
|
|
15
|
+
{{ indexValue(item) }}
|
|
16
|
+
</view>
|
|
17
|
+
|
|
18
|
+
<!-- 索引字母提示 -->
|
|
19
|
+
<hy-transition :show="showToast && isTouching" :customStyle="toastStyle">
|
|
20
|
+
<view class="hy-index-bar__toast">
|
|
21
|
+
<text class="hy-index-bar__toast--text">{{ modelValue }}</text>
|
|
22
|
+
</view>
|
|
23
|
+
</hy-transition>
|
|
24
|
+
</view>
|
|
25
|
+
</view>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
export default {
|
|
30
|
+
name: 'hy-index-bar',
|
|
31
|
+
options: {
|
|
32
|
+
addGlobalClass: true,
|
|
33
|
+
virtualHost: true,
|
|
34
|
+
styleIsolation: 'shared'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import { computed, ref, onMounted, getCurrentInstance, nextTick } from 'vue'
|
|
41
|
+
import type { CSSProperties } from 'vue'
|
|
42
|
+
import type { IIndexBarEmits, IIndexItem } from './typing'
|
|
43
|
+
import { addUnit, getRect, sleep } from '../../libs'
|
|
44
|
+
import indexBarProps from './props'
|
|
45
|
+
// 组件
|
|
46
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 索引栏组件,用于快速定位列表内容的索引栏组件,支持点击和滑动两种交互方式
|
|
50
|
+
* @displayName hy-index-bar
|
|
51
|
+
*/
|
|
52
|
+
defineOptions({})
|
|
53
|
+
|
|
54
|
+
const props = defineProps(indexBarProps)
|
|
55
|
+
const emit = defineEmits<IIndexBarEmits>()
|
|
56
|
+
|
|
57
|
+
// 获取当前组件实例
|
|
58
|
+
const instance = getCurrentInstance()
|
|
59
|
+
|
|
60
|
+
// 使用props中的activeIndex,同时保持内部状态用于点击事件
|
|
61
|
+
const isTouching = ref<boolean>(false)
|
|
62
|
+
const lastIndex = ref<string>('')
|
|
63
|
+
const toastStyle = ref<CSSProperties>({
|
|
64
|
+
position: 'absolute',
|
|
65
|
+
left: '-150rpx',
|
|
66
|
+
zIndex: 10
|
|
67
|
+
})
|
|
68
|
+
// 缓存索引栏高度和索引项高度
|
|
69
|
+
const indexBarRect = ref<UniNamespace.NodeInfo>()
|
|
70
|
+
const itemHeight = ref<number>(0)
|
|
71
|
+
|
|
72
|
+
const indexBarClass = computed<string[]>(() => {
|
|
73
|
+
return [`hy-index-bar--${props.position}`]
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const indexBarStyle = computed<CSSProperties>(() => {
|
|
77
|
+
return {
|
|
78
|
+
width: addUnit(props.width),
|
|
79
|
+
height: addUnit(props.height),
|
|
80
|
+
...props.customStyle
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const indexValue = computed(() => {
|
|
85
|
+
return (item: IIndexItem) => {
|
|
86
|
+
return typeof item === 'object' && item !== null ? item.index : item
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// 缓存索引项样式,避免重复计算
|
|
91
|
+
const indexItemStyles = computed(() => {
|
|
92
|
+
// 计算通用样式部分
|
|
93
|
+
const commonStyle = {
|
|
94
|
+
width: addUnit(props.width),
|
|
95
|
+
height: addUnit(props.width),
|
|
96
|
+
fontSize: addUnit(props.indexSize)
|
|
97
|
+
} as CSSProperties
|
|
98
|
+
console.log(
|
|
99
|
+
props.indexList.reduce((styles: Record<string, CSSProperties>, item: IIndexItem) => {
|
|
100
|
+
const isActive = props.modelValue === indexValue.value(item)
|
|
101
|
+
styles[indexValue.value(item)] = {
|
|
102
|
+
...commonStyle,
|
|
103
|
+
color: isActive ? props.activeIndexColor : props.indexColor,
|
|
104
|
+
backgroundColor: isActive ? props.activeIndexBgColor : props.indexBgColor
|
|
105
|
+
}
|
|
106
|
+
return styles
|
|
107
|
+
}, {})
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
// 为每个索引项创建样式对象并缓存
|
|
111
|
+
return props.indexList.reduce((styles: Record<string, CSSProperties>, item: IIndexItem) => {
|
|
112
|
+
const isActive = props.modelValue === indexValue.value(item)
|
|
113
|
+
styles[indexValue.value(item)] = {
|
|
114
|
+
...commonStyle,
|
|
115
|
+
color: isActive ? props.activeIndexColor : props.indexColor,
|
|
116
|
+
backgroundColor: isActive ? props.activeIndexBgColor : props.indexBgColor
|
|
117
|
+
}
|
|
118
|
+
return styles
|
|
119
|
+
}, {})
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
// 获取索引项样式的便捷方法
|
|
123
|
+
const getIndexItemStyle = (index: string) => {
|
|
124
|
+
console.log(index, '===')
|
|
125
|
+
return indexItemStyles.value[index] || {}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const handleIndexClick = (index: string, event: any) => {
|
|
129
|
+
emit('update:modelValue', index)
|
|
130
|
+
emit('click', index, event)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const handleTouchStart = (event: any) => {
|
|
134
|
+
isTouching.value = true
|
|
135
|
+
handleTouchMove(event)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 触摸移动事件处理
|
|
139
|
+
const handleTouchMove = (event: any) => {
|
|
140
|
+
// 获取触摸点坐标
|
|
141
|
+
const touch = event.touches ? event.touches[0] : event
|
|
142
|
+
const touchY = (touch.clientY || touch.y) - indexBarRect.value?.top!
|
|
143
|
+
|
|
144
|
+
// 计算当前触摸的索引位置
|
|
145
|
+
const index = Math.min(
|
|
146
|
+
Math.max(Math.floor(touchY / itemHeight.value), 0),
|
|
147
|
+
props.indexList.length - 1
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
const clickedIndex = props.indexList[index]?.index || props.indexList[index]
|
|
151
|
+
if (clickedIndex) {
|
|
152
|
+
// 只有当索引发生变化时才更新activeIndex
|
|
153
|
+
if (clickedIndex !== props.modelValue) {
|
|
154
|
+
emit('update:modelValue', clickedIndex)
|
|
155
|
+
emit('scroll', clickedIndex)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 只有当索引发生变化时才更新toast
|
|
159
|
+
if (clickedIndex !== lastIndex.value) {
|
|
160
|
+
lastIndex.value = clickedIndex
|
|
161
|
+
|
|
162
|
+
// 计算Toast的位置 - 使其与当前索引项对齐
|
|
163
|
+
let toastTop =
|
|
164
|
+
indexBarRect.value?.top! + index * itemHeight.value - 25 + itemHeight.value / 2
|
|
165
|
+
// #ifdef H5
|
|
166
|
+
toastTop = toastTop + 44 // h5需要加上导航栏高度
|
|
167
|
+
// #endif
|
|
168
|
+
toastStyle.value.top = addUnit(toastTop)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const handleTouchEnd = async () => {
|
|
174
|
+
await sleep(1000)
|
|
175
|
+
isTouching.value = false
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 获取列表元素属性值
|
|
180
|
+
* */
|
|
181
|
+
const init = () => {
|
|
182
|
+
nextTick(() => {
|
|
183
|
+
getRect('.hy-index-bar__index--list', false, instance).then((rect) => {
|
|
184
|
+
indexBarRect.value = rect
|
|
185
|
+
itemHeight.value = rect.height! / props.indexList.length
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
onMounted(() => {
|
|
191
|
+
init()
|
|
192
|
+
})
|
|
193
|
+
</script>
|
|
194
|
+
|
|
195
|
+
<style lang="scss" scoped>
|
|
196
|
+
@import './index.scss';
|
|
197
|
+
</style>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
@use "../../libs/css/mixin" as *;
|
|
2
|
+
@use "../../libs/css/theme" as *;
|
|
3
|
+
|
|
4
|
+
@include b(index-bar) {
|
|
5
|
+
position: fixed;
|
|
6
|
+
top: 0;
|
|
7
|
+
bottom: 0;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
z-index: 999;
|
|
13
|
+
transform: translateZ(0);
|
|
14
|
+
-webkit-transform: translateZ(0);
|
|
15
|
+
|
|
16
|
+
@include m(left) {
|
|
17
|
+
left: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@include m(right) {
|
|
21
|
+
right: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@include e(index) {
|
|
25
|
+
@include m(list) {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
align-items: center;
|
|
29
|
+
margin-right: $hy-border-margin-padding-base;
|
|
30
|
+
|
|
31
|
+
@include e(item) {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
color: $hy-text-color--3;
|
|
36
|
+
margin: 2rpx 0;
|
|
37
|
+
border-radius: $hy-border-radius-sm;
|
|
38
|
+
|
|
39
|
+
@include is(active) {
|
|
40
|
+
position: relative;
|
|
41
|
+
color: $hy-primary;
|
|
42
|
+
background: $hy-background--hover;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@include e(toast) {
|
|
49
|
+
width: 50px;
|
|
50
|
+
height: 50px;
|
|
51
|
+
border-radius: 100px 100px 0 100px;
|
|
52
|
+
text-align: center;
|
|
53
|
+
color: #ffffff;
|
|
54
|
+
background-color: #c9c9c9;
|
|
55
|
+
transform: rotate(-45deg);
|
|
56
|
+
display: flex;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
align-items: center;
|
|
59
|
+
|
|
60
|
+
@include m(text) {
|
|
61
|
+
transform: rotate(45deg);
|
|
62
|
+
font-size: $hy-font-size-lg;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
+
import type { IIndexItem } from './typing'
|
|
3
|
+
|
|
4
|
+
const indexBarProps = {
|
|
5
|
+
/**
|
|
6
|
+
* 当前激活的索引
|
|
7
|
+
*/
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: '',
|
|
11
|
+
required: true
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* 索引列表数据
|
|
15
|
+
*/
|
|
16
|
+
indexList: {
|
|
17
|
+
type: Array as PropType<IIndexItem[]>,
|
|
18
|
+
default: () => []
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* 索引栏位置
|
|
22
|
+
* @values left, right
|
|
23
|
+
*/
|
|
24
|
+
position: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'right'
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* 是否显示索引字母提示
|
|
30
|
+
*/
|
|
31
|
+
showToast: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: true
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* 索引项颜色
|
|
37
|
+
*/
|
|
38
|
+
indexColor: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: ''
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* 激活索引项颜色
|
|
44
|
+
*/
|
|
45
|
+
activeIndexColor: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: ''
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* 索引项背景色
|
|
51
|
+
*/
|
|
52
|
+
indexBgColor: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: 'transparent'
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* 激活索引项背景色
|
|
58
|
+
*/
|
|
59
|
+
activeIndexBgColor: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: ''
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* 索引项大小
|
|
65
|
+
*/
|
|
66
|
+
indexSize: {
|
|
67
|
+
type: [Number, String],
|
|
68
|
+
default: 12
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* 索引栏高度
|
|
72
|
+
*/
|
|
73
|
+
height: {
|
|
74
|
+
type: [Number, String],
|
|
75
|
+
default: '100%'
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* 索引栏宽度
|
|
79
|
+
*/
|
|
80
|
+
width: {
|
|
81
|
+
type: [Number, String],
|
|
82
|
+
default: 20
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* 自定义样式
|
|
86
|
+
*/
|
|
87
|
+
customStyle: Object as PropType<CSSProperties>,
|
|
88
|
+
/**
|
|
89
|
+
* 自定义外部类名
|
|
90
|
+
*/
|
|
91
|
+
customClass: String
|
|
92
|
+
} as const
|
|
93
|
+
|
|
94
|
+
export default indexBarProps
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue'
|
|
2
|
+
import type indexBarProps from './props'
|
|
3
|
+
|
|
4
|
+
export interface HyIndexBarProps extends ExtractPropTypes<typeof indexBarProps> {}
|
|
5
|
+
|
|
6
|
+
export interface IndexType {
|
|
7
|
+
/**
|
|
8
|
+
* 索引值
|
|
9
|
+
*/
|
|
10
|
+
index: string
|
|
11
|
+
/**
|
|
12
|
+
* 索引对应的内容
|
|
13
|
+
*/
|
|
14
|
+
title: string
|
|
15
|
+
/**
|
|
16
|
+
* 索引对应的列表数据
|
|
17
|
+
*/
|
|
18
|
+
data?: any[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IIndexItem extends IndexType {}
|
|
22
|
+
|
|
23
|
+
export interface IIndexBarEmits {
|
|
24
|
+
/**
|
|
25
|
+
* 点击索引时触发的事件
|
|
26
|
+
*/
|
|
27
|
+
(e: 'click', index: string, event: Event): void
|
|
28
|
+
/**
|
|
29
|
+
* 滚动到指定索引时触发的事件
|
|
30
|
+
*/
|
|
31
|
+
(e: 'scroll', index: string): void
|
|
32
|
+
/**
|
|
33
|
+
* 改变索引值
|
|
34
|
+
*/
|
|
35
|
+
(e: 'update:modelValue', index: string): void
|
|
36
|
+
}
|