@ant-design/agentic-ui 2.30.0 → 2.30.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 (63) hide show
  1. package/dist/Bubble/List/index.d.ts +4 -0
  2. package/dist/Bubble/List/index.js +8 -5
  3. package/dist/Bubble/MessagesContent/EXCEPTION.js +11 -2
  4. package/dist/Bubble/MessagesContent/MarkdownPreview.js +13 -7
  5. package/dist/Bubble/MessagesContent/index.js +39 -10
  6. package/dist/Bubble/MessagesContent/style.js +55 -22
  7. package/dist/Bubble/type.d.ts +4 -0
  8. package/dist/I18n/locales.js +2 -2
  9. package/dist/MarkdownEditor/BaseMarkdownEditor.js +37 -5
  10. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiTaskBlock.d.ts +4 -0
  11. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiTaskBlock.js +74 -0
  12. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiToolUseBarBlock.d.ts +4 -0
  13. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiToolUseBarBlock.js +114 -0
  14. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.d.ts +20 -0
  15. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.js +169 -0
  16. package/dist/MarkdownEditor/editor/elements/Table/EditableTable.d.ts +11 -0
  17. package/dist/MarkdownEditor/editor/elements/Table/EditableTable.js +207 -0
  18. package/dist/MarkdownEditor/editor/elements/Table/Table.js +10 -276
  19. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/index.js +7 -227
  20. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/index.js +20 -229
  21. package/dist/MarkdownEditor/editor/elements/Table/commands/tableCommands.d.ts +9 -0
  22. package/dist/MarkdownEditor/editor/elements/Table/commands/tableCommands.js +242 -0
  23. package/dist/MarkdownEditor/editor/elements/Table/utils/editableTableWidth.d.ts +20 -0
  24. package/dist/MarkdownEditor/editor/elements/Table/utils/editableTableWidth.js +60 -0
  25. package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableColWidths.d.ts +6 -0
  26. package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableColWidths.js +20 -0
  27. package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableContentWidth.d.ts +10 -0
  28. package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableContentWidth.js +103 -0
  29. package/dist/MarkdownEditor/editor/elements/index.js +7 -0
  30. package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +33 -2
  31. package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +3 -0
  32. package/dist/MarkdownEditor/editor/plugins/handlePaste.js +4 -1
  33. package/dist/MarkdownEditor/style.js +109 -7
  34. package/dist/MarkdownEditor/types.d.ts +5 -0
  35. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +2 -2
  36. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +11 -8
  37. package/dist/MarkdownInputField/AttachmentButton/index.js +7 -2
  38. package/dist/MarkdownInputField/AttachmentButton/types.d.ts +5 -1
  39. package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +7 -0
  40. package/dist/MarkdownInputField/AttachmentButton/utils.js +9 -1
  41. package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +10 -5
  42. package/dist/MarkdownInputField/FileUploadManager/index.d.ts +9 -0
  43. package/dist/MarkdownInputField/FileUploadManager/index.js +20 -4
  44. package/dist/MarkdownInputField/MarkdownInputField.js +5 -3
  45. package/dist/MarkdownInputField/SendActions/index.d.ts +9 -0
  46. package/dist/MarkdownInputField/SendActions/index.js +3 -2
  47. package/dist/MarkdownInputField/utils/renderHelpers.d.ts +8 -1
  48. package/dist/MarkdownInputField/utils/renderHelpers.js +5 -1
  49. package/dist/MarkdownRenderer/AnimationText.d.ts +4 -7
  50. package/dist/MarkdownRenderer/AnimationText.js +117 -15
  51. package/dist/MarkdownRenderer/MarkdownRenderer.js +15 -1
  52. package/dist/MarkdownRenderer/index.d.ts +2 -2
  53. package/dist/MarkdownRenderer/index.js +1 -1
  54. package/dist/MarkdownRenderer/renderers/AgenticUiTaskBlockRenderer.d.ts +6 -0
  55. package/dist/MarkdownRenderer/renderers/AgenticUiTaskBlockRenderer.js +66 -0
  56. package/dist/MarkdownRenderer/renderers/AgenticUiToolUseBarBlockRenderer.d.ts +6 -0
  57. package/dist/MarkdownRenderer/renderers/AgenticUiToolUseBarBlockRenderer.js +134 -0
  58. package/dist/MarkdownRenderer/style.js +7 -6
  59. package/dist/MarkdownRenderer/useMarkdownToReact.js +5 -4
  60. package/dist/MarkdownRenderer/useStreaming.js +8 -1
  61. package/dist/Plugins/chart/ChartRender.js +1 -0
  62. package/dist/Plugins/chart/index.js +3 -1
  63. package/package.json +2 -1
@@ -0,0 +1,114 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _object_spread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
28
+ }
29
+ function ownKeys(object, enumerableOnly) {
30
+ var keys = Object.keys(object);
31
+ if (Object.getOwnPropertySymbols) {
32
+ var symbols = Object.getOwnPropertySymbols(object);
33
+ if (enumerableOnly) {
34
+ symbols = symbols.filter(function(sym) {
35
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
+ });
37
+ }
38
+ keys.push.apply(keys, symbols);
39
+ }
40
+ return keys;
41
+ }
42
+ function _object_spread_props(target, source) {
43
+ source = source != null ? source : {};
44
+ if (Object.getOwnPropertyDescriptors) {
45
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
+ } else {
47
+ ownKeys(Object(source)).forEach(function(key) {
48
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
+ });
50
+ }
51
+ return target;
52
+ }
53
+ function _object_without_properties(source, excluded) {
54
+ if (source == null) return {};
55
+ var target = {}, sourceKeys, key, i;
56
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
57
+ sourceKeys = Reflect.ownKeys(source);
58
+ for(i = 0; i < sourceKeys.length; i++){
59
+ key = sourceKeys[i];
60
+ if (excluded.indexOf(key) >= 0) continue;
61
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
62
+ target[key] = source[key];
63
+ }
64
+ return target;
65
+ }
66
+ target = _object_without_properties_loose(source, excluded);
67
+ if (Object.getOwnPropertySymbols) {
68
+ sourceKeys = Object.getOwnPropertySymbols(source);
69
+ for(i = 0; i < sourceKeys.length; i++){
70
+ key = sourceKeys[i];
71
+ if (excluded.indexOf(key) >= 0) continue;
72
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
73
+ target[key] = source[key];
74
+ }
75
+ }
76
+ return target;
77
+ }
78
+ function _object_without_properties_loose(source, excluded) {
79
+ if (source == null) return {};
80
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
81
+ for(i = 0; i < sourceKeys.length; i++){
82
+ key = sourceKeys[i];
83
+ if (excluded.indexOf(key) >= 0) continue;
84
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
85
+ target[key] = source[key];
86
+ }
87
+ return target;
88
+ }
89
+ import React from "react";
90
+ import { ToolUseBar } from "../../../../ToolUseBar";
91
+ import { normalizeToolUseBarPropsFromJson } from "./agenticUiEmbedUtils";
92
+ export var AgenticUiToolUseBarBlock = function AgenticUiToolUseBarBlock(param) {
93
+ var attributes = param.attributes, children = param.children, element = param.element;
94
+ var _normalizeToolUseBarPropsFromJson = normalizeToolUseBarPropsFromJson(element.value), tools = _normalizeToolUseBarPropsFromJson.tools, restBar = _object_without_properties(_normalizeToolUseBarPropsFromJson, [
95
+ "tools"
96
+ ]);
97
+ return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, attributes), {
98
+ contentEditable: false,
99
+ "data-testid": "agentic-ui-toolusebar-block",
100
+ style: {
101
+ margin: '0.75em 0'
102
+ }
103
+ }), /*#__PURE__*/ React.createElement(ToolUseBar, _object_spread({
104
+ tools: tools
105
+ }, restBar)), /*#__PURE__*/ React.createElement("span", {
106
+ "data-testid": "agentic-ui-toolusebar-hidden-children",
107
+ style: {
108
+ display: 'none'
109
+ }
110
+ }, children));
111
+ };
112
+ AgenticUiToolUseBarBlock.displayName = 'AgenticUiToolUseBarBlock';
113
+ export var ReadonlyAgenticUiToolUseBarBlock = /*#__PURE__*/ React.memo(AgenticUiToolUseBarBlock);
114
+ ReadonlyAgenticUiToolUseBarBlock.displayName = 'ReadonlyAgenticUiToolUseBarBlock';
@@ -0,0 +1,20 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { TaskListProps } from '../../../../TaskList/types';
3
+ import type { ToolCall } from '../../../../ToolUseBar/BarItem';
4
+ /**
5
+ * 将 ```agentic-ui-task JSON 规范化为 TaskListProps(与 parseCode 解析结果一致)
6
+ */
7
+ export declare function normalizeTaskListPropsFromJson(parsed: unknown): TaskListProps;
8
+ /**
9
+ * 将 ```agentic-ui-toolusebar JSON 规范化为 ToolUseBar 所需 props
10
+ *
11
+ * 支持 `tools` 数组;旧版 `items`(text/key,原为 SuggestionList)会映射为最小 ToolCall
12
+ */
13
+ export interface NormalizedToolUseBarEmbedProps {
14
+ tools: ToolCall[];
15
+ className?: string;
16
+ style?: CSSProperties;
17
+ light?: boolean;
18
+ disableAnimation?: boolean;
19
+ }
20
+ export declare function normalizeToolUseBarPropsFromJson(parsed: unknown): NormalizedToolUseBarEmbedProps;
@@ -0,0 +1,169 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _object_spread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
28
+ }
29
+ function ownKeys(object, enumerableOnly) {
30
+ var keys = Object.keys(object);
31
+ if (Object.getOwnPropertySymbols) {
32
+ var symbols = Object.getOwnPropertySymbols(object);
33
+ if (enumerableOnly) {
34
+ symbols = symbols.filter(function(sym) {
35
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
+ });
37
+ }
38
+ keys.push.apply(keys, symbols);
39
+ }
40
+ return keys;
41
+ }
42
+ function _object_spread_props(target, source) {
43
+ source = source != null ? source : {};
44
+ if (Object.getOwnPropertyDescriptors) {
45
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
+ } else {
47
+ ownKeys(Object(source)).forEach(function(key) {
48
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
+ });
50
+ }
51
+ return target;
52
+ }
53
+ function _type_of(obj) {
54
+ "@swc/helpers - typeof";
55
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
56
+ }
57
+ var TASK_STATUSES = [
58
+ 'success',
59
+ 'pending',
60
+ 'loading',
61
+ 'error'
62
+ ];
63
+ var isTaskStatus = function isTaskStatus(v) {
64
+ return typeof v === 'string' && TASK_STATUSES.includes(v);
65
+ };
66
+ /**
67
+ * 将 ```agentic-ui-task JSON 规范化为 TaskListProps(与 parseCode 解析结果一致)
68
+ */ export function normalizeTaskListPropsFromJson(parsed) {
69
+ var root = parsed && (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === 'object' && !Array.isArray(parsed) ? parsed : null;
70
+ var rawItems = root && Array.isArray(root.items) ? root.items : Array.isArray(parsed) ? parsed : [];
71
+ var items = rawItems.filter(function(x) {
72
+ return !!x && (typeof x === "undefined" ? "undefined" : _type_of(x)) === 'object';
73
+ }).map(function(x) {
74
+ var status = isTaskStatus(x.status) ? x.status : 'pending';
75
+ var key = x.key !== undefined && x.key !== null ? String(x.key) : '';
76
+ var title = x.title === undefined || x.title === null ? undefined : String(x.title);
77
+ var content = '';
78
+ if (x.content !== undefined && x.content !== null) {
79
+ if (Array.isArray(x.content)) {
80
+ content = x.content.map(function(line) {
81
+ return String(line);
82
+ }).join('\n');
83
+ } else {
84
+ content = String(x.content);
85
+ }
86
+ }
87
+ return {
88
+ key: key,
89
+ title: title,
90
+ content: content,
91
+ status: status
92
+ };
93
+ }).filter(function(item) {
94
+ return item.key.length > 0;
95
+ });
96
+ var variantRaw = root ? root.variant : undefined;
97
+ /** 嵌入块默认紧凑摘要条;需完整任务链样式时设 `variant: "default"` */ var variant = variantRaw === 'default' ? 'default' : 'simple';
98
+ var className = root && typeof root.className === 'string' ? root.className : undefined;
99
+ return {
100
+ items: items,
101
+ variant: variant,
102
+ className: className
103
+ };
104
+ }
105
+ var TOOL_STATUSES = [
106
+ 'idle',
107
+ 'loading',
108
+ 'success',
109
+ 'error'
110
+ ];
111
+ var isToolCallStatus = function isToolCallStatus(v) {
112
+ return typeof v === 'string' && TOOL_STATUSES.includes(v);
113
+ };
114
+ var toolFromRecord = function toolFromRecord(x) {
115
+ var id = x.id !== undefined && x.id !== null ? String(x.id) : x.key !== undefined && x.key !== null ? String(x.key) : '';
116
+ if (!id) return null;
117
+ var status = isToolCallStatus(x.status) ? x.status : 'idle';
118
+ return {
119
+ id: id,
120
+ toolName: x.toolName !== undefined && x.toolName !== null ? String(x.toolName) : '',
121
+ toolTarget: x.toolTarget !== undefined && x.toolTarget !== null ? String(x.toolTarget) : '',
122
+ time: x.time !== undefined && x.time !== null ? String(x.time) : undefined,
123
+ errorMessage: typeof x.errorMessage === 'string' ? x.errorMessage : undefined,
124
+ type: x.type === 'summary' || x.type === 'normal' || typeof x.type === 'string' ? x.type : undefined,
125
+ content: x.content !== undefined && x.content !== null ? String(x.content) : undefined,
126
+ status: status,
127
+ testId: typeof x.testId === 'string' ? x.testId : undefined
128
+ };
129
+ };
130
+ export function normalizeToolUseBarPropsFromJson(parsed) {
131
+ var root = parsed && (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === 'object' && !Array.isArray(parsed) ? parsed : null;
132
+ var tools = [];
133
+ if (root && Array.isArray(root.tools)) {
134
+ var raw = root.tools;
135
+ tools = raw.filter(function(x) {
136
+ return !!x && (typeof x === "undefined" ? "undefined" : _type_of(x)) === 'object';
137
+ }).map(function(x) {
138
+ return toolFromRecord(x);
139
+ }).filter(function(t) {
140
+ return t !== null;
141
+ });
142
+ } else if (root && Array.isArray(root.items)) {
143
+ var rawItems = root.items;
144
+ tools = rawItems.filter(function(x) {
145
+ return !!x && (typeof x === "undefined" ? "undefined" : _type_of(x)) === 'object';
146
+ }).filter(function(x) {
147
+ return typeof x.text === 'string';
148
+ }).map(function(x, i) {
149
+ var id = x.key !== undefined && x.key !== null ? String(x.key) : String(i);
150
+ return toolFromRecord(_object_spread_props(_object_spread({}, x), {
151
+ id: id,
152
+ toolName: x.text,
153
+ toolTarget: '',
154
+ status: 'idle'
155
+ }));
156
+ }).filter(function(t) {
157
+ return t !== null;
158
+ });
159
+ }
160
+ var className = root && typeof root.className === 'string' ? root.className : undefined;
161
+ var light = root && root.light === true ? true : undefined;
162
+ var disableAnimation = root && root.disableAnimation === true ? true : undefined;
163
+ return {
164
+ tools: tools,
165
+ className: className,
166
+ light: light,
167
+ disableAnimation: disableAnimation
168
+ };
169
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { TableNode } from '../../types/Table';
3
+ export interface EditableTableProps {
4
+ baseCls: string;
5
+ children: React.ReactNode;
6
+ tablePath?: number[];
7
+ tableNode?: TableNode;
8
+ markdownContainerRef?: React.RefObject<HTMLElement | null>;
9
+ tableCssVariables?: React.CSSProperties;
10
+ }
11
+ export declare const EditableTable: React.FC<EditableTableProps>;
@@ -0,0 +1,207 @@
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 _define_property(obj, key, value) {
10
+ if (key in obj) {
11
+ Object.defineProperty(obj, key, {
12
+ value: value,
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true
16
+ });
17
+ } else {
18
+ obj[key] = value;
19
+ }
20
+ return obj;
21
+ }
22
+ function _iterable_to_array_limit(arr, i) {
23
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
24
+ if (_i == null) return;
25
+ var _arr = [];
26
+ var _n = true;
27
+ var _d = false;
28
+ var _s, _e;
29
+ try {
30
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
31
+ _arr.push(_s.value);
32
+ if (i && _arr.length === i) break;
33
+ }
34
+ } catch (err) {
35
+ _d = true;
36
+ _e = err;
37
+ } finally{
38
+ try {
39
+ if (!_n && _i["return"] != null) _i["return"]();
40
+ } finally{
41
+ if (_d) throw _e;
42
+ }
43
+ }
44
+ return _arr;
45
+ }
46
+ function _non_iterable_rest() {
47
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48
+ }
49
+ function _object_spread(target) {
50
+ for(var i = 1; i < arguments.length; i++){
51
+ var source = arguments[i] != null ? arguments[i] : {};
52
+ var ownKeys = Object.keys(source);
53
+ if (typeof Object.getOwnPropertySymbols === "function") {
54
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
55
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
56
+ }));
57
+ }
58
+ ownKeys.forEach(function(key) {
59
+ _define_property(target, key, source[key]);
60
+ });
61
+ }
62
+ return target;
63
+ }
64
+ function ownKeys(object, enumerableOnly) {
65
+ var keys = Object.keys(object);
66
+ if (Object.getOwnPropertySymbols) {
67
+ var symbols = Object.getOwnPropertySymbols(object);
68
+ if (enumerableOnly) {
69
+ symbols = symbols.filter(function(sym) {
70
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
71
+ });
72
+ }
73
+ keys.push.apply(keys, symbols);
74
+ }
75
+ return keys;
76
+ }
77
+ function _object_spread_props(target, source) {
78
+ source = source != null ? source : {};
79
+ if (Object.getOwnPropertyDescriptors) {
80
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
81
+ } else {
82
+ ownKeys(Object(source)).forEach(function(key) {
83
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
84
+ });
85
+ }
86
+ return target;
87
+ }
88
+ function _sliced_to_array(arr, i) {
89
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
90
+ }
91
+ function _unsupported_iterable_to_array(o, minLen) {
92
+ if (!o) return;
93
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
94
+ var n = Object.prototype.toString.call(o).slice(8, -1);
95
+ if (n === "Object" && o.constructor) n = o.constructor.name;
96
+ if (n === "Map" || n === "Set") return Array.from(n);
97
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
98
+ }
99
+ import classNames from "clsx";
100
+ import React, { useEffect, useMemo } from "react";
101
+ import { MOBILE_BREAKPOINT } from "../../../../Constants/mobile";
102
+ import { TABLE_ROW_INDEX_COL_WIDTH, TableColgroup } from "./TableColgroup";
103
+ import { TableRowIndex } from "./TableRowIndex";
104
+ import { getEditableTableMinWidth } from "./utils/editableTableWidth";
105
+ import { useEditableTableColWidths } from "./utils/useEditableTableColWidths";
106
+ import { useEditableTableContentWidth } from "./utils/useEditableTableContentWidth";
107
+ import useScrollShadow from "./useScrollShadow";
108
+ var TABLE_MIN_CONTAINER_WIDTH = 200;
109
+ export var EditableTable = function EditableTable(param) {
110
+ var baseCls = param.baseCls, children = param.children, tablePath = param.tablePath, tableNode = param.tableNode, markdownContainerRef = param.markdownContainerRef, tableCssVariables = param.tableCssVariables;
111
+ var _tableNode_children__children, _tableNode_children_, _tableNode_children;
112
+ var columnCount = (tableNode === null || tableNode === void 0 ? void 0 : (_tableNode_children = tableNode.children) === null || _tableNode_children === void 0 ? void 0 : (_tableNode_children_ = _tableNode_children[0]) === null || _tableNode_children_ === void 0 ? void 0 : (_tableNode_children__children = _tableNode_children_.children) === null || _tableNode_children__children === void 0 ? void 0 : _tableNode_children__children.length) || 0;
113
+ var mobileBreakpointValue = parseInt(MOBILE_BREAKPOINT, 10) || 768;
114
+ var _useScrollShadow = _sliced_to_array(useScrollShadow(), 2), tableRef = _useScrollShadow[0], scrollState = _useScrollShadow[1];
115
+ var _useEditableTableContentWidth = useEditableTableContentWidth({
116
+ readonly: false,
117
+ markdownContainerRef: markdownContainerRef,
118
+ minContainerWidth: TABLE_MIN_CONTAINER_WIDTH
119
+ }), resolvedContentWidth = _useEditableTableContentWidth.resolvedContentWidth, availableTableWidth = _useEditableTableContentWidth.availableTableWidth;
120
+ var colWidths = useEditableTableColWidths({
121
+ readonly: false,
122
+ columnCount: columnCount,
123
+ availableTableWidth: availableTableWidth,
124
+ mobileBreakpointValue: mobileBreakpointValue,
125
+ element: tableNode
126
+ });
127
+ useEffect(function() {
128
+ var resize = function resize() {
129
+ if (process.env.NODE_ENV === 'test') return;
130
+ var dom = tableRef.current;
131
+ if (!dom) return;
132
+ var requiredMinWidth = getEditableTableMinWidth({
133
+ columnCount: columnCount,
134
+ colWidths: colWidths,
135
+ availableTableWidth: availableTableWidth,
136
+ mobileBreakpointValue: mobileBreakpointValue,
137
+ resolvedContentWidth: resolvedContentWidth,
138
+ minContainerWidth: TABLE_MIN_CONTAINER_WIDTH,
139
+ rowIndexColWidth: TABLE_ROW_INDEX_COL_WIDTH
140
+ });
141
+ dom.style.minWidth = "".concat(requiredMinWidth, "px");
142
+ };
143
+ document.addEventListener('md-resize', resize);
144
+ window.addEventListener('resize', resize);
145
+ resize();
146
+ return function() {
147
+ document.removeEventListener('md-resize', resize);
148
+ window.removeEventListener('resize', resize);
149
+ };
150
+ }, [
151
+ tableRef,
152
+ columnCount,
153
+ colWidths,
154
+ availableTableWidth,
155
+ mobileBreakpointValue,
156
+ resolvedContentWidth
157
+ ]);
158
+ useEffect(function() {
159
+ document.dispatchEvent(new CustomEvent('md-resize', {
160
+ detail: {}
161
+ }));
162
+ }, []);
163
+ var tableDom = useMemo(function() {
164
+ return /*#__PURE__*/ React.createElement("table", {
165
+ className: classNames("".concat(baseCls, "-editor-table")),
166
+ onDragStart: function onDragStart(e) {
167
+ e.preventDefault();
168
+ return false;
169
+ }
170
+ }, /*#__PURE__*/ React.createElement(TableColgroup, {
171
+ colWidths: colWidths,
172
+ prefixColWidth: TABLE_ROW_INDEX_COL_WIDTH
173
+ }), /*#__PURE__*/ React.createElement("tbody", null, /*#__PURE__*/ React.createElement(TableRowIndex, {
174
+ colWidths: colWidths,
175
+ columnCount: columnCount,
176
+ tablePath: tablePath
177
+ }), children));
178
+ }, [
179
+ baseCls,
180
+ colWidths,
181
+ columnCount,
182
+ tablePath,
183
+ children
184
+ ]);
185
+ var boxShadowStyle = useMemo(function() {
186
+ return {
187
+ flex: 1,
188
+ minWidth: 0,
189
+ boxShadow: "\n ".concat(scrollState.vertical.hasScroll && !scrollState.vertical.isAtStart ? 'inset 0 8px 8px -8px rgba(0,0,0,0.1)' : '', "\n ").concat(scrollState.vertical.hasScroll && !scrollState.vertical.isAtEnd ? 'inset 0 -8px 8px -8px rgba(0,0,0,0.1)' : '', "\n ").concat(scrollState.horizontal.hasScroll && !scrollState.horizontal.isAtStart ? 'inset 8px 0 8px -8px rgba(0,0,0,0.1)' : '', "\n ").concat(scrollState.horizontal.hasScroll && !scrollState.horizontal.isAtEnd ? 'inset -8px 0 8px -8px rgba(0,0,0,0.1)' : '', "\n ")
190
+ };
191
+ }, [
192
+ scrollState
193
+ ]);
194
+ return /*#__PURE__*/ React.createElement("div", {
195
+ className: classNames(baseCls),
196
+ ref: tableRef,
197
+ style: _object_spread(_object_spread_props(_object_spread({}, boxShadowStyle), {
198
+ position: 'relative'
199
+ }), tableCssVariables),
200
+ onDragStart: function onDragStart(e) {
201
+ e.preventDefault();
202
+ },
203
+ onDoubleClick: function onDoubleClick(e) {
204
+ e.preventDefault();
205
+ }
206
+ }, tableDom);
207
+ };