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
@@ -218,58 +218,5 @@ const getItemType = computed(() => {
218
218
  </script>
219
219
 
220
220
  <style lang="scss" scoped>
221
- @import "../../libs/css/mixin.scss";
222
- @import "../../theme.scss";
223
-
224
- .hy-swiper__wrapper {
225
- flex: 1;
226
- }
227
- .hy-swiper {
228
- @include flex;
229
- justify-content: center;
230
- align-items: center;
231
- position: relative;
232
- overflow: hidden;
233
-
234
- &__wrapper {
235
- flex: 1;
236
-
237
- &__item {
238
- flex: 1;
239
-
240
- &__wrapper {
241
- @include flex;
242
- position: relative;
243
- overflow: hidden;
244
- transition: transform 0.3s;
245
- flex: 1;
246
-
247
- &__image {
248
- flex: 1;
249
- }
250
-
251
- &__video {
252
- flex: 1;
253
- }
254
-
255
- &__title {
256
- position: absolute;
257
- background-color: rgba(0, 0, 0, 0.3);
258
- bottom: 0;
259
- left: 0;
260
- right: 0;
261
- font-size: 28rpx;
262
- padding: $hy-border-margin-padding-sm $hy-border-margin-padding-lg;
263
- color: #ffffff;
264
- flex: 1;
265
- }
266
- }
267
- }
268
- }
269
-
270
- &__indicator {
271
- position: absolute;
272
- bottom: $hy-border-margin-padding-sm;
273
- }
274
- }
221
+ @import "./index.scss";
275
222
  </style>
@@ -0,0 +1,82 @@
1
+ @use "../../theme.scss" as *;
2
+ @use "../../libs/css/mixin.scss" as *;
3
+
4
+ .hy-swiper {
5
+ @include flex;
6
+ justify-content: center;
7
+ align-items: center;
8
+ position: relative;
9
+ overflow: hidden;
10
+
11
+ &__wrapper {
12
+ flex: 1;
13
+
14
+ &__item {
15
+ flex: 1;
16
+
17
+ &__wrapper {
18
+ @include flex;
19
+ position: relative;
20
+ overflow: hidden;
21
+ transition: transform 0.3s;
22
+ flex: 1;
23
+
24
+ &__image {
25
+ flex: 1;
26
+ }
27
+
28
+ &__video {
29
+ flex: 1;
30
+ }
31
+
32
+ &__title {
33
+ position: absolute;
34
+ background-color: rgba(0, 0, 0, 0.3);
35
+ bottom: 0;
36
+ left: 0;
37
+ right: 0;
38
+ font-size: 28rpx;
39
+ padding: $hy-border-margin-padding-sm $hy-border-margin-padding-lg;
40
+ color: #ffffff;
41
+ flex: 1;
42
+ }
43
+ }
44
+ }
45
+ }
46
+
47
+ &__indicator {
48
+ position: absolute;
49
+ bottom: $hy-border-margin-padding-sm;
50
+ }
51
+ }
52
+
53
+
54
+ .hy-swiper-indicator {
55
+ &__wrapper {
56
+ @include flex;
57
+
58
+ &--line {
59
+ border-radius: 100px;
60
+ height: 4px;
61
+
62
+ &__bar {
63
+ width: 22px;
64
+ height: 4px;
65
+ border-radius: $hy-border-radius-semicircle;
66
+ background-color: #ffffff;
67
+ transition: transform 0.3s;
68
+ }
69
+ }
70
+
71
+ &__dot {
72
+ width: 5px;
73
+ height: 5px;
74
+ border-radius: $hy-border-radius-semicircle;
75
+ margin: 0 $hy-border-margin-padding-sm;
76
+
77
+ &--active {
78
+ width: 12px;
79
+ }
80
+ }
81
+ }
82
+ }
@@ -11,31 +11,32 @@
11
11
  :style="[nodeStyle]"
12
12
  ref="hy-switch__node"
13
13
  >
14
- <HyIcon
15
- v-if="loading"
16
- :name="IconConfig.LOADING"
17
- is-rotate
18
- :color="modelValue ? activeColor : '#AAABAD'"
19
- :size="size * 0.6"
20
- ></HyIcon>
14
+ <hy-loading
15
+ :show="loading"
16
+ :size="switchSize * 0.6"
17
+ mode="circle"
18
+ ></hy-loading>
19
+ <view class="" v-if="!loading">
20
+ <slot>
21
+ <HyIcon
22
+ :name="modelValue ? activeIcon : inactiveIcon"
23
+ :size="switchSize * 0.6"
24
+ :color="iconColor"
25
+ ></HyIcon>
26
+ </slot>
27
+ </view>
21
28
  </view>
22
29
  </view>
23
30
  </template>
24
31
 
25
32
  <script setup lang="ts">
26
- import {
27
- toRefs,
28
- watch,
29
- ref,
30
- nextTick,
31
- computed,
32
- type CSSProperties,
33
- } from "vue";
34
- import { IconConfig } from "../../config";
33
+ import { toRefs, watch, nextTick, computed, type CSSProperties } from "vue";
35
34
  import { addUnit, error } from "../../utils";
36
35
  import defaultProps from "./props";
37
36
  import type IProps from "./typing";
38
37
 
38
+ // 组件
39
+ import HyLoading from "../hy-loading/hy-loading.vue";
39
40
  import HyIcon from "../hy-icon/hy-icon.vue";
40
41
 
41
42
  const props = withDefaults(defineProps<IProps>(), defaultProps);
@@ -52,7 +53,6 @@ const {
52
53
  inactiveColor,
53
54
  } = toRefs(props);
54
55
  const emit = defineEmits(["update:modelValue", "change"]);
55
- const bgColor = ref("#ffffff");
56
56
 
57
57
  watch(
58
58
  () => modelValue.value,
@@ -64,14 +64,36 @@ watch(
64
64
  { immediate: true },
65
65
  );
66
66
 
67
+ /**
68
+ * @description 是否打开
69
+ * */
67
70
  const isActive = computed(() => {
68
71
  return modelValue.value === activeValue.value;
69
72
  });
73
+
74
+ /**
75
+ * @description 设置开关大小
76
+ * */
77
+ const switchSize = computed((): number => {
78
+ const sz: AnyObject = {
79
+ small: 20,
80
+ medium: 25,
81
+ large: 30,
82
+ };
83
+
84
+ return typeof size.value === "number"
85
+ ? size.value
86
+ : sz[size.value] || Number(size.value);
87
+ });
88
+
89
+ /**
90
+ * @description 开关样式
91
+ * */
70
92
  const switchStyle = computed<CSSProperties>(() => {
71
93
  let style: CSSProperties = {};
72
94
  // 这里需要加2,是为了腾出边框的距离,否则圆点node会和外边框紧贴在一起
73
- style.width = addUnit(size.value * 2 + 2);
74
- style.height = addUnit(Number(size.value) + 2);
95
+ style.width = addUnit(switchSize.value * 2 + 2);
96
+ style.height = addUnit(switchSize.value + 2);
75
97
  // style.borderColor = this.value ? 'rgba(0, 0, 0, 0)' : 'rgba(0, 0, 0, 0.12)'
76
98
  // 如果自定义了“非激活”演示,name边框颜色设置为透明(跟非激活颜色一致)
77
99
  // 这里不能简单的设置为非激活的颜色,否则打开状态时,会有边框,所以需要透明
@@ -83,32 +105,47 @@ const switchStyle = computed<CSSProperties>(() => {
83
105
  : inactiveColor.value;
84
106
  return style;
85
107
  });
108
+
109
+ /**
110
+ * @description 圆圈样式
111
+ * */
86
112
  const nodeStyle = computed<CSSProperties>(() => {
87
113
  let style: CSSProperties = {};
88
114
  // 如果自定义非激活颜色,将node圆点的尺寸减少两个像素,让其与外边框距离更大一点
89
- style.width = addUnit(size.value - space.value);
90
- style.height = addUnit(size.value - space.value);
115
+ style.width = addUnit(switchSize.value - space.value);
116
+ style.height = addUnit(switchSize.value - space.value);
91
117
  const translateX = isActive.value
92
118
  ? addUnit(space.value)
93
- : addUnit(size.value);
119
+ : addUnit(switchSize.value);
94
120
  style.transform = `translateX(-${translateX})`;
95
121
  return style;
96
122
  });
123
+
124
+ /**
125
+ * @description 背景样式
126
+ * */
97
127
  const bgStyle = computed<CSSProperties>(() => {
98
128
  let style: CSSProperties = {};
99
129
  // 这里配置一个多余的元素在HTML中,是为了让switch切换时,有更良好的背景色扩充体验(见实际效果)
100
- style.width = addUnit(Number(size.value) * 2 - size.value / 2);
101
- style.height = addUnit(size.value);
130
+ style.width = addUnit(switchSize.value * 2 - switchSize.value / 2);
131
+ style.height = addUnit(switchSize.value);
102
132
  style.backgroundColor = inactiveColor.value;
103
133
  // 打开时,让此元素收缩,否则反之
104
134
  style.transform = `scale(${isActive.value ? 0 : 1})`;
105
135
  return style;
106
136
  });
137
+
138
+ /**
139
+ * @description 自定义颜色
140
+ * */
107
141
  const customInactiveColor = computed(() => {
108
142
  // 之所以需要判断是否自定义了“非激活”颜色,是为了让node圆点离外边框更宽一点的距离
109
143
  return inactiveColor.value !== "#fff" && inactiveColor.value !== "#ffffff";
110
144
  });
111
145
 
146
+ /**
147
+ * @description 点击事件
148
+ * */
112
149
  const clickHandler = () => {
113
150
  if (!disabled.value && !loading.value) {
114
151
  const oldValue = isActive.value ? inactiveValue.value : activeValue.value;
@@ -124,52 +161,5 @@ const clickHandler = () => {
124
161
  </script>
125
162
 
126
163
  <style lang="scss" scoped>
127
- @import "../../libs/css/mixin.scss";
128
-
129
- .hy-switch {
130
- @include flex(row);
131
- /* #ifndef APP-NVUE */
132
- box-sizing: border-box;
133
- /* #endif */
134
- position: relative;
135
- background-color: #fff;
136
- border-width: 1px;
137
- border-radius: 100px;
138
- transition: background-color 0.4s;
139
- border-color: rgba(0, 0, 0, 0.12);
140
- border-style: solid;
141
- justify-content: flex-end;
142
- align-items: center;
143
- // 由于weex为阿里逗着玩的KPI项目,导致bug奇多,这必须要写这一行,
144
- // 否则在iOS上,点击页面任意地方,都会触发switch的点击事件
145
- overflow: hidden;
146
-
147
- &__node {
148
- @include flex(row);
149
- align-items: center;
150
- justify-content: center;
151
- border-radius: 100px;
152
- background-color: #fff;
153
- border-radius: 100px;
154
- box-shadow: 1px 1px 1px 0 rgba(0, 0, 0, 0.25);
155
- transition-property: transform;
156
- transition-duration: 0.4s;
157
- transition-timing-function: cubic-bezier(0.3, 1.05, 0.4, 1.05);
158
- }
159
-
160
- &__bg {
161
- position: absolute;
162
- border-radius: 100px;
163
- background-color: #ffffff;
164
- transition-property: transform;
165
- transition-duration: 0.4s;
166
- border-top-left-radius: 0;
167
- border-bottom-left-radius: 0;
168
- transition-timing-function: ease;
169
- }
170
-
171
- &--disabled {
172
- opacity: 0.6;
173
- }
174
- }
164
+ @import "./index.scss";
175
165
  </style>
@@ -0,0 +1,46 @@
1
+ @use "../../theme.scss" as *;
2
+ @use "../../libs/css/mixin.scss" as *;
3
+
4
+ .hy-switch {
5
+ @include flex(row);
6
+ /* #ifndef APP-NVUE */
7
+ box-sizing: border-box;
8
+ /* #endif */
9
+ position: relative;
10
+ background-color: #fff;
11
+ border-radius: $hy-border-radius-semicircle;
12
+ transition: background-color 0.4s;
13
+ border: 1px solid rgba(0, 0, 0, 0.12);
14
+ justify-content: flex-end;
15
+ align-items: center;
16
+ // 由于weex为阿里逗着玩的KPI项目,导致bug奇多,这必须要写这一行,
17
+ // 否则在iOS上,点击页面任意地方,都会触发switch的点击事件
18
+ overflow: hidden;
19
+
20
+ &__node {
21
+ @include flex(row);
22
+ align-items: center;
23
+ justify-content: center;
24
+ background-color: #fff;
25
+ border-radius: $hy-border-radius-semicircle;
26
+ box-shadow: 1px 1px 1px 0 rgba(0, 0, 0, 0.25);
27
+ transition-property: transform;
28
+ transition-duration: 0.4s;
29
+ transition-timing-function: cubic-bezier(0.3, 1.05, 0.4, 1.05);
30
+ }
31
+
32
+ &__bg {
33
+ position: absolute;
34
+ border-radius: $hy-border-radius-semicircle;
35
+ background-color: #ffffff;
36
+ transition-property: transform;
37
+ transition-duration: 0.4s;
38
+ border-top-left-radius: 0;
39
+ border-bottom-left-radius: 0;
40
+ transition-timing-function: ease;
41
+ }
42
+
43
+ &--disabled {
44
+ opacity: 0.6;
45
+ }
46
+ }
@@ -5,11 +5,14 @@ const defaultProps: IProps = {
5
5
  modelValue: false,
6
6
  loading: false,
7
7
  disabled: false,
8
- size: 25,
8
+ size: "medium",
9
9
  activeColor: ColorConfig.primary,
10
10
  inactiveColor: "#ffffff",
11
11
  activeValue: true,
12
12
  inactiveValue: false,
13
+ activeIcon: "",
14
+ inactiveIcon: "",
15
+ iconColor: "",
13
16
  asyncChange: false,
14
17
  space: 0,
15
18
  };
@@ -1,4 +1,5 @@
1
1
  import type { CSSProperties } from "vue";
2
+ import { HyApp } from "@/package/typing/modules/common";
2
3
 
3
4
  export default interface IProps {
4
5
  /**
@@ -16,7 +17,7 @@ export default interface IProps {
16
17
  /**
17
18
  * @description 开关尺寸,单位px (默认 25 )
18
19
  * */
19
- size?: number;
20
+ size?: HyApp.SizeType | string | number;
20
21
  /**
21
22
  * @description 打开时的背景色 (默认 '#2979ff' )
22
23
  * */
@@ -33,6 +34,18 @@ export default interface IProps {
33
34
  * @description 关闭选择器时通过change事件发出的值 (默认 false )
34
35
  * */
35
36
  inactiveValue?: boolean;
37
+ /**
38
+ * @description 打开选择器时图标
39
+ * */
40
+ activeIcon?: string;
41
+ /**
42
+ * @description 关闭选择器时图标
43
+ * */
44
+ inactiveIcon?: string;
45
+ /**
46
+ * @description 图标颜色
47
+ * */
48
+ iconColor?: string;
36
49
  /**
37
50
  * @description 是否开启异步变更,开启后需要手动控制输入值 (默认 false )
38
51
  * */
@@ -25,7 +25,7 @@
25
25
  item.disabled && 'hy-tabs__wrapper__nav__item--disabled',
26
26
  innerCurrent == index
27
27
  ? 'hy-tabs__wrapper__nav__item-active'
28
- : ''
28
+ : '',
29
29
  ]"
30
30
  >
31
31
  <slot
@@ -51,7 +51,8 @@
51
51
  <text
52
52
  v-else
53
53
  :class="[
54
- item.disabled && 'hy-tabs__wrapper__nav__item__text--disabled'
54
+ item.disabled &&
55
+ 'hy-tabs__wrapper__nav__item__text--disabled',
55
56
  ]"
56
57
  class="hy-tabs__wrapper__nav__item__text"
57
58
  :style="[textStyle(index)]"
@@ -94,7 +95,7 @@
94
95
  (item?.badge && item?.badge?.inverted) || propsBadge?.inverted
95
96
  "
96
97
  :customStyle="{
97
- marginLeft: '4px'
98
+ marginLeft: '4px',
98
99
  }"
99
100
  ></HyBadge>
100
101
  </view>
@@ -109,8 +110,8 @@
109
110
  transitionDuration: `${firstTime ? 0 : duration}ms`,
110
111
  height: addUnit(lineHeight),
111
112
  background: lineColor,
112
- backgroundSize: lineBgSize
113
- }
113
+ backgroundSize: lineBgSize,
114
+ },
114
115
  ]"
115
116
  >
116
117
  </view>
@@ -139,15 +140,16 @@
139
140
  <script setup lang="ts">
140
141
  import {
141
142
  computed,
142
- CSSProperties,
143
+ type CSSProperties,
143
144
  toRefs,
144
145
  ref,
145
146
  watch,
146
147
  nextTick,
147
- onMounted
148
+ onMounted, getCurrentInstance,
148
149
  } from "vue";
149
150
  import defaultProps from "./props";
150
- import IProps, { TabsItemVo } from "./typing";
151
+ import type IProps from "./typing";
152
+ import type { TabsItemVo } from "./typing";
151
153
  import { addUnit, getPx, getRect, sleep } from "../../utils";
152
154
 
153
155
  // 组件
@@ -158,12 +160,13 @@ const props = withDefaults(defineProps<IProps>(), defaultProps);
158
160
  const { list, current, activeStyle, lineWidth, inactiveStyle } = toRefs(props);
159
161
  const emit = defineEmits(["click", "longPress", "update:current", "change"]);
160
162
 
163
+ const instance = getCurrentInstance();
161
164
  const firstTime = ref<boolean>(true);
162
165
  const scrollLeft = ref<number>(0);
163
166
  const scrollViewWidth = ref<number>(0);
164
167
  const lineOffsetLeft = ref<number>(0);
165
168
  const tabsRect = ref<UniApp.NodeInfo>({
166
- left: 0
169
+ left: 0,
167
170
  });
168
171
  const innerCurrent = ref<number>(0);
169
172
 
@@ -178,11 +181,11 @@ watch(
178
181
  });
179
182
  }
180
183
  },
181
- { immediate: true }
184
+ { immediate: true },
182
185
  );
183
186
  watch(
184
187
  () => list.value,
185
- () => resize()
188
+ () => resize(),
186
189
  );
187
190
 
188
191
  const textStyle = computed(() => {
@@ -234,9 +237,9 @@ const clickHandler = (item: TabsItemVo, index: number) => {
234
237
  "click",
235
238
  {
236
239
  ...item,
237
- index
240
+ index,
238
241
  },
239
- index
242
+ index,
240
243
  );
241
244
  // 如果disabled状态,返回
242
245
  if (item.disabled) return;
@@ -249,7 +252,7 @@ const clickHandler = (item: TabsItemVo, index: number) => {
249
252
  const longPressHandler = (item: TabsItemVo, index: number) => {
250
253
  emit("longPress", {
251
254
  ...item,
252
- index
255
+ index,
253
256
  });
254
257
  };
255
258
  const setScrollLeft = () => {
@@ -275,7 +278,7 @@ const setScrollLeft = () => {
275
278
  // 这里做一个限制,限制scrollLeft的最大值为整个scroll-view宽度减去tabs组件的宽度
276
279
  scrollLeft_1 = Math.min(
277
280
  scrollLeft_1,
278
- scrollViewWidth.value - (tabsRect.value.width || 0)
281
+ scrollViewWidth.value - (tabsRect.value.width || 0),
279
282
  );
280
283
  scrollLeft.value = Math.max(0, scrollLeft_1);
281
284
  };
@@ -313,7 +316,7 @@ const resize = () => {
313
316
  // 获取了tabs的尺寸之后,设置滑块的位置
314
317
  setLineLeft();
315
318
  setScrollLeft();
316
- }
319
+ },
317
320
  );
318
321
  };
319
322
  /**
@@ -321,7 +324,7 @@ const resize = () => {
321
324
  * */
322
325
  const getTabsRect = () => {
323
326
  return new Promise((resolve) => {
324
- getRect(".hy-tabs__wrapper__scroll-view").then((size) => resolve(size));
327
+ getRect(".hy-tabs__wrapper__scroll-view", false, instance).then((size) => resolve(size));
325
328
  });
326
329
  };
327
330
  /**
@@ -330,7 +333,7 @@ const getTabsRect = () => {
330
333
  const getAllItemRect = () => {
331
334
  return new Promise((resolve) => {
332
335
  const promiseAllArr = list.value.map((item, index) =>
333
- getRect(`.hy-tabs__wrapper__nav__item-${index}`)
336
+ getRect(`.hy-tabs__wrapper__nav__item-${index}`, false, instance),
334
337
  );
335
338
  Promise.all(promiseAllArr).then((sizes) => resolve(sizes));
336
339
  });
@@ -350,67 +353,5 @@ const animationFinish = (e: any) => {
350
353
  </script>
351
354
 
352
355
  <style lang="scss" scoped>
353
- @import "../../libs/css/mixin.scss";
354
- @import "../../theme.scss";
355
-
356
- .hy-tabs {
357
- &__wrapper {
358
- @include flex;
359
- align-items: center;
360
-
361
- &__scroll-view-wrapper {
362
- flex: 1;
363
- /* #ifndef APP-NVUE */
364
- overflow: auto hidden;
365
- /* #endif */
366
- }
367
-
368
- &__scroll-view {
369
- @include flex;
370
- flex: 1;
371
- }
372
-
373
- &__nav {
374
- @include flex;
375
- position: relative;
376
-
377
- &__item {
378
- padding: 0 11px;
379
- @include flex;
380
- align-items: center;
381
- justify-content: center;
382
- /* #ifdef H5 */
383
- cursor: pointer;
384
- /* #endif */
385
-
386
- &--disabled {
387
- /* #ifdef H5 */
388
- cursor: not-allowed;
389
- /* #endif */
390
- }
391
-
392
- &__text {
393
- font-size: 15px;
394
- color: $hy-text-color-grey;
395
- white-space: nowrap !important;
396
-
397
- &--disabled {
398
- color: $hy-color-disable-bg !important;
399
- }
400
- }
401
- }
402
-
403
- &__line {
404
- height: 3px;
405
- background: $hy-primary;
406
- width: 30px;
407
- position: absolute;
408
- bottom: 2px;
409
- border-radius: 100px;
410
- transition-property: transform;
411
- transition-duration: 300ms;
412
- }
413
- }
414
- }
415
- }
356
+ @import "./index.scss";
416
357
  </style>