@antv/g6 5.0.0-beta.0 → 5.0.0-beta.10
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/dist/g6.min.js +2 -2
- package/esm/api-doc/item.d.ts +2 -0
- package/esm/api-doc/item.js +2 -0
- package/esm/api-doc/item.js.map +1 -1
- package/esm/constant/shape.d.ts +4 -1
- package/esm/constant/shape.js.map +1 -1
- package/esm/index.d.ts +22 -7
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/esm/item/combo.d.ts +1 -1
- package/esm/item/combo.js +16 -9
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +20 -3
- package/esm/item/edge.js +99 -43
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +3 -2
- package/esm/item/item.js +21 -11
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +2 -1
- package/esm/item/node.js +33 -16
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +7 -10
- package/esm/runtime/controller/data.js +127 -283
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +1 -0
- package/esm/runtime/controller/item.js +267 -151
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/plugin.js +3 -3
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/graph.d.ts +103 -23
- package/esm/runtime/graph.js +460 -88
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/activate-relations.d.ts +9 -9
- package/esm/stdlib/behavior/activate-relations.js +8 -8
- package/esm/stdlib/behavior/activate-relations.js.map +1 -1
- package/esm/stdlib/behavior/brush-select.js +1 -2
- package/esm/stdlib/behavior/brush-select.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +1 -1
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/create-edge.d.ts +57 -0
- package/esm/stdlib/behavior/create-edge.js +207 -0
- package/esm/stdlib/behavior/create-edge.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/esm/stdlib/behavior/drag-canvas.js +57 -26
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
- package/esm/stdlib/behavior/drag-combo.js +43 -32
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +3 -3
- package/esm/stdlib/behavior/drag-node.js +76 -63
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/index.d.ts +3 -0
- package/esm/stdlib/behavior/index.js +3 -0
- package/esm/stdlib/behavior/index.js.map +1 -1
- package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
- package/esm/stdlib/behavior/lasso-select.js +1 -2
- package/esm/stdlib/behavior/lasso-select.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/esm/stdlib/behavior/scroll-canvas.js +266 -0
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
- package/esm/stdlib/behavior/shortcuts-call.js +80 -0
- package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas.d.ts +2 -1
- package/esm/stdlib/behavior/zoom-canvas.js +55 -24
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.d.ts +2 -2
- package/esm/stdlib/data/mapNodeSize.js +2 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/transformV4Data.d.ts +2 -2
- package/esm/stdlib/data/transformV4Data.js +2 -2
- package/esm/stdlib/data/transformV4Data.js.map +1 -1
- package/esm/stdlib/data/validateData.d.ts +2 -2
- package/esm/stdlib/data/validateData.js +16 -11
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +16 -6
- package/esm/stdlib/index.js +20 -10
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +96 -6
- package/esm/stdlib/item/edge/base.js +92 -19
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/line.js +5 -2
- package/esm/stdlib/item/edge/line.js.map +1 -1
- package/esm/stdlib/item/edge/polyline.d.ts +3 -2
- package/esm/stdlib/item/edge/polyline.js +3 -3
- package/esm/stdlib/item/edge/polyline.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +90 -16
- package/esm/stdlib/item/node/base.js +91 -41
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/base3d.d.ts +24 -0
- package/esm/stdlib/item/node/base3d.js +24 -8
- package/esm/stdlib/item/node/base3d.js.map +1 -1
- package/esm/stdlib/item/node/diamond.js +1 -1
- package/esm/stdlib/item/node/ellipse.js +2 -2
- package/esm/stdlib/item/node/hexagon.js +12 -5
- package/esm/stdlib/item/node/hexagon.js.map +1 -1
- package/esm/stdlib/item/node/image.d.ts +40 -0
- package/esm/stdlib/item/node/image.js +110 -0
- package/esm/stdlib/item/node/image.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +1 -0
- package/esm/stdlib/item/node/index.js +1 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/plugin/history/combo-command.js +2 -2
- package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
- package/esm/stdlib/plugin/history/index.d.ts +10 -10
- package/esm/stdlib/plugin/history/index.js +14 -14
- package/esm/stdlib/plugin/history/index.js.map +1 -1
- package/esm/stdlib/plugin/history/item-data-command.js +25 -16
- package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/index.d.ts +2 -0
- package/esm/stdlib/plugin/index.js +2 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/legend/index.js +5 -3
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/plugin/map/index.d.ts +118 -0
- package/esm/stdlib/plugin/map/index.js +683 -0
- package/esm/stdlib/plugin/map/index.js.map +1 -0
- package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
- package/esm/stdlib/plugin/minimap/index.js +116 -9
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
- package/esm/stdlib/plugin/snapline/index.js +1063 -0
- package/esm/stdlib/plugin/snapline/index.js.map +1 -0
- package/esm/stdlib/plugin/timebar/index.d.ts +98 -0
- package/esm/stdlib/plugin/timebar/index.js +303 -0
- package/esm/stdlib/plugin/timebar/index.js.map +1 -0
- package/esm/stdlib/plugin/toolbar/index.js +1 -1
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/plugin/types.d.ts +2 -0
- package/esm/stdlib/theme/dark.js +42 -2
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +4 -4
- package/esm/types/common.d.ts +1 -0
- package/esm/types/event.d.ts +1 -0
- package/esm/types/graph.d.ts +48 -22
- package/esm/types/hook.d.ts +22 -2
- package/esm/types/item.d.ts +6 -0
- package/esm/types/item.js.map +1 -1
- package/esm/types/spec.d.ts +20 -4
- package/esm/types/view.d.ts +5 -0
- package/esm/util/bbox.d.ts +16 -1
- package/esm/util/bbox.js +29 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/canvas.d.ts +2 -2
- package/esm/util/canvas.js +5 -11
- package/esm/util/canvas.js.map +1 -1
- package/esm/util/event.d.ts +3 -1
- package/esm/util/event.js +8 -1
- package/esm/util/event.js.map +1 -1
- package/esm/util/item.d.ts +16 -1
- package/esm/util/item.js +31 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/layout.d.ts +11 -0
- package/esm/util/layout.js +45 -0
- package/esm/util/layout.js.map +1 -1
- package/esm/util/point.js +9 -2
- package/esm/util/point.js.map +1 -1
- package/esm/util/router.d.ts +4 -3
- package/esm/util/router.js +8 -5
- package/esm/util/router.js.map +1 -1
- package/esm/util/shape.d.ts +3 -3
- package/esm/util/shape.js +8 -12
- package/esm/util/shape.js.map +1 -1
- package/esm/util/warn.d.ts +14 -0
- package/esm/util/warn.js +4 -0
- package/esm/util/warn.js.map +1 -0
- package/lib/api-doc/item.d.ts +2 -0
- package/lib/api-doc/item.js +5 -1
- package/lib/api-doc/item.js.map +1 -1
- package/lib/constant/shape.d.ts +4 -1
- package/lib/constant/shape.js.map +1 -1
- package/lib/index.d.ts +22 -7
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/item/combo.d.ts +1 -1
- package/lib/item/combo.js +16 -9
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +20 -3
- package/lib/item/edge.js +98 -42
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +3 -2
- package/lib/item/item.js +21 -11
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +2 -1
- package/lib/item/node.js +33 -16
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +7 -10
- package/lib/runtime/controller/data.js +127 -283
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +1 -0
- package/lib/runtime/controller/item.js +266 -150
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/plugin.js +3 -3
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/graph.d.ts +103 -23
- package/lib/runtime/graph.js +460 -88
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/activate-relations.d.ts +9 -9
- package/lib/stdlib/behavior/activate-relations.js +8 -8
- package/lib/stdlib/behavior/activate-relations.js.map +1 -1
- package/lib/stdlib/behavior/brush-select.js +1 -2
- package/lib/stdlib/behavior/brush-select.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +1 -1
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/create-edge.d.ts +57 -0
- package/lib/stdlib/behavior/create-edge.js +211 -0
- package/lib/stdlib/behavior/create-edge.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/lib/stdlib/behavior/drag-canvas.js +57 -26
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
- package/lib/stdlib/behavior/drag-combo.js +43 -32
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +3 -3
- package/lib/stdlib/behavior/drag-node.js +76 -63
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/index.d.ts +3 -0
- package/lib/stdlib/behavior/index.js +3 -0
- package/lib/stdlib/behavior/index.js.map +1 -1
- package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
- package/lib/stdlib/behavior/lasso-select.js +1 -2
- package/lib/stdlib/behavior/lasso-select.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/lib/stdlib/behavior/scroll-canvas.js +270 -0
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
- package/lib/stdlib/behavior/shortcuts-call.js +84 -0
- package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas.d.ts +2 -1
- package/lib/stdlib/behavior/zoom-canvas.js +55 -24
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.d.ts +2 -2
- package/lib/stdlib/data/mapNodeSize.js +2 -2
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/transformV4Data.d.ts +2 -2
- package/lib/stdlib/data/transformV4Data.js +2 -2
- package/lib/stdlib/data/transformV4Data.js.map +1 -1
- package/lib/stdlib/data/validateData.d.ts +2 -2
- package/lib/stdlib/data/validateData.js +16 -11
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +16 -6
- package/lib/stdlib/index.js +20 -10
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +96 -6
- package/lib/stdlib/item/edge/base.js +92 -19
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/line.js +5 -2
- package/lib/stdlib/item/edge/line.js.map +1 -1
- package/lib/stdlib/item/edge/polyline.d.ts +3 -2
- package/lib/stdlib/item/edge/polyline.js +3 -3
- package/lib/stdlib/item/edge/polyline.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +90 -16
- package/lib/stdlib/item/node/base.js +91 -41
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/base3d.d.ts +24 -0
- package/lib/stdlib/item/node/base3d.js +24 -8
- package/lib/stdlib/item/node/base3d.js.map +1 -1
- package/lib/stdlib/item/node/diamond.js +1 -1
- package/lib/stdlib/item/node/ellipse.js +2 -2
- package/lib/stdlib/item/node/hexagon.js +12 -5
- package/lib/stdlib/item/node/hexagon.js.map +1 -1
- package/lib/stdlib/item/node/image.d.ts +40 -0
- package/lib/stdlib/item/node/image.js +114 -0
- package/lib/stdlib/item/node/image.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +1 -0
- package/lib/stdlib/item/node/index.js +1 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/plugin/history/combo-command.js +2 -2
- package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
- package/lib/stdlib/plugin/history/index.d.ts +10 -10
- package/lib/stdlib/plugin/history/index.js +14 -14
- package/lib/stdlib/plugin/history/index.js.map +1 -1
- package/lib/stdlib/plugin/history/item-data-command.js +25 -16
- package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/index.d.ts +2 -0
- package/lib/stdlib/plugin/index.js +2 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/legend/index.js +5 -3
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/plugin/map/index.d.ts +118 -0
- package/lib/stdlib/plugin/map/index.js +687 -0
- package/lib/stdlib/plugin/map/index.js.map +1 -0
- package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
- package/lib/stdlib/plugin/minimap/index.js +116 -9
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
- package/lib/stdlib/plugin/snapline/index.js +1067 -0
- package/lib/stdlib/plugin/snapline/index.js.map +1 -0
- package/lib/stdlib/plugin/timebar/index.d.ts +98 -0
- package/lib/stdlib/plugin/timebar/index.js +307 -0
- package/lib/stdlib/plugin/timebar/index.js.map +1 -0
- package/lib/stdlib/plugin/toolbar/index.js +1 -1
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/plugin/types.d.ts +2 -0
- package/lib/stdlib/theme/dark.js +42 -2
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +4 -4
- package/lib/types/common.d.ts +1 -0
- package/lib/types/event.d.ts +1 -0
- package/lib/types/graph.d.ts +48 -22
- package/lib/types/hook.d.ts +22 -2
- package/lib/types/item.d.ts +6 -0
- package/lib/types/item.js.map +1 -1
- package/lib/types/spec.d.ts +20 -4
- package/lib/types/view.d.ts +5 -0
- package/lib/util/bbox.d.ts +16 -1
- package/lib/util/bbox.js +32 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/canvas.d.ts +2 -2
- package/lib/util/canvas.js +5 -11
- package/lib/util/canvas.js.map +1 -1
- package/lib/util/event.d.ts +3 -1
- package/lib/util/event.js +8 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/item.d.ts +16 -1
- package/lib/util/item.js +33 -9
- package/lib/util/item.js.map +1 -1
- package/lib/util/layout.d.ts +11 -0
- package/lib/util/layout.js +47 -1
- package/lib/util/layout.js.map +1 -1
- package/lib/util/point.js +9 -2
- package/lib/util/point.js.map +1 -1
- package/lib/util/router.d.ts +4 -3
- package/lib/util/router.js +8 -5
- package/lib/util/router.js.map +1 -1
- package/lib/util/shape.d.ts +3 -3
- package/lib/util/shape.js +8 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/warn.d.ts +14 -0
- package/lib/util/warn.js +8 -0
- package/lib/util/warn.js.map +1 -0
- package/package.json +10 -10
- package/src/api-doc/item.ts +2 -0
- package/src/constant/shape.ts +2 -1
- package/src/index.ts +4 -2
- package/src/item/combo.ts +14 -9
- package/src/item/edge.ts +131 -57
- package/src/item/item.ts +24 -15
- package/src/item/node.ts +38 -24
- package/src/runtime/controller/data.ts +142 -341
- package/src/runtime/controller/item.ts +236 -72
- package/src/runtime/controller/plugin.ts +15 -3
- package/src/runtime/graph.ts +592 -96
- package/src/stdlib/behavior/activate-relations.ts +8 -8
- package/src/stdlib/behavior/brush-select.ts +4 -2
- package/src/stdlib/behavior/click-select.ts +1 -1
- package/src/stdlib/behavior/create-edge.ts +296 -0
- package/src/stdlib/behavior/drag-canvas.ts +76 -27
- package/src/stdlib/behavior/drag-combo.ts +10 -10
- package/src/stdlib/behavior/drag-node.ts +18 -18
- package/src/stdlib/behavior/index.ts +3 -0
- package/src/stdlib/behavior/lasso-select.ts +5 -3
- package/src/stdlib/behavior/scroll-canvas.ts +348 -0
- package/src/stdlib/behavior/shortcuts-call.ts +120 -0
- package/src/stdlib/behavior/zoom-canvas.ts +72 -25
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/transformV4Data.ts +2 -2
- package/src/stdlib/data/validateData.ts +16 -11
- package/src/stdlib/index.ts +33 -9
- package/src/stdlib/item/edge/base.ts +118 -19
- package/src/stdlib/item/edge/line.ts +8 -2
- package/src/stdlib/item/edge/polyline.ts +7 -5
- package/src/stdlib/item/node/base.ts +117 -46
- package/src/stdlib/item/node/base3d.ts +24 -9
- package/src/stdlib/item/node/diamond.ts +1 -1
- package/src/stdlib/item/node/ellipse.ts +2 -2
- package/src/stdlib/item/node/hexagon.ts +14 -6
- package/src/stdlib/item/node/image.ts +190 -0
- package/src/stdlib/item/node/index.ts +1 -0
- package/src/stdlib/plugin/history/combo-command.ts +2 -2
- package/src/stdlib/plugin/history/index.ts +14 -14
- package/src/stdlib/plugin/history/item-data-command.ts +35 -17
- package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
- package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
- package/src/stdlib/plugin/index.ts +2 -0
- package/src/stdlib/plugin/legend/index.ts +5 -4
- package/src/stdlib/plugin/map/index.ts +808 -0
- package/src/stdlib/plugin/minimap/index.ts +120 -10
- package/src/stdlib/plugin/snapline/index.ts +1297 -0
- package/src/stdlib/plugin/timebar/index.ts +473 -0
- package/src/stdlib/plugin/toolbar/index.ts +1 -1
- package/src/stdlib/plugin/types.ts +2 -0
- package/src/stdlib/theme/dark.ts +66 -2
- package/src/stdlib/theme/light.ts +4 -4
- package/src/types/common.ts +1 -0
- package/src/types/event.ts +1 -0
- package/src/types/graph.ts +59 -25
- package/src/types/hook.ts +22 -2
- package/src/types/item.ts +10 -0
- package/src/types/spec.ts +23 -4
- package/src/types/view.ts +8 -3
- package/src/util/bbox.ts +38 -1
- package/src/util/canvas.ts +5 -5
- package/src/util/event.ts +14 -1
- package/src/util/item.ts +65 -28
- package/src/util/layout.ts +45 -0
- package/src/util/point.ts +8 -3
- package/src/util/router.ts +15 -6
- package/src/util/shape.ts +16 -14
- package/src/util/warn.ts +20 -0
- package/src/api-doc/readme.md +0 -59
|
@@ -17,7 +17,6 @@ const util_1 = require("@antv/util");
|
|
|
17
17
|
const stdlib_1 = require("../../stdlib");
|
|
18
18
|
const data_1 = require("../../util/data");
|
|
19
19
|
const extension_1 = require("../../util/extension");
|
|
20
|
-
const type_1 = require("../../util/type");
|
|
21
20
|
const layout_1 = require("../../util/layout");
|
|
22
21
|
const behavior_1 = require("../../util/behavior");
|
|
23
22
|
/**
|
|
@@ -117,9 +116,9 @@ class DataController {
|
|
|
117
116
|
* Get the extensions from useLib.
|
|
118
117
|
*/
|
|
119
118
|
getExtensions() {
|
|
120
|
-
const {
|
|
119
|
+
const { transforms = [] } = this.graph.getSpecification();
|
|
121
120
|
const requiredTransformers = ['validate-data'];
|
|
122
|
-
return [...
|
|
121
|
+
return [...transforms, ...requiredTransformers]
|
|
123
122
|
.map((config) => ({
|
|
124
123
|
config,
|
|
125
124
|
func: (0, extension_1.getExtension)(config, stdlib_1.registery.useLib, 'transform'),
|
|
@@ -132,7 +131,7 @@ class DataController {
|
|
|
132
131
|
*/
|
|
133
132
|
onDataChange(param) {
|
|
134
133
|
const { data, type: changeType } = param;
|
|
135
|
-
const {
|
|
134
|
+
const { graphCore } = this;
|
|
136
135
|
const change = () => {
|
|
137
136
|
switch (changeType) {
|
|
138
137
|
case 'remove':
|
|
@@ -153,8 +152,8 @@ class DataController {
|
|
|
153
152
|
break;
|
|
154
153
|
}
|
|
155
154
|
};
|
|
156
|
-
if (
|
|
157
|
-
|
|
155
|
+
if (graphCore) {
|
|
156
|
+
graphCore.batch(change);
|
|
158
157
|
}
|
|
159
158
|
else {
|
|
160
159
|
change();
|
|
@@ -163,21 +162,21 @@ class DataController {
|
|
|
163
162
|
onTreeCollapseExpand(params) {
|
|
164
163
|
const { ids, action } = params;
|
|
165
164
|
ids.forEach((id) => {
|
|
166
|
-
this.
|
|
165
|
+
this.graphCore.mergeNodeData(id, {
|
|
167
166
|
collapsed: action === 'collapse',
|
|
168
167
|
});
|
|
169
168
|
});
|
|
170
169
|
}
|
|
171
170
|
onLayout({ options }) {
|
|
172
171
|
if (this.treeDirtyFlag && (0, layout_1.isTreeLayout)(options)) {
|
|
173
|
-
this.
|
|
172
|
+
this.establishGraphCoreTree();
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
175
|
onGraphInit() {
|
|
177
176
|
const { modes = {} } = this.graph.getSpecification();
|
|
178
177
|
const mode = this.graph.getMode() || 'default';
|
|
179
178
|
if ((0, behavior_1.hasTreeBehaviors)(modes[mode])) {
|
|
180
|
-
this.
|
|
179
|
+
this.establishGraphCoreTree();
|
|
181
180
|
}
|
|
182
181
|
}
|
|
183
182
|
onBehaviorChange(param) {
|
|
@@ -186,31 +185,29 @@ class DataController {
|
|
|
186
185
|
if (action !== 'add' || !modes.includes(mode))
|
|
187
186
|
return;
|
|
188
187
|
if ((0, behavior_1.hasTreeBehaviors)(behaviors)) {
|
|
189
|
-
this.
|
|
188
|
+
this.establishGraphCoreTree();
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
onModeChange(param) {
|
|
193
192
|
const { modes = {} } = this.graph.getSpecification();
|
|
194
193
|
if ((0, behavior_1.hasTreeBehaviors)(modes[param.mode])) {
|
|
195
|
-
this.
|
|
194
|
+
this.establishGraphCoreTree();
|
|
196
195
|
}
|
|
197
196
|
}
|
|
198
|
-
|
|
197
|
+
establishGraphCoreTree() {
|
|
199
198
|
if (!this.treeDirtyFlag)
|
|
200
199
|
return;
|
|
201
|
-
const nodes = this.
|
|
202
|
-
const edges = this.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
(0, data_1.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
(
|
|
212
|
-
this.userGraphCore.setParent(child.id, node.id, 'tree');
|
|
213
|
-
});
|
|
200
|
+
const nodes = this.graphCore.getAllNodes();
|
|
201
|
+
const edges = this.graphCore.getAllEdges();
|
|
202
|
+
// graph data to tree structure and storing
|
|
203
|
+
const rootIds = nodes
|
|
204
|
+
.filter((node) => node.data.isRoot)
|
|
205
|
+
.map((node) => node.id);
|
|
206
|
+
(0, data_1.graphData2TreeData)({}, { nodes, edges }, rootIds).forEach((tree) => {
|
|
207
|
+
(0, data_1.traverse)(tree, (node) => {
|
|
208
|
+
var _a;
|
|
209
|
+
(_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
|
|
210
|
+
this.graphCore.setParent(child.id, node.id, 'tree');
|
|
214
211
|
});
|
|
215
212
|
});
|
|
216
213
|
});
|
|
@@ -226,16 +223,9 @@ class DataController {
|
|
|
226
223
|
const { type: dataType, data } = this.formatData(dataConfig) || {};
|
|
227
224
|
if (!dataType)
|
|
228
225
|
return;
|
|
226
|
+
this.dataType = dataType;
|
|
229
227
|
const { nodes = [], edges = [], combos = [] } = this.transformData(data);
|
|
230
228
|
if (changeType === 'replace') {
|
|
231
|
-
this.userGraphCore = new graphlib_1.Graph({
|
|
232
|
-
nodes: nodes.concat((combos === null || combos === void 0 ? void 0 : combos.map((combo) => ({
|
|
233
|
-
id: combo.id,
|
|
234
|
-
data: Object.assign(Object.assign({}, combo.data), { _isCombo: true }),
|
|
235
|
-
}))) || []),
|
|
236
|
-
edges,
|
|
237
|
-
onChanged: (event) => this.updateGraphCore(event),
|
|
238
|
-
});
|
|
239
229
|
this.graphCore = new graphlib_1.Graph((0, util_1.clone)({
|
|
240
230
|
nodes: nodes.concat((combos === null || combos === void 0 ? void 0 : combos.map((combo) => ({
|
|
241
231
|
id: combo.id,
|
|
@@ -268,9 +258,9 @@ class DataController {
|
|
|
268
258
|
}
|
|
269
259
|
}
|
|
270
260
|
else {
|
|
271
|
-
const {
|
|
261
|
+
const { graphCore } = this;
|
|
272
262
|
const prevData = (0, data_1.deconstructData)({
|
|
273
|
-
nodes:
|
|
263
|
+
nodes: graphCore.getAllNodes(),
|
|
274
264
|
edges: [],
|
|
275
265
|
});
|
|
276
266
|
const nodesAndCombos = nodes.concat(combos.map((combo) => ({
|
|
@@ -279,94 +269,124 @@ class DataController {
|
|
|
279
269
|
})));
|
|
280
270
|
// =========== node & combos ============
|
|
281
271
|
if (!prevData.nodes.length) {
|
|
282
|
-
|
|
272
|
+
graphCore.addNodes(nodesAndCombos);
|
|
283
273
|
}
|
|
284
274
|
else {
|
|
285
275
|
if (changeType === 'mergeReplace') {
|
|
286
|
-
// remove the nodes which are not in data but in
|
|
276
|
+
// remove the nodes which are not in incoming data but in graphCore
|
|
287
277
|
const nodeAndComboIds = nodesAndCombos.map((node) => node.id);
|
|
288
278
|
prevData.nodes.forEach((prevNode) => {
|
|
289
|
-
if (!nodeAndComboIds.includes(prevNode.id))
|
|
290
|
-
|
|
279
|
+
if (!nodeAndComboIds.includes(prevNode.id)) {
|
|
280
|
+
this.removeNode(prevNode);
|
|
281
|
+
}
|
|
291
282
|
});
|
|
292
283
|
}
|
|
293
284
|
// add or update node
|
|
294
285
|
nodesAndCombos.forEach((item) => {
|
|
295
|
-
if (
|
|
286
|
+
if (graphCore.hasNode(item.id)) {
|
|
296
287
|
// update node which is in the graphCore
|
|
297
|
-
|
|
288
|
+
graphCore.mergeNodeData(item.id, item.data);
|
|
298
289
|
}
|
|
299
290
|
else {
|
|
300
291
|
// add node which is in data but not in graphCore
|
|
301
|
-
|
|
292
|
+
graphCore.addNode(item);
|
|
302
293
|
}
|
|
303
294
|
});
|
|
304
295
|
}
|
|
305
296
|
// =========== edge ============
|
|
306
|
-
prevData.edges =
|
|
297
|
+
prevData.edges = graphCore.getAllEdges();
|
|
307
298
|
if (!prevData.edges.length) {
|
|
308
|
-
|
|
299
|
+
graphCore.addEdges(edges);
|
|
309
300
|
}
|
|
310
301
|
else {
|
|
311
302
|
if (changeType === 'mergeReplace') {
|
|
312
|
-
// remove the edges which are not in data but in
|
|
303
|
+
// remove the edges which are not in incoming data but in graphCore
|
|
313
304
|
const edgeIds = edges.map((edge) => edge.id);
|
|
314
305
|
prevData.edges.forEach((prevEdge) => {
|
|
315
306
|
if (!edgeIds.includes(prevEdge.id))
|
|
316
|
-
|
|
307
|
+
graphCore.removeEdge(prevEdge.id);
|
|
317
308
|
});
|
|
318
309
|
}
|
|
319
310
|
// add or update edge
|
|
320
311
|
edges.forEach((edge) => {
|
|
321
|
-
if (
|
|
312
|
+
if (graphCore.hasEdge(edge.id)) {
|
|
322
313
|
// update edge which is in the graphCore
|
|
323
|
-
|
|
314
|
+
graphCore.mergeEdgeData(edge.id, edge.data);
|
|
324
315
|
}
|
|
325
316
|
else {
|
|
326
317
|
// add edge which is in data but not in graphCore
|
|
327
|
-
|
|
318
|
+
graphCore.addEdge(edge);
|
|
328
319
|
}
|
|
329
320
|
});
|
|
330
321
|
}
|
|
331
322
|
}
|
|
332
323
|
if ((_a = data.edges) === null || _a === void 0 ? void 0 : _a.length) {
|
|
333
|
-
const {
|
|
324
|
+
const { graphCore } = this;
|
|
334
325
|
// convert and store tree structure to graphCore
|
|
335
326
|
this.updateTreeGraph(dataType, {
|
|
336
|
-
nodes:
|
|
337
|
-
edges:
|
|
327
|
+
nodes: graphCore.getAllNodes(),
|
|
328
|
+
edges: graphCore.getAllEdges(),
|
|
338
329
|
});
|
|
339
330
|
}
|
|
340
331
|
}
|
|
332
|
+
removeNode(nodeModel) {
|
|
333
|
+
const { id, data } = nodeModel;
|
|
334
|
+
const { graphCore } = this;
|
|
335
|
+
if (graphCore.hasTreeStructure('combo')) {
|
|
336
|
+
// remove from its parent's children list
|
|
337
|
+
graphCore.setParent(id, undefined, 'combo');
|
|
338
|
+
const { parentId } = data;
|
|
339
|
+
// move the children to the grandparent's children list
|
|
340
|
+
graphCore.getChildren(id, 'combo').forEach((child) => {
|
|
341
|
+
graphCore.setParent(child.id, parentId, 'combo');
|
|
342
|
+
graphCore.mergeNodeData(child.id, { parentId });
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
if (graphCore.hasTreeStructure('tree')) {
|
|
346
|
+
const succeedIds = [];
|
|
347
|
+
graphCore.dfsTree(id, (child) => {
|
|
348
|
+
succeedIds.push(child.id);
|
|
349
|
+
}, 'tree');
|
|
350
|
+
const succeedEdgeIds = graphCore
|
|
351
|
+
.getAllEdges()
|
|
352
|
+
.filter(({ source, target }) => succeedIds.includes(source) && succeedIds.includes(target))
|
|
353
|
+
.map((edge) => edge.id);
|
|
354
|
+
this.graph.showItem(succeedIds
|
|
355
|
+
.filter((succeedId) => succeedId !== id)
|
|
356
|
+
.concat(succeedEdgeIds));
|
|
357
|
+
// for tree graph view, remove the node from the parent's children list
|
|
358
|
+
graphCore.setParent(id, undefined, 'tree');
|
|
359
|
+
// for tree graph view, make the its children to be roots
|
|
360
|
+
graphCore
|
|
361
|
+
.getChildren(id, 'tree')
|
|
362
|
+
.forEach((child) => graphCore.setParent(child.id, undefined, 'tree'));
|
|
363
|
+
}
|
|
364
|
+
graphCore.removeNode(id);
|
|
365
|
+
}
|
|
341
366
|
/**
|
|
342
367
|
* Remove part of old data.
|
|
343
368
|
* @param data data to be removed which is part of old one
|
|
344
369
|
*/
|
|
345
370
|
removeData(data) {
|
|
346
|
-
const {
|
|
371
|
+
const { graphCore } = this;
|
|
347
372
|
const { nodes = [], edges = [], combos = [] } = data;
|
|
348
373
|
const nodesAndCombos = nodes.concat(combos);
|
|
349
|
-
const prevNodesAndCombos =
|
|
350
|
-
const prevEdges =
|
|
374
|
+
const prevNodesAndCombos = graphCore.getAllNodes();
|
|
375
|
+
const prevEdges = graphCore.getAllEdges();
|
|
351
376
|
if (prevNodesAndCombos.length && nodesAndCombos.length) {
|
|
352
|
-
// update
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
this.graphCore.getChildren(item.id, 'combo').forEach((child) => {
|
|
357
|
-
userGraphCore.mergeNodeData(child.id, { parentId });
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
}
|
|
377
|
+
// update combo tree view and tree graph view
|
|
378
|
+
nodesAndCombos.forEach((item) => {
|
|
379
|
+
this.removeNode(item);
|
|
380
|
+
});
|
|
361
381
|
// remove the node
|
|
362
|
-
|
|
382
|
+
// graphCore.removeNodes(nodesAndCombos.map((node) => node.id));
|
|
363
383
|
}
|
|
364
384
|
if (prevEdges.length && edges.length) {
|
|
365
385
|
// add or update edge
|
|
366
386
|
const ids = edges
|
|
367
387
|
.map((edge) => edge.id)
|
|
368
|
-
.filter((id) =>
|
|
369
|
-
|
|
388
|
+
.filter((id) => graphCore.hasEdge(id));
|
|
389
|
+
graphCore.removeEdges(ids);
|
|
370
390
|
}
|
|
371
391
|
}
|
|
372
392
|
/**
|
|
@@ -374,39 +394,42 @@ class DataController {
|
|
|
374
394
|
* @param data data to be updated which is part of old one
|
|
375
395
|
*/
|
|
376
396
|
updateData(dataConfig) {
|
|
377
|
-
const {
|
|
397
|
+
const { graphCore } = this;
|
|
378
398
|
const { type: dataType, data } = this.formatData(dataConfig);
|
|
379
399
|
if (!dataType)
|
|
380
400
|
return;
|
|
381
401
|
const { nodes = [], edges = [], combos = [] } = data; //this.transformData(data as GraphData);
|
|
382
402
|
const { nodes: prevNodes, edges: prevEdges, combos: prevCombos, } = (0, data_1.deconstructData)({
|
|
383
|
-
nodes:
|
|
384
|
-
edges:
|
|
403
|
+
nodes: graphCore.getAllNodes(),
|
|
404
|
+
edges: graphCore.getAllEdges(),
|
|
385
405
|
});
|
|
386
406
|
if (prevNodes.length) {
|
|
387
407
|
// update node
|
|
388
408
|
nodes.forEach((newModel) => {
|
|
389
409
|
const { id, data } = newModel;
|
|
390
410
|
if (data) {
|
|
391
|
-
const mergedData = mergeOneLevelData(
|
|
392
|
-
|
|
411
|
+
const mergedData = mergeOneLevelData(graphCore.getNode(id), newModel);
|
|
412
|
+
graphCore.mergeNodeData(id, mergedData);
|
|
413
|
+
}
|
|
414
|
+
if (data.hasOwnProperty('parentId')) {
|
|
415
|
+
graphCore.setParent(id, data.parentId, 'combo');
|
|
393
416
|
}
|
|
394
417
|
});
|
|
395
418
|
}
|
|
396
419
|
if (prevEdges.length) {
|
|
397
420
|
// update edge
|
|
398
421
|
edges.forEach((newModel) => {
|
|
399
|
-
const oldModel =
|
|
422
|
+
const oldModel = graphCore.getEdge(newModel.id);
|
|
400
423
|
if (!oldModel)
|
|
401
424
|
return;
|
|
402
425
|
const { id, source, target, data } = newModel;
|
|
403
426
|
if (source && oldModel.source !== source)
|
|
404
|
-
|
|
427
|
+
graphCore.updateEdgeSource(id, source);
|
|
405
428
|
if (target && oldModel.target !== target)
|
|
406
|
-
|
|
429
|
+
graphCore.updateEdgeTarget(id, target);
|
|
407
430
|
if (data) {
|
|
408
|
-
const mergedData = mergeOneLevelData(
|
|
409
|
-
|
|
431
|
+
const mergedData = mergeOneLevelData(graphCore.getEdge(id), newModel);
|
|
432
|
+
graphCore.mergeEdgeData(id, mergedData);
|
|
410
433
|
}
|
|
411
434
|
});
|
|
412
435
|
}
|
|
@@ -415,6 +438,8 @@ class DataController {
|
|
|
415
438
|
const modelsToMove = [];
|
|
416
439
|
combos.forEach((newModel) => {
|
|
417
440
|
const { id, data } = newModel;
|
|
441
|
+
if (!data)
|
|
442
|
+
return;
|
|
418
443
|
const { x: comboNewX, y: comboNewY } = data, others = __rest(data, ["x", "y"]);
|
|
419
444
|
if (comboNewX !== undefined || comboNewY !== undefined) {
|
|
420
445
|
if (this.graphCore.getChildren(id, 'combo').length) {
|
|
@@ -451,24 +476,27 @@ class DataController {
|
|
|
451
476
|
}
|
|
452
477
|
// update other properties
|
|
453
478
|
if (Object.keys(others).length) {
|
|
454
|
-
const mergedData = mergeOneLevelData(
|
|
479
|
+
const mergedData = mergeOneLevelData(graphCore.getNode(id), {
|
|
455
480
|
id,
|
|
456
481
|
data: others,
|
|
457
482
|
});
|
|
458
|
-
|
|
483
|
+
graphCore.mergeNodeData(id, mergedData);
|
|
484
|
+
if (others.hasOwnProperty('parentId')) {
|
|
485
|
+
graphCore.setParent(id, others.parentId, 'combo');
|
|
486
|
+
}
|
|
459
487
|
}
|
|
460
488
|
});
|
|
461
489
|
// update succeed nodes
|
|
462
490
|
modelsToMove.forEach((newModel) => {
|
|
463
491
|
const { id, data } = newModel;
|
|
464
|
-
|
|
492
|
+
graphCore.mergeNodeData(id, data);
|
|
465
493
|
});
|
|
466
494
|
}
|
|
467
495
|
if (edges === null || edges === void 0 ? void 0 : edges.filter((edge) => edge.hasOwnProperty('source') || edge.hasOwnProperty('target')).length) {
|
|
468
496
|
// convert and store tree structure to graphCore
|
|
469
497
|
this.updateTreeGraph(dataType, {
|
|
470
|
-
nodes: this.
|
|
471
|
-
edges: this.
|
|
498
|
+
nodes: this.graphCore.getAllNodes(),
|
|
499
|
+
edges: this.graphCore.getAllEdges(),
|
|
472
500
|
});
|
|
473
501
|
}
|
|
474
502
|
}
|
|
@@ -489,7 +517,7 @@ class DataController {
|
|
|
489
517
|
return;
|
|
490
518
|
}
|
|
491
519
|
return {
|
|
492
|
-
type: type || 'graphData',
|
|
520
|
+
type: type || this.dataType || 'graphData',
|
|
493
521
|
data: data,
|
|
494
522
|
};
|
|
495
523
|
}
|
|
@@ -534,12 +562,12 @@ class DataController {
|
|
|
534
562
|
}
|
|
535
563
|
});
|
|
536
564
|
// update succeed nodes
|
|
537
|
-
const {
|
|
565
|
+
const { graphCore } = this;
|
|
538
566
|
succeedNodesModels.forEach((newModel) => {
|
|
539
567
|
const { id, data } = newModel;
|
|
540
568
|
if (data) {
|
|
541
|
-
const mergedData = mergeOneLevelData(
|
|
542
|
-
|
|
569
|
+
const mergedData = mergeOneLevelData(graphCore.getNode(id), newModel);
|
|
570
|
+
graphCore.mergeNodeData(id, mergedData);
|
|
543
571
|
}
|
|
544
572
|
});
|
|
545
573
|
}
|
|
@@ -547,17 +575,20 @@ class DataController {
|
|
|
547
575
|
const { combos = [] } = data;
|
|
548
576
|
if (!(combos === null || combos === void 0 ? void 0 : combos.length))
|
|
549
577
|
return;
|
|
550
|
-
const {
|
|
578
|
+
const { graphCore } = this;
|
|
551
579
|
const { id, data: comboData } = combos[0];
|
|
552
580
|
const { _children = [] } = comboData, others = __rest(comboData, ["_children"]);
|
|
581
|
+
if (!graphCore.hasTreeStructure('combo')) {
|
|
582
|
+
graphCore.attachTreeStructure('combo');
|
|
583
|
+
}
|
|
553
584
|
// add or update combo
|
|
554
|
-
if (
|
|
585
|
+
if (graphCore.hasNode(id)) {
|
|
555
586
|
// update node which is in the graphCore
|
|
556
|
-
|
|
587
|
+
graphCore.mergeNodeData(id, Object.assign(Object.assign({}, others), { _isCombo: true }));
|
|
557
588
|
}
|
|
558
589
|
else {
|
|
559
590
|
// add node which is in data but not in graphCore
|
|
560
|
-
|
|
591
|
+
graphCore.addNode({ id, data: Object.assign(Object.assign({}, others), { _isCombo: true }) });
|
|
561
592
|
}
|
|
562
593
|
// update strucutre
|
|
563
594
|
_children.forEach((childId) => {
|
|
@@ -565,206 +596,19 @@ class DataController {
|
|
|
565
596
|
console.warn(`Adding child ${childId} to combo ${id} failed. The child ${childId} does not exist`);
|
|
566
597
|
return;
|
|
567
598
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* Update graphCore with transformed userGraphCore data.
|
|
573
|
-
*/
|
|
574
|
-
updateGraphCore(event) {
|
|
575
|
-
const { graphCore } = this;
|
|
576
|
-
const { nodes = [], edges = [], combos = [], } = (0, data_1.deconstructData)({
|
|
577
|
-
nodes: this.userGraphCore.getAllNodes(),
|
|
578
|
-
edges: this.userGraphCore.getAllEdges(),
|
|
579
|
-
});
|
|
580
|
-
const prevNodesAndCombos = graphCore.getAllNodes();
|
|
581
|
-
// function to update one data in graphCore with different model type ('node' or 'edge')
|
|
582
|
-
const syncUpdateToGraphCore = (id, newValue, oldValue, isNodeOrCombo, diff = []) => {
|
|
583
|
-
if (isNodeOrCombo) {
|
|
584
|
-
if (newValue.data)
|
|
585
|
-
graphCore.updateNodeData(id, Object.assign({}, newValue.data));
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
588
|
-
if (diff.includes('data'))
|
|
589
|
-
graphCore.updateEdgeData(id, Object.assign({}, newValue.data));
|
|
590
|
-
// source and target may be changed
|
|
591
|
-
if (diff.includes('source'))
|
|
592
|
-
graphCore.updateEdgeSource(id, newValue.source);
|
|
593
|
-
if (diff.includes('target'))
|
|
594
|
-
graphCore.updateEdgeTarget(id, newValue.target);
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
graphCore.batch(() => {
|
|
598
|
-
// === step 3: sync to graphCore according to the changes in userGraphCore ==
|
|
599
|
-
const newModelMap = {};
|
|
600
|
-
const parentMap = {};
|
|
601
|
-
const changeMap = {};
|
|
602
|
-
const treeChanges = [];
|
|
603
|
-
event.changes.forEach((change) => {
|
|
604
|
-
var _a;
|
|
605
|
-
const id = change.id || ((_a = change.value) === null || _a === void 0 ? void 0 : _a.id);
|
|
606
|
-
if (id !== undefined) {
|
|
607
|
-
changeMap[id] = true;
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
if ([
|
|
611
|
-
'TreeStructureAttached',
|
|
612
|
-
'TreeStructureChanged',
|
|
613
|
-
'TreeStructureChanged',
|
|
614
|
-
].includes(change.type)) {
|
|
615
|
-
treeChanges.push(change);
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
|
-
nodes.forEach((model) => {
|
|
619
|
-
newModelMap[model.id] = { type: 'node', model };
|
|
620
|
-
if (model.data.hasOwnProperty('parentId')) {
|
|
621
|
-
parentMap[model.id] = {
|
|
622
|
-
new: model.data.parentId,
|
|
623
|
-
old: undefined,
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
edges.forEach((model) => (newModelMap[model.id] = { type: 'edge', model }));
|
|
628
|
-
combos.forEach((model) => {
|
|
629
|
-
newModelMap[model.id] = { type: 'combo', model };
|
|
630
|
-
if (model.data.hasOwnProperty('parentId')) {
|
|
631
|
-
parentMap[model.id] = {
|
|
632
|
-
new: model.data.parentId,
|
|
633
|
-
old: undefined,
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
prevNodesAndCombos.forEach((prevModel) => {
|
|
638
|
-
var _a, _b;
|
|
639
|
-
const { id } = prevModel;
|
|
640
|
-
if (((_a = parentMap[id]) === null || _a === void 0 ? void 0 : _a.new) !== undefined ||
|
|
641
|
-
prevModel.data.parentId !== undefined) {
|
|
642
|
-
parentMap[id] = {
|
|
643
|
-
new: (_b = parentMap[id]) === null || _b === void 0 ? void 0 : _b.new,
|
|
644
|
-
old: prevModel.data.parentId,
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
else {
|
|
648
|
-
delete parentMap[id];
|
|
649
|
-
}
|
|
650
|
-
const { model: newModel } = newModelMap[id] || {};
|
|
651
|
-
// remove
|
|
652
|
-
if (!newModel) {
|
|
653
|
-
// remove a combo, put the children to upper parent
|
|
654
|
-
if (prevModel.data._isCombo) {
|
|
655
|
-
graphCore.getChildren(id, 'combo').forEach((child) => {
|
|
656
|
-
parentMap[child.id] = Object.assign(Object.assign({}, parentMap[child.id]), { new: prevModel.data.parentId });
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
// if it has combo parent, remove it from the parent's children list
|
|
660
|
-
if (prevModel.data.parentId) {
|
|
661
|
-
graphCore.setParent(id, undefined, 'combo');
|
|
662
|
-
}
|
|
663
|
-
// for tree graph view, show the succeed nodes and edges
|
|
664
|
-
const succeedIds = [];
|
|
665
|
-
if (graphCore.hasTreeStructure('tree')) {
|
|
666
|
-
graphCore.dfsTree(id, (child) => {
|
|
667
|
-
succeedIds.push(child.id);
|
|
668
|
-
}, 'tree');
|
|
669
|
-
const succeedEdgeIds = graphCore
|
|
670
|
-
.getAllEdges()
|
|
671
|
-
.filter(({ source, target }) => succeedIds.includes(source) && succeedIds.includes(target))
|
|
672
|
-
.map((edge) => edge.id);
|
|
673
|
-
this.graph.showItem(succeedIds
|
|
674
|
-
.filter((succeedId) => succeedId !== id)
|
|
675
|
-
.concat(succeedEdgeIds));
|
|
676
|
-
// for tree graph view, remove the node from the parent's children list
|
|
677
|
-
graphCore.setParent(id, undefined, 'tree');
|
|
678
|
-
// for tree graph view, make the its children to be roots
|
|
679
|
-
graphCore
|
|
680
|
-
.getChildren(id, 'tree')
|
|
681
|
-
.forEach((child) => graphCore.setParent(child.id, undefined, 'tree'));
|
|
682
|
-
}
|
|
683
|
-
// remove the node data
|
|
684
|
-
graphCore.removeNode(id);
|
|
685
|
-
delete parentMap[prevModel.id];
|
|
686
|
-
}
|
|
687
|
-
// update
|
|
688
|
-
// || diffAt(newModel, prevModel, true)?.length
|
|
689
|
-
else if (changeMap[id])
|
|
690
|
-
syncUpdateToGraphCore(id, newModel, prevModel, true);
|
|
691
|
-
// delete from the map indicates this model is visited
|
|
692
|
-
delete newModelMap[id];
|
|
693
|
-
});
|
|
694
|
-
graphCore.getAllEdges().forEach((prevEdge) => {
|
|
695
|
-
const { id } = prevEdge;
|
|
696
|
-
const { model: newModel } = newModelMap[id] || {};
|
|
697
|
-
// remove
|
|
698
|
-
if (!newModel)
|
|
699
|
-
graphCore.removeEdge(id);
|
|
700
|
-
// update
|
|
701
|
-
else {
|
|
702
|
-
const diff = diffAt(newModel, prevEdge, false);
|
|
703
|
-
if (diff === null || diff === void 0 ? void 0 : diff.length)
|
|
704
|
-
syncUpdateToGraphCore(id, newModel, prevEdge, false, diff);
|
|
705
|
-
}
|
|
706
|
-
// delete from the map indicates this model is visited
|
|
707
|
-
delete newModelMap[id];
|
|
708
|
-
});
|
|
709
|
-
// add
|
|
710
|
-
Object.values(newModelMap).forEach(({ type, model }) => {
|
|
711
|
-
if (type === 'node' || type === 'combo')
|
|
712
|
-
graphCore.addNode(model);
|
|
713
|
-
else if (type === 'edge')
|
|
714
|
-
graphCore.addEdge(model);
|
|
715
|
-
});
|
|
716
|
-
// update parents after adding all items
|
|
717
|
-
Object.keys(parentMap).forEach((id) => {
|
|
718
|
-
var _a;
|
|
719
|
-
if (parentMap[id].new === parentMap[id].old)
|
|
720
|
-
return;
|
|
721
|
-
if (!(0, data_1.validateComboStrucutre)(this.graph, id, parentMap[id].new)) {
|
|
722
|
-
graphCore.mergeNodeData(id, { parentId: parentMap[id].old });
|
|
723
|
-
return;
|
|
724
|
-
}
|
|
725
|
-
graphCore.mergeNodeData(id, { parentId: parentMap[id].new });
|
|
726
|
-
graphCore.setParent(id, parentMap[id].new, 'combo');
|
|
727
|
-
// after remove from parent's children list, check whether the parent is empty
|
|
728
|
-
// if so, update parent's position to be the child's
|
|
729
|
-
if (parentMap[id].old !== undefined) {
|
|
730
|
-
const parentChildren = graphCore.getChildren(parentMap[id].old, 'combo');
|
|
731
|
-
const { x = 0, y = 0, z = 0, } = (_a = this.graph.getDisplayModel(parentMap[id].old)) === null || _a === void 0 ? void 0 : _a.data;
|
|
732
|
-
if (!parentChildren.length) {
|
|
733
|
-
graphCore.mergeNodeData(parentMap[id].old, {
|
|
734
|
-
x: (0, type_1.convertToNumber)(x),
|
|
735
|
-
y: (0, type_1.convertToNumber)(y),
|
|
736
|
-
z: (0, type_1.convertToNumber)(z),
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
// update tree structure
|
|
742
|
-
treeChanges.forEach((change) => {
|
|
743
|
-
const { type, treeKey, nodeId, newParentId } = change;
|
|
744
|
-
if (type === 'TreeStructureAttached') {
|
|
745
|
-
graphCore.attachTreeStructure(treeKey);
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
else if (type === 'TreeStructureChanged') {
|
|
749
|
-
graphCore.setParent(nodeId, newParentId, treeKey);
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
else if (type === 'TreeStructureDetached') {
|
|
753
|
-
graphCore.detachTreeStructure(treeKey);
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
});
|
|
599
|
+
graphCore.setParent(childId, id, 'combo');
|
|
600
|
+
graphCore.mergeNodeData(childId, { parentId: id });
|
|
757
601
|
});
|
|
758
602
|
}
|
|
759
603
|
/**
|
|
760
|
-
* Clone data from
|
|
604
|
+
* Clone data from graphCore, and run transforms
|
|
761
605
|
* @returns transformed data and the id map list
|
|
762
606
|
*/
|
|
763
607
|
transformData(data) {
|
|
764
608
|
let dataCloned = (0, util_1.clone)(data);
|
|
765
609
|
// transform the data with transform extensions, output innerData and idMaps ===
|
|
766
610
|
this.extensions.forEach(({ func, config }) => {
|
|
767
|
-
dataCloned = func(dataCloned, config, this.
|
|
611
|
+
dataCloned = func(dataCloned, config, this.graphCore);
|
|
768
612
|
});
|
|
769
613
|
return dataCloned;
|
|
770
614
|
}
|
|
@@ -774,12 +618,12 @@ class DataController {
|
|
|
774
618
|
* @param data
|
|
775
619
|
*/
|
|
776
620
|
updateTreeGraph(dataType, data) {
|
|
777
|
-
this.
|
|
621
|
+
this.graphCore.attachTreeStructure('tree');
|
|
778
622
|
if (dataType === 'treeData') {
|
|
779
623
|
// tree structure storing
|
|
780
624
|
data.edges.forEach((edge) => {
|
|
781
625
|
const { source, target } = edge;
|
|
782
|
-
this.
|
|
626
|
+
this.graphCore.setParent(target, source, 'tree');
|
|
783
627
|
});
|
|
784
628
|
}
|
|
785
629
|
else {
|