@antv/g6 5.0.0-beta.2 → 5.0.0-beta.20
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/graph.d.ts +3 -3
- package/esm/api-doc/graph.js +3 -3
- package/esm/api-doc/graph.js.map +1 -1
- package/esm/api-doc/types.d.ts +1 -0
- package/esm/api-doc/types.js +1 -2
- package/esm/api-doc/types.js.map +1 -1
- package/esm/constant/shape.d.ts +3 -1
- package/esm/index.d.ts +24 -63
- package/esm/index.js +4 -5
- package/esm/index.js.map +1 -1
- package/esm/item/combo.d.ts +1 -1
- package/esm/item/combo.js +18 -14
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +19 -2
- package/esm/item/edge.js +100 -44
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +3 -2
- package/esm/item/item.js +27 -13
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +2 -8
- package/esm/item/node.js +31 -19
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +7 -10
- package/esm/runtime/controller/data.js +125 -281
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/interaction.js +9 -4
- package/esm/runtime/controller/interaction.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +1 -0
- package/esm/runtime/controller/item.js +285 -150
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.js +1 -3
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.js +9 -5
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/graph.d.ts +104 -24
- package/esm/runtime/graph.js +472 -94
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/activate-relations.d.ts +1 -1
- package/esm/stdlib/behavior/activate-relations.js +2 -2
- package/esm/stdlib/behavior/activate-relations.js.map +1 -1
- package/esm/stdlib/behavior/brush-select.d.ts +9 -3
- package/esm/stdlib/behavior/brush-select.js +10 -12
- package/esm/stdlib/behavior/brush-select.js.map +1 -1
- package/esm/stdlib/behavior/click-select.d.ts +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/collapse-expand-combo.d.ts +1 -1
- package/esm/stdlib/behavior/collapse-expand-tree.d.ts +1 -1
- package/esm/stdlib/behavior/create-edge.d.ts +57 -0
- package/esm/stdlib/behavior/create-edge.js +215 -0
- package/esm/stdlib/behavior/create-edge.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +3 -1
- package/esm/stdlib/behavior/drag-canvas.js +78 -33
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.d.ts +3 -3
- 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 +4 -4
- package/esm/stdlib/behavior/drag-node.js +80 -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 +3 -4
- 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 +87 -0
- package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
- package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.d.ts +3 -1
- package/esm/stdlib/behavior/zoom-canvas.js +70 -26
- 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 +13 -12
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +18 -6
- package/esm/stdlib/index.js +22 -10
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +3 -5
- package/esm/stdlib/item/edge/base.js +32 -31
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
- package/esm/stdlib/item/edge/cubic.js +1 -1
- package/esm/stdlib/item/edge/cubic.js.map +1 -1
- package/esm/stdlib/item/edge/loop.js +1 -1
- package/esm/stdlib/item/edge/loop.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +3 -6
- package/esm/stdlib/item/node/base.js +30 -60
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/base3d.d.ts +1 -0
- package/esm/stdlib/item/node/base3d.js +1 -0
- package/esm/stdlib/item/node/base3d.js.map +1 -1
- package/esm/stdlib/item/node/cube.d.ts +35 -0
- package/esm/stdlib/item/node/cube.js +54 -0
- package/esm/stdlib/item/node/cube.js.map +1 -0
- package/esm/stdlib/item/node/diamond.js +1 -1
- package/esm/stdlib/item/node/donut.d.ts +3 -3
- package/esm/stdlib/item/node/ellipse.js +2 -2
- package/esm/stdlib/item/node/hexagon.js +6 -2
- 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 +4 -0
- package/esm/stdlib/item/node/index.js +4 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
- package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
- package/esm/stdlib/plugin/grid/index.d.ts +1 -1
- package/esm/stdlib/plugin/grid/index.js +3 -4
- package/esm/stdlib/plugin/grid/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/convexHull.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.d.ts +2 -2
- package/esm/stdlib/plugin/hull/hullComponent.js +5 -9
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/hull/util.d.ts +2 -2
- package/esm/stdlib/plugin/hull/util.js +6 -2
- package/esm/stdlib/plugin/hull/util.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.d.ts +3 -3
- package/esm/stdlib/plugin/legend/index.js +3 -3
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/plugin/menu/index.d.ts +4 -4
- package/esm/stdlib/plugin/menu/index.js +3 -3
- package/esm/stdlib/plugin/menu/index.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.d.ts +6 -2
- package/esm/stdlib/plugin/minimap/index.js +119 -12
- 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 +4 -4
- package/esm/stdlib/plugin/timebar/index.js +6 -6
- package/esm/stdlib/plugin/timebar/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
- package/esm/stdlib/plugin/toolbar/index.js +4 -4
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/plugin/tooltip/index.d.ts +5 -5
- package/esm/stdlib/plugin/tooltip/index.js +3 -4
- package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
- package/esm/stdlib/plugin/types.d.ts +2 -0
- package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
- package/esm/stdlib/plugin/watermaker/index.js +243 -0
- package/esm/stdlib/plugin/watermaker/index.js.map +1 -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/animate.d.ts +2 -2
- package/esm/types/behavior.d.ts +1 -1
- package/esm/types/combo.d.ts +7 -7
- package/esm/types/common.d.ts +5 -5
- package/esm/types/data.d.ts +6 -6
- package/esm/types/edge.d.ts +9 -9
- package/esm/types/event.d.ts +2 -1
- package/esm/types/graph.d.ts +48 -22
- package/esm/types/history.d.ts +2 -2
- package/esm/types/hook.d.ts +23 -3
- package/esm/types/index.d.ts +2 -1
- package/esm/types/index.js +1 -0
- package/esm/types/index.js.map +1 -1
- package/esm/types/item.d.ts +18 -12
- package/esm/types/item.js.map +1 -1
- package/esm/types/layout.d.ts +6 -6
- package/esm/types/loop.d.ts +2 -2
- package/esm/types/node.d.ts +7 -7
- package/esm/types/plugin.d.ts +1 -1
- package/esm/types/render.d.ts +1 -1
- package/esm/types/spec.d.ts +19 -3
- package/esm/types/stdlib.d.ts +1 -1
- package/esm/types/theme.d.ts +8 -8
- package/esm/types/view.d.ts +7 -2
- package/esm/util/bbox.d.ts +16 -1
- package/esm/util/bbox.js +33 -5
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/behavior.d.ts +2 -2
- package/esm/util/behavior.js +2 -2
- package/esm/util/behavior.js.map +1 -1
- package/esm/util/data.d.ts +2 -2
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.d.ts +15 -0
- package/esm/util/dom.js +29 -0
- package/esm/util/dom.js.map +1 -0
- package/esm/util/event.d.ts +5 -3
- package/esm/util/event.js +8 -1
- package/esm/util/event.js.map +1 -1
- package/esm/util/extend.d.ts +1 -1
- package/esm/util/extend.js +0 -1
- package/esm/util/extend.js.map +1 -1
- package/esm/util/index.d.ts +7 -52
- package/esm/util/index.js +7 -23
- package/esm/util/index.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 +13 -2
- package/esm/util/layout.js +45 -0
- package/esm/util/layout.js.map +1 -1
- package/esm/util/loop.d.ts +1 -1
- package/esm/util/loop.js +4 -0
- package/esm/util/loop.js.map +1 -1
- package/esm/util/math.d.ts +1 -1
- package/esm/util/matrix.d.ts +6 -0
- package/esm/util/matrix.js +48 -0
- package/esm/util/matrix.js.map +1 -0
- package/esm/util/path.js +1 -1
- package/esm/util/path.js.map +1 -1
- package/esm/util/point.d.ts +1 -1
- package/esm/util/point.js +9 -2
- package/esm/util/point.js.map +1 -1
- package/esm/util/polyline.d.ts +2 -1
- package/esm/util/polyline.js +2 -1
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/shape.d.ts +1 -2
- package/esm/util/shape.js +15 -25
- package/esm/util/shape.js.map +1 -1
- package/esm/util/shape3d.js +16 -17
- package/esm/util/shape3d.js.map +1 -1
- package/esm/util/text.d.ts +1 -1
- package/esm/util/text.js +3 -2
- package/esm/util/text.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/graph.d.ts +3 -3
- package/lib/api-doc/graph.js +27 -7
- package/lib/api-doc/graph.js.map +1 -1
- package/lib/api-doc/types.d.ts +1 -0
- package/lib/api-doc/types.js +2 -2
- package/lib/api-doc/types.js.map +1 -1
- package/lib/constant/shape.d.ts +3 -1
- package/lib/index.d.ts +24 -63
- package/lib/index.js +18 -10
- package/lib/index.js.map +1 -1
- package/lib/item/combo.d.ts +1 -1
- package/lib/item/combo.js +18 -14
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +19 -2
- package/lib/item/edge.js +99 -43
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +3 -2
- package/lib/item/item.js +27 -13
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +2 -8
- package/lib/item/node.js +31 -19
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +7 -10
- package/lib/runtime/controller/data.js +125 -281
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/interaction.js +9 -4
- package/lib/runtime/controller/interaction.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +1 -0
- package/lib/runtime/controller/item.js +284 -149
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.js +1 -3
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.js +9 -5
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/graph.d.ts +104 -24
- package/lib/runtime/graph.js +473 -94
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/activate-relations.d.ts +1 -1
- package/lib/stdlib/behavior/activate-relations.js +2 -2
- package/lib/stdlib/behavior/activate-relations.js.map +1 -1
- package/lib/stdlib/behavior/brush-select.d.ts +9 -3
- package/lib/stdlib/behavior/brush-select.js +13 -12
- package/lib/stdlib/behavior/brush-select.js.map +1 -1
- package/lib/stdlib/behavior/click-select.d.ts +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/collapse-expand-combo.d.ts +1 -1
- package/lib/stdlib/behavior/collapse-expand-tree.d.ts +1 -1
- package/lib/stdlib/behavior/create-edge.d.ts +57 -0
- package/lib/stdlib/behavior/create-edge.js +219 -0
- package/lib/stdlib/behavior/create-edge.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +3 -1
- package/lib/stdlib/behavior/drag-canvas.js +78 -33
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.d.ts +3 -3
- 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 +4 -4
- package/lib/stdlib/behavior/drag-node.js +80 -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 +6 -4
- 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 +91 -0
- package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
- package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.d.ts +3 -1
- package/lib/stdlib/behavior/zoom-canvas.js +70 -26
- 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 +13 -12
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +18 -6
- package/lib/stdlib/index.js +22 -10
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +3 -5
- package/lib/stdlib/item/edge/base.js +30 -29
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
- package/lib/stdlib/item/edge/cubic.js +2 -2
- package/lib/stdlib/item/edge/cubic.js.map +1 -1
- package/lib/stdlib/item/edge/loop.js +3 -3
- package/lib/stdlib/item/edge/loop.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +3 -6
- package/lib/stdlib/item/node/base.js +29 -59
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/base3d.d.ts +1 -0
- package/lib/stdlib/item/node/base3d.js +1 -0
- package/lib/stdlib/item/node/base3d.js.map +1 -1
- package/lib/stdlib/item/node/cube.d.ts +35 -0
- package/lib/stdlib/item/node/cube.js +58 -0
- package/lib/stdlib/item/node/cube.js.map +1 -0
- package/lib/stdlib/item/node/diamond.js +1 -1
- package/lib/stdlib/item/node/donut.d.ts +3 -3
- package/lib/stdlib/item/node/ellipse.js +2 -2
- package/lib/stdlib/item/node/hexagon.js +6 -2
- 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 +4 -0
- package/lib/stdlib/item/node/index.js +4 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
- package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
- package/lib/stdlib/plugin/grid/index.d.ts +1 -1
- package/lib/stdlib/plugin/grid/index.js +6 -7
- package/lib/stdlib/plugin/grid/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/convexHull.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.d.ts +2 -2
- package/lib/stdlib/plugin/hull/hullComponent.js +5 -9
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/hull/util.d.ts +2 -2
- package/lib/stdlib/plugin/hull/util.js +26 -22
- package/lib/stdlib/plugin/hull/util.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.d.ts +3 -3
- package/lib/stdlib/plugin/legend/index.js +3 -3
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/plugin/menu/index.d.ts +4 -4
- package/lib/stdlib/plugin/menu/index.js +6 -6
- package/lib/stdlib/plugin/menu/index.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.d.ts +6 -2
- package/lib/stdlib/plugin/minimap/index.js +121 -14
- 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 +4 -4
- package/lib/stdlib/plugin/timebar/index.js +6 -6
- package/lib/stdlib/plugin/timebar/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
- package/lib/stdlib/plugin/toolbar/index.js +5 -5
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/plugin/tooltip/index.d.ts +5 -5
- package/lib/stdlib/plugin/tooltip/index.js +10 -11
- package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
- package/lib/stdlib/plugin/types.d.ts +2 -0
- package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
- package/lib/stdlib/plugin/watermaker/index.js +247 -0
- package/lib/stdlib/plugin/watermaker/index.js.map +1 -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/animate.d.ts +2 -2
- package/lib/types/behavior.d.ts +1 -1
- package/lib/types/combo.d.ts +7 -7
- package/lib/types/common.d.ts +5 -5
- package/lib/types/data.d.ts +6 -6
- package/lib/types/edge.d.ts +9 -9
- package/lib/types/event.d.ts +2 -1
- package/lib/types/event.js +2 -2
- package/lib/types/event.js.map +1 -1
- package/lib/types/graph.d.ts +48 -22
- package/lib/types/history.d.ts +2 -2
- package/lib/types/history.js +1 -1
- package/lib/types/history.js.map +1 -1
- package/lib/types/hook.d.ts +23 -3
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.js +3 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/item.d.ts +18 -12
- package/lib/types/item.js +1 -1
- package/lib/types/item.js.map +1 -1
- package/lib/types/layout.d.ts +6 -6
- package/lib/types/loop.d.ts +2 -2
- package/lib/types/loop.js +1 -1
- package/lib/types/loop.js.map +1 -1
- package/lib/types/node.d.ts +7 -7
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/render.d.ts +1 -1
- package/lib/types/spec.d.ts +19 -3
- package/lib/types/stdlib.d.ts +1 -1
- package/lib/types/theme.d.ts +8 -8
- package/lib/types/view.d.ts +7 -2
- package/lib/util/bbox.d.ts +16 -1
- package/lib/util/bbox.js +36 -6
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/behavior.d.ts +2 -2
- package/lib/util/behavior.js +2 -2
- package/lib/util/behavior.js.map +1 -1
- package/lib/util/data.d.ts +2 -2
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.d.ts +15 -0
- package/lib/util/dom.js +34 -0
- package/lib/util/dom.js.map +1 -0
- package/lib/util/event.d.ts +5 -3
- package/lib/util/event.js +8 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/extend.d.ts +1 -1
- package/lib/util/extend.js +0 -1
- package/lib/util/extend.js.map +1 -1
- package/lib/util/index.d.ts +7 -52
- package/lib/util/index.js +23 -23
- package/lib/util/index.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 +13 -2
- package/lib/util/layout.js +47 -1
- package/lib/util/layout.js.map +1 -1
- package/lib/util/loop.d.ts +1 -1
- package/lib/util/loop.js +4 -0
- package/lib/util/loop.js.map +1 -1
- package/lib/util/math.d.ts +1 -1
- package/lib/util/matrix.d.ts +6 -0
- package/lib/util/matrix.js +52 -0
- package/lib/util/matrix.js.map +1 -0
- package/lib/util/path.js +2 -2
- package/lib/util/path.js.map +1 -1
- package/lib/util/point.d.ts +1 -1
- package/lib/util/point.js +9 -2
- package/lib/util/point.js.map +1 -1
- package/lib/util/polyline.d.ts +2 -1
- package/lib/util/polyline.js +2 -1
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/shape.d.ts +1 -2
- package/lib/util/shape.js +16 -26
- package/lib/util/shape.js.map +1 -1
- package/lib/util/shape3d.js +15 -16
- package/lib/util/shape3d.js.map +1 -1
- package/lib/util/text.d.ts +1 -1
- package/lib/util/text.js +3 -2
- package/lib/util/text.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 +41 -50
- package/src/api-doc/graph.ts +4 -3
- package/src/api-doc/types.ts +1 -0
- package/src/constant/shape.ts +1 -1
- package/src/index.ts +5 -6
- package/src/item/combo.ts +16 -15
- package/src/item/edge.ts +135 -57
- package/src/item/item.ts +32 -19
- package/src/item/node.ts +36 -50
- package/src/runtime/controller/data.ts +140 -339
- package/src/runtime/controller/interaction.ts +10 -4
- package/src/runtime/controller/item.ts +261 -78
- package/src/runtime/controller/layout.ts +1 -5
- package/src/runtime/controller/plugin.ts +15 -4
- package/src/runtime/graph.ts +605 -103
- package/src/stdlib/behavior/activate-relations.ts +2 -2
- package/src/stdlib/behavior/brush-select.ts +14 -13
- package/src/stdlib/behavior/click-select.ts +1 -1
- package/src/stdlib/behavior/create-edge.ts +305 -0
- package/src/stdlib/behavior/drag-canvas.ts +107 -35
- package/src/stdlib/behavior/drag-combo.ts +10 -10
- package/src/stdlib/behavior/drag-node.ts +27 -18
- package/src/stdlib/behavior/index.ts +3 -0
- package/src/stdlib/behavior/lasso-select.ts +7 -5
- package/src/stdlib/behavior/scroll-canvas.ts +348 -0
- package/src/stdlib/behavior/shortcuts-call.ts +129 -0
- package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
- package/src/stdlib/behavior/zoom-canvas.ts +98 -27
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/transformV4Data.ts +2 -2
- package/src/stdlib/data/validateData.ts +16 -16
- package/src/stdlib/index.ts +28 -7
- package/src/stdlib/item/edge/base.ts +32 -41
- package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
- package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
- package/src/stdlib/item/edge/cubic.ts +1 -1
- package/src/stdlib/item/edge/loop.ts +1 -1
- package/src/stdlib/item/node/base.ts +38 -65
- package/src/stdlib/item/node/base3d.ts +1 -0
- package/src/stdlib/item/node/cube.ts +102 -0
- 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 +6 -2
- package/src/stdlib/item/node/image.ts +190 -0
- package/src/stdlib/item/node/index.ts +4 -0
- package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
- package/src/stdlib/plugin/grid/index.ts +6 -6
- 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/convexHull.ts +1 -1
- package/src/stdlib/plugin/hull/hullComponent.ts +10 -8
- package/src/stdlib/plugin/hull/util.ts +6 -2
- package/src/stdlib/plugin/index.ts +2 -0
- package/src/stdlib/plugin/legend/index.ts +6 -6
- package/src/stdlib/plugin/menu/index.ts +13 -13
- package/src/stdlib/plugin/minimap/index.ts +126 -16
- package/src/stdlib/plugin/snapline/index.ts +1297 -0
- package/src/stdlib/plugin/timebar/index.ts +4 -4
- package/src/stdlib/plugin/toolbar/index.ts +8 -8
- package/src/stdlib/plugin/tooltip/index.ts +10 -10
- package/src/stdlib/plugin/types.ts +2 -0
- package/src/stdlib/plugin/watermaker/index.ts +302 -0
- package/src/stdlib/theme/dark.ts +66 -2
- package/src/stdlib/theme/light.ts +4 -4
- package/src/types/event.ts +1 -0
- package/src/types/graph.ts +62 -25
- package/src/types/hook.ts +22 -2
- package/src/types/index.ts +2 -1
- package/src/types/item.ts +10 -0
- package/src/types/plugin.ts +1 -1
- package/src/types/spec.ts +22 -3
- package/src/types/view.ts +8 -3
- package/src/util/bbox.ts +42 -6
- package/src/util/behavior.ts +4 -4
- package/src/util/data.ts +2 -3
- package/src/util/dom.ts +33 -0
- package/src/util/event.ts +14 -1
- package/src/util/extend.ts +2 -3
- package/src/util/index.ts +7 -24
- package/src/util/item.ts +65 -28
- package/src/util/layout.ts +48 -2
- package/src/util/loop.ts +5 -1
- package/src/util/math.ts +1 -1
- package/src/util/matrix.ts +66 -0
- package/src/util/path.ts +1 -1
- package/src/util/point.ts +9 -4
- package/src/util/polyline.ts +2 -1
- package/src/util/router.ts +1 -1
- package/src/util/shape.ts +22 -26
- package/src/util/shape3d.ts +20 -20
- package/src/util/text.ts +3 -1
- package/src/util/warn.ts +20 -0
|
@@ -118,7 +118,7 @@ export class ActivateRelations extends Behavior {
|
|
|
118
118
|
edgeIds,
|
|
119
119
|
);
|
|
120
120
|
|
|
121
|
-
graph.
|
|
121
|
+
graph.historyBatch(() => {
|
|
122
122
|
/** 节点 */
|
|
123
123
|
graph.setItemState(activeNodeIds, ACTIVE_STATE, true);
|
|
124
124
|
graph.setItemState(inactiveNodeIds, ACTIVE_STATE, false);
|
|
@@ -132,7 +132,7 @@ export class ActivateRelations extends Behavior {
|
|
|
132
132
|
}
|
|
133
133
|
public clearActiveState(e: any) {
|
|
134
134
|
const { activeState: ACTIVE_STATE } = this.options;
|
|
135
|
-
this.graph.
|
|
135
|
+
this.graph.historyBatch(() => {
|
|
136
136
|
this.graph.setItemState(this.prevNodeIds, ACTIVE_STATE, false);
|
|
137
137
|
this.graph.setItemState(this.prevEdgeIds, ACTIVE_STATE, false);
|
|
138
138
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
2
|
import { ID } from '@antv/graphlib';
|
|
3
|
-
import
|
|
3
|
+
import rectSelector from '../selector/rect';
|
|
4
4
|
import { Behavior } from '../../types/behavior';
|
|
5
5
|
import { Point } from '../../types/common';
|
|
6
6
|
import { IG6GraphEvent } from '../../types/event';
|
|
@@ -125,6 +125,7 @@ export class BrushSelect extends Behavior {
|
|
|
125
125
|
pointerdown: this.onMouseDown,
|
|
126
126
|
pointermove: this.onMouseMove,
|
|
127
127
|
pointerup: this.onMouseUp,
|
|
128
|
+
'canvas:click': this.onCanvasClick,
|
|
128
129
|
};
|
|
129
130
|
};
|
|
130
131
|
|
|
@@ -140,6 +141,10 @@ export class BrushSelect extends Behavior {
|
|
|
140
141
|
return keyMap[trigger];
|
|
141
142
|
}
|
|
142
143
|
|
|
144
|
+
public onCanvasClick(event: IG6GraphEvent) {
|
|
145
|
+
this.clearStates();
|
|
146
|
+
}
|
|
147
|
+
|
|
143
148
|
public onMouseDown(event: IG6GraphEvent) {
|
|
144
149
|
if (!this.options.shouldBegin(event)) return;
|
|
145
150
|
const { itemId, itemType, canvas } = event;
|
|
@@ -151,11 +156,6 @@ export class BrushSelect extends Behavior {
|
|
|
151
156
|
y: canvas.y,
|
|
152
157
|
};
|
|
153
158
|
|
|
154
|
-
if (!this.isKeydown(event as any)) {
|
|
155
|
-
this.clearStates();
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
159
|
const { brush } = this;
|
|
160
160
|
if (!brush) {
|
|
161
161
|
this.brush = this.createBrush();
|
|
@@ -180,13 +180,12 @@ export class BrushSelect extends Behavior {
|
|
|
180
180
|
|
|
181
181
|
public onMouseUp(event: IG6GraphEvent) {
|
|
182
182
|
if (!this.mousedown) return;
|
|
183
|
-
if (!this.isKeydown(event as any)) {
|
|
184
|
-
this.clearStates();
|
|
185
|
-
}
|
|
186
183
|
|
|
187
184
|
this.removeBrush();
|
|
188
185
|
this.brush = undefined;
|
|
189
|
-
|
|
186
|
+
if (this.isKeydown(event as any)) {
|
|
187
|
+
this.selectedIds = this.selectItems(event);
|
|
188
|
+
}
|
|
190
189
|
this.dragging = false;
|
|
191
190
|
this.mousedown = false;
|
|
192
191
|
}
|
|
@@ -345,8 +344,10 @@ export class BrushSelect extends Behavior {
|
|
|
345
344
|
const { graph, options } = this;
|
|
346
345
|
const { brushStyle } = options;
|
|
347
346
|
const brush = graph.drawTransient('rect', BRUSH_SHAPE_ID, {
|
|
348
|
-
style:
|
|
349
|
-
|
|
347
|
+
style: {
|
|
348
|
+
...brushStyle,
|
|
349
|
+
pointerEvents: 'none',
|
|
350
|
+
},
|
|
350
351
|
});
|
|
351
352
|
return brush;
|
|
352
353
|
}
|
|
@@ -371,7 +372,7 @@ export class BrushSelect extends Behavior {
|
|
|
371
372
|
}
|
|
372
373
|
|
|
373
374
|
public getSelector() {
|
|
374
|
-
return
|
|
375
|
+
return rectSelector;
|
|
375
376
|
}
|
|
376
377
|
|
|
377
378
|
public getPoints(event: IG6GraphEvent) {
|
|
@@ -136,7 +136,7 @@ export class ClickSelect extends Behavior {
|
|
|
136
136
|
|
|
137
137
|
// Select/Unselect item.
|
|
138
138
|
if (this.options.shouldUpdate(event)) {
|
|
139
|
-
this.graph.
|
|
139
|
+
this.graph.historyBatch(() => {
|
|
140
140
|
if (!multiple) {
|
|
141
141
|
// Not multiple, clear all currently selected items
|
|
142
142
|
this.graph.setItemState(this.selectedIds, state, false);
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import type { IG6GraphEvent } from '../../types';
|
|
2
|
+
import { warn } from '../../util/warn';
|
|
3
|
+
import { generateEdgeID } from '../../util/item';
|
|
4
|
+
import { Behavior } from '../../types/behavior';
|
|
5
|
+
import { EdgeDisplayModelData } from '../../types/edge';
|
|
6
|
+
|
|
7
|
+
const KEYBOARD_TRIGGERS = ['shift', 'ctrl', 'control', 'alt', 'meta'] as const;
|
|
8
|
+
const EVENT_TRIGGERS = ['click', 'drag'] as const;
|
|
9
|
+
|
|
10
|
+
const VIRTUAL_EDGE_ID = 'g6-create-edge-virtual-edge';
|
|
11
|
+
const DUMMY_NODE_ID = 'g6-create-edge-dummy-node';
|
|
12
|
+
|
|
13
|
+
// type Trigger = (typeof EVENT_TRIGGERS)[number];
|
|
14
|
+
|
|
15
|
+
interface CreateEdgeOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The triggering conditions for this interaction can be either 'click' or 'drag'.
|
|
18
|
+
* Default to `click`.
|
|
19
|
+
*/
|
|
20
|
+
trigger: (typeof EVENT_TRIGGERS)[number];
|
|
21
|
+
/**
|
|
22
|
+
* The assistant secondary key on keyboard. If it is not assigned, the behavior will be triggered when trigger happens.
|
|
23
|
+
* cound be 'shift', 'ctrl', 'control', 'alt', 'meta', undefined.
|
|
24
|
+
*/
|
|
25
|
+
secondaryKey?: (typeof KEYBOARD_TRIGGERS)[number];
|
|
26
|
+
/**
|
|
27
|
+
* Config of the created edge.
|
|
28
|
+
*/
|
|
29
|
+
edgeConfig: EdgeDisplayModelData;
|
|
30
|
+
/**
|
|
31
|
+
* The event name to trigger after creating the virtual edge.
|
|
32
|
+
*/
|
|
33
|
+
createVirtualEventName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The event name to trigger after creating the actual edge.
|
|
36
|
+
*/
|
|
37
|
+
createActualEventName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The event name to trigger after canceling the behavior.
|
|
40
|
+
*/
|
|
41
|
+
cancelCreateEventName?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether allow the behavior happen on the current item.
|
|
44
|
+
*/
|
|
45
|
+
shouldBegin: (event: IG6GraphEvent) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* Whether it is allowed to end the creation of edges under the current conditions being operated.
|
|
49
|
+
*/
|
|
50
|
+
shouldEnd: (event: IG6GraphEvent) => boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const DEFAULT_OPTIONS: CreateEdgeOptions = {
|
|
54
|
+
trigger: 'click',
|
|
55
|
+
secondaryKey: undefined,
|
|
56
|
+
shouldBegin: () => true,
|
|
57
|
+
shouldEnd: () => true,
|
|
58
|
+
edgeConfig: {},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export class CreateEdge extends Behavior {
|
|
62
|
+
isKeyDown = false;
|
|
63
|
+
addingEdge = null;
|
|
64
|
+
dummyNode = null;
|
|
65
|
+
|
|
66
|
+
constructor(options: Partial<CreateEdgeOptions>) {
|
|
67
|
+
super(Object.assign({}, DEFAULT_OPTIONS, options));
|
|
68
|
+
this.validateOptions(options);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
validateOptions(options: Partial<CreateEdgeOptions>) {
|
|
72
|
+
if (options.trigger && !EVENT_TRIGGERS.includes(options.trigger)) {
|
|
73
|
+
warn({
|
|
74
|
+
optionName: `create-edge.trigger`,
|
|
75
|
+
shouldBe: EVENT_TRIGGERS,
|
|
76
|
+
now: options.trigger,
|
|
77
|
+
scope: 'behavior',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
this.options.trigger = DEFAULT_OPTIONS.trigger;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (
|
|
84
|
+
options.secondaryKey &&
|
|
85
|
+
!KEYBOARD_TRIGGERS.includes(options.secondaryKey)
|
|
86
|
+
) {
|
|
87
|
+
warn({
|
|
88
|
+
optionName: `create-edge.secondaryKey`,
|
|
89
|
+
shouldBe: KEYBOARD_TRIGGERS,
|
|
90
|
+
now: options.secondaryKey,
|
|
91
|
+
scope: 'behavior',
|
|
92
|
+
});
|
|
93
|
+
this.options.secondaryKey = DEFAULT_OPTIONS.secondaryKey;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getEvents = () => {
|
|
98
|
+
const { trigger, secondaryKey } = this.options;
|
|
99
|
+
const [CLICK_NAME] = EVENT_TRIGGERS;
|
|
100
|
+
|
|
101
|
+
const triggerEvents =
|
|
102
|
+
trigger === CLICK_NAME
|
|
103
|
+
? {
|
|
104
|
+
'node:click': this.handleCreateEdge,
|
|
105
|
+
pointermove: this.updateEndPoint,
|
|
106
|
+
'edge:click': this.cancelCreating,
|
|
107
|
+
'canvas:click': this.cancelCreating,
|
|
108
|
+
'combo:click': this.handleCreateEdge,
|
|
109
|
+
}
|
|
110
|
+
: {
|
|
111
|
+
'node:dragstart': this.handleCreateEdge,
|
|
112
|
+
'combo:dragstart': this.handleCreateEdge,
|
|
113
|
+
drag: this.updateEndPoint,
|
|
114
|
+
drop: this.onDrop,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const keyboardEvents = secondaryKey
|
|
118
|
+
? {
|
|
119
|
+
keydown: this.onKeyDown,
|
|
120
|
+
keyup: this.onKeyUp,
|
|
121
|
+
}
|
|
122
|
+
: {};
|
|
123
|
+
|
|
124
|
+
return { ...triggerEvents, ...keyboardEvents } as Record<
|
|
125
|
+
string,
|
|
126
|
+
(e: IG6GraphEvent) => void
|
|
127
|
+
>;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
handleCreateEdge = (e: IG6GraphEvent) => {
|
|
131
|
+
if (this.options.secondaryKey && !this.isKeyDown) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const { graph, options, addingEdge } = this;
|
|
136
|
+
const currentNodeId = e.itemId;
|
|
137
|
+
|
|
138
|
+
const { edgeConfig, createVirtualEventName, createActualEventName } =
|
|
139
|
+
options;
|
|
140
|
+
|
|
141
|
+
if (addingEdge) {
|
|
142
|
+
if (!this.options.shouldEnd(e)) {
|
|
143
|
+
this.cancelCreating();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// create edge end, add the actual edge to graph and remove the virtual edge and node
|
|
147
|
+
const actualEdge = graph.addData('edge', {
|
|
148
|
+
id: generateEdgeID(addingEdge.source, currentNodeId),
|
|
149
|
+
source: addingEdge.source,
|
|
150
|
+
target: currentNodeId,
|
|
151
|
+
data: {
|
|
152
|
+
...edgeConfig,
|
|
153
|
+
type:
|
|
154
|
+
currentNodeId === addingEdge.source ? 'loop-edge' : edgeConfig.type,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
if (createActualEventName) {
|
|
158
|
+
graph.emit(createActualEventName, { edge: actualEdge });
|
|
159
|
+
}
|
|
160
|
+
this.cancelCreating();
|
|
161
|
+
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!this.options.shouldBegin(e)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this.dummyNode = graph.addData('node', {
|
|
170
|
+
id: DUMMY_NODE_ID,
|
|
171
|
+
data: {
|
|
172
|
+
x: e.canvas.x,
|
|
173
|
+
y: e.canvas.y,
|
|
174
|
+
keyShape: {
|
|
175
|
+
opacity: 0,
|
|
176
|
+
interactive: false,
|
|
177
|
+
},
|
|
178
|
+
labelShape: {
|
|
179
|
+
opacity: 0,
|
|
180
|
+
},
|
|
181
|
+
anchorPoints: [[0.5, 0.5]],
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
this.addingEdge = graph.addData('edge', {
|
|
185
|
+
id: VIRTUAL_EDGE_ID,
|
|
186
|
+
source: currentNodeId,
|
|
187
|
+
target: DUMMY_NODE_ID,
|
|
188
|
+
data: {
|
|
189
|
+
...edgeConfig,
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
if (createVirtualEventName) {
|
|
193
|
+
graph.emit(createVirtualEventName, { edge: this.addingEdge });
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
onDrop = async (e: IG6GraphEvent) => {
|
|
198
|
+
const { addingEdge, options, graph } = this;
|
|
199
|
+
|
|
200
|
+
const { edgeConfig, secondaryKey, createActualEventName } = options;
|
|
201
|
+
if (secondaryKey && !this.isKeyDown) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (!addingEdge) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
210
|
+
e.canvas.x,
|
|
211
|
+
e.canvas.y,
|
|
212
|
+
);
|
|
213
|
+
const currentIds = elements
|
|
214
|
+
// @ts-ignore TODO: G type
|
|
215
|
+
.map((ele) => ele.parentNode.getAttribute?.('data-item-id'))
|
|
216
|
+
.filter((id) => id !== undefined && !DUMMY_NODE_ID !== id);
|
|
217
|
+
const dropId = currentIds.find(
|
|
218
|
+
(id) => this.graph.getComboData(id) || this.graph.getNodeData(id),
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
if (!dropId) {
|
|
222
|
+
this.cancelCreating();
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (!this.options.shouldEnd(e)) {
|
|
227
|
+
this.cancelCreating();
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const actualEdge = graph.addData('edge', {
|
|
232
|
+
id: generateEdgeID(addingEdge.source, dropId),
|
|
233
|
+
source: addingEdge.source,
|
|
234
|
+
target: dropId,
|
|
235
|
+
data: {
|
|
236
|
+
...edgeConfig,
|
|
237
|
+
type: dropId === addingEdge.source ? 'loop-edge' : edgeConfig.type,
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
if (createActualEventName) {
|
|
241
|
+
graph.emit(createActualEventName, { edge: actualEdge });
|
|
242
|
+
}
|
|
243
|
+
this.cancelCreating();
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
updateEndPoint = (e: IG6GraphEvent) => {
|
|
247
|
+
const { options, graph, addingEdge, isKeyDown } = this;
|
|
248
|
+
if (options.secondaryKey && !isKeyDown) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!addingEdge) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const sourceId = addingEdge.source,
|
|
257
|
+
targetId = addingEdge.target;
|
|
258
|
+
|
|
259
|
+
if (!graph.getItemById(sourceId)) {
|
|
260
|
+
this.addingEdge = null;
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
graph.updatePosition('node', {
|
|
265
|
+
id: targetId,
|
|
266
|
+
data: {
|
|
267
|
+
x: e.canvas.x,
|
|
268
|
+
y: e.canvas.y,
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
cancelCreating = () => {
|
|
274
|
+
if (this.addingEdge) {
|
|
275
|
+
this.graph.removeData('edge', VIRTUAL_EDGE_ID);
|
|
276
|
+
this.addingEdge = null;
|
|
277
|
+
}
|
|
278
|
+
if (this.dummyNode) {
|
|
279
|
+
this.graph.removeData('node', DUMMY_NODE_ID);
|
|
280
|
+
this.dummyNode = null;
|
|
281
|
+
}
|
|
282
|
+
if (this.options.cancelCreateEventName) {
|
|
283
|
+
this.graph.emit(this.options.cancelCreateEventName, {});
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
onKeyDown = (e: KeyboardEvent) => {
|
|
288
|
+
const code = e.key;
|
|
289
|
+
|
|
290
|
+
if (!code) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (code.toLocaleLowerCase() === this.options.secondaryKey) {
|
|
295
|
+
this.isKeyDown = true;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
onKeyUp = (e: IG6GraphEvent) => {
|
|
300
|
+
if (this.addingEdge) {
|
|
301
|
+
this.cancelCreating();
|
|
302
|
+
}
|
|
303
|
+
this.isKeyDown = false;
|
|
304
|
+
};
|
|
305
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isNumber } from '@antv/util';
|
|
2
2
|
import { Behavior } from '../../types/behavior';
|
|
3
3
|
import { Point } from '../../types/common';
|
|
4
|
+
import { ID, IG6GraphEvent } from '../../types';
|
|
4
5
|
|
|
5
6
|
const VALID_TRIGGERS = ['drag', 'directionKeys'];
|
|
7
|
+
const DRAG_DURATION = 250;
|
|
6
8
|
export interface DragCanvasOptions {
|
|
7
9
|
/**
|
|
8
10
|
* Whether enable optimize strategies, which will hide all the shapes excluding node keyShape while dragging.
|
|
@@ -53,7 +55,7 @@ export interface DragCanvasOptions {
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const DEFAULT_OPTIONS: Required<DragCanvasOptions> = {
|
|
56
|
-
enableOptimize:
|
|
58
|
+
enableOptimize: undefined,
|
|
57
59
|
dragOnItems: false,
|
|
58
60
|
trigger: 'drag',
|
|
59
61
|
direction: 'both',
|
|
@@ -73,6 +75,8 @@ export class DragCanvas extends Behavior {
|
|
|
73
75
|
private disableKeydown: boolean;
|
|
74
76
|
private hiddenEdgeIds: ID[];
|
|
75
77
|
private hiddenNodeIds: ID[];
|
|
78
|
+
private tileRequestId?: number;
|
|
79
|
+
private lastDragTriggerTime?: number;
|
|
76
80
|
|
|
77
81
|
constructor(options: Partial<DragCanvasOptions>) {
|
|
78
82
|
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
@@ -132,25 +136,47 @@ export class DragCanvas extends Behavior {
|
|
|
132
136
|
|
|
133
137
|
private hideShapes() {
|
|
134
138
|
const { graph } = this;
|
|
135
|
-
|
|
139
|
+
|
|
140
|
+
const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
|
|
141
|
+
graph.getSpecification().optimize || {};
|
|
142
|
+
const optimize =
|
|
143
|
+
this.options.enableOptimize !== undefined
|
|
144
|
+
? this.options.enableOptimize
|
|
145
|
+
: graphBehaviorOptimize;
|
|
146
|
+
const shouldOptimize = isNumber(optimize)
|
|
147
|
+
? graph.getAllNodesData().length > optimize
|
|
148
|
+
: optimize;
|
|
149
|
+
|
|
150
|
+
if (shouldOptimize) {
|
|
136
151
|
this.hiddenEdgeIds = graph
|
|
137
152
|
.getAllEdgesData()
|
|
138
153
|
.map((edge) => edge.id)
|
|
139
154
|
.filter((id) => graph.getItemVisible(id) === true);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
this.hiddenNodeIds = graph
|
|
156
|
+
.getAllNodesData()
|
|
157
|
+
.map((node) => node.id)
|
|
158
|
+
.filter((id) => graph.getItemVisible(id) === true);
|
|
159
|
+
const hiddenIds = [...this.hiddenNodeIds];
|
|
160
|
+
const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
|
|
161
|
+
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
162
|
+
hiddenIds.slice(
|
|
163
|
+
i * tileBehaviorSize,
|
|
164
|
+
i * tileBehaviorSize + tileBehaviorSize,
|
|
165
|
+
),
|
|
166
|
+
);
|
|
167
|
+
const update = () => {
|
|
168
|
+
if (!sections.length && this.tileRequestId) {
|
|
169
|
+
cancelAnimationFrame(this.tileRequestId);
|
|
170
|
+
this.tileRequestId = undefined;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const section = sections.shift();
|
|
174
|
+
graph.executeWithNoStack(() => {
|
|
175
|
+
graph.hideItem(section, false, true);
|
|
176
|
+
});
|
|
177
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
178
|
+
};
|
|
179
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
154
180
|
}
|
|
155
181
|
}
|
|
156
182
|
|
|
@@ -212,6 +238,31 @@ export class DragCanvas extends Behavior {
|
|
|
212
238
|
const { eventName, direction, secondaryKeyToDisable } = this.options;
|
|
213
239
|
// disabled key is pressing
|
|
214
240
|
if (secondaryKeyToDisable && this.disableKeydown) return;
|
|
241
|
+
|
|
242
|
+
// begin dragging
|
|
243
|
+
if (!this.dragging) {
|
|
244
|
+
this.hideShapes();
|
|
245
|
+
this.dragging = true;
|
|
246
|
+
this.graph.canvas.getConfig().disableHitTesting = true;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const { tileBehavior: graphBehaviorOptimize } =
|
|
250
|
+
this.graph.getSpecification().optimize || {};
|
|
251
|
+
|
|
252
|
+
const shouldDebounce =
|
|
253
|
+
typeof graphBehaviorOptimize === 'boolean'
|
|
254
|
+
? graphBehaviorOptimize
|
|
255
|
+
: this.graph.getAllNodesData().length < graphBehaviorOptimize;
|
|
256
|
+
|
|
257
|
+
const now = Date.now();
|
|
258
|
+
if (
|
|
259
|
+
shouldDebounce &&
|
|
260
|
+
this.lastDragTriggerTime &&
|
|
261
|
+
now - this.lastDragTriggerTime < DRAG_DURATION / 5
|
|
262
|
+
) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
215
266
|
const { graph } = this;
|
|
216
267
|
const { client } = event;
|
|
217
268
|
const diffX = client.x - this.pointerDownAt.x;
|
|
@@ -220,12 +271,6 @@ export class DragCanvas extends Behavior {
|
|
|
220
271
|
if (direction === 'y' && !diffY) return;
|
|
221
272
|
if (direction === 'both' && !diffX && !diffY) return;
|
|
222
273
|
|
|
223
|
-
// begin dragging
|
|
224
|
-
if (!this.dragging) {
|
|
225
|
-
this.hideShapes();
|
|
226
|
-
this.dragging = true;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
274
|
const { dx, dy } = this.formatDisplacement(diffX, diffY);
|
|
230
275
|
graph.translate({ dx, dy });
|
|
231
276
|
|
|
@@ -235,25 +280,52 @@ export class DragCanvas extends Behavior {
|
|
|
235
280
|
if (eventName) {
|
|
236
281
|
this.graph.emit(eventName, { translate: { dx, dy } });
|
|
237
282
|
}
|
|
283
|
+
this.lastDragTriggerTime = now;
|
|
238
284
|
}
|
|
239
285
|
|
|
240
286
|
public onPointerUp() {
|
|
241
287
|
this.pointerDownAt = undefined;
|
|
242
288
|
this.dragging = false;
|
|
289
|
+
this.graph.canvas.getConfig().disableHitTesting = false;
|
|
243
290
|
|
|
244
|
-
const { graph } = this;
|
|
245
|
-
|
|
246
|
-
graph.
|
|
247
|
-
|
|
248
|
-
|
|
291
|
+
const { graph, hiddenNodeIds, hiddenEdgeIds = [] } = this;
|
|
292
|
+
const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
|
|
293
|
+
graph.getSpecification().optimize || {};
|
|
294
|
+
const optimize =
|
|
295
|
+
this.options.enableOptimize !== undefined
|
|
296
|
+
? this.options.enableOptimize
|
|
297
|
+
: graphBehaviorOptimize;
|
|
298
|
+
const shouldOptimize = isNumber(optimize)
|
|
299
|
+
? graph.getAllNodesData().length > optimize
|
|
300
|
+
: optimize;
|
|
301
|
+
|
|
302
|
+
if (shouldOptimize) {
|
|
303
|
+
if (this.tileRequestId) {
|
|
304
|
+
cancelAnimationFrame(this.tileRequestId);
|
|
305
|
+
this.tileRequestId = undefined;
|
|
306
|
+
}
|
|
307
|
+
if (hiddenNodeIds) {
|
|
308
|
+
const hiddenIds = [...hiddenNodeIds, ...hiddenEdgeIds];
|
|
309
|
+
const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
|
|
310
|
+
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
311
|
+
hiddenIds.slice(
|
|
312
|
+
i * tileBehaviorSize,
|
|
313
|
+
i * tileBehaviorSize + tileBehaviorSize,
|
|
314
|
+
),
|
|
315
|
+
);
|
|
316
|
+
const update = () => {
|
|
317
|
+
if (!sections.length && this.tileRequestId) {
|
|
318
|
+
cancelAnimationFrame(this.tileRequestId);
|
|
319
|
+
this.tileRequestId = undefined;
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
graph.startHistoryBatch();
|
|
323
|
+
graph.showItem(sections.shift(), false);
|
|
324
|
+
graph.stopHistoryBatch();
|
|
325
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
326
|
+
};
|
|
327
|
+
this.tileRequestId = requestAnimationFrame(update);
|
|
249
328
|
}
|
|
250
|
-
// if (this.hiddenNodeIds) {
|
|
251
|
-
// this.hiddenNodeIds.forEach((id) => {
|
|
252
|
-
// this.graph.drawTransient('node', id, { action: 'remove' });
|
|
253
|
-
// });
|
|
254
|
-
// graph.showItem(this.hiddenNodeIds, true);
|
|
255
|
-
// }
|
|
256
|
-
graph.stopBatch();
|
|
257
329
|
}
|
|
258
330
|
}
|
|
259
331
|
|
|
@@ -250,7 +250,7 @@ export class DragCombo extends Behavior {
|
|
|
250
250
|
selectedComboIds,
|
|
251
251
|
this.hiddenComboTreeRoots,
|
|
252
252
|
);
|
|
253
|
-
this.graph.
|
|
253
|
+
this.graph.executeWithNoStack(() => {
|
|
254
254
|
this.graph.hideItem(
|
|
255
255
|
this.hiddenEdges.map((edge) => edge.id),
|
|
256
256
|
true,
|
|
@@ -280,7 +280,7 @@ export class DragCombo extends Behavior {
|
|
|
280
280
|
});
|
|
281
281
|
|
|
282
282
|
// Hide original edges and nodes. They will be restored when pointerup.
|
|
283
|
-
this.graph.
|
|
283
|
+
this.graph.executeWithNoStack(() => {
|
|
284
284
|
this.graph.hideItem(selectedComboIds, true);
|
|
285
285
|
this.graph.hideItem(
|
|
286
286
|
this.hiddenEdges.map((edge) => edge.id),
|
|
@@ -429,7 +429,7 @@ export class DragCombo extends Behavior {
|
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
public restoreHiddenItems(positions?: Position[]) {
|
|
432
|
-
this.graph.
|
|
432
|
+
this.graph.pauseStack();
|
|
433
433
|
if (this.hiddenEdges.length) {
|
|
434
434
|
this.graph.showItem(
|
|
435
435
|
this.hiddenEdges.map((edge) => edge.id),
|
|
@@ -452,7 +452,7 @@ export class DragCombo extends Behavior {
|
|
|
452
452
|
true,
|
|
453
453
|
);
|
|
454
454
|
}
|
|
455
|
-
this.graph.
|
|
455
|
+
this.graph.resumeStack();
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
public onPointerUp(event: IG6GraphEvent) {
|
|
@@ -526,8 +526,8 @@ export class DragCombo extends Behavior {
|
|
|
526
526
|
this.originPositions = [];
|
|
527
527
|
}
|
|
528
528
|
|
|
529
|
-
public onDropNode(event: IG6GraphEvent) {
|
|
530
|
-
const elements = this.graph.canvas.document.
|
|
529
|
+
public async onDropNode(event: IG6GraphEvent) {
|
|
530
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
531
531
|
event.canvas.x,
|
|
532
532
|
event.canvas.y,
|
|
533
533
|
);
|
|
@@ -561,7 +561,7 @@ export class DragCombo extends Behavior {
|
|
|
561
561
|
|
|
562
562
|
public onDropCombo(event: IG6GraphEvent) {
|
|
563
563
|
const newParentId = event.itemId;
|
|
564
|
-
this.graph.
|
|
564
|
+
this.graph.startHistoryBatch();
|
|
565
565
|
this.originPositions.forEach(({ id }) => {
|
|
566
566
|
const model = this.graph.getComboData(id);
|
|
567
567
|
if (!model || model.id === newParentId) return;
|
|
@@ -570,12 +570,12 @@ export class DragCombo extends Behavior {
|
|
|
570
570
|
// event.stopPropagation();
|
|
571
571
|
this.graph.updateData('combo', { id, data: { parentId: newParentId } });
|
|
572
572
|
});
|
|
573
|
-
this.graph.
|
|
573
|
+
this.graph.stopHistoryBatch();
|
|
574
574
|
this.onPointerUp(event);
|
|
575
575
|
}
|
|
576
576
|
|
|
577
577
|
public onDropCanvas(event: IG6GraphEvent) {
|
|
578
|
-
this.graph.
|
|
578
|
+
this.graph.startHistoryBatch();
|
|
579
579
|
this.originPositions.forEach(({ id }) => {
|
|
580
580
|
const model = this.graph.getComboData(id);
|
|
581
581
|
if (!model) return;
|
|
@@ -583,7 +583,7 @@ export class DragCombo extends Behavior {
|
|
|
583
583
|
if (!parentId) return;
|
|
584
584
|
this.graph.updateData('combo', { id, data: { parentId: undefined } });
|
|
585
585
|
});
|
|
586
|
-
this.graph.
|
|
586
|
+
this.graph.stopHistoryBatch();
|
|
587
587
|
this.onPointerUp(event);
|
|
588
588
|
}
|
|
589
589
|
}
|