hy-app 0.1.2 → 0.1.4

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 (247) hide show
  1. package/README.md +1 -1
  2. package/api/http.ts +8 -8
  3. package/components/dialog/index.ts +2 -2
  4. package/components/hy-address-picker/hy-address-picker.vue +3 -29
  5. package/components/hy-address-picker/index.scss +27 -0
  6. package/components/hy-avatar/hy-avatar.vue +1 -45
  7. package/components/hy-avatar/index.scss +45 -0
  8. package/components/hy-avatar/typing.d.ts +1 -1
  9. package/components/hy-back-top/hy-back-top.vue +7 -22
  10. package/components/hy-back-top/index.scss +16 -0
  11. package/components/hy-back-top/props.ts +4 -4
  12. package/components/hy-back-top/typing.d.ts +2 -3
  13. package/components/hy-badge/hy-badge.vue +1 -72
  14. package/components/hy-badge/index.scss +72 -0
  15. package/components/hy-button/hy-button.vue +17 -128
  16. package/components/hy-button/index.scss +116 -0
  17. package/components/hy-button/typing.d.ts +1 -1
  18. package/components/hy-calendar/header.vue +76 -0
  19. package/components/hy-calendar/hy-calendar.vue +366 -0
  20. package/components/hy-calendar/index.scss +171 -0
  21. package/components/hy-calendar/month.vue +524 -0
  22. package/components/hy-calendar/props.ts +37 -0
  23. package/components/hy-calendar/typing.d.ts +126 -0
  24. package/components/hy-card/hy-card.vue +21 -84
  25. package/components/hy-card/index.scss +57 -0
  26. package/components/hy-card/props.ts +2 -2
  27. package/components/hy-card/typing.d.ts +1 -1
  28. package/components/hy-cell/hy-cell.vue +1 -137
  29. package/components/hy-cell/index.scss +137 -0
  30. package/components/hy-check-button/hy-check-button.vue +1 -0
  31. package/components/hy-check-button/index.scss +5 -0
  32. package/components/hy-checkbox/hy-checkbox.vue +2 -95
  33. package/components/hy-checkbox/index.scss +94 -0
  34. package/components/hy-checkbox/typing.d.ts +1 -2
  35. package/components/hy-count-down/hy-count-down.vue +150 -0
  36. package/components/hy-count-down/index.scss +6 -0
  37. package/components/hy-count-down/index.ts +52 -0
  38. package/components/hy-count-down/props.ts +10 -0
  39. package/components/hy-count-down/typing.d.ts +20 -0
  40. package/components/hy-count-to/hy-count-to.vue +213 -0
  41. package/components/hy-count-to/index.scss +6 -0
  42. package/components/hy-count-to/props.ts +17 -0
  43. package/components/hy-count-to/typing.d.ts +48 -0
  44. package/components/hy-datetime-picker/hy-datetime-picker.vue +2 -28
  45. package/components/hy-datetime-picker/index.scss +28 -0
  46. package/components/hy-divider/hy-divider.vue +24 -49
  47. package/components/hy-divider/index.scss +26 -0
  48. package/components/hy-divider/props.ts +2 -2
  49. package/components/hy-divider/typing.d.ts +1 -1
  50. package/components/hy-dropdown/hy-dropdown.vue +43 -0
  51. package/components/hy-dropdown/index.scss +17 -0
  52. package/components/hy-dropdown/props.ts +17 -0
  53. package/components/hy-dropdown/typing.d.ts +48 -0
  54. package/components/hy-dropdown-item/hy-dropdown-item.vue +194 -0
  55. package/components/hy-dropdown-item/index.scss +96 -0
  56. package/components/hy-dropdown-item/props.ts +10 -0
  57. package/components/hy-dropdown-item/typing.d.ts +31 -0
  58. package/components/hy-empty/hy-empty.vue +8 -26
  59. package/components/hy-empty/index.scss +19 -0
  60. package/components/hy-empty/props.ts +2 -2
  61. package/components/hy-empty/typing.d.ts +1 -1
  62. package/components/hy-float-button/hy-float-button.vue +217 -0
  63. package/components/hy-float-button/index.scss +67 -0
  64. package/components/hy-float-button/props.ts +25 -0
  65. package/components/hy-float-button/typing.d.ts +93 -0
  66. package/components/hy-folding-panel/hy-folding-panel.vue +9 -12
  67. package/components/hy-folding-panel/index.scss +6 -0
  68. package/components/hy-folding-panel/props.ts +2 -2
  69. package/components/hy-folding-panel/typing.d.ts +2 -2
  70. package/components/hy-form/hy-form.vue +17 -34
  71. package/components/hy-form/index.scss +30 -0
  72. package/components/hy-form/props.ts +2 -0
  73. package/components/hy-form/typing.d.ts +9 -1
  74. package/components/hy-grid/hy-grid.vue +1 -43
  75. package/components/hy-grid/index.scss +40 -0
  76. package/components/hy-icon/hy-icon.vue +1 -93
  77. package/components/hy-icon/index.scss +84 -0
  78. package/components/hy-image/hy-image.vue +216 -0
  79. package/components/hy-image/index.scss +26 -0
  80. package/components/hy-image/props.ts +24 -0
  81. package/components/hy-image/typing.d.ts +76 -0
  82. package/components/hy-input/hy-input.vue +2 -72
  83. package/components/hy-input/index.scss +65 -0
  84. package/components/hy-line/hy-line.vue +4 -8
  85. package/components/hy-line/index.scss +5 -0
  86. package/components/hy-line/props.ts +3 -3
  87. package/components/hy-line/typing.d.ts +2 -2
  88. package/components/hy-line-progress/hy-line-progress.vue +15 -44
  89. package/components/hy-line-progress/index.scss +38 -0
  90. package/components/hy-line-progress/props.ts +2 -2
  91. package/components/hy-line-progress/typing.d.ts +1 -1
  92. package/components/hy-list/hy-list.vue +11 -41
  93. package/components/hy-list/index.scss +32 -0
  94. package/components/hy-list/props.ts +2 -2
  95. package/components/hy-loading/hy-loading.vue +95 -0
  96. package/components/hy-loading/index.scss +103 -0
  97. package/components/hy-loading/props.ts +17 -0
  98. package/components/hy-loading/typing.d.ts +53 -0
  99. package/components/hy-login/TheUserLogin.vue +20 -88
  100. package/components/hy-login/hy-login.vue +9 -9
  101. package/components/hy-login/props.ts +4 -4
  102. package/components/hy-modal/hy-modal.vue +11 -89
  103. package/components/hy-modal/index.scss +77 -0
  104. package/components/hy-modal/props.ts +2 -2
  105. package/components/hy-modal/typing.d.ts +1 -1
  106. package/components/hy-navbar/hy-navbar.vue +20 -92
  107. package/components/hy-navbar/index.scss +67 -0
  108. package/components/hy-navbar/props.ts +2 -2
  109. package/components/hy-navbar/typing.d.ts +1 -1
  110. package/components/hy-notice-bar/hy-column-notice.vue +11 -39
  111. package/components/hy-notice-bar/hy-notice-bar.vue +10 -12
  112. package/components/hy-notice-bar/hy-row-notice.vue +16 -58
  113. package/components/hy-notice-bar/index.scss +93 -0
  114. package/components/hy-notice-bar/props.ts +4 -2
  115. package/components/hy-notice-bar/typing.d.ts +13 -3
  116. package/components/hy-number-step/hy-number-step.vue +1 -70
  117. package/components/hy-number-step/index.scss +71 -0
  118. package/components/hy-overlay/hy-overlay.vue +2 -14
  119. package/components/hy-overlay/index.scss +9 -0
  120. package/components/hy-parse/hy-parse.vue +499 -0
  121. package/components/hy-parse/index.scss +9 -0
  122. package/components/hy-parse/node/node.vue +584 -0
  123. package/components/hy-parse/parser.js +1337 -0
  124. package/components/hy-parse/props.ts +19 -0
  125. package/components/hy-parse/typing.d.ts +68 -0
  126. package/components/hy-picker/hy-picker.vue +1 -68
  127. package/components/hy-picker/index.scss +68 -0
  128. package/components/hy-popup/hy-popup.vue +1 -74
  129. package/components/hy-popup/index.scss +60 -0
  130. package/components/hy-price/hy-price.vue +7 -19
  131. package/components/hy-price/index.scss +11 -0
  132. package/components/hy-price/props.ts +4 -3
  133. package/components/hy-price/typing.d.ts +8 -4
  134. package/components/hy-qrcode/hy-qrcode.vue +15 -37
  135. package/components/hy-qrcode/index.scss +23 -0
  136. package/components/hy-qrcode/props.ts +2 -2
  137. package/components/hy-qrcode/typing.d.ts +2 -2
  138. package/components/hy-radio/hy-radio.vue +2 -101
  139. package/components/hy-radio/index.scss +93 -0
  140. package/components/hy-radio/typing.d.ts +1 -2
  141. package/components/hy-rate/hy-rate.vue +1 -33
  142. package/components/hy-rate/index.scss +33 -0
  143. package/components/hy-read-more/hy-read-more.vue +7 -30
  144. package/components/hy-read-more/index.scss +25 -0
  145. package/components/hy-read-more/props.ts +3 -3
  146. package/components/hy-read-more/typing.d.ts +1 -1
  147. package/components/hy-safe-bottom/hy-safe-bottom.vue +5 -9
  148. package/components/hy-safe-bottom/index.scss +5 -0
  149. package/components/hy-scroll-list/hy-scroll-list.vue +13 -43
  150. package/components/hy-scroll-list/index.scss +34 -0
  151. package/components/hy-scroll-list/props.ts +2 -2
  152. package/components/hy-scroll-list/typing.d.ts +1 -1
  153. package/components/hy-search/hy-search.vue +1 -83
  154. package/components/hy-search/index.scss +83 -0
  155. package/components/hy-slider/hy-slider.vue +18 -95
  156. package/components/hy-slider/index.scss +77 -0
  157. package/components/hy-status-bar/hy-status-bar.vue +41 -0
  158. package/components/hy-status-bar/index.scss +6 -0
  159. package/components/hy-status-bar/props.ts +8 -0
  160. package/components/hy-status-bar/typing.d.ts +12 -0
  161. package/components/hy-steps/hy-steps.vue +36 -163
  162. package/components/hy-steps/index.scss +131 -0
  163. package/components/hy-steps/props.ts +2 -2
  164. package/components/hy-steps/typing.d.ts +2 -2
  165. package/components/hy-submitBar/Index.vue +17 -0
  166. package/components/hy-submitBar/hy-submitBar.vue +216 -0
  167. package/components/hy-submitBar/index.scss +9 -0
  168. package/components/hy-submitBar/props.ts +22 -0
  169. package/components/hy-submitBar/typing.d.ts +88 -0
  170. package/components/hy-subsection/hy-subsection.vue +40 -132
  171. package/components/hy-subsection/index.scss +82 -0
  172. package/components/hy-subsection/props.ts +1 -0
  173. package/components/hy-subsection/typing.d.ts +13 -4
  174. package/components/hy-swipe-action/hy-swipe-action.vue +294 -0
  175. package/components/hy-swipe-action/index.scss +9 -0
  176. package/components/hy-swipe-action/index.wxs +235 -0
  177. package/components/hy-swipe-action/props.ts +16 -0
  178. package/components/hy-swipe-action/typing.d.ts +55 -0
  179. package/components/hy-swipe-action/wxs.js +15 -0
  180. package/components/hy-swiper/hy-swiper-indicator.vue +5 -35
  181. package/components/hy-swiper/hy-swiper.vue +1 -54
  182. package/components/hy-swiper/index.scss +82 -0
  183. package/components/hy-switch/hy-switch.vue +62 -72
  184. package/components/hy-switch/index.scss +46 -0
  185. package/components/hy-switch/props.ts +4 -1
  186. package/components/hy-switch/typing.d.ts +14 -1
  187. package/components/hy-tabs/hy-tabs.vue +22 -81
  188. package/components/hy-tabs/index.scss +63 -0
  189. package/components/hy-tabs/props.ts +5 -5
  190. package/components/hy-tabs/typing.d.ts +1 -1
  191. package/components/hy-tag/hy-tag.vue +25 -220
  192. package/components/hy-tag/index.scss +205 -0
  193. package/components/hy-text/hy-text.vue +238 -0
  194. package/components/hy-text/index.scss +70 -0
  195. package/components/hy-text/index.ts +0 -0
  196. package/components/hy-text/props.ts +30 -0
  197. package/components/hy-text/typing.d.ts +98 -0
  198. package/components/hy-textarea/hy-textarea.vue +1 -46
  199. package/components/hy-textarea/index.scss +40 -0
  200. package/components/hy-toast/hy-toast.vue +175 -0
  201. package/components/hy-toast/index.scss +77 -0
  202. package/components/hy-toast/props.ts +3 -0
  203. package/components/hy-toast/typing.d.ts +38 -0
  204. package/components/hy-tooltip/hy-tooltip.vue +42 -95
  205. package/components/hy-tooltip/index.scss +64 -0
  206. package/components/hy-tooltip/props.ts +2 -2
  207. package/components/hy-tooltip/typing.d.ts +1 -1
  208. package/components/hy-transition/hy-transition.vue +4 -2
  209. package/components/hy-transition/typing.d.ts +1 -13
  210. package/components/hy-upload/hy-upload.vue +37 -182
  211. package/components/hy-upload/index.scss +147 -0
  212. package/components/hy-upload/props.ts +2 -2
  213. package/components/hy-upload/typing.d.ts +11 -11
  214. package/components/hy-warn/hy-warn.vue +17 -144
  215. package/components/hy-warn/index.scss +109 -0
  216. package/components/hy-warn/props.ts +3 -3
  217. package/components/hy-warn/typing.d.ts +4 -3
  218. package/components/hy-waterfall/hy-waterfall.vue +168 -38
  219. package/components/hy-waterfall/index.scss +16 -0
  220. package/components/hy-waterfall/props.ts +4 -5
  221. package/components/hy-waterfall/typing.d.ts +5 -9
  222. package/components/index.ts +25 -1
  223. package/components/message/index.ts +54 -54
  224. package/composables/index.ts +1 -0
  225. package/composables/useShare.ts +27 -0
  226. package/config/color.ts +3 -2
  227. package/config/icon.ts +21 -1
  228. package/global/index.ts +6 -6
  229. package/global/register-properties.ts +2 -2
  230. package/index.scss +2 -1
  231. package/index.ts +9 -8
  232. package/libs/css/common.scss +14 -2
  233. package/package.json +3 -2
  234. package/{libs/css → public/font}/iconfont.css +4 -4
  235. package/theme.scss +6 -4
  236. package/typing/index.ts +1 -1
  237. package/typing/modules/common.d.ts +36 -1
  238. package/utils/calendar.js +1021 -0
  239. package/utils/colorGradient.ts +112 -0
  240. package/utils/index.ts +2 -0
  241. package/utils/inside.ts +80 -34
  242. package/utils/inspect.ts +115 -0
  243. package/utils/utils.ts +20 -19
  244. package/libs/css/download.zip +0 -0
  245. /package/{libs/css → public/font}/iconfont.ttf +0 -0
  246. /package/{libs/css → public/font}/iconfont.woff +0 -0
  247. /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
- <view class="hy-divider__line" :style="[leftLineStyle, lineStyle]"></view>
4
- <HyIcon
5
- v-if="text === 'loading'"
6
- :name="IconConfig.LOADING"
7
- :color="textColor"
8
- is-rotate
9
- ></HyIcon>
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
- <view class="hy-divider__line" :style="[rightLineStyle, lineStyle]"></view>
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 HyIcon from "../hy-icon/hy-icon.vue";
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 "../../libs/css/mixin.scss";
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,26 @@
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
+ min-height: 35px;
10
+
11
+ &__line {
12
+ /* #ifndef APP-NVUE */
13
+ vertical-align: middle;
14
+ /* #endif */
15
+ }
16
+
17
+ &__text {
18
+ margin: 0 $hy-border-margin-padding-sm;
19
+ }
20
+
21
+ &__dot {
22
+ font-size: $hy-font-size-sm;
23
+ margin: 0 $hy-border-margin-padding-sm;
24
+ color: #c0c4cc;
25
+ }
26
+ }
@@ -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;
@@ -1,4 +1,4 @@
1
- import { CSSProperties } from "vue";
1
+ import type { CSSProperties } from "vue";
2
2
 
3
3
  export default interface IProps {
4
4
  /**
@@ -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,10 @@
1
+ import type IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ modelValue: "",
5
+ title: "",
6
+ menus: [],
7
+ disabled: false,
8
+ };
9
+
10
+ export default defaultProps;
@@ -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
+ }