tang-ui-x 1.0.0

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 (98) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -0
  3. package/components/TActionSheet/index.uvue +170 -0
  4. package/components/TActionSheet/type.uts +29 -0
  5. package/components/TAvatar/index.uvue +156 -0
  6. package/components/TAvatar/type.uts +54 -0
  7. package/components/TBadge/index.uvue +152 -0
  8. package/components/TBadge/type.uts +48 -0
  9. package/components/TButton/README.md +111 -0
  10. package/components/TButton/index.uvue +380 -0
  11. package/components/TButton/type.uts +95 -0
  12. package/components/TCard/index.uvue +174 -0
  13. package/components/TCard/type.uts +50 -0
  14. package/components/TCell/index.uvue +49 -0
  15. package/components/TCheckbox/index.uvue +187 -0
  16. package/components/TCheckboxGroup/index.uvue +139 -0
  17. package/components/TCheckboxGroup/type.uts +26 -0
  18. package/components/TCol/index.uvue +82 -0
  19. package/components/TCol/type.uts +30 -0
  20. package/components/TCollapse/index.uvue +93 -0
  21. package/components/TCollapse/type.uts +36 -0
  22. package/components/TCollapseItem/index.uvue +194 -0
  23. package/components/TCollapseItem/type.uts +25 -0
  24. package/components/TDialog/index.uvue +386 -0
  25. package/components/TDialog/type.uts +84 -0
  26. package/components/TDivider/index.uvue +235 -0
  27. package/components/TDivider/type.uts +91 -0
  28. package/components/TEmpty/index.uvue +128 -0
  29. package/components/TErrorState/index.uvue +57 -0
  30. package/components/TGrid/index.uvue +115 -0
  31. package/components/TGrid/type.uts +77 -0
  32. package/components/TGridItem/index.uvue +243 -0
  33. package/components/TGridItem/type.uts +64 -0
  34. package/components/TIcon/index.uvue +96 -0
  35. package/components/TImage/index.uvue +255 -0
  36. package/components/TImage/type.uts +146 -0
  37. package/components/TInput/README.md +119 -0
  38. package/components/TInput/index.uvue +376 -0
  39. package/components/TInput/type.uts +138 -0
  40. package/components/TList/index.uvue +82 -0
  41. package/components/TList/type.uts +68 -0
  42. package/components/TListItem/index.uvue +161 -0
  43. package/components/TListItem/type.uts +49 -0
  44. package/components/TLoading/index.uvue +153 -0
  45. package/components/TLoading/type.uts +43 -0
  46. package/components/TNavBar/index.uvue +120 -0
  47. package/components/TNavBar/type.uts +22 -0
  48. package/components/TNoticeBar/index.uvue +106 -0
  49. package/components/TNoticeBar/type.uts +21 -0
  50. package/components/TNumberInput/index.uvue +226 -0
  51. package/components/TPicker/index.uvue +276 -0
  52. package/components/TPicker/type.uts +105 -0
  53. package/components/TPopup/index.uvue +442 -0
  54. package/components/TProgress/index.uvue +103 -0
  55. package/components/TProgress/type.uts +64 -0
  56. package/components/TRadioButton/index.uvue +232 -0
  57. package/components/TRadioGroup/index.uvue +117 -0
  58. package/components/TRadioGroup/type.uts +25 -0
  59. package/components/TRate/index.uvue +182 -0
  60. package/components/TRow/index.uvue +105 -0
  61. package/components/TRow/type.uts +52 -0
  62. package/components/TSearchBar/index.uvue +255 -0
  63. package/components/TSearchBar/type.uts +140 -0
  64. package/components/TSelect/index.uvue +655 -0
  65. package/components/TSelect/type.uts +57 -0
  66. package/components/TSlider/index.uvue +72 -0
  67. package/components/TSlider/type.uts +21 -0
  68. package/components/TSwiper/index.uvue +222 -0
  69. package/components/TSwiper/type.uts +77 -0
  70. package/components/TSwitch/index.uvue +177 -0
  71. package/components/TSwitch/type.uts +52 -0
  72. package/components/TText/README.md +124 -0
  73. package/components/TText/index.uvue +257 -0
  74. package/components/TText/type.uts +114 -0
  75. package/components/TTextarea/index.uvue +239 -0
  76. package/components/TTextarea/type.uts +106 -0
  77. package/components/TToast/type.uts +14 -0
  78. package/components/Tabs/README.md +297 -0
  79. package/components/Tabs/index.uvue +383 -0
  80. package/components/Tabs/type.uts +10 -0
  81. package/components/Tags/README.md +297 -0
  82. package/components/Tags/index.uvue +383 -0
  83. package/components/Tags/type.uts +10 -0
  84. package/components/VbenFrom/index.uvue +392 -0
  85. package/composables/useModal.uts +294 -0
  86. package/composables/useTheme.uts +235 -0
  87. package/composables/useToast.uts +322 -0
  88. package/index.js +62 -0
  89. package/package.json +48 -0
  90. package/style/colors/index.scss +157 -0
  91. package/style/index.scss +399 -0
  92. package/types/index.uts +52 -0
  93. package/uni.scss +79 -0
  94. package/utils/color.uts +92 -0
  95. package/utils/common.uts +245 -0
  96. package/utils/dom.uts +275 -0
  97. package/utils/index.uts +10 -0
  98. package/utils/validator.uts +155 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * TBadge 徽标组件属性类型定义
3
+ */
4
+ export type TBadgeProps = {
5
+ /**
6
+ * 显示的数值
7
+ */
8
+ value?: number | string
9
+
10
+ /**
11
+ * 最大值,超过最大值显示 max+
12
+ * @default 99
13
+ */
14
+ max?: number
15
+
16
+ /**
17
+ * 是否显示小圆点
18
+ * @default false
19
+ */
20
+ isDot?: boolean
21
+
22
+ /**
23
+ * 是否隐藏徽标
24
+ * @default false
25
+ */
26
+ hidden?: boolean
27
+
28
+ /**
29
+ * 徽标类型
30
+ * @default "danger"
31
+ */
32
+ type?: 'primary' | 'success' | 'warning' | 'danger' | 'info'
33
+
34
+ /**
35
+ * 自定义背景色
36
+ */
37
+ bgColor?: string
38
+
39
+ /**
40
+ * 自定义文字颜色
41
+ */
42
+ color?: string
43
+
44
+ /**
45
+ * 偏移量 [x, y]
46
+ */
47
+ offset?: [number, number]
48
+ }
@@ -0,0 +1,111 @@
1
+ # TButton 按钮组件
2
+
3
+ 按钮组件,支持多种类型、尺寸、形状和状态。
4
+
5
+ ## 基础用法
6
+
7
+ ```vue
8
+ <template>
9
+ <TButton text="默认按钮" />
10
+ <TButton type="primary" text="主要按钮" />
11
+ <TButton type="success" text="成功按钮" />
12
+ <TButton type="warning" text="警告按钮" />
13
+ <TButton type="danger" text="危险按钮" />
14
+ <TButton type="info" text="信息按钮" />
15
+ </template>
16
+ ```
17
+
18
+ ## 朴素按钮
19
+
20
+ ```vue
21
+ <template>
22
+ <TButton plain text="朴素按钮" />
23
+ <TButton type="primary" plain text="主要按钮" />
24
+ <TButton type="success" plain text="成功按钮" />
25
+ </template>
26
+ ```
27
+
28
+ ## 按钮尺寸
29
+
30
+ ```vue
31
+ <template>
32
+ <TButton size="large" text="大型按钮" />
33
+ <TButton size="medium" text="中等按钮" />
34
+ <TButton size="small" text="小型按钮" />
35
+ <TButton size="mini" text="迷你按钮" />
36
+ </template>
37
+ ```
38
+
39
+ ## 按钮形状
40
+
41
+ ```vue
42
+ <template>
43
+ <TButton shape="square" text="方形按钮" />
44
+ <TButton shape="round" text="圆角按钮" />
45
+ <TButton shape="circle" icon="+" />
46
+ </template>
47
+ ```
48
+
49
+ ## 禁用状态
50
+
51
+ ```vue
52
+ <template>
53
+ <TButton disabled text="禁用按钮" />
54
+ <TButton type="primary" disabled text="禁用按钮" />
55
+ </template>
56
+ ```
57
+
58
+ ## 加载状态
59
+
60
+ ```vue
61
+ <template>
62
+ <TButton loading text="加载中" />
63
+ <TButton type="primary" loading text="加载中" />
64
+ </template>
65
+ ```
66
+
67
+ ## 块级按钮
68
+
69
+ ```vue
70
+ <template>
71
+ <TButton block text="块级按钮" />
72
+ <TButton type="primary" block text="块级按钮" />
73
+ </template>
74
+ ```
75
+
76
+ ## 带图标按钮
77
+
78
+ ```vue
79
+ <template>
80
+ <TButton icon="🔍" text="搜索" />
81
+ <TButton type="primary" icon="✓" text="确认" />
82
+ </template>
83
+ ```
84
+
85
+ ## Props
86
+
87
+ | 参数 | 说明 | 类型 | 可选值 | 默认值 |
88
+ |------|------|------|--------|--------|
89
+ | type | 按钮类型 | string | primary / success / warning / danger / info / default | default |
90
+ | size | 按钮尺寸 | string | large / medium / small / mini | medium |
91
+ | shape | 按钮形状 | string | square / round / circle | square |
92
+ | plain | 是否为朴素按钮 | boolean | - | false |
93
+ | disabled | 是否禁用 | boolean | - | false |
94
+ | loading | 是否加载中 | boolean | - | false |
95
+ | block | 是否为块级按钮 | boolean | - | false |
96
+ | text | 按钮文本 | string | - | - |
97
+ | icon | 图标 | string | - | - |
98
+ | customClass | 自定义类名 | string | - | - |
99
+ | customStyle | 自定义样式 | string | - | - |
100
+
101
+ ## Events
102
+
103
+ | 事件名 | 说明 | 回调参数 |
104
+ |--------|------|----------|
105
+ | click | 点击按钮时触发 | - |
106
+
107
+ ## Slots
108
+
109
+ | 名称 | 说明 |
110
+ |------|------|
111
+ | default | 按钮内容 |
@@ -0,0 +1,380 @@
1
+ <script setup lang="uts" >
2
+ import { computed } from 'vue'
3
+ import type { ButtonType, ButtonSize, ButtonShape } from './type.uts'
4
+
5
+ /**
6
+ * TButton 按钮组件
7
+ * @description 支持多种类型、尺寸、形状的按钮组件
8
+ */
9
+
10
+ // Props 定义
11
+ interface Props {
12
+ type?: ButtonType
13
+ size?: ButtonSize
14
+ shape?: ButtonShape
15
+ plain?: boolean
16
+ disabled?: boolean
17
+ loading?: boolean
18
+ block?: boolean
19
+ text?: string
20
+ icon?: string
21
+ customClass?: string
22
+ customStyle?: string
23
+ }
24
+
25
+ const props = withDefaults(defineProps<Props>(), {
26
+ type: 'default',
27
+ size: 'medium',
28
+ shape: 'square',
29
+ plain: false,
30
+ disabled: false,
31
+ loading: false,
32
+ block: false,
33
+ text: '',
34
+ icon: '',
35
+ customClass: '',
36
+ customStyle: ''
37
+ })
38
+
39
+ // Emits 定义
40
+ const emit = defineEmits<{
41
+ click: []
42
+ }>()
43
+
44
+ /**
45
+ * 计算按钮类名
46
+ */
47
+ const buttonClasses = computed((): string => {
48
+ const classes: string[] = []
49
+
50
+ // 类型样式
51
+ classes.push(`t-button--${props.type}`)
52
+
53
+ // 尺寸样式
54
+ classes.push(`t-button--${props.size}`)
55
+
56
+ // 形状样式
57
+ classes.push(`t-button--${props.shape}`)
58
+
59
+ // 朴素按钮
60
+ if (props.plain) {
61
+ classes.push('t-button--plain')
62
+ }
63
+
64
+ // 禁用状态
65
+ if (props.disabled) {
66
+ classes.push('t-button--disabled')
67
+ }
68
+
69
+ // 加载状态
70
+ if (props.loading) {
71
+ classes.push('t-button--loading')
72
+ }
73
+
74
+ // 块级按钮
75
+ if (props.block) {
76
+ classes.push('t-button--block')
77
+ }
78
+
79
+ // 自定义类名
80
+ if (props.customClass) {
81
+ classes.push(props.customClass)
82
+ }
83
+
84
+ return classes.join(' ')
85
+ })
86
+
87
+ /**
88
+ * 计算按钮样式
89
+ */
90
+ const buttonStyles = computed((): string => {
91
+ return props.customStyle
92
+ })
93
+
94
+ /**
95
+ * 计算 hover 类名
96
+ */
97
+ const hoverClass = computed((): string => {
98
+ if (props.disabled || props.loading) {
99
+ return 'none'
100
+ }
101
+ return 't-button--hover'
102
+ })
103
+
104
+ /**
105
+ * 处理点击事件
106
+ */
107
+ const handleClick = () => {
108
+ if (props.disabled || props.loading) {
109
+ return
110
+ }
111
+ emit('click')
112
+ }
113
+ </script>
114
+
115
+ <template>
116
+ <button
117
+ class="t-button"
118
+ :class="buttonClasses"
119
+ :style="buttonStyles"
120
+ :disabled="disabled || loading"
121
+ :hover-class="hoverClass"
122
+ @click="handleClick"
123
+ >
124
+ <!-- 加载图标 -->
125
+ <view v-if="loading" class="t-button__loading">
126
+ <text class="t-button__loading-icon">⟳</text>
127
+ </view>
128
+
129
+ <!-- 自定义图标 -->
130
+ <view v-else-if="icon" class="t-button__icon">
131
+ <text class="t-button__icon-text">{{ icon }}</text>
132
+ </view>
133
+
134
+ <!-- 按钮文本 -->
135
+ <view v-if="text || $slots.default" class="t-button__text">
136
+ <slot>{{ text }}</slot>
137
+ </view>
138
+ </button>
139
+ </template>
140
+
141
+
142
+ <style lang="scss" scoped>
143
+ // 覆盖 uni-button 原生组件的默认样式
144
+ // 使用 uni-button.t-button 确保覆盖原生样式
145
+ uni-button.t-button {
146
+ position: relative;
147
+ display: inline-flex;
148
+ align-items: center;
149
+ justify-content: center;
150
+ box-sizing: border-box;
151
+ padding: 0 16px;
152
+ font-size: 14px;
153
+ line-height: 1.5;
154
+ text-align: center;
155
+ border: 1px solid transparent;
156
+ border-radius: 4px;
157
+ transition: all 0.3s;
158
+ cursor: pointer;
159
+ user-select: none;
160
+ // 重置 uni-button 的默认样式
161
+ flex-shrink: 0;
162
+ flex-grow: 0;
163
+ flex-basis: auto;
164
+ min-height: 0;
165
+ min-width: 0;
166
+ background-image: none;
167
+ outline: none;
168
+ -webkit-appearance: none;
169
+ appearance: none;
170
+
171
+ &__loading {
172
+ display: flex;
173
+ align-items: center;
174
+ margin-right: 4px;
175
+ }
176
+
177
+ &__loading-icon {
178
+ display: inline-block;
179
+ animation: rotate 1s linear infinite;
180
+ font-size: 14px;
181
+ }
182
+
183
+ &__icon {
184
+ display: flex;
185
+ align-items: center;
186
+ margin-right: 4px;
187
+ }
188
+
189
+ &__icon-text {
190
+ font-size: 16px;
191
+ }
192
+
193
+ &__text {
194
+ display: flex;
195
+ align-items: center;
196
+ }
197
+
198
+ // 尺寸样式
199
+ &--large {
200
+ height: 44px;
201
+ padding: 0 20px;
202
+ font-size: 16px;
203
+ }
204
+
205
+ &--medium {
206
+ height: 36px;
207
+ padding: 0 16px;
208
+ font-size: 14px;
209
+ }
210
+
211
+ &--small {
212
+ height: 28px;
213
+ padding: 0 12px;
214
+ font-size: 12px;
215
+ }
216
+
217
+ &--mini {
218
+ height: 24px;
219
+ padding: 0 8px;
220
+ font-size: 12px;
221
+ }
222
+
223
+ // 形状样式
224
+ &--square {
225
+ border-radius: 4px;
226
+ }
227
+
228
+ &--round {
229
+ border-radius: 999px;
230
+ }
231
+
232
+ &--circle {
233
+ border-radius: 50%;
234
+ padding: 0;
235
+ width: 36px;
236
+
237
+ &.t-button--large {
238
+ width: 44px;
239
+ }
240
+
241
+ &.t-button--small {
242
+ width: 28px;
243
+ }
244
+
245
+ &.t-button--mini {
246
+ width: 24px;
247
+ }
248
+ }
249
+
250
+ // 类型样式 - 默认
251
+ &--default {
252
+ background-color: #ffffff;
253
+ border-color: #dcdfe6;
254
+ color: #606266;
255
+
256
+ &.t-button--hover {
257
+ background-color: #f5f7fa;
258
+ border-color: #c6e2ff;
259
+ color: #409eff;
260
+ }
261
+
262
+ &.t-button--plain {
263
+ background-color: #ffffff;
264
+ border-color: #dcdfe6;
265
+ color: #606266;
266
+ }
267
+ }
268
+
269
+ // 类型样式 - 主要
270
+ &--primary {
271
+ background-color: #409eff;
272
+ border-color: #409eff;
273
+ color: #ffffff;
274
+
275
+ &.t-button--hover {
276
+ background-color: #66b1ff;
277
+ border-color: #66b1ff;
278
+ }
279
+
280
+ &.t-button--plain {
281
+ background-color: #ecf5ff;
282
+ border-color: #b3d8ff;
283
+ color: #409eff;
284
+ }
285
+ }
286
+
287
+ // 类型样式 - 成功
288
+ &--success {
289
+ background-color: #67c23a;
290
+ border-color: #67c23a;
291
+ color: #ffffff;
292
+
293
+ &.t-button--hover {
294
+ background-color: #85ce61;
295
+ border-color: #85ce61;
296
+ }
297
+
298
+ &.t-button--plain {
299
+ background-color: #f0f9ff;
300
+ border-color: #c2e7b0;
301
+ color: #67c23a;
302
+ }
303
+ }
304
+
305
+ // 类型样式 - 警告
306
+ &--warning {
307
+ background-color: #e6a23c;
308
+ border-color: #e6a23c;
309
+ color: #ffffff;
310
+
311
+ &.t-button--hover {
312
+ background-color: #ebb563;
313
+ border-color: #ebb563;
314
+ }
315
+
316
+ &.t-button--plain {
317
+ background-color: #fdf6ec;
318
+ border-color: #f5dab1;
319
+ color: #e6a23c;
320
+ }
321
+ }
322
+
323
+ // 类型样式 - 危险
324
+ &--danger {
325
+ background-color: #f56c6c;
326
+ border-color: #f56c6c;
327
+ color: #ffffff;
328
+
329
+ &.t-button--hover {
330
+ background-color: #f78989;
331
+ border-color: #f78989;
332
+ }
333
+
334
+ &.t-button--plain {
335
+ background-color: #fef0f0;
336
+ border-color: #fbc4c4;
337
+ color: #f56c6c;
338
+ }
339
+ }
340
+
341
+ // 类型样式 - 信息
342
+ &--info {
343
+ background-color: #909399;
344
+ border-color: #909399;
345
+ color: #ffffff;
346
+
347
+ &.t-button--hover {
348
+ background-color: #a6a9ad;
349
+ border-color: #a6a9ad;
350
+ }
351
+
352
+ &.t-button--plain {
353
+ background-color: #f4f4f5;
354
+ border-color: #d3d4d6;
355
+ color: #909399;
356
+ }
357
+ }
358
+
359
+ // 禁用状态
360
+ &--disabled {
361
+ opacity: 0.6;
362
+ cursor: not-allowed;
363
+ }
364
+
365
+ // 块级按钮
366
+ &--block {
367
+ display: flex;
368
+ width: 100%;
369
+ }
370
+ }
371
+
372
+ @keyframes rotate {
373
+ from {
374
+ transform: rotate(0deg);
375
+ }
376
+ to {
377
+ transform: rotate(360deg);
378
+ }
379
+ }
380
+ </style>
@@ -0,0 +1,95 @@
1
+ /**
2
+ * TButton 组件类型定义
3
+ */
4
+
5
+ /**
6
+ * 按钮类型
7
+ */
8
+ export type ButtonType = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default'
9
+
10
+ /**
11
+ * 按钮尺寸
12
+ */
13
+ export type ButtonSize = 'large' | 'medium' | 'small' | 'mini'
14
+
15
+ /**
16
+ * 按钮形状
17
+ */
18
+ export type ButtonShape = 'square' | 'round' | 'circle'
19
+
20
+ /**
21
+ * 按钮 Props 接口
22
+ */
23
+ export interface TButtonProps {
24
+ /**
25
+ * 按钮类型
26
+ * @default 'default'
27
+ */
28
+ type?: ButtonType
29
+
30
+ /**
31
+ * 按钮尺寸
32
+ * @default 'medium'
33
+ */
34
+ size?: ButtonSize
35
+
36
+ /**
37
+ * 按钮形状
38
+ * @default 'square'
39
+ */
40
+ shape?: ButtonShape
41
+
42
+ /**
43
+ * 是否为朴素按钮
44
+ * @default false
45
+ */
46
+ plain?: boolean
47
+
48
+ /**
49
+ * 是否为禁用状态
50
+ * @default false
51
+ */
52
+ disabled?: boolean
53
+
54
+ /**
55
+ * 是否为加载状态
56
+ * @default false
57
+ */
58
+ loading?: boolean
59
+
60
+ /**
61
+ * 是否为块级按钮
62
+ * @default false
63
+ */
64
+ block?: boolean
65
+
66
+ /**
67
+ * 按钮文本
68
+ */
69
+ text?: string
70
+
71
+ /**
72
+ * 图标名称
73
+ */
74
+ icon?: string
75
+
76
+ /**
77
+ * 自定义类名
78
+ */
79
+ customClass?: string
80
+
81
+ /**
82
+ * 自定义样式
83
+ */
84
+ customStyle?: string
85
+ }
86
+
87
+ /**
88
+ * 按钮事件接口
89
+ */
90
+ export interface TButtonEmits {
91
+ /**
92
+ * 点击事件
93
+ */
94
+ click: () => void
95
+ }