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
@@ -95,48 +95,57 @@
95
95
 
96
96
  <script lang="ts">
97
97
  export default {
98
- name: 'hy-search',
98
+ name: "hy-search",
99
99
  options: {
100
100
  addGlobalClass: true,
101
101
  virtualHost: true,
102
- styleIsolation: 'shared',
102
+ styleIsolation: "shared",
103
103
  },
104
- }
104
+ };
105
105
  </script>
106
106
 
107
107
  <script setup lang="ts">
108
- import { computed, nextTick, toRefs, ref, watch } from 'vue'
109
- import type { PropType, CSSProperties } from 'vue'
110
- import type { ISearchEmits } from './typing'
111
- import { sleep, addUnit } from '../../utils'
112
- import { IconConfig } from '../../config'
113
- import HyIcon from '../hy-icon/hy-icon.vue'
114
- import type HyIconProps from '../hy-icon/typing'
108
+ import { computed, nextTick, ref, watch } from "vue";
109
+ import type { PropType, CSSProperties } from "vue";
110
+ import type { ISearchEmits } from "./typing";
111
+ import { sleep, addUnit } from "../../utils";
112
+ import { IconConfig } from "../../config";
113
+ import HyIcon from "../hy-icon/hy-icon.vue";
114
+ import type HyIconProps from "../hy-icon/typing";
115
+ import type {
116
+ InputOnBlurEvent,
117
+ InputOnConfirmEvent,
118
+ InputOnFocusEvent,
119
+ InputOnInputEvent,
120
+ } from "@uni-helper/uni-types";
115
121
 
116
122
  /**
117
123
  * 搜索组件,集成了常见搜索框所需功能,用户可以一键引入,开箱即用。
118
124
  * @displayName hy-search
119
125
  */
120
- defineOptions({})
126
+ defineOptions({});
121
127
 
122
128
  // const props = withDefaults(defineProps<IProps>(), defaultProps)
123
129
  const props = defineProps({
124
130
  /** 输入框初始值 */
125
- modelValue: String,
131
+ modelValue: {
132
+ type: String,
133
+ default: "",
134
+ },
126
135
  /**
127
136
  * 搜索框形状
128
137
  * @values circle,square
129
138
  * */
130
139
  shape: {
131
140
  type: String,
132
- default: 'circle',
141
+ default: "circle",
133
142
  },
134
143
  /** 搜索框背景颜色 */
135
144
  bgColor: String,
136
145
  /** 占位文字内容 */
137
146
  placeholder: {
138
147
  type: String,
139
- default: '请输入关键字',
148
+ default: "请输入关键字",
140
149
  },
141
150
  /** 是否启用清除控件 */
142
151
  clear: {
@@ -156,7 +165,7 @@ const props = defineProps({
156
165
  /** 右侧控件文字 */
157
166
  actionText: {
158
167
  type: String,
159
- default: '搜索',
168
+ default: "搜索",
160
169
  },
161
170
  /** 右侧控件的样式,对象形式 */
162
171
  actionStyle: {
@@ -166,7 +175,7 @@ const props = defineProps({
166
175
  /** 输入框内容水平对齐方式 */
167
176
  inputAlign: {
168
177
  type: String,
169
- default: 'left',
178
+ default: "left",
170
179
  },
171
180
  /** 自定义输入框样式,对象形式 */
172
181
  inputStyle: {
@@ -181,14 +190,14 @@ const props = defineProps({
181
190
  /** 边框颜色,配置了颜色,才会有边框 */
182
191
  borderColor: {
183
192
  type: String,
184
- default: 'transparent',
193
+ default: "transparent",
185
194
  },
186
195
  /** 输入框字体颜色 */
187
196
  color: String,
188
197
  /** placeholder的颜色 */
189
198
  placeholderColor: {
190
199
  type: String,
191
- default: '#909399',
200
+ default: "#909399",
192
201
  },
193
202
  /** 输入框左边的图标属性集合,可以为图标名称或图片路径 */
194
203
  searchIcon: Object as PropType<HyIconProps>,
@@ -230,111 +239,109 @@ const props = defineProps({
230
239
  },
231
240
  /** 自定义外部类名 */
232
241
  customClass: String,
233
- })
234
- const { focus, modelValue, showAction, animation, disabled } = toRefs(props)
235
- const emit = defineEmits<ISearchEmits>()
242
+ });
243
+ const emit = defineEmits<ISearchEmits>();
236
244
 
237
- const keyword = ref<string>('')
238
- // 是否显示右边的清除图标
239
- const showClear = ref<boolean>(false)
240
- const show = ref<boolean>(false)
245
+ const keyword = ref<string>("");
246
+ // 显示右边搜索按钮
247
+ const show = ref<boolean>(false);
241
248
  // 标记input当前状态是否处于聚焦中,如果是,才会显示右侧的清除控件
242
- const focused = ref(focus.value)
249
+ const focused = ref(props.focus);
243
250
 
244
251
  watch(
245
252
  () => keyword.value,
246
253
  (newValue: string) => {
247
- emit('update:modelValue', newValue)
248
- emit('change', newValue)
254
+ emit("update:modelValue", newValue);
255
+ emit("change", newValue);
249
256
  },
250
- )
257
+ );
251
258
 
252
259
  watch(
253
- () => modelValue.value,
260
+ () => props.modelValue,
254
261
  (newValue: string) => {
255
- keyword.value = newValue
262
+ keyword.value = newValue;
256
263
  },
257
264
  { immediate: true },
258
- )
265
+ );
259
266
 
260
267
  const showActionBtn = computed<boolean>(() => {
261
- return !animation.value && showAction.value
262
- })
268
+ return !props.animation && props.showAction;
269
+ });
263
270
 
264
271
  /**
265
- * @description
272
+ * 值改变触发
266
273
  * */
267
- const inputChange = (e: Event) => {
268
- keyword.value = e.detail.value
269
- }
274
+ const inputChange = (e: InputOnInputEvent) => {
275
+ keyword.value = e.detail.value;
276
+ };
270
277
  /**
271
278
  * @description 清空输入
272
279
  * */
273
280
  const clear = () => {
274
- keyword.value = ''
281
+ keyword.value = "";
275
282
  // 延后发出事件,避免在父组件监听clear事件时,value为更新前的值(不为空)
276
283
  nextTick(() => {
277
- emit('clear')
278
- })
279
- }
284
+ emit("clear");
285
+ });
286
+ };
280
287
  /**
281
288
  * @description 确定搜索
282
289
  * */
283
- const search = (e: InputEvent) => {
284
- emit('search', e.detail.value)
290
+ const search = (e: InputOnConfirmEvent) => {
291
+ emit("search", e, e.detail.value);
285
292
  try {
286
293
  // 收起键盘
287
- uni.hideKeyboard()
294
+ uni.hideKeyboard();
288
295
  } catch (e) {}
289
- }
296
+ };
290
297
  /**
291
298
  * @description 点击右边自定义按钮的事件
292
299
  */
293
300
  const confirm = () => {
294
- emit('confirm', keyword.value)
301
+ emit("confirm", keyword.value);
295
302
  try {
296
303
  // 收起键盘
297
- uni.hideKeyboard()
304
+ uni.hideKeyboard();
298
305
  } catch (e) {}
299
- }
306
+ };
300
307
  /**
301
308
  * @description 获取焦点
302
309
  * */
303
- const getFocus = () => {
304
- focused.value = true
310
+ const getFocus = (e: InputOnFocusEvent) => {
311
+ focused.value = true;
305
312
  // 开启右侧搜索按钮展开的动画效果
306
- if (animation.value && showAction.value) show.value = true
307
- emit('focus', keyword.value)
308
- }
313
+ if (props.animation && props.showAction) show.value = true;
314
+ emit("focus", e, keyword.value);
315
+ };
309
316
  /**
310
317
  * @description 失去焦点
311
318
  */
312
- const blur = async () => {
319
+ const blur = async (e: InputOnBlurEvent) => {
313
320
  // 最开始使用的是监听图标@touchstart事件,自从hx2.8.4后,此方法在微信小程序出错
314
321
  // 这里改为监听点击事件,手点击清除图标时,同时也发生了@blur事件,导致图标消失而无法点击,这里做一个延时
315
- show.value = false
316
- emit('blur', keyword.value)
317
- await sleep(100)
318
- focused.value = false
319
- }
322
+ show.value = false;
323
+ emit("blur", e, keyword.value);
324
+ await sleep(100);
325
+ focused.value = false;
326
+ };
320
327
  /**
321
328
  * @description 点击搜索框,只有disabled=true时才发出事件,因为禁止了输入,意味着是想跳转真正的搜索页
322
329
  * */
323
330
  const clickHandler = () => {
324
- if (disabled.value) emit('click')
325
- }
331
+ if (props.disabled) emit("click");
332
+ };
326
333
  /**
327
334
  * @description 点击左边图标
328
335
  * */
329
336
  const clickIcon = () => {
330
- emit('clickIcon', keyword.value)
337
+ emit("clickIcon", keyword.value);
331
338
  try {
332
339
  // 收起键盘
333
- uni.hideKeyboard()
340
+ uni.hideKeyboard();
334
341
  } catch (e) {}
335
- }
342
+ };
336
343
  </script>
337
344
 
338
345
  <style lang="scss" scoped>
339
- @import './index.scss';
346
+ @import "./index.scss";
340
347
  </style>
@@ -1,122 +1,123 @@
1
- import type { CSSProperties } from 'vue'
2
- import type HyIconProps from '../hy-icon/typing'
1
+ import type { CSSProperties } from "vue";
2
+ import type HyIconProps from "../hy-icon/typing";
3
+ import type { InputOnConfirmEvent } from "@uni-helper/uni-types";
3
4
 
4
5
  export default interface HySearchProps {
5
6
  /**
6
7
  * @description 输入框初始值
7
8
  * */
8
- modelValue: string
9
+ modelValue: string;
9
10
  /**
10
11
  * @description 搜索框形状,circle-圆形,square-方形(默认 'circle' )
11
12
  * */
12
- shape?: HyApp.ShapeType
13
+ shape?: HyApp.ShapeType;
13
14
  /**
14
15
  * @description 搜索框背景颜色(默认 '#f2f2f2' )
15
16
  * */
16
- bgColor?: string
17
+ bgColor?: string;
17
18
  /**
18
19
  * @description 占位文字内容(默认 '请输入关键字' )
19
20
  * */
20
- placeholder?: string
21
+ placeholder?: string;
21
22
  /**
22
23
  * @description 是否启用清除控件(默认 true )
23
24
  * */
24
- clear?: boolean
25
+ clear?: boolean;
25
26
  /**
26
27
  * @description 是否自动获得焦点(默认 false )
27
28
  * */
28
- focus?: boolean
29
+ focus?: boolean;
29
30
  /**
30
31
  * @description 是否显示右侧控件(默认 true )
31
32
  * */
32
- showAction?: boolean
33
+ showAction?: boolean;
33
34
  /**
34
35
  * @description 右侧控件的样式,对象形式
35
36
  * */
36
- actionStyle?: CSSProperties
37
+ actionStyle?: CSSProperties;
37
38
  /**
38
39
  * @description 右侧控件文字(默认 '搜索' )
39
40
  * */
40
- actionText?: string
41
+ actionText?: string;
41
42
  /**
42
43
  * @description 输入框内容水平对齐方式 (默认 'left' )
43
44
  * */
44
- inputAlign?: HyApp.RowCenterType
45
+ inputAlign?: HyApp.RowCenterType;
45
46
  /**
46
47
  * @description 自定义输入框样式,对象形式
47
48
  * */
48
- inputStyle?: CSSProperties
49
+ inputStyle?: CSSProperties;
49
50
  /**
50
51
  * @description 是否启用输入框(默认 false )
51
52
  * */
52
- disabled?: boolean
53
+ disabled?: boolean;
53
54
  /**
54
55
  * @description 边框颜色,配置了颜色,才会有边框 (默认 'transparent' )
55
56
  * */
56
- borderColor?: string
57
+ borderColor?: string;
57
58
  /**
58
59
  * @description 输入框字体颜色(默认 '#606266' )
59
60
  * */
60
- color?: string
61
+ color?: string;
61
62
  /**
62
63
  * @description placeholder的颜色(默认 '#909399' )
63
64
  * */
64
- placeholderColor?: string
65
+ placeholderColor?: string;
65
66
  /**
66
67
  * @description 输入框左边的图标属性集合,可以为图标名称或图片路径 (默认 'search' )
67
68
  * */
68
- searchIcon?: Partial<HyIconProps>
69
+ searchIcon?: Partial<HyIconProps>;
69
70
  /**
70
71
  * @description 组件与其他上下左右之间的距离,带单位的字符串形式,如"30px" (默认 '0' )
71
72
  * */
72
- margin?: string
73
+ margin?: string;
73
74
  /**
74
75
  * @description 是否开启动画,见上方说明(默认 false )
75
76
  * */
76
- animation?: boolean
77
+ animation?: boolean;
77
78
  /**
78
79
  * @description 输入框最大能输入的长度,-1为不限制长度 (默认 '-1' )
79
80
  * */
80
- maxlength?: string | number
81
+ maxlength?: string | number;
81
82
  /**
82
83
  * @description 输入框高度,单位px(默认 64 )
83
84
  * */
84
- height?: number
85
+ height?: number;
85
86
  /**
86
87
  * @description 搜索框左边显示内容
87
88
  * */
88
- label?: string | null
89
+ label?: string | null;
89
90
  /**
90
91
  * @description 键盘弹起时,是否自动上推页面
91
92
  * */
92
- adjustPosition?: boolean
93
+ adjustPosition?: boolean;
93
94
  /**
94
95
  * @description 键盘收起时,是否自动失去焦点
95
96
  * */
96
- autoBlur?: boolean
97
+ autoBlur?: boolean;
97
98
  /**
98
99
  * @description 定义需要用到的外部样式
99
100
  * */
100
- customStyle?: CSSProperties
101
+ customStyle?: CSSProperties;
101
102
  }
102
103
 
103
104
  export interface ISearchEmits {
104
105
  /** disabled为true时,点击输入框,发出此事件,用于跳转搜索页 */
105
- (e: 'click'): void
106
+ (e: "click"): void;
106
107
  /** 输入框内容发生变化时触发 */
107
- (e: 'change', value: string): void
108
+ (e: "change", value: string): void;
108
109
  /** 左侧icon点击时候时触发 */
109
- (e: 'clickIcon'): void
110
+ (e: "clickIcon", keyword: string): void;
110
111
  /** 用户确定搜索时触发,用户按回车键,或者手机键盘右下角的"搜索"键时触发 */
111
- (e: 'search', value: string): void
112
+ (e: "search", event: InputOnConfirmEvent, value: string): void;
112
113
  /** 配置了clearabled后,清空内容时会发出此事件 */
113
- (e: 'clear'): void
114
+ (e: "clear"): void;
114
115
  /** 用户点击右侧控件时触发 */
115
- (e: 'confirm', value: string): void
116
+ (e: "confirm", value: string): void;
116
117
  /** 输入框获得焦点时触发 */
117
- (e: 'focus', value: string): void
118
+ (e: "focus", e: InputOnFocusEvent, keyword: string): void;
118
119
  /** 输入框失去焦点时触发 */
119
- (e: 'blur', value: string): void
120
+ (e: "blur", e: InputOnBlurEvent, keyword: string): void;
120
121
  /** 输入框内容发生变化时触发 */
121
- (e: 'update:modelValue', value: string): void
122
+ (e: "update:modelValue", value: string): void;
122
123
  }