hy-app 0.3.1 → 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 (96) 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-badge/hy-badge.vue +47 -46
  8. package/components/hy-button/hy-button.vue +117 -93
  9. package/components/hy-calendar/hy-calendar.vue +168 -160
  10. package/components/hy-card/hy-card.vue +50 -43
  11. package/components/hy-card/typing.d.ts +33 -32
  12. package/components/hy-cell/hy-cell.vue +73 -51
  13. package/components/hy-check-button/hy-check-button.vue +54 -47
  14. package/components/hy-checkbox/hy-checkbox.vue +97 -105
  15. package/components/hy-code-input/hy-code-input.vue +80 -89
  16. package/components/hy-config-provider/hy-config-provider.vue +19 -20
  17. package/components/hy-count-down/hy-count-down.vue +66 -67
  18. package/components/hy-count-to/hy-count-to.vue +105 -99
  19. package/components/hy-count-to/typing.d.ts +13 -12
  20. package/components/hy-datetime-picker/hy-datetime-picker.vue +261 -253
  21. package/components/hy-datetime-picker/typing.d.ts +42 -40
  22. package/components/hy-divider/hy-divider.vue +68 -73
  23. package/components/hy-dropdown/hy-dropdown.vue +20 -19
  24. package/components/hy-dropdown-item/hy-dropdown-item.vue +66 -61
  25. package/components/hy-dropdown-item/typing.d.ts +9 -9
  26. package/components/hy-empty/hy-empty.vue +42 -42
  27. package/components/hy-flex/hy-flex.vue +52 -26
  28. package/components/hy-float-button/hy-float-button.vue +218 -210
  29. package/components/hy-folding-panel/hy-folding-panel.vue +32 -33
  30. package/components/hy-form/hy-form.vue +264 -259
  31. package/components/hy-grid/hy-grid.vue +44 -43
  32. package/components/hy-icon/hy-icon.vue +61 -67
  33. package/components/hy-image/hy-image.vue +112 -88
  34. package/components/hy-image/typing.d.ts +27 -23
  35. package/components/hy-input/hy-input.vue +157 -127
  36. package/components/hy-input/typing.d.ts +53 -47
  37. package/components/hy-line/hy-line.vue +26 -26
  38. package/components/hy-line-progress/hy-line-progress.vue +42 -35
  39. package/components/hy-list/hy-list.vue +76 -85
  40. package/components/hy-loading/hy-loading.vue +26 -23
  41. package/components/hy-menu/hy-menu.vue +48 -43
  42. package/components/hy-menu/typing.d.ts +18 -17
  43. package/components/hy-modal/hy-modal.vue +39 -35
  44. package/components/hy-navbar/hy-navbar.vue +25 -25
  45. package/components/hy-navbar/typing.d.ts +24 -22
  46. package/components/hy-notice-bar/hy-notice-bar.vue +26 -27
  47. package/components/hy-notify/hy-notify.vue +53 -53
  48. package/components/hy-number-step/hy-number-step.vue +134 -146
  49. package/components/hy-number-step/typing.d.ts +35 -35
  50. package/components/hy-overlay/hy-overlay.vue +23 -21
  51. package/components/hy-pagination/hy-pagination.vue +41 -36
  52. package/components/hy-picker/hy-picker.vue +184 -154
  53. package/components/hy-picker/typing.d.ts +39 -39
  54. package/components/hy-popover/hy-popover.vue +97 -77
  55. package/components/hy-popup/hy-popup.vue +107 -98
  56. package/components/hy-price/hy-price.vue +38 -34
  57. package/components/hy-qrcode/hy-qrcode.vue +50 -51
  58. package/components/hy-radio/hy-radio.vue +101 -113
  59. package/components/hy-rate/hy-rate.vue +107 -88
  60. package/components/hy-read-more/hy-read-more.vue +64 -49
  61. package/components/hy-scroll-list/hy-scroll-list.vue +45 -48
  62. package/components/hy-search/hy-search.vue +73 -66
  63. package/components/hy-search/typing.d.ts +36 -35
  64. package/components/hy-signature/hy-signature.vue +282 -240
  65. package/components/hy-slider/hy-slider.vue +195 -153
  66. package/components/hy-slider/typing.d.ts +21 -21
  67. package/components/hy-steps/hy-steps.vue +118 -90
  68. package/components/hy-steps/index.scss +31 -21
  69. package/components/hy-submit-bar/hy-submit-bar.vue +61 -70
  70. package/components/hy-subsection/hy-subsection.vue +99 -102
  71. package/components/hy-subsection/typing.d.ts +19 -19
  72. package/components/hy-swipe-action/hy-swipe-action.vue +131 -118
  73. package/components/hy-swiper/hy-swiper.vue +85 -71
  74. package/components/hy-switch/hy-switch.vue +67 -72
  75. package/components/hy-switch/typing.d.ts +21 -19
  76. package/components/hy-tabs/hy-tabs.vue +168 -113
  77. package/components/hy-tag/hy-tag.vue +90 -86
  78. package/components/hy-tag/typing.d.ts +26 -21
  79. package/components/hy-text/hy-text.vue +119 -111
  80. package/components/hy-textarea/hy-textarea.vue +100 -93
  81. package/components/hy-textarea/typing.d.ts +36 -31
  82. package/components/hy-toast/hy-toast.vue +77 -67
  83. package/components/hy-tooltip/hy-tooltip.vue +109 -91
  84. package/components/hy-transition/hy-transition.vue +62 -66
  85. package/components/hy-upload/hy-upload.vue +294 -152
  86. package/components/hy-upload/typing.d.ts +41 -36
  87. package/components/hy-warn/hy-warn.vue +34 -27
  88. package/components/hy-waterfall/hy-waterfall.vue +83 -74
  89. package/components/hy-watermark/hy-watermark.vue +134 -115
  90. package/composables/usePopover.ts +236 -221
  91. package/composables/useQueue.ts +53 -52
  92. package/package.json +2 -2
  93. package/store/index.ts +9 -1
  94. package/typing/index.ts +0 -1
  95. package/typing/modules/common.d.ts +0 -2
  96. package/web-types.json +1 -1
@@ -26,8 +26,15 @@
26
26
  :class="['hy-button', 'hy-reset-button', bemClass, customClass]"
27
27
  >
28
28
  <template v-if="loading">
29
- <HyLoading :mode="loadingMode" :size="loadingSize" :color="loadingColor"></HyLoading>
30
- <text class="hy-button__loading-text" :style="[{ fontSize: textSize + 'px' }]">
29
+ <HyLoading
30
+ :mode="loadingMode"
31
+ :size="loadingSize"
32
+ :color="loadingColor"
33
+ ></HyLoading>
34
+ <text
35
+ class="hy-button__loading-text"
36
+ :style="[{ fontSize: textSize + 'px' }]"
37
+ >
31
38
  {{ loadingText || text }}
32
39
  </text>
33
40
  </template>
@@ -49,7 +56,11 @@
49
56
  ></HyIcon>
50
57
  <!-- @slot 插入默认的值 -->
51
58
  <slot>
52
- <text class="hy-button__text" :style="[{ fontSize: textSize + 'px' }]">{{ text }}</text>
59
+ <text
60
+ class="hy-button__text"
61
+ :style="[{ fontSize: textSize + 'px' }]"
62
+ >{{ text }}</text
63
+ >
53
64
  </slot>
54
65
  </template>
55
66
  </button>
@@ -72,7 +83,11 @@
72
83
  :style="[baseColor, customStyle]"
73
84
  >
74
85
  <template v-if="loading">
75
- <HyLoading :mode="loadingMode" :size="loadingSize" :color="loadingColor"></HyLoading>
86
+ <HyLoading
87
+ :mode="loadingMode"
88
+ :size="loadingSize"
89
+ :color="loadingColor"
90
+ ></HyLoading>
76
91
  <text
77
92
  class="hy-button__loading-text"
78
93
  :style="[nvueTextStyle]"
@@ -116,31 +131,31 @@
116
131
 
117
132
  <script lang="ts">
118
133
  export default {
119
- name: 'hy-button',
134
+ name: "hy-button",
120
135
  options: {
121
136
  addGlobalClass: true,
122
137
  virtualHost: true,
123
- styleIsolation: 'shared',
138
+ styleIsolation: "shared",
124
139
  },
125
- }
140
+ };
126
141
  </script>
127
142
 
128
143
  <script setup lang="ts">
144
+ import { computed } from "vue";
145
+ import type { CSSProperties, PropType } from "vue";
146
+ import { bem, throttle } from "../../utils";
147
+ import { ColorConfig } from "../../config";
148
+ import type { IButtonEmits } from "./typing";
149
+ import type HyIconProps from "../hy-icon/typing";
150
+ // 组件
151
+ import HyIcon from "../hy-icon/hy-icon.vue";
152
+ import HyLoading from "../hy-loading/hy-loading.vue";
153
+
129
154
  /**
130
155
  * 该组件内部实现以uni-app的基础button组件为基础,进行二次封装
131
156
  * @displayName hy-button
132
157
  */
133
- defineOptions({})
134
- import { computed, toRefs } from 'vue'
135
- import type { CSSProperties, PropType } from 'vue'
136
- import { bem, throttle } from '../../utils'
137
- import { ColorConfig } from '../../config'
138
- import type { IButtonEmits } from './typing.d.ts'
139
- import type HyIconProps from '../hy-icon/typing'
140
-
141
- // 组件
142
- import HyIcon from '../hy-icon/hy-icon.vue'
143
- import HyLoading from '../hy-loading/hy-loading.vue'
158
+ defineOptions({});
144
159
 
145
160
  // const props = withDefaults(defineProps<HyButtonProps>(), param)
146
161
  const props = defineProps({
@@ -155,7 +170,7 @@ const props = defineProps({
155
170
  * */
156
171
  type: {
157
172
  type: String,
158
- default: 'primary',
173
+ default: "primary",
159
174
  },
160
175
  /**
161
176
  * 按钮尺寸
@@ -163,7 +178,7 @@ const props = defineProps({
163
178
  * */
164
179
  size: {
165
180
  type: String,
166
- default: 'medium',
181
+ default: "medium",
167
182
  },
168
183
  /**
169
184
  * 按钮形状
@@ -171,7 +186,7 @@ const props = defineProps({
171
186
  * */
172
187
  shape: {
173
188
  type: String,
174
- default: 'square',
189
+ default: "square",
175
190
  },
176
191
  /** 按钮是否镂空,背景色透明 */
177
192
  plain: {
@@ -196,7 +211,7 @@ const props = defineProps({
196
211
  * */
197
212
  loadingMode: {
198
213
  type: String,
199
- default: 'spinner',
214
+ default: "spinner",
200
215
  },
201
216
  /** 加载图标大小 */
202
217
  loadingSize: {
@@ -220,7 +235,7 @@ const props = defineProps({
220
235
  * */
221
236
  lang: {
222
237
  type: String,
223
- default: 'en',
238
+ default: "en",
224
239
  },
225
240
  /** 会话来源,openType="contact"时有效 */
226
241
  sessionFrom: String,
@@ -267,135 +282,144 @@ const props = defineProps({
267
282
  customStyle: Object as unknown as PropType<CSSProperties>,
268
283
  /** 自定义外部类名 */
269
284
  customClass: String,
270
- })
271
- const { disabled, loading, throttleTime, stop, size, type, plain, color, icon } = toRefs(props)
272
- const emit = defineEmits<IButtonEmits>()
285
+ });
286
+ const emit = defineEmits<IButtonEmits>();
273
287
 
274
- const textColor = (ColorConfig as any)[type.value]
288
+ const textColor = (ColorConfig as any)[props.type];
275
289
 
276
290
  /**
277
291
  * @description 生成bem风格的类名
278
292
  */
279
293
  const bemClass = computed(() => {
280
294
  // this.bem为一个computed变量,在mixin中
281
- if (!color.value) {
282
- return bem('button', props, ['type', 'shape', 'size'], ['disabled', 'plain', 'hairline'])
295
+ if (!props.color) {
296
+ return bem(
297
+ "button",
298
+ props,
299
+ ["type", "shape", "size"],
300
+ ["disabled", "plain", "hairline"],
301
+ );
283
302
  } else {
284
303
  // 由于nvue的原因,在有color参数时,不需要传入type,否则会生成type相关的类型,影响最终的样式
285
- return bem('button', props, ['shape', 'size'], ['disabled', 'plain', 'hairline'])
304
+ return bem(
305
+ "button",
306
+ props,
307
+ ["shape", "size"],
308
+ ["disabled", "plain", "hairline"],
309
+ );
286
310
  }
287
- })
311
+ });
288
312
 
289
313
  const loadingColor = computed(() => {
290
- if (plain.value) {
314
+ if (props.plain) {
291
315
  // 如果有设置color值,则用color值,否则使用type主题颜色
292
- return color.value ? color.value : ''
316
+ return props.color ? props.color : "";
293
317
  }
294
- if (type.value === 'info') {
295
- return '#c9c9c9'
318
+ if (props.type === "info") {
319
+ return "#c9c9c9";
296
320
  }
297
- return '#fff'
298
- })
321
+ return "#fff";
322
+ });
299
323
 
300
324
  const iconColorCom = computed((): string => {
301
325
  // 如果是镂空状态,设置了color就用color值,否则使用主题颜色,
302
- if (icon.value?.color) return icon.value?.color
303
- if (plain.value) {
304
- return color.value ? color.value : ''
326
+ if (props.icon?.color) return props.icon?.color;
327
+ if (props.plain) {
328
+ return props.color ? props.color : "";
305
329
  } else {
306
- return '#ffffff'
330
+ return "#ffffff";
307
331
  }
308
- })
332
+ });
309
333
  const baseColor = computed((): CSSProperties => {
310
- let style: CSSProperties = {}
311
- if (color.value) {
334
+ let style: CSSProperties = {};
335
+ if (props.color) {
312
336
  // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
313
- style.color = plain.value ? color.value : 'white'
314
- if (!plain.value) {
337
+ style.color = props.plain ? props.color : "white";
338
+ if (!props.plain) {
315
339
  // 非镂空,背景色使用自定义的颜色
316
- style['background'] = color.value
340
+ style["background"] = props.color;
317
341
  }
318
- if (color.value.indexOf('gradient') !== -1) {
342
+ if (props.color.indexOf("gradient") !== -1) {
319
343
  // 如果自定义的颜色为渐变色,不显示边框,以及通过backgroundImage设置渐变色
320
344
  // weex文档说明可以写borderWidth的形式,为什么这里需要分开写?
321
345
  // 因为weex是阿里巴巴为了部门业绩考核而做的你懂的东西,所以需要这么写才有效
322
- style.borderTopWidth = 0
323
- style.borderRightWidth = 0
324
- style.borderBottomWidth = 0
325
- style.borderLeftWidth = 0
326
- if (!plain.value) {
327
- style.backgroundImage = color.value
346
+ style.borderTopWidth = 0;
347
+ style.borderRightWidth = 0;
348
+ style.borderBottomWidth = 0;
349
+ style.borderLeftWidth = 0;
350
+ if (!props.plain) {
351
+ style.backgroundImage = props.color;
328
352
  }
329
353
  } else {
330
354
  // 非渐变色,则设置边框相关的属性
331
- style.borderColor = color.value
332
- style.borderWidth = '1px'
333
- style.borderStyle = 'solid'
355
+ style.borderColor = props.color;
356
+ style.borderWidth = "1px";
357
+ style.borderStyle = "solid";
334
358
  }
335
359
  } else {
336
360
  // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
337
- // style.color = plain.value ? textColor : "";
361
+ // style.color = props.plain ? textColor : "";
338
362
  }
339
- return style
340
- })
363
+ return style;
364
+ });
341
365
 
342
366
  // nvue版本按钮的字体不会继承父组件的颜色,需要对每一个text组件进行单独的设置
343
367
  const nvueTextStyle = computed((): CSSProperties => {
344
- let style: CSSProperties = {}
368
+ let style: CSSProperties = {};
345
369
  // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
346
- if (type.value === 'info') {
347
- style.color = '#323233'
370
+ if (props.type === "info") {
371
+ style.color = "#323233";
348
372
  }
349
- if (color.value) {
350
- style.color = plain.value ? color.value : 'white'
373
+ if (props.color) {
374
+ style.color = props.plain ? props.color : "white";
351
375
  }
352
- style.fontSize = textSize.value + 'px'
353
- return style
354
- })
376
+ style.fontSize = textSize.value + "px";
377
+ return style;
378
+ });
355
379
  /**
356
380
  * @description 字体大小
357
381
  * */
358
382
  const textSize = computed((): number => {
359
- let fontSize = 14
360
- if (size.value === 'large') fontSize = 16
361
- if (size.value === 'medium') fontSize = 14
362
- if (size.value === 'small') fontSize = 12
363
- if (size.value === 'mini') fontSize = 10
364
- return fontSize
365
- })
383
+ let fontSize = 14;
384
+ if (props.size === "large") fontSize = 16;
385
+ if (props.size === "medium") fontSize = 14;
386
+ if (props.size === "small") fontSize = 12;
387
+ if (props.size === "mini") fontSize = 10;
388
+ return fontSize;
389
+ });
366
390
 
367
391
  const clickHandler = (e: any) => {
368
392
  // 非禁止并且非加载中,才能点击
369
- if (!disabled.value && !loading.value) {
393
+ if (!props.disabled && !props.loading) {
370
394
  // 进行节流控制,每this.throttle毫秒内,只在开始处执行
371
395
  throttle(() => {
372
- emit('click', e)
373
- }, throttleTime.value)
396
+ emit("click", e);
397
+ }, props.throttleTime);
374
398
  }
375
399
  // 是否阻止事件传播
376
- stop.value && e.stopPropagation()
377
- }
400
+ props.stop && e.stopPropagation();
401
+ };
378
402
 
379
403
  const getphonenumber = (e: any) => {
380
- emit('getphonenumber', e)
381
- }
404
+ emit("getphonenumber", e);
405
+ };
382
406
  const getuserinfo = (e: any) => {
383
- emit('getuserinfo', e)
384
- }
407
+ emit("getuserinfo", e);
408
+ };
385
409
  const error = (e: any) => {
386
- emit('error', e)
387
- }
410
+ emit("error", e);
411
+ };
388
412
  const opensetting = (e: any) => {
389
- emit('opensetting', e)
390
- }
413
+ emit("opensetting", e);
414
+ };
391
415
  const launchapp = (e: any) => {
392
- emit('launchapp', e)
393
- }
416
+ emit("launchapp", e);
417
+ };
394
418
  const agreeprivacyauthorization = (e: any) => {
395
- emit('agreeprivacyauthorization', e)
396
- }
419
+ emit("agreeprivacyauthorization", e);
420
+ };
397
421
  </script>
398
422
 
399
423
  <style lang="scss" scoped>
400
- @import './index.scss';
424
+ @import "./index.scss";
401
425
  </style>