tang-ui-x 1.0.6 → 1.1.1
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/components/TForm/README.md +644 -0
- package/components/TForm/index.uvue +392 -0
- package/components/TForm/type.uts +80 -0
- package/components/TRadioButton/README.md +117 -0
- package/components/TRadioButton/index.uvue +69 -64
- package/index.uts +108 -107
- package/package.json +48 -47
- package/components/VbenFrom/index.uvue +0 -392
|
@@ -14,6 +14,8 @@ type Props = {
|
|
|
14
14
|
options?: FormOption[]
|
|
15
15
|
/** 单个按钮模式:选项值 */
|
|
16
16
|
value?: string | number
|
|
17
|
+
/** 单个按钮模式:显示标签 */
|
|
18
|
+
label?: string
|
|
17
19
|
/** 按钮尺寸 */
|
|
18
20
|
size?: 'small' | 'medium' | 'large'
|
|
19
21
|
/** 活动状态颜色 */
|
|
@@ -60,14 +62,16 @@ const isOptionsMode = computed(() => props.options && props.options.length > 0)
|
|
|
60
62
|
* 单个按钮模式:判断是否被选中
|
|
61
63
|
*/
|
|
62
64
|
const isChecked = computed(() => {
|
|
63
|
-
|
|
65
|
+
// 优先使用 model.value 判断
|
|
66
|
+
if (model.value !== undefined && model.value !== null) {
|
|
64
67
|
return model.value === props.value
|
|
65
68
|
}
|
|
66
|
-
|
|
69
|
+
// 如果没有 model.value,使用 checked 属性
|
|
70
|
+
return props.checked === true
|
|
67
71
|
})
|
|
68
72
|
|
|
69
73
|
/**
|
|
70
|
-
|
|
74
|
+
* 处理变化
|
|
71
75
|
*/
|
|
72
76
|
const handleChange = (value: string | number) => {
|
|
73
77
|
model.value = value
|
|
@@ -79,7 +83,9 @@ const handleChange = (value: string | number) => {
|
|
|
79
83
|
*/
|
|
80
84
|
const handleClick = () => {
|
|
81
85
|
if (props.disabled || isOptionsMode.value) return
|
|
82
|
-
|
|
86
|
+
if (props.value !== undefined) {
|
|
87
|
+
handleChange(props.value)
|
|
88
|
+
}
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
/**
|
|
@@ -99,26 +105,26 @@ const sizeClass = computed(() => {
|
|
|
99
105
|
<!-- 选项组模式:使用 options 属性 -->
|
|
100
106
|
<view v-if="isOptionsMode" class="radio-group" :style="cssVars">
|
|
101
107
|
<view
|
|
102
|
-
v-for="option in
|
|
108
|
+
v-for="option in options"
|
|
103
109
|
:key="option.value"
|
|
104
110
|
class="radio-item"
|
|
105
|
-
:class="{ 'radio-disabled':
|
|
106
|
-
@click="!
|
|
111
|
+
:class="{ 'radio-disabled': disabled }"
|
|
112
|
+
@click="!disabled && handleChange(option.value)"
|
|
107
113
|
>
|
|
108
|
-
<view class="radio-icon" :class="{ active: model === option.value, 'radio-disabled':
|
|
109
|
-
<view v-if="model === option.value" class="radio-dot"></view>
|
|
114
|
+
<view class="radio-icon" :class="{ active: model.value === option.value, 'radio-disabled': disabled }">
|
|
115
|
+
<view v-if="model.value === option.value" class="radio-dot"></view>
|
|
110
116
|
</view>
|
|
111
117
|
<text class="radio-label">{{ option.label }}</text>
|
|
112
118
|
</view>
|
|
113
119
|
</view>
|
|
114
120
|
|
|
115
121
|
<!-- 单个按钮模式:使用插槽或默认内容 -->
|
|
116
|
-
<view v-else class="radio-item" :class="[sizeClass, { 'radio-disabled':
|
|
117
|
-
<view class="radio-icon" :class="{ active: isChecked, 'radio-disabled':
|
|
122
|
+
<view v-else class="radio-item" :class="[sizeClass, { active: isChecked, 'radio-disabled': disabled }]" :style="cssVars" @tap="handleClick">
|
|
123
|
+
<view class="radio-icon" :class="{ active: isChecked, 'radio-disabled': disabled }">
|
|
118
124
|
<view v-if="isChecked" class="radio-dot"></view>
|
|
119
125
|
</view>
|
|
120
126
|
<slot>
|
|
121
|
-
<text v-if="
|
|
127
|
+
<text v-if="label || value !== undefined" class="radio-label">{{ label || value }}</text>
|
|
122
128
|
</slot>
|
|
123
129
|
</view>
|
|
124
130
|
</template>
|
|
@@ -126,24 +132,29 @@ const sizeClass = computed(() => {
|
|
|
126
132
|
<style lang="scss" scoped>
|
|
127
133
|
/* 选项组容器 */
|
|
128
134
|
.radio-group {
|
|
135
|
+
display: flex;
|
|
129
136
|
flex-direction: column;
|
|
130
137
|
gap: 16rpx;
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
/* 单个按钮容器 */
|
|
134
141
|
.radio-item {
|
|
142
|
+
display: flex;
|
|
135
143
|
flex-direction: row;
|
|
136
144
|
align-items: center;
|
|
137
145
|
gap: 16rpx;
|
|
146
|
+
padding: 8rpx 0;
|
|
147
|
+
cursor: pointer;
|
|
148
|
+
}
|
|
138
149
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
150
|
+
.radio-item.radio-disabled {
|
|
151
|
+
opacity: 0.5;
|
|
152
|
+
cursor: not-allowed;
|
|
143
153
|
}
|
|
144
154
|
|
|
145
155
|
/* 单选按钮图标 */
|
|
146
156
|
.radio-icon {
|
|
157
|
+
display: flex;
|
|
147
158
|
justify-content: center;
|
|
148
159
|
align-items: center;
|
|
149
160
|
border-radius: 50%;
|
|
@@ -151,14 +162,14 @@ const sizeClass = computed(() => {
|
|
|
151
162
|
border-style: solid;
|
|
152
163
|
border-color: var(--radio-inactive-color);
|
|
153
164
|
transition: all 0.2s ease;
|
|
165
|
+
}
|
|
154
166
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
167
|
+
.radio-icon.active {
|
|
168
|
+
border-color: var(--radio-active-color);
|
|
169
|
+
}
|
|
158
170
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
171
|
+
.radio-icon.radio-disabled {
|
|
172
|
+
border-color: #dcdfe6;
|
|
162
173
|
}
|
|
163
174
|
|
|
164
175
|
/* 单选点 */
|
|
@@ -168,65 +179,59 @@ const sizeClass = computed(() => {
|
|
|
168
179
|
}
|
|
169
180
|
|
|
170
181
|
/* 尺寸样式 */
|
|
171
|
-
.radio-size-small {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
182
|
+
.radio-size-small .radio-icon {
|
|
183
|
+
width: 28rpx;
|
|
184
|
+
height: 28rpx;
|
|
185
|
+
}
|
|
176
186
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
187
|
+
.radio-size-small .radio-dot {
|
|
188
|
+
width: 14rpx;
|
|
189
|
+
height: 14rpx;
|
|
190
|
+
}
|
|
181
191
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
192
|
+
.radio-size-small .radio-label {
|
|
193
|
+
font-size: 24rpx;
|
|
185
194
|
}
|
|
186
195
|
|
|
187
|
-
.radio-size-medium {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
196
|
+
.radio-size-medium .radio-icon {
|
|
197
|
+
width: 36rpx;
|
|
198
|
+
height: 36rpx;
|
|
199
|
+
}
|
|
192
200
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
201
|
+
.radio-size-medium .radio-dot {
|
|
202
|
+
width: 20rpx;
|
|
203
|
+
height: 20rpx;
|
|
204
|
+
}
|
|
197
205
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
206
|
+
.radio-size-medium .radio-label {
|
|
207
|
+
font-size: 28rpx;
|
|
201
208
|
}
|
|
202
209
|
|
|
203
|
-
.radio-size-large {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
210
|
+
.radio-size-large .radio-icon {
|
|
211
|
+
width: 44rpx;
|
|
212
|
+
height: 44rpx;
|
|
213
|
+
}
|
|
208
214
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
.radio-size-large .radio-dot {
|
|
216
|
+
width: 26rpx;
|
|
217
|
+
height: 26rpx;
|
|
218
|
+
}
|
|
213
219
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
220
|
+
.radio-size-large .radio-label {
|
|
221
|
+
font-size: 32rpx;
|
|
217
222
|
}
|
|
218
223
|
|
|
219
224
|
/* 文本标签 */
|
|
220
225
|
.radio-label {
|
|
221
226
|
color: var(--radio-inactive-color);
|
|
222
227
|
transition: color 0.2s ease;
|
|
228
|
+
}
|
|
223
229
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
.radio-item.active .radio-label {
|
|
231
|
+
color: var(--radio-active-color);
|
|
232
|
+
}
|
|
227
233
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
234
|
+
.radio-item.radio-disabled .radio-label {
|
|
235
|
+
color: #c0c4cc;
|
|
231
236
|
}
|
|
232
237
|
</style>
|
package/index.uts
CHANGED
|
@@ -1,107 +1,108 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tang UI - UniApp X UI 组件库
|
|
3
|
-
* @description 基于 uni-app x 的移动端 UI 组件库
|
|
4
|
-
* @version 1.0.2
|
|
5
|
-
* @author sugar258596
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 注意:uni-app x 项目推荐使用 easycom 自动导入组件
|
|
10
|
-
*
|
|
11
|
-
* 在 pages.json 中配置:
|
|
12
|
-
* {
|
|
13
|
-
* "easycom": {
|
|
14
|
-
* "autoscan": true,
|
|
15
|
-
* "custom": {
|
|
16
|
-
* "^T(.*)": "tang-ui-x/components/T$1/index.uvue"
|
|
17
|
-
* }
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* 然后在页面中直接使用:
|
|
22
|
-
* <TButton type="primary">按钮</TButton>
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
// 导出工具函数
|
|
26
|
-
export * from './utils/index.uts'
|
|
27
|
-
|
|
28
|
-
// 导出 composables
|
|
29
|
-
export { useTheme } from './composables/useTheme.uts'
|
|
30
|
-
export { useToast } from './composables/useToast.uts'
|
|
31
|
-
export { useModal } from './composables/useModal.uts'
|
|
32
|
-
|
|
33
|
-
// 版本信息
|
|
34
|
-
export const version: string = '1.0.5'
|
|
35
|
-
|
|
36
|
-
// 组件列表(用于文档和类型提示)
|
|
37
|
-
export const components: string[] = [
|
|
38
|
-
// 基础组件
|
|
39
|
-
'TButton',
|
|
40
|
-
'TIcon',
|
|
41
|
-
'TText',
|
|
42
|
-
'TImage',
|
|
43
|
-
'TDivider',
|
|
44
|
-
|
|
45
|
-
// 布局组件
|
|
46
|
-
'TCard',
|
|
47
|
-
'TList',
|
|
48
|
-
'TListItem',
|
|
49
|
-
'TCell',
|
|
50
|
-
'TGrid',
|
|
51
|
-
'TGridItem',
|
|
52
|
-
'TRow',
|
|
53
|
-
'TCol',
|
|
54
|
-
|
|
55
|
-
// 表单组件
|
|
56
|
-
'TInput',
|
|
57
|
-
'TNumberInput',
|
|
58
|
-
'TTextarea',
|
|
59
|
-
'TSearchBar',
|
|
60
|
-
'TSwitch',
|
|
61
|
-
'TCheckbox',
|
|
62
|
-
'TCheckboxGroup',
|
|
63
|
-
'TRadioButton',
|
|
64
|
-
'TRadioGroup',
|
|
65
|
-
'TSelect',
|
|
66
|
-
'TSlider',
|
|
67
|
-
'TRate',
|
|
68
|
-
'TPicker',
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
78
|
-
'
|
|
79
|
-
'
|
|
80
|
-
'
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
'
|
|
85
|
-
'
|
|
86
|
-
'
|
|
87
|
-
'
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
'
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Tang UI - UniApp X UI 组件库
|
|
3
|
+
* @description 基于 uni-app x 的移动端 UI 组件库
|
|
4
|
+
* @version 1.0.2
|
|
5
|
+
* @author sugar258596
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 注意:uni-app x 项目推荐使用 easycom 自动导入组件
|
|
10
|
+
*
|
|
11
|
+
* 在 pages.json 中配置:
|
|
12
|
+
* {
|
|
13
|
+
* "easycom": {
|
|
14
|
+
* "autoscan": true,
|
|
15
|
+
* "custom": {
|
|
16
|
+
* "^T(.*)": "tang-ui-x/components/T$1/index.uvue"
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* 然后在页面中直接使用:
|
|
22
|
+
* <TButton type="primary">按钮</TButton>
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
// 导出工具函数
|
|
26
|
+
export * from './utils/index.uts'
|
|
27
|
+
|
|
28
|
+
// 导出 composables
|
|
29
|
+
export { useTheme } from './composables/useTheme.uts'
|
|
30
|
+
export { useToast } from './composables/useToast.uts'
|
|
31
|
+
export { useModal } from './composables/useModal.uts'
|
|
32
|
+
|
|
33
|
+
// 版本信息
|
|
34
|
+
export const version: string = '1.0.5'
|
|
35
|
+
|
|
36
|
+
// 组件列表(用于文档和类型提示)
|
|
37
|
+
export const components: string[] = [
|
|
38
|
+
// 基础组件
|
|
39
|
+
'TButton',
|
|
40
|
+
'TIcon',
|
|
41
|
+
'TText',
|
|
42
|
+
'TImage',
|
|
43
|
+
'TDivider',
|
|
44
|
+
|
|
45
|
+
// 布局组件
|
|
46
|
+
'TCard',
|
|
47
|
+
'TList',
|
|
48
|
+
'TListItem',
|
|
49
|
+
'TCell',
|
|
50
|
+
'TGrid',
|
|
51
|
+
'TGridItem',
|
|
52
|
+
'TRow',
|
|
53
|
+
'TCol',
|
|
54
|
+
|
|
55
|
+
// 表单组件
|
|
56
|
+
'TInput',
|
|
57
|
+
'TNumberInput',
|
|
58
|
+
'TTextarea',
|
|
59
|
+
'TSearchBar',
|
|
60
|
+
'TSwitch',
|
|
61
|
+
'TCheckbox',
|
|
62
|
+
'TCheckboxGroup',
|
|
63
|
+
'TRadioButton',
|
|
64
|
+
'TRadioGroup',
|
|
65
|
+
'TSelect',
|
|
66
|
+
'TSlider',
|
|
67
|
+
'TRate',
|
|
68
|
+
'TPicker',
|
|
69
|
+
'TForm',
|
|
70
|
+
|
|
71
|
+
// 数据展示
|
|
72
|
+
'Tags',
|
|
73
|
+
'TBadge',
|
|
74
|
+
'TAvatar',
|
|
75
|
+
'TProgress',
|
|
76
|
+
'TNoticeBar',
|
|
77
|
+
'TCollapse',
|
|
78
|
+
'TCollapseItem',
|
|
79
|
+
'TEmpty',
|
|
80
|
+
'TErrorState',
|
|
81
|
+
'TSwiper',
|
|
82
|
+
|
|
83
|
+
// 反馈组件
|
|
84
|
+
'TLoading',
|
|
85
|
+
'TToast',
|
|
86
|
+
'TDialog',
|
|
87
|
+
'TPopup',
|
|
88
|
+
'TActionSheet',
|
|
89
|
+
|
|
90
|
+
// 导航组件
|
|
91
|
+
'Tabs',
|
|
92
|
+
'TNavBar'
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Tang UI 插件
|
|
97
|
+
*/
|
|
98
|
+
const TangUI = {
|
|
99
|
+
install(app: any) {
|
|
100
|
+
// uni-app x 使用 easycom 自动导入组件,这里不需要注册组件
|
|
101
|
+
console.log('Tang UI X installed, version:', version)
|
|
102
|
+
},
|
|
103
|
+
version,
|
|
104
|
+
components
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 默认导出
|
|
108
|
+
export default TangUI
|
package/package.json
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tang-ui-x",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "UniApp X UI 组件库 - 基于 uni-app x 的移动端 UI 组件库",
|
|
5
|
-
"main": "index.uts",
|
|
6
|
-
"module": "index.uts",
|
|
7
|
-
"types": "types/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"components",
|
|
10
|
-
"composables",
|
|
11
|
-
"utils",
|
|
12
|
-
"types",
|
|
13
|
-
"style",
|
|
14
|
-
"uni.scss",
|
|
15
|
-
"index.uts",
|
|
16
|
-
"README.md",
|
|
17
|
-
"LICENSE"
|
|
18
|
-
],
|
|
19
|
-
"keywords": [
|
|
20
|
-
"uniapp",
|
|
21
|
-
"uni-app-x",
|
|
22
|
-
"uniapp-x",
|
|
23
|
-
"ui",
|
|
24
|
-
"components",
|
|
25
|
-
"mobile",
|
|
26
|
-
"vue3",
|
|
27
|
-
"typescript",
|
|
28
|
-
"tang-ui"
|
|
29
|
-
],
|
|
30
|
-
"author": "sugar258596",
|
|
31
|
-
"license": "MIT",
|
|
32
|
-
"repository": {
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "https://github.com/sugar258596/tang-ui.git"
|
|
35
|
-
},
|
|
36
|
-
"bugs": {
|
|
37
|
-
"url": "https://github.com/sugar258596/tang-ui/issues"
|
|
38
|
-
},
|
|
39
|
-
"homepage": "https://github.com/sugar258596/tang-ui#readme",
|
|
40
|
-
"peerDependencies": {
|
|
41
|
-
"vue": "^3.0.0"
|
|
42
|
-
},
|
|
43
|
-
"scripts": {
|
|
44
|
-
"preinstall": "npx only-allow pnpm",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "tang-ui-x",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "UniApp X UI 组件库 - 基于 uni-app x 的移动端 UI 组件库",
|
|
5
|
+
"main": "index.uts",
|
|
6
|
+
"module": "index.uts",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"components",
|
|
10
|
+
"composables",
|
|
11
|
+
"utils",
|
|
12
|
+
"types",
|
|
13
|
+
"style",
|
|
14
|
+
"uni.scss",
|
|
15
|
+
"index.uts",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"uniapp",
|
|
21
|
+
"uni-app-x",
|
|
22
|
+
"uniapp-x",
|
|
23
|
+
"ui",
|
|
24
|
+
"components",
|
|
25
|
+
"mobile",
|
|
26
|
+
"vue3",
|
|
27
|
+
"typescript",
|
|
28
|
+
"tang-ui"
|
|
29
|
+
],
|
|
30
|
+
"author": "sugar258596",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/sugar258596/tang-ui.git"
|
|
35
|
+
},
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/sugar258596/tang-ui/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/sugar258596/tang-ui#readme",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"vue": "^3.0.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"preinstall": "npx only-allow pnpm",
|
|
45
|
+
"prepublishOnly": "pnpm run build",
|
|
46
|
+
"build": "echo 'Build completed'",
|
|
47
|
+
"version": "pnpm run build"
|
|
48
|
+
}
|
|
48
49
|
}
|