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,17 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { IconConfig } from '../../libs'
|
|
2
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const dropdownProps = {
|
|
5
|
+
/** 标题菜单的高度,单位px */
|
|
6
|
+
height: {
|
|
7
|
+
type: [String, Number],
|
|
8
|
+
default: 40
|
|
9
|
+
},
|
|
10
|
+
/** 标题菜单是否显示下边框 */
|
|
11
|
+
borderBottom: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false
|
|
14
|
+
},
|
|
15
|
+
/** 是否固定定位 */
|
|
16
|
+
sticky: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: true
|
|
19
|
+
},
|
|
20
|
+
/** 标题和选项卡选中的颜色 */
|
|
21
|
+
activeColor: String,
|
|
22
|
+
/** 标题和选项卡未选中的颜色 */
|
|
23
|
+
inactiveColor: String,
|
|
24
|
+
/** 图标名称 */
|
|
25
|
+
menuIcon: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: IconConfig.ARROW_DOWN_FILL
|
|
28
|
+
},
|
|
29
|
+
/** 图标大小 */
|
|
30
|
+
menuIconSize: {
|
|
31
|
+
type: [String, Number],
|
|
32
|
+
default: 14
|
|
33
|
+
},
|
|
34
|
+
/** 定义需要用到的外部样式 */
|
|
35
|
+
customStyle: {
|
|
36
|
+
type: Object as PropType<CSSProperties>
|
|
37
|
+
}
|
|
38
|
+
}
|
|
16
39
|
|
|
17
|
-
export default
|
|
40
|
+
export default dropdownProps
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
import type { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
3
|
export default interface HyDropdownProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
48
|
}
|
|
@@ -1,238 +1,206 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
2
|
+
<!-- 标题栏 -->
|
|
3
|
+
<view :class="['hy-dropdown-item__header', isOpen && 'is-active']" @click="handleClick">
|
|
4
|
+
<text
|
|
5
|
+
class="hy-dropdown-item__header--title"
|
|
6
|
+
:style="{ color: currentColor, fontSize: addUnit(titleSize) }"
|
|
7
|
+
>
|
|
8
|
+
{{ title }}
|
|
9
|
+
</text>
|
|
10
|
+
<HyIcon
|
|
11
|
+
:custom-style="{
|
|
12
|
+
transform: isOpen ? 'rotate(-180deg)' : 'rotate(0deg)'
|
|
13
|
+
}"
|
|
14
|
+
:name="menuIcon"
|
|
15
|
+
:size="menuIconSize"
|
|
16
|
+
:color="currentColor"
|
|
17
|
+
></HyIcon>
|
|
18
|
+
</view>
|
|
19
|
+
<!-- 下拉弹窗 -->
|
|
20
|
+
<HyOverlay :show="isOpen" :custom-style="{ top: addUnit(dropPopupTop) }" @click="closePopupFn">
|
|
21
|
+
<view
|
|
22
|
+
class="hy-dropdown-item__main"
|
|
23
|
+
:style="{ top: addUnit(dropPopupTop), height: addUnit(dropHeight) }"
|
|
24
|
+
>
|
|
25
|
+
<view class="hy-dropdown-item__main--container" :class="customClass">
|
|
26
|
+
<!-- 插槽 -->
|
|
27
|
+
<slot v-if="hasSlot"></slot>
|
|
28
|
+
<!-- 选项 -->
|
|
29
|
+
<view class="hy-dropdown-item__main--container__list" v-else>
|
|
30
|
+
<view
|
|
31
|
+
:class="[
|
|
32
|
+
'hy-dropdown-item__main--container__list-item',
|
|
33
|
+
currentIndex === index && 'is-active'
|
|
34
|
+
]"
|
|
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
|
+
>
|
|
45
|
+
{{ item.label }}
|
|
46
|
+
</view>
|
|
47
|
+
<!-- 勾选图标 -->
|
|
48
|
+
<HyIcon
|
|
49
|
+
v-if="currentIndex === index"
|
|
50
|
+
:color="currentColor"
|
|
51
|
+
:name="IconConfig.CHECK_MASK"
|
|
52
|
+
></HyIcon>
|
|
53
|
+
</view>
|
|
54
|
+
</view>
|
|
53
55
|
</view>
|
|
54
|
-
<!-- 勾选图标 -->
|
|
55
|
-
<HyIcon
|
|
56
|
-
v-if="currentIndex === index"
|
|
57
|
-
:color="currentColor"
|
|
58
|
-
:name="IconConfig.CHECK_MASK"
|
|
59
|
-
></HyIcon>
|
|
60
|
-
</view>
|
|
61
56
|
</view>
|
|
62
|
-
|
|
63
|
-
</view>
|
|
64
|
-
</HyOverlay>
|
|
57
|
+
</HyOverlay>
|
|
65
58
|
</template>
|
|
66
59
|
|
|
67
60
|
<script lang="ts">
|
|
68
61
|
export default {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
62
|
+
name: 'hy-dropdown-item',
|
|
63
|
+
options: {
|
|
64
|
+
styleIsolation: 'shared'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
74
67
|
</script>
|
|
75
68
|
|
|
76
69
|
<script setup lang="ts">
|
|
77
|
-
import {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
watch,
|
|
83
|
-
useSlots,
|
|
84
|
-
getCurrentInstance,
|
|
85
|
-
type PropType,
|
|
86
|
-
} from "vue";
|
|
87
|
-
import type { IDropdownItemEmits, DropdownMenuItem } from "./typing";
|
|
88
|
-
import type FatherIProps from "../hy-dropdown/typing";
|
|
89
|
-
import { addUnit, getRect, throttle, IconConfig } from "../../libs";
|
|
70
|
+
import { computed, inject, ref, onMounted, watch, useSlots, getCurrentInstance } from 'vue'
|
|
71
|
+
import type { IDropdownItemEmits, DropdownMenuItem } from './typing'
|
|
72
|
+
import type FatherIProps from '../hy-dropdown/typing'
|
|
73
|
+
import { addUnit, getRect, throttle, IconConfig } from '../../libs'
|
|
74
|
+
import dropdownItemProps from './props'
|
|
90
75
|
// 组件
|
|
91
|
-
import HyOverlay from
|
|
92
|
-
import HyIcon from
|
|
76
|
+
import HyOverlay from '../hy-overlay/hy-overlay.vue'
|
|
77
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
93
78
|
|
|
94
79
|
/**
|
|
95
80
|
* 主要提供筛选下拉筛选框,内置基础筛选功能,可以根据自己的需求自定义筛选项。和hy-dropdown组合用法
|
|
96
81
|
* @displayName hy-dropdown-item
|
|
97
82
|
*/
|
|
98
|
-
defineOptions({})
|
|
83
|
+
defineOptions({})
|
|
99
84
|
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
/** 获取值 */
|
|
103
|
-
modelValue: [String, Number],
|
|
104
|
-
/** 标题 */
|
|
105
|
-
title: String,
|
|
106
|
-
/** 下拉选择值 */
|
|
107
|
-
menus: {
|
|
108
|
-
type: Array as unknown as PropType<DropdownMenuItem[]>,
|
|
109
|
-
default: [],
|
|
110
|
-
},
|
|
111
|
-
/** 禁用组件点击 */
|
|
112
|
-
disabled: {
|
|
113
|
-
type: Boolean,
|
|
114
|
-
default: false,
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
const emit = defineEmits<IDropdownItemEmits>();
|
|
85
|
+
const props = defineProps(dropdownItemProps)
|
|
86
|
+
const emit = defineEmits<IDropdownItemEmits>()
|
|
118
87
|
|
|
119
|
-
const slots = useSlots()
|
|
88
|
+
const slots = useSlots()
|
|
120
89
|
//是否有插槽
|
|
121
90
|
const hasSlot = computed(() => {
|
|
122
|
-
|
|
123
|
-
})
|
|
124
|
-
const instance = getCurrentInstance()
|
|
91
|
+
return Object.keys(slots).length > 0
|
|
92
|
+
})
|
|
93
|
+
const instance = getCurrentInstance()
|
|
125
94
|
//父的props值
|
|
126
|
-
const dropdownProps: FatherIProps | undefined = inject(
|
|
127
|
-
const { titleSize, menuIcon, menuIconSize, inactiveColor } =
|
|
128
|
-
dropdownProps as FatherIProps;
|
|
95
|
+
const dropdownProps: FatherIProps | undefined = inject('dropdownProps')
|
|
96
|
+
const { titleSize, menuIcon, menuIconSize, inactiveColor } = dropdownProps as FatherIProps
|
|
129
97
|
//当前打开的dropItem项(标签名)
|
|
130
|
-
const currentDropItem: any = inject(
|
|
98
|
+
const currentDropItem: any = inject('currentDropItem')
|
|
131
99
|
//当前文字/箭头颜色
|
|
132
100
|
const currentColor = computed(() => {
|
|
133
|
-
|
|
134
|
-
})
|
|
101
|
+
return isOpen.value ? dropdownProps?.activeColor : inactiveColor
|
|
102
|
+
})
|
|
135
103
|
//是否打开
|
|
136
|
-
const isOpen = ref<boolean>(false)
|
|
104
|
+
const isOpen = ref<boolean>(false)
|
|
137
105
|
//下拉弹窗距离页面顶部距离
|
|
138
|
-
const dropPopupTop = ref(0)
|
|
106
|
+
const dropPopupTop = ref(0)
|
|
139
107
|
//下拉弹窗高度
|
|
140
|
-
const dropHeight = ref<string | number>(0)
|
|
108
|
+
const dropHeight = ref<string | number>(0)
|
|
141
109
|
//下拉选项当前选中的索引
|
|
142
|
-
const currentIndex = ref(-1)
|
|
110
|
+
const currentIndex = ref(-1)
|
|
143
111
|
|
|
144
112
|
//动态class
|
|
145
|
-
const customClass = computed(() => (isOpen.value ?
|
|
113
|
+
const customClass = computed(() => (isOpen.value ? 'visible' : 'hidden'))
|
|
146
114
|
|
|
147
115
|
onMounted(() => {
|
|
148
|
-
|
|
149
|
-
})
|
|
116
|
+
getDropPopupTop()
|
|
117
|
+
})
|
|
150
118
|
|
|
151
119
|
/**
|
|
152
120
|
* @description 计算下拉弹窗区域距离页面顶部距离
|
|
153
121
|
* */
|
|
154
122
|
const getDropPopupTop = () => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
123
|
+
getRect('.hy-dropdown-item__header', false, instance).then((rect) => {
|
|
124
|
+
const { bottom } = rect as UniApp.NodeInfo
|
|
125
|
+
// #ifdef H5
|
|
126
|
+
//H5需要加上导航栏高度,固定44px
|
|
127
|
+
dropPopupTop.value = (bottom || 0) + 44
|
|
128
|
+
// #endif
|
|
129
|
+
// #ifndef H5
|
|
130
|
+
dropPopupTop.value = bottom || 0
|
|
131
|
+
// #endif
|
|
132
|
+
})
|
|
133
|
+
}
|
|
166
134
|
|
|
167
135
|
watch(isOpen, (v) => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
})
|
|
136
|
+
//打开状态显示父容器
|
|
137
|
+
if (v) {
|
|
138
|
+
dropHeight.value = 'auto'
|
|
139
|
+
} else {
|
|
140
|
+
//关闭状态隐藏父容器
|
|
141
|
+
//延迟改变使得关闭动画能完整呈现
|
|
142
|
+
setTimeout(() => {
|
|
143
|
+
dropHeight.value = 0
|
|
144
|
+
}, 200)
|
|
145
|
+
}
|
|
146
|
+
})
|
|
179
147
|
/**
|
|
180
148
|
* @description 动态控制开关,
|
|
181
149
|
* @desc 防止点击展开后在点击下一个,导致上一个没有关闭bug
|
|
182
150
|
* */
|
|
183
151
|
watch(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
152
|
+
() => currentDropItem?.value,
|
|
153
|
+
(newVal) => {
|
|
154
|
+
//关闭其他条件的下拉弹窗
|
|
155
|
+
if (newVal !== props.title) {
|
|
156
|
+
isOpen.value = false
|
|
157
|
+
}
|
|
189
158
|
}
|
|
190
|
-
|
|
191
|
-
);
|
|
159
|
+
)
|
|
192
160
|
|
|
193
161
|
//根据双向绑定值动态设置下拉选中项索引
|
|
194
162
|
watch(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
)
|
|
163
|
+
() => props.modelValue,
|
|
164
|
+
(newVal) => {
|
|
165
|
+
currentIndex.value = props.menus.findIndex((item) => item.value === newVal)
|
|
166
|
+
},
|
|
167
|
+
{ immediate: true }
|
|
168
|
+
)
|
|
201
169
|
|
|
202
170
|
//选中监听
|
|
203
171
|
const onSelect = (item: DropdownMenuItem, index: number) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
172
|
+
isOpen.value = false
|
|
173
|
+
if (index !== currentIndex.value) {
|
|
174
|
+
currentIndex.value = index
|
|
175
|
+
emit('change', item, index)
|
|
176
|
+
emit('update:modelValue', item.value)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
211
179
|
|
|
212
180
|
/**
|
|
213
181
|
* @description 打开或关闭
|
|
214
182
|
* */
|
|
215
183
|
const handleClick = () =>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
184
|
+
throttle(() => {
|
|
185
|
+
//节流处理,防止点击过快动画未结束又切换导致显示bug
|
|
186
|
+
isOpen.value = !isOpen.value
|
|
187
|
+
if (isOpen.value) {
|
|
188
|
+
// 防止点击展开后在点击下一个,导致上一个没有关闭bug
|
|
189
|
+
currentDropItem.value = props.title
|
|
190
|
+
getDropPopupTop()
|
|
191
|
+
}
|
|
192
|
+
})
|
|
225
193
|
|
|
226
194
|
/**
|
|
227
195
|
* @description 点击遮罩框关闭弹窗
|
|
228
196
|
* */
|
|
229
197
|
const closePopupFn = () => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
198
|
+
if (dropdownProps?.closeOnClickMask) {
|
|
199
|
+
isOpen.value = false
|
|
200
|
+
}
|
|
201
|
+
}
|
|
234
202
|
</script>
|
|
235
203
|
|
|
236
204
|
<style lang="scss" scoped>
|
|
237
|
-
@import
|
|
205
|
+
@import './index.scss';
|
|
238
206
|
</style>
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { DropdownMenuItem } from '../hy-dropdown-item/typing'
|
|
2
|
+
import type { PropType } from 'vue'
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const dropdownItemProps = {
|
|
5
|
+
/** 获取值 */
|
|
6
|
+
modelValue: [String, Number],
|
|
7
|
+
/** 标题 */
|
|
8
|
+
title: String,
|
|
9
|
+
/** 下拉选择值 */
|
|
10
|
+
menus: {
|
|
11
|
+
type: Array as unknown as PropType<DropdownMenuItem[]>,
|
|
12
|
+
default: []
|
|
13
|
+
},
|
|
14
|
+
/** 禁用组件点击 */
|
|
15
|
+
disabled: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
}
|
|
19
|
+
}
|
|
9
20
|
|
|
10
|
-
export default
|
|
21
|
+
export default dropdownItemProps
|