hy-app 0.1.2 → 0.1.3
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/README.md +1 -1
- package/api/http.ts +8 -8
- package/components/dialog/index.ts +2 -2
- package/components/hy-address-picker/hy-address-picker.vue +3 -29
- package/components/hy-address-picker/index.scss +27 -0
- package/components/hy-avatar/hy-avatar.vue +1 -45
- package/components/hy-avatar/index.scss +45 -0
- package/components/hy-avatar/typing.d.ts +1 -1
- package/components/hy-back-top/hy-back-top.vue +7 -22
- package/components/hy-back-top/index.scss +16 -0
- package/components/hy-back-top/props.ts +4 -4
- package/components/hy-back-top/typing.d.ts +2 -3
- package/components/hy-badge/hy-badge.vue +1 -72
- package/components/hy-badge/index.scss +72 -0
- package/components/hy-button/hy-button.vue +12 -124
- package/components/hy-button/index.scss +116 -0
- package/components/hy-calendar/header.vue +76 -0
- package/components/hy-calendar/hy-calendar.vue +366 -0
- package/components/hy-calendar/index.scss +171 -0
- package/components/hy-calendar/month.vue +524 -0
- package/components/hy-calendar/props.ts +37 -0
- package/components/hy-calendar/typing.d.ts +126 -0
- package/components/hy-card/hy-card.vue +21 -84
- package/components/hy-card/index.scss +57 -0
- package/components/hy-card/props.ts +2 -2
- package/components/hy-card/typing.d.ts +1 -1
- package/components/hy-cell/hy-cell.vue +1 -137
- package/components/hy-cell/index.scss +137 -0
- package/components/hy-check-button/hy-check-button.vue +1 -0
- package/components/hy-check-button/index.scss +5 -0
- package/components/hy-checkbox/hy-checkbox.vue +2 -95
- package/components/hy-checkbox/index.scss +94 -0
- package/components/hy-checkbox/typing.d.ts +1 -2
- package/components/hy-count-down/hy-count-down.vue +150 -0
- package/components/hy-count-down/index.scss +6 -0
- package/components/hy-count-down/index.ts +52 -0
- package/components/hy-count-down/props.ts +10 -0
- package/components/hy-count-down/typing.d.ts +20 -0
- package/components/hy-count-to/hy-count-to.vue +213 -0
- package/components/hy-count-to/index.scss +6 -0
- package/components/hy-count-to/props.ts +17 -0
- package/components/hy-count-to/typing.d.ts +48 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +2 -28
- package/components/hy-datetime-picker/index.scss +28 -0
- package/components/hy-divider/hy-divider.vue +24 -49
- package/components/hy-divider/index.scss +25 -0
- package/components/hy-divider/props.ts +2 -2
- package/components/hy-divider/typing.d.ts +1 -1
- package/components/hy-dropdown/hy-dropdown.vue +43 -0
- package/components/hy-dropdown/index.scss +17 -0
- package/components/hy-dropdown/props.ts +17 -0
- package/components/hy-dropdown/typing.d.ts +48 -0
- package/components/hy-dropdown-item/hy-dropdown-item.vue +194 -0
- package/components/hy-dropdown-item/index.scss +96 -0
- package/components/hy-dropdown-item/props.ts +10 -0
- package/components/hy-dropdown-item/typing.d.ts +31 -0
- package/components/hy-empty/hy-empty.vue +8 -26
- package/components/hy-empty/index.scss +19 -0
- package/components/hy-empty/props.ts +2 -2
- package/components/hy-empty/typing.d.ts +1 -1
- package/components/hy-float-button/hy-float-button.vue +201 -0
- package/components/hy-float-button/index.scss +69 -0
- package/components/hy-float-button/props.ts +25 -0
- package/components/hy-float-button/typing.d.ts +93 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +9 -12
- package/components/hy-folding-panel/index.scss +6 -0
- package/components/hy-folding-panel/props.ts +2 -2
- package/components/hy-folding-panel/typing.d.ts +2 -2
- package/components/hy-form/hy-form.vue +17 -34
- package/components/hy-form/index.scss +30 -0
- package/components/hy-form/props.ts +2 -0
- package/components/hy-form/typing.d.ts +9 -1
- package/components/hy-grid/hy-grid.vue +1 -43
- package/components/hy-grid/index.scss +40 -0
- package/components/hy-icon/hy-icon.vue +1 -93
- package/components/hy-icon/index.scss +84 -0
- package/components/hy-image/hy-image.vue +212 -0
- package/components/hy-image/index.scss +26 -0
- package/components/hy-image/props.ts +24 -0
- package/components/hy-image/typing.d.ts +76 -0
- package/components/hy-input/hy-input.vue +2 -72
- package/components/hy-input/index.scss +65 -0
- package/components/hy-line/hy-line.vue +4 -8
- package/components/hy-line/index.scss +5 -0
- package/components/hy-line/props.ts +3 -3
- package/components/hy-line/typing.d.ts +2 -2
- package/components/hy-line-progress/hy-line-progress.vue +15 -44
- package/components/hy-line-progress/index.scss +38 -0
- package/components/hy-line-progress/props.ts +2 -2
- package/components/hy-line-progress/typing.d.ts +1 -1
- package/components/hy-list/hy-list.vue +11 -41
- package/components/hy-list/index.scss +32 -0
- package/components/hy-list/props.ts +2 -2
- package/components/hy-loading/hy-loading.vue +95 -0
- package/components/hy-loading/index.scss +103 -0
- package/components/hy-loading/props.ts +17 -0
- package/components/hy-loading/typing.d.ts +52 -0
- package/components/hy-login/TheUserLogin.vue +16 -16
- package/components/hy-login/hy-login.vue +9 -9
- package/components/hy-login/props.ts +4 -4
- package/components/hy-modal/hy-modal.vue +11 -89
- package/components/hy-modal/index.scss +77 -0
- package/components/hy-modal/props.ts +2 -2
- package/components/hy-modal/typing.d.ts +1 -1
- package/components/hy-navbar/hy-navbar.vue +20 -92
- package/components/hy-navbar/index.scss +67 -0
- package/components/hy-navbar/props.ts +2 -2
- package/components/hy-navbar/typing.d.ts +1 -1
- package/components/hy-notice-bar/hy-column-notice.vue +11 -39
- package/components/hy-notice-bar/hy-notice-bar.vue +10 -12
- package/components/hy-notice-bar/hy-row-notice.vue +5 -56
- package/components/hy-notice-bar/index.scss +93 -0
- package/components/hy-notice-bar/props.ts +4 -2
- package/components/hy-notice-bar/typing.d.ts +13 -3
- package/components/hy-number-step/hy-number-step.vue +1 -70
- package/components/hy-number-step/index.scss +71 -0
- package/components/hy-overlay/hy-overlay.vue +2 -14
- package/components/hy-overlay/index.scss +9 -0
- package/components/hy-picker/hy-picker.vue +1 -68
- package/components/hy-picker/index.scss +68 -0
- package/components/hy-popup/hy-popup.vue +1 -74
- package/components/hy-popup/index.scss +60 -0
- package/components/hy-price/hy-price.vue +1 -11
- package/components/hy-price/index.scss +11 -0
- package/components/hy-qrcode/hy-qrcode.vue +15 -37
- package/components/hy-qrcode/index.scss +23 -0
- package/components/hy-qrcode/props.ts +2 -2
- package/components/hy-qrcode/typing.d.ts +2 -2
- package/components/hy-radio/hy-radio.vue +2 -101
- package/components/hy-radio/index.scss +93 -0
- package/components/hy-radio/typing.d.ts +1 -2
- package/components/hy-rate/hy-rate.vue +1 -33
- package/components/hy-rate/index.scss +33 -0
- package/components/hy-read-more/hy-read-more.vue +7 -30
- package/components/hy-read-more/index.scss +25 -0
- package/components/hy-read-more/props.ts +3 -3
- package/components/hy-read-more/typing.d.ts +1 -1
- package/components/hy-safe-bottom/hy-safe-bottom.vue +5 -9
- package/components/hy-safe-bottom/index.scss +5 -0
- package/components/hy-scroll-list/hy-scroll-list.vue +13 -43
- package/components/hy-scroll-list/index.scss +34 -0
- package/components/hy-scroll-list/props.ts +2 -2
- package/components/hy-scroll-list/typing.d.ts +1 -1
- package/components/hy-search/hy-search.vue +1 -83
- package/components/hy-search/index.scss +83 -0
- package/components/hy-slider/hy-slider.vue +14 -92
- package/components/hy-slider/index.scss +77 -0
- package/components/hy-status-bar/hy-status-bar.vue +41 -0
- package/components/hy-status-bar/index.scss +6 -0
- package/components/hy-status-bar/props.ts +8 -0
- package/components/hy-status-bar/typing.d.ts +12 -0
- package/components/hy-steps/hy-steps.vue +36 -163
- package/components/hy-steps/index.scss +131 -0
- package/components/hy-steps/props.ts +2 -2
- package/components/hy-steps/typing.d.ts +2 -2
- package/components/hy-subsection/hy-subsection.vue +40 -132
- package/components/hy-subsection/index.scss +82 -0
- package/components/hy-subsection/props.ts +1 -0
- package/components/hy-subsection/typing.d.ts +13 -4
- package/components/hy-swipe-action/hy-swipe-action.vue +294 -0
- package/components/hy-swipe-action/index.scss +9 -0
- package/components/hy-swipe-action/index.wxs +235 -0
- package/components/hy-swipe-action/props.ts +16 -0
- package/components/hy-swipe-action/typing.d.ts +55 -0
- package/components/hy-swipe-action/wxs.js +15 -0
- package/components/hy-swiper/hy-swiper-indicator.vue +5 -35
- package/components/hy-swiper/hy-swiper.vue +1 -54
- package/components/hy-swiper/index.scss +82 -0
- package/components/hy-switch/hy-switch.vue +62 -72
- package/components/hy-switch/index.scss +46 -0
- package/components/hy-switch/props.ts +4 -1
- package/components/hy-switch/typing.d.ts +14 -1
- package/components/hy-tabs/hy-tabs.vue +22 -81
- package/components/hy-tabs/index.scss +63 -0
- package/components/hy-tabs/props.ts +5 -5
- package/components/hy-tabs/typing.d.ts +1 -1
- package/components/hy-tag/hy-tag.vue +1 -214
- package/components/hy-tag/index.scss +204 -0
- package/components/hy-text/hy-text.vue +238 -0
- package/components/hy-text/index.scss +70 -0
- package/components/hy-text/index.ts +0 -0
- package/components/hy-text/props.ts +30 -0
- package/components/hy-text/typing.d.ts +98 -0
- package/components/hy-textarea/hy-textarea.vue +1 -46
- package/components/hy-textarea/index.scss +40 -0
- package/components/hy-tooltip/hy-tooltip.vue +42 -95
- package/components/hy-tooltip/index.scss +64 -0
- package/components/hy-tooltip/props.ts +2 -2
- package/components/hy-tooltip/typing.d.ts +1 -1
- package/components/hy-transition/hy-transition.vue +4 -2
- package/components/hy-transition/typing.d.ts +1 -13
- package/components/hy-upload/hy-upload.vue +37 -182
- package/components/hy-upload/index.scss +147 -0
- package/components/hy-upload/props.ts +2 -2
- package/components/hy-upload/typing.d.ts +11 -11
- package/components/hy-warn/hy-warn.vue +15 -123
- package/components/hy-warn/index.scss +109 -0
- package/components/hy-warn/props.ts +3 -3
- package/components/hy-warn/typing.d.ts +4 -3
- package/components/hy-waterfall/index.scss +82 -0
- package/components/index.ts +25 -1
- package/components/message/index.ts +54 -54
- package/config/color.ts +2 -1
- package/global/index.ts +6 -6
- package/global/register-properties.ts +2 -2
- package/index.scss +2 -1
- package/libs/css/common.scss +14 -2
- package/package.json +2 -2
- package/{libs/css → public/font}/iconfont.css +4 -4
- package/theme.scss +6 -4
- package/typing/modules/common.d.ts +16 -1
- package/utils/calendar.js +1021 -0
- package/utils/colorGradient.ts +112 -0
- package/utils/index.ts +2 -0
- package/utils/inside.ts +80 -34
- package/utils/inspect.ts +66 -0
- package/utils/utils.ts +11 -12
- package/libs/css/download.zip +0 -0
- /package/{libs/css → public/font}/iconfont.ttf +0 -0
- /package/{libs/css → public/font}/iconfont.woff +0 -0
- /package/{libs/css → public/font}/iconfont.woff2 +0 -0
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="hy-divider" :style="dividerStyle" @tap="clickHandler">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
:
|
|
7
|
-
:
|
|
8
|
-
|
|
9
|
-
></
|
|
3
|
+
<HyLine
|
|
4
|
+
:color="lineColor"
|
|
5
|
+
:customStyle="leftLineStyle"
|
|
6
|
+
:style="leftLineStyle"
|
|
7
|
+
:hairline="hairline"
|
|
8
|
+
:dashed="dashed"
|
|
9
|
+
></HyLine>
|
|
10
|
+
<HyLoading :show="text === 'loading'" size="18" mode="spinner"></HyLoading>
|
|
10
11
|
<text v-if="dot" class="hy-divider__dot">●</text>
|
|
11
12
|
<text v-else-if="text" class="hy-divider__text" :style="textStyle">{{
|
|
12
13
|
content
|
|
13
14
|
}}</text>
|
|
14
|
-
<
|
|
15
|
+
<HyLine
|
|
16
|
+
:color="lineColor"
|
|
17
|
+
:customStyle="rightLineStyle"
|
|
18
|
+
:style="rightLineStyle"
|
|
19
|
+
:hairline="hairline"
|
|
20
|
+
:dashed="dashed"
|
|
21
|
+
></HyLine>
|
|
15
22
|
</view>
|
|
16
23
|
</template>
|
|
17
24
|
|
|
18
25
|
<script setup lang="ts">
|
|
19
|
-
import { computed, CSSProperties, toRefs } from "vue";
|
|
26
|
+
import { computed, type CSSProperties, toRefs } from "vue";
|
|
20
27
|
import defaultProps from "./props";
|
|
21
|
-
import IProps from "./typing";
|
|
28
|
+
import type IProps from "./typing";
|
|
22
29
|
import { addUnit } from "../../utils";
|
|
23
|
-
import { IconConfig } from "../../config";
|
|
24
30
|
|
|
25
31
|
// 组件
|
|
26
|
-
import
|
|
32
|
+
import HyLine from "../hy-line/hy-line.vue";
|
|
33
|
+
import HyLoading from "../hy-loading/hy-loading.vue";
|
|
27
34
|
|
|
28
35
|
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
29
36
|
const {
|
|
@@ -38,7 +45,7 @@ const {
|
|
|
38
45
|
noMoreText,
|
|
39
46
|
marginTop,
|
|
40
47
|
marginBottom,
|
|
41
|
-
customStyle
|
|
48
|
+
customStyle,
|
|
42
49
|
} = toRefs(props);
|
|
43
50
|
const emit = defineEmits(["click"]);
|
|
44
51
|
|
|
@@ -87,21 +94,13 @@ const textStyle = computed<CSSProperties>(() => {
|
|
|
87
94
|
style.color = textColor.value;
|
|
88
95
|
return style;
|
|
89
96
|
});
|
|
90
|
-
|
|
91
|
-
* @description 线样式
|
|
92
|
-
* */
|
|
93
|
-
const lineStyle = computed<CSSProperties>(() => {
|
|
94
|
-
const style: CSSProperties = {
|
|
95
|
-
borderBottom: `1px ${dashed.value ? "dashed" : "solid"} ${lineColor.value}`
|
|
96
|
-
};
|
|
97
|
-
return style;
|
|
98
|
-
});
|
|
97
|
+
|
|
99
98
|
/**
|
|
100
99
|
* @description 左边线条的的样式
|
|
101
100
|
* */
|
|
102
101
|
const leftLineStyle = computed<CSSProperties>(() => {
|
|
103
102
|
const style: CSSProperties = {
|
|
104
|
-
marginRight: "20rpx"
|
|
103
|
+
marginRight: "20rpx",
|
|
105
104
|
};
|
|
106
105
|
// 如果是在左边,设置左边的宽度为固定值
|
|
107
106
|
if (isLoad) {
|
|
@@ -118,7 +117,7 @@ const leftLineStyle = computed<CSSProperties>(() => {
|
|
|
118
117
|
* */
|
|
119
118
|
const rightLineStyle = computed<CSSProperties>(() => {
|
|
120
119
|
const style: CSSProperties = {
|
|
121
|
-
marginLeft: "20rpx"
|
|
120
|
+
marginLeft: "20rpx",
|
|
122
121
|
};
|
|
123
122
|
// 如果是在右边,设置右边的宽度为固定值
|
|
124
123
|
if (isLoad) {
|
|
@@ -136,29 +135,5 @@ const clickHandler = () => {
|
|
|
136
135
|
</script>
|
|
137
136
|
|
|
138
137
|
<style lang="scss" scoped>
|
|
139
|
-
@import "
|
|
140
|
-
@import "../../theme.scss";
|
|
141
|
-
|
|
142
|
-
.hy-divider {
|
|
143
|
-
@include flex;
|
|
144
|
-
flex-direction: row;
|
|
145
|
-
justify-content: center;
|
|
146
|
-
align-items: center;
|
|
147
|
-
|
|
148
|
-
&__line {
|
|
149
|
-
/* #ifndef APP-NVUE */
|
|
150
|
-
vertical-align: middle;
|
|
151
|
-
/* #endif */
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
&__text {
|
|
155
|
-
margin: 0 $hy-border-margin-padding-sm;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
&__dot {
|
|
159
|
-
font-size: $hy-font-size-sm;
|
|
160
|
-
margin: 0 $hy-border-margin-padding-sm;
|
|
161
|
-
color: #c0c4cc;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
138
|
+
@import "./index.scss";
|
|
164
139
|
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@use "../../libs/css/mixin.scss" as *;
|
|
2
|
+
@use "../../theme.scss" as *;
|
|
3
|
+
|
|
4
|
+
.hy-divider {
|
|
5
|
+
@include flex;
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
9
|
+
|
|
10
|
+
&__line {
|
|
11
|
+
/* #ifndef APP-NVUE */
|
|
12
|
+
vertical-align: middle;
|
|
13
|
+
/* #endif */
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&__text {
|
|
17
|
+
margin: 0 $hy-border-margin-padding-sm;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__dot {
|
|
21
|
+
font-size: $hy-font-size-sm;
|
|
22
|
+
margin: 0 $hy-border-margin-padding-sm;
|
|
23
|
+
color: #c0c4cc;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import IProps from "./typing";
|
|
1
|
+
import type IProps from "./typing";
|
|
2
2
|
import { IconConfig } from "../../config";
|
|
3
3
|
|
|
4
4
|
const defaultProps: IProps = {
|
|
@@ -15,7 +15,7 @@ const defaultProps: IProps = {
|
|
|
15
15
|
loadingText: "正在加载...",
|
|
16
16
|
noMoreText: "没有更多了",
|
|
17
17
|
marginTop: "0",
|
|
18
|
-
marginBottom: "0"
|
|
18
|
+
marginBottom: "0",
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export default defaultProps;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-dropdown" :style="dropdownStyle">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { provide, ref, computed, type CSSProperties, toRefs } from "vue";
|
|
9
|
+
import type IProps from "./typing";
|
|
10
|
+
import defaultProps from "./props";
|
|
11
|
+
import { addUnit } from "@/package";
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
14
|
+
const { height, borderBottom } = toRefs(props);
|
|
15
|
+
|
|
16
|
+
//样式设置
|
|
17
|
+
const dropdownStyle = computed(() => {
|
|
18
|
+
const style: CSSProperties = props.sticky
|
|
19
|
+
? {
|
|
20
|
+
position: "sticky",
|
|
21
|
+
// #ifdef H5
|
|
22
|
+
top: "44px",
|
|
23
|
+
// #endif
|
|
24
|
+
// #ifndef H5
|
|
25
|
+
top: 0,
|
|
26
|
+
// #endif
|
|
27
|
+
}
|
|
28
|
+
: {};
|
|
29
|
+
style.height = addUnit(height.value);
|
|
30
|
+
if (borderBottom.value) style.borderBottom = "1px solid #dadbde";
|
|
31
|
+
|
|
32
|
+
return style;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
//当前打开的项(以标题标识)
|
|
36
|
+
const currentDropItem = ref("");
|
|
37
|
+
provide("dropdownProps", props);
|
|
38
|
+
provide("currentDropItem", currentDropItem);
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<style lang="scss" scoped>
|
|
42
|
+
@import "./index.scss";
|
|
43
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.hy-dropdown {
|
|
2
|
+
width: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
background-color: #fff;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 兼容小程序端
|
|
11
|
+
*/
|
|
12
|
+
/* #ifdef MP-WEIXIN */
|
|
13
|
+
:deep(hy-dropdown-item) {
|
|
14
|
+
flex: 1;
|
|
15
|
+
width: 0;
|
|
16
|
+
}
|
|
17
|
+
/* #endif */
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type IProps from "./typing";
|
|
2
|
+
import { ColorConfig, IconConfig } from "@/package";
|
|
3
|
+
|
|
4
|
+
const defaultProps: IProps = {
|
|
5
|
+
activeColor: ColorConfig.primary,
|
|
6
|
+
inactiveColor: "#606266",
|
|
7
|
+
closeOnClickMask: true,
|
|
8
|
+
sticky: true,
|
|
9
|
+
height: 40,
|
|
10
|
+
borderBottom: false,
|
|
11
|
+
titleSize: 16,
|
|
12
|
+
borderRadius: 0,
|
|
13
|
+
menuIcon: IconConfig.ARROW_DOWN_FILL,
|
|
14
|
+
menuIconSize: 14,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default defaultProps;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 标题和选项卡选中的颜色(默认#2979ff)
|
|
6
|
+
* */
|
|
7
|
+
activeColor?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @description 标题和选项卡未选中的颜色(默认#606266)
|
|
10
|
+
* */
|
|
11
|
+
inactiveColor?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description 点击遮罩是否关闭菜单(默认true)
|
|
14
|
+
* */
|
|
15
|
+
closeOnClickMask?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @description 是否粘性定位(默认true)
|
|
18
|
+
* */
|
|
19
|
+
sticky?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description 标题菜单的高度,单位任意(默认80)
|
|
22
|
+
* */
|
|
23
|
+
height?: number | string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 标题菜单是否显示下边框(默认false)
|
|
26
|
+
* */
|
|
27
|
+
borderBottom?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @description 标题的字体大小,单位任意,数值默认为rpx单位(默认28)
|
|
30
|
+
* */
|
|
31
|
+
titleSize?: number;
|
|
32
|
+
/**
|
|
33
|
+
* @description 菜单展开内容下方的圆角值,单位任意(默认0)
|
|
34
|
+
* */
|
|
35
|
+
borderRadius?: number;
|
|
36
|
+
/**
|
|
37
|
+
* @description 是否显示遮罩
|
|
38
|
+
* */
|
|
39
|
+
menuIcon?: string;
|
|
40
|
+
/**
|
|
41
|
+
* @description 是否显示遮罩
|
|
42
|
+
* */
|
|
43
|
+
menuIconSize?: number;
|
|
44
|
+
/**
|
|
45
|
+
* @description 定义需要用到的外部样式
|
|
46
|
+
* */
|
|
47
|
+
customStyle?: CSSProperties;
|
|
48
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 标题栏 -->
|
|
3
|
+
<view class="hy-dropdown-item__header" @click="handleClick">
|
|
4
|
+
<text
|
|
5
|
+
class="hy-dropdown-item__header--title"
|
|
6
|
+
:style="{ color: currentColor, fontSize: addUnit(titleSize) }"
|
|
7
|
+
>{{ title }}</text
|
|
8
|
+
>
|
|
9
|
+
<HyIcon
|
|
10
|
+
:custom-style="{
|
|
11
|
+
transform: isOpen ? 'rotate(-180deg)' : 'rotate(0deg)',
|
|
12
|
+
}"
|
|
13
|
+
:name="menuIcon"
|
|
14
|
+
:size="menuIconSize"
|
|
15
|
+
:color="currentColor"
|
|
16
|
+
></HyIcon>
|
|
17
|
+
</view>
|
|
18
|
+
<!-- 下拉弹窗 -->
|
|
19
|
+
<HyOverlay
|
|
20
|
+
:show="isOpen"
|
|
21
|
+
:custom-style="{ top: addUnit(dropPopupTop) }"
|
|
22
|
+
@click="closePopupFn"
|
|
23
|
+
>
|
|
24
|
+
<view
|
|
25
|
+
class="hy-dropdown-item__main"
|
|
26
|
+
:style="{ top: addUnit(dropPopupTop), height: addUnit(dropHeight) }"
|
|
27
|
+
>
|
|
28
|
+
<view class="hy-dropdown-item__main--container" :class="customClass">
|
|
29
|
+
<!-- 插槽 -->
|
|
30
|
+
<slot v-if="hasSlot"></slot>
|
|
31
|
+
<!-- 选项 -->
|
|
32
|
+
<view class="hy-dropdown-item__main--container__list" v-else>
|
|
33
|
+
<view
|
|
34
|
+
class="hy-dropdown-item__main--container__list-item"
|
|
35
|
+
v-for="(item, index) in menus"
|
|
36
|
+
:key="item.value || index"
|
|
37
|
+
@click="onSelect(item, index)"
|
|
38
|
+
>
|
|
39
|
+
<view
|
|
40
|
+
class="hy-dropdown-item__main--container__list-item--label"
|
|
41
|
+
:style="{
|
|
42
|
+
color: currentIndex === index ? currentColor : inactiveColor,
|
|
43
|
+
}"
|
|
44
|
+
>{{ item.label }}</view
|
|
45
|
+
>
|
|
46
|
+
<!-- 勾选图标 -->
|
|
47
|
+
<HyIcon
|
|
48
|
+
v-if="currentIndex === index"
|
|
49
|
+
:color="currentColor"
|
|
50
|
+
:name="IconConfig.CHECK_MASK"
|
|
51
|
+
></HyIcon>
|
|
52
|
+
</view>
|
|
53
|
+
</view>
|
|
54
|
+
</view>
|
|
55
|
+
</view>
|
|
56
|
+
</HyOverlay>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<script setup lang="ts">
|
|
60
|
+
import {computed, inject, ref, onMounted, watch, useSlots, toRefs, getCurrentInstance} from "vue";
|
|
61
|
+
import defaultProps from "./props";
|
|
62
|
+
import type IProps from "./typing";
|
|
63
|
+
import type FatherIProps from "../hy-dropdown/typing";
|
|
64
|
+
import type { DropdownMenuItem } from "./typing";
|
|
65
|
+
import { addUnit, getRect, throttle } from "../../utils";
|
|
66
|
+
import { IconConfig } from "../../config";
|
|
67
|
+
|
|
68
|
+
import HyOverlay from "../hy-overlay/hy-overlay.vue";
|
|
69
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
70
|
+
|
|
71
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
72
|
+
const { modelValue, menus } = toRefs(props);
|
|
73
|
+
const emits = defineEmits(["update:modelValue", "change"]);
|
|
74
|
+
|
|
75
|
+
const slots = useSlots();
|
|
76
|
+
//是否有插槽
|
|
77
|
+
const hasSlot = computed(() => {
|
|
78
|
+
return Object.keys(slots).length > 0;
|
|
79
|
+
});
|
|
80
|
+
const instance = getCurrentInstance();
|
|
81
|
+
//父的props值
|
|
82
|
+
const dropdownProps: FatherIProps | undefined = inject("dropdownProps");
|
|
83
|
+
const { titleSize, menuIcon, menuIconSize, inactiveColor } =
|
|
84
|
+
dropdownProps as FatherIProps;
|
|
85
|
+
//当前打开的dropItem项(标签名)
|
|
86
|
+
const currentDropItem: any = inject("currentDropItem");
|
|
87
|
+
//当前文字/箭头颜色
|
|
88
|
+
const currentColor = computed(() => {
|
|
89
|
+
return isOpen.value ? dropdownProps?.activeColor : inactiveColor;
|
|
90
|
+
});
|
|
91
|
+
//是否打开
|
|
92
|
+
const isOpen = ref<boolean>(false);
|
|
93
|
+
//下拉弹窗距离页面顶部距离
|
|
94
|
+
const dropPopupTop = ref(0);
|
|
95
|
+
//下拉弹窗高度
|
|
96
|
+
const dropHeight = ref<string | number>(0);
|
|
97
|
+
//下拉选项当前选中的索引
|
|
98
|
+
const currentIndex = ref(-1);
|
|
99
|
+
|
|
100
|
+
//动态class
|
|
101
|
+
const customClass = computed(() => (isOpen.value ? "visible" : "hidden"));
|
|
102
|
+
|
|
103
|
+
onMounted(() => {
|
|
104
|
+
getDropPopupTop();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @description 计算下拉弹窗区域距离页面顶部距离
|
|
109
|
+
* */
|
|
110
|
+
const getDropPopupTop = () => {
|
|
111
|
+
getRect(".hy-dropdown-item__header", false, instance).then((rect) => {
|
|
112
|
+
const { bottom } = rect as UniApp.NodeInfo;
|
|
113
|
+
// #ifdef H5
|
|
114
|
+
//H5需要加上导航栏高度,固定44px
|
|
115
|
+
dropPopupTop.value = (bottom || 0) + 44;
|
|
116
|
+
// #endif
|
|
117
|
+
// #ifndef H5
|
|
118
|
+
dropPopupTop.value = bottom || 0;
|
|
119
|
+
// #endif
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
watch(isOpen, (v) => {
|
|
124
|
+
//打开状态显示父容器
|
|
125
|
+
if (v) {
|
|
126
|
+
dropHeight.value = "auto";
|
|
127
|
+
} else {
|
|
128
|
+
//关闭状态隐藏父容器
|
|
129
|
+
//延迟改变使得关闭动画能完整呈现
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
dropHeight.value = 0;
|
|
132
|
+
}, 200);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* @description 动态控制开关,
|
|
137
|
+
* @desc 防止点击展开后在点击下一个,导致上一个没有关闭bug
|
|
138
|
+
* */
|
|
139
|
+
watch(
|
|
140
|
+
() => currentDropItem?.value,
|
|
141
|
+
(newVal) => {
|
|
142
|
+
//关闭其他条件的下拉弹窗
|
|
143
|
+
if (newVal !== props.title) {
|
|
144
|
+
isOpen.value = false;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
//根据双向绑定值动态设置下拉选中项索引
|
|
150
|
+
watch(
|
|
151
|
+
() => modelValue.value,
|
|
152
|
+
(newVal) => {
|
|
153
|
+
currentIndex.value = menus.value.findIndex((item) => item.value === newVal);
|
|
154
|
+
},
|
|
155
|
+
{ immediate: true },
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
//选中监听
|
|
159
|
+
const onSelect = (item: DropdownMenuItem, index: number) => {
|
|
160
|
+
isOpen.value = false;
|
|
161
|
+
if (index !== currentIndex.value) {
|
|
162
|
+
currentIndex.value = index;
|
|
163
|
+
emits("update:modelValue", item.value);
|
|
164
|
+
emits("change", item.value);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @description 打开或关闭
|
|
170
|
+
* */
|
|
171
|
+
const handleClick = () =>
|
|
172
|
+
throttle(() => {
|
|
173
|
+
//节流处理,防止点击过快动画未结束又切换导致显示bug
|
|
174
|
+
isOpen.value = !isOpen.value;
|
|
175
|
+
if (isOpen.value) {
|
|
176
|
+
// 防止点击展开后在点击下一个,导致上一个没有关闭bug
|
|
177
|
+
currentDropItem.value = props.title;
|
|
178
|
+
getDropPopupTop();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @description 点击遮罩框关闭弹窗
|
|
184
|
+
* */
|
|
185
|
+
const closePopupFn = () => {
|
|
186
|
+
if (dropdownProps?.closeOnClickMask) {
|
|
187
|
+
isOpen.value = false;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
</script>
|
|
191
|
+
|
|
192
|
+
<style lang="scss" scoped>
|
|
193
|
+
@import "./index.scss";
|
|
194
|
+
</style>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
@use "../../theme.scss" as *;
|
|
2
|
+
|
|
3
|
+
.hy-dropdown-item {
|
|
4
|
+
&__header {
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
padding: $hy-border-margin-padding-base;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
font-size: 30rpx;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
text-align: center;
|
|
15
|
+
position: relative;
|
|
16
|
+
z-index: 999;
|
|
17
|
+
background-color: #ffffff;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__main {
|
|
21
|
+
position: fixed;
|
|
22
|
+
left: 0;
|
|
23
|
+
right: 0;
|
|
24
|
+
bottom: 0;
|
|
25
|
+
z-index: 999;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
background-color: rgba(0, 0, 0, 0);
|
|
29
|
+
|
|
30
|
+
&--container {
|
|
31
|
+
background-color: #fff;
|
|
32
|
+
min-height: 200rpx;
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: -100%;
|
|
35
|
+
left: 0;
|
|
36
|
+
right: 0;
|
|
37
|
+
z-index: 1000;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
&.visible {
|
|
40
|
+
animation: visibleAnimaFrames 0.5s forwards;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.hidden {
|
|
44
|
+
animation: hiddenAnimaFrames 0.5s forwards;
|
|
45
|
+
}
|
|
46
|
+
&__list {
|
|
47
|
+
width: 100%;
|
|
48
|
+
padding: 0 35rpx;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
&-item {
|
|
51
|
+
width: 100%;
|
|
52
|
+
padding: 30rpx 0;
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
|
|
57
|
+
&:not(:last-of-type) {
|
|
58
|
+
border-bottom: 1px solid #f2f2f2;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&--label {
|
|
62
|
+
font-size: 30rpx;
|
|
63
|
+
flex: 1;
|
|
64
|
+
width: 0;
|
|
65
|
+
margin-right: 40rpx;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
text-overflow: ellipsis;
|
|
68
|
+
white-space: nowrap;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/*打开动画*/
|
|
77
|
+
@keyframes visibleAnimaFrames {
|
|
78
|
+
0% {
|
|
79
|
+
top: -100%;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
100% {
|
|
83
|
+
top: 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/*关闭动画*/
|
|
88
|
+
@keyframes hiddenAnimaFrames {
|
|
89
|
+
0% {
|
|
90
|
+
top: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
100% {
|
|
94
|
+
top: -100%;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export interface DropdownMenuItem {
|
|
4
|
+
/**
|
|
5
|
+
* @description 展示标题
|
|
6
|
+
* */
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* @description 值
|
|
10
|
+
* */
|
|
11
|
+
value: string | number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default interface IProps {
|
|
15
|
+
/**
|
|
16
|
+
* @description 获取值
|
|
17
|
+
* */
|
|
18
|
+
modelValue: string | number;
|
|
19
|
+
/**
|
|
20
|
+
* @description 标题
|
|
21
|
+
* */
|
|
22
|
+
title: string;
|
|
23
|
+
/**
|
|
24
|
+
* @description 下拉选择值
|
|
25
|
+
* */
|
|
26
|
+
menus?: DropdownMenuItem[];
|
|
27
|
+
/**
|
|
28
|
+
* @description 禁用组件点击
|
|
29
|
+
* */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
}
|