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
@@ -2,7 +2,7 @@
2
2
  <!--注意阻止横向滑动的穿透:横向移动时阻止冒泡-->
3
3
  <view
4
4
  class="hy-swipe-action"
5
- @click.stop="onClick()"
5
+ @click.stop="onClick"
6
6
  @touchstart="startDrag"
7
7
  @touchmove="onDrag"
8
8
  @touchend="endDrag"
@@ -11,19 +11,30 @@
11
11
  <!--容器-->
12
12
  <view class="hy-swipe-action--wrapper" :style="wrapperStyle">
13
13
  <!--左侧操作-->
14
- <view :class="['hy-swipe-action--left', leftClass]" @click="onClick('left')">
14
+ <view
15
+ :class="['hy-swipe-action--left', leftClass]"
16
+ @click="onClick('left')"
17
+ >
15
18
  <slot name="left" />
16
19
  </view>
17
20
  <!--左侧操作-->
18
21
 
19
22
  <!--内容-->
20
- <view :class="['hy-swipe-action--center', borderBottom && 'hy-border__bottom']">
23
+ <view
24
+ :class="[
25
+ 'hy-swipe-action--center',
26
+ borderBottom && 'hy-border__bottom',
27
+ ]"
28
+ >
21
29
  <slot></slot>
22
30
  </view>
23
31
  <!--内容-->
24
32
 
25
33
  <!--右侧操作-->
26
- <view :class="['hy-swipe-action--right', rightClass]" @click="onClick('right')">
34
+ <view
35
+ :class="['hy-swipe-action--right', rightClass]"
36
+ @click="onClick('right')"
37
+ >
27
38
  <slot name="right">
28
39
  <view v-if="!slots.left" class="hy-swipe-action--right__action">
29
40
  <view
@@ -44,13 +55,13 @@
44
55
 
45
56
  <script lang="ts">
46
57
  export default {
47
- name: 'hy-swipe-action',
58
+ name: "hy-swipe-action",
48
59
  options: {
49
60
  addGlobalClass: true,
50
61
  virtualHost: true,
51
- styleIsolation: 'shared',
62
+ styleIsolation: "shared",
52
63
  },
53
- }
64
+ };
54
65
  </script>
55
66
  <script lang="ts" setup>
56
67
  import {
@@ -61,24 +72,24 @@ import {
61
72
  ref,
62
73
  watch,
63
74
  useSlots,
64
- type PropType,
65
- } from 'vue'
75
+ } from "vue";
76
+ import type { PropType } from "vue";
66
77
  import type {
67
78
  ISwipeActionEmits,
68
79
  SwipeActionStatus,
69
80
  SwipeActionPosition,
70
81
  SwipeActionReason,
71
82
  SwipeActionOptionsVo,
72
- } from './typing'
73
- import { useTouch } from '../../composables'
74
- import { closeOther, pushToQueue, removeFromQueue } from './index'
75
- import { getRect, guid } from '../../utils'
83
+ } from "./typing";
84
+ import { useTouch } from "../../composables";
85
+ import { closeOther, pushToQueue, removeFromQueue } from "./index";
86
+ import { getRect, guid } from "../../utils";
76
87
 
77
88
  /**
78
89
  * 常用于单元格左右滑删除等手势操作。
79
90
  * @displayName hy-swipe-action
80
91
  */
81
- defineOptions({})
92
+ defineOptions({});
82
93
 
83
94
  // const props = withDefaults(defineProps<IProps>(), defaultProps)
84
95
  const props = defineProps({
@@ -102,15 +113,15 @@ const props = defineProps({
102
113
  type: Array as unknown as PropType<SwipeActionOptionsVo[]>,
103
114
  default: () => [
104
115
  {
105
- text: '收藏',
116
+ text: "收藏",
106
117
  style: {
107
- backgroundColor: '#3c9cff',
118
+ backgroundColor: "#3c9cff",
108
119
  },
109
120
  },
110
121
  {
111
- text: '删除',
122
+ text: "删除",
112
123
  style: {
113
- backgroundColor: '#f56c6c',
124
+ backgroundColor: "#f56c6c",
114
125
  },
115
126
  },
116
127
  ],
@@ -122,74 +133,74 @@ const props = defineProps({
122
133
  },
123
134
  /** 关闭滑动按钮前的钩子函数 */
124
135
  beforeClose: Function,
125
- })
126
- const emit = defineEmits<ISwipeActionEmits>()
127
- const leftClass = `hy-swipe-action--left--${guid()}`
128
- const rightClass = `hy-swipe-action--right--${guid()}`
136
+ });
137
+ const emit = defineEmits<ISwipeActionEmits>();
138
+ const leftClass = `hy-swipe-action--left--${guid()}`;
139
+ const rightClass = `hy-swipe-action--right--${guid()}`;
129
140
 
130
- const slots = useSlots()
131
- const wrapperStyle = ref<string>('')
141
+ const slots = useSlots();
142
+ const wrapperStyle = ref<string>("");
132
143
 
133
144
  // 滑动开始时,wrapper的偏移量
134
- const originOffset = ref<number>(0)
145
+ const originOffset = ref<number>(0);
135
146
  // wrapper现在的偏移量
136
- const wrapperOffset = ref<number>(0)
147
+ const wrapperOffset = ref<number>(0);
137
148
  // 是否处于滑动状态
138
- const touching = ref<boolean>(false)
149
+ const touching = ref<boolean>(false);
139
150
 
140
- const touch = useTouch()
151
+ const touch = useTouch();
141
152
 
142
- const { proxy } = getCurrentInstance() as any
153
+ const { proxy } = getCurrentInstance() as any;
143
154
 
144
155
  watch(
145
156
  () => props.modelValue,
146
- (value, old) => {
147
- changeState(value, old)
157
+ (newVal, oldVal) => {
158
+ changeState(newVal, oldVal);
148
159
  },
149
160
  {
150
161
  deep: true,
151
162
  },
152
- )
163
+ );
153
164
 
154
165
  onBeforeMount(() => {
155
- pushToQueue(proxy)
166
+ pushToQueue(proxy);
156
167
  // 滑动开始时,wrapper的偏移量
157
- originOffset.value = 0
168
+ originOffset.value = 0;
158
169
  // wrapper现在的偏移量
159
- wrapperOffset.value = 0
170
+ wrapperOffset.value = 0;
160
171
  // 是否处于滑动状态
161
- touching.value = false
162
- })
172
+ touching.value = false;
173
+ });
163
174
 
164
175
  onMounted(() => {
165
- touching.value = true
166
- changeState(props.modelValue)
167
- touching.value = false
168
- })
176
+ touching.value = true;
177
+ changeState(props.modelValue);
178
+ touching.value = false;
179
+ });
169
180
 
170
181
  onBeforeUnmount(() => {
171
- removeFromQueue(proxy)
172
- })
182
+ removeFromQueue(proxy);
183
+ });
173
184
 
174
- function changeState(value: SwipeActionStatus, old?: SwipeActionStatus) {
185
+ function changeState(value?: SwipeActionStatus, old?: SwipeActionStatus) {
175
186
  if (props.disabled) {
176
- return
187
+ return;
177
188
  }
178
189
  getWidths().then(([leftWidth, rightWidth]) => {
179
190
  switch (value) {
180
- case 'close':
191
+ case "close":
181
192
  // 调用此函数时,偏移量本就是0
182
- if (wrapperOffset.value === 0) return
183
- close('value', old)
184
- break
185
- case 'left':
186
- swipeMove(leftWidth)
187
- break
188
- case 'right':
189
- swipeMove(-rightWidth)
190
- break
193
+ if (wrapperOffset.value === 0) return;
194
+ close("value", old);
195
+ break;
196
+ case "left":
197
+ swipeMove(leftWidth);
198
+ break;
199
+ case "right":
200
+ swipeMove(-rightWidth);
201
+ break;
191
202
  }
192
- })
203
+ });
193
204
  }
194
205
 
195
206
  /**
@@ -198,31 +209,33 @@ function changeState(value: SwipeActionStatus, old?: SwipeActionStatus) {
198
209
  */
199
210
  const getWidths = (): Promise<number[]> => {
200
211
  return Promise.all([
201
- getRect('.' + leftClass, false, proxy).then((rect) => {
202
- return rect.width ? rect.width : 0
212
+ getRect("." + leftClass, false, proxy).then((rect) => {
213
+ return rect.width ? rect.width : 0;
203
214
  }),
204
- getRect('.' + rightClass, false, proxy).then((rect) => {
205
- return rect.width ? rect.width : 0
215
+ getRect("." + rightClass, false, proxy).then((rect) => {
216
+ return rect.width ? rect.width : 0;
206
217
  }),
207
- ])
208
- }
218
+ ]);
219
+ };
209
220
  /**
210
221
  * @description wrapper滑动函数
211
222
  * @param {Number} offset 滑动漂移量
212
223
  */
213
224
  function swipeMove(offset = 0) {
214
225
  // this.offset = offset
215
- const transform = `translate3d(${offset}px, 0, 0)`
226
+ const transform = `translate3d(${offset}px, 0, 0)`;
216
227
  // 跟随手指滑动,不需要动画
217
- const transition = touching.value ? 'none' : '.6s cubic-bezier(0.18, 0.89, 0.32, 1)'
228
+ const transition = touching.value
229
+ ? "none"
230
+ : ".6s cubic-bezier(0.18, 0.89, 0.32, 1)";
218
231
  wrapperStyle.value = `
219
232
  -webkit-transform: ${transform};
220
233
  -webkit-transition: ${transition};
221
234
  transform: ${transform};
222
235
  transition: ${transition};
223
- `
236
+ `;
224
237
  // 记录容器当前偏移的量
225
- wrapperOffset.value = offset
238
+ wrapperOffset.value = offset;
226
239
  }
227
240
  /**
228
241
  * @description click的handler
@@ -230,67 +243,67 @@ function swipeMove(offset = 0) {
230
243
  */
231
244
  function onClick(position?: SwipeActionPosition) {
232
245
  if (props.disabled || wrapperOffset.value === 0) {
233
- return
246
+ return;
234
247
  }
235
248
 
236
- position = position || 'inside'
237
- close('click', position)
238
- emit('click', position)
249
+ position = position || "inside";
250
+ close("click", position);
251
+ emit("click", position);
239
252
  }
240
253
  /**
241
254
  * @description 开始滑动
242
255
  */
243
256
  function startDrag(event: TouchEvent) {
244
- if (props.disabled) return
257
+ if (props.disabled) return;
245
258
 
246
- originOffset.value = wrapperOffset.value
247
- touch.touchStart(event)
248
- closeOther(proxy)
259
+ originOffset.value = wrapperOffset.value;
260
+ touch.touchStart(event);
261
+ closeOther(proxy);
249
262
  }
250
263
  /**
251
264
  * @description 滑动时,逐渐展示按钮
252
265
  * @param event
253
266
  */
254
267
  function onDrag(event: TouchEvent) {
255
- if (props.disabled) return
268
+ if (props.disabled) return;
256
269
 
257
- touch.touchMove(event)
258
- if (touch.direction.value === 'vertical') {
259
- return
270
+ touch.touchMove(event);
271
+ if (touch.direction.value === "vertical") {
272
+ return;
260
273
  } else {
261
- event.preventDefault()
262
- event.stopPropagation()
274
+ event.preventDefault();
275
+ event.stopPropagation();
263
276
  }
264
277
 
265
- touching.value = true
278
+ touching.value = true;
266
279
 
267
280
  // 本次滑动,wrapper应该设置的偏移量
268
- const offset = originOffset.value + touch.deltaX.value
281
+ const offset = originOffset.value + touch.deltaX.value;
269
282
  getWidths().then(([leftWidth, rightWidth]) => {
270
283
  // 如果需要想滑出来的按钮不存在,对应的按钮肯定滑不出来,容器处于初始状态。此时需要模拟一下位于此处的start事件。
271
284
  if ((leftWidth === 0 && offset > 0) || (rightWidth === 0 && offset < 0)) {
272
- swipeMove(0)
273
- return startDrag(event)
285
+ swipeMove(0);
286
+ return startDrag(event);
274
287
  }
275
288
  // 按钮已经展示完了,再滑动没有任何意义,相当于滑动结束。此时需要模拟一下位于此处的start事件。
276
289
  if (leftWidth !== 0 && offset >= leftWidth) {
277
- swipeMove(leftWidth)
278
- return startDrag(event)
290
+ swipeMove(leftWidth);
291
+ return startDrag(event);
279
292
  } else if (rightWidth !== 0 && -offset >= rightWidth) {
280
- swipeMove(-rightWidth)
281
- return startDrag(event)
293
+ swipeMove(-rightWidth);
294
+ return startDrag(event);
282
295
  }
283
- swipeMove(offset)
284
- })
296
+ swipeMove(offset);
297
+ });
285
298
  }
286
299
  /**
287
300
  * @description 滑动结束,自动修正位置
288
301
  */
289
302
  function endDrag() {
290
- if (props.disabled) return
303
+ if (props.disabled) return;
291
304
  // 滑出"操作按钮"的阈值
292
- const THRESHOLD = 0.3
293
- touching.value = false
305
+ const THRESHOLD = 0.3;
306
+ touching.value = false;
294
307
 
295
308
  getWidths().then(([leftWidth, rightWidth]) => {
296
309
  if (
@@ -298,69 +311,69 @@ function endDrag() {
298
311
  wrapperOffset.value < 0 && // 目前仍然是右按钮
299
312
  wrapperOffset.value - originOffset.value < rightWidth * THRESHOLD // 并且滑动的范围不超过右边框阀值
300
313
  ) {
301
- swipeMove(-rightWidth) // 回归右按钮
302
- emit('update:modelValue', 'right')
314
+ swipeMove(-rightWidth); // 回归右按钮
315
+ emit("update:modelValue", "right");
303
316
  } else if (
304
317
  originOffset.value > 0 && // 之前展示的是左按钮
305
318
  wrapperOffset.value > 0 && // 现在仍然是左按钮
306
319
  originOffset.value - wrapperOffset.value < leftWidth * THRESHOLD // 并且滑动的范围不超过左按钮阀值
307
320
  ) {
308
- swipeMove(leftWidth) // 回归左按钮
309
- emit('update:modelValue', 'left')
321
+ swipeMove(leftWidth); // 回归左按钮
322
+ emit("update:modelValue", "left");
310
323
  } else if (
311
324
  rightWidth > 0 &&
312
325
  originOffset.value >= 0 && // 之前是初始状态或者展示左按钮显
313
326
  wrapperOffset.value < 0 && // 现在展示右按钮
314
327
  Math.abs(wrapperOffset.value) > rightWidth * THRESHOLD // 视图中已经展示的右按钮长度超过阀值
315
328
  ) {
316
- swipeMove(-rightWidth)
317
- emit('update:modelValue', 'right')
329
+ swipeMove(-rightWidth);
330
+ emit("update:modelValue", "right");
318
331
  } else if (
319
332
  leftWidth > 0 &&
320
333
  originOffset.value <= 0 && // 之前初始状态或者右按钮显示
321
334
  wrapperOffset.value > 0 && // 现在左按钮
322
335
  Math.abs(wrapperOffset.value) > leftWidth * THRESHOLD // 视图中已经展示的左按钮长度超过阀值
323
336
  ) {
324
- swipeMove(leftWidth)
325
- emit('update:modelValue', 'left')
337
+ swipeMove(leftWidth);
338
+ emit("update:modelValue", "left");
326
339
  } else {
327
340
  // 回归初始状态
328
- close('swipe')
341
+ close("swipe");
329
342
  }
330
- })
343
+ });
331
344
  }
332
345
  /**
333
346
  * @description 关闭操过按钮,并在合适的时候调用 beforeClose
334
347
  */
335
348
  function close(reason: SwipeActionReason, position?: SwipeActionPosition) {
336
- if (reason === 'swipe' && originOffset.value === 0) {
349
+ if (reason === "swipe" && originOffset.value === 0) {
337
350
  // offset:0 ——> offset:0
338
- return swipeMove(0)
339
- } else if (reason === 'swipe' && originOffset.value > 0) {
351
+ return swipeMove(0);
352
+ } else if (reason === "swipe" && originOffset.value > 0) {
340
353
  // offset > 0 ——> offset:0
341
- position = 'left'
342
- } else if (reason === 'swipe' && originOffset.value < 0) {
354
+ position = "left";
355
+ } else if (reason === "swipe" && originOffset.value < 0) {
343
356
  // offset < 0 ——> offset:0
344
- position = 'right'
357
+ position = "right";
345
358
  }
346
359
 
347
360
  if (reason && position) {
348
- props.beforeClose && props.beforeClose(reason, position)
361
+ props.beforeClose && props.beforeClose(reason, position);
349
362
  }
350
363
 
351
- swipeMove(0)
352
- if (props.modelValue !== 'close') {
353
- emit('update:modelValue', 'close')
364
+ swipeMove(0);
365
+ if (props.modelValue !== "close") {
366
+ emit("update:modelValue", "close");
354
367
  }
355
368
  }
356
369
 
357
370
  const onActiveClick = (item: any, index: number) => {
358
- close('click', 'right')
359
- emit('clickAction', item, index)
360
- }
371
+ close("click", "right");
372
+ emit("clickAction", item, index);
373
+ };
361
374
 
362
- defineExpose({ close })
375
+ defineExpose({ close });
363
376
  </script>
364
377
  <style lang="scss" scoped>
365
- @import './index.scss';
378
+ @import "./index.scss";
366
379
  </style>