hy-app 0.4.15 → 0.5.1

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 (206) 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/hy-coupon.vue +10 -5
  55. package/components/hy-coupon/index.scss +148 -64
  56. package/components/hy-coupon/props.ts +35 -50
  57. package/components/hy-coupon/typing.d.ts +10 -0
  58. package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
  59. package/components/hy-datetime-picker/props.ts +142 -32
  60. package/components/hy-datetime-picker/typing.d.ts +132 -132
  61. package/components/hy-divider/hy-divider.vue +90 -169
  62. package/components/hy-divider/props.ts +78 -19
  63. package/components/hy-divider/typing.d.ts +60 -60
  64. package/components/hy-dropdown/hy-dropdown.vue +37 -71
  65. package/components/hy-dropdown/props.ts +38 -15
  66. package/components/hy-dropdown/typing.d.ts +44 -44
  67. package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
  68. package/components/hy-dropdown-item/props.ts +19 -8
  69. package/components/hy-empty/hy-empty.vue +75 -129
  70. package/components/hy-empty/props.ts +57 -15
  71. package/components/hy-empty/typing.d.ts +84 -84
  72. package/components/hy-flex/hy-flex.vue +33 -88
  73. package/components/hy-flex/props.ts +58 -0
  74. package/components/hy-flex/typing.d.ts +14 -16
  75. package/components/hy-float-button/hy-float-button.vue +289 -406
  76. package/components/hy-float-button/props.ts +109 -25
  77. package/components/hy-folding-panel/hy-folding-panel.vue +74 -114
  78. package/components/hy-folding-panel/props.ts +42 -0
  79. package/components/hy-folding-panel/typing.d.ts +57 -57
  80. package/components/hy-folding-panel-item/hy-folding-panel-item.vue +139 -231
  81. package/components/hy-folding-panel-item/props.ts +81 -0
  82. package/components/hy-folding-panel-item/typing.d.ts +23 -23
  83. package/components/hy-form/hy-form.vue +172 -212
  84. package/components/hy-form/props.ts +37 -0
  85. package/components/hy-form/typing.d.ts +68 -61
  86. package/components/hy-form-group/typing.d.ts +74 -74
  87. package/components/hy-form-item/hy-form-item.vue +100 -129
  88. package/components/hy-form-item/props.ts +25 -0
  89. package/components/hy-form-item/typing.d.ts +40 -37
  90. package/components/hy-grid/hy-grid.vue +76 -132
  91. package/components/hy-grid/props.ts +58 -16
  92. package/components/hy-grid/typing.d.ts +66 -66
  93. package/components/hy-icon/hy-icon.vue +84 -161
  94. package/components/hy-icon/props.ts +76 -22
  95. package/components/hy-icon/typing.d.ts +83 -82
  96. package/components/hy-image/hy-image.vue +142 -272
  97. package/components/hy-image/props.ts +105 -23
  98. package/components/hy-image/typing.d.ts +84 -87
  99. package/components/hy-input/hy-input.vue +230 -421
  100. package/components/hy-input/props.ts +183 -35
  101. package/components/hy-input/typing.d.ts +169 -169
  102. package/components/hy-line/hy-line.vue +34 -72
  103. package/components/hy-line/props.ts +41 -10
  104. package/components/hy-line/typing.d.ts +29 -29
  105. package/components/hy-line-progress/hy-line-progress.vue +66 -101
  106. package/components/hy-line-progress/props.ts +31 -10
  107. package/components/hy-line-progress/typing.d.ts +29 -29
  108. package/components/hy-list/hy-list.vue +151 -220
  109. package/components/hy-list/props.ts +67 -16
  110. package/components/hy-list/typing.d.ts +52 -52
  111. package/components/hy-loading/hy-loading.vue +63 -119
  112. package/components/hy-loading/props.ts +63 -15
  113. package/components/hy-loading/typing.d.ts +49 -49
  114. package/components/hy-menu/hy-menu.vue +124 -166
  115. package/components/hy-menu/props.ts +42 -10
  116. package/components/hy-menu/typing.d.ts +60 -60
  117. package/components/hy-modal/hy-modal.vue +127 -218
  118. package/components/hy-modal/props.ts +89 -24
  119. package/components/hy-navbar/hy-navbar.vue +104 -177
  120. package/components/hy-navbar/props.ts +76 -22
  121. package/components/hy-navbar/typing.d.ts +81 -81
  122. package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
  123. package/components/hy-notice-bar/props.ts +80 -19
  124. package/components/hy-notice-bar/typing.d.ts +62 -62
  125. package/components/hy-notify/hy-notify.vue +128 -177
  126. package/components/hy-notify/props.ts +49 -12
  127. package/components/hy-notify/typing.d.ts +45 -41
  128. package/components/hy-number-step/hy-number-step.vue +281 -394
  129. package/components/hy-number-step/props.ts +110 -27
  130. package/components/hy-number-step/typing.d.ts +120 -120
  131. package/components/hy-overlay/hy-overlay.vue +39 -66
  132. package/components/hy-overlay/props.ts +31 -8
  133. package/components/hy-pagination/hy-pagination.vue +100 -155
  134. package/components/hy-pagination/props.ts +53 -13
  135. package/components/hy-picker/hy-picker.vue +309 -430
  136. package/components/hy-picker/index.scss +8 -12
  137. package/components/hy-picker/props.ts +110 -26
  138. package/components/hy-popover/hy-popover.vue +190 -252
  139. package/components/hy-popover/props.ts +48 -10
  140. package/components/hy-popup/hy-popup.vue +162 -248
  141. package/components/hy-popup/props.ts +82 -18
  142. package/components/hy-price/hy-price.vue +45 -104
  143. package/components/hy-price/props.ts +52 -12
  144. package/components/hy-price/typing.d.ts +41 -36
  145. package/components/hy-qrcode/hy-qrcode.vue +115 -185
  146. package/components/hy-qrcode/props.ts +68 -18
  147. package/components/hy-qrcode/typing.d.ts +67 -66
  148. package/components/hy-radio/hy-radio.vue +161 -259
  149. package/components/hy-radio/props.ts +95 -25
  150. package/components/hy-radio/typing.d.ts +85 -84
  151. package/components/hy-rate/hy-rate.vue +185 -270
  152. package/components/hy-rate/props.ts +76 -18
  153. package/components/hy-rate/typing.d.ts +61 -60
  154. package/components/hy-read-more/hy-read-more.vue +93 -136
  155. package/components/hy-read-more/props.ts +43 -13
  156. package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
  157. package/components/hy-scroll-list/props.ts +22 -11
  158. package/components/hy-search/hy-search.vue +155 -284
  159. package/components/hy-search/props.ts +130 -25
  160. package/components/hy-signature/hy-signature.vue +491 -635
  161. package/components/hy-signature/props.ts +115 -26
  162. package/components/hy-signature/typing.d.ts +138 -138
  163. package/components/hy-slider/hy-slider.vue +388 -477
  164. package/components/hy-slider/props.ts +75 -19
  165. package/components/hy-steps/hy-steps.vue +212 -279
  166. package/components/hy-steps/props.ts +47 -13
  167. package/components/hy-submit-bar/hy-submit-bar.vue +136 -221
  168. package/components/hy-submit-bar/props.ts +89 -20
  169. package/components/hy-submit-bar/typing.d.ts +87 -87
  170. package/components/hy-subsection/hy-subsection.vue +132 -185
  171. package/components/hy-subsection/props.ts +50 -17
  172. package/components/hy-subsection/typing.d.ts +52 -52
  173. package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
  174. package/components/hy-swipe-action/props.ts +43 -18
  175. package/components/hy-swipe-action/typing.d.ts +46 -46
  176. package/components/hy-swiper/hy-swiper.vue +159 -286
  177. package/components/hy-swiper/props.ts +126 -28
  178. package/components/hy-swiper/typing.d.ts +115 -115
  179. package/components/hy-switch/hy-switch.vue +112 -176
  180. package/components/hy-switch/props.ts +60 -15
  181. package/components/hy-switch/typing.d.ts +63 -63
  182. package/components/hy-tabBar/hy-tabBar.vue +64 -60
  183. package/components/hy-tabs/hy-tabs.vue +277 -380
  184. package/components/hy-tabs/props.ts +75 -18
  185. package/components/hy-tag/hy-tag.vue +111 -204
  186. package/components/hy-tag/props.ts +81 -19
  187. package/components/hy-text/hy-text.vue +200 -322
  188. package/components/hy-text/props.ts +107 -28
  189. package/components/hy-textarea/hy-textarea.vue +147 -256
  190. package/components/hy-textarea/props.ts +112 -25
  191. package/components/hy-textarea/typing.d.ts +42 -42
  192. package/components/hy-toast/hy-toast.vue +135 -143
  193. package/components/hy-tooltip/hy-tooltip.vue +220 -306
  194. package/components/hy-tooltip/props.ts +79 -15
  195. package/components/hy-transition/hy-transition.vue +111 -138
  196. package/components/hy-transition/props.ts +30 -8
  197. package/components/hy-upload/hy-upload.vue +320 -469
  198. package/components/hy-upload/props.ts +130 -27
  199. package/components/hy-warn/hy-warn.vue +80 -129
  200. package/components/hy-warn/props.ts +47 -12
  201. package/components/hy-waterfall/hy-waterfall.vue +139 -163
  202. package/components/hy-waterfall/props.ts +19 -7
  203. package/components/hy-watermark/hy-watermark.vue +762 -870
  204. package/components/hy-watermark/props.ts +103 -22
  205. package/package.json +2 -2
  206. package/web-types.json +1 -1
@@ -1,21 +1,77 @@
1
- import type IProps from "./typing";
2
- import { ColorConfig } from "../../libs/config";
1
+ import type { CSSProperties, PropType } from 'vue'
3
2
 
4
- const defaultProps: IProps = {
5
- modelValue: 0,
6
- blockSize: 18,
7
- min: 0,
8
- max: 100,
9
- step: 1,
10
- activeColor: "",
11
- inactiveColor: "",
12
- blockColor: "",
13
- showValue: false,
14
- disabled: false,
15
- useNative: false,
16
- height: "2px",
17
- rangeValue: [0, 0],
18
- isRange: false,
19
- };
3
+ const sliderProps = {
4
+ /** 滑块默认值 */
5
+ modelValue: {
6
+ type: Number,
7
+ default: 0
8
+ },
9
+ /** 滑块的大小,取值范围为 12 - 28 */
10
+ blockSize: {
11
+ type: [String, Number],
12
+ default: 18
13
+ },
14
+ /** 最小值 */
15
+ min: {
16
+ type: Number,
17
+ default: 0
18
+ },
19
+ /** 最大值 */
20
+ max: {
21
+ type: Number,
22
+ default: 100
23
+ },
24
+ /** 步长 */
25
+ step: {
26
+ type: Number,
27
+ default: 1
28
+ },
29
+ /** 底部选择部分的背景颜色 */
30
+ activeColor: String,
31
+ /** 底部条背景颜色 */
32
+ inactiveColor: String,
33
+ /** 滑块颜色 */
34
+ blockColor: String,
35
+ /** 是否显示当前的选择值 */
36
+ showValue: {
37
+ type: Boolean,
38
+ default: false
39
+ },
40
+ /** 是否禁用滑块 */
41
+ disabled: {
42
+ type: Boolean,
43
+ default: false
44
+ },
45
+ /** 是否渲染uni-app框架内置组件 */
46
+ useNative: {
47
+ type: Boolean,
48
+ default: false
49
+ },
50
+ /** 滑块条高度,单位rpx */
51
+ height: {
52
+ type: [String, Number],
53
+ default: 2
54
+ },
55
+ /** 双滑块时值 */
56
+ rangeValue: {
57
+ type: Array as PropType<number[]>,
58
+ default: [0, 0]
59
+ },
60
+ /** 是否区间的模式 */
61
+ isRange: {
62
+ type: Boolean,
63
+ default: false
64
+ },
65
+ /** 给滑块自定义样式,对象形式 */
66
+ blockStyle: {
67
+ type: Object as PropType<CSSProperties>
68
+ },
69
+ /** 定义需要用到的外部样式 */
70
+ customStyle: {
71
+ type: Object as PropType<CSSProperties>
72
+ },
73
+ /** 自定义外部类名 */
74
+ customClass: String
75
+ }
20
76
 
21
- export default defaultProps;
77
+ export default sliderProps
@@ -1,334 +1,267 @@
1
1
  <template>
2
- <view :class="[`hy-steps--${direction}`, 'hy-steps']">
3
- <template v-for="(item, i) in list" :key="i">
4
- <view
5
- ref="hy-steps-item"
6
- :class="[`hy-steps-item--${direction}`, 'hy-steps-item']"
7
- >
8
- <!-- 线条 -->
9
- <view
10
- v-if="i > 0"
11
- :class="[
12
- `hy-steps-item__line--${direction}`,
13
- 'hy-steps-item__line',
14
- statusClass(i, item.error),
15
- ]"
16
- :style="lineStyle(item, i)"
17
- ></view>
18
- <!-- 线条 -->
2
+ <view :class="[`hy-steps--${direction}`, 'hy-steps']">
3
+ <template v-for="(item, i) in list" :key="i">
4
+ <view ref="hy-steps-item" :class="[`hy-steps-item--${direction}`, 'hy-steps-item']">
5
+ <!-- 线条 -->
6
+ <view
7
+ v-if="i > 0"
8
+ :class="[
9
+ `hy-steps-item__line--${direction}`,
10
+ 'hy-steps-item__line',
11
+ statusClass(i, item.error)
12
+ ]"
13
+ :style="lineStyle(item, i)"
14
+ ></view>
15
+ <!-- 线条 -->
19
16
 
20
- <!-- 步骤状态 -->
21
- <view
22
- :class="[
23
- `hy-steps-item__wrapper--${direction}`,
24
- dot ? `hy-steps-item__wrapper--dot` : statusClass(i, item.error),
25
- 'hy-steps-item__wrapper',
26
- ]"
27
- :style="itemStyleInner"
28
- >
29
- <slot
30
- v-if="$slots.icon"
31
- name="icon"
32
- :error="item?.error"
33
- :index="i"
34
- ></slot>
35
- <template v-else>
36
- <view
37
- :class="[
38
- 'hy-steps-item__wrapper--dot__item',
39
- `hy-steps-item__wrapper--dot__${statusClass(i, item.error)}`,
40
- ]"
41
- v-if="dot"
42
- :style="{
43
- backgroundColor: statusColor(i, item?.error),
44
- }"
45
- ></view>
46
- <view
47
- class="hy-steps-item__wrapper__icon"
48
- v-else-if="activeIcon || inactiveIcon"
49
- >
50
- <HyIcon
51
- :name="i <= current ? activeIcon : inactiveIcon"
52
- :size="iconSize"
53
- :color="i <= current ? activeColor : inactiveColor"
54
- ></HyIcon>
55
- </view>
56
- <view
57
- v-else
58
- :style="{
59
- backgroundColor:
60
- statusClass(i, item.error) === 'process'
61
- ? activeColor
62
- : 'transparent',
63
- borderColor: statusColor(i, item?.error),
64
- }"
65
- class="hy-steps-item__wrapper__circle"
66
- >
67
- <text
68
- v-if="
69
- statusClass(i, item.error) === 'process' ||
70
- statusClass(i, item.error) === 'wait'
71
- "
72
- class="hy-steps-item__wrapper__circle__text"
73
- :style="{
74
- color: textColor(i),
75
- }"
76
- >
77
- {{ i + 1 }}
78
- </text>
79
- <HyIcon
80
- v-else
81
- :color="
82
- statusClass(i, item.error) === 'error' ? 'error' : activeColor
83
- "
84
- :size="iconSize"
85
- :name="
86
- statusClass(i, item.error) === 'error'
87
- ? IconConfig.CLOSE
88
- : IconConfig.CHECK_MASK
89
- "
90
- ></HyIcon>
91
- </view>
92
- </template>
93
- </view>
94
- <!-- 步骤状态 -->
17
+ <!-- 步骤状态 -->
18
+ <view
19
+ :class="[
20
+ `hy-steps-item__wrapper--${direction}`,
21
+ dot ? `hy-steps-item__wrapper--dot` : statusClass(i, item.error),
22
+ 'hy-steps-item__wrapper'
23
+ ]"
24
+ :style="itemStyleInner"
25
+ >
26
+ <slot v-if="$slots.icon" name="icon" :error="item?.error" :index="i"></slot>
27
+ <template v-else>
28
+ <view
29
+ :class="[
30
+ 'hy-steps-item__wrapper--dot__item',
31
+ `hy-steps-item__wrapper--dot__${statusClass(i, item.error)}`
32
+ ]"
33
+ v-if="dot"
34
+ :style="{
35
+ backgroundColor: statusColor(i, item?.error)
36
+ }"
37
+ ></view>
38
+ <view
39
+ class="hy-steps-item__wrapper__icon"
40
+ v-else-if="activeIcon || inactiveIcon"
41
+ >
42
+ <hy-icon
43
+ :name="i <= current ? activeIcon : inactiveIcon"
44
+ :size="iconSize"
45
+ :color="i <= current ? activeColor : inactiveColor"
46
+ ></hy-icon>
47
+ </view>
48
+ <view
49
+ v-else
50
+ :style="{
51
+ backgroundColor:
52
+ statusClass(i, item.error) === 'process'
53
+ ? activeColor
54
+ : 'transparent',
55
+ borderColor: statusColor(i, item?.error)
56
+ }"
57
+ class="hy-steps-item__wrapper__circle"
58
+ >
59
+ <text
60
+ v-if="
61
+ statusClass(i, item.error) === 'process' ||
62
+ statusClass(i, item.error) === 'wait'
63
+ "
64
+ class="hy-steps-item__wrapper__circle__text"
65
+ :style="{
66
+ color: textColor(i)
67
+ }"
68
+ >
69
+ {{ i + 1 }}
70
+ </text>
71
+ <hy-icon
72
+ v-else
73
+ :color="
74
+ statusClass(i, item.error) === 'error' ? 'error' : activeColor
75
+ "
76
+ :size="iconSize"
77
+ :name="
78
+ statusClass(i, item.error) === 'error'
79
+ ? IconConfig.CLOSE
80
+ : IconConfig.CHECK_MASK
81
+ "
82
+ ></hy-icon>
83
+ </view>
84
+ </template>
85
+ </view>
86
+ <!-- 步骤状态 -->
95
87
 
96
- <!-- 内容区域 -->
97
- <view
98
- class="hy-steps-item__content"
99
- :class="[`hy-steps-item__content--${direction}`]"
100
- :style="[contentStyle]"
101
- >
102
- <slot
103
- v-if="$slots.content"
104
- name="content"
105
- :record="item"
106
- :index="i"
107
- ></slot>
108
- <template v-else>
109
- <slot
110
- v-if="$slots.title"
111
- name="title"
112
- :title="item.title"
113
- :index="i"
114
- ></slot>
115
- <text v-else :class="titleClass(i, item.error)">
116
- {{ item.title }}
117
- </text>
118
- <slot
119
- v-if="$slots.desc"
120
- name="desc"
121
- :desc="item.desc"
122
- :index="i"
123
- ></slot>
124
- <text v-else :style="{ fontSize: '12px', color: '#999' }">{{
125
- item.desc
126
- }}</text>
127
- </template>
128
- </view>
129
- <!-- 内容区域 -->
130
- </view>
131
- </template>
132
- </view>
88
+ <!-- 内容区域 -->
89
+ <view
90
+ class="hy-steps-item__content"
91
+ :class="[`hy-steps-item__content--${direction}`]"
92
+ :style="[contentStyle]"
93
+ >
94
+ <slot v-if="$slots.content" name="content" :record="item" :index="i"></slot>
95
+ <template v-else>
96
+ <slot
97
+ v-if="$slots.title"
98
+ name="title"
99
+ :title="item.title"
100
+ :index="i"
101
+ ></slot>
102
+ <text v-else :class="titleClass(i, item.error)">
103
+ {{ item.title }}
104
+ </text>
105
+ <slot v-if="$slots.desc" name="desc" :desc="item.desc" :index="i"></slot>
106
+ <text v-else :style="{ fontSize: '12px', color: '#999' }">{{
107
+ item.desc
108
+ }}</text>
109
+ </template>
110
+ </view>
111
+ <!-- 内容区域 -->
112
+ </view>
113
+ </template>
114
+ </view>
133
115
  </template>
134
116
 
135
117
  <script lang="ts">
136
118
  export default {
137
- name: "hy-steps",
138
- options: {
139
- addGlobalClass: true,
140
- virtualHost: true,
141
- styleIsolation: "shared",
142
- },
143
- };
119
+ name: 'hy-steps',
120
+ options: {
121
+ addGlobalClass: true,
122
+ virtualHost: true,
123
+ styleIsolation: 'shared'
124
+ }
125
+ }
144
126
  </script>
145
127
 
146
128
  <script setup lang="ts">
147
- import { computed, ref, onMounted, getCurrentInstance, watch } from "vue";
148
- import type { CSSProperties, PropType } from "vue";
149
- import type { IStepsEmits } from "./typing";
150
- import type { StepListVo } from "./typing";
151
- import { addUnit, getRect, ColorConfig, IconConfig } from "../../libs";
129
+ import { computed, ref, onMounted, getCurrentInstance, watch } from 'vue'
130
+ import type { CSSProperties } from 'vue'
131
+ import type { IStepsEmits } from './typing'
132
+ import type { StepListVo } from './typing'
133
+ import { addUnit, getRect, ColorConfig, IconConfig } from '../../libs'
134
+ import stepsProps from './props'
135
+ // 组件
136
+ import HyIcon from '../hy-icon/hy-icon.vue'
152
137
 
153
138
  /**
154
139
  * 一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。
155
140
  * @displayName hy-steps
156
141
  */
157
- defineOptions({});
158
-
159
- // 组件
160
- import HyIcon from "../hy-icon/hy-icon.vue";
142
+ defineOptions({})
161
143
 
162
- // const props = withDefaults(defineProps<IProps>(), defaultProps)
163
- const props = defineProps({
164
- /** 设置当前处于第几步 */
165
- current: {
166
- type: Number,
167
- default: 0,
168
- },
169
- /** 步骤条的数据集 */
170
- list: {
171
- type: Array as PropType<StepListVo[]>,
172
- default: [],
173
- },
174
- /**
175
- * 方向
176
- * @values row,column
177
- * */
178
- direction: {
179
- type: String,
180
- default: "row",
181
- },
182
- /** 激活状态颜色 */
183
- activeColor: {
184
- type: String,
185
- default: "",
186
- },
187
- /** 未激活状态颜色 */
188
- inactiveColor: {
189
- type: String,
190
- default: "",
191
- },
192
- /** 激活状态的图标 */
193
- activeIcon: String,
194
- /** 未激活状态图标 */
195
- inactiveIcon: String,
196
- /** 是否显示点类型 */
197
- dot: {
198
- type: Boolean,
199
- default: false,
200
- },
201
- /** 图标大小 */
202
- iconSize: {
203
- type: [String, Number],
204
- default: 17,
205
- },
206
- });
207
- const emit = defineEmits<IStepsEmits>();
144
+ const props = defineProps(stepsProps)
145
+ const emit = defineEmits<IStepsEmits>()
208
146
 
209
147
  const size = ref<UniApp.NodeInfo>({
210
- height: 0,
211
- width: 0,
212
- });
213
- const instance = getCurrentInstance();
148
+ height: 0,
149
+ width: 0
150
+ })
151
+ const instance = getCurrentInstance()
214
152
 
215
153
  watch(
216
- () => props.current,
217
- (newVal: number) => {
218
- if (props.list[newVal - 1]?.error) {
219
- const index = props.list.findIndex((item) => item.error);
220
- emit("update:current", index);
221
- emit("change", index);
154
+ () => props.current,
155
+ (newVal: number) => {
156
+ if (props.list[newVal - 1]?.error) {
157
+ const index = props.list.findIndex((item) => item.error)
158
+ emit('update:current', index)
159
+ emit('change', index)
160
+ }
222
161
  }
223
- },
224
- );
162
+ )
225
163
 
226
164
  // 字体标题类名
227
165
  const titleClass = computed(() => {
228
- return (index: number, error: boolean) => {
229
- const classes = ["hy-steps-item__content__title"];
230
- if (props.current === index) {
231
- classes.push("hy-steps-item__content__title--active");
166
+ return (index: number, error: boolean) => {
167
+ const classes = ['hy-steps-item__content__title']
168
+ if (props.current === index) {
169
+ classes.push('hy-steps-item__content__title--active')
232
170
 
233
- if (error) {
234
- classes.push("hy-steps-item__content__title--error");
235
- }
236
- }
171
+ if (error) {
172
+ classes.push('hy-steps-item__content__title--error')
173
+ }
174
+ }
237
175
 
238
- return classes;
239
- };
240
- });
176
+ return classes
177
+ }
178
+ })
241
179
  // 字体颜色
242
180
  const textColor = computed(() => {
243
- return (index: number) =>
244
- index === props.current ? "#ffffff" : props.inactiveColor;
245
- });
181
+ return (index: number) => (index === props.current ? '#ffffff' : props.inactiveColor)
182
+ })
246
183
 
247
184
  /**
248
185
  * @description 线条样式
249
186
  * */
250
187
  const lineStyle = computed(() => {
251
- return (temp: StepListVo, index: number): CSSProperties => {
252
- const style: CSSProperties = {};
253
- if (props.direction === "row") {
254
- style.width = addUnit(size.value.width! - 25);
255
- style.left = addUnit(-size.value.width! / 2 + 12);
256
- } else {
257
- style.height = addUnit(size.value.height! - 30);
258
- style.top = addUnit(25);
188
+ return (temp: StepListVo, index: number): CSSProperties => {
189
+ const style: CSSProperties = {}
190
+ if (props.direction === 'row') {
191
+ style.width = addUnit(size.value.width! - 25)
192
+ style.left = addUnit(-size.value.width! / 2 + 12)
193
+ } else {
194
+ style.height = addUnit(size.value.height! - 30)
195
+ style.top = addUnit(25)
196
+ }
197
+ style.backgroundColor = temp.error ? '' : index < props.current ? '' : props.inactiveColor
198
+ return style
259
199
  }
260
- style.backgroundColor = temp.error
261
- ? ""
262
- : index < props.current
263
- ? ""
264
- : props.inactiveColor;
265
- return style;
266
- };
267
- });
200
+ })
268
201
 
269
202
  const itemStyleInner = computed(() => {
270
- return {};
271
- });
203
+ return {}
204
+ })
272
205
  /**
273
206
  * @description 状态类名
274
207
  * */
275
208
  const statusClass = computed(() => {
276
- return (index: number, error: boolean = false) => {
277
- if (props.current == index) {
278
- return error ? "error" : "process";
279
- } else if (props.current > index) {
280
- return "finish";
281
- } else {
282
- return "wait";
209
+ return (index: number, error: boolean = false) => {
210
+ if (props.current == index) {
211
+ return error ? 'error' : 'process'
212
+ } else if (props.current > index) {
213
+ return 'finish'
214
+ } else {
215
+ return 'wait'
216
+ }
283
217
  }
284
- };
285
- });
218
+ })
286
219
  const statusColor = computed(() => {
287
- return (index: number, error?: boolean) => {
288
- let colorTmp: string | number;
289
- switch (statusClass.value(index, error)) {
290
- case "finish":
291
- colorTmp = props.activeColor;
292
- break;
293
- case "error":
294
- colorTmp = ColorConfig.error;
295
- break;
296
- case "process":
297
- colorTmp = props.dot ? props.current : "transparent";
298
- break;
299
- default:
300
- colorTmp = props.inactiveColor;
301
- break;
220
+ return (index: number, error?: boolean) => {
221
+ let colorTmp: string | number
222
+ switch (statusClass.value(index, error)) {
223
+ case 'finish':
224
+ colorTmp = props.activeColor
225
+ break
226
+ case 'error':
227
+ colorTmp = ColorConfig.error
228
+ break
229
+ case 'process':
230
+ colorTmp = props.dot ? props.current : 'transparent'
231
+ break
232
+ default:
233
+ colorTmp = props.inactiveColor
234
+ break
235
+ }
236
+ return colorTmp
302
237
  }
303
- return colorTmp;
304
- };
305
- });
238
+ })
306
239
 
307
240
  const contentStyle = computed<CSSProperties>(() => {
308
- const style: CSSProperties = {};
309
- if (props.direction === "column") {
310
- style.marginLeft = props.dot ? "2px" : "6px";
311
- style.marginTop = props.dot ? "0px" : "6px";
312
- } else {
313
- style.marginTop = props.dot ? "2px" : "6px";
314
- style.marginLeft = props.dot ? "2px" : "6px";
315
- }
241
+ const style: CSSProperties = {}
242
+ if (props.direction === 'column') {
243
+ style.marginLeft = props.dot ? '2px' : '6px'
244
+ style.marginTop = props.dot ? '0px' : '6px'
245
+ } else {
246
+ style.marginTop = props.dot ? '2px' : '6px'
247
+ style.marginLeft = props.dot ? '2px' : '6px'
248
+ }
316
249
 
317
- return style;
318
- });
250
+ return style
251
+ })
319
252
 
320
253
  onMounted(() => {
321
- getStepsItemRect();
322
- });
254
+ getStepsItemRect()
255
+ })
323
256
 
324
257
  // 获取组件的尺寸,用于设置横线的位置
325
258
  const getStepsItemRect = () => {
326
- getRect(".hy-steps-item", false, instance).then((rect) => {
327
- size.value = rect as UniApp.NodeInfo;
328
- });
329
- };
259
+ getRect('.hy-steps-item', false, instance).then((rect) => {
260
+ size.value = rect as UniApp.NodeInfo
261
+ })
262
+ }
330
263
  </script>
331
264
 
332
265
  <style lang="scss" scoped>
333
- @import "./index.scss";
266
+ @import './index.scss';
334
267
  </style>