vue-clean-tabs 1.0.0 → 1.1.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.
- package/README.md +104 -129
- package/dist/index.esm.js +85 -80
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +67 -67
- package/src/components/ConfigurableSimpleTabs.vue +85 -37
- package/src/index.ts +19 -18
- package/src/types.ts +181 -180
package/src/types.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
// 标签项接口
|
|
4
4
|
export interface TabItem {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
disabled?: boolean; // 是否禁用
|
|
8
|
+
route?: string; // 可选路由地址
|
|
9
|
+
icon?: string; // 可选图标
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
// 尺寸类型
|
|
@@ -17,234 +17,235 @@ export type IndicatorStyle = 'line' | 'dot' | 'pill' | 'underline';
|
|
|
17
17
|
|
|
18
18
|
// 主题配置接口
|
|
19
19
|
export interface SimpleTabsTheme {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
// 激活状态文字颜色
|
|
21
|
+
activeTextColor: string;
|
|
22
|
+
// 非激活状态文字颜色
|
|
23
|
+
inactiveTextColor: string;
|
|
24
|
+
// 悬浮状态文字颜色
|
|
25
|
+
hoverTextColor: string;
|
|
26
|
+
// 背景色
|
|
27
|
+
backgroundColor: string;
|
|
28
|
+
// 激活指示器颜色
|
|
29
|
+
indicatorColor: string;
|
|
30
|
+
// 字体系列
|
|
31
|
+
fontFamily: string;
|
|
32
|
+
// 边框颜色(如果需要)
|
|
33
|
+
borderColor?: string;
|
|
34
|
+
// 阴影(如果需要)
|
|
35
|
+
boxShadow?: string;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// 样式配置接口
|
|
39
39
|
export interface StyleConfig {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
// 内边距
|
|
41
|
+
padding: string;
|
|
42
|
+
// 字体大小
|
|
43
|
+
fontSize: string;
|
|
44
|
+
// 字体粗细
|
|
45
|
+
fontWeight: string;
|
|
46
|
+
// 指示器高度
|
|
47
|
+
indicatorHeight: string;
|
|
48
|
+
// 指示器样式
|
|
49
|
+
indicatorStyle: IndicatorStyle;
|
|
50
|
+
// 圆角大小
|
|
51
|
+
borderRadius?: string;
|
|
52
|
+
// 标签间距
|
|
53
|
+
gap?: string;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// 动画配置接口
|
|
57
57
|
export interface AnimationConfig {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
// 过渡时长
|
|
59
|
+
transitionDuration: string;
|
|
60
|
+
// 缓动函数
|
|
61
|
+
easing: string;
|
|
62
|
+
// 是否启用动画
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
// 指示器动画时长
|
|
65
|
+
indicatorTransition?: string;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// 响应式配置接口
|
|
69
69
|
export interface ResponsiveConfig {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
// 移动端断点
|
|
71
|
+
mobileBreakpoint: number;
|
|
72
|
+
// 移动端样式
|
|
73
|
+
mobileStyle?: Partial<StyleConfig>;
|
|
74
|
+
// 是否启用响应式
|
|
75
|
+
enabled: boolean;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// 主组件Props接口
|
|
79
79
|
export interface SimpleTabsProps {
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
80
|
+
// 标签页数据
|
|
81
|
+
tabs: TabItem[];
|
|
82
|
+
|
|
83
|
+
// 默认激活的标签ID
|
|
84
|
+
defaultActive?: string;
|
|
85
|
+
|
|
86
|
+
// 尺寸
|
|
87
|
+
size?: TabSize;
|
|
88
|
+
|
|
89
|
+
// 主题配置
|
|
90
|
+
theme?: Partial<SimpleTabsTheme>;
|
|
91
|
+
|
|
92
|
+
// 样式配置
|
|
93
|
+
style?: Partial<StyleConfig>;
|
|
94
|
+
|
|
95
|
+
// 动画配置
|
|
96
|
+
animation?: Partial<AnimationConfig>;
|
|
97
|
+
|
|
98
|
+
// 响应式配置
|
|
99
|
+
responsive?: Partial<ResponsiveConfig>;
|
|
100
|
+
|
|
101
|
+
// 自定义类名
|
|
102
|
+
className?: string;
|
|
103
|
+
|
|
104
|
+
// 自定义内联样式
|
|
105
|
+
customStyle?: Record<string, any>;
|
|
106
|
+
|
|
107
|
+
// 是否显示为块级元素
|
|
108
|
+
block?: boolean;
|
|
109
|
+
|
|
110
|
+
// 居中对齐
|
|
111
|
+
centered?: boolean;
|
|
112
|
+
|
|
113
|
+
// 是否可滚动(当标签过多时)
|
|
114
|
+
scrollable?: boolean;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// 事件接口
|
|
118
118
|
export interface SimpleTabsEvents {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
'tab-change': [tabId: string, tab: TabItem];
|
|
120
|
+
'tab-click': [tabId: string, tab: TabItem, event: Event];
|
|
121
|
+
'tab-hover': [tabId: string, tab: TabItem];
|
|
122
|
+
'tab-leave': [tabId: string, tab: TabItem];
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// 默认主题
|
|
126
126
|
export const defaultTheme: SimpleTabsTheme = {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
activeTextColor: 'rgb(20, 23, 26)',
|
|
128
|
+
inactiveTextColor: 'rgb(76, 82, 89)',
|
|
129
|
+
hoverTextColor: 'rgb(55, 65, 81)',
|
|
130
|
+
backgroundColor: '#ffffff',
|
|
131
|
+
indicatorColor: 'rgb(20, 23, 26)',
|
|
132
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Display", "Inter", sans-serif',
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
// 尺寸配置
|
|
136
136
|
export const sizeConfigs: Record<TabSize, StyleConfig> = {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
137
|
+
small: {
|
|
138
|
+
padding: '8px 10px',
|
|
139
|
+
fontSize: '14px',
|
|
140
|
+
fontWeight: '500',
|
|
141
|
+
indicatorHeight: '2px',
|
|
142
|
+
indicatorStyle: 'line',
|
|
143
|
+
gap: '16px',
|
|
144
|
+
},
|
|
145
|
+
medium: {
|
|
146
|
+
padding: '14px 12px',
|
|
147
|
+
fontSize: '16px',
|
|
148
|
+
fontWeight: '600',
|
|
149
|
+
indicatorHeight: '2px',
|
|
150
|
+
indicatorStyle: 'line',
|
|
151
|
+
gap: '20px',
|
|
152
|
+
},
|
|
153
|
+
large: {
|
|
154
|
+
padding: '16px 16px',
|
|
155
|
+
fontSize: '18px',
|
|
156
|
+
fontWeight: '700',
|
|
157
|
+
indicatorHeight: '3px',
|
|
158
|
+
indicatorStyle: 'line',
|
|
159
|
+
gap: '24px',
|
|
160
|
+
},
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
// 默认动画配置
|
|
164
164
|
export const defaultAnimation: AnimationConfig = {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
transitionDuration: '0.2s',
|
|
166
|
+
easing: 'ease',
|
|
167
|
+
enabled: true,
|
|
168
|
+
indicatorTransition: '0.3s ease',
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
// 默认响应式配置
|
|
172
172
|
export const defaultResponsive: ResponsiveConfig = {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
mobileBreakpoint: 768,
|
|
174
|
+
enabled: true,
|
|
175
|
+
mobileStyle: {
|
|
176
|
+
padding: '14px 0',
|
|
177
|
+
gap: '16px',
|
|
178
|
+
},
|
|
179
179
|
};
|
|
180
180
|
|
|
181
181
|
// 指示器样式映射
|
|
182
182
|
export const indicatorStyles: Record<IndicatorStyle, (color: string, height: string) => Record<string, string>> = {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
183
|
+
line: (color: string, height: string) => ({
|
|
184
|
+
position: 'absolute',
|
|
185
|
+
bottom: '0',
|
|
186
|
+
left: '12px',
|
|
187
|
+
right: '12px',
|
|
188
|
+
height,
|
|
189
|
+
backgroundColor: color,
|
|
190
|
+
borderRadius: '0',
|
|
191
|
+
}),
|
|
192
|
+
|
|
193
|
+
underline: (color: string, height: string) => ({
|
|
194
|
+
position: 'absolute',
|
|
195
|
+
bottom: '0',
|
|
196
|
+
left: '0',
|
|
197
|
+
right: '0',
|
|
198
|
+
height,
|
|
199
|
+
backgroundColor: color,
|
|
200
|
+
borderRadius: '0',
|
|
201
|
+
}),
|
|
202
|
+
|
|
203
|
+
dot: (color: string, height: string) => ({
|
|
204
|
+
position: 'absolute',
|
|
205
|
+
bottom: '4px',
|
|
206
|
+
left: '50%',
|
|
207
|
+
transform: 'translateX(-50%)',
|
|
208
|
+
width: height,
|
|
209
|
+
height,
|
|
210
|
+
backgroundColor: color,
|
|
211
|
+
borderRadius: '50%',
|
|
212
|
+
}),
|
|
213
|
+
|
|
214
|
+
pill: (color: string, height: string) => ({
|
|
215
|
+
position: 'absolute',
|
|
216
|
+
bottom: '4px',
|
|
217
|
+
left: '8px',
|
|
218
|
+
right: '8px',
|
|
219
|
+
height,
|
|
220
|
+
backgroundColor: color,
|
|
221
|
+
borderRadius: height,
|
|
222
|
+
}),
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
// 工具函数:获取指示器样式
|
|
226
226
|
export const getIndicatorStyle = (
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
style: IndicatorStyle,
|
|
228
|
+
color: string,
|
|
229
|
+
height: string
|
|
230
230
|
): Record<string, string> => {
|
|
231
|
-
|
|
231
|
+
return indicatorStyles[style](color, height);
|
|
232
232
|
};
|
|
233
233
|
|
|
234
234
|
// 工具函数:合并配置
|
|
235
235
|
export const mergeConfig = <T extends Record<string, any>>(
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
defaultConfig: T,
|
|
237
|
+
userConfig?: Partial<T>
|
|
238
238
|
): T => {
|
|
239
|
-
|
|
239
|
+
return { ...defaultConfig, ...userConfig };
|
|
240
240
|
};
|
|
241
241
|
|
|
242
242
|
// 工具函数:获取响应式样式
|
|
243
243
|
export const getResponsiveStyle = (
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
isMobile: boolean,
|
|
245
|
+
baseStyle: StyleConfig,
|
|
246
|
+
mobileStyle?: Partial<StyleConfig>
|
|
247
247
|
): StyleConfig => {
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
if (!isMobile || !mobileStyle) return baseStyle;
|
|
249
|
+
return { ...baseStyle, ...mobileStyle };
|
|
250
250
|
};
|
|
251
|
+
|