hy-app 0.3.0 → 0.3.2

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 (108) hide show
  1. package/README.md +6 -3
  2. package/common/shakeService.ts +31 -29
  3. package/components/avatar.zip +0 -0
  4. package/components/hy-action-sheet/hy-action-sheet.vue +71 -46
  5. package/components/hy-address-picker/hy-address-picker.vue +94 -83
  6. package/components/hy-avatar/hy-avatar.vue +84 -85
  7. package/components/hy-back-top/hy-back-top.vue +8 -6
  8. package/components/hy-badge/hy-badge.vue +47 -46
  9. package/components/hy-button/hy-button.vue +117 -93
  10. package/components/hy-calendar/hy-calendar.vue +168 -160
  11. package/components/hy-card/hy-card.vue +50 -43
  12. package/components/hy-card/typing.d.ts +33 -32
  13. package/components/hy-cell/hy-cell.vue +73 -51
  14. package/components/hy-check-button/hy-check-button.vue +54 -47
  15. package/components/hy-checkbox/hy-checkbox.vue +97 -105
  16. package/components/hy-code-input/hy-code-input.vue +80 -89
  17. package/components/hy-config-provider/hy-config-provider.vue +20 -21
  18. package/components/hy-count-down/hy-count-down.vue +66 -67
  19. package/components/hy-count-to/hy-count-to.vue +105 -99
  20. package/components/hy-count-to/typing.d.ts +13 -12
  21. package/components/hy-datetime-picker/hy-datetime-picker.vue +261 -253
  22. package/components/hy-datetime-picker/typing.d.ts +42 -40
  23. package/components/hy-divider/hy-divider.vue +68 -73
  24. package/components/hy-dropdown/hy-dropdown.vue +20 -19
  25. package/components/hy-dropdown-item/hy-dropdown-item.vue +66 -61
  26. package/components/hy-dropdown-item/typing.d.ts +9 -9
  27. package/components/hy-empty/hy-empty.vue +42 -42
  28. package/components/hy-flex/hy-flex.vue +99 -0
  29. package/components/hy-flex/index.scss +8 -0
  30. package/components/hy-flex/typing.d.ts +23 -0
  31. package/components/hy-float-button/hy-float-button.vue +218 -210
  32. package/components/hy-folding-panel/hy-folding-panel.vue +32 -33
  33. package/components/hy-form/hy-form.vue +264 -252
  34. package/components/hy-form/typing.d.ts +4 -0
  35. package/components/hy-form-group/hy-form-group.vue +114 -183
  36. package/components/hy-form-item/hy-form-item.vue +12 -10
  37. package/components/hy-form-item/index.scss +2 -2
  38. package/components/hy-form-item/typing.d.ts +3 -6
  39. package/components/hy-grid/hy-grid.vue +44 -43
  40. package/components/hy-icon/hy-icon.vue +61 -67
  41. package/components/hy-image/hy-image.vue +112 -88
  42. package/components/hy-image/typing.d.ts +27 -23
  43. package/components/hy-input/hy-input.vue +157 -127
  44. package/components/hy-input/typing.d.ts +53 -47
  45. package/components/hy-line/hy-line.vue +26 -26
  46. package/components/hy-line-progress/hy-line-progress.vue +42 -35
  47. package/components/hy-list/hy-list.vue +76 -85
  48. package/components/hy-loading/hy-loading.vue +26 -23
  49. package/components/hy-login/TheUserLogin.vue +1 -1
  50. package/components/hy-menu/hy-menu.vue +48 -43
  51. package/components/hy-menu/typing.d.ts +18 -17
  52. package/components/hy-modal/hy-modal.vue +39 -35
  53. package/components/hy-navbar/hy-navbar.vue +25 -25
  54. package/components/hy-navbar/typing.d.ts +24 -22
  55. package/components/hy-notice-bar/hy-notice-bar.vue +26 -27
  56. package/components/hy-notify/hy-notify.vue +53 -53
  57. package/components/hy-number-step/hy-number-step.vue +134 -146
  58. package/components/hy-number-step/typing.d.ts +35 -35
  59. package/components/hy-overlay/hy-overlay.vue +23 -21
  60. package/components/hy-pagination/hy-pagination.vue +41 -36
  61. package/components/hy-picker/hy-picker.vue +184 -154
  62. package/components/hy-picker/typing.d.ts +39 -39
  63. package/components/hy-popover/hy-popover.vue +97 -77
  64. package/components/hy-popup/hy-popup.vue +107 -98
  65. package/components/hy-price/hy-price.vue +38 -34
  66. package/components/hy-qrcode/hy-qrcode.vue +50 -51
  67. package/components/hy-radio/hy-radio.vue +101 -113
  68. package/components/hy-rate/hy-rate.vue +107 -88
  69. package/components/hy-read-more/hy-read-more.vue +64 -49
  70. package/components/hy-scroll-list/hy-scroll-list.vue +45 -48
  71. package/components/hy-search/hy-search.vue +73 -66
  72. package/components/hy-search/typing.d.ts +36 -35
  73. package/components/hy-signature/hy-signature.vue +282 -240
  74. package/components/hy-slider/hy-slider.vue +195 -153
  75. package/components/hy-slider/typing.d.ts +21 -21
  76. package/components/hy-steps/hy-steps.vue +118 -90
  77. package/components/hy-steps/index.scss +31 -21
  78. package/components/hy-submit-bar/hy-submit-bar.vue +61 -70
  79. package/components/hy-subsection/hy-subsection.vue +99 -102
  80. package/components/hy-subsection/typing.d.ts +19 -19
  81. package/components/hy-swipe-action/hy-swipe-action.vue +131 -118
  82. package/components/hy-swiper/hy-swiper.vue +85 -71
  83. package/components/hy-switch/hy-switch.vue +67 -72
  84. package/components/hy-switch/typing.d.ts +21 -19
  85. package/components/hy-tabs/hy-tabs.vue +168 -113
  86. package/components/hy-tag/hy-tag.vue +90 -86
  87. package/components/hy-tag/typing.d.ts +26 -21
  88. package/components/hy-text/hy-text.vue +119 -111
  89. package/components/hy-textarea/hy-textarea.vue +100 -93
  90. package/components/hy-textarea/typing.d.ts +36 -31
  91. package/components/hy-toast/hy-toast.vue +77 -67
  92. package/components/hy-tooltip/hy-tooltip.vue +109 -91
  93. package/components/hy-transition/hy-transition.vue +62 -66
  94. package/components/hy-upload/hy-upload.vue +294 -152
  95. package/components/hy-upload/typing.d.ts +41 -36
  96. package/components/hy-warn/hy-warn.vue +34 -27
  97. package/components/hy-waterfall/hy-waterfall.vue +83 -74
  98. package/components/hy-watermark/hy-watermark.vue +134 -115
  99. package/components/index.ts +1 -1
  100. package/composables/usePopover.ts +236 -221
  101. package/composables/useQueue.ts +53 -52
  102. package/global.d.ts +1 -0
  103. package/package.json +2 -2
  104. package/store/index.ts +9 -1
  105. package/theme.scss +5 -5
  106. package/typing/index.ts +0 -1
  107. package/typing/modules/common.d.ts +0 -2
  108. package/web-types.json +1 -1
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <HyTransition mode="fade" :show="show" :style="transStyle" :duration="fade ? 1000 : 0">
2
+ <HyTransition
3
+ mode="fade"
4
+ :show="show"
5
+ :style="transStyle"
6
+ :duration="fade ? 1000 : 0"
7
+ >
3
8
  <view
4
9
  :class="['hy-image', 'box-border', customClass]"
5
10
  @tap="clickHandler"
@@ -51,50 +56,61 @@
51
56
 
52
57
  <script lang="ts">
53
58
  export default {
54
- name: 'hy-image',
59
+ name: "hy-image",
55
60
  options: {
56
61
  addGlobalClass: true,
57
62
  virtualHost: true,
58
- styleIsolation: 'shared',
63
+ styleIsolation: "shared",
59
64
  },
60
- }
65
+ };
61
66
  </script>
62
67
 
63
68
  <script setup lang="ts">
64
- import { computed, onMounted, ref, toRefs, watch } from 'vue'
65
- import type { PropType, CSSProperties } from 'vue'
66
- import type { IImageEmits } from './typing'
67
- import { addUnit, getPx } from '../../utils'
68
- import { IconConfig } from '../../config'
69
+ import { computed, onMounted, ref, watch } from "vue";
70
+ import type { PropType, CSSProperties } from "vue";
71
+ import type { IImageEmits } from "./typing";
72
+ import { addUnit, getPx } from "../../utils";
73
+ import { IconConfig } from "../../config";
69
74
  // 组件
70
- import HyIcon from '../hy-icon/hy-icon.vue'
71
- import HyTransition from '../hy-transition/hy-transition.vue'
72
- import HyLoading from '../hy-loading/hy-loading.vue'
75
+ import HyIcon from "../hy-icon/hy-icon.vue";
76
+ import HyTransition from "../hy-transition/hy-transition.vue";
77
+ import HyLoading from "../hy-loading/hy-loading.vue";
78
+ import type {
79
+ ImageOnErrorEvent,
80
+ ImageOnLoadEvent,
81
+ } from "@uni-helper/uni-types";
73
82
 
74
83
  /**
75
84
  * uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
76
85
  * @displayName hy-image
77
86
  */
78
- defineOptions({})
87
+ defineOptions({});
79
88
 
80
89
  // const props = withDefaults(defineProps<IProps>(), defaultProps)
81
90
  const props = defineProps({
82
91
  /** 图片地址 */
83
- src: String,
84
- /** 裁剪模式,见官网说明 */
92
+ src: {
93
+ type: String,
94
+ default: "",
95
+ required: true,
96
+ },
97
+ /**
98
+ * 裁剪模式,见官网说明
99
+ * @values scaleToFill,aspectFit,aspectFill,widthFix,heightFix,top,bottom,center,left,right,top left,top right,bottom left,bottom right
100
+ * */
85
101
  mode: {
86
102
  type: String,
87
- default: 'aspectFill',
103
+ default: "aspectFill",
88
104
  },
89
105
  /** 宽度,单位任意,如果为数值,则为px单位 */
90
106
  width: {
91
107
  type: [String, Number],
92
- default: '',
108
+ default: "",
93
109
  },
94
110
  /** 高度,单位任意,如果为数值,则为px单位 */
95
111
  height: {
96
112
  type: [String, Number],
97
- default: '',
113
+ default: "",
98
114
  },
99
115
  /**
100
116
  * 图片形状
@@ -102,7 +118,7 @@ const props = defineProps({
102
118
  * */
103
119
  shape: {
104
120
  type: String,
105
- default: 'square',
121
+ default: "square",
106
122
  },
107
123
  /** 圆角值,单位任意,如果为数值,则为px单位 */
108
124
  radius: {
@@ -172,126 +188,134 @@ const props = defineProps({
172
188
  },
173
189
  /** 自定义外部类名 */
174
190
  customClass: String,
175
- })
176
- const {
177
- customStyle,
178
- duration,
179
- src,
180
- width,
181
- height,
182
- mode,
183
- shape,
184
- radius,
185
- bgColor,
186
- previewImage,
187
- indistinct,
188
- } = toRefs(props)
189
- const emit = defineEmits<IImageEmits>()
191
+ });
192
+ const emit = defineEmits<IImageEmits>();
190
193
 
191
194
  // 图片是否加载错误,如果是,则显示错误占位图
192
- const isError = ref(false)
195
+ const isError = ref(false);
193
196
  // 初始化组件时,默认为加载中状态
194
- const loading = ref(true)
197
+ const loading = ref(true);
195
198
  // 不透明度,为了实现淡入淡出的效果
196
- const opacity = ref(1)
199
+ const opacity = ref(1);
197
200
  // 过渡时间,因为props的值无法修改,故需要一个中间值
198
- const durationTime = ref(duration.value)
201
+ const durationTime = ref(props.duration);
199
202
  // 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
200
- const backgroundStyle = ref({})
203
+ const backgroundStyle = ref({});
201
204
  // 用于fade模式的控制组件显示与否
202
- const show = ref(false)
205
+ const show = ref(false);
203
206
 
204
207
  watch(
205
- () => src.value,
208
+ () => props.src,
206
209
  (newValue) => {
207
210
  if (!newValue) {
208
211
  // 如果传入null或者'',或者false,或者undefined,标记为错误状态
209
- isError.value = true
210
- loading.value = false
212
+ isError.value = true;
213
+ loading.value = false;
211
214
  } else {
212
- isError.value = false
213
- loading.value = true
215
+ isError.value = false;
216
+ loading.value = true;
214
217
  }
215
218
  },
216
219
  { immediate: true },
217
- )
220
+ );
218
221
 
219
222
  const transStyle = computed<CSSProperties>(() => {
220
- const style: CSSProperties = {}
221
- if (loading.value || isError.value || width.value == '100%' || mode.value != 'heightFix') {
222
- style.width = addUnit(width.value)
223
+ const style: CSSProperties = {};
224
+ if (
225
+ loading.value ||
226
+ isError.value ||
227
+ props.width == "100%" ||
228
+ props.mode != "heightFix"
229
+ ) {
230
+ style.width = addUnit(props.width);
223
231
  } else {
224
- style.width = 'fit-content'
232
+ style.width = "fit-content";
225
233
  }
226
- if (loading.value || isError.value || height.value == '100%' || mode.value != 'widthFix') {
227
- style.height = addUnit(height.value)
234
+ if (
235
+ loading.value ||
236
+ isError.value ||
237
+ props.height == "100%" ||
238
+ props.mode != "widthFix"
239
+ ) {
240
+ style.height = addUnit(props.height);
228
241
  } else {
229
- style.height = 'fit-content'
242
+ style.height = "fit-content";
230
243
  }
231
- return style
232
- })
244
+ return style;
245
+ });
233
246
 
234
247
  const wrapStyle = computed(() => {
235
- const style: CSSProperties = {}
236
- if (loading.value || isError.value || width.value == '100%' || mode.value != 'heightFix') {
237
- style.width = addUnit(width.value)
248
+ const style: CSSProperties = {};
249
+ if (
250
+ loading.value ||
251
+ isError.value ||
252
+ props.width == "100%" ||
253
+ props.mode != "heightFix"
254
+ ) {
255
+ style.width = addUnit(props.width);
238
256
  } else {
239
- style.width = 'fit-content'
257
+ style.width = "fit-content";
240
258
  }
241
- if (loading.value || isError.value || height.value == '100%' || mode.value != 'widthFix') {
242
- style.height = addUnit(height.value)
259
+ if (
260
+ loading.value ||
261
+ isError.value ||
262
+ props.height == "100%" ||
263
+ props.mode != "widthFix"
264
+ ) {
265
+ style.height = addUnit(props.height);
243
266
  } else {
244
- style.height = 'fit-content'
267
+ style.height = "fit-content";
245
268
  }
246
269
  // 如果是显示圆形,设置一个很多的半径值即可
247
- style.borderRadius = shape.value == 'circle' ? '10000px' : addUnit(radius.value)
270
+ style.borderRadius =
271
+ props.shape == "circle" ? "10000px" : addUnit(props.radius);
248
272
  // 如果设置圆角,必须要有hidden,否则可能圆角无效
249
- style.overflow = getPx(radius.value) > 0 ? 'hidden' : 'visible'
273
+ style.overflow = getPx(props.radius) > 0 ? "hidden" : "visible";
250
274
 
251
- return Object.assign(style, customStyle.value)
252
- })
275
+ return Object.assign(style, props.customStyle);
276
+ });
253
277
 
254
278
  onMounted(() => {
255
- show.value = true
256
- })
279
+ show.value = true;
280
+ });
257
281
 
258
282
  const clickHandler = () => {
259
- emit('click')
283
+ emit("click");
260
284
 
261
- if (previewImage.value) {
285
+ if (props.previewImage) {
262
286
  uni.previewImage({
263
- urls: [src.value],
264
- })
287
+ urls: [props.src],
288
+ });
265
289
  }
266
- }
290
+ };
267
291
 
268
292
  /**
269
293
  * @description 图片加载失败
270
294
  * */
271
- const onErrorHandler = (err: Event) => {
272
- loading.value = false
273
- isError.value = true
274
- emit('error', err)
275
- }
295
+ const onErrorHandler = (err: ImageOnErrorEvent) => {
296
+ loading.value = false;
297
+ isError.value = true;
298
+ emit("error", err);
299
+ };
276
300
 
277
301
  /**
278
302
  * @description 图片加载成功
279
303
  * */
280
- const onLoadHandler = (e: Event) => {
281
- loading.value = false
282
- isError.value = false
283
- emit('load', e)
284
- removeBgColor()
285
- }
304
+ const onLoadHandler = (e: ImageOnLoadEvent) => {
305
+ loading.value = false;
306
+ isError.value = false;
307
+ emit("load", e);
308
+ removeBgColor();
309
+ };
286
310
 
287
311
  const removeBgColor = () => {
288
312
  // 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
289
313
  backgroundStyle.value = {
290
- backgroundColor: bgColor.value || '',
291
- }
292
- }
314
+ backgroundColor: props.bgColor,
315
+ };
316
+ };
293
317
  </script>
294
318
 
295
319
  <style scoped lang="scss">
296
- @import './index.scss';
320
+ @import "./index.scss";
297
321
  </style>
@@ -1,89 +1,93 @@
1
- import type { CSSProperties } from 'vue'
1
+ import type { CSSProperties } from "vue";
2
+ import type {
3
+ ImageOnErrorEvent,
4
+ ImageOnLoadEvent,
5
+ } from "@uni-helper/uni-types";
2
6
 
3
7
  export default interface HyImageProps {
4
8
  /**
5
9
  * @description 图片地址
6
10
  * */
7
- src?: string
11
+ src?: string;
8
12
  /**
9
13
  * @description 裁剪模式,见官网说明 (默认 'aspectFill' )
10
14
  * */
11
- mode?: HyApp.ImageModeVo
15
+ mode?: HyApp.ImageModeVo;
12
16
  /**
13
17
  * @description 宽度,单位任意,如果为数值,则为px单位 (默认 '300' )
14
18
  * */
15
- width?: string | number
19
+ width?: string | number;
16
20
  /**
17
21
  * @description 高度,单位任意,如果为数值,则为px单位 (默认 '225' )
18
22
  * */
19
- height?: string | number
23
+ height?: string | number;
20
24
  /**
21
25
  * @description 图片形状,circle-圆形,square-方形 (默认 'square' )
22
26
  * */
23
- shape?: HyApp.ShapeType
27
+ shape?: HyApp.ShapeType;
24
28
  /**
25
29
  * @description 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
26
30
  * */
27
- radius?: number | string
31
+ radius?: number | string;
28
32
  /**
29
33
  * @description 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 (默认 true )
30
34
  * */
31
- lazyLoad?: boolean
35
+ lazyLoad?: boolean;
32
36
  /**
33
37
  * @description 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 (默认 true )
34
38
  * */
35
- showMenuByLongPress?: boolean
39
+ showMenuByLongPress?: boolean;
36
40
  /**
37
41
  * @description 加载中的图标,或者小图片 (默认 'photo' )
38
42
  * */
39
- loadingIcon?: string
43
+ loadingIcon?: string;
40
44
  /**
41
45
  * @description 加载失败的图标,或者小图片 (默认 'error-circle' )
42
46
  * */
43
- errorIcon?: string
47
+ errorIcon?: string;
44
48
  /**
45
49
  * @description 是否显示加载中的图标或者自定义的slot (默认 true )
46
50
  * */
47
- showLoading?: boolean
51
+ showLoading?: boolean;
48
52
  /**
49
53
  * @description 是否显示加载错误的图标或者自定义的slot (默认 true )
50
54
  * */
51
- showError?: boolean
55
+ showError?: boolean;
52
56
  /**
53
57
  * @description 是否需要淡入效果 (默认 true )
54
58
  * */
55
- fade?: boolean
59
+ fade?: boolean;
56
60
  /**
57
61
  * @description 只支持网络资源,只对微信小程序有效 (默认 false )
58
62
  * */
59
- webp?: boolean
63
+ webp?: boolean;
60
64
  /**
61
65
  * @description 搭配fade参数的过渡时间,单位ms (默认 500 )
62
66
  * */
63
- duration?: number
67
+ duration?: number;
64
68
  /**
65
69
  * @description 背景颜色,用于深色页面加载图片时,为了和背景色融合 (默认 '#f3f4f6' )
66
70
  * */
67
- bgColor?: string
71
+ bgColor?: string;
68
72
  /**
69
73
  * @description 是否模糊图片 (默认 false )
70
74
  * */
71
- indistinct?: boolean
75
+ indistinct?: boolean;
72
76
  /**
73
77
  * @description 是否预览图片 (默认 false )
74
78
  * */
75
- previewImage?: boolean
79
+ previewImage?: boolean;
76
80
  /**
77
81
  * @description 定义需要用到的外部样式
78
82
  * */
79
- customStyle?: CSSProperties
83
+ customStyle?: CSSProperties;
80
84
  }
81
85
 
82
86
  export interface IImageEmits {
83
87
  /** 点击触发 */
84
- (e: 'click'): void
88
+ (e: "click"): void;
85
89
  /** 图片加载错误触发 */
86
- (e: 'error', err: Event): void
90
+ (e: "error", err: ImageOnErrorEvent): void;
87
91
  /** 图片加载中触发 */
88
- (e: 'load', event: Event): void
92
+ (e: "load", event: ImageOnLoadEvent): void;
89
93
  }