uview-pro 0.5.14 → 0.5.16
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 +53 -8
- package/components/u-action-sheet/types.ts +10 -2
- package/components/u-action-sheet-item/types.ts +10 -2
- package/components/u-alert-tips/types.ts +10 -2
- package/components/u-avatar/types.ts +10 -2
- package/components/u-back-top/types.ts +10 -2
- package/components/u-badge/types.ts +10 -2
- package/components/u-button/types.ts +11 -3
- package/components/u-button/u-button.vue +17 -0
- package/components/u-calendar/types.ts +10 -2
- package/components/u-car-keyboard/types.ts +11 -3
- package/components/u-card/types.ts +10 -2
- package/components/u-cell-group/types.ts +10 -2
- package/components/u-cell-item/types.ts +10 -2
- package/components/u-checkbox/types.ts +12 -4
- package/components/u-checkbox/u-checkbox.vue +73 -9
- package/components/u-checkbox-group/types.ts +14 -6
- package/components/u-checkbox-group/u-checkbox-group.vue +1 -1
- package/components/u-circle-progress/types.ts +10 -2
- package/components/u-city-select/types.ts +10 -2
- package/components/u-col/types.ts +10 -2
- package/components/u-collapse/types.ts +10 -2
- package/components/u-collapse-item/types.ts +10 -2
- package/components/u-column-notice/types.ts +10 -2
- package/components/u-config-provider/types.ts +10 -2
- package/components/u-count-down/types.ts +10 -2
- package/components/u-count-to/types.ts +10 -2
- package/components/u-divider/types.ts +10 -2
- package/components/u-dropdown/types.ts +10 -2
- package/components/u-dropdown-item/types.ts +10 -2
- package/components/u-empty/types.ts +10 -2
- package/components/u-fab/types.ts +10 -2
- package/components/u-field/types.ts +10 -2
- package/components/u-form/types.ts +14 -4
- package/components/u-form-item/types.ts +16 -3
- package/components/u-form-item/u-form-item.vue +73 -9
- package/components/u-full-screen/types.ts +10 -2
- package/components/u-gap/types.ts +10 -2
- package/components/u-grid/types.ts +10 -2
- package/components/u-grid-item/types.ts +10 -2
- package/components/u-icon/types.ts +10 -2
- package/components/u-image/types.ts +10 -2
- package/components/u-index-anchor/types.ts +10 -2
- package/components/u-input/types.ts +16 -3
- package/components/u-input/u-input.vue +100 -22
- package/components/u-loading/types.ts +10 -2
- package/components/u-loadmore/types.ts +10 -2
- package/components/u-mask/types.ts +10 -2
- package/components/u-message-input/types.ts +10 -2
- package/components/u-modal/types.ts +10 -2
- package/components/u-pagination/types.ts +11 -2
- package/components/u-picker/types.ts +10 -2
- package/components/u-popup/types.ts +10 -2
- package/components/u-radio/types.ts +14 -4
- package/components/u-radio/u-radio.vue +78 -10
- package/components/u-radio-group/types.ts +12 -4
- package/components/u-rate/types.ts +10 -2
- package/components/u-read-more/types.ts +10 -2
- package/components/u-row/types.ts +10 -2
- package/components/u-row-notice/types.ts +10 -2
- package/components/u-safe-bottom/types.ts +19 -0
- package/components/u-safe-bottom/u-safe-bottom.vue +1 -1
- package/components/u-search/types.ts +10 -2
- package/components/u-section/types.ts +10 -2
- package/components/u-select/types.ts +10 -2
- package/components/u-skeleton/types.ts +10 -2
- package/components/u-slider/types.ts +10 -2
- package/components/u-status-bar/types.ts +21 -0
- package/components/u-status-bar/u-status-bar.vue +1 -1
- package/components/u-step/types.ts +10 -2
- package/components/u-steps/types.ts +10 -2
- package/components/u-sticky/types.ts +10 -2
- package/components/u-subsection/types.ts +10 -2
- package/components/u-swipe-action/types.ts +10 -2
- package/components/u-swiper/types.ts +10 -2
- package/components/u-switch/types.ts +12 -4
- package/components/u-switch/u-switch.vue +60 -5
- package/components/u-tabbar/types.ts +10 -2
- package/components/u-table/types.ts +10 -2
- package/components/u-tabs/types.ts +10 -2
- package/components/u-tabs-swiper/types.ts +10 -2
- package/components/u-tag/types.ts +10 -2
- package/components/u-tag/u-tag.vue +5 -0
- package/components/u-td/types.ts +10 -2
- package/components/u-text/types.ts +10 -2
- package/components/u-textarea/types.ts +16 -5
- package/components/u-textarea/u-textarea.vue +87 -6
- package/components/u-th/types.ts +10 -2
- package/components/u-time-line/u-time-line.vue +13 -2
- package/components/u-time-line-item/types.ts +10 -2
- package/components/u-toast/types.ts +10 -2
- package/components/u-top-tips/types.ts +10 -2
- package/components/u-tr/types.ts +11 -3
- package/components/u-transition/types.ts +10 -2
- package/components/u-upload/types.ts +10 -2
- package/components/u-verification-code/types.ts +10 -2
- package/components/u-waterfall/types.ts +10 -2
- package/index.ts +4 -5
- package/libs/config/config.ts +27 -4
- package/libs/css/common.scss +5 -0
- package/libs/hooks/useCompRelation.ts +37 -34
- package/libs/index.ts +0 -1
- package/libs/util/config-provider.ts +24 -25
- package/package.json +3 -2
- package/types/global.d.ts +8 -9
- package/components/common/props.ts +0 -22
- package/components/u-safe-bottom/props.ts +0 -11
- package/components/u-status-bar/props.ts +0 -13
- package/libs/util/logger.ts +0 -364
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
<view
|
|
9
9
|
class="u-switch__node node-class"
|
|
10
10
|
:style="{
|
|
11
|
-
width:
|
|
12
|
-
height:
|
|
11
|
+
width: currentSize,
|
|
12
|
+
height: currentSize
|
|
13
13
|
}"
|
|
14
14
|
>
|
|
15
|
-
<u-loading :show="loading" class="u-switch__loading" :size="
|
|
15
|
+
<u-loading :show="loading" class="u-switch__loading" :size="loadingSize" :color="loadingColor" />
|
|
16
16
|
</view>
|
|
17
17
|
</view>
|
|
18
18
|
</template>
|
|
@@ -32,8 +32,9 @@ export default {
|
|
|
32
32
|
|
|
33
33
|
<script setup lang="ts">
|
|
34
34
|
import { computed, nextTick } from 'vue';
|
|
35
|
-
import { $u } from '../..';
|
|
35
|
+
import { $u, useChildren } from '../..';
|
|
36
36
|
import { SwitchProps } from './types';
|
|
37
|
+
import type { SizeType } from '../../types/global';
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* switch 开关选择器
|
|
@@ -52,6 +53,60 @@ import { SwitchProps } from './types';
|
|
|
52
53
|
const props = defineProps(SwitchProps);
|
|
53
54
|
|
|
54
55
|
const emit = defineEmits(['update:modelValue', 'change']);
|
|
56
|
+
const { parentExposed } = useChildren('u-switch', 'u-form');
|
|
57
|
+
|
|
58
|
+
// 根据 size 定义不同的配置
|
|
59
|
+
const sizeConfig = {
|
|
60
|
+
small: {
|
|
61
|
+
size: 40
|
|
62
|
+
},
|
|
63
|
+
default: {
|
|
64
|
+
size: 50
|
|
65
|
+
},
|
|
66
|
+
large: {
|
|
67
|
+
size: 60
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// 获取实际使用的 size 值(优先级:props.size > u-form.size)
|
|
72
|
+
const actualSize = computed(() => {
|
|
73
|
+
// 优先使用 props 的 size 属性
|
|
74
|
+
if (props.size !== '') {
|
|
75
|
+
return String(props.size);
|
|
76
|
+
}
|
|
77
|
+
// 次优先:使用 u-form 的 size 属性
|
|
78
|
+
if (parentExposed.value?.props?.size) {
|
|
79
|
+
return String(parentExposed.value.props.size);
|
|
80
|
+
}
|
|
81
|
+
// 默认值
|
|
82
|
+
return 'default';
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// 判断实际使用的 size 是否在预设配置中
|
|
86
|
+
const isInSizeConfig = computed(() => actualSize.value in sizeConfig);
|
|
87
|
+
|
|
88
|
+
// 获取预设 size(用于查找 sizeConfig 配置,如图标大小、高度等)
|
|
89
|
+
const presetSize = computed(() => {
|
|
90
|
+
return (isInSizeConfig.value ? actualSize.value : 'default') as SizeType;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// 获取当前尺寸配置
|
|
94
|
+
const currentSizeConfig = computed(() => sizeConfig[presetSize.value]);
|
|
95
|
+
|
|
96
|
+
// 获取实际要使用的 size(如果是预设值使用配置值,否则作为自定义值处理)
|
|
97
|
+
const currentSize = computed(() => {
|
|
98
|
+
if (isInSizeConfig.value) {
|
|
99
|
+
return $u.addUnit(currentSizeConfig.value.size);
|
|
100
|
+
}
|
|
101
|
+
// 自定义size值,直接作为fontSize处理
|
|
102
|
+
return $u.addUnit(actualSize.value);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// 加载动画尺寸,取当前size的60%
|
|
106
|
+
const loadingSize = computed(() => {
|
|
107
|
+
const sizeNum = Number(currentSize.value.replace('rpx', ''));
|
|
108
|
+
return sizeNum * 0.6;
|
|
109
|
+
});
|
|
55
110
|
|
|
56
111
|
/**
|
|
57
112
|
* 计算属性:是否处于激活状态
|
|
@@ -66,7 +121,7 @@ const isChecked = computed(() => {
|
|
|
66
121
|
*/
|
|
67
122
|
const switchStyle = computed(() => {
|
|
68
123
|
let style: Record<string, string> = {};
|
|
69
|
-
style.fontSize =
|
|
124
|
+
style.fontSize = currentSize.value;
|
|
70
125
|
style.backgroundColor = isChecked.value ? props.activeColor : props.inactiveColor;
|
|
71
126
|
return style;
|
|
72
127
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
-
import { baseProps } from '../common/props';
|
|
3
2
|
import type { TabbarItem } from '../../types/global';
|
|
4
3
|
import zIndex from '../../libs/config/zIndex';
|
|
5
4
|
|
|
@@ -8,7 +7,16 @@ import zIndex from '../../libs/config/zIndex';
|
|
|
8
7
|
* @description 底部导航栏,支持凸起按钮、徽标、切换前回调等
|
|
9
8
|
*/
|
|
10
9
|
export const TabbarProps = {
|
|
11
|
-
|
|
10
|
+
/** 自定义根节点样式 */
|
|
11
|
+
customStyle: {
|
|
12
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
13
|
+
default: () => ({})
|
|
14
|
+
},
|
|
15
|
+
/** 自定义根节点样式类 */
|
|
16
|
+
customClass: {
|
|
17
|
+
type: String as unknown as PropType<string>,
|
|
18
|
+
default: ''
|
|
19
|
+
},
|
|
12
20
|
/** 是否显示tabbar */
|
|
13
21
|
show: { type: Boolean, default: true },
|
|
14
22
|
/** v-model绑定当前激活项的值 */
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { TextAlign } from '../../types/global';
|
|
3
|
-
import { baseProps } from '../common/props';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* TableProps 表格 props 类型定义
|
|
7
6
|
* @description 表格组件,支持自定义边框、背景、对齐方式等
|
|
8
7
|
*/
|
|
9
8
|
export const TableProps = {
|
|
10
|
-
|
|
9
|
+
/** 自定义根节点样式 */
|
|
10
|
+
customStyle: {
|
|
11
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
12
|
+
default: () => ({})
|
|
13
|
+
},
|
|
14
|
+
/** 自定义根节点样式类 */
|
|
15
|
+
customClass: {
|
|
16
|
+
type: String as unknown as PropType<string>,
|
|
17
|
+
default: ''
|
|
18
|
+
},
|
|
11
19
|
/** 表格边框的颜色 */
|
|
12
20
|
borderColor: { type: String, default: 'var(--u-border-color)' },
|
|
13
21
|
/** 单元格的内容对齐方式,作用类似css的text-align */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { TabsItem } from '../../types/global';
|
|
3
|
-
import { baseProps } from '../common/props';
|
|
4
3
|
import { getColor } from '../../';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -8,7 +7,16 @@ import { getColor } from '../../';
|
|
|
8
7
|
* @description 标签组件,支持横向滚动、滑块、徽标等
|
|
9
8
|
*/
|
|
10
9
|
export const TabsProps = {
|
|
11
|
-
|
|
10
|
+
/** 自定义根节点样式 */
|
|
11
|
+
customStyle: {
|
|
12
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
13
|
+
default: () => ({})
|
|
14
|
+
},
|
|
15
|
+
/** 自定义根节点样式类 */
|
|
16
|
+
customClass: {
|
|
17
|
+
type: String as unknown as PropType<string>,
|
|
18
|
+
default: ''
|
|
19
|
+
},
|
|
12
20
|
/** tabs是否可以左右拖动 */
|
|
13
21
|
isScroll: { type: Boolean, default: true },
|
|
14
22
|
/** 标签数组 */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { TabsSwiperAutoCenterMode, TabsSwiperListItem } from '../../types/global';
|
|
3
|
-
import { baseProps } from '../common/props';
|
|
4
3
|
import { getColor } from '../../';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -8,7 +7,16 @@ import { getColor } from '../../';
|
|
|
8
7
|
* @description 全屏选项卡,支持滑块、渐变色、滚动居中等
|
|
9
8
|
*/
|
|
10
9
|
export const TabsSwiperProps = {
|
|
11
|
-
|
|
10
|
+
/** 自定义根节点样式 */
|
|
11
|
+
customStyle: {
|
|
12
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
13
|
+
default: () => ({})
|
|
14
|
+
},
|
|
15
|
+
/** 自定义根节点样式类 */
|
|
16
|
+
customClass: {
|
|
17
|
+
type: String as unknown as PropType<string>,
|
|
18
|
+
default: ''
|
|
19
|
+
},
|
|
12
20
|
/** tabs是否可以左右拖动 */
|
|
13
21
|
isScroll: { type: Boolean, default: true },
|
|
14
22
|
/** 标签数组,元素为对象,如[{name: '推荐'}] */
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { TagShape, TagMode, TagSize, ThemeType } from '../../types/global';
|
|
3
|
-
import { baseProps } from '../common/props';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* TagProps tag props 类型定义
|
|
7
6
|
* @description 标签组件,支持多种类型、尺寸、形状、可关闭等
|
|
8
7
|
*/
|
|
9
8
|
export const TagProps = {
|
|
10
|
-
|
|
9
|
+
/** 自定义根节点样式 */
|
|
10
|
+
customStyle: {
|
|
11
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
12
|
+
default: () => ({})
|
|
13
|
+
},
|
|
14
|
+
/** 自定义根节点样式类 */
|
|
15
|
+
customClass: {
|
|
16
|
+
type: String as unknown as PropType<string>,
|
|
17
|
+
default: ''
|
|
18
|
+
},
|
|
11
19
|
/** 类型,primary、success、info、warning、error */
|
|
12
20
|
type: { type: String as PropType<ThemeType>, default: 'primary' },
|
|
13
21
|
/** 是否禁用 */
|
|
@@ -189,26 +189,31 @@ function close() {
|
|
|
189
189
|
.u-mode-dark-primary {
|
|
190
190
|
background-color: $u-type-primary;
|
|
191
191
|
color: var(--u-white-color);
|
|
192
|
+
border: 1px solid $u-type-primary;
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
.u-mode-dark-success {
|
|
195
196
|
background-color: $u-type-success;
|
|
196
197
|
color: var(--u-white-color);
|
|
198
|
+
border: 1px solid $u-type-success;
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
.u-mode-dark-error {
|
|
200
202
|
background-color: $u-type-error;
|
|
201
203
|
color: var(--u-white-color);
|
|
204
|
+
border: 1px solid $u-type-error;
|
|
202
205
|
}
|
|
203
206
|
|
|
204
207
|
.u-mode-dark-warning {
|
|
205
208
|
background-color: $u-type-warning;
|
|
206
209
|
color: var(--u-white-color);
|
|
210
|
+
border: 1px solid $u-type-warning;
|
|
207
211
|
}
|
|
208
212
|
|
|
209
213
|
.u-mode-dark-info {
|
|
210
214
|
background-color: $u-type-info;
|
|
211
215
|
color: var(--u-white-color);
|
|
216
|
+
border: 1px solid $u-type-info;
|
|
212
217
|
}
|
|
213
218
|
|
|
214
219
|
.u-mode-plain-primary {
|
package/components/u-td/types.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
-
import { baseProps } from '../common/props';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* TdProps td props 类型定义
|
|
6
5
|
* @description 表格单元格组件,支持宽度自定义
|
|
7
6
|
*/
|
|
8
7
|
export const TdProps = {
|
|
9
|
-
|
|
8
|
+
/** 自定义根节点样式 */
|
|
9
|
+
customStyle: {
|
|
10
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
11
|
+
default: () => ({})
|
|
12
|
+
},
|
|
13
|
+
/** 自定义根节点样式类 */
|
|
14
|
+
customClass: {
|
|
15
|
+
type: String as unknown as PropType<string>,
|
|
16
|
+
default: ''
|
|
17
|
+
},
|
|
10
18
|
/** 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比 */
|
|
11
19
|
width: { type: [Number, String] as PropType<number | string>, default: 'auto' }
|
|
12
20
|
};
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { ThemeType } from '../../types/global';
|
|
3
|
-
import { baseProps } from '../common/props';
|
|
4
3
|
|
|
5
4
|
export const TextProps = {
|
|
6
|
-
|
|
5
|
+
/** 自定义根节点样式 */
|
|
6
|
+
customStyle: {
|
|
7
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
8
|
+
default: () => ({})
|
|
9
|
+
},
|
|
10
|
+
/** 自定义根节点样式类 */
|
|
11
|
+
customClass: {
|
|
12
|
+
type: String as unknown as PropType<string>,
|
|
13
|
+
default: ''
|
|
14
|
+
},
|
|
7
15
|
// 主题颜色
|
|
8
16
|
type: { type: String as PropType<ThemeType>, default: '' },
|
|
9
17
|
/** 是否显示文本 */
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
import type { TextareaBorder } from '../../types/global';
|
|
2
|
+
import type { TextareaBorder, SizeType } from '../../types/global';
|
|
4
3
|
|
|
5
4
|
const textarea = {
|
|
6
5
|
value: '',
|
|
7
6
|
placeholder: '',
|
|
8
7
|
placeholderClass: 'input-placeholder',
|
|
9
8
|
placeholderStyle: 'color: var(--u-light-color)',
|
|
10
|
-
height: '
|
|
9
|
+
height: '',
|
|
11
10
|
confirmType: 'done',
|
|
12
11
|
disabled: false,
|
|
13
12
|
count: false,
|
|
@@ -24,11 +23,21 @@ const textarea = {
|
|
|
24
23
|
holdKeyboard: false,
|
|
25
24
|
maxlength: 140,
|
|
26
25
|
border: 'surround',
|
|
27
|
-
formatter: null
|
|
26
|
+
formatter: null,
|
|
27
|
+
size: ''
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export const TextareaProps = {
|
|
31
|
-
|
|
31
|
+
/** 自定义根节点样式 */
|
|
32
|
+
customStyle: {
|
|
33
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
34
|
+
default: () => ({})
|
|
35
|
+
},
|
|
36
|
+
/** 自定义根节点样式类 */
|
|
37
|
+
customClass: {
|
|
38
|
+
type: String as unknown as PropType<string>,
|
|
39
|
+
default: ''
|
|
40
|
+
},
|
|
32
41
|
// 输入框的内容
|
|
33
42
|
modelValue: { type: [String, Number] as PropType<string | number>, default: textarea.value },
|
|
34
43
|
// 输入框为空时占位符
|
|
@@ -78,6 +87,8 @@ export const TextareaProps = {
|
|
|
78
87
|
formatter: { type: Function as unknown as PropType<((val: any) => any) | null>, default: textarea.formatter },
|
|
79
88
|
// 是否忽略组件内对文本合成系统事件的处理
|
|
80
89
|
ignoreCompositionEvent: { type: Boolean as PropType<boolean>, default: true },
|
|
90
|
+
/** 文本域文字大小(默认default),支持 small/default/large 预设值,也支持 16/16px/16rpx 等自定义值 */
|
|
91
|
+
size: { type: [String, Number] as PropType<SizeType | string | number>, default: textarea.size },
|
|
81
92
|
/** 是否可清空(默认true) */
|
|
82
93
|
clearable: { type: Boolean, default: true },
|
|
83
94
|
/** 输入框的验证状态,用于错误时,边框是否改为红色 */
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
:value="innerValue"
|
|
17
17
|
:style="getStyle"
|
|
18
18
|
:placeholder="String(props.placeholder)"
|
|
19
|
-
:placeholder-style="
|
|
19
|
+
:placeholder-style="getPlaceholderStyle"
|
|
20
20
|
:placeholder-class="props.placeholderClass"
|
|
21
21
|
:disabled="props.disabled"
|
|
22
22
|
:focus="props.focus"
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
<text
|
|
44
44
|
class="u-textarea__count"
|
|
45
45
|
:style="{
|
|
46
|
-
'background-color': props.disabled ? 'transparent' : 'var(--u-bg-white)'
|
|
46
|
+
'background-color': props.disabled ? 'transparent' : 'var(--u-bg-white)',
|
|
47
|
+
'font-size': currentCountSize
|
|
47
48
|
}"
|
|
48
49
|
v-if="props.count"
|
|
49
50
|
>
|
|
@@ -53,9 +54,15 @@
|
|
|
53
54
|
<view class="u-textarea__right-icon u-flex">
|
|
54
55
|
<view
|
|
55
56
|
class="u-textarea__right-icon__clear u-textarea__right-icon__item"
|
|
56
|
-
v-if="clearable &&
|
|
57
|
+
v-if="clearable && modelValue != '' && !disabled"
|
|
58
|
+
:class="{ 'u-hidden': !focused }"
|
|
57
59
|
>
|
|
58
|
-
<u-icon
|
|
60
|
+
<u-icon
|
|
61
|
+
name="close-circle-fill"
|
|
62
|
+
color="var(--u-light-color)"
|
|
63
|
+
:size="currentIconSize"
|
|
64
|
+
@click="onClear"
|
|
65
|
+
/>
|
|
59
66
|
</view>
|
|
60
67
|
</view>
|
|
61
68
|
</view>
|
|
@@ -78,6 +85,7 @@ export default {
|
|
|
78
85
|
import { ref, computed, watch, nextTick } from 'vue';
|
|
79
86
|
import { TextareaProps } from './types';
|
|
80
87
|
import { $u, useChildren } from '../../';
|
|
88
|
+
import type { SizeType } from '../../types/global';
|
|
81
89
|
|
|
82
90
|
/**
|
|
83
91
|
* Textarea 文本域
|
|
@@ -128,6 +136,7 @@ const emit = defineEmits([
|
|
|
128
136
|
]);
|
|
129
137
|
|
|
130
138
|
const { emitToParent } = useChildren('u-textarea', 'u-form-item');
|
|
139
|
+
const { parentExposed } = useChildren('u-textarea', 'u-form');
|
|
131
140
|
|
|
132
141
|
// state
|
|
133
142
|
const innerValue = ref('');
|
|
@@ -137,6 +146,67 @@ const changeFromInner = ref(false);
|
|
|
137
146
|
const innerFormatter = ref((v: any) => v);
|
|
138
147
|
const validateState = ref(props.validateState); // 当前input的验证状态,用于错误时,边框是否改为红色
|
|
139
148
|
|
|
149
|
+
// 根据 size 定义不同的配置
|
|
150
|
+
const sizeConfig = {
|
|
151
|
+
small: {
|
|
152
|
+
fontSize: 24,
|
|
153
|
+
iconSize: 28,
|
|
154
|
+
countSize: 20,
|
|
155
|
+
textareaHeight: 70
|
|
156
|
+
},
|
|
157
|
+
default: {
|
|
158
|
+
fontSize: 28,
|
|
159
|
+
iconSize: 32,
|
|
160
|
+
countSize: 24,
|
|
161
|
+
textareaHeight: 100
|
|
162
|
+
},
|
|
163
|
+
large: {
|
|
164
|
+
fontSize: 32,
|
|
165
|
+
iconSize: 36,
|
|
166
|
+
countSize: 24,
|
|
167
|
+
textareaHeight: 130
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// 获取实际使用的 size 值(优先级:props.size > u-form.size)
|
|
172
|
+
const actualSize = computed(() => {
|
|
173
|
+
// 优先使用 props 的 size 属性
|
|
174
|
+
if (props.size !== '') {
|
|
175
|
+
return String(props.size);
|
|
176
|
+
}
|
|
177
|
+
// 次优先:使用 u-form 的 size 属性(u-form 的 size 只支持预设值)
|
|
178
|
+
if (parentExposed.value?.props?.size) {
|
|
179
|
+
return String(parentExposed.value.props.size);
|
|
180
|
+
}
|
|
181
|
+
// 默认值
|
|
182
|
+
return 'default';
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// 判断实际使用的 size 是否在预设配置中
|
|
186
|
+
const isInSizeConfig = computed(() => actualSize.value in sizeConfig);
|
|
187
|
+
|
|
188
|
+
// 获取预设 size(用于查找 sizeConfig 配置,如图标大小、高度等)
|
|
189
|
+
const presetSize = computed(() => {
|
|
190
|
+
return (isInSizeConfig.value ? actualSize.value : 'default') as SizeType;
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// 获取当前尺寸配置
|
|
194
|
+
const currentSizeConfig = computed(() => sizeConfig[presetSize.value]);
|
|
195
|
+
|
|
196
|
+
// 获取实际要使用的 font-size(如果是预设值使用配置值,否则作为自定义值处理)
|
|
197
|
+
const actualFontSize = computed(() => {
|
|
198
|
+
if (isInSizeConfig.value) {
|
|
199
|
+
return $u.addUnit(currentSizeConfig.value.fontSize);
|
|
200
|
+
}
|
|
201
|
+
// 自定义size值,直接作为fontSize处理
|
|
202
|
+
return $u.addUnit(actualSize.value);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// 计算当前图标大小
|
|
206
|
+
const currentIconSize = computed(() => currentSizeConfig.value.iconSize);
|
|
207
|
+
// 计算统计显示的字体大小
|
|
208
|
+
const currentCountSize = computed(() => $u.addUnit(currentSizeConfig.value.countSize));
|
|
209
|
+
|
|
140
210
|
// watch value prop
|
|
141
211
|
watch(
|
|
142
212
|
() => props.modelValue,
|
|
@@ -200,14 +270,25 @@ const getStyle = computed(() => {
|
|
|
200
270
|
let style: Record<string, any> = {};
|
|
201
271
|
// 如果没有自定义高度,就根据textarea来分配一个默认的高度
|
|
202
272
|
if (props.autoHeight) {
|
|
203
|
-
style.minHeight = $u.addUnit(props.height
|
|
273
|
+
style.minHeight = $u.addUnit(props.height ? props.height : currentSizeConfig.value.textareaHeight);
|
|
204
274
|
style.height = 'auto';
|
|
205
275
|
} else {
|
|
206
|
-
style.height = $u.addUnit(props.height);
|
|
276
|
+
style.height = $u.addUnit(props.height ? props.height : currentSizeConfig.value.textareaHeight);
|
|
207
277
|
}
|
|
278
|
+
// 根据 size 属性设置字体大小
|
|
279
|
+
style.fontSize = actualFontSize.value;
|
|
208
280
|
return $u.toStyle(style, props.customStyle);
|
|
209
281
|
});
|
|
210
282
|
|
|
283
|
+
const getPlaceholderStyle = computed(() => {
|
|
284
|
+
return $u.toStyle(
|
|
285
|
+
{
|
|
286
|
+
fontSize: actualFontSize.value
|
|
287
|
+
},
|
|
288
|
+
props.placeholderStyle
|
|
289
|
+
);
|
|
290
|
+
});
|
|
291
|
+
|
|
211
292
|
function onFormItemError(status: boolean) {
|
|
212
293
|
validateState.value = status;
|
|
213
294
|
}
|
package/components/u-th/types.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
-
import { baseProps } from '../common/props';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* ThProps th props 类型定义
|
|
6
5
|
* @description 表格表头单元格组件,支持宽度自定义
|
|
7
6
|
*/
|
|
8
7
|
export const ThProps = {
|
|
9
|
-
|
|
8
|
+
/** 自定义根节点样式 */
|
|
9
|
+
customStyle: {
|
|
10
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
11
|
+
default: () => ({})
|
|
12
|
+
},
|
|
13
|
+
/** 自定义根节点样式类 */
|
|
14
|
+
customClass: {
|
|
15
|
+
type: String as unknown as PropType<string>,
|
|
16
|
+
default: ''
|
|
17
|
+
},
|
|
10
18
|
/** 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比 */
|
|
11
19
|
width: { type: [Number, String] as PropType<number | string>, default: 'auto' }
|
|
12
20
|
};
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
20
|
<script setup lang="ts">
|
|
21
|
-
import {
|
|
21
|
+
import type { PropType } from 'vue';
|
|
22
22
|
import { $u } from '../../';
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -28,7 +28,18 @@ import { $u } from '../../';
|
|
|
28
28
|
* @example <u-time-line></u-time-line>
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
const props = defineProps({
|
|
31
|
+
const props = defineProps({
|
|
32
|
+
/** 自定义根节点样式 */
|
|
33
|
+
customStyle: {
|
|
34
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
35
|
+
default: () => ({})
|
|
36
|
+
},
|
|
37
|
+
/** 自定义根节点样式类 */
|
|
38
|
+
customClass: {
|
|
39
|
+
type: String as unknown as PropType<string>,
|
|
40
|
+
default: ''
|
|
41
|
+
}
|
|
42
|
+
});
|
|
32
43
|
</script>
|
|
33
44
|
|
|
34
45
|
<style lang="scss" scoped>
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
-
import { baseProps } from '../common/props';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* TimeLineItemProps 时间轴节点 props 类型定义
|
|
6
5
|
* @description 时间轴节点组件,支持自定义节点颜色、位置
|
|
7
6
|
*/
|
|
8
7
|
export const TimeLineItemProps = {
|
|
9
|
-
|
|
8
|
+
/** 自定义根节点样式 */
|
|
9
|
+
customStyle: {
|
|
10
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
11
|
+
default: () => ({})
|
|
12
|
+
},
|
|
13
|
+
/** 自定义根节点样式类 */
|
|
14
|
+
customClass: {
|
|
15
|
+
type: String as unknown as PropType<string>,
|
|
16
|
+
default: ''
|
|
17
|
+
},
|
|
10
18
|
/** 节点的背景颜色 */
|
|
11
19
|
bgColor: { type: String, default: 'var(--u-bg-white)' },
|
|
12
20
|
/** 节点左边图标绝对定位的top值,单位rpx */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { ThemeType, ToastPosition } from '../../types/global';
|
|
3
|
-
import { baseProps } from '../common/props';
|
|
4
3
|
import zIndex from '../../libs/config/zIndex';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -8,7 +7,16 @@ import zIndex from '../../libs/config/zIndex';
|
|
|
8
7
|
* @description 消息提示组件,支持 z-index 及多种配置项
|
|
9
8
|
*/
|
|
10
9
|
export const ToastProps = {
|
|
11
|
-
|
|
10
|
+
/** 自定义根节点样式 */
|
|
11
|
+
customStyle: {
|
|
12
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
13
|
+
default: () => ({})
|
|
14
|
+
},
|
|
15
|
+
/** 自定义根节点样式类 */
|
|
16
|
+
customClass: {
|
|
17
|
+
type: String as unknown as PropType<string>,
|
|
18
|
+
default: ''
|
|
19
|
+
},
|
|
12
20
|
/** 层级 z-index */
|
|
13
21
|
zIndex: { type: [Number, String] as PropType<number | string>, default: zIndex.toast },
|
|
14
22
|
/** 提示类型,success/warning/error/loading 等 */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
-
import { baseProps } from '../common/props';
|
|
3
2
|
import zIndex from '../../libs/config/zIndex';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -7,7 +6,16 @@ import zIndex from '../../libs/config/zIndex';
|
|
|
7
6
|
* @description 顶部提示组件,支持导航栏高度、z-index
|
|
8
7
|
*/
|
|
9
8
|
export const TopTipsProps = {
|
|
10
|
-
|
|
9
|
+
/** 自定义根节点样式 */
|
|
10
|
+
customStyle: {
|
|
11
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
12
|
+
default: () => ({})
|
|
13
|
+
},
|
|
14
|
+
/** 自定义根节点样式类 */
|
|
15
|
+
customClass: {
|
|
16
|
+
type: String as unknown as PropType<string>,
|
|
17
|
+
default: ''
|
|
18
|
+
},
|
|
11
19
|
/** 导航栏高度,用于提示的初始化 */
|
|
12
20
|
navbarHeight: { type: [Number, String] as PropType<number | string>, default: 0 },
|
|
13
21
|
/** z-index值 */
|
package/components/u-tr/types.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type { ExtractPropTypes } from 'vue';
|
|
2
|
-
import { baseProps } from '../common/props';
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* TrProps tr props 类型定义
|
|
6
5
|
* @description 表格行组件,无特殊 props
|
|
7
6
|
*/
|
|
8
7
|
export const TrProps = {
|
|
9
|
-
|
|
8
|
+
/** 自定义根节点样式 */
|
|
9
|
+
customStyle: {
|
|
10
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
11
|
+
default: () => ({})
|
|
12
|
+
},
|
|
13
|
+
/** 自定义根节点样式类 */
|
|
14
|
+
customClass: {
|
|
15
|
+
type: String as unknown as PropType<string>,
|
|
16
|
+
default: ''
|
|
17
|
+
}
|
|
10
18
|
};
|
|
11
19
|
export type TrProps = ExtractPropTypes<typeof TrProps>;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
|
-
import { baseProps } from '../common/props';
|
|
3
2
|
import type { TransitionDuration, TransitionPreset } from '../../types/global';
|
|
4
3
|
|
|
5
4
|
export const TransitionProps = {
|
|
6
|
-
|
|
5
|
+
/** 自定义根节点样式 */
|
|
6
|
+
customStyle: {
|
|
7
|
+
type: [String, Object] as PropType<string | Record<string, any>>,
|
|
8
|
+
default: () => ({})
|
|
9
|
+
},
|
|
10
|
+
/** 自定义根节点样式类 */
|
|
11
|
+
customClass: {
|
|
12
|
+
type: String as unknown as PropType<string>,
|
|
13
|
+
default: ''
|
|
14
|
+
},
|
|
7
15
|
show: {
|
|
8
16
|
type: Boolean,
|
|
9
17
|
default: true
|