@kne/react-flow-chart 0.1.10 → 0.2.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.
@@ -1,9 +1,8 @@
1
1
  import React, { createContext, useContext as useContext$1, useState, useRef, useMemo, useEffect } from 'react';
2
2
  import useEvent from '@kne/use-event';
3
3
  import classnames from 'classnames';
4
- import { ReactComponent } from './add~nSLLXReQ.svg';
5
4
  import { useIntl, IntlProvider } from 'react-intl';
6
- import arrow from './arrow~bbpMpvlG.svg';
5
+ import { ReactComponent } from './add~nSLLXReQ.svg';
7
6
  import { ReactComponent as ReactComponent$1 } from './delete~RuDNzAkQ.svg';
8
7
  import { v4 } from 'uuid';
9
8
  import useControlValue from '@kne/use-control-value';
@@ -12,13 +11,13 @@ function _objectWithoutPropertiesLoose(r, e) {
12
11
  if (null == r) return {};
13
12
  var t = {};
14
13
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
15
- if (e.includes(n)) continue;
14
+ if (-1 !== e.indexOf(n)) continue;
16
15
  t[n] = r[n];
17
16
  }
18
17
  return t;
19
18
  }
20
19
 
21
- var style = {"container":"_AIhaC","show-scrollbar":"_qp1e9","content":"_XZmmG","is-scale":"_q6z6A","vertical":"_B4OPa","arrow-line":"_W5dM8","show-arrow":"_0Cmjn","add-node":"_sVaw9","add-node-btn":"_Y4-Yv","dot":"_06DKa","normal":"_59XmF","node-type-popover":"_6Grsl","show":"_DGtHa","action-bar":"_vxlwT","action-scale":"_xd3mP","action-scale-btn":"_IVeCE","action-scale-num":"_c9-Rl","condition-node-container":"_QTtQr","condition-add-btn":"_9Gq3x","condition-node-item-list":"_MlJIV","condition-node-item":"_4TP17","condition-node-item-line":"_Q-b5J","condition-node-item-last-line":"_n1DDB","condition-node-item-link-line":"_l-p-G","condition-node-item-node-wrap":"_MnV8A","condition-node-item-link-cross-line":"_ERDNK","delete-node":"_I73Kt","end-node-container":"_WzQqY","node-container":"_HGnYM","normal-node-content":"_Uf6Nh","normal-node-title":"_-7Pvj","normal-node-data":"_leHgE","normal-node-data-text":"_Kqf3r","normal-node-data-icon":"_-RR3K","node-type-content":"_0sM8G","node-type-group":"_wsgr5","node-type-group-name":"_ka6d9","node-type-list":"_lmTJ8","node-type-item":"_4q38j","normal-node-container":"_vS7Kd","normal-node-wrap":"_FhjH6","normal-node-content-wrap":"_EYYsJ","start-node-container":"_pydi2","start-node-content":"_u41XY","condition-content-title":"_MgJlN","condition-content-title-add-btn":"_X7-fq"};
20
+ var style = {"wrapper":"kne-react-flow-chart_Gah47","container":"kne-react-flow-chart_AIhaC","show-scrollbar":"kne-react-flow-chart_qp1e9","content":"kne-react-flow-chart_XZmmG","is-scale":"kne-react-flow-chart_q6z6A","vertical":"kne-react-flow-chart_B4OPa","arrow-line":"kne-react-flow-chart_W5dM8","show-arrow":"kne-react-flow-chart_0Cmjn","add-node":"kne-react-flow-chart_sVaw9","add-node-btn":"kne-react-flow-chart_Y4-Yv","dot":"kne-react-flow-chart_06DKa","normal":"kne-react-flow-chart_59XmF","node-type-popover":"kne-react-flow-chart_6Grsl","show":"kne-react-flow-chart_DGtHa","action-bar":"kne-react-flow-chart_vxlwT","action-scale":"kne-react-flow-chart_xd3mP","action-scale-btn":"kne-react-flow-chart_IVeCE","is-disabled":"kne-react-flow-chart_-cv3B","action-scale-reset":"kne-react-flow-chart_9Mw3U","action-scale-divider":"kne-react-flow-chart_Nu4nf","action-scale-num":"kne-react-flow-chart_c9-Rl","condition-node-container":"kne-react-flow-chart_QTtQr","condition-add-btn":"kne-react-flow-chart_9Gq3x","condition-node-item-list":"kne-react-flow-chart_MlJIV","condition-node-item":"kne-react-flow-chart_4TP17","condition-node-item-line":"kne-react-flow-chart_Q-b5J","condition-node-item-last-line":"kne-react-flow-chart_n1DDB","condition-node-item-link-line":"kne-react-flow-chart_l-p-G","condition-node-item-node-wrap":"kne-react-flow-chart_MnV8A","condition-node-item-link-cross-line":"kne-react-flow-chart_ERDNK","delete-node":"kne-react-flow-chart_I73Kt","end-node-container":"kne-react-flow-chart_WzQqY","node-container":"kne-react-flow-chart_HGnYM","normal-node-content":"kne-react-flow-chart_Uf6Nh","normal-node-title":"kne-react-flow-chart_-7Pvj","normal-node-data":"kne-react-flow-chart_leHgE","normal-node-data-text":"kne-react-flow-chart_Kqf3r","normal-node-data-icon":"kne-react-flow-chart_-RR3K","node-type-content":"kne-react-flow-chart_0sM8G","node-type-group":"kne-react-flow-chart_wsgr5","node-type-group-name":"kne-react-flow-chart_ka6d9","node-type-list":"kne-react-flow-chart_lmTJ8","node-type-item":"kne-react-flow-chart_4q38j","node-type-item-icon":"kne-react-flow-chart_LlqNc","node-type-item-text":"kne-react-flow-chart_FP-Sn","node-type-item-name":"kne-react-flow-chart_BuYmx","node-type-item-desc":"kne-react-flow-chart_yhXFF","normal-node-container":"kne-react-flow-chart_vS7Kd","normal-node-wrap":"kne-react-flow-chart_FhjH6","normal-node-content-wrap":"kne-react-flow-chart_EYYsJ","start-node-container":"kne-react-flow-chart_pydi2","start-node-content":"kne-react-flow-chart_u41XY","condition-content-title":"kne-react-flow-chart_MgJlN","condition-content-title-add-btn":"kne-react-flow-chart_X7-fq"};
22
21
 
23
22
  const getDefaultNodeList = ({
24
23
  formatMessage
@@ -57,6 +56,11 @@ const getDefaultNodeTypeList = ({
57
56
  name: formatMessage({
58
57
  id: 'conditionBranch'
59
58
  })
59
+ }, {
60
+ type: 'parallel',
61
+ name: formatMessage({
62
+ id: 'parallelBranch'
63
+ })
60
64
  }]
61
65
  }];
62
66
  };
@@ -70,19 +74,31 @@ const useContext = () => {
70
74
  return useContext$1(context);
71
75
  };
72
76
 
77
+ const MIN_SCALE = 10;
78
+ const MAX_SCALE = 300;
73
79
  const ActionBar = props => {
74
80
  const {
75
81
  scale,
76
82
  onChange
77
83
  } = Object.assign({}, {}, props);
84
+ const {
85
+ formatMessage
86
+ } = useIntl();
87
+ const change = next => onChange(Math.min(MAX_SCALE, Math.max(MIN_SCALE, next)));
78
88
  return /*#__PURE__*/React.createElement("div", {
79
- className: style['action-bar']
89
+ className: classnames('flow-chart-action-bar', style['action-bar']),
90
+ onMouseDown: e => e.stopPropagation()
80
91
  }, /*#__PURE__*/React.createElement("div", {
81
92
  className: style['action-scale']
82
93
  }, /*#__PURE__*/React.createElement("div", {
83
- className: style['action-scale-btn'],
94
+ className: classnames(style['action-scale-btn'], {
95
+ [style['is-disabled']]: scale >= MAX_SCALE
96
+ }),
97
+ title: formatMessage({
98
+ id: 'zoomIn'
99
+ }),
84
100
  onClick: () => {
85
- onChange(scale + 10);
101
+ change(scale + 10);
86
102
  }
87
103
  }, /*#__PURE__*/React.createElement("svg", {
88
104
  viewBox: "0 0 1024 1024",
@@ -93,9 +109,14 @@ const ActionBar = props => {
93
109
  }))), /*#__PURE__*/React.createElement("div", {
94
110
  className: style['action-scale-num']
95
111
  }, scale.toFixed(0), "%"), /*#__PURE__*/React.createElement("div", {
96
- className: style['action-scale-btn'],
112
+ className: classnames(style['action-scale-btn'], {
113
+ [style['is-disabled']]: scale <= MIN_SCALE
114
+ }),
115
+ title: formatMessage({
116
+ id: 'zoomOut'
117
+ }),
97
118
  onClick: () => {
98
- onChange(scale - 10);
119
+ change(scale - 10);
99
120
  }
100
121
  }, /*#__PURE__*/React.createElement("svg", {
101
122
  viewBox: "0 0 1024 1024",
@@ -103,7 +124,19 @@ const ActionBar = props => {
103
124
  xmlns: "http://www.w3.org/2000/svg"
104
125
  }, /*#__PURE__*/React.createElement("path", {
105
126
  d: "M587.229378 437.990403 580.722174 437.990403 76.975139 437.990403 76.975139 581.918419 580.722174 581.918419 587.229378 581.918419 940.542216 581.918419 940.542216 437.990403Z"
106
- })))));
127
+ }))), /*#__PURE__*/React.createElement("div", {
128
+ className: style['action-scale-divider']
129
+ }), /*#__PURE__*/React.createElement("div", {
130
+ className: classnames(style['action-scale-reset'], {
131
+ [style['is-disabled']]: scale === 100
132
+ }),
133
+ title: formatMessage({
134
+ id: 'resetScale'
135
+ }),
136
+ onClick: () => {
137
+ onChange(100);
138
+ }
139
+ }, "1:1")));
107
140
  };
108
141
 
109
142
  const ArrowLine = props => {
@@ -141,18 +174,26 @@ const NodeTypeContent = props => {
141
174
  return /*#__PURE__*/React.createElement("div", {
142
175
  className: style['node-type-group'],
143
176
  key: groupIndex
144
- }, /*#__PURE__*/React.createElement("div", {
177
+ }, group.name && /*#__PURE__*/React.createElement("div", {
145
178
  className: style['node-type-group-name']
146
179
  }, group.name), /*#__PURE__*/React.createElement("div", {
147
180
  className: style['node-type-list']
148
181
  }, group.list.map((nodeType, typeIndex) => {
149
182
  return /*#__PURE__*/React.createElement("div", {
150
- className: style['node-type-item'],
183
+ className: classnames(style['node-type-item'], nodeType.className),
151
184
  key: typeIndex,
152
185
  onClick: e => {
153
186
  onClick && onClick(nodeType);
154
187
  }
155
- }, nodeType.name);
188
+ }, nodeType.icon && /*#__PURE__*/React.createElement("span", {
189
+ className: classnames(style['node-type-item-icon'], 'flow-chart-node-type-icon')
190
+ }, nodeType.icon), /*#__PURE__*/React.createElement("span", {
191
+ className: style['node-type-item-text']
192
+ }, /*#__PURE__*/React.createElement("span", {
193
+ className: style['node-type-item-name']
194
+ }, nodeType.name), nodeType.description && /*#__PURE__*/React.createElement("span", {
195
+ className: style['node-type-item-desc']
196
+ }, nodeType.description)));
156
197
  })));
157
198
  }));
158
199
  };
@@ -283,10 +324,24 @@ const NodeContent = props => {
283
324
  nodeData
284
325
  } = Object.assign({}, {}, props);
285
326
  const {
286
- emitter
327
+ emitter,
328
+ renderNodeContent,
329
+ renderNodeTitle,
330
+ getNodeClassName
287
331
  } = useContext();
332
+ const defaultTitle = (typeof nodeData.titleRender === 'function' ? nodeData.titleRender(nodeData) : nodeData.title) || '';
333
+ const title = typeof renderNodeTitle === 'function' ? renderNodeTitle({
334
+ nodeData,
335
+ title: defaultTitle
336
+ }) : defaultTitle;
337
+ const content = typeof renderNodeContent === 'function' ? renderNodeContent({
338
+ nodeData,
339
+ content: nodeData.content
340
+ }) : nodeData.content;
288
341
  return /*#__PURE__*/React.createElement("div", {
289
- className: style['normal-node-content'],
342
+ className: classnames(style['normal-node-content'], 'flow-chart-node-content', typeof getNodeClassName === 'function' && getNodeClassName({
343
+ nodeData
344
+ })),
290
345
  onClick: () => {
291
346
  emitter.emit('node-content-click', {
292
347
  nodeData
@@ -294,15 +349,18 @@ const NodeContent = props => {
294
349
  }
295
350
  }, /*#__PURE__*/React.createElement("div", {
296
351
  className: style['normal-node-title']
297
- }, (typeof nodeData.titleRender === 'function' ? nodeData.titleRender(nodeData) : nodeData.title) || ''), /*#__PURE__*/React.createElement("div", {
298
- className: style['normal-node-data']
352
+ }, title), /*#__PURE__*/React.createElement("div", {
353
+ className: classnames(style['normal-node-data'], 'flow-chart-node-data')
299
354
  }, /*#__PURE__*/React.createElement("div", {
300
355
  className: style['normal-node-data-text']
301
- }, nodeData.content || ''), /*#__PURE__*/React.createElement("img", {
302
- src: arrow,
303
- alt: "\u7BAD\u5934",
304
- className: style['normal-node-data-icon']
305
- })));
356
+ }, content || ''), /*#__PURE__*/React.createElement("svg", {
357
+ className: classnames(style['normal-node-data-icon'], 'flow-chart-node-data-icon'),
358
+ viewBox: "64 64 896 896",
359
+ fill: "currentColor",
360
+ "aria-hidden": "true"
361
+ }, /*#__PURE__*/React.createElement("path", {
362
+ d: "M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
363
+ }))));
306
364
  };
307
365
 
308
366
  const ConditionNode = props => {
@@ -322,8 +380,11 @@ const ConditionNode = props => {
322
380
  readonly,
323
381
  emitter
324
382
  } = useContext();
383
+ const addBranchText = formatMessage({
384
+ id: nodeData.type === 'parallel' ? 'addBranch' : 'addConditions'
385
+ });
325
386
  return /*#__PURE__*/React.createElement("div", {
326
- className: classnames(style['condition-node-container'], {
387
+ className: classnames(style['condition-node-container'], `flow-chart-${nodeData.type}-node`, {
327
388
  [style['vertical']]: vertical
328
389
  })
329
390
  }, !readonly && !nodeData.content && /*#__PURE__*/React.createElement("div", {
@@ -333,9 +394,7 @@ const ConditionNode = props => {
333
394
  nodeData
334
395
  });
335
396
  }
336
- }, formatMessage({
337
- id: 'addConditions'
338
- })), nodeData.content && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(NodeContent, {
397
+ }, addBranchText), nodeData.content && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(NodeContent, {
339
398
  nodeData: Object.assign({}, nodeData, {
340
399
  titleRender: nodeData => /*#__PURE__*/React.createElement("div", {
341
400
  className: style['condition-content-title']
@@ -347,9 +406,7 @@ const ConditionNode = props => {
347
406
  nodeData
348
407
  });
349
408
  }
350
- }, formatMessage({
351
- id: 'addConditions'
352
- }))))
409
+ }, addBranchText)))
353
410
  })
354
411
  }), /*#__PURE__*/React.createElement(ArrowLine, null)), /*#__PURE__*/React.createElement("div", {
355
412
  className: style['condition-node-item-list']
@@ -463,7 +520,7 @@ const Node = props => {
463
520
  nodeData: nodeData
464
521
  });
465
522
  }
466
- if (nodeData.type === 'condition') {
523
+ if (nodeData.type === 'condition' || nodeData.type === 'parallel') {
467
524
  return /*#__PURE__*/React.createElement(ConditionNode, {
468
525
  nodeData: nodeData,
469
526
  isMouseEnter: isMouseEnter || isCurrentMouseEnter
@@ -476,7 +533,7 @@ const Node = props => {
476
533
  });
477
534
  };
478
535
  return /*#__PURE__*/React.createElement("div", {
479
- className: style['node-container'],
536
+ className: classnames(style['node-container'], `flow-chart-node-${nodeData.type}`),
480
537
  onMouseEnter: () => {
481
538
  setIsCurrentMouseEnter(true);
482
539
  },
@@ -488,6 +545,27 @@ const Node = props => {
488
545
  }));
489
546
  };
490
547
 
548
+ const BRANCH_CONTAINER_TYPES = ['condition', 'parallel'];
549
+ const isBranchContainer = type => BRANCH_CONTAINER_TYPES.indexOf(type) > -1;
550
+ const findNode = (tree, {
551
+ currentNodeId
552
+ }) => {
553
+ const core = tree => {
554
+ if (Array.isArray(tree)) {
555
+ for (let node of tree) {
556
+ const res = core(node);
557
+ if (res) {
558
+ return res;
559
+ }
560
+ }
561
+ }
562
+ if (tree.id === currentNodeId) {
563
+ return tree;
564
+ }
565
+ return tree.children ? core(tree.children) : null;
566
+ };
567
+ return core(tree);
568
+ };
491
569
  const appendNode = (tree, {
492
570
  currentNodeId,
493
571
  node,
@@ -498,7 +576,7 @@ const appendNode = (tree, {
498
576
  const currentIndex = tree.findIndex(node => node.id === currentNodeId);
499
577
  if (currentIndex > -1) {
500
578
  const newTree = tree.slice(0);
501
- if (newTree[currentIndex].type === 'condition' && type === 'condition') {
579
+ if (isBranchContainer(newTree[currentIndex].type) && (type === 'branch' || type === newTree[currentIndex].type)) {
502
580
  const newNode = Object.assign({}, newTree[currentIndex]);
503
581
  const newChildren = (newNode.children || []).slice(0);
504
582
  newChildren.push([node]);
@@ -533,7 +611,7 @@ const removeNode = (tree, {
533
611
  return newTree;
534
612
  } else {
535
613
  return tree.map(node => core(node)).filter(node => {
536
- return !(node.type === 'condition' && node.children.length < 2);
614
+ return !(isBranchContainer(node.type) && node.children.length < 2);
537
615
  });
538
616
  }
539
617
  }
@@ -557,12 +635,19 @@ const replaceNode = (tree, {
557
635
  type: tree.type
558
636
  });
559
637
  }
560
- return tree.children ? Object.assign(tree, {
638
+ return tree.children ? Object.assign({}, tree, {
561
639
  children: core(tree.children)
562
640
  }) : tree;
563
641
  };
564
642
  return core(tree);
565
643
  };
644
+ const treeUtil = {
645
+ findNode,
646
+ appendNode,
647
+ removeNode,
648
+ replaceNode,
649
+ isBranchContainer
650
+ };
566
651
 
567
652
  const message = {};
568
653
  const loader = (locale, localeMessage) => {
@@ -579,11 +664,18 @@ const locale = {
579
664
  condition: '条件',
580
665
  conditionContent: '条件内容',
581
666
  nodeContent: '节点内容',
582
- addConditions: '添加条件'
667
+ addConditions: '添加条件',
668
+ parallelBranch: '并行分支',
669
+ branch: '分支',
670
+ branchContent: '分支内容',
671
+ addBranch: '添加分支',
672
+ zoomIn: '放大',
673
+ zoomOut: '缩小',
674
+ resetScale: '还原到 100%'
583
675
  };
584
676
 
585
677
  const _excluded = ["className"],
586
- _excluded2 = ["readonly", "showScrollBar", "enableDrag", "initFit", "vertical", "onEditNode", "nodeTemplate"],
678
+ _excluded2 = ["readonly", "showScrollBar", "enableDrag", "initFit", "vertical", "onEditNode", "nodeTemplate", "nodeTypeList", "renderNodeContent", "renderNodeTitle", "getNodeClassName"],
587
679
  _excluded3 = ["locale"];
588
680
  loader('zh-cn', locale);
589
681
  const FlowChart = _ref => {
@@ -605,7 +697,11 @@ const FlowChart = _ref => {
605
697
  initFit,
606
698
  vertical,
607
699
  onEditNode,
608
- nodeTemplate
700
+ nodeTemplate,
701
+ nodeTypeList,
702
+ renderNodeContent,
703
+ renderNodeTitle,
704
+ getNodeClassName
609
705
  } = _Object$assign,
610
706
  otherProps = _objectWithoutPropertiesLoose(_Object$assign, _excluded2);
611
707
  const {
@@ -651,62 +747,70 @@ const FlowChart = _ref => {
651
747
  }
652
748
  }, [initFit]);
653
749
  useEffect(() => {
750
+ const getTemplate = (type, parentType) => {
751
+ var _nodeTemplateRef$curr;
752
+ const template = (_nodeTemplateRef$curr = nodeTemplateRef.current) == null ? void 0 : _nodeTemplateRef$curr[type];
753
+ return typeof template === 'function' ? template({
754
+ type,
755
+ parentType
756
+ }) : template;
757
+ };
758
+ const createBranch = parentType => {
759
+ const defaultBranch = parentType === 'parallel' ? {
760
+ title: formatMessage({
761
+ id: 'branch'
762
+ }),
763
+ content: formatMessage({
764
+ id: 'branchContent'
765
+ })
766
+ } : {
767
+ title: formatMessage({
768
+ id: 'condition'
769
+ }),
770
+ content: formatMessage({
771
+ id: 'conditionContent'
772
+ })
773
+ };
774
+ return Object.assign({}, defaultBranch, getTemplate('branch', parentType), {
775
+ id: v4(),
776
+ type: 'branch'
777
+ });
778
+ };
779
+ const defaultTitles = {
780
+ condition: {
781
+ title: formatMessage({
782
+ id: 'conditionBranch'
783
+ })
784
+ },
785
+ parallel: {
786
+ title: formatMessage({
787
+ id: 'parallelBranch'
788
+ })
789
+ },
790
+ normal: {
791
+ title: formatMessage({
792
+ id: 'normalNode'
793
+ }),
794
+ content: formatMessage({
795
+ id: 'nodeContent'
796
+ })
797
+ }
798
+ };
654
799
  emitter.addListener('add-node-type-click', ({
655
800
  type,
656
801
  nodeData
657
802
  }) => {
658
- if (type === 'condition') {
659
- var _nodeTemplateRef$curr, _nodeTemplateRef$curr2, _nodeTemplateRef$curr3;
660
- return setNodeList(appendNode(nodeListRef.current, {
661
- currentNodeId: nodeData.id,
662
- node: Object.assign({}, {
663
- title: formatMessage({
664
- id: 'conditionBranch'
665
- })
666
- }, (_nodeTemplateRef$curr = nodeTemplateRef.current) == null ? void 0 : _nodeTemplateRef$curr['condition'], {
667
- id: v4(),
668
- type: 'condition',
669
- children: [[Object.assign({}, {
670
- title: formatMessage({
671
- id: 'condition'
672
- }),
673
- content: formatMessage({
674
- id: 'conditionContent'
675
- })
676
- }, (_nodeTemplateRef$curr2 = nodeTemplateRef.current) == null ? void 0 : _nodeTemplateRef$curr2['branch'], {
677
- id: v4(),
678
- type: 'branch'
679
- })], [Object.assign({}, {
680
- title: formatMessage({
681
- id: 'condition'
682
- }),
683
- content: formatMessage({
684
- id: 'conditionContent'
685
- })
686
- }, (_nodeTemplateRef$curr3 = nodeTemplateRef.current) == null ? void 0 : _nodeTemplateRef$curr3['branch'], {
687
- id: v4(),
688
- type: 'branch'
689
- })]]
690
- })
691
- }));
692
- }
693
- if (type === 'normal') {
694
- var _nodeTemplateRef$curr4;
695
- return setNodeList(appendNode(nodeListRef.current, {
696
- currentNodeId: nodeData.id,
697
- node: Object.assign({}, {
698
- title: formatMessage({
699
- id: 'normalNode'
700
- }),
701
- content: formatMessage({
702
- id: 'nodeContent'
703
- })
704
- }, (_nodeTemplateRef$curr4 = nodeTemplateRef.current) == null ? void 0 : _nodeTemplateRef$curr4['normal'], {
705
- id: v4(),
706
- type: 'normal'
707
- })
708
- }));
803
+ const node = Object.assign({}, defaultTitles[type], getTemplate(type), {
804
+ id: v4(),
805
+ type
806
+ });
807
+ if (isBranchContainer(type)) {
808
+ node.children = [[createBranch(type)], [createBranch(type)]];
709
809
  }
810
+ setNodeList(appendNode(nodeListRef.current, {
811
+ currentNodeId: nodeData.id,
812
+ node
813
+ }));
710
814
  });
711
815
  emitter.addListener('delete-node-click', ({
712
816
  nodeData
@@ -718,21 +822,10 @@ const FlowChart = _ref => {
718
822
  emitter.addListener('add-condition-branch-click', ({
719
823
  nodeData
720
824
  }) => {
721
- var _nodeTemplateRef$curr5;
722
825
  setNodeList(appendNode(nodeListRef.current, {
723
826
  currentNodeId: nodeData.id,
724
- type: 'condition',
725
- node: Object.assign({}, {
726
- title: formatMessage({
727
- id: 'condition'
728
- }),
729
- content: formatMessage({
730
- id: 'conditionContent'
731
- })
732
- }, (_nodeTemplateRef$curr5 = nodeTemplateRef.current) == null ? void 0 : _nodeTemplateRef$curr5['branch'], {
733
- id: v4(),
734
- type: 'branch'
735
- })
827
+ type: 'branch',
828
+ node: createBranch(nodeData.type)
736
829
  }));
737
830
  });
738
831
  emitter.addListener('node-content-click', ({
@@ -770,9 +863,18 @@ const FlowChart = _ref => {
770
863
  readonly,
771
864
  vertical,
772
865
  nodeList,
866
+ nodeTypeList,
867
+ renderNodeContent,
868
+ renderNodeTitle,
869
+ getNodeClassName,
773
870
  emitter
774
871
  }
775
872
  }, /*#__PURE__*/React.createElement("div", {
873
+ className: classnames('flow-chart-wrapper', style['wrapper'])
874
+ }, /*#__PURE__*/React.createElement(ActionBar, {
875
+ scale: scale,
876
+ onChange: setScale
877
+ }), /*#__PURE__*/React.createElement("div", {
776
878
  ref: containerRef,
777
879
  className: classnames(className, 'flow-chart-container', style['container'], {
778
880
  [style['show-scrollbar']]: showScrollBar
@@ -784,10 +886,7 @@ const FlowChart = _ref => {
784
886
  mousePosition.current.scrollLeft = containerRef.current.scrollLeft;
785
887
  mousePosition.current.scrollTop = containerRef.current.scrollTop;
786
888
  }
787
- }, /*#__PURE__*/React.createElement(ActionBar, {
788
- scale: scale,
789
- onChange: setScale
790
- }), /*#__PURE__*/React.createElement("div", {
889
+ }, /*#__PURE__*/React.createElement("div", {
791
890
  ref: contentRef,
792
891
  className: classnames('flow-chart-content', style['content'], {
793
892
  [style['vertical']]: vertical,
@@ -802,7 +901,7 @@ const FlowChart = _ref => {
802
901
  nodeList: nodeList,
803
902
  nodeData: node
804
903
  });
805
- }))));
904
+ })))));
806
905
  };
807
906
  const FlowChartIntl = _ref2 => {
808
907
  let {
@@ -815,5 +914,5 @@ const FlowChartIntl = _ref2 => {
815
914
  }, /*#__PURE__*/React.createElement(FlowChart, props));
816
915
  };
817
916
 
818
- export { FlowChartIntl as default, loader as localeLoader };
917
+ export { FlowChartIntl as default, loader as localeLoader, treeUtil };
819
918
  //# sourceMappingURL=index.modern.js.map