@huanban/rulego-editor-react 1.1.0 → 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.
@@ -12,18 +12,90 @@
12
12
  * @see ComponentField — 字段定义类型
13
13
  */
14
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
+ }
15
66
  /** 组件字段定义 */
16
67
  export interface FieldDef {
17
68
  /** 字段名 */
18
69
  name: string;
19
70
  /** 字段类型 */
20
- type: string;
71
+ type?: string;
21
72
  /** 显示标签 */
22
73
  label?: string;
23
74
  /** 字段描述 */
24
75
  desc?: string;
25
76
  /** 默认值 */
26
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;
27
99
  /** 校验规则 */
28
100
  rules?: unknown[];
29
101
  }
@@ -71,6 +143,26 @@ export interface NodePropertyDrawerProps {
71
143
  onSubmit: (model: NodeModel) => void;
72
144
  /** 关闭回调 */
73
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>;
74
166
  }
75
167
  /**
76
168
  * NodePropertyDrawer 组件
@@ -12,6 +12,8 @@
12
12
  * @see RuleChainSettingsProps — 设置参数
13
13
  */
14
14
  import React from 'react';
15
+ import type { LocaleMessages } from '@huanban/rulego-editor-core';
16
+ import type { EditorTranslate } from '../i18n';
15
17
  /** 规则链设置数据 */
16
18
  export interface RuleChainSettingsData {
17
19
  /** 规则链 ID */
@@ -63,6 +65,12 @@ export interface RuleChainSettingsProps {
63
65
  onSave?: (data: RuleChainSettingsData) => void;
64
66
  /** 取消 / 关闭 */
65
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;
66
74
  }
67
75
  /**
68
76
  * RuleChainSettings 组件
@@ -29,8 +29,9 @@
29
29
  */
30
30
  import React from 'react';
31
31
  import { HuanbanRulegoEditor } from '@huanban/rulego-editor-core';
32
+ import type { AIAssistantOpenOptions, HuanbanRulegoEditorOptions } from '@huanban/rulego-editor-core';
32
33
  import type { EditorCore } from '@huanban/rulego-editor-core';
33
- import type { RuleChainData, ComponentDefinition } from '@huanban/rulego-editor-core';
34
+ import type { RuleChainData, RawComponentData } from '@huanban/rulego-editor-core';
34
35
  import LogicFlow from '@logicflow/core';
35
36
  /**
36
37
  * RuleGoEditor 组件 Props
@@ -61,15 +62,19 @@ export interface RuleGoEditorProps {
61
62
  * 当需要自定义请求逻辑(如统一认证拦截、请求签名、错误重试等)时使用
62
63
  * 函数签名: (url: string, init: RequestInit) => Promise<Response>
63
64
  */
64
- customFetch?: (url: string, init: RequestInit) => Promise<Response>;
65
+ customFetch?: (url: string, init?: RequestInit) => Promise<Response>;
65
66
  /** 初始规则链数据 */
66
67
  data?: RuleChainData | null;
67
- /** 初始组件列表 */
68
- components?: ComponentDefinition[];
68
+ /** 初始组件列表,支持数组或官方 /api/v1/components 分段返回 */
69
+ components?: RawComponentData;
69
70
  /** 是否显示工具栏, 默认 true */
70
71
  showToolbar?: boolean;
71
72
  /** 工具栏左侧标题 */
72
73
  toolbarTitle?: string;
74
+ /** 是否显示工具栏按钮文字,默认 false;设为 true 时显示图标 + 文字 */
75
+ showToolbarButtonLabels?: boolean;
76
+ /** 工具栏是否只显示图标,默认 true;显式 false 时可显示文字 */
77
+ toolbarIconOnly?: boolean;
73
78
  /** 是否显示侧边栏, 默认 true */
74
79
  showSidebar?: boolean;
75
80
  /** 侧边栏宽度, 默认 220 */
@@ -78,6 +83,16 @@ export interface RuleGoEditorProps {
78
83
  sidebarCollapsed?: boolean;
79
84
  /** 是否显示信息按钮 */
80
85
  showInfoButton?: boolean;
86
+ /** 是否显示 AI 助手按钮 */
87
+ showAiChatButton?: boolean;
88
+ /** 是否显示设置按钮 */
89
+ showSettingsButton?: boolean;
90
+ /** 是否显示调试面板按钮 */
91
+ showDebugConsoleButton?: boolean;
92
+ /** 是否显示清除调试高亮按钮 */
93
+ showClearDebugHighlightButton?: boolean;
94
+ /** 是否显示框选按钮 */
95
+ showSelectionButton?: boolean;
81
96
  /** 是否显示导出按钮, 默认 true */
82
97
  showExportDialog?: boolean;
83
98
  /** 是否显示运行按钮 */
@@ -102,13 +117,23 @@ export interface RuleGoEditorProps {
102
117
  lfPlugins?: any[];
103
118
  /** EditorCore 额外配置 */
104
119
  coreOptions?: Record<string, unknown>;
120
+ /** 直接透传给 HuanbanRulegoEditor 的扩展配置,显式 props 会覆盖这里的同名字段 */
121
+ options?: Partial<HuanbanRulegoEditorOptions>;
105
122
  /** 编辑器就绪 */
106
123
  onReady?: (ctx: {
107
124
  lf: LogicFlow;
108
125
  core: EditorCore;
109
126
  }) => void;
110
127
  /** 保存回调 */
111
- onSave?: (data: unknown) => void;
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
+ }>;
112
137
  /** 节点点击 */
113
138
  onNodeClick?: (data: unknown) => void;
114
139
  /** 节点双击 */
@@ -133,7 +158,15 @@ export interface RuleGoEditorProps {
133
158
  /** 语言切换回调 */
134
159
  onLocaleChange?: (locale: string) => void;
135
160
  /** 劫持部署 */
136
- onDeploy?: (chainId: string, action: 'deploy' | 'undeploy' | 'reload') => void;
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
+ }>;
137
170
  /** 选择规则链 */
138
171
  onSelectRuleChain?: (ruleChain: any) => void;
139
172
  /** 删除规则链 */
@@ -144,6 +177,12 @@ export interface RuleGoEditorProps {
144
177
  ruleItems?: any[];
145
178
  /** 规则链 API 地址 */
146
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;
147
186
  }
148
187
  /**
149
188
  * RuleGoEditor 的命令式 API
@@ -159,13 +198,19 @@ export interface RuleGoEditorRef {
159
198
  /** 重新加载数据 */
160
199
  loadData: (data: RuleChainData) => void;
161
200
  /** 重新加载组件 */
162
- loadComponents: (components: ComponentDefinition[]) => void;
201
+ loadComponents: (components: RawComponentData) => void;
163
202
  /** 导出数据 */
164
203
  exportData: () => RuleChainData | null;
165
204
  /** 切换小地图 */
166
205
  toggleMiniMap: () => void;
167
206
  /** 手动触发自动排版 — 基于 DAG 拓扑排序重新排列节点 */
168
207
  autoLayout: () => void;
208
+ /** 打开独立设置弹窗 */
209
+ openSettings: (initialTab?: 'user' | 'setting' | 'ai' | 'skills') => void;
210
+ /** 打开 AI 助手侧栏 */
211
+ openAiAssistant: (options?: AIAssistantOpenOptions) => void;
212
+ /** 关闭 AI 助手侧栏 */
213
+ closeAiAssistant: () => void;
169
214
  }
170
215
  /**
171
216
  * RuleGoEditor — React 封装组件
@@ -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
@@ -15,6 +15,8 @@
15
15
  * - 通过回调 props 处理节点定位
16
16
  */
17
17
  import React from 'react';
18
+ import type { LocaleMessages } from '@huanban/rulego-editor-core';
19
+ import type { EditorTranslate } from '../i18n';
18
20
  /** 搜索结果项 */
19
21
  export interface SearchResultItem {
20
22
  /** 节点 ID */
@@ -38,6 +40,12 @@ export interface SearchPanelProps {
38
40
  onClose: () => void;
39
41
  /** 面板位置 */
40
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;
41
49
  }
42
50
  /**
43
51
  * SearchPanel 组件
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ export interface SearchableSelectOption {
3
+ label: string;
4
+ value: string;
5
+ description?: string;
6
+ }
7
+ export interface SearchableSelectProps {
8
+ name?: string;
9
+ value?: string;
10
+ values?: string[];
11
+ options?: SearchableSelectOption[];
12
+ multiple?: boolean;
13
+ allowCreate?: boolean;
14
+ disabled?: boolean;
15
+ placeholder?: string;
16
+ searchPlaceholder?: string;
17
+ noMatchText?: string;
18
+ createOptionText?: string;
19
+ selectedCountText?: string;
20
+ resultCountText?: string;
21
+ moreOptionsText?: string;
22
+ className?: string;
23
+ threshold?: number;
24
+ maxVisibleOptions?: number;
25
+ onChange: (value: string) => void;
26
+ onMultiChange?: (values: string[]) => void;
27
+ }
28
+ export declare const SearchableSelect: React.FC<SearchableSelectProps>;
29
+ //# sourceMappingURL=SearchableSelect.d.ts.map
@@ -13,6 +13,8 @@
13
13
  * @see ValidationPanelProps — 面板参数
14
14
  */
15
15
  import React from 'react';
16
+ import type { LocaleMessages } from '@huanban/rulego-editor-core';
17
+ import type { EditorTranslate } from '../i18n';
16
18
  /** 验证错误项 */
17
19
  export interface ValidationItem {
18
20
  /** 规则名称 */
@@ -46,6 +48,12 @@ export interface ValidationPanelProps {
46
48
  onClose?: () => void;
47
49
  /** 清除验证结果 */
48
50
  onClear?: () => void;
51
+ /** Current locale. Defaults to zh-CN. */
52
+ locale?: string;
53
+ /** Extra locale messages merged into the selected locale. */
54
+ messages?: LocaleMessages;
55
+ /** Host-provided translation function. */
56
+ t?: EditorTranslate;
49
57
  }
50
58
  /**
51
59
  * ValidationPanel 组件
@@ -19,7 +19,8 @@
19
19
  * @module @huanban/rulego-editor-react
20
20
  */
21
21
  import React from 'react';
22
- import type { WorkflowItem, WorkflowFetcher, WorkflowInfoIcons, WorkflowTheme, RuleChainAPIOptions } from '@huanban/rulego-editor-core';
22
+ import type { EditorTranslate } from '../i18n';
23
+ import type { LocaleMessages, WorkflowItem, WorkflowFetcher, WorkflowInfoIcons, WorkflowTheme, RuleChainAPIOptions } from '@huanban/rulego-editor-core';
23
24
  /** 自定义 Tab 定义 */
24
25
  export interface ExtraTab {
25
26
  key: string;
@@ -52,6 +53,21 @@ export interface WorkflowInfoPanelProps {
52
53
  onError?: (error: Error) => void;
53
54
  /** 请求刷新外部数据 */
54
55
  onRefresh?: () => void;
56
+ /** Current locale. Defaults to zh-CN. */
57
+ locale?: string;
58
+ /** Extra locale messages merged into the selected locale. */
59
+ messages?: LocaleMessages;
60
+ /** Host-provided translation function. */
61
+ t?: EditorTranslate;
55
62
  }
63
+ export interface WorkflowIntegrationUrls {
64
+ executeUrl: string;
65
+ notifyUrl: string;
66
+ mcpSseUrl: string;
67
+ debugWsUrl: string;
68
+ runtimeWsUrl: string;
69
+ endpointWsHint: string;
70
+ }
71
+ export declare function buildWorkflowIntegrationUrls(apiBase: string | undefined, workflowId: string): WorkflowIntegrationUrls;
56
72
  export declare const WorkflowInfoPanel: React.FC<WorkflowInfoPanelProps>;
57
73
  //# sourceMappingURL=WorkflowInfoPanel.d.ts.map
@@ -28,7 +28,8 @@
28
28
  * @module @huanban/rulego-editor-react
29
29
  */
30
30
  import React from 'react';
31
- import type { WorkflowItem, WorkflowFetcher, WorkflowListIcons, WorkflowTheme, RuleChainAPIOptions } from '@huanban/rulego-editor-core';
31
+ import type { WorkflowItem, WorkflowFetcher, WorkflowListIcons, WorkflowTheme, RuleChainAPIOptions, LocaleMessages } from '@huanban/rulego-editor-core';
32
+ import type { EditorTranslate } from '../i18n';
32
33
  /**
33
34
  * WorkflowList 组件 Props
34
35
  */
@@ -55,6 +56,12 @@ export interface WorkflowListProps {
55
56
  showCreate?: boolean;
56
57
  /** 是否显示刷新按钮,默认 true */
57
58
  showRefresh?: boolean;
59
+ /** Current locale. Defaults to zh-CN. */
60
+ locale?: string;
61
+ /** Extra locale messages merged into the selected locale. */
62
+ messages?: LocaleMessages;
63
+ /** Host-provided translation function. */
64
+ t?: EditorTranslate;
58
65
  /** 替换标题栏区域 */
59
66
  renderHeader?: (defaultHeader: React.ReactNode) => React.ReactNode;
60
67
  /** 替换每行操作按钮 */
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { LocaleMessages } from '@huanban/rulego-editor-core';
3
+ import type { EditorTranslate } from '../../i18n';
4
+ interface Props {
5
+ nodeData: any;
6
+ onUpdate: (properties: any) => void;
7
+ locale?: string;
8
+ messages?: LocaleMessages;
9
+ t?: EditorTranslate;
10
+ }
11
+ export declare const AgentOrchestrationProperties: React.FC<Props>;
12
+ export {};
13
+ //# sourceMappingURL=AgentOrchestrationProperties.d.ts.map
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { LocaleMessages } from '@huanban/rulego-editor-core';
2
+ export type EditorTranslate = (key: string, params?: Record<string, string | number>) => string;
3
+ export interface FrameworkI18nProps {
4
+ /** Current locale. Supports zh-CN/zh_cn/zh and en-US/en_us/en. */
5
+ locale?: string;
6
+ /** Extra messages merged into the selected locale. */
7
+ messages?: LocaleMessages;
8
+ /** Host-provided translation function. It takes priority over built-in messages. */
9
+ t?: EditorTranslate;
10
+ }
11
+ export declare function normalizeFrameworkLocale(locale?: string): 'zh-CN' | 'en-US';
12
+ export declare function createFrameworkTranslator(options?: FrameworkI18nProps): (key: string, fallback?: string, params?: Record<string, string | number>) => string;
13
+ export declare function relationTypeLabel(translate: (key: string, fallback?: string, params?: Record<string, string | number>) => string, value: string): string;
14
+ //# sourceMappingURL=i18n.d.ts.map