iop-bpmn-react 0.0.3 → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 IOP Platform
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -5,10 +5,12 @@
5
5
  ## 特性
6
6
 
7
7
  - 🎨 **开箱即用** - 提供 BpmnViewer 和 BpmnModeler 两个 React 组件
8
- - 📝 **Flowable 扩展属性** - 完整支持 26 种 Flowable/activiti 扩展类型
9
- - 🌐 **国际化** - 内置中文翻译支持
8
+ - 📝 **Flowable 扩展属性** - 完整支持 26 种 Flowable/activiti 扩展类型,属性面板可视化编辑
9
+ - 🌐 **国际化** - 内置中文翻译支持,可扩展其他语言
10
10
  - 🎯 **TypeScript** - 完整的类型定义
11
- - 📦 **多种构建格式** - 支持 ES Module 和 UMD 格式
11
+ - 📐 **自动布局** - 内置 bpmn-auto-layout,支持为缺少坐标信息的 XML 自动生成布局
12
+ - 🔍 **规则校验** - 内置 bpmnlint,实时校验流程规范性
13
+ - ✏️ **手绘风格** - 支持 sketchy 手绘风格渲染
12
14
 
13
15
  ## 安装
14
16
 
@@ -23,16 +25,114 @@ import { BpmnViewer, BpmnModeler } from 'iop-bpmn-react'
23
25
  import 'iop-bpmn-react/style.css'
24
26
 
25
27
  // 只读查看
26
- function Viewer() {
27
- return <BpmnViewer bpmnXml={xml} />
28
+ function ViewerDemo() {
29
+ return <BpmnViewer xml={bpmnXml} />
28
30
  }
29
31
 
30
32
  // 可编辑建模
31
- function Modeler() {
32
- return <BpmnModeler bpmnXml={xml} />
33
+ function ModelerDemo() {
34
+ return <BpmnModeler xml={bpmnXml} />
33
35
  }
34
36
  ```
35
37
 
38
+ ## 导入
39
+
40
+ ```tsx
41
+ // 组件
42
+ import { BpmnViewer, BpmnModeler } from 'iop-bpmn-react'
43
+ import 'iop-bpmn-react/style.css'
44
+
45
+ // 工具函数
46
+ import { fitToView, layoutProcess } from 'iop-bpmn-react'
47
+
48
+ // 国际化
49
+ import { i18n, zhTranslations, addTranslations, getTranslations } from 'iop-bpmn-react'
50
+
51
+ // 令牌模拟模块
52
+ import { TokenSimulationModule } from 'iop-bpmn-react'
53
+ ```
54
+
55
+ ## API
56
+
57
+ ### BpmnViewer
58
+
59
+ 只读 BPMN 流程查看器组件。
60
+
61
+ ```tsx
62
+ <BpmnViewer
63
+ xml={bpmnXml}
64
+ autoLayout={false}
65
+ locale="zh"
66
+ className="viewer"
67
+ style={{ width: '100%', height: '500px' }}
68
+ onInit={(viewer) => { /* viewer 初始化完成 */ }}
69
+ />
70
+ ```
71
+
72
+ | 属性 | 类型 | 默认值 | 说明 |
73
+ |------|------|--------|------|
74
+ | `xml` | `string` | **必填** | BPMN 2.0 XML 字符串 |
75
+ | `autoLayout` | `boolean` | `false` | 是否自动布局(为缺少 DI 信息的 XML 生成坐标) |
76
+ | `locale` | `'zh' \| 'en' \| 'ja'` | `'zh'` | 界面语言 |
77
+ | `className` | `string` | — | 自定义类名 |
78
+ | `style` | `CSSProperties` | — | 自定义样式 |
79
+ | `onInit` | `(viewer: Viewer) => void` | — | 初始化完成回调 |
80
+
81
+ ### BpmnModeler
82
+
83
+ 可编辑 BPMN 流程建模器组件,内置属性面板。
84
+
85
+ ```tsx
86
+ <BpmnModeler
87
+ xml={bpmnXml}
88
+ autoLayout={false}
89
+ linting={true}
90
+ sketchy={false}
91
+ locale="zh"
92
+ className="modeler"
93
+ style={{ width: '100%', height: '500px' }}
94
+ onSave={(xml) => console.log(xml)}
95
+ onChange={(xml) => console.log(xml)}
96
+ onInit={(modeler) => { /* modeler 初始化完成 */ }}
97
+ />
98
+ ```
99
+
100
+ | 属性 | 类型 | 默认值 | 说明 |
101
+ |------|------|--------|------|
102
+ | `xml` | `string` | **必填** | BPMN 2.0 XML 字符串 |
103
+ | `autoLayout` | `boolean` | `false` | 是否自动布局 |
104
+ | `linting` | `boolean` | `false` | 是否启用规则校验 |
105
+ | `sketchy` | `boolean` | `false` | 是否启用手绘风格 |
106
+ | `locale` | `'zh' \| 'en' \| 'ja'` | `'zh'` | 界面语言 |
107
+ | `className` | `string` | — | 画布容器类名 |
108
+ | `style` | `CSSProperties` | — | 画布容器样式 |
109
+ | `panelClassName` | `string` | — | 属性面板容器类名 |
110
+ | `panelStyle` | `CSSProperties` | — | 属性面板容器样式 |
111
+ | `onSave` | `(xml: string) => void` | — | 保存回调 |
112
+ | `onChange` | `(xml: string) => void` | — | 内容变更回调 |
113
+ | `onInit` | `(modeler: Modeler) => void` | — | 初始化完成回调 |
114
+
115
+ ### fitToView
116
+
117
+ 将流程图适配到视口并居中显示。
118
+
119
+ ```tsx
120
+ import { fitToView } from 'iop-bpmn-react'
121
+
122
+ // 在 onInit 回调中使用
123
+ <BpmnViewer onInit={(viewer) => fitToView(viewer)} />
124
+ ```
125
+
126
+ ### layoutProcess
127
+
128
+ 对 BPMN XML 进行自动布局,为缺少坐标信息的元素生成位置。
129
+
130
+ ```tsx
131
+ import { layoutProcess } from 'iop-bpmn-react'
132
+
133
+ const layoutedXml = await layoutProcess(xmlString)
134
+ ```
135
+
36
136
  ## 开发命令
37
137
 
38
138
  | 任务 | 命令 |
@@ -283,8 +383,8 @@ src/
283
383
 
284
384
  ## 技术栈
285
385
 
286
- - **Vite** - 构建工具
287
- - **React 18** + TypeScript
386
+ - **Vite 8** - 构建工具
387
+ - **React 19** + TypeScript
288
388
  - **bpmn-js** - BPMN 2.0 流程图引擎
289
389
  - **bpmn-js-properties-panel** - 属性面板组件
290
390
  - **bpmn-js-i18n** - 国际化翻译