@ant-design/agentic-ui 2.30.31 → 2.30.33
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/dist/AILabel/index.d.ts +2 -0
- package/dist/AILabel/index.js +4 -2
- package/dist/AgentRunBar/Robot.js +0 -1
- package/dist/AgentRunBar/index.js +1 -0
- package/dist/AgenticLayout/index.js +1 -0
- package/dist/AnswerAlert/index.js +1 -0
- package/dist/BackTo/ScrollVisibleButton.d.ts +2 -0
- package/dist/BackTo/ScrollVisibleButton.js +4 -2
- package/dist/Bubble/List/PureBubbleList.js +2 -0
- package/dist/Bubble/style.js +0 -1
- package/dist/ChatBootPage/ButtonTab.js +1 -0
- package/dist/ChatBootPage/ButtonTabGroup.js +1 -0
- package/dist/ChatBootPage/CaseReply.js +1 -0
- package/dist/ChatBootPage/Title.js +1 -0
- package/dist/ChatLayout/index.js +1 -0
- package/dist/Components/ActionItemBox/ActionItemBox.js +1 -0
- package/dist/Components/Button/IconButton/index.js +1 -0
- package/dist/Components/Button/SwitchButton/index.js +1 -0
- package/dist/Components/Button/ToggleButton/index.js +1 -0
- package/dist/Components/GradientText/index.js +1 -0
- package/dist/Components/LayoutHeader/index.js +2 -1
- package/dist/Components/Loading/Loading.js +2 -0
- package/dist/Components/Robot/index.js +1 -0
- package/dist/Components/SuggestionList/index.js +1 -0
- package/dist/Components/TextAnimate/index.js +1 -0
- package/dist/Components/TypingAnimation/index.js +2 -1
- package/dist/Components/VisualList/index.js +3 -0
- package/dist/Components/lotties/ThreeThinkingLottie/index.d.ts +68 -0
- package/dist/Components/lotties/ThreeThinkingLottie/index.js +151 -0
- package/dist/Components/lotties/ThreeThinkingLottie/three-thinking.json +130 -0
- package/dist/Components/lotties/index.d.ts +1 -0
- package/dist/Components/lotties/index.js +1 -0
- package/dist/History/index.js +1 -0
- package/dist/MarkdownEditor/BaseMarkdownEditor.js +2 -0
- package/dist/MarkdownRenderer/MarkdownRenderer.js +1 -0
- package/dist/Plugins/chart/components/ChartContainer/ChartContainer.d.ts +13 -3
- package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +19 -4
- package/dist/Plugins/chart/hooks/index.d.ts +2 -0
- package/dist/Plugins/chart/hooks/index.js +1 -0
- package/dist/Plugins/chart/hooks/useDetectTheme.d.ts +46 -0
- package/dist/Plugins/chart/hooks/useDetectTheme.js +222 -0
- package/dist/Schema/SchemaEditor/index.js +1 -0
- package/dist/Schema/SchemaForm/index.js +1 -0
- package/dist/TaskList/TaskList.js +21 -4
- package/dist/TaskList/components/TaskListItem.js +2 -1
- package/dist/TaskList/style.js +1 -1
- package/dist/ThoughtChainList/index.js +1 -0
- package/dist/ToolUseBar/index.js +7 -6
- package/dist/ToolUseBarThink/style.js +0 -7
- package/dist/WelcomeMessage/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"v": "5.7.4",
|
|
3
|
+
"fr": 30,
|
|
4
|
+
"ip": 0,
|
|
5
|
+
"op": 60,
|
|
6
|
+
"w": 32,
|
|
7
|
+
"h": 32,
|
|
8
|
+
"nm": "ThreeThinking",
|
|
9
|
+
"ddd": 0,
|
|
10
|
+
"assets": [],
|
|
11
|
+
"layers": [
|
|
12
|
+
{
|
|
13
|
+
"ddd": 0,
|
|
14
|
+
"ind": 1,
|
|
15
|
+
"ty": 4,
|
|
16
|
+
"nm": "Thinking Dot 1",
|
|
17
|
+
"sr": 1,
|
|
18
|
+
"ks": {
|
|
19
|
+
"o": { "a": 0, "k": 100 },
|
|
20
|
+
"r": { "a": 0, "k": 0 },
|
|
21
|
+
"p": { "a": 0, "k": [10, 16, 0] },
|
|
22
|
+
"a": { "a": 0, "k": [0, 0, 0] },
|
|
23
|
+
"s": {
|
|
24
|
+
"a": 1,
|
|
25
|
+
"k": [
|
|
26
|
+
{ "t": 0, "s": [100, 100, 100], "e": [60, 60, 100] },
|
|
27
|
+
{ "t": 15, "s": [60, 60, 100], "e": [100, 100, 100] },
|
|
28
|
+
{ "t": 30, "s": [100, 100, 100] }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"ao": 0,
|
|
33
|
+
"shapes": [
|
|
34
|
+
{
|
|
35
|
+
"ty": "el",
|
|
36
|
+
"d": 1,
|
|
37
|
+
"s": { "a": 0, "k": [6, 6] },
|
|
38
|
+
"p": { "a": 0, "k": [0, 0] }
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"ty": "fl",
|
|
42
|
+
"c": { "a": 0, "k": [0.09, 0.47, 1, 1] },
|
|
43
|
+
"o": { "a": 0, "k": 100 }
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"ip": 0,
|
|
47
|
+
"op": 60,
|
|
48
|
+
"st": 0
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"ddd": 0,
|
|
52
|
+
"ind": 2,
|
|
53
|
+
"ty": 4,
|
|
54
|
+
"nm": "Thinking Dot 2",
|
|
55
|
+
"sr": 1,
|
|
56
|
+
"ks": {
|
|
57
|
+
"o": { "a": 0, "k": 100 },
|
|
58
|
+
"r": { "a": 0, "k": 0 },
|
|
59
|
+
"p": { "a": 0, "k": [16, 16, 0] },
|
|
60
|
+
"a": { "a": 0, "k": [0, 0, 0] },
|
|
61
|
+
"s": {
|
|
62
|
+
"a": 1,
|
|
63
|
+
"k": [
|
|
64
|
+
{ "t": 0, "s": [100, 100, 100], "e": [60, 60, 100] },
|
|
65
|
+
{ "t": 10, "s": [60, 60, 100], "e": [100, 100, 100] },
|
|
66
|
+
{ "t": 20, "s": [100, 100, 100], "e": [60, 60, 100] },
|
|
67
|
+
{ "t": 30, "s": [60, 60, 100], "e": [100, 100, 100] },
|
|
68
|
+
{ "t": 40, "s": [100, 100, 100] }
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"ao": 0,
|
|
73
|
+
"shapes": [
|
|
74
|
+
{
|
|
75
|
+
"ty": "el",
|
|
76
|
+
"d": 1,
|
|
77
|
+
"s": { "a": 0, "k": [6, 6] },
|
|
78
|
+
"p": { "a": 0, "k": [0, 0] }
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"ty": "fl",
|
|
82
|
+
"c": { "a": 0, "k": [0.09, 0.47, 1, 1] },
|
|
83
|
+
"o": { "a": 0, "k": 100 }
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"ip": 0,
|
|
87
|
+
"op": 60,
|
|
88
|
+
"st": 0
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"ddd": 0,
|
|
92
|
+
"ind": 3,
|
|
93
|
+
"ty": 4,
|
|
94
|
+
"nm": "Thinking Dot 3",
|
|
95
|
+
"sr": 1,
|
|
96
|
+
"ks": {
|
|
97
|
+
"o": { "a": 0, "k": 100 },
|
|
98
|
+
"r": { "a": 0, "k": 0 },
|
|
99
|
+
"p": { "a": 0, "k": [22, 16, 0] },
|
|
100
|
+
"a": { "a": 0, "k": [0, 0, 0] },
|
|
101
|
+
"s": {
|
|
102
|
+
"a": 1,
|
|
103
|
+
"k": [
|
|
104
|
+
{ "t": 0, "s": [60, 60, 100], "e": [100, 100, 100] },
|
|
105
|
+
{ "t": 15, "s": [100, 100, 100], "e": [60, 60, 100] },
|
|
106
|
+
{ "t": 30, "s": [60, 60, 100] }
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"ao": 0,
|
|
111
|
+
"shapes": [
|
|
112
|
+
{
|
|
113
|
+
"ty": "el",
|
|
114
|
+
"d": 1,
|
|
115
|
+
"s": { "a": 0, "k": [6, 6] },
|
|
116
|
+
"p": { "a": 0, "k": [0, 0] }
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"ty": "fl",
|
|
120
|
+
"c": { "a": 0, "k": [0.09, 0.47, 1, 1] },
|
|
121
|
+
"o": { "a": 0, "k": 100 }
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"ip": 0,
|
|
125
|
+
"op": 60,
|
|
126
|
+
"st": 0
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"markers": []
|
|
130
|
+
}
|
package/dist/History/index.js
CHANGED
|
@@ -274,6 +274,7 @@ export * from "./utils";
|
|
|
274
274
|
if (props.standalone) {
|
|
275
275
|
var _props_agent3, _props_agent4, _props_agent5, _props_agent6, _props_agent7, _props_slots_beforeHistoryList, _props_slots;
|
|
276
276
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
277
|
+
"data-testid": "history-standalone",
|
|
277
278
|
style: {
|
|
278
279
|
display: 'flex',
|
|
279
280
|
flexDirection: 'column',
|
|
@@ -394,6 +394,7 @@ var I18nBoundary = function I18nBoundary(param) {
|
|
|
394
394
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
395
395
|
id: props.id ? String(props.id) || undefined : undefined,
|
|
396
396
|
className: classNames(baseClassName, 'markdown-editor', hashId, props.className, (_obj = {}, _define_property(_obj, "".concat(baseClassName, "-readonly"), true), _define_property(_obj, "".concat(baseClassName, "-report"), props.reportMode), _define_property(_obj, "".concat(baseClassName, "-slide"), props.slideMode), _obj)),
|
|
397
|
+
"data-testid": "markdown-editor",
|
|
397
398
|
style: _object_spread({
|
|
398
399
|
width: width || '100%',
|
|
399
400
|
height: height || 'auto'
|
|
@@ -453,6 +454,7 @@ var I18nBoundary = function I18nBoundary(param) {
|
|
|
453
454
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
454
455
|
id: props.id ? String(props.id) || undefined : undefined,
|
|
455
456
|
className: classNames(baseClassName, 'markdown-editor', hashId, props.className, (_obj1 = {}, _define_property(_obj1, "".concat(baseClassName, "-readonly"), readonly), _define_property(_obj1, "".concat(baseClassName, "-edit"), !readonly), _define_property(_obj1, "".concat(baseClassName, "-report"), props.reportMode), _define_property(_obj1, "".concat(baseClassName, "-slide"), props.slideMode), _obj1)),
|
|
457
|
+
"data-testid": "markdown-editor",
|
|
456
458
|
style: _object_spread({
|
|
457
459
|
width: width || '100%',
|
|
458
460
|
height: height || 'auto'
|
|
@@ -369,6 +369,7 @@ var SCHEMA_LANGUAGES = new Set([
|
|
|
369
369
|
return wrapVarSSR(wrapSSR(wrapContentSSR(/*#__PURE__*/ React.createElement("div", {
|
|
370
370
|
ref: containerRef,
|
|
371
371
|
className: clsx(prefixCls, "".concat(prefixCls, "-readonly"), hashId, className),
|
|
372
|
+
"data-testid": "markdown-renderer",
|
|
372
373
|
style: style
|
|
373
374
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
374
375
|
className: clsx("".concat(prefixCls, "-container"), hashId),
|
|
@@ -7,6 +7,8 @@ export interface ChartContainerProps {
|
|
|
7
7
|
style?: React.CSSProperties;
|
|
8
8
|
/** 图表主题 */
|
|
9
9
|
theme?: 'light' | 'dark';
|
|
10
|
+
/** 是否自动检测主题(检测 html[data-theme='dark'] 和 CSS 变量亮度) */
|
|
11
|
+
autoDetectTheme?: boolean;
|
|
10
12
|
/** 是否为移动端 */
|
|
11
13
|
isMobile?: boolean;
|
|
12
14
|
/** 图表变体 */
|
|
@@ -42,7 +44,7 @@ export interface ChartContainerRef {
|
|
|
42
44
|
* @param {string} [props.className] - 自定义CSS类名
|
|
43
45
|
* @param {React.ReactNode} props.children - 子元素
|
|
44
46
|
* @param {React.CSSProperties} [props.style] - 样式对象
|
|
45
|
-
* @param {'light' | 'dark'} [props.theme='
|
|
47
|
+
* @param {'light' | 'dark'} [props.theme] - 图表主题,不传时自动检测(检测 html[data-theme='dark'] 或 CSS 变量亮度)
|
|
46
48
|
* @param {boolean} [props.isMobile=false] - 是否为移动端
|
|
47
49
|
* @param {object} [props.errorBoundary] - 错误边界配置
|
|
48
50
|
* @param {boolean} [props.errorBoundary.enabled=true] - 是否启用错误边界
|
|
@@ -52,17 +54,24 @@ export interface ChartContainerRef {
|
|
|
52
54
|
*
|
|
53
55
|
* @example
|
|
54
56
|
* ```tsx
|
|
55
|
-
* //
|
|
57
|
+
* // 基础使用(自动检测主题)
|
|
56
58
|
* <ChartContainer
|
|
57
59
|
* baseClassName="area-chart-container"
|
|
58
60
|
* className="custom-chart"
|
|
59
|
-
* theme="light"
|
|
60
61
|
* isMobile={false}
|
|
61
62
|
* style={{ width: 600, height: 400 }}
|
|
62
63
|
* >
|
|
63
64
|
* <div>图表内容</div>
|
|
64
65
|
* </ChartContainer>
|
|
65
66
|
*
|
|
67
|
+
* // 显式指定主题
|
|
68
|
+
* <ChartContainer
|
|
69
|
+
* baseClassName="area-chart-container"
|
|
70
|
+
* theme="dark"
|
|
71
|
+
* >
|
|
72
|
+
* <div>图表内容</div>
|
|
73
|
+
* </ChartContainer>
|
|
74
|
+
*
|
|
66
75
|
* // 自定义错误边界
|
|
67
76
|
* <ChartContainer
|
|
68
77
|
* baseClassName="line-chart-container"
|
|
@@ -98,6 +107,7 @@ export interface ChartContainerRef {
|
|
|
98
107
|
* - 内置错误边界保护,防止图表错误影响整个应用
|
|
99
108
|
* - 错误边界默认启用,可通过配置禁用或自定义
|
|
100
109
|
* - `theme="dark"` 时在本容器内嵌套 Ant Design 暗色算法,工具栏/筛选等 antd 控件与画布暗色一致(嵌套容器不重复包裹)
|
|
110
|
+
* - 支持自动主题检测:当 theme 未指定时,会自动检测 html[data-theme='dark'] 属性或 CSS 变量亮度判断主题
|
|
101
111
|
*/
|
|
102
112
|
declare const ChartContainer: React.FC<ChartContainerProps & {
|
|
103
113
|
baseClassName: string;
|
|
@@ -65,6 +65,7 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
65
65
|
import { ConfigProvider, theme as antdTheme } from "antd";
|
|
66
66
|
import classNames from "clsx";
|
|
67
67
|
import React from "react";
|
|
68
|
+
import { useDetectTheme } from "../../hooks";
|
|
68
69
|
import { ChartDarkAntdProvidedContext, useChartDarkAntdProvided } from "./ChartDarkAntdContext";
|
|
69
70
|
import ChartErrorBoundary from "./ChartErrorBoundary";
|
|
70
71
|
import { useStyle } from "./style";
|
|
@@ -81,7 +82,7 @@ import { useStyle } from "./style";
|
|
|
81
82
|
* @param {string} [props.className] - 自定义CSS类名
|
|
82
83
|
* @param {React.ReactNode} props.children - 子元素
|
|
83
84
|
* @param {React.CSSProperties} [props.style] - 样式对象
|
|
84
|
-
* @param {'light' | 'dark'} [props.theme='
|
|
85
|
+
* @param {'light' | 'dark'} [props.theme] - 图表主题,不传时自动检测(检测 html[data-theme='dark'] 或 CSS 变量亮度)
|
|
85
86
|
* @param {boolean} [props.isMobile=false] - 是否为移动端
|
|
86
87
|
* @param {object} [props.errorBoundary] - 错误边界配置
|
|
87
88
|
* @param {boolean} [props.errorBoundary.enabled=true] - 是否启用错误边界
|
|
@@ -91,17 +92,24 @@ import { useStyle } from "./style";
|
|
|
91
92
|
*
|
|
92
93
|
* @example
|
|
93
94
|
* ```tsx
|
|
94
|
-
* //
|
|
95
|
+
* // 基础使用(自动检测主题)
|
|
95
96
|
* <ChartContainer
|
|
96
97
|
* baseClassName="area-chart-container"
|
|
97
98
|
* className="custom-chart"
|
|
98
|
-
* theme="light"
|
|
99
99
|
* isMobile={false}
|
|
100
100
|
* style={{ width: 600, height: 400 }}
|
|
101
101
|
* >
|
|
102
102
|
* <div>图表内容</div>
|
|
103
103
|
* </ChartContainer>
|
|
104
104
|
*
|
|
105
|
+
* // 显式指定主题
|
|
106
|
+
* <ChartContainer
|
|
107
|
+
* baseClassName="area-chart-container"
|
|
108
|
+
* theme="dark"
|
|
109
|
+
* >
|
|
110
|
+
* <div>图表内容</div>
|
|
111
|
+
* </ChartContainer>
|
|
112
|
+
*
|
|
105
113
|
* // 自定义错误边界
|
|
106
114
|
* <ChartContainer
|
|
107
115
|
* baseClassName="line-chart-container"
|
|
@@ -137,8 +145,9 @@ import { useStyle } from "./style";
|
|
|
137
145
|
* - 内置错误边界保护,防止图表错误影响整个应用
|
|
138
146
|
* - 错误边界默认启用,可通过配置禁用或自定义
|
|
139
147
|
* - `theme="dark"` 时在本容器内嵌套 Ant Design 暗色算法,工具栏/筛选等 antd 控件与画布暗色一致(嵌套容器不重复包裹)
|
|
148
|
+
* - 支持自动主题检测:当 theme 未指定时,会自动检测 html[data-theme='dark'] 属性或 CSS 变量亮度判断主题
|
|
140
149
|
*/ var ChartContainer = function ChartContainer(_0) {
|
|
141
|
-
var baseClassName = _0.baseClassName, className = _0.className, children = _0.children, style = _0.style, classNamesProp = _0.classNames, stylesProp = _0.styles,
|
|
150
|
+
var baseClassName = _0.baseClassName, className = _0.className, children = _0.children, style = _0.style, classNamesProp = _0.classNames, stylesProp = _0.styles, themeProp = _0.theme, _0_autoDetectTheme = _0.autoDetectTheme, autoDetectTheme = _0_autoDetectTheme === void 0 ? true : _0_autoDetectTheme, _0_variant = _0.variant, variant = _0_variant === void 0 ? 'default' : _0_variant, _0_isMobile = _0.isMobile, isMobile = _0_isMobile === void 0 ? false : _0_isMobile, _0_errorBoundary = _0.errorBoundary, errorBoundary = _0_errorBoundary === void 0 ? {
|
|
142
151
|
enabled: true
|
|
143
152
|
} : _0_errorBoundary, restProps = _object_without_properties(_0, [
|
|
144
153
|
"baseClassName",
|
|
@@ -148,12 +157,18 @@ import { useStyle } from "./style";
|
|
|
148
157
|
"classNames",
|
|
149
158
|
"styles",
|
|
150
159
|
"theme",
|
|
160
|
+
"autoDetectTheme",
|
|
151
161
|
"variant",
|
|
152
162
|
"isMobile",
|
|
153
163
|
"errorBoundary"
|
|
154
164
|
]);
|
|
155
165
|
var _useStyle = useStyle(baseClassName), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
|
|
156
166
|
var ancestorDarkAntdProvided = useChartDarkAntdProvided();
|
|
167
|
+
// 自动检测主题:当 themeProp 未指定且 autoDetectTheme 为 true 时,自动检测
|
|
168
|
+
var detectedTheme = useDetectTheme({
|
|
169
|
+
observeChanges: autoDetectTheme
|
|
170
|
+
});
|
|
171
|
+
var theme = themeProp !== null && themeProp !== void 0 ? themeProp : autoDetectTheme ? detectedTheme : 'light';
|
|
157
172
|
var wrapDarkAntd = theme === 'dark' && !ancestorDarkAntdProvided;
|
|
158
173
|
// 构建动态类名
|
|
159
174
|
var combinedClassName = classNames(baseClassName, hashId, theme === 'light' && "".concat(baseClassName, "-light-theme"), theme === 'dark' && "".concat(baseClassName, "-dark-theme"), isMobile && "".concat(baseClassName, "-mobile"), !isMobile && "".concat(baseClassName, "-desktop"), variant === 'outline' && "".concat(baseClassName, "-outline"), variant === 'borderless' && "".concat(baseClassName, "-borderless"), className, classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.root);
|
|
@@ -7,4 +7,6 @@ export { useChartDataFilter } from './useChartDataFilter';
|
|
|
7
7
|
export type { ChartStatisticConfig, StatisticConfigType, } from './useChartStatistic';
|
|
8
8
|
export { useChartStatistics } from './useChartStatistics';
|
|
9
9
|
export { useChartTheme } from './useChartTheme';
|
|
10
|
+
export { useDetectTheme } from './useDetectTheme';
|
|
11
|
+
export type { DetectThemeOptions } from './useDetectTheme';
|
|
10
12
|
export { useResponsiveSize } from './useResponsiveSize';
|
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
*/ export { useChartDataFilter } from "./useChartDataFilter";
|
|
6
6
|
export { useChartStatistics } from "./useChartStatistics";
|
|
7
7
|
export { useChartTheme } from "./useChartTheme";
|
|
8
|
+
export { useDetectTheme } from "./useDetectTheme";
|
|
8
9
|
export { useResponsiveSize } from "./useResponsiveSize";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主题检测配置选项
|
|
3
|
+
*/
|
|
4
|
+
export interface DetectThemeOptions {
|
|
5
|
+
/**
|
|
6
|
+
* 用于检测主题的 CSS 变量名
|
|
7
|
+
* @default '--color-gray-bg-page'
|
|
8
|
+
*/
|
|
9
|
+
cssVariable?: string;
|
|
10
|
+
/**
|
|
11
|
+
* 亮度阈值,低于此值认为是暗色主题
|
|
12
|
+
* @default 145
|
|
13
|
+
*/
|
|
14
|
+
darknessThreshold?: number;
|
|
15
|
+
/**
|
|
16
|
+
* 是否监听主题变化
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
observeChanges?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 自动检测当前主题的 Hook
|
|
23
|
+
*
|
|
24
|
+
* 检测策略(按优先级):
|
|
25
|
+
* 1. 检查 `html[data-theme='dark']` 属性
|
|
26
|
+
* 2. 检查指定 CSS 变量的亮度值
|
|
27
|
+
* 3. 检查 `--color-gray-bg-page` 的亮度值
|
|
28
|
+
*
|
|
29
|
+
* @param options 检测配置选项
|
|
30
|
+
* @returns 检测到的主题 'light' | 'dark'
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const theme = useDetectTheme();
|
|
35
|
+
* // theme: 'light' | 'dark'
|
|
36
|
+
*
|
|
37
|
+
* // 自定义配置
|
|
38
|
+
* const theme = useDetectTheme({
|
|
39
|
+
* cssVariable: '--color-primary-bg-page',
|
|
40
|
+
* darknessThreshold: 128,
|
|
41
|
+
* observeChanges: true,
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const useDetectTheme: (options?: DetectThemeOptions) => 'light' | 'dark';
|
|
46
|
+
export default useDetectTheme;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _iterable_to_array_limit(arr, i) {
|
|
10
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
11
|
+
if (_i == null) return;
|
|
12
|
+
var _arr = [];
|
|
13
|
+
var _n = true;
|
|
14
|
+
var _d = false;
|
|
15
|
+
var _s, _e;
|
|
16
|
+
try {
|
|
17
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
18
|
+
_arr.push(_s.value);
|
|
19
|
+
if (i && _arr.length === i) break;
|
|
20
|
+
}
|
|
21
|
+
} catch (err) {
|
|
22
|
+
_d = true;
|
|
23
|
+
_e = err;
|
|
24
|
+
} finally{
|
|
25
|
+
try {
|
|
26
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
27
|
+
} finally{
|
|
28
|
+
if (_d) throw _e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return _arr;
|
|
32
|
+
}
|
|
33
|
+
function _non_iterable_rest() {
|
|
34
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
35
|
+
}
|
|
36
|
+
function _sliced_to_array(arr, i) {
|
|
37
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
38
|
+
}
|
|
39
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
40
|
+
if (!o) return;
|
|
41
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
42
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
43
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
44
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
|
+
}
|
|
47
|
+
import { useEffect, useState } from "react";
|
|
48
|
+
/**
|
|
49
|
+
* 解析颜色值为 RGB
|
|
50
|
+
*/ var parseColorToRgb = function parseColorToRgb(color) {
|
|
51
|
+
var normalizedColor = color.trim().toLowerCase();
|
|
52
|
+
// 短十六进制格式 #rgb
|
|
53
|
+
var shortHexMatch = normalizedColor.match(/^#([0-9a-f]{3})$/i);
|
|
54
|
+
if (shortHexMatch) {
|
|
55
|
+
var _shortHexMatch__split_map = _sliced_to_array(shortHexMatch[1].split('').map(function(char) {
|
|
56
|
+
return Number.parseInt(char + char, 16);
|
|
57
|
+
}), 3), r = _shortHexMatch__split_map[0], g = _shortHexMatch__split_map[1], b = _shortHexMatch__split_map[2];
|
|
58
|
+
return {
|
|
59
|
+
r: r,
|
|
60
|
+
g: g,
|
|
61
|
+
b: b
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// 标准十六进制格式 #rrggbb
|
|
65
|
+
var hexMatch = normalizedColor.match(/^#([0-9a-f]{6})$/i);
|
|
66
|
+
if (hexMatch) {
|
|
67
|
+
return {
|
|
68
|
+
r: Number.parseInt(hexMatch[1].slice(0, 2), 16),
|
|
69
|
+
g: Number.parseInt(hexMatch[1].slice(2, 4), 16),
|
|
70
|
+
b: Number.parseInt(hexMatch[1].slice(4, 6), 16)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// rgb/rgba 格式
|
|
74
|
+
var rgbMatch = normalizedColor.match(/^rgba?\((\d{1,3})[\s,]+(\d{1,3})[\s,]+(\d{1,3})(?:[\s,]+[\d.]+)?\)$/i);
|
|
75
|
+
if (rgbMatch) {
|
|
76
|
+
return {
|
|
77
|
+
r: Number.parseInt(rgbMatch[1], 10),
|
|
78
|
+
g: Number.parseInt(rgbMatch[2], 10),
|
|
79
|
+
b: Number.parseInt(rgbMatch[3], 10)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* 计算颜色的亮度
|
|
86
|
+
* 使用加权公式:Y = 0.299*R + 0.587*G + 0.114*B
|
|
87
|
+
*/ var calculateBrightness = function calculateBrightness(color) {
|
|
88
|
+
var rgb = parseColorToRgb(color);
|
|
89
|
+
if (!rgb) return null;
|
|
90
|
+
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* 检测背景色是否为暗色
|
|
94
|
+
*/ var isDarkBackground = function isDarkBackground(color) {
|
|
95
|
+
var threshold = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 145;
|
|
96
|
+
var brightness = calculateBrightness(color);
|
|
97
|
+
if (brightness === null) return false;
|
|
98
|
+
return brightness < threshold;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* 检测 HTML 元素的 data-theme 属性是否为 dark
|
|
102
|
+
*/ var checkDataTheme = function checkDataTheme() {
|
|
103
|
+
if (typeof document === 'undefined') return false;
|
|
104
|
+
var htmlElement = document.documentElement;
|
|
105
|
+
return htmlElement.getAttribute('data-theme') === 'dark';
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* 获取 CSS 变量的计算值
|
|
109
|
+
*/ var getCSSVariableValue = function getCSSVariableValue(variableName) {
|
|
110
|
+
if (typeof window === 'undefined') return null;
|
|
111
|
+
var computedStyle = window.getComputedStyle(document.documentElement);
|
|
112
|
+
var value = computedStyle.getPropertyValue(variableName).trim();
|
|
113
|
+
return value || null;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* 根据多种方式检测当前主题
|
|
117
|
+
*/ var detectTheme = function detectTheme(cssVariable, darknessThreshold) {
|
|
118
|
+
// 1. 首先检查 html[data-theme='dark']
|
|
119
|
+
if (checkDataTheme()) {
|
|
120
|
+
return 'dark';
|
|
121
|
+
}
|
|
122
|
+
// 2. 检查 CSS 变量的亮度
|
|
123
|
+
var cssValue = getCSSVariableValue(cssVariable);
|
|
124
|
+
if (cssValue && isDarkBackground(cssValue, darknessThreshold)) {
|
|
125
|
+
return 'dark';
|
|
126
|
+
}
|
|
127
|
+
// 3. 检查背景色 CSS 变量
|
|
128
|
+
var bgColor = getCSSVariableValue('--color-gray-bg-page');
|
|
129
|
+
if (bgColor && isDarkBackground(bgColor, darknessThreshold)) {
|
|
130
|
+
return 'dark';
|
|
131
|
+
}
|
|
132
|
+
return 'light';
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* 自动检测当前主题的 Hook
|
|
136
|
+
*
|
|
137
|
+
* 检测策略(按优先级):
|
|
138
|
+
* 1. 检查 `html[data-theme='dark']` 属性
|
|
139
|
+
* 2. 检查指定 CSS 变量的亮度值
|
|
140
|
+
* 3. 检查 `--color-gray-bg-page` 的亮度值
|
|
141
|
+
*
|
|
142
|
+
* @param options 检测配置选项
|
|
143
|
+
* @returns 检测到的主题 'light' | 'dark'
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```tsx
|
|
147
|
+
* const theme = useDetectTheme();
|
|
148
|
+
* // theme: 'light' | 'dark'
|
|
149
|
+
*
|
|
150
|
+
* // 自定义配置
|
|
151
|
+
* const theme = useDetectTheme({
|
|
152
|
+
* cssVariable: '--color-primary-bg-page',
|
|
153
|
+
* darknessThreshold: 128,
|
|
154
|
+
* observeChanges: true,
|
|
155
|
+
* });
|
|
156
|
+
* ```
|
|
157
|
+
*/ export var useDetectTheme = function useDetectTheme() {
|
|
158
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
159
|
+
var _options_cssVariable = options.cssVariable, cssVariable = _options_cssVariable === void 0 ? '--color-gray-bg-page' : _options_cssVariable, _options_darknessThreshold = options.darknessThreshold, darknessThreshold = _options_darknessThreshold === void 0 ? 145 : _options_darknessThreshold, _options_observeChanges = options.observeChanges, observeChanges = _options_observeChanges === void 0 ? true : _options_observeChanges;
|
|
160
|
+
var _useState = _sliced_to_array(useState(function() {
|
|
161
|
+
return detectTheme(cssVariable, darknessThreshold);
|
|
162
|
+
}), 2), theme = _useState[0], setTheme = _useState[1];
|
|
163
|
+
useEffect(function() {
|
|
164
|
+
if (!observeChanges) return;
|
|
165
|
+
var updateTheme = function updateTheme() {
|
|
166
|
+
setTheme(detectTheme(cssVariable, darknessThreshold));
|
|
167
|
+
};
|
|
168
|
+
// 监听 data-theme 属性变化
|
|
169
|
+
var htmlElement = document.documentElement;
|
|
170
|
+
var observer = new MutationObserver(function(mutations) {
|
|
171
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
172
|
+
try {
|
|
173
|
+
for(var _iterator = mutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
174
|
+
var mutation = _step.value;
|
|
175
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'data-theme') {
|
|
176
|
+
updateTheme();
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} catch (err) {
|
|
181
|
+
_didIteratorError = true;
|
|
182
|
+
_iteratorError = err;
|
|
183
|
+
} finally{
|
|
184
|
+
try {
|
|
185
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
186
|
+
_iterator.return();
|
|
187
|
+
}
|
|
188
|
+
} finally{
|
|
189
|
+
if (_didIteratorError) {
|
|
190
|
+
throw _iteratorError;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
observer.observe(htmlElement, {
|
|
196
|
+
attributes: true,
|
|
197
|
+
attributeFilter: [
|
|
198
|
+
'data-theme',
|
|
199
|
+
'class',
|
|
200
|
+
'style'
|
|
201
|
+
]
|
|
202
|
+
});
|
|
203
|
+
// 监听 prefers-color-scheme 变化
|
|
204
|
+
var mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
205
|
+
var handleMediaChange = function handleMediaChange() {
|
|
206
|
+
updateTheme();
|
|
207
|
+
};
|
|
208
|
+
mediaQuery.addEventListener('change', handleMediaChange);
|
|
209
|
+
// 初始检测
|
|
210
|
+
updateTheme();
|
|
211
|
+
return function() {
|
|
212
|
+
observer.disconnect();
|
|
213
|
+
mediaQuery.removeEventListener('change', handleMediaChange);
|
|
214
|
+
};
|
|
215
|
+
}, [
|
|
216
|
+
cssVariable,
|
|
217
|
+
darknessThreshold,
|
|
218
|
+
observeChanges
|
|
219
|
+
]);
|
|
220
|
+
return theme;
|
|
221
|
+
};
|
|
222
|
+
export default useDetectTheme;
|
|
@@ -442,6 +442,7 @@ import { useStyle } from "./style";
|
|
|
442
442
|
]);
|
|
443
443
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
444
444
|
className: classNames(prefixCls, className, hashId),
|
|
445
|
+
"data-testid": prefixCls,
|
|
445
446
|
style: {
|
|
446
447
|
height: typeof height === 'number' ? "".concat(height, "px") : height
|
|
447
448
|
}
|
|
@@ -73,7 +73,7 @@ import { ChevronUp } from "@sofa-design/icons";
|
|
|
73
73
|
import { ConfigProvider } from "antd";
|
|
74
74
|
import classNames from "clsx";
|
|
75
75
|
import { useMergedState } from "rc-util";
|
|
76
|
-
import React, { memo, useContext, useMemo } from "react";
|
|
76
|
+
import React, { memo, useContext, useEffect, useMemo, useState } from "react";
|
|
77
77
|
import { ActionIconBox } from "../Components/ActionIconBox";
|
|
78
78
|
import { useRefFunction } from "../Hooks/useRefFunction";
|
|
79
79
|
import { I18nContext } from "../I18n";
|
|
@@ -81,6 +81,7 @@ import { StatusIcon } from "./components/StatusIcon";
|
|
|
81
81
|
import { TaskListItem } from "./components/TaskListItem";
|
|
82
82
|
import { getArrowRotation } from "./constants";
|
|
83
83
|
import { useStyle } from "./style";
|
|
84
|
+
var SIMPLE_COLLAPSE_DURATION_MS = 350;
|
|
84
85
|
var getDefaultExpandedKeys = function getDefaultExpandedKeys(items, isControlled) {
|
|
85
86
|
return isControlled ? [] : items.map(function(item) {
|
|
86
87
|
return item.key;
|
|
@@ -112,11 +113,26 @@ export var TaskList = /*#__PURE__*/ memo(function(param) {
|
|
|
112
113
|
return onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(val);
|
|
113
114
|
}
|
|
114
115
|
}), 2), simpleExpanded = _useMergedState1[0], setSimpleExpanded = _useMergedState1[1];
|
|
116
|
+
var _useState = _sliced_to_array(useState(true), 2), shouldRenderContent = _useState[0], setShouldRenderContent = _useState[1];
|
|
115
117
|
var handleSimpleToggle = useRefFunction(function() {
|
|
116
118
|
setSimpleExpanded(function(prev) {
|
|
117
119
|
return !prev;
|
|
118
120
|
});
|
|
119
121
|
});
|
|
122
|
+
useEffect(function() {
|
|
123
|
+
if (simpleExpanded) {
|
|
124
|
+
setShouldRenderContent(true);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
var timer = window.setTimeout(function() {
|
|
128
|
+
setShouldRenderContent(false);
|
|
129
|
+
}, SIMPLE_COLLAPSE_DURATION_MS);
|
|
130
|
+
return function() {
|
|
131
|
+
window.clearTimeout(timer);
|
|
132
|
+
};
|
|
133
|
+
}, [
|
|
134
|
+
simpleExpanded
|
|
135
|
+
]);
|
|
120
136
|
var _useMemo = useMemo(function() {
|
|
121
137
|
var completedCount = items.filter(function(i) {
|
|
122
138
|
return i.status === 'success';
|
|
@@ -168,7 +184,8 @@ export var TaskList = /*#__PURE__*/ memo(function(param) {
|
|
|
168
184
|
};
|
|
169
185
|
if (variant !== 'simple') {
|
|
170
186
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
171
|
-
className: className
|
|
187
|
+
className: className,
|
|
188
|
+
"data-testid": prefixCls
|
|
172
189
|
}, renderItems(items)));
|
|
173
190
|
}
|
|
174
191
|
var simpleCls = "".concat(prefixCls, "-simple");
|
|
@@ -210,8 +227,8 @@ export var TaskList = /*#__PURE__*/ memo(function(param) {
|
|
|
210
227
|
"data-testid": "task-list-simple-arrow"
|
|
211
228
|
})))), /*#__PURE__*/ React.createElement("div", {
|
|
212
229
|
className: classNames("".concat(simpleCls, "-content"), hashId, _define_property({}, "".concat(simpleCls, "-content-expanded"), simpleExpanded))
|
|
213
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
230
|
+
}, shouldRenderContent ? /*#__PURE__*/ React.createElement("div", {
|
|
214
231
|
className: classNames("".concat(simpleCls, "-list"), hashId)
|
|
215
|
-
}, renderItems(visibleItems)))));
|
|
232
|
+
}, renderItems(visibleItems)) : null)));
|
|
216
233
|
});
|
|
217
234
|
TaskList.displayName = 'TaskList';
|