hy-app 0.2.13 → 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/HyButton.docgen.js +6 -0
- package/components/hy-button/hy-button.vue +70 -77
- package/components/hy-button/props.ts +40 -41
- 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 +5 -13
- package/utils/inspect.ts +3 -1
- package/web-types.json +1 -1
- package/component-helper.ts +0 -177
- package/components.json +0 -3287
- package/dist/attributes.json +0 -1
- package/dist/docs/components/hy-action-sheet/hy-action-sheet.md +0 -41
- package/dist/docs/components/hy-address-picker/hy-address-picker.md +0 -25
- package/dist/docs/components/hy-avatar/hy-avatar.md +0 -19
- package/dist/docs/components/hy-back-top/hy-back-top.md +0 -19
- package/dist/docs/components/hy-badge/hy-badge.md +0 -13
- package/dist/docs/components/hy-button/hy-button.md +0 -61
- package/dist/docs/components/hy-calendar/header.md +0 -17
- package/dist/docs/components/hy-calendar/hy-calendar.md +0 -27
- package/dist/docs/components/hy-calendar/month.md +0 -38
- package/dist/docs/components/hy-card/hy-card.md +0 -24
- package/dist/docs/components/hy-cell/hy-cell.md +0 -26
- package/dist/docs/components/hy-check-button/hy-check-button.md +0 -14
- package/dist/docs/components/hy-checkbox/hy-checkbox.md +0 -21
- package/dist/docs/components/hy-code-input/hy-code-input.md +0 -15
- package/dist/docs/components/hy-config-provider/hy-config-provider.md +0 -13
- package/dist/docs/components/hy-count-down/hy-count-down.md +0 -34
- package/dist/docs/components/hy-count-to/hy-count-to.md +0 -31
- package/dist/docs/components/hy-datetime-picker/hy-datetime-picker.md +0 -25
- package/dist/docs/components/hy-divider/hy-divider.md +0 -13
- package/dist/docs/components/hy-dropdown/hy-dropdown.md +0 -13
- package/dist/docs/components/hy-dropdown-item/hy-dropdown-item.md +0 -20
- package/dist/docs/components/hy-empty/hy-empty.md +0 -20
- package/dist/docs/components/hy-float-button/hy-float-button.md +0 -20
- package/dist/docs/components/hy-folding-panel/hy-folding-panel.md +0 -24
- package/dist/docs/components/hy-form/hy-form.md +0 -29
- package/dist/docs/components/hy-grid/hy-grid.md +0 -19
- package/dist/docs/components/hy-icon/hy-icon.md +0 -13
- package/dist/docs/components/hy-image/hy-image.md +0 -22
- package/dist/docs/components/hy-input/hy-input.md +0 -29
- package/dist/docs/components/hy-line/hy-line.md +0 -7
- package/dist/docs/components/hy-line-progress/hy-line-progress.md +0 -13
- package/dist/docs/components/hy-list/hy-list.md +0 -25
- package/dist/docs/components/hy-loading/hy-loading.md +0 -14
- package/dist/docs/components/hy-login/ThePhoneLogin.md +0 -20
- package/dist/docs/components/hy-login/TheUserLogin.md +0 -44
- package/dist/docs/components/hy-login/hy-login.md +0 -14
- package/dist/docs/components/hy-menu/hy-menu.md +0 -21
- package/dist/docs/components/hy-modal/hy-modal.md +0 -23
- package/dist/docs/components/hy-navbar/hy-navbar.md +0 -22
- package/dist/docs/components/hy-notice-bar/hy-column-notice.md +0 -20
- package/dist/docs/components/hy-notice-bar/hy-notice-bar.md +0 -14
- package/dist/docs/components/hy-notice-bar/hy-row-notice.md +0 -20
- package/dist/docs/components/hy-notify/hy-notify.md +0 -23
- package/dist/docs/components/hy-number-step/hy-number-step.md +0 -27
- package/dist/docs/components/hy-overlay/hy-overlay.md +0 -19
- package/dist/docs/components/hy-pagination/hy-pagination.md +0 -14
- package/dist/docs/components/hy-parse/hy-parse.md +0 -46
- package/dist/docs/components/hy-parse/node/node.md +0 -7
- package/dist/docs/components/hy-picker/hy-picker.md +0 -32
- package/dist/docs/components/hy-popover/hy-popover.md +0 -34
- package/dist/docs/components/hy-popup/hy-popup.md +0 -22
- package/dist/docs/components/hy-price/hy-price.md +0 -13
- package/dist/docs/components/hy-qrcode/hy-qrcode.md +0 -15
- package/dist/docs/components/hy-radio/hy-radio.md +0 -21
- package/dist/docs/components/hy-rate/hy-rate.md +0 -14
- package/dist/docs/components/hy-read-more/hy-read-more.md +0 -21
- package/dist/docs/components/hy-scroll-list/hy-scroll-list.md +0 -21
- package/dist/docs/components/hy-search/hy-search.md +0 -27
- package/dist/docs/components/hy-signature/hy-signature.md +0 -45
- package/dist/docs/components/hy-slider/hy-slider.md +0 -24
- package/dist/docs/components/hy-status-bar/hy-status-bar.md +0 -13
- package/dist/docs/components/hy-steps/hy-steps.md +0 -23
- package/dist/docs/components/hy-submit-bar/hy-submit-bar.md +0 -21
- package/dist/docs/components/hy-subsection/hy-subsection.md +0 -14
- package/dist/docs/components/hy-swipe-action/hy-swipe-action.md +0 -29
- package/dist/docs/components/hy-swiper/hy-swiper-indicator.md +0 -23
- package/dist/docs/components/hy-swiper/hy-swiper.md +0 -22
- package/dist/docs/components/hy-switch/hy-switch.md +0 -20
- package/dist/docs/components/hy-tabBar/hy-tabBar.md +0 -13
- package/dist/docs/components/hy-tabs/hy-tabs.md +0 -27
- package/dist/docs/components/hy-tag/hy-tag.md +0 -21
- package/dist/docs/components/hy-text/hy-text.md +0 -13
- package/dist/docs/components/hy-textarea/hy-textarea.md +0 -19
- package/dist/docs/components/hy-toast/hy-toast.md +0 -17
- package/dist/docs/components/hy-tooltip/hy-tooltip.md +0 -13
- package/dist/docs/components/hy-transition/hy-transition.md +0 -25
- package/dist/docs/components/hy-upload/hy-upload.md +0 -25
- package/dist/docs/components/hy-warn/hy-warn.md +0 -14
- package/dist/docs/components/hy-waterfall/hy-waterfall.md +0 -30
- package/dist/docs/components/hy-watermark/hy-watermark.md +0 -7
- package/dist/docs/components/message/TheMessage.md +0 -17
- package/dist/docs/components/yk-dialog/yk-dialog.md +0 -7
- package/dist/tags.json +0 -1
- package/dist/web-types.json +0 -1
- package/docgen.config.js +0 -14
- package/web-types.config.js +0 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="hy-tooltip" :style="customStyle">
|
|
2
|
+
<view :class="['hy-tooltip', customClass]" :style="customStyle">
|
|
3
3
|
<HyOverlay
|
|
4
4
|
:show="showTooltip && tooltipTop !== -10000 && overlay"
|
|
5
5
|
:customStyle="{ backgroundColor: 'rgba(0, 0, 0, 0)' }"
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
:style="{
|
|
17
17
|
color: color,
|
|
18
18
|
backgroundColor:
|
|
19
|
-
bgColor && showTooltip && tooltipTop !== -10000
|
|
20
|
-
? bgColor
|
|
21
|
-
: 'transparent',
|
|
19
|
+
bgColor && showTooltip && tooltipTop !== -10000 ? bgColor : 'transparent',
|
|
22
20
|
}"
|
|
23
|
-
>{{ text }}</text
|
|
24
21
|
>
|
|
22
|
+
{{ text }}
|
|
23
|
+
</text>
|
|
25
24
|
<HyTransition
|
|
26
25
|
mode="fade"
|
|
27
26
|
:show="showTooltip"
|
|
@@ -33,11 +32,7 @@
|
|
|
33
32
|
...tooltipStyle,
|
|
34
33
|
}"
|
|
35
34
|
>
|
|
36
|
-
<view
|
|
37
|
-
class="hy-tooltip__wrapper__popup"
|
|
38
|
-
:id="tooltipId"
|
|
39
|
-
:ref="tooltipId"
|
|
40
|
-
>
|
|
35
|
+
<view class="hy-tooltip__wrapper__popup" :id="tooltipId" :ref="tooltipId">
|
|
41
36
|
<view
|
|
42
37
|
v-if="showCopy || buttons.length"
|
|
43
38
|
class="hy-tooltip__wrapper__popup__indicator"
|
|
@@ -59,9 +54,7 @@
|
|
|
59
54
|
hover-class="hy-tooltip__wrapper__popup__list__btn--hover"
|
|
60
55
|
@tap="setClipboardData"
|
|
61
56
|
>
|
|
62
|
-
<text class="hy-tooltip__wrapper__popup__list__btn__text"
|
|
63
|
-
>复制</text
|
|
64
|
-
>
|
|
57
|
+
<text class="hy-tooltip__wrapper__popup__list__btn__text">复制</text>
|
|
65
58
|
</view>
|
|
66
59
|
<HyLine
|
|
67
60
|
direction="column"
|
|
@@ -77,8 +70,9 @@
|
|
|
77
70
|
<text
|
|
78
71
|
class="hy-tooltip__wrapper__popup__list__btn__text"
|
|
79
72
|
@tap="btnClickHandler(index)"
|
|
80
|
-
>{{ item }}</text
|
|
81
73
|
>
|
|
74
|
+
{{ item }}
|
|
75
|
+
</text>
|
|
82
76
|
</view>
|
|
83
77
|
<HyLine
|
|
84
78
|
direction="column"
|
|
@@ -95,13 +89,18 @@
|
|
|
95
89
|
</template>
|
|
96
90
|
|
|
97
91
|
<script lang="ts">
|
|
92
|
+
/**
|
|
93
|
+
* Tooltip组件主要用于长按操作,类似微信的长按气泡
|
|
94
|
+
* @displayName hy-tooltip
|
|
95
|
+
*/
|
|
96
|
+
defineOptions({})
|
|
98
97
|
export default {
|
|
99
98
|
name: 'hy-tooltip',
|
|
100
99
|
options: {
|
|
101
100
|
addGlobalClass: true,
|
|
102
101
|
virtualHost: true,
|
|
103
|
-
styleIsolation: 'shared'
|
|
104
|
-
}
|
|
102
|
+
styleIsolation: 'shared',
|
|
103
|
+
},
|
|
105
104
|
}
|
|
106
105
|
</script>
|
|
107
106
|
|
|
@@ -111,180 +110,225 @@ import {
|
|
|
111
110
|
type CSSProperties,
|
|
112
111
|
toRefs,
|
|
113
112
|
ref,
|
|
114
|
-
onMounted,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
import {
|
|
113
|
+
onMounted,
|
|
114
|
+
getCurrentInstance,
|
|
115
|
+
type PropType,
|
|
116
|
+
} from 'vue'
|
|
117
|
+
import type { ITooltipEmits } from './typing'
|
|
118
|
+
import { addUnit, getRect, guid, sleep } from '../../utils'
|
|
119
119
|
|
|
120
120
|
// 组件
|
|
121
|
-
import HyOverlay from
|
|
122
|
-
import HyTransition from
|
|
123
|
-
import HyLine from
|
|
121
|
+
import HyOverlay from '../hy-overlay/hy-overlay.vue'
|
|
122
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
123
|
+
import HyLine from '../hy-line/hy-line.vue'
|
|
124
124
|
|
|
125
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
126
|
+
const props = defineProps({
|
|
127
|
+
/** 需要显示的提示文字 */
|
|
128
|
+
text: String,
|
|
129
|
+
/** 点击复制按钮时,复制的文本,为空则使用text值 */
|
|
130
|
+
copyText: String,
|
|
131
|
+
/** 文本大小 */
|
|
132
|
+
size: {
|
|
133
|
+
type: [String, Number],
|
|
134
|
+
default: 14,
|
|
135
|
+
},
|
|
136
|
+
/** 字体颜色 */
|
|
137
|
+
color: String,
|
|
138
|
+
/** 弹出提示框时,文本的背景色 */
|
|
139
|
+
bgColor: {
|
|
140
|
+
type: String,
|
|
141
|
+
default: 'transparent',
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* 弹出提示的方向
|
|
145
|
+
* @values top,bottom
|
|
146
|
+
* */
|
|
147
|
+
direction: {
|
|
148
|
+
type: String,
|
|
149
|
+
default: 'top',
|
|
150
|
+
},
|
|
151
|
+
/** 弹出提示的z-index,nvue无效 */
|
|
152
|
+
zIndex: {
|
|
153
|
+
type: Number,
|
|
154
|
+
default: 10071,
|
|
155
|
+
},
|
|
156
|
+
/** 是否显示复制按钮 */
|
|
157
|
+
showCopy: {
|
|
158
|
+
type: Boolean,
|
|
159
|
+
default: true,
|
|
160
|
+
},
|
|
161
|
+
/** 扩展的按钮组 */
|
|
162
|
+
buttons: {
|
|
163
|
+
type: Array,
|
|
164
|
+
default() {
|
|
165
|
+
return []
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
/** 是否显示透明遮罩以防止触摸穿透 */
|
|
169
|
+
overlay: {
|
|
170
|
+
type: Boolean,
|
|
171
|
+
default: true,
|
|
172
|
+
},
|
|
173
|
+
/** 是否显示遮罩 */
|
|
174
|
+
showToast: {
|
|
175
|
+
type: Boolean,
|
|
176
|
+
default: true,
|
|
177
|
+
},
|
|
178
|
+
/** 定义需要用到的外部样式 */
|
|
179
|
+
customStyle: Object as PropType<CSSProperties>,
|
|
180
|
+
/** 自定义外部类名 */
|
|
181
|
+
customClass: String,
|
|
182
|
+
})
|
|
183
|
+
const { showToast, copyText, text, showCopy, buttons, direction } = toRefs(props)
|
|
184
|
+
const emit = defineEmits<ITooltipEmits>()
|
|
129
185
|
|
|
130
|
-
const instance = getCurrentInstance()
|
|
131
|
-
const showTooltip = ref<boolean>(true)
|
|
132
|
-
const textId = ref(guid())
|
|
133
|
-
const tooltipId = ref(guid())
|
|
134
|
-
const tooltipTop = ref<number>(-10000)
|
|
186
|
+
const instance = getCurrentInstance()
|
|
187
|
+
const showTooltip = ref<boolean>(true)
|
|
188
|
+
const textId = ref(guid())
|
|
189
|
+
const tooltipId = ref(guid())
|
|
190
|
+
const tooltipTop = ref<number>(-10000)
|
|
135
191
|
// 气泡的位置信息
|
|
136
192
|
const tooltipInfo = ref<UniApp.NodeInfo>({
|
|
137
193
|
width: 0,
|
|
138
194
|
left: 0,
|
|
139
|
-
})
|
|
195
|
+
})
|
|
140
196
|
const textInfo = ref<UniApp.NodeInfo>({
|
|
141
197
|
width: 0,
|
|
142
198
|
left: 0,
|
|
143
199
|
right: 0,
|
|
144
|
-
})
|
|
200
|
+
})
|
|
145
201
|
// 三角形指示器的样式
|
|
146
202
|
const indicatorStyle = ref<CSSProperties>({
|
|
147
203
|
left: 0,
|
|
148
204
|
right: 0,
|
|
149
|
-
})
|
|
205
|
+
})
|
|
150
206
|
// 气泡在可能超出屏幕边沿范围时,重新定位后,距离屏幕边沿的距离
|
|
151
|
-
const screenGap = ref(12)
|
|
207
|
+
const screenGap = ref(12)
|
|
152
208
|
// 三角形指示器的宽高,由于对元素进行了角度旋转,精确计算指示器位置时,需要用到其尺寸信息
|
|
153
|
-
const indicatorWidth = ref(14)
|
|
209
|
+
const indicatorWidth = ref(14)
|
|
154
210
|
|
|
155
211
|
// 特别处理H5的复制,因为H5浏览器是自带系统复制功能的,在H5环境
|
|
156
212
|
// 当一些依赖参数变化时,需要重新计算气泡和指示器的位置信息
|
|
157
213
|
const propsChange = computed(() => {
|
|
158
|
-
return [text.value, buttons.value]
|
|
159
|
-
})
|
|
214
|
+
return [text.value, buttons.value]
|
|
215
|
+
})
|
|
160
216
|
// 计算气泡和指示器的位置信息
|
|
161
217
|
const tooltipStyle = computed(() => {
|
|
162
218
|
const style: CSSProperties = {
|
|
163
|
-
transform: `translateY(${direction.value ===
|
|
219
|
+
transform: `translateY(${direction.value === 'top' ? '-100%' : '100%'})`,
|
|
164
220
|
},
|
|
165
221
|
// #ifdef APP || H5 || MP-WEIXIN
|
|
166
|
-
sysInfo = uni.getWindowInfo()
|
|
222
|
+
sysInfo = uni.getWindowInfo()
|
|
167
223
|
// #endif
|
|
168
224
|
if (
|
|
169
225
|
tooltipInfo.value.width! / 2 >
|
|
170
226
|
textInfo.value.left! + textInfo.value.width! / 2 - screenGap.value
|
|
171
227
|
) {
|
|
172
|
-
indicatorStyle.value = {}
|
|
173
|
-
style.left = `-${addUnit(textInfo.value.left! - screenGap.value)}
|
|
228
|
+
indicatorStyle.value = {}
|
|
229
|
+
style.left = `-${addUnit(textInfo.value.left! - screenGap.value)}`
|
|
174
230
|
indicatorStyle.value.left = addUnit(
|
|
175
231
|
textInfo.value.width! / 2 - Number(style.left) - indicatorWidth.value / 2,
|
|
176
|
-
)
|
|
232
|
+
)
|
|
177
233
|
} else if (
|
|
178
234
|
tooltipInfo.value.width! / 2 >
|
|
179
|
-
sysInfo.windowWidth -
|
|
180
|
-
textInfo.value.right! +
|
|
181
|
-
textInfo.value.width! / 2 -
|
|
182
|
-
screenGap.value
|
|
235
|
+
sysInfo.windowWidth - textInfo.value.right! + textInfo.value.width! / 2 - screenGap.value
|
|
183
236
|
) {
|
|
184
|
-
indicatorStyle.value = {}
|
|
185
|
-
style.right = `-${addUnit(
|
|
186
|
-
sysInfo.windowWidth - textInfo.value.right! - screenGap.value,
|
|
187
|
-
)}`;
|
|
237
|
+
indicatorStyle.value = {}
|
|
238
|
+
style.right = `-${addUnit(sysInfo.windowWidth - textInfo.value.right! - screenGap.value)}`
|
|
188
239
|
indicatorStyle.value.right = addUnit(
|
|
189
|
-
textInfo.value.width! / 2 -
|
|
190
|
-
|
|
191
|
-
indicatorWidth.value / 2,
|
|
192
|
-
);
|
|
240
|
+
textInfo.value.width! / 2 - Number(style.right) - indicatorWidth.value / 2,
|
|
241
|
+
)
|
|
193
242
|
} else {
|
|
194
|
-
const left = Math.abs(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
style.left =
|
|
198
|
-
textInfo.value.width! > tooltipInfo.value.width!
|
|
199
|
-
? addUnit(left)
|
|
200
|
-
: -addUnit(left);
|
|
201
|
-
indicatorStyle.value = {};
|
|
243
|
+
const left = Math.abs(textInfo.value.width! / 2 - tooltipInfo.value.width! / 2)
|
|
244
|
+
style.left = textInfo.value.width! > tooltipInfo.value.width! ? addUnit(left) : -addUnit(left)
|
|
245
|
+
indicatorStyle.value = {}
|
|
202
246
|
}
|
|
203
|
-
if (direction.value ===
|
|
204
|
-
style.marginTop =
|
|
205
|
-
indicatorStyle.value.bottom =
|
|
247
|
+
if (direction.value === 'top') {
|
|
248
|
+
style.marginTop = '-10px'
|
|
249
|
+
indicatorStyle.value.bottom = '-4px'
|
|
206
250
|
} else {
|
|
207
|
-
style.marginBottom =
|
|
208
|
-
indicatorStyle.value.top =
|
|
251
|
+
style.marginBottom = '-10px'
|
|
252
|
+
indicatorStyle.value.top = '-4px'
|
|
209
253
|
}
|
|
210
|
-
return style
|
|
211
|
-
})
|
|
254
|
+
return style
|
|
255
|
+
})
|
|
212
256
|
|
|
213
257
|
onMounted(() => {
|
|
214
|
-
getElRect()
|
|
215
|
-
})
|
|
258
|
+
getElRect()
|
|
259
|
+
})
|
|
216
260
|
|
|
217
261
|
/**
|
|
218
262
|
* @description 长按触发事件
|
|
219
263
|
* */
|
|
220
264
|
const longPressHandler = () => {
|
|
221
|
-
tooltipTop.value = 0
|
|
222
|
-
showTooltip.value = true
|
|
223
|
-
}
|
|
265
|
+
tooltipTop.value = 0
|
|
266
|
+
showTooltip.value = true
|
|
267
|
+
}
|
|
224
268
|
|
|
225
269
|
/**
|
|
226
270
|
* @description 点击透明遮罩
|
|
227
271
|
* */
|
|
228
272
|
const overlayClickHandler = () => {
|
|
229
|
-
showTooltip.value = false
|
|
230
|
-
}
|
|
273
|
+
showTooltip.value = false
|
|
274
|
+
}
|
|
231
275
|
|
|
232
276
|
/**
|
|
233
277
|
* @description 点击弹出按钮
|
|
234
278
|
* */
|
|
235
279
|
const btnClickHandler = (index: number) => {
|
|
236
|
-
showTooltip.value = false
|
|
280
|
+
showTooltip.value = false
|
|
237
281
|
// 如果需要展示复制按钮,此处index需要加1,因为复制按钮在第一个位置
|
|
238
|
-
emit(
|
|
239
|
-
}
|
|
282
|
+
emit('click', showCopy.value ? index + 1 : index)
|
|
283
|
+
}
|
|
240
284
|
|
|
241
285
|
/**
|
|
242
286
|
* @description 元素尺寸
|
|
243
287
|
* */
|
|
244
288
|
const getElRect = () => {
|
|
245
289
|
// 调用之前,先将指示器调整到屏幕外,方便获取尺寸
|
|
246
|
-
showTooltip.value = true
|
|
247
|
-
tooltipTop.value = -10000
|
|
290
|
+
showTooltip.value = true
|
|
291
|
+
tooltipTop.value = -10000
|
|
248
292
|
sleep(500).then(() => {
|
|
249
293
|
getRect(`#${tooltipId.value}`, false, instance).then((size) => {
|
|
250
|
-
tooltipInfo.value = size as UniApp.NodeInfo
|
|
294
|
+
tooltipInfo.value = size as UniApp.NodeInfo
|
|
251
295
|
// 获取气泡尺寸之后,将其隐藏,为了让下次切换气泡显示与隐藏时,有淡入淡出的效果
|
|
252
|
-
showTooltip.value = false
|
|
253
|
-
})
|
|
296
|
+
showTooltip.value = false
|
|
297
|
+
})
|
|
254
298
|
getRect(`#${textId.value}`, false, instance).then((size) => {
|
|
255
|
-
textInfo.value = size as UniApp.NodeInfo
|
|
256
|
-
})
|
|
257
|
-
})
|
|
258
|
-
}
|
|
299
|
+
textInfo.value = size as UniApp.NodeInfo
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
}
|
|
259
303
|
/**
|
|
260
304
|
* @description 复制文本到粘贴板
|
|
261
305
|
* */
|
|
262
306
|
const setClipboardData = () => {
|
|
263
307
|
// 关闭组件
|
|
264
|
-
showTooltip.value = false
|
|
265
|
-
emit(
|
|
308
|
+
showTooltip.value = false
|
|
309
|
+
emit('click', 0)
|
|
266
310
|
uni.setClipboardData({
|
|
267
311
|
// 优先使用copyText字段,如果没有,则默认使用text字段当做复制的内容
|
|
268
312
|
data: copyText.value || text.value,
|
|
269
313
|
success: () => {
|
|
270
314
|
showToast.value &&
|
|
271
315
|
uni.showToast({
|
|
272
|
-
title:
|
|
273
|
-
})
|
|
316
|
+
title: '复制成功',
|
|
317
|
+
})
|
|
274
318
|
},
|
|
275
319
|
fail: () => {
|
|
276
320
|
showToast.value &&
|
|
277
321
|
uni.showToast({
|
|
278
|
-
title:
|
|
279
|
-
})
|
|
322
|
+
title: '复制失败',
|
|
323
|
+
})
|
|
280
324
|
},
|
|
281
325
|
complete: () => {
|
|
282
|
-
showTooltip.value = false
|
|
326
|
+
showTooltip.value = false
|
|
283
327
|
},
|
|
284
|
-
})
|
|
285
|
-
}
|
|
328
|
+
})
|
|
329
|
+
}
|
|
286
330
|
</script>
|
|
287
331
|
|
|
288
332
|
<style lang="scss" scoped>
|
|
289
|
-
@import
|
|
333
|
+
@import './index.scss';
|
|
290
334
|
</style>
|
|
@@ -1,52 +1,57 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
3
|
export default interface HyTooltipProps {
|
|
4
4
|
/**
|
|
5
5
|
* @description 需要显示的提示文字
|
|
6
6
|
* */
|
|
7
|
-
text: string
|
|
7
|
+
text: string
|
|
8
8
|
/**
|
|
9
9
|
* @description 点击复制按钮时,复制的文本,为空则使用text值
|
|
10
10
|
* */
|
|
11
|
-
copyText?: string
|
|
11
|
+
copyText?: string
|
|
12
12
|
/**
|
|
13
13
|
* @description 文本大小(默认 14 )
|
|
14
14
|
* */
|
|
15
|
-
size?: number | string
|
|
15
|
+
size?: number | string
|
|
16
16
|
/**
|
|
17
17
|
* @description 字体颜色(默认 '#606266' )
|
|
18
18
|
* */
|
|
19
|
-
color?: string
|
|
19
|
+
color?: string
|
|
20
20
|
/**
|
|
21
21
|
* @description 弹出提示框时,文本的背景色(默认 'transparent' )
|
|
22
22
|
* */
|
|
23
|
-
bgColor?: string
|
|
23
|
+
bgColor?: string
|
|
24
24
|
/**
|
|
25
25
|
* @description 弹出提示的方向,top-上方,bottom-下方(默认 'top' )
|
|
26
26
|
* */
|
|
27
|
-
direction?: HyApp.TopBottomType
|
|
27
|
+
direction?: HyApp.TopBottomType
|
|
28
28
|
/**
|
|
29
29
|
* @description 弹出提示的z-index,nvue无效(默认 10071 )
|
|
30
30
|
* */
|
|
31
|
-
zIndex?: number
|
|
31
|
+
zIndex?: number
|
|
32
32
|
/**
|
|
33
33
|
* @description 是否显示复制按钮(默认 true )
|
|
34
34
|
* */
|
|
35
|
-
showCopy?: boolean
|
|
35
|
+
showCopy?: boolean
|
|
36
36
|
/**
|
|
37
37
|
* @description 扩展的按钮组
|
|
38
38
|
* */
|
|
39
|
-
buttons?: string[]
|
|
39
|
+
buttons?: string[]
|
|
40
40
|
/**
|
|
41
41
|
* @description 是否显示透明遮罩以防止触摸穿透(默认 true )
|
|
42
42
|
* */
|
|
43
|
-
overlay?: boolean
|
|
43
|
+
overlay?: boolean
|
|
44
44
|
/**
|
|
45
45
|
* @description 是否显示遮罩
|
|
46
46
|
* */
|
|
47
|
-
showToast?: boolean
|
|
47
|
+
showToast?: boolean
|
|
48
48
|
/**
|
|
49
49
|
* @description 定义需要用到的外部样式
|
|
50
50
|
* */
|
|
51
|
-
customStyle?: CSSProperties
|
|
51
|
+
customStyle?: CSSProperties
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ITooltipEmits {
|
|
55
|
+
/** 点击菜单按钮触发 */
|
|
56
|
+
(e: 'click', index: number): void
|
|
52
57
|
}
|
|
@@ -11,23 +11,58 @@
|
|
|
11
11
|
</view>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
/**
|
|
16
|
+
* 该组件用于组件的动画过渡效果。
|
|
17
|
+
* @displayName hy-transition
|
|
18
|
+
*/
|
|
19
|
+
defineOptions({})
|
|
20
|
+
export default {
|
|
21
|
+
name: 'hy-transition',
|
|
22
|
+
options: {
|
|
23
|
+
addGlobalClass: true,
|
|
24
|
+
virtualHost: true,
|
|
25
|
+
styleIsolation: 'shared',
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
14
30
|
<script setup lang="ts">
|
|
15
|
-
import { computed, type CSSProperties, ref, watch, nextTick, toRefs } from 'vue'
|
|
31
|
+
import { computed, type CSSProperties, ref, watch, nextTick, toRefs, PropType } from 'vue'
|
|
16
32
|
import { sleep } from '../../utils'
|
|
17
|
-
import
|
|
18
|
-
import type IProps from './typing'
|
|
33
|
+
import type { ITransitionEmits } from './typing'
|
|
19
34
|
|
|
20
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
35
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
36
|
+
const props = defineProps({
|
|
37
|
+
/** 是否展示组件 */
|
|
38
|
+
show: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false,
|
|
41
|
+
},
|
|
42
|
+
/** 使用的动画模式 */
|
|
43
|
+
mode: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: 'fade',
|
|
46
|
+
},
|
|
47
|
+
/** 动画的执行时间,单位ms */
|
|
48
|
+
duration: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: 300,
|
|
51
|
+
},
|
|
52
|
+
/** 使用的动画过渡函数 */
|
|
53
|
+
timingFunction: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: 'ease-out',
|
|
56
|
+
},
|
|
57
|
+
/** 定义需要用到的外部样式 */
|
|
58
|
+
customStyle: {
|
|
59
|
+
type: Object as PropType<CSSProperties>,
|
|
60
|
+
},
|
|
61
|
+
/** 自定义外部类名 */
|
|
62
|
+
customClass: String,
|
|
63
|
+
})
|
|
21
64
|
const { show, mode, duration, customStyle, timingFunction } = toRefs(props)
|
|
22
|
-
const emit = defineEmits(
|
|
23
|
-
'click',
|
|
24
|
-
'beforeEnter',
|
|
25
|
-
'enter',
|
|
26
|
-
'afterEnter',
|
|
27
|
-
'beforeLeave',
|
|
28
|
-
'leave',
|
|
29
|
-
'afterLeave',
|
|
30
|
-
])
|
|
65
|
+
const emit = defineEmits<ITransitionEmits>()
|
|
31
66
|
|
|
32
67
|
const hasInit = ref<boolean>(false) // 是否显示/隐藏组件
|
|
33
68
|
const viewStyle = ref<CSSProperties>({}) // 组件内部的样式
|
|
@@ -26,3 +26,20 @@ export default interface HyTransitionProps {
|
|
|
26
26
|
* */
|
|
27
27
|
customClass?: string
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
export interface ITransitionEmits {
|
|
31
|
+
/** 进入中触发 */
|
|
32
|
+
(e: 'enter'): void
|
|
33
|
+
/** 离开中触发 */
|
|
34
|
+
(e: 'leave'): void
|
|
35
|
+
/** 点击触发 */
|
|
36
|
+
(e: 'click'): void
|
|
37
|
+
/** 进入后触发 */
|
|
38
|
+
(e: 'afterEnter'): void
|
|
39
|
+
/** 离开后触发 */
|
|
40
|
+
(e: 'afterLeave'): void
|
|
41
|
+
/** 进入前触发 */
|
|
42
|
+
(e: 'beforeEnter'): void
|
|
43
|
+
/** 离开前触发 */
|
|
44
|
+
(e: 'beforeLeave'): void
|
|
45
|
+
}
|