@antv/g6 5.0.0-beta.36 → 5.0.0-beta.38
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/dist/lib/animations/executor.d.ts +4 -5
- package/dist/lib/animations/index.d.ts +22 -8
- package/dist/lib/animations/types.d.ts +78 -20
- package/dist/lib/behaviors/collapse-expand.d.ts +10 -1
- package/dist/lib/behaviors/drag-canvas.d.ts +1 -0
- package/dist/lib/behaviors/hover-element.d.ts +2 -0
- package/dist/lib/constants/animation.d.ts +3 -2
- package/dist/lib/constants/events/animation.d.ts +2 -0
- package/dist/lib/constants/events/graph.d.ts +0 -12
- package/dist/lib/elements/base-element.d.ts +35 -0
- package/dist/lib/elements/combos/base-combo.d.ts +8 -32
- package/dist/lib/elements/combos/circle.d.ts +1 -2
- package/dist/lib/elements/edges/base-edge.d.ts +21 -30
- package/dist/lib/elements/nodes/base-node.d.ts +7 -27
- package/dist/lib/elements/nodes/html.d.ts +3 -2
- package/dist/lib/elements/shapes/badge.d.ts +1 -1
- package/dist/lib/elements/shapes/base-shape.d.ts +6 -0
- package/dist/lib/exports.d.ts +3 -2
- package/dist/lib/layouts/types.d.ts +1 -1
- package/dist/lib/plugins/background/index.d.ts +38 -0
- package/dist/lib/plugins/{contextmenu.d.ts → contextmenu/index.d.ts} +5 -5
- package/dist/lib/plugins/index.d.ts +2 -0
- package/dist/lib/plugins/legend.d.ts +1 -1
- package/dist/lib/plugins/timebar.d.ts +1 -1
- package/dist/lib/plugins/toolbar/index.d.ts +2 -2
- package/{lib/plugins/watermark.d.ts → dist/lib/plugins/watermark/index.d.ts} +3 -3
- package/dist/lib/runtime/animation.d.ts +54 -0
- package/dist/lib/runtime/data.d.ts +4 -4
- package/dist/lib/runtime/element.d.ts +26 -40
- package/dist/lib/runtime/graph.d.ts +1 -0
- package/dist/lib/runtime/layout.d.ts +7 -0
- package/dist/lib/runtime/transform.d.ts +1 -0
- package/dist/lib/runtime/types.d.ts +7 -0
- package/dist/lib/spec/data.d.ts +14 -0
- package/dist/lib/spec/element/animation.d.ts +3 -9
- package/dist/lib/spec/element/combo.d.ts +4 -3
- package/dist/lib/spec/element/edge.d.ts +4 -3
- package/dist/lib/spec/element/node.d.ts +4 -3
- package/dist/lib/spec/graph.d.ts +1 -1
- package/dist/lib/transforms/base-transform.d.ts +2 -1
- package/dist/lib/transforms/collapse-expand-combo.d.ts +4 -3
- package/dist/lib/transforms/collapse-expand-node.d.ts +12 -0
- package/dist/lib/transforms/get-edge-actual-ends.d.ts +13 -0
- package/dist/lib/transforms/index.d.ts +2 -0
- package/dist/lib/transforms/process-parallel-edges.d.ts +6 -4
- package/dist/lib/transforms/types.d.ts +2 -2
- package/dist/lib/transforms/update-related-edge.d.ts +2 -1
- package/dist/lib/transforms/utils.d.ts +13 -0
- package/dist/lib/types/animation.d.ts +1 -2
- package/dist/lib/types/node.d.ts +12 -0
- package/dist/lib/utils/animation.d.ts +17 -29
- package/dist/lib/utils/collapsibility.d.ts +9 -0
- package/dist/lib/utils/element.d.ts +19 -2
- package/dist/lib/utils/theme.d.ts +9 -0
- package/dist/lib/utils/transform.d.ts +14 -0
- package/esm/animations/executor.d.ts +4 -5
- package/esm/animations/executor.js +31 -48
- package/esm/animations/executor.js.map +1 -1
- package/esm/animations/index.d.ts +22 -8
- package/esm/animations/index.js +10 -12
- package/esm/animations/index.js.map +1 -1
- package/esm/animations/types.d.ts +78 -20
- package/esm/behaviors/collapse-expand.d.ts +10 -1
- package/esm/behaviors/collapse-expand.js +15 -6
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/create-edge.js +2 -2
- package/esm/behaviors/create-edge.js.map +1 -1
- package/esm/behaviors/drag-canvas.d.ts +1 -0
- package/esm/behaviors/drag-canvas.js +5 -1
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element.js +2 -2
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/hover-element.d.ts +2 -0
- package/esm/behaviors/hover-element.js +12 -2
- package/esm/behaviors/hover-element.js.map +1 -1
- package/esm/constants/animation.d.ts +3 -2
- package/esm/constants/animation.js.map +1 -1
- package/esm/constants/events/animation.d.ts +2 -0
- package/esm/constants/events/animation.js +2 -0
- package/esm/constants/events/animation.js.map +1 -1
- package/esm/constants/events/graph.d.ts +0 -12
- package/esm/constants/events/graph.js +0 -12
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/elements/base-element.d.ts +35 -0
- package/esm/elements/base-element.js +42 -0
- package/esm/elements/base-element.js.map +1 -0
- package/esm/elements/combos/base-combo.d.ts +8 -32
- package/esm/elements/combos/base-combo.js +53 -55
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/combos/circle.d.ts +1 -2
- package/esm/elements/combos/circle.js +1 -12
- package/esm/elements/combos/circle.js.map +1 -1
- package/esm/elements/combos/rect.js +1 -2
- package/esm/elements/combos/rect.js.map +1 -1
- package/esm/elements/edges/base-edge.d.ts +21 -30
- package/esm/elements/edges/base-edge.js +38 -35
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/edges/polyline.js +8 -4
- package/esm/elements/edges/polyline.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +7 -27
- package/esm/elements/nodes/base-node.js +16 -38
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/html.d.ts +3 -2
- package/esm/elements/nodes/html.js +13 -3
- package/esm/elements/nodes/html.js.map +1 -1
- package/esm/elements/shapes/badge.d.ts +1 -1
- package/esm/elements/shapes/base-shape.d.ts +6 -0
- package/esm/elements/shapes/base-shape.js +23 -6
- package/esm/elements/shapes/base-shape.js.map +1 -1
- package/esm/exports.d.ts +3 -2
- package/esm/layouts/types.d.ts +1 -1
- package/esm/plugins/background/index.d.ts +38 -0
- package/esm/plugins/background/index.js +49 -0
- package/esm/plugins/background/index.js.map +1 -0
- package/esm/plugins/{contextmenu.d.ts → contextmenu/index.d.ts} +5 -5
- package/esm/plugins/{contextmenu.js → contextmenu/index.js} +4 -4
- package/esm/plugins/contextmenu/index.js.map +1 -0
- package/esm/{utils/contextmenu.js → plugins/contextmenu/util.js} +1 -1
- package/esm/{utils/contextmenu.js.map → plugins/contextmenu/util.js.map} +1 -1
- package/esm/plugins/history/index.js +1 -1
- package/esm/plugins/history/index.js.map +1 -1
- package/esm/plugins/history/{utils.js → util.js} +1 -1
- package/esm/plugins/history/util.js.map +1 -0
- package/esm/plugins/index.d.ts +2 -0
- package/esm/plugins/index.js +1 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/legend.d.ts +1 -1
- package/esm/plugins/legend.js +1 -1
- package/esm/plugins/timebar.d.ts +1 -1
- package/esm/plugins/timebar.js +1 -1
- package/esm/plugins/timebar.js.map +1 -1
- package/esm/plugins/toolbar/index.d.ts +2 -2
- package/esm/plugins/toolbar/index.js +1 -1
- package/{dist/lib/plugins/watermark.d.ts → esm/plugins/watermark/index.d.ts} +3 -3
- package/esm/plugins/{watermark.js → watermark/index.js} +4 -4
- package/esm/plugins/watermark/index.js.map +1 -0
- package/esm/{utils/watermark.js → plugins/watermark/util.js} +1 -1
- package/esm/plugins/watermark/util.js.map +1 -0
- package/esm/registry/build-in.js +14 -6
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/index.js +6 -4
- package/esm/registry/index.js.map +1 -1
- package/esm/runtime/animation.d.ts +54 -0
- package/esm/runtime/animation.js +139 -0
- package/esm/runtime/animation.js.map +1 -0
- package/esm/runtime/canvas.js +0 -5
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +4 -4
- package/esm/runtime/data.js +16 -17
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +26 -40
- package/esm/runtime/element.js +218 -179
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +1 -0
- package/esm/runtime/graph.js +50 -21
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.d.ts +7 -0
- package/esm/runtime/layout.js +44 -3
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/transform.d.ts +1 -0
- package/esm/runtime/transform.js +9 -2
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types.d.ts +7 -0
- package/esm/runtime/viewport.js +2 -2
- package/esm/runtime/viewport.js.map +1 -1
- package/esm/spec/data.d.ts +14 -0
- package/esm/spec/element/animation.d.ts +3 -9
- package/esm/spec/element/combo.d.ts +4 -3
- package/esm/spec/element/edge.d.ts +4 -3
- package/esm/spec/element/node.d.ts +4 -3
- package/esm/spec/graph.d.ts +1 -1
- package/esm/themes/base.js +14 -10
- package/esm/themes/base.js.map +1 -1
- package/esm/transforms/base-transform.d.ts +2 -1
- package/esm/transforms/base-transform.js +1 -1
- package/esm/transforms/base-transform.js.map +1 -1
- package/esm/transforms/collapse-expand-combo.d.ts +4 -3
- package/esm/transforms/collapse-expand-combo.js +9 -25
- package/esm/transforms/collapse-expand-combo.js.map +1 -1
- package/esm/transforms/collapse-expand-node.d.ts +12 -0
- package/esm/transforms/collapse-expand-node.js +91 -0
- package/esm/transforms/collapse-expand-node.js.map +1 -0
- package/esm/transforms/get-edge-actual-ends.d.ts +13 -0
- package/esm/transforms/get-edge-actual-ends.js +36 -0
- package/esm/transforms/get-edge-actual-ends.js.map +1 -0
- package/esm/transforms/index.d.ts +2 -0
- package/esm/transforms/index.js +2 -0
- package/esm/transforms/index.js.map +1 -1
- package/esm/transforms/process-parallel-edges.d.ts +6 -4
- package/esm/transforms/process-parallel-edges.js +42 -27
- package/esm/transforms/process-parallel-edges.js.map +1 -1
- package/esm/transforms/types.d.ts +2 -2
- package/esm/transforms/types.js +1 -10
- package/esm/transforms/types.js.map +1 -1
- package/esm/transforms/update-related-edge.d.ts +2 -1
- package/esm/transforms/update-related-edge.js +4 -1
- package/esm/transforms/update-related-edge.js.map +1 -1
- package/esm/transforms/utils.d.ts +13 -0
- package/esm/transforms/utils.js +25 -0
- package/esm/transforms/utils.js.map +1 -0
- package/esm/types/animation.d.ts +1 -2
- package/esm/types/node.d.ts +12 -0
- package/esm/utils/animation.d.ts +17 -29
- package/esm/utils/animation.js +64 -54
- package/esm/utils/animation.js.map +1 -1
- package/esm/utils/cache.js +0 -1
- package/esm/utils/cache.js.map +1 -1
- package/esm/utils/collapsibility.d.ts +9 -0
- package/esm/utils/collapsibility.js +11 -0
- package/esm/utils/collapsibility.js.map +1 -0
- package/esm/utils/dom.js +1 -2
- package/esm/utils/dom.js.map +1 -1
- package/esm/utils/edge.js +2 -1
- package/esm/utils/edge.js.map +1 -1
- package/esm/utils/element.d.ts +19 -2
- package/esm/utils/element.js +24 -3
- package/esm/utils/element.js.map +1 -1
- package/esm/utils/theme.d.ts +9 -0
- package/esm/utils/theme.js +17 -0
- package/esm/utils/theme.js.map +1 -0
- package/esm/utils/transform.d.ts +14 -0
- package/esm/utils/transform.js +24 -0
- package/esm/utils/transform.js.map +1 -1
- package/lib/animations/executor.d.ts +4 -5
- package/lib/animations/executor.js +30 -47
- package/lib/animations/executor.js.map +1 -1
- package/lib/animations/index.d.ts +22 -8
- package/lib/animations/index.js +12 -14
- package/lib/animations/index.js.map +1 -1
- package/lib/animations/types.d.ts +78 -20
- package/lib/behaviors/collapse-expand.d.ts +10 -1
- package/lib/behaviors/collapse-expand.js +15 -6
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/create-edge.js +2 -2
- package/lib/behaviors/create-edge.js.map +1 -1
- package/lib/behaviors/drag-canvas.d.ts +1 -0
- package/lib/behaviors/drag-canvas.js +5 -1
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element.js +2 -2
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/hover-element.d.ts +2 -0
- package/lib/behaviors/hover-element.js +12 -2
- package/lib/behaviors/hover-element.js.map +1 -1
- package/lib/constants/animation.d.ts +3 -2
- package/lib/constants/animation.js.map +1 -1
- package/lib/constants/events/animation.d.ts +2 -0
- package/lib/constants/events/animation.js +2 -0
- package/lib/constants/events/animation.js.map +1 -1
- package/lib/constants/events/graph.d.ts +0 -12
- package/lib/constants/events/graph.js +0 -12
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/elements/base-element.d.ts +35 -0
- package/lib/elements/base-element.js +46 -0
- package/lib/elements/base-element.js.map +1 -0
- package/lib/elements/combos/base-combo.d.ts +8 -32
- package/lib/elements/combos/base-combo.js +52 -54
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/combos/circle.d.ts +1 -2
- package/lib/elements/combos/circle.js +1 -12
- package/lib/elements/combos/circle.js.map +1 -1
- package/lib/elements/combos/rect.js +1 -2
- package/lib/elements/combos/rect.js.map +1 -1
- package/lib/elements/edges/base-edge.d.ts +21 -30
- package/lib/elements/edges/base-edge.js +38 -35
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/edges/polyline.js +8 -4
- package/lib/elements/edges/polyline.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +7 -27
- package/lib/elements/nodes/base-node.js +15 -37
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/html.d.ts +3 -2
- package/lib/elements/nodes/html.js +12 -2
- package/lib/elements/nodes/html.js.map +1 -1
- package/lib/elements/shapes/badge.d.ts +1 -1
- package/lib/elements/shapes/base-shape.d.ts +6 -0
- package/lib/elements/shapes/base-shape.js +23 -6
- package/lib/elements/shapes/base-shape.js.map +1 -1
- package/lib/exports.d.ts +3 -2
- package/lib/layouts/types.d.ts +1 -1
- package/lib/plugins/background/index.d.ts +38 -0
- package/lib/plugins/background/index.js +53 -0
- package/lib/plugins/background/index.js.map +1 -0
- package/lib/plugins/{contextmenu.d.ts → contextmenu/index.d.ts} +5 -5
- package/lib/plugins/{contextmenu.js → contextmenu/index.js} +6 -6
- package/lib/plugins/{contextmenu.js.map → contextmenu/index.js.map} +1 -1
- package/lib/{utils/contextmenu.js → plugins/contextmenu/util.js} +1 -1
- package/lib/{utils/contextmenu.js.map → plugins/contextmenu/util.js.map} +1 -1
- package/lib/plugins/history/index.js +2 -2
- package/lib/plugins/history/index.js.map +1 -1
- package/lib/plugins/history/{utils.js → util.js} +1 -1
- package/lib/plugins/history/util.js.map +1 -0
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/index.js +3 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/legend.d.ts +1 -1
- package/lib/plugins/legend.js +1 -1
- package/lib/plugins/timebar.d.ts +1 -1
- package/lib/plugins/timebar.js +1 -1
- package/lib/plugins/timebar.js.map +1 -1
- package/lib/plugins/toolbar/index.d.ts +2 -2
- package/lib/plugins/toolbar/index.js +1 -1
- package/{esm/plugins/watermark.d.ts → lib/plugins/watermark/index.d.ts} +3 -3
- package/lib/plugins/{watermark.js → watermark/index.js} +6 -6
- package/lib/plugins/watermark/index.js.map +1 -0
- package/lib/{utils/watermark.js → plugins/watermark/util.js} +1 -1
- package/lib/plugins/watermark/util.js.map +1 -0
- package/lib/registry/build-in.js +11 -3
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/index.js +6 -4
- package/lib/registry/index.js.map +1 -1
- package/lib/runtime/animation.d.ts +54 -0
- package/lib/runtime/animation.js +143 -0
- package/lib/runtime/animation.js.map +1 -0
- package/lib/runtime/canvas.js +0 -5
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +4 -4
- package/lib/runtime/data.js +15 -16
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +26 -40
- package/lib/runtime/element.js +215 -176
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +1 -0
- package/lib/runtime/graph.js +49 -20
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.d.ts +7 -0
- package/lib/runtime/layout.js +43 -2
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/transform.d.ts +1 -0
- package/lib/runtime/transform.js +9 -2
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types.d.ts +7 -0
- package/lib/runtime/viewport.js +1 -1
- package/lib/runtime/viewport.js.map +1 -1
- package/lib/spec/data.d.ts +14 -0
- package/lib/spec/element/animation.d.ts +3 -9
- package/lib/spec/element/combo.d.ts +4 -3
- package/lib/spec/element/edge.d.ts +4 -3
- package/lib/spec/element/node.d.ts +4 -3
- package/lib/spec/graph.d.ts +1 -1
- package/lib/themes/base.js +14 -10
- package/lib/themes/base.js.map +1 -1
- package/lib/transforms/base-transform.d.ts +2 -1
- package/lib/transforms/base-transform.js +1 -1
- package/lib/transforms/base-transform.js.map +1 -1
- package/lib/transforms/collapse-expand-combo.d.ts +4 -3
- package/lib/transforms/collapse-expand-combo.js +13 -29
- package/lib/transforms/collapse-expand-combo.js.map +1 -1
- package/lib/transforms/collapse-expand-node.d.ts +12 -0
- package/lib/transforms/collapse-expand-node.js +95 -0
- package/lib/transforms/collapse-expand-node.js.map +1 -0
- package/lib/transforms/get-edge-actual-ends.d.ts +13 -0
- package/lib/transforms/get-edge-actual-ends.js +41 -0
- package/lib/transforms/get-edge-actual-ends.js.map +1 -0
- package/lib/transforms/index.d.ts +2 -0
- package/lib/transforms/index.js +5 -1
- package/lib/transforms/index.js.map +1 -1
- package/lib/transforms/process-parallel-edges.d.ts +6 -4
- package/lib/transforms/process-parallel-edges.js +41 -26
- package/lib/transforms/process-parallel-edges.js.map +1 -1
- package/lib/transforms/types.d.ts +2 -2
- package/lib/transforms/types.js +0 -12
- package/lib/transforms/types.js.map +1 -1
- package/lib/transforms/update-related-edge.d.ts +2 -1
- package/lib/transforms/update-related-edge.js +4 -1
- package/lib/transforms/update-related-edge.js.map +1 -1
- package/lib/transforms/utils.d.ts +13 -0
- package/lib/transforms/utils.js +29 -0
- package/lib/transforms/utils.js.map +1 -0
- package/lib/types/animation.d.ts +1 -2
- package/lib/types/node.d.ts +12 -0
- package/lib/utils/animation.d.ts +17 -29
- package/lib/utils/animation.js +65 -56
- package/lib/utils/animation.js.map +1 -1
- package/lib/utils/cache.js +0 -1
- package/lib/utils/cache.js.map +1 -1
- package/lib/utils/collapsibility.d.ts +9 -0
- package/lib/utils/collapsibility.js +15 -0
- package/lib/utils/collapsibility.js.map +1 -0
- package/lib/utils/dom.js +1 -2
- package/lib/utils/dom.js.map +1 -1
- package/lib/utils/edge.js +2 -1
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/element.d.ts +19 -2
- package/lib/utils/element.js +26 -3
- package/lib/utils/element.js.map +1 -1
- package/lib/utils/theme.d.ts +9 -0
- package/lib/utils/theme.js +21 -0
- package/lib/utils/theme.js.map +1 -0
- package/lib/utils/transform.d.ts +14 -0
- package/lib/utils/transform.js +26 -1
- package/lib/utils/transform.js.map +1 -1
- package/package.json +6 -6
- package/src/animations/executor.ts +39 -61
- package/src/animations/index.ts +19 -15
- package/src/animations/types.ts +82 -27
- package/src/behaviors/collapse-expand.ts +25 -9
- package/src/behaviors/create-edge.ts +2 -2
- package/src/behaviors/drag-canvas.ts +6 -1
- package/src/behaviors/drag-element.ts +2 -2
- package/src/behaviors/hover-element.ts +17 -3
- package/src/constants/animation.ts +4 -2
- package/src/constants/events/animation.ts +2 -0
- package/src/constants/events/graph.ts +0 -12
- package/src/elements/base-element.ts +52 -0
- package/src/elements/combos/base-combo.ts +66 -74
- package/src/elements/combos/circle.ts +2 -20
- package/src/elements/combos/rect.ts +1 -2
- package/src/elements/edges/base-edge.ts +57 -45
- package/src/elements/edges/polyline.ts +8 -4
- package/src/elements/nodes/base-node.ts +20 -47
- package/src/elements/nodes/html.ts +17 -4
- package/src/elements/shapes/base-shape.ts +24 -9
- package/src/exports.ts +3 -2
- package/src/layouts/types.ts +1 -1
- package/src/plugins/background/index.ts +65 -0
- package/src/plugins/{contextmenu.ts → contextmenu/index.ts} +7 -7
- package/src/plugins/history/index.ts +1 -1
- package/src/plugins/index.ts +2 -0
- package/src/plugins/legend.ts +1 -1
- package/src/plugins/timebar.ts +2 -2
- package/src/plugins/toolbar/index.ts +2 -2
- package/src/plugins/{watermark.ts → watermark/index.ts} +5 -5
- package/src/registry/build-in.ts +21 -5
- package/src/registry/index.ts +4 -5
- package/src/runtime/animation.ts +186 -0
- package/src/runtime/canvas.ts +0 -5
- package/src/runtime/data.ts +16 -19
- package/src/runtime/element.ts +289 -255
- package/src/runtime/graph.ts +52 -37
- package/src/runtime/layout.ts +51 -4
- package/src/runtime/transform.ts +10 -2
- package/src/runtime/types.ts +7 -0
- package/src/runtime/viewport.ts +2 -2
- package/src/spec/data.ts +14 -1
- package/src/spec/element/animation.ts +3 -13
- package/src/spec/element/combo.ts +4 -3
- package/src/spec/element/edge.ts +4 -3
- package/src/spec/element/node.ts +4 -3
- package/src/spec/graph.ts +1 -1
- package/src/themes/base.ts +14 -10
- package/src/transforms/base-transform.ts +2 -1
- package/src/transforms/collapse-expand-combo.ts +11 -32
- package/src/transforms/collapse-expand-node.ts +107 -0
- package/src/transforms/get-edge-actual-ends.ts +45 -0
- package/src/transforms/index.ts +2 -0
- package/src/transforms/process-parallel-edges.ts +50 -36
- package/src/transforms/types.ts +5 -5
- package/src/transforms/update-related-edge.ts +5 -1
- package/src/transforms/utils.ts +31 -0
- package/src/types/animation.ts +1 -3
- package/src/types/node.ts +12 -0
- package/src/utils/animation.ts +73 -63
- package/src/utils/cache.ts +0 -1
- package/src/utils/collapsibility.ts +12 -0
- package/src/utils/dom.ts +1 -2
- package/src/utils/edge.ts +2 -1
- package/src/utils/element.ts +28 -3
- package/src/utils/theme.ts +18 -0
- package/src/utils/transform.ts +33 -0
- package/dist/lib/utils/combo.d.ts +0 -34
- package/esm/plugins/contextmenu.js.map +0 -1
- package/esm/plugins/history/utils.js.map +0 -1
- package/esm/plugins/watermark.js.map +0 -1
- package/esm/utils/combo.d.ts +0 -34
- package/esm/utils/combo.js +0 -111
- package/esm/utils/combo.js.map +0 -1
- package/esm/utils/watermark.js.map +0 -1
- package/lib/plugins/history/utils.js.map +0 -1
- package/lib/plugins/watermark.js.map +0 -1
- package/lib/utils/combo.d.ts +0 -34
- package/lib/utils/combo.js +0 -117
- package/lib/utils/combo.js.map +0 -1
- package/lib/utils/watermark.js.map +0 -1
- package/src/utils/combo.ts +0 -134
- /package/dist/lib/{utils/contextmenu.d.ts → plugins/contextmenu/util.d.ts} +0 -0
- /package/dist/lib/plugins/history/{utils.d.ts → util.d.ts} +0 -0
- /package/dist/lib/{utils/watermark.d.ts → plugins/watermark/util.d.ts} +0 -0
- /package/esm/{utils/contextmenu.d.ts → plugins/contextmenu/util.d.ts} +0 -0
- /package/esm/plugins/history/{utils.d.ts → util.d.ts} +0 -0
- /package/esm/{utils/watermark.d.ts → plugins/watermark/util.d.ts} +0 -0
- /package/lib/{utils/contextmenu.d.ts → plugins/contextmenu/util.d.ts} +0 -0
- /package/lib/plugins/history/{utils.d.ts → util.d.ts} +0 -0
- /package/lib/{utils/watermark.d.ts → plugins/watermark/util.d.ts} +0 -0
- /package/src/{utils/contextmenu.ts → plugins/contextmenu/util.ts} +0 -0
- /package/src/plugins/history/{utils.ts → util.ts} +0 -0
- /package/src/{utils/watermark.ts → plugins/watermark/util.ts} +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { DisplayObjectConfig, CircleStyleProps as GCircleStyleProps } from '@antv/g';
|
|
2
2
|
import { Circle as GCircle, Group } from '@antv/g';
|
|
3
|
-
import {
|
|
4
|
-
import type { Point, Position, STDSize } from '../../types';
|
|
3
|
+
import type { Point, STDSize } from '../../types';
|
|
5
4
|
import { getBBoxSize } from '../../utils/bbox';
|
|
6
|
-
import { getCircleCollapsedOrigin, getXYByCollapsedOrigin } from '../../utils/combo';
|
|
7
5
|
import { getEllipseIntersectPoint } from '../../utils/point';
|
|
8
6
|
import { subStyleProps } from '../../utils/prefix';
|
|
9
7
|
import { parseSize } from '../../utils/size';
|
|
@@ -34,12 +32,11 @@ export class CircleCombo extends BaseCombo<CircleComboStyleProps> {
|
|
|
34
32
|
protected getKeyStyle(attributes: Required<CircleComboStyleProps>): GCircleStyleProps {
|
|
35
33
|
const { collapsed } = attributes;
|
|
36
34
|
const keyStyle = super.getKeyStyle(attributes);
|
|
37
|
-
const collapsedStyle = subStyleProps(keyStyle, 'collapsed');
|
|
38
35
|
|
|
39
36
|
const [width] = this.getKeySize(attributes);
|
|
40
37
|
return {
|
|
41
38
|
...keyStyle,
|
|
42
|
-
...(collapsed &&
|
|
39
|
+
...(collapsed && subStyleProps(keyStyle, 'collapsed')),
|
|
43
40
|
r: width / 2,
|
|
44
41
|
};
|
|
45
42
|
}
|
|
@@ -51,27 +48,12 @@ export class CircleCombo extends BaseCombo<CircleComboStyleProps> {
|
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
protected getExpandedKeySize(attributes: Required<CircleComboStyleProps>): STDSize {
|
|
54
|
-
if (!isEmpty(attributes.size)) {
|
|
55
|
-
const [expandedWidth, expandedHeight] = parseSize(attributes.size);
|
|
56
|
-
const expandedR = Math.sqrt(expandedWidth ** 2 + expandedHeight ** 2) / 2;
|
|
57
|
-
return [expandedR * 2, expandedR * 2, 0];
|
|
58
|
-
}
|
|
59
51
|
const contentBBox = this.getContentBBox(attributes);
|
|
60
52
|
const [width, height] = getBBoxSize(contentBBox);
|
|
61
53
|
const expandedR = Math.sqrt(width ** 2 + height ** 2) / 2;
|
|
62
54
|
return [expandedR * 2, expandedR * 2, 0];
|
|
63
55
|
}
|
|
64
56
|
|
|
65
|
-
protected getCollapsedOriginPosition(attributes: Required<CircleComboStyleProps>): Position {
|
|
66
|
-
return getXYByCollapsedOrigin(
|
|
67
|
-
attributes.collapsedOrigin,
|
|
68
|
-
this.getContentBBox(attributes).center,
|
|
69
|
-
this.getCollapsedKeySize(attributes),
|
|
70
|
-
this.getExpandedKeySize(attributes),
|
|
71
|
-
getCircleCollapsedOrigin,
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
57
|
public getIntersectPoint(point: Point): Point {
|
|
76
58
|
const keyShapeBounds = this.getKey().getBounds();
|
|
77
59
|
return getEllipseIntersectPoint(point, keyShapeBounds);
|
|
@@ -27,12 +27,11 @@ export class RectCombo extends BaseCombo<RectComboStyleProps> {
|
|
|
27
27
|
|
|
28
28
|
protected getKeyStyle(attributes: Required<RectComboStyleProps>): GRectStyleProps {
|
|
29
29
|
const keyStyle = super.getKeyStyle(attributes);
|
|
30
|
-
const collapsedStyle = subStyleProps(keyStyle, 'collapsed');
|
|
31
30
|
|
|
32
31
|
const [width, height] = this.getKeySize(attributes);
|
|
33
32
|
return {
|
|
34
33
|
...keyStyle,
|
|
35
|
-
...(attributes.collapsed &&
|
|
34
|
+
...(attributes.collapsed && subStyleProps(keyStyle, 'collapsed')),
|
|
36
35
|
width,
|
|
37
36
|
height,
|
|
38
37
|
x: -width / 2,
|
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
EdgeArrowStyleProps,
|
|
15
15
|
EdgeKey,
|
|
16
16
|
EdgeLabelStyleProps,
|
|
17
|
+
ID,
|
|
17
18
|
Keyframe,
|
|
18
19
|
LoopStyleProps,
|
|
19
20
|
Node,
|
|
@@ -27,9 +28,9 @@ import { omitStyleProps, subStyleProps } from '../../utils/prefix';
|
|
|
27
28
|
import { parseSize } from '../../utils/size';
|
|
28
29
|
import * as Symbol from '../../utils/symbol';
|
|
29
30
|
import { getWordWrapWidthByEnds } from '../../utils/text';
|
|
31
|
+
import { BaseElement } from '../base-element';
|
|
30
32
|
import type { LabelStyleProps } from '../shapes';
|
|
31
33
|
import { Label } from '../shapes';
|
|
32
|
-
import { BaseShape } from '../shapes/base-shape';
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* <zh/> 边的通用样式属性
|
|
@@ -50,6 +51,13 @@ export interface BaseEdgeStyleProps
|
|
|
50
51
|
* @defaultValue true
|
|
51
52
|
*/
|
|
52
53
|
label?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* <zh/> 是否启用自环边
|
|
56
|
+
*
|
|
57
|
+
* <en/> Whether to enable self-loop edge
|
|
58
|
+
* @defaultValue true
|
|
59
|
+
*/
|
|
60
|
+
loop?: boolean;
|
|
53
61
|
/**
|
|
54
62
|
* <zh/> 是否显示边的光晕
|
|
55
63
|
*
|
|
@@ -84,19 +92,21 @@ export interface BaseEdgeStyleProps
|
|
|
84
92
|
*/
|
|
85
93
|
endArrowOffset?: number;
|
|
86
94
|
/**
|
|
87
|
-
* <zh/> 边的起点
|
|
95
|
+
* <zh/> 边的起点 ID
|
|
88
96
|
*
|
|
89
|
-
* <en/> The
|
|
90
|
-
* @
|
|
97
|
+
* <en/> The ID of the source node
|
|
98
|
+
* @remarks
|
|
99
|
+
* <zh/> 该属性指向物理意义上的起点,由 G6 内部维护,用户无需过多关注。通常情况下,`sourceNode` 与上一级的 `source` 属性一致。但在某些情况下,`sourceNode` 可能会被 G6 内部转换,例如在 Combo 收起时内部节点上的边会自动连接到父 Combo,此时 `sourceNode` 会变更为父 Combo 的 ID。
|
|
100
|
+
*
|
|
101
|
+
* <en/> This property concerning the physical origin, maintained internally by G6. In general, `sourceNode` corresponds to the `source` attribute of the parent level. However, in certain cases, such as when a Combo is collapsed and internal nodes are destroyed, corresponding edges will automatically connect to the parent Combo. At this point, `sourceNode` will be changed to the ID of the parent Combo
|
|
91
102
|
*/
|
|
92
|
-
sourceNode:
|
|
103
|
+
sourceNode: ID;
|
|
93
104
|
/**
|
|
94
105
|
* <zh/> 边的终点 shape
|
|
95
106
|
*
|
|
96
107
|
* <en/> The source shape. Represents the start of the edge
|
|
97
|
-
* @internal
|
|
98
108
|
*/
|
|
99
|
-
targetNode:
|
|
109
|
+
targetNode: ID;
|
|
100
110
|
/**
|
|
101
111
|
* <zh/> 边起始连接的 port
|
|
102
112
|
*
|
|
@@ -157,7 +167,7 @@ type ParsedBaseEdgeStyleProps = Required<BaseEdgeStyleProps>;
|
|
|
157
167
|
*
|
|
158
168
|
* <en/> Base class of the edge
|
|
159
169
|
*/
|
|
160
|
-
export abstract class BaseEdge extends
|
|
170
|
+
export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> {
|
|
161
171
|
public type = 'edge';
|
|
162
172
|
|
|
163
173
|
static defaultStyleProps: Partial<BaseEdgeStyleProps> = {
|
|
@@ -178,6 +188,7 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
|
|
|
178
188
|
haloPointerEvents: 'none',
|
|
179
189
|
haloStrokeOpacity: 0.25,
|
|
180
190
|
haloZIndex: -1,
|
|
191
|
+
loop: true,
|
|
181
192
|
startArrow: false,
|
|
182
193
|
startArrowSize: 8,
|
|
183
194
|
startArrowLineDash: 0,
|
|
@@ -198,10 +209,22 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
|
|
|
198
209
|
super(deepMix({}, { style: BaseEdge.defaultStyleProps }, options));
|
|
199
210
|
}
|
|
200
211
|
|
|
212
|
+
protected get sourceNode() {
|
|
213
|
+
const { context, sourceNode: source } = this.parsedAttributes;
|
|
214
|
+
return context.element!.getElement<Node>(source)!;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
protected get targetNode() {
|
|
218
|
+
const { context, targetNode: target } = this.parsedAttributes;
|
|
219
|
+
return context.element!.getElement<Node>(target)!;
|
|
220
|
+
}
|
|
221
|
+
|
|
201
222
|
protected getKeyStyle(attributes: ParsedBaseEdgeStyleProps): PathStyleProps {
|
|
202
|
-
const {
|
|
223
|
+
const { loop, ...style } = this.getGraphicStyle(attributes);
|
|
224
|
+
const { sourceNode, targetNode } = this;
|
|
225
|
+
|
|
226
|
+
const d = loop && isSameNode(sourceNode, targetNode) ? this.getLoopPath(attributes) : this.getKeyPath(attributes);
|
|
203
227
|
|
|
204
|
-
const d = isSameNode(sourceNode, targetNode) ? this.getLoopPath(attributes) : this.getKeyPath(attributes);
|
|
205
228
|
return {
|
|
206
229
|
d,
|
|
207
230
|
...omitStyleProps(style, ['halo', 'label', 'startArrow', 'endArrow']),
|
|
@@ -211,7 +234,8 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
|
|
|
211
234
|
protected abstract getKeyPath(attributes: ParsedBaseEdgeStyleProps): PathArray;
|
|
212
235
|
|
|
213
236
|
protected getLoopPath(attributes: ParsedBaseEdgeStyleProps): PathArray {
|
|
214
|
-
const {
|
|
237
|
+
const { sourcePort, targetPort } = attributes;
|
|
238
|
+
const node = this.sourceNode;
|
|
215
239
|
|
|
216
240
|
const bbox = getNodeBBox(node);
|
|
217
241
|
const defaultDist = Math.max(getBBoxWidth(bbox), getBBoxHeight(bbox));
|
|
@@ -226,7 +250,8 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
|
|
|
226
250
|
}
|
|
227
251
|
|
|
228
252
|
protected getEndpoints(attributes: ParsedBaseEdgeStyleProps): [Point, Point] {
|
|
229
|
-
const {
|
|
253
|
+
const { sourcePort: sourcePortKey, targetPort: targetPortKey } = attributes;
|
|
254
|
+
const { sourceNode, targetNode } = this;
|
|
230
255
|
|
|
231
256
|
const [sourcePort, targetPort] = findPorts(sourceNode, targetNode, sourcePortKey, targetPortKey);
|
|
232
257
|
|
|
@@ -278,7 +303,7 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
|
|
|
278
303
|
? (['markerStart', 'markerStartOffset', 'startArrowOffset'] as const)
|
|
279
304
|
: (['markerEnd', 'markerEndOffset', 'endArrowOffset'] as const);
|
|
280
305
|
|
|
281
|
-
const arrow = keyShape.
|
|
306
|
+
const arrow = keyShape.parsedStyle[marker];
|
|
282
307
|
// update
|
|
283
308
|
if (arrow) arrow.attr(arrowStyle);
|
|
284
309
|
// create
|
|
@@ -340,39 +365,26 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
|
|
|
340
365
|
this.drawHaloShape(attributes, container);
|
|
341
366
|
}
|
|
342
367
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
*/
|
|
349
|
-
public onCreate() {}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* <zh/> 在元素更新并执行完过渡动画后调用
|
|
353
|
-
*
|
|
354
|
-
* <en/> Called after the element is updated and the transition animation is completed
|
|
355
|
-
* @override
|
|
356
|
-
*/
|
|
357
|
-
public onUpdate() {}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* <zh/> 在元素完成退场动画并销毁后调用
|
|
361
|
-
*
|
|
362
|
-
* <en/> Called after the element completes the exit animation and is destroyed
|
|
363
|
-
* @override
|
|
364
|
-
*/
|
|
365
|
-
public onDestroy() {}
|
|
368
|
+
protected onframe() {
|
|
369
|
+
this.drawKeyShape(this.parsedAttributes, this);
|
|
370
|
+
this.drawHaloShape(this.parsedAttributes, this);
|
|
371
|
+
this.drawLabelShape(this.parsedAttributes, this);
|
|
372
|
+
}
|
|
366
373
|
|
|
367
374
|
public animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions) {
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
375
|
+
const animation = super.animate(keyframes, options);
|
|
376
|
+
|
|
377
|
+
if (!animation) return animation;
|
|
378
|
+
|
|
379
|
+
// 设置 currentTime 时触发更新
|
|
380
|
+
// Trigger update when setting currentTime
|
|
381
|
+
return new Proxy(animation, {
|
|
382
|
+
set: (target, propKey, value) => {
|
|
383
|
+
// 需要推迟 onframe 调用时机,等待节点位置更新完成
|
|
384
|
+
// Need to delay the timing of the onframe call, wait for the node position update to complete
|
|
385
|
+
if (propKey === 'currentTime') Promise.resolve().then(() => this.onframe());
|
|
386
|
+
return Reflect.set(target, propKey, value);
|
|
387
|
+
},
|
|
388
|
+
});
|
|
377
389
|
}
|
|
378
390
|
}
|
|
@@ -74,7 +74,8 @@ export class Polyline extends BaseEdge {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
protected getKeyPath(attributes: ParsedPolylineStyleProps): PathArray {
|
|
77
|
-
const {
|
|
77
|
+
const { radius } = attributes;
|
|
78
|
+
const { sourceNode, targetNode } = this;
|
|
78
79
|
// 1. 获取连接点(若有连接桩,取连接桩中心;反之,取节点中心)和连接桩 | Get connection points (if port, take port center; otherwise, take node center) and ports
|
|
79
80
|
const { sourcePoint, targetPoint, sourcePort, targetPort } = this.getEndpointsAndPorts(attributes);
|
|
80
81
|
|
|
@@ -98,7 +99,8 @@ export class Polyline extends BaseEdge {
|
|
|
98
99
|
sourcePort: Port | undefined;
|
|
99
100
|
targetPort: Port | undefined;
|
|
100
101
|
} {
|
|
101
|
-
const {
|
|
102
|
+
const { sourcePort: sourcePortKey, targetPort: targetPortKey } = attributes;
|
|
103
|
+
const { sourceNode, targetNode } = this;
|
|
102
104
|
|
|
103
105
|
const [sourcePort, targetPort] = findPorts(sourceNode, targetNode, sourcePortKey, targetPortKey);
|
|
104
106
|
|
|
@@ -111,7 +113,8 @@ export class Polyline extends BaseEdge {
|
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
protected getControlPoints(attributes: ParsedPolylineStyleProps, sourcePoint: Point, targetPoint: Point): Point[] {
|
|
114
|
-
const { controlPoints,
|
|
116
|
+
const { controlPoints, router, routerPadding } = attributes;
|
|
117
|
+
const { sourceNode, targetNode } = this;
|
|
115
118
|
|
|
116
119
|
if (!router) return [...controlPoints];
|
|
117
120
|
|
|
@@ -122,7 +125,8 @@ export class Polyline extends BaseEdge {
|
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
protected getLoopPath(attributes: ParsedPolylineStyleProps): PathArray {
|
|
125
|
-
const {
|
|
128
|
+
const { sourcePort: sourcePortKey, targetPort: targetPortKey, radius } = attributes;
|
|
129
|
+
const node = this.sourceNode;
|
|
126
130
|
|
|
127
131
|
const bbox = getNodeBBox(node);
|
|
128
132
|
// 默认转折点距离为 bbox 的最大宽高的 1/4 | Default distance of the turning point is 1/4 of the maximum width and height of the bbox
|
|
@@ -5,8 +5,7 @@ import type { CategoricalPalette } from '../../palettes/types';
|
|
|
5
5
|
import type { NodeData } from '../../spec';
|
|
6
6
|
import type {
|
|
7
7
|
BaseElementStyleProps,
|
|
8
|
-
|
|
9
|
-
Node,
|
|
8
|
+
ID,
|
|
10
9
|
NodeBadgeStyleProps,
|
|
11
10
|
NodeLabelStyleProps,
|
|
12
11
|
NodePortStyleProps,
|
|
@@ -25,8 +24,9 @@ import { omitStyleProps, subObject, subStyleProps } from '../../utils/prefix';
|
|
|
25
24
|
import { parseSize } from '../../utils/size';
|
|
26
25
|
import { getWordWrapWidthByBox } from '../../utils/text';
|
|
27
26
|
import { replaceTranslateInTransform } from '../../utils/transform';
|
|
27
|
+
import { BaseElement } from '../base-element';
|
|
28
28
|
import type { BadgeStyleProps, IconStyleProps, LabelStyleProps } from '../shapes';
|
|
29
|
-
import { Badge,
|
|
29
|
+
import { Badge, Icon, Label } from '../shapes';
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* <zh/> 节点通用样式配置项
|
|
@@ -83,7 +83,7 @@ export interface BaseNodeStyleProps
|
|
|
83
83
|
*
|
|
84
84
|
* <en/> Only valid in the tree graph
|
|
85
85
|
*/
|
|
86
|
-
childrenNode?:
|
|
86
|
+
childrenNode?: ID[];
|
|
87
87
|
/**
|
|
88
88
|
* <zh/> 子节点数据
|
|
89
89
|
*
|
|
@@ -184,7 +184,7 @@ export interface BaseNodeStyleProps
|
|
|
184
184
|
*
|
|
185
185
|
* <en/> Design document: https://www.yuque.com/antv/g6/gl1iof1xpzg6ed98
|
|
186
186
|
*/
|
|
187
|
-
export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps> extends
|
|
187
|
+
export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps> extends BaseElement<S> {
|
|
188
188
|
public type = 'node';
|
|
189
189
|
|
|
190
190
|
static defaultStyleProps: Partial<BaseNodeStyleProps> = {
|
|
@@ -221,10 +221,6 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
221
221
|
super(deepMix({}, { style: BaseNode.defaultStyleProps }, options));
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
public get parsedAttributes() {
|
|
225
|
-
return this.attributes as Required<S>;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
224
|
protected getSize(attributes = this.attributes) {
|
|
229
225
|
const { size } = attributes;
|
|
230
226
|
return parseSize(size);
|
|
@@ -299,8 +295,8 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
299
295
|
|
|
300
296
|
protected getBadgeStyle(style: NodeBadgeStyleProps): NodeBadgeStyleProps {
|
|
301
297
|
const keyShape = this.getKey();
|
|
302
|
-
const { placement = 'top', ...restStyle } = style;
|
|
303
|
-
const textStyle = getTextStyleByPlacement(keyShape.getLocalBounds(), placement, true);
|
|
298
|
+
const { placement = 'top', offsetX, offsetY, ...restStyle } = style;
|
|
299
|
+
const textStyle = getTextStyleByPlacement(keyShape.getLocalBounds(), placement, offsetX, offsetY, true);
|
|
304
300
|
return { ...textStyle, ...restStyle };
|
|
305
301
|
}
|
|
306
302
|
|
|
@@ -379,6 +375,10 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
379
375
|
);
|
|
380
376
|
}
|
|
381
377
|
|
|
378
|
+
protected drawIconShape(attributes: Required<S>, container: Group): void {
|
|
379
|
+
this.upsert('icon', Icon, this.getIconStyle(attributes), container);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
382
|
protected drawBadgeShapes(attributes: Required<S>, container: Group): void {
|
|
383
383
|
const badgesStyle = this.getBadgesStyle(attributes);
|
|
384
384
|
Object.keys(badgesStyle).forEach((key) => {
|
|
@@ -393,6 +393,10 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
393
393
|
});
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
+
protected drawLabelShape(attributes: Required<S>, container: Group): void {
|
|
397
|
+
this.upsert('label', Label, this.getLabelStyle(attributes), container);
|
|
398
|
+
}
|
|
399
|
+
|
|
396
400
|
protected abstract drawKeyShape(attributes: Required<S>, container: Group): DisplayObject | undefined;
|
|
397
401
|
|
|
398
402
|
public render(attributes = this.parsedAttributes, container: Group = this) {
|
|
@@ -410,51 +414,20 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
410
414
|
this.drawHaloShape(attributes, container);
|
|
411
415
|
|
|
412
416
|
// 3. icon
|
|
413
|
-
this.
|
|
417
|
+
this.drawIconShape(attributes, container);
|
|
414
418
|
|
|
415
419
|
// 4. badges
|
|
416
420
|
this.drawBadgeShapes(attributes, container);
|
|
417
421
|
|
|
418
422
|
// 5. label
|
|
419
|
-
this.
|
|
423
|
+
this.drawLabelShape(attributes, container);
|
|
420
424
|
|
|
421
425
|
// 6. ports
|
|
422
426
|
this.drawPortShapes(attributes, container);
|
|
423
427
|
}
|
|
424
428
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
* <en/> Called after the element is created and the entrance animation is completed
|
|
429
|
-
* @override
|
|
430
|
-
*/
|
|
431
|
-
public onCreate() {}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* <zh/> 在元素更新并执行完过渡动画后调用
|
|
435
|
-
*
|
|
436
|
-
* <en/> Called after the element is updated and the transition animation is completed
|
|
437
|
-
* @override
|
|
438
|
-
*/
|
|
439
|
-
public onUpdate() {}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* <zh/> 在元素完成退场动画并销毁后调用
|
|
443
|
-
*
|
|
444
|
-
* <en/> Called after the element completes the exit animation and is destroyed
|
|
445
|
-
* @override
|
|
446
|
-
*/
|
|
447
|
-
public onDestroy() {}
|
|
448
|
-
|
|
449
|
-
public animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions) {
|
|
450
|
-
const result = super.animate(keyframes, options);
|
|
451
|
-
|
|
452
|
-
if (result) {
|
|
453
|
-
result.onframe = () => {
|
|
454
|
-
this.drawBadgeShapes(this.parsedAttributes, this);
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return result;
|
|
429
|
+
protected onframe() {
|
|
430
|
+
this.drawBadgeShapes(this.parsedAttributes, this);
|
|
431
|
+
this.drawLabelShape(this.parsedAttributes, this);
|
|
459
432
|
}
|
|
460
433
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
2
|
DisplayObjectConfig,
|
|
3
3
|
FederatedMouseEvent,
|
|
4
|
+
FederatedPointerEvent,
|
|
5
|
+
HTML as GHTML,
|
|
4
6
|
HTMLStyleProps as GHTMLStyleProps,
|
|
5
7
|
Group,
|
|
6
8
|
ICanvas,
|
|
7
9
|
IEventTarget,
|
|
10
|
+
Rect,
|
|
8
11
|
} from '@antv/g';
|
|
9
|
-
import { FederatedPointerEvent, HTML as GHTML } from '@antv/g';
|
|
10
12
|
import { isNil, isUndefined, pick } from '@antv/util';
|
|
11
13
|
import { NodeEvent } from '../../constants';
|
|
12
14
|
import type { BaseNodeStyleProps } from './base-node';
|
|
@@ -73,7 +75,10 @@ export class HTML extends BaseNode<HTMLStyleProps> {
|
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
protected drawKeyShape(attributes: Required<HTMLStyleProps>, container: Group) {
|
|
76
|
-
|
|
78
|
+
const style = this.getKeyStyle(attributes);
|
|
79
|
+
const { width, height } = style;
|
|
80
|
+
const bounds = this.upsert('key-container', Rect, { width, height, opacity: 0 }, container);
|
|
81
|
+
return this.upsert('key', GHTML, style, bounds);
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
public connectedCallback() {
|
|
@@ -90,12 +95,13 @@ export class HTML extends BaseNode<HTMLStyleProps> {
|
|
|
90
95
|
}
|
|
91
96
|
}
|
|
92
97
|
|
|
93
|
-
public
|
|
98
|
+
public destroy() {
|
|
94
99
|
const element = this.getDomElement();
|
|
95
100
|
this.events.forEach((eventName) => {
|
|
96
101
|
// @ts-expect-error assert event is PointerEvent
|
|
97
102
|
element.removeEventListener(eventName, this.forwardEvents);
|
|
98
103
|
});
|
|
104
|
+
super.destroy();
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
private forwardEvents = (nativeEvent: PointerEvent) => {
|
|
@@ -240,4 +246,11 @@ export class HTML extends BaseNode<HTMLStyleProps> {
|
|
|
240
246
|
}
|
|
241
247
|
return { x, y };
|
|
242
248
|
}
|
|
249
|
+
|
|
250
|
+
protected onframe(): void {
|
|
251
|
+
super.onframe();
|
|
252
|
+
// sync opacity
|
|
253
|
+
const { opacity } = this.attributes;
|
|
254
|
+
this.getDomElement().style.opacity = `${opacity}`;
|
|
255
|
+
}
|
|
243
256
|
}
|
|
@@ -109,12 +109,30 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
|
|
|
109
109
|
return style;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Get the prefix pairs for composite shapes used to handle animation
|
|
114
|
+
* @returns tuples array where each tuple contains a key corresponding to a method `get${key}Style` and its shape prefix
|
|
115
|
+
*/
|
|
116
|
+
protected get compositeShapes(): [string, string][] {
|
|
117
|
+
return [
|
|
118
|
+
['badges', 'badge-'],
|
|
119
|
+
['ports', 'port-'],
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
* <zh/> 是否自动托管动画
|
|
125
|
+
*
|
|
126
|
+
* <en/> Whether to automatically host animation
|
|
127
|
+
*/
|
|
128
|
+
protected hostingAnimation = true;
|
|
129
|
+
|
|
112
130
|
public animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions): IAnimation | null {
|
|
113
131
|
if (keyframes.length === 0) return null;
|
|
114
|
-
|
|
115
132
|
const animationMap: IAnimation[] = [];
|
|
116
133
|
|
|
117
134
|
const result = super.animate(keyframes, options);
|
|
135
|
+
if (!this.hostingAnimation) return result;
|
|
118
136
|
if (result) animationMap.push(result);
|
|
119
137
|
|
|
120
138
|
if (Array.isArray(keyframes) && keyframes.length > 0) {
|
|
@@ -132,17 +150,12 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
|
|
|
132
150
|
const subKeyframes: Keyframe[] = keyframes.map((style) =>
|
|
133
151
|
method.call(this, { ...this.attributes, ...style }),
|
|
134
152
|
);
|
|
135
|
-
|
|
136
153
|
const result = shape.animate(preprocessKeyframes(subKeyframes), options);
|
|
137
154
|
if (result) animationMap.push(result);
|
|
138
155
|
}
|
|
139
156
|
});
|
|
140
157
|
|
|
141
|
-
|
|
142
|
-
const badges = subObject(this.shapeMap, 'badge-');
|
|
143
|
-
const ports = subObject(this.shapeMap, 'port-');
|
|
144
|
-
|
|
145
|
-
const handleShapeSet = (shapeSet: Record<string, DisplayObject>, name: string) => {
|
|
158
|
+
const handleCompositeShapeAnimation = (shapeSet: Record<string, DisplayObject>, name: string) => {
|
|
146
159
|
if (!isEmpty(shapeSet)) {
|
|
147
160
|
const methodName = `get${upperFirst(name)}Style` as keyof this;
|
|
148
161
|
const method = this[methodName];
|
|
@@ -160,8 +173,10 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
|
|
|
160
173
|
}
|
|
161
174
|
};
|
|
162
175
|
|
|
163
|
-
|
|
164
|
-
|
|
176
|
+
this.compositeShapes.forEach(([key, prefix]) => {
|
|
177
|
+
const shapeSet = subObject(this.shapeMap, prefix);
|
|
178
|
+
handleCompositeShapeAnimation(shapeSet, key);
|
|
179
|
+
});
|
|
165
180
|
}
|
|
166
181
|
}
|
|
167
182
|
|
package/src/exports.ts
CHANGED
|
@@ -103,7 +103,7 @@ export type {
|
|
|
103
103
|
RandomLayoutOptions,
|
|
104
104
|
} from '@antv/layout';
|
|
105
105
|
export type { PathArray } from '@antv/util';
|
|
106
|
-
export type { AnimationContext, AnimationEffectTiming, AnimationExecutor } from './animations/types';
|
|
106
|
+
export type { AnimationContext, AnimationEffectTiming, AnimationExecutor, AnimationOptions } from './animations/types';
|
|
107
107
|
export type {
|
|
108
108
|
BaseBehaviorOptions,
|
|
109
109
|
BrushSelectOptions,
|
|
@@ -150,7 +150,7 @@ export type {
|
|
|
150
150
|
PolygonStyleProps,
|
|
151
151
|
} from './elements/shapes';
|
|
152
152
|
export type { ContourLabelStyleProps, ContourStyleProps } from './elements/shapes/contour';
|
|
153
|
-
export type {
|
|
153
|
+
export type { BaseLayoutOptions, WebWorkerLayoutOptions } from './layouts/types';
|
|
154
154
|
export type { CategoricalPalette } from './palettes/types';
|
|
155
155
|
export type {
|
|
156
156
|
BasePluginOptions,
|
|
@@ -183,6 +183,7 @@ export type {
|
|
|
183
183
|
ViewportOptions,
|
|
184
184
|
} from './spec';
|
|
185
185
|
export type { CustomBehaviorOption } from './spec/behavior';
|
|
186
|
+
export type { AnimationStage } from './spec/element/animation';
|
|
186
187
|
export type { LayoutOptions, STDLayoutOptions, SingleLayoutOptions } from './spec/layout';
|
|
187
188
|
export type { CustomPluginOption } from './spec/plugin';
|
|
188
189
|
export type { BaseTransformOptions } from './transforms';
|
package/src/layouts/types.ts
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { omit } from '@antv/util';
|
|
2
|
+
import type { RuntimeContext } from '../../runtime/types';
|
|
3
|
+
import { createPluginContainer } from '../../utils/dom';
|
|
4
|
+
import type { BasePluginOptions } from '../base-plugin';
|
|
5
|
+
import { BasePlugin } from '../base-plugin';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* <zh/> 背景配置项
|
|
9
|
+
*
|
|
10
|
+
* <en/> Background options
|
|
11
|
+
*/
|
|
12
|
+
export interface BackgroundOptions extends BasePluginOptions, CSSStyleDeclaration {}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* <zh/> 背景图
|
|
16
|
+
*
|
|
17
|
+
* <en/> Background image
|
|
18
|
+
* @remarks
|
|
19
|
+
* <zh/> 支持为图画布设置一个背景图片,让画布更有层次感、叙事性。
|
|
20
|
+
*
|
|
21
|
+
* <en/> Support setting a background image for the canvas to make the canvas more hierarchical and narrative.
|
|
22
|
+
*/
|
|
23
|
+
export class Background extends BasePlugin<BackgroundOptions> {
|
|
24
|
+
static defaultOptions: Partial<BackgroundOptions> = {
|
|
25
|
+
transition: 'background 0.5s',
|
|
26
|
+
backgroundSize: 'cover',
|
|
27
|
+
opacity: '0.35',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
private $element: HTMLElement = createPluginContainer('background');
|
|
31
|
+
|
|
32
|
+
constructor(context: RuntimeContext, options: BackgroundOptions) {
|
|
33
|
+
super(context, Object.assign({}, Background.defaultOptions, options));
|
|
34
|
+
|
|
35
|
+
const $container = this.context.canvas.getContainer();
|
|
36
|
+
$container!.appendChild(this.$element);
|
|
37
|
+
|
|
38
|
+
this.update(options);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* <zh/> 更新背景图配置
|
|
43
|
+
*
|
|
44
|
+
* <en/> Update the background image configuration
|
|
45
|
+
* @param options - <zh/> 配置项 | <en/> Options
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
public async update(options: Partial<BackgroundOptions>) {
|
|
49
|
+
super.update(options);
|
|
50
|
+
|
|
51
|
+
// Set the background style.
|
|
52
|
+
Object.assign(this.$element.style, omit(this.options, ['key', 'type']));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* <zh/> 销毁背景图
|
|
57
|
+
*
|
|
58
|
+
* <en/> Destroy the background image
|
|
59
|
+
*/
|
|
60
|
+
public destroy(): void {
|
|
61
|
+
super.destroy();
|
|
62
|
+
// Remove the background dom.
|
|
63
|
+
this.$element.remove();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { RuntimeContext } from '
|
|
2
|
-
import type { IElementEvent } from '
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
1
|
+
import type { RuntimeContext } from '../../runtime/types';
|
|
2
|
+
import type { IElementEvent } from '../../types/event';
|
|
3
|
+
import { createPluginContainer, insertDOM } from '../../utils/dom';
|
|
4
|
+
import type { BasePluginOptions } from '../base-plugin';
|
|
5
|
+
import { BasePlugin } from '../base-plugin';
|
|
6
|
+
import type { Item } from './util';
|
|
7
|
+
import { CONTEXTMENU_CSS, getContentFromItems } from './util';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* <zh/> 上下文菜单配置项
|