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
|
@@ -1,363 +1,277 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<text class="hy-tooltip__content--text" v-else>{{ text }}</text>
|
|
29
|
-
</view>
|
|
2
|
+
<view class="hy-tooltip">
|
|
3
|
+
<hy-overlay
|
|
4
|
+
:show="showTooltip && tooltipTop !== -10000 && overlay"
|
|
5
|
+
:customStyle="{ backgroundColor: 'rgba(0, 0, 0, 0)' }"
|
|
6
|
+
@click="closeHandler"
|
|
7
|
+
></hy-overlay>
|
|
8
|
+
<!-- 文本内容区域 -->
|
|
9
|
+
<view
|
|
10
|
+
:class="`hy-tooltip__content ${customClass}`"
|
|
11
|
+
id="target"
|
|
12
|
+
@longpress.stop="longPressHandler"
|
|
13
|
+
@tap.stop="clickHandler"
|
|
14
|
+
:style="[
|
|
15
|
+
{
|
|
16
|
+
color: color,
|
|
17
|
+
fontSize: addUnit(size),
|
|
18
|
+
fontWeight: bold ? 'bold' : '',
|
|
19
|
+
backgroundColor:
|
|
20
|
+
bgColor && showTooltip && tooltipTop !== -10000 ? bgColor : 'transparent'
|
|
21
|
+
},
|
|
22
|
+
customStyle
|
|
23
|
+
]"
|
|
24
|
+
>
|
|
25
|
+
<slot v-if="$slots.default"></slot>
|
|
26
|
+
<text class="hy-tooltip__content--text" v-else>{{ text }}</text>
|
|
27
|
+
</view>
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
29
|
+
<!-- 用于获取弹窗宽高 -->
|
|
30
|
+
<view class="hy-tooltip__popup hy-tooltip__hidden" id="pos">
|
|
31
|
+
<view class="hy-tooltip__container custom-pop">
|
|
32
|
+
<view class="hy-tooltip__container--list">
|
|
33
|
+
<view
|
|
34
|
+
v-if="showCopy"
|
|
35
|
+
class="hy-tooltip__container--list__btn"
|
|
36
|
+
hover-class="hy-tooltip__container--list__btn--hover"
|
|
37
|
+
@tap.stop="setClipboardData"
|
|
38
|
+
>
|
|
39
|
+
<text class="hy-tooltip__container--list__btn--text">复制</text>
|
|
40
|
+
</view>
|
|
41
|
+
<hy-line
|
|
42
|
+
direction="column"
|
|
43
|
+
color="#8d8e90"
|
|
44
|
+
v-if="showCopy && buttons.length > 0"
|
|
45
|
+
length="18"
|
|
46
|
+
></hy-line>
|
|
47
|
+
<template v-for="(item, index) in buttons" :key="index">
|
|
48
|
+
<view
|
|
49
|
+
class="hy-tooltip__container--list__btn"
|
|
50
|
+
hover-class="hy-tooltip__container--list__btn--hover"
|
|
51
|
+
>
|
|
52
|
+
<text
|
|
53
|
+
class="hy-tooltip__container--list__btn--text"
|
|
54
|
+
@tap="btnClickHandler(index)"
|
|
55
|
+
>
|
|
56
|
+
{{ item }}
|
|
57
|
+
</text>
|
|
58
|
+
</view>
|
|
59
|
+
<hy-line
|
|
60
|
+
direction="column"
|
|
61
|
+
color="#8d8e90"
|
|
62
|
+
v-if="index < buttons.length - 1"
|
|
63
|
+
length="18"
|
|
64
|
+
></hy-line>
|
|
65
|
+
</template>
|
|
66
|
+
</view>
|
|
60
67
|
</view>
|
|
61
|
-
<HyLine
|
|
62
|
-
direction="column"
|
|
63
|
-
color="#8d8e90"
|
|
64
|
-
v-if="index < buttons.length - 1"
|
|
65
|
-
length="18"
|
|
66
|
-
></HyLine>
|
|
67
|
-
</template>
|
|
68
68
|
</view>
|
|
69
|
-
</view>
|
|
70
|
-
</view>
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
70
|
+
<hy-transition
|
|
71
|
+
mode="fade"
|
|
72
|
+
:show="showTooltip"
|
|
73
|
+
:duration="300"
|
|
74
|
+
custom-class="hy-tooltip__popup"
|
|
75
|
+
:custom-style="{
|
|
76
|
+
...popover.popStyle.value,
|
|
77
|
+
zIndex: zIndex
|
|
78
|
+
}"
|
|
79
|
+
>
|
|
80
|
+
<view class="hy-tooltip__container">
|
|
81
|
+
<!-- 三角形 -->
|
|
82
|
+
<view
|
|
83
|
+
:class="`hy-tooltip__arrow ${popover.arrowClass.value}`"
|
|
84
|
+
:style="popover.arrowStyle.value"
|
|
85
|
+
></view>
|
|
86
|
+
<!-- 三角形 -->
|
|
89
87
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
88
|
+
<view class="hy-tooltip__container--list">
|
|
89
|
+
<view
|
|
90
|
+
v-if="showCopy"
|
|
91
|
+
class="hy-tooltip__container--list__btn"
|
|
92
|
+
hover-class="hy-tooltip__container--list__btn--hover"
|
|
93
|
+
@tap="setClipboardData"
|
|
94
|
+
>
|
|
95
|
+
<text class="hy-tooltip__container--list__btn--text">复制</text>
|
|
96
|
+
</view>
|
|
97
|
+
<hy-line
|
|
98
|
+
direction="column"
|
|
99
|
+
color="#8d8e90"
|
|
100
|
+
v-if="showCopy && buttons.length > 0"
|
|
101
|
+
length="18"
|
|
102
|
+
></hy-line>
|
|
103
|
+
<template v-for="(item, index) in buttons" :key="index">
|
|
104
|
+
<view
|
|
105
|
+
class="hy-tooltip__container--list__btn"
|
|
106
|
+
hover-class="hy-tooltip__container--list__btn--hover"
|
|
107
|
+
>
|
|
108
|
+
<text
|
|
109
|
+
class="hy-tooltip__container--list__btn--text"
|
|
110
|
+
@tap="btnClickHandler(index)"
|
|
111
|
+
>
|
|
112
|
+
{{ item }}
|
|
113
|
+
</text>
|
|
114
|
+
</view>
|
|
115
|
+
<hy-line
|
|
116
|
+
direction="column"
|
|
117
|
+
color="#8d8e90"
|
|
118
|
+
v-if="index < buttons.length - 1"
|
|
119
|
+
length="18"
|
|
120
|
+
></hy-line>
|
|
121
|
+
</template>
|
|
122
|
+
</view>
|
|
116
123
|
</view>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
color="#8d8e90"
|
|
120
|
-
v-if="index < buttons.length - 1"
|
|
121
|
-
length="18"
|
|
122
|
-
></HyLine>
|
|
123
|
-
</template>
|
|
124
|
-
</view>
|
|
125
|
-
</view>
|
|
126
|
-
</HyTransition>
|
|
127
|
-
</view>
|
|
124
|
+
</hy-transition>
|
|
125
|
+
</view>
|
|
128
126
|
</template>
|
|
129
127
|
|
|
130
128
|
<script lang="ts">
|
|
131
129
|
export default {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
130
|
+
name: 'hy-tooltip',
|
|
131
|
+
options: {
|
|
132
|
+
addGlobalClass: true,
|
|
133
|
+
virtualHost: true,
|
|
134
|
+
styleIsolation: 'shared'
|
|
135
|
+
}
|
|
136
|
+
}
|
|
139
137
|
</script>
|
|
140
138
|
|
|
141
139
|
<script setup lang="ts">
|
|
140
|
+
import { ref, onMounted, watch, inject, onBeforeUnmount, getCurrentInstance } from 'vue'
|
|
141
|
+
import type { ITooltipEmits } from './typing'
|
|
142
142
|
import {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
import
|
|
152
|
-
import type { IPlacementVo } from "../hy-popover/typing";
|
|
153
|
-
import {
|
|
154
|
-
type Queue,
|
|
155
|
-
queueKey,
|
|
156
|
-
usePopover,
|
|
157
|
-
closeOther,
|
|
158
|
-
removeFromQueue,
|
|
159
|
-
pushToQueue,
|
|
160
|
-
addUnit,
|
|
161
|
-
} from "../../libs";
|
|
143
|
+
type Queue,
|
|
144
|
+
queueKey,
|
|
145
|
+
usePopover,
|
|
146
|
+
closeOther,
|
|
147
|
+
removeFromQueue,
|
|
148
|
+
pushToQueue,
|
|
149
|
+
addUnit
|
|
150
|
+
} from '../../libs'
|
|
151
|
+
import tooltipProps from './props'
|
|
162
152
|
|
|
163
153
|
// 组件
|
|
164
|
-
import HyTransition from
|
|
165
|
-
import HyLine from
|
|
166
|
-
import HyOverlay from
|
|
154
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
155
|
+
import HyLine from '../hy-line/hy-line.vue'
|
|
156
|
+
import HyOverlay from '../hy-overlay/hy-overlay.vue'
|
|
167
157
|
|
|
168
158
|
/**
|
|
169
159
|
* Tooltip组件主要用于长按操作,类似微信的长按气泡
|
|
170
160
|
* @displayName hy-tooltip
|
|
171
161
|
*/
|
|
172
|
-
defineOptions({})
|
|
162
|
+
defineOptions({})
|
|
173
163
|
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
/** 需要显示的提示文字 */
|
|
177
|
-
text: {
|
|
178
|
-
type: String,
|
|
179
|
-
default: "",
|
|
180
|
-
},
|
|
181
|
-
/** 点击复制按钮时,复制的文本,为空则使用text值 */
|
|
182
|
-
copyText: {
|
|
183
|
-
type: String,
|
|
184
|
-
default: "",
|
|
185
|
-
},
|
|
186
|
-
/**
|
|
187
|
-
* 触发模式
|
|
188
|
-
* @values longpress,click
|
|
189
|
-
* */
|
|
190
|
-
triggerMode: {
|
|
191
|
-
type: String as PropType<"longpress" | "click">,
|
|
192
|
-
default: "longpress",
|
|
193
|
-
},
|
|
194
|
-
/**
|
|
195
|
-
* 指定 popover 的放置位置
|
|
196
|
-
* @values top,top-start,top-end,bottom,bottom-start,bottom-end,left,left-start,left-end,right,right-start,right-end
|
|
197
|
-
* */
|
|
198
|
-
placement: {
|
|
199
|
-
type: String as PropType<IPlacementVo>,
|
|
200
|
-
default: "bottom",
|
|
201
|
-
},
|
|
202
|
-
/** 文本大小 */
|
|
203
|
-
size: {
|
|
204
|
-
type: [String, Number],
|
|
205
|
-
default: 14,
|
|
206
|
-
},
|
|
207
|
-
/** 字体颜色 */
|
|
208
|
-
color: String,
|
|
209
|
-
/** 字体粗细 */
|
|
210
|
-
bold: {
|
|
211
|
-
type: Boolean,
|
|
212
|
-
default: false,
|
|
213
|
-
},
|
|
214
|
-
/** 弹出提示框时,文本的背景色 */
|
|
215
|
-
bgColor: {
|
|
216
|
-
type: String,
|
|
217
|
-
default: "transparent",
|
|
218
|
-
},
|
|
219
|
-
/** 弹出提示的z-index,nvue无效 */
|
|
220
|
-
zIndex: {
|
|
221
|
-
type: Number,
|
|
222
|
-
default: 10071,
|
|
223
|
-
},
|
|
224
|
-
/** 是否显示复制按钮 */
|
|
225
|
-
showCopy: {
|
|
226
|
-
type: Boolean,
|
|
227
|
-
default: true,
|
|
228
|
-
},
|
|
229
|
-
/** 扩展的按钮组 */
|
|
230
|
-
buttons: {
|
|
231
|
-
type: Array,
|
|
232
|
-
default() {
|
|
233
|
-
return [];
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
/** 是否显示透明遮罩以防止触摸穿透 */
|
|
237
|
-
overlay: {
|
|
238
|
-
type: Boolean,
|
|
239
|
-
default: true,
|
|
240
|
-
},
|
|
241
|
-
/** 是否显示提示 */
|
|
242
|
-
showToast: {
|
|
243
|
-
type: Boolean,
|
|
244
|
-
default: true,
|
|
245
|
-
},
|
|
246
|
-
/** 定义需要用到的外部样式 */
|
|
247
|
-
customStyle: Object as PropType<CSSProperties>,
|
|
248
|
-
/** 自定义外部类名 */
|
|
249
|
-
customClass: String,
|
|
250
|
-
});
|
|
251
|
-
const emit = defineEmits<ITooltipEmits>();
|
|
164
|
+
const props = defineProps(tooltipProps)
|
|
165
|
+
const emit = defineEmits<ITooltipEmits>()
|
|
252
166
|
|
|
253
|
-
const queue = inject<Queue | null>(queueKey, null)
|
|
254
|
-
const { proxy } = getCurrentInstance() as any
|
|
167
|
+
const queue = inject<Queue | null>(queueKey, null)
|
|
168
|
+
const { proxy } = getCurrentInstance() as any
|
|
255
169
|
// 显示三角标
|
|
256
|
-
const visibleArrow = ref<boolean>(true)
|
|
257
|
-
const popover = usePopover(visibleArrow.value)
|
|
258
|
-
const showTooltip = ref<boolean>(false)
|
|
259
|
-
const tooltipTop = ref<number>(-10000)
|
|
260
|
-
const selector: string =
|
|
170
|
+
const visibleArrow = ref<boolean>(true)
|
|
171
|
+
const popover = usePopover(visibleArrow.value)
|
|
172
|
+
const showTooltip = ref<boolean>(false)
|
|
173
|
+
const tooltipTop = ref<number>(-10000)
|
|
174
|
+
const selector: string = 'tooltip'
|
|
261
175
|
|
|
262
176
|
watch(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
)
|
|
177
|
+
() => props.placement,
|
|
178
|
+
() => {
|
|
179
|
+
popover.init(props.placement, visibleArrow.value, selector)
|
|
180
|
+
}
|
|
181
|
+
)
|
|
268
182
|
|
|
269
183
|
watch(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
184
|
+
() => showTooltip.value,
|
|
185
|
+
(newValue) => {
|
|
186
|
+
if (newValue) {
|
|
187
|
+
popover.control(props.placement, 0)
|
|
188
|
+
if (queue && queue.closeOther) {
|
|
189
|
+
queue.closeOther(proxy)
|
|
190
|
+
} else {
|
|
191
|
+
closeOther(proxy)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
279
194
|
}
|
|
280
|
-
|
|
281
|
-
);
|
|
195
|
+
)
|
|
282
196
|
|
|
283
197
|
onMounted(() => {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
})
|
|
198
|
+
// getElRect();
|
|
199
|
+
popover.init(props.placement, visibleArrow.value, selector)
|
|
200
|
+
})
|
|
287
201
|
|
|
288
202
|
function onBeforeMount(param: () => void) {}
|
|
289
203
|
|
|
290
204
|
onBeforeMount(() => {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
})
|
|
205
|
+
if (queue && queue.pushToQueue) {
|
|
206
|
+
queue.pushToQueue(proxy)
|
|
207
|
+
} else {
|
|
208
|
+
pushToQueue(proxy)
|
|
209
|
+
}
|
|
210
|
+
})
|
|
297
211
|
|
|
298
212
|
onBeforeUnmount(() => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
})
|
|
213
|
+
if (queue && queue.removeFromQueue) {
|
|
214
|
+
queue.removeFromQueue(proxy)
|
|
215
|
+
} else {
|
|
216
|
+
removeFromQueue(proxy)
|
|
217
|
+
}
|
|
218
|
+
})
|
|
305
219
|
|
|
306
220
|
// 长按触发事件
|
|
307
221
|
const longPressHandler = () => {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
222
|
+
if (props.triggerMode === 'longpress') {
|
|
223
|
+
tooltipTop.value = 0
|
|
224
|
+
showTooltip.value = true
|
|
225
|
+
}
|
|
226
|
+
}
|
|
313
227
|
|
|
314
228
|
// 点击触发事件
|
|
315
229
|
const clickHandler = () => {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
230
|
+
if (props.triggerMode === 'click') {
|
|
231
|
+
tooltipTop.value = 0
|
|
232
|
+
showTooltip.value = true
|
|
233
|
+
}
|
|
234
|
+
}
|
|
321
235
|
|
|
322
236
|
// 点击关闭
|
|
323
237
|
const closeHandler = () => {
|
|
324
|
-
|
|
325
|
-
}
|
|
238
|
+
showTooltip.value = false
|
|
239
|
+
}
|
|
326
240
|
|
|
327
241
|
// 点击操作栏按钮
|
|
328
242
|
const btnClickHandler = (index: number) => {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
243
|
+
showTooltip.value = false
|
|
244
|
+
// 如果需要展示复制按钮,此处index需要加1,因为复制按钮在第一个位置
|
|
245
|
+
emit('click', props.showCopy ? index + 1 : index)
|
|
246
|
+
}
|
|
333
247
|
|
|
334
248
|
// 复制文本到粘贴板
|
|
335
249
|
const setClipboardData = () => {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
250
|
+
// 关闭组件
|
|
251
|
+
showTooltip.value = false
|
|
252
|
+
emit('click', 0)
|
|
253
|
+
uni.setClipboardData({
|
|
254
|
+
// 优先使用copyText字段,如果没有,则默认使用text字段当做复制的内容
|
|
255
|
+
data: props.copyText || props.text,
|
|
256
|
+
success: () => {
|
|
257
|
+
props.showToast &&
|
|
258
|
+
uni.showToast({
|
|
259
|
+
title: '复制成功'
|
|
260
|
+
})
|
|
261
|
+
},
|
|
262
|
+
fail: () => {
|
|
263
|
+
props.showToast &&
|
|
264
|
+
uni.showToast({
|
|
265
|
+
title: '复制失败'
|
|
266
|
+
})
|
|
267
|
+
},
|
|
268
|
+
complete: () => {
|
|
269
|
+
showTooltip.value = false
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
}
|
|
359
273
|
</script>
|
|
360
274
|
|
|
361
275
|
<style lang="scss" scoped>
|
|
362
|
-
@import
|
|
276
|
+
@import './index.scss';
|
|
363
277
|
</style>
|