@aura-react-comp/ui 0.0.0-stage → 0.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/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 +163 -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 +107 -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 +175 -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 +247 -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 +258 -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 +118 -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 +182 -0
- package/esm/pagination/index.less +230 -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 +155 -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 +104 -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 +471 -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 +179 -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 +160 -0
- package/esm/tabs/index.d.ts +45 -0
- package/esm/tabs/index.js +170 -0
- package/esm/tabs/index.less +228 -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 +226 -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 +107 -0
- package/esm/upload/index.d.ts +68 -0
- package/esm/upload/index.js +447 -0
- package/esm/upload/index.less +376 -0
- package/esm/upload/request.d.ts +26 -0
- package/esm/upload/request.js +38 -0
- package/package.json +56 -3
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/* ===== Aura Design Tokens — Light Theme (Default) ===== */
|
|
2
|
+
:root {
|
|
3
|
+
/* Primary — Violet */
|
|
4
|
+
--aura-primary-50: #faf5ff;
|
|
5
|
+
--aura-primary-100: #f3e8ff;
|
|
6
|
+
--aura-primary-200: #e9d5ff;
|
|
7
|
+
--aura-primary-300: #d8b4fe;
|
|
8
|
+
--aura-primary-400: #c084fc;
|
|
9
|
+
--aura-primary-500: #a855f7;
|
|
10
|
+
--aura-primary-600: #9333ea;
|
|
11
|
+
--aura-primary-700: #7c3aed;
|
|
12
|
+
--aura-primary-800: #6d28d9;
|
|
13
|
+
--aura-primary-900: #5b21b6;
|
|
14
|
+
--aura-primary-950: #3b0764;
|
|
15
|
+
|
|
16
|
+
/* Gray */
|
|
17
|
+
--aura-gray-50: #f9fafb;
|
|
18
|
+
--aura-gray-100: #f3f4f6;
|
|
19
|
+
--aura-gray-200: #e5e7eb;
|
|
20
|
+
--aura-gray-300: #d1d5db;
|
|
21
|
+
--aura-gray-400: #9ca3af;
|
|
22
|
+
--aura-gray-500: #6b7280;
|
|
23
|
+
--aura-gray-600: #4b5563;
|
|
24
|
+
--aura-gray-700: #374151;
|
|
25
|
+
--aura-gray-800: #1f2937;
|
|
26
|
+
--aura-gray-900: #111827;
|
|
27
|
+
--aura-gray-950: #030712;
|
|
28
|
+
|
|
29
|
+
/* Semantic Colors */
|
|
30
|
+
--aura-success: #10b981;
|
|
31
|
+
--aura-success-light: #d1fae5;
|
|
32
|
+
--aura-warning: #f59e0b;
|
|
33
|
+
--aura-warning-light: #fef3c7;
|
|
34
|
+
--aura-error: #ef4444;
|
|
35
|
+
--aura-error-light: #fee2e2;
|
|
36
|
+
--aura-info: #3b82f6;
|
|
37
|
+
--aura-info-light: #dbeafe;
|
|
38
|
+
|
|
39
|
+
/* Background */
|
|
40
|
+
--aura-bg: #ffffff;
|
|
41
|
+
--aura-bg-secondary: #f9fafb;
|
|
42
|
+
--aura-bg-tertiary: #f3f4f6;
|
|
43
|
+
|
|
44
|
+
/* Text */
|
|
45
|
+
--aura-text: #111827;
|
|
46
|
+
--aura-text-secondary: #6b7280;
|
|
47
|
+
--aura-text-tertiary: #9ca3af;
|
|
48
|
+
--aura-text-inverse: #ffffff;
|
|
49
|
+
|
|
50
|
+
/* Border */
|
|
51
|
+
--aura-border: #e5e7eb;
|
|
52
|
+
--aura-border-hover: #d1d5db;
|
|
53
|
+
|
|
54
|
+
/* Selection — 拖拽选区遮罩底色
|
|
55
|
+
* 主色带透明度的派生色收在令牌层,而非在组件样式中用 color-mix 临时派生:
|
|
56
|
+
* rgba 全浏览器可用,且换主题只需改这一处。 */
|
|
57
|
+
--aura-selection-bg: rgba(124, 58, 237, 0.22);
|
|
58
|
+
|
|
59
|
+
/* Spacing */
|
|
60
|
+
--aura-spacing-1: 4px;
|
|
61
|
+
--aura-spacing-2: 8px;
|
|
62
|
+
--aura-spacing-3: 12px;
|
|
63
|
+
--aura-spacing-4: 16px;
|
|
64
|
+
--aura-spacing-5: 20px;
|
|
65
|
+
--aura-spacing-6: 24px;
|
|
66
|
+
--aura-spacing-7: 28px;
|
|
67
|
+
--aura-spacing-8: 32px;
|
|
68
|
+
--aura-spacing-9: 36px;
|
|
69
|
+
--aura-spacing-10: 40px;
|
|
70
|
+
--aura-spacing-11: 44px;
|
|
71
|
+
--aura-spacing-12: 48px;
|
|
72
|
+
|
|
73
|
+
/* Border Radius */
|
|
74
|
+
--aura-radius-sm: 6px;
|
|
75
|
+
--aura-radius-md: 10px;
|
|
76
|
+
--aura-radius-lg: 14px;
|
|
77
|
+
--aura-radius-xl: 20px;
|
|
78
|
+
--aura-radius-full: 9999px;
|
|
79
|
+
|
|
80
|
+
/* Shadows */
|
|
81
|
+
--aura-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
82
|
+
--aura-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
|
|
83
|
+
--aura-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
|
84
|
+
--aura-shadow-glow: 0 0 20px rgba(124, 58, 237, 0.3);
|
|
85
|
+
|
|
86
|
+
/* Font Size */
|
|
87
|
+
--aura-font-size-xs: 12px;
|
|
88
|
+
--aura-font-size-sm: 13px;
|
|
89
|
+
--aura-font-size-md: 14px;
|
|
90
|
+
--aura-font-size-lg: 16px;
|
|
91
|
+
--aura-font-size-xl: 18px;
|
|
92
|
+
--aura-font-size-2xl: 20px;
|
|
93
|
+
--aura-font-size-3xl: 24px;
|
|
94
|
+
|
|
95
|
+
/* Duration */
|
|
96
|
+
--aura-duration-fast: 150ms;
|
|
97
|
+
--aura-duration-normal: 200ms;
|
|
98
|
+
--aura-duration-slow: 300ms;
|
|
99
|
+
--aura-easing: cubic-bezier(0.4, 0, 0.2, 1);
|
|
100
|
+
|
|
101
|
+
/* ===== AI 组件(@aura-react-comp/x) ===== */
|
|
102
|
+
--aura-x-bubble-ai-bg: rgba(255, 255, 255, 0.72);
|
|
103
|
+
--aura-x-bubble-user-bg: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
|
|
104
|
+
--aura-x-bubble-user-text: #ffffff;
|
|
105
|
+
--aura-x-bubble-border: rgba(124, 58, 237, 0.22);
|
|
106
|
+
--aura-x-code-bg: #f6f8fa;
|
|
107
|
+
--aura-x-stage-bg: #fafafa;
|
|
108
|
+
--aura-x-accent: #7c3aed;
|
|
109
|
+
--aura-x-accent-soft: rgba(124, 58, 237, 0.08);
|
|
110
|
+
--aura-x-accent-gradient: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
|
|
111
|
+
--aura-x-glass-blur: saturate(180%) blur(14px);
|
|
112
|
+
--aura-x-glow: 0 0 0 1px rgba(124, 58, 237, 0.16), 0 12px 32px -8px rgba(124, 58, 237, 0.28);
|
|
113
|
+
--aura-x-focus-ring: 0 0 0 3px rgba(124, 58, 237, 0.16);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* ===== Dark Theme ===== */
|
|
117
|
+
[data-theme="dark"] {
|
|
118
|
+
--aura-primary-50: #3b0764;
|
|
119
|
+
--aura-primary-100: #4c1d95;
|
|
120
|
+
--aura-primary-200: #5b21b6;
|
|
121
|
+
--aura-primary-300: #6d28d9;
|
|
122
|
+
--aura-primary-400: #7c3aed;
|
|
123
|
+
--aura-primary-500: #8b5cf6;
|
|
124
|
+
--aura-primary-600: #a78bfa;
|
|
125
|
+
--aura-primary-700: #c4b5fd;
|
|
126
|
+
--aura-primary-800: #ddd6fe;
|
|
127
|
+
--aura-primary-900: #ede9fe;
|
|
128
|
+
--aura-primary-950: #faf5ff;
|
|
129
|
+
|
|
130
|
+
--aura-gray-50: #030712;
|
|
131
|
+
--aura-gray-100: #111827;
|
|
132
|
+
--aura-gray-200: #1f2937;
|
|
133
|
+
--aura-gray-300: #374151;
|
|
134
|
+
--aura-gray-400: #4b5563;
|
|
135
|
+
--aura-gray-500: #6b7280;
|
|
136
|
+
--aura-gray-600: #9ca3af;
|
|
137
|
+
--aura-gray-700: #d1d5db;
|
|
138
|
+
--aura-gray-800: #e5e7eb;
|
|
139
|
+
--aura-gray-900: #f3f4f6;
|
|
140
|
+
--aura-gray-950: #f9fafb;
|
|
141
|
+
|
|
142
|
+
--aura-success: #34d399;
|
|
143
|
+
--aura-success-light: rgba(16, 185, 129, 0.15);
|
|
144
|
+
--aura-warning: #fbbf24;
|
|
145
|
+
--aura-warning-light: rgba(245, 158, 11, 0.15);
|
|
146
|
+
--aura-error: #f87171;
|
|
147
|
+
--aura-error-light: rgba(239, 68, 68, 0.15);
|
|
148
|
+
--aura-info: #60a5fa;
|
|
149
|
+
--aura-info-light: rgba(59, 130, 246, 0.15);
|
|
150
|
+
|
|
151
|
+
--aura-bg: #0f0c29;
|
|
152
|
+
--aura-bg-secondary: #1a1a3e;
|
|
153
|
+
--aura-bg-tertiary: #252550;
|
|
154
|
+
|
|
155
|
+
--aura-text: #f3f4f6;
|
|
156
|
+
--aura-text-secondary: #9ca3af;
|
|
157
|
+
--aura-text-tertiary: #6b7280;
|
|
158
|
+
--aura-text-inverse: #111827;
|
|
159
|
+
|
|
160
|
+
--aura-border: rgba(139, 92, 246, 0.2);
|
|
161
|
+
--aura-border-hover: rgba(139, 92, 246, 0.4);
|
|
162
|
+
|
|
163
|
+
--aura-selection-bg: rgba(196, 181, 253, 0.22);
|
|
164
|
+
|
|
165
|
+
--aura-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
|
|
166
|
+
--aura-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
|
|
167
|
+
--aura-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
|
|
168
|
+
--aura-shadow-glow: 0 0 20px rgba(124, 58, 237, 0.4);
|
|
169
|
+
|
|
170
|
+
/* ===== AI 组件(@aura-react-comp/x) ===== */
|
|
171
|
+
--aura-x-bubble-ai-bg: rgba(26, 26, 62, 0.55);
|
|
172
|
+
--aura-x-bubble-user-bg: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
|
|
173
|
+
--aura-x-bubble-user-text: #f3f4f6;
|
|
174
|
+
--aura-x-bubble-border: rgba(139, 92, 246, 0.35);
|
|
175
|
+
--aura-x-code-bg: rgba(3, 7, 18, 0.6);
|
|
176
|
+
--aura-x-stage-bg: #0f0c29;
|
|
177
|
+
--aura-x-accent: #a78bfa;
|
|
178
|
+
--aura-x-accent-soft: rgba(167, 139, 250, 0.12);
|
|
179
|
+
--aura-x-accent-gradient: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
|
|
180
|
+
--aura-x-glass-blur: saturate(180%) blur(16px);
|
|
181
|
+
--aura-x-glow: 0 0 0 1px rgba(139, 92, 246, 0.35), 0 12px 32px -8px rgba(139, 92, 246, 0.4);
|
|
182
|
+
--aura-x-focus-ring: 0 0 0 3px rgba(139, 92, 246, 0.28);
|
|
183
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTheme } from './ThemeProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTheme } from "./ThemeProvider";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TooltipProps {
|
|
3
|
+
/** 提示内容 */
|
|
4
|
+
content: React.ReactNode;
|
|
5
|
+
/** 弹出方位
|
|
6
|
+
* @default 'top'
|
|
7
|
+
*/
|
|
8
|
+
placement?: 'top' | 'bottom' | 'left' | 'right' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
9
|
+
/** 触发方式
|
|
10
|
+
* @default 'hover'
|
|
11
|
+
*/
|
|
12
|
+
trigger?: 'hover' | 'click' | 'focus';
|
|
13
|
+
/** 显示延迟(毫秒);`mouseEnterDelay` 的简写形式
|
|
14
|
+
* @default 0
|
|
15
|
+
*/
|
|
16
|
+
delay?: number;
|
|
17
|
+
/** 鼠标移入后延迟显示(毫秒)
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
mouseEnterDelay?: number;
|
|
21
|
+
/** 鼠标移出后延迟隐藏(毫秒)
|
|
22
|
+
* @default 0
|
|
23
|
+
*/
|
|
24
|
+
mouseLeaveDelay?: number;
|
|
25
|
+
/** 受控显示状态;传入后组件显隐完全由该值驱动 */
|
|
26
|
+
open?: boolean;
|
|
27
|
+
/** 显示状态变化回调(受控 / 非受控均会触发) */
|
|
28
|
+
onOpenChange?: (open: boolean) => void;
|
|
29
|
+
/** 是否禁用 */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/** 自定义类名 */
|
|
32
|
+
className?: string;
|
|
33
|
+
/** 自定义样式 */
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
/** 目标元素(仅接受单个 ReactElement) */
|
|
36
|
+
children: React.ReactElement;
|
|
37
|
+
}
|
|
38
|
+
export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React, { forwardRef, useState, useCallback, useRef, useEffect } from 'react';
|
|
2
|
+
import { classNames, prefixCls } from '@aura-react-comp/shared';
|
|
3
|
+
import "./index.less";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
/** 退场动画时长(与 index.less 的过渡时间保持一致) */
|
|
7
|
+
const LEAVE_DURATION = 200;
|
|
8
|
+
export const Tooltip = /*#__PURE__*/forwardRef(({
|
|
9
|
+
content,
|
|
10
|
+
placement = 'top',
|
|
11
|
+
trigger = 'hover',
|
|
12
|
+
delay = 0,
|
|
13
|
+
mouseEnterDelay,
|
|
14
|
+
mouseLeaveDelay = 0,
|
|
15
|
+
open: controlledOpen,
|
|
16
|
+
onOpenChange,
|
|
17
|
+
disabled = false,
|
|
18
|
+
className,
|
|
19
|
+
style,
|
|
20
|
+
children
|
|
21
|
+
}, ref) => {
|
|
22
|
+
const isControlled = controlledOpen !== undefined;
|
|
23
|
+
const enterDelay = mouseEnterDelay ?? delay;
|
|
24
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
25
|
+
// mounted:DOM 是否挂载(含退场动画期);animating:是否处于显示动画态
|
|
26
|
+
const [mounted, setMounted] = useState(false);
|
|
27
|
+
const [animating, setAnimating] = useState(false);
|
|
28
|
+
const enterTimerRef = useRef(null);
|
|
29
|
+
const leaveTimerRef = useRef(null);
|
|
30
|
+
const unmountTimerRef = useRef(null);
|
|
31
|
+
const clearTimers = useCallback(() => {
|
|
32
|
+
if (enterTimerRef.current) clearTimeout(enterTimerRef.current);
|
|
33
|
+
if (leaveTimerRef.current) clearTimeout(leaveTimerRef.current);
|
|
34
|
+
enterTimerRef.current = null;
|
|
35
|
+
leaveTimerRef.current = null;
|
|
36
|
+
}, []);
|
|
37
|
+
const currentOpen = isControlled ? controlledOpen : internalOpen;
|
|
38
|
+
|
|
39
|
+
// 受控模式:跟随 open prop 驱动动画与挂载
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!isControlled) return;
|
|
42
|
+
if (controlledOpen) {
|
|
43
|
+
setMounted(true);
|
|
44
|
+
setAnimating(true);
|
|
45
|
+
} else {
|
|
46
|
+
setAnimating(false);
|
|
47
|
+
const timer = setTimeout(() => setMounted(false), LEAVE_DURATION);
|
|
48
|
+
return () => clearTimeout(timer);
|
|
49
|
+
}
|
|
50
|
+
}, [isControlled, controlledOpen]);
|
|
51
|
+
|
|
52
|
+
// 显示(enterDelay 为 0 时同步执行,与既有行为一致)
|
|
53
|
+
const show = useCallback(() => {
|
|
54
|
+
if (disabled) return;
|
|
55
|
+
clearTimers();
|
|
56
|
+
const triggerShow = () => {
|
|
57
|
+
if (!isControlled) {
|
|
58
|
+
setMounted(true);
|
|
59
|
+
setAnimating(true);
|
|
60
|
+
setInternalOpen(true);
|
|
61
|
+
}
|
|
62
|
+
onOpenChange?.(true);
|
|
63
|
+
};
|
|
64
|
+
if (enterDelay > 0) {
|
|
65
|
+
enterTimerRef.current = setTimeout(triggerShow, enterDelay);
|
|
66
|
+
} else {
|
|
67
|
+
triggerShow();
|
|
68
|
+
}
|
|
69
|
+
}, [disabled, clearTimers, isControlled, onOpenChange, enterDelay]);
|
|
70
|
+
|
|
71
|
+
// 隐藏(退场动画结束后卸载 DOM;leaveDelay 为 0 时同步执行)
|
|
72
|
+
const hide = useCallback(() => {
|
|
73
|
+
if (disabled) return;
|
|
74
|
+
clearTimers();
|
|
75
|
+
const triggerHide = () => {
|
|
76
|
+
onOpenChange?.(false);
|
|
77
|
+
if (isControlled) return;
|
|
78
|
+
setAnimating(false);
|
|
79
|
+
setInternalOpen(false);
|
|
80
|
+
unmountTimerRef.current = setTimeout(() => setMounted(false), LEAVE_DURATION);
|
|
81
|
+
};
|
|
82
|
+
if (mouseLeaveDelay > 0) {
|
|
83
|
+
leaveTimerRef.current = setTimeout(triggerHide, mouseLeaveDelay);
|
|
84
|
+
} else {
|
|
85
|
+
triggerHide();
|
|
86
|
+
}
|
|
87
|
+
}, [disabled, clearTimers, isControlled, onOpenChange, mouseLeaveDelay]);
|
|
88
|
+
|
|
89
|
+
// 切换(click 触发)
|
|
90
|
+
const toggle = useCallback(() => {
|
|
91
|
+
if (disabled) return;
|
|
92
|
+
if (currentOpen) {
|
|
93
|
+
hide();
|
|
94
|
+
} else {
|
|
95
|
+
show();
|
|
96
|
+
}
|
|
97
|
+
}, [disabled, currentOpen, show, hide]);
|
|
98
|
+
|
|
99
|
+
// 组件卸载时清理定时器
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
return () => clearTimers();
|
|
102
|
+
}, [clearTimers]);
|
|
103
|
+
|
|
104
|
+
// 构建子元素的 props
|
|
105
|
+
const childProps = {};
|
|
106
|
+
const childOwnProps = children.props;
|
|
107
|
+
if (trigger === 'hover') {
|
|
108
|
+
childProps.onMouseEnter = e => {
|
|
109
|
+
show();
|
|
110
|
+
childOwnProps.onMouseEnter?.(e);
|
|
111
|
+
};
|
|
112
|
+
childProps.onMouseLeave = e => {
|
|
113
|
+
hide();
|
|
114
|
+
childOwnProps.onMouseLeave?.(e);
|
|
115
|
+
};
|
|
116
|
+
} else if (trigger === 'click') {
|
|
117
|
+
childProps.onClick = e => {
|
|
118
|
+
toggle();
|
|
119
|
+
childOwnProps.onClick?.(e);
|
|
120
|
+
};
|
|
121
|
+
} else if (trigger === 'focus') {
|
|
122
|
+
childProps.onFocus = e => {
|
|
123
|
+
show();
|
|
124
|
+
childOwnProps.onFocus?.(e);
|
|
125
|
+
};
|
|
126
|
+
childProps.onBlur = e => {
|
|
127
|
+
hide();
|
|
128
|
+
childOwnProps.onBlur?.(e);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const wrapperCls = classNames(prefixCls('tooltip-wrapper'), className);
|
|
132
|
+
const tooltipCls = classNames(prefixCls('tooltip'), prefixCls(`tooltip-${placement}`), animating && prefixCls('tooltip-visible'));
|
|
133
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
134
|
+
ref: ref,
|
|
135
|
+
className: wrapperCls,
|
|
136
|
+
style: style,
|
|
137
|
+
children: [/*#__PURE__*/React.cloneElement(children, childProps), mounted && content && /*#__PURE__*/_jsxs("div", {
|
|
138
|
+
className: tooltipCls,
|
|
139
|
+
role: "tooltip",
|
|
140
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
141
|
+
className: prefixCls('tooltip-content'),
|
|
142
|
+
children: content
|
|
143
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
144
|
+
className: prefixCls('tooltip-arrow')
|
|
145
|
+
})]
|
|
146
|
+
})]
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
Tooltip.displayName = 'Tooltip';
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/* ===== Tooltip 组件样式 ===== */
|
|
2
|
+
|
|
3
|
+
.aura-tooltip-wrapper {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.aura-tooltip {
|
|
9
|
+
position: absolute;
|
|
10
|
+
z-index: 1070;
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
opacity: 0;
|
|
13
|
+
width: max-content;
|
|
14
|
+
transform: scale(0.9);
|
|
15
|
+
transition:
|
|
16
|
+
opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
|
|
17
|
+
transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
18
|
+
|
|
19
|
+
// ===== 出现状态 =====
|
|
20
|
+
&&-visible {
|
|
21
|
+
opacity: 1;
|
|
22
|
+
transform: scale(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ===== 方位定位 =====
|
|
26
|
+
&&-top {
|
|
27
|
+
bottom: calc(100% + 8px);
|
|
28
|
+
left: 50%;
|
|
29
|
+
transform-origin: center bottom;
|
|
30
|
+
transform: translateX(-50%) scale(0.9);
|
|
31
|
+
|
|
32
|
+
&.aura-tooltip-visible {
|
|
33
|
+
transform: translateX(-50%) scale(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&&-bottom {
|
|
38
|
+
top: calc(100% + 8px);
|
|
39
|
+
left: 50%;
|
|
40
|
+
transform-origin: center top;
|
|
41
|
+
transform: translateX(-50%) scale(0.9);
|
|
42
|
+
|
|
43
|
+
&.aura-tooltip-visible {
|
|
44
|
+
transform: translateX(-50%) scale(1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&&-left {
|
|
49
|
+
right: calc(100% + 8px);
|
|
50
|
+
top: 50%;
|
|
51
|
+
transform-origin: right center;
|
|
52
|
+
transform: translateY(-50%) scale(0.9);
|
|
53
|
+
|
|
54
|
+
&.aura-tooltip-visible {
|
|
55
|
+
transform: translateY(-50%) scale(1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&&-right {
|
|
60
|
+
left: calc(100% + 8px);
|
|
61
|
+
top: 50%;
|
|
62
|
+
transform-origin: left center;
|
|
63
|
+
transform: translateY(-50%) scale(0.9);
|
|
64
|
+
|
|
65
|
+
&.aura-tooltip-visible {
|
|
66
|
+
transform: translateY(-50%) scale(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&&-topLeft {
|
|
71
|
+
bottom: calc(100% + 8px);
|
|
72
|
+
left: 0;
|
|
73
|
+
transform-origin: left bottom;
|
|
74
|
+
transform: scale(0.9);
|
|
75
|
+
|
|
76
|
+
&.aura-tooltip-visible {
|
|
77
|
+
transform: scale(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&&-topRight {
|
|
82
|
+
bottom: calc(100% + 8px);
|
|
83
|
+
right: 0;
|
|
84
|
+
transform-origin: right bottom;
|
|
85
|
+
transform: scale(0.9);
|
|
86
|
+
|
|
87
|
+
&.aura-tooltip-visible {
|
|
88
|
+
transform: scale(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&&-bottomLeft {
|
|
93
|
+
top: calc(100% + 8px);
|
|
94
|
+
left: 0;
|
|
95
|
+
transform-origin: left top;
|
|
96
|
+
transform: scale(0.9);
|
|
97
|
+
|
|
98
|
+
&.aura-tooltip-visible {
|
|
99
|
+
transform: scale(1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&&-bottomRight {
|
|
104
|
+
top: calc(100% + 8px);
|
|
105
|
+
right: 0;
|
|
106
|
+
transform-origin: right top;
|
|
107
|
+
transform: scale(0.9);
|
|
108
|
+
|
|
109
|
+
&.aura-tooltip-visible {
|
|
110
|
+
transform: scale(1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&&-leftTop {
|
|
115
|
+
right: calc(100% + 8px);
|
|
116
|
+
top: 0;
|
|
117
|
+
transform-origin: right top;
|
|
118
|
+
transform: scale(0.9);
|
|
119
|
+
|
|
120
|
+
&.aura-tooltip-visible {
|
|
121
|
+
transform: scale(1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&&-leftBottom {
|
|
126
|
+
right: calc(100% + 8px);
|
|
127
|
+
bottom: 0;
|
|
128
|
+
transform-origin: right bottom;
|
|
129
|
+
transform: scale(0.9);
|
|
130
|
+
|
|
131
|
+
&.aura-tooltip-visible {
|
|
132
|
+
transform: scale(1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&&-rightTop {
|
|
137
|
+
left: calc(100% + 8px);
|
|
138
|
+
top: 0;
|
|
139
|
+
transform-origin: left top;
|
|
140
|
+
transform: scale(0.9);
|
|
141
|
+
|
|
142
|
+
&.aura-tooltip-visible {
|
|
143
|
+
transform: scale(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&&-rightBottom {
|
|
148
|
+
left: calc(100% + 8px);
|
|
149
|
+
bottom: 0;
|
|
150
|
+
transform-origin: left bottom;
|
|
151
|
+
transform: scale(0.9);
|
|
152
|
+
|
|
153
|
+
&.aura-tooltip-visible {
|
|
154
|
+
transform: scale(1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ===== 提示内容 =====
|
|
160
|
+
.aura-tooltip-content {
|
|
161
|
+
padding: 6px 12px;
|
|
162
|
+
border-radius: var(--aura-radius-sm);
|
|
163
|
+
background: var(--aura-gray-800);
|
|
164
|
+
color: var(--aura-text-inverse);
|
|
165
|
+
font-size: var(--aura-font-size-sm);
|
|
166
|
+
line-height: 1.5;
|
|
167
|
+
white-space: nowrap;
|
|
168
|
+
box-shadow: var(--aura-shadow-md);
|
|
169
|
+
max-width: 300px;
|
|
170
|
+
word-wrap: break-word;
|
|
171
|
+
white-space: normal;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ===== 箭头 =====
|
|
175
|
+
.aura-tooltip-arrow {
|
|
176
|
+
position: absolute;
|
|
177
|
+
width: 8px;
|
|
178
|
+
height: 8px;
|
|
179
|
+
background: var(--aura-gray-800);
|
|
180
|
+
transform: rotate(45deg);
|
|
181
|
+
|
|
182
|
+
// 箭头根据方位定位
|
|
183
|
+
.aura-tooltip-top &,
|
|
184
|
+
.aura-tooltip-topLeft &,
|
|
185
|
+
.aura-tooltip-topRight & {
|
|
186
|
+
bottom: -4px;
|
|
187
|
+
left: 50%;
|
|
188
|
+
margin-left: -4px;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.aura-tooltip-topLeft & {
|
|
192
|
+
left: 16px;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.aura-tooltip-topRight & {
|
|
196
|
+
left: auto;
|
|
197
|
+
right: 16px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.aura-tooltip-bottom &,
|
|
201
|
+
.aura-tooltip-bottomLeft &,
|
|
202
|
+
.aura-tooltip-bottomRight & {
|
|
203
|
+
top: -4px;
|
|
204
|
+
left: 50%;
|
|
205
|
+
margin-left: -4px;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.aura-tooltip-bottomLeft & {
|
|
209
|
+
left: 16px;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.aura-tooltip-bottomRight & {
|
|
213
|
+
left: auto;
|
|
214
|
+
right: 16px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.aura-tooltip-left &,
|
|
218
|
+
.aura-tooltip-leftTop &,
|
|
219
|
+
.aura-tooltip-leftBottom & {
|
|
220
|
+
right: -4px;
|
|
221
|
+
top: 50%;
|
|
222
|
+
margin-top: -4px;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.aura-tooltip-right &,
|
|
226
|
+
.aura-tooltip-rightTop &,
|
|
227
|
+
.aura-tooltip-rightBottom & {
|
|
228
|
+
left: -4px;
|
|
229
|
+
top: 50%;
|
|
230
|
+
margin-top: -4px;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ===== 暗色模式 =====
|
|
235
|
+
[data-theme='dark'] {
|
|
236
|
+
.aura-tooltip-content {
|
|
237
|
+
background: var(--aura-gray-200);
|
|
238
|
+
color: var(--aura-gray-900);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.aura-tooltip-arrow {
|
|
242
|
+
background: var(--aura-gray-200);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
export interface TitleProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
3
|
+
level?: 1 | 2 | 3 | 4 | 5;
|
|
4
|
+
}
|
|
5
|
+
export declare const Title: React.ForwardRefExoticComponent<TitleProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
6
|
+
export interface TextProps extends HTMLAttributes<HTMLSpanElement> {
|
|
7
|
+
variant?: 'default' | 'secondary' | 'success' | 'warning' | 'danger';
|
|
8
|
+
strong?: boolean;
|
|
9
|
+
underline?: boolean;
|
|
10
|
+
delete?: boolean;
|
|
11
|
+
code?: boolean;
|
|
12
|
+
mark?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const Text: React.ForwardRefExoticComponent<TextProps & React.RefAttributes<HTMLSpanElement>>;
|
|
15
|
+
export interface ParagraphProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
16
|
+
ellipsis?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const Paragraph: React.ForwardRefExoticComponent<ParagraphProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
19
|
+
export type TypographyProps = HTMLAttributes<HTMLSpanElement>;
|
|
20
|
+
interface TypographyComponent extends React.ForwardRefExoticComponent<TypographyProps & React.RefAttributes<HTMLSpanElement>> {
|
|
21
|
+
Title: typeof Title;
|
|
22
|
+
Text: typeof Text;
|
|
23
|
+
Paragraph: typeof Paragraph;
|
|
24
|
+
}
|
|
25
|
+
export declare const Typography: TypographyComponent;
|
|
26
|
+
export {};
|