hy-app 0.2.13 → 0.2.15

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 (223) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +81 -13
  2. package/components/hy-action-sheet/typing.d.ts +1 -3
  3. package/components/hy-address-picker/hy-address-picker.vue +109 -8
  4. package/components/hy-address-picker/index.scss +2 -2
  5. package/components/hy-address-picker/typing.d.ts +39 -30
  6. package/components/hy-avatar/hy-avatar.vue +78 -4
  7. package/components/hy-avatar/typing.d.ts +21 -16
  8. package/components/hy-back-top/hy-back-top.vue +86 -28
  9. package/components/hy-back-top/typing.d.ts +17 -12
  10. package/components/hy-badge/hy-badge.vue +114 -43
  11. package/components/hy-badge/typing.d.ts +20 -15
  12. package/components/hy-button/HyButton.docgen.js +6 -0
  13. package/components/hy-button/hy-button.vue +70 -77
  14. package/components/hy-button/props.ts +40 -41
  15. package/components/hy-calendar/hy-calendar.vue +290 -143
  16. package/components/hy-calendar/typing.d.ts +38 -31
  17. package/components/hy-card/hy-card.vue +139 -36
  18. package/components/hy-card/typing.d.ts +39 -28
  19. package/components/hy-cell/hy-cell.vue +131 -67
  20. package/components/hy-cell/typing.d.ts +6 -1
  21. package/components/hy-check-button/hy-check-button.vue +101 -32
  22. package/components/hy-check-button/typing.d.ts +26 -19
  23. package/components/hy-checkbox/hy-checkbox.vue +167 -78
  24. package/components/hy-checkbox/typing.d.ts +26 -19
  25. package/components/hy-code-input/hy-code-input.vue +101 -5
  26. package/components/hy-code-input/typing.d.ts +9 -0
  27. package/components/hy-config-provider/hy-config-provider.vue +44 -24
  28. package/components/hy-config-provider/typing.d.ts +0 -4
  29. package/components/hy-count-down/hy-count-down.vue +99 -62
  30. package/components/hy-count-down/typing.d.ts +18 -5
  31. package/components/hy-count-to/hy-count-to.vue +165 -113
  32. package/components/hy-count-to/typing.d.ts +15 -11
  33. package/components/hy-datetime-picker/hy-datetime-picker.vue +338 -232
  34. package/components/hy-datetime-picker/typing.d.ts +49 -39
  35. package/components/hy-divider/hy-divider.vue +128 -64
  36. package/components/hy-divider/typing.d.ts +16 -16
  37. package/components/hy-dropdown/hy-dropdown.vue +57 -19
  38. package/components/hy-dropdown/typing.d.ts +14 -14
  39. package/components/hy-dropdown-item/hy-dropdown-item.vue +34 -5
  40. package/components/hy-dropdown-item/typing.d.ts +13 -6
  41. package/components/hy-empty/hy-empty.vue +64 -6
  42. package/components/hy-empty/typing.d.ts +5 -0
  43. package/components/hy-float-button/hy-float-button.vue +117 -5
  44. package/components/hy-float-button/typing.d.ts +7 -0
  45. package/components/hy-folding-panel/hy-folding-panel.vue +87 -25
  46. package/components/hy-folding-panel/typing.d.ts +24 -15
  47. package/components/hy-grid/hy-grid.vue +95 -35
  48. package/components/hy-grid/typing.d.ts +24 -19
  49. package/components/hy-icon/hy-icon.vue +84 -6
  50. package/components/hy-icon/typing.d.ts +5 -0
  51. package/components/hy-image/hy-image.vue +105 -6
  52. package/components/hy-image/typing.d.ts +9 -0
  53. package/components/hy-input/hy-input.vue +277 -130
  54. package/components/hy-input/props.ts +13 -14
  55. package/components/hy-input/typing.d.ts +59 -38
  56. package/components/hy-line/hy-line.vue +65 -25
  57. package/components/hy-line-progress/hy-line-progress.vue +68 -35
  58. package/components/hy-list/hy-list.vue +127 -61
  59. package/components/hy-list/typing.d.ts +19 -12
  60. package/components/hy-loading/hy-loading.vue +79 -25
  61. package/components/hy-menu/hy-menu.vue +69 -45
  62. package/components/hy-menu/typing.d.ts +22 -15
  63. package/components/hy-modal/hy-modal.vue +91 -4
  64. package/components/hy-modal/typing.d.ts +11 -0
  65. package/components/hy-navbar/hy-navbar.vue +105 -25
  66. package/components/hy-navbar/typing.d.ts +25 -20
  67. package/components/hy-notice-bar/hy-notice-bar.vue +97 -19
  68. package/components/hy-notice-bar/typing.d.ts +22 -17
  69. package/components/hy-notify/hy-notify.vue +106 -54
  70. package/components/hy-number-step/hy-number-step.vue +211 -120
  71. package/components/hy-number-step/typing.d.ts +45 -28
  72. package/components/hy-overlay/hy-overlay.vue +60 -16
  73. package/components/hy-overlay/typing.d.ts +11 -6
  74. package/components/hy-pagination/hy-pagination.vue +94 -37
  75. package/components/hy-pagination/typing.d.ts +20 -11
  76. package/components/hy-picker/hy-picker.vue +225 -160
  77. package/components/hy-picker/typing.d.ts +51 -28
  78. package/components/hy-popover/hy-popover.vue +55 -7
  79. package/components/hy-popover/typing.d.ts +21 -1
  80. package/components/hy-popup/hy-popup.vue +164 -99
  81. package/components/hy-popup/typing.d.ts +11 -0
  82. package/components/hy-price/hy-price.vue +77 -30
  83. package/components/hy-price/typing.d.ts +10 -10
  84. package/components/hy-qrcode/hy-qrcode.vue +75 -5
  85. package/components/hy-qrcode/typing.d.ts +25 -16
  86. package/components/hy-radio/hy-radio.vue +169 -88
  87. package/components/hy-radio/typing.d.ts +29 -22
  88. package/components/hy-rate/hy-rate.vue +155 -104
  89. package/components/hy-rate/typing.d.ts +23 -16
  90. package/components/hy-read-more/hy-read-more.vue +83 -56
  91. package/components/hy-read-more/typing.d.ts +18 -11
  92. package/components/hy-scroll-list/hy-scroll-list.vue +69 -58
  93. package/components/hy-scroll-list/typing.d.ts +14 -7
  94. package/components/hy-search/hy-search.vue +168 -62
  95. package/components/hy-search/typing.d.ts +47 -26
  96. package/components/hy-signature/hy-signature.vue +354 -272
  97. package/components/hy-signature/typing.d.ts +65 -52
  98. package/components/hy-slider/hy-slider.vue +208 -160
  99. package/components/hy-slider/typing.d.ts +28 -17
  100. package/components/hy-steps/hy-steps.vue +125 -99
  101. package/components/hy-steps/typing.d.ts +21 -14
  102. package/components/hy-submit-bar/hy-submit-bar.vue +129 -48
  103. package/components/hy-submit-bar/typing.d.ts +30 -23
  104. package/components/hy-subsection/hy-subsection.vue +139 -96
  105. package/components/hy-subsection/typing.d.ts +23 -16
  106. package/components/hy-swipe-action/hy-swipe-action.vue +161 -135
  107. package/components/hy-swipe-action/typing.d.ts +26 -17
  108. package/components/hy-swiper/hy-swiper.vue +178 -73
  109. package/components/hy-swiper/typing.d.ts +37 -28
  110. package/components/hy-switch/hy-switch.vue +107 -60
  111. package/components/hy-switch/typing.d.ts +25 -18
  112. package/components/hy-tabs/hy-tabs.vue +170 -160
  113. package/components/hy-tabs/typing.d.ts +36 -22
  114. package/components/hy-tag/hy-tag.vue +133 -58
  115. package/components/hy-tag/typing.d.ts +26 -18
  116. package/components/hy-text/hy-text.vue +106 -6
  117. package/components/hy-text/typing.d.ts +31 -26
  118. package/components/hy-textarea/hy-textarea.vue +183 -89
  119. package/components/hy-textarea/typing.d.ts +41 -24
  120. package/components/hy-tooltip/hy-tooltip.vue +145 -101
  121. package/components/hy-tooltip/typing.d.ts +18 -13
  122. package/components/hy-transition/hy-transition.vue +48 -13
  123. package/components/hy-transition/typing.d.ts +17 -0
  124. package/components/hy-upload/hy-upload.vue +113 -148
  125. package/components/hy-upload/typing.d.ts +71 -71
  126. package/components/hy-warn/hy-warn.vue +79 -36
  127. package/components/hy-warn/typing.d.ts +18 -11
  128. package/components/hy-waterfall/hy-waterfall.vue +90 -77
  129. package/components/hy-watermark/hy-watermark.vue +82 -5
  130. package/components/hy-watermark/typing.d.ts +20 -20
  131. package/global.d.ts +39 -59
  132. package/package.json +5 -13
  133. package/utils/inspect.ts +3 -1
  134. package/web-types.json +1 -1
  135. package/component-helper.ts +0 -177
  136. package/components.json +0 -3287
  137. package/dist/attributes.json +0 -1
  138. package/dist/docs/components/hy-action-sheet/hy-action-sheet.md +0 -41
  139. package/dist/docs/components/hy-address-picker/hy-address-picker.md +0 -25
  140. package/dist/docs/components/hy-avatar/hy-avatar.md +0 -19
  141. package/dist/docs/components/hy-back-top/hy-back-top.md +0 -19
  142. package/dist/docs/components/hy-badge/hy-badge.md +0 -13
  143. package/dist/docs/components/hy-button/hy-button.md +0 -61
  144. package/dist/docs/components/hy-calendar/header.md +0 -17
  145. package/dist/docs/components/hy-calendar/hy-calendar.md +0 -27
  146. package/dist/docs/components/hy-calendar/month.md +0 -38
  147. package/dist/docs/components/hy-card/hy-card.md +0 -24
  148. package/dist/docs/components/hy-cell/hy-cell.md +0 -26
  149. package/dist/docs/components/hy-check-button/hy-check-button.md +0 -14
  150. package/dist/docs/components/hy-checkbox/hy-checkbox.md +0 -21
  151. package/dist/docs/components/hy-code-input/hy-code-input.md +0 -15
  152. package/dist/docs/components/hy-config-provider/hy-config-provider.md +0 -13
  153. package/dist/docs/components/hy-count-down/hy-count-down.md +0 -34
  154. package/dist/docs/components/hy-count-to/hy-count-to.md +0 -31
  155. package/dist/docs/components/hy-datetime-picker/hy-datetime-picker.md +0 -25
  156. package/dist/docs/components/hy-divider/hy-divider.md +0 -13
  157. package/dist/docs/components/hy-dropdown/hy-dropdown.md +0 -13
  158. package/dist/docs/components/hy-dropdown-item/hy-dropdown-item.md +0 -20
  159. package/dist/docs/components/hy-empty/hy-empty.md +0 -20
  160. package/dist/docs/components/hy-float-button/hy-float-button.md +0 -20
  161. package/dist/docs/components/hy-folding-panel/hy-folding-panel.md +0 -24
  162. package/dist/docs/components/hy-form/hy-form.md +0 -29
  163. package/dist/docs/components/hy-grid/hy-grid.md +0 -19
  164. package/dist/docs/components/hy-icon/hy-icon.md +0 -13
  165. package/dist/docs/components/hy-image/hy-image.md +0 -22
  166. package/dist/docs/components/hy-input/hy-input.md +0 -29
  167. package/dist/docs/components/hy-line/hy-line.md +0 -7
  168. package/dist/docs/components/hy-line-progress/hy-line-progress.md +0 -13
  169. package/dist/docs/components/hy-list/hy-list.md +0 -25
  170. package/dist/docs/components/hy-loading/hy-loading.md +0 -14
  171. package/dist/docs/components/hy-login/ThePhoneLogin.md +0 -20
  172. package/dist/docs/components/hy-login/TheUserLogin.md +0 -44
  173. package/dist/docs/components/hy-login/hy-login.md +0 -14
  174. package/dist/docs/components/hy-menu/hy-menu.md +0 -21
  175. package/dist/docs/components/hy-modal/hy-modal.md +0 -23
  176. package/dist/docs/components/hy-navbar/hy-navbar.md +0 -22
  177. package/dist/docs/components/hy-notice-bar/hy-column-notice.md +0 -20
  178. package/dist/docs/components/hy-notice-bar/hy-notice-bar.md +0 -14
  179. package/dist/docs/components/hy-notice-bar/hy-row-notice.md +0 -20
  180. package/dist/docs/components/hy-notify/hy-notify.md +0 -23
  181. package/dist/docs/components/hy-number-step/hy-number-step.md +0 -27
  182. package/dist/docs/components/hy-overlay/hy-overlay.md +0 -19
  183. package/dist/docs/components/hy-pagination/hy-pagination.md +0 -14
  184. package/dist/docs/components/hy-parse/hy-parse.md +0 -46
  185. package/dist/docs/components/hy-parse/node/node.md +0 -7
  186. package/dist/docs/components/hy-picker/hy-picker.md +0 -32
  187. package/dist/docs/components/hy-popover/hy-popover.md +0 -34
  188. package/dist/docs/components/hy-popup/hy-popup.md +0 -22
  189. package/dist/docs/components/hy-price/hy-price.md +0 -13
  190. package/dist/docs/components/hy-qrcode/hy-qrcode.md +0 -15
  191. package/dist/docs/components/hy-radio/hy-radio.md +0 -21
  192. package/dist/docs/components/hy-rate/hy-rate.md +0 -14
  193. package/dist/docs/components/hy-read-more/hy-read-more.md +0 -21
  194. package/dist/docs/components/hy-scroll-list/hy-scroll-list.md +0 -21
  195. package/dist/docs/components/hy-search/hy-search.md +0 -27
  196. package/dist/docs/components/hy-signature/hy-signature.md +0 -45
  197. package/dist/docs/components/hy-slider/hy-slider.md +0 -24
  198. package/dist/docs/components/hy-status-bar/hy-status-bar.md +0 -13
  199. package/dist/docs/components/hy-steps/hy-steps.md +0 -23
  200. package/dist/docs/components/hy-submit-bar/hy-submit-bar.md +0 -21
  201. package/dist/docs/components/hy-subsection/hy-subsection.md +0 -14
  202. package/dist/docs/components/hy-swipe-action/hy-swipe-action.md +0 -29
  203. package/dist/docs/components/hy-swiper/hy-swiper-indicator.md +0 -23
  204. package/dist/docs/components/hy-swiper/hy-swiper.md +0 -22
  205. package/dist/docs/components/hy-switch/hy-switch.md +0 -20
  206. package/dist/docs/components/hy-tabBar/hy-tabBar.md +0 -13
  207. package/dist/docs/components/hy-tabs/hy-tabs.md +0 -27
  208. package/dist/docs/components/hy-tag/hy-tag.md +0 -21
  209. package/dist/docs/components/hy-text/hy-text.md +0 -13
  210. package/dist/docs/components/hy-textarea/hy-textarea.md +0 -19
  211. package/dist/docs/components/hy-toast/hy-toast.md +0 -17
  212. package/dist/docs/components/hy-tooltip/hy-tooltip.md +0 -13
  213. package/dist/docs/components/hy-transition/hy-transition.md +0 -25
  214. package/dist/docs/components/hy-upload/hy-upload.md +0 -25
  215. package/dist/docs/components/hy-warn/hy-warn.md +0 -14
  216. package/dist/docs/components/hy-waterfall/hy-waterfall.md +0 -30
  217. package/dist/docs/components/hy-watermark/hy-watermark.md +0 -7
  218. package/dist/docs/components/message/TheMessage.md +0 -17
  219. package/dist/docs/components/yk-dialog/yk-dialog.md +0 -7
  220. package/dist/tags.json +0 -1
  221. package/dist/web-types.json +0 -1
  222. package/docgen.config.js +0 -14
  223. package/web-types.config.js +0 -7
@@ -1,149 +1,170 @@
1
- import type { CSSProperties } from "vue";
2
- import type HyIconProps from "../hy-icon/typing";
1
+ import type { CSSProperties } from 'vue'
2
+ import type HyIconProps from '../hy-icon/typing'
3
3
 
4
4
  export default interface HyInputProps {
5
5
  /**
6
6
  * @description 输入的值
7
7
  * */
8
- modelValue: string | number;
8
+ modelValue: string | number
9
9
  /**
10
10
  * @description 输入框类型,见上方说明 ( 默认 'text' )
11
11
  * */
12
- type?: HyApp.InputType;
12
+ type?: HyApp.InputType
13
13
  /**
14
14
  * @description 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true,兼容性:微信小程序、百度小程序、字节跳动小程序、QQ小程序 ( 默认 false )
15
15
  * */
16
- fixed?: boolean;
16
+ fixed?: boolean
17
17
  /**
18
18
  * @description 是否禁用输入框 ( 默认 false )
19
19
  * */
20
- disabled?: boolean;
20
+ disabled?: boolean
21
21
  /**
22
22
  * @description 禁用状态时的背景色( 默认 '#f5f7fa' )
23
23
  * */
24
- disabledColor?: string;
24
+ disabledColor?: string
25
25
  /**
26
26
  * @description 是否显示清除控件 ( 默认 false )
27
27
  * */
28
- clearable?: boolean;
28
+ clearable?: boolean
29
29
  /**
30
30
  * @description 是否密码类型 ( 默认 false )
31
31
  * */
32
- password?: boolean;
32
+ password?: boolean
33
33
  /**
34
34
  * @description 最大输入长度,设置为 -1 的时候不限制最大长度 ( 默认 -1 )
35
35
  * */
36
- maxlength?: number;
36
+ maxlength?: number
37
37
  /**
38
38
  * @description 输入框为空时的占位符
39
39
  * */
40
- placeholder?: string | null;
40
+ placeholder?: string | null
41
41
  /**
42
42
  * @description 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ ( 默认 'input-placeholder' )
43
43
  * */
44
- placeholderClass?: string;
44
+ placeholderClass?: string
45
45
  /**
46
46
  * @description 指定placeholder的样式,字符串/对象形式,如"color: red;"
47
47
  * */
48
- placeholderStyle?: CSSProperties;
48
+ placeholderStyle?: CSSProperties
49
49
  /**
50
50
  * @description 是否显示输入字数统计,只在 type ="text"或type ="textarea"时有效 ( 默认 false )
51
51
  * */
52
- showWordLimit?: boolean;
52
+ showWordLimit?: boolean
53
53
  /**
54
54
  * @description 设置右下角按钮的文字,兼容性详见uni-app文档 ( 默认 'done' )
55
55
  * */
56
- confirmType?: string;
56
+ confirmType?: string
57
57
  /**
58
58
  * @description 点击键盘右下角按钮时是否保持键盘不收起,H5无效 ( 默认 false )
59
59
  * */
60
- confirmHold?: boolean;
60
+ confirmHold?: boolean
61
61
  /**
62
62
  * @description focus时,点击页面的时候不收起键盘,微信小程序有效 ( 默认 false )
63
63
  * */
64
- holdKeyboard?: boolean;
64
+ holdKeyboard?: boolean
65
65
  /**
66
66
  * @description 自动获取焦点,在 H5 平台能否聚焦以及软键盘是否跟随弹出,取决于当前浏览器本身的实现。nvue 页面不支持,需使用组件的 focus()、blur() 方法控制焦点 ( 默认 false )
67
67
  * */
68
- focus?: boolean;
68
+ focus?: boolean
69
69
  /**
70
70
  * @description 键盘收起时,是否自动失去焦点,目前仅App3.0.0+有效 ( 默认 false )
71
71
  * */
72
- autoBlur?: boolean;
72
+ autoBlur?: boolean
73
73
  /**
74
74
  * @description 是否去掉 iOS 下的默认内边距,仅微信小程序,且type=textarea时有效 ( 默认 false )
75
75
  * */
76
- disableDefaultPadding?: boolean;
76
+ disableDefaultPadding?: boolean
77
77
  /**
78
78
  * @description 指定focus时光标的位置( 默认 140 )
79
79
  * */
80
- cursor?: number;
80
+ cursor?: number
81
81
  /**
82
82
  * @description 输入框聚焦时底部与键盘的距离 ( 默认 30 )
83
83
  * */
84
- cursorSpacing?: number;
84
+ cursorSpacing?: number
85
85
  /**
86
86
  * @description 光标起始位置,自动聚集时有效,需与selection-end搭配使用 ( 默认 -1 )
87
87
  * */
88
- selectionStart?: number;
88
+ selectionStart?: number
89
89
  /**
90
90
  * @description 光标结束位置,自动聚集时有效,需与selection-start搭配使用 ( 默认 -1 )
91
91
  * */
92
- selectionEnd?: number;
92
+ selectionEnd?: number
93
93
  /**
94
94
  * @description 键盘弹起时,是否自动上推页面 ( 默认 true )
95
95
  * */
96
- adjustPosition?: boolean;
96
+ adjustPosition?: boolean
97
97
  /**
98
98
  * @description 输入框内容对齐方式( 默认 'left' )
99
99
  * */
100
- inputAlign?: HyApp.RowCenterType;
100
+ inputAlign?: HyApp.RowCenterType
101
101
  /**
102
102
  * @description 输入框字体的大小 ( 默认 '15px' )
103
103
  * */
104
- fontSize?: string | number;
104
+ fontSize?: string | number
105
105
  /**
106
106
  * @description 输入框字体颜色 ( 默认 '#303133' )
107
107
  * */
108
- color?: string;
108
+ color?: string
109
109
  /**
110
110
  * @description 输入框前置图标
111
111
  * */
112
- prefixIcon?: Partial<HyIconProps>;
112
+ prefixIcon?: Partial<HyIconProps>
113
113
  /**
114
114
  * @description 输入框后置图标
115
115
  * */
116
- suffixIcon?: Partial<HyIconProps>;
116
+ suffixIcon?: Partial<HyIconProps>
117
117
  /**
118
118
  * @description 边框类型,surround-四周边框,bottom-底部边框,none-无边框 ( 默认 'surround' )
119
119
  * */
120
- border?: HyApp.BorderType;
120
+ border?: HyApp.BorderType
121
121
  /**
122
122
  * @description 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会 ( 默认 false )
123
123
  * */
124
- readonly?: boolean;
124
+ readonly?: boolean
125
125
  /**
126
126
  * @description 输入框形状,circle-圆形,square-方形 ( 默认 'square' )
127
127
  * */
128
- shape?: HyApp.ShapeType;
128
+ shape?: HyApp.ShapeType
129
129
  /**
130
130
  * @description 内容式化函数
131
131
  * */
132
- formatter?: Function | null;
132
+ formatter?: Function | null
133
133
  /**
134
134
  * @description 定义需要用到的外部样式
135
135
  * */
136
- customStyle?: CSSProperties;
136
+ customStyle?: CSSProperties
137
137
  /**
138
138
  * @description 值变化事件
139
139
  * */
140
- onChange?: Function;
140
+ onChange?: Function
141
141
  /**
142
142
  * @description 失去焦点事件
143
143
  * */
144
- onBlur?: Function;
144
+ onBlur?: Function
145
145
  /**
146
146
  * @description 是否忽略组件内对文本合成系统事件的处理。
147
147
  * */
148
- ignoreCompositionEvent?: boolean;
148
+ ignoreCompositionEvent?: boolean
149
+ }
150
+
151
+ export interface IInputEmits {
152
+ /** 输入框失去焦点时触发 */
153
+ (e: 'blur', value: string | number): void
154
+ /** 输入框聚焦时触发 */
155
+ (e: 'focus'): void
156
+ /** 点击完成按钮时触发 */
157
+ (e: 'confirm', value: string | number): void
158
+ /** 键盘高度发生变化的时候触发此事件 */
159
+ (e: 'keyboardheightchange', event: Event): void
160
+ /** 内容发生变化触发此事件 */
161
+ (e: 'change', value: string | number): void
162
+ /** 内容发生变化触发此事件 */
163
+ (e: 'update:modelValue', value: string | number): void
164
+ /** 点击清空内容 */
165
+ (e: 'clear'): void
166
+ /** 点击前缀触发 */
167
+ (e: 'onPrefix'): void
168
+ /** 点击后缀触发 */
169
+ (e: 'onSuffix'): void
149
170
  }
@@ -1,51 +1,91 @@
1
1
  <template>
2
- <view class="hy-line" :style="lineStyle"> </view>
2
+ <view :class="['hy-line', customClass]" :style="lineStyle"></view>
3
3
  </template>
4
4
 
5
5
  <script lang="ts">
6
+ /**
7
+ * 一般用于显示一根线条,用于分隔内容块,有横向和竖向两种模式,且能设置0.5px线条,使用也很简单。
8
+ * @displayName hy-line
9
+ */
10
+ defineOptions({})
6
11
  export default {
7
12
  name: 'hy-line',
8
13
  options: {
9
14
  addGlobalClass: true,
10
15
  virtualHost: true,
11
- styleIsolation: 'shared'
12
- }
16
+ styleIsolation: 'shared',
17
+ },
13
18
  }
14
19
  </script>
15
20
 
16
21
  <script setup lang="ts">
17
- import { computed, type CSSProperties, toRefs } from "vue";
18
- import defaultProps from "./props";
19
- import type IProps from "./typing";
20
- import { addUnit } from "../../utils";
22
+ import { computed, type CSSProperties, type PropType, toRefs } from 'vue'
23
+ import { addUnit } from '../../utils'
21
24
 
22
- const props = withDefaults(defineProps<IProps>(), defaultProps);
23
- const { margin, length, dashed, direction, hairline, color, customStyle } =
24
- toRefs(props);
25
+ // const props = withDefaults(defineProps<IProps>(), defaultProps);
26
+ const props = defineProps({
27
+ /** 线条的颜色 */
28
+ color: String,
29
+ /** 长度,竖向时表现为高度,横向时表现为长度,可以为百分比,带px单位的值等 */
30
+ length: {
31
+ type: String,
32
+ default: '100%',
33
+ },
34
+ /**
35
+ * 线条的方向
36
+ * @values row,column
37
+ * */
38
+ direction: {
39
+ type: String,
40
+ default: 'row',
41
+ },
42
+ /** 是否显示细线条 */
43
+ hairline: {
44
+ type: Boolean,
45
+ default: true,
46
+ },
47
+ /** 线条与上下左右 元素的间距,字符串形式,如"30px" */
48
+ margin: {
49
+ type: [String, Number],
50
+ default: 0,
51
+ },
52
+ /** 是否虚线 */
53
+ dashed: {
54
+ type: Boolean,
55
+ default: false,
56
+ },
57
+ /** 定义需要用到的外部样式 */
58
+ customStyle: {
59
+ type: Object as PropType<CSSProperties>,
60
+ },
61
+ /** 自定义外部类名 */
62
+ customClass: String,
63
+ })
64
+ const { margin, length, dashed, direction, hairline, color, customStyle } = toRefs(props)
25
65
 
26
66
  const lineStyle = computed<CSSProperties>(() => {
27
- const style: CSSProperties = {};
28
- style.margin = margin.value;
67
+ const style: CSSProperties = {}
68
+ style.margin = margin.value
29
69
  // 如果是水平线条,边框高度为1px,再通过transform缩小一半,就是0.5px了
30
- if (direction.value === "row") {
70
+ if (direction.value === 'row') {
31
71
  // 此处采用兼容分开写,兼容nvue的写法
32
- style.borderBottomWidth = "1px";
33
- style.borderBottomStyle = dashed.value ? "dashed" : "solid";
34
- style.width = addUnit(length.value);
35
- if (!hairline.value) style.borderBottomWidth = "1.5px";
72
+ style.borderBottomWidth = '1px'
73
+ style.borderBottomStyle = dashed.value ? 'dashed' : 'solid'
74
+ style.width = addUnit(length.value)
75
+ if (!hairline.value) style.borderBottomWidth = '1.5px'
36
76
  } else {
37
77
  // 如果是竖向线条,边框宽度为1px,再通过transform缩小一半,就是0.5px了
38
- style.borderLeftWidth = "1px";
39
- style.borderLeftStyle = dashed.value ? "dashed" : "solid";
40
- style.height = addUnit(length.value);
41
- if (hairline.value) style.transform = "scaleX(0.5)";
78
+ style.borderLeftWidth = '1px'
79
+ style.borderLeftStyle = dashed.value ? 'dashed' : 'solid'
80
+ style.height = addUnit(length.value)
81
+ if (hairline.value) style.transform = 'scaleX(0.5)'
42
82
  }
43
83
 
44
- style.borderColor = color.value;
45
- return Object.assign(style, customStyle.value);
46
- });
84
+ style.borderColor = color.value
85
+ return Object.assign(style, customStyle.value)
86
+ })
47
87
  </script>
48
88
 
49
89
  <style lang="scss" scoped>
50
- @import "./index.scss";
90
+ @import './index.scss';
51
91
  </style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="hy-line-progress" :style="customStyle">
2
+ <view :class="['hy-line-progress', customClass]" :style="customStyle">
3
3
  <view
4
4
  class="hy-line-progress__background"
5
5
  ref="hy-line-progress__background"
@@ -7,8 +7,7 @@
7
7
  backgroundColor: inactiveColor,
8
8
  height: addUnit(height),
9
9
  }"
10
- >
11
- </view>
10
+ ></view>
12
11
  <view class="hy-line-progress__line" :style="[progressStyle]">
13
12
  <slot>
14
13
  <text
@@ -17,21 +16,27 @@
17
16
  :style="{
18
17
  fontSize: fontSize ? addUnit(fontSize) : addUnit(getPx(height)),
19
18
  }"
20
- >{{ innserPercentage + "%" }}</text
21
19
  >
20
+ {{ innserPercentage + '%' }}
21
+ </text>
22
22
  </slot>
23
23
  </view>
24
24
  </view>
25
25
  </template>
26
26
 
27
27
  <script lang="ts">
28
+ /**
29
+ * 展示操作或任务的当前进度,比如上传文件,是一个线形的进度条。
30
+ * @displayName hy-line-progress
31
+ */
32
+ defineOptions({})
28
33
  export default {
29
34
  name: 'hy-line-progress',
30
35
  options: {
31
36
  addGlobalClass: true,
32
37
  virtualHost: true,
33
- styleIsolation: 'shared'
34
- }
38
+ styleIsolation: 'shared',
39
+ },
35
40
  }
36
41
  </script>
37
42
 
@@ -41,64 +46,92 @@ import {
41
46
  type CSSProperties,
42
47
  getCurrentInstance,
43
48
  onMounted,
49
+ type PropType,
44
50
  ref,
45
51
  toRefs,
46
52
  watch,
47
- } from "vue";
48
- import defaultProps from "./props";
49
- import type IProps from "./typing";
50
- import { addUnit, getPx, getRect, range, sleep } from "../../utils";
53
+ } from 'vue'
54
+ import { addUnit, getPx, getRect, range, sleep } from '../../utils'
51
55
 
52
- const props = withDefaults(defineProps<IProps>(), defaultProps);
53
- const { percentage, activeColor, height } = toRefs(props);
56
+ // const props = withDefaults(defineProps<IProps>(), defaultProps);
57
+ const props = defineProps({
58
+ /** 激活部分的颜色 */
59
+ activeColor: String,
60
+ /** 背景色 */
61
+ inactiveColor: String,
62
+ /** 进度百分比,数值 */
63
+ percentage: {
64
+ type: Number,
65
+ default: 0,
66
+ },
67
+ /** 是否在进度条内部显示百分比的值 */
68
+ showText: {
69
+ type: Boolean,
70
+ default: false,
71
+ },
72
+ /** 进度条的高度,单位px */
73
+ height: {
74
+ type: [String, Number],
75
+ default: 8,
76
+ },
77
+ /** 字体大小,单位px */
78
+ fontSize: [String, Number],
79
+ /** 定义需要用到的外部样式 */
80
+ customStyle: {
81
+ type: Object as PropType<CSSProperties>,
82
+ },
83
+ /** 自定义外部类名 */
84
+ customClass: String,
85
+ })
86
+ const { percentage, activeColor, height } = toRefs(props)
54
87
 
55
- const instance = getCurrentInstance();
56
- const lineWidth = ref<string | number>(0);
88
+ const instance = getCurrentInstance()
89
+ const lineWidth = ref<string | number>(0)
57
90
 
58
91
  watch(
59
92
  () => percentage.value,
60
93
  () => resizeProgressWidth(),
61
- );
94
+ )
62
95
 
63
96
  const progressStyle = computed<CSSProperties>(() => {
64
- const style: CSSProperties = {};
65
- style.width = lineWidth.value;
66
- style.backgroundColor = activeColor.value;
67
- style.height = addUnit(height.value);
68
- return style;
69
- });
97
+ const style: CSSProperties = {}
98
+ style.width = lineWidth.value
99
+ style.backgroundColor = activeColor.value
100
+ style.height = addUnit(height.value)
101
+ return style
102
+ })
70
103
 
71
104
  const innserPercentage = computed(() => {
72
105
  // 控制范围在0-100之间
73
- return range(0, 100, percentage.value);
74
- });
106
+ return range(0, 100, percentage.value)
107
+ })
75
108
 
76
109
  onMounted(() => {
77
- init();
78
- });
110
+ init()
111
+ })
79
112
 
80
113
  const init = async () => {
81
- await sleep(20);
82
- resizeProgressWidth();
83
- };
114
+ await sleep(20)
115
+ resizeProgressWidth()
116
+ }
84
117
  const getProgressWidth = () => {
85
118
  return new Promise((resolve) => {
86
119
  // #ifndef APP-NVUE
87
- resolve(getRect(".hy-line-progress__background", false, instance));
120
+ resolve(getRect('.hy-line-progress__background', false, instance))
88
121
  // #endif
89
- });
90
- };
122
+ })
123
+ }
91
124
 
92
125
  /**
93
126
  * @description 计算轨道长度
94
127
  * */
95
128
  const resizeProgressWidth = async () => {
96
- const { width } = await getProgressWidth();
129
+ const { width } = await getProgressWidth()
97
130
  // 通过设置的percentage值,计算其所占总长度的百分比
98
- lineWidth.value = addUnit((width * innserPercentage.value) / 100);
99
- };
131
+ lineWidth.value = addUnit((width * innserPercentage.value) / 100)
132
+ }
100
133
  </script>
101
134
 
102
135
  <style lang="scss" scoped>
103
- @import "./index.scss";
136
+ @import './index.scss';
104
137
  </style>