@huanban/rulego-editor-react 1.3.18 → 1.4.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/README.md +304 -10
- package/dist/components/AIAssistant.d.ts +1 -7
- package/dist/components/ComponentSidebar.d.ts +13 -52
- package/dist/components/ContextMenu.d.ts +1 -59
- package/dist/components/CopilotChat.d.ts +27 -22
- package/dist/components/DataViewDialog.d.ts +0 -33
- package/dist/components/DebugPanel.d.ts +5 -65
- package/dist/components/DynamicForm.d.ts +0 -40
- package/dist/components/EdgePropertyDrawer.d.ts +0 -35
- package/dist/components/EditorConnectionStatus.d.ts +12 -0
- package/dist/components/EditorEdgeHoverTools.d.ts +11 -0
- package/dist/components/EditorIcon.d.ts +7 -0
- package/dist/components/EditorNodeHoverTools.d.ts +16 -0
- package/dist/components/EditorPanelDock.d.ts +18 -0
- package/dist/components/EditorStatusBar.d.ts +34 -0
- package/dist/components/EditorToolbar.d.ts +2 -62
- package/dist/components/ImportExportDialog.d.ts +1 -37
- package/dist/components/LogViewer.d.ts +0 -29
- package/dist/components/MiniMap.d.ts +0 -46
- package/dist/components/NodePropertyDrawer.d.ts +19 -102
- package/dist/components/ProblemsPanel.d.ts +21 -0
- package/dist/components/RuleChainSettings.d.ts +0 -45
- package/dist/components/RuleGoEditor.d.ts +37 -147
- package/dist/components/RuleMaintenancePanel.d.ts +0 -1
- package/dist/components/SearchPanel.d.ts +0 -39
- package/dist/components/SearchableSelect.d.ts +0 -1
- package/dist/components/ValidationPanel.d.ts +0 -39
- package/dist/components/WorkflowExplorer.d.ts +24 -0
- package/dist/components/WorkflowInfoPanel.d.ts +1 -36
- package/dist/components/WorkflowList.d.ts +2 -69
- package/dist/components/WorkspaceTabs.d.ts +17 -0
- package/dist/components/properties/AgentOrchestrationProperties.d.ts +2 -1
- package/dist/hooks/useBoundStore.d.ts +8 -0
- package/dist/hooks/useClipboard.d.ts +2 -63
- package/dist/hooks/useEditorCore.d.ts +0 -79
- package/dist/hooks/useEditorI18n.d.ts +0 -26
- package/dist/hooks/useEditorPanels.d.ts +23 -0
- package/dist/hooks/useEditorShell.d.ts +35 -0
- package/dist/hooks/useEditorTheme.d.ts +0 -30
- package/dist/hooks/useEditorWorkspace.d.ts +25 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +4 -44
- package/dist/i18n.d.ts +6 -4
- package/dist/index.cjs +17 -0
- package/dist/index.d.ts +28 -62
- package/dist/index.esm.js +6235 -104685
- package/dist/style.css +1 -1
- package/package.json +13 -8
- package/dist/index.cjs.js +0 -9470
|
@@ -1,60 +1,21 @@
|
|
|
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
1
|
import React from 'react';
|
|
18
2
|
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
19
3
|
import type { EditorTranslate } from '../i18n';
|
|
20
|
-
/** 搜索结果项 */
|
|
21
4
|
export interface SearchResultItem {
|
|
22
|
-
/** 节点 ID */
|
|
23
5
|
id: string;
|
|
24
|
-
/** 节点名称 */
|
|
25
6
|
name: string;
|
|
26
|
-
/** 节点类型 */
|
|
27
7
|
type: string;
|
|
28
|
-
/** 组件类型显示名 */
|
|
29
8
|
typeLabel?: string;
|
|
30
|
-
/** 附加信息 (如配置片段) */
|
|
31
9
|
extra?: string;
|
|
32
10
|
}
|
|
33
|
-
/** SearchPanel 属性 */
|
|
34
11
|
export interface SearchPanelProps {
|
|
35
|
-
/** 所有可搜索的节点列表 */
|
|
36
12
|
nodes: SearchResultItem[];
|
|
37
|
-
/** 点击搜索结果回调 — 定位到对应节点 */
|
|
38
13
|
onSelectNode?: (nodeId: string) => void;
|
|
39
|
-
/** 关闭搜索面板回调 */
|
|
40
14
|
onClose: () => void;
|
|
41
|
-
/** 面板位置 */
|
|
42
15
|
position?: 'top-center' | 'top-right';
|
|
43
|
-
/** Current locale. Defaults to zh-CN. */
|
|
44
16
|
locale?: string;
|
|
45
|
-
/** Extra locale messages merged into the selected locale. */
|
|
46
17
|
messages?: LocaleMessages;
|
|
47
|
-
/** Host-provided translation function. */
|
|
48
18
|
t?: EditorTranslate;
|
|
49
19
|
}
|
|
50
|
-
/**
|
|
51
|
-
* SearchPanel 组件
|
|
52
|
-
*
|
|
53
|
-
* @description
|
|
54
|
-
* 提供节点搜索功能。输入关键词后实时过滤匹配节点,
|
|
55
|
-
* 点击搜索结果可定位到画布中对应的节点。
|
|
56
|
-
* 使用 ESC 键或关闭按钮关闭面板。
|
|
57
|
-
*/
|
|
58
20
|
declare const SearchPanel: React.FC<SearchPanelProps>;
|
|
59
21
|
export default SearchPanel;
|
|
60
|
-
//# sourceMappingURL=SearchPanel.d.ts.map
|
|
@@ -1,65 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/ValidationPanel.tsx
|
|
3
|
-
* @description 规则链验证面板 — React 实现
|
|
4
|
-
*
|
|
5
|
-
* 功能:
|
|
6
|
-
* - 显示验证结果(错误/警告/信息)
|
|
7
|
-
* - 按级别分组展示
|
|
8
|
-
* - 点击错误项高亮对应节点/边
|
|
9
|
-
* - 支持手动触发验证
|
|
10
|
-
* - 统计信息展示
|
|
11
|
-
* - 零 UI 框架依赖(纯 React + CSS)
|
|
12
|
-
*
|
|
13
|
-
* @see ValidationPanelProps — 面板参数
|
|
14
|
-
*/
|
|
15
1
|
import React from 'react';
|
|
16
2
|
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
17
3
|
import type { EditorTranslate } from '../i18n';
|
|
18
|
-
/** 验证错误项 */
|
|
19
4
|
export interface ValidationItem {
|
|
20
|
-
/** 规则名称 */
|
|
21
5
|
rule: string;
|
|
22
|
-
/** 错误级别 */
|
|
23
6
|
level: 'error' | 'warning' | 'info';
|
|
24
|
-
/** 错误消息 */
|
|
25
7
|
message: string;
|
|
26
|
-
/** 关联的元素 ID */
|
|
27
8
|
elementId?: string;
|
|
28
|
-
/** 关联的元素类型 */
|
|
29
9
|
elementType?: 'node' | 'edge';
|
|
30
10
|
}
|
|
31
|
-
/** ValidationPanel Props */
|
|
32
11
|
export interface ValidationPanelProps {
|
|
33
|
-
/** 验证结果列表 */
|
|
34
12
|
items: ValidationItem[];
|
|
35
|
-
/** 是否验证通过 */
|
|
36
13
|
isValid?: boolean;
|
|
37
|
-
/** 是否可见 */
|
|
38
14
|
visible?: boolean;
|
|
39
|
-
/** 是否正在验证中 */
|
|
40
15
|
loading?: boolean;
|
|
41
|
-
/** 面板标题 */
|
|
42
16
|
title?: string;
|
|
43
|
-
/** 手动触发验证 */
|
|
44
17
|
onValidate?: () => void;
|
|
45
|
-
/** 点击验证项(跳转到对应元素) */
|
|
46
18
|
onItemClick?: (item: ValidationItem) => void;
|
|
47
|
-
/** 关闭面板 */
|
|
48
19
|
onClose?: () => void;
|
|
49
|
-
/** 清除验证结果 */
|
|
50
20
|
onClear?: () => void;
|
|
51
|
-
/** Current locale. Defaults to zh-CN. */
|
|
52
21
|
locale?: string;
|
|
53
|
-
/** Extra locale messages merged into the selected locale. */
|
|
54
22
|
messages?: LocaleMessages;
|
|
55
|
-
/** Host-provided translation function. */
|
|
56
23
|
t?: EditorTranslate;
|
|
57
24
|
}
|
|
58
|
-
/**
|
|
59
|
-
* ValidationPanel 组件
|
|
60
|
-
*
|
|
61
|
-
* 显示规则链校验结果,支持点击跳转到问题元素。
|
|
62
|
-
*/
|
|
63
25
|
declare const ValidationPanel: React.FC<ValidationPanelProps>;
|
|
64
26
|
export default ValidationPanel;
|
|
65
|
-
//# sourceMappingURL=ValidationPanel.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExplorerTreeStore, type EditorStatePersistenceOptions, type ExplorerTreePersistenceState, type WorkflowItem } from '@huanban/rulego-editor-core';
|
|
3
|
+
export interface WorkflowExplorerProps {
|
|
4
|
+
workflows: readonly WorkflowItem[];
|
|
5
|
+
store?: ExplorerTreeStore;
|
|
6
|
+
persistence?: EditorStatePersistenceOptions<ExplorerTreePersistenceState>;
|
|
7
|
+
activeChainId?: string;
|
|
8
|
+
keyword?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
emptyText?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
onKeywordChange?: (keyword: string) => void;
|
|
14
|
+
onOpen?: (workflow: WorkflowItem) => void;
|
|
15
|
+
virtualization?: {
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
threshold?: number;
|
|
18
|
+
itemHeight?: number;
|
|
19
|
+
viewportHeight?: number;
|
|
20
|
+
overscan?: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare function WorkflowExplorer({ workflows, store: externalStore, persistence, activeChainId, keyword, placeholder, emptyText, className, style, onKeywordChange, onOpen, virtualization, }: WorkflowExplorerProps): React.JSX.Element;
|
|
24
|
+
export default WorkflowExplorer;
|
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/WorkflowInfoPanel.tsx
|
|
3
|
-
* @description 工作流信息面板组件 — 支持独立引用
|
|
4
|
-
*
|
|
5
|
-
* 六大替换能力:
|
|
6
|
-
* 1. 请求替换: fetcher prop 或 apiBase
|
|
7
|
-
* 2. CSS 替换: huanban_rulego_info__ 前缀 + CSS 变量
|
|
8
|
-
* 3. Slot 插槽: renderBaseInfo / renderVarsSecrets / renderIntegration / renderExtraTabs
|
|
9
|
-
* 4. 图标替换: icons prop
|
|
10
|
-
* 5. 主题切换: theme prop
|
|
11
|
-
* 6. 事件回调: onSave / onError / onRefresh
|
|
12
|
-
*
|
|
13
|
-
* Tab 页:
|
|
14
|
-
* - 基础信息(ID/名称/根规则链/调试模式/分类/描述/状态)
|
|
15
|
-
* - 输入定义(可视化/JSON Schema 编辑)
|
|
16
|
-
* - 变量(变量与秘钥 key-value 编辑)
|
|
17
|
-
* - 应用集成(API/MCP 地址展示)
|
|
18
|
-
* - 自定义 Tab(通过 renderExtraTabs 扩展)
|
|
19
|
-
*
|
|
20
|
-
* @module @huanban/rulego-editor-react
|
|
21
|
-
*/
|
|
22
1
|
import React from 'react';
|
|
23
2
|
import type { EditorTranslate } from '../i18n';
|
|
24
3
|
import type { LocaleMessages, WorkflowItem, WorkflowFetcher, WorkflowInfoIcons, WorkflowTheme, RuleChainAPIOptions } from '@huanban/rulego-editor-core';
|
|
25
|
-
/** 自定义 Tab 定义 */
|
|
26
4
|
export interface ExtraTab {
|
|
27
5
|
key: string;
|
|
28
6
|
label: React.ReactNode;
|
|
@@ -31,36 +9,24 @@ export interface ExtraTab {
|
|
|
31
9
|
export interface WorkflowInfoPanelProps {
|
|
32
10
|
apiBase?: string;
|
|
33
11
|
apiOptions?: Partial<RuleChainAPIOptions>;
|
|
12
|
+
apiContextKey?: string;
|
|
34
13
|
fetcher?: WorkflowFetcher;
|
|
35
|
-
/** 当前工作流数据 */
|
|
36
14
|
workflow: WorkflowItem | null;
|
|
37
15
|
theme?: WorkflowTheme;
|
|
38
16
|
className?: string;
|
|
39
17
|
style?: React.CSSProperties;
|
|
40
18
|
icons?: Partial<WorkflowInfoIcons>;
|
|
41
|
-
/** 默认激活的 Tab,默认 'base' */
|
|
42
19
|
defaultTab?: string;
|
|
43
|
-
/** 显示维护验证扩展 Tab;该能力依赖宿主后端提供 validate-upstream/schema-diff/repair-plan/patch-preview 扩展接口,默认关闭 */
|
|
44
20
|
showMaintenance?: boolean;
|
|
45
|
-
/** 替换基础信息面板 */
|
|
46
21
|
renderBaseInfo?: (workflow: WorkflowItem, defaultPanel: React.ReactNode) => React.ReactNode;
|
|
47
|
-
/** 替换变量/秘钥面板 */
|
|
48
22
|
renderVarsSecrets?: (workflow: WorkflowItem, defaultPanel: React.ReactNode) => React.ReactNode;
|
|
49
|
-
/** 替换集成面板 */
|
|
50
23
|
renderIntegration?: (workflow: WorkflowItem, apiBase: string, defaultPanel: React.ReactNode) => React.ReactNode;
|
|
51
|
-
/** 追加自定义 Tab */
|
|
52
24
|
renderExtraTabs?: (workflow: WorkflowItem) => ExtraTab[];
|
|
53
|
-
/** 保存成功 */
|
|
54
25
|
onSave?: (type: string) => void;
|
|
55
|
-
/** 出错 */
|
|
56
26
|
onError?: (error: Error) => void;
|
|
57
|
-
/** 请求刷新外部数据 */
|
|
58
27
|
onRefresh?: () => void;
|
|
59
|
-
/** Current locale. Defaults to zh-CN. */
|
|
60
28
|
locale?: string;
|
|
61
|
-
/** Extra locale messages merged into the selected locale. */
|
|
62
29
|
messages?: LocaleMessages;
|
|
63
|
-
/** Host-provided translation function. */
|
|
64
30
|
t?: EditorTranslate;
|
|
65
31
|
}
|
|
66
32
|
export interface WorkflowIntegrationUrls {
|
|
@@ -76,4 +42,3 @@ export interface WorkflowIntegrationUrls {
|
|
|
76
42
|
}
|
|
77
43
|
export declare function buildWorkflowIntegrationUrls(apiBase: string | undefined, workflowId: string): WorkflowIntegrationUrls;
|
|
78
44
|
export declare const WorkflowInfoPanel: React.FC<WorkflowInfoPanelProps>;
|
|
79
|
-
//# sourceMappingURL=WorkflowInfoPanel.d.ts.map
|
|
@@ -1,106 +1,39 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file components/WorkflowList.tsx
|
|
3
|
-
* @description 工作流列表组件 — 支持独立引用
|
|
4
|
-
*
|
|
5
|
-
* 六大替换能力:
|
|
6
|
-
* 1. 请求替换: fetcher prop(实现 WorkflowFetcher 接口)或 apiBase(用内置 fetch)
|
|
7
|
-
* 2. CSS 替换: 所有 class 用 huanban_rulego_list__ 前缀 + CSS 变量,可完全覆盖
|
|
8
|
-
* 3. Slot 插槽: renderHeader / renderActions / renderEmpty / renderCreateForm / renderRow
|
|
9
|
-
* 4. 图标替换: icons prop(传入自定义图标 ReactNode)
|
|
10
|
-
* 5. 主题切换: theme prop('light' | 'dark')
|
|
11
|
-
* 6. 事件回调: onDesign / onInfo / onViewLogs / onChange / onError / onCreateSuccess
|
|
12
|
-
*
|
|
13
|
-
* 使用方式:
|
|
14
|
-
* ```tsx
|
|
15
|
-
* // 最简用法(内置 fetch)
|
|
16
|
-
* <WorkflowList apiBase="http://127.0.0.1:9090/api/v1" />
|
|
17
|
-
*
|
|
18
|
-
* // 完整自定义
|
|
19
|
-
* <WorkflowList
|
|
20
|
-
* fetcher={myFetcher}
|
|
21
|
-
* icons={{ design: <EditOutlined /> }}
|
|
22
|
-
* theme="dark"
|
|
23
|
-
* renderActions={(wf, defaults) => <>{defaults}<MyBtn /></>}
|
|
24
|
-
* onDesign={(id) => navigate(`/editor/${id}`)}
|
|
25
|
-
* />
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @module @huanban/rulego-editor-react
|
|
29
|
-
*/
|
|
30
1
|
import React from 'react';
|
|
31
2
|
import type { WorkflowItem, WorkflowFetcher, WorkflowListIcons, WorkflowTheme, RuleChainAPIOptions, LocaleMessages } from '@huanban/rulego-editor-core';
|
|
32
3
|
import type { EditorTranslate } from '../i18n';
|
|
33
|
-
/**
|
|
34
|
-
* WorkflowList 组件 Props
|
|
35
|
-
*/
|
|
36
4
|
export interface WorkflowListProps {
|
|
37
|
-
/** API 基础地址(用内置 RuleChainAPI) */
|
|
38
5
|
apiBase?: string;
|
|
39
|
-
/** API 配置(传给内置 RuleChainAPI 的完整配置) */
|
|
40
6
|
apiOptions?: Partial<RuleChainAPIOptions>;
|
|
41
|
-
|
|
7
|
+
apiContextKey?: string;
|
|
42
8
|
fetcher?: WorkflowFetcher;
|
|
43
|
-
/** 每页条数,默认 10 */
|
|
44
9
|
pageSize?: number;
|
|
45
|
-
/** 列表布局。grid 更适合作为管理页卡片墙,list 保留旧列表风格。 */
|
|
46
10
|
layout?: 'grid' | 'list';
|
|
47
|
-
/** 新建成功后是否自动调用 onDesign 进入编辑器。默认在传入 onDesign 时开启。 */
|
|
48
11
|
autoOpenAfterCreate?: boolean;
|
|
49
|
-
/** 主题 */
|
|
50
12
|
theme?: WorkflowTheme;
|
|
51
|
-
/** 额外 CSS 类名 */
|
|
52
13
|
className?: string;
|
|
53
|
-
/** 行内样式 */
|
|
54
14
|
style?: React.CSSProperties;
|
|
55
|
-
/** 自定义图标映射 */
|
|
56
15
|
icons?: Partial<WorkflowListIcons>;
|
|
57
|
-
/** 是否显示搜索框,默认 true */
|
|
58
16
|
showSearch?: boolean;
|
|
59
|
-
/** 是否显示新建按钮,默认 true */
|
|
60
17
|
showCreate?: boolean;
|
|
61
|
-
/** 是否显示刷新按钮,默认 true */
|
|
62
18
|
showRefresh?: boolean;
|
|
63
|
-
/** 禁用自动请求和列表操作。常用于后端返回 401/403 后等待宿主登录。 */
|
|
64
19
|
disabled?: boolean;
|
|
65
|
-
/** 禁用时内容区显示的提示文案。 */
|
|
66
20
|
disabledMessage?: string;
|
|
67
|
-
/** Current locale. Defaults to zh-CN. */
|
|
68
21
|
locale?: string;
|
|
69
|
-
/** Extra locale messages merged into the selected locale. */
|
|
70
22
|
messages?: LocaleMessages;
|
|
71
|
-
/** Host-provided translation function. */
|
|
72
23
|
t?: EditorTranslate;
|
|
73
|
-
/** 替换标题栏区域 */
|
|
74
24
|
renderHeader?: (defaultHeader: React.ReactNode) => React.ReactNode;
|
|
75
|
-
/** 替换每行操作按钮 */
|
|
76
25
|
renderActions?: (workflow: WorkflowItem, defaultActions: React.ReactNode) => React.ReactNode;
|
|
77
|
-
/** 替换空状态 */
|
|
78
26
|
renderEmpty?: () => React.ReactNode;
|
|
79
|
-
/** 替换新建表单内容 */
|
|
80
27
|
renderCreateForm?: (defaultForm: React.ReactNode, handlers: {
|
|
81
28
|
close: () => void;
|
|
82
29
|
submit: (data: Record<string, unknown>) => void;
|
|
83
30
|
}) => React.ReactNode;
|
|
84
|
-
/** 替换行渲染 */
|
|
85
31
|
renderRow?: (workflow: WorkflowItem, index: number, defaultRow: React.ReactNode) => React.ReactNode;
|
|
86
|
-
/** 点击设计按钮 */
|
|
87
32
|
onDesign?: (chainId: string) => void;
|
|
88
|
-
/** 点击信息按钮 */
|
|
89
33
|
onInfo?: (workflow: WorkflowItem) => void;
|
|
90
|
-
|
|
91
|
-
onViewLogs?: (chainId: string) => void;
|
|
92
|
-
/** 列表数据变化(增删改后) */
|
|
34
|
+
onViewLogs?: (chainId: string, workflow?: WorkflowItem) => void;
|
|
93
35
|
onChange?: () => void;
|
|
94
|
-
/** 发生错误 */
|
|
95
36
|
onError?: (error: Error) => void;
|
|
96
|
-
/** 创建成功 */
|
|
97
37
|
onCreateSuccess?: (chainId: string) => void;
|
|
98
38
|
}
|
|
99
|
-
/**
|
|
100
|
-
* 工作流列表组件
|
|
101
|
-
*
|
|
102
|
-
* @description 支持独立引用,所有功能在包里实现。
|
|
103
|
-
* CSS 类名前缀 huanban_rulego_list__,不会污染宿主项目。
|
|
104
|
-
*/
|
|
105
39
|
export declare const WorkflowList: React.FC<WorkflowListProps>;
|
|
106
|
-
//# sourceMappingURL=WorkflowList.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { EditorWorkspaceTab, EditorWorkspaceTabAction } from '@huanban/rulego-editor-core';
|
|
3
|
+
import type { EditorTranslate } from '../i18n';
|
|
4
|
+
export interface WorkspaceTabsProps {
|
|
5
|
+
tabs: readonly EditorWorkspaceTab[];
|
|
6
|
+
activeTabId?: string | null;
|
|
7
|
+
locale?: string;
|
|
8
|
+
t?: EditorTranslate;
|
|
9
|
+
onActivate?: (tabId: string) => void;
|
|
10
|
+
onClose?: (tabId: string) => void;
|
|
11
|
+
onAdd?: () => void;
|
|
12
|
+
onEditInfo?: (tabId: string) => void;
|
|
13
|
+
onTabAction?: (tabId: string, action: EditorWorkspaceTabAction) => void;
|
|
14
|
+
hideAdd?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function WorkspaceTabs({ tabs, activeTabId, locale, t, onActivate, onClose, onAdd, onEditInfo, onTabAction, hideAdd, }: WorkspaceTabsProps): React.JSX.Element;
|
|
17
|
+
export default WorkspaceTabs;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { AIManager } from '@huanban/rulego-editor-core';
|
|
2
3
|
import type { LocaleMessages } from '@huanban/rulego-editor-core';
|
|
3
4
|
import type { EditorTranslate } from '../../i18n';
|
|
4
5
|
interface Props {
|
|
5
6
|
nodeData: any;
|
|
6
7
|
onUpdate: (properties: any) => void;
|
|
8
|
+
aiManager?: AIManager;
|
|
7
9
|
locale?: string;
|
|
8
10
|
messages?: LocaleMessages;
|
|
9
11
|
t?: EditorTranslate;
|
|
10
12
|
}
|
|
11
13
|
export declare const AgentOrchestrationProperties: React.FC<Props>;
|
|
12
14
|
export {};
|
|
13
|
-
//# sourceMappingURL=AgentOrchestrationProperties.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface BoundStore<TState> {
|
|
2
|
+
subscribe: (listener: (state: TState) => void) => () => void;
|
|
3
|
+
destroy: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare function useBoundStore<TState, TStore extends BoundStore<TState>>(externalStore: TStore | null | undefined, createStore: () => TStore, readState: (store: TStore) => TState): {
|
|
6
|
+
store: TStore;
|
|
7
|
+
state: TState;
|
|
8
|
+
};
|
|
@@ -1,89 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file useClipboard.ts
|
|
3
|
-
* @description 规则链编辑器剪贴板管理 Hook
|
|
4
|
-
*
|
|
5
|
-
* 功能:
|
|
6
|
-
* - 复制节点(单个/多个)到内部剪贴板
|
|
7
|
-
* - 粘贴节点(自动偏移位置防重叠)
|
|
8
|
-
* - 剪切节点(复制 + 删除)
|
|
9
|
-
* - 全选节点
|
|
10
|
-
* - 支持 Ctrl/Cmd + C/V/X/A 快捷键
|
|
11
|
-
*
|
|
12
|
-
* 设计:
|
|
13
|
-
* - 使用内存剪贴板(不使用系统剪贴板,避免权限问题)
|
|
14
|
-
* - 粘贴时自动生成新 ID,避免 ID 冲突
|
|
15
|
-
* - 粘贴位置自动偏移 (30px, 30px)
|
|
16
|
-
*/
|
|
17
|
-
/** 剪贴板中的节点数据 */
|
|
18
1
|
export interface ClipboardNode {
|
|
19
|
-
/** 原始节点 ID */
|
|
20
2
|
originalId: string;
|
|
21
|
-
/** 节点类型 */
|
|
22
3
|
type: string;
|
|
23
|
-
/** 节点名称 */
|
|
24
4
|
name: string;
|
|
25
|
-
/** 节点位置 X */
|
|
26
5
|
x: number;
|
|
27
|
-
/** 节点位置 Y */
|
|
28
6
|
y: number;
|
|
29
|
-
/** 节点属性数据 */
|
|
30
7
|
properties: Record<string, unknown>;
|
|
31
|
-
/** 节点的完整配置快照 */
|
|
32
8
|
config?: Record<string, unknown>;
|
|
33
9
|
}
|
|
34
|
-
/** 剪贴板操作回调 */
|
|
35
10
|
export interface ClipboardCallbacks {
|
|
36
|
-
/** 获取当前选中的节点 */
|
|
37
11
|
getSelectedNodes?: () => ClipboardNode[];
|
|
38
|
-
|
|
12
|
+
getExistingNodeIds?: () => Iterable<string>;
|
|
13
|
+
confirmDeleteNodes?: (nodeIds: string[]) => boolean;
|
|
39
14
|
onDeleteNodes?: (nodeIds: string[]) => void;
|
|
40
|
-
/** 添加新节点(粘贴用) */
|
|
41
15
|
onAddNodes?: (nodes: ClipboardNode[]) => void;
|
|
42
|
-
/** 全选所有节点 */
|
|
43
16
|
onSelectAll?: () => void;
|
|
44
|
-
/** 通知消息 */
|
|
45
17
|
onNotify?: (type: 'success' | 'info', message: string) => void;
|
|
46
18
|
}
|
|
47
|
-
/** useClipboard 返回值 */
|
|
48
19
|
export interface ClipboardManager {
|
|
49
|
-
/** 复制选中节点 */
|
|
50
20
|
copy: () => void;
|
|
51
|
-
/** 剪切选中节点 */
|
|
52
21
|
cut: () => void;
|
|
53
|
-
/** 粘贴剪贴板节点 */
|
|
54
22
|
paste: () => void;
|
|
55
|
-
/** 全选 */
|
|
56
23
|
selectAll: () => void;
|
|
57
|
-
/** 剪贴板是否有内容 */
|
|
58
24
|
hasContent: boolean;
|
|
59
|
-
/** 剪贴板中节点数量 */
|
|
60
25
|
clipboardCount: number;
|
|
61
|
-
/** 清空剪贴板 */
|
|
62
26
|
clear: () => void;
|
|
63
27
|
}
|
|
64
|
-
/**
|
|
65
|
-
* useClipboard Hook
|
|
66
|
-
*
|
|
67
|
-
* @description
|
|
68
|
-
* 管理编辑器的复制/剪切/粘贴/全选操作。
|
|
69
|
-
* 使用内存剪贴板存储节点数据,粘贴时自动生成新 ID 并偏移位置。
|
|
70
|
-
*
|
|
71
|
-
* @param callbacks - 操作回调
|
|
72
|
-
* @returns 剪贴板管理器
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```tsx
|
|
76
|
-
* const clipboard = useClipboard({
|
|
77
|
-
* getSelectedNodes: () => selectedNodes,
|
|
78
|
-
* onDeleteNodes: (ids) => deleteNodes(ids),
|
|
79
|
-
* onAddNodes: (nodes) => addNodes(nodes),
|
|
80
|
-
* onSelectAll: () => selectAllNodes(),
|
|
81
|
-
* })
|
|
82
|
-
*
|
|
83
|
-
* // 在键盘事件中调用
|
|
84
|
-
* clipboard.copy()
|
|
85
|
-
* clipboard.paste()
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
28
|
export declare function useClipboard(callbacks: ClipboardCallbacks): ClipboardManager;
|
|
89
|
-
//# sourceMappingURL=useClipboard.d.ts.map
|
|
@@ -1,104 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file hooks/useEditorCore.ts
|
|
3
|
-
* @description React Hook — 将 EditorCore 桥接到 React 状态系统
|
|
4
|
-
*
|
|
5
|
-
* 兼容性:
|
|
6
|
-
* - React 16.8+ (hooks 引入版本)
|
|
7
|
-
* - React 17.x
|
|
8
|
-
* - React 18.x / 19.x
|
|
9
|
-
* - Next.js Pages Router 和 App Router
|
|
10
|
-
*
|
|
11
|
-
* 设计决策:
|
|
12
|
-
* - 使用 useEffect + useState 而非 React 18 的 useSyncExternalStore,
|
|
13
|
-
* 以确保对 React 16.8+ 的兼容性
|
|
14
|
-
* - 对于 Next.js SSR, EditorCore 实例仅在 useEffect 中创建 (客户端)
|
|
15
|
-
*
|
|
16
|
-
* 使用方式:
|
|
17
|
-
* ```tsx
|
|
18
|
-
* import { useEditorCore } from '@huanban/rulego-editor-react'
|
|
19
|
-
*
|
|
20
|
-
* function MyEditor() {
|
|
21
|
-
* const {
|
|
22
|
-
* core,
|
|
23
|
-
* isReady,
|
|
24
|
-
* isDirty,
|
|
25
|
-
* selectedNode,
|
|
26
|
-
* componentGroups,
|
|
27
|
-
* on,
|
|
28
|
-
* loadData,
|
|
29
|
-
* } = useEditorCore({ url: 'http://127.0.0.1:9090' }) // 通过 url 参数传入实际地址
|
|
30
|
-
*
|
|
31
|
-
* return <div ref={canvasRef} />
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* Next.js 兼容用法:
|
|
36
|
-
* ```tsx
|
|
37
|
-
* // 在 Next.js 中, 使用动态导入避免 SSR 报错
|
|
38
|
-
* import dynamic from 'next/dynamic'
|
|
39
|
-
* const Editor = dynamic(() => import('./Editor'), { ssr: false })
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @see EditorCore — 编辑器核心引擎
|
|
43
|
-
*/
|
|
44
1
|
import { EditorCore } from '@huanban/rulego-editor-core';
|
|
45
2
|
import type { EditorOptions, EditorEventMap, EditorEventName, RuleChainData, RuleNodeConfig, RuleConnectionConfig, ComponentDefinition, ComponentGroup } from '@huanban/rulego-editor-core';
|
|
46
|
-
/**
|
|
47
|
-
* Hook 内部管理的状态
|
|
48
|
-
*/
|
|
49
3
|
interface EditorState {
|
|
50
|
-
/** 编辑器是否就绪 */
|
|
51
4
|
isReady: boolean;
|
|
52
|
-
/** 数据是否已修改 */
|
|
53
5
|
isDirty: boolean;
|
|
54
|
-
/** 是否正在加载 */
|
|
55
6
|
isLoading: boolean;
|
|
56
|
-
/** 当前选中的节点 */
|
|
57
7
|
selectedNode: RuleNodeConfig | null;
|
|
58
|
-
/** 当前选中的边 */
|
|
59
8
|
selectedEdge: RuleConnectionConfig | null;
|
|
60
|
-
/** 组件分组 */
|
|
61
9
|
componentGroups: ComponentGroup[];
|
|
62
|
-
/** 当前编辑的节点视图 */
|
|
63
10
|
currentNodeView: ComponentDefinition | null;
|
|
64
|
-
/** 当前编辑的节点模型 */
|
|
65
11
|
currentNodeModel: Record<string, unknown>;
|
|
66
|
-
/** 当前编辑的边模型 */
|
|
67
12
|
currentEdgeModel: Record<string, unknown>;
|
|
68
|
-
/** 是否可撤销 */
|
|
69
13
|
canUndo: boolean;
|
|
70
|
-
/** 是否可重做 */
|
|
71
14
|
canRedo: boolean;
|
|
72
15
|
}
|
|
73
|
-
/**
|
|
74
|
-
* useEditorCore 返回的 Hook 接口
|
|
75
|
-
*/
|
|
76
16
|
export interface UseEditorCoreReturn extends EditorState {
|
|
77
|
-
/** EditorCore 原始实例 */
|
|
78
17
|
core: EditorCore | null;
|
|
79
|
-
/** 加载规则链数据 */
|
|
80
18
|
loadData: (data: RuleChainData) => void;
|
|
81
|
-
/** 监听事件 (在组件卸载时自动清理) */
|
|
82
19
|
on: <E extends EditorEventName>(event: E, handler: (payload: EditorEventMap[E]) => void) => void;
|
|
83
|
-
/** 发送事件 */
|
|
84
20
|
emit: <E extends EditorEventName>(event: E, ...args: EditorEventMap[E] extends void ? [] : [EditorEventMap[E]]) => void;
|
|
85
|
-
/** 初始化 (传入 LogicFlow 实例) */
|
|
86
21
|
init: (lfInstance: unknown) => void;
|
|
87
|
-
/** 手动触发保存 */
|
|
88
22
|
save: () => void;
|
|
89
23
|
}
|
|
90
|
-
/**
|
|
91
|
-
* React Hook — 创建和管理 EditorCore
|
|
92
|
-
*
|
|
93
|
-
* @param options - 编辑器选项 (仅在首次渲染时使用)
|
|
94
|
-
* @returns 编辑器状态和操作方法
|
|
95
|
-
*
|
|
96
|
-
* 内部原理:
|
|
97
|
-
* - 使用 useRef 持有 EditorCore 实例 (避免重复创建)
|
|
98
|
-
* - 使用 useState 维护状态 (确保 React 重渲染)
|
|
99
|
-
* - 使用 useEffect 进行状态订阅和清理
|
|
100
|
-
* - 避免使用 React 18 专有 API, 确保 16.8+ 兼容性
|
|
101
|
-
*/
|
|
102
24
|
export declare function useEditorCore(options?: Partial<EditorOptions>): UseEditorCoreReturn;
|
|
103
25
|
export {};
|
|
104
|
-
//# sourceMappingURL=useEditorCore.d.ts.map
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file hooks/useEditorI18n.ts
|
|
3
|
-
* @description React Hook — 国际化
|
|
4
|
-
*
|
|
5
|
-
* 兼容 React 16.8+, 不使用 React 18 专有 API。
|
|
6
|
-
*
|
|
7
|
-
* 使用方式:
|
|
8
|
-
* ```tsx
|
|
9
|
-
* const { t, locale, setLocale } = useEditorI18n(core)
|
|
10
|
-
*
|
|
11
|
-
* return <button>{t('toolbar.save')}</button>
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
1
|
import type { EditorCore } from '@huanban/rulego-editor-core';
|
|
15
|
-
/**
|
|
16
|
-
* useEditorI18n 返回类型
|
|
17
|
-
*/
|
|
18
2
|
export interface UseEditorI18nReturn {
|
|
19
|
-
/** 翻译函数 */
|
|
20
3
|
t: (key: string, params?: Record<string, string>) => string;
|
|
21
|
-
/** 当前语言 */
|
|
22
4
|
locale: string;
|
|
23
|
-
/** 切换语言 */
|
|
24
5
|
setLocale: (locale: string) => void;
|
|
25
6
|
}
|
|
26
|
-
/**
|
|
27
|
-
* 国际化 Hook
|
|
28
|
-
*
|
|
29
|
-
* @param core - EditorCore 实例 (可空, SSR 安全)
|
|
30
|
-
* @returns 翻译函数和语言操作
|
|
31
|
-
*/
|
|
32
7
|
export declare function useEditorI18n(core: EditorCore | null): UseEditorI18nReturn;
|
|
33
|
-
//# sourceMappingURL=useEditorI18n.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EditorPanelRegistry } from '@huanban/rulego-editor-core';
|
|
2
|
+
import type { EditorDockId, EditorPanelDefinition, EditorPanelRegistryOptions, EditorPanelState } from '@huanban/rulego-editor-core';
|
|
3
|
+
export interface UseEditorPanelsOptions extends Omit<EditorPanelRegistryOptions, 'panels'> {
|
|
4
|
+
panels?: EditorPanelRegistry | ReadonlyArray<EditorPanelDefinition> | null;
|
|
5
|
+
}
|
|
6
|
+
export interface UseEditorPanelsReturn {
|
|
7
|
+
panels: EditorPanelRegistry;
|
|
8
|
+
state: Readonly<EditorPanelState>;
|
|
9
|
+
openPanel: (id: string, activate?: boolean) => boolean;
|
|
10
|
+
closePanel: (id: string) => boolean;
|
|
11
|
+
activatePanel: (id: string) => boolean;
|
|
12
|
+
setPanelExpanded: (id: string, expanded: boolean) => boolean;
|
|
13
|
+
togglePanelExpanded: (id: string) => boolean;
|
|
14
|
+
isPanelExpanded: (id: string) => boolean;
|
|
15
|
+
register: (panel: EditorPanelDefinition, options?: {
|
|
16
|
+
open?: boolean;
|
|
17
|
+
activate?: boolean;
|
|
18
|
+
}) => boolean;
|
|
19
|
+
unregister: (id: string) => boolean;
|
|
20
|
+
getPanels: (dock?: EditorDockId) => EditorPanelDefinition[];
|
|
21
|
+
getActivePanel: (dock: EditorDockId) => EditorPanelDefinition | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function useEditorPanels(options?: UseEditorPanelsOptions): UseEditorPanelsReturn;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ConnectionStatusStore, EditorDockStore, ServerStatusStore } from '@huanban/rulego-editor-core';
|
|
2
|
+
import type { ConnectionStatusState, EditorDockId, EditorDockOptions, EditorDockState, ServerStatus, ServerWsEventStatus, ServerStatusOptions, ServerStatusState } from '@huanban/rulego-editor-core';
|
|
3
|
+
export interface UseEditorDockOptions extends EditorDockOptions {
|
|
4
|
+
dockStore?: EditorDockStore | null;
|
|
5
|
+
}
|
|
6
|
+
export interface UseEditorDockReturn {
|
|
7
|
+
dock: EditorDockStore;
|
|
8
|
+
state: EditorDockState;
|
|
9
|
+
setDockVisibility: (dock: EditorDockId, visible: boolean) => boolean;
|
|
10
|
+
setDockWidth: (dock: EditorDockId, width: number) => boolean;
|
|
11
|
+
setDockHeight: (dock: 'bottom', height: number) => boolean;
|
|
12
|
+
resetDockState: () => EditorDockState | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function useEditorDock(options?: UseEditorDockOptions): UseEditorDockReturn;
|
|
15
|
+
export interface UseServerStatusOptions extends ServerStatusOptions {
|
|
16
|
+
serverStatus?: ServerStatusStore | null;
|
|
17
|
+
}
|
|
18
|
+
export interface UseServerStatusReturn {
|
|
19
|
+
server: ServerStatusStore;
|
|
20
|
+
state: Readonly<ServerStatusState>;
|
|
21
|
+
setServerUrl: (baseUrl: string, wsUrl?: string) => void;
|
|
22
|
+
setServerStatus: (status: ServerStatus, details?: Partial<ServerStatusState>) => void;
|
|
23
|
+
recordHttpStatus: (statusCode: number, message?: string) => ServerStatus;
|
|
24
|
+
recordWebSocketStatus: (status: ServerWsEventStatus, closeCode?: number | null, message?: string) => ServerStatus;
|
|
25
|
+
setReconnectAttempt: (attempt: number) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare function useServerStatus(options?: UseServerStatusOptions): UseServerStatusReturn;
|
|
28
|
+
export interface UseConnectionStatusOptions {
|
|
29
|
+
connectionStatus?: ConnectionStatusStore | null;
|
|
30
|
+
}
|
|
31
|
+
export interface UseConnectionStatusReturn {
|
|
32
|
+
connectionStatus: ConnectionStatusStore;
|
|
33
|
+
state: Readonly<ConnectionStatusState>;
|
|
34
|
+
}
|
|
35
|
+
export declare function useConnectionStatus(options?: UseConnectionStatusOptions): UseConnectionStatusReturn;
|