@aura-react-comp/ui 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +67 -2
- package/esm/alert/index.d.ts +28 -0
- package/esm/alert/index.js +76 -0
- package/esm/alert/index.less +172 -0
- package/esm/avatar/index.d.ts +41 -0
- package/esm/avatar/index.js +117 -0
- package/esm/avatar/index.less +162 -0
- package/esm/badge/index.d.ts +29 -0
- package/esm/badge/index.js +84 -0
- package/esm/badge/index.less +215 -0
- package/esm/breadcrumb/index.d.ts +31 -0
- package/esm/breadcrumb/index.js +91 -0
- package/esm/breadcrumb/index.less +108 -0
- package/esm/button/index.d.ts +28 -0
- package/esm/button/index.js +59 -0
- package/esm/button/index.less +191 -0
- package/esm/card/index.d.ts +67 -0
- package/esm/card/index.js +156 -0
- package/esm/card/index.less +231 -0
- package/esm/checkbox/index.d.ts +35 -0
- package/esm/checkbox/index.js +118 -0
- package/esm/checkbox/index.less +141 -0
- package/esm/collapse/index.d.ts +45 -0
- package/esm/collapse/index.js +157 -0
- package/esm/collapse/index.less +144 -0
- package/esm/divider/index.d.ts +16 -0
- package/esm/divider/index.js +37 -0
- package/esm/divider/index.less +115 -0
- package/esm/dropdown/index.d.ts +38 -0
- package/esm/dropdown/index.js +108 -0
- package/esm/dropdown/index.less +245 -0
- package/esm/empty/index.d.ts +35 -0
- package/esm/empty/index.js +87 -0
- package/esm/empty/index.less +67 -0
- package/esm/flex/index.d.ts +24 -0
- package/esm/flex/index.js +64 -0
- package/esm/flex/index.less +9 -0
- package/esm/form/index.d.ts +121 -0
- package/esm/form/index.js +443 -0
- package/esm/form/index.less +257 -0
- package/esm/global.d.ts +6 -0
- package/esm/index.d.ts +78 -0
- package/esm/index.js +41 -0
- package/esm/input/index.d.ts +51 -0
- package/esm/input/index.js +217 -0
- package/esm/input/index.less +369 -0
- package/esm/layout/index.d.ts +46 -0
- package/esm/layout/index.js +135 -0
- package/esm/layout/index.less +132 -0
- package/esm/menu/index.d.ts +91 -0
- package/esm/menu/index.js +294 -0
- package/esm/menu/index.less +340 -0
- package/esm/message/index.d.ts +33 -0
- package/esm/message/index.js +199 -0
- package/esm/message/index.less +113 -0
- package/esm/notification/index.d.ts +33 -0
- package/esm/notification/index.js +229 -0
- package/esm/notification/index.less +175 -0
- package/esm/pagination/index.d.ts +38 -0
- package/esm/pagination/index.js +180 -0
- package/esm/pagination/index.less +238 -0
- package/esm/popconfirm/index.d.ts +37 -0
- package/esm/popconfirm/index.js +115 -0
- package/esm/popconfirm/index.less +229 -0
- package/esm/radio/index.d.ts +33 -0
- package/esm/radio/index.js +122 -0
- package/esm/radio/index.less +119 -0
- package/esm/rate/index.d.ts +30 -0
- package/esm/rate/index.js +143 -0
- package/esm/rate/index.less +87 -0
- package/esm/result/index.d.ts +19 -0
- package/esm/result/index.js +69 -0
- package/esm/result/index.less +103 -0
- package/esm/scrollbar/index.d.ts +18 -0
- package/esm/scrollbar/index.js +35 -0
- package/esm/scrollbar/index.less +67 -0
- package/esm/select/index.d.ts +63 -0
- package/esm/select/index.js +358 -0
- package/esm/select/index.less +427 -0
- package/esm/slider/index.d.ts +36 -0
- package/esm/slider/index.js +255 -0
- package/esm/slider/index.less +154 -0
- package/esm/space/index.d.ts +16 -0
- package/esm/space/index.js +34 -0
- package/esm/space/index.less +34 -0
- package/esm/spin/index.d.ts +44 -0
- package/esm/spin/index.js +152 -0
- package/esm/spin/index.less +170 -0
- package/esm/steps/index.d.ts +55 -0
- package/esm/steps/index.js +165 -0
- package/esm/steps/index.less +394 -0
- package/esm/switch/index.d.ts +30 -0
- package/esm/switch/index.js +56 -0
- package/esm/switch/index.less +135 -0
- package/esm/tabs/index.d.ts +45 -0
- package/esm/tabs/index.js +170 -0
- package/esm/tabs/index.less +226 -0
- package/esm/tag/index.d.ts +52 -0
- package/esm/tag/index.js +120 -0
- package/esm/tag/index.less +227 -0
- package/esm/textarea/index.d.ts +27 -0
- package/esm/textarea/index.js +84 -0
- package/esm/textarea/index.less +224 -0
- package/esm/theme/ThemeProvider.d.ts +15 -0
- package/esm/theme/ThemeProvider.js +32 -0
- package/esm/theme/index.d.ts +2 -0
- package/esm/theme/index.js +1 -0
- package/esm/theme/tokens.css +183 -0
- package/esm/theme/useTheme.d.ts +1 -0
- package/esm/theme/useTheme.js +1 -0
- package/esm/tooltip/index.d.ts +38 -0
- package/esm/tooltip/index.js +149 -0
- package/esm/tooltip/index.less +244 -0
- package/esm/typography/index.d.ts +26 -0
- package/esm/typography/index.js +92 -0
- package/esm/typography/index.less +106 -0
- package/esm/upload/index.d.ts +68 -0
- package/esm/upload/index.js +447 -0
- package/esm/upload/index.less +371 -0
- package/esm/upload/request.d.ts +26 -0
- package/esm/upload/request.js +38 -0
- package/package.json +56 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
.aura-switch {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
border: none;
|
|
6
|
+
background: var(--aura-gray-300);
|
|
7
|
+
border-radius: var(--aura-radius-full);
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
transition: background 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
padding: 0;
|
|
12
|
+
vertical-align: middle;
|
|
13
|
+
user-select: none;
|
|
14
|
+
|
|
15
|
+
&:hover:not(.aura-switch-disabled):not(.aura-switch-loading) {
|
|
16
|
+
box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 内部文字区域
|
|
20
|
+
&-inner {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
color: var(--aura-text-inverse);
|
|
25
|
+
font-size: var(--aura-font-size-xs);
|
|
26
|
+
line-height: 1;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
transition: opacity var(--aura-duration-normal) var(--aura-easing);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 圆点手柄
|
|
32
|
+
&-handle {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 2px;
|
|
35
|
+
left: 2px;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
background: var(--aura-text-inverse);
|
|
41
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
|
|
42
|
+
transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 选中状态
|
|
46
|
+
&&-checked {
|
|
47
|
+
background: var(--aura-primary-700);
|
|
48
|
+
|
|
49
|
+
.aura-switch-handle {
|
|
50
|
+
transform: translateX(calc(100% + 2px));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:hover:not(.aura-switch-disabled):not(.aura-switch-loading) {
|
|
54
|
+
box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 禁用状态
|
|
59
|
+
&&-disabled {
|
|
60
|
+
opacity: 0.4;
|
|
61
|
+
cursor: not-allowed;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 加载状态
|
|
65
|
+
&&-loading {
|
|
66
|
+
cursor: not-allowed;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 尺寸:sm 28×16px
|
|
70
|
+
&&-sm {
|
|
71
|
+
width: 28px;
|
|
72
|
+
height: 16px;
|
|
73
|
+
|
|
74
|
+
.aura-switch-inner { margin: 0 4px; font-size: 10px; }
|
|
75
|
+
.aura-switch-handle { width: 12px; height: 12px; }
|
|
76
|
+
|
|
77
|
+
&.aura-switch-checked {
|
|
78
|
+
.aura-switch-handle { transform: translateX(12px); }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 尺寸:md 40×22px
|
|
83
|
+
&&-md {
|
|
84
|
+
width: 40px;
|
|
85
|
+
height: 22px;
|
|
86
|
+
|
|
87
|
+
.aura-switch-inner { margin: 0 8px; }
|
|
88
|
+
.aura-switch-handle { width: 18px; height: 18px; }
|
|
89
|
+
|
|
90
|
+
&.aura-switch-checked {
|
|
91
|
+
.aura-switch-handle { transform: translateX(18px); }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 尺寸:lg 52×28px
|
|
96
|
+
&&-lg {
|
|
97
|
+
width: 52px;
|
|
98
|
+
height: 28px;
|
|
99
|
+
|
|
100
|
+
.aura-switch-inner { margin: 0 10px; font-size: var(--aura-font-size-sm); }
|
|
101
|
+
.aura-switch-handle { width: 24px; height: 24px; }
|
|
102
|
+
|
|
103
|
+
&.aura-switch-checked {
|
|
104
|
+
.aura-switch-handle { transform: translateX(24px); }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 加载旋转图标
|
|
109
|
+
&-loading-icon {
|
|
110
|
+
display: inline-block;
|
|
111
|
+
width: 10px;
|
|
112
|
+
height: 10px;
|
|
113
|
+
border: 2px solid var(--aura-primary-700);
|
|
114
|
+
border-right-color: transparent;
|
|
115
|
+
border-radius: 50%;
|
|
116
|
+
animation: aura-spin 0.6s linear infinite;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 暗色模式光晕效果
|
|
121
|
+
[data-theme="dark"] {
|
|
122
|
+
.aura-switch {
|
|
123
|
+
&:hover:not(.aura-switch-disabled):not(.aura-switch-loading) {
|
|
124
|
+
box-shadow: 0 0 8px rgba(124, 58, 237, 0.15);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&.aura-switch-checked {
|
|
128
|
+
box-shadow: 0 0 16px rgba(124, 58, 237, 0.35);
|
|
129
|
+
|
|
130
|
+
&:hover:not(.aura-switch-disabled):not(.aura-switch-loading) {
|
|
131
|
+
box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TabItemProps {
|
|
3
|
+
/** 唯一标识,用于匹配激活状态 */
|
|
4
|
+
tabKey: string;
|
|
5
|
+
/** 选项卡标题 */
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
/** 是否禁用 */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** 选项卡内容 */
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/** 内部组件:单个选项卡面板 */
|
|
13
|
+
declare const TabItem: React.FC<TabItemProps>;
|
|
14
|
+
export interface TabsProps {
|
|
15
|
+
/** 默认激活的 tabKey */
|
|
16
|
+
defaultActiveKey?: string;
|
|
17
|
+
/** 受控激活的 tabKey */
|
|
18
|
+
activeKey?: string;
|
|
19
|
+
/** 变体样式
|
|
20
|
+
* @default 'default'
|
|
21
|
+
*/
|
|
22
|
+
variant?: 'default' | 'card' | 'pill';
|
|
23
|
+
/** 尺寸
|
|
24
|
+
* @default 'md'
|
|
25
|
+
*/
|
|
26
|
+
size?: 'sm' | 'md' | 'lg';
|
|
27
|
+
/** 切换回调 */
|
|
28
|
+
onChange?: (key: string) => void;
|
|
29
|
+
/** 切换后是否销毁非激活面板;默认保留已访问面板的挂载状态(保留表单等内部状态) */
|
|
30
|
+
destroyInactiveTabPane?: boolean;
|
|
31
|
+
/** 自定义类名 */
|
|
32
|
+
className?: string;
|
|
33
|
+
/** 自定义样式 */
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
/** 子元素 */
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
export declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
export interface TabsComponent extends React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>> {
|
|
40
|
+
Tab: typeof TabItem;
|
|
41
|
+
}
|
|
42
|
+
export declare const TabsWithSub: TabsComponent;
|
|
43
|
+
export { TabItem };
|
|
44
|
+
declare const _default: TabsComponent;
|
|
45
|
+
export default _default;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import React, { forwardRef, createContext, useContext, useState, useCallback, useRef, useEffect, useLayoutEffect } from 'react';
|
|
2
|
+
import { classNames, prefixCls } from '@aura-react-comp/shared';
|
|
3
|
+
import "./index.less";
|
|
4
|
+
|
|
5
|
+
/* ===== Context ===== */
|
|
6
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const TabsContext = /*#__PURE__*/createContext(null);
|
|
10
|
+
function useTabsContext() {
|
|
11
|
+
const ctx = useContext(TabsContext);
|
|
12
|
+
if (!ctx) throw new Error('TabItem 必须在 Tabs 内部使用');
|
|
13
|
+
return ctx;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* ===== TabItem ===== */
|
|
17
|
+
|
|
18
|
+
/** 内部组件:单个选项卡面板 */
|
|
19
|
+
const TabItem = ({
|
|
20
|
+
children
|
|
21
|
+
}) => {
|
|
22
|
+
const {
|
|
23
|
+
activeKey
|
|
24
|
+
} = useTabsContext();
|
|
25
|
+
// 只渲染占位,不显示内容 —— Tabs 组件自己控制渲染
|
|
26
|
+
void activeKey;
|
|
27
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
28
|
+
children: children
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
TabItem.displayName = 'TabItem';
|
|
32
|
+
|
|
33
|
+
/* ===== Tabs ===== */
|
|
34
|
+
|
|
35
|
+
export const Tabs = /*#__PURE__*/forwardRef(({
|
|
36
|
+
defaultActiveKey,
|
|
37
|
+
activeKey: controlledActiveKey,
|
|
38
|
+
variant = 'default',
|
|
39
|
+
size = 'md',
|
|
40
|
+
onChange,
|
|
41
|
+
destroyInactiveTabPane = false,
|
|
42
|
+
className,
|
|
43
|
+
style,
|
|
44
|
+
children
|
|
45
|
+
}, ref) => {
|
|
46
|
+
/* --- 受控/非受控 --- */
|
|
47
|
+
const [internalKey, setInternalKey] = useState(defaultActiveKey);
|
|
48
|
+
const isControlled = controlledActiveKey !== undefined;
|
|
49
|
+
const activeKey = isControlled ? controlledActiveKey : internalKey;
|
|
50
|
+
|
|
51
|
+
/* --- 从 children 提取 tab 信息 --- */
|
|
52
|
+
const tabItems = [];
|
|
53
|
+
React.Children.forEach(children, child => {
|
|
54
|
+
if ( /*#__PURE__*/React.isValidElement(child) && child.type === TabItem) {
|
|
55
|
+
const {
|
|
56
|
+
tabKey,
|
|
57
|
+
title,
|
|
58
|
+
disabled,
|
|
59
|
+
children: content
|
|
60
|
+
} = child.props;
|
|
61
|
+
tabItems.push({
|
|
62
|
+
tabKey,
|
|
63
|
+
title,
|
|
64
|
+
disabled: !!disabled,
|
|
65
|
+
children: content
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// 如果没有 activeKey,取第一个
|
|
71
|
+
const resolvedActiveKey = activeKey ?? tabItems[0]?.tabKey ?? '';
|
|
72
|
+
|
|
73
|
+
// 已访问过的面板:非 destroy 模式下保持挂载(hidden 隐藏),保留内部状态
|
|
74
|
+
const [visitedKeys, setVisitedKeys] = useState(() => new Set(resolvedActiveKey ? [resolvedActiveKey] : []));
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
setVisitedKeys(prev => prev.has(resolvedActiveKey) ? prev : new Set(prev).add(resolvedActiveKey));
|
|
77
|
+
}, [resolvedActiveKey]);
|
|
78
|
+
const handleChange = useCallback(key => {
|
|
79
|
+
if (!isControlled) setInternalKey(key);
|
|
80
|
+
onChange?.(key);
|
|
81
|
+
}, [isControlled, onChange]);
|
|
82
|
+
|
|
83
|
+
/* --- 指示器定位(仅 default variant) --- */
|
|
84
|
+
const navRef = useRef(null);
|
|
85
|
+
const [indicatorStyle, setIndicatorStyle] = React.useState({});
|
|
86
|
+
const updateIndicator = useCallback(() => {
|
|
87
|
+
if (variant !== 'default' || !navRef.current) return;
|
|
88
|
+
const activeTab = navRef.current.querySelector(`[data-tab-key="${resolvedActiveKey}"]`);
|
|
89
|
+
if (activeTab) {
|
|
90
|
+
const navRect = navRef.current.getBoundingClientRect();
|
|
91
|
+
const tabRect = activeTab.getBoundingClientRect();
|
|
92
|
+
setIndicatorStyle({
|
|
93
|
+
width: tabRect.width,
|
|
94
|
+
transform: `translateX(${tabRect.left - navRect.left}px)`
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}, [variant, resolvedActiveKey]);
|
|
98
|
+
|
|
99
|
+
// 用 useLayoutEffect 保证指示器在渲染后同步更新,避免闪烁
|
|
100
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
101
|
+
useIsomorphicLayoutEffect(() => {
|
|
102
|
+
updateIndicator();
|
|
103
|
+
}, [updateIndicator]);
|
|
104
|
+
|
|
105
|
+
/* --- 查找当前激活的内容 --- */
|
|
106
|
+
const activeContent = tabItems.find(item => item.tabKey === resolvedActiveKey)?.children;
|
|
107
|
+
|
|
108
|
+
/* --- 需要渲染的面板 --- */
|
|
109
|
+
const panelsToRender = destroyInactiveTabPane ? tabItems.filter(item => item.tabKey === resolvedActiveKey) : tabItems.filter(item => visitedKeys.has(item.tabKey));
|
|
110
|
+
|
|
111
|
+
/* --- className --- */
|
|
112
|
+
const wrapperCls = classNames(prefixCls('tabs'), prefixCls(`tabs-${variant}`), prefixCls(`tabs-${size}`), className);
|
|
113
|
+
const ctxValue = {
|
|
114
|
+
activeKey: resolvedActiveKey,
|
|
115
|
+
onChange: handleChange,
|
|
116
|
+
variant,
|
|
117
|
+
size
|
|
118
|
+
};
|
|
119
|
+
return /*#__PURE__*/_jsx(TabsContext.Provider, {
|
|
120
|
+
value: ctxValue,
|
|
121
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
122
|
+
ref: ref,
|
|
123
|
+
className: wrapperCls,
|
|
124
|
+
style: style,
|
|
125
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
126
|
+
ref: navRef,
|
|
127
|
+
className: prefixCls('tabs-nav'),
|
|
128
|
+
role: "tablist",
|
|
129
|
+
children: [tabItems.map(item => {
|
|
130
|
+
const isActive = item.tabKey === resolvedActiveKey;
|
|
131
|
+
const tabCls = classNames(prefixCls('tabs-tab'), isActive && prefixCls('tabs-tab-active'), item.disabled && prefixCls('tabs-tab-disabled'));
|
|
132
|
+
return /*#__PURE__*/_jsx("button", {
|
|
133
|
+
type: "button",
|
|
134
|
+
role: "tab",
|
|
135
|
+
"data-tab-key": item.tabKey,
|
|
136
|
+
className: tabCls,
|
|
137
|
+
"aria-selected": isActive,
|
|
138
|
+
"aria-disabled": item.disabled,
|
|
139
|
+
onClick: () => {
|
|
140
|
+
if (!item.disabled) handleChange(item.tabKey);
|
|
141
|
+
},
|
|
142
|
+
children: item.title
|
|
143
|
+
}, item.tabKey);
|
|
144
|
+
}), variant === 'default' && /*#__PURE__*/_jsx("span", {
|
|
145
|
+
className: prefixCls('tabs-indicator'),
|
|
146
|
+
style: indicatorStyle
|
|
147
|
+
})]
|
|
148
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
149
|
+
className: classNames(prefixCls('tabs-content'), activeContent == null && prefixCls('tabs-content-empty')),
|
|
150
|
+
children: panelsToRender.map(item => /*#__PURE__*/_jsx("div", {
|
|
151
|
+
className: prefixCls('tabs-panel'),
|
|
152
|
+
role: "tabpanel",
|
|
153
|
+
hidden: item.tabKey !== resolvedActiveKey,
|
|
154
|
+
children: item.children
|
|
155
|
+
}, item.tabKey))
|
|
156
|
+
})]
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
Tabs.displayName = 'Tabs';
|
|
161
|
+
|
|
162
|
+
// 子组件挂载
|
|
163
|
+
const TabsCompound = Tabs;
|
|
164
|
+
TabsCompound.Tab = TabItem;
|
|
165
|
+
|
|
166
|
+
// 导出复合类型
|
|
167
|
+
|
|
168
|
+
export const TabsWithSub = Tabs;
|
|
169
|
+
export { TabItem };
|
|
170
|
+
export default Tabs;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
.aura-tabs {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
|
|
5
|
+
/* ===== Nav Bar ===== */
|
|
6
|
+
&-nav {
|
|
7
|
+
position: relative;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: 0;
|
|
11
|
+
border-bottom: 1px solid var(--aura-border);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* ===== Tab 按钮 ===== */
|
|
15
|
+
&-tab {
|
|
16
|
+
position: relative;
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
padding: 8px 16px;
|
|
21
|
+
font-size: var(--aura-font-size-md);
|
|
22
|
+
font-family: inherit;
|
|
23
|
+
line-height: 1.5;
|
|
24
|
+
color: var(--aura-text-secondary);
|
|
25
|
+
background: transparent;
|
|
26
|
+
border: none;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
transition: color var(--aura-duration-normal) var(--aura-easing),
|
|
29
|
+
background-color var(--aura-duration-normal) var(--aura-easing),
|
|
30
|
+
border-color var(--aura-duration-normal) var(--aura-easing),
|
|
31
|
+
transform var(--aura-duration-fast) var(--aura-easing);
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
user-select: none;
|
|
34
|
+
|
|
35
|
+
&:hover {
|
|
36
|
+
color: var(--aura-primary-700);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:active {
|
|
40
|
+
transform: scale(0.97);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&-active {
|
|
44
|
+
color: var(--aura-primary-700);
|
|
45
|
+
font-weight: 600;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&-disabled {
|
|
49
|
+
color: var(--aura-text-tertiary);
|
|
50
|
+
cursor: not-allowed;
|
|
51
|
+
|
|
52
|
+
&:hover {
|
|
53
|
+
color: var(--aura-text-tertiary);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:active {
|
|
57
|
+
transform: none;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* ===== 指示器(default variant) ===== */
|
|
63
|
+
&-indicator {
|
|
64
|
+
position: absolute;
|
|
65
|
+
bottom: -1px;
|
|
66
|
+
left: 0;
|
|
67
|
+
height: 2px;
|
|
68
|
+
background: var(--aura-primary-700);
|
|
69
|
+
border-radius: 2px 2px 0 0;
|
|
70
|
+
transition: transform var(--aura-duration-slow) var(--aura-easing),
|
|
71
|
+
width var(--aura-duration-slow) var(--aura-easing);
|
|
72
|
+
will-change: transform, width;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* ===== Content ===== */
|
|
76
|
+
&-content {
|
|
77
|
+
padding-top: var(--aura-spacing-4);
|
|
78
|
+
|
|
79
|
+
&-empty {
|
|
80
|
+
padding-top: 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* ===== Panel 切换动画 ===== */
|
|
85
|
+
&-panel {
|
|
86
|
+
animation: aura-tabs-fade-in var(--aura-duration-slow) var(--aura-easing);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* ===== Size 变体 ===== */
|
|
90
|
+
&-sm {
|
|
91
|
+
.aura-tabs-tab {
|
|
92
|
+
padding: 4px 12px;
|
|
93
|
+
font-size: var(--aura-font-size-sm);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&-lg {
|
|
98
|
+
.aura-tabs-tab {
|
|
99
|
+
padding: 12px 24px;
|
|
100
|
+
font-size: var(--aura-font-size-lg);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* ===== Variant: card ===== */
|
|
105
|
+
&&-card {
|
|
106
|
+
.aura-tabs-nav {
|
|
107
|
+
border-bottom: none;
|
|
108
|
+
gap: 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.aura-tabs-tab {
|
|
112
|
+
border: 1px solid transparent;
|
|
113
|
+
border-bottom: none;
|
|
114
|
+
border-radius: var(--aura-radius-md) var(--aura-radius-md) 0 0;
|
|
115
|
+
background: transparent;
|
|
116
|
+
transition: all var(--aura-duration-normal) var(--aura-easing);
|
|
117
|
+
|
|
118
|
+
&:hover {
|
|
119
|
+
background: var(--aura-bg-secondary);
|
|
120
|
+
border-color: var(--aura-border);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&-active {
|
|
124
|
+
background: var(--aura-bg);
|
|
125
|
+
border-color: var(--aura-border);
|
|
126
|
+
color: var(--aura-primary-700);
|
|
127
|
+
|
|
128
|
+
&:hover {
|
|
129
|
+
background: var(--aura-bg);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* ===== Variant: pill ===== */
|
|
136
|
+
&&-pill {
|
|
137
|
+
.aura-tabs-nav {
|
|
138
|
+
border-bottom: none;
|
|
139
|
+
gap: var(--aura-spacing-2);
|
|
140
|
+
background: var(--aura-bg-secondary);
|
|
141
|
+
padding: var(--aura-spacing-1);
|
|
142
|
+
border-radius: var(--aura-radius-full);
|
|
143
|
+
display: inline-flex;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.aura-tabs-tab {
|
|
147
|
+
border-radius: var(--aura-radius-full);
|
|
148
|
+
padding: 6px 16px;
|
|
149
|
+
transition: all var(--aura-duration-normal) var(--aura-easing);
|
|
150
|
+
|
|
151
|
+
&:hover {
|
|
152
|
+
background: var(--aura-bg-tertiary);
|
|
153
|
+
color: var(--aura-text);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&-active {
|
|
157
|
+
background: var(--aura-primary-700);
|
|
158
|
+
color: var(--aura-text-inverse);
|
|
159
|
+
box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
|
|
160
|
+
|
|
161
|
+
&:hover {
|
|
162
|
+
background: var(--aura-primary-600);
|
|
163
|
+
color: var(--aura-text-inverse);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// pill size sm
|
|
169
|
+
&.aura-tabs-sm {
|
|
170
|
+
.aura-tabs-tab {
|
|
171
|
+
padding: 3px 12px;
|
|
172
|
+
font-size: var(--aura-font-size-sm);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// pill size lg
|
|
177
|
+
&.aura-tabs-lg {
|
|
178
|
+
.aura-tabs-tab {
|
|
179
|
+
padding: 8px 24px;
|
|
180
|
+
font-size: var(--aura-font-size-lg);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* ===== 动画关键帧 ===== */
|
|
187
|
+
@keyframes aura-tabs-fade-in {
|
|
188
|
+
from {
|
|
189
|
+
opacity: 0;
|
|
190
|
+
transform: translateY(4px);
|
|
191
|
+
}
|
|
192
|
+
to {
|
|
193
|
+
opacity: 1;
|
|
194
|
+
transform: translateY(0);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* ===== 暗色模式 ===== */
|
|
199
|
+
[data-theme="dark"] {
|
|
200
|
+
.aura-tabs {
|
|
201
|
+
&-tab {
|
|
202
|
+
&:hover {
|
|
203
|
+
color: var(--aura-primary-400);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&-active {
|
|
207
|
+
color: var(--aura-primary-400);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
&-indicator {
|
|
212
|
+
background: var(--aura-primary-400);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
&&-pill {
|
|
216
|
+
.aura-tabs-tab-active {
|
|
217
|
+
background: var(--aura-primary-600);
|
|
218
|
+
box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
|
|
219
|
+
|
|
220
|
+
&:hover {
|
|
221
|
+
background: var(--aura-primary-500);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TagProps {
|
|
3
|
+
/** 标签变体样式
|
|
4
|
+
* @default 'default'
|
|
5
|
+
*/
|
|
6
|
+
variant?: 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info';
|
|
7
|
+
/** 标签尺寸
|
|
8
|
+
* @default 'md'
|
|
9
|
+
*/
|
|
10
|
+
size?: 'sm' | 'md' | 'lg';
|
|
11
|
+
/** 是否可关闭 */
|
|
12
|
+
closable?: boolean;
|
|
13
|
+
/** 关闭回调 */
|
|
14
|
+
onClose?: () => void;
|
|
15
|
+
/** 自定义类名 */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** 自定义样式 */
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
/** 标签内容 */
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export declare const Tag: React.ForwardRefExoticComponent<TagProps & React.RefAttributes<HTMLSpanElement>>;
|
|
23
|
+
export interface TagCheckableProps {
|
|
24
|
+
/** 是否选中
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
checked?: boolean;
|
|
28
|
+
/** 选中状态变化回调 */
|
|
29
|
+
onChange?: (checked: boolean) => void;
|
|
30
|
+
/** 标签值(在 Group 中使用) */
|
|
31
|
+
value?: string | number;
|
|
32
|
+
/** 自定义类名 */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** 自定义样式 */
|
|
35
|
+
style?: React.CSSProperties;
|
|
36
|
+
/** 标签内容 */
|
|
37
|
+
children?: React.ReactNode;
|
|
38
|
+
}
|
|
39
|
+
export declare const TagCheckable: React.ForwardRefExoticComponent<TagCheckableProps & React.RefAttributes<HTMLSpanElement>>;
|
|
40
|
+
export interface TagGroupProps {
|
|
41
|
+
/** 当前选中值(受控,配合 Tag.Checkable 使用) */
|
|
42
|
+
value?: (string | number)[];
|
|
43
|
+
/** 选中值变化回调 */
|
|
44
|
+
onChange?: (value: (string | number)[]) => void;
|
|
45
|
+
/** 自定义类名 */
|
|
46
|
+
className?: string;
|
|
47
|
+
/** 自定义样式 */
|
|
48
|
+
style?: React.CSSProperties;
|
|
49
|
+
/** 子元素 */
|
|
50
|
+
children?: React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
export declare const TagGroup: React.FC<TagGroupProps>;
|