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.
Files changed (211) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +155 -238
  2. package/components/hy-action-sheet/props.ts +68 -15
  3. package/components/hy-action-sheet/typing.d.ts +115 -115
  4. package/components/hy-address-picker/hy-address-picker.vue +185 -289
  5. package/components/hy-address-picker/props.ts +97 -21
  6. package/components/hy-address-picker/typing.d.ts +90 -89
  7. package/components/hy-avatar/hy-avatar.vue +121 -204
  8. package/components/hy-avatar/props.ts +76 -18
  9. package/components/hy-avatar/typing.d.ts +63 -62
  10. package/components/hy-back-top/hy-back-top.vue +65 -120
  11. package/components/hy-back-top/props.ts +57 -16
  12. package/components/hy-back-top/typing.d.ts +43 -42
  13. package/components/hy-badge/hy-badge.vue +66 -138
  14. package/components/hy-badge/props.ts +73 -17
  15. package/components/hy-badge/typing.d.ts +59 -58
  16. package/components/hy-button/hy-button.vue +226 -375
  17. package/components/hy-button/props.ts +129 -158
  18. package/components/hy-calendar/header.vue +48 -64
  19. package/components/hy-calendar/hy-calendar.vue +274 -438
  20. package/components/hy-calendar/month.vue +508 -516
  21. package/components/hy-calendar/props.ts +157 -35
  22. package/components/hy-calendar/typing.d.ts +129 -128
  23. package/components/hy-card/hy-card.vue +118 -240
  24. package/components/hy-card/index.scss +1 -2
  25. package/components/hy-card/props.ts +122 -27
  26. package/components/hy-card/typing.d.ts +119 -118
  27. package/components/hy-cell/hy-cell.vue +176 -258
  28. package/components/hy-cell/props.ts +71 -17
  29. package/components/hy-cell/typing.d.ts +87 -86
  30. package/components/hy-check-button/hy-check-button.vue +69 -139
  31. package/components/hy-check-button/props.ts +72 -18
  32. package/components/hy-check-button/typing.d.ts +74 -73
  33. package/components/hy-checkbox/hy-checkbox.vue +170 -263
  34. package/components/hy-checkbox/props.ts +94 -24
  35. package/components/hy-checkbox/typing.d.ts +72 -72
  36. package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
  37. package/components/hy-checkbox-group/props.ts +80 -0
  38. package/components/hy-checkbox-group/typing.d.ts +65 -65
  39. package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
  40. package/components/hy-checkbox-item/props.ts +24 -0
  41. package/components/hy-checkbox-item/typing.d.ts +4 -3
  42. package/components/hy-code-input/hy-code-input.vue +179 -262
  43. package/components/hy-code-input/props.ts +84 -18
  44. package/components/hy-code-input/typing.d.ts +71 -71
  45. package/components/hy-config-provider/hy-config-provider.vue +28 -50
  46. package/components/hy-config-provider/props.ts +26 -11
  47. package/components/hy-config-provider/typing.d.ts +20 -20
  48. package/components/hy-count-down/hy-count-down.vue +103 -131
  49. package/components/hy-count-down/props.ts +30 -8
  50. package/components/hy-count-down/typing.d.ts +25 -25
  51. package/components/hy-count-to/hy-count-to.vue +148 -213
  52. package/components/hy-count-to/props.ts +60 -15
  53. package/components/hy-count-to/typing.d.ts +46 -46
  54. package/components/hy-coupon/README.md +133 -0
  55. package/components/hy-coupon/hy-coupon.vue +180 -0
  56. package/components/hy-coupon/index.scss +553 -0
  57. package/components/hy-coupon/props.ts +129 -0
  58. package/components/hy-coupon/typing.d.ts +146 -0
  59. package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
  60. package/components/hy-datetime-picker/props.ts +142 -32
  61. package/components/hy-datetime-picker/typing.d.ts +132 -132
  62. package/components/hy-divider/hy-divider.vue +90 -169
  63. package/components/hy-divider/props.ts +78 -19
  64. package/components/hy-divider/typing.d.ts +60 -60
  65. package/components/hy-dropdown/hy-dropdown.vue +37 -71
  66. package/components/hy-dropdown/props.ts +38 -15
  67. package/components/hy-dropdown/typing.d.ts +44 -44
  68. package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
  69. package/components/hy-dropdown-item/props.ts +19 -8
  70. package/components/hy-empty/hy-empty.vue +75 -129
  71. package/components/hy-empty/props.ts +57 -15
  72. package/components/hy-empty/typing.d.ts +84 -84
  73. package/components/hy-flex/hy-flex.vue +33 -88
  74. package/components/hy-flex/props.ts +58 -0
  75. package/components/hy-flex/typing.d.ts +14 -16
  76. package/components/hy-float-button/hy-float-button.vue +289 -406
  77. package/components/hy-float-button/props.ts +109 -25
  78. package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
  79. package/components/hy-folding-panel/props.ts +40 -15
  80. package/components/hy-folding-panel/typing.d.ts +52 -63
  81. package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
  82. package/components/hy-folding-panel-item/index.scss +87 -0
  83. package/components/hy-folding-panel-item/props.ts +81 -0
  84. package/components/hy-folding-panel-item/typing.d.ts +23 -0
  85. package/components/hy-form/hy-form.vue +172 -212
  86. package/components/hy-form/props.ts +37 -0
  87. package/components/hy-form/typing.d.ts +68 -61
  88. package/components/hy-form-group/typing.d.ts +74 -74
  89. package/components/hy-form-item/hy-form-item.vue +100 -129
  90. package/components/hy-form-item/props.ts +25 -0
  91. package/components/hy-form-item/typing.d.ts +40 -37
  92. package/components/hy-grid/hy-grid.vue +76 -132
  93. package/components/hy-grid/props.ts +58 -16
  94. package/components/hy-grid/typing.d.ts +66 -66
  95. package/components/hy-icon/hy-icon.vue +84 -161
  96. package/components/hy-icon/props.ts +76 -22
  97. package/components/hy-icon/typing.d.ts +83 -82
  98. package/components/hy-image/hy-image.vue +142 -272
  99. package/components/hy-image/props.ts +105 -23
  100. package/components/hy-image/typing.d.ts +84 -87
  101. package/components/hy-input/hy-input.vue +230 -421
  102. package/components/hy-input/props.ts +183 -35
  103. package/components/hy-input/typing.d.ts +169 -169
  104. package/components/hy-line/hy-line.vue +34 -72
  105. package/components/hy-line/props.ts +41 -10
  106. package/components/hy-line/typing.d.ts +29 -29
  107. package/components/hy-line-progress/hy-line-progress.vue +66 -101
  108. package/components/hy-line-progress/props.ts +31 -10
  109. package/components/hy-line-progress/typing.d.ts +29 -29
  110. package/components/hy-list/hy-list.vue +151 -220
  111. package/components/hy-list/props.ts +67 -16
  112. package/components/hy-list/typing.d.ts +52 -52
  113. package/components/hy-loading/hy-loading.vue +63 -119
  114. package/components/hy-loading/props.ts +63 -15
  115. package/components/hy-loading/typing.d.ts +49 -49
  116. package/components/hy-menu/hy-menu.vue +124 -166
  117. package/components/hy-menu/props.ts +42 -10
  118. package/components/hy-menu/typing.d.ts +60 -60
  119. package/components/hy-modal/hy-modal.vue +127 -218
  120. package/components/hy-modal/props.ts +89 -24
  121. package/components/hy-navbar/hy-navbar.vue +104 -177
  122. package/components/hy-navbar/props.ts +76 -22
  123. package/components/hy-navbar/typing.d.ts +81 -81
  124. package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
  125. package/components/hy-notice-bar/props.ts +80 -19
  126. package/components/hy-notice-bar/typing.d.ts +62 -62
  127. package/components/hy-notify/hy-notify.vue +128 -177
  128. package/components/hy-notify/props.ts +49 -12
  129. package/components/hy-notify/typing.d.ts +45 -41
  130. package/components/hy-number-step/hy-number-step.vue +281 -394
  131. package/components/hy-number-step/props.ts +110 -27
  132. package/components/hy-number-step/typing.d.ts +120 -120
  133. package/components/hy-overlay/hy-overlay.vue +39 -66
  134. package/components/hy-overlay/props.ts +31 -8
  135. package/components/hy-pagination/hy-pagination.vue +100 -155
  136. package/components/hy-pagination/props.ts +53 -13
  137. package/components/hy-picker/hy-picker.vue +309 -430
  138. package/components/hy-picker/index.scss +8 -12
  139. package/components/hy-picker/props.ts +110 -26
  140. package/components/hy-popover/hy-popover.vue +190 -252
  141. package/components/hy-popover/props.ts +48 -10
  142. package/components/hy-popup/hy-popup.vue +162 -248
  143. package/components/hy-popup/props.ts +82 -18
  144. package/components/hy-price/hy-price.vue +45 -104
  145. package/components/hy-price/props.ts +52 -12
  146. package/components/hy-price/typing.d.ts +41 -36
  147. package/components/hy-qrcode/hy-qrcode.vue +115 -185
  148. package/components/hy-qrcode/props.ts +68 -18
  149. package/components/hy-qrcode/typing.d.ts +67 -66
  150. package/components/hy-radio/hy-radio.vue +161 -259
  151. package/components/hy-radio/props.ts +95 -25
  152. package/components/hy-radio/typing.d.ts +85 -84
  153. package/components/hy-rate/hy-rate.vue +185 -270
  154. package/components/hy-rate/props.ts +76 -18
  155. package/components/hy-rate/typing.d.ts +61 -60
  156. package/components/hy-read-more/hy-read-more.vue +93 -136
  157. package/components/hy-read-more/props.ts +43 -13
  158. package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
  159. package/components/hy-scroll-list/props.ts +22 -11
  160. package/components/hy-search/hy-search.vue +155 -284
  161. package/components/hy-search/props.ts +130 -25
  162. package/components/hy-signature/hy-signature.vue +491 -635
  163. package/components/hy-signature/props.ts +115 -26
  164. package/components/hy-signature/typing.d.ts +138 -138
  165. package/components/hy-slider/hy-slider.vue +388 -477
  166. package/components/hy-slider/props.ts +75 -19
  167. package/components/hy-steps/hy-steps.vue +212 -279
  168. package/components/hy-steps/props.ts +47 -13
  169. package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
  170. package/components/hy-submit-bar/props.ts +89 -20
  171. package/components/hy-submit-bar/typing.d.ts +86 -85
  172. package/components/hy-subsection/hy-subsection.vue +132 -185
  173. package/components/hy-subsection/props.ts +50 -17
  174. package/components/hy-subsection/typing.d.ts +52 -52
  175. package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
  176. package/components/hy-swipe-action/props.ts +43 -18
  177. package/components/hy-swipe-action/typing.d.ts +46 -46
  178. package/components/hy-swiper/hy-swiper.vue +159 -286
  179. package/components/hy-swiper/props.ts +126 -28
  180. package/components/hy-swiper/typing.d.ts +115 -115
  181. package/components/hy-switch/hy-switch.vue +112 -176
  182. package/components/hy-switch/props.ts +60 -15
  183. package/components/hy-switch/typing.d.ts +63 -63
  184. package/components/hy-tabBar/hy-tabBar.vue +64 -60
  185. package/components/hy-tabs/hy-tabs.vue +277 -380
  186. package/components/hy-tabs/props.ts +75 -18
  187. package/components/hy-tag/hy-tag.vue +111 -204
  188. package/components/hy-tag/props.ts +81 -19
  189. package/components/hy-text/hy-text.vue +200 -322
  190. package/components/hy-text/props.ts +107 -28
  191. package/components/hy-textarea/hy-textarea.vue +147 -256
  192. package/components/hy-textarea/props.ts +112 -25
  193. package/components/hy-textarea/typing.d.ts +42 -42
  194. package/components/hy-toast/hy-toast.vue +135 -143
  195. package/components/hy-tooltip/hy-tooltip.vue +220 -306
  196. package/components/hy-tooltip/props.ts +79 -15
  197. package/components/hy-transition/hy-transition.vue +111 -138
  198. package/components/hy-transition/props.ts +30 -8
  199. package/components/hy-upload/hy-upload.vue +320 -469
  200. package/components/hy-upload/props.ts +130 -27
  201. package/components/hy-warn/hy-warn.vue +80 -129
  202. package/components/hy-warn/props.ts +47 -12
  203. package/components/hy-waterfall/hy-waterfall.vue +139 -163
  204. package/components/hy-waterfall/props.ts +19 -7
  205. package/components/hy-watermark/hy-watermark.vue +762 -870
  206. package/components/hy-watermark/props.ts +103 -22
  207. package/global.d.ts +2 -0
  208. package/libs/css/theme.scss +3 -3
  209. package/package.json +2 -2
  210. package/web-types.json +1 -1
  211. package/components/hy-folding-panel/index.scss +0 -9
@@ -1,17 +1,40 @@
1
- import type IProps from "./typing";
2
- import { IconConfig } from "../../libs";
1
+ import { IconConfig } from '../../libs'
2
+ import type { CSSProperties, PropType } from 'vue'
3
3
 
4
- const defaultProps: IProps = {
5
- activeColor: "",
6
- inactiveColor: "",
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
- };
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 defaultProps;
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
- * @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
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
- <view
4
- :class="['hy-dropdown-item__header', isOpen && 'is-active']"
5
- @click="handleClick"
6
- >
7
- <text
8
- class="hy-dropdown-item__header--title"
9
- :style="{ color: currentColor, fontSize: addUnit(titleSize) }"
10
- >
11
- {{ title }}
12
- </text>
13
- <HyIcon
14
- :custom-style="{
15
- transform: isOpen ? 'rotate(-180deg)' : 'rotate(0deg)',
16
- }"
17
- :name="menuIcon"
18
- :size="menuIconSize"
19
- :color="currentColor"
20
- ></HyIcon>
21
- </view>
22
- <!-- 下拉弹窗 -->
23
- <HyOverlay
24
- :show="isOpen"
25
- :custom-style="{ top: addUnit(dropPopupTop) }"
26
- @click="closePopupFn"
27
- >
28
- <view
29
- class="hy-dropdown-item__main"
30
- :style="{ top: addUnit(dropPopupTop), height: addUnit(dropHeight) }"
31
- >
32
- <view class="hy-dropdown-item__main--container" :class="customClass">
33
- <!-- 插槽 -->
34
- <slot v-if="hasSlot"></slot>
35
- <!-- 选项 -->
36
- <view class="hy-dropdown-item__main--container__list" v-else>
37
- <view
38
- :class="[
39
- 'hy-dropdown-item__main--container__list-item',
40
- currentIndex === index && 'is-active',
41
- ]"
42
- v-for="(item, index) in menus"
43
- :key="item.value || index"
44
- @click="onSelect(item, index)"
45
- >
46
- <view
47
- class="hy-dropdown-item__main--container__list-item--label"
48
- :style="{
49
- color: currentIndex === index ? currentColor : inactiveColor,
50
- }"
51
- >
52
- {{ item.label }}
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
- </view>
63
- </view>
64
- </HyOverlay>
57
+ </HyOverlay>
65
58
  </template>
66
59
 
67
60
  <script lang="ts">
68
61
  export default {
69
- name: "hy-dropdown-item",
70
- options: {
71
- styleIsolation: "shared",
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
- computed,
79
- inject,
80
- ref,
81
- onMounted,
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 "../hy-overlay/hy-overlay.vue";
92
- import HyIcon from "../hy-icon/hy-icon.vue";
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
- // const props = withDefaults(defineProps<IProps>(), defaultProps)
101
- const props = defineProps({
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
- return Object.keys(slots).length > 0;
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("dropdownProps");
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("currentDropItem");
98
+ const currentDropItem: any = inject('currentDropItem')
131
99
  //当前文字/箭头颜色
132
100
  const currentColor = computed(() => {
133
- return isOpen.value ? dropdownProps?.activeColor : inactiveColor;
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 ? "visible" : "hidden"));
113
+ const customClass = computed(() => (isOpen.value ? 'visible' : 'hidden'))
146
114
 
147
115
  onMounted(() => {
148
- getDropPopupTop();
149
- });
116
+ getDropPopupTop()
117
+ })
150
118
 
151
119
  /**
152
120
  * @description 计算下拉弹窗区域距离页面顶部距离
153
121
  * */
154
122
  const getDropPopupTop = () => {
155
- getRect(".hy-dropdown-item__header", false, instance).then((rect) => {
156
- const { bottom } = rect as UniApp.NodeInfo;
157
- // #ifdef H5
158
- //H5需要加上导航栏高度,固定44px
159
- dropPopupTop.value = (bottom || 0) + 44;
160
- // #endif
161
- // #ifndef H5
162
- dropPopupTop.value = bottom || 0;
163
- // #endif
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
- if (v) {
170
- dropHeight.value = "auto";
171
- } else {
172
- //关闭状态隐藏父容器
173
- //延迟改变使得关闭动画能完整呈现
174
- setTimeout(() => {
175
- dropHeight.value = 0;
176
- }, 200);
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
- () => currentDropItem?.value,
185
- (newVal) => {
186
- //关闭其他条件的下拉弹窗
187
- if (newVal !== props.title) {
188
- isOpen.value = false;
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
- () => props.modelValue,
196
- (newVal) => {
197
- currentIndex.value = props.menus.findIndex((item) => item.value === newVal);
198
- },
199
- { immediate: true },
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
- isOpen.value = false;
205
- if (index !== currentIndex.value) {
206
- currentIndex.value = index;
207
- emit("change", item, index);
208
- emit("update:modelValue", item.value);
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
- throttle(() => {
217
- //节流处理,防止点击过快动画未结束又切换导致显示bug
218
- isOpen.value = !isOpen.value;
219
- if (isOpen.value) {
220
- // 防止点击展开后在点击下一个,导致上一个没有关闭bug
221
- currentDropItem.value = props.title;
222
- getDropPopupTop();
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
- if (dropdownProps?.closeOnClickMask) {
231
- isOpen.value = false;
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 "./index.scss";
205
+ @import './index.scss';
238
206
  </style>
@@ -1,10 +1,21 @@
1
- import type IProps from "./typing";
1
+ import type { DropdownMenuItem } from '../hy-dropdown-item/typing'
2
+ import type { PropType } from 'vue'
2
3
 
3
- const defaultProps: IProps = {
4
- modelValue: "",
5
- title: "",
6
- menus: [],
7
- disabled: false,
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 defaultProps;
21
+ export default dropdownItemProps