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
@@ -0,0 +1,26 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { NumberKeyboardMode } from '../../types/global';
3
+
4
+ /**
5
+ * NumberKeyboardProps 数字/身份证键盘 props 类型定义
6
+ * @description 支持数字、身份证、带小数点等多种模式,支持乱序,支持长按退格。
7
+ */
8
+ export const NumberKeyboardProps = {
9
+ /** 键盘的类型,number-数字键盘,card-身份证键盘 */
10
+ mode: {
11
+ type: String as PropType<NumberKeyboardMode>,
12
+ default: 'number'
13
+ },
14
+ /** 是否显示键盘的"."符号 */
15
+ dotEnabled: {
16
+ type: Boolean,
17
+ default: true
18
+ },
19
+ /** 是否打乱键盘按键的顺序 */
20
+ random: {
21
+ type: Boolean,
22
+ default: false
23
+ }
24
+ };
25
+
26
+ export type NumberKeyboardProps = ExtractPropTypes<typeof NumberKeyboardProps>;
@@ -25,6 +25,7 @@
25
25
  <script setup lang="ts">
26
26
  import { computed } from 'vue';
27
27
  import { $u } from '../..';
28
+ import { NumberKeyboardProps } from './types';
28
29
 
29
30
  defineOptions({
30
31
  name: 'u-number-keyboard'
@@ -39,15 +40,8 @@ defineOptions({
39
40
  * @event {Function} change 按键被点击
40
41
  * @event {Function} backspace 退格键被点击
41
42
  */
43
+ const props = defineProps(NumberKeyboardProps);
42
44
 
43
- const props = defineProps({
44
- /** 键盘的类型,number-数字键盘,card-身份证键盘 */
45
- mode: { type: String, default: 'number' },
46
- /** 是否显示键盘的"."符号 */
47
- dotEnabled: { type: Boolean, default: true },
48
- /** 是否打乱键盘按键的顺序 */
49
- random: { type: Boolean, default: false }
50
- });
51
45
  const emit = defineEmits(['change', 'backspace']);
52
46
 
53
47
  const backspace = 'backspace'; // 退格键内容
@@ -0,0 +1,111 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { PickerMode, PickerParams } from '../../types/global';
3
+
4
+ /**
5
+ * PickerProps 选择器 props 类型定义
6
+ * @description 支持时间、地区、单列、多列等多种模式
7
+ */
8
+ export const PickerProps = {
9
+ /** picker中需要显示的参数 */
10
+ params: {
11
+ type: Object as PropType<PickerParams>,
12
+ default: () => ({ timestamp: true })
13
+ },
14
+ /** 当mode=selector或者mode=multiSelector时,提供的数组 */
15
+ range: {
16
+ type: Array as PropType<any[]>,
17
+ default: () => []
18
+ },
19
+ /** 当mode=selector或者mode=multiSelector时,提供的默认选中的下标 */
20
+ defaultSelector: {
21
+ type: Array as PropType<any[]>,
22
+ default: () => [0]
23
+ },
24
+ /** 当 range 是一个 Array<Object> 时,通过 range-key 来指定 Object 中 key 的值作为选择器显示内容 */
25
+ rangeKey: {
26
+ type: String,
27
+ default: ''
28
+ },
29
+ /** 模式选择,region-地区类型,time-时间类型,selector-单列模式,multiSelector-多列模式 */
30
+ mode: {
31
+ type: String as PropType<PickerMode>,
32
+ default: 'time'
33
+ },
34
+ /** 年份开始时间 */
35
+ startYear: {
36
+ type: [String, Number] as PropType<number | string>,
37
+ default: 1950
38
+ },
39
+ /** 年份结束时间 */
40
+ endYear: {
41
+ type: [String, Number] as PropType<number | string>,
42
+ default: 2050
43
+ },
44
+ /** "取消"按钮的颜色 */
45
+ cancelColor: {
46
+ type: String,
47
+ default: '#606266'
48
+ },
49
+ /** "确定"按钮的颜色 */
50
+ confirmColor: {
51
+ type: String,
52
+ default: '#2979ff'
53
+ },
54
+ /** 默认显示的时间,2025-07-02 || 2025-07-02 13:01:00 || 2025/07/02 */
55
+ defaultTime: {
56
+ type: String,
57
+ default: ''
58
+ },
59
+ /** 默认显示的地区,可传类似["河北省", "秦皇岛市", "北戴河区"] */
60
+ defaultRegion: {
61
+ type: Array as PropType<any[]>,
62
+ default: () => []
63
+ },
64
+ /** 时间模式时,是否显示后面的年月日中文提示 */
65
+ showTimeTag: {
66
+ type: Boolean,
67
+ default: true
68
+ },
69
+ /** 默认显示地区的编码,defaultRegion和areaCode同时存在,areaCode优先,可传类似["13", "1303", "130304"] */
70
+ areaCode: {
71
+ type: Array as PropType<any[]>,
72
+ default: () => []
73
+ },
74
+ /** 是否开启底部安全区适配 */
75
+ safeAreaInsetBottom: {
76
+ type: Boolean,
77
+ default: false
78
+ },
79
+ /** 是否允许通过点击遮罩关闭Picker */
80
+ maskCloseAble: {
81
+ type: Boolean,
82
+ default: true
83
+ },
84
+ /** 通过双向绑定控制组件的弹出与收起 */
85
+ modelValue: {
86
+ type: [Boolean, String, Number, Array, Object] as PropType<any>,
87
+ default: false
88
+ },
89
+ /** 弹出的z-index值 */
90
+ zIndex: {
91
+ type: [String, Number] as PropType<number | string>,
92
+ default: 0
93
+ },
94
+ /** 顶部标题 */
95
+ title: {
96
+ type: String,
97
+ default: ''
98
+ },
99
+ /** 取消按钮的文字 */
100
+ cancelText: {
101
+ type: String,
102
+ default: '取消'
103
+ },
104
+ /** 确认按钮的文字 */
105
+ confirmText: {
106
+ type: String,
107
+ default: '确认'
108
+ }
109
+ };
110
+
111
+ export type PickerProps = ExtractPropTypes<typeof PickerProps>;
@@ -106,6 +106,7 @@ import { ref, computed, watch, onMounted, nextTick } from 'vue';
106
106
  import provinces from '../../libs/util/province';
107
107
  import citys from '../../libs/util/city';
108
108
  import areas from '../../libs/util/area';
109
+ import { PickerProps } from './types';
109
110
 
110
111
  defineOptions({
111
112
  name: 'u-picker'
@@ -137,179 +138,7 @@ defineOptions({
137
138
  * @event {Function} cancel 点击取消按钮,返回当前选择的值
138
139
  * @example <u-picker v-model="show" mode="time"></u-picker>
139
140
  */
140
- const props = defineProps({
141
- /**
142
- * picker中需要显示的参数
143
- * @default { year: true, month: true, day: true, hour: false, minute: false, second: false, province: true, city: true, area: true, timestamp: true }
144
- */
145
- params: {
146
- type: Object,
147
- default: () => ({
148
- year: true,
149
- month: true,
150
- day: true,
151
- hour: false,
152
- minute: false,
153
- second: false,
154
- province: true,
155
- city: true,
156
- area: true,
157
- timestamp: true
158
- })
159
- },
160
- /**
161
- * 当mode=selector或者mode=multiSelector时,提供的数组
162
- * @default []
163
- */
164
- range: {
165
- type: Array,
166
- default: () => []
167
- },
168
- /**
169
- * 当mode=selector或者mode=multiSelector时,提供的默认选中的下标
170
- * @default [0]
171
- */
172
- defaultSelector: {
173
- type: Array,
174
- default: () => [0]
175
- },
176
- /**
177
- * 当 range 是一个 Array<Object> 时,通过 range-key 来指定 Object 中 key 的值作为选择器显示内容
178
- * @default ''
179
- */
180
- rangeKey: {
181
- type: String,
182
- default: ''
183
- },
184
- /**
185
- * 模式选择,region-地区类型,time-时间类型,selector-单列模式,multiSelector-多列模式
186
- * @default 'time'
187
- */
188
- mode: {
189
- type: String,
190
- default: 'time'
191
- },
192
- /**
193
- * 年份开始时间
194
- * @default 1950
195
- */
196
- startYear: {
197
- type: [String, Number],
198
- default: 1950
199
- },
200
- /**
201
- * 年份结束时间
202
- * @default 2050
203
- */
204
- endYear: {
205
- type: [String, Number],
206
- default: 2050
207
- },
208
- /**
209
- * "取消"按钮的颜色
210
- * @default '#606266'
211
- */
212
- cancelColor: {
213
- type: String,
214
- default: '#606266'
215
- },
216
- /**
217
- * "确定"按钮的颜色
218
- * @default '#2979ff'
219
- */
220
- confirmColor: {
221
- type: String,
222
- default: '#2979ff'
223
- },
224
- /**
225
- * 默认显示的时间,2025-07-02 || 2025-07-02 13:01:00 || 2025/07/02
226
- * @default ''
227
- */
228
- defaultTime: {
229
- type: String,
230
- default: ''
231
- },
232
- /**
233
- * 默认显示的地区,可传类似["河北省", "秦皇岛市", "北戴河区"]
234
- * @default []
235
- */
236
- defaultRegion: {
237
- type: Array,
238
- default: () => []
239
- },
240
- /**
241
- * 时间模式时,是否显示后面的年月日中文提示
242
- * @default true
243
- */
244
- showTimeTag: {
245
- type: Boolean,
246
- default: true
247
- },
248
- /**
249
- * 默认显示地区的编码,defaultRegion和areaCode同时存在,areaCode优先,可传类似["13", "1303", "130304"]
250
- * @default []
251
- */
252
- areaCode: {
253
- type: Array,
254
- default: () => []
255
- },
256
- /**
257
- * 是否开启底部安全区适配
258
- * @default false
259
- */
260
- safeAreaInsetBottom: {
261
- type: Boolean,
262
- default: false
263
- },
264
- /**
265
- * 是否允许通过点击遮罩关闭Picker
266
- * @default true
267
- */
268
- maskCloseAble: {
269
- type: Boolean,
270
- default: true
271
- },
272
- /**
273
- * 通过双向绑定控制组件的弹出与收起
274
- * @default false
275
- */
276
- modelValue: {
277
- type: Boolean,
278
- default: false
279
- },
280
- /**
281
- * 弹出的z-index值
282
- * @default 0
283
- */
284
- zIndex: {
285
- type: [String, Number],
286
- default: 0
287
- },
288
- /**
289
- * 顶部标题
290
- * @default ''
291
- */
292
- title: {
293
- type: String,
294
- default: ''
295
- },
296
- /**
297
- * 取消按钮的文字
298
- * @default '取消'
299
- */
300
- cancelText: {
301
- type: String,
302
- default: '取消'
303
- },
304
- /**
305
- * 确认按钮的文字
306
- * @default '确认'
307
- */
308
- confirmText: {
309
- type: String,
310
- default: '确认'
311
- }
312
- });
141
+ const props = defineProps(PickerProps);
313
142
 
314
143
  const popupValue = computed({
315
144
  get: () => props.modelValue,
@@ -530,7 +359,7 @@ function setDays() {
530
359
  let totalDays = new Date(year.value, month.value, 0).getDate();
531
360
  days.value = generateArray(1, totalDays);
532
361
  let index = 0;
533
- // 这里不能使用类似setMonths()中的this.valueArr.splice(this.valueArr.length - 1, xxx)做法
362
+ // 这里不能使用类似setMonths()中的this.valueArr.splice(this.valueArr.length - 1, 1, xxx)做法
534
363
  // 因为this.month和this.year变化时,会触发watch中的this.setDays(),导致this.valueArr.length计算有误
535
364
  if (props.params.year && props.params.month) index = 2;
536
365
  else if (props.params.month) index = 1;
@@ -0,0 +1,59 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { PopupCloseIconPos, PopupMode } from '../../types/global';
3
+
4
+ /**
5
+ * PopupMode 弹窗弹出方向类型
6
+ */
7
+
8
+ /**
9
+ * PopupProps 弹窗 props 类型定义
10
+ * @description 弹出层容器,支持多种弹出方向和自定义内容
11
+ */
12
+ export const PopupProps = {
13
+ /** 显示状态 */
14
+ show: { type: Boolean, default: false },
15
+ /** 弹出方向,left|right|top|bottom|center */
16
+ mode: { type: String as PropType<PopupMode>, default: 'left' },
17
+ /** 是否显示遮罩 */
18
+ mask: { type: Boolean, default: true },
19
+ /** 抽屉的宽度(mode=left|right),或者高度(mode=top|bottom),单位rpx,或者"auto",或者百分比"50%",表示由内容撑开高度或者宽度 */
20
+ length: { type: [Number, String] as PropType<number | string>, default: 'auto' },
21
+ /** 是否开启缩放动画,只在mode=center时有效 */
22
+ zoom: { type: Boolean, default: true },
23
+ /** 是否开启底部安全区适配,开启的话,会在iPhoneX机型底部添加一定的内边距 */
24
+ safeAreaInsetBottom: { type: Boolean, default: false },
25
+ /** 是否可以通过点击遮罩进行关闭 */
26
+ maskCloseAble: { type: Boolean, default: true },
27
+ /** 用户自定义样式 */
28
+ customStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
29
+ /** v-model 控制弹窗显示 */
30
+ modelValue: { type: Boolean, default: false },
31
+ /** 内部参数,解决多层调用报错不能修改props值的问题 */
32
+ popup: { type: Boolean, default: true },
33
+ /** 圆角 */
34
+ borderRadius: { type: [Number, String] as PropType<number | string>, default: 0 },
35
+ /** 弹窗z-index */
36
+ zIndex: { type: [Number, String] as PropType<number | string>, default: '' },
37
+ /** 是否显示关闭图标 */
38
+ closeable: { type: Boolean, default: false },
39
+ /** 关闭图标的名称,只能uView的内置图标 */
40
+ closeIcon: { type: String, default: 'close' },
41
+ /** 自定义关闭图标位置,top-left为左上角,top-right为右上角,bottom-left为左下角,bottom-right为右下角 */
42
+ closeIconPos: { type: String as PropType<PopupCloseIconPos>, default: 'top-right' },
43
+ /** 关闭图标的颜色 */
44
+ closeIconColor: { type: String, default: '#909399' },
45
+ /** 关闭图标的大小,单位rpx */
46
+ closeIconSize: { type: [String, Number] as PropType<number | string>, default: '30' },
47
+ /** 弹窗宽度 */
48
+ width: { type: String, default: '' },
49
+ /** 弹窗高度 */
50
+ height: { type: String, default: '' },
51
+ /** 负top定位,支持rpx/px/百分比 */
52
+ negativeTop: { type: [String, Number] as PropType<number | string>, default: 0 },
53
+ /** 遮罩自定义样式 */
54
+ maskCustomStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
55
+ /** 动画时长,单位ms */
56
+ duration: { type: [String, Number] as PropType<number | string>, default: 250 }
57
+ };
58
+
59
+ export type PopupProps = ExtractPropTypes<typeof PopupProps>;
@@ -48,6 +48,7 @@
48
48
  <script setup lang="ts">
49
49
  import { ref, computed, watch, onMounted, nextTick } from 'vue';
50
50
  import { $u } from '../..';
51
+ import { PopupProps } from './types';
51
52
 
52
53
  defineOptions({
53
54
  name: 'u-popup'
@@ -77,53 +78,7 @@ defineOptions({
77
78
  * @example <u-popup v-model="show"><view>出淤泥而不染,濯清涟而不妖</view></u-popup>
78
79
  */
79
80
 
80
- const props = defineProps({
81
- // 显示状态
82
- show: { type: Boolean, default: false },
83
- // 弹出方向,left|right|top|bottom|center
84
- mode: { type: String, default: 'left' },
85
- // 是否显示遮罩
86
- mask: { type: Boolean, default: true },
87
- // 抽屉的宽度(mode=left|right),或者高度(mode=top|bottom),单位rpx,或者"auto"
88
- // 或者百分比"50%",表示由内容撑开高度或者宽度
89
- length: { type: [Number, String], default: 'auto' },
90
- // 是否开启缩放动画,只在mode=center时有效
91
- zoom: { type: Boolean, default: true },
92
- // 是否开启底部安全区适配,开启的话,会在iPhoneX机型底部添加一定的内边距
93
- safeAreaInsetBottom: { type: Boolean, default: false },
94
- // 是否可以通过点击遮罩进行关闭
95
- maskCloseAble: { type: Boolean, default: true },
96
- // 用户自定义样式
97
- customStyle: { type: Object, default: () => ({}) },
98
- modelValue: { type: Boolean, default: false },
99
- // 此为内部参数,不在文档对外使用,为了解决Picker和keyboard等融合了弹窗的组件
100
- // 对v-model双向绑定多层调用造成报错不能修改props值的问题
101
- popup: { type: Boolean, default: true },
102
- borderRadius: { type: [Number, String], default: 0 },
103
- zIndex: { type: [Number, String], default: '' },
104
- // 是否显示关闭图标
105
- closeable: { type: Boolean, default: false },
106
- // 关闭图标的名称,只能uView的内置图标
107
- closeIcon: { type: String, default: 'close' },
108
- // 自定义关闭图标位置,top-left为左上角,top-right为右上角,bottom-left为左下角,bottom-right为右下角
109
- closeIconPos: { type: String, default: 'top-right' },
110
- // 关闭图标的颜色
111
- closeIconColor: { type: String, default: '#909399' },
112
- // 关闭图标的大小,单位rpx
113
- closeIconSize: { type: [String, Number], default: '30' },
114
- // 宽度,只对左,右,中部弹出时起作用,单位rpx,或者"auto"
115
- // 或者百分比"50%",表示由内容撑开高度或者宽度,优先级高于length参数
116
- width: { type: String, default: '' },
117
- // 高度,只对上,下,中部弹出时起作用,单位rpx,或者"auto"
118
- // 或者百分比"50%",表示由内容撑开高度或者宽度,优先级高于length参数
119
- height: { type: String, default: '' },
120
- // 给一个负的margin-top,往上偏移,避免和键盘重合的情况,仅在mode=center时有效
121
- negativeTop: { type: [String, Number], default: 0 },
122
- // 遮罩的样式,一般用于修改遮罩的透明度
123
- maskCustomStyle: { type: Object, default: () => ({}) },
124
- // 遮罩打开或收起的动画过渡时间,单位ms
125
- duration: { type: [String, Number], default: 250 }
126
- });
81
+ const props = defineProps(PopupProps);
127
82
  const emit = defineEmits(['update:modelValue', 'open', 'close']);
128
83
 
129
84
  // 组件内部状态
@@ -0,0 +1,25 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { Shape } from '../../types/global';
3
+
4
+ /**
5
+ * RadioProps 单选框 props 类型定义
6
+ * @description 单选框用于有一个选择,用户只能选择其中一个的场景。搭配u-radio-group使用
7
+ */
8
+ export const RadioProps = {
9
+ /** radio的名称 */
10
+ name: { type: [String, Number] as PropType<string | number>, default: '' },
11
+ /** 形状,square为方形,circle为圆形 */
12
+ shape: { type: String as PropType<Shape>, default: '' },
13
+ /** 是否禁用 */
14
+ disabled: { type: [String, Boolean] as PropType<string | boolean>, default: '' },
15
+ /** 是否禁止点击提示语选中复选框 */
16
+ labelDisabled: { type: [String, Boolean] as PropType<string | boolean>, default: '' },
17
+ /** 选中状态下的颜色,如设置此值,将会覆盖parent的activeColor值 */
18
+ activeColor: { type: String, default: '' },
19
+ /** 图标的大小,单位rpx */
20
+ iconSize: { type: [String, Number] as PropType<number | string>, default: '' },
21
+ /** label的字体大小,rpx单位 */
22
+ labelSize: { type: [String, Number] as PropType<number | string>, default: '' }
23
+ };
24
+
25
+ export type RadioProps = ExtractPropTypes<typeof RadioProps>;
@@ -18,6 +18,7 @@
18
18
  <script setup lang="ts">
19
19
  import { computed, inject } from 'vue';
20
20
  import { $u } from '../..';
21
+ import { RadioProps } from './types';
21
22
 
22
23
  defineOptions({
23
24
  name: 'u-radio'
@@ -38,22 +39,7 @@ defineOptions({
38
39
  * @example <u-radio :label-disabled="false">门掩黄昏,无计留春住</u-radio>
39
40
  */
40
41
 
41
- const props = defineProps({
42
- /** radio的名称 */
43
- name: { type: [String, Number], default: '' },
44
- /** 形状,square为方形,circle为原型 */
45
- shape: { type: String, default: '' },
46
- /** 是否禁用 */
47
- disabled: { type: [String, Boolean], default: '' },
48
- /** 是否禁止点击提示语选中复选框 */
49
- labelDisabled: { type: [String, Boolean], default: '' },
50
- /** 选中状态下的颜色,如设置此值,将会覆盖parent的activeColor值 */
51
- activeColor: { type: String, default: '' },
52
- /** 图标的大小,单位rpx */
53
- iconSize: { type: [String, Number], default: '' },
54
- /** label的字体大小,rpx单位 */
55
- labelSize: { type: [String, Number], default: '' }
56
- });
42
+ const props = defineProps(RadioProps);
57
43
 
58
44
  const emit = defineEmits(['change']);
59
45
 
@@ -0,0 +1,29 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { Shape } from '../../types/global';
3
+
4
+ /**
5
+ * RadioGroupProps 单选框组 props 类型定义
6
+ * @description 单选框用于有一个选择,用户只能选择其中一个的场景。搭配u-radio使用
7
+ */
8
+ export const RadioGroupProps = {
9
+ /** 是否禁用所有单选框 */
10
+ disabled: { type: Boolean, default: false },
11
+ /** 匹配某一个radio组件,如果某个radio的name值等于此值,那么这个radio就被会选中 */
12
+ modelValue: { type: [String, Number] as PropType<string | number>, default: '' },
13
+ /** 选中状态下的颜色 */
14
+ activeColor: { type: String, default: '#2979ff' },
15
+ /** 组件的整体大小 */
16
+ size: { type: [String, Number] as PropType<number | string>, default: 34 },
17
+ /** 是否禁止点击提示语选中复选框 */
18
+ labelDisabled: { type: Boolean, default: false },
19
+ /** 形状,square为方形,circle为原型 */
20
+ shape: { type: String as PropType<Shape>, default: 'circle' },
21
+ /** 图标的大小,单位rpx */
22
+ iconSize: { type: [String, Number] as PropType<number | string>, default: 20 },
23
+ /** 每个checkbox占u-checkbox-group的宽度 */
24
+ width: { type: [String, Number] as PropType<number | string>, default: 'auto' },
25
+ /** 是否每个checkbox都换行 */
26
+ wrap: { type: Boolean, default: false }
27
+ };
28
+
29
+ export type RadioGroupProps = ExtractPropTypes<typeof RadioGroupProps>;
@@ -7,6 +7,7 @@
7
7
  <script setup lang="ts">
8
8
  import { ref, provide, watch, getCurrentInstance } from 'vue';
9
9
  import { $u } from '../..';
10
+ import { RadioGroupProps } from './types';
10
11
 
11
12
  defineOptions({
12
13
  name: 'u-radio-group'
@@ -28,26 +29,7 @@ defineOptions({
28
29
  * @example <u-radio-group v-model="value"></u-radio-group>
29
30
  */
30
31
 
31
- const props = defineProps({
32
- /** 是否禁用所有单选框 */
33
- disabled: { type: Boolean, default: false },
34
- /** 匹配某一个radio组件,如果某个radio的name值等于此值,那么这个radio就被会选中 */
35
- modelValue: { type: [String, Number], default: '' },
36
- /** 选中状态下的颜色 */
37
- activeColor: { type: String, default: '#2979ff' },
38
- /** 组件的整体大小 */
39
- size: { type: [String, Number], default: 34 },
40
- /** 是否禁止点击提示语选中复选框 */
41
- labelDisabled: { type: Boolean, default: false },
42
- /** 形状,square为方形,circle为原型 */
43
- shape: { type: String, default: 'circle' },
44
- /** 图标的大小,单位rpx */
45
- iconSize: { type: [String, Number], default: 20 },
46
- /** 每个checkbox占u-checkbox-group的宽度 */
47
- width: { type: [String, Number], default: 'auto' },
48
- /** 是否每个checkbox都换行 */
49
- wrap: { type: Boolean, default: false }
50
- });
32
+ const props = defineProps(RadioGroupProps);
51
33
 
52
34
  const emit = defineEmits(['update:modelValue', 'change']);
53
35
 
@@ -0,0 +1,40 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ /**
4
+ * RateProps 评分组件 props 类型定义
5
+ * @description 满意度调查、星型评分场景
6
+ */
7
+ export const RateProps = {
8
+ /** v-model双向绑定选中的星星数量 */
9
+ modelValue: { type: [Number, String] as PropType<number | string>, default: -1 },
10
+ /** 要显示的星星数量 */
11
+ count: { type: [Number, String] as PropType<number | string>, default: 5 },
12
+ /** 当前需要默认选中的星星(选中的个数) */
13
+ current: { type: [Number, String] as PropType<number | string>, default: 0 },
14
+ /** 是否不可选中 */
15
+ disabled: { type: Boolean, default: false },
16
+ /** 星星的大小,单位rpx */
17
+ size: { type: [Number, String] as PropType<number | string>, default: 32 },
18
+ /** 未选中时的颜色 */
19
+ inactiveColor: { type: String, default: '#b2b2b2' },
20
+ /** 选中的颜色 */
21
+ activeColor: { type: String, default: '#FA3534' },
22
+ /** 星星之间的间距,单位rpx */
23
+ gutter: { type: [Number, String] as PropType<number | string>, default: 10 },
24
+ /** 最少能选择的星星个数 */
25
+ minCount: { type: [Number, String] as PropType<number | string>, default: 0 },
26
+ /** 是否允许半星 */
27
+ allowHalf: { type: Boolean, default: false },
28
+ /** 选中时的图标(星星) */
29
+ activeIcon: { type: String, default: 'star-fill' },
30
+ /** 未选中时的图标(星星) */
31
+ inactiveIcon: { type: String, default: 'star' },
32
+ /** 自定义扩展前缀,方便用户扩展自己的图标库 */
33
+ customPrefix: { type: String, default: 'uicon' },
34
+ /** 分段颜色 */
35
+ colors: { type: Array as PropType<string[]>, default: () => [] },
36
+ /** 分段图标 */
37
+ icons: { type: Array as PropType<string[]>, default: () => [] }
38
+ };
39
+
40
+ export type RateProps = ExtractPropTypes<typeof RateProps>;