@antv/g6 4.8.14 → 5.0.0-alpha.2
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 +19 -3
- package/esm/constant/index.d.ts +1 -0
- package/esm/constant/index.js +2 -0
- package/esm/constant/index.js.map +1 -0
- package/esm/constant/shape.d.ts +27 -0
- package/esm/constant/shape.js +26 -0
- package/esm/constant/shape.js.map +1 -0
- package/esm/index.d.ts +124 -0
- package/esm/index.js +11 -0
- package/esm/index.js.map +1 -0
- package/esm/item/combo.d.ts +4 -0
- package/esm/item/combo.js +4 -0
- package/esm/item/combo.js.map +1 -0
- package/esm/item/edge.d.ts +54 -0
- package/esm/item/edge.js +113 -0
- package/esm/item/edge.js.map +1 -0
- package/esm/item/item.d.ts +189 -0
- package/esm/item/item.js +636 -0
- package/esm/item/item.js.map +1 -0
- package/esm/item/node.d.ts +54 -0
- package/esm/item/node.js +170 -0
- package/esm/item/node.js.map +1 -0
- package/esm/runtime/controller/data.d.ts +65 -0
- package/esm/runtime/controller/data.js +489 -0
- package/esm/runtime/controller/data.js.map +1 -0
- package/esm/runtime/controller/extension.d.ts +9 -0
- package/esm/runtime/controller/extension.js +11 -0
- package/esm/runtime/controller/extension.js.map +1 -0
- package/esm/runtime/controller/index.d.ts +7 -0
- package/esm/runtime/controller/index.js +8 -0
- package/esm/runtime/controller/index.js.map +1 -0
- package/esm/runtime/controller/interaction.d.ts +51 -0
- package/esm/runtime/controller/interaction.js +259 -0
- package/esm/runtime/controller/interaction.js.map +1 -0
- package/esm/runtime/controller/item.d.ts +101 -0
- package/esm/runtime/controller/item.js +537 -0
- package/esm/runtime/controller/item.js.map +1 -0
- package/esm/runtime/controller/layout.d.ts +30 -0
- package/esm/runtime/controller/layout.js +204 -0
- package/esm/runtime/controller/layout.js.map +1 -0
- package/esm/runtime/controller/plugin.d.ts +34 -0
- package/esm/runtime/controller/plugin.js +140 -0
- package/esm/runtime/controller/plugin.js.map +1 -0
- package/esm/runtime/controller/theme.d.ts +29 -0
- package/esm/runtime/controller/theme.js +54 -0
- package/esm/runtime/controller/theme.js.map +1 -0
- package/esm/runtime/controller/viewport.d.ts +11 -0
- package/esm/runtime/controller/viewport.js +102 -0
- package/esm/runtime/controller/viewport.js.map +1 -0
- package/esm/runtime/graph.d.ts +462 -0
- package/esm/runtime/graph.js +1077 -0
- package/esm/runtime/graph.js.map +1 -0
- package/esm/runtime/hooks.d.ts +33 -0
- package/esm/runtime/hooks.js +74 -0
- package/esm/runtime/hooks.js.map +1 -0
- package/esm/stdlib/behavior/activate-relations.d.ts +62 -0
- package/esm/stdlib/behavior/activate-relations.js +81 -0
- package/esm/stdlib/behavior/activate-relations.js.map +1 -0
- package/esm/stdlib/behavior/brush-select.d.ts +110 -0
- package/esm/stdlib/behavior/brush-select.js +268 -0
- package/esm/stdlib/behavior/brush-select.js.map +1 -0
- package/esm/stdlib/behavior/click-select.d.ts +71 -0
- package/esm/stdlib/behavior/click-select.js +143 -0
- package/esm/stdlib/behavior/click-select.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +82 -0
- package/esm/stdlib/behavior/drag-canvas.js +246 -0
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -0
- package/esm/stdlib/behavior/drag-node.d.ts +80 -0
- package/esm/stdlib/behavior/drag-node.js +250 -0
- package/esm/stdlib/behavior/drag-node.js.map +1 -0
- package/esm/stdlib/behavior/hover-activate.d.ts +41 -0
- package/esm/stdlib/behavior/hover-activate.js +63 -0
- package/esm/stdlib/behavior/hover-activate.js.map +1 -0
- package/esm/stdlib/behavior/lasso-select.d.ts +27 -0
- package/esm/stdlib/behavior/lasso-select.js +79 -0
- package/esm/stdlib/behavior/lasso-select.js.map +1 -0
- package/esm/stdlib/behavior/orbit-canvas-3d.d.ts +37 -0
- package/esm/stdlib/behavior/orbit-canvas-3d.js +62 -0
- package/esm/stdlib/behavior/orbit-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/rotate-canvas-3d.d.ts +61 -0
- package/esm/stdlib/behavior/rotate-canvas-3d.js +123 -0
- package/esm/stdlib/behavior/rotate-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/track-canvas-3d.d.ts +37 -0
- package/esm/stdlib/behavior/track-canvas-3d.js +62 -0
- package/esm/stdlib/behavior/track-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.d.ts +51 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.js +74 -0
- package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas.d.ts +61 -0
- package/esm/stdlib/behavior/zoom-canvas.js +160 -0
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -0
- package/esm/stdlib/data/comboFromNode.d.ts +9 -0
- package/esm/stdlib/data/comboFromNode.js +28 -0
- package/esm/stdlib/data/comboFromNode.js.map +1 -0
- package/esm/stdlib/index.d.ts +80 -0
- package/esm/stdlib/index.js +82 -0
- package/esm/stdlib/index.js.map +1 -0
- package/esm/stdlib/item/edge/base.d.ts +111 -0
- package/esm/stdlib/item/edge/base.js +341 -0
- package/esm/stdlib/item/edge/base.js.map +1 -0
- package/esm/stdlib/item/edge/index.d.ts +1 -0
- package/esm/stdlib/item/edge/index.js +2 -0
- package/esm/stdlib/item/edge/index.js.map +1 -0
- package/esm/stdlib/item/edge/line.d.ts +33 -0
- package/esm/stdlib/item/edge/line.js +45 -0
- package/esm/stdlib/item/edge/line.js.map +1 -0
- package/esm/stdlib/item/node/base.d.ts +137 -0
- package/esm/stdlib/item/node/base.js +414 -0
- package/esm/stdlib/item/node/base.js.map +1 -0
- package/esm/stdlib/item/node/base3d.d.ts +72 -0
- package/esm/stdlib/item/node/base3d.js +113 -0
- package/esm/stdlib/item/node/base3d.js.map +1 -0
- package/esm/stdlib/item/node/circle.d.ts +30 -0
- package/esm/stdlib/item/node/circle.js +56 -0
- package/esm/stdlib/item/node/circle.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +2 -0
- package/esm/stdlib/item/node/index.js +3 -0
- package/esm/stdlib/item/node/index.js.map +1 -0
- package/esm/stdlib/item/node/sphere.d.ts +33 -0
- package/esm/stdlib/item/node/sphere.js +52 -0
- package/esm/stdlib/item/node/sphere.js.map +1 -0
- package/esm/stdlib/plugin/legend/index.d.ts +121 -0
- package/esm/stdlib/plugin/legend/index.js +587 -0
- package/esm/stdlib/plugin/legend/index.js.map +1 -0
- package/esm/stdlib/plugin/minimap/index.d.ts +106 -0
- package/esm/stdlib/plugin/minimap/index.js +578 -0
- package/esm/stdlib/plugin/minimap/index.js.map +1 -0
- package/esm/stdlib/selector/lasso.d.ts +15 -0
- package/esm/stdlib/selector/lasso.js +61 -0
- package/esm/stdlib/selector/lasso.js.map +1 -0
- package/esm/stdlib/selector/rect.d.ts +16 -0
- package/esm/stdlib/selector/rect.js +54 -0
- package/esm/stdlib/selector/rect.js.map +1 -0
- package/esm/stdlib/theme/dark.d.ts +3 -0
- package/esm/stdlib/theme/dark.js +279 -0
- package/esm/stdlib/theme/dark.js.map +1 -0
- package/esm/stdlib/theme/light.d.ts +3 -0
- package/esm/stdlib/theme/light.js +274 -0
- package/esm/stdlib/theme/light.js.map +1 -0
- package/esm/stdlib/themeSolver/base.d.ts +15 -0
- package/esm/stdlib/themeSolver/base.js +11 -0
- package/esm/stdlib/themeSolver/base.js.map +1 -0
- package/esm/stdlib/themeSolver/spec.d.ts +37 -0
- package/esm/stdlib/themeSolver/spec.js +66 -0
- package/esm/stdlib/themeSolver/spec.js.map +1 -0
- package/esm/stdlib/themeSolver/subject.d.ts +43 -0
- package/esm/stdlib/themeSolver/subject.js +396 -0
- package/esm/stdlib/themeSolver/subject.js.map +1 -0
- package/esm/types/animate.d.ts +59 -0
- package/esm/types/animate.js +2 -0
- package/esm/types/animate.js.map +1 -0
- package/esm/types/behavior.d.ts +45 -0
- package/esm/types/behavior.js +14 -0
- package/esm/types/behavior.js.map +1 -0
- package/esm/types/combo.d.ts +87 -0
- package/esm/types/combo.js +2 -0
- package/esm/types/combo.js.map +1 -0
- package/esm/types/common.d.ts +6 -0
- package/esm/types/common.js +2 -0
- package/esm/types/common.js.map +1 -0
- package/esm/types/data.d.ts +21 -0
- package/esm/types/data.js +2 -0
- package/esm/types/data.js.map +1 -0
- package/esm/types/edge.d.ts +100 -0
- package/esm/types/edge.js +2 -0
- package/esm/types/edge.js.map +1 -0
- package/esm/types/event.d.ts +30 -0
- package/esm/types/event.js +31 -0
- package/esm/types/event.js.map +1 -0
- package/esm/types/graph.d.ts +445 -0
- package/esm/types/graph.js +2 -0
- package/esm/types/graph.js.map +1 -0
- package/esm/types/hook.d.ts +97 -0
- package/esm/types/hook.js +2 -0
- package/esm/types/hook.js.map +1 -0
- package/esm/types/index.d.ts +10 -0
- package/esm/types/index.js +2 -0
- package/esm/types/index.js.map +1 -0
- package/esm/types/item.d.ts +229 -0
- package/esm/types/item.js +16 -0
- package/esm/types/item.js.map +1 -0
- package/esm/types/layout.d.ts +69 -0
- package/esm/types/layout.js +20 -0
- package/esm/types/layout.js.map +1 -0
- package/esm/types/node.d.ts +134 -0
- package/esm/types/node.js +2 -0
- package/esm/types/node.js.map +1 -0
- package/esm/types/plugin.d.ts +40 -0
- package/esm/types/plugin.js +53 -0
- package/esm/types/plugin.js.map +1 -0
- package/esm/types/render.d.ts +1 -0
- package/esm/types/render.js +2 -0
- package/esm/types/render.js.map +1 -0
- package/esm/types/spec.d.ts +65 -0
- package/esm/types/spec.js +2 -0
- package/esm/types/spec.js.map +1 -0
- package/esm/types/stdlib.d.ts +13 -0
- package/esm/types/stdlib.js +2 -0
- package/esm/types/stdlib.js.map +1 -0
- package/esm/types/theme.d.ts +102 -0
- package/esm/types/theme.js +15 -0
- package/esm/types/theme.js.map +1 -0
- package/esm/types/view.d.ts +23 -0
- package/esm/types/view.js +2 -0
- package/esm/types/view.js.map +1 -0
- package/esm/util/animate.d.ts +101 -0
- package/esm/util/animate.js +350 -0
- package/esm/util/animate.js.map +1 -0
- package/esm/util/array.d.ts +20 -0
- package/esm/util/array.js +60 -0
- package/esm/util/array.js.map +1 -0
- package/esm/util/canvas.d.ts +20 -0
- package/esm/util/canvas.js +81 -0
- package/esm/util/canvas.js.map +1 -0
- package/esm/util/event.d.ts +12 -0
- package/esm/util/event.js +26 -0
- package/esm/util/event.js.map +1 -0
- package/esm/util/extend.d.ts +21 -0
- package/esm/util/extend.js +22 -0
- package/esm/util/extend.js.map +1 -0
- package/esm/util/extension.d.ts +10 -0
- package/esm/util/extension.js +24 -0
- package/esm/util/extension.js.map +1 -0
- package/esm/util/index.d.ts +14 -0
- package/esm/util/index.js +5 -0
- package/esm/util/index.js.map +1 -0
- package/esm/util/item.d.ts +14 -0
- package/esm/util/item.js +42 -0
- package/esm/util/item.js.map +1 -0
- package/esm/util/mapper.d.ts +17 -0
- package/esm/util/mapper.js +60 -0
- package/esm/util/mapper.js.map +1 -0
- package/esm/util/math.d.ts +8 -0
- package/esm/util/math.js +9 -0
- package/esm/util/math.js.map +1 -0
- package/esm/util/point.d.ts +61 -0
- package/esm/util/point.js +160 -0
- package/esm/util/point.js.map +1 -0
- package/esm/util/shape.d.ts +105 -0
- package/esm/util/shape.js +504 -0
- package/esm/util/shape.js.map +1 -0
- package/esm/util/shape3d.d.ts +23 -0
- package/esm/util/shape3d.js +147 -0
- package/esm/util/shape3d.js.map +1 -0
- package/esm/util/text.d.ts +18 -0
- package/esm/util/text.js +36 -0
- package/esm/util/text.js.map +1 -0
- package/esm/util/type.d.ts +2 -0
- package/esm/util/type.js +2 -0
- package/esm/util/type.js.map +1 -0
- package/esm/util/zoom.d.ts +17 -0
- package/esm/util/zoom.js +36 -0
- package/esm/util/zoom.js.map +1 -0
- package/lib/constant/index.d.ts +1 -0
- package/lib/constant/index.js +18 -0
- package/lib/constant/index.js.map +1 -0
- package/lib/constant/shape.d.ts +27 -0
- package/lib/constant/shape.js +29 -0
- package/lib/constant/shape.js.map +1 -0
- package/lib/index.d.ts +124 -4
- package/lib/index.js +30 -27
- package/lib/index.js.map +1 -0
- package/lib/item/combo.d.ts +4 -0
- package/lib/item/combo.js +10 -0
- package/lib/item/combo.js.map +1 -0
- package/lib/item/edge.d.ts +54 -0
- package/lib/item/edge.js +119 -0
- package/lib/item/edge.js.map +1 -0
- package/lib/item/item.d.ts +189 -0
- package/lib/item/item.js +639 -0
- package/lib/item/item.js.map +1 -0
- package/lib/item/node.d.ts +54 -0
- package/lib/item/node.js +176 -0
- package/lib/item/node.js.map +1 -0
- package/lib/runtime/controller/data.d.ts +65 -0
- package/lib/runtime/controller/data.js +493 -0
- package/lib/runtime/controller/data.js.map +1 -0
- package/lib/runtime/controller/extension.d.ts +9 -0
- package/lib/runtime/controller/extension.js +15 -0
- package/lib/runtime/controller/extension.js.map +1 -0
- package/lib/runtime/controller/index.d.ts +7 -0
- package/lib/runtime/controller/index.js +24 -0
- package/lib/runtime/controller/index.js.map +1 -0
- package/lib/runtime/controller/interaction.d.ts +51 -0
- package/lib/runtime/controller/interaction.js +263 -0
- package/lib/runtime/controller/interaction.js.map +1 -0
- package/lib/runtime/controller/item.d.ts +101 -0
- package/lib/runtime/controller/item.js +544 -0
- package/lib/runtime/controller/item.js.map +1 -0
- package/lib/runtime/controller/layout.d.ts +30 -0
- package/lib/runtime/controller/layout.js +208 -0
- package/lib/runtime/controller/layout.js.map +1 -0
- package/lib/runtime/controller/plugin.d.ts +34 -0
- package/lib/runtime/controller/plugin.js +147 -0
- package/lib/runtime/controller/plugin.js.map +1 -0
- package/lib/runtime/controller/theme.d.ts +29 -0
- package/lib/runtime/controller/theme.js +61 -0
- package/lib/runtime/controller/theme.js.map +1 -0
- package/lib/runtime/controller/viewport.d.ts +11 -0
- package/lib/runtime/controller/viewport.js +106 -0
- package/lib/runtime/controller/viewport.js.map +1 -0
- package/lib/runtime/graph.d.ts +462 -0
- package/lib/runtime/graph.js +1083 -0
- package/lib/runtime/graph.js.map +1 -0
- package/lib/runtime/hooks.d.ts +33 -0
- package/lib/runtime/hooks.js +77 -0
- package/lib/runtime/hooks.js.map +1 -0
- package/lib/stdlib/behavior/activate-relations.d.ts +62 -0
- package/lib/stdlib/behavior/activate-relations.js +84 -0
- package/lib/stdlib/behavior/activate-relations.js.map +1 -0
- package/lib/stdlib/behavior/brush-select.d.ts +110 -0
- package/lib/stdlib/behavior/brush-select.js +271 -0
- package/lib/stdlib/behavior/brush-select.js.map +1 -0
- package/lib/stdlib/behavior/click-select.d.ts +71 -0
- package/lib/stdlib/behavior/click-select.js +146 -0
- package/lib/stdlib/behavior/click-select.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +82 -0
- package/lib/stdlib/behavior/drag-canvas.js +249 -0
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -0
- package/lib/stdlib/behavior/drag-node.d.ts +80 -0
- package/lib/stdlib/behavior/drag-node.js +253 -0
- package/lib/stdlib/behavior/drag-node.js.map +1 -0
- package/lib/stdlib/behavior/hover-activate.d.ts +41 -0
- package/lib/stdlib/behavior/hover-activate.js +67 -0
- package/lib/stdlib/behavior/hover-activate.js.map +1 -0
- package/lib/stdlib/behavior/lasso-select.d.ts +27 -0
- package/lib/stdlib/behavior/lasso-select.js +85 -0
- package/lib/stdlib/behavior/lasso-select.js.map +1 -0
- package/lib/stdlib/behavior/orbit-canvas-3d.d.ts +37 -0
- package/lib/stdlib/behavior/orbit-canvas-3d.js +68 -0
- package/lib/stdlib/behavior/orbit-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/rotate-canvas-3d.d.ts +61 -0
- package/lib/stdlib/behavior/rotate-canvas-3d.js +126 -0
- package/lib/stdlib/behavior/rotate-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/track-canvas-3d.d.ts +37 -0
- package/lib/stdlib/behavior/track-canvas-3d.js +68 -0
- package/lib/stdlib/behavior/track-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.d.ts +51 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.js +77 -0
- package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas.d.ts +61 -0
- package/lib/stdlib/behavior/zoom-canvas.js +163 -0
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -0
- package/lib/stdlib/data/comboFromNode.d.ts +9 -0
- package/lib/stdlib/data/comboFromNode.js +32 -0
- package/lib/stdlib/data/comboFromNode.js.map +1 -0
- package/lib/stdlib/index.d.ts +80 -0
- package/lib/stdlib/index.js +90 -0
- package/lib/stdlib/index.js.map +1 -0
- package/lib/stdlib/item/edge/base.d.ts +111 -0
- package/lib/stdlib/item/edge/base.js +345 -0
- package/lib/stdlib/item/edge/base.js.map +1 -0
- package/lib/stdlib/item/edge/index.d.ts +1 -0
- package/lib/stdlib/item/edge/index.js +18 -0
- package/lib/stdlib/item/edge/index.js.map +1 -0
- package/lib/stdlib/item/edge/line.d.ts +33 -0
- package/lib/stdlib/item/edge/line.js +49 -0
- package/lib/stdlib/item/edge/line.js.map +1 -0
- package/lib/stdlib/item/node/base.d.ts +137 -0
- package/lib/stdlib/item/node/base.js +418 -0
- package/lib/stdlib/item/node/base.js.map +1 -0
- package/lib/stdlib/item/node/base3d.d.ts +72 -0
- package/lib/stdlib/item/node/base3d.js +117 -0
- package/lib/stdlib/item/node/base3d.js.map +1 -0
- package/lib/stdlib/item/node/circle.d.ts +30 -0
- package/lib/stdlib/item/node/circle.js +60 -0
- package/lib/stdlib/item/node/circle.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +2 -0
- package/lib/stdlib/item/node/index.js +19 -0
- package/lib/stdlib/item/node/index.js.map +1 -0
- package/lib/stdlib/item/node/sphere.d.ts +33 -0
- package/lib/stdlib/item/node/sphere.js +56 -0
- package/lib/stdlib/item/node/sphere.js.map +1 -0
- package/lib/stdlib/plugin/legend/index.d.ts +121 -0
- package/lib/stdlib/plugin/legend/index.js +590 -0
- package/lib/stdlib/plugin/legend/index.js.map +1 -0
- package/lib/stdlib/plugin/minimap/index.d.ts +106 -0
- package/lib/stdlib/plugin/minimap/index.js +581 -0
- package/lib/stdlib/plugin/minimap/index.js.map +1 -0
- package/lib/stdlib/selector/lasso.d.ts +15 -0
- package/lib/stdlib/selector/lasso.js +63 -0
- package/lib/stdlib/selector/lasso.js.map +1 -0
- package/lib/stdlib/selector/rect.d.ts +16 -0
- package/lib/stdlib/selector/rect.js +56 -0
- package/lib/stdlib/selector/rect.js.map +1 -0
- package/lib/stdlib/theme/dark.d.ts +3 -0
- package/lib/stdlib/theme/dark.js +281 -0
- package/lib/stdlib/theme/dark.js.map +1 -0
- package/lib/stdlib/theme/light.d.ts +3 -0
- package/lib/stdlib/theme/light.js +276 -0
- package/lib/stdlib/theme/light.js.map +1 -0
- package/lib/stdlib/themeSolver/base.d.ts +15 -0
- package/lib/stdlib/themeSolver/base.js +14 -0
- package/lib/stdlib/themeSolver/base.js.map +1 -0
- package/lib/stdlib/themeSolver/spec.d.ts +37 -0
- package/lib/stdlib/themeSolver/spec.js +72 -0
- package/lib/stdlib/themeSolver/spec.js.map +1 -0
- package/lib/stdlib/themeSolver/subject.d.ts +43 -0
- package/lib/stdlib/themeSolver/subject.js +404 -0
- package/lib/stdlib/themeSolver/subject.js.map +1 -0
- package/lib/types/animate.d.ts +59 -0
- package/lib/types/animate.js +3 -0
- package/lib/types/animate.js.map +1 -0
- package/lib/types/behavior.d.ts +45 -0
- package/lib/types/behavior.js +18 -0
- package/lib/types/behavior.js.map +1 -0
- package/lib/types/combo.d.ts +87 -0
- package/lib/types/combo.js +3 -0
- package/lib/types/combo.js.map +1 -0
- package/lib/types/common.d.ts +6 -0
- package/lib/types/common.js +3 -0
- package/lib/types/common.js.map +1 -0
- package/lib/types/data.d.ts +21 -0
- package/lib/types/data.js +3 -0
- package/lib/types/data.js.map +1 -0
- package/lib/types/edge.d.ts +100 -0
- package/lib/types/edge.js +3 -0
- package/lib/types/edge.js.map +1 -0
- package/lib/types/event.d.ts +30 -0
- package/lib/types/event.js +34 -0
- package/lib/types/event.js.map +1 -0
- package/lib/types/graph.d.ts +445 -0
- package/lib/types/graph.js +3 -0
- package/lib/types/graph.js.map +1 -0
- package/lib/types/hook.d.ts +97 -0
- package/lib/types/hook.js +3 -0
- package/lib/types/hook.js.map +1 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.js +7 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/item.d.ts +229 -0
- package/lib/types/item.js +19 -0
- package/lib/types/item.js.map +1 -0
- package/lib/types/layout.d.ts +69 -0
- package/lib/types/layout.js +25 -0
- package/lib/types/layout.js.map +1 -0
- package/lib/types/node.d.ts +134 -0
- package/lib/types/node.js +3 -0
- package/lib/types/node.js.map +1 -0
- package/lib/types/plugin.d.ts +40 -0
- package/lib/types/plugin.js +57 -0
- package/lib/types/plugin.js.map +1 -0
- package/lib/types/render.d.ts +1 -0
- package/lib/types/render.js +3 -0
- package/lib/types/render.js.map +1 -0
- package/lib/types/spec.d.ts +65 -0
- package/lib/types/spec.js +3 -0
- package/lib/types/spec.js.map +1 -0
- package/lib/types/stdlib.d.ts +13 -0
- package/lib/types/stdlib.js +3 -0
- package/lib/types/stdlib.js.map +1 -0
- package/lib/types/theme.d.ts +102 -0
- package/lib/types/theme.js +19 -0
- package/lib/types/theme.js.map +1 -0
- package/lib/types/view.d.ts +23 -0
- package/lib/types/view.js +3 -0
- package/lib/types/view.js.map +1 -0
- package/lib/util/animate.d.ts +101 -0
- package/lib/util/animate.js +358 -0
- package/lib/util/animate.js.map +1 -0
- package/lib/util/array.d.ts +20 -0
- package/lib/util/array.js +68 -0
- package/lib/util/array.js.map +1 -0
- package/lib/util/canvas.d.ts +20 -0
- package/lib/util/canvas.js +86 -0
- package/lib/util/canvas.js.map +1 -0
- package/lib/util/event.d.ts +12 -0
- package/lib/util/event.js +30 -0
- package/lib/util/event.js.map +1 -0
- package/lib/util/extend.d.ts +21 -0
- package/lib/util/extend.js +29 -0
- package/lib/util/extend.js.map +1 -0
- package/lib/util/extension.d.ts +10 -0
- package/lib/util/extension.js +29 -0
- package/lib/util/extension.js.map +1 -0
- package/lib/util/index.d.ts +14 -0
- package/lib/util/index.js +7 -0
- package/lib/util/index.js.map +1 -0
- package/lib/util/item.d.ts +14 -0
- package/lib/util/item.js +47 -0
- package/lib/util/item.js.map +1 -0
- package/lib/util/mapper.d.ts +17 -0
- package/lib/util/mapper.js +63 -0
- package/lib/util/mapper.js.map +1 -0
- package/lib/util/math.d.ts +8 -0
- package/lib/util/math.js +13 -0
- package/lib/util/math.js.map +1 -0
- package/lib/util/point.d.ts +61 -0
- package/lib/util/point.js +169 -0
- package/lib/util/point.js.map +1 -0
- package/lib/util/shape.d.ts +105 -0
- package/lib/util/shape.js +519 -0
- package/lib/util/shape.js.map +1 -0
- package/lib/util/shape3d.d.ts +23 -0
- package/lib/util/shape3d.js +153 -0
- package/lib/util/shape3d.js.map +1 -0
- package/lib/util/text.d.ts +18 -0
- package/lib/util/text.js +41 -0
- package/lib/util/text.js.map +1 -0
- package/lib/util/type.d.ts +2 -0
- package/lib/util/type.js +6 -0
- package/lib/util/type.js.map +1 -0
- package/lib/util/zoom.d.ts +17 -0
- package/lib/util/zoom.js +41 -0
- package/lib/util/zoom.js.map +1 -0
- package/package.json +82 -50
- package/src/constant/index.ts +1 -0
- package/src/constant/shape.ts +33 -0
- package/src/index.ts +13 -0
- package/src/item/combo.ts +5 -0
- package/src/item/edge.ts +177 -0
- package/src/item/item.ts +812 -0
- package/src/item/node.ts +275 -0
- package/src/runtime/controller/data.ts +575 -0
- package/src/runtime/controller/extension.ts +14 -0
- package/src/runtime/controller/index.ts +7 -0
- package/src/runtime/controller/interaction.ts +343 -0
- package/src/runtime/controller/item.ts +780 -0
- package/src/runtime/controller/layout.ts +251 -0
- package/src/runtime/controller/plugin.ts +171 -0
- package/src/runtime/controller/theme.ts +69 -0
- package/src/runtime/controller/viewport.ts +131 -0
- package/src/runtime/graph.ts +1439 -0
- package/src/runtime/hooks.ts +64 -0
- package/src/stdlib/behavior/activate-relations.ts +139 -0
- package/src/stdlib/behavior/brush-select.ts +386 -0
- package/src/stdlib/behavior/click-select.ts +201 -0
- package/src/stdlib/behavior/drag-canvas.ts +333 -0
- package/src/stdlib/behavior/drag-node.ts +402 -0
- package/src/stdlib/behavior/hover-activate.ts +106 -0
- package/src/stdlib/behavior/lasso-select.ts +94 -0
- package/src/stdlib/behavior/orbit-canvas-3d.ts +104 -0
- package/src/stdlib/behavior/rotate-canvas-3d.ts +172 -0
- package/src/stdlib/behavior/track-canvas-3d.ts +104 -0
- package/src/stdlib/behavior/zoom-canvas-3d.ts +127 -0
- package/src/stdlib/behavior/zoom-canvas.ts +244 -0
- package/src/stdlib/data/comboFromNode.ts +28 -0
- package/src/stdlib/index.ts +87 -0
- package/src/stdlib/item/edge/base.ts +571 -0
- package/src/stdlib/item/edge/index.ts +1 -0
- package/src/stdlib/item/edge/line.ts +98 -0
- package/src/stdlib/item/node/base.ts +726 -0
- package/src/stdlib/item/node/base3d.ts +192 -0
- package/src/stdlib/item/node/circle.ts +113 -0
- package/src/stdlib/item/node/index.ts +2 -0
- package/src/stdlib/item/node/sphere.ts +99 -0
- package/src/stdlib/plugin/legend/index.ts +733 -0
- package/src/stdlib/plugin/minimap/index.ts +689 -0
- package/src/stdlib/selector/lasso.ts +75 -0
- package/src/stdlib/selector/rect.ts +78 -0
- package/src/stdlib/theme/dark.ts +340 -0
- package/src/stdlib/theme/light.ts +333 -0
- package/src/stdlib/themeSolver/base.ts +22 -0
- package/src/stdlib/themeSolver/spec.ts +110 -0
- package/src/stdlib/themeSolver/subject.ts +502 -0
- package/src/types/animate.ts +71 -0
- package/src/types/behavior.ts +49 -0
- package/src/types/combo.ts +120 -0
- package/src/types/common.ts +7 -0
- package/src/types/data.ts +35 -0
- package/src/types/edge.ts +119 -0
- package/src/types/event.ts +47 -0
- package/src/types/graph.ts +573 -0
- package/src/types/hook.ts +98 -0
- package/src/types/index.ts +29 -0
- package/src/types/item.ts +324 -0
- package/src/types/layout.ts +138 -0
- package/src/types/node.ts +162 -0
- package/src/types/plugin.ts +77 -0
- package/src/types/render.ts +1 -0
- package/src/types/spec.ts +116 -0
- package/src/types/stdlib.ts +25 -0
- package/src/types/theme.ts +101 -0
- package/src/types/view.ts +31 -0
- package/src/util/animate.ts +430 -0
- package/src/util/array.ts +57 -0
- package/src/util/canvas.ts +95 -0
- package/src/util/event.ts +34 -0
- package/src/util/extend.ts +42 -0
- package/src/util/extension.ts +29 -0
- package/src/util/index.ts +4 -0
- package/src/util/item.ts +70 -0
- package/src/util/mapper.ts +61 -0
- package/src/util/math.ts +9 -0
- package/src/util/point.ts +195 -0
- package/src/util/shape.ts +609 -0
- package/src/util/shape3d.ts +198 -0
- package/src/util/text.ts +49 -0
- package/src/util/type.ts +4 -0
- package/src/util/zoom.ts +39 -0
- package/README.en-US.md +0 -170
- package/README.md +0 -177
- package/dist/g6.min.js.map +0 -1
- package/es/index.d.ts +0 -4
- package/es/index.js +0 -5
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ID } from '@antv/graphlib';
|
|
2
|
+
import { Behavior } from '../../types/behavior';
|
|
3
|
+
import { IG6GraphEvent } from '../../types/event';
|
|
4
|
+
import { Point } from '../../types/common';
|
|
5
|
+
|
|
6
|
+
const ALLOWED_TRIGGERS = ['shift', 'ctrl', 'alt', 'meta'] as const;
|
|
7
|
+
type Trigger = (typeof ALLOWED_TRIGGERS)[number];
|
|
8
|
+
|
|
9
|
+
interface ClickSelectOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Whether to allow multiple selection.
|
|
12
|
+
* Defaults to true.
|
|
13
|
+
* If set to false, `trigger` options will be ignored.
|
|
14
|
+
*/
|
|
15
|
+
multiple: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The key to pressed with mouse click to apply multiple selection.
|
|
18
|
+
* Defaults to `"shift"`.
|
|
19
|
+
* Could be "shift", "ctrl", "alt", or "meta".
|
|
20
|
+
*/
|
|
21
|
+
trigger: Trigger;
|
|
22
|
+
/**
|
|
23
|
+
* Item types to be able to select.
|
|
24
|
+
* Defaults to `["node"]`.
|
|
25
|
+
* Should be an array of "node", "edge", or "combo".
|
|
26
|
+
*/
|
|
27
|
+
itemTypes: Array<'node' | 'edge' | 'combo'>;
|
|
28
|
+
/**
|
|
29
|
+
* The state to be applied when select.
|
|
30
|
+
* Defaults to `"selected"`.
|
|
31
|
+
* Can be set to "active", "highlighted", etc.
|
|
32
|
+
*/
|
|
33
|
+
selectedState: 'selected'; // TODO: Enum
|
|
34
|
+
/**
|
|
35
|
+
* The event name to trigger when select/unselect an item.
|
|
36
|
+
*/
|
|
37
|
+
eventName: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether allow the behavior happen on the current item.
|
|
40
|
+
*/
|
|
41
|
+
shouldBegin: (event: IG6GraphEvent) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to update item state.
|
|
44
|
+
* If it returns false, you may probably listen to `eventName` and
|
|
45
|
+
* manage states or data manually
|
|
46
|
+
*/
|
|
47
|
+
shouldUpdate: (event: IG6GraphEvent) => boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const DEFAULT_OPTIONS: ClickSelectOptions = {
|
|
51
|
+
multiple: true,
|
|
52
|
+
trigger: 'shift',
|
|
53
|
+
selectedState: 'selected',
|
|
54
|
+
itemTypes: ['node', 'edge'],
|
|
55
|
+
eventName: '',
|
|
56
|
+
shouldBegin: () => true,
|
|
57
|
+
shouldUpdate: () => true,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default class ClickSelect extends Behavior {
|
|
61
|
+
options: ClickSelectOptions;
|
|
62
|
+
/**
|
|
63
|
+
* Cache the ids of items selected by this behavior
|
|
64
|
+
*/
|
|
65
|
+
private selectedIds: ID[] = [];
|
|
66
|
+
/**
|
|
67
|
+
* Two flag to avoid onCanvasClick triggered while dragging canvas
|
|
68
|
+
*/
|
|
69
|
+
private canvasPointerDown: Point | undefined = undefined;
|
|
70
|
+
private canvasPointerMove: Boolean = false;
|
|
71
|
+
|
|
72
|
+
constructor(options: Partial<ClickSelectOptions>) {
|
|
73
|
+
super(Object.assign({}, DEFAULT_OPTIONS, options));
|
|
74
|
+
// Validate options
|
|
75
|
+
if (options.trigger && !ALLOWED_TRIGGERS.includes(options.trigger)) {
|
|
76
|
+
console.warn(
|
|
77
|
+
`G6: Invalid trigger option "${options.trigger}" for click-select behavior!`,
|
|
78
|
+
);
|
|
79
|
+
this.options.trigger = DEFAULT_OPTIONS.trigger;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getEvents = () => {
|
|
84
|
+
return {
|
|
85
|
+
'node:click': this.onClick,
|
|
86
|
+
'edge:click': this.onClick,
|
|
87
|
+
'canvas:pointerdown': this.onCanvasPointerDown,
|
|
88
|
+
'canvas:pointermove': this.onCanvasPointerMove,
|
|
89
|
+
'canvas:pointerup': this.onCanvasPointerUp,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
private isMultipleSelect(event: MouseEvent) {
|
|
94
|
+
if (!this.options.multiple) return false;
|
|
95
|
+
const key = this.options.trigger;
|
|
96
|
+
const keyMap: Record<Trigger, boolean> = {
|
|
97
|
+
shift: event.shiftKey,
|
|
98
|
+
ctrl: event.ctrlKey,
|
|
99
|
+
alt: event.altKey,
|
|
100
|
+
meta: event.metaKey,
|
|
101
|
+
};
|
|
102
|
+
return keyMap[this.options.trigger];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public onClick(event: IG6GraphEvent) {
|
|
106
|
+
if (!this.options.shouldBegin(event)) return;
|
|
107
|
+
|
|
108
|
+
// Will not be 'canvas' because this method is listened on node and edge click.
|
|
109
|
+
const itemType = event.itemType as 'node' | 'edge' | 'combo';
|
|
110
|
+
const itemId = event.itemId;
|
|
111
|
+
|
|
112
|
+
const selectable = this.options.itemTypes.includes(itemType);
|
|
113
|
+
if (!selectable) return;
|
|
114
|
+
|
|
115
|
+
const state = this.options.selectedState;
|
|
116
|
+
const multiple = this.isMultipleSelect(event as any);
|
|
117
|
+
// FIXME: should use graph.getItemState() instead
|
|
118
|
+
const isSelectAction = !this.graph
|
|
119
|
+
.findIdByState(itemType, state)
|
|
120
|
+
.includes(itemId);
|
|
121
|
+
const action: 'select' | 'unselect' = isSelectAction
|
|
122
|
+
? 'select'
|
|
123
|
+
: 'unselect';
|
|
124
|
+
|
|
125
|
+
// Select/Unselect item.
|
|
126
|
+
if (this.options.shouldUpdate(event)) {
|
|
127
|
+
if (!multiple) {
|
|
128
|
+
// Not multiple, clear all currently selected items
|
|
129
|
+
this.graph.setItemState(this.selectedIds, state, false);
|
|
130
|
+
}
|
|
131
|
+
this.graph.setItemState(itemId, state, isSelectAction);
|
|
132
|
+
if (isSelectAction) {
|
|
133
|
+
this.selectedIds.push(itemId);
|
|
134
|
+
} else {
|
|
135
|
+
this.selectedIds.filter((id) => id !== itemId);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Emit an event.
|
|
140
|
+
if (this.options.eventName) {
|
|
141
|
+
const selectedNodeIds = this.graph.findIdByState('node', state);
|
|
142
|
+
const selectedEdgeIds = this.graph.findIdByState('edge', state);
|
|
143
|
+
const selectedComboIds = this.graph.findIdByState('combo', state);
|
|
144
|
+
this.graph.emit(this.options.eventName, {
|
|
145
|
+
action,
|
|
146
|
+
itemId,
|
|
147
|
+
itemType,
|
|
148
|
+
selectedNodeIds,
|
|
149
|
+
selectedEdgeIds,
|
|
150
|
+
selectedComboIds,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public onCanvasPointerDown(event: IG6GraphEvent) {
|
|
156
|
+
this.canvasPointerDown = {
|
|
157
|
+
x: event.canvas.x,
|
|
158
|
+
y: event.canvas.y,
|
|
159
|
+
};
|
|
160
|
+
this.canvasPointerMove = false;
|
|
161
|
+
}
|
|
162
|
+
public onCanvasPointerMove(event: IG6GraphEvent) {
|
|
163
|
+
if (this.canvasPointerDown) {
|
|
164
|
+
const deltaX = Math.abs(this.canvasPointerDown.x - event.canvas.x);
|
|
165
|
+
const deltaY = Math.abs(this.canvasPointerDown.y - event.canvas.y);
|
|
166
|
+
if (deltaX > 1 || deltaY > 1) this.canvasPointerMove = true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public onCanvasPointerUp(event: IG6GraphEvent) {
|
|
171
|
+
if (this.canvasPointerDown && !this.canvasPointerMove)
|
|
172
|
+
this.onCanvasClick(event);
|
|
173
|
+
this.canvasPointerDown = undefined;
|
|
174
|
+
this.canvasPointerMove = false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public onCanvasClick(event: IG6GraphEvent) {
|
|
178
|
+
if (!this.options.shouldBegin(event)) return;
|
|
179
|
+
|
|
180
|
+
// Find current selected items.
|
|
181
|
+
const state = this.options.selectedState;
|
|
182
|
+
if (!this.selectedIds.length) return;
|
|
183
|
+
|
|
184
|
+
// Unselect all items.
|
|
185
|
+
if (this.options.shouldUpdate(event)) {
|
|
186
|
+
this.graph.setItemState(this.selectedIds, state, false);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Emit an event.
|
|
190
|
+
if (this.options.eventName) {
|
|
191
|
+
this.graph.emit(this.options.eventName, {
|
|
192
|
+
action: 'unselect',
|
|
193
|
+
itemId: '',
|
|
194
|
+
itemType: '',
|
|
195
|
+
selectedNodeIds: [],
|
|
196
|
+
selectedEdgeIds: [],
|
|
197
|
+
selectedComboIds: [],
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { ID, IG6GraphEvent } from 'types';
|
|
2
|
+
import { Behavior } from '../../types/behavior';
|
|
3
|
+
import { Point } from '../../types/common';
|
|
4
|
+
|
|
5
|
+
const VALID_TRIGGERS = ['drag', 'directionKeys'];
|
|
6
|
+
export interface DragCanvasOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Whether enable optimize strategies, which will hide all the shapes excluding node keyShape while dragging.
|
|
9
|
+
*/
|
|
10
|
+
enableOptimize?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether allow trigger this behavior when drag start on nodes / edges / combos.
|
|
13
|
+
*/
|
|
14
|
+
dragOnItems?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The trigger for the behavior, 'drag' by default. 'directionKeys' means trigger this behavior by up / down / left / right keys on keyboard.
|
|
17
|
+
*/
|
|
18
|
+
trigger?: 'drag' | 'directionKeys';
|
|
19
|
+
/**
|
|
20
|
+
* The direction to drag the canvas. 'both' by default.
|
|
21
|
+
*/
|
|
22
|
+
direction?: 'both' | 'x' | 'y';
|
|
23
|
+
/**
|
|
24
|
+
* The assistant secondary key on keyboard. If it is not assigned, the behavior will be triggered when trigger happens.
|
|
25
|
+
*/
|
|
26
|
+
secondaryKey?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The assistant secondary key on keyboard to prevent the behavior to be tiggered. 'shift' by default.
|
|
29
|
+
*/
|
|
30
|
+
secondaryKeyToDisable?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The key on keyboard to speed up translating while pressing and drag-canvas by direction keys. The trigger should be 'directionKeys' for this option.
|
|
33
|
+
*/
|
|
34
|
+
speedUpKey?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The range of canvas to limit dragging, 0 by default, which means the graph cannot be dragged totally out of the view port range.
|
|
37
|
+
* If scalableRange is number or a string without 'px', means it is a ratio of the graph content.
|
|
38
|
+
* If scalableRange is a string with 'px', it is regarded as pixels.
|
|
39
|
+
* If scalableRange = 0, no constrains;
|
|
40
|
+
* If scalableRange > 0, the graph can be dragged out of the view port range
|
|
41
|
+
* If scalableRange < 0, the range is smaller than the view port.
|
|
42
|
+
* Refer to https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*IFfoS67_HssAAAAAAAAAAAAAARQnAQ
|
|
43
|
+
*/
|
|
44
|
+
scalableRange?: string | number;
|
|
45
|
+
/**
|
|
46
|
+
* The event name to trigger when drag end.
|
|
47
|
+
*/
|
|
48
|
+
eventName?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Whether allow the behavior happen on the current item.
|
|
51
|
+
*/
|
|
52
|
+
shouldBegin?: (event: IG6GraphEvent) => boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const DEFAULT_OPTIONS: Required<DragCanvasOptions> = {
|
|
56
|
+
enableOptimize: false,
|
|
57
|
+
dragOnItems: false,
|
|
58
|
+
trigger: 'drag',
|
|
59
|
+
direction: 'both',
|
|
60
|
+
secondaryKey: '',
|
|
61
|
+
secondaryKeyToDisable: 'shift',
|
|
62
|
+
speedUpKey: '',
|
|
63
|
+
scalableRange: 0,
|
|
64
|
+
eventName: '',
|
|
65
|
+
shouldBegin: () => true,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default class DragCanvas extends Behavior {
|
|
69
|
+
options: DragCanvasOptions;
|
|
70
|
+
|
|
71
|
+
private pointerDownAt: Point;
|
|
72
|
+
private dragging: boolean; // pointerdown + pointermove a distance
|
|
73
|
+
private keydown: boolean;
|
|
74
|
+
private speedupKeydown: boolean;
|
|
75
|
+
private disableKeydown: boolean;
|
|
76
|
+
private hiddenEdgeIds: ID[];
|
|
77
|
+
private hiddenNodeIds: ID[];
|
|
78
|
+
|
|
79
|
+
constructor(options: Partial<DragCanvasOptions>) {
|
|
80
|
+
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
81
|
+
if (!VALID_TRIGGERS.includes(finalOptions.trigger)) {
|
|
82
|
+
console.warn(
|
|
83
|
+
`The trigger ${finalOptions.trigger} is not valid, 'drag' will take effect.`,
|
|
84
|
+
);
|
|
85
|
+
finalOptions.trigger = 'drag';
|
|
86
|
+
}
|
|
87
|
+
super(finalOptions);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getEvents() {
|
|
91
|
+
if (typeof window !== 'undefined') {
|
|
92
|
+
window.addEventListener('keydown', this.onKeydown.bind(this));
|
|
93
|
+
window.addEventListener('keyup', this.onKeyup.bind(this));
|
|
94
|
+
}
|
|
95
|
+
if (this.options.trigger === 'directionKeys') {
|
|
96
|
+
return {
|
|
97
|
+
keydown: this.onKeydown,
|
|
98
|
+
keyup: this.onKeyup,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
pointerdown: this.onPointerDown,
|
|
103
|
+
pointermove: this.onPointerMove,
|
|
104
|
+
pointerup: this.onPointerUp,
|
|
105
|
+
keydown: this.onKeydown,
|
|
106
|
+
keyup: this.onKeyup,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public onPointerDown(event) {
|
|
111
|
+
const { secondaryKey, secondaryKeyToDisable, dragOnItems, shouldBegin } =
|
|
112
|
+
this.options;
|
|
113
|
+
// disabled key is pressing
|
|
114
|
+
if (secondaryKeyToDisable && this.disableKeydown) return;
|
|
115
|
+
// assistant key is not pressing
|
|
116
|
+
if (secondaryKey && !this.keydown) return;
|
|
117
|
+
// should not begin
|
|
118
|
+
if (!shouldBegin(event)) return;
|
|
119
|
+
// begin on an item
|
|
120
|
+
const isDragOnItem = event.itemId && event.itemId !== 'CANVAS';
|
|
121
|
+
if (isDragOnItem && !dragOnItems) return;
|
|
122
|
+
|
|
123
|
+
const { client } = event;
|
|
124
|
+
this.pointerDownAt = { x: client.x, y: client.y };
|
|
125
|
+
|
|
126
|
+
document.addEventListener(
|
|
127
|
+
'mouseup',
|
|
128
|
+
(evt) => {
|
|
129
|
+
this.onPointerUp();
|
|
130
|
+
},
|
|
131
|
+
{ once: true },
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private hideShapes() {
|
|
136
|
+
const { graph } = this;
|
|
137
|
+
if (this.options.enableOptimize) {
|
|
138
|
+
this.hiddenEdgeIds = graph
|
|
139
|
+
.getAllEdgesData()
|
|
140
|
+
.map((edge) => edge.id)
|
|
141
|
+
.filter((id) => graph.getItemVisible(id) === true);
|
|
142
|
+
graph.hideItem(this.hiddenEdgeIds, true);
|
|
143
|
+
this.hiddenNodeIds = graph
|
|
144
|
+
.getAllNodesData()
|
|
145
|
+
.map((node) => node.id)
|
|
146
|
+
.filter((id) => graph.getItemVisible(id) === true);
|
|
147
|
+
// draw node's keyShapes on transient, and then hidden the real nodes;
|
|
148
|
+
this.hiddenNodeIds.forEach((id) => {
|
|
149
|
+
graph.drawTransient('node', id, {
|
|
150
|
+
onlyDrawKeyShape: true,
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
graph.hideItem(this.hiddenNodeIds, true);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private formatDisplacement(diffX: number, diffY: number) {
|
|
158
|
+
const { graph } = this;
|
|
159
|
+
const { scalableRange, direction } = this.options;
|
|
160
|
+
const [width, height] = graph.getSize();
|
|
161
|
+
const graphBBox = graph.canvas.getRoot().getRenderBounds();
|
|
162
|
+
let rangeNum = Number(scalableRange);
|
|
163
|
+
let isPixel;
|
|
164
|
+
if (typeof scalableRange === 'string') {
|
|
165
|
+
if (scalableRange.includes('px')) {
|
|
166
|
+
isPixel = scalableRange.includes('px');
|
|
167
|
+
rangeNum = Number(scalableRange.replace('px', ''));
|
|
168
|
+
}
|
|
169
|
+
if (scalableRange.includes('%')) {
|
|
170
|
+
rangeNum = Number(scalableRange.replace('%', '')) / 100;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (rangeNum === 0) return { dx: diffX, dy: diffY };
|
|
174
|
+
|
|
175
|
+
let expandWidth = rangeNum;
|
|
176
|
+
let expandHeight = rangeNum;
|
|
177
|
+
// If it is not a string with 'px', regard as ratio
|
|
178
|
+
if (!isPixel) {
|
|
179
|
+
expandWidth = width * rangeNum;
|
|
180
|
+
expandHeight = height * rangeNum;
|
|
181
|
+
}
|
|
182
|
+
const leftTopClient = graph.getViewportByCanvas({
|
|
183
|
+
x: graphBBox.min[0],
|
|
184
|
+
y: graphBBox.min[1],
|
|
185
|
+
});
|
|
186
|
+
const rightBottomClient = graph.getViewportByCanvas({
|
|
187
|
+
x: graphBBox.max[0],
|
|
188
|
+
y: graphBBox.max[1],
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
let dx = diffX;
|
|
192
|
+
let dy = diffY;
|
|
193
|
+
if (
|
|
194
|
+
direction === 'y' ||
|
|
195
|
+
(diffX > 0 && rightBottomClient.x + diffX > width + expandWidth) ||
|
|
196
|
+
(diffX < 0 && leftTopClient.x + expandWidth + diffX < 0)
|
|
197
|
+
) {
|
|
198
|
+
dx = 0;
|
|
199
|
+
}
|
|
200
|
+
if (
|
|
201
|
+
direction === 'x' ||
|
|
202
|
+
(diffY > 0 && rightBottomClient.y + diffY > height + expandHeight) ||
|
|
203
|
+
(diffY < 0 && leftTopClient.y + expandHeight + diffY < 0)
|
|
204
|
+
) {
|
|
205
|
+
dy = 0;
|
|
206
|
+
}
|
|
207
|
+
return { dx, dy };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public onPointerMove(event) {
|
|
211
|
+
if (!this.pointerDownAt) return;
|
|
212
|
+
const { eventName, direction, secondaryKeyToDisable } = this.options;
|
|
213
|
+
// disabled key is pressing
|
|
214
|
+
if (secondaryKeyToDisable && this.disableKeydown) return;
|
|
215
|
+
const { graph } = this;
|
|
216
|
+
const { client } = event;
|
|
217
|
+
const diffX = client.x - this.pointerDownAt.x;
|
|
218
|
+
const diffY = client.y - this.pointerDownAt.y;
|
|
219
|
+
if (direction === 'x' && !diffX) return;
|
|
220
|
+
if (direction === 'y' && !diffY) return;
|
|
221
|
+
if (direction === 'both' && !diffX && !diffY) return;
|
|
222
|
+
|
|
223
|
+
// begin dragging
|
|
224
|
+
if (!this.dragging) {
|
|
225
|
+
this.hideShapes();
|
|
226
|
+
this.dragging = true;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const { dx, dy } = this.formatDisplacement(diffX, diffY);
|
|
230
|
+
graph.translate({ dx, dy });
|
|
231
|
+
|
|
232
|
+
this.pointerDownAt = { x: client.x, y: client.y };
|
|
233
|
+
|
|
234
|
+
// Emit event.
|
|
235
|
+
if (eventName) {
|
|
236
|
+
this.graph.emit(eventName, { translate: { dx, dy } });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public onPointerUp() {
|
|
241
|
+
this.pointerDownAt = undefined;
|
|
242
|
+
this.dragging = false;
|
|
243
|
+
|
|
244
|
+
const { graph } = this;
|
|
245
|
+
if (this.options.enableOptimize) {
|
|
246
|
+
if (this.hiddenEdgeIds) {
|
|
247
|
+
graph.showItem(this.hiddenEdgeIds, true);
|
|
248
|
+
}
|
|
249
|
+
if (this.hiddenNodeIds) {
|
|
250
|
+
this.hiddenNodeIds.forEach((id) => {
|
|
251
|
+
this.graph.drawTransient('node', id, { action: 'remove' });
|
|
252
|
+
});
|
|
253
|
+
graph.showItem(this.hiddenNodeIds, true);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public onKeydown(event) {
|
|
259
|
+
const { key } = event;
|
|
260
|
+
const {
|
|
261
|
+
secondaryKey,
|
|
262
|
+
secondaryKeyToDisable,
|
|
263
|
+
trigger,
|
|
264
|
+
speedUpKey,
|
|
265
|
+
eventName,
|
|
266
|
+
shouldBegin,
|
|
267
|
+
} = this.options;
|
|
268
|
+
if (secondaryKey && secondaryKey === key.toLowerCase()) {
|
|
269
|
+
this.keydown = true;
|
|
270
|
+
}
|
|
271
|
+
if (speedUpKey && speedUpKey === key.toLowerCase()) {
|
|
272
|
+
this.speedupKeydown = true;
|
|
273
|
+
}
|
|
274
|
+
if (secondaryKeyToDisable && secondaryKeyToDisable === key.toLowerCase()) {
|
|
275
|
+
this.disableKeydown = true;
|
|
276
|
+
}
|
|
277
|
+
if (trigger === 'directionKeys') {
|
|
278
|
+
if (secondaryKey && !this.keydown) return;
|
|
279
|
+
if (secondaryKeyToDisable && this.disableKeydown) return;
|
|
280
|
+
if (!shouldBegin(event)) return;
|
|
281
|
+
const { graph, speedupKeydown } = this;
|
|
282
|
+
const speed = speedupKeydown ? 20 : 1;
|
|
283
|
+
let dx = 0;
|
|
284
|
+
let dy = 0;
|
|
285
|
+
switch (key) {
|
|
286
|
+
case 'ArrowLeft':
|
|
287
|
+
dx = -speed;
|
|
288
|
+
break;
|
|
289
|
+
case 'ArrowRight':
|
|
290
|
+
dx = speed;
|
|
291
|
+
break;
|
|
292
|
+
case 'ArrowUp':
|
|
293
|
+
dy = -speed;
|
|
294
|
+
break;
|
|
295
|
+
case 'ArrowDown':
|
|
296
|
+
dy = speed;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
if (dx || dy) {
|
|
300
|
+
const { dx: formattedDx, dy: formattedDy } = this.formatDisplacement(
|
|
301
|
+
dx,
|
|
302
|
+
dy,
|
|
303
|
+
);
|
|
304
|
+
graph.translate({ dx: formattedDx, dy: formattedDy });
|
|
305
|
+
if (eventName) {
|
|
306
|
+
this.graph.emit(eventName, {
|
|
307
|
+
translate: { dx: formattedDx, dy: formattedDy },
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
public onKeyup(event) {
|
|
315
|
+
const { key } = event;
|
|
316
|
+
const { secondaryKey, secondaryKeyToDisable, speedUpKey } = this.options;
|
|
317
|
+
if (secondaryKey && secondaryKey === key.toLowerCase()) {
|
|
318
|
+
this.keydown = false;
|
|
319
|
+
}
|
|
320
|
+
if (speedUpKey && speedUpKey === key.toLowerCase()) {
|
|
321
|
+
this.speedupKeydown = false;
|
|
322
|
+
}
|
|
323
|
+
if (secondaryKeyToDisable && secondaryKeyToDisable === key.toLowerCase()) {
|
|
324
|
+
this.disableKeydown = false;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
public destroy() {
|
|
328
|
+
if (typeof window !== 'undefined') {
|
|
329
|
+
window.removeEventListener('keydown', this.onKeydown.bind(this));
|
|
330
|
+
window.removeEventListener('keyup', this.onKeyup.bind(this));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|