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,6 +1,3 @@
1
- <docs>
2
- 从底部弹出的动作菜单面板。
3
- </docs>
4
1
  <template>
5
2
  <view>
6
3
  <HyPopup
@@ -39,9 +36,9 @@
39
36
  <button
40
37
  v-for="(action, rowIndex) in actions"
41
38
  :key="rowIndex"
42
- :class="`hy-action-sheet__action ${action?.disabled ? 'hy-action-sheet__action--disabled' : ''} ${
43
- action?.loading ? 'hy-action-sheet__action--loading' : ''
44
- }`"
39
+ :class="`hy-action-sheet__action ${
40
+ action?.disabled ? 'hy-action-sheet__action--disabled' : ''
41
+ } ${action?.loading ? 'hy-action-sheet__action--loading' : ''}`"
45
42
  :style="`color: ${action?.color}`"
46
43
  @click="onSelect(rowIndex, 'action')"
47
44
  >
@@ -94,6 +91,11 @@
94
91
  </view>
95
92
  </template>
96
93
  <script lang="ts">
94
+ /**
95
+ * 本组件用于从底部弹出一个操作菜单,供用户选择并返回结果。本组件功能类似于uni的uni.showActionSheetAPI,配置更加灵活,所有平台都表现一致。
96
+ * @displayName hy-action-sheet
97
+ */
98
+ defineOptions({})
97
99
  export default {
98
100
  name: 'hy-action-sheet',
99
101
  options: {
@@ -105,13 +107,9 @@ export default {
105
107
  </script>
106
108
 
107
109
  <script lang="ts" setup>
108
- /**
109
- * 按钮组件,用于触发操作,如提交表单或打开链接
110
- */
111
- import { watch, ref } from 'vue'
110
+ import { watch, ref, PropType, type CSSProperties } from 'vue'
112
111
  import { isArray } from '../../utils'
113
- import defaultProps from './props'
114
- import type { IActionSheetPanel, IActionSheetEmits, HyActionSheetProps } from './typing.d.ts'
112
+ import { IActionSheetPanel, IActionSheetEmits, IActionSheetAction } from './typing.d.ts'
115
113
 
116
114
  // 组件
117
115
  import HyIcon from '../hy-icon/hy-icon.vue'
@@ -119,7 +117,77 @@ import HyPopup from '../hy-popup/hy-popup.vue'
119
117
  import HyLoading from '../hy-loading/hy-loading.vue'
120
118
  import HyButton from '../hy-button/hy-button.vue'
121
119
 
122
- const props = withDefaults(defineProps<HyActionSheetProps>(), defaultProps)
120
+ // const props = withDefaults(defineProps<HyActionSheetProps>(), defaultProps)
121
+ const props = defineProps({
122
+ /** 操作菜单是否展示 */
123
+ modelValue: {
124
+ type: Boolean,
125
+ default: false,
126
+ required: true,
127
+ },
128
+ /** 菜单选项列表 */
129
+ actions: {
130
+ type: Array as PropType<IActionSheetAction[]>,
131
+ default() {
132
+ return []
133
+ },
134
+ },
135
+ /** 自定义面板项,可以为字符串数组,也可以为对象数组,如果为二维数组,则为多行展示 */
136
+ panels: {
137
+ type: Array as PropType<Array<IActionSheetPanel | IActionSheetPanel[]>>,
138
+ default() {
139
+ return []
140
+ },
141
+ },
142
+ /** 操作菜单是否展示 */
143
+ round: {
144
+ type: [String, Number],
145
+ default: 20,
146
+ },
147
+ /** 标题 */
148
+ title: String,
149
+ /**
150
+ * 标题文字位置
151
+ * @values left,center,right
152
+ * */
153
+ titleAlign: {
154
+ type: String,
155
+ default: 'center',
156
+ },
157
+ /** 取消按钮的提示文字,不为空时显示按钮 */
158
+ cancelText: String,
159
+ /** 点击某个菜单项时是否关闭弹窗 */
160
+ closeOnClickAction: {
161
+ type: Boolean,
162
+ default: true,
163
+ },
164
+ /** 点击遮罩是否允许关闭 */
165
+ closeOnClickOverlay: {
166
+ type: Boolean,
167
+ default: true,
168
+ },
169
+ /** 弹框动画持续时间 */
170
+ duration: {
171
+ type: Number,
172
+ default: 200,
173
+ },
174
+ /** 菜单层级 */
175
+ zIndex: {
176
+ type: Number,
177
+ default: 100,
178
+ },
179
+ /** 处理底部安全区 */
180
+ safeAreaInsetBottom: {
181
+ type: Boolean,
182
+ default: true,
183
+ },
184
+ /** 自定义外部样式 */
185
+ customStyle: Object as PropType<CSSProperties>,
186
+ /** 自定义外部类名 */
187
+ customClass: String,
188
+ /** 自定义标题类名 */
189
+ customHeaderClass: String,
190
+ })
123
191
  const emit = defineEmits<IActionSheetEmits>()
124
192
 
125
193
  const formatPanels = ref<Array<IActionSheetPanel> | Array<IActionSheetPanel[]>>([])
@@ -122,8 +122,6 @@ export interface IActionSheetEmits {
122
122
  (e: 'close'): void
123
123
  /** 打开面板时触发 */
124
124
  (e: 'open'): void
125
- /**
126
- * 手动更新弹窗显示隐藏
127
- * */
125
+ /** 手动更新弹窗显示隐藏 */
128
126
  (e: 'update:modelValue', visible: boolean): void
129
127
  }
@@ -1,6 +1,7 @@
1
1
  <template>
2
- <view class="u-datetime-picker">
3
- <view v-if="hasInput" class="u-datetime-picker__has-input" @tap="onShowByClickInput">
2
+ <view class="hy-address-picker">
3
+ <view v-if="hasInput" class="hy-address-picker__has-input" @tap="onShowByClickInput">
4
+ <!-- @slot 自定义输入框 -->
4
5
  <slot name="trigger" :value="inputValue">
5
6
  <HyInput
6
7
  v-model="inputValue"
@@ -45,11 +46,13 @@
45
46
  @change="change"
46
47
  >
47
48
  <template #toolbar-right>
49
+ <!-- @slot 工具栏右侧内容,自定义右侧内容,因为微信小程序限制,需要同时设置:toolbarRightSlot="true"生效。 -->
48
50
  <slot name="toolbar-right">
49
51
  {{ confirmText }}
50
52
  </slot>
51
53
  </template>
52
54
  <template #toolbar-bottom>
55
+ <!-- @slot 工具栏下面内容,自定义底部内容 -->
53
56
  <slot name="toolbar-bottom"></slot>
54
57
  </template>
55
58
  </HyPicker>
@@ -57,6 +60,11 @@
57
60
  </template>
58
61
 
59
62
  <script lang="ts">
63
+ /**
64
+ * 此选择器用于选择地址
65
+ * @displayName hy-address-picker
66
+ */
67
+ defineOptions({})
60
68
  export default {
61
69
  name: 'hy-address-picker',
62
70
  options: {
@@ -68,18 +76,111 @@ export default {
68
76
  </script>
69
77
 
70
78
  <script setup lang="ts">
71
- import { onMounted, ref, toRefs } from 'vue'
72
- import defaultProps from './props'
73
- import type IProps from './typing'
79
+ import { type CSSProperties, onMounted, PropType, ref, toRefs } from 'vue'
80
+ import type { IAddressPickerEmits } from './typing'
74
81
  import address from '../../utils/address.json'
75
-
82
+ import type HyInputProps from '../hy-input/typing'
76
83
  // 组件
77
84
  import HyInput from '../hy-input/hy-input.vue'
78
85
  import HyPicker from '../hy-picker/hy-picker.vue'
79
86
 
80
- const props = withDefaults(defineProps<IProps>(), defaultProps)
87
+ // const props = withDefaults(defineProps<IProps>(), defaultProps)
88
+ const props = defineProps({
89
+ /** 用于控制选择器的弹出和收起 */
90
+ show: {
91
+ type: Boolean,
92
+ default: false,
93
+ },
94
+ /**
95
+ * 弹出层弹出方向
96
+ * @values top,bottom
97
+ * */
98
+ popupMode: {
99
+ type: String,
100
+ default: 'bottom',
101
+ },
102
+ /** 是否显示顶部的操作栏 */
103
+ showToolbar: {
104
+ type: Boolean,
105
+ default: true,
106
+ },
107
+ /** 绑定值 */
108
+ modelValue: {
109
+ type: String,
110
+ required: true,
111
+ },
112
+ /** 顶部标题 */
113
+ title: String,
114
+ /** 字符串截取数组条件 */
115
+ separator: {
116
+ type: String,
117
+ default: ' ',
118
+ },
119
+ /** 是否显示加载中状态 */
120
+ loading: {
121
+ type: Boolean,
122
+ default: false,
123
+ },
124
+ /** 各列中,单个选项的高度 */
125
+ itemHeight: {
126
+ type: Number,
127
+ default: 44,
128
+ },
129
+ /** 取消按钮的文字 */
130
+ cancelText: {
131
+ type: String,
132
+ default: '取消',
133
+ },
134
+ /** 确认按钮的文字 */
135
+ confirmText: {
136
+ type: String,
137
+ default: '确认',
138
+ },
139
+ /** 取消按钮的颜色 */
140
+ cancelColor: {
141
+ type: String,
142
+ default: '#909193',
143
+ },
144
+ /** 确认按钮的颜色 */
145
+ confirmColor: {
146
+ type: String,
147
+ default: '#3c9cff',
148
+ },
149
+ /** 每列中可见选项的数量 */
150
+ visibleItemCount: {
151
+ type: Number,
152
+ default: 5,
153
+ },
154
+ /** 是否允许点击遮罩关闭选择器 */
155
+ closeOnClickOverlay: {
156
+ type: Boolean,
157
+ default: false,
158
+ },
159
+ /** 各列的默认索引 */
160
+ defaultIndex: {
161
+ type: Array as PropType<Array<any>>,
162
+ },
163
+ /** 是否显示输入框 */
164
+ hasInput: {
165
+ type: Boolean,
166
+ default: false,
167
+ },
168
+ /** 输入框集合属性 */
169
+ input: {
170
+ type: Object as PropType<HyInputProps>,
171
+ },
172
+ /** 右边插槽 */
173
+ toolbarRightSlot: {
174
+ type: Boolean,
175
+ default: false,
176
+ },
177
+ /** 自定义输入框外部样式 */
178
+ customStyle: {
179
+ type: Object as PropType<CSSProperties>,
180
+ },
181
+ })
81
182
  const { show, modelValue, hasInput, input, separator, closeOnClickOverlay } = toRefs(props)
82
- const emit = defineEmits(['close', 'cancel', 'confirm', 'change', 'update:modelValue'])
183
+ const emit = defineEmits<IAddressPickerEmits>()
83
184
 
84
185
  // 原来的日期选择器不方便,这里增加一个hasInput选项支持类似element的自带输入框的功能。
85
186
  const inputValue = ref<string>('') // 表单显示值
@@ -1,5 +1,5 @@
1
1
  @use "../../libs/css/mixin.scss" as *;
2
- @include b(datetime-picker) {
2
+ @include b(address-picker) {
3
3
  flex: 1;
4
4
  &__has-input {
5
5
  position: relative;
@@ -24,4 +24,4 @@
24
24
  padding: 0 10px;
25
25
  }
26
26
  }
27
- }
27
+ }
@@ -1,90 +1,99 @@
1
- import type { CSSProperties } from "vue";
2
- import type HyInputProps from "../hy-input/typing";
1
+ import type { CSSProperties } from 'vue'
2
+ import type HyInputProps from '../hy-input/typing'
3
3
 
4
4
  export default interface HyAddressPickerProps {
5
5
  /**
6
6
  * @description 用于控制选择器的弹出和收起 ( 默认 false )
7
7
  * */
8
- show?: boolean;
8
+ show?: boolean
9
9
  /**
10
10
  * @description 弹出层弹出方向
11
11
  * */
12
- popupMode?: HyApp.LayoutType;
12
+ popupMode?: HyApp.LayoutType
13
13
  /**
14
14
  * @description 是否显示顶部的操作栏 ( 默认 true )
15
15
  * */
16
- showToolbar?: boolean;
16
+ showToolbar?: boolean
17
17
  /**
18
18
  * @description 绑定值
19
19
  * */
20
- modelValue: string;
20
+ modelValue: string
21
21
  /**
22
22
  * @description 顶部标题
23
23
  * */
24
- title?: string;
24
+ title?: string
25
25
  /**
26
26
  * @description 字符串截取数组条件
27
27
  * */
28
- separator?: string;
28
+ separator?: string
29
29
  /**
30
30
  * @description 是否显示加载中状态 ( 默认 false )
31
31
  * */
32
- loading?: boolean;
32
+ loading?: boolean
33
33
  /**
34
34
  * @description 各列中,单个选项的高度 ( 默认 44 )
35
35
  * */
36
- itemHeight?: number;
36
+ itemHeight?: number
37
37
  /**
38
38
  * @description 取消按钮的文字 ( 默认 '取消' )
39
39
  * */
40
- cancelText?: string;
40
+ cancelText?: string
41
41
  /**
42
42
  * @description 确认按钮的文字 ( 默认 '确认' )
43
43
  * */
44
- confirmText?: string;
44
+ confirmText?: string
45
45
  /**
46
46
  * @description 取消按钮的颜色 ( 默认 '#909193' )
47
47
  * */
48
- cancelColor?: string;
48
+ cancelColor?: string
49
49
  /**
50
50
  * @description 确认按钮的颜色 ( 默认 '#3c9cff' )
51
51
  * */
52
- confirmColor?: string;
52
+ confirmColor?: string
53
53
  /**
54
54
  * @description 每列中可见选项的数量 ( 默认 5 )
55
55
  * */
56
- visibleItemCount?: number;
56
+ visibleItemCount?: number
57
57
  /**
58
58
  * @description 是否允许点击遮罩关闭选择器 ( 默认 false )
59
59
  * */
60
- closeOnClickOverlay?: boolean;
60
+ closeOnClickOverlay?: boolean
61
61
  /**
62
62
  * @description 各列的默认索引
63
63
  * @note 类型有问题,需要调整
64
64
  * */
65
- defaultIndex?: Array<any>;
65
+ defaultIndex?: Array<any>
66
66
  /**
67
- * @description 输入框是否显示边框 ( 默认 false )
67
+ * @description 是否显示输入框 ( 默认 false )
68
68
  * */
69
- hasInput?: boolean;
69
+ hasInput?: boolean
70
70
  /**
71
71
  * @description 输入框集合属性
72
72
  * */
73
- input?: Partial<HyInputProps>;
73
+ input?: Partial<HyInputProps>
74
74
  /**
75
75
  * @description 右边插槽
76
76
  * */
77
- toolbarRightSlot?: boolean;
78
- /**
79
- * @description 输入框形状
80
- * */
81
- shape?: HyApp.ShapeType;
82
- /**
83
- * @description 输入框边框
84
- * */
85
- border?: HyApp.BorderType;
77
+ toolbarRightSlot?: boolean
86
78
  /**
87
79
  * @description 自定义输入框外部样式
88
80
  * */
89
- customStyle?: CSSProperties;
81
+ customStyle?: CSSProperties
82
+ }
83
+
84
+ export type ConfirmParams = {
85
+ /** 选中值 */
86
+ value: string
87
+ }
88
+ export interface IAddressPickerEmits {
89
+ /** 关闭选择器时触发 */
90
+ (e: 'close'): void
91
+ /** 点击取消按钮触发 */
92
+ (e: 'cancel'): void
93
+ /** 点击确认按钮触发 */
94
+ (e: 'confirm', params: ConfirmParams): void
95
+ /** 当选择值变化时触发 */
96
+ (e: 'change', args: any): void
97
+ /** 当选择值变化时触发 */
98
+ (e: 'update:modelValue', value: ConfirmParams['value']): void
90
99
  }
@@ -41,6 +41,11 @@
41
41
  </template>
42
42
 
43
43
  <script lang="ts">
44
+ /**
45
+ * 本组件一般用于展示头像的地方,如个人中心,或者评论列表页的用户头像展示等场所
46
+ * @displayName hy-avatar
47
+ */
48
+ defineOptions({})
44
49
  export default {
45
50
  name: 'hy-avatar',
46
51
  options: {
@@ -53,14 +58,83 @@ export default {
53
58
 
54
59
  <script setup lang="ts">
55
60
  import { computed, type CSSProperties, toRefs, ref, watch } from 'vue'
56
- import defaultProps from './props'
57
- import type IProps from './typing'
61
+ import type { IAvatarEmit } from './typing'
58
62
  import { addUnit, random } from '../../utils'
59
63
 
60
64
  // 组件
61
65
  import HyIcon from '../hy-icon/hy-icon.vue'
62
66
 
63
- const props = withDefaults(defineProps<IProps>(), defaultProps)
67
+ // const props = withDefaults(defineProps<IProps>(), defaultProps)
68
+ const props = defineProps({
69
+ /** 头像路径 */
70
+ src: String,
71
+ /**
72
+ * 头像形状
73
+ * @values circle,square
74
+ * */
75
+ shape: {
76
+ type: String,
77
+ default: 'circle',
78
+ },
79
+ /**
80
+ * 头像尺寸
81
+ * @values large, medium, small
82
+ * */
83
+ size: {
84
+ type: [String, Number],
85
+ default: 'medium',
86
+ },
87
+ /**
88
+ * 头像图片的裁剪类型
89
+ * @values scaleToFill,aspectFit,aspectFill,widthFix,heightFix,top,bottom,center,left,right,top left,top right,bottom left,bottom right
90
+ * */
91
+ mode: {
92
+ type: String,
93
+ default: 'scaleToFill',
94
+ },
95
+ /** 用文字替代图片,级别优先于src */
96
+ text: String,
97
+ /** 头像背景颜色 */
98
+ bgColor: {
99
+ type: String,
100
+ default: '#c0c4cc',
101
+ },
102
+ /** 文字颜色 */
103
+ color: {
104
+ type: String,
105
+ default: '#ffffff',
106
+ },
107
+ /** 文字大小 */
108
+ fontSize: {
109
+ type: Number,
110
+ default: 18,
111
+ },
112
+ /** 显示的图标 */
113
+ icon: String,
114
+ /** 显示小程序头像,只对百度,微信,QQ小程序有效 */
115
+ mpAvatar: {
116
+ type: Boolean,
117
+ default: false,
118
+ },
119
+ /** 是否使用随机背景色 */
120
+ randomBgColor: {
121
+ type: Boolean,
122
+ default: false,
123
+ },
124
+ /** 加载失败的默认头像(组件有内置默认图片) */
125
+ defaultUrl: String,
126
+ /** 如果配置了randomBgColor为true,且配置了此值,则从默认的背景色数组中取出对应索引的颜色值,取值0-19之间 */
127
+ colorIndex: {
128
+ type: Number,
129
+ default: 0,
130
+ },
131
+ /** 组件标识符 */
132
+ name: String,
133
+ /** 自定义输入框外部样式 */
134
+ customStyle: {
135
+ type: Object as PropType<CSSProperties>,
136
+ },
137
+ })
64
138
  const {
65
139
  src,
66
140
  defaultUrl,
@@ -74,7 +148,7 @@ const {
74
148
  name,
75
149
  customStyle,
76
150
  } = toRefs(props)
77
- const emit = defineEmits(['click'])
151
+ const emit = defineEmits<IAvatarEmit>()
78
152
 
79
153
  const base64Avatar =
80
154
  'data:image/jpg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAA8AAD/4QMraHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjMtYzAxMSA2Ni4xNDU2NjEsIDIwMTIvMDIvMDYtMTQ6NTY6MjcgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzYgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlk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zGLlJRSq26JAelwsWONYjbXxcZvmwO8AAAAAAAAAAAAAAAAAAef3TEWPkVivx3NY9T6UBiAAAAAABo2+VmGXblddIJ8eivRUD0oAAAAAAAAAAAAAAAAAAAYt4tKeFKVNYNSXfRgefAAAAAAAAr7VuSSWPedKaW5v1MCsAAAAAAAAAAAAAAAAAAIe6bj96Ts2n+JPzSXzP3ATgAAAAAAAAFbbt1UUrOQ9FpC4/UwK6aaqtU+DAAAAAAAAAAAAAAA4lKMIuUmoxWrb4ARNx3R3q2rLpa4Sl0y/YCcAAAAAAAAAAANmFud7G8r89r6X0dgFvGzLGRGtuWvTF6NAdwAAAAAAAAAAAy5W442PVN+K59EePp5ARMvOv5MvO6QXCC4AZwAAAAAAAAAAAAAcxlKLUotprg1owN+PvORborq+7Hnwl3gUbO74VzRydt8pKn68ANcJwmqwkpLmnUDkAAAAfNy9atqtyagut0AxXt5xIV8Fbj6lRd7Am5G65V6qUvtwfyx94GMAAAAAAAAAAAAAAAAAAAOU2nVOj5gdsc3LiqRvTpyqwOxbnnrhdfpSfrQB7pnv/AGvuS9gHXPMy5/Fem1yq0v0A6W29XqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf//Z'
@@ -1,64 +1,69 @@
1
- import type { CSSProperties } from "vue";
1
+ import type { CSSProperties } from 'vue'
2
2
 
3
3
  export default interface HyAvatarProps {
4
4
  /**
5
5
  * @description 头像路径,如加载失败,将会显示默认头像(不能为相对路径)
6
6
  * */
7
- src?: string;
7
+ src?: string
8
8
  /**
9
9
  * @description 头像形状 ( circle (默认) | square)
10
10
  * */
11
- shape?: HyApp.ShapeType;
11
+ shape?: HyApp.ShapeType
12
12
  /**
13
13
  * @description 头像尺寸,可以为指定字符串(large, default, mini),或者数值 (默认 40 )
14
14
  * */
15
- size?: number | HyApp.SizeType;
15
+ size?: number | HyApp.SizeType
16
16
  /**
17
17
  * @description 头像图片的裁剪类型,与uni的image组件的mode参数一致,如效果达不到需求,可尝试传widthFix值 (默认 'scaleToFill' )
18
18
  * */
19
- mode?: string;
19
+ mode?: string
20
20
  /**
21
21
  * @description 用文字替代图片,级别优先于src
22
22
  * */
23
- text?: string;
23
+ text?: string
24
24
  /**
25
25
  * @description 背景颜色,一般显示文字时用 (默认 '#c0c4cc' )
26
26
  * */
27
- bgColor?: string;
27
+ bgColor?: string
28
28
  /**
29
29
  * @description 文字颜色 (默认 '#ffffff' )
30
30
  * */
31
- color?: string;
31
+ color?: string
32
32
  /**
33
33
  * @description 文字大小 (默认 18 )
34
34
  * */
35
- fontSize?: number | string;
35
+ fontSize?: number | string
36
36
  /**
37
37
  * @description 显示的图标
38
38
  * */
39
- icon?: string;
39
+ icon?: string
40
40
  /**
41
41
  * @description 显示小程序头像,只对百度,微信,QQ小程序有效 (默认 false )
42
42
  * */
43
- mpAvatar?: boolean;
43
+ mpAvatar?: boolean
44
44
  /**
45
45
  * @description 是否使用随机背景色 (默认 false )
46
46
  * */
47
- randomBgColor?: boolean;
47
+ randomBgColor?: boolean
48
48
  /**
49
49
  * @description 加载失败的默认头像(组件有内置默认图片)
50
50
  * */
51
- defaultUrl?: string;
51
+ defaultUrl?: string
52
52
  /**
53
53
  * @description 如果配置了randomBgColor为true,且配置了此值,则从默认的背景色数组中取出对应索引的颜色值,取值0-19之间
54
54
  * */
55
- colorIndex?: number;
55
+ colorIndex?: number
56
56
  /**
57
57
  * @description 组件标识符 (默认 'level' )
58
58
  * */
59
- name?: string;
59
+ name?: string
60
60
  /**
61
61
  * @description 定义需要用到的外部样式
62
62
  * */
63
- customStyle?: CSSProperties;
63
+ customStyle?: CSSProperties
64
+ }
65
+
66
+ export interface IAvatarEmit {
67
+ /** 点击头像触发 */
68
+ (e: 'click', name: string, e: Event): void
64
69
  }