hy-app 0.6.4 → 0.6.6
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/attributes.json +1 -1
- package/components/hy-address-picker/hy-address-picker.vue +249 -249
- package/components/hy-address-picker/props.ts +103 -103
- package/components/hy-button/hy-button.vue +320 -289
- package/components/hy-button/props.ts +143 -143
- package/components/hy-button/typing.d.ts +43 -35
- package/components/hy-calendar/header.vue +58 -58
- package/components/hy-calendar/hy-calendar.vue +8 -6
- package/components/hy-calendar/month.vue +402 -402
- package/components/hy-calendar/props.ts +169 -169
- package/components/hy-calendar/typing.d.ts +47 -45
- package/components/hy-cell-item/hy-cell-item.vue +161 -161
- package/components/hy-cell-item/props.ts +59 -59
- package/components/hy-check-button/hy-check-button.vue +135 -135
- package/components/hy-code-input/hy-code-input.vue +231 -231
- package/components/hy-code-input/props.ts +90 -90
- package/components/hy-config-provider/hy-config-provider.vue +53 -53
- package/components/hy-config-provider/props.ts +30 -30
- package/components/hy-coupon/hy-coupon.vue +183 -183
- package/components/hy-coupon/props.ts +108 -108
- package/components/hy-datetime-picker/hy-datetime-picker.vue +41 -55
- package/components/hy-datetime-picker/props.ts +144 -144
- package/components/hy-datetime-picker/typing.d.ts +2 -0
- package/components/hy-divider/props.ts +83 -83
- package/components/hy-empty/icon.ts +72 -72
- package/components/hy-folding-panel/hy-folding-panel-group.vue +162 -162
- package/components/hy-form/hy-form.vue +220 -220
- package/components/hy-icon/hy-icon.vue +112 -112
- package/components/hy-index-bar/hy-index-bar.vue +185 -185
- package/components/hy-index-bar/index.scss +64 -64
- package/components/hy-index-bar/props.ts +94 -94
- package/components/hy-index-bar/typing.d.ts +36 -36
- package/components/hy-input/hy-input.vue +333 -333
- package/components/hy-input/props.ts +186 -186
- package/components/hy-modal/hy-modal.vue +211 -211
- package/components/hy-modal/props.ts +94 -94
- package/components/hy-modal/typing.d.ts +16 -16
- package/components/hy-notice-bar/hy-row-notice.vue +121 -121
- package/components/hy-notify/hy-notify.vue +174 -174
- package/components/hy-number-step/hy-number-step.vue +367 -367
- package/components/hy-overlay/hy-overlay.vue +61 -61
- package/components/hy-overlay/props.ts +38 -38
- package/components/hy-pagination/hy-pagination.vue +136 -136
- package/components/hy-pagination/props.ts +58 -58
- package/components/hy-parse/hy-parse.vue +550 -550
- package/components/hy-parse/node/node.vue +781 -781
- package/components/hy-parse/parser.js +1455 -1455
- package/components/hy-parse/props.ts +19 -19
- package/components/hy-parse/typing.d.ts +68 -68
- package/components/hy-picker/hy-picker.vue +435 -435
- package/components/hy-picker/props.ts +122 -122
- package/components/hy-picker/typing.d.ts +38 -38
- package/components/hy-qrcode/props.ts +72 -72
- package/components/hy-qrcode/qrcode.js.bak +1433 -1433
- package/components/hy-radio/props.ts +97 -97
- package/components/hy-read-more/props.ts +48 -48
- package/components/hy-search/props.ts +133 -133
- package/components/hy-signature/canvasHelper.ts +51 -51
- package/components/hy-signature/props.ts +121 -121
- package/components/hy-skeleton/hy-skeleton.vue +142 -142
- package/components/hy-skeleton/props.ts +46 -46
- package/components/hy-skeleton/typing.d.ts +31 -31
- package/components/hy-steps/hy-steps.vue +275 -275
- package/components/hy-steps/typing.d.ts +25 -25
- package/components/hy-swiper/hy-swiper.vue +3 -3
- package/components/hy-swiper/index.scss +5 -5
- package/components/hy-swiper/props.ts +0 -1
- package/components/hy-table/hy-table.vue +630 -630
- package/components/hy-table/props.ts +62 -62
- package/components/hy-table/typing.d.ts +29 -29
- package/components/hy-tabs/hy-tabs.vue +336 -335
- package/components/hy-tabs/props.ts +84 -77
- package/components/hy-tag/hy-tag.vue +173 -173
- package/components/hy-tag/props.ts +89 -89
- package/components/hy-text/hy-text.vue +237 -237
- package/components/hy-text/props.ts +115 -115
- package/components/hy-textarea/hy-textarea.vue +198 -198
- package/components/hy-toast/hy-toast.vue +200 -200
- package/components/hy-toast/props.ts +3 -3
- package/components/hy-transition/hy-transition.vue +157 -157
- package/components/hy-transition/props.ts +32 -32
- package/components/hy-upload/hy-upload.vue +384 -384
- package/components/hy-watermark/hy-watermark.vue +1058 -1058
- package/components/hy-watermark/props.ts +109 -109
- package/global.d.ts +94 -94
- package/libs/api/http.ts +119 -119
- package/libs/composables/index.ts +8 -8
- package/libs/composables/useMessage.ts +149 -149
- package/libs/composables/useToast.ts +45 -45
- package/libs/composables/useTranslate.ts +10 -10
- package/libs/css/_config.scss +5 -5
- package/libs/index.ts +8 -8
- package/libs/locale/index.ts +32 -32
- package/libs/locale/lang/en-US.ts +84 -84
- package/libs/locale/lang/zh-CN.ts +87 -87
- package/libs/typing/index.ts +2 -2
- package/libs/typing/modules/common.d.ts +139 -139
- package/libs/typing/modules/form.ts +176 -176
- package/libs/typing/modules/http.d.ts +19 -19
- package/libs/typing/modules/index.d.ts +12 -12
- package/libs/utils/inside.ts +340 -340
- package/libs/utils/inspect.ts +140 -140
- package/libs/utils/utils.ts +525 -525
- package/package.json +81 -81
- package/tags.json +1 -1
- package/web-types.json +1 -1
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import { IconConfig } from '../../libs/config'
|
|
2
|
-
import type { CSSProperties, PropType } from 'vue'
|
|
3
|
-
import { useTranslate } from '../../libs'
|
|
4
|
-
|
|
5
|
-
const { t } = useTranslate('loadMore')
|
|
6
|
-
|
|
7
|
-
const dividerProps = {
|
|
8
|
-
/** 是否虚线 */
|
|
9
|
-
dashed: {
|
|
10
|
-
type: Boolean,
|
|
11
|
-
default: false
|
|
12
|
-
},
|
|
13
|
-
/** 是否细线 */
|
|
14
|
-
hairline: {
|
|
15
|
-
type: Boolean,
|
|
16
|
-
default: true
|
|
17
|
-
},
|
|
18
|
-
/** 是否以点替代文字,优先于text字段起作用 */
|
|
19
|
-
dot: {
|
|
20
|
-
type: Boolean,
|
|
21
|
-
default: false
|
|
22
|
-
},
|
|
23
|
-
/**
|
|
24
|
-
* 内容文本的位置
|
|
25
|
-
* @values left,center,right
|
|
26
|
-
* */
|
|
27
|
-
textPosition: {
|
|
28
|
-
type: String,
|
|
29
|
-
default: 'center'
|
|
30
|
-
},
|
|
31
|
-
/** 文本内容,如果为loadMore就是加载前,如果为loading就是加载中,如果为noMore就是没有更多 */
|
|
32
|
-
text: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: ''
|
|
35
|
-
},
|
|
36
|
-
/** 文本大小 */
|
|
37
|
-
textSize: {
|
|
38
|
-
type: [String, Number],
|
|
39
|
-
default: 14
|
|
40
|
-
},
|
|
41
|
-
/** 文本颜色 */
|
|
42
|
-
textColor: String,
|
|
43
|
-
/** 线条颜色 */
|
|
44
|
-
lineColor: String,
|
|
45
|
-
/** 加载图标 */
|
|
46
|
-
loadingIcon: {
|
|
47
|
-
type: String,
|
|
48
|
-
default: IconConfig.LOADING
|
|
49
|
-
},
|
|
50
|
-
/** 加载前的提示语 */
|
|
51
|
-
loadMoreText: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: () => t('loadMore')
|
|
54
|
-
},
|
|
55
|
-
/** 加载中提示语 */
|
|
56
|
-
loadingText: {
|
|
57
|
-
type: String,
|
|
58
|
-
default: () => t('loading')
|
|
59
|
-
},
|
|
60
|
-
/** 没有更多的提示语 */
|
|
61
|
-
noMoreText: {
|
|
62
|
-
type: String,
|
|
63
|
-
default: () => t('finished')
|
|
64
|
-
},
|
|
65
|
-
/** 上边距 */
|
|
66
|
-
marginTop: {
|
|
67
|
-
type: [String, Number],
|
|
68
|
-
default: 0
|
|
69
|
-
},
|
|
70
|
-
/** 下边距 */
|
|
71
|
-
marginBottom: {
|
|
72
|
-
type: [String, Number],
|
|
73
|
-
default: 0
|
|
74
|
-
},
|
|
75
|
-
/** 定义需要用到的外部样式 */
|
|
76
|
-
customStyle: {
|
|
77
|
-
type: Object as PropType<CSSProperties>
|
|
78
|
-
},
|
|
79
|
-
/** 自定义外部类名 */
|
|
80
|
-
customClass: String
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export default dividerProps
|
|
1
|
+
import { IconConfig } from '../../libs/config'
|
|
2
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
3
|
+
import { useTranslate } from '../../libs'
|
|
4
|
+
|
|
5
|
+
const { t } = useTranslate('loadMore')
|
|
6
|
+
|
|
7
|
+
const dividerProps = {
|
|
8
|
+
/** 是否虚线 */
|
|
9
|
+
dashed: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false
|
|
12
|
+
},
|
|
13
|
+
/** 是否细线 */
|
|
14
|
+
hairline: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: true
|
|
17
|
+
},
|
|
18
|
+
/** 是否以点替代文字,优先于text字段起作用 */
|
|
19
|
+
dot: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* 内容文本的位置
|
|
25
|
+
* @values left,center,right
|
|
26
|
+
* */
|
|
27
|
+
textPosition: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'center'
|
|
30
|
+
},
|
|
31
|
+
/** 文本内容,如果为loadMore就是加载前,如果为loading就是加载中,如果为noMore就是没有更多 */
|
|
32
|
+
text: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: ''
|
|
35
|
+
},
|
|
36
|
+
/** 文本大小 */
|
|
37
|
+
textSize: {
|
|
38
|
+
type: [String, Number],
|
|
39
|
+
default: 14
|
|
40
|
+
},
|
|
41
|
+
/** 文本颜色 */
|
|
42
|
+
textColor: String,
|
|
43
|
+
/** 线条颜色 */
|
|
44
|
+
lineColor: String,
|
|
45
|
+
/** 加载图标 */
|
|
46
|
+
loadingIcon: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: IconConfig.LOADING
|
|
49
|
+
},
|
|
50
|
+
/** 加载前的提示语 */
|
|
51
|
+
loadMoreText: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: () => t('loadMore')
|
|
54
|
+
},
|
|
55
|
+
/** 加载中提示语 */
|
|
56
|
+
loadingText: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: () => t('loading')
|
|
59
|
+
},
|
|
60
|
+
/** 没有更多的提示语 */
|
|
61
|
+
noMoreText: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: () => t('finished')
|
|
64
|
+
},
|
|
65
|
+
/** 上边距 */
|
|
66
|
+
marginTop: {
|
|
67
|
+
type: [String, Number],
|
|
68
|
+
default: 0
|
|
69
|
+
},
|
|
70
|
+
/** 下边距 */
|
|
71
|
+
marginBottom: {
|
|
72
|
+
type: [String, Number],
|
|
73
|
+
default: 0
|
|
74
|
+
},
|
|
75
|
+
/** 定义需要用到的外部样式 */
|
|
76
|
+
customStyle: {
|
|
77
|
+
type: Object as PropType<CSSProperties>
|
|
78
|
+
},
|
|
79
|
+
/** 自定义外部类名 */
|
|
80
|
+
customClass: String
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default dividerProps
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import type { IEmptyIcon } from './typing'
|
|
2
|
-
|
|
3
|
-
const url = 'https://pic.imgdd.cc/item/'
|
|
4
|
-
|
|
5
|
-
const emptyIcon: IEmptyIcon = {
|
|
6
|
-
content: {
|
|
7
|
-
desc: '暂无内容',
|
|
8
|
-
icon: url + '695f8d4ffa2f0e88008de857.png'
|
|
9
|
-
},
|
|
10
|
-
search: {
|
|
11
|
-
desc: '暂无搜索结果',
|
|
12
|
-
icon: url + '695f8d89fa2f0e88008debc3.png'
|
|
13
|
-
},
|
|
14
|
-
address: {
|
|
15
|
-
desc: '暂无收货地址',
|
|
16
|
-
icon: url + '695f8d4efa2f0e88008de847.png'
|
|
17
|
-
},
|
|
18
|
-
network: {
|
|
19
|
-
desc: '暂无网络',
|
|
20
|
-
icon: url + '695f8d6dfa2f0e88008dea15.png'
|
|
21
|
-
},
|
|
22
|
-
order: {
|
|
23
|
-
desc: '暂无订单',
|
|
24
|
-
icon: url + '695f8d89fa2f0e88008debbc.png'
|
|
25
|
-
},
|
|
26
|
-
coupon: {
|
|
27
|
-
desc: '暂无优惠券',
|
|
28
|
-
icon: url + '695f8d4efa2f0e88008de84b.png'
|
|
29
|
-
},
|
|
30
|
-
collect: {
|
|
31
|
-
desc: '暂无收藏',
|
|
32
|
-
icon: url + '695f8d4efa2f0e88008de846.png'
|
|
33
|
-
},
|
|
34
|
-
history: {
|
|
35
|
-
desc: '无历史记录',
|
|
36
|
-
icon: url + 'history.png'
|
|
37
|
-
},
|
|
38
|
-
message: {
|
|
39
|
-
desc: '暂无消息',
|
|
40
|
-
icon: url + '695f8d4efa2f0e88008de852.png'
|
|
41
|
-
},
|
|
42
|
-
comment: {
|
|
43
|
-
desc: '暂无评论',
|
|
44
|
-
icon: url + '695f8d6cfa2f0e88008dea09.png'
|
|
45
|
-
},
|
|
46
|
-
integral: {
|
|
47
|
-
desc: '暂无积分',
|
|
48
|
-
icon: url + '695f8d6dfa2f0e88008dea0d.png'
|
|
49
|
-
},
|
|
50
|
-
card: {
|
|
51
|
-
desc: '暂无银行卡',
|
|
52
|
-
icon: url + '695f8d4efa2f0e88008de851.png'
|
|
53
|
-
},
|
|
54
|
-
notification: {
|
|
55
|
-
desc: '暂无通知',
|
|
56
|
-
icon: url + '695f8d6dfa2f0e88008dea16.png'
|
|
57
|
-
},
|
|
58
|
-
shop: {
|
|
59
|
-
desc: '暂无购物车',
|
|
60
|
-
icon: url + '695f8d8afa2f0e88008debcb.png'
|
|
61
|
-
},
|
|
62
|
-
activity: {
|
|
63
|
-
desc: '暂无活动',
|
|
64
|
-
icon: url + '695f8f60fa2f0e88008e068c.png'
|
|
65
|
-
},
|
|
66
|
-
loading: {
|
|
67
|
-
desc: '加载中',
|
|
68
|
-
icon: url + '695f8d6dfa2f0e88008dea13.png'
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default emptyIcon
|
|
1
|
+
import type { IEmptyIcon } from './typing'
|
|
2
|
+
|
|
3
|
+
const url = 'https://pic.imgdd.cc/item/'
|
|
4
|
+
|
|
5
|
+
const emptyIcon: IEmptyIcon = {
|
|
6
|
+
content: {
|
|
7
|
+
desc: '暂无内容',
|
|
8
|
+
icon: url + '695f8d4ffa2f0e88008de857.png'
|
|
9
|
+
},
|
|
10
|
+
search: {
|
|
11
|
+
desc: '暂无搜索结果',
|
|
12
|
+
icon: url + '695f8d89fa2f0e88008debc3.png'
|
|
13
|
+
},
|
|
14
|
+
address: {
|
|
15
|
+
desc: '暂无收货地址',
|
|
16
|
+
icon: url + '695f8d4efa2f0e88008de847.png'
|
|
17
|
+
},
|
|
18
|
+
network: {
|
|
19
|
+
desc: '暂无网络',
|
|
20
|
+
icon: url + '695f8d6dfa2f0e88008dea15.png'
|
|
21
|
+
},
|
|
22
|
+
order: {
|
|
23
|
+
desc: '暂无订单',
|
|
24
|
+
icon: url + '695f8d89fa2f0e88008debbc.png'
|
|
25
|
+
},
|
|
26
|
+
coupon: {
|
|
27
|
+
desc: '暂无优惠券',
|
|
28
|
+
icon: url + '695f8d4efa2f0e88008de84b.png'
|
|
29
|
+
},
|
|
30
|
+
collect: {
|
|
31
|
+
desc: '暂无收藏',
|
|
32
|
+
icon: url + '695f8d4efa2f0e88008de846.png'
|
|
33
|
+
},
|
|
34
|
+
history: {
|
|
35
|
+
desc: '无历史记录',
|
|
36
|
+
icon: url + 'history.png'
|
|
37
|
+
},
|
|
38
|
+
message: {
|
|
39
|
+
desc: '暂无消息',
|
|
40
|
+
icon: url + '695f8d4efa2f0e88008de852.png'
|
|
41
|
+
},
|
|
42
|
+
comment: {
|
|
43
|
+
desc: '暂无评论',
|
|
44
|
+
icon: url + '695f8d6cfa2f0e88008dea09.png'
|
|
45
|
+
},
|
|
46
|
+
integral: {
|
|
47
|
+
desc: '暂无积分',
|
|
48
|
+
icon: url + '695f8d6dfa2f0e88008dea0d.png'
|
|
49
|
+
},
|
|
50
|
+
card: {
|
|
51
|
+
desc: '暂无银行卡',
|
|
52
|
+
icon: url + '695f8d4efa2f0e88008de851.png'
|
|
53
|
+
},
|
|
54
|
+
notification: {
|
|
55
|
+
desc: '暂无通知',
|
|
56
|
+
icon: url + '695f8d6dfa2f0e88008dea16.png'
|
|
57
|
+
},
|
|
58
|
+
shop: {
|
|
59
|
+
desc: '暂无购物车',
|
|
60
|
+
icon: url + '695f8d8afa2f0e88008debcb.png'
|
|
61
|
+
},
|
|
62
|
+
activity: {
|
|
63
|
+
desc: '暂无活动',
|
|
64
|
+
icon: url + '695f8f60fa2f0e88008e068c.png'
|
|
65
|
+
},
|
|
66
|
+
loading: {
|
|
67
|
+
desc: '加载中',
|
|
68
|
+
icon: url + '695f8d6dfa2f0e88008dea13.png'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default emptyIcon
|
|
@@ -1,163 +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
|
-
}
|
|
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
163
|
</style>
|