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
@@ -1,131 +1,131 @@
1
- import type { CSSProperties } from 'vue'
2
- import type HyInputProps from '../hy-input/typing'
1
+ import type { CSSProperties } from "vue";
2
+ import type HyInputProps from "../hy-input/typing";
3
3
 
4
4
  export interface PickerColumnVo extends AnyObject {
5
5
  /**
6
6
  * @description id必填
7
7
  * */
8
- id: string
8
+ id: string;
9
9
  /**
10
10
  * @description 显示文本
11
11
  * */
12
- text?: string
12
+ text?: string;
13
13
  }
14
14
 
15
15
  export default interface HyPickerProps {
16
16
  /**
17
17
  * @description 显示到输入框值
18
18
  * */
19
- modelValue?: string | string[]
19
+ modelValue?: string | string[];
20
20
  /**
21
21
  * @description 对象数组,设置每一列的数据
22
22
  * */
23
- columns: (string | PickerColumnVo)[][]
23
+ columns: (string | PickerColumnVo)[][];
24
24
  /**
25
25
  * @description 是否显示弹窗(默认 false )
26
26
  * */
27
- show?: boolean
27
+ show?: boolean;
28
28
  /**
29
29
  * @description 弹窗弹出模式
30
30
  * */
31
- popupMode?: HyApp.LayoutType
31
+ popupMode?: HyApp.LayoutType;
32
32
  /**
33
33
  * @description 分割数组条件
34
34
  * */
35
- separator?: string
35
+ separator?: string;
36
36
  /**
37
37
  * @description 是否显示顶部的操作栏(默认 true )
38
38
  * */
39
- showToolbar?: boolean
39
+ showToolbar?: boolean;
40
40
  /**
41
41
  * @description 顶部标题
42
42
  * */
43
- title?: string
43
+ title?: string;
44
44
  /**
45
45
  * @description 是否显示加载中状态(默认 false )
46
46
  * */
47
- loading?: boolean
47
+ loading?: boolean;
48
48
  /**
49
49
  * @description 各列中,单个选项的高度(默认 44 )
50
50
  * */
51
- itemHeight?: number
51
+ itemHeight?: number;
52
52
  /**
53
53
  * @description 取消按钮的文字(默认 '取消' )
54
54
  * */
55
- cancelText?: string
55
+ cancelText?: string;
56
56
  /**
57
57
  * @description 确认按钮的文字(默认 '确定' )
58
58
  * */
59
- confirmText?: string
59
+ confirmText?: string;
60
60
  /**
61
61
  * @description 取消按钮的颜色(默认 '#909193' )
62
62
  * */
63
- cancelColor?: string
63
+ cancelColor?: string;
64
64
  /**
65
65
  * @description 确认按钮的颜色(默认 '#3c9cff' )
66
66
  * */
67
- confirmColor?: string
67
+ confirmColor?: string;
68
68
  /**
69
69
  * @description 每列中可见选项的数量(默认 5 )
70
70
  * */
71
- visibleItemCount?: number
71
+ visibleItemCount?: number;
72
72
  /**
73
73
  * @description 选项对象中,需要展示的属性键名(默认 'text' )
74
74
  * */
75
- keyName?: string
75
+ keyName?: string;
76
76
  /**
77
77
  * @description 是否允许点击遮罩关闭选择器(默认 false )
78
78
  * */
79
- closeOnClickOverlay?: boolean
79
+ closeOnClickOverlay?: boolean;
80
80
  /**
81
81
  * @description 各列的默认索引
82
82
  * */
83
- defaultIndex?: number[]
83
+ defaultIndex?: number[];
84
84
  /**
85
85
  * @description 是否在手指松开时立即触发change事件(默认 true )
86
86
  * */
87
- immediateChange?: boolean
87
+ immediateChange?: boolean;
88
88
  /**
89
89
  * @description 最高层级
90
90
  * */
91
- zIndex?: number
91
+ zIndex?: number;
92
92
  /**
93
93
  * @description 是否显示输入框(默认 false )
94
94
  * */
95
- hasInput?: boolean
95
+ hasInput?: boolean;
96
96
  /**
97
97
  * @description 输入框集合属性
98
98
  * */
99
- input?: Partial<HyInputProps>
99
+ input?: Partial<HyInputProps>;
100
100
  /**
101
101
  * @description 是否自定义选择器nav左边内容
102
102
  * */
103
- toolbarRightSlot?: boolean
103
+ toolbarRightSlot?: boolean;
104
104
  /**
105
105
  * @description 自定义输入框外部样式
106
106
  * */
107
- customStyle?: CSSProperties
107
+ customStyle?: CSSProperties;
108
108
  }
109
109
 
110
110
  export type SelectValueVo = {
111
- value: string[]
112
- index?: number
113
- indexs?: number[]
111
+ value: string[];
112
+ index?: number;
113
+ indexs?: number[];
114
114
  // values为当前变化列的数组内容
115
- values?: Array<any>
116
- columnIndex?: Array<number>
117
- }
115
+ values?: Array<any>;
116
+ columnIndex?: number;
117
+ };
118
118
  export interface IPickerEmits {
119
119
  /** 关闭选择器时触发 */
120
- (e: 'close'): void
120
+ (e: "close"): void;
121
121
  /** 点击取消按钮 */
122
- (e: 'cancel'): void
122
+ (e: "cancel"): void;
123
123
  /** 点击确定按钮,返回当前选择的值 */
124
- (e: 'confirm', params: SelectValueVo): void
124
+ (e: "confirm", params: SelectValueVo): void;
125
125
  /** 当选择值变化时触发 */
126
- (e: 'change', params: SelectValueVo): void
126
+ (e: "change", params: SelectValueVo): void;
127
127
  /** 显示隐藏触发 */
128
- (e: 'update:show', show: boolean): void
128
+ (e: "update:show", show: boolean): void;
129
129
  /** 选中值触发 */
130
- (e: 'update:modelValue', value: any): void
130
+ (e: "update:modelValue", value: any): void;
131
131
  }
@@ -8,11 +8,14 @@
8
8
  <!-- 使用插槽时无法获取正确宽高 -->
9
9
  <view class="hy-popover__pos hy-popover__hidden" id="pos">
10
10
  <view class="hy-popover__container">
11
- <view v-if="!slots.content && mode === 'normal'" class="hy-popover__inner">
11
+ <view
12
+ v-if="!slots.content && mode === 'normal'"
13
+ class="hy-popover__inner"
14
+ >
12
15
  {{ content }}
13
16
  </view>
14
17
  <view
15
- v-if="!slots.content && mode === 'menu' && typeof content === 'object'"
18
+ v-if="!slots.content && mode === 'menu' && isArray(content)"
16
19
  class="hy-popover__menu"
17
20
  >
18
21
  <view
@@ -21,7 +24,11 @@
21
24
  class="hy-popover__menu-inner"
22
25
  @click="menuClick(index)"
23
26
  >
24
- <hy-icon v-if="item.iconClass" :name="item.iconClass" custom-class="hy-popover__icon" />
27
+ <hy-icon
28
+ v-if="item.iconClass"
29
+ :name="item.iconClass"
30
+ custom-class="hy-popover__icon"
31
+ />
25
32
  <text>{{ item.content }}</text>
26
33
  </view>
27
34
  </view>
@@ -32,7 +39,7 @@
32
39
  </view>
33
40
  <hy-transition
34
41
  custom-class="hy-popover__pos"
35
- :custom-style="popover.popStyle"
42
+ :custom-style="popover.popStyle.value"
36
43
  :show="showPopover"
37
44
  name="fade"
38
45
  :duration="200"
@@ -46,14 +53,17 @@
46
53
  <!-- 三角形 -->
47
54
 
48
55
  <!-- 普通模式 -->
49
- <view v-if="!slots.content && mode === 'normal'" class="hy-popover__inner">
56
+ <view
57
+ v-if="!slots.content && mode === 'normal'"
58
+ class="hy-popover__inner"
59
+ >
50
60
  {{ content }}
51
61
  </view>
52
62
  <!-- 普通模式 -->
53
63
 
54
64
  <!-- 列表模式 -->
55
65
  <view
56
- v-if="!slots.content && mode === 'menu' && Array.isArray(content)"
66
+ v-if="!slots.content && mode === 'menu' && isArray(content)"
57
67
  class="hy-popover__menu"
58
68
  >
59
69
  <view
@@ -69,7 +79,9 @@
69
79
  custom-class="hy-popover__icon"
70
80
  />
71
81
  <view style="display: inline-block">
72
- {{ typeof item === 'object' && item.content ? item.content : item }}
82
+ {{
83
+ typeof item === "object" && item.content ? item.content : item
84
+ }}
73
85
  </view>
74
86
  </view>
75
87
  </view>
@@ -94,13 +106,13 @@
94
106
 
95
107
  <script lang="ts">
96
108
  export default {
97
- name: 'hy-popover',
109
+ name: "hy-popover",
98
110
  options: {
99
111
  virtualHost: true,
100
112
  addGlobalClass: true,
101
- styleIsolation: 'shared',
113
+ styleIsolation: "shared",
102
114
  },
103
- }
115
+ };
104
116
  </script>
105
117
 
106
118
  <script lang="ts" setup>
@@ -110,25 +122,29 @@ import {
110
122
  onBeforeMount,
111
123
  onBeforeUnmount,
112
124
  ref,
113
- toRefs,
114
125
  useSlots,
115
126
  watch,
116
127
  inject,
117
- } from 'vue'
118
- import type { PropType, CSSProperties } from 'vue'
119
- import type { IOffset, IPopoverEmits, PopoverContentVo, PopoverExpose } from './typing'
120
- import { isArray } from '../../utils'
121
- import { type Queue, queueKey, usePopover } from '../../composables'
122
- import { closeOther, pushToQueue, removeFromQueue } from '../../common'
128
+ } from "vue";
129
+ import type { PropType, CSSProperties } from "vue";
130
+ import type {
131
+ IOffset,
132
+ IPlacementVo,
133
+ IPopoverEmits,
134
+ PopoverExpose,
135
+ } from "./typing";
136
+ import { isArray } from "../../utils";
137
+ import { type Queue, queueKey, usePopover } from "../../composables";
138
+ import { closeOther, pushToQueue, removeFromQueue } from "../../common";
123
139
  // 组件
124
- import HyIcon from '../hy-icon/hy-icon.vue'
125
- import HyTransition from '../hy-transition/hy-transition.vue'
140
+ import HyIcon from "../hy-icon/hy-icon.vue";
141
+ import HyTransition from "../hy-transition/hy-transition.vue";
126
142
 
127
143
  /**
128
144
  * 常用于展示提示信息。
129
145
  * @displayName hy-popover
130
146
  */
131
- defineOptions({})
147
+ defineOptions({});
132
148
 
133
149
  // const props = withDefaults(defineProps<IProps>(), defaultProps)
134
150
  const props = defineProps({
@@ -138,14 +154,17 @@ const props = defineProps({
138
154
  default: false,
139
155
  },
140
156
  /** 显示的内容,也可以通过 slot#content 传入 */
141
- content: [String, Array],
157
+ content: {
158
+ type: [String, Array] as PropType<string | any[]>,
159
+ required: true,
160
+ },
142
161
  /**
143
162
  * 指定 popover 的放置位置
144
163
  * @values top,top-start,top-end,bottom,bottom-start,bottom-end,left,left-start,left-end,right,right-start,right-end
145
164
  * */
146
165
  placement: {
147
- type: String,
148
- default: 'bottom',
166
+ type: String as PropType<IPlacementVo>,
167
+ default: "bottom",
149
168
  },
150
169
  /** 控制 popover 的显示状态 */
151
170
  offset: {
@@ -168,118 +187,119 @@ const props = defineProps({
168
187
  * */
169
188
  mode: {
170
189
  type: String,
171
- default: 'normal',
190
+ default: "normal",
172
191
  },
173
192
  /** 定义需要用到的外部样式 */
174
193
  customStyle: Object as PropType<CSSProperties>,
175
194
  /** 自定义外部类名 */
176
195
  customClass: String,
177
- })
178
- const { modelValue, content, mode, placement } = toRefs(props)
179
- const emit = defineEmits<IPopoverEmits>()
196
+ });
197
+ const emit = defineEmits<IPopoverEmits>();
180
198
 
181
- const slots = useSlots()
182
- const queue = inject<Queue | null>(queueKey, null)
183
- const selector: string = 'popover'
184
- const { proxy } = getCurrentInstance() as any
185
- const popover = usePopover()
186
- const showPopover = ref<boolean>(false) // 控制popover显隐
199
+ const slots = useSlots();
200
+ const queue = inject<Queue | null>(queueKey, null);
201
+ const selector: string = "popover";
202
+ const { proxy } = getCurrentInstance() as any;
203
+ const popover = usePopover();
204
+ const showPopover = ref<boolean>(false); // 控制popover显隐
187
205
 
188
206
  watch(
189
- () => content.value,
207
+ () => props.content,
190
208
  (newVal) => {
191
- if (mode.value === 'normal' && typeof newVal !== 'string') {
192
- console.error('在“normal”模式下,值类型必须为字符串类型。')
193
- } else if (mode.value === 'menu' && !isArray(newVal)) {
194
- console.error('在“menu”模式下,值类型必须是数组类型。')
209
+ if (props.mode === "normal" && typeof newVal !== "string") {
210
+ console.error("在“normal”模式下,值类型必须为字符串类型。");
211
+ } else if (props.mode === "menu" && !isArray(newVal)) {
212
+ console.error("在“menu”模式下,值类型必须是数组类型。");
195
213
  }
196
214
  },
197
- )
215
+ );
198
216
 
199
217
  watch(
200
218
  () => props.placement,
201
- () => {
202
- popover.init(placement.value, true, selector)
219
+ (newVal) => {
220
+ popover.init(newVal, true, selector);
203
221
  },
204
- )
222
+ );
205
223
 
206
224
  watch(
207
- () => modelValue.value,
225
+ () => props.modelValue,
208
226
  (newValue: boolean) => {
209
- showPopover.value = newValue
227
+ showPopover.value = newValue;
210
228
  },
211
- )
229
+ );
212
230
 
213
231
  watch(
214
232
  () => showPopover.value,
215
233
  (newValue) => {
216
234
  if (newValue) {
217
- popover.control(placement.value, props.offset)
235
+ popover.control(props.placement, props.offset);
218
236
  // provide/inject在微信小程序不能使用,所以执行两个保存方法
219
237
  if (queue && queue.closeOther) {
220
- queue.closeOther(proxy)
238
+ queue.closeOther(proxy);
221
239
  } else {
222
- closeOther(proxy)
240
+ closeOther(proxy);
223
241
  }
224
242
  }
225
- popover.showStyle.value = newValue ? 'display: inline-block;' : 'display: none;'
226
- emit('change', { show: newValue })
227
- emit(`${newValue ? 'open' : 'close'}`)
243
+ popover.showStyle.value = newValue
244
+ ? "display: inline-block;"
245
+ : "display: none;";
246
+ emit("change", { show: newValue });
247
+ emit(`${newValue ? "open" : "close"}`);
228
248
  },
229
- )
249
+ );
230
250
 
231
251
  onMounted(() => {
232
- popover.init(placement.value, true, selector)
233
- })
252
+ popover.init(props.placement, true, selector);
253
+ });
234
254
 
235
255
  onBeforeMount(() => {
236
256
  if (queue && queue.pushToQueue) {
237
- queue.pushToQueue(proxy)
257
+ queue.pushToQueue(proxy);
238
258
  } else {
239
- pushToQueue(proxy)
259
+ pushToQueue(proxy);
240
260
  }
241
- popover.showStyle.value = showPopover.value ? 'opacity: 1;' : 'opacity: 0;'
242
- })
261
+ popover.showStyle.value = showPopover.value ? "opacity: 1;" : "opacity: 0;";
262
+ });
243
263
 
244
264
  onBeforeUnmount(() => {
245
265
  if (queue && queue.removeFromQueue) {
246
- queue.removeFromQueue(proxy)
266
+ queue.removeFromQueue(proxy);
247
267
  } else {
248
- removeFromQueue(proxy)
268
+ removeFromQueue(proxy);
249
269
  }
250
- })
270
+ });
251
271
 
252
272
  const menuClick = (index: number) => {
253
- updateModelValue(false)
254
- emit('menuClick', {
255
- item: (props.content as Array<Record<string, any>>)[index],
273
+ updateModelValue(false);
274
+ emit("menuClick", {
275
+ item: isArray(props.content) ? props.content[index] : props.content,
256
276
  index,
257
- })
258
- }
277
+ });
278
+ };
259
279
 
260
280
  const toggle = () => {
261
- if (props.disabled) return
262
- updateModelValue(!showPopover.value)
263
- }
281
+ if (props.disabled) return;
282
+ updateModelValue(!showPopover.value);
283
+ };
264
284
 
265
285
  const open = () => {
266
- updateModelValue(true)
267
- }
286
+ updateModelValue(true);
287
+ };
268
288
 
269
289
  const close = () => {
270
- updateModelValue(false)
271
- }
290
+ updateModelValue(false);
291
+ };
272
292
 
273
293
  function updateModelValue(value: boolean) {
274
- showPopover.value = value
275
- emit('update:modelValue', value)
294
+ showPopover.value = value;
295
+ emit("update:modelValue", value);
276
296
  }
277
297
 
278
298
  defineExpose<PopoverExpose>({
279
299
  open,
280
300
  close,
281
- })
301
+ });
282
302
  </script>
283
303
  <style lang="scss" scoped>
284
- @import './index.scss';
304
+ @import "./index.scss";
285
305
  </style>