hy-app 0.2.14 → 0.2.15
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-action-sheet/hy-action-sheet.vue +81 -13
- package/components/hy-action-sheet/typing.d.ts +1 -3
- package/components/hy-address-picker/hy-address-picker.vue +109 -8
- package/components/hy-address-picker/index.scss +2 -2
- package/components/hy-address-picker/typing.d.ts +39 -30
- package/components/hy-avatar/hy-avatar.vue +78 -4
- package/components/hy-avatar/typing.d.ts +21 -16
- package/components/hy-back-top/hy-back-top.vue +86 -28
- package/components/hy-back-top/typing.d.ts +17 -12
- package/components/hy-badge/hy-badge.vue +114 -43
- package/components/hy-badge/typing.d.ts +20 -15
- package/components/hy-button/hy-button.vue +22 -40
- package/components/hy-calendar/hy-calendar.vue +290 -143
- package/components/hy-calendar/typing.d.ts +38 -31
- package/components/hy-card/hy-card.vue +139 -36
- package/components/hy-card/typing.d.ts +39 -28
- package/components/hy-cell/hy-cell.vue +131 -67
- package/components/hy-cell/typing.d.ts +6 -1
- package/components/hy-check-button/hy-check-button.vue +101 -32
- package/components/hy-check-button/typing.d.ts +26 -19
- package/components/hy-checkbox/hy-checkbox.vue +167 -78
- package/components/hy-checkbox/typing.d.ts +26 -19
- package/components/hy-code-input/hy-code-input.vue +101 -5
- package/components/hy-code-input/typing.d.ts +9 -0
- package/components/hy-config-provider/hy-config-provider.vue +44 -24
- package/components/hy-config-provider/typing.d.ts +0 -4
- package/components/hy-count-down/hy-count-down.vue +99 -62
- package/components/hy-count-down/typing.d.ts +18 -5
- package/components/hy-count-to/hy-count-to.vue +165 -113
- package/components/hy-count-to/typing.d.ts +15 -11
- package/components/hy-datetime-picker/hy-datetime-picker.vue +338 -232
- package/components/hy-datetime-picker/typing.d.ts +49 -39
- package/components/hy-divider/hy-divider.vue +128 -64
- package/components/hy-divider/typing.d.ts +16 -16
- package/components/hy-dropdown/hy-dropdown.vue +57 -19
- package/components/hy-dropdown/typing.d.ts +14 -14
- package/components/hy-dropdown-item/hy-dropdown-item.vue +34 -5
- package/components/hy-dropdown-item/typing.d.ts +13 -6
- package/components/hy-empty/hy-empty.vue +64 -6
- package/components/hy-empty/typing.d.ts +5 -0
- package/components/hy-float-button/hy-float-button.vue +117 -5
- package/components/hy-float-button/typing.d.ts +7 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +87 -25
- package/components/hy-folding-panel/typing.d.ts +24 -15
- package/components/hy-grid/hy-grid.vue +95 -35
- package/components/hy-grid/typing.d.ts +24 -19
- package/components/hy-icon/hy-icon.vue +84 -6
- package/components/hy-icon/typing.d.ts +5 -0
- package/components/hy-image/hy-image.vue +105 -6
- package/components/hy-image/typing.d.ts +9 -0
- package/components/hy-input/hy-input.vue +277 -130
- package/components/hy-input/props.ts +13 -14
- package/components/hy-input/typing.d.ts +59 -38
- package/components/hy-line/hy-line.vue +65 -25
- package/components/hy-line-progress/hy-line-progress.vue +68 -35
- package/components/hy-list/hy-list.vue +127 -61
- package/components/hy-list/typing.d.ts +19 -12
- package/components/hy-loading/hy-loading.vue +79 -25
- package/components/hy-menu/hy-menu.vue +69 -45
- package/components/hy-menu/typing.d.ts +22 -15
- package/components/hy-modal/hy-modal.vue +91 -4
- package/components/hy-modal/typing.d.ts +11 -0
- package/components/hy-navbar/hy-navbar.vue +105 -25
- package/components/hy-navbar/typing.d.ts +25 -20
- package/components/hy-notice-bar/hy-notice-bar.vue +97 -19
- package/components/hy-notice-bar/typing.d.ts +22 -17
- package/components/hy-notify/hy-notify.vue +106 -54
- package/components/hy-number-step/hy-number-step.vue +211 -120
- package/components/hy-number-step/typing.d.ts +45 -28
- package/components/hy-overlay/hy-overlay.vue +60 -16
- package/components/hy-overlay/typing.d.ts +11 -6
- package/components/hy-pagination/hy-pagination.vue +94 -37
- package/components/hy-pagination/typing.d.ts +20 -11
- package/components/hy-picker/hy-picker.vue +225 -160
- package/components/hy-picker/typing.d.ts +51 -28
- package/components/hy-popover/hy-popover.vue +55 -7
- package/components/hy-popover/typing.d.ts +21 -1
- package/components/hy-popup/hy-popup.vue +164 -99
- package/components/hy-popup/typing.d.ts +11 -0
- package/components/hy-price/hy-price.vue +77 -30
- package/components/hy-price/typing.d.ts +10 -10
- package/components/hy-qrcode/hy-qrcode.vue +75 -5
- package/components/hy-qrcode/typing.d.ts +25 -16
- package/components/hy-radio/hy-radio.vue +169 -88
- package/components/hy-radio/typing.d.ts +29 -22
- package/components/hy-rate/hy-rate.vue +155 -104
- package/components/hy-rate/typing.d.ts +23 -16
- package/components/hy-read-more/hy-read-more.vue +83 -56
- package/components/hy-read-more/typing.d.ts +18 -11
- package/components/hy-scroll-list/hy-scroll-list.vue +69 -58
- package/components/hy-scroll-list/typing.d.ts +14 -7
- package/components/hy-search/hy-search.vue +168 -62
- package/components/hy-search/typing.d.ts +47 -26
- package/components/hy-signature/hy-signature.vue +354 -272
- package/components/hy-signature/typing.d.ts +65 -52
- package/components/hy-slider/hy-slider.vue +208 -160
- package/components/hy-slider/typing.d.ts +28 -17
- package/components/hy-steps/hy-steps.vue +125 -99
- package/components/hy-steps/typing.d.ts +21 -14
- package/components/hy-submit-bar/hy-submit-bar.vue +129 -48
- package/components/hy-submit-bar/typing.d.ts +30 -23
- package/components/hy-subsection/hy-subsection.vue +139 -96
- package/components/hy-subsection/typing.d.ts +23 -16
- package/components/hy-swipe-action/hy-swipe-action.vue +161 -135
- package/components/hy-swipe-action/typing.d.ts +26 -17
- package/components/hy-swiper/hy-swiper.vue +178 -73
- package/components/hy-swiper/typing.d.ts +37 -28
- package/components/hy-switch/hy-switch.vue +107 -60
- package/components/hy-switch/typing.d.ts +25 -18
- package/components/hy-tabs/hy-tabs.vue +170 -160
- package/components/hy-tabs/typing.d.ts +36 -22
- package/components/hy-tag/hy-tag.vue +133 -58
- package/components/hy-tag/typing.d.ts +26 -18
- package/components/hy-text/hy-text.vue +106 -6
- package/components/hy-text/typing.d.ts +31 -26
- package/components/hy-textarea/hy-textarea.vue +183 -89
- package/components/hy-textarea/typing.d.ts +41 -24
- package/components/hy-tooltip/hy-tooltip.vue +145 -101
- package/components/hy-tooltip/typing.d.ts +18 -13
- package/components/hy-transition/hy-transition.vue +48 -13
- package/components/hy-transition/typing.d.ts +17 -0
- package/components/hy-upload/hy-upload.vue +113 -148
- package/components/hy-upload/typing.d.ts +71 -71
- package/components/hy-warn/hy-warn.vue +79 -36
- package/components/hy-warn/typing.d.ts +18 -11
- package/components/hy-waterfall/hy-waterfall.vue +90 -77
- package/components/hy-watermark/hy-watermark.vue +82 -5
- package/components/hy-watermark/typing.d.ts +20 -20
- package/global.d.ts +39 -59
- package/package.json +3 -13
- package/utils/inspect.ts +3 -1
- package/web-types.json +1 -1
- package/compiler.ts +0 -108
- package/component-helper.ts +0 -179
- package/components.json +0 -3287
- package/docgen.config.js +0 -13
- package/web-types.config.js +0 -7
|
@@ -1,88 +1,95 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
2
|
-
import type BadgeProps from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
|
+
import type BadgeProps from '../hy-badge/props'
|
|
3
3
|
|
|
4
|
-
interface IconMenus {
|
|
4
|
+
export interface IconMenus {
|
|
5
5
|
/**
|
|
6
6
|
* @description icon图标
|
|
7
7
|
* */
|
|
8
|
-
icon: string
|
|
8
|
+
icon: string
|
|
9
9
|
/**
|
|
10
10
|
* @description 文本
|
|
11
11
|
* */
|
|
12
|
-
text: string
|
|
12
|
+
text: string
|
|
13
13
|
/**
|
|
14
14
|
* @description 徽标值
|
|
15
15
|
* */
|
|
16
|
-
badge?: BadgeProps[
|
|
16
|
+
badge?: BadgeProps['badge']
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export default interface HySubmitBarProps {
|
|
20
20
|
/**
|
|
21
21
|
* @description 左边菜单栏
|
|
22
22
|
* */
|
|
23
|
-
menus?: IconMenus[]
|
|
23
|
+
menus?: IconMenus[]
|
|
24
24
|
/**
|
|
25
25
|
* @description 绝对定位
|
|
26
26
|
* */
|
|
27
|
-
fixed?: boolean
|
|
27
|
+
fixed?: boolean
|
|
28
28
|
/**
|
|
29
29
|
* @description 是否显示边框
|
|
30
30
|
* */
|
|
31
|
-
border?: boolean
|
|
31
|
+
border?: boolean
|
|
32
32
|
/**
|
|
33
33
|
* @description 加载左边按钮loading
|
|
34
34
|
* */
|
|
35
|
-
leftLoading?: boolean
|
|
35
|
+
leftLoading?: boolean
|
|
36
36
|
/**
|
|
37
37
|
* @description 加载右边按钮loading
|
|
38
38
|
* */
|
|
39
|
-
rightLoading?: boolean
|
|
39
|
+
rightLoading?: boolean
|
|
40
40
|
/**
|
|
41
41
|
* @description 左边icon的颜色
|
|
42
42
|
* */
|
|
43
|
-
iconColor?: string
|
|
43
|
+
iconColor?: string
|
|
44
44
|
/**
|
|
45
45
|
* @description 左边文字的颜色
|
|
46
46
|
* */
|
|
47
|
-
iconLabelColor?: string
|
|
47
|
+
iconLabelColor?: string
|
|
48
48
|
/**
|
|
49
49
|
* @description 右边按钮文字颜色
|
|
50
50
|
* */
|
|
51
|
-
textColor?: string
|
|
51
|
+
textColor?: string
|
|
52
52
|
/**
|
|
53
53
|
* @description 显示左边按钮
|
|
54
54
|
* */
|
|
55
|
-
showLeftBtn?: boolean
|
|
55
|
+
showLeftBtn?: boolean
|
|
56
56
|
/**
|
|
57
57
|
* @description 显示右边按钮
|
|
58
58
|
* */
|
|
59
|
-
showRightBtn?: boolean
|
|
59
|
+
showRightBtn?: boolean
|
|
60
60
|
/**
|
|
61
61
|
* @description 左边按钮文字
|
|
62
62
|
* */
|
|
63
|
-
leftBtnText?: string
|
|
63
|
+
leftBtnText?: string
|
|
64
64
|
/**
|
|
65
65
|
* @description 右边按钮文字
|
|
66
66
|
* */
|
|
67
|
-
rightBtnText?: string
|
|
67
|
+
rightBtnText?: string
|
|
68
68
|
/**
|
|
69
69
|
* @description 左边按钮颜色,支持渐变色
|
|
70
70
|
* */
|
|
71
|
-
leftBtnColor?: string
|
|
71
|
+
leftBtnColor?: string
|
|
72
72
|
/**
|
|
73
73
|
* @description 有边按钮颜色,支持渐变色
|
|
74
74
|
* */
|
|
75
|
-
rightBtnColor?: string
|
|
75
|
+
rightBtnColor?: string
|
|
76
76
|
/**
|
|
77
77
|
* @description 按钮的形状
|
|
78
78
|
* */
|
|
79
|
-
shape?: HyApp.ShapeType
|
|
79
|
+
shape?: HyApp.ShapeType
|
|
80
80
|
/**
|
|
81
81
|
* @description 按钮点击等待时长(运用了节流方法)
|
|
82
82
|
* */
|
|
83
|
-
warn?: number
|
|
83
|
+
warn?: number
|
|
84
84
|
/**
|
|
85
85
|
* @description 定义需要用到的外部样式
|
|
86
86
|
* */
|
|
87
|
-
customStyle?: CSSProperties
|
|
87
|
+
customStyle?: CSSProperties
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface ISubmitBarEmits {
|
|
91
|
+
/** 点击按钮触发 */
|
|
92
|
+
(e: 'click', index: number): void
|
|
93
|
+
/** 点击左侧小菜单图标触发 */
|
|
94
|
+
(e: 'menuClick', index: number): void
|
|
88
95
|
}
|
|
@@ -13,33 +13,85 @@
|
|
|
13
13
|
v-for="(item, index) in list"
|
|
14
14
|
:key="index"
|
|
15
15
|
>
|
|
16
|
-
<text class="hy-subsection__item__text" :style="[textStyle(index)]">{{
|
|
17
|
-
getName(item)
|
|
18
|
-
}}</text>
|
|
16
|
+
<text class="hy-subsection__item__text" :style="[textStyle(index)]">{{ getName(item) }}</text>
|
|
19
17
|
</view>
|
|
20
18
|
</view>
|
|
21
19
|
</template>
|
|
22
20
|
|
|
23
21
|
<script lang="ts">
|
|
22
|
+
/**
|
|
23
|
+
* 该分段器一般用于用户从几个选项中选择某一个的场景
|
|
24
|
+
* @displayName hy-subsection
|
|
25
|
+
*/
|
|
26
|
+
defineOptions({})
|
|
24
27
|
export default {
|
|
25
|
-
name:
|
|
28
|
+
name: 'hy-subsection',
|
|
26
29
|
options: {
|
|
27
30
|
addGlobalClass: true,
|
|
28
31
|
virtualHost: true,
|
|
29
|
-
styleIsolation:
|
|
32
|
+
styleIsolation: 'shared',
|
|
30
33
|
},
|
|
31
|
-
}
|
|
34
|
+
}
|
|
32
35
|
</script>
|
|
33
36
|
|
|
34
37
|
<script setup lang="ts">
|
|
35
|
-
import { computed, toRefs, ref, onMounted, getCurrentInstance } from
|
|
36
|
-
import type { CSSProperties } from
|
|
37
|
-
import
|
|
38
|
-
import type
|
|
39
|
-
import
|
|
40
|
-
import { addUnit, getRect, guid } from "../../utils";
|
|
38
|
+
import { computed, toRefs, ref, onMounted, getCurrentInstance } from 'vue'
|
|
39
|
+
import type { CSSProperties } from 'vue'
|
|
40
|
+
import type { ISubsectionEmits } from './typing'
|
|
41
|
+
import type { SubSectionVo } from './typing'
|
|
42
|
+
import { addUnit, getRect, guid } from '../../utils'
|
|
41
43
|
|
|
42
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
44
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
45
|
+
const props = defineProps({
|
|
46
|
+
/** 接收值 */
|
|
47
|
+
modelValue: String,
|
|
48
|
+
/** 默认值 */
|
|
49
|
+
current: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 0,
|
|
52
|
+
},
|
|
53
|
+
/** tab的数据 */
|
|
54
|
+
list: {
|
|
55
|
+
type: Array,
|
|
56
|
+
default() {
|
|
57
|
+
return []
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
/** list的键值 */
|
|
61
|
+
customKeys: {
|
|
62
|
+
type: Object,
|
|
63
|
+
default() {
|
|
64
|
+
return {
|
|
65
|
+
name: 'name',
|
|
66
|
+
value: 'value',
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
/** 激活时的颜色 */
|
|
71
|
+
activeColor: String,
|
|
72
|
+
/** 未激活时的颜色 */
|
|
73
|
+
inactiveColor: String,
|
|
74
|
+
/**
|
|
75
|
+
* 模式选择,mode=button为按钮形式,mode=subsection时为分段模式
|
|
76
|
+
* @values button,subsection
|
|
77
|
+
* */
|
|
78
|
+
mode: {
|
|
79
|
+
type: String,
|
|
80
|
+
default: 'button',
|
|
81
|
+
},
|
|
82
|
+
/** 字体大小,单位px */
|
|
83
|
+
fontSize: {
|
|
84
|
+
type: Number,
|
|
85
|
+
default: 12,
|
|
86
|
+
},
|
|
87
|
+
/** 激活选项的字体是否加粗 */
|
|
88
|
+
bold: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: true,
|
|
91
|
+
},
|
|
92
|
+
/** 组件背景颜色,mode为button时有效 */
|
|
93
|
+
bgColor: String,
|
|
94
|
+
})
|
|
43
95
|
const {
|
|
44
96
|
modelValue,
|
|
45
97
|
current,
|
|
@@ -51,159 +103,150 @@ const {
|
|
|
51
103
|
bgColor,
|
|
52
104
|
inactiveColor,
|
|
53
105
|
customKeys,
|
|
54
|
-
} = toRefs(props)
|
|
55
|
-
const emit = defineEmits(
|
|
106
|
+
} = toRefs(props)
|
|
107
|
+
const emit = defineEmits<ISubsectionEmits>()
|
|
56
108
|
|
|
57
|
-
const instance = getCurrentInstance()
|
|
109
|
+
const instance = getCurrentInstance()
|
|
58
110
|
// 组件尺寸
|
|
59
111
|
const itemRect = ref<UniApp.NodeInfo>({
|
|
60
112
|
width: 0,
|
|
61
113
|
height: 0,
|
|
62
|
-
})
|
|
63
|
-
const innerCurrent = ref<number>(0)
|
|
64
|
-
const guidClass = guid()
|
|
114
|
+
})
|
|
115
|
+
const innerCurrent = ref<number>(0)
|
|
116
|
+
const guidClass = guid()
|
|
65
117
|
|
|
66
118
|
/**
|
|
67
119
|
* @description 容器样式
|
|
68
120
|
* */
|
|
69
121
|
const wrapperStyle = computed<CSSProperties>(() => {
|
|
70
|
-
const style: CSSProperties = {}
|
|
122
|
+
const style: CSSProperties = {}
|
|
71
123
|
// button模式时,设置背景色
|
|
72
|
-
if (mode.value ===
|
|
73
|
-
style.backgroundColor = bgColor.value
|
|
124
|
+
if (mode.value === 'button') {
|
|
125
|
+
style.backgroundColor = bgColor.value
|
|
74
126
|
}
|
|
75
|
-
return style
|
|
76
|
-
})
|
|
127
|
+
return style
|
|
128
|
+
})
|
|
77
129
|
/**
|
|
78
130
|
* @description 容器类名
|
|
79
131
|
* */
|
|
80
132
|
const wrapperClass = computed(() => {
|
|
81
133
|
return (index: number) => {
|
|
82
134
|
return [
|
|
83
|
-
|
|
84
|
-
|
|
135
|
+
'hy-subsection__item',
|
|
136
|
+
'cursor-pointer',
|
|
85
137
|
`hy-subsection__item--${innerCurrent.value}__${guidClass}`,
|
|
86
138
|
`hy-subsection__item--${mode.value}`,
|
|
87
|
-
index < list.value.length - 1 &&
|
|
88
|
-
index === 0 &&
|
|
89
|
-
index === list.value.length - 1 &&
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
})
|
|
139
|
+
index < list.value.length - 1 && 'hy-subsection__item--no-border-right',
|
|
140
|
+
index === 0 && 'hy-subsection__item--first',
|
|
141
|
+
index === list.value.length - 1 && 'hy-subsection__item--last',
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
})
|
|
93
145
|
/**
|
|
94
146
|
* @description 滑块的样式
|
|
95
147
|
* */
|
|
96
148
|
const barStyle = computed<CSSProperties>(() => {
|
|
97
|
-
const style: CSSProperties = {}
|
|
98
|
-
style.width = `${itemRect.value.width}px
|
|
99
|
-
style.height = `${itemRect.value.height}px
|
|
149
|
+
const style: CSSProperties = {}
|
|
150
|
+
style.width = `${itemRect.value.width}px`
|
|
151
|
+
style.height = `${itemRect.value.height}px`
|
|
100
152
|
// 通过translateX移动滑块,其移动的距离为索引*item的宽度
|
|
101
|
-
style.transform = `translateX(${
|
|
102
|
-
|
|
103
|
-
}px)`;
|
|
104
|
-
if (mode.value === "subsection") {
|
|
153
|
+
style.transform = `translateX(${innerCurrent.value * itemRect.value.width!}px)`
|
|
154
|
+
if (mode.value === 'subsection') {
|
|
105
155
|
// 在subsection模式下,需要动态设置滑块的圆角,因为移动滑块使用的是translateX,无法通过父元素设置overflow: hidden隐藏滑块的直角
|
|
106
|
-
style.backgroundColor = activeColor.value
|
|
156
|
+
style.backgroundColor = activeColor.value
|
|
107
157
|
}
|
|
108
|
-
return style
|
|
109
|
-
})
|
|
158
|
+
return style
|
|
159
|
+
})
|
|
110
160
|
/**
|
|
111
161
|
* @description 滑块的类目
|
|
112
162
|
* */
|
|
113
163
|
const barClass = computed(() => {
|
|
114
|
-
let className: string[] = [
|
|
164
|
+
let className: string[] = ['hy-subsection__bar', 'cursor-pointer']
|
|
115
165
|
const className_2 = [
|
|
116
|
-
mode.value ===
|
|
117
|
-
innerCurrent.value === 0 &&
|
|
118
|
-
mode.value === "subsection" &&
|
|
119
|
-
"hy-subsection__bar--first",
|
|
166
|
+
mode.value === 'button' && 'hy-subsection--button__bar',
|
|
167
|
+
innerCurrent.value === 0 && mode.value === 'subsection' && 'hy-subsection__bar--first',
|
|
120
168
|
innerCurrent.value > 0 &&
|
|
121
169
|
innerCurrent.value < list.value.length - 1 &&
|
|
122
|
-
mode.value ===
|
|
123
|
-
|
|
170
|
+
mode.value === 'subsection' &&
|
|
171
|
+
'hy-subsection__bar--center',
|
|
124
172
|
innerCurrent.value === list.value.length - 1 &&
|
|
125
|
-
mode.value ===
|
|
126
|
-
|
|
127
|
-
].filter(Boolean) as string[]
|
|
128
|
-
className = className.concat(className_2)
|
|
173
|
+
mode.value === 'subsection' &&
|
|
174
|
+
'hy-subsection__bar--last',
|
|
175
|
+
].filter(Boolean) as string[]
|
|
176
|
+
className = className.concat(className_2)
|
|
129
177
|
|
|
130
|
-
return className
|
|
131
|
-
})
|
|
178
|
+
return className
|
|
179
|
+
})
|
|
132
180
|
/**
|
|
133
181
|
* @description 分段器item的样式
|
|
134
182
|
* */
|
|
135
183
|
const itemStyle = computed<CSSProperties>(() => {
|
|
136
|
-
const style: CSSProperties = {}
|
|
137
|
-
if (mode.value ===
|
|
184
|
+
const style: CSSProperties = {}
|
|
185
|
+
if (mode.value === 'subsection') {
|
|
138
186
|
// 设置border的样式
|
|
139
|
-
style.borderColor = activeColor.value
|
|
140
|
-
style.borderWidth =
|
|
141
|
-
style.borderStyle =
|
|
187
|
+
style.borderColor = activeColor.value
|
|
188
|
+
style.borderWidth = '1px'
|
|
189
|
+
style.borderStyle = 'solid'
|
|
142
190
|
}
|
|
143
|
-
return style
|
|
144
|
-
})
|
|
191
|
+
return style
|
|
192
|
+
})
|
|
145
193
|
/**
|
|
146
194
|
* @description 分段器文字颜色
|
|
147
195
|
* */
|
|
148
196
|
const textStyle = computed(() => {
|
|
149
197
|
return (index: number): CSSProperties => {
|
|
150
|
-
const style: CSSProperties = {}
|
|
151
|
-
style.fontWeight =
|
|
152
|
-
|
|
153
|
-
style.fontSize = addUnit(fontSize.value);
|
|
198
|
+
const style: CSSProperties = {}
|
|
199
|
+
style.fontWeight = bold.value && innerCurrent.value === index ? 'bold' : 'normal'
|
|
200
|
+
style.fontSize = addUnit(fontSize.value)
|
|
154
201
|
// subsection模式下,激活时默认为白色的文字
|
|
155
|
-
if (mode.value ===
|
|
156
|
-
style.color = innerCurrent.value === index ?
|
|
202
|
+
if (mode.value === 'subsection') {
|
|
203
|
+
style.color = innerCurrent.value === index ? '#fff' : inactiveColor.value
|
|
157
204
|
} else {
|
|
158
205
|
// button模式下,激活时文字颜色默认为activeColor
|
|
159
|
-
style.color =
|
|
160
|
-
innerCurrent.value === index ? activeColor.value : inactiveColor.value;
|
|
206
|
+
style.color = innerCurrent.value === index ? activeColor.value : inactiveColor.value
|
|
161
207
|
}
|
|
162
|
-
return style
|
|
163
|
-
}
|
|
164
|
-
})
|
|
208
|
+
return style
|
|
209
|
+
}
|
|
210
|
+
})
|
|
165
211
|
|
|
166
212
|
onMounted(() => {
|
|
167
|
-
init()
|
|
168
|
-
})
|
|
213
|
+
init()
|
|
214
|
+
})
|
|
169
215
|
|
|
170
216
|
/**
|
|
171
217
|
* @description 初始化
|
|
172
218
|
* */
|
|
173
219
|
const init = () => {
|
|
174
220
|
innerCurrent.value = list.value.findIndex((item: SubSectionVo) => {
|
|
175
|
-
if (typeof item ===
|
|
176
|
-
return item === modelValue.value
|
|
221
|
+
if (typeof item === 'string' || typeof item === 'number') {
|
|
222
|
+
return item === modelValue.value
|
|
177
223
|
} else {
|
|
178
|
-
return item[customKeys.value.value] === modelValue.value
|
|
224
|
+
return item[customKeys.value.value] === modelValue.value
|
|
179
225
|
}
|
|
180
|
-
})
|
|
226
|
+
})
|
|
181
227
|
|
|
182
228
|
// 设置默认值当没有找的时候导致样式问题
|
|
183
|
-
innerCurrent.value =
|
|
184
|
-
innerCurrent.value === -1 ? current.value : innerCurrent.value;
|
|
229
|
+
innerCurrent.value = innerCurrent.value === -1 ? current.value : innerCurrent.value
|
|
185
230
|
|
|
186
231
|
// TODO: 多个数组在一起计算宽度, 宽度不一样会有问题,所以必须加guidClass随机数
|
|
187
|
-
getRect(`.hy-subsection__item--0__${guidClass}`, false, instance).then(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
);
|
|
192
|
-
};
|
|
232
|
+
getRect(`.hy-subsection__item--0__${guidClass}`, false, instance).then((size) => {
|
|
233
|
+
itemRect.value = size as UniApp.NodeInfo
|
|
234
|
+
})
|
|
235
|
+
}
|
|
193
236
|
|
|
194
237
|
/**
|
|
195
238
|
* @description 判断值
|
|
196
239
|
* */
|
|
197
240
|
const getValue = (item: SubSectionVo) => {
|
|
198
|
-
return typeof item ===
|
|
199
|
-
}
|
|
241
|
+
return typeof item === 'object' ? item[customKeys.value.value] : item
|
|
242
|
+
}
|
|
200
243
|
|
|
201
244
|
/**
|
|
202
245
|
* @description 判断展示文本
|
|
203
246
|
* */
|
|
204
247
|
const getName = (item: SubSectionVo) => {
|
|
205
|
-
return typeof item ===
|
|
206
|
-
}
|
|
248
|
+
return typeof item === 'object' ? item[customKeys.value.name] : item
|
|
249
|
+
}
|
|
207
250
|
|
|
208
251
|
/**
|
|
209
252
|
* @description 点击事件
|
|
@@ -211,13 +254,13 @@ const getName = (item: SubSectionVo) => {
|
|
|
211
254
|
const clickHandler = (temp: SubSectionVo, index: number) => {
|
|
212
255
|
// 值改变才触发
|
|
213
256
|
if (innerCurrent.value !== index) {
|
|
214
|
-
emit(
|
|
215
|
-
emit(
|
|
257
|
+
emit('change', index)
|
|
258
|
+
emit('update:modelValue', getValue(temp))
|
|
216
259
|
}
|
|
217
|
-
innerCurrent.value = index
|
|
218
|
-
}
|
|
260
|
+
innerCurrent.value = index
|
|
261
|
+
}
|
|
219
262
|
</script>
|
|
220
263
|
|
|
221
264
|
<style lang="scss" scoped>
|
|
222
|
-
@import
|
|
265
|
+
@import './index.scss';
|
|
223
266
|
</style>
|
|
@@ -1,56 +1,63 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
2
|
-
import { HyApp } from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
|
+
import { HyApp } from '@/package/typing/modules/common'
|
|
3
3
|
|
|
4
4
|
export interface SubSectionItemVo extends HyApp.FieldNamesType {
|
|
5
|
-
name: string
|
|
6
|
-
value: string | number
|
|
5
|
+
name: string
|
|
6
|
+
value: string | number
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export type SubSectionVo = string | number | SubSectionItemVo
|
|
9
|
+
export type SubSectionVo = string | number | SubSectionItemVo
|
|
10
10
|
|
|
11
11
|
export default interface HySubsectionProps {
|
|
12
12
|
/**
|
|
13
13
|
* @description 接收值
|
|
14
14
|
* */
|
|
15
|
-
modelValue: string | number
|
|
15
|
+
modelValue: string | number
|
|
16
16
|
/**
|
|
17
17
|
* @description 默认值 (默认0)
|
|
18
18
|
* */
|
|
19
|
-
current?: number
|
|
19
|
+
current?: number
|
|
20
20
|
/**
|
|
21
21
|
* @description tab的数据
|
|
22
22
|
* */
|
|
23
|
-
list: SubSectionVo[]
|
|
23
|
+
list: SubSectionVo[]
|
|
24
24
|
/**
|
|
25
25
|
* @description list的键值
|
|
26
26
|
* */
|
|
27
|
-
customKeys?: HyApp.IFieldNames
|
|
27
|
+
customKeys?: HyApp.IFieldNames
|
|
28
28
|
/**
|
|
29
29
|
* @description 激活时的颜色(默认 '#3c9cff' )
|
|
30
30
|
* */
|
|
31
|
-
activeColor?: string
|
|
31
|
+
activeColor?: string
|
|
32
32
|
/**
|
|
33
33
|
* @description 未激活时的颜色(默认 '#303133' )
|
|
34
34
|
* */
|
|
35
|
-
inactiveColor?: string
|
|
35
|
+
inactiveColor?: string
|
|
36
36
|
/**
|
|
37
37
|
* @description 模式选择,mode=button为按钮形式,mode=subsection时为分段模式(默认 'button' )
|
|
38
38
|
* */
|
|
39
|
-
mode?:
|
|
39
|
+
mode?: 'button' | 'subsection'
|
|
40
40
|
/**
|
|
41
41
|
* @description 字体大小,单位px(默认 12 )
|
|
42
42
|
* */
|
|
43
|
-
fontSize?: number | string
|
|
43
|
+
fontSize?: number | string
|
|
44
44
|
/**
|
|
45
45
|
* @description 激活选项的字体是否加粗(默认 true )
|
|
46
46
|
* */
|
|
47
|
-
bold?: boolean
|
|
47
|
+
bold?: boolean
|
|
48
48
|
/**
|
|
49
49
|
* @description 组件背景颜色,mode为button时有效(默认 '#eeeeef' )
|
|
50
50
|
* */
|
|
51
|
-
bgColor?: string
|
|
51
|
+
bgColor?: string
|
|
52
52
|
/**
|
|
53
53
|
* @description 定义需要用到的外部样式
|
|
54
54
|
* */
|
|
55
|
-
customStyle?: CSSProperties
|
|
55
|
+
customStyle?: CSSProperties
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ISubsectionEmits {
|
|
59
|
+
/** 改变触发 */
|
|
60
|
+
(e: 'change', index: number): void
|
|
61
|
+
/** 改变触发 */
|
|
62
|
+
(e: 'update:modelValue', value: any): void
|
|
56
63
|
}
|