@bpmn-nova/vue 0.3.5-preview → 0.3.7-preview

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
@@ -4,7 +4,7 @@ BPMN Nova 的 Vue 3.3+ Adapter,提供 Studio、Designer、Viewer、审批轨
4
4
 
5
5
  > **English summary:** Vue 3.3+ components and exposed instance methods for BPMN Nova process design, viewing, approval traces, properties, themes, and SVG export.
6
6
 
7
- > 当前版本为 `0.3.5-preview`。Vue 由宿主工程提供,本包不会替应用选择或升级框架版本。
7
+ > 当前版本为 `0.3.7-preview`。Vue 由宿主工程提供,本包不会替应用选择或升级框架版本。
8
8
 
9
9
  ![BPMN Nova Vue 流程工作台](https://raw.githubusercontent.com/daxiangme/bpmn-nova/dev/docs/assets/bpmn-nova-designer.jpg)
10
10
 
@@ -14,29 +14,11 @@ BPMN Nova 的 Vue 3.3+ Adapter,提供 Studio、Designer、Viewer、审批轨
14
14
  npm install @bpmn-nova/vue@preview
15
15
  ```
16
16
 
17
- ```js
18
- import '@bpmn-nova/vue/styles.css'
19
- ```
20
-
21
- 只安装本包;`@bpmn-nova/studio` 会作为内部依赖自动解析。容器必须有明确高度。
22
-
23
- TypeScript 类型也从 Vue 入口导入,不要为了模型类型额外声明 Studio 直依赖:
24
-
25
- ```ts
26
- import type {
27
- BpmnNode,
28
- EdgeType,
29
- ElementSelection,
30
- NodeType,
31
- ProcessModel,
32
- } from '@bpmn-nova/vue'
33
- ```
34
-
35
- 公共类型门面还包含 `BpmnEdge`、`EngineId` 和 `LayoutOptions`。
17
+ 只安装本包;匹配版本的 `@bpmn-nova/studio` 会作为依赖自动解析。公共 TypeScript 类型直接从 `@bpmn-nova/vue` 导入,不需要为类型额外添加 Studio 直依赖。
36
18
 
37
- 使用代码生成助手或 IDE Agent 接入时,从随包的 `llms.txt` 开始;需要完整接口和定制资料时再读取 `llms-full.txt`。两份文件都包含在 npm tarball 中,不依赖源码仓库可见性。
19
+ CSS 必须显式导入 `@bpmn-nova/vue/styles.css`;视觉容器及其父级需要具有可计算高度。
38
20
 
39
- ## 流程设计
21
+ ## 最小用法
40
22
 
41
23
  ```vue
42
24
  <script setup>
@@ -69,301 +51,17 @@ function handleChange(model, reason, nextXml) {
69
51
  </template>
70
52
  ```
71
53
 
72
- Expose 提供 `getActions()`、`validate()`、`exportXml()`、`fitView()`、`setTheme()`、`exportSvg()` `openSvgExportPreview()`。
73
-
74
- `xml`/`model` 是外部替换输入,`change` 的 XML 是草稿输出。宿主回写完全相同的导出 XML 不会重新导入或清空撤销历史;切换服务器 revision 或流程时传入不同 XML 会替换模型。Activiti 宿主应显式使用 `engine="activiti"`。
75
-
76
- ## 组合宿主头部与业务属性面板
77
-
78
- 默认 `BpmnStudio` 是包含 Header、Palette、Canvas、Properties 和 Statusbar 的完整工作台。下面的接入显式隐藏 Nova Properties,保留 Nova Palette,并只替换 Header 左侧品牌区:
79
-
80
- ```vue
81
- <script setup>
82
- import { ref } from 'vue'
83
- import { BpmnStudio } from '@bpmn-nova/vue'
84
- import '@bpmn-nova/vue/styles.css'
85
-
86
- const studioRef = ref(null)
87
- const selectedElement = ref(null)
88
- const supportedNodeTypes = ['startEvent', 'userTask', 'exclusiveGateway', 'endEvent']
89
-
90
- function handleSelectionChange(selection, element) {
91
- selectedElement.value = selection ? element : null
92
- }
93
- </script>
94
-
95
- <template>
96
- <div class="process-design-workbench">
97
- <BpmnStudio
98
- ref="studioRef"
99
- :xml="xml"
100
- engine="activiti"
101
- mode="design"
102
- :allowed-modes="['design']"
103
- :config="{
104
- modeling: { allowedNodeTypes: supportedNodeTypes, allowedEdgeTypes: ['sequenceFlow'] },
105
- ui: { controlSize: 'medium', regions: { right: 'hidden' } },
106
- }"
107
- theme="auto"
108
- @change="handleChange"
109
- @selection-change="handleSelectionChange"
110
- @validation="handleValidation"
111
- >
112
- <template #header-start="{ state, actions }">
113
- <button type="button" @click="back">← 返回审批列表</button>
114
- <ApprovalIcon :icon="icon" />
115
- <strong>{{ processName }}</strong>
116
- <span>{{ processType }}</span>
117
- </template>
118
- <template #header-actions="{ actions, mode, ui }">
119
- <button type="button" :disabled="mode !== 'design'" @click="actions.validate()">校验</button>
120
- <button type="button" :disabled="mode !== 'design'" @click="saveDraft(actions.exportXml())">保存</button>
121
- <button type="button" :disabled="mode !== 'design'" @click="publishProcess(actions)">发布</button>
122
- </template>
123
- </BpmnStudio>
124
-
125
- <DxProcessProperties
126
- v-if="selectedElement"
127
- :element-id="selectedElement.id"
128
- />
129
- </div>
130
- </template>
131
- ```
132
-
133
- `header-start` 与 `header-actions` 使用 Vue Teleport 在当前应用内渲染,因此保留 provide/inject、响应式状态与组件生命周期。`header-actions` 只替换默认“校验 / 导入 / 导出”动作组,完整 `header` 的优先级更高。默认 Header 的最佳视图只保留在底部缩放区;若整个 Header 都不需要,配置 `regions.header = 'hidden'`。
134
-
135
- `actions.validate()` 以 `toolbar` 来源先更新 Nova 默认状态栏,再发送 `validation` 事件并返回 issues;Expose `validate()` 使用 `api` 来源。事件的 `valid` 仅在存在 error 时为 `false`,warning 不默认阻止发布。保存与发布仍由宿主负责。
136
-
137
- ```js
138
- async function publishProcess(actions) {
139
- const issues = actions.validate()
140
- if (issues.some((issue) => issue.level === 'error')) return
141
- await publishXml(actions.exportXml())
142
- }
143
- ```
144
-
145
- 编辑器属性面板应订阅 `selection-change`,该事件覆盖节点、连线、多选、清空和键盘选择。`element-click` 是点击观察事件,不能代替选择状态。宿主使用稳定 BPMN Element ID 关联业务配置,并自行拥有保存、发布、权限和服务端事务。
146
-
147
- `config` 收拢 `modeling/ui/viewer/export` 静态选项。顶部控件尺寸使用 `config.ui.controlSize`,默认 `medium`,支持 `small`、`medium`、`large` 和 `24px`–`48px`。Slot Context 的只读 `ui.controlHeight` 可直接适配宿主按钮;Element Plus `default`、Ant Design `middle` 都映射到 Nova `medium`。自定义 px 时也可在 Header Actions 样式中读取 `--nova-control-height` 等公开变量。
148
-
149
- ```vue
150
- <BpmnStudio ref="studioRef" :config="{ ui: { controlSize: '36px' } }">
151
- <template #header-actions="{ actions, ui }">
152
- <HostActions :actions="actions" :button-height="ui.controlHeight" />
153
- </template>
154
- </BpmnStudio>
155
- ```
156
-
157
- Expose 同步提供 `getConfig()` / `setConfig()`;响应式更新 UI、Viewer 或 Export 不重建 Canvas。旧顶层配置继续兼容并标记 Deprecated,同项冲突时显式旧值优先。`config.modeling` 只在内部 Controller 创建时建立节点和连线约束。
158
-
159
- ## 原生右侧 Slot 与折叠
160
-
161
- 不需要把所有业务面板都放到 Nova 外部。使用 `#right` 可以只替换右侧内容,并保留 Nova 的布局与折叠按钮;它高于 `slotsConfig.right`,通过 Teleport 保留宿主上下文。不要同时设置 `regions.right: 'hidden'`,否则整个区域都隐藏。
162
-
163
- ```vue
164
- <BpmnStudio
165
- ref="studioRef"
166
- :xml="xml"
167
- :config="{ ui: {
168
- leftPanel: { collapsible: true, defaultCollapsed: false },
169
- rightPanel: { collapsible: true, defaultCollapsed: false, layout: 'flex' },
170
- } }"
171
- @sidebar-change="event => console.log(event.side, event.collapsed, event.source)"
172
- >
173
- <template #right="{ panelSelection, mode }">
174
- <header style="flex: none; padding: 12px">业务详情 · {{ mode }}</header>
175
- <div style="flex: 1; min-height: 0; overflow: auto; padding: 12px">
176
- {{ panelSelection.selectedElement?.id ?? '未选择元素' }}
177
- <!-- 填入宿主表单 -->
178
- </div>
179
- <footer style="flex: none; padding: 12px">宿主固定操作区</footer>
180
- </template>
181
- </BpmnStudio>
182
- ```
183
-
184
- 默认 `flex` 由宿主安排内部滚动;`scroll` 由 Nova 滚动整个内容,宿主只填普通内容。父容器仍需可计算高度。收起不卸载 Slot,不丢失表单/滚动状态、不自动 Fit;左右分隔线中点按钮支持键盘,200ms 动画尊重减少动态效果。容器 ≤720px 时首次默认收起,按钮保留,展开挤压画布而非抽屉,宽窄屏分别记忆状态。
185
-
186
- Expose 增加 `getSidebarState()`、`setSidebarCollapsed(side, collapsed)`、`subscribeSidebarChange()`、`getPanelSelection()`、`subscribePanelSelection()`;设置仅在实际切换时返回 `true`。Header/Right Slot 共享响应式 `panelSelection`(`selection`、`selectedElement`、`trace`),只读轨迹选择不回写设计选择。
187
-
188
- Instance 默认隐藏右侧且没有展开按钮;需要时显式设置 `config.ui.regions.right: 'default'`。新增能力自 `0.3.5-preview` 提供。完整示例见[侧栏指南](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/CUSTOMIZATION.md#侧栏布局与平滑折叠)或包内 `llms-full.txt`。
189
-
190
- ## Mode 双向同步与副标题刷新
191
-
192
- ```vue
193
- <script setup>
194
- import { ref } from 'vue'
195
-
196
- const studioRef = ref(null)
197
- const mode = ref('design')
198
- const summaries = new Map()
199
- const resolveSubtitle = ({ node }) => summaries.has(node.id)
200
- ? summaries.get(node.id)
201
- : undefined
202
-
203
- function updateSummary() {
204
- summaries.set('ServiceTask_Archive', '归档到采购系统')
205
- studioRef.value?.refreshPresentation()
206
- }
207
- </script>
208
-
209
- <template>
210
- <BpmnStudio
211
- ref="studioRef"
212
- v-model:mode="mode"
213
- :allowed-modes="['design', 'viewer']"
214
- :node-subtitle-resolver="resolveSubtitle"
215
- @mode-change="event => console.log(event.source)"
216
- >
217
- <template #header-start="{ mode: actualMode }">
218
- <HostHeader :mode="actualMode" />
219
- </template>
220
- </BpmnStudio>
221
- </template>
222
- ```
223
-
224
- Expose 的 `getMode()` / `setMode()` 使用 Shell 实际状态。Resolver 返回 `undefined` 保留默认值、`null` 移除副标题行、字符串替换显示;函数引用变化会自动刷新,稳定闭包内部数据变化需显式调用 `refreshPresentation()`。Resolver 只影响 Design/Viewer 标准卡片和 SVG,不覆盖 Instance Runtime Presentation,也不修改 XML、History、Selection 或 Viewport。
225
-
226
- ## 只读展示与审批轨迹
227
-
228
- 真实后端的数据格式与接入步骤见[审批轨迹接入指南](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/RUNTIME-INTEGRATION.md),完整正文也包含在包内 `llms-full.txt`。Vue 根入口的 `ProcessInstanceSnapshot`、Activity/Action/Transition、`RuntimeTraceClickEvent` 与资源 Resolver 等 14 个 Runtime 类型出口自 `0.3.5-preview` 提供;旧版可按指南从 `BpmnStudioProps['runtime']` 推导,无需增加 Studio 直依赖。
229
-
230
- ```vue
231
- <script setup>
232
- import { BpmnViewer } from '@bpmn-nova/vue'
233
- import '@bpmn-nova/vue/styles.css'
234
-
235
- defineProps({
236
- xml: String,
237
- runtime: Object,
238
- runtimeAssetResolver: Function,
239
- })
240
- </script>
241
-
242
- <template>
243
- <div style="height: 720px">
244
- <BpmnViewer
245
- :xml="xml"
246
- engine="flowable"
247
- :runtime="runtime"
248
- projection="compact"
249
- responsive
250
- theme="auto"
251
- :runtime-asset-resolver="runtimeAssetResolver"
252
- @trace-click="event => console.log(event)"
253
- />
254
- </div>
255
- </template>
256
- ```
257
-
258
- - `approval`:实际发生的有效路径。
259
- - `compact`:移动时间线、审批动作、图片和附件。
260
- - `standard`:完整 BPMN 叠加运行状态。
261
-
262
- ![BPMN Nova Vue 移动审批时间线](https://raw.githubusercontent.com/daxiangme/bpmn-nova/dev/docs/assets/bpmn-nova-approval-mobile-timeline.jpg)
263
-
264
- ## Runtime Action 与附件
265
-
266
- ```js
267
- const runtime = {
268
- processInstanceId: 'purchase-20260824',
269
- status: 'running',
270
- activities: [{
271
- id: 'activity-manager-1',
272
- elementId: 'UserTask_Manager',
273
- visitId: 'visit-manager-1',
274
- status: 'completed',
275
- assignee: '李经理',
276
- }],
277
- actions: [{
278
- id: 'approve-manager-1',
279
- type: 'approve',
280
- elementId: 'UserTask_Manager',
281
- visitId: 'visit-manager-1',
282
- occurredAt: '2026-08-24T10:12:00+08:00',
283
- actor: { id: 'manager-li', name: '李经理' },
284
- content: {
285
- plainText: '资料完整,同意提交总经理审批。',
286
- blocks: [{ type: 'file', assetId: 'purchase-checklist' }],
287
- assets: [{
288
- id: 'purchase-checklist',
289
- name: '采购核验清单.txt',
290
- mediaType: 'text/plain',
291
- size: 248,
292
- }],
293
- },
294
- }],
295
- visitedEdges: [],
296
- }
297
-
298
- const runtimeAssetResolver = async (asset, { purpose, signal }) => {
299
- const response = await fetch(
300
- `/api/runtime-assets/${encodeURIComponent(asset.id)}?purpose=${purpose}`,
301
- { signal },
302
- )
303
- return response.ok ? response.url : null
304
- }
305
- ```
306
-
307
- Runtime Snapshot 只保存资源引用;上传、存储和权限签发由宿主负责。
308
-
309
- ## 主题和 SVG 导出
310
-
311
- ```vue
312
- <BpmnStudio
313
- ref="studioRef"
314
- :xml="xml"
315
- :theme="{
316
- mode: 'auto',
317
- dark: {
318
- colors: {
319
- canvas: '#0b1018',
320
- surface: '#18202b',
321
- },
322
- },
323
- }"
324
- />
325
- ```
326
-
327
- ```js
328
- studioRef.value?.openSvgExportPreview({
329
- theme: 'current',
330
- filename: '采购申请审批流程.svg',
331
- })
332
- ```
333
-
334
- 主题属性变化会更新现有实例,不会重新挂载画布、清除选择或关闭详情。
335
-
336
- ## Properties 与自定义 Renderer
337
-
338
- 本包还导出:
339
-
340
- - `BpmnDesigner`、`BpmnCanvas`、`BpmnPalettePanel`、`BpmnPropertiesPanel`
341
- - `useBpmnStudio`
342
- - `createVuePropertyComponent`
343
- - `createVueRuntimeDetailsComponent`
344
- - `createVueRuntimeTransitionDetailsComponent`
345
- - `createVueRuntimeTimelineComponent`
346
- - `createStudioController`、`createEmptyProcess`、`importBpmn`、`exportBpmn`
347
- - Palette、Properties、Context Menu、Icon 和 Template Registry 的公开创建函数
348
-
349
- 完整工作台可通过 `allowedNodeTypes` 与 `allowedEdgeTypes` 限制宿主支持的图元类型,通过 `allowedModes` 限制可切换的工作台模式。图元限制同时作用于 XML 导入、Palette、连接、快捷新增、模板和节点类型转换。
350
-
351
- ## 常见问题
54
+ `initialXml` 由宿主提供。组件负责实例生命周期;SSR 应用只在客户端挂载。`xml` / `model` 用于外部替换输入,事件中的 XML 是草稿输出。
352
55
 
353
- - **无高度:** 为外层容器设置明确高度。
354
- - **无样式:** 导入一次 `@bpmn-nova/vue/styles.css`。
355
- - **Vue 重复:** Vue 应由宿主提供并保持单实例。
356
- - **SSR:** 将可视组件放到客户端挂载阶段。
357
- - **包选择:** Vue 项目只直接安装 `@bpmn-nova/vue`。
56
+ ## 完整文档
358
57
 
359
- ## 文档与 AI
58
+ - [官网与文档](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/index.md)
59
+ - [Vue 接入、宿主组合和完整示例](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/vue.md)
60
+ - [组件参数与事件](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/components/index.md)、[公开 API](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/api/index.md)
61
+ - [审批轨迹接入](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/guide/runtime.md)、[自定义扩展](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/customization/index.md)
62
+ - [更新日志](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/src/changelog.md)
360
63
 
361
- - npm 包内 `llms.txt`:可执行安装入口
362
- - npm 包内 `llms-full.txt`:完整 AI 上下文
363
- - [完整项目能力](https://github.com/daxiangme/bpmn-nova)
364
- - [React/Vue 组件说明](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/COMPONENTS.md)
365
- - [公开 Interface](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/API.md)
366
- - [审批轨迹接入指南](https://github.com/daxiangme/bpmn-nova/blob/dev/docs/RUNTIME-INTEGRATION.md)
64
+ 官网尚未部署,以上链接暂指向仓库文档。AI 接入从随包的 `llms.txt` 开始;`llms-full.txt` 提供完整离线上下文,两份文件都包含在 npm tarball 中。
367
65
 
368
66
  ## License
369
67
 
package/dist/index.d.ts CHANGED
@@ -80,20 +80,31 @@ export type {
80
80
  StudioViewerConfig,
81
81
  } from '@bpmn-nova/studio'
82
82
 
83
- /** Runtime integration facade. Added in 0.3.5-preview; no runtime JavaScript exports. */
83
+ /** Runtime integration facade. Types since 0.3.5-preview; inspectRuntime / formatRuntimeInstant since 0.3.6-preview. */
84
84
  export type {
85
85
  ActivityInstance,
86
86
  ActivityStatus,
87
+ ActivityVisitState,
87
88
  ProcessInstanceSnapshot,
88
89
  RuntimeApprovalAction,
89
90
  RuntimeApprovalActionType,
90
91
  RuntimeApprovalContent,
91
92
  RuntimeApprovalContentBlock,
92
93
  RuntimeAssetRef,
94
+ RuntimeDiagnostic,
93
95
  RuntimeEdgeVisit,
96
+ RuntimeInstant,
94
97
  RuntimeParticipant,
95
98
  RuntimeTransition,
96
99
  } from '@bpmn-nova/studio/runtime'
100
+ export {
101
+ activityState,
102
+ createRuntimePresentation,
103
+ formatRuntimeInstant,
104
+ inspectRuntime,
105
+ normalizeRuntime,
106
+ parseRuntimeInstant,
107
+ } from '@bpmn-nova/studio/runtime'
97
108
  export type {
98
109
  RuntimeAssetPurpose,
99
110
  RuntimeAssetResolver,
package/dist/index.js CHANGED
@@ -6,6 +6,15 @@ import { createEmptyProcess } from '@bpmn-nova/studio';
6
6
  import { BpmnCanvas as CoreCanvas, BpmnStudioShell as CoreStudioShell, createInteractionController, createStudioController, createTemplateRegistry } from '@bpmn-nova/studio';
7
7
  import { PalettePanel as CorePalettePanel, createDefaultPaletteRegistry as createCoreDefaultPaletteRegistry } from '@bpmn-nova/studio';
8
8
 
9
+ export {
10
+ activityState,
11
+ createRuntimePresentation,
12
+ formatRuntimeInstant,
13
+ inspectRuntime,
14
+ normalizeRuntime,
15
+ parseRuntimeInstant,
16
+ } from '@bpmn-nova/studio/runtime';
17
+
9
18
  export {
10
19
  createContextMenuRegistry,
11
20
  createDefaultContextMenuRegistry,
package/dist/styles.css CHANGED
@@ -938,6 +938,11 @@ button.mb-runtime-action-summary:hover, button.mb-runtime-action-summary:focus-v
938
938
  .mb-runtime-timeline-content { min-width: 0; display: grid; gap: 4px; }
939
939
  .mb-runtime-timeline-card { width: 100%; min-width: 0; overflow: visible; border: 0; border-radius: 0; display: grid; color: inherit; background: transparent; box-shadow: none; }
940
940
  .mb-runtime-timeline-card-main { width: 100%; min-width: 0; border: 0; border-radius: 8px; padding: 5px 7px; display: grid; gap: 3px; color: inherit; background: transparent; text-align: left; font: inherit; cursor: pointer; transition: background-color .14s ease, box-shadow .14s ease; }
941
+ .mb-runtime-timeline-card-main.has-avatars { grid-template-columns: auto minmax(0, 1fr); align-items: start; column-gap: 8px; }
942
+ .mb-runtime-timeline-card-copy { min-width: 0; display: grid; gap: 3px; }
943
+ .mb-runtime-timeline-avatars { display: flex; align-items: center; margin-top: 2px; }
944
+ .mb-runtime-timeline-avatars .mb-runtime-details-avatar + .mb-runtime-details-avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--nova-color-surface, #fff); }
945
+ .mb-runtime-timeline-avatar-more { font-size: var(--nova-font-size-xs, 10px); }
941
946
  .mb-runtime-timeline-card-main:hover { background: var(--nova-color-primary-soft, #f5f6ff); }
942
947
  .mb-runtime-timeline-card-main:focus-visible { outline: none; background: var(--nova-color-primary-soft, #f5f6ff); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--nova-color-primary) 22%, transparent); }
943
948
  .mb-runtime-timeline-card-main:active { background: color-mix(in srgb, var(--nova-color-primary-soft) 84%, var(--nova-color-primary)); }