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.
- package/changelog.md +5 -0
- package/components/u-action-sheet/types.ts +35 -0
- package/components/u-action-sheet/u-action-sheet.vue +2 -47
- package/components/u-alert-tips/types.ts +39 -0
- package/components/u-alert-tips/u-alert-tips.vue +3 -32
- package/components/u-avatar/types.ts +34 -0
- package/components/u-avatar/u-avatar.vue +3 -30
- package/components/u-avatar-cropper/types.ts +23 -0
- package/components/u-avatar-cropper/u-avatar-cropper.vue +2 -45
- package/components/u-back-top/types.ts +39 -0
- package/components/u-back-top/u-back-top.vue +2 -33
- package/components/u-badge/types.ts +36 -0
- package/components/u-badge/u-badge.vue +2 -26
- package/components/u-button/types.ts +66 -0
- package/components/u-button/u-button.vue +3 -88
- package/components/u-calendar/types.ts +63 -0
- package/components/u-calendar/u-calendar.vue +2 -135
- package/components/u-car-keyboard/types.ts +12 -0
- package/components/u-car-keyboard/u-car-keyboard.vue +2 -4
- package/components/u-card/types.ts +59 -0
- package/components/u-card/u-card.vue +2 -48
- package/components/u-cell-group/types.ts +17 -0
- package/components/u-cell-group/u-cell-group.vue +3 -9
- package/components/u-cell-item/types.ts +54 -0
- package/components/u-cell-item/u-cell-item.vue +2 -45
- package/components/u-checkbox/types.ts +31 -0
- package/components/u-checkbox/u-checkbox.vue +2 -47
- package/components/u-checkbox-group/types.ts +32 -0
- package/components/u-checkbox-group/u-checkbox-group.vue +2 -57
- package/components/u-circle-progress/types.ts +52 -0
- package/components/u-circle-progress/u-circle-progress.vue +2 -23
- package/components/u-city-select/types.ts +20 -0
- package/components/u-city-select/u-city-select.vue +2 -10
- package/components/u-col/types.ts +30 -0
- package/components/u-col/u-col.vue +2 -14
- package/components/u-collapse/types.ts +31 -0
- package/components/u-collapse/u-collapse.vue +2 -16
- package/components/u-collapse-item/types.ts +25 -0
- package/components/u-collapse-item/u-collapse-item.vue +2 -16
- package/components/u-column-notice/types.ts +48 -0
- package/components/u-column-notice/u-column-notice.vue +2 -97
- package/components/u-count-down/types.ts +42 -0
- package/components/u-count-down/u-count-down.vue +2 -82
- package/components/u-count-to/types.ts +32 -0
- package/components/u-count-to/u-count-to.vue +2 -58
- package/components/u-divider/types.ts +31 -0
- package/components/u-divider/u-divider.vue +2 -22
- package/components/u-dropdown/types.ts +32 -0
- package/components/u-dropdown/u-dropdown.vue +2 -24
- package/components/u-dropdown-item/types.ts +27 -0
- package/components/u-dropdown-item/u-dropdown-item.vue +4 -16
- package/components/u-empty/types.ts +36 -0
- package/components/u-empty/u-empty.vue +3 -26
- package/components/u-field/types.ts +69 -0
- package/components/u-field/u-field.vue +2 -117
- package/components/u-form/types.ts +25 -0
- package/components/u-form/u-form.vue +2 -46
- package/components/u-form-item/types.ts +70 -0
- package/components/u-form-item/u-form-item.vue +2 -62
- package/components/u-full-screen/types.ts +14 -0
- package/components/u-full-screen/u-full-screen.vue +2 -0
- package/components/u-gap/types.ts +18 -0
- package/components/u-gap/u-gap.vue +2 -10
- package/components/u-grid/types.ts +19 -0
- package/components/u-grid/u-grid.vue +3 -11
- package/components/u-grid-item/types.ts +16 -0
- package/components/u-grid-item/u-grid-item.vue +2 -8
- package/components/u-icon/types.ts +62 -0
- package/components/u-icon/u-icon.vue +2 -123
- package/components/u-image/types.ts +39 -38
- package/components/u-index-anchor/types.ts +16 -0
- package/components/u-index-anchor/u-index-anchor.vue +2 -17
- package/components/u-index-list/types.ts +43 -0
- package/components/u-index-list/u-index-list.vue +13 -34
- package/components/u-input/types.ts +140 -0
- package/components/u-input/u-input.vue +2 -209
- package/components/u-keyboard/types.ts +40 -0
- package/components/u-keyboard/u-keyboard.vue +2 -32
- package/components/u-lazy-load/types.ts +37 -0
- package/components/u-lazy-load/u-lazy-load.vue +3 -58
- package/components/u-line/types.ts +44 -0
- package/components/u-line/u-line.vue +2 -14
- package/components/u-line-progress/types.ts +58 -0
- package/components/u-line-progress/u-line-progress.vue +2 -21
- package/components/u-link/types.ts +43 -0
- package/components/u-link/u-link.vue +2 -14
- package/components/u-loading/types.ts +35 -0
- package/components/u-loading/u-loading.vue +2 -23
- package/components/u-loadmore/types.ts +79 -0
- package/components/u-loadmore/u-loadmore.vue +2 -67
- package/components/u-mask/types.ts +43 -0
- package/components/u-mask/u-mask.vue +2 -33
- package/components/u-message-input/types.ts +74 -0
- package/components/u-message-input/u-message-input.vue +2 -62
- package/components/u-modal/types.ts +118 -0
- package/components/u-modal/u-modal.vue +2 -86
- package/components/u-navbar/types.ts +103 -0
- package/components/u-navbar/u-navbar.vue +2 -90
- package/components/u-no-network/types.ts +28 -0
- package/components/u-no-network/u-no-network.vue +2 -23
- package/components/u-notice-bar/types.ts +111 -0
- package/components/u-notice-bar/u-notice-bar.vue +2 -102
- package/components/u-number-box/types.ts +42 -0
- package/components/u-number-box/u-number-box.vue +2 -34
- package/components/u-number-keyboard/types.ts +26 -0
- package/components/u-number-keyboard/u-number-keyboard.vue +2 -8
- package/components/u-picker/types.ts +111 -0
- package/components/u-picker/u-picker.vue +3 -174
- package/components/u-popup/types.ts +59 -0
- package/components/u-popup/u-popup.vue +2 -47
- package/components/u-radio/types.ts +25 -0
- package/components/u-radio/u-radio.vue +2 -16
- package/components/u-radio-group/types.ts +29 -0
- package/components/u-radio-group/u-radio-group.vue +2 -20
- package/components/u-rate/types.ts +40 -0
- package/components/u-rate/u-rate.vue +2 -124
- package/components/u-read-more/types.ts +35 -0
- package/components/u-read-more/u-read-more.vue +2 -51
- package/components/u-row/types.ts +20 -0
- package/components/u-row/u-row.vue +2 -10
- package/components/u-row-notice/types.ts +39 -0
- package/components/u-row-notice/u-row-notice.vue +2 -72
- package/components/u-search/types.ts +53 -0
- package/components/u-search/u-search.vue +2 -44
- package/components/u-section/types.ts +32 -0
- package/components/u-section/u-section.vue +2 -52
- package/components/u-select/types.ts +43 -0
- package/components/u-select/u-select.vue +2 -34
- package/components/u-skeleton/types.ts +20 -0
- package/components/u-skeleton/u-skeleton.vue +2 -27
- package/components/u-slider/types.ts +32 -0
- package/components/u-slider/u-slider.vue +2 -57
- package/components/u-steps/types.ts +28 -0
- package/components/u-steps/u-steps.vue +2 -42
- package/components/u-sticky/types.ts +22 -0
- package/components/u-sticky/u-sticky.vue +2 -32
- package/components/u-subsection/types.ts +36 -0
- package/components/u-subsection/u-subsection.vue +2 -62
- package/components/u-swipe-action/types.ts +50 -0
- package/components/u-swipe-action/u-swipe-action.vue +2 -39
- package/components/u-swiper/types.ts +47 -0
- package/components/u-swiper/u-swiper.vue +2 -41
- package/components/u-switch/types.ts +28 -0
- package/components/u-switch/u-switch.vue +2 -20
- package/components/u-tabbar/types.ts +36 -0
- package/components/u-tabbar/u-tabbar.vue +6 -75
- package/components/u-table/types.ts +25 -0
- package/components/u-table/u-table.vue +2 -51
- package/components/u-tabs/types.ts +51 -0
- package/components/u-tabs/u-tabs.vue +6 -44
- package/components/u-tabs-swiper/types.ts +53 -0
- package/components/u-tabs-swiper/u-tabs-swiper.vue +3 -50
- package/components/u-tag/types.ts +37 -0
- package/components/u-tag/u-tag.vue +2 -28
- package/components/u-td/types.ts +12 -0
- package/components/u-td/u-td.vue +2 -9
- package/components/u-th/types.ts +12 -0
- package/components/u-th/u-th.vue +2 -9
- package/components/u-time-line-item/types.ts +14 -0
- package/components/u-time-line-item/u-time-line-item.vue +2 -12
- package/components/u-toast/types.ts +35 -3
- package/components/u-toast/u-toast.vue +2 -7
- package/components/u-top-tips/types.ts +14 -0
- package/components/u-top-tips/u-top-tips.vue +17 -22
- package/components/u-tr/types.ts +8 -0
- package/components/u-tr/u-tr.vue +3 -0
- package/components/u-upload/types.ts +71 -0
- package/components/u-upload/u-upload.vue +6 -67
- package/components/u-verification-code/types.ts +22 -0
- package/components/u-verification-code/u-verification-code.vue +2 -32
- package/components/u-waterfall/types.ts +16 -0
- package/components/u-waterfall/u-waterfall.vue +2 -18
- package/package.json +1 -1
- package/types/global.d.ts +200 -0
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<script setup lang="ts">
|
|
14
14
|
import { computed } from 'vue';
|
|
15
15
|
import { $u } from '../..';
|
|
16
|
+
import { IconProps } from './types';
|
|
16
17
|
|
|
17
18
|
defineOptions({
|
|
18
19
|
name: 'u-icon'
|
|
@@ -54,129 +55,7 @@ const emit = defineEmits<{
|
|
|
54
55
|
(e: 'touchstart', index: string | number): void;
|
|
55
56
|
}>();
|
|
56
57
|
|
|
57
|
-
const props = defineProps(
|
|
58
|
-
/**
|
|
59
|
-
* 图标名称,见示例图标集
|
|
60
|
-
* @default ''
|
|
61
|
-
*/
|
|
62
|
-
name: { type: String, default: '' },
|
|
63
|
-
/**
|
|
64
|
-
* 图标颜色,可接受主题色
|
|
65
|
-
* @default ''
|
|
66
|
-
*/
|
|
67
|
-
color: { type: String, default: '' },
|
|
68
|
-
/**
|
|
69
|
-
* 字体大小,单位rpx(默认32)
|
|
70
|
-
* @default 'inherit'
|
|
71
|
-
*/
|
|
72
|
-
size: { type: [Number, String], default: 'inherit' },
|
|
73
|
-
/**
|
|
74
|
-
* 是否显示粗体
|
|
75
|
-
* @default false
|
|
76
|
-
*/
|
|
77
|
-
bold: { type: Boolean, default: false },
|
|
78
|
-
/**
|
|
79
|
-
* 点击图标的时候传递事件出去的index(用于区分点击了哪一个)
|
|
80
|
-
* @default ''
|
|
81
|
-
*/
|
|
82
|
-
index: { type: [Number, String], default: '' },
|
|
83
|
-
/**
|
|
84
|
-
* 触摸图标时的类名
|
|
85
|
-
* @default ''
|
|
86
|
-
*/
|
|
87
|
-
hoverClass: { type: String, default: '' },
|
|
88
|
-
/**
|
|
89
|
-
* 自定义扩展前缀,方便用户扩展自己的图标库
|
|
90
|
-
* @default 'uicon'
|
|
91
|
-
*/
|
|
92
|
-
customPrefix: { type: String, default: 'uicon' },
|
|
93
|
-
/**
|
|
94
|
-
* 图标右边或者下面的文字
|
|
95
|
-
* @default ''
|
|
96
|
-
*/
|
|
97
|
-
label: { type: [String, Number], default: '' },
|
|
98
|
-
/**
|
|
99
|
-
* label的位置,只能右边或者下边
|
|
100
|
-
* @default 'right'
|
|
101
|
-
* @values 'right' | 'bottom'
|
|
102
|
-
*/
|
|
103
|
-
labelPos: { type: String, default: 'right' },
|
|
104
|
-
/**
|
|
105
|
-
* label的大小,单位rpx(默认28)
|
|
106
|
-
* @default '28'
|
|
107
|
-
*/
|
|
108
|
-
labelSize: { type: [String, Number], default: '28' },
|
|
109
|
-
/**
|
|
110
|
-
* label的颜色
|
|
111
|
-
* @default '#606266'
|
|
112
|
-
*/
|
|
113
|
-
labelColor: { type: String, default: '#606266' },
|
|
114
|
-
/**
|
|
115
|
-
* label与图标的距离(横向排列),单位rpx(默认6)
|
|
116
|
-
* @default '6'
|
|
117
|
-
*/
|
|
118
|
-
marginLeft: { type: [String, Number], default: '6' },
|
|
119
|
-
/**
|
|
120
|
-
* label与图标的距离(竖向排列),单位rpx(默认6)
|
|
121
|
-
* @default '6'
|
|
122
|
-
*/
|
|
123
|
-
marginTop: { type: [String, Number], default: '6' },
|
|
124
|
-
/**
|
|
125
|
-
* label与图标的距离(竖向排列),单位rpx(默认6)
|
|
126
|
-
* @default '6'
|
|
127
|
-
*/
|
|
128
|
-
marginRight: { type: [String, Number], default: '6' },
|
|
129
|
-
/**
|
|
130
|
-
* label与图标的距离(竖向排列),单位rpx(默认6)
|
|
131
|
-
* @default '6'
|
|
132
|
-
*/
|
|
133
|
-
marginBottom: { type: [String, Number], default: '6' },
|
|
134
|
-
/**
|
|
135
|
-
* label与图标的距离,单位rpx,权重高于 margin
|
|
136
|
-
* @default ''
|
|
137
|
-
*/
|
|
138
|
-
space: { type: [String, Number], default: '' },
|
|
139
|
-
/**
|
|
140
|
-
* 图片的mode,参考uni-app image组件
|
|
141
|
-
* @default 'widthFix'
|
|
142
|
-
*/
|
|
143
|
-
imgMode: { type: String, default: 'widthFix' },
|
|
144
|
-
/**
|
|
145
|
-
* 自定义样式,对象形式
|
|
146
|
-
* @default {}
|
|
147
|
-
*/
|
|
148
|
-
customStyle: { type: Object as () => Record<string, any>, default: () => ({}) },
|
|
149
|
-
/**
|
|
150
|
-
* 用于显示图片小图标时,图片的宽度,单位rpx
|
|
151
|
-
* @default ''
|
|
152
|
-
*/
|
|
153
|
-
width: { type: [String, Number], default: '' },
|
|
154
|
-
/**
|
|
155
|
-
* 用于显示图片小图标时,图片的高度,单位rpx
|
|
156
|
-
* @default ''
|
|
157
|
-
*/
|
|
158
|
-
height: { type: [String, Number], default: '' },
|
|
159
|
-
/**
|
|
160
|
-
* 用于解决某些情况下,让图标垂直居中的用途,单位rpx
|
|
161
|
-
* @default 0
|
|
162
|
-
*/
|
|
163
|
-
top: { type: [String, Number], default: 0 },
|
|
164
|
-
/**
|
|
165
|
-
* 是否为DecimalIcon
|
|
166
|
-
* @default false
|
|
167
|
-
*/
|
|
168
|
-
showDecimalIcon: { type: Boolean, default: false },
|
|
169
|
-
/**
|
|
170
|
-
* 背景颜色,可接受主题色,仅Decimal时有效
|
|
171
|
-
* @default '#ececec'
|
|
172
|
-
*/
|
|
173
|
-
inactiveColor: { type: String, default: '#ececec' },
|
|
174
|
-
/**
|
|
175
|
-
* 显示的百分比,仅Decimal时有效
|
|
176
|
-
* @default '50'
|
|
177
|
-
*/
|
|
178
|
-
percent: { type: [Number, String], default: '50' }
|
|
179
|
-
});
|
|
58
|
+
const props = defineProps(IconProps);
|
|
180
59
|
|
|
181
60
|
/**
|
|
182
61
|
* 计算图标的类名集合
|
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import { type ComponentPublicInstance, type ExtractPropTypes } from 'vue'
|
|
1
|
+
import { type ComponentPublicInstance, type ExtractPropTypes, type PropType } from 'vue';
|
|
2
|
+
import type { ImgMode, Shape } from '../../types/global';
|
|
2
3
|
|
|
3
4
|
// 定义 ImageProps 的类型
|
|
4
5
|
export const ImageProps = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
6
|
+
/** 图片地址 */
|
|
7
|
+
src: { type: String, default: '' },
|
|
8
|
+
/** 裁剪模式 */
|
|
9
|
+
mode: { type: String as PropType<ImgMode>, default: 'aspectFill' },
|
|
10
|
+
/** 宽度,单位任意,如果为数值,则为rpx单位(默认100%) */
|
|
11
|
+
width: { type: [String, Number], default: '100%' },
|
|
12
|
+
/** 高度,单位任意,如果为数值,则为rpx单位(默认 auto) */
|
|
13
|
+
height: { type: [String, Number], default: 'auto' },
|
|
14
|
+
/** 图片形状,circle-圆形,square-方形(默认square) */
|
|
15
|
+
shape: { type: String as PropType<Shape>, default: 'square' },
|
|
16
|
+
/** 圆角值,单位任意,如果为数值,则为rpx单位(默认 0) */
|
|
17
|
+
borderRadius: { type: [String, Number], default: 0 },
|
|
18
|
+
/** 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效(默认 true) */
|
|
19
|
+
lazyLoad: { type: Boolean, default: true },
|
|
20
|
+
/** 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效(默认 true) */
|
|
21
|
+
showMenuByLongpress: { type: Boolean, default: true },
|
|
22
|
+
/** 加载中的图标,或者小图片(默认 photo) */
|
|
23
|
+
loadingIcon: { type: String, default: 'photo' },
|
|
24
|
+
/** 加载失败的图标,或者小图片(默认 error-circle) */
|
|
25
|
+
errorIcon: { type: String, default: 'error-circle' },
|
|
26
|
+
/** 是否显示加载中的图标或者自定义的slot(默认 true) */
|
|
27
|
+
showLoading: { type: Boolean, default: true },
|
|
28
|
+
/** 是否显示加载错误的图标或者自定义的slot(默认 true) */
|
|
29
|
+
showError: { type: Boolean, default: true },
|
|
30
|
+
/** 是否需要淡入效果(默认 true) */
|
|
31
|
+
fade: { type: Boolean, default: true },
|
|
32
|
+
/** 只支持网络资源,只对微信小程序有效(默认 false) */
|
|
33
|
+
webp: { type: Boolean, default: false },
|
|
34
|
+
/** 搭配fade参数的过渡时间,单位ms(默认 500) */
|
|
35
|
+
duration: { type: [String, Number], default: 500 },
|
|
36
|
+
/** 背景颜色,用于深色页面加载图片时,为了和背景色融合(默认 #f3f4f6) */
|
|
37
|
+
bgColor: { type: String, default: '#f3f4f6' }
|
|
38
|
+
};
|
|
38
39
|
|
|
39
40
|
// 将 ImageProps 转换为类型
|
|
40
|
-
export type ImageProps = ExtractPropTypes<typeof ImageProps
|
|
41
|
+
export type ImageProps = ExtractPropTypes<typeof ImageProps>;
|
|
41
42
|
|
|
42
43
|
// 暴露的组件实例方法
|
|
43
44
|
export type ImageExpose = {
|
|
44
|
-
|
|
45
|
-
}
|
|
45
|
+
changeStatus: (status: 'loading' | 'error' | 'normal') => void;
|
|
46
|
+
};
|
|
46
47
|
|
|
47
48
|
// 组件实例类型
|
|
48
|
-
export type ImageInstance = ComponentPublicInstance<ImageProps, ImageExpose
|
|
49
|
+
export type ImageInstance = ComponentPublicInstance<ImageProps, ImageExpose>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* u-index-anchor 组件 Props 类型定义
|
|
5
|
+
* @description 索引锚点属性
|
|
6
|
+
*/
|
|
7
|
+
export const IndexAnchorProps = {
|
|
8
|
+
/** 是否使用自定义内容的插槽 */
|
|
9
|
+
useSlot: { type: Boolean, default: false },
|
|
10
|
+
/** 索引字符,如果定义了use-slot,此参数自动失效 */
|
|
11
|
+
index: { type: String, default: '' },
|
|
12
|
+
/** 自定义样式,对象形式 */
|
|
13
|
+
customStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) }
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type IndexAnchorProps = ExtractPropTypes<typeof IndexAnchorProps>;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<script setup lang="ts">
|
|
16
|
+
import { IndexAnchorProps } from './types';
|
|
16
17
|
import { ref, computed, onMounted, getCurrentInstance } from 'vue';
|
|
17
18
|
import { $u } from '../..';
|
|
18
19
|
|
|
@@ -31,23 +32,7 @@ defineOptions({
|
|
|
31
32
|
* @example <u-index-anchor :index="item" />
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
|
-
const props = defineProps(
|
|
35
|
-
/** 是否使用自定义内容的插槽 */
|
|
36
|
-
useSlot: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: false
|
|
39
|
-
},
|
|
40
|
-
/** 索引字符,如果定义了use-slot,此参数自动失效 */
|
|
41
|
-
index: {
|
|
42
|
-
type: String,
|
|
43
|
-
default: ''
|
|
44
|
-
},
|
|
45
|
-
/** 自定义样式,对象形式 */
|
|
46
|
-
customStyle: {
|
|
47
|
-
type: Object as () => Record<string, any>,
|
|
48
|
-
default: () => ({})
|
|
49
|
-
}
|
|
50
|
-
});
|
|
35
|
+
const props = defineProps(IndexAnchorProps);
|
|
51
36
|
|
|
52
37
|
// 响应式变量
|
|
53
38
|
const active = ref(false);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* u-index-list 组件 props 类型定义
|
|
5
|
+
* @description 通过折叠面板收纳内容区域,搭配<u-index-anchor>使用
|
|
6
|
+
*/
|
|
7
|
+
export const IndexListProps = {
|
|
8
|
+
/** 是否开启锚点自动吸顶 */
|
|
9
|
+
sticky: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: true
|
|
12
|
+
},
|
|
13
|
+
/** 锚点吸顶时的层级 */
|
|
14
|
+
zIndex: {
|
|
15
|
+
type: [Number, String] as PropType<number | string>,
|
|
16
|
+
default: ''
|
|
17
|
+
},
|
|
18
|
+
/** 当前滚动高度 */
|
|
19
|
+
scrollTop: {
|
|
20
|
+
type: [Number, String] as PropType<number | string>,
|
|
21
|
+
default: 0
|
|
22
|
+
},
|
|
23
|
+
/** 锚点自动吸顶时与顶部的距离 */
|
|
24
|
+
offsetTop: {
|
|
25
|
+
type: [Number, String] as PropType<number | string>,
|
|
26
|
+
default: 0
|
|
27
|
+
},
|
|
28
|
+
/** 索引字符列表 */
|
|
29
|
+
indexList: {
|
|
30
|
+
type: Array as PropType<string[]>,
|
|
31
|
+
default: undefined // 组件内用 getIndexList() 兜底
|
|
32
|
+
},
|
|
33
|
+
/** 锚点和右边索引字符高亮颜色 */
|
|
34
|
+
activeColor: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: '#2979ff'
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* u-index-list 组件 props 类型
|
|
42
|
+
*/
|
|
43
|
+
export type IndexListProps = ExtractPropTypes<typeof IndexListProps>;
|
|
@@ -49,6 +49,7 @@ function getIndexList() {
|
|
|
49
49
|
<script setup lang="ts">
|
|
50
50
|
import { ref, reactive, computed, watch, onMounted, getCurrentInstance } from 'vue';
|
|
51
51
|
import { $u } from '../..';
|
|
52
|
+
import { IndexListProps } from './types';
|
|
52
53
|
|
|
53
54
|
defineOptions({
|
|
54
55
|
name: 'u-index-list'
|
|
@@ -67,42 +68,20 @@ defineOptions({
|
|
|
67
68
|
* @event {Function} select 选中右边索引字符时触发
|
|
68
69
|
* @example <u-index-list :scrollTop="scrollTop"></u-index-list>
|
|
69
70
|
*/
|
|
70
|
-
const props = defineProps(
|
|
71
|
-
/** 是否开启锚点自动吸顶 */
|
|
72
|
-
sticky: {
|
|
73
|
-
type: Boolean,
|
|
74
|
-
default: true
|
|
75
|
-
},
|
|
76
|
-
/** 锚点吸顶时的层级 */
|
|
77
|
-
zIndex: {
|
|
78
|
-
type: [Number, String],
|
|
79
|
-
default: ''
|
|
80
|
-
},
|
|
81
|
-
/** 当前滚动高度 */
|
|
82
|
-
scrollTop: {
|
|
83
|
-
type: [Number, String],
|
|
84
|
-
default: 0
|
|
85
|
-
},
|
|
86
|
-
/** 锚点自动吸顶时与顶部的距离 */
|
|
87
|
-
offsetTop: {
|
|
88
|
-
type: [Number, String],
|
|
89
|
-
default: 0
|
|
90
|
-
},
|
|
91
|
-
/** 索引字符列表 */
|
|
92
|
-
indexList: {
|
|
93
|
-
type: Array,
|
|
94
|
-
default: () => getIndexList()
|
|
95
|
-
},
|
|
96
|
-
/** 锚点和右边索引字符高亮颜色 */
|
|
97
|
-
activeColor: {
|
|
98
|
-
type: String,
|
|
99
|
-
default: '#2979ff'
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
71
|
+
const props = defineProps(IndexListProps);
|
|
103
72
|
const emit = defineEmits(['select']);
|
|
104
73
|
const instance = getCurrentInstance();
|
|
105
74
|
|
|
75
|
+
// 索引列表生成函数
|
|
76
|
+
function getIndexList() {
|
|
77
|
+
const indexList: string[] = [];
|
|
78
|
+
const charCodeOfA = 'A'.charCodeAt(0);
|
|
79
|
+
for (let i = 0; i < 26; i++) {
|
|
80
|
+
indexList.push(String.fromCharCode(charCodeOfA + i));
|
|
81
|
+
}
|
|
82
|
+
return indexList;
|
|
83
|
+
}
|
|
84
|
+
|
|
106
85
|
// 变量定义
|
|
107
86
|
const activeAnchorIndex = ref(0);
|
|
108
87
|
const showSidebar = ref(true);
|
|
@@ -121,7 +100,7 @@ const stickyOffsetTop = ref(0);
|
|
|
121
100
|
// 弹出toast的z-index值
|
|
122
101
|
const alertZIndex = computed(() => $u.zIndex.toast).value;
|
|
123
102
|
// indexList 响应式
|
|
124
|
-
const indexList = computed(() => props.indexList).value;
|
|
103
|
+
const indexList = computed(() => props.indexList ?? getIndexList()).value;
|
|
125
104
|
const zIndex = computed(() => props.zIndex).value;
|
|
126
105
|
const activeColor = computed(() => props.activeColor).value;
|
|
127
106
|
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import type { InputAlign, InputConfirmType, InputType } from '../../types/global';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* u-input 组件 props 类型定义
|
|
6
|
+
* @description 此组件为一个输入框,默认没有边框和样式,是专门为配合表单组件u-form而设计的,利用它可以快速实现表单验证,输入内容,下拉选择等功能。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const InputProps = {
|
|
10
|
+
/** 用于双向绑定输入框的值 */
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: [String, Number] as PropType<string | number>,
|
|
13
|
+
default: ''
|
|
14
|
+
},
|
|
15
|
+
/** 输入框的类型,textarea,text,number */
|
|
16
|
+
type: {
|
|
17
|
+
type: String as PropType<InputType>,
|
|
18
|
+
default: 'text'
|
|
19
|
+
},
|
|
20
|
+
/** 输入框文字的对齐方式(默认left) */
|
|
21
|
+
inputAlign: {
|
|
22
|
+
type: String as PropType<InputAlign>,
|
|
23
|
+
default: 'left'
|
|
24
|
+
},
|
|
25
|
+
/** placeholder显示值(默认 '请输入内容') */
|
|
26
|
+
placeholder: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: '请输入内容'
|
|
29
|
+
},
|
|
30
|
+
/** 是否禁用输入框(默认false) */
|
|
31
|
+
disabled: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
/** 输入框的最大可输入长度(默认140) */
|
|
36
|
+
maxlength: {
|
|
37
|
+
type: [Number, String] as PropType<number | string>,
|
|
38
|
+
default: 140
|
|
39
|
+
},
|
|
40
|
+
/** placeholder的样式,字符串形式,如"color: red;"(默认 "color: #c0c4cc;") */
|
|
41
|
+
placeholderStyle: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: 'color: #c0c4cc;'
|
|
44
|
+
},
|
|
45
|
+
/** 设置键盘右下角按钮的文字,仅在type为text时生效(默认done) */
|
|
46
|
+
confirmType: {
|
|
47
|
+
type: String as PropType<InputConfirmType>,
|
|
48
|
+
default: 'done'
|
|
49
|
+
},
|
|
50
|
+
/** 自定义输入框的样式,对象形式 */
|
|
51
|
+
customStyle: {
|
|
52
|
+
type: Object as PropType<Record<string, any>>,
|
|
53
|
+
default: () => ({})
|
|
54
|
+
},
|
|
55
|
+
/** 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true */
|
|
56
|
+
fixed: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false
|
|
59
|
+
},
|
|
60
|
+
/** 是否自动获得焦点(默认false) */
|
|
61
|
+
focus: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
/** 密码类型时,是否显示右侧的密码图标(默认true) */
|
|
66
|
+
passwordIcon: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: true
|
|
69
|
+
},
|
|
70
|
+
/** input|textarea是否显示边框(默认false) */
|
|
71
|
+
border: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
/** 输入框的边框颜色(默认#dcdfe6) */
|
|
76
|
+
borderColor: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: '#dcdfe6'
|
|
79
|
+
},
|
|
80
|
+
/** 是否自动增高输入区域,type为textarea时有效(默认true) */
|
|
81
|
+
autoHeight: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: true
|
|
84
|
+
},
|
|
85
|
+
/** type=select时,旋转右侧的图标,标识当前处于打开还是关闭select的状态 */
|
|
86
|
+
selectOpen: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false
|
|
89
|
+
},
|
|
90
|
+
/** 高度,单位rpx */
|
|
91
|
+
height: {
|
|
92
|
+
type: [Number, String] as PropType<number | string>,
|
|
93
|
+
default: ''
|
|
94
|
+
},
|
|
95
|
+
/** 是否可清空(默认true) */
|
|
96
|
+
clearable: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: true
|
|
99
|
+
},
|
|
100
|
+
/** 指定光标与键盘的距离,单位 px(默认0) */
|
|
101
|
+
cursorSpacing: {
|
|
102
|
+
type: [Number, String] as PropType<number | string>,
|
|
103
|
+
default: 0
|
|
104
|
+
},
|
|
105
|
+
/** 光标起始位置,自动聚焦时有效,需与selection-end搭配使用(默认-1) */
|
|
106
|
+
selectionStart: {
|
|
107
|
+
type: [Number, String] as PropType<number | string>,
|
|
108
|
+
default: -1
|
|
109
|
+
},
|
|
110
|
+
/** 光标结束位置,自动聚焦时有效,需与selection-start搭配使用(默认-1) */
|
|
111
|
+
selectionEnd: {
|
|
112
|
+
type: [Number, String] as PropType<number | string>,
|
|
113
|
+
default: -1
|
|
114
|
+
},
|
|
115
|
+
/** 是否自动去除两端的空格(默认true) */
|
|
116
|
+
trim: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: true
|
|
119
|
+
},
|
|
120
|
+
/** 是否显示键盘上方带有”完成“按钮那一栏(默认true) */
|
|
121
|
+
showConfirmbar: {
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: true
|
|
124
|
+
},
|
|
125
|
+
/** 弹出键盘时是否自动调节高度,uni-app默认值是true */
|
|
126
|
+
adjustPosition: {
|
|
127
|
+
type: Boolean,
|
|
128
|
+
default: true
|
|
129
|
+
},
|
|
130
|
+
/** 输入框的验证状态,用于错误时,边框是否改为红色 */
|
|
131
|
+
validateState: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
default: false
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* u-input 组件 props 类型
|
|
139
|
+
*/
|
|
140
|
+
export type InputProps = ExtractPropTypes<typeof InputProps>;
|