hy-app 0.4.13 → 0.5.0
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 +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
|
@@ -57,18 +57,14 @@
|
|
|
57
57
|
@include edeep(mask) {
|
|
58
58
|
background-image: none;
|
|
59
59
|
}
|
|
60
|
-
}
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
align-items: center;
|
|
71
|
-
background-color: rgba(255, 255, 255, 0.87);
|
|
72
|
-
z-index: 1000;
|
|
61
|
+
@include edeep(loading) {
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 0;
|
|
64
|
+
right: 0;
|
|
65
|
+
left: 0;
|
|
66
|
+
bottom: 0;
|
|
67
|
+
z-index: 1000;
|
|
68
|
+
}
|
|
73
69
|
}
|
|
74
70
|
}
|
|
@@ -1,28 +1,112 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { PickerColumnVo } from './typing'
|
|
2
|
+
import type HyInputProps from './typing'
|
|
3
|
+
import type { PropType } from 'vue'
|
|
2
4
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
const pickerProps = {
|
|
6
|
+
/** 显示到输入框值 */
|
|
7
|
+
modelValue: {
|
|
8
|
+
type: [String, Array],
|
|
9
|
+
default: ''
|
|
10
|
+
},
|
|
11
|
+
/** 是否显示弹窗 */
|
|
12
|
+
show: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false
|
|
15
|
+
},
|
|
16
|
+
/** 弹窗弹出模式 */
|
|
17
|
+
popupMode: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: 'bottom'
|
|
20
|
+
},
|
|
21
|
+
/** 分割数组条件 */
|
|
22
|
+
separator: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: '/'
|
|
25
|
+
},
|
|
26
|
+
/** 是否显示顶部的操作栏 */
|
|
27
|
+
showToolbar: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: true
|
|
30
|
+
},
|
|
31
|
+
/** 顶部标题 */
|
|
32
|
+
title: String,
|
|
33
|
+
/** 二维数组,设置每一列的数据 */
|
|
34
|
+
columns: {
|
|
35
|
+
type: Array as unknown as PropType<(string | PickerColumnVo)[][]>,
|
|
36
|
+
default: []
|
|
37
|
+
},
|
|
38
|
+
/** 是否显示加载中状态 */
|
|
39
|
+
loading: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
42
|
+
},
|
|
43
|
+
/** 各列中,单个选项的高度 */
|
|
44
|
+
itemHeight: {
|
|
45
|
+
type: Number,
|
|
46
|
+
default: 44
|
|
47
|
+
},
|
|
48
|
+
/** 取消按钮的文字 */
|
|
49
|
+
cancelText: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: '取消'
|
|
52
|
+
},
|
|
53
|
+
/** 确认按钮的文字 */
|
|
54
|
+
confirmText: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: '确定'
|
|
57
|
+
},
|
|
58
|
+
/** 取消按钮的颜色 */
|
|
59
|
+
cancelColor: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: '#909193'
|
|
62
|
+
},
|
|
63
|
+
/** 确认按钮的颜色 */
|
|
64
|
+
confirmColor: String,
|
|
65
|
+
/** 每列中可见选项的数量 */
|
|
66
|
+
visibleItemCount: {
|
|
67
|
+
type: Number,
|
|
68
|
+
default: 5
|
|
69
|
+
},
|
|
70
|
+
/** 显示到选项对象中,需要展示的属性键名 */
|
|
71
|
+
keyName: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: 'text'
|
|
74
|
+
},
|
|
75
|
+
/** 是否允许点击遮罩关闭选择器 */
|
|
76
|
+
closeOnClickOverlay: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: false
|
|
79
|
+
},
|
|
80
|
+
/** 各列的默认索引 */
|
|
81
|
+
defaultIndex: {
|
|
82
|
+
type: Array as PropType<number[]>,
|
|
83
|
+
default: []
|
|
84
|
+
},
|
|
85
|
+
/** 是否在手指松开时立即触发change事件 */
|
|
86
|
+
immediateChange: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: true
|
|
89
|
+
},
|
|
90
|
+
/** 最高层级 */
|
|
91
|
+
zIndex: {
|
|
92
|
+
type: Number,
|
|
93
|
+
default: 10076
|
|
94
|
+
},
|
|
95
|
+
/** 是否显示输入框 */
|
|
96
|
+
hasInput: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false
|
|
99
|
+
},
|
|
100
|
+
/** 输入框集合属性 */
|
|
101
|
+
input: {
|
|
102
|
+
type: Object as PropType<HyInputProps>,
|
|
103
|
+
default: () => {}
|
|
104
|
+
},
|
|
105
|
+
/** 是否自定义选择器nav左边内容 */
|
|
106
|
+
toolbarRightSlot: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: false
|
|
109
|
+
}
|
|
110
|
+
}
|
|
27
111
|
|
|
28
|
-
export default
|
|
112
|
+
export default pickerProps
|
|
@@ -1,258 +1,196 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
>
|
|
8
|
-
<!-- 使用插槽时无法获取正确宽高 -->
|
|
9
|
-
<view class="hy-popover__pos hy-popover__hidden" id="pos">
|
|
10
|
-
<view class="hy-popover__container">
|
|
11
|
-
<view
|
|
12
|
-
v-if="!slots.content && mode === 'normal'"
|
|
13
|
-
class="hy-popover__inner"
|
|
14
|
-
>
|
|
15
|
-
{{ content }}
|
|
16
|
-
</view>
|
|
17
|
-
<view
|
|
18
|
-
v-if="!slots.content && mode === 'menu' && isArray(content)"
|
|
19
|
-
class="hy-popover__menu"
|
|
20
|
-
>
|
|
21
|
-
<view
|
|
22
|
-
v-for="(item, index) in content"
|
|
23
|
-
:key="index"
|
|
24
|
-
class="hy-popover__menu-inner"
|
|
25
|
-
@click="menuClick(index)"
|
|
26
|
-
>
|
|
27
|
-
<hy-icon
|
|
28
|
-
v-if="item.iconClass"
|
|
29
|
-
:name="item.iconClass"
|
|
30
|
-
custom-class="hy-popover__icon"
|
|
31
|
-
/>
|
|
32
|
-
<text>{{ item.content }}</text>
|
|
33
|
-
</view>
|
|
34
|
-
</view>
|
|
35
|
-
</view>
|
|
36
|
-
</view>
|
|
37
|
-
|
|
38
|
-
<hy-transition
|
|
39
|
-
custom-class="hy-popover__pos"
|
|
40
|
-
:custom-style="popover.popStyle.value"
|
|
41
|
-
:show="showPopover"
|
|
42
|
-
:duration="200"
|
|
2
|
+
<view
|
|
3
|
+
:class="['hy-popover', customClass]"
|
|
4
|
+
:style="customStyle"
|
|
5
|
+
id="popover"
|
|
6
|
+
@click.stop="popover.noop"
|
|
43
7
|
>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
8
|
+
<!-- 使用插槽时无法获取正确宽高 -->
|
|
9
|
+
<view class="hy-popover__pos hy-popover__hidden" id="pos">
|
|
10
|
+
<view class="hy-popover__container">
|
|
11
|
+
<view v-if="!slots.content && mode === 'normal'" class="hy-popover__inner">
|
|
12
|
+
{{ content }}
|
|
13
|
+
</view>
|
|
14
|
+
<view
|
|
15
|
+
v-if="!slots.content && mode === 'menu' && isArray(content)"
|
|
16
|
+
class="hy-popover__menu"
|
|
17
|
+
>
|
|
18
|
+
<view
|
|
19
|
+
v-for="(item, index) in content"
|
|
20
|
+
:key="index"
|
|
21
|
+
class="hy-popover__menu-inner"
|
|
22
|
+
@click="menuClick(index)"
|
|
23
|
+
>
|
|
24
|
+
<hy-icon
|
|
25
|
+
v-if="item.iconClass"
|
|
26
|
+
:name="item.iconClass"
|
|
27
|
+
custom-class="hy-popover__icon"
|
|
28
|
+
/>
|
|
29
|
+
<text>{{ item.content }}</text>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
32
|
+
</view>
|
|
58
33
|
</view>
|
|
59
|
-
<!-- 普通模式 -->
|
|
60
34
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
35
|
+
<hy-transition
|
|
36
|
+
custom-class="hy-popover__pos"
|
|
37
|
+
:custom-style="popover.popStyle.value"
|
|
38
|
+
:show="showPopover"
|
|
39
|
+
:duration="200"
|
|
65
40
|
>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
41
|
+
<view class="hy-popover__container">
|
|
42
|
+
<!-- 三角形 -->
|
|
43
|
+
<view
|
|
44
|
+
:class="`hy-popover__arrow ${popover.arrowClass.value}`"
|
|
45
|
+
:style="popover.arrowStyle.value"
|
|
46
|
+
></view>
|
|
47
|
+
<!-- 三角形 -->
|
|
48
|
+
|
|
49
|
+
<!-- 普通模式 -->
|
|
50
|
+
<view v-if="!slots.content && mode === 'normal'" class="hy-popover__inner">
|
|
51
|
+
{{ content }}
|
|
52
|
+
</view>
|
|
53
|
+
<!-- 普通模式 -->
|
|
54
|
+
|
|
55
|
+
<!-- 列表模式 -->
|
|
56
|
+
<view
|
|
57
|
+
v-if="!slots.content && mode === 'menu' && isArray(content)"
|
|
58
|
+
class="hy-popover__menu"
|
|
59
|
+
>
|
|
60
|
+
<view
|
|
61
|
+
v-for="(item, index) in content"
|
|
62
|
+
:key="index"
|
|
63
|
+
class="hy-popover__menu-inner"
|
|
64
|
+
@click="menuClick(index)"
|
|
65
|
+
:style="index === 0 ? 'border-top: none' : ''"
|
|
66
|
+
>
|
|
67
|
+
<hy-icon
|
|
68
|
+
v-if="typeof item === 'object' && item.icon"
|
|
69
|
+
:name="item.icon"
|
|
70
|
+
custom-class="hy-popover__icon"
|
|
71
|
+
/>
|
|
72
|
+
<view style="display: inline-block">
|
|
73
|
+
{{ typeof item === 'object' && item.content ? item.content : item }}
|
|
74
|
+
</view>
|
|
75
|
+
</view>
|
|
76
|
+
</view>
|
|
77
|
+
<!-- 列表模式 -->
|
|
78
|
+
|
|
79
|
+
<!-- 用户自定义样式 -->
|
|
80
|
+
<slot name="content" v-else />
|
|
81
|
+
<!-- 用户自定义样式 -->
|
|
82
82
|
</view>
|
|
83
|
-
|
|
83
|
+
<hy-icon
|
|
84
|
+
v-if="showClose"
|
|
85
|
+
name="close"
|
|
86
|
+
custom-class="hy-popover__close-icon"
|
|
87
|
+
@click="toggle"
|
|
88
|
+
></hy-icon>
|
|
89
|
+
</hy-transition>
|
|
90
|
+
<view @click="toggle" class="hy-popover__target" id="target">
|
|
91
|
+
<slot />
|
|
84
92
|
</view>
|
|
85
|
-
<!-- 列表模式 -->
|
|
86
|
-
|
|
87
|
-
<!-- 用户自定义样式 -->
|
|
88
|
-
<slot name="content" v-else />
|
|
89
|
-
<!-- 用户自定义样式 -->
|
|
90
|
-
</view>
|
|
91
|
-
<hy-icon
|
|
92
|
-
v-if="showClose"
|
|
93
|
-
name="close"
|
|
94
|
-
custom-class="hy-popover__close-icon"
|
|
95
|
-
@click="toggle"
|
|
96
|
-
></hy-icon>
|
|
97
|
-
</hy-transition>
|
|
98
|
-
<view @click="toggle" class="hy-popover__target" id="target">
|
|
99
|
-
<slot />
|
|
100
93
|
</view>
|
|
101
|
-
</view>
|
|
102
94
|
</template>
|
|
103
95
|
|
|
104
96
|
<script lang="ts">
|
|
105
97
|
export default {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
98
|
+
name: 'hy-popover',
|
|
99
|
+
options: {
|
|
100
|
+
virtualHost: true,
|
|
101
|
+
addGlobalClass: true,
|
|
102
|
+
styleIsolation: 'shared'
|
|
103
|
+
}
|
|
104
|
+
}
|
|
113
105
|
</script>
|
|
114
106
|
|
|
115
107
|
<script lang="ts" setup>
|
|
116
108
|
import {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
} from
|
|
127
|
-
import type { PropType, CSSProperties } from "vue";
|
|
128
|
-
import type {
|
|
129
|
-
IOffset,
|
|
130
|
-
IPlacementVo,
|
|
131
|
-
IPopoverEmits,
|
|
132
|
-
PopoverExpose,
|
|
133
|
-
} from "./typing";
|
|
109
|
+
getCurrentInstance,
|
|
110
|
+
onBeforeMount,
|
|
111
|
+
onBeforeUnmount,
|
|
112
|
+
ref,
|
|
113
|
+
useSlots,
|
|
114
|
+
watch,
|
|
115
|
+
inject,
|
|
116
|
+
nextTick
|
|
117
|
+
} from 'vue'
|
|
118
|
+
import type { IPopoverEmits, PopoverExpose } from './typing'
|
|
134
119
|
import {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
} from
|
|
120
|
+
type Queue,
|
|
121
|
+
queueKey,
|
|
122
|
+
usePopover,
|
|
123
|
+
closeOther,
|
|
124
|
+
pushToQueue,
|
|
125
|
+
removeFromQueue,
|
|
126
|
+
isArray
|
|
127
|
+
} from '../../libs'
|
|
128
|
+
import popoverProps from './props'
|
|
143
129
|
// 组件
|
|
144
|
-
import HyIcon from
|
|
145
|
-
import HyTransition from
|
|
130
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
131
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
146
132
|
|
|
147
133
|
/**
|
|
148
134
|
* 常用于展示提示信息。
|
|
149
135
|
* @displayName hy-popover
|
|
150
136
|
*/
|
|
151
|
-
defineOptions({})
|
|
137
|
+
defineOptions({})
|
|
152
138
|
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
/** 控制 popover 的显示状态 */
|
|
156
|
-
modelValue: {
|
|
157
|
-
type: Boolean,
|
|
158
|
-
default: false,
|
|
159
|
-
},
|
|
160
|
-
/** 显示的内容,也可以通过 slot#content 传入 */
|
|
161
|
-
content: {
|
|
162
|
-
type: [String, Array] as PropType<string | any[]>,
|
|
163
|
-
},
|
|
164
|
-
/**
|
|
165
|
-
* 指定 popover 的放置位置
|
|
166
|
-
* @values top,top-start,top-end,bottom,bottom-start,bottom-end,left,left-start,left-end,right,right-start,right-end
|
|
167
|
-
* */
|
|
168
|
-
placement: {
|
|
169
|
-
type: String as PropType<IPlacementVo>,
|
|
170
|
-
default: "bottom",
|
|
171
|
-
},
|
|
172
|
-
/** 控制 popover 的显示状态 */
|
|
173
|
-
offset: {
|
|
174
|
-
type: [Number, Array, Object] as PropType<IOffset>,
|
|
175
|
-
default: 0,
|
|
176
|
-
},
|
|
177
|
-
/** 是否显示关闭按钮 */
|
|
178
|
-
showClose: {
|
|
179
|
-
type: Boolean,
|
|
180
|
-
default: false,
|
|
181
|
-
},
|
|
182
|
-
/** 是否禁用 popover */
|
|
183
|
-
disabled: {
|
|
184
|
-
type: Boolean,
|
|
185
|
-
default: false,
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* 当前显示的模式,决定内容的展现形式
|
|
189
|
-
* @values normal,menu
|
|
190
|
-
* */
|
|
191
|
-
mode: {
|
|
192
|
-
type: String,
|
|
193
|
-
default: "normal",
|
|
194
|
-
},
|
|
195
|
-
/** 定义需要用到的外部样式 */
|
|
196
|
-
customStyle: Object as PropType<CSSProperties>,
|
|
197
|
-
/** 自定义外部类名 */
|
|
198
|
-
customClass: String,
|
|
199
|
-
});
|
|
200
|
-
const emit = defineEmits<IPopoverEmits>();
|
|
139
|
+
const props = defineProps(popoverProps)
|
|
140
|
+
const emit = defineEmits<IPopoverEmits>()
|
|
201
141
|
|
|
202
|
-
const slots = useSlots()
|
|
203
|
-
const queue = inject<Queue | null>(queueKey, null)
|
|
204
|
-
const selector: string =
|
|
205
|
-
const visibleArrow = ref<boolean>(true)
|
|
206
|
-
const { proxy } = getCurrentInstance() as any
|
|
207
|
-
const popover = usePopover()
|
|
208
|
-
const showPopover = ref<boolean>(false)
|
|
142
|
+
const slots = useSlots()
|
|
143
|
+
const queue = inject<Queue | null>(queueKey, null)
|
|
144
|
+
const selector: string = 'popover'
|
|
145
|
+
const visibleArrow = ref<boolean>(true)
|
|
146
|
+
const { proxy } = getCurrentInstance() as any
|
|
147
|
+
const popover = usePopover()
|
|
148
|
+
const showPopover = ref<boolean>(false) // 控制popover显隐
|
|
209
149
|
|
|
210
150
|
watch(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
151
|
+
() => props.content,
|
|
152
|
+
(newVal) => {
|
|
153
|
+
if (props.mode === 'normal' && typeof newVal !== 'string') {
|
|
154
|
+
console.error('在“normal”模式下,值类型必须为字符串类型。')
|
|
155
|
+
} else if (props.mode === 'menu' && !isArray(newVal)) {
|
|
156
|
+
console.error('在“menu”模式下,值类型必须是数组类型。')
|
|
157
|
+
}
|
|
217
158
|
}
|
|
218
|
-
|
|
219
|
-
);
|
|
159
|
+
)
|
|
220
160
|
|
|
221
161
|
watch(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
)
|
|
162
|
+
() => props.placement,
|
|
163
|
+
(newVal) => {
|
|
164
|
+
nextTick(() => {
|
|
165
|
+
popover.init(newVal, visibleArrow.value, selector)
|
|
166
|
+
})
|
|
167
|
+
},
|
|
168
|
+
{ immediate: true }
|
|
169
|
+
)
|
|
230
170
|
|
|
231
171
|
watch(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
)
|
|
172
|
+
() => props.modelValue,
|
|
173
|
+
(newValue: boolean) => {
|
|
174
|
+
showPopover.value = newValue
|
|
175
|
+
}
|
|
176
|
+
)
|
|
237
177
|
|
|
238
178
|
watch(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
179
|
+
() => showPopover.value,
|
|
180
|
+
(newValue) => {
|
|
181
|
+
if (newValue) {
|
|
182
|
+
popover.control(props.placement, props.offset)
|
|
183
|
+
if (queue && queue.closeOther) {
|
|
184
|
+
queue.closeOther(proxy)
|
|
185
|
+
} else {
|
|
186
|
+
closeOther(proxy)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
popover.showStyle.value = newValue ? 'display: inline-block;' : 'display: none;'
|
|
190
|
+
emit('change', { show: newValue })
|
|
191
|
+
emit(`${newValue ? 'open' : 'close'}`)
|
|
248
192
|
}
|
|
249
|
-
|
|
250
|
-
? "display: inline-block;"
|
|
251
|
-
: "display: none;";
|
|
252
|
-
emit("change", { show: newValue });
|
|
253
|
-
emit(`${newValue ? "open" : "close"}`);
|
|
254
|
-
},
|
|
255
|
-
);
|
|
193
|
+
)
|
|
256
194
|
|
|
257
195
|
// onMounted(() => {
|
|
258
196
|
// setTimeout(() => {
|
|
@@ -261,53 +199,53 @@ watch(
|
|
|
261
199
|
// });
|
|
262
200
|
|
|
263
201
|
onBeforeMount(() => {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
})
|
|
202
|
+
if (queue && queue.pushToQueue) {
|
|
203
|
+
queue.pushToQueue(proxy)
|
|
204
|
+
} else {
|
|
205
|
+
pushToQueue(proxy)
|
|
206
|
+
}
|
|
207
|
+
popover.showStyle.value = showPopover.value ? 'opacity: 1;' : 'opacity: 0;'
|
|
208
|
+
})
|
|
271
209
|
|
|
272
210
|
onBeforeUnmount(() => {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
})
|
|
211
|
+
if (queue && queue.removeFromQueue) {
|
|
212
|
+
queue.removeFromQueue(proxy)
|
|
213
|
+
} else {
|
|
214
|
+
removeFromQueue(proxy)
|
|
215
|
+
}
|
|
216
|
+
})
|
|
279
217
|
|
|
280
218
|
const menuClick = (index: number) => {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
219
|
+
updateModelValue(false)
|
|
220
|
+
emit('menuClick', {
|
|
221
|
+
item: isArray(props.content) ? props.content[index] : props.content,
|
|
222
|
+
index
|
|
223
|
+
})
|
|
224
|
+
}
|
|
287
225
|
|
|
288
226
|
const toggle = () => {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
227
|
+
if (props.disabled) return
|
|
228
|
+
updateModelValue(!showPopover.value)
|
|
229
|
+
}
|
|
292
230
|
|
|
293
231
|
const open = () => {
|
|
294
|
-
|
|
295
|
-
}
|
|
232
|
+
updateModelValue(true)
|
|
233
|
+
}
|
|
296
234
|
|
|
297
235
|
const close = () => {
|
|
298
|
-
|
|
299
|
-
}
|
|
236
|
+
updateModelValue(false)
|
|
237
|
+
}
|
|
300
238
|
|
|
301
239
|
function updateModelValue(value: boolean) {
|
|
302
|
-
|
|
303
|
-
|
|
240
|
+
showPopover.value = value
|
|
241
|
+
emit('update:modelValue', value)
|
|
304
242
|
}
|
|
305
243
|
|
|
306
244
|
defineExpose<PopoverExpose>({
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
})
|
|
245
|
+
open,
|
|
246
|
+
close
|
|
247
|
+
})
|
|
310
248
|
</script>
|
|
311
249
|
<style lang="scss" scoped>
|
|
312
|
-
@import
|
|
250
|
+
@import './index.scss';
|
|
313
251
|
</style>
|