hy-app 0.3.15 → 0.4.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 +2 -2
- package/components/hy-action-sheet/typing.d.ts +32 -33
- package/components/hy-back-top/hy-back-top.vue +36 -32
- package/components/hy-button/hy-button.vue +7 -7
- package/components/hy-button/typing.d.ts +39 -40
- package/components/hy-calendar/index.scss +1 -1
- package/components/hy-card/hy-card.vue +3 -3
- package/components/hy-cell/hy-cell.vue +125 -118
- package/components/hy-cell/index.scss +7 -7
- package/components/hy-checkbox/hy-checkbox.vue +17 -16
- package/components/hy-checkbox/index.scss +1 -1
- package/components/hy-checkbox-group/hy-checkbox-group.vue +6 -4
- package/components/hy-checkbox-item/hy-checkbox-item.vue +56 -44
- package/components/hy-checkbox-item/index.scss +1 -1
- package/components/hy-checkbox-item/typing.d.ts +3 -2
- package/components/hy-code-input/hy-code-input.vue +314 -314
- package/components/hy-code-input/index.scss +12 -12
- package/components/hy-count-down/index.scss +1 -1
- package/components/hy-datetime-picker/index.scss +1 -1
- package/components/hy-datetime-picker/typing.d.ts +0 -1
- package/components/hy-divider/index.scss +3 -3
- package/components/hy-dropdown-item/hy-dropdown-item.vue +2 -2
- package/components/hy-dropdown-item/index.scss +5 -5
- package/components/hy-float-button/hy-float-button.vue +1 -1
- package/components/hy-float-button/index.scss +9 -18
- package/components/hy-folding-panel/index.scss +1 -1
- package/components/hy-form/hy-form.vue +2 -7
- package/components/hy-form-item/hy-form-item.vue +203 -201
- package/components/hy-form-item/typing.d.ts +20 -14
- package/components/hy-grid/hy-grid.vue +23 -23
- package/components/hy-grid/index.scss +2 -8
- package/components/hy-icon/index.scss +8 -8
- package/components/hy-input/hy-input.vue +45 -44
- package/components/hy-input/index.scss +12 -11
- package/components/hy-line-progress/index.scss +3 -3
- package/components/hy-list/hy-list.vue +2 -2
- package/components/hy-list/index.scss +4 -4
- package/components/hy-loading/hy-loading.vue +2 -3
- package/components/hy-loading/index.scss +17 -15
- package/components/hy-menu/hy-menu.vue +38 -30
- package/components/hy-menu/index.scss +1 -1
- package/components/hy-menu/typing.d.ts +16 -12
- package/components/hy-modal/hy-modal.vue +11 -11
- package/components/hy-modal/index.scss +17 -17
- package/components/hy-modal/typing.d.ts +0 -2
- package/components/hy-navbar/hy-navbar.vue +3 -3
- package/components/hy-navbar/index.scss +10 -11
- package/components/hy-notice-bar/hy-column-notice.vue +2 -2
- package/components/hy-notice-bar/hy-row-notice.vue +3 -3
- package/components/hy-notice-bar/index.scss +9 -12
- package/components/hy-notify/hy-notify.vue +8 -5
- package/components/hy-notify/index.scss +2 -2
- package/components/hy-number-step/index.scss +9 -10
- package/components/hy-pagination/index.scss +7 -2
- package/components/hy-parse/index.scss +0 -9
- package/components/hy-picker/hy-picker.vue +1 -1
- package/components/hy-picker/index.scss +9 -16
- package/components/hy-popover/hy-popover.vue +6 -4
- package/components/hy-popup/hy-popup.vue +4 -2
- package/components/hy-popup/index.scss +45 -32
- package/components/hy-qrcode/hy-qrcode.vue +3 -3
- package/components/hy-qrcode/index.scss +18 -17
- package/components/hy-radio/hy-radio.vue +20 -18
- package/components/hy-radio/index.scss +26 -22
- package/components/hy-rate/hy-rate.vue +5 -5
- package/components/hy-rate/index.scss +4 -4
- package/components/hy-read-more/hy-read-more.vue +19 -20
- package/components/hy-read-more/index.scss +12 -6
- package/components/hy-scroll-list/hy-scroll-list.vue +3 -6
- package/components/hy-scroll-list/index.scss +4 -4
- package/components/hy-search/index.scss +9 -8
- package/components/hy-slider/hy-slider.vue +5 -5
- package/components/hy-slider/index.scss +12 -12
- package/components/hy-status-bar/index.scss +3 -1
- package/components/hy-steps/hy-steps.vue +50 -23
- package/components/hy-submit-bar/hy-submit-bar.vue +1 -1
- package/components/hy-submit-bar/index.scss +5 -4
- package/components/hy-subsection/hy-subsection.vue +3 -3
- package/components/hy-subsection/index.scss +7 -7
- package/components/hy-swipe-action/hy-swipe-action.vue +8 -8
- package/components/hy-swipe-action/index.scss +8 -4
- package/components/hy-swiper/hy-swiper-indicator.vue +2 -2
- package/components/hy-swiper/hy-swiper.vue +6 -6
- package/components/hy-swiper/index.scss +6 -10
- package/components/hy-switch/hy-switch.vue +4 -4
- package/components/hy-switch/index.scss +4 -22
- package/components/hy-tabs/hy-tabs.vue +16 -16
- package/components/hy-tabs/index.scss +16 -16
- package/components/hy-tag/index.scss +1 -1
- package/components/hy-text/index.scss +3 -3
- package/components/hy-textarea/hy-textarea.vue +11 -11
- package/components/hy-textarea/index.scss +11 -10
- package/components/hy-toast/hy-toast.vue +5 -5
- package/components/hy-toast/index.scss +8 -8
- package/components/hy-tooltip/hy-tooltip.vue +193 -183
- package/components/hy-tooltip/index.scss +69 -45
- package/components/hy-upload/hy-upload.vue +15 -10
- package/components/hy-upload/index.scss +37 -36
- package/components/hy-warn/hy-warn.vue +11 -11
- package/components/hy-warn/index.scss +76 -82
- package/components/hy-waterfall/index.scss +2 -1
- package/composables/usePopover.ts +2 -2
- package/libs/css/mixin.scss +0 -9
- package/package.json +2 -2
- package/utils/inside.ts +4 -1
- package/utils/utils.ts +187 -162
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
flex-wrap: nowrap;
|
|
9
9
|
color: $hy-text-color;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
@include e(price) {
|
|
12
12
|
font-size: 14px;
|
|
13
13
|
color: $hy-text-color--grey;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
@include e(value) {
|
|
17
17
|
font-size: 14px;
|
|
18
18
|
@include flex;
|
|
19
19
|
flex-wrap: wrap;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
align-items: center;
|
|
23
23
|
|
|
24
24
|
/*链接*/
|
|
25
|
-
|
|
25
|
+
@include m(link) {
|
|
26
26
|
text-decoration: underline;
|
|
27
27
|
color: $hy-primary;
|
|
28
28
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<view
|
|
3
3
|
:class="['hy-textarea', customClass, textareaClass]"
|
|
4
4
|
:style="[textareaStyle, borderStyle(isFocus)]"
|
|
5
5
|
>
|
|
6
|
-
<
|
|
7
|
-
class="hy-
|
|
6
|
+
<textarea
|
|
7
|
+
class="hy-textarea__field"
|
|
8
8
|
:value="innerValue"
|
|
9
9
|
:style="{ height: autoHeight ? 'auto' : addUnit(height) }"
|
|
10
10
|
:placeholder="placeholder || ''"
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
@input="onInput"
|
|
31
31
|
@confirm="onConfirm"
|
|
32
32
|
@keyboardheightchange="onKeyboardheightchange"
|
|
33
|
-
></
|
|
33
|
+
></textarea>
|
|
34
34
|
<!-- #ifndef MP-ALIPAY -->
|
|
35
|
-
<
|
|
36
|
-
class="hy-
|
|
35
|
+
<text
|
|
36
|
+
class="hy-textarea__count"
|
|
37
37
|
:style="{
|
|
38
38
|
'background-color': disabled ? 'transparent' : '',
|
|
39
39
|
}"
|
|
40
40
|
v-if="count"
|
|
41
41
|
>
|
|
42
42
|
{{ innerValue.length }}/{{ maxlength }}
|
|
43
|
-
</
|
|
43
|
+
</text>
|
|
44
44
|
<!-- #endif -->
|
|
45
|
-
</
|
|
45
|
+
</view>
|
|
46
46
|
</template>
|
|
47
47
|
|
|
48
48
|
<script lang="ts">
|
|
@@ -220,10 +220,10 @@ watch(
|
|
|
220
220
|
const textareaClass = computed(() => {
|
|
221
221
|
let classes: string[] = [];
|
|
222
222
|
props.border === "surround" &&
|
|
223
|
-
(classes = classes.concat(["hy-border", "hy-
|
|
223
|
+
(classes = classes.concat(["hy-border", "hy-textarea__radius"]));
|
|
224
224
|
props.border === "bottom" &&
|
|
225
|
-
(classes = classes.concat(["hy-border__bottom", "hy-
|
|
226
|
-
props.disabled && classes.push("hy-
|
|
225
|
+
(classes = classes.concat(["hy-border__bottom", "hy-textarea__no-radius"]));
|
|
226
|
+
props.disabled && classes.push("hy-textarea__disabled");
|
|
227
227
|
return classes.join(" ");
|
|
228
228
|
});
|
|
229
229
|
// 组件的样式
|
|
@@ -8,25 +8,26 @@
|
|
|
8
8
|
flex: 1;
|
|
9
9
|
padding: $hy-border-margin-padding-sm;
|
|
10
10
|
|
|
11
|
-
@include
|
|
11
|
+
@include e(field) {
|
|
12
12
|
min-height: 50rpx;
|
|
13
13
|
max-height: 200rpx;
|
|
14
|
+
color: $hy-text-color;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
@include
|
|
17
|
+
@include e(radius) {
|
|
17
18
|
border-radius: $hy-border-radius-sm;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
@include
|
|
21
|
+
@include e(no-radius) {
|
|
21
22
|
border-radius: $hy-border-radius-no;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
@include
|
|
25
|
+
@include e(disabled) {
|
|
25
26
|
background-color: $hy-background--disabled;
|
|
26
27
|
color: $hy-text-color--disabled;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
@include
|
|
30
|
+
@include e(field) {
|
|
30
31
|
flex: 1;
|
|
31
32
|
font-size: 15px;
|
|
32
33
|
width: 100%;
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
border: none;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
@include
|
|
38
|
+
@include e(count) {
|
|
38
39
|
position: absolute;
|
|
39
40
|
right: 5px;
|
|
40
41
|
bottom: 2px;
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
border-radius: $hy-border-radius-sm;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
textarea {
|
|
48
|
-
background-color: transparent;
|
|
49
|
-
border: none;
|
|
50
|
-
}
|
|
48
|
+
//textarea {
|
|
49
|
+
// background-color: transparent;
|
|
50
|
+
// border: none;
|
|
51
|
+
//}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
:style="[contentStyle]"
|
|
9
9
|
:class="[
|
|
10
10
|
'hy-toast__content',
|
|
11
|
-
'hy-
|
|
11
|
+
'hy-toast__' + tmpConfig.type,
|
|
12
12
|
tmpConfig.type === 'loading' || tmpConfig.loading
|
|
13
13
|
? 'hy-toast__content--loading'
|
|
14
14
|
: '',
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
></HyIcon>
|
|
32
32
|
<text
|
|
33
33
|
:class="[
|
|
34
|
-
'hy-
|
|
35
|
-
'hy-
|
|
34
|
+
'hy-toast__content--text',
|
|
35
|
+
'hy-toast__content--text__' + tmpConfig.type,
|
|
36
36
|
]"
|
|
37
37
|
style="max-width: 400rpx"
|
|
38
38
|
>
|
|
@@ -139,10 +139,10 @@ const contentStyle = computed(() => {
|
|
|
139
139
|
|
|
140
140
|
const loadingIconColor = computed(() => {
|
|
141
141
|
let colorTmp = "rgb(255, 255, 255)";
|
|
142
|
-
if (isThemeType(tmpConfig.value.type)) {
|
|
142
|
+
if (isThemeType(tmpConfig.value.type!)) {
|
|
143
143
|
// loading-icon组件内部会对color参数进行一个透明度处理,该方法要求传入的颜色值
|
|
144
144
|
// 必须为rgb格式的,所以这里做一个处理
|
|
145
|
-
colorTmp = hexToRgb(ColorConfig[tmpConfig.value.type]) as string;
|
|
145
|
+
colorTmp = hexToRgb(ColorConfig[tmpConfig.value.type!]) as string;
|
|
146
146
|
}
|
|
147
147
|
return colorTmp;
|
|
148
148
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@use "../../libs/css/theme" as *;
|
|
3
3
|
|
|
4
4
|
@include b(toast){
|
|
5
|
-
|
|
5
|
+
@include e(content) {
|
|
6
6
|
@include flex;
|
|
7
7
|
padding: 12px 20px;
|
|
8
8
|
border-radius: 4px;
|
|
@@ -14,33 +14,33 @@
|
|
|
14
14
|
/* #endif */
|
|
15
15
|
position: relative;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
@include m(loading) {
|
|
18
18
|
flex-direction: column;
|
|
19
19
|
padding: 20px;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
@include m(text) {
|
|
23
23
|
color: #ffffff;
|
|
24
24
|
font-size: 15px;
|
|
25
25
|
line-height: 15px;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
@include e(default) {
|
|
28
28
|
color: #ffffff;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
@include e(error) {
|
|
32
32
|
color: $hy-error;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
@include e(primary) {
|
|
36
36
|
color: $hy-primary;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
@include e(success) {
|
|
40
40
|
color: $hy-success;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
@include e(warning) {
|
|
44
44
|
color: $hy-warning;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1,98 +1,126 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
2
|
+
<view
|
|
3
|
+
:class="['hy-tooltip', customClass]"
|
|
4
|
+
:style="customStyle"
|
|
5
|
+
@click.stop="closeHandler"
|
|
6
|
+
>
|
|
3
7
|
<HyOverlay
|
|
4
8
|
:show="showTooltip && tooltipTop !== -10000 && overlay"
|
|
5
9
|
:customStyle="{ backgroundColor: 'rgba(0, 0, 0, 0)' }"
|
|
6
|
-
@click="
|
|
10
|
+
@click="closeHandler"
|
|
7
11
|
></HyOverlay>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
:customStyle="{
|
|
31
|
-
position: 'absolute',
|
|
32
|
-
top: addUnit(tooltipTop),
|
|
33
|
-
zIndex: zIndex,
|
|
34
|
-
...tooltipStyle,
|
|
35
|
-
}"
|
|
36
|
-
>
|
|
37
|
-
<view
|
|
38
|
-
class="hy-tooltip__wrapper__popup"
|
|
39
|
-
:id="tooltipId"
|
|
40
|
-
:ref="tooltipId"
|
|
41
|
-
>
|
|
12
|
+
<!-- 文本内容区域 -->
|
|
13
|
+
<view
|
|
14
|
+
class="hy-tooltip__content"
|
|
15
|
+
id="target"
|
|
16
|
+
@longpress.stop="longPressHandler"
|
|
17
|
+
@tap.stop="clickHandler"
|
|
18
|
+
:style="{
|
|
19
|
+
color: color,
|
|
20
|
+
backgroundColor:
|
|
21
|
+
bgColor && showTooltip && tooltipTop !== -10000
|
|
22
|
+
? bgColor
|
|
23
|
+
: 'transparent',
|
|
24
|
+
}"
|
|
25
|
+
>
|
|
26
|
+
<slot v-if="$slots.default"></slot>
|
|
27
|
+
<text class="hy-tooltip__content--text" v-else>{{ text }}</text>
|
|
28
|
+
</view>
|
|
29
|
+
|
|
30
|
+
<!-- 用于获取弹窗宽高 -->
|
|
31
|
+
<view class="hy-tooltip__popup hy-tooltip__hidden" id="pos">
|
|
32
|
+
<view class="hy-tooltip__container custom-pop">
|
|
33
|
+
<view class="hy-tooltip__container--list">
|
|
42
34
|
<view
|
|
43
|
-
v-if="showCopy
|
|
44
|
-
class="hy-
|
|
45
|
-
hover-class="hy-
|
|
46
|
-
|
|
47
|
-
indicatorStyle,
|
|
48
|
-
{
|
|
49
|
-
width: addUnit(indicatorWidth),
|
|
50
|
-
height: addUnit(indicatorWidth),
|
|
51
|
-
},
|
|
52
|
-
]"
|
|
35
|
+
v-if="showCopy"
|
|
36
|
+
class="hy-tooltip__container--list__btn"
|
|
37
|
+
hover-class="hy-tooltip__container--list__btn--hover"
|
|
38
|
+
@tap="setClipboardData"
|
|
53
39
|
>
|
|
54
|
-
|
|
40
|
+
<text class="hy-tooltip__container--list__btn--text">复制</text>
|
|
55
41
|
</view>
|
|
56
|
-
<
|
|
42
|
+
<HyLine
|
|
43
|
+
direction="column"
|
|
44
|
+
color="#8d8e90"
|
|
45
|
+
v-if="showCopy && buttons.length > 0"
|
|
46
|
+
length="18"
|
|
47
|
+
></HyLine>
|
|
48
|
+
<template v-for="(item, index) in buttons" :key="index">
|
|
57
49
|
<view
|
|
58
|
-
|
|
59
|
-
class="hy-
|
|
60
|
-
hover-class="hy-tooltip__wrapper__popup__list__btn--hover"
|
|
61
|
-
@tap="setClipboardData"
|
|
50
|
+
class="hy-tooltip__container--list__btn"
|
|
51
|
+
hover-class="hy-tooltip__container--list__btn--hover"
|
|
62
52
|
>
|
|
63
|
-
<text
|
|
64
|
-
|
|
53
|
+
<text
|
|
54
|
+
class="hy-tooltip__container--list__btn--text"
|
|
55
|
+
@tap="btnClickHandler(index)"
|
|
65
56
|
>
|
|
57
|
+
{{ item }}
|
|
58
|
+
</text>
|
|
66
59
|
</view>
|
|
67
60
|
<HyLine
|
|
68
61
|
direction="column"
|
|
69
62
|
color="#8d8e90"
|
|
70
|
-
v-if="
|
|
63
|
+
v-if="index < buttons.length - 1"
|
|
71
64
|
length="18"
|
|
72
65
|
></HyLine>
|
|
73
|
-
|
|
74
|
-
<view
|
|
75
|
-
class="hy-tooltip__wrapper__popup__list__btn"
|
|
76
|
-
hover-class="hy-tooltip__wrapper__popup__list__btn--hover"
|
|
77
|
-
>
|
|
78
|
-
<text
|
|
79
|
-
class="hy-tooltip__wrapper__popup__list__btn__text"
|
|
80
|
-
@tap="btnClickHandler(index)"
|
|
81
|
-
>
|
|
82
|
-
{{ item }}
|
|
83
|
-
</text>
|
|
84
|
-
</view>
|
|
85
|
-
<HyLine
|
|
86
|
-
direction="column"
|
|
87
|
-
color="#8d8e90"
|
|
88
|
-
v-if="index < buttons.length - 1"
|
|
89
|
-
length="18"
|
|
90
|
-
></HyLine>
|
|
91
|
-
</template>
|
|
92
|
-
</view>
|
|
66
|
+
</template>
|
|
93
67
|
</view>
|
|
94
|
-
</
|
|
68
|
+
</view>
|
|
95
69
|
</view>
|
|
70
|
+
|
|
71
|
+
<HyTransition
|
|
72
|
+
mode="fade"
|
|
73
|
+
:show="showTooltip"
|
|
74
|
+
:duration="300"
|
|
75
|
+
custom-class="hy-tooltip__popup"
|
|
76
|
+
:custom-style="popover.popStyle.value"
|
|
77
|
+
>
|
|
78
|
+
<view class="hy-tooltip__container">
|
|
79
|
+
<!-- 三角形 -->
|
|
80
|
+
<view
|
|
81
|
+
v-if="showCopy"
|
|
82
|
+
:class="`hy-tooltip__arrow ${popover.arrowClass.value}`"
|
|
83
|
+
:style="popover.arrowStyle.value"
|
|
84
|
+
></view>
|
|
85
|
+
<!-- 三角形 -->
|
|
86
|
+
|
|
87
|
+
<view class="hy-tooltip__container--list">
|
|
88
|
+
<view
|
|
89
|
+
v-if="showCopy"
|
|
90
|
+
class="hy-tooltip__container--list__btn"
|
|
91
|
+
hover-class="hy-tooltip__container--list__btn--hover"
|
|
92
|
+
@tap="setClipboardData"
|
|
93
|
+
>
|
|
94
|
+
<text class="hy-tooltip__container--list__btn--text">复制</text>
|
|
95
|
+
</view>
|
|
96
|
+
<HyLine
|
|
97
|
+
direction="column"
|
|
98
|
+
color="#8d8e90"
|
|
99
|
+
v-if="showCopy && buttons.length > 0"
|
|
100
|
+
length="18"
|
|
101
|
+
></HyLine>
|
|
102
|
+
<template v-for="(item, index) in buttons" :key="index">
|
|
103
|
+
<view
|
|
104
|
+
class="hy-tooltip__container--list__btn"
|
|
105
|
+
hover-class="hy-tooltip__container--list__btn--hover"
|
|
106
|
+
>
|
|
107
|
+
<text
|
|
108
|
+
class="hy-tooltip__container--list__btn--text"
|
|
109
|
+
@tap="btnClickHandler(index)"
|
|
110
|
+
>
|
|
111
|
+
{{ item }}
|
|
112
|
+
</text>
|
|
113
|
+
</view>
|
|
114
|
+
<HyLine
|
|
115
|
+
direction="column"
|
|
116
|
+
color="#8d8e90"
|
|
117
|
+
v-if="index < buttons.length - 1"
|
|
118
|
+
length="18"
|
|
119
|
+
></HyLine>
|
|
120
|
+
</template>
|
|
121
|
+
</view>
|
|
122
|
+
</view>
|
|
123
|
+
</HyTransition>
|
|
96
124
|
</view>
|
|
97
125
|
</template>
|
|
98
126
|
|
|
@@ -108,15 +136,24 @@ export default {
|
|
|
108
136
|
</script>
|
|
109
137
|
|
|
110
138
|
<script setup lang="ts">
|
|
111
|
-
import {
|
|
139
|
+
import {
|
|
140
|
+
ref,
|
|
141
|
+
onMounted,
|
|
142
|
+
watch,
|
|
143
|
+
inject,
|
|
144
|
+
onBeforeUnmount,
|
|
145
|
+
getCurrentInstance,
|
|
146
|
+
} from "vue";
|
|
112
147
|
import type { CSSProperties, PropType } from "vue";
|
|
113
148
|
import type { ITooltipEmits } from "./typing";
|
|
114
|
-
import {
|
|
149
|
+
import { type Queue, queueKey, usePopover } from "../../composables";
|
|
150
|
+
import type { IPlacementVo } from "../hy-popover/typing";
|
|
151
|
+
import { closeOther, removeFromQueue, pushToQueue } from "../../common";
|
|
115
152
|
|
|
116
153
|
// 组件
|
|
117
|
-
import HyOverlay from "../hy-overlay/hy-overlay.vue";
|
|
118
154
|
import HyTransition from "../hy-transition/hy-transition.vue";
|
|
119
155
|
import HyLine from "../hy-line/hy-line.vue";
|
|
156
|
+
import HyOverlay from "../hy-overlay/hy-overlay.vue";
|
|
120
157
|
|
|
121
158
|
/**
|
|
122
159
|
* Tooltip组件主要用于长按操作,类似微信的长按气泡
|
|
@@ -141,6 +178,22 @@ const props = defineProps({
|
|
|
141
178
|
type: [String, Number],
|
|
142
179
|
default: 14,
|
|
143
180
|
},
|
|
181
|
+
/**
|
|
182
|
+
* 触发模式
|
|
183
|
+
* @values longpress,click
|
|
184
|
+
* */
|
|
185
|
+
triggerMode: {
|
|
186
|
+
type: String as PropType<"longpress" | "click">,
|
|
187
|
+
default: "longpress",
|
|
188
|
+
},
|
|
189
|
+
/**
|
|
190
|
+
* 指定 popover 的放置位置
|
|
191
|
+
* @values top,top-start,top-end,bottom,bottom-start,bottom-end,left,left-start,left-end,right,right-start,right-end
|
|
192
|
+
* */
|
|
193
|
+
placement: {
|
|
194
|
+
type: String as PropType<IPlacementVo>,
|
|
195
|
+
default: "bottom",
|
|
196
|
+
},
|
|
144
197
|
/** 字体颜色 */
|
|
145
198
|
color: String,
|
|
146
199
|
/** 弹出提示框时,文本的背景色 */
|
|
@@ -190,131 +243,88 @@ const props = defineProps({
|
|
|
190
243
|
});
|
|
191
244
|
const emit = defineEmits<ITooltipEmits>();
|
|
192
245
|
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
const
|
|
246
|
+
const queue = inject<Queue | null>(queueKey, null);
|
|
247
|
+
const { proxy } = getCurrentInstance() as any;
|
|
248
|
+
// 显示三角标
|
|
249
|
+
const visibleArrow = ref<boolean>(true);
|
|
250
|
+
const popover = usePopover(visibleArrow.value);
|
|
251
|
+
const showTooltip = ref<boolean>(false);
|
|
197
252
|
const tooltipTop = ref<number>(-10000);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
253
|
+
const selector: string = "tooltip";
|
|
254
|
+
|
|
255
|
+
watch(
|
|
256
|
+
() => props.placement,
|
|
257
|
+
() => {
|
|
258
|
+
popover.init(props.placement, visibleArrow.value, selector);
|
|
259
|
+
},
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
watch(
|
|
263
|
+
() => showTooltip.value,
|
|
264
|
+
(newValue) => {
|
|
265
|
+
if (newValue) {
|
|
266
|
+
popover.control(props.placement, 0);
|
|
267
|
+
if (queue && queue.closeOther) {
|
|
268
|
+
queue.closeOther(proxy);
|
|
269
|
+
} else {
|
|
270
|
+
closeOther(proxy);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
onMounted(() => {
|
|
277
|
+
// getElRect();
|
|
278
|
+
popover.init(props.placement, visibleArrow.value, selector);
|
|
212
279
|
});
|
|
213
|
-
// 气泡在可能超出屏幕边沿范围时,重新定位后,距离屏幕边沿的距离
|
|
214
|
-
const screenGap = ref(12);
|
|
215
|
-
// 三角形指示器的宽高,由于对元素进行了角度旋转,精确计算指示器位置时,需要用到其尺寸信息
|
|
216
|
-
const indicatorWidth = ref(14);
|
|
217
280
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// #ifdef APP || H5 || MP-WEIXIN
|
|
224
|
-
sysInfo = uni.getWindowInfo();
|
|
225
|
-
// #endif
|
|
226
|
-
if (
|
|
227
|
-
tooltipInfo.value.width! / 2 >
|
|
228
|
-
textInfo.value.left! + textInfo.value.width! / 2 - screenGap.value
|
|
229
|
-
) {
|
|
230
|
-
indicatorStyle.value = {};
|
|
231
|
-
style.left = `-${addUnit(textInfo.value.left! - screenGap.value)}`;
|
|
232
|
-
indicatorStyle.value.left = addUnit(
|
|
233
|
-
textInfo.value.width! / 2 - Number(style.left) - indicatorWidth.value / 2,
|
|
234
|
-
);
|
|
235
|
-
} else if (
|
|
236
|
-
tooltipInfo.value.width! / 2 >
|
|
237
|
-
sysInfo.windowWidth -
|
|
238
|
-
textInfo.value.right! +
|
|
239
|
-
textInfo.value.width! / 2 -
|
|
240
|
-
screenGap.value
|
|
241
|
-
) {
|
|
242
|
-
indicatorStyle.value = {};
|
|
243
|
-
style.right = `-${addUnit(sysInfo.windowWidth - textInfo.value.right! - screenGap.value)}`;
|
|
244
|
-
indicatorStyle.value.right = addUnit(
|
|
245
|
-
textInfo.value.width! / 2 -
|
|
246
|
-
Number(style.right) -
|
|
247
|
-
indicatorWidth.value / 2,
|
|
248
|
-
);
|
|
249
|
-
} else {
|
|
250
|
-
const left = Math.abs(
|
|
251
|
-
textInfo.value.width! / 2 - tooltipInfo.value.width! / 2,
|
|
252
|
-
);
|
|
253
|
-
style.left =
|
|
254
|
-
textInfo.value.width! > tooltipInfo.value.width!
|
|
255
|
-
? addUnit(left)
|
|
256
|
-
: -addUnit(left);
|
|
257
|
-
indicatorStyle.value = {};
|
|
258
|
-
}
|
|
259
|
-
if (props.direction === "top") {
|
|
260
|
-
style.marginTop = "-10px";
|
|
261
|
-
indicatorStyle.value.bottom = "-4px";
|
|
281
|
+
function onBeforeMount(param: () => void) {}
|
|
282
|
+
|
|
283
|
+
onBeforeMount(() => {
|
|
284
|
+
if (queue && queue.pushToQueue) {
|
|
285
|
+
queue.pushToQueue(proxy);
|
|
262
286
|
} else {
|
|
263
|
-
|
|
264
|
-
indicatorStyle.value.top = "-4px";
|
|
287
|
+
pushToQueue(proxy);
|
|
265
288
|
}
|
|
266
|
-
return style;
|
|
267
289
|
});
|
|
268
290
|
|
|
269
|
-
|
|
270
|
-
|
|
291
|
+
onBeforeUnmount(() => {
|
|
292
|
+
if (queue && queue.removeFromQueue) {
|
|
293
|
+
queue.removeFromQueue(proxy);
|
|
294
|
+
} else {
|
|
295
|
+
removeFromQueue(proxy);
|
|
296
|
+
}
|
|
271
297
|
});
|
|
272
298
|
|
|
273
|
-
|
|
274
|
-
* @description 长按触发事件
|
|
275
|
-
* */
|
|
299
|
+
// 长按触发事件
|
|
276
300
|
const longPressHandler = () => {
|
|
277
|
-
|
|
278
|
-
|
|
301
|
+
if (props.triggerMode === "longpress") {
|
|
302
|
+
tooltipTop.value = 0;
|
|
303
|
+
showTooltip.value = true;
|
|
304
|
+
}
|
|
279
305
|
};
|
|
280
306
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
307
|
+
// 点击触发事件
|
|
308
|
+
const clickHandler = () => {
|
|
309
|
+
if (props.triggerMode === "click") {
|
|
310
|
+
tooltipTop.value = 0;
|
|
311
|
+
showTooltip.value = true;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
// 点击关闭
|
|
316
|
+
const closeHandler = () => {
|
|
285
317
|
showTooltip.value = false;
|
|
286
318
|
};
|
|
287
319
|
|
|
288
|
-
|
|
289
|
-
* @description 点击弹出按钮
|
|
290
|
-
* */
|
|
320
|
+
// 点击操作栏按钮
|
|
291
321
|
const btnClickHandler = (index: number) => {
|
|
292
322
|
showTooltip.value = false;
|
|
293
323
|
// 如果需要展示复制按钮,此处index需要加1,因为复制按钮在第一个位置
|
|
294
324
|
emit("click", props.showCopy ? index + 1 : index);
|
|
295
325
|
};
|
|
296
326
|
|
|
297
|
-
|
|
298
|
-
* @description 元素尺寸
|
|
299
|
-
* */
|
|
300
|
-
const getElRect = () => {
|
|
301
|
-
// 调用之前,先将指示器调整到屏幕外,方便获取尺寸
|
|
302
|
-
showTooltip.value = true;
|
|
303
|
-
tooltipTop.value = -10000;
|
|
304
|
-
sleep(500).then(() => {
|
|
305
|
-
getRect(`#${tooltipId.value}`, false, instance).then((size) => {
|
|
306
|
-
tooltipInfo.value = size as UniApp.NodeInfo;
|
|
307
|
-
// 获取气泡尺寸之后,将其隐藏,为了让下次切换气泡显示与隐藏时,有淡入淡出的效果
|
|
308
|
-
showTooltip.value = false;
|
|
309
|
-
});
|
|
310
|
-
getRect(`#${textId.value}`, false, instance).then((size) => {
|
|
311
|
-
textInfo.value = size as UniApp.NodeInfo;
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
};
|
|
315
|
-
/**
|
|
316
|
-
* @description 复制文本到粘贴板
|
|
317
|
-
* */
|
|
327
|
+
// 复制文本到粘贴板
|
|
318
328
|
const setClipboardData = () => {
|
|
319
329
|
// 关闭组件
|
|
320
330
|
showTooltip.value = false;
|