1- "use strict" ;
1+
22
33function _typeof ( obj ) { "@babel/helpers - typeof" ; if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return _typeof ( obj ) ; }
44
@@ -65,7 +65,8 @@ var propTypes = {
6565 multipleSelect : _propTypes . default . bool ,
6666 onClickNode : _propTypes . default . func ,
6767 onClickChart : _propTypes . default . func ,
68- onZoomChange : _propTypes . default . func
68+ onZoomChange : _propTypes . default . func ,
69+ onDropNode : _propTypes . default . func
6970} ;
7071var defaultProps = {
7172 pan : false ,
@@ -92,7 +93,8 @@ var ChartContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
9293 multipleSelect = _ref . multipleSelect ,
9394 onClickNode = _ref . onClickNode ,
9495 onClickChart = _ref . onClickChart ,
95- onZoomChange = _ref . onZoomChange ;
96+ onZoomChange = _ref . onZoomChange ,
97+ onDropNode = _ref . onDropNode ;
9698 var container = ( 0 , _react . useRef ) ( ) ;
9799 var chart = ( 0 , _react . useRef ) ( ) ;
98100 var downloadButton = ( 0 , _react . useRef ) ( ) ;
@@ -137,7 +139,13 @@ var ChartContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
137139 download = _useState16 [ 0 ] ,
138140 setDownload = _useState16 [ 1 ] ;
139141
140- var attachRel = function attachRel ( data , flags ) {
142+ var attachRel = ( 0 , _react . useCallback ) ( function ( data , flags ) {
143+ if ( ! ! data && data . length ) {
144+ data . forEach ( function ( item ) {
145+ attachRel ( item , flags === "00" ? flags : "1" + ( data . length > 1 ? 1 : 0 ) ) ;
146+ } ) ;
147+ }
148+
141149 data . relationship = flags + ( data . children && data . children . length > 0 ? 1 : 0 ) ;
142150
143151 if ( data . children ) {
@@ -147,7 +155,7 @@ var ChartContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
147155 }
148156
149157 return data ;
150- } ;
158+ } , [ ] ) ;
151159
152160 var _useState17 = ( 0 , _react . useState ) ( datasource ) ,
153161 _useState18 = _slicedToArray ( _useState17 , 2 ) ,
@@ -329,8 +337,9 @@ var ChartContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
329337
330338 case 4 :
331339 setDS ( _objectSpread ( { } , dsDigger . ds ) ) ;
340+ return _context . abrupt ( "return" , _objectSpread ( { } , dsDigger . ds ) ) ;
332341
333- case 5 :
342+ case 6 :
334343 case "end" :
335344 return _context . stop ( ) ;
336345 }
@@ -391,9 +400,18 @@ var ChartContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
391400 }
392401
393402 setTransform ( "matrix(" + newScale + ", 0, 0, " + newScale + ", 0, 0)" ) ;
403+ } ,
404+ getChart : function getChart ( ) {
405+ return ds . children ;
406+ } ,
407+ resetPosition : function resetPosition ( ) {
408+ setTransform ( "" ) ;
394409 }
395410 } ;
396411 } ) ;
412+ var dsWithAttachedRel = ( 0 , _react . useMemo ) ( function ( ) {
413+ return attachRel ( ds , "00" ) ;
414+ } , [ attachRel , ds ] ) ;
397415 return /*#__PURE__*/ _react . default . createElement ( "div" , {
398416 ref : container ,
399417 className : "orgchart-container " + containerClass ,
@@ -409,14 +427,26 @@ var ChartContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
409427 onClick : clickChartHandler ,
410428 onMouseDown : pan ? panStartHandler : undefined ,
411429 onMouseMove : pan && panning ? panHandler : undefined
412- } , /*#__PURE__*/ _react . default . createElement ( "ul" , null , /*#__PURE__*/ _react . default . createElement ( _ChartNode . default , {
413- datasource : attachRel ( ds , "00" ) ,
430+ } , /*#__PURE__*/ _react . default . createElement ( "ul" , null , ! ! dsWithAttachedRel && dsWithAttachedRel . length ? dsWithAttachedRel . map ( function ( _ds ) {
431+ return /*#__PURE__*/ _react . default . createElement ( _ChartNode . default , {
432+ datasource : _ds ,
433+ NodeTemplate : NodeTemplate ,
434+ draggable : draggable ,
435+ collapsible : collapsible ,
436+ multipleSelect : multipleSelect ,
437+ changeHierarchy : changeHierarchy ,
438+ onClickNode : onClickNode ,
439+ onDropNode : onDropNode
440+ } ) ;
441+ } ) : /*#__PURE__*/ _react . default . createElement ( _ChartNode . default , {
442+ datasource : dsWithAttachedRel ,
414443 NodeTemplate : NodeTemplate ,
415444 draggable : draggable ,
416445 collapsible : collapsible ,
417446 multipleSelect : multipleSelect ,
418447 changeHierarchy : changeHierarchy ,
419- onClickNode : onClickNode
448+ onClickNode : onClickNode ,
449+ onDropNode : onDropNode
420450 } ) ) ) , /*#__PURE__*/ _react . default . createElement ( "a" , {
421451 className : "oc-download-btn hidden" ,
422452 ref : downloadButton ,
0 commit comments