uview-pro 0.0.7 → 0.0.8

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 (174) hide show
  1. package/changelog.md +5 -0
  2. package/components/u-action-sheet/types.ts +35 -0
  3. package/components/u-action-sheet/u-action-sheet.vue +2 -47
  4. package/components/u-alert-tips/types.ts +39 -0
  5. package/components/u-alert-tips/u-alert-tips.vue +3 -32
  6. package/components/u-avatar/types.ts +34 -0
  7. package/components/u-avatar/u-avatar.vue +3 -30
  8. package/components/u-avatar-cropper/types.ts +23 -0
  9. package/components/u-avatar-cropper/u-avatar-cropper.vue +2 -45
  10. package/components/u-back-top/types.ts +39 -0
  11. package/components/u-back-top/u-back-top.vue +2 -33
  12. package/components/u-badge/types.ts +36 -0
  13. package/components/u-badge/u-badge.vue +2 -26
  14. package/components/u-button/types.ts +66 -0
  15. package/components/u-button/u-button.vue +3 -88
  16. package/components/u-calendar/types.ts +63 -0
  17. package/components/u-calendar/u-calendar.vue +2 -135
  18. package/components/u-car-keyboard/types.ts +12 -0
  19. package/components/u-car-keyboard/u-car-keyboard.vue +2 -4
  20. package/components/u-card/types.ts +59 -0
  21. package/components/u-card/u-card.vue +2 -48
  22. package/components/u-cell-group/types.ts +17 -0
  23. package/components/u-cell-group/u-cell-group.vue +3 -9
  24. package/components/u-cell-item/types.ts +54 -0
  25. package/components/u-cell-item/u-cell-item.vue +2 -45
  26. package/components/u-checkbox/types.ts +31 -0
  27. package/components/u-checkbox/u-checkbox.vue +2 -47
  28. package/components/u-checkbox-group/types.ts +32 -0
  29. package/components/u-checkbox-group/u-checkbox-group.vue +2 -57
  30. package/components/u-circle-progress/types.ts +52 -0
  31. package/components/u-circle-progress/u-circle-progress.vue +2 -23
  32. package/components/u-city-select/types.ts +20 -0
  33. package/components/u-city-select/u-city-select.vue +2 -10
  34. package/components/u-col/types.ts +30 -0
  35. package/components/u-col/u-col.vue +2 -14
  36. package/components/u-collapse/types.ts +31 -0
  37. package/components/u-collapse/u-collapse.vue +2 -16
  38. package/components/u-collapse-item/types.ts +25 -0
  39. package/components/u-collapse-item/u-collapse-item.vue +2 -16
  40. package/components/u-column-notice/types.ts +48 -0
  41. package/components/u-column-notice/u-column-notice.vue +2 -97
  42. package/components/u-count-down/types.ts +42 -0
  43. package/components/u-count-down/u-count-down.vue +2 -82
  44. package/components/u-count-to/types.ts +32 -0
  45. package/components/u-count-to/u-count-to.vue +2 -58
  46. package/components/u-divider/types.ts +31 -0
  47. package/components/u-divider/u-divider.vue +2 -22
  48. package/components/u-dropdown/types.ts +32 -0
  49. package/components/u-dropdown/u-dropdown.vue +2 -24
  50. package/components/u-dropdown-item/types.ts +27 -0
  51. package/components/u-dropdown-item/u-dropdown-item.vue +4 -16
  52. package/components/u-empty/types.ts +36 -0
  53. package/components/u-empty/u-empty.vue +3 -26
  54. package/components/u-field/types.ts +69 -0
  55. package/components/u-field/u-field.vue +2 -117
  56. package/components/u-form/types.ts +25 -0
  57. package/components/u-form/u-form.vue +2 -46
  58. package/components/u-form-item/types.ts +70 -0
  59. package/components/u-form-item/u-form-item.vue +2 -62
  60. package/components/u-full-screen/types.ts +14 -0
  61. package/components/u-full-screen/u-full-screen.vue +2 -0
  62. package/components/u-gap/types.ts +18 -0
  63. package/components/u-gap/u-gap.vue +2 -10
  64. package/components/u-grid/types.ts +19 -0
  65. package/components/u-grid/u-grid.vue +3 -11
  66. package/components/u-grid-item/types.ts +16 -0
  67. package/components/u-grid-item/u-grid-item.vue +2 -8
  68. package/components/u-icon/types.ts +62 -0
  69. package/components/u-icon/u-icon.vue +2 -123
  70. package/components/u-image/types.ts +39 -38
  71. package/components/u-index-anchor/types.ts +16 -0
  72. package/components/u-index-anchor/u-index-anchor.vue +2 -17
  73. package/components/u-index-list/types.ts +43 -0
  74. package/components/u-index-list/u-index-list.vue +13 -34
  75. package/components/u-input/types.ts +140 -0
  76. package/components/u-input/u-input.vue +2 -209
  77. package/components/u-keyboard/types.ts +40 -0
  78. package/components/u-keyboard/u-keyboard.vue +2 -32
  79. package/components/u-lazy-load/types.ts +37 -0
  80. package/components/u-lazy-load/u-lazy-load.vue +3 -58
  81. package/components/u-line/types.ts +44 -0
  82. package/components/u-line/u-line.vue +2 -14
  83. package/components/u-line-progress/types.ts +58 -0
  84. package/components/u-line-progress/u-line-progress.vue +2 -21
  85. package/components/u-link/types.ts +43 -0
  86. package/components/u-link/u-link.vue +2 -14
  87. package/components/u-loading/types.ts +35 -0
  88. package/components/u-loading/u-loading.vue +2 -23
  89. package/components/u-loadmore/types.ts +79 -0
  90. package/components/u-loadmore/u-loadmore.vue +2 -67
  91. package/components/u-mask/types.ts +43 -0
  92. package/components/u-mask/u-mask.vue +2 -33
  93. package/components/u-message-input/types.ts +74 -0
  94. package/components/u-message-input/u-message-input.vue +2 -62
  95. package/components/u-modal/types.ts +118 -0
  96. package/components/u-modal/u-modal.vue +2 -86
  97. package/components/u-navbar/types.ts +103 -0
  98. package/components/u-navbar/u-navbar.vue +2 -90
  99. package/components/u-no-network/types.ts +28 -0
  100. package/components/u-no-network/u-no-network.vue +2 -23
  101. package/components/u-notice-bar/types.ts +111 -0
  102. package/components/u-notice-bar/u-notice-bar.vue +2 -102
  103. package/components/u-number-box/types.ts +42 -0
  104. package/components/u-number-box/u-number-box.vue +2 -34
  105. package/components/u-number-keyboard/types.ts +26 -0
  106. package/components/u-number-keyboard/u-number-keyboard.vue +2 -8
  107. package/components/u-picker/types.ts +111 -0
  108. package/components/u-picker/u-picker.vue +3 -174
  109. package/components/u-popup/types.ts +59 -0
  110. package/components/u-popup/u-popup.vue +2 -47
  111. package/components/u-radio/types.ts +25 -0
  112. package/components/u-radio/u-radio.vue +2 -16
  113. package/components/u-radio-group/types.ts +29 -0
  114. package/components/u-radio-group/u-radio-group.vue +2 -20
  115. package/components/u-rate/types.ts +40 -0
  116. package/components/u-rate/u-rate.vue +2 -124
  117. package/components/u-read-more/types.ts +35 -0
  118. package/components/u-read-more/u-read-more.vue +2 -51
  119. package/components/u-row/types.ts +20 -0
  120. package/components/u-row/u-row.vue +2 -10
  121. package/components/u-row-notice/types.ts +39 -0
  122. package/components/u-row-notice/u-row-notice.vue +2 -72
  123. package/components/u-search/types.ts +53 -0
  124. package/components/u-search/u-search.vue +2 -44
  125. package/components/u-section/types.ts +32 -0
  126. package/components/u-section/u-section.vue +2 -52
  127. package/components/u-select/types.ts +43 -0
  128. package/components/u-select/u-select.vue +2 -34
  129. package/components/u-skeleton/types.ts +20 -0
  130. package/components/u-skeleton/u-skeleton.vue +2 -27
  131. package/components/u-slider/types.ts +32 -0
  132. package/components/u-slider/u-slider.vue +2 -57
  133. package/components/u-steps/types.ts +28 -0
  134. package/components/u-steps/u-steps.vue +2 -42
  135. package/components/u-sticky/types.ts +22 -0
  136. package/components/u-sticky/u-sticky.vue +2 -32
  137. package/components/u-subsection/types.ts +36 -0
  138. package/components/u-subsection/u-subsection.vue +2 -62
  139. package/components/u-swipe-action/types.ts +50 -0
  140. package/components/u-swipe-action/u-swipe-action.vue +2 -39
  141. package/components/u-swiper/types.ts +47 -0
  142. package/components/u-swiper/u-swiper.vue +2 -41
  143. package/components/u-switch/types.ts +28 -0
  144. package/components/u-switch/u-switch.vue +2 -20
  145. package/components/u-tabbar/types.ts +36 -0
  146. package/components/u-tabbar/u-tabbar.vue +6 -75
  147. package/components/u-table/types.ts +25 -0
  148. package/components/u-table/u-table.vue +2 -51
  149. package/components/u-tabs/types.ts +51 -0
  150. package/components/u-tabs/u-tabs.vue +6 -44
  151. package/components/u-tabs-swiper/types.ts +53 -0
  152. package/components/u-tabs-swiper/u-tabs-swiper.vue +3 -50
  153. package/components/u-tag/types.ts +37 -0
  154. package/components/u-tag/u-tag.vue +2 -28
  155. package/components/u-td/types.ts +12 -0
  156. package/components/u-td/u-td.vue +2 -9
  157. package/components/u-th/types.ts +12 -0
  158. package/components/u-th/u-th.vue +2 -9
  159. package/components/u-time-line-item/types.ts +14 -0
  160. package/components/u-time-line-item/u-time-line-item.vue +2 -12
  161. package/components/u-toast/types.ts +35 -3
  162. package/components/u-toast/u-toast.vue +2 -7
  163. package/components/u-top-tips/types.ts +14 -0
  164. package/components/u-top-tips/u-top-tips.vue +17 -22
  165. package/components/u-tr/types.ts +8 -0
  166. package/components/u-tr/u-tr.vue +3 -0
  167. package/components/u-upload/types.ts +71 -0
  168. package/components/u-upload/u-upload.vue +6 -67
  169. package/components/u-verification-code/types.ts +22 -0
  170. package/components/u-verification-code/u-verification-code.vue +2 -32
  171. package/components/u-waterfall/types.ts +16 -0
  172. package/components/u-waterfall/u-waterfall.vue +2 -18
  173. package/package.json +1 -1
  174. package/types/global.d.ts +200 -0
@@ -15,6 +15,7 @@
15
15
 
16
16
  <script setup lang="ts">
17
17
  import { computed } from 'vue';
18
+ import { TagProps } from './types';
18
19
 
19
20
  defineOptions({
20
21
  name: 'u-tag'
@@ -45,34 +46,7 @@ const emit = defineEmits<{
45
46
  (e: 'close', index: string | number): void;
46
47
  }>();
47
48
 
48
- const props = defineProps({
49
- /** 标签类型 info、primary、success、warning、error */
50
- type: { type: String, default: 'primary' },
51
- /** 是否禁用这个标签,禁用的话,会屏蔽点击事件 */
52
- disabled: { type: [Boolean, String], default: false },
53
- /** 标签的大小,分为default(默认),mini(较小) */
54
- size: { type: String, default: 'default' },
55
- /** tag的形状,circle(两边半圆形), square(方形,带圆角),circleLeft(左边是半圆),circleRight(右边是半圆) */
56
- shape: { type: String, default: 'square' },
57
- /** 标签文字 */
58
- text: { type: [String, Number], default: '' },
59
- /** 背景颜色,默认为空字符串,即不处理 */
60
- bgColor: { type: String, default: '' },
61
- /** 标签字体颜色,默认为空字符串,即不处理 */
62
- color: { type: String, default: '' },
63
- /** 镂空形式标签的边框颜色 */
64
- borderColor: { type: String, default: '' },
65
- /** 关闭按钮图标的颜色 */
66
- closeColor: { type: String, default: '' },
67
- /** 点击时返回的索引值,用于区分例遍的数组哪个元素被点击了 */
68
- index: { type: [Number, String], default: '' },
69
- /** 模式选择,dark|light|plain */
70
- mode: { type: String, default: 'light' },
71
- /** 是否可关闭 */
72
- closeable: { type: Boolean, default: false },
73
- /** 是否显示 */
74
- show: { type: Boolean, default: true }
75
- });
49
+ const props = defineProps(TagProps);
76
50
 
77
51
  /**
78
52
  * 计算 tag 的自定义样式
@@ -0,0 +1,12 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * TdProps td props 类型定义
5
+ * @description 表格单元格组件,支持宽度自定义
6
+ */
7
+ export const TdProps = {
8
+ /** 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比 */
9
+ width: { type: [Number, String] as PropType<number | string>, default: 'auto' }
10
+ };
11
+
12
+ export type TdProps = ExtractPropTypes<typeof TdProps>;
@@ -7,6 +7,7 @@
7
7
  <script setup lang="ts">
8
8
  import { ref, onMounted, getCurrentInstance } from 'vue';
9
9
  import { $u } from '../..';
10
+ import { TdProps } from './types';
10
11
 
11
12
  defineOptions({ name: 'u-td' });
12
13
 
@@ -18,15 +19,7 @@ defineOptions({ name: 'u-td' });
18
19
  * @example <u-td>二年级</u-td>
19
20
  */
20
21
 
21
- const props = defineProps({
22
- /**
23
- * 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
24
- */
25
- width: {
26
- type: [Number, String],
27
- default: 'auto'
28
- }
29
- });
22
+ const props = defineProps(TdProps);
30
23
 
31
24
  /**
32
25
  * 组合式API变量声明
@@ -0,0 +1,12 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * ThProps th props 类型定义
5
+ * @description 表格表头单元格组件,支持宽度自定义
6
+ */
7
+ export const ThProps = {
8
+ /** 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比 */
9
+ width: { type: [Number, String] as PropType<number | string>, default: '' }
10
+ };
11
+
12
+ export type ThProps = ExtractPropTypes<typeof ThProps>;
@@ -7,6 +7,7 @@
7
7
  <script setup lang="ts">
8
8
  import { ref, onMounted, getCurrentInstance } from 'vue';
9
9
  import { $u } from '../..';
10
+ import { ThProps } from './types';
10
11
 
11
12
  defineOptions({ name: 'u-th' });
12
13
 
@@ -18,15 +19,7 @@ defineOptions({ name: 'u-th' });
18
19
  * @example 暂无示例
19
20
  */
20
21
 
21
- const props = defineProps({
22
- /**
23
- * 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
24
- */
25
- width: {
26
- type: [Number, String],
27
- default: ''
28
- }
29
- });
22
+ const props = defineProps(ThProps);
30
23
 
31
24
  const thStyle = ref<Record<string, any>>({}); // 标题单元格样式
32
25
  let parent: any = null; // 父组件实例
@@ -0,0 +1,14 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * TimeLineItemProps 时间轴节点 props 类型定义
5
+ * @description 时间轴节点组件,支持自定义节点颜色、位置
6
+ */
7
+ export const TimeLineItemProps = {
8
+ /** 节点的背景颜色 */
9
+ bgColor: { type: String, default: '#ffffff' },
10
+ /** 节点左边图标绝对定位的top值,单位rpx */
11
+ nodeTop: { type: [String, Number] as PropType<string | number>, default: '' }
12
+ };
13
+
14
+ export type TimeLineItemProps = ExtractPropTypes<typeof TimeLineItemProps>;
@@ -11,6 +11,7 @@
11
11
 
12
12
  <script setup lang="ts">
13
13
  import { computed } from 'vue';
14
+ import { TimeLineItemProps } from './types';
14
15
 
15
16
  defineOptions({ name: 'u-time-line-item' });
16
17
 
@@ -27,18 +28,7 @@ defineOptions({ name: 'u-time-line-item' });
27
28
  * 节点的背景颜色
28
29
  * @default "#ffffff"
29
30
  */
30
- const props = defineProps({
31
- /** 节点的背景颜色 */
32
- bgColor: {
33
- type: String,
34
- default: '#ffffff'
35
- },
36
- /** 节点左边图标绝对定位的top值,单位rpx */
37
- nodeTop: {
38
- type: [String, Number],
39
- default: ''
40
- }
41
- });
31
+ const props = defineProps(TimeLineItemProps);
42
32
 
43
33
  /**
44
34
  * 计算节点样式
@@ -1,4 +1,36 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { ThemeType, ToastPosition } from '../../types/global';
3
+
4
+ /**
5
+ * ToastProps toast props 类型定义
6
+ * @description 消息提示组件,支持 z-index 及多种配置项
7
+ */
8
+ export const ToastProps = {
9
+ /** 层级 z-index */
10
+ zIndex: { type: [Number, String] as PropType<number | string>, default: '' },
11
+ /** 提示类型,success/warning/error/loading 等 */
12
+ type: { type: String as PropType<ThemeType | 'default'>, default: '' },
13
+ /** 显示时长,单位ms */
14
+ duration: { type: Number, default: 2000 },
15
+ /** 是否显示图标 */
16
+ icon: { type: Boolean, default: true },
17
+ /** 显示位置,center/top/bottom */
18
+ position: { type: String as PropType<ToastPosition>, default: 'center' },
19
+ /** 关闭时的回调函数 */
20
+ callback: { type: Function as PropType<(() => void) | null>, default: null },
21
+ /** 是否返回上一页 */
22
+ back: { type: Boolean, default: false },
23
+ /** 是否为tab页面跳转 */
24
+ isTab: { type: Boolean, default: false },
25
+ /** 跳转的url */
26
+ url: { type: String, default: '' },
27
+ /** 跳转参数对象 */
28
+ params: { type: Object as PropType<Record<string, any>>, default: () => ({}) }
29
+ };
30
+
31
+ export type ToastProps = ExtractPropTypes<typeof ToastProps>;
32
+
1
33
  export type ToastExpose = {
2
- show: (options: Record<string, any>) => void
3
- hide: () => void
4
- }
34
+ show: (options: Record<string, any>) => void;
35
+ hide: () => void;
36
+ };
@@ -17,6 +17,7 @@
17
17
  import { ref, computed } from 'vue';
18
18
  import { $u } from '../..';
19
19
  import type { ToastExpose } from './types';
20
+ import { ToastProps } from './types';
20
21
 
21
22
  defineOptions({
22
23
  name: 'u-toast'
@@ -30,13 +31,7 @@ defineOptions({
30
31
  * @event {Function} show 显示toast,如需一进入页面就显示toast,请在onReady生命周期调用
31
32
  * @example <u-toast ref="uToast" />
32
33
  */
33
- const props = defineProps({
34
- /** z-index值 */
35
- zIndex: {
36
- type: [Number, String],
37
- default: ''
38
- }
39
- });
34
+ const props = defineProps(ToastProps);
40
35
 
41
36
  // 是否显示toast
42
37
  const isShow = ref(false);
@@ -0,0 +1,14 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * TopTipsProps top-tips props 类型定义
5
+ * @description 顶部提示组件,支持导航栏高度、z-index
6
+ */
7
+ export const TopTipsProps = {
8
+ /** 导航栏高度,用于提示的初始化 */
9
+ navbarHeight: { type: [Number, String] as PropType<number | string>, default: 0 },
10
+ /** z-index值 */
11
+ zIndex: { type: [Number, String] as PropType<number | string>, default: '' }
12
+ };
13
+
14
+ export type TopTipsProps = ExtractPropTypes<typeof TopTipsProps>;
@@ -5,6 +5,7 @@
5
5
  <script setup lang="ts">
6
6
  import { ref, computed } from 'vue';
7
7
  import { $u } from '../..';
8
+ import { TopTipsProps } from './types';
8
9
 
9
10
  defineOptions({ name: 'u-top-tips' });
10
11
 
@@ -17,27 +18,7 @@ defineOptions({ name: 'u-top-tips' });
17
18
  * @example <u-top-tips ref="uTips"></u-top-tips>
18
19
  */
19
20
 
20
- const props = defineProps({
21
- /** 导航栏高度,用于提示的初始化 */
22
- navbarHeight: {
23
- type: [Number, String],
24
- default() {
25
- let result = 0;
26
- // #ifndef H5
27
- result = 0;
28
- // #endif
29
- // #ifdef H5
30
- result = 44;
31
- // #endif
32
- return result;
33
- }
34
- },
35
- /** z-index值 */
36
- zIndex: {
37
- type: [Number, String],
38
- default: ''
39
- }
40
- });
21
+ const props = defineProps(TopTipsProps);
41
22
 
42
23
  let timer: number | null = null; // 定时器
43
24
  const isShow = ref(false); // 是否显示消息组件
@@ -47,8 +28,22 @@ const duration = ref(2000); // 组件显示的时间,单位为毫秒
47
28
 
48
29
  const uZIndex = computed(() => (props.zIndex ? props.zIndex : $u.zIndex.topTips));
49
30
 
31
+ const uNavbarHeight = computed(() => {
32
+ if (props.navbarHeight) {
33
+ return props.navbarHeight;
34
+ }
35
+ let height = 0;
36
+ // #ifndef H5
37
+ height = 0;
38
+ // #endif
39
+ // #ifdef H5
40
+ height = 44;
41
+ // #endif
42
+ return height;
43
+ });
44
+
50
45
  const tipStyle = computed(() => ({
51
- top: Number(props.navbarHeight) + 'px',
46
+ top: Number(uNavbarHeight.value) + 'px',
52
47
  zIndex: uZIndex.value
53
48
  }));
54
49
 
@@ -0,0 +1,8 @@
1
+ import type { ExtractPropTypes } from 'vue';
2
+
3
+ /**
4
+ * TrProps tr props 类型定义
5
+ * @description 表格行组件,无特殊 props
6
+ */
7
+ export const TrProps = {};
8
+ export type TrProps = ExtractPropTypes<typeof TrProps>;
@@ -5,6 +5,8 @@
5
5
  </template>
6
6
 
7
7
  <script setup lang="ts">
8
+ import { TrProps } from './types';
9
+
8
10
  defineOptions({ name: 'u-tr' });
9
11
 
10
12
  /**
@@ -13,6 +15,7 @@ defineOptions({ name: 'u-tr' });
13
15
  * @tutorial https://uview-pro.netlify.app/components/table.html
14
16
  * @example <u-tr></u-tr>
15
17
  */
18
+ const props = defineProps(TrProps);
16
19
  </script>
17
20
 
18
21
  <style lang="scss" scoped>
@@ -0,0 +1,71 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { ImgMode, UploadSizeType, UploadSourceType } from '../../types/global';
3
+
4
+ /**
5
+ * UploadProps upload props 类型定义
6
+ * @description 文件上传组件,支持多种自定义参数
7
+ */
8
+ export const UploadProps = {
9
+ /** 选择器宽度,单位rpx */
10
+ width: { type: [Number, String] as PropType<number | string>, default: 80 },
11
+ /** 选择器高度,单位rpx */
12
+ height: { type: [Number, String] as PropType<number | string>, default: 80 },
13
+ /** 最大上传数量 */
14
+ maxCount: { type: [Number, String] as PropType<number | string>, default: 9 },
15
+ /** 是否可删除 */
16
+ deletable: { type: Boolean, default: true },
17
+ /** 是否显示上传列表 */
18
+ showUploadList: { type: Boolean, default: true },
19
+ /** 是否显示上传进度 */
20
+ showProgress: { type: Boolean, default: true },
21
+ /** 删除按钮背景色 */
22
+ delBgColor: { type: String, default: '#f56c6c' },
23
+ /** 删除按钮图标 */
24
+ delIcon: { type: String, default: 'close' },
25
+ /** 删除按钮颜色 */
26
+ delColor: { type: String, default: '#fff' },
27
+ /** 图片裁剪模式 */
28
+ imageMode: { type: String as PropType<ImgMode>, default: 'aspectFill' },
29
+ /** 是否自定义上传按钮 */
30
+ customBtn: { type: Boolean, default: false },
31
+ /** 上传按钮文字 */
32
+ uploadText: { type: String, default: '上传' },
33
+ /** 上传地址 */
34
+ action: { type: String, default: '' },
35
+ /** 是否禁用 */
36
+ disabled: { type: Boolean, default: false },
37
+ /** 索引值 */
38
+ index: { type: [String, Number] as PropType<string | number>, default: '' },
39
+ /** 请求头对象 */
40
+ header: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
41
+ /** formData对象 */
42
+ formData: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
43
+ /** 文件字段名 */
44
+ name: { type: String, default: 'file' },
45
+ /** 压缩/原图,微信小程序有效 */
46
+ sizeType: { type: Array as PropType<UploadSizeType[]>, default: () => ['original', 'compressed'] },
47
+ /** 来源,相册/相机 */
48
+ sourceType: { type: Array as PropType<UploadSourceType[]>, default: () => ['album', 'camera'] },
49
+ /** 是否可预览大图 */
50
+ previewFullImage: { type: Boolean, default: true },
51
+ /** 是否支持多选 */
52
+ multiple: { type: Boolean, default: true },
53
+ /** 单个文件最大大小,单位B */
54
+ maxSize: { type: [Number, String] as PropType<number | string>, default: Number.MAX_VALUE },
55
+ /** 文件列表 */
56
+ fileList: { type: Array as PropType<any[]>, default: () => [] },
57
+ /** 限制文件类型 */
58
+ limitType: { type: Array as PropType<string[]>, default: () => [] },
59
+ /** 是否自动上传 */
60
+ autoUpload: { type: Boolean, default: true },
61
+ /** 是否显示提示 */
62
+ showTips: { type: Boolean, default: true },
63
+ /** 上传前钩子,返回true或Promise */
64
+ beforeUpload: { type: Function as PropType<((index: number, files: any[]) => boolean | Promise<any>) | null>, default: null },
65
+ /** 删除前钩子,返回true或Promise */
66
+ beforeRemove: { type: Function as PropType<((index: number, files: any[]) => boolean | Promise<any>) | null>, default: null },
67
+ /** 是否转为json格式 */
68
+ toJson: { type: Boolean, default: false }
69
+ };
70
+
71
+ export type UploadProps = ExtractPropTypes<typeof UploadProps>;
@@ -53,6 +53,7 @@
53
53
  <script setup lang="ts">
54
54
  import { ref, watch } from 'vue';
55
55
  import { $u } from '../..';
56
+ import { UploadProps } from './types';
56
57
 
57
58
  defineOptions({
58
59
  name: 'u-upload'
@@ -100,69 +101,7 @@ defineOptions({
100
101
  * @example <u-upload :action="action" :file-list="fileList" ></u-upload>
101
102
  */
102
103
 
103
- const props = defineProps({
104
- //是否显示组件自带的图片预览功能
105
- showUploadList: { type: Boolean, default: true },
106
- // 后端地址
107
- action: { type: String, default: '' },
108
- // 最大上传数量
109
- maxCount: { type: [String, Number], default: 52 },
110
- // 是否显示进度条
111
- showProgress: { type: Boolean, default: true },
112
- // 是否启用
113
- disabled: { type: Boolean, default: false },
114
- // 预览上传的图片时的裁剪模式,和image组件mode属性一致
115
- imageMode: { type: String, default: 'aspectFill' },
116
- // 头部信息
117
- header: { type: Object, default: () => ({}) },
118
- // 额外携带的参数
119
- formData: { type: Object, default: () => ({}) },
120
- // 上传的文件字段名
121
- name: { type: String, default: 'file' },
122
- // 所选的图片的尺寸, 可选值为original compressed
123
- sizeType: { type: Array, default: () => ['original', 'compressed'] },
124
- sourceType: { type: Array, default: () => ['album', 'camera'] },
125
- // 是否在点击预览图后展示全屏图片预览
126
- previewFullImage: { type: Boolean, default: true },
127
- // 是否开启图片多选,部分安卓机型不支持
128
- multiple: { type: Boolean, default: true },
129
- // 是否展示删除按钮
130
- deletable: { type: Boolean, default: true },
131
- // 文件大小限制,单位为byte
132
- maxSize: { type: [String, Number], default: Number.MAX_VALUE },
133
- // 显示已上传的文件列表
134
- fileList: { type: Array, default: () => [] },
135
- // 上传区域的提示文字
136
- uploadText: { type: String, default: '选择图片' },
137
- // 是否自动上传
138
- autoUpload: { type: Boolean, default: true },
139
- // 是否显示toast消息提示
140
- showTips: { type: Boolean, default: true },
141
- // 是否通过slot自定义传入选择图标的按钮
142
- customBtn: { type: Boolean, default: false },
143
- // 内部预览图片区域和选择图片按钮的区域宽度
144
- width: { type: [String, Number], default: 200 },
145
- // 内部预览图片区域和选择图片按钮的区域高度
146
- height: { type: [String, Number], default: 200 },
147
- // 右上角关闭按钮的背景颜色
148
- delBgColor: { type: String, default: '#fa3534' },
149
- // 右上角关闭按钮的叉号图标的颜色
150
- delColor: { type: String, default: '#ffffff' },
151
- // 右上角删除图标名称,只能为uView内置图标
152
- delIcon: { type: String, default: 'close' },
153
- // 如果上传后的返回值为json字符串,是否自动转json
154
- toJson: { type: Boolean, default: true },
155
- // 上传前的钩子,每个文件上传前都会执行
156
- beforeUpload: { type: Function, default: null },
157
- // 移除文件前的钩子
158
- beforeRemove: { type: Function, default: null },
159
- // 允许上传的图片后缀
160
- // 支付宝小程序真机选择图片的后缀为"image"
161
- // https://opendocs.alipay.com/mini/api/media-image
162
- limitType: { type: Array, default: () => ['png', 'jpg', 'jpeg', 'webp', 'gif', 'image'] },
163
- // 在各个回调事件中的最后一个参数返回,用于区别是哪一个组件的事件
164
- index: { type: [Number, String], default: '' }
165
- });
104
+ const props = defineProps(UploadProps);
166
105
 
167
106
  const emit = defineEmits([
168
107
  'on-list-change',
@@ -320,8 +259,8 @@ async function uploadFile(index = 0) {
320
259
  // 明白意思即可,无需纠结this.$u.$parent.call(this)的细节
321
260
  let beforeResponse = props.beforeUpload(index, lists.value);
322
261
  // 判断是否返回了promise
323
- if (!!beforeResponse && typeof beforeResponse.then === 'function') {
324
- await beforeResponse
262
+ if (typeof beforeResponse === 'object' && beforeResponse !== null && typeof (beforeResponse as Promise<any>).then === 'function') {
263
+ await (beforeResponse as Promise<any>)
325
264
  .then(() => {
326
265
  // promise返回成功,不进行动作,继续上传
327
266
  })
@@ -410,8 +349,8 @@ function deleteItem(index: number) {
410
349
  // 此处钩子执行 原理同before-remove参数,见上方注释
411
350
  let beforeResponse = props.beforeRemove(index, lists.value);
412
351
  // 判断是否返回了promise
413
- if (!!beforeResponse && typeof beforeResponse.then === 'function') {
414
- await beforeResponse
352
+ if (typeof beforeResponse === 'object' && beforeResponse !== null && typeof (beforeResponse as Promise<any>).then === 'function') {
353
+ await (beforeResponse as Promise<any>)
415
354
  .then(() => {
416
355
  // promise返回成功,不进行动作,继续上传
417
356
  handlerDeleteItem(index);
@@ -0,0 +1,22 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * VerificationCodeProps 验证码输入框 props 类型定义
5
+ * @description 验证码输入倒计时组件
6
+ */
7
+ export const VerificationCodeProps = {
8
+ /** 倒计时时长,单位秒 */
9
+ seconds: { type: [String, Number] as PropType<string | number>, default: 60 },
10
+ /** 开始时按钮文字 */
11
+ startText: { type: String, default: '获取验证码' },
12
+ /** 倒计时进行中按钮文字,X为剩余秒数 */
13
+ changeText: { type: String, default: 'X秒重新获取' },
14
+ /** 结束时按钮文字 */
15
+ endText: { type: String, default: '重新获取' },
16
+ /** 是否保持倒计时不中断(如页面切换) */
17
+ keepRunning: { type: Boolean, default: false },
18
+ /** 唯一标识key,用于区分多个验证码组件 */
19
+ uniqueKey: { type: String, default: '' }
20
+ };
21
+
22
+ export type VerificationCodeProps = ExtractPropTypes<typeof VerificationCodeProps>;
@@ -6,6 +6,7 @@
6
6
 
7
7
  <script setup lang="ts">
8
8
  import { ref, watch, onMounted, onBeforeUnmount } from 'vue';
9
+ import { VerificationCodeProps } from './types';
9
10
 
10
11
  defineOptions({ name: 'u-verification-code' });
11
12
 
@@ -27,38 +28,7 @@ defineOptions({ name: 'u-verification-code' });
27
28
 
28
29
  const emit = defineEmits(['change', 'start', 'end']);
29
30
 
30
- const props = defineProps({
31
- /** 倒计时总秒数 */
32
- seconds: {
33
- type: [String, Number],
34
- default: 60
35
- },
36
- /** 尚未开始时提示 */
37
- startText: {
38
- type: String,
39
- default: '获取验证码'
40
- },
41
- /** 正在倒计时中的提示 */
42
- changeText: {
43
- type: String,
44
- default: 'X秒重新获取'
45
- },
46
- /** 倒计时结束时的提示 */
47
- endText: {
48
- type: String,
49
- default: '重新获取'
50
- },
51
- /** 是否在H5刷新或各端返回再进入时继续倒计时 */
52
- keepRunning: {
53
- type: Boolean,
54
- default: false
55
- },
56
- /** 区分多个页面或多个倒计时组件本地存储的key */
57
- uniqueKey: {
58
- type: String,
59
- default: ''
60
- }
61
- });
31
+ const props = defineProps(VerificationCodeProps);
62
32
 
63
33
  /** 当前倒计时秒数 */
64
34
  const secNum = ref(Number(props.seconds));
@@ -0,0 +1,16 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * WaterfallProps waterfall props 类型定义
5
+ * @description 瀑布流组件,支持数据、间隔、idKey
6
+ */
7
+ export const WaterfallProps = {
8
+ /** 瀑布流数据数组,必填 */
9
+ modelValue: { type: Array as PropType<any[]>, required: true, default: () => [] },
10
+ /** 新增数据的动画间隔,单位ms */
11
+ addTime: { type: [Number, String] as PropType<number | string>, default: 200 },
12
+ /** 数据项的唯一标识key */
13
+ idKey: { type: String, default: 'id' }
14
+ };
15
+
16
+ export type WaterfallProps = ExtractPropTypes<typeof WaterfallProps>;
@@ -11,6 +11,7 @@
11
11
  <script setup lang="ts">
12
12
  import { ref, computed, watch, onMounted, getCurrentInstance } from 'vue';
13
13
  import { $u } from '../..';
14
+ import { WaterfallProps } from './types';
14
15
 
15
16
  defineOptions({ name: 'u-waterfall' });
16
17
 
@@ -25,24 +26,7 @@ defineOptions({ name: 'u-waterfall' });
25
26
 
26
27
  const emit = defineEmits(['update:modelValue']);
27
28
 
28
- const props = defineProps({
29
- /** 瀑布流数据 */
30
- modelValue: {
31
- type: Array as () => any[],
32
- required: true,
33
- default: () => []
34
- },
35
- /** 每次向结构插入数据的时间间隔,单位ms */
36
- addTime: {
37
- type: [Number, String],
38
- default: 200
39
- },
40
- /** id值,用于清除某一条数据时,根据此idKey名称找到并移除 */
41
- idKey: {
42
- type: String,
43
- default: 'id'
44
- }
45
- });
29
+ const props = defineProps(WaterfallProps);
46
30
 
47
31
  const leftList = ref<any[]>([]);
48
32
  const rightList = ref<any[]>([]);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-pro",
3
3
  "name": "uview-pro",
4
4
  "displayName": "uView Pro 基于Vue3+TS全面重构的UI组件库,拥有70+精选组件",
5
- "version": "0.0.7",
5
+ "version": "0.0.8",
6
6
  "description": "uView Pro,是全面支持Vue3的uni-app生态框架,70+精选组件已使用TypeScript重构,已全面支持uni-app Vue3.0",
7
7
  "main": "index.ts",
8
8
  "module": "index.ts",