@coding-flow/flow-design 0.1.3 → 0.1.4

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 CHANGED
@@ -1,13 +1,13 @@
1
- # @coding-flow/flow-pc-design
1
+ # @coding-flow/flow-design
2
2
 
3
- Flow Engine PC 端流程设计器组件库,提供节点配置、属性面板、脚本配置等功能。
3
+ Flow Engine 流程设计器组件库,提供可视化流程设计、节点配置、属性面板、脚本配置等功能。
4
4
 
5
5
  ## 简介
6
6
 
7
- `flow-pc-design` 是 Flow Engine PC 端的流程设计器组件库,提供:
7
+ `flow-design` 是 Flow Engine 的流程设计器组件库,提供:
8
8
 
9
- - 流程设计器(可视化流程设计)
10
- - 节点配置面板(15 种节点类型配置)
9
+ - 流程设计器(基于 @flowgram.ai 的可视化流程设计)
10
+ - 节点配置面板(19 种节点类型配置)
11
11
  - 属性面板(节点属性编辑)
12
12
  - 脚本配置器(Groovy 脚本编辑)
13
13
  - 变量选择器
@@ -15,7 +15,7 @@ Flow Engine PC 端流程设计器组件库,提供节点配置、属性面板
15
15
 
16
16
  ### 依赖关系
17
17
 
18
- - **依赖**: `@coding-flow/flow-core`, `@coding-flow/flow-types`, `@coding-flow/flow-pc-ui`
18
+ - **依赖**: `@coding-flow/flow-core`、`@coding-flow/flow-types`、`@coding-flow/flow-icons`、`@coding-flow/flow-pc-ui`、`@flowgram.ai/fixed-layout-editor`、`@coding-script/script-engine`
19
19
 
20
20
  ## Setup
21
21
 
@@ -33,182 +33,6 @@ pnpm install
33
33
  pnpm run build
34
34
  ```
35
35
 
36
- 监听模式构建:
37
-
38
- ```bash
39
- pnpm run dev
40
- ```
41
-
42
- ## 核心功能
43
-
44
- ### 流程设计器
45
-
46
- 可视化流程设计器,支持:
47
-
48
- - 节点拖拽添加
49
- - 节点连线
50
- - 节点配置
51
- - 流程预览
52
- - 流程校验
53
- - 流程导入/导出
54
-
55
- ```typescript
56
- import { WorkflowDesigner } from '@coding-flow/flow-pc-design';
57
-
58
- <WorkflowDesigner
59
- workflow={workflow}
60
- onChange={handleWorkflowChange}
61
- onValidate={handleValidate}
62
- />
63
- ```
64
-
65
- ### 节点配置
66
-
67
- 支持 15 种节点类型的配置:
68
-
69
- **基础节点 (9 种)**:
70
- - `StartNode` - 开始节点
71
- - `EndNode` - 结束节点
72
- - `ApprovalNode` - 审批节点
73
- - `HandleNode` - 办理节点
74
- - `NotifyNode` - 通知节点
75
- - `RouterNode` - 路由节点
76
- - `SubProcessNode` - 子流程节点
77
- - `DelayNode` - 延迟节点
78
- - `TriggerNode` - 触发节点
79
-
80
- **块节点 (3 种)**:
81
- - `ConditionNode` - 条件节点
82
- - `ParallelNode` - 并行节点
83
- - `InclusiveNode` - 包容节点
84
-
85
- **分支节点 (3 种)**:
86
- - `ConditionBranchNode` - 条件分支
87
- - `ParallelBranchNode` - 并行分支
88
- - `InclusiveBranchNode` - 包容分支
89
-
90
- ### 属性面板
91
-
92
- 节点属性编辑:
93
-
94
- - 基本信息配置
95
- - 审批人配置
96
- - 表单权限配置
97
- - 通知配置
98
- - 超时策略配置
99
-
100
- ### 脚本配置器
101
-
102
- Groovy 脚本编辑支持:
103
-
104
- - 语法高亮
105
- - 代码补全
106
- - 语法检查
107
- - 变量提示
108
- - TypeScript/Groovy 转换
109
-
110
- ```typescript
111
- import { ScriptEditor } from '@coding-flow/flow-pc-design';
112
-
113
- <ScriptEditor
114
- value={script}
115
- onChange={handleScriptChange}
116
- scriptType="CONDITION"
117
- variables={availableVariables}
118
- />
119
- ```
120
-
121
- ### 变量选择器
122
-
123
- 流程变量选择:
124
-
125
- - 表单字段变量
126
- - 流程实例变量
127
- - 系统内置变量
128
- - 自定义变量
129
-
130
- ```typescript
131
- import { VariablePicker } from '@coding-flow/flow-pc-design';
132
-
133
- <VariablePicker
134
- variables={variables}
135
- onSelect={handleVariableSelect}
136
- filterTypes={['FORM_FIELD', 'INSTANCE']}
137
- />
138
- ```
139
-
140
- ### 策略配置
141
-
142
- 节点策略配置:
143
-
144
- - 多人审批策略(会签/或签)
145
- - 超时策略
146
- - 通知策略
147
- - 权限策略
148
-
149
- ## 模块结构
150
-
151
- ```
152
- flow-pc-design/
153
- ├── src/
154
- │ ├── designer/ # 流程设计器
155
- │ ├── node-config/ # 节点配置组件
156
- │ ├── property-panel/ # 属性面板
157
- │ ├── script/ # 脚本编辑器
158
- │ ├── variable/ # 变量选择器
159
- │ ├── strategy/ # 策略配置
160
- │ ├── components/ # 公共组件
161
- │ └── index.ts # 统一导出
162
- └── README.md
163
- ```
164
-
165
- ## 使用示例
166
-
167
- ### 流程设计器
168
-
169
- ```typescript
170
- import { WorkflowDesigner } from '@coding-flow/flow-pc-design';
171
- import type { Workflow } from '@coding-flow/flow-types';
172
-
173
- const MyWorkflowDesigner = () => {
174
- const [workflow, setWorkflow] = useState<Workflow>({ ... });
175
-
176
- return (
177
- <WorkflowDesigner
178
- workflow={workflow}
179
- onChange={setWorkflow}
180
- onSave={handleSave}
181
- onPreview={handlePreview}
182
- />
183
- );
184
- };
185
- ```
186
-
187
- ### 脚本编辑器
188
-
189
- ```typescript
190
- import { ScriptEditor } from '@coding-flow/flow-pc-design';
191
- import type { ScriptType } from '@coding-flow/flow-pc-design';
192
-
193
- const MyScriptEditor = () => {
194
- const [script, setScript] = useState('');
195
-
196
- return (
197
- <ScriptEditor
198
- value={script}
199
- onChange={setScript}
200
- scriptType="CONDITION"
201
- variables={variables}
202
- onInsertVariable={(variable) => {
203
- setScript(prev => prev + variable);
204
- }}
205
- />
206
- );
207
- };
208
- ```
209
-
210
36
  ## Learn more
211
37
 
212
- - [Rslib documentation](https://lib.rsbuild.io/) - Rslib 特性和 API
213
- - [Flow Engine Docs](https://github.com/codingapi/flow-engine) - 完整文档
214
- - [CLAUDE.md](../../CLAUDE.md) - 开发指南
38
+ - [Flow Engine Docs](https://github.com/codingapi/flow-engine) - 完整文档
@@ -1,3 +1,4 @@
1
+ import { generateUUID } from "../../../utils/uuid.js";
1
2
  class WorkflowFormManager {
2
3
  form;
3
4
  formList;
@@ -45,7 +46,7 @@ class WorkflowFormManager {
45
46
  } else list.push(field);
46
47
  if (!exist) list.push({
47
48
  ...values,
48
- id: crypto.randomUUID()
49
+ id: generateUUID()
49
50
  });
50
51
  const mainCode = this.form.code;
51
52
  if (code === mainCode) return {
@@ -1 +1,2 @@
1
1
  export * from "./id";
2
+ export * from "./uuid";
@@ -1 +1,2 @@
1
1
  export * from "./id.js";
2
+ export * from "./uuid.js";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 生成 UUID v4。
3
+ * <p>优先使用原生 crypto.randomUUID(仅安全上下文与较新浏览器可用);
4
+ * 回退到 crypto.getRandomValues 构造(非安全上下文同样可用);
5
+ * 最后回退 Math.random 拼接,保证在打包后的生产环境(HTTP/旧浏览器)不抛错。
6
+ */
7
+ export declare const generateUUID: () => string;
@@ -0,0 +1,16 @@
1
+ const generateUUID = ()=>{
2
+ if ("u" > typeof crypto && 'function' == typeof crypto.randomUUID) return crypto.randomUUID();
3
+ if ("u" > typeof crypto && 'function' == typeof crypto.getRandomValues) {
4
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
5
+ bytes[6] = 0x0f & bytes[6] | 0x40;
6
+ bytes[8] = 0x3f & bytes[8] | 0x80;
7
+ const hex = Array.from(bytes, (b)=>b.toString(16).padStart(2, '0')).join('');
8
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
9
+ }
10
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c)=>{
11
+ const r = 16 * Math.random() | 0;
12
+ const v = 'x' === c ? r : 0x3 & r | 0x8;
13
+ return v.toString(16);
14
+ });
15
+ };
16
+ export { generateUUID };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-design",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "flow-engine design components ",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -54,16 +54,16 @@
54
54
  "nanoid": "^5.1.6",
55
55
  "react-redux": "^9.2.0",
56
56
  "styled-components": "^5.3.11",
57
- "@coding-flow/flow-core": "0.1.3",
58
- "@coding-flow/flow-icons": "0.1.3",
59
- "@coding-flow/flow-pc-ui": "0.1.3",
60
- "@coding-flow/flow-types": "0.1.3"
57
+ "@coding-flow/flow-types": "0.1.4",
58
+ "@coding-flow/flow-pc-ui": "0.1.4",
59
+ "@coding-flow/flow-core": "0.1.4",
60
+ "@coding-flow/flow-icons": "0.1.4"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/lodash-es": "^4.17.12",
64
64
  "@types/styled-components": "^5.1.36",
65
- "@coding-flow/flow-core": "0.1.3",
66
- "@coding-flow/flow-types": "0.1.3"
65
+ "@coding-flow/flow-types": "0.1.4",
66
+ "@coding-flow/flow-core": "0.1.4"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "rslib build",