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
@@ -24,9 +24,7 @@
24
24
  :top="item?.iconConfig?.top || iconConfig?.top"
25
25
  :stop="item?.iconConfig?.stop || iconConfig?.stop"
26
26
  :round="item?.iconConfig?.round || iconConfig?.round || 6"
27
- :customStyle="
28
- item?.iconConfig?.customStyle || iconConfig?.customStyle
29
- "
27
+ :customStyle="item?.iconConfig?.customStyle || iconConfig?.customStyle"
30
28
  ></HyIcon>
31
29
  </slot>
32
30
  </view>
@@ -35,66 +33,128 @@
35
33
  </template>
36
34
 
37
35
  <script lang="ts">
36
+ /**
37
+ * 宫格组件一般用于同时展示多个同类项目的场景,可以给宫格的项目设置徽标组件(badge),或者图标等,也可以扩展为左右滑动的轮播形式
38
+ * @displayName hy-grid
39
+ */
40
+ defineOptions({})
38
41
  export default {
39
- name: "hy-grid",
42
+ name: 'hy-grid',
40
43
  options: {
41
44
  addGlobalClass: true,
42
45
  virtualHost: true,
43
- styleIsolation: "shared",
46
+ styleIsolation: 'shared',
44
47
  },
45
- };
48
+ }
46
49
  </script>
47
50
 
48
51
  <script setup lang="ts">
49
- import { computed, type CSSProperties, toRefs } from "vue";
50
- import defaultProps from "./props";
51
- import type IProps from "./typing";
52
- import { addUnit } from "../../utils";
52
+ import { computed, toRefs } from 'vue'
53
+ import type { CSSProperties, PropType } from 'vue'
54
+ import type { CustomKeysVo, GridItemVo, IGridEmits } from './typing'
55
+ import { addUnit } from '../../utils'
53
56
 
54
57
  // 组件
55
- import HyIcon from "../hy-icon/hy-icon.vue";
58
+ import HyIcon from '../hy-icon/hy-icon.vue'
59
+ import type HyIconProps from '@/package/components/hy-icon/typing'
56
60
 
57
- const props = withDefaults(defineProps<IProps>(), defaultProps);
58
- const { align, customStyle, bgColor, itemHeight, border } = toRefs(props);
59
- const emit = defineEmits(["click"]);
61
+ // const props = withDefaults(defineProps<IProps>(), defaultProps);
62
+ const props = defineProps({
63
+ /** 数据列表 */
64
+ list: {
65
+ type: Array as PropType<GridItemVo[]>,
66
+ default: [],
67
+ },
68
+ /** 自定义键值 */
69
+ customKeys: {
70
+ type: Object as PropType<CustomKeysVo>,
71
+ default: {
72
+ name: 'name',
73
+ icon: 'icon',
74
+ },
75
+ },
76
+ /** 宫格的列数 */
77
+ col: {
78
+ type: Number,
79
+ default: 5,
80
+ },
81
+ /** 是否显示宫格的边框 */
82
+ border: {
83
+ type: Boolean,
84
+ default: false,
85
+ },
86
+ /** 单个宫格高度 */
87
+ itemHeight: {
88
+ type: [Number, String],
89
+ default: '80px',
90
+ },
91
+ /**
92
+ * 宫格对齐方式,表现为数量少的时候,靠左,居中,还是靠右
93
+ * @values left,center,right
94
+ * */
95
+ align: {
96
+ type: String,
97
+ default: 'left',
98
+ },
99
+ /** 间隔 */
100
+ gap: {
101
+ type: [Number, String],
102
+ default: 0,
103
+ },
104
+ /** 宫格的背景颜色 */
105
+ bgColor: {
106
+ type: String,
107
+ default: 'transparent',
108
+ },
109
+ /** 图标属性api配置集合 */
110
+ iconConfig: Object as PropType<HyIconProps>,
111
+ /** 定义需要用到的外部样式 */
112
+ customStyle: {
113
+ type: Object as PropType<CSSProperties>,
114
+ },
115
+ /** 自定义外部类名 */
116
+ customClass: String,
117
+ })
118
+ const { align, customStyle, bgColor, itemHeight, border } = toRefs(props)
119
+ const emit = defineEmits<IGridEmits>()
60
120
 
61
121
  /**
62
122
  * @description 宫格对齐方式
63
123
  * */
64
124
  const gridStyle = computed<CSSProperties>(() => {
65
- let style: CSSProperties = {};
125
+ let style: CSSProperties = {}
66
126
  switch (align.value) {
67
- case "left":
68
- style.justifyContent = "flex-start";
69
- break;
70
- case "center":
71
- style.justifyContent = "center";
72
- break;
73
- case "right":
74
- style.justifyContent = "flex-end";
75
- break;
127
+ case 'left':
128
+ style.justifyContent = 'flex-start'
129
+ break
130
+ case 'center':
131
+ style.justifyContent = 'center'
132
+ break
133
+ case 'right':
134
+ style.justifyContent = 'flex-end'
135
+ break
76
136
  default:
77
- style.justifyContent = "flex-start";
137
+ style.justifyContent = 'flex-start'
78
138
  }
79
- return Object.assign(style, customStyle.value || {});
80
- });
139
+ return Object.assign(style, customStyle.value || {})
140
+ })
81
141
 
82
142
  const itemStyle = computed<CSSProperties>(() => {
83
143
  const style: CSSProperties = {
84
144
  background: bgColor.value,
85
145
  height: addUnit(itemHeight.value),
86
- width: "100%",
87
- border: border.value ? "0.5px solid #c8c7cc66" : "",
88
- };
89
- return style;
90
- });
146
+ width: '100%',
147
+ border: border.value ? '0.5px solid #c8c7cc66' : '',
148
+ }
149
+ return style
150
+ })
91
151
 
92
152
  /**
93
153
  * @description 点击事件
94
154
  * */
95
155
  const childClick = (name: string | Record<string, any>) => {
96
- emit("click", name);
97
- };
156
+ emit('click', name)
157
+ }
98
158
  </script>
99
159
 
100
160
  <style lang="scss" scoped>
@@ -102,5 +162,5 @@ const childClick = (name: string | Record<string, any>) => {
102
162
  grid-gap: v-bind(gap);
103
163
  grid-template-columns: repeat(v-bind(col), 1fr);
104
164
  }
105
- @import "./index.scss";
165
+ @import './index.scss';
106
166
  </style>
@@ -1,74 +1,79 @@
1
- import { CSSProperties } from "vue";
2
- import type HyIconProps from "../hy-icon/typing";
1
+ import { CSSProperties } from 'vue'
2
+ import type HyIconProps from '../hy-icon/typing'
3
3
 
4
- interface GridItemVo {
4
+ export interface GridItemVo {
5
5
  /**
6
6
  * @description 图标名称或图片地址
7
7
  * */
8
- icon?: string;
8
+ icon?: string
9
9
  /**
10
10
  * @description 名称
11
11
  * */
12
- name?: string;
12
+ name?: string
13
13
  /**
14
14
  * @description 图标属性api配置
15
15
  * */
16
- iconConfig?: Partial<HyIconProps>;
16
+ iconConfig?: Partial<HyIconProps>
17
17
  /**
18
18
  * @description 自定义内容键值对
19
19
  * */
20
- [key: string]: any;
20
+ [key: string]: any
21
21
  }
22
22
  export interface CustomKeysVo {
23
23
  /**
24
24
  * @description 自定义标题键名
25
25
  * */
26
- name: string;
26
+ name: string
27
27
  /**
28
28
  * @description 自定义icon键名
29
29
  * */
30
- icon: string;
30
+ icon: string
31
31
  }
32
32
 
33
33
  export default interface HyGridProps {
34
34
  /**
35
35
  * @description 数据集
36
36
  * */
37
- list: GridItemVo[];
37
+ list: GridItemVo[]
38
38
  /**
39
39
  * @description 自定义键值
40
40
  * */
41
- customKeys?: CustomKeysVo;
41
+ customKeys?: CustomKeysVo
42
42
  /**
43
43
  * @description 宫格的列数(默认 3 )
44
44
  * */
45
- col?: number;
45
+ col?: number
46
46
  /**
47
47
  * @description 是否显示宫格的边框(默认 false )
48
48
  * */
49
- border?: boolean;
49
+ border?: boolean
50
50
  /**
51
51
  * @description 单个宫格高度(默认 60px )
52
52
  * */
53
- itemHeight?: number | string;
53
+ itemHeight?: number | string
54
54
  /**
55
55
  * @description 宫格对齐方式,表现为数量少的时候,靠左,居中,还是靠右 (默认 'left' )
56
56
  * */
57
- align?: "center" | HyApp.LeftRightType;
57
+ align?: 'center' | HyApp.LeftRightType
58
58
  /**
59
59
  * @description 间隔(默认 0px)
60
60
  * */
61
- gap?: number | string;
61
+ gap?: number | string
62
62
  /**
63
63
  * @description 宫格的背景颜色 (默认 'transparent' )
64
64
  * */
65
- bgColor?: string;
65
+ bgColor?: string
66
66
  /**
67
67
  * @description 图标属性api配置集合
68
68
  * */
69
- iconConfig?: Partial<HyIconProps>;
69
+ iconConfig?: Partial<HyIconProps>
70
70
  /**
71
71
  * @description 定义需要用到的外部样式
72
72
  * */
73
- customStyle?: CSSProperties;
73
+ customStyle?: CSSProperties
74
+ }
75
+
76
+ export interface IGridEmits {
77
+ /** 点击小菜单触发 */
78
+ (e: 'click', name: string | Record<string, any>)): void
74
79
  }
@@ -25,6 +25,11 @@
25
25
  </template>
26
26
 
27
27
  <script lang="ts">
28
+ /**
29
+ * 基于字体的图标集,包含了大多数常见场景的图标,使用简单,开箱即用,无需自己再写每个图标的样式,直接简单配置即可。支持自定义图标。
30
+ * @displayName hy-icon
31
+ */
32
+ defineOptions({})
28
33
  export default {
29
34
  name: 'hy-icon',
30
35
  options: {
@@ -36,12 +41,85 @@ export default {
36
41
  </script>
37
42
 
38
43
  <script setup lang="ts">
39
- import { computed, type CSSProperties, toRefs } from 'vue'
44
+ import { computed, type CSSProperties, type PropType, toRefs } from 'vue'
40
45
  import { addUnit } from '../../utils'
41
- import defaultProps from './props'
42
- import type IProps from './typing'
46
+ import type { IIconEmits } from './typing'
43
47
 
44
- const props = withDefaults(defineProps<IProps>(), defaultProps)
48
+ // const props = withDefaults(defineProps<IProps>(), defaultProps)
49
+ const props = defineProps({
50
+ /** 图标名称 */
51
+ name: String,
52
+ /** 图标颜色 */
53
+ color: String,
54
+ /** 图标字体大小,单位px */
55
+ size: {
56
+ type: [Number, String],
57
+ default: '20px',
58
+ },
59
+ /** 是否显示粗体 */
60
+ bold: {
61
+ type: Boolean,
62
+ default: false,
63
+ },
64
+ /** 点击图标的时候传递事件出去的index(用于区分点击了哪一个) */
65
+ index: String,
66
+ /** 自定义扩展前缀,方便用户扩展自己的图标库 */
67
+ customPrefix: {
68
+ type: String,
69
+ default: 'hy-icon',
70
+ },
71
+ /** 图标右侧的label文字 */
72
+ label: String,
73
+ /**
74
+ * label相对于图标的位置,只能right或bottom
75
+ * @values right,bottom
76
+ * */
77
+ labelPos: {
78
+ type: String,
79
+ default: 'right',
80
+ },
81
+ /** label字体大小,单位px */
82
+ labelSize: String,
83
+ /** 图标右侧的label文字颜色 */
84
+ labelColor: String,
85
+ /** label与图标的距离,单位px */
86
+ space: {
87
+ type: [Number, String],
88
+ default: '2px',
89
+ },
90
+ /** 图片的mode */
91
+ imgMode: String,
92
+ /** 显示图片小图标时的宽度 */
93
+ width: String,
94
+ /** 显示图片小图标时的高度 */
95
+ height: String,
96
+ /** 图标在垂直方向上的定位 用于解决某些情况下,让图标垂直居中的用途 */
97
+ top: {
98
+ type: Number,
99
+ default: 0,
100
+ },
101
+ /** 是否阻止事件传播 */
102
+ stop: {
103
+ type: Boolean,
104
+ default: false,
105
+ },
106
+ /** 是否旋转 */
107
+ isRotate: {
108
+ type: Boolean,
109
+ default: false,
110
+ },
111
+ /** 图标圆角 */
112
+ round: {
113
+ type: Number,
114
+ default: 0,
115
+ },
116
+ /** 定义需要用到的外部样式 */
117
+ customStyle: {
118
+ type: Object as PropType<CSSProperties>,
119
+ },
120
+ /** 自定义外部类名 */
121
+ customClass: String,
122
+ })
45
123
  const {
46
124
  customPrefix,
47
125
  name,
@@ -58,7 +136,7 @@ const {
58
136
  customClass,
59
137
  customStyle,
60
138
  } = toRefs(props)
61
- const emit = defineEmits(['click'])
139
+ const emit = defineEmits<IIconEmits>()
62
140
 
63
141
  const uClasses = computed(() => {
64
142
  let classes: string | string[] = [
@@ -110,7 +188,7 @@ const imgStyle = computed((): CSSProperties => {
110
188
  /**
111
189
  * @description 点击
112
190
  * */
113
- const clickHandler = (e: any) => {
191
+ const clickHandler = (e: Event) => {
114
192
  emit('click', index.value, e)
115
193
  // 是否阻止事件冒泡
116
194
  stop.value && e.stopPropagation()
@@ -82,3 +82,8 @@ export default interface HyIconProps {
82
82
  * */
83
83
  customClass?: string
84
84
  }
85
+
86
+ export interface IIconEmits {
87
+ /** 点击图标触发 */
88
+ (e: 'click', index: string, e: Event): void
89
+ }
@@ -1,6 +1,10 @@
1
1
  <template>
2
2
  <HyTransition mode="fade" :show="show" :style="transStyle" :duration="fade ? 1000 : 0">
3
- <view class="hy-image box-border" @tap="clickHandler" :style="[wrapStyle, backgroundStyle]">
3
+ <view
4
+ :class="['hy-image', 'box-border', customClass]"
5
+ @tap="clickHandler"
6
+ :style="[wrapStyle, backgroundStyle]"
7
+ >
4
8
  <image
5
9
  v-if="!isError"
6
10
  :src="src"
@@ -46,6 +50,11 @@
46
50
  </template>
47
51
 
48
52
  <script lang="ts">
53
+ /**
54
+ * uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
55
+ * @displayName hy-image
56
+ */
57
+ defineOptions({})
49
58
  export default {
50
59
  name: 'hy-image',
51
60
  options: {
@@ -57,17 +66,107 @@ export default {
57
66
  </script>
58
67
 
59
68
  <script setup lang="ts">
60
- import { computed, type CSSProperties, onMounted, ref, toRefs, watch } from 'vue'
61
- import defaultProps from './props'
62
- import type IProps from './typing'
69
+ import { computed, onMounted, ref, toRefs, watch } from 'vue'
70
+ import type { PropType, CSSProperties } from 'vue'
71
+ import type { IImageEmits } from './typing'
63
72
  import { addUnit, getPx } from '../../utils'
64
73
 
65
74
  // 组件
66
75
  import HyIcon from '../hy-icon/hy-icon.vue'
67
76
  import HyTransition from '../hy-transition/hy-transition.vue'
68
77
  import HyLoading from '../hy-loading/hy-loading.vue'
78
+ import { IconConfig } from '@/package'
69
79
 
70
- const props = withDefaults(defineProps<IProps>(), defaultProps)
80
+ // const props = withDefaults(defineProps<IProps>(), defaultProps)
81
+ const props = defineProps({
82
+ /** 图片地址 */
83
+ src: String,
84
+ /** 裁剪模式,见官网说明 */
85
+ mode: {
86
+ type: String,
87
+ default: 'aspectFill',
88
+ },
89
+ /** 宽度,单位任意,如果为数值,则为px单位 */
90
+ width: String,
91
+ /** 高度,单位任意,如果为数值,则为px单位 */
92
+ height: String,
93
+ /**
94
+ * 图片形状
95
+ * @values circle,square
96
+ * */
97
+ shape: {
98
+ type: String,
99
+ default: 'square',
100
+ },
101
+ /** 圆角值,单位任意,如果为数值,则为px单位 */
102
+ radius: {
103
+ type: [Number, String],
104
+ default: 0,
105
+ },
106
+ /** 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 */
107
+ lazyLoad: {
108
+ type: Boolean,
109
+ default: true,
110
+ },
111
+ /** 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 */
112
+ showMenuByLongPress: {
113
+ type: Boolean,
114
+ default: true,
115
+ },
116
+ /** 加载中的图标,或者小图片 */
117
+ loadingIcon: {
118
+ type: String,
119
+ default: IconConfig.LOADING,
120
+ },
121
+ /** 加载失败的图标,或者小图片 */
122
+ errorIcon: {
123
+ type: String,
124
+ default: IconConfig.NOTICE,
125
+ },
126
+ /** 是否显示加载中的图标或者自定义的slot */
127
+ showLoading: {
128
+ type: Boolean,
129
+ default: true,
130
+ },
131
+ /** 是否显示加载错误的图标或者自定义的slot */
132
+ showError: {
133
+ type: Boolean,
134
+ default: true,
135
+ },
136
+ /** 是否需要淡入效果 */
137
+ fade: {
138
+ type: Boolean,
139
+ default: true,
140
+ },
141
+ /** 只支持网络资源,只对微信小程序有效 */
142
+ webp: {
143
+ type: Boolean,
144
+ default: false,
145
+ },
146
+ /** 搭配fade参数的过渡时间,单位ms */
147
+ duration: {
148
+ type: Number,
149
+ default: 500,
150
+ },
151
+ /** 背景颜色,用于深色页面加载图片时,为了和背景色融合 */
152
+ bgColor: String,
153
+ /** 是否模糊图片 */
154
+ indistinct: {
155
+ type: Boolean,
156
+ default: false,
157
+ },
158
+ /** 是否预览图片 */
159
+ previewImage: {
160
+ type: Boolean,
161
+ default: false,
162
+ },
163
+ /** 定义需要用到的外部样式 */
164
+ customStyle: {
165
+ type: Object as PropType<CSSProperties>,
166
+ },
167
+ /** 自定义外部类名 */
168
+ customClass: String,
169
+ })
71
170
  const {
72
171
  customStyle,
73
172
  duration,
@@ -81,7 +180,7 @@ const {
81
180
  previewImage,
82
181
  indistinct,
83
182
  } = toRefs(props)
84
- const emit = defineEmits(['click', 'error', 'load'])
183
+ const emit = defineEmits<IImageEmits>()
85
184
 
86
185
  // 图片是否加载错误,如果是,则显示错误占位图
87
186
  const isError = ref(false)
@@ -78,3 +78,12 @@ export default interface HyImageProps {
78
78
  * */
79
79
  customStyle?: CSSProperties
80
80
  }
81
+
82
+ export interface IImageEmits {
83
+ /** 点击触发 */
84
+ (e: 'click'): void
85
+ /** 图片加载错误触发 */
86
+ (e: 'error', err: Event): void
87
+ /** 图片加载中触发 */
88
+ (e: 'load', event: Event): void
89
+ }