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
@@ -60,6 +60,7 @@
60
60
 
61
61
  <script setup lang="ts">
62
62
  import { ref, computed, watch } from 'vue';
63
+ import { SelectProps } from './types';
63
64
 
64
65
  defineOptions({
65
66
  name: 'u-select'
@@ -87,40 +88,7 @@ defineOptions({
87
88
  * @example <u-select v-model="show" :list="list"></u-select>
88
89
  */
89
90
 
90
- const props = defineProps({
91
- /** 列数据 */
92
- list: { type: Array, default: () => [] },
93
- /** 是否显示边框 */
94
- border: { type: Boolean, default: true },
95
- /** 通过双向绑定控制组件的弹出与收起 */
96
- modelValue: { type: Boolean, default: false },
97
- /** "取消"按钮的颜色 */
98
- cancelColor: { type: String, default: '#606266' },
99
- /** "确定"按钮的颜色 */
100
- confirmColor: { type: String, default: '#2979ff' },
101
- /** 弹出的z-index值 */
102
- zIndex: { type: [String, Number], default: 0 },
103
- /** 是否开启底部安全区适配 */
104
- safeAreaInsetBottom: { type: Boolean, default: false },
105
- /** 是否允许通过点击遮罩关闭Picker */
106
- maskCloseAble: { type: Boolean, default: true },
107
- /** 提供的默认选中的下标 */
108
- defaultValue: { type: Array, default: () => [0] },
109
- /** 模式选择,single-column-单列,mutil-column-多列,mutil-column-auto-多列联动 */
110
- mode: { type: String, default: 'single-column' },
111
- /** 自定义value属性名 */
112
- valueName: { type: String, default: 'value' },
113
- /** 自定义label属性名 */
114
- labelName: { type: String, default: 'label' },
115
- /** 自定义多列联动模式的children属性名 */
116
- childName: { type: String, default: 'children' },
117
- /** 顶部标题 */
118
- title: { type: String, default: '' },
119
- /** 取消按钮的文字 */
120
- cancelText: { type: String, default: '取消' },
121
- /** 确认按钮的文字 */
122
- confirmText: { type: String, default: '确认' }
123
- });
91
+ const props = defineProps(SelectProps);
124
92
  const emit = defineEmits(['update:modelValue', 'confirm', 'cancel', 'click']);
125
93
  // 用于列改变时,保存当前的索引,下一次变化时比较得出是哪一列发生了变化
126
94
 
@@ -0,0 +1,20 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * SkeletonProps 骨架屏 props 类型定义
5
+ * @description 骨架屏用于页面数据加载时的占位
6
+ */
7
+ export const SkeletonProps = {
8
+ /** 骨架块状元素的背景颜色 */
9
+ elColor: { type: String, default: '#e5e5e5' },
10
+ /** 整个骨架屏页面的背景颜色 */
11
+ bgColor: { type: String, default: '#ffffff' },
12
+ /** 是否显示加载动画 */
13
+ animation: { type: Boolean, default: false },
14
+ /** 圆角值,只对类名为u-skeleton-fillet的元素生效 */
15
+ borderRadius: { type: [String, Number] as PropType<string | number>, default: 10 },
16
+ /** 是否显示骨架,true-显示,false-隐藏 */
17
+ loading: { type: Boolean, default: true }
18
+ };
19
+
20
+ export type SkeletonProps = ExtractPropTypes<typeof SkeletonProps>;
@@ -9,6 +9,7 @@
9
9
  <script setup lang="ts">
10
10
  import { ref, computed, onMounted, getCurrentInstance } from 'vue';
11
11
  import { $u } from '../..';
12
+ import { SkeletonProps } from './types';
12
13
 
13
14
  defineOptions({ name: 'u-skeleton' });
14
15
 
@@ -24,33 +25,7 @@ defineOptions({ name: 'u-skeleton' });
24
25
  * @example <u-skeleton :loading="true" :animation="true"></u-skeleton>
25
26
  */
26
27
 
27
- const props = defineProps({
28
- /** 骨架块状元素的背景颜色 */
29
- elColor: {
30
- type: String,
31
- default: '#e5e5e5'
32
- },
33
- /** 整个骨架屏页面的背景颜色 */
34
- bgColor: {
35
- type: String,
36
- default: '#ffffff'
37
- },
38
- /** 是否显示加载动画 */
39
- animation: {
40
- type: Boolean,
41
- default: false
42
- },
43
- /** 圆角值,只对类名为u-skeleton-fillet的元素生效,为数值,不带单位 */
44
- borderRadius: {
45
- type: [String, Number],
46
- default: 10
47
- },
48
- /** 是否显示骨架,true-显示,false-隐藏 */
49
- loading: {
50
- type: Boolean,
51
- default: true
52
- }
53
- });
28
+ const props = defineProps(SkeletonProps);
54
29
 
55
30
  const instance = getCurrentInstance();
56
31
  const windowWinth = ref(750); // 骨架屏宽度
@@ -0,0 +1,32 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * SliderProps 滑块选择器 props 类型定义
5
+ * @description 滑块选择器,支持自定义样式、步长、禁用等
6
+ */
7
+ export const SliderProps = {
8
+ /** 当前进度百分比值,范围0-100 */
9
+ modelValue: { type: [Number, String] as PropType<number | string>, default: 0 },
10
+ /** 是否禁用滑块 */
11
+ disabled: { type: Boolean, default: false },
12
+ /** 滑块宽度,高等于宽,单位rpx */
13
+ blockWidth: { type: [Number, String] as PropType<number | string>, default: 30 },
14
+ /** 最小值 */
15
+ min: { type: [Number, String] as PropType<number | string>, default: 0 },
16
+ /** 最大值 */
17
+ max: { type: [Number, String] as PropType<number | string>, default: 100 },
18
+ /** 步进值 */
19
+ step: { type: [Number, String] as PropType<number | string>, default: 1 },
20
+ /** 滑块条高度,单位rpx */
21
+ height: { type: [Number, String] as PropType<number | string>, default: 6 },
22
+ /** 进度条的激活部分颜色 */
23
+ activeColor: { type: String, default: '#2979ff' },
24
+ /** 进度条的背景颜色 */
25
+ inactiveColor: { type: String, default: '#c0c4cc' },
26
+ /** 滑块的背景颜色 */
27
+ blockColor: { type: String, default: '#ffffff' },
28
+ /** 用户对滑块的自定义颜色 */
29
+ blockStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) }
30
+ };
31
+
32
+ export type SliderProps = ExtractPropTypes<typeof SliderProps>;
@@ -58,68 +58,13 @@
58
58
  */
59
59
  import { ref, watch, onMounted, useSlots, getCurrentInstance } from 'vue';
60
60
  import { $u } from '../..';
61
+ import { SliderProps } from './types';
61
62
 
62
63
  defineOptions({ name: 'u-slider' });
63
64
 
64
65
  const emit = defineEmits(['update:modelValue', 'start', 'moving', 'end']);
65
66
 
66
- const props = defineProps({
67
- /** 当前进度百分比值,范围0-100 */
68
- modelValue: {
69
- type: [Number, String],
70
- default: 0
71
- },
72
- /** 是否禁用滑块 */
73
- disabled: {
74
- type: Boolean,
75
- default: false
76
- },
77
- /** 滑块宽度,高等于宽,单位rpx */
78
- blockWidth: {
79
- type: [Number, String],
80
- default: 30
81
- },
82
- /** 最小值 */
83
- min: {
84
- type: [Number, String],
85
- default: 0
86
- },
87
- /** 最大值 */
88
- max: {
89
- type: [Number, String],
90
- default: 100
91
- },
92
- /** 步进值 */
93
- step: {
94
- type: [Number, String],
95
- default: 1
96
- },
97
- /** 滑块条高度,单位rpx */
98
- height: {
99
- type: [Number, String],
100
- default: 6
101
- },
102
- /** 进度条的激活部分颜色 */
103
- activeColor: {
104
- type: String,
105
- default: '#2979ff'
106
- },
107
- /** 进度条的背景颜色 */
108
- inactiveColor: {
109
- type: String,
110
- default: '#c0c4cc'
111
- },
112
- /** 滑块的背景颜色 */
113
- blockColor: {
114
- type: String,
115
- default: '#ffffff'
116
- },
117
- /** 用户对滑块的自定义颜色 */
118
- blockStyle: {
119
- type: Object as () => Record<string, any>,
120
- default: () => ({})
121
- }
122
- });
67
+ const props = defineProps(SliderProps);
123
68
 
124
69
  const slots = useSlots();
125
70
  const instance = getCurrentInstance();
@@ -0,0 +1,28 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { StepDirection, StepMode, StepsListItem, ThemeType } from '../../types/global';
3
+
4
+ /**
5
+ * StepsProps 步骤条 props 类型定义
6
+ * @description 步骤条,支持横向/竖向、主题色、激活色等
7
+ */
8
+
9
+ export const StepsProps = {
10
+ /** 步骤条的类型,dot|number */
11
+ mode: { type: String as PropType<StepMode>, default: 'dot' },
12
+ /** 步骤条的数据 */
13
+ list: { type: Array as PropType<StepsListItem[]>, default: () => [] },
14
+ /** 主题类型, primary|success|info|warning|error */
15
+ type: { type: String as PropType<ThemeType>, default: 'primary' },
16
+ /** 当前哪一步是激活的 */
17
+ current: { type: [Number, String] as PropType<number | string>, default: 0 },
18
+ /** 激活步骤的颜色 */
19
+ activeColor: { type: String, default: '#2979ff' },
20
+ /** 未激活的颜色 */
21
+ unActiveColor: { type: String, default: '#909399' },
22
+ /** 自定义图标 */
23
+ icon: { type: String, default: 'checkmark' },
24
+ /** step的排列方向,row-横向,column-竖向 */
25
+ direction: { type: String as PropType<StepDirection>, default: 'row' }
26
+ };
27
+
28
+ export type StepsProps = ExtractPropTypes<typeof StepsProps>;
@@ -22,6 +22,7 @@
22
22
 
23
23
  <script setup lang="ts">
24
24
  import { computed } from 'vue';
25
+ import { StepsProps } from './types';
25
26
 
26
27
  defineOptions({ name: 'u-steps' });
27
28
 
@@ -40,48 +41,7 @@ defineOptions({ name: 'u-steps' });
40
41
  * @example <u-steps :list="numList" active-color="#fa3534"></u-steps>
41
42
  */
42
43
 
43
- const props = defineProps({
44
- /** 步骤条的类型,dot|number */
45
- mode: {
46
- type: String,
47
- default: 'dot'
48
- },
49
- /** 步骤条的数据 */
50
- list: {
51
- type: Array as () => { name: string }[],
52
- default: (): { name: string }[] => []
53
- },
54
- /** 主题类型, primary|success|info|warning|error */
55
- type: {
56
- type: String,
57
- default: 'primary'
58
- },
59
- /** 当前哪一步是激活的 */
60
- current: {
61
- type: [Number, String],
62
- default: 0
63
- },
64
- /** 激活步骤的颜色 */
65
- activeColor: {
66
- type: String,
67
- default: '#2979ff'
68
- },
69
- /** 未激活的颜色 */
70
- unActiveColor: {
71
- type: String,
72
- default: '#909399'
73
- },
74
- /** 自定义图标 */
75
- icon: {
76
- type: String,
77
- default: 'checkmark'
78
- },
79
- /** step的排列方向,row-横向,column-竖向 */
80
- direction: {
81
- type: String,
82
- default: 'row'
83
- }
84
- });
44
+ const props = defineProps(StepsProps);
85
45
 
86
46
  // 计算属性,计算当前步骤的索引值
87
47
  // 如果 current 是字符串,则转换为数字,否则直接使用数字
@@ -0,0 +1,22 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * StickyProps 吸顶组件 props 类型定义
5
+ * @description 吸顶组件,支持自定义吸顶距离、z-index、背景色等
6
+ */
7
+ export const StickyProps = {
8
+ /** 吸顶容器到顶部某个距离的时候,进行吸顶,在H5平台,NavigationBar为44px */
9
+ offsetTop: { type: [Number, String] as PropType<number | string>, default: 0 },
10
+ /** 列表中的索引值 */
11
+ index: { type: [Number, String] as PropType<number | string>, default: '' },
12
+ /** 是否开启吸顶功能 */
13
+ enable: { type: Boolean, default: true },
14
+ /** h5顶部导航栏的高度 */
15
+ h5NavHeight: { type: [Number, String] as PropType<number | string>, default: 44 },
16
+ /** 吸顶区域的背景颜色 */
17
+ bgColor: { type: String, default: '#ffffff' },
18
+ /** z-index值 */
19
+ zIndex: { type: [Number, String] as PropType<number | string>, default: '' }
20
+ };
21
+
22
+ export type StickyProps = ExtractPropTypes<typeof StickyProps>;
@@ -27,6 +27,7 @@
27
27
  <script setup lang="ts">
28
28
  import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount, getCurrentInstance } from 'vue';
29
29
  import { $u } from '../..';
30
+ import { StickyProps } from './types';
30
31
 
31
32
  defineOptions({ name: 'u-sticky' });
32
33
 
@@ -44,41 +45,10 @@ defineOptions({ name: 'u-sticky' });
44
45
  * @event unfixed 组件取消吸顶时触发
45
46
  * @example <u-sticky offset-top="200"><view>塞下秋来风景异,衡阳雁去无留意</view></u-sticky>
46
47
  */
48
+ const props = defineProps(StickyProps);
47
49
 
48
50
  const emit = defineEmits(['fixed', 'unfixed']);
49
51
 
50
- const props = defineProps({
51
- /** 吸顶容器到顶部某个距离的时候,进行吸顶,在H5平台,NavigationBar为44px */
52
- offsetTop: {
53
- type: [Number, String],
54
- default: 0
55
- },
56
- /** 列表中的索引值 */
57
- index: {
58
- type: [Number, String],
59
- default: ''
60
- },
61
- /** 是否开启吸顶功能 */
62
- enable: {
63
- type: Boolean,
64
- default: true
65
- },
66
- /** h5顶部导航栏的高度 */
67
- h5NavHeight: {
68
- type: [Number, String],
69
- default: 44
70
- },
71
- /** 吸顶区域的背景颜色 */
72
- bgColor: {
73
- type: String,
74
- default: '#ffffff'
75
- },
76
- /** z-index值 */
77
- zIndex: {
78
- type: [Number, String],
79
- default: ''
80
- }
81
- });
82
52
  const instance = getCurrentInstance();
83
53
  const fixed = ref(false);
84
54
  const height = ref<'auto' | number>('auto');
@@ -0,0 +1,36 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { SubsectionListItem, SubsectionMode } from '../../types/global';
3
+
4
+ /**
5
+ * SubsectionProps 分段器 props 类型定义
6
+ * @description 分段器,支持按钮/分段模式、动画、颜色等
7
+ */
8
+
9
+ export const SubsectionProps = {
10
+ /** tab的数据 */
11
+ list: { type: Array as PropType<Array<string | SubsectionListItem>>, default: () => [] },
12
+ /** 当前活动的tab的index */
13
+ current: { type: [Number, String] as PropType<number | string>, default: 0 },
14
+ /** 激活的颜色 */
15
+ activeColor: { type: String, default: '#303133' },
16
+ /** 未激活的颜色 */
17
+ inactiveColor: { type: String, default: '#606266' },
18
+ /** 模式选择,mode=button为按钮形式,mode=subsection时为分段模式 */
19
+ mode: { type: String as PropType<SubsectionMode>, default: 'button' },
20
+ /** 字体大小,单位rpx */
21
+ fontSize: { type: [Number, String] as PropType<number | string>, default: 28 },
22
+ /** 是否开启动画效果 */
23
+ animation: { type: Boolean, default: true },
24
+ /** 组件的高度,单位rpx */
25
+ height: { type: [Number, String] as PropType<number | string>, default: 70 },
26
+ /** 激活tab的字体是否加粗 */
27
+ bold: { type: Boolean, default: true },
28
+ /** mode=button时,组件背景颜色 */
29
+ bgColor: { type: String, default: '#eeeeef' },
30
+ /** mode = button时,滑块背景颜色 */
31
+ buttonColor: { type: String, default: '#ffffff' },
32
+ /** 在切换分段器的时候,是否让设备震一下 */
33
+ vibrateShort: { type: Boolean, default: false }
34
+ };
35
+
36
+ export type SubsectionProps = ExtractPropTypes<typeof SubsectionProps>;
@@ -17,6 +17,7 @@
17
17
  <script setup lang="ts">
18
18
  import { ref, computed, watch, onMounted, getCurrentInstance } from 'vue';
19
19
  import { $u } from '../..';
20
+ import { SubsectionProps } from './types';
20
21
 
21
22
  defineOptions({ name: 'u-subsection' });
22
23
 
@@ -46,68 +47,7 @@ interface ListItem {
46
47
  [key: string]: any;
47
48
  }
48
49
 
49
- const props = defineProps({
50
- /** tab的数据 */
51
- list: {
52
- type: Array as () => Array<string | ListItem>,
53
- default: () => []
54
- },
55
- /** 当前活动的tab的index */
56
- current: {
57
- type: [Number, String],
58
- default: 0
59
- },
60
- /** 激活的颜色 */
61
- activeColor: {
62
- type: String,
63
- default: '#303133'
64
- },
65
- /** 未激活的颜色 */
66
- inactiveColor: {
67
- type: String,
68
- default: '#606266'
69
- },
70
- /** 模式选择,mode=button为按钮形式,mode=subsection时为分段模式 */
71
- mode: {
72
- type: String,
73
- default: 'button'
74
- },
75
- /** 字体大小,单位rpx */
76
- fontSize: {
77
- type: [Number, String],
78
- default: 28
79
- },
80
- /** 是否开启动画效果 */
81
- animation: {
82
- type: Boolean,
83
- default: true
84
- },
85
- /** 组件的高度,单位rpx */
86
- height: {
87
- type: [Number, String],
88
- default: 70
89
- },
90
- /** 激活tab的字体是否加粗 */
91
- bold: {
92
- type: Boolean,
93
- default: true
94
- },
95
- /** mode=button时,组件背景颜色 */
96
- bgColor: {
97
- type: String,
98
- default: '#eeeeef'
99
- },
100
- /** mode = button时,滑块背景颜色 */
101
- buttonColor: {
102
- type: String,
103
- default: '#ffffff'
104
- },
105
- /** 在切换分段器的时候,是否让设备震一下 */
106
- vibrateShort: {
107
- type: Boolean,
108
- default: false
109
- }
110
- });
50
+ const props = defineProps(SubsectionProps);
111
51
 
112
52
  const emit = defineEmits<{ (e: 'change', index: number): void }>();
113
53
 
@@ -0,0 +1,50 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { SwipeActionOption } from '../../types/global';
3
+
4
+ /**
5
+ * swipeAction 左滑单元格 props 类型定义
6
+ * @description 该组件一般用于左滑唤出操作菜单的场景,用的最多的是左滑删除操作。
7
+ */
8
+
9
+ export const SwipeActionProps = {
10
+ /** index值,用于得知点击删除的是哪个按钮 */
11
+ index: {
12
+ type: [Number, String] as PropType<string | number>,
13
+ default: ''
14
+ },
15
+ /** 滑动按钮的宽度,单位为rpx */
16
+ btnWidth: {
17
+ type: [String, Number] as PropType<string | number>,
18
+ default: 180
19
+ },
20
+ /** 是否禁止某个action滑动 */
21
+ disabled: {
22
+ type: Boolean,
23
+ default: false
24
+ },
25
+ /** 打开或者关闭组件 */
26
+ show: {
27
+ type: Boolean,
28
+ default: false
29
+ },
30
+ /** 组件背景颜色 */
31
+ bgColor: {
32
+ type: String,
33
+ default: '#ffffff'
34
+ },
35
+ /** 是否使手机发生短促震动,目前只在iOS的微信小程序有效(2020-05-06) */
36
+ vibrateShort: {
37
+ type: Boolean,
38
+ default: false
39
+ },
40
+ /** 按钮操作参数 */
41
+ options: {
42
+ type: Array as PropType<SwipeActionOption[]>,
43
+ default: () => []
44
+ }
45
+ };
46
+
47
+ /**
48
+ * swipeAction 组件 props 类型
49
+ */
50
+ export type SwipeActionProps = ExtractPropTypes<typeof SwipeActionProps>;
@@ -26,6 +26,7 @@
26
26
  <script lang="ts" setup>
27
27
  import { ref, computed, watch, nextTick, onMounted } from 'vue';
28
28
  import { $u } from '../..';
29
+ import { SwipeActionProps } from './types';
29
30
 
30
31
  defineOptions({ name: 'u-swipe-action' });
31
32
 
@@ -45,45 +46,7 @@ defineOptions({ name: 'u-swipe-action' });
45
46
  * @event {Function} open 组件触发打开状态时
46
47
  * @example <u-swipe-action btn-text="收藏">...</u-swipe-action>
47
48
  */
48
-
49
- const props = defineProps({
50
- /** index值,用于得知点击删除的是哪个按钮 */
51
- index: {
52
- type: [Number, String],
53
- default: ''
54
- },
55
- /** 滑动按钮的宽度,单位为rpx */
56
- btnWidth: {
57
- type: [String, Number],
58
- default: 180
59
- },
60
- /** 是否禁止某个action滑动 */
61
- disabled: {
62
- type: Boolean,
63
- default: false
64
- },
65
- /** 打开或者关闭组件 */
66
- show: {
67
- type: Boolean,
68
- default: false
69
- },
70
- /** 组件背景颜色 */
71
- bgColor: {
72
- type: String,
73
- default: '#ffffff'
74
- },
75
- /** 是否使手机发生短促震动,目前只在iOS的微信小程序有效(2020-05-06) */
76
- vibrateShort: {
77
- type: Boolean,
78
- default: false
79
- },
80
- /** 按钮操作参数 */
81
- options: {
82
- type: Array as () => Array<{ text: string; style?: Record<string, any> }>,
83
- default: () => []
84
- }
85
- });
86
-
49
+ const props = defineProps(SwipeActionProps);
87
50
  const emit = defineEmits(['click', 'close', 'content-click', 'open']);
88
51
 
89
52
  // 组件内部状态
@@ -0,0 +1,47 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { ImgMode, SwiperIndicatorPosition, SwiperMode } from '../../types/global';
3
+
4
+ /**
5
+ * SwiperProps 轮播图 props 类型定义
6
+ * @description 轮播图,支持多种指示器、3D、自动播放等
7
+ */
8
+ export const SwiperProps = {
9
+ /** 轮播数据列表,数组对象 */
10
+ list: { type: Array as PropType<Array<Record<string, any>>>, default: () => [] },
11
+ /** 是否显示标题 */
12
+ title: { type: Boolean, default: false },
13
+ /** 指示器配置对象 */
14
+ indicator: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
15
+ /** 圆角,单位rpx */
16
+ borderRadius: { type: [Number, String] as PropType<number | string>, default: 8 },
17
+ /** 自动切换时间间隔,单位ms */
18
+ interval: { type: [String, Number] as PropType<number | string>, default: 3000 },
19
+ /** 指示器类型,round/dot/line等 */
20
+ mode: { type: String as PropType<SwiperMode>, default: 'round' },
21
+ /** 轮播高度,单位rpx */
22
+ height: { type: [Number, String] as PropType<number | string>, default: 250 },
23
+ /** 指示器位置 */
24
+ indicatorPos: { type: String as PropType<SwiperIndicatorPosition>, default: 'bottomCenter' },
25
+ /** 是否开启3D效果 */
26
+ effect3d: { type: Boolean, default: false },
27
+ /** 3D模式下前一项的边距,单位rpx */
28
+ effect3dPreviousMargin: { type: [Number, String] as PropType<number | string>, default: 50 },
29
+ /** 是否自动播放 */
30
+ autoplay: { type: Boolean, default: true },
31
+ /** 切换动画时长,单位ms */
32
+ duration: { type: [Number, String] as PropType<number | string>, default: 500 },
33
+ /** 是否循环播放 */
34
+ circular: { type: Boolean, default: true },
35
+ /** 图片裁剪模式 */
36
+ imgMode: { type: String as PropType<ImgMode>, default: 'aspectFill' },
37
+ /** 轮播项对象的图片字段名 */
38
+ name: { type: String, default: 'image' },
39
+ /** 轮播背景色 */
40
+ bgColor: { type: String, default: '#f3f4f6' },
41
+ /** 当前激活项索引 */
42
+ current: { type: [Number, String] as PropType<number | string>, default: 0 },
43
+ /** 标题样式对象 */
44
+ titleStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) }
45
+ };
46
+
47
+ export type SwiperProps = ExtractPropTypes<typeof SwiperProps>;