@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
package/src/runtime/element.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/* eslint-disable jsdoc/require-returns */
|
|
2
2
|
/* eslint-disable jsdoc/require-param */
|
|
3
|
-
import type { BaseStyleProps
|
|
3
|
+
import type { BaseStyleProps } from '@antv/g';
|
|
4
4
|
import { Group } from '@antv/g';
|
|
5
|
-
import {
|
|
6
|
-
import { executor as animationExecutor } from '../animations';
|
|
7
|
-
import type { AnimationContext } from '../animations/types';
|
|
5
|
+
import { groupBy, isEmpty, isString } from '@antv/util';
|
|
8
6
|
import { AnimationType, COMBO_KEY, ChangeType, GraphEvent } from '../constants';
|
|
9
7
|
import { ELEMENT_TYPES } from '../constants/element';
|
|
10
8
|
import { getExtension } from '../registry';
|
|
@@ -12,7 +10,6 @@ import type { ComboData, EdgeData, NodeData } from '../spec';
|
|
|
12
10
|
import type { AnimationStage } from '../spec/element/animation';
|
|
13
11
|
import type { DrawData, ProcedureData } from '../transforms/types';
|
|
14
12
|
import type {
|
|
15
|
-
AnimatableTask,
|
|
16
13
|
Combo,
|
|
17
14
|
DataChange,
|
|
18
15
|
Edge,
|
|
@@ -22,20 +19,20 @@ import type {
|
|
|
22
19
|
ElementType,
|
|
23
20
|
ID,
|
|
24
21
|
Node,
|
|
25
|
-
NodeLikeData,
|
|
26
22
|
State,
|
|
27
23
|
StyleIterationContext,
|
|
28
24
|
} from '../types';
|
|
29
|
-
import {
|
|
30
|
-
import { cacheStyle, getCachedStyle, hasCachedStyle } from '../utils/cache';
|
|
25
|
+
import { cacheStyle, getCachedStyle, hasCachedStyle, setCacheStyle } from '../utils/cache';
|
|
31
26
|
import { reduceDataChanges } from '../utils/change';
|
|
32
|
-
import {
|
|
33
|
-
import { updateStyle } from '../utils/element';
|
|
27
|
+
import { isCollapsed } from '../utils/collapsibility';
|
|
28
|
+
import { markToBeDestroyed, updateStyle } from '../utils/element';
|
|
34
29
|
import type { BaseEvent } from '../utils/event';
|
|
35
30
|
import { AnimateEvent, ElementLifeCycleEvent, GraphLifeCycleEvent, emit } from '../utils/event';
|
|
36
31
|
import { idOf } from '../utils/id';
|
|
37
32
|
import { assignColorByPalette, parsePalette } from '../utils/palette';
|
|
33
|
+
import { positionOf } from '../utils/position';
|
|
38
34
|
import { computeElementCallbackStyle } from '../utils/style';
|
|
35
|
+
import { themeOf } from '../utils/theme';
|
|
39
36
|
import type { RuntimeContext } from './types';
|
|
40
37
|
|
|
41
38
|
export class ElementController {
|
|
@@ -90,11 +87,7 @@ export class ElementController {
|
|
|
90
87
|
}
|
|
91
88
|
|
|
92
89
|
private getTheme(elementType: ElementType) {
|
|
93
|
-
|
|
94
|
-
if (!theme) return {};
|
|
95
|
-
|
|
96
|
-
const themeConfig = getExtension('theme', theme);
|
|
97
|
-
return themeConfig?.[elementType] || {};
|
|
90
|
+
return themeOf(this.context.options)[elementType] || {};
|
|
98
91
|
}
|
|
99
92
|
|
|
100
93
|
public getThemeStyle(elementType: ElementType) {
|
|
@@ -237,76 +230,6 @@ export class ElementController {
|
|
|
237
230
|
return this.container.combo.children as Combo[];
|
|
238
231
|
}
|
|
239
232
|
|
|
240
|
-
private getAnimation(elementType: ElementType, stage: AnimationStage) {
|
|
241
|
-
const { options } = this.context;
|
|
242
|
-
|
|
243
|
-
const userDefined = options?.[elementType]?.animation;
|
|
244
|
-
if (userDefined === false) return false;
|
|
245
|
-
const userDefinedStage = userDefined?.[stage];
|
|
246
|
-
if (userDefinedStage) return userDefinedStage;
|
|
247
|
-
|
|
248
|
-
const themeDefined = this.getTheme(elementType)?.animation;
|
|
249
|
-
if (themeDefined === false) return false;
|
|
250
|
-
const themeDefinedStage = themeDefined?.[stage];
|
|
251
|
-
|
|
252
|
-
return themeDefinedStage ?? false;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
private getAnimationExecutor(
|
|
256
|
-
elementType: ElementType,
|
|
257
|
-
stage: AnimationStage,
|
|
258
|
-
animation: boolean = true,
|
|
259
|
-
context?: Partial<AnimationContext>,
|
|
260
|
-
): AnimationExecutor {
|
|
261
|
-
const { options } = this.context;
|
|
262
|
-
const stageAnimation = get(options, [elementType, 'animation', stage], true);
|
|
263
|
-
|
|
264
|
-
if (options.animation === false || stageAnimation === false || !animation) return () => null;
|
|
265
|
-
|
|
266
|
-
return (
|
|
267
|
-
id: ID,
|
|
268
|
-
shape: Element,
|
|
269
|
-
originalStyle: Record<string, unknown>,
|
|
270
|
-
modifiedStyle?: Record<string, unknown>,
|
|
271
|
-
) => {
|
|
272
|
-
return animationExecutor(
|
|
273
|
-
shape,
|
|
274
|
-
this.getAnimation(elementType, stage),
|
|
275
|
-
{},
|
|
276
|
-
{
|
|
277
|
-
originalStyle,
|
|
278
|
-
modifiedStyle,
|
|
279
|
-
states: this.getElementState(id),
|
|
280
|
-
...context,
|
|
281
|
-
},
|
|
282
|
-
);
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* <zh/> 获取边端点连接上下文
|
|
288
|
-
*
|
|
289
|
-
* <en/> Get edge end context
|
|
290
|
-
* @returns <zh/> 边端点连接上下文 | <en/> edge end context
|
|
291
|
-
* @remarks
|
|
292
|
-
* <zh/> 只提供了最基本的节点示例和连接点位置信息,更多的上下文信息需要在边元素中计算
|
|
293
|
-
*
|
|
294
|
-
* <en/> Only the most basic node instances and connection point position information are provided, and more context information needs to be calculated in the edge element
|
|
295
|
-
*/
|
|
296
|
-
private getEdgeEndsContext(datum: EdgeData) {
|
|
297
|
-
const { model } = this.context;
|
|
298
|
-
const { source, target } = datum;
|
|
299
|
-
const sourceNodeData = model.getElementDataById(source) as NodeLikeData;
|
|
300
|
-
const targetNodeData = model.getElementDataById(target) as NodeLikeData;
|
|
301
|
-
const sourceNode = this.getElement<Node>(
|
|
302
|
-
findActualConnectNodeData(sourceNodeData, (id) => model.getParentData(id, COMBO_KEY)).id,
|
|
303
|
-
);
|
|
304
|
-
const targetNode = this.getElement<Node>(
|
|
305
|
-
findActualConnectNodeData(targetNodeData, (id) => model.getParentData(id, COMBO_KEY)).id,
|
|
306
|
-
);
|
|
307
|
-
return { sourceNode, targetNode };
|
|
308
|
-
}
|
|
309
|
-
|
|
310
233
|
public getElementComputedStyle(elementType: ElementType, datum: ElementDatum) {
|
|
311
234
|
const id = idOf(datum);
|
|
312
235
|
// 优先级(从低到高) Priority (from low to high):
|
|
@@ -319,17 +242,12 @@ export class ElementController {
|
|
|
319
242
|
|
|
320
243
|
const style = Object.assign({}, themeStyle, paletteStyle, dataStyle, defaultStyle, themeStateStyle, stateStyle);
|
|
321
244
|
|
|
322
|
-
if (elementType === '
|
|
323
|
-
Object.assign(style, this.getEdgeEndsContext(datum as EdgeData));
|
|
324
|
-
} else if (elementType === 'combo') {
|
|
245
|
+
if (elementType === 'combo') {
|
|
325
246
|
const childrenData = this.context.model.getChildrenData(id);
|
|
326
247
|
const isCollapsed = !!style.collapsed;
|
|
327
|
-
const childrenNode = isCollapsed
|
|
328
|
-
? []
|
|
329
|
-
: (childrenData.map((child) => this.getElement(idOf(child))).filter(Boolean) as (Node | Combo)[]);
|
|
248
|
+
const childrenNode = isCollapsed ? [] : childrenData.map(idOf).filter((id) => this.getElement(id));
|
|
330
249
|
Object.assign(style, { childrenNode, childrenData });
|
|
331
250
|
}
|
|
332
|
-
|
|
333
251
|
return style;
|
|
334
252
|
}
|
|
335
253
|
|
|
@@ -338,51 +256,40 @@ export class ElementController {
|
|
|
338
256
|
*
|
|
339
257
|
* <en/> start render process
|
|
340
258
|
*/
|
|
341
|
-
public
|
|
259
|
+
public draw(context: DrawContext = { animation: true }) {
|
|
342
260
|
this.init();
|
|
343
261
|
|
|
344
|
-
const data = this.computeChangesAndDrawData();
|
|
345
|
-
if (!data) return;
|
|
262
|
+
const data = this.computeChangesAndDrawData(context);
|
|
263
|
+
if (!data) return null;
|
|
264
|
+
|
|
346
265
|
const { dataChanges, drawData } = data;
|
|
347
266
|
// 计算样式 / Calculate style
|
|
348
267
|
this.computeStyle();
|
|
349
|
-
|
|
350
268
|
// 创建渲染任务 / Create render task
|
|
351
269
|
const { add, update, remove } = drawData;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
270
|
+
this.destroyElements(remove, context);
|
|
271
|
+
this.createElements(add, context);
|
|
272
|
+
this.updateElements(update, context);
|
|
273
|
+
|
|
274
|
+
const { animation, silence } = context;
|
|
355
275
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
276
|
+
return this.context.animation!.animate(
|
|
277
|
+
animation,
|
|
278
|
+
silence
|
|
359
279
|
? {}
|
|
360
280
|
: {
|
|
361
281
|
before: () =>
|
|
362
|
-
this.emit(
|
|
363
|
-
new GraphLifeCycleEvent(GraphEvent.BEFORE_DRAW, { dataChanges, animation: drawContext.animation }),
|
|
364
|
-
drawContext,
|
|
365
|
-
),
|
|
282
|
+
this.emit(new GraphLifeCycleEvent(GraphEvent.BEFORE_DRAW, { dataChanges, animation }), context),
|
|
366
283
|
beforeAnimate: (animation) =>
|
|
367
|
-
this.emit(
|
|
368
|
-
new AnimateEvent(GraphEvent.BEFORE_ANIMATE, AnimationType.DRAW, animation, drawData),
|
|
369
|
-
drawContext,
|
|
370
|
-
),
|
|
284
|
+
this.emit(new AnimateEvent(GraphEvent.BEFORE_ANIMATE, AnimationType.DRAW, animation, drawData), context),
|
|
371
285
|
afterAnimate: (animation) =>
|
|
372
|
-
this.emit(
|
|
373
|
-
|
|
374
|
-
drawContext,
|
|
375
|
-
),
|
|
376
|
-
after: () =>
|
|
377
|
-
this.emit(
|
|
378
|
-
new GraphLifeCycleEvent(GraphEvent.AFTER_DRAW, { dataChanges, animation: drawContext.animation }),
|
|
379
|
-
drawContext,
|
|
380
|
-
),
|
|
286
|
+
this.emit(new AnimateEvent(GraphEvent.AFTER_ANIMATE, AnimationType.DRAW, animation, drawData), context),
|
|
287
|
+
after: () => this.emit(new GraphLifeCycleEvent(GraphEvent.AFTER_DRAW, { dataChanges, animation }), context),
|
|
381
288
|
},
|
|
382
|
-
)
|
|
289
|
+
);
|
|
383
290
|
}
|
|
384
291
|
|
|
385
|
-
private computeChangesAndDrawData() {
|
|
292
|
+
private computeChangesAndDrawData(context: DrawContext) {
|
|
386
293
|
const { model } = this.context;
|
|
387
294
|
const dataChanges = model.getChanges();
|
|
388
295
|
const tasks = reduceDataChanges(dataChanges);
|
|
@@ -425,7 +332,7 @@ export class ElementController {
|
|
|
425
332
|
combos: dataOf<ComboData>(ComboRemoved),
|
|
426
333
|
},
|
|
427
334
|
};
|
|
428
|
-
const drawData = this.transformData(input);
|
|
335
|
+
const drawData = this.transformData(input, context);
|
|
429
336
|
|
|
430
337
|
// 清空变更 / Clear changes
|
|
431
338
|
model.clearChanges();
|
|
@@ -433,22 +340,22 @@ export class ElementController {
|
|
|
433
340
|
return { dataChanges, drawData };
|
|
434
341
|
}
|
|
435
342
|
|
|
436
|
-
private transformData(input: DrawData): DrawData {
|
|
343
|
+
private transformData(input: DrawData, context: DrawContext): DrawData {
|
|
437
344
|
const transforms = this.context.transform.getTransformInstance();
|
|
438
345
|
|
|
439
|
-
return Object.values(transforms).reduce((data, transform) => transform.beforeDraw(data), input);
|
|
346
|
+
return Object.values(transforms).reduce((data, transform) => transform.beforeDraw(data, context), input);
|
|
440
347
|
}
|
|
441
348
|
|
|
442
349
|
private createElement(elementType: ElementType, datum: ElementDatum, context: DrawContext) {
|
|
443
350
|
const id = idOf(datum);
|
|
444
351
|
const currentElement = this.getElement(id);
|
|
445
|
-
if (currentElement) return
|
|
352
|
+
if (currentElement) return;
|
|
446
353
|
const type = this.getElementType(elementType, datum);
|
|
447
354
|
const style = this.getElementComputedStyle(elementType, datum);
|
|
448
355
|
|
|
449
356
|
// get shape constructor
|
|
450
357
|
const Ctor = getExtension(elementType, type);
|
|
451
|
-
if (!Ctor) return
|
|
358
|
+
if (!Ctor) return;
|
|
452
359
|
|
|
453
360
|
this.emit(new ElementLifeCycleEvent(GraphEvent.BEFORE_ELEMENT_CREATE, elementType, datum), context);
|
|
454
361
|
|
|
@@ -465,17 +372,26 @@ export class ElementController {
|
|
|
465
372
|
this.shapeTypeMap[id] = type;
|
|
466
373
|
this.elementMap[id] = element;
|
|
467
374
|
|
|
468
|
-
const {
|
|
469
|
-
|
|
470
|
-
|
|
375
|
+
const { stage = 'enter' } = context;
|
|
376
|
+
|
|
377
|
+
this.context.animation?.add(
|
|
378
|
+
{
|
|
379
|
+
element,
|
|
380
|
+
elementType,
|
|
381
|
+
stage,
|
|
382
|
+
originalStyle: { ...element.attributes },
|
|
383
|
+
modifiedStyle: { ...element.attributes, ...style },
|
|
384
|
+
},
|
|
385
|
+
{
|
|
471
386
|
after: () => {
|
|
472
387
|
this.emit(new ElementLifeCycleEvent(GraphEvent.AFTER_ELEMENT_CREATE, elementType, datum), context);
|
|
473
388
|
element.onCreate();
|
|
474
389
|
},
|
|
475
|
-
}
|
|
390
|
+
},
|
|
391
|
+
);
|
|
476
392
|
}
|
|
477
393
|
|
|
478
|
-
private
|
|
394
|
+
private createElements(data: ProcedureData, context: DrawContext) {
|
|
479
395
|
const { nodes, edges, combos } = data;
|
|
480
396
|
const iteration: [ElementType, Map<ID, ElementDatum>][] = [
|
|
481
397
|
['node', nodes],
|
|
@@ -483,49 +399,18 @@ export class ElementController {
|
|
|
483
399
|
['edge', edges],
|
|
484
400
|
];
|
|
485
401
|
|
|
486
|
-
const tasks: AnimatableTask[] = [];
|
|
487
402
|
iteration.forEach(([elementType, elementData]) => {
|
|
488
|
-
|
|
489
|
-
const animator = this.getAnimationExecutor(elementType, 'enter', context.animation);
|
|
490
|
-
elementData.forEach((datum) =>
|
|
491
|
-
tasks.push(() => this.createElement(elementType, datum, { ...context, animator })),
|
|
492
|
-
);
|
|
403
|
+
elementData.forEach((datum) => this.createElement(elementType, datum, context));
|
|
493
404
|
});
|
|
494
|
-
|
|
495
|
-
return tasks;
|
|
496
405
|
}
|
|
497
406
|
|
|
498
|
-
/**
|
|
499
|
-
* <zh/> 由于 show 和 hide 的时序存在差异
|
|
500
|
-
* - show: 立即将元素显示出来,然后执行动画
|
|
501
|
-
* - hide: 先执行动画,然后隐藏元素
|
|
502
|
-
*
|
|
503
|
-
* 如果在调用 hide 后立即调用 show,hide 动画完成后会将元素隐藏
|
|
504
|
-
*
|
|
505
|
-
* 因此需要缓存元素最新的可见性
|
|
506
|
-
*
|
|
507
|
-
* <en/> Due to the difference in the timing of show and hide
|
|
508
|
-
* - show: immediately shows the element and then executes the animation
|
|
509
|
-
* - hide: executes the animation first, and then hides the element
|
|
510
|
-
*
|
|
511
|
-
* If show is called immediately after hide,it hide the element after hide animation completed
|
|
512
|
-
*
|
|
513
|
-
* Therefore, the latest visibility of the element needs to be cached
|
|
514
|
-
*/
|
|
515
|
-
private latestElementVisibilityMap: WeakMap<DisplayObject, BaseStyleProps['visibility']> = new WeakMap();
|
|
516
|
-
|
|
517
407
|
private updateElement(elementType: ElementType, datum: ElementDatum, context: DrawContext) {
|
|
518
|
-
const { animator } = context;
|
|
519
|
-
|
|
520
408
|
const id = idOf(datum);
|
|
409
|
+
|
|
521
410
|
const element = this.getElement(id);
|
|
522
411
|
if (!element) return () => null;
|
|
523
412
|
|
|
524
413
|
this.emit(new ElementLifeCycleEvent(GraphEvent.BEFORE_ELEMENT_UPDATE, elementType, datum), context);
|
|
525
|
-
const afterUpdate = () => {
|
|
526
|
-
this.emit(new ElementLifeCycleEvent(GraphEvent.AFTER_ELEMENT_UPDATE, elementType, datum), context);
|
|
527
|
-
element.onUpdate();
|
|
528
|
-
};
|
|
529
414
|
|
|
530
415
|
const type = this.getElementType(elementType, datum);
|
|
531
416
|
const style = this.getElementComputedStyle(elementType, datum);
|
|
@@ -533,67 +418,49 @@ export class ElementController {
|
|
|
533
418
|
// 如果类型不同,需要先销毁原有元素,再创建新元素
|
|
534
419
|
// If the type is different, you need to destroy the original element first, and then create a new element
|
|
535
420
|
if (this.shapeTypeMap[id] !== type) {
|
|
536
|
-
|
|
537
|
-
this.
|
|
538
|
-
|
|
539
|
-
afterUpdate();
|
|
540
|
-
return null;
|
|
541
|
-
};
|
|
542
|
-
}
|
|
421
|
+
element.destroy();
|
|
422
|
+
delete this.shapeTypeMap[id];
|
|
423
|
+
delete this.elementMap[id];
|
|
543
424
|
|
|
544
|
-
|
|
545
|
-
if (context.stage === 'visibility' && 'visibility' in style) {
|
|
546
|
-
// 缓存原始透明度 / Cache original opacity
|
|
547
|
-
if (!hasCachedStyle(element, 'opacity')) cacheStyle(element, 'opacity');
|
|
548
|
-
|
|
549
|
-
const originalOpacity = getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity');
|
|
550
|
-
this.latestElementVisibilityMap.set(element, style.visibility);
|
|
551
|
-
|
|
552
|
-
// show
|
|
553
|
-
if (style.visibility !== 'hidden') {
|
|
554
|
-
updateStyle(element, { visibility: 'visible' });
|
|
555
|
-
return () =>
|
|
556
|
-
withAnimationCallbacks(
|
|
557
|
-
animator?.(id, element, { ...element.attributes, opacity: 0 }, { opacity: originalOpacity }),
|
|
558
|
-
{ after: afterUpdate },
|
|
559
|
-
);
|
|
560
|
-
}
|
|
561
|
-
// hide
|
|
562
|
-
else if (style.visibility === 'hidden') {
|
|
563
|
-
return () =>
|
|
564
|
-
withAnimationCallbacks(
|
|
565
|
-
animator?.(id, element, { ...element.attributes, opacity: originalOpacity }, { opacity: 0 }),
|
|
566
|
-
{
|
|
567
|
-
after: () => {
|
|
568
|
-
updateStyle(element, { visibility: this.latestElementVisibilityMap.get(element) });
|
|
569
|
-
afterUpdate();
|
|
570
|
-
},
|
|
571
|
-
},
|
|
572
|
-
);
|
|
573
|
-
}
|
|
425
|
+
this.createElement(elementType, datum, { animation: false, silence: true });
|
|
574
426
|
}
|
|
575
427
|
|
|
576
|
-
const
|
|
577
|
-
updateStyle(element, style);
|
|
428
|
+
const { stage = 'update' } = context;
|
|
578
429
|
|
|
579
|
-
|
|
580
|
-
// If the endpoint node of the edge has been destroyed, update the endpoint node
|
|
581
|
-
if (elementType === 'edge') {
|
|
582
|
-
if (originalStyle.sourceNode.destroyed) {
|
|
583
|
-
originalStyle.sourceNode = style.sourceNode;
|
|
584
|
-
}
|
|
585
|
-
if (originalStyle.targetNode.destroyed) {
|
|
586
|
-
originalStyle.targetNode = style.targetNode;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
430
|
+
const exactStage = stage !== 'visibility' ? stage : style.visibility === 'hidden' ? 'hide' : 'show';
|
|
589
431
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
432
|
+
this.context.animation?.add(
|
|
433
|
+
{
|
|
434
|
+
element,
|
|
435
|
+
elementType,
|
|
436
|
+
stage: exactStage,
|
|
437
|
+
originalStyle: { ...element.attributes },
|
|
438
|
+
modifiedStyle: { ...element.attributes, ...style },
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
before: () => {
|
|
442
|
+
if (stage !== 'collapse') updateStyle(element, style);
|
|
443
|
+
|
|
444
|
+
if (stage === 'visibility') {
|
|
445
|
+
// 缓存原始透明度 / Cache original opacity
|
|
446
|
+
// 会在 animation controller 中访问该缓存值 / The cached value will be accessed in the animation controller
|
|
447
|
+
if (!hasCachedStyle(element, 'opacity')) cacheStyle(element, 'opacity');
|
|
448
|
+
setCacheStyle(element, 'visibility', exactStage === 'show' ? 'visible' : 'hidden');
|
|
449
|
+
if (exactStage === 'show') updateStyle(element, { visibility: 'visible' });
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
afterAnimate: () => {},
|
|
453
|
+
after: () => {
|
|
454
|
+
if (stage === 'collapse') updateStyle(element, style);
|
|
455
|
+
if (exactStage === 'hide') updateStyle(element, { visibility: getCachedStyle(element, 'visibility') });
|
|
456
|
+
this.emit(new ElementLifeCycleEvent(GraphEvent.AFTER_ELEMENT_UPDATE, elementType, datum), context);
|
|
457
|
+
element.onUpdate();
|
|
458
|
+
},
|
|
459
|
+
},
|
|
460
|
+
);
|
|
594
461
|
}
|
|
595
462
|
|
|
596
|
-
private
|
|
463
|
+
private updateElements(data: ProcedureData, context: DrawContext) {
|
|
597
464
|
const { nodes, edges, combos } = data;
|
|
598
465
|
const iteration: [ElementType, Map<ID, ElementDatum>][] = [
|
|
599
466
|
['node', nodes],
|
|
@@ -601,39 +468,39 @@ export class ElementController {
|
|
|
601
468
|
['edge', edges],
|
|
602
469
|
];
|
|
603
470
|
|
|
604
|
-
const { animation, stage } = context;
|
|
605
|
-
const tasks: AnimatableTask[] = [];
|
|
606
471
|
iteration.forEach(([elementType, elementData]) => {
|
|
607
|
-
|
|
608
|
-
const animator = this.getAnimationExecutor(elementType, stage || 'update', animation);
|
|
609
|
-
elementData.forEach((datum) =>
|
|
610
|
-
tasks.push(() => this.updateElement(elementType, datum, { ...context, animator })),
|
|
611
|
-
);
|
|
472
|
+
elementData.forEach((datum) => this.updateElement(elementType, datum, context));
|
|
612
473
|
});
|
|
613
|
-
|
|
614
|
-
return tasks;
|
|
615
474
|
}
|
|
616
475
|
|
|
617
476
|
private destroyElement(elementType: ElementType, datum: ElementDatum, context: DrawContext) {
|
|
618
|
-
const {
|
|
477
|
+
const { stage = 'exit' } = context;
|
|
619
478
|
const id = idOf(datum);
|
|
620
479
|
const element = this.elementMap[id];
|
|
621
480
|
if (!element) return () => null;
|
|
622
481
|
|
|
623
482
|
this.emit(new ElementLifeCycleEvent(GraphEvent.BEFORE_ELEMENT_DESTROY, elementType, datum), context);
|
|
624
483
|
|
|
625
|
-
|
|
626
|
-
|
|
484
|
+
this.context.animation?.add(
|
|
485
|
+
{
|
|
486
|
+
element,
|
|
487
|
+
elementType,
|
|
488
|
+
stage,
|
|
489
|
+
originalStyle: { ...element.attributes },
|
|
490
|
+
modifiedStyle: { ...element.attributes },
|
|
491
|
+
},
|
|
492
|
+
{
|
|
627
493
|
after: () => {
|
|
628
494
|
this.clearElement(id);
|
|
629
495
|
element.destroy();
|
|
630
496
|
element.onDestroy();
|
|
631
497
|
this.emit(new ElementLifeCycleEvent(GraphEvent.AFTER_ELEMENT_DESTROY, elementType, datum), context);
|
|
632
498
|
},
|
|
633
|
-
}
|
|
499
|
+
},
|
|
500
|
+
);
|
|
634
501
|
}
|
|
635
502
|
|
|
636
|
-
private
|
|
503
|
+
private destroyElements(data: ProcedureData, context: DrawContext) {
|
|
637
504
|
const { nodes, edges, combos } = data;
|
|
638
505
|
const iteration: [ElementType, Map<ID, ElementDatum>][] = [
|
|
639
506
|
['combo', combos],
|
|
@@ -641,19 +508,11 @@ export class ElementController {
|
|
|
641
508
|
['node', nodes],
|
|
642
509
|
];
|
|
643
510
|
|
|
644
|
-
const { animation, stage = 'exit' } = context;
|
|
645
|
-
const tasks: AnimatableTask[] = [];
|
|
646
511
|
iteration.forEach(([elementType, elementData]) => {
|
|
647
|
-
|
|
648
|
-
const animator = this.getAnimationExecutor(elementType, stage, animation);
|
|
649
|
-
elementData.forEach((datum) =>
|
|
650
|
-
tasks.push(() => this.destroyElement(elementType, datum, { ...context, animator })),
|
|
651
|
-
);
|
|
512
|
+
elementData.forEach((datum) => this.destroyElement(elementType, datum, context));
|
|
652
513
|
});
|
|
653
514
|
|
|
654
515
|
// TODO 重新计算色板样式,如果是分组色板,则不需要重新计算
|
|
655
|
-
|
|
656
|
-
return tasks;
|
|
657
516
|
}
|
|
658
517
|
|
|
659
518
|
private clearElement(id: ID) {
|
|
@@ -664,9 +523,192 @@ export class ElementController {
|
|
|
664
523
|
delete this.shapeTypeMap[id];
|
|
665
524
|
}
|
|
666
525
|
|
|
526
|
+
/**
|
|
527
|
+
* <zh/> 收起节点
|
|
528
|
+
*
|
|
529
|
+
* <en/> collapse node
|
|
530
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
531
|
+
* @param animation - <zh/> 是否使用动画,默认为 true | <en/> Whether to use animation, default is true
|
|
532
|
+
*/
|
|
533
|
+
public async collapseNode(id: ID, animation: boolean): Promise<void> {
|
|
534
|
+
const { model, layout } = this.context;
|
|
535
|
+
|
|
536
|
+
const preprocess = this.computeChangesAndDrawData({ stage: 'collapse', animation })!;
|
|
537
|
+
|
|
538
|
+
preprocess.drawData.remove.nodes.forEach((datum) => {
|
|
539
|
+
const id = idOf(datum);
|
|
540
|
+
const element = this.getElement(id);
|
|
541
|
+
if (element) markToBeDestroyed(element);
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// 进行预布局,计算出所有元素的位置
|
|
545
|
+
// Perform pre-layout to calculate the position of all elements
|
|
546
|
+
const result = await layout!.simulate();
|
|
547
|
+
model.updateData(result);
|
|
548
|
+
|
|
549
|
+
// 重新计算数据 / Recalculate data
|
|
550
|
+
const { drawData } = this.computeChangesAndDrawData({ stage: 'collapse', animation })!;
|
|
551
|
+
const { add, remove, update } = drawData;
|
|
552
|
+
|
|
553
|
+
const context = { animation, stage: 'collapse', data: drawData } as const;
|
|
554
|
+
|
|
555
|
+
this.destroyElements(remove, context);
|
|
556
|
+
this.createElements(add, context);
|
|
557
|
+
this.updateElements(update, context);
|
|
558
|
+
|
|
559
|
+
await this.context.animation!.animate(
|
|
560
|
+
animation,
|
|
561
|
+
{
|
|
562
|
+
beforeAnimate: (animation) =>
|
|
563
|
+
this.emit(new AnimateEvent(GraphEvent.BEFORE_ANIMATE, AnimationType.COLLAPSE, animation, drawData), context),
|
|
564
|
+
afterAnimate: (animation) =>
|
|
565
|
+
this.emit(new AnimateEvent(GraphEvent.AFTER_ANIMATE, AnimationType.COLLAPSE, animation, drawData), context),
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
collapse: {
|
|
569
|
+
target: id,
|
|
570
|
+
descendants: Array.from(remove.nodes).map(([, node]) => idOf(node)),
|
|
571
|
+
position: positionOf(update.nodes.get(id)!),
|
|
572
|
+
},
|
|
573
|
+
},
|
|
574
|
+
)?.finished;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* <zh/> 展开节点
|
|
579
|
+
*
|
|
580
|
+
* <en/> expand node
|
|
581
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
582
|
+
* @param animation - <zh/> 是否使用动画,默认为 true | <en/> Whether to use animation, default is true
|
|
583
|
+
*/
|
|
584
|
+
public async expandNode(id: ID, animation: boolean): Promise<void> {
|
|
585
|
+
const { model, layout } = this.context;
|
|
586
|
+
if (!model.getAncestorsData(id, COMBO_KEY).every((datum) => isCollapsed(datum))) return;
|
|
587
|
+
|
|
588
|
+
const position = positionOf(model.getNodeData([id])[0]);
|
|
589
|
+
|
|
590
|
+
// 首先创建展开的元素,然后进行预布局
|
|
591
|
+
// First create the expanded element, then perform pre-layout
|
|
592
|
+
const {
|
|
593
|
+
drawData: { add },
|
|
594
|
+
} = this.computeChangesAndDrawData({ stage: 'collapse', animation })!;
|
|
595
|
+
this.createElements(add, { animation: false, stage: 'expand' });
|
|
596
|
+
// 重置动画 / Reset animation
|
|
597
|
+
this.context.animation!.clear();
|
|
598
|
+
|
|
599
|
+
const result = await layout!.simulate();
|
|
600
|
+
model.updateData(result);
|
|
601
|
+
|
|
602
|
+
// 重新计算数据 / Recalculate data
|
|
603
|
+
this.computeStyle();
|
|
604
|
+
const { drawData } = this.computeChangesAndDrawData({ stage: 'collapse', animation })!;
|
|
605
|
+
const { update } = drawData;
|
|
606
|
+
|
|
607
|
+
const context = { animation, stage: 'expand', data: drawData } as const;
|
|
608
|
+
|
|
609
|
+
// 将新增边添加到更新列表 / Add new edges to the update list
|
|
610
|
+
add.edges.forEach((edge) => {
|
|
611
|
+
const id = idOf(edge);
|
|
612
|
+
if (!update.edges.has(id)) update.edges.set(id, edge);
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
this.updateElements(update, context);
|
|
616
|
+
|
|
617
|
+
await this.context.animation!.animate(
|
|
618
|
+
animation,
|
|
619
|
+
{
|
|
620
|
+
beforeAnimate: (animation) =>
|
|
621
|
+
this.emit(new AnimateEvent(GraphEvent.BEFORE_ANIMATE, AnimationType.EXPAND, animation, drawData), context),
|
|
622
|
+
afterAnimate: (animation) =>
|
|
623
|
+
this.emit(new AnimateEvent(GraphEvent.AFTER_ANIMATE, AnimationType.EXPAND, animation, drawData), context),
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
expand: {
|
|
627
|
+
target: id,
|
|
628
|
+
descendants: Array.from(add.nodes).map(([, node]) => idOf(node)),
|
|
629
|
+
position,
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
)?.finished;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
public async collapseCombo(id: ID, animation: boolean): Promise<void> {
|
|
636
|
+
const { model, element } = this.context;
|
|
637
|
+
if (model.getAncestorsData(id, COMBO_KEY).some((datum) => isCollapsed(datum))) return;
|
|
638
|
+
|
|
639
|
+
const combo = element!.getElement<Combo>(id)!;
|
|
640
|
+
|
|
641
|
+
const position = combo.getComboPosition({
|
|
642
|
+
...combo.attributes,
|
|
643
|
+
collapsed: true,
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
const { dataChanges, drawData } = this.computeChangesAndDrawData({ stage: 'collapse', animation })!;
|
|
647
|
+
|
|
648
|
+
const { update, remove } = drawData;
|
|
649
|
+
const context = { animation, stage: 'collapse', data: drawData } as const;
|
|
650
|
+
|
|
651
|
+
this.destroyElements(remove, context);
|
|
652
|
+
this.updateElements(update, context);
|
|
653
|
+
|
|
654
|
+
const idsOf = (data: Map<ID, ElementDatum>) => Array.from(data).map(([, node]) => idOf(node));
|
|
655
|
+
|
|
656
|
+
await this.context.animation!.animate(
|
|
657
|
+
animation,
|
|
658
|
+
{
|
|
659
|
+
before: () => this.emit(new GraphLifeCycleEvent(GraphEvent.BEFORE_DRAW, { dataChanges, animation }), context),
|
|
660
|
+
beforeAnimate: (animation) =>
|
|
661
|
+
this.emit(new AnimateEvent(GraphEvent.BEFORE_ANIMATE, AnimationType.COLLAPSE, animation, drawData), context),
|
|
662
|
+
afterAnimate: (animation) =>
|
|
663
|
+
this.emit(new AnimateEvent(GraphEvent.AFTER_ANIMATE, AnimationType.COLLAPSE, animation, drawData), context),
|
|
664
|
+
after: () => this.emit(new GraphLifeCycleEvent(GraphEvent.AFTER_DRAW, { dataChanges, animation }), context),
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
collapse: {
|
|
668
|
+
target: id,
|
|
669
|
+
descendants: [...idsOf(remove.nodes), ...idsOf(remove.combos)],
|
|
670
|
+
position,
|
|
671
|
+
},
|
|
672
|
+
},
|
|
673
|
+
)?.finished;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
public async expandCombo(id: ID, animation: boolean): Promise<void> {
|
|
677
|
+
const { model } = this.context;
|
|
678
|
+
const position = positionOf(model.getComboData([id])[0]);
|
|
679
|
+
|
|
680
|
+
// 重新计算数据 / Recalculate data
|
|
681
|
+
this.computeStyle();
|
|
682
|
+
const { dataChanges, drawData } = this.computeChangesAndDrawData({ stage: 'expand', animation })!;
|
|
683
|
+
const { add, update } = drawData;
|
|
684
|
+
const context = { animation, stage: 'expand', data: drawData } as const;
|
|
685
|
+
|
|
686
|
+
this.createElements(add, context);
|
|
687
|
+
this.updateElements(update, context);
|
|
688
|
+
|
|
689
|
+
const idsOf = (data: Map<ID, ElementDatum>) => Array.from(data).map(([, node]) => idOf(node));
|
|
690
|
+
|
|
691
|
+
await this.context.animation!.animate(
|
|
692
|
+
animation,
|
|
693
|
+
{
|
|
694
|
+
before: () => this.emit(new GraphLifeCycleEvent(GraphEvent.BEFORE_DRAW, { dataChanges, animation }), context),
|
|
695
|
+
beforeAnimate: (animation) =>
|
|
696
|
+
this.emit(new AnimateEvent(GraphEvent.BEFORE_ANIMATE, AnimationType.EXPAND, animation, drawData), context),
|
|
697
|
+
afterAnimate: (animation) =>
|
|
698
|
+
this.emit(new AnimateEvent(GraphEvent.AFTER_ANIMATE, AnimationType.EXPAND, animation, drawData), context),
|
|
699
|
+
after: () => this.emit(new GraphLifeCycleEvent(GraphEvent.AFTER_DRAW, { dataChanges, animation }), context),
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
expand: {
|
|
703
|
+
target: id,
|
|
704
|
+
descendants: [...idsOf(add.nodes), ...idsOf(add.combos)],
|
|
705
|
+
position,
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
)?.finished;
|
|
709
|
+
}
|
|
710
|
+
|
|
667
711
|
public destroy() {
|
|
668
|
-
Object.values(this.elementMap).forEach((element) => element.destroy());
|
|
669
|
-
Object.values(this.container).forEach((container) => container.destroy());
|
|
670
712
|
// @ts-expect-error force delete
|
|
671
713
|
this.container = {};
|
|
672
714
|
this.elementMap = {};
|
|
@@ -676,24 +718,16 @@ export class ElementController {
|
|
|
676
718
|
this.paletteStyle = {};
|
|
677
719
|
// @ts-expect-error force delete
|
|
678
720
|
this.context = {};
|
|
679
|
-
// @ts-expect-error force delete
|
|
680
|
-
this.latestElementVisibilityMap = undefined;
|
|
681
721
|
}
|
|
682
722
|
}
|
|
683
723
|
|
|
684
|
-
|
|
685
|
-
id: ID,
|
|
686
|
-
shape: Element,
|
|
687
|
-
originalStyle: Record<string, unknown>,
|
|
688
|
-
modifiedStyle?: Record<string, unknown>,
|
|
689
|
-
) => IAnimation | null;
|
|
690
|
-
|
|
691
|
-
type DrawContext = {
|
|
692
|
-
animator?: AnimationExecutor;
|
|
724
|
+
export interface DrawContext {
|
|
693
725
|
/** <zh/> 是否使用动画,默认为 true | <en/> Whether to use animation, default is true */
|
|
694
726
|
animation: boolean;
|
|
695
727
|
/** <zh/> 当前绘制阶段 | <en/> Current draw stage */
|
|
696
728
|
stage?: AnimationStage;
|
|
697
729
|
/** <zh/> 是否不抛出事件 | <en/> Whether not to throw events */
|
|
698
730
|
silence?: boolean;
|
|
699
|
-
|
|
731
|
+
/** <zh/> 收起/展开的对象 ID | <en/> ID of the object to collapse/expand */
|
|
732
|
+
collapseExpandTarget?: ID;
|
|
733
|
+
}
|