@huanban/rulego-editor-react 1.0.15 → 1.1.2
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/components/AIAssistant.d.ts +22 -0
- package/dist/components/ComponentSidebar.d.ts +85 -0
- package/dist/components/ContextMenu.d.ts +106 -0
- package/dist/components/CopilotChat.d.ts +31 -0
- package/dist/components/DataViewDialog.d.ts +49 -0
- package/dist/components/DebugPanel.d.ts +100 -0
- package/dist/components/DynamicForm.d.ts +65 -0
- package/dist/components/EdgePropertyDrawer.d.ts +62 -0
- package/dist/components/EditorToolbar.d.ts +107 -0
- package/dist/components/ImportExportDialog.d.ts +53 -0
- package/dist/components/LogViewer.d.ts +45 -0
- package/dist/components/MiniMap.d.ts +83 -0
- package/dist/components/NodePropertyDrawer.d.ts +175 -0
- package/dist/components/RuleChainSettings.d.ts +82 -0
- package/dist/components/RuleGoEditor.d.ts +230 -0
- package/dist/components/RuleMaintenancePanel.d.ts +15 -0
- package/dist/components/SearchPanel.d.ts +60 -0
- package/dist/components/SearchableSelect.d.ts +29 -0
- package/dist/components/ValidationPanel.d.ts +65 -0
- package/dist/components/WorkflowInfoPanel.d.ts +73 -0
- package/dist/components/WorkflowList.d.ts +98 -0
- package/dist/components/properties/AgentOrchestrationProperties.d.ts +13 -0
- package/dist/hooks/useClipboard.d.ts +89 -0
- package/dist/hooks/useEditorCore.d.ts +104 -0
- package/dist/hooks/useEditorI18n.d.ts +33 -0
- package/dist/hooks/useEditorTheme.d.ts +37 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +73 -0
- package/dist/i18n.d.ts +14 -0
- package/dist/index.cjs.js +5854 -895
- package/dist/index.d.ts +118 -0
- package/dist/index.esm.js +78905 -45299
- package/dist/style.css +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file LogViewer.tsx
|
|
3
|
+
* @description 支持虚拟滚动的高性能调试日志面板
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
7
|
+
import type { EditorTranslate } from '../i18n';
|
|
8
|
+
/**
|
|
9
|
+
* 日志实体接口定义
|
|
10
|
+
* @interface LogEntry
|
|
11
|
+
*/
|
|
12
|
+
export interface LogEntry {
|
|
13
|
+
/** 唯一日志标识 UUID */
|
|
14
|
+
id: string;
|
|
15
|
+
/** 产生日志的毫秒时间戳 */
|
|
16
|
+
timestamp: number;
|
|
17
|
+
/** 日志级别 */
|
|
18
|
+
level: 'info' | 'warn' | 'error' | 'debug';
|
|
19
|
+
/** 实际文本内容 */
|
|
20
|
+
message: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 日志面板组件属性
|
|
24
|
+
* @interface LogViewerProps
|
|
25
|
+
*/
|
|
26
|
+
export interface LogViewerProps {
|
|
27
|
+
/** 从外层 WebSocket 接收并维护的日志数组 */
|
|
28
|
+
logs: LogEntry[];
|
|
29
|
+
/** Current locale. Defaults to zh-CN. */
|
|
30
|
+
locale?: string;
|
|
31
|
+
/** Extra locale messages merged into the selected locale. */
|
|
32
|
+
messages?: LocaleMessages;
|
|
33
|
+
/** Host-provided translation function. */
|
|
34
|
+
t?: EditorTranslate;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 高性能调试日志控制台 (LogViewer)
|
|
38
|
+
*
|
|
39
|
+
* @component
|
|
40
|
+
* @description 专为高并发/海量报文调试设计的面板。
|
|
41
|
+
* 考虑到不引入额外的庞大虚拟列表库(如 react-window),此处实现了基础的数组切片限流策略。
|
|
42
|
+
* 始终保证 DOM 树内仅渲染最新 200 条节点,彻底根除由于 `DOM Nodes` 暴增导致的浏览器卡顿问题。
|
|
43
|
+
*/
|
|
44
|
+
export declare const LogViewer: React.FC<LogViewerProps>;
|
|
45
|
+
//# sourceMappingURL=LogViewer.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/MiniMap.tsx
|
|
3
|
+
* @description 小地图导航组件 — React 实现
|
|
4
|
+
*
|
|
5
|
+
* 功能:
|
|
6
|
+
* - 显示画布全局缩略视图
|
|
7
|
+
* - 标记所有节点位置(按类型着色)
|
|
8
|
+
* - 标记当前视口范围(拖拽移动)
|
|
9
|
+
* - 标记选中节点(高亮)
|
|
10
|
+
* - 可折叠/展开
|
|
11
|
+
* - 零 UI 框架依赖(纯 React + CSS)
|
|
12
|
+
*
|
|
13
|
+
* @see MiniMapProps — 参数类型
|
|
14
|
+
*/
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
17
|
+
import type { EditorTranslate } from '../i18n';
|
|
18
|
+
/** 小地图中的节点数据 */
|
|
19
|
+
export interface MiniMapNode {
|
|
20
|
+
/** 节点 ID */
|
|
21
|
+
id: string;
|
|
22
|
+
/** X 坐标 */
|
|
23
|
+
x: number;
|
|
24
|
+
/** Y 坐标 */
|
|
25
|
+
y: number;
|
|
26
|
+
/** 宽度 */
|
|
27
|
+
width?: number;
|
|
28
|
+
/** 高度 */
|
|
29
|
+
height?: number;
|
|
30
|
+
/** 节点类型 */
|
|
31
|
+
type?: string;
|
|
32
|
+
/** 是否选中 */
|
|
33
|
+
selected?: boolean;
|
|
34
|
+
/** 显示颜色 */
|
|
35
|
+
color?: string;
|
|
36
|
+
}
|
|
37
|
+
/** 小地图中的视口数据 */
|
|
38
|
+
export interface MiniMapViewport {
|
|
39
|
+
/** 视口左上角 X */
|
|
40
|
+
x: number;
|
|
41
|
+
/** 视口左上角 Y */
|
|
42
|
+
y: number;
|
|
43
|
+
/** 视口宽度 */
|
|
44
|
+
width: number;
|
|
45
|
+
/** 视口高度 */
|
|
46
|
+
height: number;
|
|
47
|
+
}
|
|
48
|
+
/** MiniMap Props */
|
|
49
|
+
export interface MiniMapProps {
|
|
50
|
+
/** 所有节点列表 */
|
|
51
|
+
nodes: MiniMapNode[];
|
|
52
|
+
/** 当前视口范围 */
|
|
53
|
+
viewport?: MiniMapViewport;
|
|
54
|
+
/** 小地图宽度(默认 200) */
|
|
55
|
+
width?: number;
|
|
56
|
+
/** 小地图高度(默认 150) */
|
|
57
|
+
height?: number;
|
|
58
|
+
/** 是否默认折叠 */
|
|
59
|
+
defaultCollapsed?: boolean;
|
|
60
|
+
/** 位置(右下角/左下角/右上角/左上角) */
|
|
61
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
62
|
+
/** 视口拖拽回调 — 返回画布坐标 */
|
|
63
|
+
onViewportChange?: (center: {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
}) => void;
|
|
67
|
+
/** 节点点击回调 */
|
|
68
|
+
onNodeClick?: (nodeId: string) => void;
|
|
69
|
+
/** Current locale. Defaults to zh-CN. */
|
|
70
|
+
locale?: string;
|
|
71
|
+
/** Extra locale messages merged into the selected locale. */
|
|
72
|
+
messages?: LocaleMessages;
|
|
73
|
+
/** Host-provided translation function. */
|
|
74
|
+
t?: EditorTranslate;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* MiniMap 组件
|
|
78
|
+
*
|
|
79
|
+
* 显示画布全局缩略图,方便大型规则链的导航。
|
|
80
|
+
*/
|
|
81
|
+
declare const MiniMap: React.FC<MiniMapProps>;
|
|
82
|
+
export default MiniMap;
|
|
83
|
+
//# sourceMappingURL=MiniMap.d.ts.map
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/NodePropertyDrawer.tsx
|
|
3
|
+
* @description 节点属性编辑抽屉 — React 实现
|
|
4
|
+
*
|
|
5
|
+
* 功能:
|
|
6
|
+
* - 双击节点弹出侧边抽屉,编辑节点配置
|
|
7
|
+
* - 根据组件 fields 定义动态渲染表单(string/bool/int/float/map/array/script)
|
|
8
|
+
* - 支持节点 ID、名称、调试模式、描述等基础字段
|
|
9
|
+
* - 提交后通过 onSubmit 回调更新节点属性
|
|
10
|
+
* - 零 UI 框架依赖(纯 React + CSS)
|
|
11
|
+
*
|
|
12
|
+
* @see ComponentField — 字段定义类型
|
|
13
|
+
*/
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
16
|
+
import type { EditorTranslate } from '../i18n';
|
|
17
|
+
export type FieldOption = string | {
|
|
18
|
+
label?: string;
|
|
19
|
+
value?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
export interface GraphNodeOptionSource {
|
|
25
|
+
id?: string;
|
|
26
|
+
nodeId?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
text?: string | {
|
|
29
|
+
value?: string;
|
|
30
|
+
};
|
|
31
|
+
type?: string;
|
|
32
|
+
properties?: Record<string, unknown>;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface RuleChainOptionSource {
|
|
36
|
+
id?: string;
|
|
37
|
+
value?: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
label?: string;
|
|
40
|
+
desc?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
root?: boolean;
|
|
43
|
+
ruleChain?: Record<string, unknown>;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface RuleChainFetchParams {
|
|
47
|
+
root: boolean;
|
|
48
|
+
keywords: string;
|
|
49
|
+
page: number;
|
|
50
|
+
size: number;
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}
|
|
53
|
+
export interface RuleChainFetchResult {
|
|
54
|
+
items?: RuleChainOptionSource[];
|
|
55
|
+
records?: RuleChainOptionSource[];
|
|
56
|
+
rows?: RuleChainOptionSource[];
|
|
57
|
+
list?: RuleChainOptionSource[];
|
|
58
|
+
total?: number;
|
|
59
|
+
page?: number;
|
|
60
|
+
current?: number;
|
|
61
|
+
size?: number;
|
|
62
|
+
pageSize?: number;
|
|
63
|
+
data?: unknown;
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
}
|
|
66
|
+
/** 组件字段定义 */
|
|
67
|
+
export interface FieldDef {
|
|
68
|
+
/** 字段名 */
|
|
69
|
+
name: string;
|
|
70
|
+
/** 字段类型 */
|
|
71
|
+
type?: string;
|
|
72
|
+
/** 显示标签 */
|
|
73
|
+
label?: string;
|
|
74
|
+
/** 字段描述 */
|
|
75
|
+
desc?: string;
|
|
76
|
+
/** 默认值 */
|
|
77
|
+
defaultValue?: unknown;
|
|
78
|
+
/** 官方 component 协议 */
|
|
79
|
+
component?: {
|
|
80
|
+
type?: string;
|
|
81
|
+
caseType?: string;
|
|
82
|
+
source?: string;
|
|
83
|
+
options?: FieldOption[];
|
|
84
|
+
multiple?: boolean;
|
|
85
|
+
filterable?: boolean;
|
|
86
|
+
allowCreate?: boolean;
|
|
87
|
+
placeholder?: string;
|
|
88
|
+
disabled?: boolean;
|
|
89
|
+
rows?: number;
|
|
90
|
+
};
|
|
91
|
+
/** 兼容旧字段选项协议 */
|
|
92
|
+
options?: FieldOption[];
|
|
93
|
+
/** 嵌套字段定义,官方 struct/table/switch 类字段会使用 */
|
|
94
|
+
fields?: FieldDef[];
|
|
95
|
+
/** 官方 ref 协议:primary/shared 字段会随连接模式联动隐藏 */
|
|
96
|
+
ref?: string;
|
|
97
|
+
/** 是否禁用 */
|
|
98
|
+
disabled?: boolean;
|
|
99
|
+
/** 校验规则 */
|
|
100
|
+
rules?: unknown[];
|
|
101
|
+
}
|
|
102
|
+
/** 节点模型数据 */
|
|
103
|
+
export interface NodeModel {
|
|
104
|
+
/** LogicFlow 节点 ID */
|
|
105
|
+
id: string;
|
|
106
|
+
/** RuleGo 节点 ID */
|
|
107
|
+
nodeId?: string;
|
|
108
|
+
/** 节点类型 */
|
|
109
|
+
type: string;
|
|
110
|
+
/** 节点名称 */
|
|
111
|
+
name: string;
|
|
112
|
+
/** 调试模式 */
|
|
113
|
+
debugMode?: boolean;
|
|
114
|
+
/** 节点配置 */
|
|
115
|
+
configuration?: Record<string, unknown>;
|
|
116
|
+
/** 附加信息(描述等) */
|
|
117
|
+
additionalInfo?: Record<string, unknown>;
|
|
118
|
+
/** 额外属性 */
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
}
|
|
121
|
+
/** 节点视图定义(组件定义) */
|
|
122
|
+
export interface NodeView {
|
|
123
|
+
/** 组件类型 */
|
|
124
|
+
type: string;
|
|
125
|
+
/** 显示标签 */
|
|
126
|
+
label?: string;
|
|
127
|
+
/** 描述 */
|
|
128
|
+
desc?: string;
|
|
129
|
+
/** 字段定义列表 */
|
|
130
|
+
fields?: FieldDef[];
|
|
131
|
+
/** 额外属性 */
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
/** NodePropertyDrawer Props */
|
|
135
|
+
export interface NodePropertyDrawerProps {
|
|
136
|
+
/** 是否显示 */
|
|
137
|
+
visible: boolean;
|
|
138
|
+
/** 节点模型数据 */
|
|
139
|
+
nodeModel: NodeModel | null;
|
|
140
|
+
/** 节点视图/组件定义 */
|
|
141
|
+
nodeView: NodeView | null;
|
|
142
|
+
/** 提交回调 */
|
|
143
|
+
onSubmit: (model: NodeModel) => void;
|
|
144
|
+
/** 关闭回调 */
|
|
145
|
+
onClose: () => void;
|
|
146
|
+
/** Current locale. Defaults to zh-CN. */
|
|
147
|
+
locale?: string;
|
|
148
|
+
/** Extra locale messages merged into the selected locale. */
|
|
149
|
+
messages?: LocaleMessages;
|
|
150
|
+
/** Host-provided translation function. */
|
|
151
|
+
t?: EditorTranslate;
|
|
152
|
+
/** Current graph nodes for official component.source=nodes hydration. */
|
|
153
|
+
graphNodes?: GraphNodeOptionSource[];
|
|
154
|
+
/** Rule chain list for official component.source=ruleChains hydration. */
|
|
155
|
+
ruleItems?: RuleChainOptionSource[];
|
|
156
|
+
/** Current rule chain used to avoid selecting itself in rule-chain fields. */
|
|
157
|
+
currentRuleChain?: RuleChainOptionSource | null;
|
|
158
|
+
/** Explicit /rules endpoint. If omitted, apiBase + /rules is used. */
|
|
159
|
+
rulesApi?: string;
|
|
160
|
+
/** API base ending at /api/v1 for remote rule-chain selector loading. */
|
|
161
|
+
apiBase?: string;
|
|
162
|
+
/** Page size for rule-chain selector modal. Defaults to 12. */
|
|
163
|
+
rulePageSize?: number;
|
|
164
|
+
/** Host override for remote rule-chain selector loading. */
|
|
165
|
+
fetchRuleChains?: (params: RuleChainFetchParams) => Promise<RuleChainFetchResult | RuleChainOptionSource[] | unknown>;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* NodePropertyDrawer 组件
|
|
169
|
+
*
|
|
170
|
+
* 纯 React 实现的节点属性编辑抽屉,无 antd 依赖。
|
|
171
|
+
* 根据组件 fields 动态渲染表单,支持多种字段类型。
|
|
172
|
+
*/
|
|
173
|
+
declare const NodePropertyDrawer: React.FC<NodePropertyDrawerProps>;
|
|
174
|
+
export default NodePropertyDrawer;
|
|
175
|
+
//# sourceMappingURL=NodePropertyDrawer.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/RuleChainSettings.tsx
|
|
3
|
+
* @description 规则链设置对话框 — React 实现
|
|
4
|
+
*
|
|
5
|
+
* 功能:
|
|
6
|
+
* - 编辑规则链元数据(名称/描述/调试模式等)
|
|
7
|
+
* - 管理规则链全局配置
|
|
8
|
+
* - 模态对话框展示
|
|
9
|
+
* - 表单验证
|
|
10
|
+
* - 零 UI 框架依赖(纯 React + CSS)
|
|
11
|
+
*
|
|
12
|
+
* @see RuleChainSettingsProps — 设置参数
|
|
13
|
+
*/
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
16
|
+
import type { EditorTranslate } from '../i18n';
|
|
17
|
+
/** 规则链设置数据 */
|
|
18
|
+
export interface RuleChainSettingsData {
|
|
19
|
+
/** 规则链 ID */
|
|
20
|
+
id?: string;
|
|
21
|
+
/** 规则链名称 */
|
|
22
|
+
name: string;
|
|
23
|
+
/** 是否为根链 */
|
|
24
|
+
root?: boolean;
|
|
25
|
+
/** 是否开启调试模式 */
|
|
26
|
+
debugMode?: boolean;
|
|
27
|
+
/** 描述 */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** 额外配置(JSON) */
|
|
30
|
+
additionalInfo?: Record<string, unknown>;
|
|
31
|
+
/** 自定义字段 */
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
/** RuleChainSettings Props */
|
|
35
|
+
export interface RuleChainSettingsProps {
|
|
36
|
+
/** 是否可见 */
|
|
37
|
+
visible: boolean;
|
|
38
|
+
/** 当前设置数据 */
|
|
39
|
+
data: RuleChainSettingsData;
|
|
40
|
+
/** 是否只读 */
|
|
41
|
+
readOnly?: boolean;
|
|
42
|
+
/** 对话框标题 */
|
|
43
|
+
title?: string;
|
|
44
|
+
/** 额外的自定义字段定义 */
|
|
45
|
+
customFields?: Array<{
|
|
46
|
+
/** 字段名 */
|
|
47
|
+
key: string;
|
|
48
|
+
/** 显示名称 */
|
|
49
|
+
label: string;
|
|
50
|
+
/** 字段类型 */
|
|
51
|
+
type: 'text' | 'number' | 'select' | 'textarea' | 'switch';
|
|
52
|
+
/** select 的选项 */
|
|
53
|
+
options?: Array<{
|
|
54
|
+
label: string;
|
|
55
|
+
value: string;
|
|
56
|
+
}>;
|
|
57
|
+
/** 默认值 */
|
|
58
|
+
defaultValue?: unknown;
|
|
59
|
+
/** 提示 */
|
|
60
|
+
placeholder?: string;
|
|
61
|
+
/** 帮助文本 */
|
|
62
|
+
help?: string;
|
|
63
|
+
}>;
|
|
64
|
+
/** 保存回调 */
|
|
65
|
+
onSave?: (data: RuleChainSettingsData) => void;
|
|
66
|
+
/** 取消 / 关闭 */
|
|
67
|
+
onClose: () => void;
|
|
68
|
+
/** Current locale. Defaults to zh-CN. */
|
|
69
|
+
locale?: string;
|
|
70
|
+
/** Extra locale messages merged into the selected locale. */
|
|
71
|
+
messages?: LocaleMessages;
|
|
72
|
+
/** Host-provided translation function. */
|
|
73
|
+
t?: EditorTranslate;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* RuleChainSettings 组件
|
|
77
|
+
*
|
|
78
|
+
* 模态对话框形式的规则链设置面板。
|
|
79
|
+
*/
|
|
80
|
+
declare const RuleChainSettings: React.FC<RuleChainSettingsProps>;
|
|
81
|
+
export default RuleChainSettings;
|
|
82
|
+
//# sourceMappingURL=RuleChainSettings.d.ts.map
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/RuleGoEditor.tsx
|
|
3
|
+
* @description React 薄封装 — 直接复用 @huanban/rulego-editor-core 的 HuanbanRulegoEditor
|
|
4
|
+
*
|
|
5
|
+
* 设计理念:
|
|
6
|
+
* - 所有编辑器核心逻辑(工具栏、侧边栏、组件列表、上下文菜单、属性面板、
|
|
7
|
+
* 小地图、键盘快捷键等)全部在 editor-core 的 HuanbanRulegoEditor 中实现
|
|
8
|
+
* - React 版只负责: 挂载 DOM → 创建实例 → 代理 Props → 卸载时销毁
|
|
9
|
+
* - 这样 React / Vue / Angular 的封装都只需 ~100 行, 功能自动与 JS 版对齐
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { RuleGoEditor } from '@huanban/rulego-editor-react'
|
|
14
|
+
*
|
|
15
|
+
* function App() {
|
|
16
|
+
* return (
|
|
17
|
+
* <RuleGoEditor
|
|
18
|
+
* apiBase="http://127.0.0.1:9090/api/v1"
|
|
19
|
+
* data={ruleChainData}
|
|
20
|
+
* components={componentsList}
|
|
21
|
+
* onSave={(data) => console.log('保存', data)}
|
|
22
|
+
* onReady={({ lf, core }) => console.log('就绪')}
|
|
23
|
+
* />
|
|
24
|
+
* )
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @see HuanbanRulegoEditor — 核心引擎 (editor-core)
|
|
29
|
+
*/
|
|
30
|
+
import React from 'react';
|
|
31
|
+
import { HuanbanRulegoEditor } from '@huanban/rulego-editor-core';
|
|
32
|
+
import type { AIAssistantOpenOptions, HuanbanRulegoEditorOptions } from '@huanban/rulego-editor-core';
|
|
33
|
+
import type { EditorCore } from '@huanban/rulego-editor-core';
|
|
34
|
+
import type { RuleChainData, RawComponentData } from '@huanban/rulego-editor-core';
|
|
35
|
+
import LogicFlow from '@logicflow/core';
|
|
36
|
+
/**
|
|
37
|
+
* RuleGoEditor 组件 Props
|
|
38
|
+
*
|
|
39
|
+
* 大部分选项直接透传给 HuanbanRulegoEditor (editor-core)
|
|
40
|
+
* React 特有的只有: className, style, width, height, ref
|
|
41
|
+
*/
|
|
42
|
+
export interface RuleGoEditorProps {
|
|
43
|
+
/** 容器高度, 默认 '100%' */
|
|
44
|
+
height?: string | number;
|
|
45
|
+
/** 容器宽度, 默认 '100%' */
|
|
46
|
+
width?: string | number;
|
|
47
|
+
/** className */
|
|
48
|
+
className?: string;
|
|
49
|
+
/** style */
|
|
50
|
+
style?: React.CSSProperties;
|
|
51
|
+
/** API 基础地址 (如 'http://127.0.0.1:9090/api/v1') */
|
|
52
|
+
apiBase?: string;
|
|
53
|
+
/** 请求超时毫秒数, 默认 5000 */
|
|
54
|
+
fetchTimeout?: number;
|
|
55
|
+
/**
|
|
56
|
+
* 自定义请求头 — 用于注入 Authorization Token 等认证信息
|
|
57
|
+
* 支持静态对象或动态函数(每次请求时调用获取最新 Token)
|
|
58
|
+
*/
|
|
59
|
+
fetchHeaders?: Record<string, string> | (() => Record<string, string>);
|
|
60
|
+
/**
|
|
61
|
+
* 自定义 fetch 函数 — 完全替换原生 fetch
|
|
62
|
+
* 当需要自定义请求逻辑(如统一认证拦截、请求签名、错误重试等)时使用
|
|
63
|
+
* 函数签名: (url: string, init: RequestInit) => Promise<Response>
|
|
64
|
+
*/
|
|
65
|
+
customFetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
66
|
+
/** 初始规则链数据 */
|
|
67
|
+
data?: RuleChainData | null;
|
|
68
|
+
/** 初始组件列表,支持数组或官方 /api/v1/components 分段返回 */
|
|
69
|
+
components?: RawComponentData;
|
|
70
|
+
/** 是否显示工具栏, 默认 true */
|
|
71
|
+
showToolbar?: boolean;
|
|
72
|
+
/** 工具栏左侧标题 */
|
|
73
|
+
toolbarTitle?: string;
|
|
74
|
+
/** 是否显示工具栏按钮文字,默认 false;设为 true 时显示图标 + 文字 */
|
|
75
|
+
showToolbarButtonLabels?: boolean;
|
|
76
|
+
/** 工具栏是否只显示图标,默认 true;显式 false 时可显示文字 */
|
|
77
|
+
toolbarIconOnly?: boolean;
|
|
78
|
+
/** 是否显示侧边栏, 默认 true */
|
|
79
|
+
showSidebar?: boolean;
|
|
80
|
+
/** 侧边栏宽度, 默认 220 */
|
|
81
|
+
sidebarWidth?: number;
|
|
82
|
+
/** 侧边栏是否默认收起 */
|
|
83
|
+
sidebarCollapsed?: boolean;
|
|
84
|
+
/** 是否显示信息按钮 */
|
|
85
|
+
showInfoButton?: boolean;
|
|
86
|
+
/** 是否显示 AI 助手按钮 */
|
|
87
|
+
showAiChatButton?: boolean;
|
|
88
|
+
/** 是否显示设置按钮 */
|
|
89
|
+
showSettingsButton?: boolean;
|
|
90
|
+
/** 是否显示调试面板按钮 */
|
|
91
|
+
showDebugConsoleButton?: boolean;
|
|
92
|
+
/** 是否显示清除调试高亮按钮 */
|
|
93
|
+
showClearDebugHighlightButton?: boolean;
|
|
94
|
+
/** 是否显示框选按钮 */
|
|
95
|
+
showSelectionButton?: boolean;
|
|
96
|
+
/** 是否显示导出按钮, 默认 true */
|
|
97
|
+
showExportDialog?: boolean;
|
|
98
|
+
/** 是否显示运行按钮 */
|
|
99
|
+
showRunButton?: boolean;
|
|
100
|
+
/** 是否显示组件管理按钮 */
|
|
101
|
+
showComponentManage?: boolean;
|
|
102
|
+
/** 是否显示部署按钮, 默认 true */
|
|
103
|
+
showDeployButton?: boolean;
|
|
104
|
+
/** 是否显示运行记录按钮 */
|
|
105
|
+
showRunHistory?: boolean;
|
|
106
|
+
/** 运行记录 URL (支持 {chainId} 占位符) */
|
|
107
|
+
runHistoryUrl?: string;
|
|
108
|
+
/** 是否在工具栏显示「链追溯」按钮, 默认 false */
|
|
109
|
+
showTraceButton?: boolean;
|
|
110
|
+
/** 是否显示调试日志 Tab */
|
|
111
|
+
showDebugTab?: boolean;
|
|
112
|
+
/** 语言设置, 默认 'zh_cn' */
|
|
113
|
+
locale?: string;
|
|
114
|
+
/** LogicFlow 额外配置 (与默认配置合并) */
|
|
115
|
+
lfOptions?: Record<string, unknown>;
|
|
116
|
+
/** LogicFlow 插件数组 */
|
|
117
|
+
lfPlugins?: any[];
|
|
118
|
+
/** EditorCore 额外配置 */
|
|
119
|
+
coreOptions?: Record<string, unknown>;
|
|
120
|
+
/** 直接透传给 HuanbanRulegoEditor 的扩展配置,显式 props 会覆盖这里的同名字段 */
|
|
121
|
+
options?: Partial<HuanbanRulegoEditorOptions>;
|
|
122
|
+
/** 编辑器就绪 */
|
|
123
|
+
onReady?: (ctx: {
|
|
124
|
+
lf: LogicFlow;
|
|
125
|
+
core: EditorCore;
|
|
126
|
+
}) => void;
|
|
127
|
+
/** 保存回调 */
|
|
128
|
+
onSave?: (data: unknown) => void | boolean | {
|
|
129
|
+
success?: boolean;
|
|
130
|
+
msg?: string;
|
|
131
|
+
message?: string;
|
|
132
|
+
} | Promise<void | boolean | {
|
|
133
|
+
success?: boolean;
|
|
134
|
+
msg?: string;
|
|
135
|
+
message?: string;
|
|
136
|
+
}>;
|
|
137
|
+
/** 节点点击 */
|
|
138
|
+
onNodeClick?: (data: unknown) => void;
|
|
139
|
+
/** 节点双击 */
|
|
140
|
+
onNodeDbClick?: (data: unknown) => void;
|
|
141
|
+
/** 边点击 */
|
|
142
|
+
onEdgeClick?: (data: unknown) => void;
|
|
143
|
+
/** 数据变化 */
|
|
144
|
+
onChange?: () => void;
|
|
145
|
+
/** 点击信息按钮 */
|
|
146
|
+
onInfoClick?: (chainInfo: any) => void;
|
|
147
|
+
/** 劫持导出 */
|
|
148
|
+
onExportDSL?: (data: {
|
|
149
|
+
json: string;
|
|
150
|
+
imageDataUrl?: string;
|
|
151
|
+
}) => void;
|
|
152
|
+
/** 劫持运行 */
|
|
153
|
+
onRunClick?: (chainId: string) => void;
|
|
154
|
+
/** 点击「链追溯」按钮回调,回传当前完整的规则链数据 (用于构建追溯底图) */
|
|
155
|
+
onTraceClick?: (chainInfo: any) => void;
|
|
156
|
+
/** 劫持组件管理 */
|
|
157
|
+
onComponentManage?: () => void;
|
|
158
|
+
/** 语言切换回调 */
|
|
159
|
+
onLocaleChange?: (locale: string) => void;
|
|
160
|
+
/** 劫持部署 */
|
|
161
|
+
onDeploy?: (chainId: string, action: 'deploy' | 'undeploy' | 'reload') => void | boolean | {
|
|
162
|
+
success?: boolean;
|
|
163
|
+
msg?: string;
|
|
164
|
+
message?: string;
|
|
165
|
+
} | Promise<void | boolean | {
|
|
166
|
+
success?: boolean;
|
|
167
|
+
msg?: string;
|
|
168
|
+
message?: string;
|
|
169
|
+
}>;
|
|
170
|
+
/** 选择规则链 */
|
|
171
|
+
onSelectRuleChain?: (ruleChain: any) => void;
|
|
172
|
+
/** 删除规则链 */
|
|
173
|
+
onDeleteRuleChain?: (chainId: string) => void;
|
|
174
|
+
/** 劫持运行记录 */
|
|
175
|
+
onRunHistory?: (chainId: string) => void;
|
|
176
|
+
/** 规则链列表数据 */
|
|
177
|
+
ruleItems?: any[];
|
|
178
|
+
/** 规则链 API 地址 */
|
|
179
|
+
rulesApi?: string;
|
|
180
|
+
/**
|
|
181
|
+
* 自定义无头节点渲染器
|
|
182
|
+
* 当使用 HeadlessHtmlNode 时,核心引擎会派发 `node:html-mount` 事件。
|
|
183
|
+
* React 适配层会捕获该事件并调用本函数,将返回的 React 节点通过 Portal 挂载到画布内部。
|
|
184
|
+
*/
|
|
185
|
+
renderNode?: (type: string, data: any, model: any) => React.ReactNode;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* RuleGoEditor 的命令式 API
|
|
189
|
+
* 通过 useRef + forwardRef 暴露给父组件
|
|
190
|
+
*/
|
|
191
|
+
export interface RuleGoEditorRef {
|
|
192
|
+
/** HuanbanRulegoEditor 实例 (editor-core) */
|
|
193
|
+
editor: HuanbanRulegoEditor | null;
|
|
194
|
+
/** LogicFlow 实例 */
|
|
195
|
+
lf: LogicFlow | null;
|
|
196
|
+
/** EditorCore 实例 */
|
|
197
|
+
core: EditorCore | null;
|
|
198
|
+
/** 重新加载数据 */
|
|
199
|
+
loadData: (data: RuleChainData) => void;
|
|
200
|
+
/** 重新加载组件 */
|
|
201
|
+
loadComponents: (components: RawComponentData) => void;
|
|
202
|
+
/** 导出数据 */
|
|
203
|
+
exportData: () => RuleChainData | null;
|
|
204
|
+
/** 切换小地图 */
|
|
205
|
+
toggleMiniMap: () => void;
|
|
206
|
+
/** 手动触发自动排版 — 基于 DAG 拓扑排序重新排列节点 */
|
|
207
|
+
autoLayout: () => void;
|
|
208
|
+
/** 打开独立设置弹窗 */
|
|
209
|
+
openSettings: (initialTab?: 'user' | 'setting' | 'ai' | 'skills') => void;
|
|
210
|
+
/** 打开 AI 助手侧栏 */
|
|
211
|
+
openAiAssistant: (options?: AIAssistantOpenOptions) => void;
|
|
212
|
+
/** 关闭 AI 助手侧栏 */
|
|
213
|
+
closeAiAssistant: () => void;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* RuleGoEditor — React 封装组件
|
|
217
|
+
*
|
|
218
|
+
* 内部直接使用 editor-core 的 HuanbanRulegoEditor,
|
|
219
|
+
* 所有功能与原生 JS 版完全一致:
|
|
220
|
+
* - 工具栏 (保存/撤销/重做/导出/部署/运行/语言/主题)
|
|
221
|
+
* - 组件侧边栏 (分类折叠/搜索/拖拽添加)
|
|
222
|
+
* - 画布 (LogicFlow 2.x)
|
|
223
|
+
* - 右键菜单
|
|
224
|
+
* - 节点/边属性抽屉
|
|
225
|
+
* - 小地图
|
|
226
|
+
* - 键盘快捷键
|
|
227
|
+
*/
|
|
228
|
+
declare const RuleGoEditor: React.ForwardRefExoticComponent<RuleGoEditorProps & React.RefAttributes<RuleGoEditorRef>>;
|
|
229
|
+
export default RuleGoEditor;
|
|
230
|
+
//# sourceMappingURL=RuleGoEditor.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { EditorTranslate } from '../i18n';
|
|
3
|
+
import type { LocaleMessages, WorkflowFetcher, WorkflowItem } from '@huanban/rulego-editor-core';
|
|
4
|
+
export interface RuleMaintenancePanelProps {
|
|
5
|
+
workflow: WorkflowItem;
|
|
6
|
+
fetcher: WorkflowFetcher | null;
|
|
7
|
+
content: Record<string, unknown> | null;
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
locale?: string;
|
|
10
|
+
messages?: LocaleMessages;
|
|
11
|
+
t?: EditorTranslate;
|
|
12
|
+
}
|
|
13
|
+
export declare const RuleMaintenancePanel: React.FC<RuleMaintenancePanelProps>;
|
|
14
|
+
export default RuleMaintenancePanel;
|
|
15
|
+
//# sourceMappingURL=RuleMaintenancePanel.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file SearchPanel.tsx
|
|
3
|
+
* @description 节点搜索面板
|
|
4
|
+
*
|
|
5
|
+
* 功能:
|
|
6
|
+
* - 按名称、类型、ID 搜索规则链中的节点
|
|
7
|
+
* - 实时过滤和高亮匹配结果
|
|
8
|
+
* - 点击搜索结果定位到对应节点
|
|
9
|
+
* - 支持快捷键触发 (Ctrl/Cmd + F)
|
|
10
|
+
* - 支持搜索历史记录(会话内)
|
|
11
|
+
*
|
|
12
|
+
* 设计:
|
|
13
|
+
* - 纯 React + CSS,无外部 UI 库依赖
|
|
14
|
+
* - rge- 前缀 CSS 类名避免冲突
|
|
15
|
+
* - 通过回调 props 处理节点定位
|
|
16
|
+
*/
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
19
|
+
import type { EditorTranslate } from '../i18n';
|
|
20
|
+
/** 搜索结果项 */
|
|
21
|
+
export interface SearchResultItem {
|
|
22
|
+
/** 节点 ID */
|
|
23
|
+
id: string;
|
|
24
|
+
/** 节点名称 */
|
|
25
|
+
name: string;
|
|
26
|
+
/** 节点类型 */
|
|
27
|
+
type: string;
|
|
28
|
+
/** 组件类型显示名 */
|
|
29
|
+
typeLabel?: string;
|
|
30
|
+
/** 附加信息 (如配置片段) */
|
|
31
|
+
extra?: string;
|
|
32
|
+
}
|
|
33
|
+
/** SearchPanel 属性 */
|
|
34
|
+
export interface SearchPanelProps {
|
|
35
|
+
/** 所有可搜索的节点列表 */
|
|
36
|
+
nodes: SearchResultItem[];
|
|
37
|
+
/** 点击搜索结果回调 — 定位到对应节点 */
|
|
38
|
+
onSelectNode?: (nodeId: string) => void;
|
|
39
|
+
/** 关闭搜索面板回调 */
|
|
40
|
+
onClose: () => void;
|
|
41
|
+
/** 面板位置 */
|
|
42
|
+
position?: 'top-center' | 'top-right';
|
|
43
|
+
/** Current locale. Defaults to zh-CN. */
|
|
44
|
+
locale?: string;
|
|
45
|
+
/** Extra locale messages merged into the selected locale. */
|
|
46
|
+
messages?: LocaleMessages;
|
|
47
|
+
/** Host-provided translation function. */
|
|
48
|
+
t?: EditorTranslate;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* SearchPanel 组件
|
|
52
|
+
*
|
|
53
|
+
* @description
|
|
54
|
+
* 提供节点搜索功能。输入关键词后实时过滤匹配节点,
|
|
55
|
+
* 点击搜索结果可定位到画布中对应的节点。
|
|
56
|
+
* 使用 ESC 键或关闭按钮关闭面板。
|
|
57
|
+
*/
|
|
58
|
+
declare const SearchPanel: React.FC<SearchPanelProps>;
|
|
59
|
+
export default SearchPanel;
|
|
60
|
+
//# sourceMappingURL=SearchPanel.d.ts.map
|