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,496 +1,379 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
3
|
-
:style="FloatButtonStyle"
|
|
4
|
-
:id="soleId"
|
|
5
|
-
:class="[
|
|
6
|
-
'hy-float-button',
|
|
7
|
-
{
|
|
8
|
-
'hy-float-button__animation': float,
|
|
9
|
-
'hy-float-button__shadow': shadow,
|
|
10
|
-
},
|
|
11
|
-
`hy-float-button--${shape}`,
|
|
12
|
-
customClass,
|
|
13
|
-
]"
|
|
14
|
-
@touchmove.stop.prevent="handleTouchMove"
|
|
15
|
-
@touchstart="handleTouchStart"
|
|
16
|
-
@touchend="handleTouchEnd"
|
|
17
|
-
>
|
|
18
2
|
<view
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
:style="FloatButtonStyle"
|
|
4
|
+
:id="soleId"
|
|
5
|
+
:class="[
|
|
6
|
+
'hy-float-button',
|
|
7
|
+
{
|
|
8
|
+
'hy-float-button__animation': float,
|
|
9
|
+
'hy-float-button__shadow': shadow
|
|
10
|
+
},
|
|
11
|
+
`hy-float-button--${shape}`,
|
|
12
|
+
customClass
|
|
13
|
+
]"
|
|
14
|
+
@touchmove.stop.prevent="handleTouchMove"
|
|
15
|
+
@touchstart="handleTouchStart"
|
|
16
|
+
@touchend="handleTouchEnd"
|
|
22
17
|
>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
<view
|
|
19
|
+
:class="['hy-float-button__container']"
|
|
20
|
+
@tap.stop="handleClick"
|
|
21
|
+
:style="{ backgroundColor: bgColor }"
|
|
22
|
+
>
|
|
23
|
+
<slot v-if="$slots.default"></slot>
|
|
24
|
+
<template v-else>
|
|
25
|
+
<hy-icon
|
|
26
|
+
:name="icon"
|
|
27
|
+
:color="iconColor"
|
|
28
|
+
:size="iconSize ? iconSize : addUnit(getPx(getFloatBtnSize) * 0.7)"
|
|
29
|
+
/>
|
|
30
|
+
<text v-if="text" :style="{ color: textColor, fontSize: fontSize }">{{
|
|
31
|
+
text
|
|
32
|
+
}}</text>
|
|
33
|
+
</template>
|
|
34
|
+
</view>
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
<view
|
|
37
|
-
:class="['hy-float-button__menus', `hy-float-button__menus--${shape}`]"
|
|
38
|
-
:style="menusStyle"
|
|
39
|
-
>
|
|
40
|
-
<template v-for="(item, i) in menus" :key="i">
|
|
36
|
+
<!-- 菜单栏 -->
|
|
41
37
|
<view
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
width: getFloatBtnSize,
|
|
45
|
-
height: getFloatBtnSize,
|
|
46
|
-
color: textColor,
|
|
47
|
-
}"
|
|
48
|
-
@click="handleMenuItemClick(item, i)"
|
|
38
|
+
:class="['hy-float-button__menus', `hy-float-button__menus--${shape}`]"
|
|
39
|
+
:style="menusStyle"
|
|
49
40
|
>
|
|
50
|
-
|
|
41
|
+
<template v-for="(item, i) in menus" :key="i">
|
|
42
|
+
<view
|
|
43
|
+
class="hy-float-button__menus--item"
|
|
44
|
+
:style="{
|
|
45
|
+
width: getFloatBtnSize,
|
|
46
|
+
height: getFloatBtnSize,
|
|
47
|
+
color: textColor
|
|
48
|
+
}"
|
|
49
|
+
@click="handleMenuItemClick(item, i)"
|
|
50
|
+
>
|
|
51
|
+
{{ typeof item === 'string' ? item : item.label }}
|
|
52
|
+
</view>
|
|
53
|
+
<hy-line
|
|
54
|
+
v-if="i !== menus.length - 1"
|
|
55
|
+
color="#FFFFFF"
|
|
56
|
+
:length="addUnit(getPx(getFloatBtnSize) * 0.7)"
|
|
57
|
+
:direction="direction === 'row' ? 'column' : 'row'"
|
|
58
|
+
:custom-style="{ margin: 'auto' }"
|
|
59
|
+
></hy-line>
|
|
60
|
+
</template>
|
|
51
61
|
</view>
|
|
52
|
-
|
|
53
|
-
v-if="i !== menus.length - 1"
|
|
54
|
-
color="#FFFFFF"
|
|
55
|
-
:length="addUnit(getPx(getFloatBtnSize) * 0.7)"
|
|
56
|
-
:direction="direction === 'row' ? 'column' : 'row'"
|
|
57
|
-
:custom-style="{ margin: 'auto' }"
|
|
58
|
-
></HyLine>
|
|
59
|
-
</template>
|
|
62
|
+
<!-- 菜单栏 -->
|
|
60
63
|
</view>
|
|
61
|
-
<!-- 菜单栏 -->
|
|
62
|
-
</view>
|
|
63
64
|
</template>
|
|
64
65
|
|
|
65
66
|
<script lang="ts">
|
|
66
67
|
export default {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
68
|
+
name: 'hy-float-button',
|
|
69
|
+
options: {
|
|
70
|
+
addGlobalClass: true,
|
|
71
|
+
virtualHost: true,
|
|
72
|
+
styleIsolation: 'shared'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
74
75
|
</script>
|
|
75
76
|
|
|
76
77
|
<script lang="ts" setup>
|
|
77
|
-
import {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
watch,
|
|
84
|
-
} from "vue";
|
|
85
|
-
import type { CSSProperties, PropType } from "vue";
|
|
86
|
-
import type { IFloatButtonEmits, IGap } from "./typing";
|
|
87
|
-
import type { MenusType } from "./typing";
|
|
88
|
-
import { addUnit, getPx, getRect, guid, isH5, IconConfig } from "../../libs";
|
|
78
|
+
import { computed, getCurrentInstance, onMounted, ref, reactive, watch } from 'vue'
|
|
79
|
+
import type { CSSProperties } from 'vue'
|
|
80
|
+
import type { IFloatButtonEmits } from './typing'
|
|
81
|
+
import type { MenusType } from './typing'
|
|
82
|
+
import { addUnit, getPx, getRect, guid, isH5 } from '../../libs'
|
|
83
|
+
import floatButtonProps from './props'
|
|
89
84
|
// 组件
|
|
90
|
-
import HyIcon from
|
|
91
|
-
import HyLine from
|
|
85
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
86
|
+
import HyLine from '../hy-line/hy-line.vue'
|
|
92
87
|
|
|
93
88
|
/**
|
|
94
89
|
* 悬浮动作按钮组件,按下可显示一组动作按钮。
|
|
95
90
|
* @displayName hy-float-button
|
|
96
91
|
*/
|
|
97
|
-
defineOptions({})
|
|
92
|
+
defineOptions({})
|
|
98
93
|
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
/** 菜单栏集合 */
|
|
102
|
-
menus: {
|
|
103
|
-
type: Array as unknown as PropType<MenusType[]>,
|
|
104
|
-
default: [],
|
|
105
|
-
},
|
|
106
|
-
/**
|
|
107
|
-
* 打开方向
|
|
108
|
-
* @values row,column
|
|
109
|
-
* */
|
|
110
|
-
direction: {
|
|
111
|
-
type: String,
|
|
112
|
-
default: "column",
|
|
113
|
-
},
|
|
114
|
-
/** 按钮显示的图标 */
|
|
115
|
-
icon: {
|
|
116
|
-
type: String,
|
|
117
|
-
default: IconConfig.PLUS,
|
|
118
|
-
},
|
|
119
|
-
/** 按钮图标大小 */
|
|
120
|
-
iconSize: String,
|
|
121
|
-
/** 按钮图标颜色 */
|
|
122
|
-
iconColor: String,
|
|
123
|
-
/** 到边框最小距离 */
|
|
124
|
-
gap: {
|
|
125
|
-
type: Object as unknown as PropType<IGap>,
|
|
126
|
-
default: { left: 16, right: 16, top: 16, bottom: 40 },
|
|
127
|
-
},
|
|
128
|
-
/** 层级 */
|
|
129
|
-
zIndex: {
|
|
130
|
-
type: Number,
|
|
131
|
-
default: 10086,
|
|
132
|
-
},
|
|
133
|
-
/** 按钮背景颜色 */
|
|
134
|
-
bgColor: String,
|
|
135
|
-
/** 按钮文字 */
|
|
136
|
-
text: String,
|
|
137
|
-
/** 按钮文字大小 */
|
|
138
|
-
fontSize: {
|
|
139
|
-
type: [Number, String],
|
|
140
|
-
default: 12,
|
|
141
|
-
},
|
|
142
|
-
/** 按钮文字的颜色 */
|
|
143
|
-
textColor: String,
|
|
144
|
-
/**
|
|
145
|
-
* 按钮的尺寸
|
|
146
|
-
* @values small,medium,large
|
|
147
|
-
* */
|
|
148
|
-
size: {
|
|
149
|
-
type: [String, Number] as PropType<string | number>,
|
|
150
|
-
default: "medium",
|
|
151
|
-
},
|
|
152
|
-
/**
|
|
153
|
-
* 按钮的形状
|
|
154
|
-
* @values circle,square
|
|
155
|
-
* */
|
|
156
|
-
shape: {
|
|
157
|
-
type: String,
|
|
158
|
-
default: "circle",
|
|
159
|
-
},
|
|
160
|
-
/** 按钮的透明度 */
|
|
161
|
-
opacity: {
|
|
162
|
-
type: Number,
|
|
163
|
-
default: 1,
|
|
164
|
-
},
|
|
165
|
-
/** 是否显示阴影 */
|
|
166
|
-
shadow: {
|
|
167
|
-
type: Boolean,
|
|
168
|
-
default: true,
|
|
169
|
-
},
|
|
170
|
-
/** 是否显示漂浮的动画 */
|
|
171
|
-
float: {
|
|
172
|
-
type: Boolean,
|
|
173
|
-
default: true,
|
|
174
|
-
},
|
|
175
|
-
/** 是否固定位置 */
|
|
176
|
-
fixed: {
|
|
177
|
-
type: Boolean,
|
|
178
|
-
default: true,
|
|
179
|
-
},
|
|
180
|
-
/** 是否能拖动 */
|
|
181
|
-
draggable: {
|
|
182
|
-
type: Boolean,
|
|
183
|
-
default: true,
|
|
184
|
-
},
|
|
185
|
-
/**
|
|
186
|
-
* 悬浮按钮位置
|
|
187
|
-
* @values left-top,left-bottom,right-top,right-bottom,left-center,right-center,top-center,bottom-center
|
|
188
|
-
* */
|
|
189
|
-
position: {
|
|
190
|
-
type: String,
|
|
191
|
-
default: "right-bottom",
|
|
192
|
-
},
|
|
193
|
-
/** 禁用点击打开菜单栏 */
|
|
194
|
-
expandable: {
|
|
195
|
-
type: Boolean,
|
|
196
|
-
default: true,
|
|
197
|
-
},
|
|
198
|
-
/** 定义需要用到的外部样式 */
|
|
199
|
-
customStyle: {
|
|
200
|
-
type: Object as PropType<CSSProperties>,
|
|
201
|
-
},
|
|
202
|
-
/** 自定义外部类名 */
|
|
203
|
-
customClass: String,
|
|
204
|
-
});
|
|
205
|
-
const emit = defineEmits<IFloatButtonEmits>();
|
|
94
|
+
const props = defineProps(floatButtonProps)
|
|
95
|
+
const emit = defineEmits<IFloatButtonEmits>()
|
|
206
96
|
|
|
207
|
-
const instance = getCurrentInstance()
|
|
97
|
+
const instance = getCurrentInstance()
|
|
208
98
|
const btnSize: AnyObject = {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
const open = ref(false)
|
|
214
|
-
const rotate = computed(() => (open.value && !props.text ?
|
|
215
|
-
const soleId = `hy-float-button__${guid()}
|
|
216
|
-
const fabSize = reactive({ width: 0, height: 0 })
|
|
217
|
-
const screen = reactive({ width: 0, height: 0 })
|
|
99
|
+
small: '50px',
|
|
100
|
+
medium: '60px',
|
|
101
|
+
large: '70px'
|
|
102
|
+
}
|
|
103
|
+
const open = ref(false)
|
|
104
|
+
const rotate = computed(() => (open.value && !props.text ? '45deg' : '0deg'))
|
|
105
|
+
const soleId = `hy-float-button__${guid()}`
|
|
106
|
+
const fabSize = reactive({ width: 0, height: 0 }) // 悬浮按钮大小
|
|
107
|
+
const screen = reactive({ width: 0, height: 0 })
|
|
218
108
|
const currentCoordinate = reactive({
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
})
|
|
109
|
+
top: 0,
|
|
110
|
+
left: 0
|
|
111
|
+
})
|
|
222
112
|
// 按下时坐标相对于元素的偏移量
|
|
223
|
-
const touchOffset = reactive({ x: 0, y: 0 })
|
|
224
|
-
const attractTransition = ref<boolean>(false)
|
|
225
|
-
const fabDirection = ref<HyApp.LeftRightType>(
|
|
226
|
-
const fabDirection2 = ref<HyApp.TopBottomType>(
|
|
113
|
+
const touchOffset = reactive({ x: 0, y: 0 })
|
|
114
|
+
const attractTransition = ref<boolean>(false)
|
|
115
|
+
const fabDirection = ref<HyApp.LeftRightType>('left')
|
|
116
|
+
const fabDirection2 = ref<HyApp.TopBottomType>('top')
|
|
227
117
|
const bounding = reactive({
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
})
|
|
118
|
+
minLeft: 10,
|
|
119
|
+
minTop: 10,
|
|
120
|
+
maxLeft: 380,
|
|
121
|
+
maxTop: 680
|
|
122
|
+
})
|
|
233
123
|
|
|
234
124
|
onMounted(async () => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
})
|
|
125
|
+
await getFatRect()
|
|
126
|
+
await getBounding()
|
|
127
|
+
initPosition()
|
|
128
|
+
})
|
|
239
129
|
|
|
240
130
|
watch(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
)
|
|
131
|
+
() => props.position,
|
|
132
|
+
() => initPosition()
|
|
133
|
+
)
|
|
244
134
|
|
|
245
135
|
/**
|
|
246
136
|
* @description 初始化距离
|
|
247
137
|
* */
|
|
248
138
|
const initPosition = () => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
139
|
+
const { minLeft, minTop, maxLeft, maxTop } = bounding
|
|
140
|
+
const centerY = (maxTop + minTop) / 2
|
|
141
|
+
const centerX = (maxLeft + minLeft) / 2
|
|
252
142
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
143
|
+
switch (props.position) {
|
|
144
|
+
case 'left-top':
|
|
145
|
+
currentCoordinate.top = minTop
|
|
146
|
+
currentCoordinate.left = minLeft
|
|
147
|
+
fabDirection.value = 'left'
|
|
148
|
+
fabDirection2.value = 'top'
|
|
149
|
+
break
|
|
150
|
+
case 'right-top':
|
|
151
|
+
currentCoordinate.top = minTop
|
|
152
|
+
currentCoordinate.left = maxLeft
|
|
153
|
+
fabDirection.value = 'right'
|
|
154
|
+
fabDirection2.value = 'top'
|
|
155
|
+
break
|
|
156
|
+
case 'left-bottom':
|
|
157
|
+
currentCoordinate.top = maxTop
|
|
158
|
+
currentCoordinate.left = minLeft
|
|
159
|
+
fabDirection.value = 'left'
|
|
160
|
+
fabDirection2.value = 'bottom'
|
|
161
|
+
break
|
|
162
|
+
case 'right-bottom':
|
|
163
|
+
currentCoordinate.top = maxTop
|
|
164
|
+
currentCoordinate.left = maxLeft
|
|
165
|
+
fabDirection.value = 'right'
|
|
166
|
+
fabDirection2.value = 'bottom'
|
|
167
|
+
break
|
|
168
|
+
case 'left-center':
|
|
169
|
+
currentCoordinate.top = centerY
|
|
170
|
+
currentCoordinate.left = minLeft
|
|
171
|
+
fabDirection.value = 'left'
|
|
172
|
+
fabDirection2.value = 'bottom'
|
|
173
|
+
break
|
|
174
|
+
case 'right-center':
|
|
175
|
+
currentCoordinate.top = centerY
|
|
176
|
+
currentCoordinate.left = maxLeft
|
|
177
|
+
fabDirection.value = 'right'
|
|
178
|
+
fabDirection2.value = 'bottom'
|
|
179
|
+
break
|
|
180
|
+
case 'top-center':
|
|
181
|
+
currentCoordinate.top = minTop
|
|
182
|
+
currentCoordinate.left = centerX
|
|
183
|
+
fabDirection.value = 'left'
|
|
184
|
+
fabDirection2.value = 'top'
|
|
185
|
+
break
|
|
186
|
+
case 'bottom-center':
|
|
187
|
+
currentCoordinate.top = maxTop
|
|
188
|
+
currentCoordinate.left = centerX
|
|
189
|
+
fabDirection.value = 'left'
|
|
190
|
+
fabDirection2.value = 'bottom'
|
|
191
|
+
break
|
|
192
|
+
}
|
|
193
|
+
}
|
|
304
194
|
|
|
305
195
|
/**
|
|
306
196
|
* @description 获取组件大小
|
|
307
197
|
* */
|
|
308
198
|
const getFloatBtnSize = computed(() => {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
return addUnit(props.size);
|
|
316
|
-
}
|
|
317
|
-
});
|
|
199
|
+
if (typeof props.size === 'string' && Object.keys(btnSize).includes(props.size)) {
|
|
200
|
+
return btnSize[props.size]
|
|
201
|
+
} else {
|
|
202
|
+
return addUnit(props.size)
|
|
203
|
+
}
|
|
204
|
+
})
|
|
318
205
|
|
|
319
206
|
/**
|
|
320
207
|
* @description 悬浮按钮样式
|
|
321
208
|
* */
|
|
322
209
|
const FloatButtonStyle = computed(() => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
210
|
+
const style: CSSProperties = {
|
|
211
|
+
top: currentCoordinate.top + 'px',
|
|
212
|
+
left: currentCoordinate.left + 'px',
|
|
213
|
+
backgroundColor: props.bgColor,
|
|
214
|
+
zIndex: props.zIndex,
|
|
215
|
+
color: props.textColor,
|
|
216
|
+
transition: 'all ease 0.3s'
|
|
217
|
+
}
|
|
218
|
+
if (props.fixed) style.position = 'fixed'
|
|
332
219
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
})
|
|
220
|
+
style.height = getFloatBtnSize.value
|
|
221
|
+
style.width = getFloatBtnSize.value
|
|
222
|
+
return Object.assign(style, props.customStyle)
|
|
223
|
+
})
|
|
337
224
|
const menusStyle = computed(() => {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
// 判断横向展示还是纵向展示
|
|
343
|
-
if (props.direction === "row") {
|
|
344
|
-
if (fabDirection.value === "right") {
|
|
345
|
-
style.transform = "translateX(-100%)";
|
|
346
|
-
style.left = "100%";
|
|
347
|
-
style.paddingRight = getFloatBtnSize.value;
|
|
348
|
-
style.flexDirection = "row-reverse";
|
|
349
|
-
} else {
|
|
350
|
-
style.paddingLeft = getFloatBtnSize.value;
|
|
225
|
+
const style: CSSProperties = {
|
|
226
|
+
backgroundColor: props.bgColor
|
|
351
227
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
228
|
+
|
|
229
|
+
// 判断横向展示还是纵向展示
|
|
230
|
+
if (props.direction === 'row') {
|
|
231
|
+
if (fabDirection.value === 'right') {
|
|
232
|
+
style.transform = 'translateX(-100%)'
|
|
233
|
+
style.left = '100%'
|
|
234
|
+
style.paddingRight = getFloatBtnSize.value
|
|
235
|
+
style.flexDirection = 'row-reverse'
|
|
236
|
+
} else {
|
|
237
|
+
style.paddingLeft = getFloatBtnSize.value
|
|
238
|
+
}
|
|
239
|
+
style.bottom = 0
|
|
240
|
+
style.transition = 'width 0.5s ease'
|
|
241
|
+
style.height = getFloatBtnSize.value
|
|
242
|
+
style.width = open.value
|
|
243
|
+
? addUnit(
|
|
244
|
+
getPx(getFloatBtnSize.value) * props.menus.length + getPx(getFloatBtnSize.value)
|
|
245
|
+
)
|
|
246
|
+
: 0
|
|
368
247
|
} else {
|
|
369
|
-
|
|
370
|
-
|
|
248
|
+
if (fabDirection2.value === 'top') {
|
|
249
|
+
style.transform = 'translateX(-100%)'
|
|
250
|
+
style.height = '100%'
|
|
251
|
+
style.left = getFloatBtnSize.value
|
|
252
|
+
style.top = '0px'
|
|
253
|
+
style.paddingTop = getFloatBtnSize.value
|
|
254
|
+
} else {
|
|
255
|
+
style.paddingBottom = getFloatBtnSize.value
|
|
256
|
+
style.bottom = 0
|
|
257
|
+
}
|
|
258
|
+
style.transition = 'height 0.5s ease'
|
|
259
|
+
style.width = getFloatBtnSize.value
|
|
260
|
+
style.height = open.value
|
|
261
|
+
? addUnit(
|
|
262
|
+
getPx(getFloatBtnSize.value) * props.menus.length + getPx(getFloatBtnSize.value)
|
|
263
|
+
)
|
|
264
|
+
: 0
|
|
371
265
|
}
|
|
372
|
-
style
|
|
373
|
-
|
|
374
|
-
style.height = open.value
|
|
375
|
-
? addUnit(
|
|
376
|
-
getPx(getFloatBtnSize.value) * props.menus.length +
|
|
377
|
-
getPx(getFloatBtnSize.value),
|
|
378
|
-
)
|
|
379
|
-
: 0;
|
|
380
|
-
}
|
|
381
|
-
return style;
|
|
382
|
-
});
|
|
266
|
+
return style
|
|
267
|
+
})
|
|
383
268
|
|
|
384
269
|
/**
|
|
385
270
|
* @description 获取悬浮按钮大小
|
|
386
271
|
* */
|
|
387
272
|
const getFatRect = () => {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
273
|
+
return new Promise((resolve, reject) => {
|
|
274
|
+
getRect(`#${soleId}`, false, instance)
|
|
275
|
+
.then((rect) => {
|
|
276
|
+
const { width, height } = rect as UniApp.NodeInfo
|
|
277
|
+
fabSize.width = width as number
|
|
278
|
+
fabSize.height = height as number
|
|
279
|
+
resolve(rect)
|
|
280
|
+
})
|
|
281
|
+
.catch((err) => {
|
|
282
|
+
reject(err)
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
}
|
|
401
286
|
|
|
402
287
|
/**
|
|
403
288
|
* @description 点击悬浮按钮
|
|
404
289
|
* */
|
|
405
290
|
const handleClick = () => {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
291
|
+
emit('click')
|
|
292
|
+
if (props.expandable) {
|
|
293
|
+
open.value = !open.value
|
|
294
|
+
}
|
|
295
|
+
}
|
|
411
296
|
|
|
412
297
|
/**
|
|
413
298
|
* @description 点击单条菜单栏
|
|
414
299
|
* */
|
|
415
300
|
const handleMenuItemClick = (temp: MenusType, index: number) => {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
301
|
+
emit('clickItem', temp, index)
|
|
302
|
+
open.value = false
|
|
303
|
+
if (typeof temp !== 'string' && temp?.url) {
|
|
304
|
+
uni.navigateTo({
|
|
305
|
+
url: temp.url
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
}
|
|
424
309
|
|
|
425
310
|
const getBounding = () => {
|
|
426
|
-
|
|
427
|
-
|
|
311
|
+
return new Promise((resolve) => {
|
|
312
|
+
const sysInfo = uni.getSystemInfoSync()
|
|
428
313
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
});
|
|
440
|
-
};
|
|
314
|
+
const { top = 16, left = 16, right = 16, bottom = 16 } = props.gap
|
|
315
|
+
screen.width = sysInfo.windowWidth
|
|
316
|
+
screen.height = isH5 ? sysInfo.windowTop + sysInfo.windowHeight : sysInfo.windowHeight
|
|
317
|
+
bounding.minTop = isH5 ? sysInfo.windowTop + top : top
|
|
318
|
+
bounding.minLeft = left
|
|
319
|
+
bounding.maxLeft = screen.width - fabSize.width - right
|
|
320
|
+
bounding.maxTop = screen.height - fabSize.height - bottom
|
|
321
|
+
resolve(bounding)
|
|
322
|
+
})
|
|
323
|
+
}
|
|
441
324
|
|
|
442
325
|
const handleTouchStart = (e: TouchEvent) => {
|
|
443
|
-
|
|
326
|
+
if (!props.draggable) return
|
|
444
327
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
}
|
|
328
|
+
const touch = e.touches[0]
|
|
329
|
+
touchOffset.x = touch.clientX - getPx(currentCoordinate.left)
|
|
330
|
+
touchOffset.y = touch.clientY - getPx(currentCoordinate.top)
|
|
331
|
+
attractTransition.value = false
|
|
332
|
+
}
|
|
450
333
|
|
|
451
334
|
function handleTouchMove(e: TouchEvent) {
|
|
452
|
-
|
|
335
|
+
if (!props.draggable) return
|
|
453
336
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
337
|
+
const touch = e.touches[0]
|
|
338
|
+
const { minLeft, minTop, maxLeft, maxTop } = bounding
|
|
339
|
+
let x = touch.clientX - touchOffset.x
|
|
340
|
+
let y = touch.clientY - touchOffset.y
|
|
458
341
|
|
|
459
|
-
|
|
460
|
-
|
|
342
|
+
if (x < minLeft) x = minLeft
|
|
343
|
+
else if (x > maxLeft) x = maxLeft
|
|
461
344
|
|
|
462
|
-
|
|
463
|
-
|
|
345
|
+
if (y < minTop) y = minTop
|
|
346
|
+
else if (y > maxTop) y = maxTop
|
|
464
347
|
|
|
465
|
-
|
|
466
|
-
|
|
348
|
+
currentCoordinate.top = y
|
|
349
|
+
currentCoordinate.left = x
|
|
467
350
|
}
|
|
468
351
|
|
|
469
352
|
function handleTouchEnd() {
|
|
470
|
-
|
|
353
|
+
if (!props.draggable) return
|
|
471
354
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
355
|
+
const screenCenterX = screen.width / 2
|
|
356
|
+
const fabCenterX = currentCoordinate.left + fabSize.width / 2
|
|
357
|
+
attractTransition.value = true
|
|
358
|
+
if (fabCenterX < screenCenterX) {
|
|
359
|
+
currentCoordinate.left = bounding.minLeft
|
|
360
|
+
fabDirection.value = 'left'
|
|
361
|
+
} else {
|
|
362
|
+
currentCoordinate.left = bounding.maxLeft
|
|
363
|
+
fabDirection.value = 'right'
|
|
364
|
+
}
|
|
482
365
|
}
|
|
483
366
|
</script>
|
|
484
367
|
|
|
485
368
|
<style scoped lang="scss">
|
|
486
|
-
@import
|
|
369
|
+
@import './index.scss';
|
|
487
370
|
.hy-float-button {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
371
|
+
&__container {
|
|
372
|
+
rotate: v-bind(rotate);
|
|
373
|
+
}
|
|
374
|
+
&__menus {
|
|
375
|
+
display: flex;
|
|
376
|
+
flex-direction: v-bind(direction);
|
|
377
|
+
}
|
|
495
378
|
}
|
|
496
379
|
</style>
|