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
@@ -16,26 +16,26 @@
16
16
 
17
17
  <script lang="ts">
18
18
  export default {
19
- name: 'hy-count-to',
19
+ name: "hy-count-to",
20
20
  options: {
21
21
  addGlobalClass: true,
22
22
  virtualHost: true,
23
- styleIsolation: 'shared',
23
+ styleIsolation: "shared",
24
24
  },
25
- }
25
+ };
26
26
  </script>
27
27
 
28
28
  <script setup lang="ts">
29
- import type { ICountToEmits } from './typing'
30
- import { computed, onMounted, ref, toRefs, watch } from 'vue'
31
- import type { CSSProperties, PropType } from 'vue'
32
- import { addUnit, isNumber } from '../../utils'
29
+ import type { ICountToEmits } from "./typing";
30
+ import { computed, onMounted, ref, watch } from "vue";
31
+ import type { CSSProperties, PropType } from "vue";
32
+ import { addUnit, isNumber } from "../../utils";
33
33
 
34
34
  /**
35
35
  * 一般用于需要滚动数字到某一个值的场景,目标要求是一个递增的值。
36
36
  * @displayName hy-count-to
37
37
  */
38
- defineOptions({})
38
+ defineOptions({});
39
39
 
40
40
  // const props = withDefaults(defineProps<IProps>(), defaultProps);
41
41
  const props = defineProps({
@@ -73,7 +73,7 @@ const props = defineProps({
73
73
  /** 十进制分割 */
74
74
  decimal: {
75
75
  type: String,
76
- default: '.',
76
+ default: ".",
77
77
  },
78
78
  /** 字体颜色 */
79
79
  color: String,
@@ -95,183 +95,189 @@ const props = defineProps({
95
95
  },
96
96
  /** 自定义外部类名 */
97
97
  customClass: String,
98
- })
99
- const { startVal, duration, endVal, autoplay, separator, useEasing, decimals, decimal } =
100
- toRefs(props)
101
- const emit = defineEmits<ICountToEmits>()
98
+ });
99
+ const emit = defineEmits<ICountToEmits>();
102
100
 
103
101
  const formatNumber = (num: number): string => {
104
- let numStr = ''
102
+ let numStr;
105
103
  // 将num转为Number类型,因为其值可能为字符串数值,调用toFixed会报错
106
- num = Number(num)
107
- numStr = num.toFixed(Number(decimals.value))
108
- numStr += ''
109
- const x = numStr.split('.')
110
- let x1 = x[0]
111
- const x2 = x.length > 1 ? decimal.value + x[1] : ''
112
- const rgx = /(\d+)(\d{3})/
113
- if (separator.value && !isNumber(separator.value)) {
104
+ num = Number(num);
105
+ numStr = num.toFixed(Number(props.decimals));
106
+ numStr += "";
107
+ const x = numStr.split(".");
108
+ let x1 = x[0];
109
+ const x2 = x.length > 1 ? props.decimal + x[1] : "";
110
+ const rgx = /(\d+)(\d{3})/;
111
+ if (props.separator && !isNumber(props.separator)) {
114
112
  while (rgx.test(x1)) {
115
- x1 = x1.replace(rgx, '$1' + separator.value + '$2')
113
+ x1 = x1.replace(rgx, "$1" + props.separator + "$2");
116
114
  }
117
115
  }
118
- return x1 + x2
119
- }
116
+ return x1 + x2;
117
+ };
120
118
 
121
- const localStartVal = ref(startVal.value)
122
- let displayValue = ref(formatNumber(startVal.value))
123
- const printVal = ref<number | null>(null)
124
- const paused = ref(false) // 是否暂停
125
- const localDuration = ref(Number(duration.value))
126
- const startTime = ref<number | null>(null) // 开始的时间
127
- const timestamp = ref<number | null>(null) // 时间戳
128
- const remaining = ref<number | null>(null) // 停留的时间
129
- const rAF = ref<number>() // 停留的时间
130
- const lastTime = ref(0) // 上一次的时间
119
+ const localStartVal = ref(props.startVal);
120
+ let displayValue = ref(formatNumber(props.startVal));
121
+ const printVal = ref<number | null>(null);
122
+ const paused = ref(false); // 是否暂停
123
+ const localDuration = ref(Number(props.duration));
124
+ const startTime = ref<number | null>(null); // 开始的时间
125
+ const timestamp = ref<number | null>(null); // 时间戳
126
+ const remaining = ref<number | null>(null); // 停留的时间
127
+ const rAF = ref<number>(); // 停留的时间
128
+ const lastTime = ref(0); // 上一次的时间
131
129
 
132
130
  const countDown = computed(() => {
133
- return startVal.value > endVal.value
134
- })
131
+ return props.startVal > props.endVal;
132
+ });
135
133
 
136
134
  watch(
137
- () => startVal.value,
138
- () => autoplay.value && start(),
139
- )
135
+ () => props.startVal,
136
+ () => props.autoplay && start(),
137
+ );
140
138
 
141
139
  watch(
142
- () => endVal.value,
143
- () => autoplay.value && start(),
144
- )
140
+ () => props.endVal,
141
+ () => props.autoplay && start(),
142
+ );
145
143
 
146
144
  onMounted(() => {
147
- autoplay.value && start()
148
- })
145
+ props.autoplay && start();
146
+ });
149
147
 
150
148
  const easingFn = (t: number, b: number, c: number, d: number) => {
151
- return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b
152
- }
149
+ return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b;
150
+ };
153
151
 
154
152
  const requestAnimationFrame = (callback: Function): number => {
155
- const currTime = new Date().getTime()
153
+ const currTime = new Date().getTime();
156
154
  // 为了使setTimteout的尽可能的接近每秒60帧的效果
157
- const timeToCall = Math.max(0, 16 - (currTime - lastTime.value))
155
+ const timeToCall = Math.max(0, 16 - (currTime - lastTime.value));
158
156
  const id = setTimeout(() => {
159
- callback(currTime + timeToCall)
160
- }, timeToCall) as unknown as number
161
- lastTime.value = currTime + timeToCall
162
- return id
163
- }
157
+ callback(currTime + timeToCall);
158
+ }, timeToCall) as unknown as number;
159
+ lastTime.value = currTime + timeToCall;
160
+ return id;
161
+ };
164
162
 
165
163
  const cancelAnimationFrame = (id?: number) => {
166
- clearTimeout(id)
167
- }
164
+ clearTimeout(id);
165
+ };
168
166
 
169
167
  /**
170
168
  * @description 开始滚动数字
171
169
  * */
172
170
  const start = () => {
173
- localStartVal.value = startVal.value
174
- startTime.value = null
175
- localDuration.value = duration.value
176
- paused.value = false
177
- rAF.value = requestAnimationFrame(count)
178
- }
171
+ localStartVal.value = props.startVal;
172
+ startTime.value = null;
173
+ localDuration.value = props.duration;
174
+ paused.value = false;
175
+ rAF.value = requestAnimationFrame(count);
176
+ };
179
177
 
180
178
  /**
181
179
  * @description 暂定状态,重新再开始滚动;或者滚动状态下,暂停
182
180
  * */
183
181
  const reStart = () => {
184
182
  if (paused.value) {
185
- resume()
186
- paused.value = false
183
+ resume();
184
+ paused.value = false;
187
185
  } else {
188
- stop()
189
- paused.value = true
186
+ stop();
187
+ paused.value = true;
190
188
  }
191
- }
189
+ };
192
190
 
193
191
  /**
194
192
  * @description 暂停
195
193
  * */
196
194
  const stop = () => {
197
- cancelAnimationFrame(rAF.value)
198
- }
195
+ cancelAnimationFrame(rAF.value);
196
+ };
199
197
 
200
198
  /**
201
199
  * @description 重新开始(暂停的情况下)
202
200
  * */
203
201
  const resume = () => {
204
- if (!remaining.value) return
205
- startTime.value = 0
206
- localDuration.value = remaining.value
202
+ if (!remaining.value) return;
203
+ startTime.value = 0;
204
+ localDuration.value = remaining.value;
207
205
  if (printVal.value) {
208
- localStartVal.value = printVal.value
206
+ localStartVal.value = printVal.value;
209
207
  }
210
- requestAnimationFrame(count)
211
- }
208
+ requestAnimationFrame(count);
209
+ };
212
210
 
213
211
  /**
214
212
  * @description 重置
215
213
  * */
216
214
  const reset = () => {
217
- startTime.value = null
218
- cancelAnimationFrame(rAF.value)
219
- displayValue.value = formatNumber(startVal.value)
220
- }
215
+ startTime.value = null;
216
+ cancelAnimationFrame(rAF.value);
217
+ displayValue.value = formatNumber(props.startVal);
218
+ };
221
219
  const count = (time_stamp: number) => {
222
- if (!startTime.value) startTime.value = time_stamp
223
- timestamp.value = time_stamp
224
- const progress = time_stamp - startTime.value
225
- remaining.value = localDuration.value - progress
226
- if (useEasing.value) {
220
+ if (!startTime.value) startTime.value = time_stamp;
221
+ timestamp.value = time_stamp;
222
+ const progress = time_stamp - startTime.value;
223
+ remaining.value = localDuration.value - progress;
224
+ if (props.useEasing) {
227
225
  if (countDown.value) {
228
226
  printVal.value =
229
227
  localStartVal.value -
230
- easingFn(progress, 0, localStartVal.value - endVal.value, localDuration.value)
228
+ easingFn(
229
+ progress,
230
+ 0,
231
+ localStartVal.value - props.endVal,
232
+ localDuration.value,
233
+ );
231
234
  } else {
232
235
  printVal.value = easingFn(
233
236
  progress,
234
237
  localStartVal.value,
235
- endVal.value - localStartVal.value,
238
+ props.endVal - localStartVal.value,
236
239
  localDuration.value,
237
- )
240
+ );
238
241
  }
239
242
  } else {
240
243
  if (countDown.value) {
241
244
  printVal.value =
242
245
  localStartVal.value -
243
- (localStartVal.value - endVal.value) * (progress / localDuration.value)
246
+ (localStartVal.value - props.endVal) * (progress / localDuration.value);
244
247
  } else {
245
248
  printVal.value =
246
249
  localStartVal.value +
247
- (endVal.value - localStartVal.value) * (progress / localDuration.value)
250
+ (props.endVal - localStartVal.value) * (progress / localDuration.value);
248
251
  }
249
252
  }
250
253
  if (countDown.value) {
251
- printVal.value = printVal.value < endVal.value ? endVal.value : printVal.value
254
+ printVal.value =
255
+ printVal.value < props.endVal ? props.endVal : printVal.value;
252
256
  } else {
253
- printVal.value = printVal.value > endVal.value ? endVal.value : printVal.value
257
+ printVal.value =
258
+ printVal.value > props.endVal ? props.endVal : printVal.value;
254
259
  }
255
- displayValue.value = formatNumber(printVal.value)
260
+ displayValue.value = formatNumber(printVal.value);
256
261
  if (progress < localDuration.value) {
257
- rAF.value = requestAnimationFrame(count)
262
+ rAF.value = requestAnimationFrame(count);
258
263
  } else {
259
- emit('end')
264
+ emit("end");
260
265
  }
261
- }
266
+ };
262
267
 
263
268
  const destroyed = () => {
264
- cancelAnimationFrame(rAF.value)
265
- }
269
+ cancelAnimationFrame(rAF.value);
270
+ };
266
271
 
267
272
  defineExpose({
268
273
  start,
269
274
  stop,
270
275
  reStart,
271
276
  resume,
272
- })
277
+ reset,
278
+ });
273
279
  </script>
274
280
 
275
281
  <style scoped lang="scss">
276
- @import './index.scss';
282
+ @import "./index.scss";
277
283
  </style>
@@ -2,49 +2,50 @@ export default interface HyCountToProps {
2
2
  /**
3
3
  * @description 开始的数值,默认从0增长到某一个数(默认 0 )
4
4
  * */
5
- startVal?: number
5
+ startVal?: number;
6
6
  /**
7
7
  * @description 要滚动的目标数值,必须 (默认 0 )
8
8
  * */
9
- endVal: number
9
+ endVal: number;
10
10
  /**
11
11
  * @description 滚动到目标数值的动画持续时间,单位为毫秒(ms) (默认
12
12
  * */
13
- duration?: number
13
+ duration?: number;
14
14
  /**
15
15
  * @description 设置数值后是否自动开始滚动 (默认 true )
16
16
  * */
17
- autoplay?: boolean
17
+ autoplay?: boolean;
18
18
  /**
19
19
  * @description 要显示的小数位数,见官网说明(默认 0 )
20
20
  * */
21
- decimals?: number
21
+ decimals?: number;
22
22
  /**
23
23
  * @description 滚动结束时,是否缓动结尾,见官网说明(默认 true )
24
24
  * */
25
- useEasing?: boolean
25
+ useEasing?: boolean;
26
26
  /**
27
27
  * @description 十进制分割 ( 默认 "." )
28
28
  * */
29
- decimal?: string
29
+ decimal?: string;
30
30
  /**
31
31
  * @description 字体颜色( 默认 '#606266' )
32
32
  * */
33
- color?: string
33
+ color?: string;
34
34
  /**
35
35
  * @description 字体大小,单位px( 默认 22 )
36
36
  * */
37
- fontSize?: number | string
37
+ fontSize?: number | string;
38
38
  /**
39
39
  * @description 字体是否加粗(默认 false )
40
40
  * */
41
- bold?: boolean
41
+ bold?: boolean;
42
42
  /**
43
43
  * @description 千位分隔符,见官网说明
44
44
  * */
45
- separator?: string
45
+ separator?: string;
46
46
  }
47
47
 
48
48
  export interface ICountToEmits {
49
- (e: 'end'): void
49
+ /** 结束执行函数 */
50
+ (e: "end"): void;
50
51
  }