@kne/react-flow-chart 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/README.md ADDED
@@ -0,0 +1,161 @@
1
+
2
+ # react-flow-chart
3
+
4
+
5
+ ### 描述
6
+
7
+ 用于展示或编辑一个审批流
8
+
9
+
10
+ ### 安装
11
+
12
+ ```shell
13
+ npm i --save @kne/react-flow-chart
14
+ ```
15
+
16
+
17
+ ### 概述
18
+
19
+ **致谢:** 本项目的大部分代码迁移自 @wanglin1994/simple-flow-chart,源项目为Vue2实现,我将它用React重新实现
20
+
21
+ [https://github.com/wanglin2/simple-flow-chart](https://github.com/wanglin2/simple-flow-chart)
22
+
23
+ 注意: 本项目的分支数据结构和源项目有所不同,如果使用本项目,请以本项目的文档为主
24
+
25
+
26
+ ### 示例
27
+
28
+
29
+ #### 示例样式
30
+
31
+ ```scss
32
+ .ant-card {
33
+ border-color: black;
34
+ text-align: center;
35
+ width: 200px;
36
+ }
37
+ ```
38
+
39
+ #### 示例代码
40
+
41
+ - 这里填写示例标题
42
+ - 这里填写示例说明
43
+ - _ReactFlowChart(@kne/current-lib_react-flow-chart),(@kne/current-lib_react-flow-chart/dist/index.css),antd(antd)
44
+
45
+ ```jsx
46
+ const { default: ReactFlowChart } = _ReactFlowChart;
47
+ const { Flex, Segmented } = antd;
48
+ const { useState } = React;
49
+
50
+ const BaseExample = () => {
51
+ const [vertical, onChange] = useState(false);
52
+ return <Flex vertical gap={8}>
53
+ <div>
54
+ <Segmented
55
+ options={[{
56
+ label: '横向', value: false
57
+ }, {
58
+ label: '纵向', value: true
59
+ }]}
60
+ onChange={onChange} value={vertical} />
61
+ </div>
62
+ <ReactFlowChart defaultValue={[{ 'id': 'startEvent', 'type': 'start', 'title': '开始' }, {
63
+ 'id': '随机id1',
64
+ 'type': 'normal',
65
+ 'title': '申请人',
66
+ 'content': '员工'
67
+ }, {
68
+ 'id': 'ac455ff3-6fbb-4af9-abc7-4553b0ea4bf7',
69
+ 'type': 'normal',
70
+ 'title': '普通节点',
71
+ 'content': '节点内容'
72
+ }, {
73
+ 'id': '05561aac-7a2f-4ed9-a71b-9f37ca980cc7',
74
+ 'type': 'condition',
75
+ 'title': '条件分支',
76
+ 'children': [[{
77
+ 'id': 'a1684192-e961-46a6-b8f0-b87bfbb045d7',
78
+ 'type': 'branch',
79
+ 'title': '条件',
80
+ 'content': '条件内容'
81
+ }, {
82
+ 'id': '239f20cf-7a6f-486f-b68a-be53d926d746',
83
+ 'type': 'normal',
84
+ 'title': '普通节点',
85
+ 'content': '节点内容'
86
+ }], [{
87
+ 'id': 'f3bca75a-586c-463e-8a01-9ca432126671',
88
+ 'type': 'branch',
89
+ 'title': '条件',
90
+ 'content': '条件内容'
91
+ }, {
92
+ 'id': '1a677d4f-8147-454c-9101-ea8a4818ce83',
93
+ 'type': 'normal',
94
+ 'title': '普通节点',
95
+ 'content': '节点内容'
96
+ }], [{
97
+ 'id': 'bad05c8a-d186-4c60-9d22-31472c0fe364',
98
+ 'type': 'branch',
99
+ 'title': '条件',
100
+ 'content': '条件内容'
101
+ }, {
102
+ 'id': 'ca240288-18ec-4b19-9e78-3527db6fbc19',
103
+ 'type': 'condition',
104
+ 'title': '条件分支',
105
+ 'children': [[{
106
+ 'id': 'bed6c075-27f4-455f-935e-4bcbc70536bf',
107
+ 'type': 'branch',
108
+ 'title': '条件',
109
+ 'content': '条件内容'
110
+ }], [{
111
+ 'id': '88f01a9a-dcd5-4396-9976-d2ed188996a8',
112
+ 'type': 'branch',
113
+ 'title': '条件',
114
+ 'content': '条件内容'
115
+ }, {
116
+ 'id': '48390694-28da-4f8b-a1b3-58166295c64a',
117
+ 'type': 'normal',
118
+ 'title': '普通节点',
119
+ 'content': '节点内容'
120
+ }]]
121
+ }]]
122
+ }, {
123
+ 'id': '07e2e432-1b3c-47e6-ac4a-54a677d9ac69',
124
+ 'type': 'condition',
125
+ 'title': '条件分支',
126
+ 'children': [[{
127
+ 'id': '133d8b89-b79a-4daf-ad46-4c2915fec339',
128
+ 'type': 'branch',
129
+ 'title': '条件',
130
+ 'content': '条件内容'
131
+ }], [{ 'id': '46ee06d5-bbf1-4c4a-8389-71e412d9af51', 'type': 'branch', 'title': '条件', 'content': '条件内容' }]]
132
+ }, {
133
+ 'id': 'c6fb9b16-5124-4bdd-b1c6-a899f257d4b4',
134
+ 'type': 'normal',
135
+ 'title': '普通节点',
136
+ 'content': '节点内容'
137
+ }, { 'id': 'endEvent', 'type': 'end', 'title': '结束' }]} onChange={(nodeList) => {
138
+ console.log(JSON.stringify(nodeList));
139
+ }} vertical={vertical} />
140
+ </Flex>;
141
+ };
142
+
143
+ render(<BaseExample />);
144
+
145
+ ```
146
+
147
+
148
+ ### API
149
+
150
+ | 属性名 | 说明 | 类型 | 默认值 |
151
+ |---------------|-----------------------|----------|-------|
152
+ | value | 节点数据,受控模式 | array | - |
153
+ | defaultValue | 节点数据,非受控模式 | array | - |
154
+ | onChange | 节点数据发生修改时触发事件 | function | - |
155
+ | readonly | 是否只读 | boolean | false |
156
+ | showScrollBar | 是否展示滚动条 | boolean | true |
157
+ | enableDrag | 内容区域是否可以拖拽滚动 | boolean | true |
158
+ | initFit | 初始化时是否自适应缩放大小 | boolean | true |
159
+ | vertical | 是否纵向展示 | boolean | false |
160
+ | onEditNode | 点击节点内容触发事件,可以用来修改节点数据 | function | - |
161
+
@@ -0,0 +1,10 @@
1
+ <svg
2
+ viewBox="0 0 1024 1024"
3
+ version="1.1"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ xmlns:xlink="http://www.w3.org/1999/xlink"
6
+ >
7
+ <path
8
+ d="M896 480H544.8V128h-65.6v352H128v66.4h351.2V896h65.6V546.4H896z"
9
+ ></path>
10
+ </svg>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1671180017363" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1156" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M312.888889 995.555556c-17.066667 0-28.444444-5.688889-39.822222-17.066667-22.755556-22.755556-17.066667-56.888889 5.688889-79.644445l364.088888-329.955555c11.377778-11.377778 17.066667-22.755556 17.066667-34.133333 0-11.377778-5.688889-22.755556-17.066667-34.133334L273.066667 187.733333c-22.755556-22.755556-28.444444-56.888889-5.688889-79.644444 22.755556-22.755556 56.888889-28.444444 79.644444-5.688889l364.088889 312.888889c34.133333 28.444444 56.888889 73.955556 56.888889 119.466667s-17.066667 85.333333-51.2 119.466666l-364.088889 329.955556c-11.377778 5.688889-28.444444 11.377778-39.822222 11.377778z" fill="#999999" p-id="1157"></path></svg>
@@ -0,0 +1,17 @@
1
+ <svg
2
+ viewBox="0 0 1024 1024"
3
+ version="1.1"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ xmlns:xlink="http://www.w3.org/1999/xlink"
6
+ >
7
+ <path d="M106.666667 213.333333h810.666666v42.666667H106.666667z"></path>
8
+ <path
9
+ d="M640 128v42.666667h42.666667V128c0-23.573333-19.093333-42.666667-42.538667-42.666667H383.872A42.496 42.496 0 0 0 341.333333 128v42.666667h42.666667V128h256z"
10
+ ></path>
11
+ <path
12
+ d="M213.333333 896V256H170.666667v639.957333C170.666667 919.552 189.653333 938.666667 213.376 938.666667h597.248C834.218667 938.666667 853.333333 919.68 853.333333 895.957333V256h-42.666666v640H213.333333z"
13
+ ></path>
14
+ <path
15
+ d="M320 341.333333h42.666667v384h-42.666667zM490.666667 341.333333h42.666666v384h-42.666666zM661.333333 341.333333h42.666667v384h-42.666667z"
16
+ ></path>
17
+ </svg>
package/dist/index.css ADDED
@@ -0,0 +1,515 @@
1
+ @keyframes _DGtHa {
2
+ 0% {
3
+ opacity: 0;
4
+ }
5
+ 100% {
6
+ opacity: 1;
7
+ }
8
+ }
9
+ ._AIhaC {
10
+ background: rgba(0, 0, 0, 0.03);
11
+ width: 100%;
12
+ height: 100%;
13
+ overflow: hidden;
14
+ -webkit-user-select: none;
15
+ user-select: none;
16
+ }
17
+ ._AIhaC._qp1e9 {
18
+ overflow: auto;
19
+ }
20
+
21
+ ._XZmmG {
22
+ display: flex;
23
+ align-items: center;
24
+ padding: 20px;
25
+ min-width: 100%;
26
+ min-height: 320px;
27
+ width: max-content;
28
+ height: max-content;
29
+ transform-origin: left top;
30
+ }
31
+ ._XZmmG._q6z6A {
32
+ transform-origin: center center;
33
+ }
34
+ ._XZmmG._B4OPa {
35
+ flex-direction: column;
36
+ justify-content: center;
37
+ }
38
+
39
+ ._W5dM8 {
40
+ position: relative;
41
+ width: 65px;
42
+ -webkit-user-select: none;
43
+ user-select: none;
44
+ }
45
+ ._W5dM8._B4OPa {
46
+ width: auto;
47
+ height: 65px;
48
+ }
49
+ ._W5dM8._B4OPa:before {
50
+ width: 2px;
51
+ height: 100%;
52
+ transform: translateX(-50%);
53
+ }
54
+ ._W5dM8._B4OPa._0Cmjn:after {
55
+ right: auto;
56
+ bottom: 0;
57
+ top: auto;
58
+ border-top: 10px solid #dedede;
59
+ border-left: 6px solid transparent;
60
+ border-right: 6px solid transparent;
61
+ border-bottom: none;
62
+ transform: translateX(-50%);
63
+ }
64
+ ._W5dM8:before {
65
+ position: absolute;
66
+ z-index: 0;
67
+ top: 0;
68
+ left: 0;
69
+ transform: translateY(-50%);
70
+ height: 2px;
71
+ width: 100%;
72
+ background-color: #dedede;
73
+ content: "";
74
+ }
75
+ ._W5dM8._0Cmjn::after {
76
+ position: absolute;
77
+ width: 0;
78
+ height: 0;
79
+ border-left: 10px solid #dedede;
80
+ border-top: 6px solid transparent;
81
+ border-bottom: 6px solid transparent;
82
+ content: "";
83
+ right: 0;
84
+ top: 0;
85
+ transform: translateY(-50%);
86
+ }
87
+
88
+ ._sVaw9 {
89
+ position: absolute;
90
+ right: 0;
91
+ top: 0;
92
+ width: 66px;
93
+ height: 100%;
94
+ display: flex;
95
+ justify-content: center;
96
+ align-items: center;
97
+ }
98
+ ._sVaw9._B4OPa {
99
+ right: auto;
100
+ top: auto;
101
+ left: 0;
102
+ bottom: 0;
103
+ width: 100%;
104
+ height: 66px;
105
+ }
106
+
107
+ ._Y4-Yv {
108
+ position: relative;
109
+ background: var(--primary-color);
110
+ width: 30px;
111
+ height: 30px;
112
+ border-radius: 50%;
113
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
114
+ display: flex;
115
+ justify-content: center;
116
+ align-items: center;
117
+ cursor: pointer;
118
+ transform: scale(0);
119
+ transition: all 0.3s;
120
+ z-index: 2;
121
+ }
122
+ ._Y4-Yv:hover {
123
+ z-index: 3;
124
+ }
125
+ ._Y4-Yv._06DKa {
126
+ transform: scale(0.3);
127
+ }
128
+ ._Y4-Yv._06DKa svg {
129
+ transform: scale(0);
130
+ }
131
+ ._Y4-Yv._59XmF {
132
+ transform: scale(1);
133
+ }
134
+ ._Y4-Yv._59XmF svg {
135
+ transform: scale(1);
136
+ }
137
+ ._Y4-Yv svg {
138
+ fill: #fff;
139
+ width: 24px;
140
+ height: 24px;
141
+ transform: scale(0);
142
+ }
143
+
144
+ ._6Grsl {
145
+ position: absolute;
146
+ visibility: hidden;
147
+ transform: scale(0);
148
+ transition: all 0.3s;
149
+ }
150
+ ._6Grsl:before, ._6Grsl:after {
151
+ content: "";
152
+ position: absolute;
153
+ top: 0;
154
+ width: 20px;
155
+ height: 100%;
156
+ }
157
+ ._6Grsl:before {
158
+ left: -20px;
159
+ }
160
+ ._6Grsl:after {
161
+ right: -20px;
162
+ }
163
+ ._6Grsl._DGtHa {
164
+ visibility: visible;
165
+ transform: scale(1);
166
+ }
167
+
168
+ ._vxlwT {
169
+ position: absolute;
170
+ right: 30px;
171
+ top: 12px;
172
+ z-index: 3;
173
+ -webkit-user-select: none;
174
+ user-select: none;
175
+ }
176
+
177
+ ._xd3mP {
178
+ display: flex;
179
+ align-items: center;
180
+ }
181
+
182
+ ._IVeCE {
183
+ width: 30px;
184
+ height: 30px;
185
+ background-color: #fff;
186
+ box-shadow: 0 1px 5px 0 rgba(10, 30, 65, 0.08);
187
+ border-radius: 6px;
188
+ display: flex;
189
+ justify-content: center;
190
+ align-items: center;
191
+ cursor: pointer;
192
+ }
193
+ ._IVeCE svg {
194
+ width: 20px;
195
+ height: 20px;
196
+ fill: rgba(0, 0, 0, 0.85);
197
+ }
198
+
199
+ ._c9-Rl {
200
+ width: 50px;
201
+ color: rgba(0, 0, 0, 0.85);
202
+ font-size: 14px;
203
+ text-align: center;
204
+ }
205
+
206
+ ._QTtQr {
207
+ position: relative;
208
+ display: flex;
209
+ align-items: center;
210
+ }
211
+ ._QTtQr._B4OPa {
212
+ flex-direction: column;
213
+ }
214
+ ._QTtQr._B4OPa ._9Gq3x {
215
+ left: 50%;
216
+ top: -18px;
217
+ transform: translateX(-50%);
218
+ width: auto;
219
+ height: 36px;
220
+ padding-top: 0;
221
+ padding-bottom: 0;
222
+ line-height: 32px;
223
+ }
224
+ ._QTtQr._B4OPa ._MlJIV {
225
+ display: flex;
226
+ }
227
+ ._QTtQr._B4OPa ._4TP17 {
228
+ padding-right: 30px;
229
+ padding-bottom: 0;
230
+ }
231
+ ._QTtQr._B4OPa ._4TP17:first-of-type > ._Q-b5J {
232
+ left: 50%;
233
+ width: 50%;
234
+ height: 2px;
235
+ top: 0;
236
+ }
237
+ ._QTtQr._B4OPa ._4TP17:first-of-type > ._Q-b5J._n1DDB {
238
+ top: 100%;
239
+ }
240
+ ._QTtQr._B4OPa ._4TP17:last-of-type > ._Q-b5J {
241
+ left: 0;
242
+ width: 50%;
243
+ height: 2px;
244
+ top: 0;
245
+ }
246
+ ._QTtQr._B4OPa ._4TP17:last-of-type > ._Q-b5J._n1DDB {
247
+ top: 100%;
248
+ }
249
+ ._QTtQr._B4OPa ._Q-b5J {
250
+ height: 2px;
251
+ width: 100%;
252
+ top: 0;
253
+ left: 0;
254
+ }
255
+ ._QTtQr._B4OPa ._n1DDB {
256
+ left: 0;
257
+ top: 100%;
258
+ }
259
+ ._QTtQr._B4OPa ._l-p-G {
260
+ height: 30px;
261
+ width: 2px;
262
+ top: 0;
263
+ left: 50%;
264
+ transform: translateX(-50%);
265
+ }
266
+ ._QTtQr._B4OPa ._MnV8A {
267
+ flex-direction: column;
268
+ height: 100%;
269
+ }
270
+ ._QTtQr._B4OPa ._ERDNK {
271
+ width: 2px;
272
+ }
273
+
274
+ ._9Gq3x {
275
+ position: absolute;
276
+ left: -18px;
277
+ top: 50%;
278
+ transform: translateY(-50%);
279
+ z-index: 2;
280
+ width: 36px;
281
+ display: flex;
282
+ flex-wrap: wrap;
283
+ border: 2px solid #dedede;
284
+ background: #fff;
285
+ border-radius: 18px;
286
+ color: #222;
287
+ cursor: pointer;
288
+ font-size: 12px;
289
+ padding: 10px;
290
+ text-align: center;
291
+ }
292
+
293
+ ._4TP17 {
294
+ padding: 30px 0 30px 30px;
295
+ position: relative;
296
+ }
297
+ ._4TP17:first-of-type > ._Q-b5J {
298
+ top: 50%;
299
+ height: 50%;
300
+ }
301
+ ._4TP17:last-of-type > ._Q-b5J {
302
+ top: 0;
303
+ height: 50%;
304
+ }
305
+
306
+ ._Q-b5J {
307
+ position: absolute;
308
+ height: 100%;
309
+ width: 2px;
310
+ left: 0;
311
+ top: 0;
312
+ background-color: #dedede;
313
+ }
314
+ ._Q-b5J._n1DDB {
315
+ left: 100%;
316
+ }
317
+
318
+ ._l-p-G {
319
+ position: absolute;
320
+ width: 30px;
321
+ height: 2px;
322
+ left: 0;
323
+ top: 50%;
324
+ transform: translateY(-50%);
325
+ background-color: #dedede;
326
+ }
327
+
328
+ ._MnV8A {
329
+ display: flex;
330
+ align-items: center;
331
+ }
332
+
333
+ ._ERDNK {
334
+ height: 2px;
335
+ flex-grow: 1;
336
+ background-color: #dedede;
337
+ }
338
+
339
+ ._I73Kt {
340
+ position: absolute;
341
+ top: -28px;
342
+ right: 0;
343
+ z-index: 2;
344
+ background: var(--primary-color);
345
+ width: 24px;
346
+ height: 24px;
347
+ border-radius: 2px;
348
+ display: flex;
349
+ justify-content: center;
350
+ align-items: center;
351
+ cursor: pointer;
352
+ animation: _DGtHa 1s;
353
+ }
354
+ ._I73Kt::after {
355
+ content: "";
356
+ position: absolute;
357
+ width: 100%;
358
+ height: 4px;
359
+ left: 0;
360
+ bottom: -4px;
361
+ }
362
+ ._I73Kt svg {
363
+ fill: #fff;
364
+ width: 16px;
365
+ height: 16px;
366
+ }
367
+
368
+ ._WzQqY {
369
+ width: 90px;
370
+ height: 40px;
371
+ border-radius: 30px;
372
+ box-shadow: 0 1px 5px 0 rgba(10, 30, 65, 0.08);
373
+ color: #fff;
374
+ line-height: 40px;
375
+ text-align: center;
376
+ background: #6e6e6e;
377
+ }
378
+
379
+ ._HGnYM {
380
+ position: relative;
381
+ }
382
+
383
+ ._Uf6Nh {
384
+ width: 200px;
385
+ min-height: 70px;
386
+ padding: 5px 10px 8px;
387
+ border: 2px solid transparent;
388
+ border-radius: 8px;
389
+ box-shadow: 0 1px 4px 0 rgba(10, 30, 65, 0.16);
390
+ transition: all 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
391
+ background-color: #fff;
392
+ cursor: pointer;
393
+ }
394
+
395
+ ._-7Pvj {
396
+ position: relative;
397
+ display: flex;
398
+ align-items: center;
399
+ border-radius: 4px 4px 0 0;
400
+ cursor: pointer;
401
+ font-size: 14px;
402
+ text-align: left;
403
+ color: #1f1f1f;
404
+ font-weight: 600;
405
+ word-break: break-all;
406
+ min-height: 20px;
407
+ }
408
+
409
+ ._leHgE {
410
+ display: flex;
411
+ min-height: 32px;
412
+ align-items: center;
413
+ justify-content: space-between;
414
+ padding: 4px 8px;
415
+ margin-top: 10px;
416
+ background: rgba(0, 0, 0, 0.03);
417
+ border-radius: 4px;
418
+ }
419
+
420
+ ._Kqf3r {
421
+ color: #111f2c;
422
+ font-size: 14px;
423
+ line-height: 32px;
424
+ word-break: break-all;
425
+ }
426
+
427
+ ._-RR3K {
428
+ width: 20px;
429
+ }
430
+
431
+ ._0sM8G {
432
+ padding: 12px 8px;
433
+ background-color: #000;
434
+ border-radius: 4px;
435
+ }
436
+
437
+ ._wsgr5 {
438
+ width: 100%;
439
+ margin-bottom: 12px;
440
+ }
441
+ ._wsgr5:last-of-type {
442
+ margin-bottom: 0;
443
+ }
444
+
445
+ ._ka6d9 {
446
+ color: #888;
447
+ margin-bottom: 12px;
448
+ }
449
+
450
+ ._lmTJ8 {
451
+ width: 100%;
452
+ display: flex;
453
+ flex-wrap: wrap;
454
+ justify-content: space-between;
455
+ margin-bottom: -12px;
456
+ }
457
+
458
+ ._4q38j {
459
+ display: flex;
460
+ width: 136px;
461
+ padding: 4px 8px;
462
+ border: 1px solid #2e2e2e;
463
+ background: #000;
464
+ color: #fff;
465
+ font-size: 14px;
466
+ cursor: pointer;
467
+ margin-bottom: 12px;
468
+ }
469
+ ._4q38j:hover {
470
+ border-color: #595959;
471
+ background: #3b3b3b;
472
+ }
473
+
474
+ ._vS7Kd {
475
+ position: relative;
476
+ display: flex;
477
+ flex-shrink: 0;
478
+ align-items: center;
479
+ }
480
+ ._vS7Kd._B4OPa {
481
+ flex-direction: column;
482
+ }
483
+ ._vS7Kd._B4OPa ._FhjH6 {
484
+ flex-direction: column;
485
+ }
486
+
487
+ ._FhjH6 {
488
+ position: relative;
489
+ display: flex;
490
+ align-items: center;
491
+ }
492
+
493
+ ._EYYsJ {
494
+ position: relative;
495
+ }
496
+
497
+ ._pydi2 {
498
+ display: flex;
499
+ align-items: center;
500
+ }
501
+ ._pydi2._B4OPa {
502
+ flex-direction: column;
503
+ }
504
+
505
+ ._u41XY {
506
+ width: 90px;
507
+ height: 40px;
508
+ border-radius: 30px;
509
+ box-shadow: 0 1px 5px 0 rgba(10, 30, 65, 0.08);
510
+ color: #fff;
511
+ line-height: 40px;
512
+ text-align: center;
513
+ background: #2c2c2c;
514
+ }
515
+ /*# sourceMappingURL=index.css.map */