@ant-design/agentic-ui 2.29.48 → 2.29.49
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/ChatLayout/style.js +2 -1
- package/dist/Components/ActionItemBox/style.js +1 -1
- package/dist/Constants/mobile.d.ts +12 -2
- package/dist/Constants/mobile.js +8 -1
- package/dist/History/hooks/useHistory.js +33 -31
- package/dist/History/menu.js +4 -0
- package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +16 -30
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +14 -40
- package/dist/MarkdownEditor/editor/elements/Table/TableColgroup.d.ts +8 -0
- package/dist/MarkdownEditor/editor/elements/Table/TableColgroup.js +37 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/getTableColWidths.d.ts +12 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/getTableColWidths.js +186 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/useReadonlyTableColWidths.d.ts +13 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/useReadonlyTableColWidths.js +96 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +21 -0
- package/dist/MarkdownEditor/style.js +2 -1
- package/dist/MarkdownInputField/FileMapView/index.js +1 -1
- package/dist/Plugins/chart/ChartRender.js +78 -14
- package/package.json +2 -1
package/dist/ChatLayout/style.js
CHANGED
|
@@ -213,7 +213,8 @@ var genStyle = function genStyle(token) {
|
|
|
213
213
|
width: '100%',
|
|
214
214
|
height: 146,
|
|
215
215
|
pointerEvents: 'none',
|
|
216
|
-
overflow: 'hidden'
|
|
216
|
+
overflow: 'hidden',
|
|
217
|
+
borderRadius: 'inherit'
|
|
217
218
|
}
|
|
218
219
|
}, "@media (max-width: ".concat(MOBILE_BREAKPOINT, ")"), {
|
|
219
220
|
'&-header': {
|
|
@@ -65,7 +65,7 @@ var genStyle = function genStyle(token) {
|
|
|
65
65
|
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
66
66
|
backgroundColor: '#FFF',
|
|
67
67
|
boxShadow: 'var(--shadow-border-base)',
|
|
68
|
-
|
|
68
|
+
minHeight: 32,
|
|
69
69
|
'&-overflow-container': {
|
|
70
70
|
position: 'absolute',
|
|
71
71
|
right: 0,
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 表格列宽阈值
|
|
3
|
+
* - 列数 < 5:使用百分比平分
|
|
4
|
+
* - 列数 >= 5:使用 TABLE_DEFAULT_COL_WIDTH 固定宽度
|
|
5
|
+
*/
|
|
6
|
+
export declare const TABLE_COL_WIDTH_MIN_COLUMNS = 5;
|
|
7
|
+
/** 编辑模式表格:列数 >= 此值时才计算并渲染 data col 元素,否则仅渲染行号列 */
|
|
8
|
+
export declare const TABLE_EDIT_COL_WIDTH_MIN_COLUMNS = 3;
|
|
9
|
+
/** 表格默认列宽 (px),与 style.ts 中 --table-cell-min-width (120px) 保持一致 */
|
|
10
|
+
export declare const TABLE_DEFAULT_COL_WIDTH = 120;
|
|
11
|
+
/** 表格最后一列最小宽度 (px),弹性列用于吸收剩余空间 */
|
|
12
|
+
export declare const TABLE_LAST_COL_MIN_WIDTH = 80;
|
|
3
13
|
export declare const MOBILE_PADDING = "clamp(4px, 2vw, 12px)";
|
|
4
14
|
export declare const MOBILE_BREAKPOINT = "768px";
|
|
5
15
|
export declare const MOBILE_TABLE_MIN_COLUMN_WIDTH = 96;
|
package/dist/Constants/mobile.js
CHANGED
|
@@ -2,7 +2,14 @@ var MOBILE_PADDING_MIN = '4px';
|
|
|
2
2
|
var MOBILE_PADDING_MAX = '12px';
|
|
3
3
|
var MOBILE_PADDING_SCALE = '2vw';
|
|
4
4
|
var MOBILE_TABLE_MIN_CELL_WIDTH = 96;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* 表格列宽阈值
|
|
7
|
+
* - 列数 < 5:使用百分比平分
|
|
8
|
+
* - 列数 >= 5:使用 TABLE_DEFAULT_COL_WIDTH 固定宽度
|
|
9
|
+
*/ export var TABLE_COL_WIDTH_MIN_COLUMNS = 5;
|
|
10
|
+
/** 编辑模式表格:列数 >= 此值时才计算并渲染 data col 元素,否则仅渲染行号列 */ export var TABLE_EDIT_COL_WIDTH_MIN_COLUMNS = 3;
|
|
11
|
+
/** 表格默认列宽 (px),与 style.ts 中 --table-cell-min-width (120px) 保持一致 */ export var TABLE_DEFAULT_COL_WIDTH = 120;
|
|
12
|
+
/** 表格最后一列最小宽度 (px),弹性列用于吸收剩余空间 */ export var TABLE_LAST_COL_MIN_WIDTH = 80;
|
|
6
13
|
export var MOBILE_PADDING = "clamp(".concat(MOBILE_PADDING_MIN, ", ").concat(MOBILE_PADDING_SCALE, ", ").concat(MOBILE_PADDING_MAX, ")");
|
|
7
14
|
export var MOBILE_BREAKPOINT = '768px';
|
|
8
15
|
export var MOBILE_TABLE_MIN_COLUMN_WIDTH = MOBILE_TABLE_MIN_CELL_WIDTH;
|
|
@@ -236,18 +236,32 @@ function _ts_generator(thisArg, body) {
|
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
import { useEffect, useState } from "react";
|
|
239
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
240
240
|
import { useRefFunction } from "../../index";
|
|
241
|
+
/**
|
|
242
|
+
* 根据关键词从列表中过滤
|
|
243
|
+
*/ function filterListByKeyword(list, keyword) {
|
|
244
|
+
if (!keyword.trim()) return list;
|
|
245
|
+
var lower = keyword.toLowerCase();
|
|
246
|
+
return list.filter(function(item) {
|
|
247
|
+
var title = typeof item.sessionTitle === 'string' ? item.sessionTitle : String(item.sessionTitle || '');
|
|
248
|
+
return title.toLowerCase().includes(lower);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
241
251
|
/**
|
|
242
252
|
* 历史记录状态管理 Hook
|
|
243
253
|
*/ export var useHistory = function useHistory(props) {
|
|
244
254
|
var _useState = _sliced_to_array(useState(false), 2), open = _useState[0], setOpen = _useState[1];
|
|
245
|
-
var
|
|
246
|
-
|
|
247
|
-
}), 2), chatList = _useState1[0], setChatList = _useState1[1];
|
|
255
|
+
var chatListRef = useRef([]);
|
|
256
|
+
var _useState1 = _sliced_to_array(useState(0), 2), listVersion = _useState1[0], setListVersion = _useState1[1];
|
|
248
257
|
var _useState2 = _sliced_to_array(useState(''), 2), searchKeyword = _useState2[0], setSearchKeyword = _useState2[1];
|
|
249
258
|
var _useState3 = _sliced_to_array(useState([]), 2), selectedIds = _useState3[0], setSelectedIds = _useState3[1];
|
|
250
|
-
var
|
|
259
|
+
var filteredList = useMemo(function() {
|
|
260
|
+
return filterListByKeyword(chatListRef.current, searchKeyword);
|
|
261
|
+
}, [
|
|
262
|
+
searchKeyword,
|
|
263
|
+
listVersion
|
|
264
|
+
]);
|
|
251
265
|
var loadHistory = useRefFunction(function() {
|
|
252
266
|
return _async_to_generator(function() {
|
|
253
267
|
var _props_request, msg;
|
|
@@ -258,13 +272,16 @@ import { useRefFunction } from "../../index";
|
|
|
258
272
|
4,
|
|
259
273
|
props === null || props === void 0 ? void 0 : (_props_request = props.request) === null || _props_request === void 0 ? void 0 : _props_request.call(props, {
|
|
260
274
|
agentId: props.agentId
|
|
261
|
-
}).then(function(
|
|
262
|
-
return
|
|
275
|
+
}).then(function(m) {
|
|
276
|
+
return m;
|
|
263
277
|
})
|
|
264
278
|
];
|
|
265
279
|
case 1:
|
|
266
280
|
msg = _state.sent();
|
|
267
|
-
|
|
281
|
+
chatListRef.current = msg || [];
|
|
282
|
+
setListVersion(function(v) {
|
|
283
|
+
return v + 1;
|
|
284
|
+
});
|
|
268
285
|
return [
|
|
269
286
|
2
|
|
270
287
|
];
|
|
@@ -300,21 +317,6 @@ import { useRefFunction } from "../../index";
|
|
|
300
317
|
props.request,
|
|
301
318
|
loadHistory
|
|
302
319
|
]);
|
|
303
|
-
// 搜索过滤逻辑
|
|
304
|
-
useEffect(function() {
|
|
305
|
-
if (!searchKeyword.trim()) {
|
|
306
|
-
setFilteredList(chatList);
|
|
307
|
-
} else {
|
|
308
|
-
var filtered = chatList.filter(function(item) {
|
|
309
|
-
var title = typeof item.sessionTitle === 'string' ? item.sessionTitle : String(item.sessionTitle || '');
|
|
310
|
-
return title.toLowerCase().includes(searchKeyword.toLowerCase());
|
|
311
|
-
});
|
|
312
|
-
setFilteredList(filtered);
|
|
313
|
-
}
|
|
314
|
-
}, [
|
|
315
|
-
chatList,
|
|
316
|
-
searchKeyword
|
|
317
|
-
]);
|
|
318
320
|
// 处理收藏
|
|
319
321
|
var handleFavorite = useRefFunction(function(sessionId, isFavorite) {
|
|
320
322
|
return _async_to_generator(function() {
|
|
@@ -328,13 +330,13 @@ import { useRefFunction } from "../../index";
|
|
|
328
330
|
];
|
|
329
331
|
case 1:
|
|
330
332
|
_state.sent();
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
333
|
+
chatListRef.current = chatListRef.current.map(function(item) {
|
|
334
|
+
return item.sessionId === sessionId ? _object_spread_props(_object_spread({}, item), {
|
|
335
|
+
isFavorite: isFavorite
|
|
336
|
+
}) : item;
|
|
337
|
+
});
|
|
338
|
+
setListVersion(function(v) {
|
|
339
|
+
return v + 1;
|
|
338
340
|
});
|
|
339
341
|
return [
|
|
340
342
|
2
|
|
@@ -404,7 +406,7 @@ import { useRefFunction } from "../../index";
|
|
|
404
406
|
return {
|
|
405
407
|
open: open,
|
|
406
408
|
setOpen: setOpen,
|
|
407
|
-
chatList:
|
|
409
|
+
chatList: chatListRef.current,
|
|
408
410
|
searchKeyword: searchKeyword,
|
|
409
411
|
selectedIds: selectedIds,
|
|
410
412
|
filteredList: filteredList,
|
package/dist/History/menu.js
CHANGED
|
@@ -78,6 +78,10 @@ var MenuItem = function MenuItem1(param) {
|
|
|
78
78
|
(_item_onClick = item.onClick) === null || _item_onClick === void 0 ? void 0 : _item_onClick.call(item);
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
+
// 分组类型但子项为空时不展示
|
|
82
|
+
if (item.type === 'group' && (!item.children || !item.children.length)) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
81
85
|
// 如果是分组且有子项,并且嵌套层级小于2
|
|
82
86
|
if (item.type === 'group' && item.children && level < 2) {
|
|
83
87
|
return /*#__PURE__*/ React.createElement("div", {
|
|
@@ -64,10 +64,11 @@ import classNames from "clsx";
|
|
|
64
64
|
import copy from "copy-to-clipboard";
|
|
65
65
|
import React, { useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
66
66
|
import { ActionIconBox } from "../../../../Components/ActionIconBox";
|
|
67
|
-
import { TABLE_COL_WIDTH_MIN_COLUMNS } from "../../../../Constants/mobile";
|
|
68
67
|
import { I18nContext } from "../../../../I18n";
|
|
69
68
|
import { useEditorStore } from "../../store";
|
|
70
69
|
import { parserSlateNodeToMarkdown } from "../../utils";
|
|
70
|
+
import { TableColgroup } from "./TableColgroup";
|
|
71
|
+
import { useReadonlyTableColWidths } from "./utils/useReadonlyTableColWidths";
|
|
71
72
|
/**
|
|
72
73
|
* 专门针对 readonly 模式优化的表格组件
|
|
73
74
|
* 移除了不必要的滚动监听和复杂的宽度计算
|
|
@@ -82,25 +83,19 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
82
83
|
copy: 'md'
|
|
83
84
|
} : _ref_actions;
|
|
84
85
|
var tableTargetRef = useRef(null);
|
|
86
|
+
var containerRef = useRef(null);
|
|
85
87
|
var modelTargetRef = useRef(null);
|
|
86
88
|
var _useState = _sliced_to_array(useState(false), 2), previewOpen = _useState[0], setPreviewOpen = _useState[1];
|
|
87
89
|
var i18n = useContext(I18nContext);
|
|
88
|
-
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// 使用固定宽度避免复杂计算
|
|
98
|
-
var defaultWidth = 80;
|
|
99
|
-
return Array(columnCount).fill(defaultWidth);
|
|
100
|
-
}, [
|
|
101
|
-
element === null || element === void 0 ? void 0 : element.otherProps,
|
|
102
|
-
element === null || element === void 0 ? void 0 : (_element_children = element.children) === null || _element_children === void 0 ? void 0 : (_element_children_ = _element_children[0]) === null || _element_children_ === void 0 ? void 0 : (_element_children__children = _element_children_.children) === null || _element_children__children === void 0 ? void 0 : _element_children__children.length
|
|
103
|
-
]);
|
|
90
|
+
var columnCount = (element === null || element === void 0 ? void 0 : (_element_children = element.children) === null || _element_children === void 0 ? void 0 : (_element_children_ = _element_children[0]) === null || _element_children_ === void 0 ? void 0 : (_element_children__children = _element_children_.children) === null || _element_children__children === void 0 ? void 0 : _element_children__children.length) || 0;
|
|
91
|
+
var otherProps = element === null || element === void 0 ? void 0 : element.otherProps;
|
|
92
|
+
var colWidths = useReadonlyTableColWidths({
|
|
93
|
+
columnCount: columnCount,
|
|
94
|
+
otherProps: otherProps,
|
|
95
|
+
containerRef: containerRef,
|
|
96
|
+
tableRef: tableTargetRef,
|
|
97
|
+
element: element
|
|
98
|
+
});
|
|
104
99
|
// 缓存复制处理函数
|
|
105
100
|
var handleCopy = useCallback(function() {
|
|
106
101
|
try {
|
|
@@ -148,19 +143,9 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
148
143
|
return /*#__PURE__*/ React.createElement("table", {
|
|
149
144
|
ref: tableTargetRef,
|
|
150
145
|
className: classNames("".concat(baseCls, "-editor-table"), 'readonly', "".concat(baseCls, "-readonly-table"), _define_property({}, "".concat(baseCls, "-readonly-pure"), editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.pure))
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
key: index,
|
|
155
|
-
style: isLastCol ? {
|
|
156
|
-
minWidth: 60
|
|
157
|
-
} : {
|
|
158
|
-
width: colWidth,
|
|
159
|
-
minWidth: colWidth,
|
|
160
|
-
maxWidth: colWidth
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
})), /*#__PURE__*/ React.createElement("tbody", null, children));
|
|
146
|
+
}, /*#__PURE__*/ React.createElement(TableColgroup, {
|
|
147
|
+
colWidths: colWidths
|
|
148
|
+
}), /*#__PURE__*/ React.createElement("tbody", null, children));
|
|
164
149
|
}, [
|
|
165
150
|
colWidths,
|
|
166
151
|
children,
|
|
@@ -186,6 +171,7 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
186
171
|
handleCopy
|
|
187
172
|
]);
|
|
188
173
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
|
|
174
|
+
ref: containerRef,
|
|
189
175
|
className: classNames(baseCls)
|
|
190
176
|
}, tableDom), popoverContent, previewOpen && /*#__PURE__*/ React.createElement(Modal, {
|
|
191
177
|
title: (editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.previewTitle) || (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale.previewTable) || '预览表格',
|
|
@@ -149,7 +149,8 @@ import classNames from "clsx";
|
|
|
149
149
|
import React, { useContext, useEffect, useMemo, useRef } from "react";
|
|
150
150
|
import { Node } from "slate";
|
|
151
151
|
import stringWidth from "string-width";
|
|
152
|
-
import { MOBILE_BREAKPOINT, MOBILE_TABLE_MIN_COLUMN_WIDTH,
|
|
152
|
+
import { MOBILE_BREAKPOINT, MOBILE_TABLE_MIN_COLUMN_WIDTH, TABLE_EDIT_COL_WIDTH_MIN_COLUMNS } from "../../../../Constants/mobile";
|
|
153
|
+
import { TableColgroup, TABLE_ROW_INDEX_COL_WIDTH } from "./TableColgroup";
|
|
153
154
|
import { useEditorStore } from "../../store";
|
|
154
155
|
import { ReadonlyTableComponent } from "./ReadonlyTableComponent";
|
|
155
156
|
import { TablePropsContext } from "./TableContext";
|
|
@@ -194,26 +195,15 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
194
195
|
var mobileBreakpointValue = parseInt(MOBILE_BREAKPOINT, 10) || 768;
|
|
195
196
|
// 总是调用 hooks,避免条件调用
|
|
196
197
|
var _useScrollShadow = _sliced_to_array(useScrollShadow(), 2), tableRef = _useScrollShadow[0], scrollState = _useScrollShadow[1];
|
|
197
|
-
//
|
|
198
|
+
// 编辑模式下列宽计算(readonly 时走 ReadonlyTableComponent,跳过计算)
|
|
198
199
|
var colWidths = useMemo(function() {
|
|
199
|
-
var _props_element_otherProps, _props_element, _props_element_children, _props_element1, _tableRows__children, _tableRows_, _markdownContainerRef_current_querySelector, _markdownContainerRef_current;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (otherProps === null || otherProps === void 0 ? void 0 : otherProps.colWidths) {
|
|
207
|
-
return otherProps.colWidths;
|
|
208
|
-
}
|
|
209
|
-
return Array(colCount).fill(80); // 固定宽度
|
|
210
|
-
}
|
|
211
|
-
// 少于 3 列不设置 col,使用浏览器默认布局
|
|
212
|
-
if (columnCount < TABLE_COL_WIDTH_MIN_COLUMNS) return [];
|
|
213
|
-
// 如果在 props 中存在,直接使用以避免计算
|
|
214
|
-
if ((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.colWidths) {
|
|
215
|
-
var _props_element_otherProps1, _props_element4;
|
|
216
|
-
return (_props_element4 = props.element) === null || _props_element4 === void 0 ? void 0 : (_props_element_otherProps1 = _props_element4.otherProps) === null || _props_element_otherProps1 === void 0 ? void 0 : _props_element_otherProps1.colWidths;
|
|
200
|
+
var _props_element_otherProps_colWidths, _props_element_otherProps, _props_element, _props_element_children, _props_element1, _tableRows__children, _tableRows_, _markdownContainerRef_current_querySelector, _markdownContainerRef_current;
|
|
201
|
+
if (readonly) return [];
|
|
202
|
+
// 少于 TABLE_EDIT_COL_WIDTH_MIN_COLUMNS 列不设置 data col,仅行号列(显式 colWidths 也忽略)
|
|
203
|
+
if (columnCount < TABLE_EDIT_COL_WIDTH_MIN_COLUMNS) return [];
|
|
204
|
+
// 显式传入 colWidths 时优先使用
|
|
205
|
+
if ((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : (_props_element_otherProps_colWidths = _props_element_otherProps.colWidths) === null || _props_element_otherProps_colWidths === void 0 ? void 0 : _props_element_otherProps_colWidths.length) {
|
|
206
|
+
return props.element.otherProps.colWidths;
|
|
217
207
|
}
|
|
218
208
|
if (typeof window === 'undefined' || !((_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : (_props_element_children = _props_element1.children) === null || _props_element_children === void 0 ? void 0 : _props_element_children.length)) return [];
|
|
219
209
|
var tableRows = props.element.children;
|
|
@@ -315,26 +305,10 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
315
305
|
e.preventDefault();
|
|
316
306
|
return false;
|
|
317
307
|
}
|
|
318
|
-
}, /*#__PURE__*/ React.createElement(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
maxWidth: 12
|
|
323
|
-
}
|
|
324
|
-
}), (colWidths || []).map(function(colWidth, index) {
|
|
325
|
-
var _ref;
|
|
326
|
-
var isLastCol = index === ((_ref = colWidths === null || colWidths === void 0 ? void 0 : colWidths.length) !== null && _ref !== void 0 ? _ref : 0) - 1;
|
|
327
|
-
return /*#__PURE__*/ React.createElement("col", {
|
|
328
|
-
key: index,
|
|
329
|
-
style: isLastCol ? {
|
|
330
|
-
minWidth: 60
|
|
331
|
-
} : {
|
|
332
|
-
width: colWidth,
|
|
333
|
-
minWidth: colWidth,
|
|
334
|
-
maxWidth: colWidth
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
}) || null), /*#__PURE__*/ React.createElement("tbody", null, readonly ? null : /*#__PURE__*/ React.createElement(TableRowIndex, {
|
|
308
|
+
}, /*#__PURE__*/ React.createElement(TableColgroup, {
|
|
309
|
+
colWidths: colWidths !== null && colWidths !== void 0 ? colWidths : [],
|
|
310
|
+
prefixColWidth: TABLE_ROW_INDEX_COL_WIDTH
|
|
311
|
+
}), /*#__PURE__*/ React.createElement("tbody", null, readonly ? null : /*#__PURE__*/ React.createElement(TableRowIndex, {
|
|
338
312
|
colWidths: colWidths,
|
|
339
313
|
columnCount: columnCount,
|
|
340
314
|
tablePath: tablePath
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColWidthValue } from './utils/getTableColWidths';
|
|
3
|
+
export interface TableColgroupProps {
|
|
4
|
+
colWidths: ColWidthValue[];
|
|
5
|
+
prefixColWidth?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const TableColgroup: React.FC<TableColgroupProps>;
|
|
8
|
+
export declare const TABLE_ROW_INDEX_COL_WIDTH = 12;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TABLE_DEFAULT_COL_WIDTH, TABLE_LAST_COL_MIN_WIDTH } from "../../../../Constants/mobile";
|
|
3
|
+
var ROW_INDEX_COL_WIDTH = 12;
|
|
4
|
+
var isPercent = function isPercent(v) {
|
|
5
|
+
return typeof v === 'string' && v.endsWith('%');
|
|
6
|
+
};
|
|
7
|
+
export var TableColgroup = function TableColgroup(param) {
|
|
8
|
+
var colWidths = param.colWidths, prefixColWidth = param.prefixColWidth;
|
|
9
|
+
var showPrefix = (prefixColWidth !== null && prefixColWidth !== void 0 ? prefixColWidth : 0) > 0;
|
|
10
|
+
if (!showPrefix && !colWidths.length) return null;
|
|
11
|
+
return /*#__PURE__*/ React.createElement("colgroup", null, showPrefix && /*#__PURE__*/ React.createElement("col", {
|
|
12
|
+
style: {
|
|
13
|
+
width: prefixColWidth,
|
|
14
|
+
minWidth: prefixColWidth,
|
|
15
|
+
maxWidth: prefixColWidth
|
|
16
|
+
}
|
|
17
|
+
}), colWidths.map(function(w, i) {
|
|
18
|
+
var last = i === colWidths.length - 1;
|
|
19
|
+
var style = isPercent(w) ? {
|
|
20
|
+
width: w,
|
|
21
|
+
minWidth: TABLE_DEFAULT_COL_WIDTH,
|
|
22
|
+
maxWidth: w
|
|
23
|
+
} : last ? {
|
|
24
|
+
minWidth: TABLE_LAST_COL_MIN_WIDTH
|
|
25
|
+
} : {
|
|
26
|
+
width: w,
|
|
27
|
+
minWidth: w,
|
|
28
|
+
maxWidth: w
|
|
29
|
+
};
|
|
30
|
+
return /*#__PURE__*/ React.createElement("col", {
|
|
31
|
+
key: i,
|
|
32
|
+
style: style
|
|
33
|
+
});
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
TableColgroup.displayName = 'TableColgroup';
|
|
37
|
+
export var TABLE_ROW_INDEX_COL_WIDTH = ROW_INDEX_COL_WIDTH;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TableNode } from '../../../types/Table';
|
|
2
|
+
export type ColWidthValue = number | string;
|
|
3
|
+
export interface ReadonlyTableColWidthsInput {
|
|
4
|
+
columnCount: number;
|
|
5
|
+
otherProps?: {
|
|
6
|
+
colWidths?: ColWidthValue[];
|
|
7
|
+
} | null;
|
|
8
|
+
element?: TableNode | null;
|
|
9
|
+
containerWidth?: number;
|
|
10
|
+
}
|
|
11
|
+
/** 只读表格列宽:显式 colWidths > 智能算法(6+列) > 内容比例 > 平分 */
|
|
12
|
+
export declare function getReadonlyTableColWidths(input: ReadonlyTableColWidthsInput): ColWidthValue[];
|
|
@@ -0,0 +1,186 @@
|
|
|
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_without_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
+
}
|
|
9
|
+
function _iterable_to_array(iter) {
|
|
10
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
11
|
+
}
|
|
12
|
+
function _non_iterable_spread() {
|
|
13
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
14
|
+
}
|
|
15
|
+
function _to_consumable_array(arr) {
|
|
16
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
17
|
+
}
|
|
18
|
+
function _type_of(obj) {
|
|
19
|
+
"@swc/helpers - typeof";
|
|
20
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
21
|
+
}
|
|
22
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
23
|
+
if (!o) return;
|
|
24
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
25
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
26
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
27
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
28
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
29
|
+
}
|
|
30
|
+
import { Node } from "slate";
|
|
31
|
+
import stringWidth from "string-width";
|
|
32
|
+
import { TABLE_DEFAULT_COL_WIDTH, TABLE_COL_WIDTH_MIN_COLUMNS } from "../../../../../Constants/mobile";
|
|
33
|
+
var SMART_SAMPLE_ROWS = 5;
|
|
34
|
+
var SMART_CELL_PADDING = 28; // 20 基础内边距 + 8 数字等字符宽度补偿
|
|
35
|
+
var SMART_FONT = '14px sans-serif';
|
|
36
|
+
var CHAR_WIDTH_PX = 12;
|
|
37
|
+
var WORD_SPLIT = /[\s\u4e00-\u9fa5]/;
|
|
38
|
+
function getTableRows(element) {
|
|
39
|
+
return element.children.flatMap(function(node) {
|
|
40
|
+
return node.type === 'table-row' ? [
|
|
41
|
+
node
|
|
42
|
+
] : 'children' in node ? node.children : [];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function getSampledCellTexts(element, columnCount, maxRows) {
|
|
46
|
+
return getTableRows(element).slice(0, maxRows).map(function(row) {
|
|
47
|
+
return Array.from({
|
|
48
|
+
length: columnCount
|
|
49
|
+
}, function(_, i) {
|
|
50
|
+
var _row_children;
|
|
51
|
+
var cell = (_row_children = row.children) === null || _row_children === void 0 ? void 0 : _row_children[i];
|
|
52
|
+
return cell && (typeof cell === "undefined" ? "undefined" : _type_of(cell)) === 'object' && 'children' in cell ? Node.string(cell) : '';
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function createMeasureContext() {
|
|
57
|
+
if (typeof document === 'undefined') return null;
|
|
58
|
+
var ctx = document.createElement('canvas').getContext('2d');
|
|
59
|
+
if (!ctx) return null;
|
|
60
|
+
ctx.font = SMART_FONT;
|
|
61
|
+
return ctx;
|
|
62
|
+
}
|
|
63
|
+
function measureText(ctx, text, pad) {
|
|
64
|
+
return text === null || text === undefined ? pad : ctx.measureText(String(text)).width + pad;
|
|
65
|
+
}
|
|
66
|
+
function getColumnMetrics(grid, col, ctx, pad) {
|
|
67
|
+
var maxW = 0;
|
|
68
|
+
var minW = 0;
|
|
69
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
70
|
+
try {
|
|
71
|
+
for(var _iterator = grid[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
72
|
+
var row = _step.value;
|
|
73
|
+
var _Math;
|
|
74
|
+
var _row_col;
|
|
75
|
+
var cellText = (_row_col = row[col]) !== null && _row_col !== void 0 ? _row_col : '';
|
|
76
|
+
var full = measureText(ctx, cellText, pad);
|
|
77
|
+
var words = cellText.split(WORD_SPLIT).filter(Boolean);
|
|
78
|
+
var longest = words.length ? (_Math = Math).max.apply(_Math, _to_consumable_array(words.map(function(w) {
|
|
79
|
+
return measureText(ctx, w, pad);
|
|
80
|
+
}))) : measureText(ctx, cellText, pad);
|
|
81
|
+
maxW = Math.max(maxW, full);
|
|
82
|
+
minW = Math.max(minW, longest);
|
|
83
|
+
}
|
|
84
|
+
} catch (err) {
|
|
85
|
+
_didIteratorError = true;
|
|
86
|
+
_iteratorError = err;
|
|
87
|
+
} finally{
|
|
88
|
+
try {
|
|
89
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
90
|
+
_iterator.return();
|
|
91
|
+
}
|
|
92
|
+
} finally{
|
|
93
|
+
if (_didIteratorError) {
|
|
94
|
+
throw _iteratorError;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
maxW: maxW,
|
|
100
|
+
minW: minW
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function getSmartColWidthsPx(grid, columnCount, containerWidth) {
|
|
104
|
+
if (columnCount <= TABLE_COL_WIDTH_MIN_COLUMNS || !grid.length || containerWidth <= 0) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
var ctx = createMeasureContext();
|
|
108
|
+
if (!ctx) return null;
|
|
109
|
+
var metrics = Array.from({
|
|
110
|
+
length: columnCount
|
|
111
|
+
}, function(_, i) {
|
|
112
|
+
return getColumnMetrics(grid, i, ctx, SMART_CELL_PADDING);
|
|
113
|
+
});
|
|
114
|
+
var totalMin = metrics.reduce(function(s, c) {
|
|
115
|
+
return s + c.minW;
|
|
116
|
+
}, 0);
|
|
117
|
+
if (totalMin >= containerWidth) return metrics.map(function(c) {
|
|
118
|
+
return c.minW;
|
|
119
|
+
});
|
|
120
|
+
var remaining = containerWidth - totalMin;
|
|
121
|
+
var totalFlex = metrics.reduce(function(s, c) {
|
|
122
|
+
return s + (c.maxW - c.minW);
|
|
123
|
+
}, 0) || 1;
|
|
124
|
+
return metrics.map(function(c) {
|
|
125
|
+
return Math.floor(c.minW + (c.maxW - c.minW) / totalFlex * remaining);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function getContentBasedColWidthsPx(element, columnCount) {
|
|
129
|
+
var rows = getTableRows(element);
|
|
130
|
+
return Array.from({
|
|
131
|
+
length: columnCount
|
|
132
|
+
}, function(_, colIndex) {
|
|
133
|
+
var maxPx = TABLE_DEFAULT_COL_WIDTH;
|
|
134
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
135
|
+
try {
|
|
136
|
+
for(var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
137
|
+
var row = _step.value;
|
|
138
|
+
var _row_children;
|
|
139
|
+
var cell = (_row_children = row.children) === null || _row_children === void 0 ? void 0 : _row_children[colIndex];
|
|
140
|
+
if (cell && (typeof cell === "undefined" ? "undefined" : _type_of(cell)) === 'object' && 'children' in cell) {
|
|
141
|
+
var w = stringWidth(Node.string(cell)) * CHAR_WIDTH_PX;
|
|
142
|
+
if (w > maxPx) maxPx = w;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} catch (err) {
|
|
146
|
+
_didIteratorError = true;
|
|
147
|
+
_iteratorError = err;
|
|
148
|
+
} finally{
|
|
149
|
+
try {
|
|
150
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
151
|
+
_iterator.return();
|
|
152
|
+
}
|
|
153
|
+
} finally{
|
|
154
|
+
if (_didIteratorError) {
|
|
155
|
+
throw _iteratorError;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return maxPx;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function pxToPercent(px) {
|
|
163
|
+
var total = px.reduce(function(a, b) {
|
|
164
|
+
return a + b;
|
|
165
|
+
}, 0);
|
|
166
|
+
return total <= 0 ? px.map(function() {
|
|
167
|
+
return '0%';
|
|
168
|
+
}) : px.map(function(w) {
|
|
169
|
+
return "".concat((w / total * 100).toFixed(2), "%");
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/** 只读表格列宽:显式 colWidths > 智能算法(6+列) > 内容比例 > 平分 */ export function getReadonlyTableColWidths(input) {
|
|
173
|
+
var _otherProps_colWidths, _element_children, _element_children1;
|
|
174
|
+
var columnCount = input.columnCount, otherProps = input.otherProps, element = input.element, containerWidth = input.containerWidth;
|
|
175
|
+
if (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps_colWidths = otherProps.colWidths) === null || _otherProps_colWidths === void 0 ? void 0 : _otherProps_colWidths.length) return otherProps.colWidths;
|
|
176
|
+
if (columnCount === 0) return [];
|
|
177
|
+
var useSmart = (element === null || element === void 0 ? void 0 : (_element_children = element.children) === null || _element_children === void 0 ? void 0 : _element_children.length) && typeof containerWidth === 'number' && containerWidth > 0;
|
|
178
|
+
if (useSmart) {
|
|
179
|
+
var grid = getSampledCellTexts(element, columnCount, SMART_SAMPLE_ROWS);
|
|
180
|
+
var smart = getSmartColWidthsPx(grid, columnCount, containerWidth);
|
|
181
|
+
if (smart) return smart;
|
|
182
|
+
}
|
|
183
|
+
if (element === null || element === void 0 ? void 0 : (_element_children1 = element.children) === null || _element_children1 === void 0 ? void 0 : _element_children1.length) return pxToPercent(getContentBasedColWidthsPx(element, columnCount));
|
|
184
|
+
var pct = (100 / columnCount).toFixed(2);
|
|
185
|
+
return Array(columnCount).fill("".concat(pct, "%"));
|
|
186
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TableNode } from '../../../types/Table';
|
|
3
|
+
import type { ColWidthValue } from './getTableColWidths';
|
|
4
|
+
export interface UseReadonlyTableColWidthsParams {
|
|
5
|
+
columnCount: number;
|
|
6
|
+
otherProps?: {
|
|
7
|
+
colWidths?: ColWidthValue[];
|
|
8
|
+
} | null;
|
|
9
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
10
|
+
tableRef: React.RefObject<HTMLTableElement | null>;
|
|
11
|
+
element?: TableNode | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function useReadonlyTableColWidths({ columnCount, otherProps, containerRef, tableRef, element, }: UseReadonlyTableColWidthsParams): ColWidthValue[];
|
|
@@ -0,0 +1,96 @@
|
|
|
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, useMemo, useState } from "react";
|
|
48
|
+
import { TABLE_COL_WIDTH_MIN_COLUMNS } from "../../../../../Constants/mobile";
|
|
49
|
+
import { getReadonlyTableColWidths } from "./getTableColWidths";
|
|
50
|
+
export function useReadonlyTableColWidths(param) {
|
|
51
|
+
var columnCount = param.columnCount, otherProps = param.otherProps, containerRef = param.containerRef, tableRef = param.tableRef, element = param.element;
|
|
52
|
+
var _useState = _sliced_to_array(useState(false), 2), needsColWidths = _useState[0], setNeedsColWidths = _useState[1];
|
|
53
|
+
var _useState1 = _sliced_to_array(useState(0), 2), containerWidth = _useState1[0], setContainerWidth = _useState1[1];
|
|
54
|
+
var computed = useMemo(function() {
|
|
55
|
+
return getReadonlyTableColWidths({
|
|
56
|
+
columnCount: columnCount,
|
|
57
|
+
otherProps: otherProps,
|
|
58
|
+
element: element,
|
|
59
|
+
containerWidth: containerWidth || undefined
|
|
60
|
+
});
|
|
61
|
+
}, [
|
|
62
|
+
columnCount,
|
|
63
|
+
otherProps,
|
|
64
|
+
element,
|
|
65
|
+
containerWidth
|
|
66
|
+
]);
|
|
67
|
+
useEffect(function() {
|
|
68
|
+
var container = containerRef.current;
|
|
69
|
+
var table = tableRef.current;
|
|
70
|
+
if (!container || !table || columnCount === 0) return;
|
|
71
|
+
var check = function check() {
|
|
72
|
+
var cw = container.clientWidth;
|
|
73
|
+
setContainerWidth(cw);
|
|
74
|
+
setNeedsColWidths(cw === 0 || table.scrollWidth > cw);
|
|
75
|
+
};
|
|
76
|
+
var ro = new ResizeObserver(check);
|
|
77
|
+
ro.observe(container);
|
|
78
|
+
check();
|
|
79
|
+
return function() {
|
|
80
|
+
return ro.disconnect();
|
|
81
|
+
};
|
|
82
|
+
}, [
|
|
83
|
+
columnCount
|
|
84
|
+
]);
|
|
85
|
+
return useMemo(function() {
|
|
86
|
+
var _otherProps_colWidths;
|
|
87
|
+
if (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps_colWidths = otherProps.colWidths) === null || _otherProps_colWidths === void 0 ? void 0 : _otherProps_colWidths.length) return otherProps.colWidths;
|
|
88
|
+
if (columnCount >= TABLE_COL_WIDTH_MIN_COLUMNS) return computed;
|
|
89
|
+
return needsColWidths ? computed : [];
|
|
90
|
+
}, [
|
|
91
|
+
otherProps === null || otherProps === void 0 ? void 0 : otherProps.colWidths,
|
|
92
|
+
needsColWidths,
|
|
93
|
+
computed,
|
|
94
|
+
columnCount
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
@@ -255,6 +255,27 @@ var myRemark = {
|
|
|
255
255
|
var chartType = getChartType();
|
|
256
256
|
// 如果 chartType 为 "table",将其视为不存在,按普通表格处理
|
|
257
257
|
var isChart = chartType && chartType !== 'table';
|
|
258
|
+
// 图表的 x、y 必须在表格列中存在,否则降级为表格渲染
|
|
259
|
+
if (isChart && chartConfig) {
|
|
260
|
+
var columnKeys = new Set(columns.map(function(c) {
|
|
261
|
+
return c.dataIndex;
|
|
262
|
+
}));
|
|
263
|
+
var configsToValidate = Array.isArray(chartConfig) ? chartConfig : [
|
|
264
|
+
chartConfig
|
|
265
|
+
];
|
|
266
|
+
var isChartConfigValid = function isChartConfigValid(cfg) {
|
|
267
|
+
if (!cfg || cfg.chartType === 'table') return true;
|
|
268
|
+
if (cfg.x && !columnKeys.has(cfg.x)) return false;
|
|
269
|
+
if (cfg.y && !columnKeys.has(cfg.y)) return false;
|
|
270
|
+
return true;
|
|
271
|
+
};
|
|
272
|
+
var allConfigsValid = configsToValidate.every(function(c) {
|
|
273
|
+
return isChartConfigValid(c);
|
|
274
|
+
});
|
|
275
|
+
if (!allConfigsValid) {
|
|
276
|
+
isChart = false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
258
279
|
// 计算合并单元格信息
|
|
259
280
|
var mergeCells = (config === null || config === void 0 ? void 0 : config.mergeCells) || [];
|
|
260
281
|
// 创建合并单元格映射,用于快速查找
|
|
@@ -417,7 +417,8 @@ var genStyle = function genStyle(token) {
|
|
|
417
417
|
margin: '16px 0',
|
|
418
418
|
maxWidth: '100%'
|
|
419
419
|
}, _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-table"), {
|
|
420
|
-
width: '100%'
|
|
420
|
+
width: '100%',
|
|
421
|
+
minWidth: 'max-content'
|
|
421
422
|
}), _define_property(_obj1, "position", 'relative'), _define_property(_obj1, "fontVariant", 'tabular-nums'), _define_property(_obj1, "borderRadius", 'var(--table-border-radius)'), _define_property(_obj1, "border", '1px solid var(--table-border-color)'), _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-pure"), {
|
|
422
423
|
border: 'none',
|
|
423
424
|
borderRadius: 'none',
|
|
@@ -265,13 +265,15 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
265
265
|
pie: {
|
|
266
266
|
title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale.pieChart) || '饼图',
|
|
267
267
|
changeData: [
|
|
268
|
-
'donut'
|
|
268
|
+
'donut',
|
|
269
|
+
'table'
|
|
269
270
|
]
|
|
270
271
|
},
|
|
271
272
|
donut: {
|
|
272
273
|
title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale1 = i18n.locale) === null || _i18n_locale1 === void 0 ? void 0 : _i18n_locale1.donutChart) || '环形图',
|
|
273
274
|
changeData: [
|
|
274
|
-
'pie'
|
|
275
|
+
'pie',
|
|
276
|
+
'table'
|
|
275
277
|
]
|
|
276
278
|
},
|
|
277
279
|
bar: {
|
|
@@ -279,7 +281,8 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
279
281
|
changeData: [
|
|
280
282
|
'column',
|
|
281
283
|
'line',
|
|
282
|
-
'area'
|
|
284
|
+
'area',
|
|
285
|
+
'table'
|
|
283
286
|
]
|
|
284
287
|
},
|
|
285
288
|
line: {
|
|
@@ -287,7 +290,8 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
287
290
|
changeData: [
|
|
288
291
|
'column',
|
|
289
292
|
'bar',
|
|
290
|
-
'area'
|
|
293
|
+
'area',
|
|
294
|
+
'table'
|
|
291
295
|
]
|
|
292
296
|
},
|
|
293
297
|
column: {
|
|
@@ -295,7 +299,8 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
295
299
|
changeData: [
|
|
296
300
|
'bar',
|
|
297
301
|
'line',
|
|
298
|
-
'area'
|
|
302
|
+
'area',
|
|
303
|
+
'table'
|
|
299
304
|
]
|
|
300
305
|
},
|
|
301
306
|
area: {
|
|
@@ -303,20 +308,27 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
303
308
|
changeData: [
|
|
304
309
|
'column',
|
|
305
310
|
'bar',
|
|
306
|
-
'line'
|
|
311
|
+
'line',
|
|
312
|
+
'table'
|
|
307
313
|
]
|
|
308
314
|
},
|
|
309
315
|
radar: {
|
|
310
316
|
title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale6 = i18n.locale) === null || _i18n_locale6 === void 0 ? void 0 : _i18n_locale6.radarChart) || '雷达图',
|
|
311
|
-
changeData: [
|
|
317
|
+
changeData: [
|
|
318
|
+
'table'
|
|
319
|
+
]
|
|
312
320
|
},
|
|
313
321
|
scatter: {
|
|
314
322
|
title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale7 = i18n.locale) === null || _i18n_locale7 === void 0 ? void 0 : _i18n_locale7.scatterChart) || '散点图',
|
|
315
|
-
changeData: [
|
|
323
|
+
changeData: [
|
|
324
|
+
'table'
|
|
325
|
+
]
|
|
316
326
|
},
|
|
317
327
|
funnel: {
|
|
318
328
|
title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale8 = i18n.locale) === null || _i18n_locale8 === void 0 ? void 0 : _i18n_locale8.funnelChart) || '漏斗图',
|
|
319
|
-
changeData: [
|
|
329
|
+
changeData: [
|
|
330
|
+
'table'
|
|
331
|
+
]
|
|
320
332
|
},
|
|
321
333
|
table: {
|
|
322
334
|
title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale9 = i18n.locale) === null || _i18n_locale9 === void 0 ? void 0 : _i18n_locale9.table) || '表格',
|
|
@@ -325,7 +337,11 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
325
337
|
'line',
|
|
326
338
|
'area',
|
|
327
339
|
'pie',
|
|
328
|
-
'donut'
|
|
340
|
+
'donut',
|
|
341
|
+
'bar',
|
|
342
|
+
'radar',
|
|
343
|
+
'scatter',
|
|
344
|
+
'funnel'
|
|
329
345
|
]
|
|
330
346
|
},
|
|
331
347
|
descriptions: {
|
|
@@ -335,7 +351,8 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
335
351
|
'line',
|
|
336
352
|
'area',
|
|
337
353
|
'pie',
|
|
338
|
-
'donut'
|
|
354
|
+
'donut',
|
|
355
|
+
'table'
|
|
339
356
|
]
|
|
340
357
|
}
|
|
341
358
|
};
|
|
@@ -1054,7 +1071,34 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
1054
1071
|
flex: 1,
|
|
1055
1072
|
maxWidth: 'calc(100% - 32px)',
|
|
1056
1073
|
maxHeight: 400,
|
|
1057
|
-
userSelect: 'none'
|
|
1074
|
+
userSelect: 'none',
|
|
1075
|
+
display: 'flex',
|
|
1076
|
+
flexDirection: 'column'
|
|
1077
|
+
}
|
|
1078
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
1079
|
+
style: {
|
|
1080
|
+
display: 'flex',
|
|
1081
|
+
alignItems: 'center',
|
|
1082
|
+
gap: 8,
|
|
1083
|
+
padding: '8px 12px',
|
|
1084
|
+
borderBottom: '1px solid #eee',
|
|
1085
|
+
flexShrink: 0
|
|
1086
|
+
}
|
|
1087
|
+
}, title && /*#__PURE__*/ React.createElement("span", {
|
|
1088
|
+
style: {
|
|
1089
|
+
fontSize: 14,
|
|
1090
|
+
fontWeight: 500
|
|
1091
|
+
}
|
|
1092
|
+
}, title), /*#__PURE__*/ React.createElement("div", {
|
|
1093
|
+
style: {
|
|
1094
|
+
marginLeft: 'auto',
|
|
1095
|
+
display: 'flex',
|
|
1096
|
+
gap: 8
|
|
1097
|
+
}
|
|
1098
|
+
}, toolBar)), /*#__PURE__*/ React.createElement("div", {
|
|
1099
|
+
style: {
|
|
1100
|
+
flex: 1,
|
|
1101
|
+
overflow: 'auto'
|
|
1058
1102
|
}
|
|
1059
1103
|
}, /*#__PURE__*/ React.createElement(Table, {
|
|
1060
1104
|
size: "small",
|
|
@@ -1064,7 +1108,7 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
1064
1108
|
rowKey: function rowKey(record) {
|
|
1065
1109
|
return record.key;
|
|
1066
1110
|
}
|
|
1067
|
-
}));
|
|
1111
|
+
})));
|
|
1068
1112
|
}
|
|
1069
1113
|
if (chartType === 'descriptions' || renderDescriptionsFallback) {
|
|
1070
1114
|
return /*#__PURE__*/ React.createElement("div", {
|
|
@@ -1073,9 +1117,29 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
|
|
|
1073
1117
|
style: {
|
|
1074
1118
|
display: 'flex',
|
|
1075
1119
|
flexDirection: 'column',
|
|
1120
|
+
gap: 8,
|
|
1121
|
+
margin: 12
|
|
1122
|
+
}
|
|
1123
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
1124
|
+
style: {
|
|
1125
|
+
display: 'flex',
|
|
1126
|
+
alignItems: 'center',
|
|
1127
|
+
gap: 8,
|
|
1128
|
+
padding: '8px 0',
|
|
1129
|
+
flexShrink: 0
|
|
1130
|
+
}
|
|
1131
|
+
}, title && /*#__PURE__*/ React.createElement("span", {
|
|
1132
|
+
style: {
|
|
1133
|
+
fontSize: 14,
|
|
1134
|
+
fontWeight: 500
|
|
1135
|
+
}
|
|
1136
|
+
}, title), /*#__PURE__*/ React.createElement("div", {
|
|
1137
|
+
style: {
|
|
1138
|
+
marginLeft: 'auto',
|
|
1139
|
+
display: 'flex',
|
|
1076
1140
|
gap: 8
|
|
1077
1141
|
}
|
|
1078
|
-
}, chartData.map(function(row, rowIndex) {
|
|
1142
|
+
}, toolBar)), chartData.map(function(row, rowIndex) {
|
|
1079
1143
|
var _config_columns;
|
|
1080
1144
|
return /*#__PURE__*/ React.createElement(Descriptions, {
|
|
1081
1145
|
bordered: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ant-design/agentic-ui",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.49",
|
|
4
4
|
"description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
|
|
5
5
|
"repository": "git@github.com:ant-design/agentic-ui.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
|
|
25
25
|
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
|
26
26
|
"prepare": "husky install && dumi setup",
|
|
27
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
27
28
|
"prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
|
|
28
29
|
"preview": "pnpm dumi preview",
|
|
29
30
|
"report:demo": "node scripts/generateDemoReport.js",
|