@ant-design/agentic-ui 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MarkdownEditor/editor/elements/Code.js +11 -6
- package/dist/MarkdownEditor/editor/elements/Image/index.js +17 -5
- package/dist/MarkdownEditor/editor/elements/Media.js +61 -9
- package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +15 -3
- package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +17 -2
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +131 -5
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +100 -1
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +945 -284
- package/dist/MarkdownEditor/editor/style.js +5 -0
- package/dist/MarkdownEditor/editor/types/Table.d.ts +1 -0
- package/dist/MarkdownEditor/editor/utils/findMatchingClose.d.ts +36 -0
- package/dist/MarkdownEditor/editor/utils/findMatchingClose.js +158 -0
- package/dist/MarkdownEditor/editor/utils/markdownToHtml.d.ts +41 -2
- package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +159 -7
- package/dist/Plugins/chart/AreaChart/index.d.ts +12 -0
- package/dist/Plugins/chart/AreaChart/index.js +14 -188
- package/dist/Plugins/chart/BarChart/index.d.ts +2 -0
- package/dist/Plugins/chart/BarChart/index.js +3 -12
- package/dist/Plugins/chart/ChartMark/Container.js +5 -2
- package/dist/Plugins/chart/ChartRender.d.ts +1 -0
- package/dist/Plugins/chart/ChartRender.js +104 -43
- package/dist/Plugins/chart/DonutChart/index.js +4 -2
- package/dist/Plugins/chart/DonutChart/types.d.ts +2 -0
- package/dist/Plugins/chart/FunnelChart/index.d.ts +2 -0
- package/dist/Plugins/chart/FunnelChart/index.js +4 -2
- package/dist/Plugins/chart/LineChart/index.d.ts +2 -0
- package/dist/Plugins/chart/LineChart/index.js +17 -162
- package/dist/Plugins/chart/RadarChart/index.d.ts +2 -0
- package/dist/Plugins/chart/RadarChart/index.js +8 -4
- package/dist/Plugins/chart/ScatterChart/index.d.ts +2 -0
- package/dist/Plugins/chart/ScatterChart/index.js +8 -4
- package/dist/Plugins/chart/components/ChartContainer/ChartContainer.d.ts +1 -0
- package/dist/Plugins/chart/components/ChartFilter/ChartFilter.d.ts +1 -1
- package/dist/Plugins/chart/components/ChartFilter/ChartFilter.js +210 -16
- package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.d.ts +2 -0
- package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +9 -2
- package/dist/Plugins/chart/components/ChartToolBar/style.js +3 -1
- package/dist/Plugins/chart/hooks/index.d.ts +10 -0
- package/dist/Plugins/chart/hooks/index.js +8 -0
- package/dist/Plugins/chart/hooks/useChartDataFilter.d.ts +46 -0
- package/dist/Plugins/chart/hooks/useChartDataFilter.js +182 -0
- package/dist/Plugins/chart/hooks/useChartStatistics.d.ts +17 -0
- package/dist/Plugins/chart/hooks/useChartStatistics.js +25 -0
- package/dist/Plugins/chart/hooks/useChartTheme.d.ts +20 -0
- package/dist/Plugins/chart/hooks/useChartTheme.js +30 -0
- package/dist/Plugins/chart/hooks/useResponsiveSize.d.ts +23 -0
- package/dist/Plugins/chart/hooks/useResponsiveSize.js +94 -0
- package/dist/Plugins/chart/index.js +92 -8
- package/dist/Plugins/chart/utils/registerChart.d.ts +35 -0
- package/dist/Plugins/chart/utils/registerChart.js +54 -0
- package/dist/Plugins/chart/utils.d.ts +19 -0
- package/dist/Plugins/chart/utils.js +27 -0
- package/dist/Plugins/code/components/CodeRenderer.js +53 -2
- package/dist/Plugins/code/components/CodeToolbar.js +22 -3
- package/dist/Plugins/mermaid/Mermaid.js +66 -66
- package/package.json +1 -1
|
@@ -3,9 +3,6 @@ function _array_like_to_array(arr, len) {
|
|
|
3
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
4
|
return arr2;
|
|
5
5
|
}
|
|
6
|
-
function _array_with_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return arr;
|
|
8
|
-
}
|
|
9
6
|
function _array_without_holes(arr) {
|
|
10
7
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
8
|
}
|
|
@@ -25,33 +22,6 @@ function _define_property(obj, key, value) {
|
|
|
25
22
|
function _iterable_to_array(iter) {
|
|
26
23
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
27
24
|
}
|
|
28
|
-
function _iterable_to_array_limit(arr, i) {
|
|
29
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
30
|
-
if (_i == null) return;
|
|
31
|
-
var _arr = [];
|
|
32
|
-
var _n = true;
|
|
33
|
-
var _d = false;
|
|
34
|
-
var _s, _e;
|
|
35
|
-
try {
|
|
36
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
37
|
-
_arr.push(_s.value);
|
|
38
|
-
if (i && _arr.length === i) break;
|
|
39
|
-
}
|
|
40
|
-
} catch (err) {
|
|
41
|
-
_d = true;
|
|
42
|
-
_e = err;
|
|
43
|
-
} finally{
|
|
44
|
-
try {
|
|
45
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
46
|
-
} finally{
|
|
47
|
-
if (_d) throw _e;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return _arr;
|
|
51
|
-
}
|
|
52
|
-
function _non_iterable_rest() {
|
|
53
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
54
|
-
}
|
|
55
25
|
function _non_iterable_spread() {
|
|
56
26
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
57
27
|
}
|
|
@@ -121,9 +91,6 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
121
91
|
}
|
|
122
92
|
return target;
|
|
123
93
|
}
|
|
124
|
-
function _sliced_to_array(arr, i) {
|
|
125
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
126
|
-
}
|
|
127
94
|
function _to_consumable_array(arr) {
|
|
128
95
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
129
96
|
}
|
|
@@ -136,17 +103,16 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
136
103
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
137
104
|
}
|
|
138
105
|
import { ConfigProvider } from "antd";
|
|
139
|
-
import { CategoryScale, Chart as ChartJS, Filler, Legend, LinearScale, LineElement, PointElement, Tooltip } from "chart.js";
|
|
140
106
|
import classNames from "classnames";
|
|
141
|
-
import React, { useContext,
|
|
107
|
+
import React, { useContext, useMemo, useRef } from "react";
|
|
142
108
|
import { Line } from "react-chartjs-2";
|
|
143
109
|
import { ChartContainer, ChartFilter, ChartStatistic, ChartToolBar, downloadChart } from "../components";
|
|
144
110
|
import { defaultColorList } from "../const";
|
|
145
|
-
import {
|
|
111
|
+
import { useChartDataFilter, useChartStatistics, useChartTheme, useResponsiveSize } from "../hooks";
|
|
112
|
+
import { extractAndSortXValues, findDataPointByXValue, registerLineChartComponents } from "../utils";
|
|
146
113
|
import { useStyle } from "./style";
|
|
147
|
-
var lineChartComponentsRegistered = false;
|
|
148
114
|
var LineChart = function(_param) {
|
|
149
|
-
var title = _param.title, data = _param.data, _param_width = _param.width, width = _param_width === void 0 ? 600 : _param_width, _param_height = _param.height, height = _param_height === void 0 ? 400 : _param_height, className = _param.className, dataTime = _param.dataTime, _param_theme = _param.theme, theme = _param_theme === void 0 ? 'light' : _param_theme, color = _param.color, _param_showLegend = _param.showLegend, showLegend = _param_showLegend === void 0 ? true : _param_showLegend, _param_legendPosition = _param.legendPosition, legendPosition = _param_legendPosition === void 0 ? 'bottom' : _param_legendPosition, _param_legendAlign = _param.legendAlign, legendAlign = _param_legendAlign === void 0 ? 'start' : _param_legendAlign, _param_showGrid = _param.showGrid, showGrid = _param_showGrid === void 0 ? true : _param_showGrid, _param_xPosition = _param.xPosition, xPosition = _param_xPosition === void 0 ? 'bottom' : _param_xPosition, _param_yPosition = _param.yPosition, yPosition = _param_yPosition === void 0 ? 'left' : _param_yPosition, _param_hiddenX = _param.hiddenX, hiddenX = _param_hiddenX === void 0 ? false : _param_hiddenX, _param_hiddenY = _param.hiddenY, hiddenY = _param_hiddenY === void 0 ? false : _param_hiddenY, toolbarExtra = _param.toolbarExtra, _param_renderFilterInToolbar = _param.renderFilterInToolbar, renderFilterInToolbar = _param_renderFilterInToolbar === void 0 ? false : _param_renderFilterInToolbar, statisticConfig = _param.statistic, props = _object_without_properties(_param, [
|
|
115
|
+
var title = _param.title, data = _param.data, _param_width = _param.width, width = _param_width === void 0 ? 600 : _param_width, _param_height = _param.height, height = _param_height === void 0 ? 400 : _param_height, className = _param.className, dataTime = _param.dataTime, _param_theme = _param.theme, theme = _param_theme === void 0 ? 'light' : _param_theme, color = _param.color, _param_showLegend = _param.showLegend, showLegend = _param_showLegend === void 0 ? true : _param_showLegend, _param_legendPosition = _param.legendPosition, legendPosition = _param_legendPosition === void 0 ? 'bottom' : _param_legendPosition, _param_legendAlign = _param.legendAlign, legendAlign = _param_legendAlign === void 0 ? 'start' : _param_legendAlign, _param_showGrid = _param.showGrid, showGrid = _param_showGrid === void 0 ? true : _param_showGrid, _param_xPosition = _param.xPosition, xPosition = _param_xPosition === void 0 ? 'bottom' : _param_xPosition, _param_yPosition = _param.yPosition, yPosition = _param_yPosition === void 0 ? 'left' : _param_yPosition, _param_hiddenX = _param.hiddenX, hiddenX = _param_hiddenX === void 0 ? false : _param_hiddenX, _param_hiddenY = _param.hiddenY, hiddenY = _param_hiddenY === void 0 ? false : _param_hiddenY, toolbarExtra = _param.toolbarExtra, _param_renderFilterInToolbar = _param.renderFilterInToolbar, renderFilterInToolbar = _param_renderFilterInToolbar === void 0 ? false : _param_renderFilterInToolbar, statisticConfig = _param.statistic, _param_loading = _param.loading, loading = _param_loading === void 0 ? false : _param_loading, props = _object_without_properties(_param, [
|
|
150
116
|
"title",
|
|
151
117
|
"data",
|
|
152
118
|
"width",
|
|
@@ -165,111 +131,24 @@ var LineChart = function(_param) {
|
|
|
165
131
|
"hiddenY",
|
|
166
132
|
"toolbarExtra",
|
|
167
133
|
"renderFilterInToolbar",
|
|
168
|
-
"statistic"
|
|
169
|
-
|
|
170
|
-
useMemo(function() {
|
|
171
|
-
if (lineChartComponentsRegistered) {
|
|
172
|
-
return undefined;
|
|
173
|
-
}
|
|
174
|
-
if (typeof window === 'undefined') {
|
|
175
|
-
return undefined;
|
|
176
|
-
}
|
|
177
|
-
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Filler, Tooltip, Legend);
|
|
178
|
-
lineChartComponentsRegistered = true;
|
|
179
|
-
return undefined;
|
|
180
|
-
}, []);
|
|
181
|
-
var safeData = Array.isArray(data) ? data : [];
|
|
182
|
-
// 使用数据哈希来优化依赖项比较
|
|
183
|
-
var dataHash = useMemo(function() {
|
|
184
|
-
return getDataHash(safeData);
|
|
185
|
-
}, [
|
|
186
|
-
safeData
|
|
134
|
+
"statistic",
|
|
135
|
+
"loading"
|
|
187
136
|
]);
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var responsiveWidth =
|
|
192
|
-
var responsiveHeight = isMobile ? Math.min(windowWidth * 0.8, 400) : height;
|
|
193
|
-
// 监听窗口大小变化
|
|
194
|
-
useEffect(function() {
|
|
195
|
-
var handleResize = function() {
|
|
196
|
-
setWindowWidth(window.innerWidth);
|
|
197
|
-
};
|
|
198
|
-
if (typeof window !== 'undefined') {
|
|
199
|
-
window.addEventListener('resize', handleResize);
|
|
200
|
-
return function() {
|
|
201
|
-
return window.removeEventListener('resize', handleResize);
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
}, []);
|
|
137
|
+
// 注册 Chart.js 组件
|
|
138
|
+
registerLineChartComponents();
|
|
139
|
+
// 响应式尺寸
|
|
140
|
+
var _useResponsiveSize = useResponsiveSize(width, height), responsiveWidth = _useResponsiveSize.responsiveWidth, responsiveHeight = _useResponsiveSize.responsiveHeight, isMobile = _useResponsiveSize.isMobile;
|
|
205
141
|
// 样式注册
|
|
206
142
|
var context = useContext(ConfigProvider.ConfigContext);
|
|
207
143
|
var baseClassName = context === null || context === void 0 ? void 0 : context.getPrefixCls('line-chart-container');
|
|
208
144
|
var _useStyle = useStyle(baseClassName), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
|
|
209
145
|
var chartRef = useRef(null);
|
|
210
146
|
// 处理 ChartStatistic 组件配置
|
|
211
|
-
var statistics =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}, [
|
|
217
|
-
statisticConfig
|
|
218
|
-
]);
|
|
219
|
-
// 从数据中提取唯一的类别作为筛选选项
|
|
220
|
-
var categories = useMemo(function() {
|
|
221
|
-
var uniqueCategories = _to_consumable_array(new Set(safeData.map(function(item) {
|
|
222
|
-
return item.category;
|
|
223
|
-
}))).filter(Boolean);
|
|
224
|
-
return uniqueCategories;
|
|
225
|
-
}, [
|
|
226
|
-
dataHash
|
|
227
|
-
]);
|
|
228
|
-
// 从数据中提取 filterLabel,过滤掉 undefined 值
|
|
229
|
-
var validFilterLabels = useMemo(function() {
|
|
230
|
-
return safeData.map(function(item) {
|
|
231
|
-
return item.filterLabel;
|
|
232
|
-
}).filter(function(filterLabel) {
|
|
233
|
-
return filterLabel !== undefined;
|
|
234
|
-
});
|
|
235
|
-
}, [
|
|
236
|
-
dataHash
|
|
237
|
-
]);
|
|
238
|
-
var filterLabels = useMemo(function() {
|
|
239
|
-
return validFilterLabels.length > 0 ? _to_consumable_array(new Set(validFilterLabels)) : undefined;
|
|
240
|
-
}, [
|
|
241
|
-
validFilterLabels
|
|
242
|
-
]);
|
|
243
|
-
// 状态管理
|
|
244
|
-
var _useState1 = _sliced_to_array(useState(categories.find(Boolean) || ''), 2), selectedFilter = _useState1[0], setSelectedFilter = _useState1[1];
|
|
245
|
-
var _useState2 = _sliced_to_array(useState(filterLabels && filterLabels.length > 0 ? filterLabels[0] : undefined), 2), selectedFilterLabel = _useState2[0], setSelectedFilterLabel = _useState2[1];
|
|
246
|
-
// 当数据变化导致当前选中分类失效时,自动回退到首个有效分类或空(显示全部)
|
|
247
|
-
useEffect(function() {
|
|
248
|
-
if (selectedFilter && !categories.includes(selectedFilter)) {
|
|
249
|
-
setSelectedFilter(categories.find(Boolean) || '');
|
|
250
|
-
}
|
|
251
|
-
}, [
|
|
252
|
-
categories,
|
|
253
|
-
selectedFilter
|
|
254
|
-
]);
|
|
255
|
-
// 筛选数据
|
|
256
|
-
var filteredData = useMemo(function() {
|
|
257
|
-
var base = selectedFilter ? safeData.filter(function(item) {
|
|
258
|
-
return item.category === selectedFilter;
|
|
259
|
-
}) : safeData;
|
|
260
|
-
var withFilterLabel = !filterLabels || !selectedFilterLabel ? base : base.filter(function(item) {
|
|
261
|
-
return item.filterLabel === selectedFilterLabel;
|
|
262
|
-
});
|
|
263
|
-
// 统一过滤掉 x 为空(null/undefined)的数据,避免后续 toString 报错
|
|
264
|
-
return withFilterLabel.filter(function(item) {
|
|
265
|
-
return item.x !== null && item.x !== undefined;
|
|
266
|
-
});
|
|
267
|
-
}, [
|
|
268
|
-
dataHash,
|
|
269
|
-
selectedFilter,
|
|
270
|
-
filterLabels,
|
|
271
|
-
selectedFilterLabel
|
|
272
|
-
]);
|
|
147
|
+
var statistics = useChartStatistics(statisticConfig);
|
|
148
|
+
// 数据筛选
|
|
149
|
+
var _useChartDataFilter = useChartDataFilter(data), filteredData = _useChartDataFilter.filteredData, filterOptions = _useChartDataFilter.filterOptions, filterLabels = _useChartDataFilter.filterLabels, selectedFilter = _useChartDataFilter.selectedFilter, setSelectedFilter = _useChartDataFilter.setSelectedFilter, selectedFilterLabel = _useChartDataFilter.selectedFilterLabel, setSelectedFilterLabel = _useChartDataFilter.setSelectedFilterLabel, filteredDataByFilterLabel = _useChartDataFilter.filteredDataByFilterLabel;
|
|
150
|
+
// 主题颜色
|
|
151
|
+
var _useChartTheme = useChartTheme(theme), axisTextColor = _useChartTheme.axisTextColor, gridColor = _useChartTheme.gridColor, isLight = _useChartTheme.isLight;
|
|
273
152
|
// 从数据中提取唯一的类型
|
|
274
153
|
var types = useMemo(function() {
|
|
275
154
|
return _to_consumable_array(new Set(filteredData.map(function(item) {
|
|
@@ -338,31 +217,6 @@ var LineChart = function(_param) {
|
|
|
338
217
|
types,
|
|
339
218
|
xValues
|
|
340
219
|
]);
|
|
341
|
-
// 筛选器选项
|
|
342
|
-
var filterOptions = useMemo(function() {
|
|
343
|
-
return categories.map(function(category) {
|
|
344
|
-
return {
|
|
345
|
-
label: category || '默认',
|
|
346
|
-
value: category || '默认'
|
|
347
|
-
};
|
|
348
|
-
});
|
|
349
|
-
}, [
|
|
350
|
-
categories
|
|
351
|
-
]);
|
|
352
|
-
// 根据 filterLabel 筛选数据 - 只有当 filterLabels 存在时才生成
|
|
353
|
-
var filteredDataByFilterLabel = useMemo(function() {
|
|
354
|
-
return filterLabels === null || filterLabels === void 0 ? void 0 : filterLabels.map(function(item) {
|
|
355
|
-
return {
|
|
356
|
-
key: item,
|
|
357
|
-
label: item
|
|
358
|
-
};
|
|
359
|
-
});
|
|
360
|
-
}, [
|
|
361
|
-
filterLabels
|
|
362
|
-
]);
|
|
363
|
-
var isLight = theme === 'light';
|
|
364
|
-
var axisTextColor = isLight ? 'rgba(0, 25, 61, 0.3255)' : 'rgba(255, 255, 255, 0.8)';
|
|
365
|
-
var gridColor = isLight ? 'rgba(0,0,0,0.08)' : 'rgba(255,255,255,0.2)';
|
|
366
220
|
var options = {
|
|
367
221
|
responsive: true,
|
|
368
222
|
maintainAspectRatio: false,
|
|
@@ -500,6 +354,7 @@ var LineChart = function(_param) {
|
|
|
500
354
|
onDownload: handleDownload,
|
|
501
355
|
extra: toolbarExtra,
|
|
502
356
|
dataTime: dataTime,
|
|
357
|
+
loading: loading,
|
|
503
358
|
filter: renderFilterInToolbar && filterOptions && filterOptions.length > 1 ? /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
|
|
504
359
|
filterOptions: filterOptions,
|
|
505
360
|
selectedFilter: selectedFilter,
|
|
@@ -520,7 +375,7 @@ var LineChart = function(_param) {
|
|
|
520
375
|
}, config), {
|
|
521
376
|
theme: theme
|
|
522
377
|
}));
|
|
523
|
-
})),
|
|
378
|
+
})), /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
|
|
524
379
|
filterOptions: filterOptions,
|
|
525
380
|
selectedFilter: selectedFilter,
|
|
526
381
|
onFilterChange: setSelectedFilter
|
|
@@ -40,6 +40,8 @@ interface RadarChartProps extends ChartContainerProps {
|
|
|
40
40
|
statistic?: StatisticConfigType;
|
|
41
41
|
/** 图例文字最大宽度(像素),超出则显示省略号,默认80px */
|
|
42
42
|
textMaxWidth?: number;
|
|
43
|
+
/** 是否显示加载状态(当图表未闭合时显示) */
|
|
44
|
+
loading?: boolean;
|
|
43
45
|
}
|
|
44
46
|
declare const RadarChart: React.FC<RadarChartProps>;
|
|
45
47
|
export default RadarChart;
|
|
@@ -138,7 +138,7 @@ import { defaultColorList } from "../const";
|
|
|
138
138
|
import { useStyle } from "./style";
|
|
139
139
|
var radarChartComponentsRegistered = false;
|
|
140
140
|
var RadarChart = function(_param) {
|
|
141
|
-
var data = _param.data, title = _param.title, _param_width = _param.width, width = _param_width === void 0 ? 600 : _param_width, _param_height = _param.height, height = _param_height === void 0 ? 400 : _param_height, className = _param.className, toolbarExtra = _param.toolbarExtra, _param_renderFilterInToolbar = _param.renderFilterInToolbar, renderFilterInToolbar = _param_renderFilterInToolbar === void 0 ? false : _param_renderFilterInToolbar, dataTime = _param.dataTime, color = _param.color, statisticConfig = _param.statistic, _param_textMaxWidth = _param.textMaxWidth, textMaxWidth = _param_textMaxWidth === void 0 ? 80 : _param_textMaxWidth, props = _object_without_properties(_param, [
|
|
141
|
+
var data = _param.data, title = _param.title, _param_width = _param.width, width = _param_width === void 0 ? 600 : _param_width, _param_height = _param.height, height = _param_height === void 0 ? 400 : _param_height, className = _param.className, toolbarExtra = _param.toolbarExtra, _param_renderFilterInToolbar = _param.renderFilterInToolbar, renderFilterInToolbar = _param_renderFilterInToolbar === void 0 ? false : _param_renderFilterInToolbar, dataTime = _param.dataTime, color = _param.color, statisticConfig = _param.statistic, _param_textMaxWidth = _param.textMaxWidth, textMaxWidth = _param_textMaxWidth === void 0 ? 80 : _param_textMaxWidth, _param_loading = _param.loading, loading = _param_loading === void 0 ? false : _param_loading, props = _object_without_properties(_param, [
|
|
142
142
|
"data",
|
|
143
143
|
"title",
|
|
144
144
|
"width",
|
|
@@ -149,7 +149,8 @@ var RadarChart = function(_param) {
|
|
|
149
149
|
"dataTime",
|
|
150
150
|
"color",
|
|
151
151
|
"statistic",
|
|
152
|
-
"textMaxWidth"
|
|
152
|
+
"textMaxWidth",
|
|
153
|
+
"loading"
|
|
153
154
|
]);
|
|
154
155
|
useMemo(function() {
|
|
155
156
|
if (radarChartComponentsRegistered) {
|
|
@@ -267,7 +268,8 @@ var RadarChart = function(_param) {
|
|
|
267
268
|
title: title || '雷达图',
|
|
268
269
|
onDownload: function() {},
|
|
269
270
|
extra: toolbarExtra,
|
|
270
|
-
dataTime: dataTime
|
|
271
|
+
dataTime: dataTime,
|
|
272
|
+
loading: loading
|
|
271
273
|
}), /*#__PURE__*/ React.createElement("div", {
|
|
272
274
|
className: classNames("".concat(prefixCls, "-empty-wrapper"), hashId),
|
|
273
275
|
style: {
|
|
@@ -551,6 +553,7 @@ var RadarChart = function(_param) {
|
|
|
551
553
|
onDownload: handleDownload,
|
|
552
554
|
extra: toolbarExtra,
|
|
553
555
|
dataTime: dataTime,
|
|
556
|
+
loading: loading,
|
|
554
557
|
filter: renderFilterInToolbar && filterEnum.length > 0 ? /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
|
|
555
558
|
filterOptions: filterEnum,
|
|
556
559
|
selectedFilter: selectedFilter,
|
|
@@ -604,7 +607,8 @@ var RadarChart = function(_param) {
|
|
|
604
607
|
title: title || '雷达图',
|
|
605
608
|
onDownload: function() {},
|
|
606
609
|
extra: toolbarExtra,
|
|
607
|
-
dataTime: dataTime
|
|
610
|
+
dataTime: dataTime,
|
|
611
|
+
loading: loading
|
|
608
612
|
}), /*#__PURE__*/ React.createElement("div", {
|
|
609
613
|
className: classNames("".concat(prefixCls, "-error-wrapper"), hashId),
|
|
610
614
|
style: {
|
|
@@ -49,6 +49,8 @@ export interface ScatterChartProps extends ChartContainerProps {
|
|
|
49
49
|
statistic?: StatisticConfigType;
|
|
50
50
|
/** 图例文字最大宽度(像素),超出则显示省略号,默认80px */
|
|
51
51
|
textMaxWidth?: number;
|
|
52
|
+
/** 是否显示加载状态(当图表未闭合时显示) */
|
|
53
|
+
loading?: boolean;
|
|
52
54
|
}
|
|
53
55
|
declare const ScatterChart: React.FC<ScatterChartProps>;
|
|
54
56
|
export default ScatterChart;
|
|
@@ -138,7 +138,7 @@ import { defaultColorList } from "../const";
|
|
|
138
138
|
import { useStyle } from "./style";
|
|
139
139
|
var scatterChartComponentsRegistered = false;
|
|
140
140
|
var ScatterChart = function(_param) {
|
|
141
|
-
var data = _param.data, _param_width = _param.width, width = _param_width === void 0 ? 600 : _param_width, _param_height = _param.height, height = _param_height === void 0 ? 400 : _param_height, className = _param.className, title = _param.title, toolbarExtra = _param.toolbarExtra, _param_renderFilterInToolbar = _param.renderFilterInToolbar, renderFilterInToolbar = _param_renderFilterInToolbar === void 0 ? false : _param_renderFilterInToolbar, dataTime = _param.dataTime, _param_xUnit = _param.xUnit, xUnit = _param_xUnit === void 0 ? '月' : _param_xUnit, yUnit = _param.yUnit, xAxisLabel = _param.xAxisLabel, yAxisLabel = _param.yAxisLabel, _param_xPosition = _param.xPosition, xPosition = _param_xPosition === void 0 ? 'bottom' : _param_xPosition, _param_yPosition = _param.yPosition, yPosition = _param_yPosition === void 0 ? 'left' : _param_yPosition, _param_hiddenX = _param.hiddenX, hiddenX = _param_hiddenX === void 0 ? false : _param_hiddenX, _param_hiddenY = _param.hiddenY, hiddenY = _param_hiddenY === void 0 ? false : _param_hiddenY, _param_showGrid = _param.showGrid, showGrid = _param_showGrid === void 0 ? true : _param_showGrid, color = _param.color, statisticConfig = _param.statistic, _param_textMaxWidth = _param.textMaxWidth, textMaxWidth = _param_textMaxWidth === void 0 ? 80 : _param_textMaxWidth, props = _object_without_properties(_param, [
|
|
141
|
+
var data = _param.data, _param_width = _param.width, width = _param_width === void 0 ? 600 : _param_width, _param_height = _param.height, height = _param_height === void 0 ? 400 : _param_height, className = _param.className, title = _param.title, toolbarExtra = _param.toolbarExtra, _param_renderFilterInToolbar = _param.renderFilterInToolbar, renderFilterInToolbar = _param_renderFilterInToolbar === void 0 ? false : _param_renderFilterInToolbar, dataTime = _param.dataTime, _param_xUnit = _param.xUnit, xUnit = _param_xUnit === void 0 ? '月' : _param_xUnit, yUnit = _param.yUnit, xAxisLabel = _param.xAxisLabel, yAxisLabel = _param.yAxisLabel, _param_xPosition = _param.xPosition, xPosition = _param_xPosition === void 0 ? 'bottom' : _param_xPosition, _param_yPosition = _param.yPosition, yPosition = _param_yPosition === void 0 ? 'left' : _param_yPosition, _param_hiddenX = _param.hiddenX, hiddenX = _param_hiddenX === void 0 ? false : _param_hiddenX, _param_hiddenY = _param.hiddenY, hiddenY = _param_hiddenY === void 0 ? false : _param_hiddenY, _param_showGrid = _param.showGrid, showGrid = _param_showGrid === void 0 ? true : _param_showGrid, color = _param.color, statisticConfig = _param.statistic, _param_textMaxWidth = _param.textMaxWidth, textMaxWidth = _param_textMaxWidth === void 0 ? 80 : _param_textMaxWidth, _param_loading = _param.loading, loading = _param_loading === void 0 ? false : _param_loading, props = _object_without_properties(_param, [
|
|
142
142
|
"data",
|
|
143
143
|
"width",
|
|
144
144
|
"height",
|
|
@@ -158,7 +158,8 @@ var ScatterChart = function(_param) {
|
|
|
158
158
|
"showGrid",
|
|
159
159
|
"color",
|
|
160
160
|
"statistic",
|
|
161
|
-
"textMaxWidth"
|
|
161
|
+
"textMaxWidth",
|
|
162
|
+
"loading"
|
|
162
163
|
]);
|
|
163
164
|
useMemo(function() {
|
|
164
165
|
if (scatterChartComponentsRegistered) {
|
|
@@ -271,7 +272,8 @@ var ScatterChart = function(_param) {
|
|
|
271
272
|
title: title || '散点图',
|
|
272
273
|
onDownload: function() {},
|
|
273
274
|
extra: toolbarExtra,
|
|
274
|
-
dataTime: dataTime
|
|
275
|
+
dataTime: dataTime,
|
|
276
|
+
loading: loading
|
|
275
277
|
}), /*#__PURE__*/ React.createElement("div", {
|
|
276
278
|
className: classNames("".concat(prefixCls, "-empty-wrapper"), hashId),
|
|
277
279
|
style: {
|
|
@@ -602,6 +604,7 @@ var ScatterChart = function(_param) {
|
|
|
602
604
|
onDownload: handleDownload,
|
|
603
605
|
extra: toolbarExtra,
|
|
604
606
|
dataTime: dataTime,
|
|
607
|
+
loading: loading,
|
|
605
608
|
filter: renderFilterInToolbar && filterEnum.length > 0 ? /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
|
|
606
609
|
filterOptions: filterEnum,
|
|
607
610
|
selectedFilter: selectedFilter,
|
|
@@ -658,7 +661,8 @@ var ScatterChart = function(_param) {
|
|
|
658
661
|
title: title || '散点图',
|
|
659
662
|
onDownload: function() {},
|
|
660
663
|
extra: toolbarExtra,
|
|
661
|
-
dataTime: dataTime
|
|
664
|
+
dataTime: dataTime,
|
|
665
|
+
loading: loading
|
|
662
666
|
}), /*#__PURE__*/ React.createElement("div", {
|
|
663
667
|
className: classNames("".concat(prefixCls, "-error-wrapper"), hashId),
|
|
664
668
|
style: {
|
|
@@ -18,5 +18,5 @@ export interface ChartFilterProps {
|
|
|
18
18
|
theme?: 'light' | 'dark';
|
|
19
19
|
variant?: 'default' | 'compact';
|
|
20
20
|
}
|
|
21
|
-
declare const ChartFilter: React.
|
|
21
|
+
declare const ChartFilter: React.NamedExoticComponent<ChartFilterProps>;
|
|
22
22
|
export default ChartFilter;
|
|
@@ -1,36 +1,228 @@
|
|
|
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
|
+
}
|
|
1
47
|
import { ChevronDown } from "@sofa-design/icons";
|
|
2
48
|
import { Button, ConfigProvider, Dropdown, Segmented } from "antd";
|
|
3
49
|
import classNames from "classnames";
|
|
4
|
-
import React, { useContext } from "react";
|
|
50
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
51
|
import { I18nContext } from "../../../../I18n";
|
|
52
|
+
import { debounce } from "../../utils";
|
|
6
53
|
import { useStyle } from "./style";
|
|
7
|
-
|
|
54
|
+
/**
|
|
55
|
+
* 比较两个数组是否相等(浅比较)
|
|
56
|
+
*/ var areArraysEqual = function(a, b) {
|
|
57
|
+
if (a === b) return true;
|
|
58
|
+
if (!a || !b) return false;
|
|
59
|
+
if (a.length !== b.length) return false;
|
|
60
|
+
return a.every(function(item, index) {
|
|
61
|
+
var other = b[index];
|
|
62
|
+
if (!other) return false;
|
|
63
|
+
// 比较所有属性
|
|
64
|
+
return Object.keys(item).every(function(key) {
|
|
65
|
+
return item[key] === other[key];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* ChartFilter 组件的 props 比较函数
|
|
71
|
+
* 用于 React.memo 优化,只在真正需要时重新渲染
|
|
72
|
+
*
|
|
73
|
+
* 注意:由于组件内部使用 ref 保存上一次有效的 filterOptions,
|
|
74
|
+
* 即使 filterOptions 暂时为空也不会导致组件消失。
|
|
75
|
+
* 因此比较时,如果当前值为空但之前有值,我们仍然认为它们"相等"(使用稳定值)。
|
|
76
|
+
*/ var arePropsEqual = function(prevProps, nextProps) {
|
|
77
|
+
// 比较基本属性
|
|
78
|
+
if (prevProps.selectedFilter !== nextProps.selectedFilter || prevProps.selectedCustomSelection !== nextProps.selectedCustomSelection || prevProps.className !== nextProps.className || prevProps.theme !== nextProps.theme || prevProps.variant !== nextProps.variant) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
// 比较数组属性(filterOptions 和 customOptions)
|
|
82
|
+
// 如果两个都是空或都有效,比较内容
|
|
83
|
+
// 如果一个为空一个有效,认为不相等(需要更新稳定值)
|
|
84
|
+
var prevFilterValid = prevProps.filterOptions && prevProps.filterOptions.length > 1;
|
|
85
|
+
var nextFilterValid = nextProps.filterOptions && nextProps.filterOptions.length > 1;
|
|
86
|
+
// 如果两个都有效,比较内容
|
|
87
|
+
if (prevFilterValid && nextFilterValid) {
|
|
88
|
+
if (!areArraysEqual(prevProps.filterOptions, nextProps.filterOptions)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
} else if (prevFilterValid !== nextFilterValid) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
// 如果两个都无效,认为相等(使用上一次的稳定值)
|
|
95
|
+
var prevCustomValid = prevProps.customOptions && prevProps.customOptions.length > 1;
|
|
96
|
+
var nextCustomValid = nextProps.customOptions && nextProps.customOptions.length > 1;
|
|
97
|
+
if (prevCustomValid && nextCustomValid) {
|
|
98
|
+
if (!areArraysEqual(prevProps.customOptions, nextProps.customOptions)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
} else if (prevCustomValid !== nextCustomValid) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
// 回调函数比较
|
|
105
|
+
// 由于我们已经用 ref 处理回调,即使引用变化也不会影响防抖逻辑
|
|
106
|
+
// 为了 memo 优化,我们只检查回调是否存在,不比较引用
|
|
107
|
+
var prevHasFilterChange = prevProps.onFilterChange !== undefined;
|
|
108
|
+
var nextHasFilterChange = nextProps.onFilterChange !== undefined;
|
|
109
|
+
if (prevHasFilterChange !== nextHasFilterChange) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
var prevHasSelectionChange = prevProps.onSelectionChange !== undefined;
|
|
113
|
+
var nextHasSelectionChange = nextProps.onSelectionChange !== undefined;
|
|
114
|
+
if (prevHasSelectionChange !== nextHasSelectionChange) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
// 所有关键属性都相同,可以跳过重新渲染
|
|
118
|
+
return true;
|
|
119
|
+
};
|
|
120
|
+
var ChartFilterComponent = function(param) {
|
|
8
121
|
var filterOptions = param.filterOptions, selectedFilter = param.selectedFilter, onFilterChange = param.onFilterChange, customOptions = param.customOptions, selectedCustomSelection = param.selectedCustomSelection, onSelectionChange = param.onSelectionChange, _param_className = param.className, className = _param_className === void 0 ? '' : _param_className, _param_theme = param.theme, theme = _param_theme === void 0 ? 'light' : _param_theme, _param_variant = param.variant, variant = _param_variant === void 0 ? 'default' : _param_variant;
|
|
9
|
-
var
|
|
122
|
+
var _stableCustomOptions_find, _i18n_locale;
|
|
10
123
|
var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
|
|
11
124
|
var i18n = useContext(I18nContext);
|
|
12
125
|
var prefixCls = getPrefixCls('chart-filter');
|
|
13
126
|
var _useStyle = useStyle(prefixCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
127
|
+
// 使用 useRef 保存最新的回调函数,避免防抖函数闭包问题
|
|
128
|
+
var onFilterChangeRef = useRef(onFilterChange);
|
|
129
|
+
var onSelectionChangeRef = useRef(onSelectionChange);
|
|
130
|
+
// 更新 ref,确保总是使用最新的回调
|
|
131
|
+
React.useEffect(function() {
|
|
132
|
+
onFilterChangeRef.current = onFilterChange;
|
|
133
|
+
onSelectionChangeRef.current = onSelectionChange;
|
|
134
|
+
}, [
|
|
135
|
+
onFilterChange,
|
|
136
|
+
onSelectionChange
|
|
137
|
+
]);
|
|
138
|
+
// 创建防抖的回调函数,1秒更新一次
|
|
139
|
+
var debouncedFilterChange = useMemo(function() {
|
|
140
|
+
return debounce(function(value) {
|
|
141
|
+
if (onFilterChangeRef.current) {
|
|
142
|
+
onFilterChangeRef.current(value);
|
|
143
|
+
}
|
|
144
|
+
}, 1000);
|
|
145
|
+
}, []);
|
|
146
|
+
var debouncedSelectionChange = useMemo(function() {
|
|
147
|
+
return debounce(function(region) {
|
|
148
|
+
if (onSelectionChangeRef.current) {
|
|
149
|
+
onSelectionChangeRef.current(region);
|
|
150
|
+
}
|
|
151
|
+
}, 1000);
|
|
152
|
+
}, []);
|
|
153
|
+
// 组件卸载时清理防抖函数
|
|
154
|
+
React.useEffect(function() {
|
|
155
|
+
return function() {
|
|
156
|
+
var _debouncedFilterChange_cancel, _debouncedSelectionChange_cancel;
|
|
157
|
+
debouncedFilterChange === null || debouncedFilterChange === void 0 ? void 0 : (_debouncedFilterChange_cancel = debouncedFilterChange.cancel) === null || _debouncedFilterChange_cancel === void 0 ? void 0 : _debouncedFilterChange_cancel.call(debouncedFilterChange);
|
|
158
|
+
debouncedSelectionChange === null || debouncedSelectionChange === void 0 ? void 0 : (_debouncedSelectionChange_cancel = debouncedSelectionChange.cancel) === null || _debouncedSelectionChange_cancel === void 0 ? void 0 : _debouncedSelectionChange_cancel.call(debouncedSelectionChange);
|
|
159
|
+
};
|
|
160
|
+
}, [
|
|
161
|
+
debouncedFilterChange,
|
|
162
|
+
debouncedSelectionChange
|
|
163
|
+
]);
|
|
164
|
+
// 稳定化 filterOptions 和 customOptions,避免在流式更新时频繁变化导致组件跳动
|
|
165
|
+
// 使用 useState 保存稳定的值,只在内容真正变化时才更新
|
|
166
|
+
var _useState = _sliced_to_array(useState(function() {
|
|
167
|
+
return filterOptions && filterOptions.length > 1 ? filterOptions : undefined;
|
|
168
|
+
}), 2), stableFilterOptions = _useState[0], setStableFilterOptions = _useState[1];
|
|
169
|
+
var _useState1 = _sliced_to_array(useState(function() {
|
|
170
|
+
return customOptions && customOptions.length > 1 ? customOptions : undefined;
|
|
171
|
+
}), 2), stableCustomOptions = _useState1[0], setStableCustomOptions = _useState1[1];
|
|
172
|
+
// 使用 useRef 保存上一次的值用于内容比较
|
|
173
|
+
var prevFilterOptionsRef = useRef(filterOptions);
|
|
174
|
+
var prevCustomOptionsRef = useRef(customOptions);
|
|
175
|
+
// 当 filterOptions 变化时,只在内容真正变化时才更新
|
|
176
|
+
useEffect(function() {
|
|
177
|
+
if (filterOptions && filterOptions.length > 1) {
|
|
178
|
+
// 比较内容是否真的变化
|
|
179
|
+
var contentChanged = !areArraysEqual(prevFilterOptionsRef.current, filterOptions);
|
|
180
|
+
if (contentChanged) {
|
|
181
|
+
// 内容变化,更新稳定值
|
|
182
|
+
setStableFilterOptions(filterOptions);
|
|
183
|
+
prevFilterOptionsRef.current = filterOptions;
|
|
184
|
+
}
|
|
185
|
+
// 如果内容相同,不更新,避免不必要的重新渲染
|
|
186
|
+
} else if (filterOptions && filterOptions.length <= 1) {
|
|
187
|
+
// 如果新值无效(长度 <= 1),但之前有有效值,保持上一次的值(不更新)
|
|
188
|
+
// 这样 filter 不会消失
|
|
189
|
+
}
|
|
190
|
+
// 注意:如果 filterOptions 变为 undefined 或 null,我们不更新稳定值,保持上一次的值
|
|
191
|
+
}, [
|
|
192
|
+
filterOptions
|
|
193
|
+
]);
|
|
194
|
+
useEffect(function() {
|
|
195
|
+
if (customOptions && customOptions.length > 1) {
|
|
196
|
+
var contentChanged = !areArraysEqual(prevCustomOptionsRef.current, customOptions);
|
|
197
|
+
if (contentChanged) {
|
|
198
|
+
setStableCustomOptions(customOptions);
|
|
199
|
+
prevCustomOptionsRef.current = customOptions;
|
|
200
|
+
}
|
|
17
201
|
}
|
|
202
|
+
}, [
|
|
203
|
+
customOptions
|
|
204
|
+
]);
|
|
205
|
+
var handleRegionChange = function(region) {
|
|
206
|
+
debouncedSelectionChange(region);
|
|
207
|
+
};
|
|
208
|
+
var handleFilterChange = function(value) {
|
|
209
|
+
debouncedFilterChange(value);
|
|
18
210
|
};
|
|
19
|
-
var hasMain = Array.isArray(
|
|
20
|
-
var hasSecondary = Array.isArray(
|
|
211
|
+
var hasMain = Array.isArray(stableFilterOptions) && stableFilterOptions.length > 1;
|
|
212
|
+
var hasSecondary = Array.isArray(stableCustomOptions) && stableCustomOptions.length > 1;
|
|
21
213
|
if (!hasMain && !hasSecondary) {
|
|
22
214
|
return null;
|
|
23
215
|
}
|
|
24
|
-
if (!
|
|
216
|
+
if (!stableFilterOptions || stableFilterOptions.length < 2) {
|
|
25
217
|
return null;
|
|
26
218
|
}
|
|
27
219
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
28
220
|
className: classNames(prefixCls, "".concat(prefixCls, "-").concat(theme), "".concat(prefixCls, "-").concat(variant), hashId, className)
|
|
29
|
-
},
|
|
221
|
+
}, stableCustomOptions && stableCustomOptions.length > 1 && /*#__PURE__*/ React.createElement("div", {
|
|
30
222
|
className: classNames("".concat(prefixCls, "-region-filter"), hashId)
|
|
31
223
|
}, /*#__PURE__*/ React.createElement(Dropdown, {
|
|
32
224
|
menu: {
|
|
33
|
-
items:
|
|
225
|
+
items: stableCustomOptions.map(function(item) {
|
|
34
226
|
return {
|
|
35
227
|
key: item.key,
|
|
36
228
|
label: item.label,
|
|
@@ -52,18 +244,20 @@ var ChartFilter = function(param) {
|
|
|
52
244
|
type: "default",
|
|
53
245
|
size: "small",
|
|
54
246
|
className: classNames("".concat(prefixCls, "-region-dropdown-btn"), hashId)
|
|
55
|
-
}, /*#__PURE__*/ React.createElement("span", null, ((
|
|
247
|
+
}, /*#__PURE__*/ React.createElement("span", null, ((_stableCustomOptions_find = stableCustomOptions.find(function(r) {
|
|
56
248
|
return r.key === selectedCustomSelection;
|
|
57
|
-
})) === null ||
|
|
249
|
+
})) === null || _stableCustomOptions_find === void 0 ? void 0 : _stableCustomOptions_find.label) || (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale.all) || '全部'), /*#__PURE__*/ React.createElement(ChevronDown, {
|
|
58
250
|
className: classNames("".concat(prefixCls, "-dropdown-icon"), hashId)
|
|
59
|
-
})))),
|
|
60
|
-
options:
|
|
251
|
+
})))), stableFilterOptions && stableFilterOptions.length > 1 && /*#__PURE__*/ React.createElement(Segmented, {
|
|
252
|
+
options: stableFilterOptions || [],
|
|
61
253
|
value: selectedFilter,
|
|
62
254
|
size: "small",
|
|
63
255
|
className: classNames("".concat(prefixCls, "-segmented-filter"), 'custom-segmented', hashId),
|
|
64
256
|
onChange: function(value) {
|
|
65
|
-
return
|
|
257
|
+
return handleFilterChange(value);
|
|
66
258
|
}
|
|
67
259
|
})));
|
|
68
260
|
};
|
|
261
|
+
// 使用 React.memo 包装组件,确保内容稳定,只在 props 真正变化时重新渲染
|
|
262
|
+
var ChartFilter = /*#__PURE__*/ React.memo(ChartFilterComponent, arePropsEqual);
|
|
69
263
|
export default ChartFilter;
|