@ant-design/agentic-ui 2.16.0 → 2.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/MarkdownEditor/editor/elements/Code.js +11 -6
  2. package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +15 -3
  3. package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +17 -2
  4. package/dist/MarkdownEditor/editor/elements/Table/Table.js +131 -5
  5. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +100 -1
  6. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +781 -240
  7. package/dist/MarkdownEditor/editor/types/Table.d.ts +1 -0
  8. package/dist/MarkdownEditor/editor/utils/findMatchingClose.d.ts +36 -0
  9. package/dist/MarkdownEditor/editor/utils/findMatchingClose.js +158 -0
  10. package/dist/MarkdownEditor/editor/utils/markdownToHtml.d.ts +41 -2
  11. package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +159 -7
  12. package/dist/Plugins/chart/AreaChart/index.d.ts +12 -0
  13. package/dist/Plugins/chart/AreaChart/index.js +14 -188
  14. package/dist/Plugins/chart/BarChart/index.d.ts +2 -0
  15. package/dist/Plugins/chart/BarChart/index.js +3 -12
  16. package/dist/Plugins/chart/ChartMark/Container.js +5 -2
  17. package/dist/Plugins/chart/ChartRender.d.ts +1 -0
  18. package/dist/Plugins/chart/ChartRender.js +104 -43
  19. package/dist/Plugins/chart/DonutChart/index.js +4 -2
  20. package/dist/Plugins/chart/DonutChart/types.d.ts +2 -0
  21. package/dist/Plugins/chart/FunnelChart/index.d.ts +2 -0
  22. package/dist/Plugins/chart/FunnelChart/index.js +4 -2
  23. package/dist/Plugins/chart/LineChart/index.d.ts +2 -0
  24. package/dist/Plugins/chart/LineChart/index.js +17 -162
  25. package/dist/Plugins/chart/RadarChart/index.d.ts +2 -0
  26. package/dist/Plugins/chart/RadarChart/index.js +8 -4
  27. package/dist/Plugins/chart/ScatterChart/index.d.ts +2 -0
  28. package/dist/Plugins/chart/ScatterChart/index.js +8 -4
  29. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.d.ts +1 -0
  30. package/dist/Plugins/chart/components/ChartFilter/ChartFilter.d.ts +1 -1
  31. package/dist/Plugins/chart/components/ChartFilter/ChartFilter.js +210 -16
  32. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.d.ts +2 -0
  33. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +9 -2
  34. package/dist/Plugins/chart/components/ChartToolBar/style.js +3 -1
  35. package/dist/Plugins/chart/hooks/index.d.ts +10 -0
  36. package/dist/Plugins/chart/hooks/index.js +8 -0
  37. package/dist/Plugins/chart/hooks/useChartDataFilter.d.ts +46 -0
  38. package/dist/Plugins/chart/hooks/useChartDataFilter.js +182 -0
  39. package/dist/Plugins/chart/hooks/useChartStatistics.d.ts +17 -0
  40. package/dist/Plugins/chart/hooks/useChartStatistics.js +25 -0
  41. package/dist/Plugins/chart/hooks/useChartTheme.d.ts +20 -0
  42. package/dist/Plugins/chart/hooks/useChartTheme.js +30 -0
  43. package/dist/Plugins/chart/hooks/useResponsiveSize.d.ts +23 -0
  44. package/dist/Plugins/chart/hooks/useResponsiveSize.js +94 -0
  45. package/dist/Plugins/chart/index.js +92 -8
  46. package/dist/Plugins/chart/utils/registerChart.d.ts +35 -0
  47. package/dist/Plugins/chart/utils/registerChart.js +54 -0
  48. package/dist/Plugins/chart/utils.d.ts +19 -0
  49. package/dist/Plugins/chart/utils.js +27 -0
  50. package/dist/Plugins/code/components/CodeRenderer.js +53 -2
  51. package/dist/Plugins/code/components/CodeToolbar.js +22 -3
  52. package/dist/Plugins/mermaid/Mermaid.js +66 -66
  53. package/package.json +1 -1
@@ -42,6 +42,8 @@ export interface ChartToolBarProps {
42
42
  extra?: React.ReactNode;
43
43
  /** 过滤器内容 */
44
44
  filter?: React.ReactNode;
45
+ /** 是否显示加载状态(当图表未闭合时显示) */
46
+ loading?: boolean;
45
47
  }
46
48
  /**
47
49
  * 图表工具栏组件
@@ -2,6 +2,7 @@ import { DownloadOutlined } from "@ant-design/icons";
2
2
  import { ConfigProvider, Tooltip } from "antd";
3
3
  import classNames from "classnames";
4
4
  import React, { useContext } from "react";
5
+ import { Loading } from "../../../../Components/Loading";
5
6
  import { I18nContext } from "../../../../I18n";
6
7
  import TimeIcon from "../icons/TimeIcon";
7
8
  import { useStyle } from "./style";
@@ -28,7 +29,7 @@ import { useStyle } from "./style";
28
29
  *
29
30
  * @since 1.0.0
30
31
  */ var ChartToolBar = function(param) {
31
- var title = param.title, dataTime = param.dataTime, _param_className = param.className, className = _param_className === void 0 ? '' : _param_className, _param_theme = param.theme, theme = _param_theme === void 0 ? 'light' : _param_theme, onDownload = param.onDownload, extra = param.extra, filter = param.filter;
32
+ var title = param.title, dataTime = param.dataTime, _param_className = param.className, className = _param_className === void 0 ? '' : _param_className, _param_theme = param.theme, theme = _param_theme === void 0 ? 'light' : _param_theme, onDownload = param.onDownload, extra = param.extra, filter = param.filter, _param_loading = param.loading, loading = _param_loading === void 0 ? false : _param_loading;
32
33
  var _i18n_locale, _i18n_locale1;
33
34
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
34
35
  var i18n = useContext(I18nContext);
@@ -46,7 +47,13 @@ import { useStyle } from "./style";
46
47
  className: classNames(prefixCls, "".concat(prefixCls, "-").concat(theme), hashId, className)
47
48
  }, /*#__PURE__*/ React.createElement("div", {
48
49
  className: classNames("".concat(prefixCls, "-header-title"), hashId)
49
- }, title), /*#__PURE__*/ React.createElement("div", {
50
+ }, title, loading && /*#__PURE__*/ React.createElement(Loading, {
51
+ style: {
52
+ fontSize: '14px',
53
+ marginLeft: '8px',
54
+ flexShrink: 0
55
+ }
56
+ })), /*#__PURE__*/ React.createElement("div", {
50
57
  className: classNames("".concat(prefixCls, "-header-actions"), hashId)
51
58
  }, dataTime ? /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(TimeIcon, {
52
59
  className: classNames("".concat(prefixCls, "-time-icon"), hashId)
@@ -71,7 +71,9 @@ var genStyle = function(token) {
71
71
  textOverflow: 'ellipsis',
72
72
  whiteSpace: 'nowrap',
73
73
  marginRight: '16px',
74
- minWidth: 0
74
+ minWidth: 0,
75
+ display: 'flex',
76
+ alignItems: 'center'
75
77
  }), _define_property(_obj3, "".concat(token.componentCls, "-header-actions"), (_obj = {
76
78
  display: 'flex',
77
79
  alignItems: 'center',
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @fileoverview 图表插件 Hooks 统一导出文件
3
+ * 提供图表组件相关的 React Hooks
4
+ * @author Chart Plugin Team
5
+ */
6
+ export type { ChartStatisticConfig, StatisticConfigType } from './useChartStatistic';
7
+ export { useChartDataFilter } from './useChartDataFilter';
8
+ export { useChartStatistics } from './useChartStatistics';
9
+ export { useChartTheme } from './useChartTheme';
10
+ export { useResponsiveSize } from './useResponsiveSize';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @fileoverview 图表插件 Hooks 统一导出文件
3
+ * 提供图表组件相关的 React Hooks
4
+ * @author Chart Plugin Team
5
+ */ export { useChartDataFilter } from "./useChartDataFilter";
6
+ export { useChartStatistics } from "./useChartStatistics";
7
+ export { useChartTheme } from "./useChartTheme";
8
+ export { useResponsiveSize } from "./useResponsiveSize";
@@ -0,0 +1,46 @@
1
+ /// <reference types="react" />
2
+ import { ChartDataItem } from '../utils';
3
+ /**
4
+ * 图表数据筛选 Hook
5
+ *
6
+ * 用于管理图表数据的筛选逻辑,包括分类筛选和 filterLabel 筛选。
7
+ * 自动处理数据变化时的筛选状态重置。
8
+ *
9
+ * @param {ChartDataItem[]} data - 原始数据数组
10
+ * @returns {object} 包含筛选后的数据、筛选选项和筛选状态的对象
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const {
15
+ * filteredData,
16
+ * categories,
17
+ * filterOptions,
18
+ * filterLabels,
19
+ * selectedFilter,
20
+ * setSelectedFilter,
21
+ * selectedFilterLabel,
22
+ * setSelectedFilterLabel,
23
+ * filteredDataByFilterLabel,
24
+ * } = useChartDataFilter(data);
25
+ * ```
26
+ *
27
+ * @since 1.0.0
28
+ */
29
+ export declare const useChartDataFilter: (data: ChartDataItem[]) => {
30
+ filteredData: ChartDataItem[];
31
+ categories: (string | undefined)[];
32
+ filterOptions: {
33
+ label: string;
34
+ value: string;
35
+ }[];
36
+ filterLabels: string[] | undefined;
37
+ selectedFilter: string;
38
+ setSelectedFilter: import("react").Dispatch<import("react").SetStateAction<string>>;
39
+ selectedFilterLabel: string | undefined;
40
+ setSelectedFilterLabel: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
41
+ filteredDataByFilterLabel: {
42
+ key: string;
43
+ label: string;
44
+ }[] | undefined;
45
+ safeData: ChartDataItem[];
46
+ };
@@ -0,0 +1,182 @@
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 _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
12
+ function _iterable_to_array(iter) {
13
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
14
+ }
15
+ function _iterable_to_array_limit(arr, i) {
16
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
17
+ if (_i == null) return;
18
+ var _arr = [];
19
+ var _n = true;
20
+ var _d = false;
21
+ var _s, _e;
22
+ try {
23
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
24
+ _arr.push(_s.value);
25
+ if (i && _arr.length === i) break;
26
+ }
27
+ } catch (err) {
28
+ _d = true;
29
+ _e = err;
30
+ } finally{
31
+ try {
32
+ if (!_n && _i["return"] != null) _i["return"]();
33
+ } finally{
34
+ if (_d) throw _e;
35
+ }
36
+ }
37
+ return _arr;
38
+ }
39
+ function _non_iterable_rest() {
40
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41
+ }
42
+ function _non_iterable_spread() {
43
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
44
+ }
45
+ function _sliced_to_array(arr, i) {
46
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
47
+ }
48
+ function _to_consumable_array(arr) {
49
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
50
+ }
51
+ function _unsupported_iterable_to_array(o, minLen) {
52
+ if (!o) return;
53
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
54
+ var n = Object.prototype.toString.call(o).slice(8, -1);
55
+ if (n === "Object" && o.constructor) n = o.constructor.name;
56
+ if (n === "Map" || n === "Set") return Array.from(n);
57
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
58
+ }
59
+ import { useEffect, useMemo, useState } from "react";
60
+ import { getDataHash } from "../utils";
61
+ /**
62
+ * 图表数据筛选 Hook
63
+ *
64
+ * 用于管理图表数据的筛选逻辑,包括分类筛选和 filterLabel 筛选。
65
+ * 自动处理数据变化时的筛选状态重置。
66
+ *
67
+ * @param {ChartDataItem[]} data - 原始数据数组
68
+ * @returns {object} 包含筛选后的数据、筛选选项和筛选状态的对象
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const {
73
+ * filteredData,
74
+ * categories,
75
+ * filterOptions,
76
+ * filterLabels,
77
+ * selectedFilter,
78
+ * setSelectedFilter,
79
+ * selectedFilterLabel,
80
+ * setSelectedFilterLabel,
81
+ * filteredDataByFilterLabel,
82
+ * } = useChartDataFilter(data);
83
+ * ```
84
+ *
85
+ * @since 1.0.0
86
+ */ export var useChartDataFilter = function(data) {
87
+ var safeData = Array.isArray(data) ? data : [];
88
+ // 使用数据哈希来优化依赖项比较
89
+ var dataHash = useMemo(function() {
90
+ return getDataHash(safeData);
91
+ }, [
92
+ safeData
93
+ ]);
94
+ // 从数据中提取唯一的类别作为筛选选项
95
+ var categories = useMemo(function() {
96
+ var uniqueCategories = _to_consumable_array(new Set(safeData.map(function(item) {
97
+ return item.category;
98
+ }))).filter(Boolean);
99
+ return uniqueCategories;
100
+ }, [
101
+ dataHash
102
+ ]);
103
+ // 从数据中提取 filterLabel,过滤掉 undefined 值
104
+ var validFilterLabels = useMemo(function() {
105
+ return safeData.map(function(item) {
106
+ return item.filterLabel;
107
+ }).filter(function(filterLabel) {
108
+ return filterLabel !== undefined;
109
+ });
110
+ }, [
111
+ dataHash
112
+ ]);
113
+ var filterLabels = useMemo(function() {
114
+ return validFilterLabels.length > 0 ? _to_consumable_array(new Set(validFilterLabels)) : undefined;
115
+ }, [
116
+ validFilterLabels
117
+ ]);
118
+ // 状态管理
119
+ var _useState = _sliced_to_array(useState(categories.find(Boolean) || ''), 2), selectedFilter = _useState[0], setSelectedFilter = _useState[1];
120
+ var _useState1 = _sliced_to_array(useState(filterLabels && filterLabels.length > 0 ? filterLabels[0] : undefined), 2), selectedFilterLabel = _useState1[0], setSelectedFilterLabel = _useState1[1];
121
+ // 当数据变化导致当前选中分类失效时,自动回退到首个有效分类或空(显示全部)
122
+ useEffect(function() {
123
+ if (selectedFilter && !categories.includes(selectedFilter)) {
124
+ setSelectedFilter(categories.find(Boolean) || '');
125
+ }
126
+ }, [
127
+ categories,
128
+ selectedFilter
129
+ ]);
130
+ // 筛选数据
131
+ var filteredData = useMemo(function() {
132
+ var base = selectedFilter ? safeData.filter(function(item) {
133
+ return item.category === selectedFilter;
134
+ }) : safeData;
135
+ var withFilterLabel = !filterLabels || !selectedFilterLabel ? base : base.filter(function(item) {
136
+ return item.filterLabel === selectedFilterLabel;
137
+ });
138
+ // 统一过滤掉 x 为空(null/undefined)的数据,避免后续 toString 报错
139
+ return withFilterLabel.filter(function(item) {
140
+ return item.x !== null && item.x !== undefined;
141
+ });
142
+ }, [
143
+ dataHash,
144
+ selectedFilter,
145
+ filterLabels,
146
+ selectedFilterLabel
147
+ ]);
148
+ // 筛选器选项
149
+ var filterOptions = useMemo(function() {
150
+ return categories.map(function(category) {
151
+ return {
152
+ label: category || '默认',
153
+ value: category || '默认'
154
+ };
155
+ });
156
+ }, [
157
+ categories
158
+ ]);
159
+ // 根据 filterLabel 筛选数据 - 只有当 filterLabels 存在时才生成
160
+ var filteredDataByFilterLabel = useMemo(function() {
161
+ return filterLabels === null || filterLabels === void 0 ? void 0 : filterLabels.map(function(item) {
162
+ return {
163
+ key: item,
164
+ label: item
165
+ };
166
+ });
167
+ }, [
168
+ filterLabels
169
+ ]);
170
+ return {
171
+ filteredData: filteredData,
172
+ categories: categories,
173
+ filterOptions: filterOptions,
174
+ filterLabels: filterLabels,
175
+ selectedFilter: selectedFilter,
176
+ setSelectedFilter: setSelectedFilter,
177
+ selectedFilterLabel: selectedFilterLabel,
178
+ setSelectedFilterLabel: setSelectedFilterLabel,
179
+ filteredDataByFilterLabel: filteredDataByFilterLabel,
180
+ safeData: safeData
181
+ };
182
+ };
@@ -0,0 +1,17 @@
1
+ import { StatisticConfigType } from './useChartStatistic';
2
+ /**
3
+ * 图表统计信息 Hook
4
+ *
5
+ * 用于处理 ChartStatistic 组件的配置,支持单个配置对象或配置数组。
6
+ *
7
+ * @param {StatisticConfigType} statisticConfig - 统计配置,可以是单个配置对象或配置数组
8
+ * @returns {ChartStatisticConfig[] | null} 处理后的统计配置数组,如果未提供配置则返回 null
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const statistics = useChartStatistics(statisticConfig);
13
+ * ```
14
+ *
15
+ * @since 1.0.0
16
+ */
17
+ export declare const useChartStatistics: (statisticConfig?: StatisticConfigType) => import("./useChartStatistic").ChartStatisticConfig[] | null;
@@ -0,0 +1,25 @@
1
+ import { useMemo } from "react";
2
+ /**
3
+ * 图表统计信息 Hook
4
+ *
5
+ * 用于处理 ChartStatistic 组件的配置,支持单个配置对象或配置数组。
6
+ *
7
+ * @param {StatisticConfigType} statisticConfig - 统计配置,可以是单个配置对象或配置数组
8
+ * @returns {ChartStatisticConfig[] | null} 处理后的统计配置数组,如果未提供配置则返回 null
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const statistics = useChartStatistics(statisticConfig);
13
+ * ```
14
+ *
15
+ * @since 1.0.0
16
+ */ export var useChartStatistics = function(statisticConfig) {
17
+ return useMemo(function() {
18
+ if (!statisticConfig) return null;
19
+ return Array.isArray(statisticConfig) ? statisticConfig : [
20
+ statisticConfig
21
+ ];
22
+ }, [
23
+ statisticConfig
24
+ ]);
25
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 图表主题 Hook
3
+ *
4
+ * 用于计算图表在不同主题下的颜色配置,包括坐标轴文字颜色和网格颜色。
5
+ *
6
+ * @param {'light' | 'dark'} theme - 图表主题
7
+ * @returns {object} 包含主题相关颜色的对象
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const { axisTextColor, gridColor, isLight } = useChartTheme('light');
12
+ * ```
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ export declare const useChartTheme: (theme?: 'light' | 'dark') => {
17
+ isLight: boolean;
18
+ axisTextColor: string;
19
+ gridColor: string;
20
+ };
@@ -0,0 +1,30 @@
1
+ import { useMemo } from "react";
2
+ /**
3
+ * 图表主题 Hook
4
+ *
5
+ * 用于计算图表在不同主题下的颜色配置,包括坐标轴文字颜色和网格颜色。
6
+ *
7
+ * @param {'light' | 'dark'} theme - 图表主题
8
+ * @returns {object} 包含主题相关颜色的对象
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const { axisTextColor, gridColor, isLight } = useChartTheme('light');
13
+ * ```
14
+ *
15
+ * @since 1.0.0
16
+ */ export var useChartTheme = function() {
17
+ var theme = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'light';
18
+ return useMemo(function() {
19
+ var isLight = theme === 'light';
20
+ var axisTextColor = isLight ? 'rgba(0, 25, 61, 0.3255)' : 'rgba(255, 255, 255, 0.8)';
21
+ var gridColor = isLight ? 'rgba(0,0,0,0.08)' : 'rgba(255,255,255,0.2)';
22
+ return {
23
+ isLight: isLight,
24
+ axisTextColor: axisTextColor,
25
+ gridColor: gridColor
26
+ };
27
+ }, [
28
+ theme
29
+ ]);
30
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 响应式尺寸 Hook
3
+ *
4
+ * 用于计算图表的响应式宽度和高度,并监听窗口大小变化。
5
+ * 在移动端(宽度 <= 768px)时自动调整为全宽和自适应高度。
6
+ *
7
+ * @param {number | string} width - 图表宽度,默认600px
8
+ * @param {number | string} height - 图表高度,默认400px
9
+ * @returns {object} 包含响应式尺寸和移动端标识的对象
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const { responsiveWidth, responsiveHeight, isMobile } = useResponsiveSize(800, 400);
14
+ * ```
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ export declare const useResponsiveSize: (width?: number | string, height?: number | string) => {
19
+ responsiveWidth: string | number;
20
+ responsiveHeight: string | number;
21
+ isMobile: boolean;
22
+ windowWidth: number;
23
+ };
@@ -0,0 +1,94 @@
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
+ /**
49
+ * 响应式尺寸 Hook
50
+ *
51
+ * 用于计算图表的响应式宽度和高度,并监听窗口大小变化。
52
+ * 在移动端(宽度 <= 768px)时自动调整为全宽和自适应高度。
53
+ *
54
+ * @param {number | string} width - 图表宽度,默认600px
55
+ * @param {number | string} height - 图表高度,默认400px
56
+ * @returns {object} 包含响应式尺寸和移动端标识的对象
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const { responsiveWidth, responsiveHeight, isMobile } = useResponsiveSize(800, 400);
61
+ * ```
62
+ *
63
+ * @since 1.0.0
64
+ */ export var useResponsiveSize = function() {
65
+ var width = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 600, height = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 400;
66
+ var _useState = _sliced_to_array(useState(typeof window !== 'undefined' ? window.innerWidth : 768), 2), windowWidth = _useState[0], setWindowWidth = _useState[1];
67
+ var isMobile = windowWidth <= 768;
68
+ var responsiveWidth = isMobile ? '100%' : width;
69
+ var responsiveHeight = isMobile ? Math.min(windowWidth * 0.8, 400) : height;
70
+ useEffect(function() {
71
+ var handleResize = function() {
72
+ setWindowWidth(window.innerWidth);
73
+ };
74
+ if (typeof window !== 'undefined') {
75
+ window.addEventListener('resize', handleResize);
76
+ return function() {
77
+ return window.removeEventListener('resize', handleResize);
78
+ };
79
+ }
80
+ }, []);
81
+ return useMemo(function() {
82
+ return {
83
+ responsiveWidth: responsiveWidth,
84
+ responsiveHeight: responsiveHeight,
85
+ isMobile: isMobile,
86
+ windowWidth: windowWidth
87
+ };
88
+ }, [
89
+ responsiveWidth,
90
+ responsiveHeight,
91
+ isMobile,
92
+ windowWidth
93
+ ]);
94
+ };
@@ -129,6 +129,7 @@ import { useSlate } from "slate-react";
129
129
  import { ErrorBoundary } from "../../MarkdownEditor/editor/elements/ErrorBoundary";
130
130
  import { useEditorStore } from "../../MarkdownEditor/editor/store";
131
131
  import { DragHandle } from "../../MarkdownEditor/editor/tools/DragHandle";
132
+ import { useMEditor } from "../../MarkdownEditor/hooks/editor";
132
133
  import { ChartRender } from "./ChartRender";
133
134
  import { getDataHash } from "./utils";
134
135
  /**
@@ -270,7 +271,7 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
270
271
  * - 集成编辑器状态管理
271
272
  * - 提供响应式布局
272
273
  */ export var ChartElement = function(props) {
273
- var _node_otherProps, _node_otherProps1, _node_otherProps2, _node_otherProps3, _node_otherProps4, _node_otherProps_columns, _node_otherProps5;
274
+ var _node_otherProps, _node_otherProps1, _node_otherProps2, _node_otherProps3, _node_otherProps4, _node_otherProps5, _node_otherProps_columns, _node_otherProps6;
274
275
  var _useEditorStore = useEditorStore(), store = _useEditorStore.store, readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef, rootContainer = _useEditorStore.rootContainer;
275
276
  var editor = useSlate();
276
277
  var node = props.element, attributes = props.attributes, children = props.children;
@@ -282,20 +283,101 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
282
283
  (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.dataSource
283
284
  ]);
284
285
  var chartData = useMemo(function() {
285
- var _node_otherProps_dataSource, _node_otherProps;
286
- return ((_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : (_node_otherProps_dataSource = _node_otherProps.dataSource) === null || _node_otherProps_dataSource === void 0 ? void 0 : _node_otherProps_dataSource.map(function(item) {
286
+ var _node_otherProps;
287
+ var dataSource = ((_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.dataSource) || [];
288
+ if (dataSource.length === 0) {
289
+ return [];
290
+ }
291
+ // 获取第一行的 keys 作为参考
292
+ var firstRowKeys = Object.keys(dataSource[0]).sort();
293
+ // 处理数据并过滤掉最后一行(如果它的 keys 和第一行不同)
294
+ var processed = dataSource.map(function(item) {
287
295
  return _object_spread_props(_object_spread({}, item), {
288
296
  column_list: Object.keys(item)
289
297
  });
290
- })) || [];
298
+ });
299
+ // 检查最后一行是否完整
300
+ if (processed.length > 1) {
301
+ var lastRow = processed[processed.length - 1];
302
+ var lastRowKeys = Object.keys(lastRow).filter(function(key) {
303
+ return key !== 'column_list';
304
+ }).sort();
305
+ // 如果最后一行的 keys 和第一行不同,丢弃最后一行
306
+ if (lastRowKeys.length !== firstRowKeys.length || !lastRowKeys.every(function(key, index) {
307
+ return key === firstRowKeys[index];
308
+ })) {
309
+ return processed.slice(0, -1);
310
+ }
311
+ }
312
+ return processed;
291
313
  }, [
292
314
  dataSourceHash,
293
315
  (_node_otherProps1 = node.otherProps) === null || _node_otherProps1 === void 0 ? void 0 : _node_otherProps1.dataSource
294
316
  ]);
295
317
  var columns = ((_node_otherProps2 = node.otherProps) === null || _node_otherProps2 === void 0 ? void 0 : _node_otherProps2.columns) || [];
318
+ // 检查图表是否未闭合
319
+ var isUnclosed = (node === null || node === void 0 ? void 0 : (_node_otherProps3 = node.otherProps) === null || _node_otherProps3 === void 0 ? void 0 : _node_otherProps3.finish) === false;
320
+ // 获取编辑器更新函数
321
+ var _useMEditor = _sliced_to_array(useMEditor(node), 2), update = _useMEditor[1];
322
+ // 判断是否是最后一个节点
323
+ var isLastNode = useMemo(function() {
324
+ try {
325
+ return store.isLatestNode(node);
326
+ } catch (e) {
327
+ return false;
328
+ }
329
+ }, [
330
+ store,
331
+ node
332
+ ]);
333
+ // 如果不是最后一个节点,且未闭合,立即设置为完成
334
+ useEffect(function() {
335
+ if (isUnclosed && !readonly && !isLastNode) {
336
+ var _node_otherProps;
337
+ // 检查 finish 是否仍然是 false(可能已经被其他逻辑更新)
338
+ if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.finish) === false) {
339
+ update({
340
+ otherProps: _object_spread_props(_object_spread({}, node === null || node === void 0 ? void 0 : node.otherProps), {
341
+ finish: true
342
+ })
343
+ }, node);
344
+ }
345
+ }
346
+ }, [
347
+ isUnclosed,
348
+ readonly,
349
+ isLastNode,
350
+ node,
351
+ update
352
+ ]);
353
+ // 5 秒超时机制:如果是最后一个节点且未闭合,5 秒后自动设置为完成
354
+ useEffect(function() {
355
+ if (isUnclosed && !readonly && isLastNode) {
356
+ var timer = setTimeout(function() {
357
+ var _node_otherProps;
358
+ // 检查 finish 是否仍然是 false(可能已经被其他逻辑更新)
359
+ if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.finish) === false) {
360
+ update({
361
+ otherProps: _object_spread_props(_object_spread({}, node === null || node === void 0 ? void 0 : node.otherProps), {
362
+ finish: true
363
+ })
364
+ }, node);
365
+ }
366
+ }, 5000); // 5 秒超时
367
+ return function() {
368
+ clearTimeout(timer);
369
+ };
370
+ }
371
+ }, [
372
+ isUnclosed,
373
+ readonly,
374
+ isLastNode,
375
+ node,
376
+ update
377
+ ]);
296
378
  var _React_useState = _sliced_to_array(React.useState(2), 2), columnLength = _React_useState[0], setColumnLength = _React_useState[1];
297
379
  var config = [
298
- ((_node_otherProps3 = node.otherProps) === null || _node_otherProps3 === void 0 ? void 0 : _node_otherProps3.config) || node.otherProps
380
+ ((_node_otherProps4 = node.otherProps) === null || _node_otherProps4 === void 0 ? void 0 : _node_otherProps4.config) || node.otherProps
299
381
  ].flat(1);
300
382
  var htmlRef = React.useRef(null);
301
383
  var _React_useState1 = _sliced_to_array(React.useState(256), 2), minWidth = _React_useState1[0], setMinWidth = _React_useState1[1];
@@ -426,7 +508,8 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
426
508
  dataTime: rest === null || rest === void 0 ? void 0 : rest.dataTime,
427
509
  groupBy: rest === null || rest === void 0 ? void 0 : rest.groupBy,
428
510
  filterBy: rest === null || rest === void 0 ? void 0 : rest.filterBy,
429
- colorLegend: rest === null || rest === void 0 ? void 0 : rest.colorLegend
511
+ colorLegend: rest === null || rest === void 0 ? void 0 : rest.colorLegend,
512
+ loading: isUnclosed
430
513
  });
431
514
  return dom;
432
515
  });
@@ -440,6 +523,7 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
440
523
  title: rest === null || rest === void 0 ? void 0 : rest.title,
441
524
  dataTime: rest === null || rest === void 0 ? void 0 : rest.dataTime,
442
525
  groupBy: rest === null || rest === void 0 ? void 0 : rest.groupBy,
526
+ loading: isUnclosed,
443
527
  filterBy: rest === null || rest === void 0 ? void 0 : rest.filterBy,
444
528
  colorLegend: rest === null || rest === void 0 ? void 0 : rest.colorLegend,
445
529
  config: {
@@ -489,8 +573,8 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
489
573
  attributes,
490
574
  // 使用更高效的依赖项比较
491
575
  dataSourceHash,
492
- (_node_otherProps4 = node.otherProps) === null || _node_otherProps4 === void 0 ? void 0 : _node_otherProps4.config,
493
- (_node_otherProps5 = node.otherProps) === null || _node_otherProps5 === void 0 ? void 0 : (_node_otherProps_columns = _node_otherProps5.columns) === null || _node_otherProps_columns === void 0 ? void 0 : _node_otherProps_columns.length,
576
+ (_node_otherProps5 = node.otherProps) === null || _node_otherProps5 === void 0 ? void 0 : _node_otherProps5.config,
577
+ (_node_otherProps6 = node.otherProps) === null || _node_otherProps6 === void 0 ? void 0 : (_node_otherProps_columns = _node_otherProps6.columns) === null || _node_otherProps_columns === void 0 ? void 0 : _node_otherProps_columns.length,
494
578
  editor,
495
579
  columnLength,
496
580
  readonly,