hy-app 0.3.1 → 0.3.3

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 (116) hide show
  1. package/README.md +6 -3
  2. package/common/shakeService.ts +31 -29
  3. package/components/hy-action-sheet/hy-action-sheet.vue +71 -46
  4. package/components/hy-address-picker/hy-address-picker.vue +94 -83
  5. package/components/hy-address-picker/index.scss +1 -1
  6. package/components/hy-avatar/hy-avatar.vue +87 -91
  7. package/components/hy-avatar/index.scss +1 -1
  8. package/components/hy-back-top/index.scss +1 -1
  9. package/components/hy-badge/hy-badge.vue +47 -46
  10. package/components/hy-button/hy-button.vue +117 -93
  11. package/components/hy-button/index.scss +2 -2
  12. package/components/hy-calendar/header.vue +11 -11
  13. package/components/hy-calendar/hy-calendar.vue +168 -160
  14. package/components/hy-calendar/index.scss +25 -25
  15. package/components/hy-calendar/month.vue +18 -19
  16. package/components/hy-card/hy-card.vue +55 -50
  17. package/components/hy-card/index.scss +11 -9
  18. package/components/hy-card/typing.d.ts +33 -32
  19. package/components/hy-cell/hy-cell.vue +81 -59
  20. package/components/hy-cell/index.scss +15 -15
  21. package/components/hy-check-button/hy-check-button.vue +54 -47
  22. package/components/hy-checkbox/hy-checkbox.vue +103 -111
  23. package/components/hy-checkbox/index.scss +24 -23
  24. package/components/hy-code-input/hy-code-input.vue +80 -89
  25. package/components/hy-config-provider/hy-config-provider.vue +19 -20
  26. package/components/hy-count-down/hy-count-down.vue +66 -67
  27. package/components/hy-count-to/hy-count-to.vue +105 -99
  28. package/components/hy-count-to/typing.d.ts +13 -12
  29. package/components/hy-datetime-picker/hy-datetime-picker.vue +261 -253
  30. package/components/hy-datetime-picker/typing.d.ts +42 -40
  31. package/components/hy-divider/hy-divider.vue +68 -73
  32. package/components/hy-dropdown/hy-dropdown.vue +20 -19
  33. package/components/hy-dropdown-item/hy-dropdown-item.vue +66 -61
  34. package/components/hy-dropdown-item/typing.d.ts +9 -9
  35. package/components/hy-empty/hy-empty.vue +53 -50
  36. package/components/hy-empty/icon.ts +32 -58
  37. package/components/hy-empty/index.scss +2 -2
  38. package/components/hy-empty/typing.d.ts +48 -35
  39. package/components/hy-flex/hy-flex.vue +52 -26
  40. package/components/hy-float-button/hy-float-button.vue +218 -210
  41. package/components/hy-folding-panel/hy-folding-panel.vue +32 -33
  42. package/components/hy-form/hy-form.vue +264 -259
  43. package/components/hy-grid/hy-grid.vue +44 -43
  44. package/components/hy-icon/hy-icon.vue +61 -67
  45. package/components/hy-image/hy-image.vue +112 -88
  46. package/components/hy-image/typing.d.ts +27 -23
  47. package/components/hy-input/hy-input.vue +157 -127
  48. package/components/hy-input/typing.d.ts +53 -47
  49. package/components/hy-line/hy-line.vue +26 -26
  50. package/components/hy-line-progress/hy-line-progress.vue +42 -35
  51. package/components/hy-list/hy-list.vue +76 -85
  52. package/components/hy-loading/hy-loading.vue +26 -23
  53. package/components/hy-menu/hy-menu.vue +48 -43
  54. package/components/hy-menu/typing.d.ts +18 -17
  55. package/components/hy-modal/hy-modal.vue +39 -35
  56. package/components/hy-navbar/hy-navbar.vue +25 -25
  57. package/components/hy-navbar/typing.d.ts +24 -22
  58. package/components/hy-notice-bar/hy-column-notice.vue +2 -2
  59. package/components/hy-notice-bar/hy-notice-bar.vue +26 -27
  60. package/components/hy-notice-bar/hy-row-notice.vue +1 -1
  61. package/components/hy-notice-bar/index.scss +6 -0
  62. package/components/hy-notify/hy-notify.vue +53 -53
  63. package/components/hy-number-step/hy-number-step.vue +134 -146
  64. package/components/hy-number-step/typing.d.ts +35 -35
  65. package/components/hy-overlay/hy-overlay.vue +23 -21
  66. package/components/hy-pagination/hy-pagination.vue +41 -36
  67. package/components/hy-picker/hy-picker.vue +184 -154
  68. package/components/hy-picker/typing.d.ts +39 -39
  69. package/components/hy-popover/hy-popover.vue +97 -77
  70. package/components/hy-popover/index.scss +3 -3
  71. package/components/hy-popup/hy-popup.vue +107 -98
  72. package/components/hy-price/hy-price.vue +38 -34
  73. package/components/hy-qrcode/hy-qrcode.vue +50 -51
  74. package/components/hy-radio/hy-radio.vue +101 -113
  75. package/components/hy-rate/hy-rate.vue +107 -88
  76. package/components/hy-read-more/hy-read-more.vue +64 -49
  77. package/components/hy-scroll-list/hy-scroll-list.vue +45 -48
  78. package/components/hy-search/hy-search.vue +75 -75
  79. package/components/hy-search/typing.d.ts +36 -35
  80. package/components/hy-signature/hy-signature.vue +282 -240
  81. package/components/hy-slider/hy-slider.vue +194 -152
  82. package/components/hy-slider/typing.d.ts +21 -21
  83. package/components/hy-steps/hy-steps.vue +118 -90
  84. package/components/hy-steps/index.scss +31 -21
  85. package/components/hy-submit-bar/hy-submit-bar.vue +61 -70
  86. package/components/hy-subsection/hy-subsection.vue +99 -102
  87. package/components/hy-subsection/typing.d.ts +19 -19
  88. package/components/hy-swipe-action/hy-swipe-action.vue +131 -118
  89. package/components/hy-swiper/hy-swiper.vue +85 -71
  90. package/components/hy-switch/hy-switch.vue +67 -72
  91. package/components/hy-switch/typing.d.ts +21 -19
  92. package/components/hy-tabs/hy-tabs.vue +168 -113
  93. package/components/hy-tag/hy-tag.vue +91 -87
  94. package/components/hy-tag/index.scss +13 -12
  95. package/components/hy-tag/typing.d.ts +26 -21
  96. package/components/hy-text/hy-text.vue +119 -111
  97. package/components/hy-textarea/hy-textarea.vue +100 -93
  98. package/components/hy-textarea/typing.d.ts +36 -31
  99. package/components/hy-toast/hy-toast.vue +77 -67
  100. package/components/hy-tooltip/hy-tooltip.vue +109 -91
  101. package/components/hy-transition/hy-transition.vue +62 -66
  102. package/components/hy-upload/hy-upload.vue +289 -154
  103. package/components/hy-upload/typing.d.ts +62 -36
  104. package/components/hy-warn/hy-warn.vue +34 -27
  105. package/components/hy-waterfall/hy-waterfall.vue +83 -74
  106. package/components/hy-watermark/hy-watermark.vue +134 -115
  107. package/composables/usePopover.ts +236 -221
  108. package/composables/useQueue.ts +53 -52
  109. package/libs/css/mixin.scss +4 -1
  110. package/libs/css/vars.css +2 -0
  111. package/package.json +2 -2
  112. package/store/index.ts +9 -1
  113. package/theme.scss +1 -0
  114. package/typing/index.ts +0 -1
  115. package/typing/modules/common.d.ts +0 -2
  116. package/web-types.json +1 -1
@@ -17,7 +17,7 @@
17
17
  borderColor: borderColor,
18
18
  }"
19
19
  >
20
- <template v-if="$slots.label || label !== null">
20
+ <template v-if="$slots.label || label">
21
21
  <slot name="label">
22
22
  <text class="hy-search__content__label">{{ label }}</text>
23
23
  </slot>
@@ -72,14 +72,7 @@
72
72
  v-if="keyword && clear && focused"
73
73
  @click="clear"
74
74
  >
75
- <HyIcon
76
- :name="IconConfig.CLOSE"
77
- size="11"
78
- color="#ffffff"
79
- :customStyle="{
80
- lineHeight: '12px',
81
- }"
82
- ></HyIcon>
75
+ <HyIcon :name="IconConfig.CLOSE" color="#ffffff"></HyIcon>
83
76
  </view>
84
77
  </view>
85
78
  <text
@@ -95,48 +88,57 @@
95
88
 
96
89
  <script lang="ts">
97
90
  export default {
98
- name: 'hy-search',
91
+ name: "hy-search",
99
92
  options: {
100
93
  addGlobalClass: true,
101
94
  virtualHost: true,
102
- styleIsolation: 'shared',
95
+ styleIsolation: "shared",
103
96
  },
104
- }
97
+ };
105
98
  </script>
106
99
 
107
100
  <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'
101
+ import { computed, nextTick, ref, watch } from "vue";
102
+ import type { PropType, CSSProperties } from "vue";
103
+ import type { ISearchEmits } from "./typing";
104
+ import { sleep, addUnit } from "../../utils";
105
+ import { IconConfig } from "../../config";
106
+ import HyIcon from "../hy-icon/hy-icon.vue";
107
+ import type HyIconProps from "../hy-icon/typing";
108
+ import type {
109
+ InputOnBlurEvent,
110
+ InputOnConfirmEvent,
111
+ InputOnFocusEvent,
112
+ InputOnInputEvent,
113
+ } from "@uni-helper/uni-types";
115
114
 
116
115
  /**
117
116
  * 搜索组件,集成了常见搜索框所需功能,用户可以一键引入,开箱即用。
118
117
  * @displayName hy-search
119
118
  */
120
- defineOptions({})
119
+ defineOptions({});
121
120
 
122
121
  // const props = withDefaults(defineProps<IProps>(), defaultProps)
123
122
  const props = defineProps({
124
123
  /** 输入框初始值 */
125
- modelValue: String,
124
+ modelValue: {
125
+ type: String,
126
+ default: "",
127
+ },
126
128
  /**
127
129
  * 搜索框形状
128
130
  * @values circle,square
129
131
  * */
130
132
  shape: {
131
133
  type: String,
132
- default: 'circle',
134
+ default: "circle",
133
135
  },
134
136
  /** 搜索框背景颜色 */
135
137
  bgColor: String,
136
138
  /** 占位文字内容 */
137
139
  placeholder: {
138
140
  type: String,
139
- default: '请输入关键字',
141
+ default: "请输入关键字",
140
142
  },
141
143
  /** 是否启用清除控件 */
142
144
  clear: {
@@ -156,7 +158,7 @@ const props = defineProps({
156
158
  /** 右侧控件文字 */
157
159
  actionText: {
158
160
  type: String,
159
- default: '搜索',
161
+ default: "搜索",
160
162
  },
161
163
  /** 右侧控件的样式,对象形式 */
162
164
  actionStyle: {
@@ -166,7 +168,7 @@ const props = defineProps({
166
168
  /** 输入框内容水平对齐方式 */
167
169
  inputAlign: {
168
170
  type: String,
169
- default: 'left',
171
+ default: "left",
170
172
  },
171
173
  /** 自定义输入框样式,对象形式 */
172
174
  inputStyle: {
@@ -181,14 +183,14 @@ const props = defineProps({
181
183
  /** 边框颜色,配置了颜色,才会有边框 */
182
184
  borderColor: {
183
185
  type: String,
184
- default: 'transparent',
186
+ default: "transparent",
185
187
  },
186
188
  /** 输入框字体颜色 */
187
189
  color: String,
188
190
  /** placeholder的颜色 */
189
191
  placeholderColor: {
190
192
  type: String,
191
- default: '#909399',
193
+ default: "#909399",
192
194
  },
193
195
  /** 输入框左边的图标属性集合,可以为图标名称或图片路径 */
194
196
  searchIcon: Object as PropType<HyIconProps>,
@@ -230,111 +232,109 @@ const props = defineProps({
230
232
  },
231
233
  /** 自定义外部类名 */
232
234
  customClass: String,
233
- })
234
- const { focus, modelValue, showAction, animation, disabled } = toRefs(props)
235
- const emit = defineEmits<ISearchEmits>()
235
+ });
236
+ const emit = defineEmits<ISearchEmits>();
236
237
 
237
- const keyword = ref<string>('')
238
- // 是否显示右边的清除图标
239
- const showClear = ref<boolean>(false)
240
- const show = ref<boolean>(false)
238
+ const keyword = ref<string>("");
239
+ // 显示右边搜索按钮
240
+ const show = ref<boolean>(false);
241
241
  // 标记input当前状态是否处于聚焦中,如果是,才会显示右侧的清除控件
242
- const focused = ref(focus.value)
242
+ const focused = ref(props.focus);
243
243
 
244
244
  watch(
245
245
  () => keyword.value,
246
246
  (newValue: string) => {
247
- emit('update:modelValue', newValue)
248
- emit('change', newValue)
247
+ emit("update:modelValue", newValue);
248
+ emit("change", newValue);
249
249
  },
250
- )
250
+ );
251
251
 
252
252
  watch(
253
- () => modelValue.value,
253
+ () => props.modelValue,
254
254
  (newValue: string) => {
255
- keyword.value = newValue
255
+ keyword.value = newValue;
256
256
  },
257
257
  { immediate: true },
258
- )
258
+ );
259
259
 
260
260
  const showActionBtn = computed<boolean>(() => {
261
- return !animation.value && showAction.value
262
- })
261
+ return !props.animation && props.showAction;
262
+ });
263
263
 
264
264
  /**
265
- * @description
265
+ * 值改变触发
266
266
  * */
267
- const inputChange = (e: Event) => {
268
- keyword.value = e.detail.value
269
- }
267
+ const inputChange = (e: InputOnInputEvent) => {
268
+ keyword.value = e.detail.value;
269
+ };
270
270
  /**
271
271
  * @description 清空输入
272
272
  * */
273
273
  const clear = () => {
274
- keyword.value = ''
274
+ keyword.value = "";
275
275
  // 延后发出事件,避免在父组件监听clear事件时,value为更新前的值(不为空)
276
276
  nextTick(() => {
277
- emit('clear')
278
- })
279
- }
277
+ emit("clear");
278
+ });
279
+ };
280
280
  /**
281
281
  * @description 确定搜索
282
282
  * */
283
- const search = (e: InputEvent) => {
284
- emit('search', e.detail.value)
283
+ const search = (e: InputOnConfirmEvent) => {
284
+ emit("search", e, e.detail.value);
285
285
  try {
286
286
  // 收起键盘
287
- uni.hideKeyboard()
287
+ uni.hideKeyboard();
288
288
  } catch (e) {}
289
- }
289
+ };
290
290
  /**
291
291
  * @description 点击右边自定义按钮的事件
292
292
  */
293
293
  const confirm = () => {
294
- emit('confirm', keyword.value)
294
+ emit("confirm", keyword.value);
295
295
  try {
296
296
  // 收起键盘
297
- uni.hideKeyboard()
297
+ uni.hideKeyboard();
298
298
  } catch (e) {}
299
- }
299
+ };
300
300
  /**
301
301
  * @description 获取焦点
302
302
  * */
303
- const getFocus = () => {
304
- focused.value = true
303
+ const getFocus = (e: InputOnFocusEvent) => {
304
+ focused.value = true;
305
305
  // 开启右侧搜索按钮展开的动画效果
306
- if (animation.value && showAction.value) show.value = true
307
- emit('focus', keyword.value)
308
- }
306
+ if (props.animation && props.showAction) show.value = true;
307
+ emit("focus", e, keyword.value);
308
+ };
309
309
  /**
310
310
  * @description 失去焦点
311
311
  */
312
- const blur = async () => {
312
+ const blur = async (e: InputOnBlurEvent) => {
313
313
  // 最开始使用的是监听图标@touchstart事件,自从hx2.8.4后,此方法在微信小程序出错
314
314
  // 这里改为监听点击事件,手点击清除图标时,同时也发生了@blur事件,导致图标消失而无法点击,这里做一个延时
315
- show.value = false
316
- emit('blur', keyword.value)
317
- await sleep(100)
318
- focused.value = false
319
- }
315
+ show.value = false;
316
+ emit("blur", e, keyword.value);
317
+ await sleep(100);
318
+ focused.value = false;
319
+ };
320
320
  /**
321
321
  * @description 点击搜索框,只有disabled=true时才发出事件,因为禁止了输入,意味着是想跳转真正的搜索页
322
322
  * */
323
323
  const clickHandler = () => {
324
- if (disabled.value) emit('click')
325
- }
324
+ if (props.disabled) emit("click");
325
+ };
326
326
  /**
327
327
  * @description 点击左边图标
328
328
  * */
329
329
  const clickIcon = () => {
330
- emit('clickIcon', keyword.value)
330
+ emit("clickIcon", keyword.value);
331
331
  try {
332
332
  // 收起键盘
333
- uni.hideKeyboard()
333
+ uni.hideKeyboard();
334
334
  } catch (e) {}
335
- }
335
+ };
336
336
  </script>
337
337
 
338
338
  <style lang="scss" scoped>
339
- @import './index.scss';
339
+ @import "./index.scss";
340
340
  </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
  }