hy-app 0.7.0 → 0.7.1

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 (32) hide show
  1. package/components/hy-calendar/hy-calendar.vue +2 -2
  2. package/components/hy-calendar/typing.d.ts +9 -0
  3. package/components/hy-count-down/hy-count-down.vue +8 -8
  4. package/components/hy-count-down/typing.d.ts +16 -0
  5. package/components/hy-count-to/hy-count-to.vue +7 -7
  6. package/components/hy-count-to/typing.d.ts +24 -0
  7. package/components/hy-dropdown-item/hy-dropdown-item.vue +1 -1
  8. package/components/hy-folding-panel/hy-folding-panel.vue +3 -3
  9. package/components/hy-folding-panel/typing.d.ts +23 -0
  10. package/components/hy-folding-panel-item/hy-folding-panel-item.vue +2 -2
  11. package/components/hy-folding-panel-item/typing.d.ts +21 -0
  12. package/components/hy-form/hy-form.vue +2 -2
  13. package/components/hy-form/typing.d.ts +37 -6
  14. package/components/hy-list/hy-list.vue +15 -13
  15. package/components/hy-list/props.ts +1 -1
  16. package/components/hy-notify/hy-notify.vue +2 -2
  17. package/components/hy-notify/typing.d.ts +34 -21
  18. package/components/hy-number-step/hy-number-step.vue +370 -367
  19. package/components/hy-number-step/index.scss +1 -0
  20. package/components/hy-number-step/props.ts +1 -1
  21. package/components/hy-popover/hy-popover.vue +2 -2
  22. package/components/hy-popover/typing.d.ts +1 -1
  23. package/components/hy-popup/hy-popup.vue +1 -1
  24. package/components/hy-signature/hy-signature.vue +17 -17
  25. package/components/hy-signature/typing.d.ts +1 -1
  26. package/components/hy-toast/hy-toast.vue +3 -3
  27. package/components/hy-toast/index.scss +1 -1
  28. package/components/hy-toast/typing.d.ts +14 -1
  29. package/libs/api/http.ts +122 -119
  30. package/libs/css/theme.scss +2 -0
  31. package/package.json +1 -1
  32. package/components/hy-folding-panel/hy-folding-panel-group.vue +0 -163
@@ -75,7 +75,6 @@ export default {
75
75
  </script>
76
76
 
77
77
  <script setup lang="ts">
78
- import type { ICalendarEmits } from './typing'
79
78
  import { computed, nextTick, onMounted, ref, watch } from 'vue'
80
79
  import {
81
80
  addUnit,
@@ -87,6 +86,7 @@ import {
87
86
  range,
88
87
  useTranslate
89
88
  } from '../../libs'
89
+ import type { ICalendarEmits, ICalendarExpose } from './typing'
90
90
  import Calendar from '../../libs/utils/calendar.js'
91
91
  import calendarProps from './props'
92
92
  import dayjs from 'dayjs/esm'
@@ -367,7 +367,7 @@ const updateMonthTop = (topArr = []) => {
367
367
  scrollIntoDefaultMonth(selected)
368
368
  }
369
369
 
370
- defineExpose({
370
+ defineExpose<ICalendarExpose>({
371
371
  setFormatter
372
372
  })
373
373
  </script>
@@ -45,3 +45,12 @@ export interface ICalendarEmits {
45
45
  /** 触发关闭属性 */
46
46
  (e: 'update:show', value: boolean): void
47
47
  }
48
+
49
+ /** HyCalendar 组件实例暴露的方法 */
50
+ export interface ICalendarExpose {
51
+ /**
52
+ * 设置日期格式化函数
53
+ * @param formatter 格式化函数,接收日期字符串参数,返回格式化后的值
54
+ */
55
+ setFormatter: (formatter: (value: string) => string) => void
56
+ }
@@ -24,7 +24,7 @@ export default {
24
24
  <script setup lang="ts">
25
25
  import { onMounted, onUnmounted, ref, watch } from 'vue'
26
26
  import { isSameSecond, parseFormat, parseTimeData } from './index'
27
- import type { ICountDownEmits } from './typing'
27
+ import type { ICountDownEmits, ICountDownExpose } from './typing'
28
28
  import countDownProps from './props'
29
29
 
30
30
  /**
@@ -62,7 +62,7 @@ onUnmounted(() => {
62
62
  })
63
63
 
64
64
  /**
65
- * @description 开始倒计时
65
+ * 开始倒计时
66
66
  */
67
67
  const start = () => {
68
68
  if (runing.value) return
@@ -74,7 +74,7 @@ const start = () => {
74
74
  }
75
75
 
76
76
  /**
77
- * @description 根据是否展示毫秒,执行不同操作函数
77
+ * 根据是否展示毫秒,执行不同操作函数
78
78
  */
79
79
  const toTick = () => {
80
80
  if (props.millisecond) {
@@ -112,14 +112,14 @@ const microTick = () => {
112
112
  }
113
113
 
114
114
  /**
115
- * @description 获取剩余的时间
115
+ * 获取剩余的时间
116
116
  */
117
117
  const getRemainTime = () => {
118
118
  // 取最大值,防止出现小于0的剩余时间值
119
119
  return Math.max(endTime.value - Date.now(), 0)
120
120
  }
121
121
  /**
122
- * @description 设置剩余的时间
122
+ * 设置剩余的时间
123
123
  */
124
124
  const setRemainTime = (remain: number) => {
125
125
  remainTime.value = remain
@@ -144,21 +144,21 @@ const reset = () => {
144
144
  }
145
145
  }
146
146
  /**
147
- * @description 暂停倒计时
147
+ * 暂停倒计时
148
148
  * */
149
149
  const pause = () => {
150
150
  runing.value = false
151
151
  clearTimeoutFn()
152
152
  }
153
153
  /**
154
- * @description 清空定时器
154
+ * 清空定时器
155
155
  * */
156
156
  const clearTimeoutFn = () => {
157
157
  clearTimeout(timer)
158
158
  timer = null
159
159
  }
160
160
 
161
- defineExpose({
161
+ defineExpose<ICountDownExpose>({
162
162
  reset,
163
163
  start,
164
164
  pause
@@ -12,3 +12,19 @@ export interface ICountDownEmits {
12
12
  /** 倒计时结束触发 */
13
13
  (e: 'finish'): void
14
14
  }
15
+
16
+ /** HyCountDown 组件实例暴露的方法 */
17
+ export interface ICountDownExpose {
18
+ /**
19
+ * 重置倒计时
20
+ */
21
+ reset: () => void
22
+ /**
23
+ * 开始倒计时
24
+ */
25
+ start: () => void
26
+ /**
27
+ * 暂停倒计时
28
+ */
29
+ pause: () => void
30
+ }
@@ -26,7 +26,7 @@ export default {
26
26
  </script>
27
27
 
28
28
  <script setup lang="ts">
29
- import type { ICountToEmits } from './typing'
29
+ import type { ICountToEmits, ICountToExpose } from './typing'
30
30
  import { computed, onMounted, ref, watch } from 'vue'
31
31
  import { addUnit, isNumber } from '../../libs'
32
32
  import countToProps from './props'
@@ -107,7 +107,7 @@ const cancelAnimationFrame = (id?: number) => {
107
107
  }
108
108
 
109
109
  /**
110
- * @description 开始滚动数字
110
+ * 开始滚动数字
111
111
  * */
112
112
  const start = () => {
113
113
  localStartVal.value = props.startVal
@@ -118,7 +118,7 @@ const start = () => {
118
118
  }
119
119
 
120
120
  /**
121
- * @description 暂定状态,重新再开始滚动;或者滚动状态下,暂停
121
+ * 暂定状态,重新再开始滚动;或者滚动状态下,暂停
122
122
  * */
123
123
  const reStart = () => {
124
124
  if (paused.value) {
@@ -131,14 +131,14 @@ const reStart = () => {
131
131
  }
132
132
 
133
133
  /**
134
- * @description 暂停
134
+ * 暂停
135
135
  * */
136
136
  const stop = () => {
137
137
  cancelAnimationFrame(rAF.value)
138
138
  }
139
139
 
140
140
  /**
141
- * @description 重新开始(暂停的情况下)
141
+ * 重新开始(暂停的情况下)
142
142
  * */
143
143
  const resume = () => {
144
144
  if (!remaining.value) return
@@ -151,7 +151,7 @@ const resume = () => {
151
151
  }
152
152
 
153
153
  /**
154
- * @description 重置
154
+ * 重置
155
155
  * */
156
156
  const reset = () => {
157
157
  startTime.value = null
@@ -204,7 +204,7 @@ const destroyed = () => {
204
204
  cancelAnimationFrame(rAF.value)
205
205
  }
206
206
 
207
- defineExpose({
207
+ defineExpose<ICountToExpose>({
208
208
  start,
209
209
  stop,
210
210
  reStart,
@@ -2,3 +2,27 @@ export interface ICountToEmits {
2
2
  /** 结束执行函数 */
3
3
  (e: 'end'): void
4
4
  }
5
+
6
+ /** HyCountTo 组件实例暴露的方法 */
7
+ export interface ICountToExpose {
8
+ /**
9
+ * 开始滚动数字
10
+ */
11
+ start: () => void
12
+ /**
13
+ * 停止滚动
14
+ */
15
+ stop: () => void
16
+ /**
17
+ * 重新开始或暂停滚动
18
+ */
19
+ reStart: () => void
20
+ /**
21
+ * 恢复滚动(暂停状态下)
22
+ */
23
+ resume: () => void
24
+ /**
25
+ * 重置到初始值
26
+ */
27
+ reset: () => void
28
+ }
@@ -172,8 +172,8 @@ const onSelect = (item: DropdownMenuItem, index: number) => {
172
172
  isOpen.value = false
173
173
  if (index !== currentIndex.value) {
174
174
  currentIndex.value = index
175
- emit('change', item, index)
176
175
  emit('update:modelValue', item.value)
176
+ emit('change', item, index)
177
177
  }
178
178
  }
179
179
 
@@ -12,7 +12,7 @@ export default {
12
12
 
13
13
  <script setup lang="ts">
14
14
  import { provide, ref, watch, toRefs } from 'vue'
15
- import type { IFoldingPanelGroupEmits } from './typing'
15
+ import type { IFoldingPanelGroupEmits, IFoldingPanelExpose } from './typing'
16
16
  import foldingPanelProps from './props'
17
17
 
18
18
  const props = defineProps(foldingPanelProps)
@@ -36,7 +36,7 @@ watch(activeIndex, (newVal) => {
36
36
  })
37
37
 
38
38
  // 提供给子组件的方法
39
- const updateActiveIndex = (index: number) => {
39
+ const updateActiveIndex = (index: number | string) => {
40
40
  if (props.disabled) return
41
41
 
42
42
  if (props.accordion) {
@@ -63,7 +63,7 @@ provide('hy-folding-panel', {
63
63
  updateActiveIndex
64
64
  })
65
65
  // 对外暴露的方法
66
- defineExpose({
66
+ defineExpose<IFoldingPanelExpose>({
67
67
  /**
68
68
  * 打开指定索引的面板
69
69
  */
@@ -17,3 +17,26 @@ export interface IFoldingPanelGroupEmits {
17
17
  */
18
18
  (e: 'close', index: number | string): void
19
19
  }
20
+
21
+ /** HyFoldingPanel 组件实例暴露的方法 */
22
+ export interface IFoldingPanelExpose {
23
+ /**
24
+ * 打开指定索引的面板
25
+ * @param index 面板索引
26
+ */
27
+ open: (index: number | string) => void
28
+ /**
29
+ * 关闭所有面板
30
+ */
31
+ closeAll: () => void
32
+ /**
33
+ * 切换指定索引面板的状态
34
+ * @param index 面板索引
35
+ */
36
+ toggle: (index: number | string) => void
37
+ /**
38
+ * 关闭指定索引的面板
39
+ * @param index 面板索引
40
+ */
41
+ close: (index: number | string) => void
42
+ }
@@ -67,7 +67,7 @@ export default {
67
67
 
68
68
  <script setup lang="ts">
69
69
  import { ref, computed, inject, onMounted } from 'vue'
70
- import type { IFoldingPanelConfig, IFoldingPanelItemEmits } from './typing'
70
+ import type { IFoldingPanelConfig, IFoldingPanelItemEmits, IFoldingPanelItemExpose } from './typing'
71
71
  import { addUnit, IconConfig } from '../../libs'
72
72
  import foldingPanelItemProps from './props'
73
73
  // 组件
@@ -124,7 +124,7 @@ const handleClick = () => {
124
124
  }
125
125
 
126
126
  // 对外暴露的方法
127
- defineExpose({
127
+ defineExpose<IFoldingPanelItemExpose>({
128
128
  /**
129
129
  * 打开面板
130
130
  */
@@ -35,3 +35,24 @@ export interface IFoldingPanelItemEmits {
35
35
  */
36
36
  (e: 'child-click', index: number | string): void
37
37
  }
38
+
39
+ /** HyFoldingPanelItem 组件实例暴露的方法 */
40
+ export interface IFoldingPanelItemExpose {
41
+ /**
42
+ * 打开面板
43
+ */
44
+ open: () => void
45
+ /**
46
+ * 关闭面板
47
+ */
48
+ close: () => void
49
+ /**
50
+ * 切换面板状态
51
+ */
52
+ toggle: () => void
53
+ /**
54
+ * 获取当前展开状态
55
+ * @returns 当前展开状态
56
+ */
57
+ getExpanded: () => boolean
58
+ }
@@ -19,7 +19,7 @@ export default {
19
19
  import { provide, reactive, ref, toRefs } from 'vue'
20
20
  import { clearVal, isArray } from '../../libs'
21
21
  import formProps from './props'
22
- import type { IFormEmits } from './typing'
22
+ import type { IFormEmits, IFormExpose } from './typing'
23
23
 
24
24
  /**
25
25
  * 表单组件父组件,需要搭配hy-form-item
@@ -203,7 +203,7 @@ const submit = async () => {
203
203
  return false
204
204
  }
205
205
 
206
- defineExpose({
206
+ defineExpose<IFormExpose>({
207
207
  validate,
208
208
  resetFields,
209
209
  clearValidate,
@@ -1,9 +1,9 @@
1
- import type { ExtractPropTypes } from 'vue'
2
- import type formProps from './props'
3
-
4
- export interface HyFormProps extends ExtractPropTypes<typeof formProps> {}
5
- export type HyFormSimpleProps = HyFormProps
6
-
1
+ import type { ExtractPropTypes } from 'vue'
2
+ import type formProps from './props'
3
+
4
+ export interface HyFormProps extends ExtractPropTypes<typeof formProps> {}
5
+ export type HyFormSimpleProps = HyFormProps
6
+
7
7
  export interface FormRule {
8
8
  /**
9
9
  * 是否必填
@@ -45,3 +45,34 @@ export interface IFormEmits {
45
45
  /** 表单校验 */
46
46
  (e: 'validate', valid: boolean, errors: AnyObject): void
47
47
  }
48
+
49
+ /** HyForm 组件实例暴露的方法和属性 */
50
+ export interface IFormExpose {
51
+ /**
52
+ * 验证所有表单字段
53
+ * @returns Promise,验证成功时 resolve,失败时 reject 并返回错误信息
54
+ */
55
+ validate: () => Promise<unknown>
56
+ /**
57
+ * 重置表单所有字段到初始值
58
+ */
59
+ resetFields: () => void
60
+ /**
61
+ * 清除表单验证错误
62
+ * @param fields 可选,指定要清除的字段名数组,不传则清除所有
63
+ */
64
+ clearValidate: (fields?: string[]) => void
65
+ /**
66
+ * 提交表单(会先执行验证)
67
+ * @returns Promise,验证成功时返回表单数据,失败时返回 false
68
+ */
69
+ submit: () => Promise<AnyObject | false>
70
+ /**
71
+ * 表单数据对象
72
+ */
73
+ formData: AnyObject
74
+ /**
75
+ * 表单错误信息
76
+ */
77
+ errors: Record<string, string>
78
+ }
@@ -114,7 +114,6 @@ const waterfall: {
114
114
  })
115
115
  // 排列方式
116
116
  const arrange = computed(() => (props.line === 1 ? 'column' : 'row'))
117
- const boxHeight = getPx(props.itemHeight) + getPx(props.marginBottom)
118
117
  const listHeight = addUnit(props.containerHeight)
119
118
  const instance = getCurrentInstance()
120
119
 
@@ -125,6 +124,9 @@ onMounted(() => {
125
124
  })
126
125
  })
127
126
 
127
+ const boxHeight = computed(() => {
128
+ return getPx(props.itemHeight) + getPx(props.marginBottom)
129
+ })
128
130
  const itemStyle = computed((): CSSProperties => {
129
131
  return {
130
132
  height: addUnit(props.itemHeight),
@@ -137,32 +139,32 @@ const itemStyle = computed((): CSSProperties => {
137
139
  })
138
140
 
139
141
  /**
140
- * @description 虚拟列表真实展示数据:起始下标
142
+ * 虚拟列表真实展示数据:起始下标
141
143
  */
142
144
  const start = computed(() => {
143
- const s = Math.floor(scrollTop.value / boxHeight)
145
+ const s = Math.floor(scrollTop.value / boxHeight.value)
144
146
  return Math.max(0, s * props.line)
145
147
  })
146
148
 
147
149
  /**
148
- * @description 虚拟列表真实展示数据:结束下标
150
+ * 虚拟列表真实展示数据:结束下标
149
151
  */
150
152
  const over = computed(() => {
151
- const o = Math.floor((scrollTop.value + viewHeight.value + 1) / boxHeight + 5)
153
+ const o = Math.floor((scrollTop.value + viewHeight.value + 1) / boxHeight.value + 5)
152
154
  return Math.min(props.list.length, o * props.line)
153
155
  })
154
156
 
155
157
  /**
156
- * @description 计算虚拟列表的padding(保持列表高度完整且滚动条能正常滚动)
158
+ * 计算虚拟列表的padding(保持列表高度完整且滚动条能正常滚动)
157
159
  */
158
160
  const paddingAttr = computed(() => {
159
- const paddingTop = start.value * boxHeight
160
- const paddingBottom = (props.list.length - over.value) * boxHeight
161
+ const paddingTop = start.value * boxHeight.value
162
+ const paddingBottom = (props.list.length - over.value) * boxHeight.value
161
163
  return `${paddingTop / props.line}px 0 ${paddingBottom / props.line}px`
162
164
  })
163
165
 
164
166
  /**
165
- * @description 虚拟列表真实展示数据
167
+ * 虚拟列表真实展示数据
166
168
  */
167
169
  const virtualData = computed<(string | Record<string, any>)[]>(() => {
168
170
  return props.list.slice(start.value, over.value)
@@ -187,28 +189,28 @@ watch(
187
189
  )
188
190
 
189
191
  /**
190
- * @description 监听滚动条距离顶部距离,实时更新
192
+ * 监听滚动条距离顶部距离,实时更新
191
193
  */
192
194
  const onScroll = async (e: any) => {
193
195
  scrollTop.value = e.detail.scrollTop || 0
194
196
  }
195
197
 
196
198
  /**
197
- * @description 滚动底部函数
199
+ * 滚动底部函数
198
200
  * */
199
201
  const scrollToLower = () => {
200
202
  emit('scrollToLower')
201
203
  }
202
204
 
203
205
  /**
204
- * @description 点击行触发函数
206
+ * 点击行触发函数
205
207
  * */
206
208
  const handleClick = (temp: string | AnyObject) => {
207
209
  emit('click', temp)
208
210
  }
209
211
 
210
212
  /**
211
- * @description 获取默认插槽
213
+ * 获取默认插槽
212
214
  */
213
215
  const slotDefault = useSlots().default
214
216
  </script>
@@ -19,7 +19,7 @@ const listProps = {
19
19
  /** 子容器的底部,会计算到容器内 */
20
20
  marginBottom: {
21
21
  type: [String, Number],
22
- default: 10
22
+ default: 0
23
23
  },
24
24
  /** 子容器的内边距 */
25
25
  padding: {
@@ -42,7 +42,7 @@ export default {
42
42
  </script>
43
43
 
44
44
  <script setup lang="ts">
45
- import type { NotifyOptions } from './typing'
45
+ import type { NotifyOptions, INotifyExpose } from './typing'
46
46
  import { computed, ref } from 'vue'
47
47
  import type { CSSProperties } from 'vue'
48
48
  import { addUnit, IconConfig } from '../../libs'
@@ -163,7 +163,7 @@ const clearTimer = () => {
163
163
  clearTimeout(timer)
164
164
  }
165
165
 
166
- defineExpose({
166
+ defineExpose<INotifyExpose>({
167
167
  show,
168
168
  close
169
169
  })
@@ -1,22 +1,35 @@
1
- export interface NotifyOptions {
2
- /** 到顶部的距离 */
3
- top?: number
4
- /** 主题类型 */
5
- type?: NotifyType
6
- /** 字体颜色 */
7
- color?: string
8
- /** 背景颜色 */
9
- bgColor?: string
10
- /** 自定义图标 */
11
- icon?: string
12
- /** 展示的文字内容 */
13
- message?: string
14
- /** 展示时长,为0时不消失 */
15
- duration?: number
16
- /** 字体大小 */
17
- fontSize?: number | string
18
- /** 是否留出顶部安全距离 */
19
- safeAreaInsetTop?: boolean
20
- /** 关闭后的回调函数 */
21
- complete?: () => void
1
+ export interface NotifyOptions {
2
+ /** 到顶部的距离 */
3
+ top?: number
4
+ /** 主题类型 */
5
+ type?: NotifyType
6
+ /** 字体颜色 */
7
+ color?: string
8
+ /** 背景颜色 */
9
+ bgColor?: string
10
+ /** 自定义图标 */
11
+ icon?: string
12
+ /** 展示的文字内容 */
13
+ message?: string
14
+ /** 展示时长,为 0 时不消失 */
15
+ duration?: number
16
+ /** 字体大小 */
17
+ fontSize?: number | string
18
+ /** 是否留出顶部安全距离 */
19
+ safeAreaInsetTop?: boolean
20
+ /** 关闭后的回调函数 */
21
+ complete?: () => void
22
+ }
23
+
24
+ /** HyNotify 组件实例暴露的方法 */
25
+ export interface INotifyExpose {
26
+ /**
27
+ * 显示 Notify 提示
28
+ * @param options Notify 配置选项
29
+ */
30
+ show: (options: NotifyOptions) => void
31
+ /**
32
+ * 关闭 Notify 提示
33
+ */
34
+ close: () => void
22
35
  }