nkk-flow 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 +21 -0
- package/README.md +180 -0
- package/dist/index.cjs +226 -0
- package/dist/index.js +5682 -0
- package/dist/style.css +2 -0
- package/dist/types/components/ui/cascader/Cascader.vue.d.ts +44 -0
- package/dist/types/components/ui/cascader/index.d.ts +2 -0
- package/dist/types/components/ui/cascader/types.d.ts +27 -0
- package/dist/types/components/ui/checkbox/Checkbox.vue.d.ts +24 -0
- package/dist/types/components/ui/checkbox/index.d.ts +1 -0
- package/dist/types/components/ui/date/DatePanel.vue.d.ts +11 -0
- package/dist/types/components/ui/date/DatePicker.vue.d.ts +21 -0
- package/dist/types/components/ui/date/index.d.ts +2 -0
- package/dist/types/components/ui/date/useFloatingPanel.d.ts +18 -0
- package/dist/types/components/ui/date-time/DateTimePicker.vue.d.ts +18 -0
- package/dist/types/components/ui/date-time/index.d.ts +1 -0
- package/dist/types/components/ui/drawer/Drawer.vue.d.ts +40 -0
- package/dist/types/components/ui/drawer/index.d.ts +1 -0
- package/dist/types/components/ui/empty/Empty.vue.d.ts +11 -0
- package/dist/types/components/ui/empty/index.d.ts +1 -0
- package/dist/types/components/ui/input/Input.vue.d.ts +20 -0
- package/dist/types/components/ui/input/index.d.ts +1 -0
- package/dist/types/components/ui/input-number/InputNumber.vue.d.ts +23 -0
- package/dist/types/components/ui/input-number/index.d.ts +1 -0
- package/dist/types/components/ui/loading/Loading.vue.d.ts +9 -0
- package/dist/types/components/ui/loading/LoadingMask.vue.d.ts +15 -0
- package/dist/types/components/ui/loading/index.d.ts +14 -0
- package/dist/types/components/ui/loading/service.d.ts +20 -0
- package/dist/types/components/ui/radio/Radio.vue.d.ts +26 -0
- package/dist/types/components/ui/radio/index.d.ts +1 -0
- package/dist/types/components/ui/scrollbar/Scrollbar.vue.d.ts +24 -0
- package/dist/types/components/ui/scrollbar/index.d.ts +1 -0
- package/dist/types/components/ui/segmented/Segmented.vue.d.ts +20 -0
- package/dist/types/components/ui/segmented/index.d.ts +2 -0
- package/dist/types/components/ui/segmented/types.d.ts +12 -0
- package/dist/types/components/ui/select/Select.vue.d.ts +34 -0
- package/dist/types/components/ui/select/index.d.ts +2 -0
- package/dist/types/components/ui/select-field/SelectField.vue.d.ts +33 -0
- package/dist/types/components/ui/select-field/index.d.ts +3 -0
- package/dist/types/components/ui/switch/Switch.vue.d.ts +15 -0
- package/dist/types/components/ui/switch/index.d.ts +1 -0
- package/dist/types/components/ui/tree-node/TreeNode.vue.d.ts +55 -0
- package/dist/types/components/ui/tree-node/TreeNodeRow.vue.d.ts +22 -0
- package/dist/types/components/ui/tree-node/context.d.ts +23 -0
- package/dist/types/components/ui/tree-node/index.d.ts +3 -0
- package/dist/types/components/ui/tree-node/types.d.ts +15 -0
- package/dist/types/components/ui/tree-node/utils.d.ts +41 -0
- package/dist/types/hooks/logicflow/adapter.d.ts +17 -0
- package/dist/types/hooks/logicflow/components/add-node-dialog/index.vue.d.ts +18 -0
- package/dist/types/hooks/logicflow/components/index.d.ts +3 -0
- package/dist/types/hooks/logicflow/components/node-config/ApprovalNodeConfig.vue.d.ts +4 -0
- package/dist/types/hooks/logicflow/components/node-config/CcNodeConfig.vue.d.ts +4 -0
- package/dist/types/hooks/logicflow/components/node-config/ConditionNodeConfig.vue.d.ts +4 -0
- package/dist/types/hooks/logicflow/components/node-config/StartNodeConfig.vue.d.ts +4 -0
- package/dist/types/hooks/logicflow/components/node-config/TimerNodeConfig.vue.d.ts +4 -0
- package/dist/types/hooks/logicflow/components/node-config/index.d.ts +19 -0
- package/dist/types/hooks/logicflow/components/node-config/index.vue.d.ts +43 -0
- package/dist/types/hooks/logicflow/components/node-config/types.d.ts +28 -0
- package/dist/types/hooks/logicflow/components/primitives/pickers/NodeConfigAssigneePicker.vue.d.ts +56 -0
- package/dist/types/hooks/logicflow/components/primitives/pickers/NodeConfigAssigneeTags.vue.d.ts +12 -0
- package/dist/types/hooks/logicflow/components/primitives/pickers/NodeConfigInitiatorPicker.vue.d.ts +30 -0
- package/dist/types/hooks/logicflow/components/primitives/ui/NodeConfigAddButton.vue.d.ts +12 -0
- package/dist/types/hooks/logicflow/components/primitives/ui/NodeConfigRadioCard.vue.d.ts +14 -0
- package/dist/types/hooks/logicflow/components/primitives/ui/NodeConfigSectionTitle.vue.d.ts +9 -0
- package/dist/types/hooks/logicflow/defaults.d.ts +9 -0
- package/dist/types/hooks/logicflow/edges/index.d.ts +1 -0
- package/dist/types/hooks/logicflow/edges/process/FlowProcessEdge.d.ts +34 -0
- package/dist/types/hooks/logicflow/edges/process/index.d.ts +1 -0
- package/dist/types/hooks/logicflow/index.d.ts +31 -0
- package/dist/types/hooks/logicflow/nodes/process/FlowProcessNode.d.ts +93 -0
- package/dist/types/hooks/logicflow/nodes/process/index.d.ts +1 -0
- package/dist/types/hooks/logicflow/register.d.ts +2 -0
- package/dist/types/hooks/logicflow/types/form.d.ts +26 -0
- package/dist/types/hooks/logicflow/types/index.d.ts +3 -0
- package/dist/types/hooks/logicflow/types/logicflow.d.ts +209 -0
- package/dist/types/hooks/logicflow/types/process/base.d.ts +52 -0
- package/dist/types/hooks/logicflow/types/process/endpoint.d.ts +19 -0
- package/dist/types/hooks/logicflow/types/process/router.d.ts +48 -0
- package/dist/types/hooks/logicflow/types/process/task.d.ts +86 -0
- package/dist/types/hooks/logicflow/types/process.d.ts +24 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nkk
|
|
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
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# nkk-flow
|
|
2
|
+
|
|
3
|
+
Vue 3 + LogicFlow 审批流画布封装。核心入口是 `useFlow`,页面只需要提供容器、业务流程 JSON 和可选配置。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install nkk-flow @logicflow/core @logicflow/extension @vueuse/core vue
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
在应用入口引入样式:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import '@logicflow/core/dist/index.css'
|
|
15
|
+
import '@logicflow/extension/lib/index.css'
|
|
16
|
+
import 'nkk-flow/style.css'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 基础用法
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
|
23
|
+
import { useFlow, type FlowProcessJson, type FlowOptions } from 'nkk-flow'
|
|
24
|
+
|
|
25
|
+
const graphRef = ref<HTMLElement | null>(null)
|
|
26
|
+
let flowApi: ReturnType<typeof useFlow> | null = null
|
|
27
|
+
|
|
28
|
+
const options: FlowOptions = {
|
|
29
|
+
editable: true,
|
|
30
|
+
tools: ['MiniMap'],
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
onMounted(() => {
|
|
34
|
+
if (!graphRef.value) return
|
|
35
|
+
flowApi = useFlow(graphRef.value, flowJson as FlowProcessJson, options)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
onBeforeUnmount(() => {
|
|
39
|
+
flowApi?.destroy()
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<template>
|
|
45
|
+
<div ref="graphRef" style="height: 100%; width: 100%;" />
|
|
46
|
+
</template>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 主要配置
|
|
50
|
+
|
|
51
|
+
`useFlow(element, flowJson, options?)`
|
|
52
|
+
|
|
53
|
+
`editable`:是否允许编辑。默认 `true`。关闭后会隐藏删除、标题编辑、添加节点和添加分支入口。
|
|
54
|
+
|
|
55
|
+
`tools`:内置工具,当前支持 `zoom`、`MiniMap`。
|
|
56
|
+
|
|
57
|
+
`nodePicker.options`:控制点击连线 `+` 后可添加的节点类型。
|
|
58
|
+
|
|
59
|
+
`nodePicker.nodeFactories`:自定义某个类型新增时生成的业务 JSON。
|
|
60
|
+
|
|
61
|
+
`nodeDrawer.orgTree` / `nodeDrawer.people` / `nodeDrawer.roles`:**组织数据由宿主注入**,库本身不发任何 HTTP 请求。宿主侧自行从后端拉取后传入,审批人/部门/角色选择器才能显示数据。
|
|
62
|
+
|
|
63
|
+
`nodeDrawer.nodeConfigs`:追加或覆盖节点配置抽屉表单。
|
|
64
|
+
|
|
65
|
+
`events`:监听节点点击、删除、标题修改、插入、抽屉保存等事件。
|
|
66
|
+
|
|
67
|
+
## 注入组织数据
|
|
68
|
+
|
|
69
|
+
`useFlow` 是一个纯画布封装,不内置任何网络请求。审批节点配置抽屉需要的组织架构、人员列表、角色列表,由宿主侧拉取后通过 `options.nodeDrawer` 注入:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { fetchDrawerOrgData } from './api/org' // 宿主侧自己的接口
|
|
73
|
+
|
|
74
|
+
const { orgTree, people, roles } = await fetchDrawerOrgData()
|
|
75
|
+
|
|
76
|
+
useFlow(container, flowJson, {
|
|
77
|
+
nodeDrawer: { orgTree, people, roles },
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
条件分支节点需要的表单字段元数据,通过 `flowApi.setMetaFormFields()` 注入:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const flowApi = useFlow(container, flowJson, options)
|
|
85
|
+
flowApi.setMetaFormFields(formFieldsFromBackend)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 扩展节点配置抽屉
|
|
89
|
+
|
|
90
|
+
每个节点配置表单独立成组件,组件接收 `payload` 和 `context`,并通过 `defineExpose` 暴露 `getPatch()`。
|
|
91
|
+
|
|
92
|
+
```vue
|
|
93
|
+
<script setup lang="ts">
|
|
94
|
+
import type { FlowNodeConfigFormExpose, FlowNodeConfigFormProps } from 'nkk-flow'
|
|
95
|
+
|
|
96
|
+
const props = defineProps<FlowNodeConfigFormProps>()
|
|
97
|
+
|
|
98
|
+
function getPatch() {
|
|
99
|
+
return {
|
|
100
|
+
customValue: props.payload.title,
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
defineExpose<FlowNodeConfigFormExpose>({ getPatch })
|
|
105
|
+
</script>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
注册到 `useFlow`:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
useFlow(container, flowJson, {
|
|
112
|
+
nodeDrawer: {
|
|
113
|
+
nodeConfigs: [
|
|
114
|
+
{
|
|
115
|
+
type: 2,
|
|
116
|
+
kind: 'cc',
|
|
117
|
+
title: '抄送节点',
|
|
118
|
+
description: '配置抄送人员',
|
|
119
|
+
component: CcNodeConfig,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 自定义新增节点 JSON
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
useFlow(container, flowJson, {
|
|
130
|
+
nodePicker: {
|
|
131
|
+
options: [{ type: 2, label: '抄送节点', description: '通知相关人员。' }],
|
|
132
|
+
nodeFactories: {
|
|
133
|
+
2: ({ nextNode, createNodeKey }) => ({
|
|
134
|
+
nodeName: '抄送节点',
|
|
135
|
+
nodeKey: createNodeKey('cc'),
|
|
136
|
+
type: 2,
|
|
137
|
+
nodeAssigneeList: [],
|
|
138
|
+
childNode: nextNode ?? {},
|
|
139
|
+
}),
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 当前内置节点类型
|
|
146
|
+
|
|
147
|
+
`-1`:结束
|
|
148
|
+
|
|
149
|
+
`0`:发起人
|
|
150
|
+
|
|
151
|
+
`1`:审批节点
|
|
152
|
+
|
|
153
|
+
`2`:抄送节点
|
|
154
|
+
|
|
155
|
+
`3`:条件分支
|
|
156
|
+
|
|
157
|
+
`4`:条件路由
|
|
158
|
+
|
|
159
|
+
`5`:子流程
|
|
160
|
+
|
|
161
|
+
`6`:延迟等待
|
|
162
|
+
|
|
163
|
+
`7`:触发器
|
|
164
|
+
|
|
165
|
+
`8`:并行路由
|
|
166
|
+
|
|
167
|
+
`9`:包容路由
|
|
168
|
+
|
|
169
|
+
`23`:路由分支
|
|
170
|
+
|
|
171
|
+
`30`:自动通过
|
|
172
|
+
|
|
173
|
+
`31`:自动拒绝
|
|
174
|
+
|
|
175
|
+
## 开发脚本
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
npm run build
|
|
179
|
+
npm run build:lib
|
|
180
|
+
```
|