@antv/g6 5.0.0-beta.37 → 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 +2 -1
- 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/{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/canvas.d.ts +0 -2
- 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/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 +2 -1
- package/esm/elements/nodes/html.js +8 -1
- 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/timebar.js +1 -1
- package/esm/plugins/timebar.js.map +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/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.d.ts +0 -2
- package/esm/runtime/canvas.js +0 -21
- 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 +44 -11
- 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/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 +2 -1
- package/lib/elements/nodes/html.js +8 -1
- 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/timebar.js +1 -1
- package/lib/plugins/timebar.js.map +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/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.d.ts +0 -2
- package/lib/runtime/canvas.js +0 -21
- 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 +44 -11
- 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/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 +9 -1
- 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/timebar.ts +1 -1
- package/src/plugins/{watermark.ts → watermark/index.ts} +5 -5
- package/src/registry/build-in.ts +21 -5
- package/src/runtime/animation.ts +186 -0
- package/src/runtime/canvas.ts +0 -24
- package/src/runtime/data.ts +16 -19
- package/src/runtime/element.ts +289 -255
- package/src/runtime/graph.ts +44 -11
- 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/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/graph.ts
CHANGED
|
@@ -41,12 +41,14 @@ import type {
|
|
|
41
41
|
Vector2,
|
|
42
42
|
ViewportAnimationEffectTiming,
|
|
43
43
|
} from '../types';
|
|
44
|
+
import { isCollapsed } from '../utils/collapsibility';
|
|
44
45
|
import { sizeOf } from '../utils/dom';
|
|
45
46
|
import { GraphLifeCycleEvent, emit } from '../utils/event';
|
|
46
47
|
import { idOf } from '../utils/id';
|
|
47
48
|
import { parsePoint, toPointObject } from '../utils/point';
|
|
48
49
|
import { zIndexOf } from '../utils/style';
|
|
49
50
|
import { subtract } from '../utils/vector';
|
|
51
|
+
import { Animation } from './animation';
|
|
50
52
|
import { BatchController } from './batch';
|
|
51
53
|
import { BehaviorController } from './behavior';
|
|
52
54
|
import type { DataURLOptions } from './canvas';
|
|
@@ -415,6 +417,7 @@ export class Graph extends EventEmitter {
|
|
|
415
417
|
return _transform;
|
|
416
418
|
}),
|
|
417
419
|
);
|
|
420
|
+
this.context.model.refreshData();
|
|
418
421
|
}
|
|
419
422
|
|
|
420
423
|
/**
|
|
@@ -824,6 +827,7 @@ export class Graph extends EventEmitter {
|
|
|
824
827
|
if (!this.context.viewport) this.context.viewport = new ViewportController(this.context);
|
|
825
828
|
if (!this.context.transform) this.context.transform = new TransformController(this.context);
|
|
826
829
|
if (!this.context.element) this.context.element = new ElementController(this.context);
|
|
830
|
+
if (!this.context.animation) this.context.animation = new Animation(this.context);
|
|
827
831
|
if (!this.context.layout) this.context.layout = new LayoutController(this.context);
|
|
828
832
|
if (!this.context.behavior) this.context.behavior = new BehaviorController(this.context);
|
|
829
833
|
}
|
|
@@ -852,7 +856,8 @@ export class Graph extends EventEmitter {
|
|
|
852
856
|
public async render(): Promise<void> {
|
|
853
857
|
await this.prepare();
|
|
854
858
|
emit(this, new GraphLifeCycleEvent(GraphEvent.BEFORE_RENDER));
|
|
855
|
-
|
|
859
|
+
const animation = this.context.element!.draw();
|
|
860
|
+
await Promise.all([animation?.finished, this.context.layout!.layout()]);
|
|
856
861
|
await this.autoFit();
|
|
857
862
|
emit(this, new GraphLifeCycleEvent(GraphEvent.AFTER_RENDER));
|
|
858
863
|
}
|
|
@@ -866,7 +871,7 @@ export class Graph extends EventEmitter {
|
|
|
866
871
|
*/
|
|
867
872
|
public async draw(): Promise<void> {
|
|
868
873
|
await this.prepare();
|
|
869
|
-
|
|
874
|
+
await this.context.element!.draw()?.finished;
|
|
870
875
|
}
|
|
871
876
|
|
|
872
877
|
/**
|
|
@@ -913,10 +918,11 @@ export class Graph extends EventEmitter {
|
|
|
913
918
|
public destroy(): void {
|
|
914
919
|
emit(this, new GraphLifeCycleEvent(GraphEvent.BEFORE_DESTROY));
|
|
915
920
|
|
|
916
|
-
const { layout, element, model, canvas, behavior, plugin } = this.context;
|
|
921
|
+
const { layout, animation, element, model, canvas, behavior, plugin } = this.context;
|
|
917
922
|
plugin?.destroy();
|
|
918
923
|
behavior?.destroy();
|
|
919
924
|
layout?.destroy();
|
|
925
|
+
animation?.destroy();
|
|
920
926
|
element?.destroy();
|
|
921
927
|
model.destroy();
|
|
922
928
|
canvas?.destroy();
|
|
@@ -1176,7 +1182,7 @@ export class Graph extends EventEmitter {
|
|
|
1176
1182
|
: [{ [args1 as ID]: args2 as Position }, args3];
|
|
1177
1183
|
|
|
1178
1184
|
Object.entries(config).forEach(([id, offset]) => this.context.model.translateNodeBy(id, offset));
|
|
1179
|
-
await this.context.element!.draw({ animation });
|
|
1185
|
+
await this.context.element!.draw({ animation })?.finished;
|
|
1180
1186
|
}
|
|
1181
1187
|
|
|
1182
1188
|
/**
|
|
@@ -1208,7 +1214,7 @@ export class Graph extends EventEmitter {
|
|
|
1208
1214
|
: [{ [args1 as ID]: args2 as Position }, args3];
|
|
1209
1215
|
|
|
1210
1216
|
Object.entries(config).forEach(([id, position]) => this.context.model.translateNodeTo(id, position));
|
|
1211
|
-
await this.context.element!.draw({ animation });
|
|
1217
|
+
await this.context.element!.draw({ animation })?.finished;
|
|
1212
1218
|
}
|
|
1213
1219
|
|
|
1214
1220
|
/**
|
|
@@ -1275,9 +1281,12 @@ export class Graph extends EventEmitter {
|
|
|
1275
1281
|
const elementType = this.getElementType(id);
|
|
1276
1282
|
dataToUpdate[`${elementType}s`].push({ id, style: { visibility: value } });
|
|
1277
1283
|
});
|
|
1278
|
-
this.updateData(dataToUpdate);
|
|
1279
1284
|
|
|
1280
|
-
|
|
1285
|
+
const { model, element } = this.context;
|
|
1286
|
+
model.preventUpdateNodeLikeHierarchy(() => {
|
|
1287
|
+
model.updateData(dataToUpdate);
|
|
1288
|
+
});
|
|
1289
|
+
await element!.draw({ animation, stage: 'visibility' })?.finished;
|
|
1281
1290
|
}
|
|
1282
1291
|
|
|
1283
1292
|
/**
|
|
@@ -1353,7 +1362,7 @@ export class Graph extends EventEmitter {
|
|
|
1353
1362
|
|
|
1354
1363
|
const { model, element } = this.context;
|
|
1355
1364
|
model.preventUpdateNodeLikeHierarchy(() => model.updateData(dataToUpdate));
|
|
1356
|
-
await element!.draw({ animation: false });
|
|
1365
|
+
await element!.draw({ animation: false })?.finished;
|
|
1357
1366
|
}
|
|
1358
1367
|
|
|
1359
1368
|
/**
|
|
@@ -1438,7 +1447,7 @@ export class Graph extends EventEmitter {
|
|
|
1438
1447
|
});
|
|
1439
1448
|
this.updateData(dataToUpdate);
|
|
1440
1449
|
|
|
1441
|
-
await this.context.element!.draw({ animation });
|
|
1450
|
+
await this.context.element!.draw({ animation })?.finished;
|
|
1442
1451
|
}
|
|
1443
1452
|
|
|
1444
1453
|
/**
|
|
@@ -1465,6 +1474,8 @@ export class Graph extends EventEmitter {
|
|
|
1465
1474
|
return this.context.element!.getElement(id)!.getRenderBounds();
|
|
1466
1475
|
}
|
|
1467
1476
|
|
|
1477
|
+
private isCollapsingExpanding = false;
|
|
1478
|
+
|
|
1468
1479
|
/**
|
|
1469
1480
|
* <zh/> 收起 Combo
|
|
1470
1481
|
*
|
|
@@ -1474,8 +1485,19 @@ export class Graph extends EventEmitter {
|
|
|
1474
1485
|
* @apiCategory element
|
|
1475
1486
|
*/
|
|
1476
1487
|
public async collapseElement(id: ID, animation: boolean = true): Promise<void> {
|
|
1488
|
+
const { model, element } = this.context;
|
|
1489
|
+
if (isCollapsed(model.getNodeLikeData([id])[0])) return;
|
|
1490
|
+
|
|
1491
|
+
if (this.isCollapsingExpanding) return;
|
|
1492
|
+
|
|
1493
|
+
const elementType = model.getElementType(id);
|
|
1494
|
+
|
|
1495
|
+
this.isCollapsingExpanding = true;
|
|
1477
1496
|
this.setElementCollapsibility(id, true);
|
|
1478
|
-
await
|
|
1497
|
+
if (elementType === 'node') await element!.collapseNode(id, animation);
|
|
1498
|
+
else if (elementType === 'combo') await element!.collapseCombo(id, animation);
|
|
1499
|
+
|
|
1500
|
+
this.isCollapsingExpanding = false;
|
|
1479
1501
|
}
|
|
1480
1502
|
|
|
1481
1503
|
/**
|
|
@@ -1487,8 +1509,19 @@ export class Graph extends EventEmitter {
|
|
|
1487
1509
|
* @apiCategory element
|
|
1488
1510
|
*/
|
|
1489
1511
|
public async expandElement(id: ID, animation: boolean = true): Promise<void> {
|
|
1512
|
+
const { model, element } = this.context;
|
|
1513
|
+
if (!isCollapsed(model.getNodeLikeData([id])[0])) return;
|
|
1514
|
+
|
|
1515
|
+
if (this.isCollapsingExpanding) return;
|
|
1516
|
+
|
|
1517
|
+
const elementType = model.getElementType(id);
|
|
1518
|
+
|
|
1519
|
+
this.isCollapsingExpanding = true;
|
|
1490
1520
|
this.setElementCollapsibility(id, false);
|
|
1491
|
-
await
|
|
1521
|
+
if (elementType === 'node') await element!.expandNode(id, animation);
|
|
1522
|
+
else if (elementType === 'combo') await element!.expandCombo(id, animation);
|
|
1523
|
+
|
|
1524
|
+
this.isCollapsingExpanding = false;
|
|
1492
1525
|
}
|
|
1493
1526
|
|
|
1494
1527
|
private setElementCollapsibility(id: ID, collapsed: boolean) {
|
package/src/runtime/layout.ts
CHANGED
|
@@ -8,8 +8,9 @@ import type { AntVLayout } from '../layouts/types';
|
|
|
8
8
|
import { getExtension } from '../registry';
|
|
9
9
|
import type { GraphData, NodeData } from '../spec';
|
|
10
10
|
import type { STDLayoutOptions } from '../spec/layout';
|
|
11
|
-
import type { AdaptiveLayout, Combo, Node, TreeData } from '../types';
|
|
12
|
-
import {
|
|
11
|
+
import type { AdaptiveLayout, Combo, ID, Node, TreeData } from '../types';
|
|
12
|
+
import { getAnimationOptions } from '../utils/animation';
|
|
13
|
+
import { isToBeDestroyed } from '../utils/element';
|
|
13
14
|
import { GraphLifeCycleEvent, emit } from '../utils/event';
|
|
14
15
|
import { createTreeStructure } from '../utils/graphlib';
|
|
15
16
|
import { idOf } from '../utils/id';
|
|
@@ -31,7 +32,7 @@ export class LayoutController {
|
|
|
31
32
|
|
|
32
33
|
private get presetOptions() {
|
|
33
34
|
return {
|
|
34
|
-
animation: !!
|
|
35
|
+
animation: !!getAnimationOptions(this.context.options, true),
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -66,6 +67,30 @@ export class LayoutController {
|
|
|
66
67
|
emit(graph, new GraphLifeCycleEvent(GraphEvent.AFTER_LAYOUT));
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
/**
|
|
71
|
+
* <zh/> 模拟布局
|
|
72
|
+
*
|
|
73
|
+
* <en/> Simulate layout
|
|
74
|
+
* @returns <zh/> 模拟布局结果 | <en/> Simulated layout result
|
|
75
|
+
*/
|
|
76
|
+
public async simulate(): Promise<GraphData> {
|
|
77
|
+
if (!this.options) return {};
|
|
78
|
+
const pipeline = Array.isArray(this.options) ? this.options : [this.options];
|
|
79
|
+
|
|
80
|
+
let simulation: GraphData = {};
|
|
81
|
+
|
|
82
|
+
for (const options of pipeline) {
|
|
83
|
+
const index = pipeline.indexOf(options);
|
|
84
|
+
|
|
85
|
+
const data = this.getLayoutData(options);
|
|
86
|
+
const result = await this.stepLayout(data, { ...this.presetOptions, ...options, animation: false }, index);
|
|
87
|
+
|
|
88
|
+
simulation = result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return simulation;
|
|
92
|
+
}
|
|
93
|
+
|
|
69
94
|
public async stepLayout(data: GraphData, options: STDLayoutOptions, index: number): Promise<GraphData> {
|
|
70
95
|
if (isTreeLayout(options)) return await this.treeLayout(data, options, index);
|
|
71
96
|
return await this.graphLayout(data, options, index);
|
|
@@ -179,7 +204,29 @@ export class LayoutController {
|
|
|
179
204
|
const { nodeFilter = () => true } = options;
|
|
180
205
|
const { nodes, edges, combos } = this.context.model.getData();
|
|
181
206
|
|
|
182
|
-
|
|
207
|
+
const getElement = (id: ID) => this.context.element!.getElement(id);
|
|
208
|
+
|
|
209
|
+
const nodesToLayout = nodes.filter((node) => {
|
|
210
|
+
const id = idOf(node);
|
|
211
|
+
const element = getElement(id);
|
|
212
|
+
if (!element) return false;
|
|
213
|
+
if (isToBeDestroyed(element)) return false;
|
|
214
|
+
return nodeFilter(node);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const nodesIdMap = new Map<ID, NodeData>(nodesToLayout.map((node) => [idOf(node), node]));
|
|
218
|
+
|
|
219
|
+
const edgesToLayout = edges.filter((edge) => {
|
|
220
|
+
const { source, target } = edge;
|
|
221
|
+
if (!nodesIdMap.has(source) || !nodesIdMap.has(target)) return false;
|
|
222
|
+
return true;
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
nodes: nodesToLayout,
|
|
227
|
+
edges: edgesToLayout,
|
|
228
|
+
combos,
|
|
229
|
+
};
|
|
183
230
|
}
|
|
184
231
|
|
|
185
232
|
/**
|
package/src/runtime/transform.ts
CHANGED
|
@@ -5,8 +5,10 @@ import type { RuntimeContext } from './types';
|
|
|
5
5
|
|
|
6
6
|
export const REQUIRED_TRANSFORMS: TransformOptions = [
|
|
7
7
|
'update-related-edges',
|
|
8
|
-
'
|
|
8
|
+
'collapse-expand-node',
|
|
9
9
|
'collapse-expand-combo',
|
|
10
|
+
'get-edge-actual-ends',
|
|
11
|
+
'arrange-draw-order',
|
|
10
12
|
];
|
|
11
13
|
|
|
12
14
|
export class TransformController extends ExtensionController<BaseTransform<CustomTransformOption>> {
|
|
@@ -17,8 +19,14 @@ export class TransformController extends ExtensionController<BaseTransform<Custo
|
|
|
17
19
|
this.setTransforms(this.context.options.transforms || []);
|
|
18
20
|
}
|
|
19
21
|
|
|
22
|
+
protected getTransforms() {}
|
|
23
|
+
|
|
20
24
|
public setTransforms(transforms: TransformOptions) {
|
|
21
|
-
this.setExtensions([
|
|
25
|
+
this.setExtensions([
|
|
26
|
+
...REQUIRED_TRANSFORMS.slice(0, REQUIRED_TRANSFORMS.length - 1),
|
|
27
|
+
...transforms,
|
|
28
|
+
REQUIRED_TRANSFORMS[REQUIRED_TRANSFORMS.length - 1],
|
|
29
|
+
]);
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
public getTransformInstance(key?: string) {
|
package/src/runtime/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GraphOptions } from '../spec';
|
|
2
|
+
import type { Animation } from './animation';
|
|
2
3
|
import type { BatchController } from './batch';
|
|
3
4
|
import type { BehaviorController } from './behavior';
|
|
4
5
|
import type { Canvas } from './canvas';
|
|
@@ -51,6 +52,12 @@ export interface RuntimeContext {
|
|
|
51
52
|
* <en/> Only available after drawing starts
|
|
52
53
|
*/
|
|
53
54
|
element?: ElementController;
|
|
55
|
+
/**
|
|
56
|
+
* <zh/> 元素动画执行器
|
|
57
|
+
*
|
|
58
|
+
* <en/> Element animation executor
|
|
59
|
+
*/
|
|
60
|
+
animation?: Animation;
|
|
54
61
|
/**
|
|
55
62
|
* <zh/> 视口控制器
|
|
56
63
|
*
|
package/src/runtime/viewport.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AABB } from '@antv/g';
|
|
|
2
2
|
import { clamp, isNumber, pick } from '@antv/util';
|
|
3
3
|
import { AnimationType, GraphEvent } from '../constants';
|
|
4
4
|
import type { FitViewOptions, ID, Point, TransformOptions, Vector2, ViewportAnimationEffectTiming } from '../types';
|
|
5
|
-
import {
|
|
5
|
+
import { getAnimationOptions } from '../utils/animation';
|
|
6
6
|
import { getBBoxSize, getCombinedBBox } from '../utils/bbox';
|
|
7
7
|
import { AnimateEvent, ViewportEvent, emit } from '../utils/event';
|
|
8
8
|
import { parsePadding } from '../utils/padding';
|
|
@@ -40,7 +40,7 @@ export class ViewportController {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
private getAnimation(animation?: ViewportAnimationEffectTiming) {
|
|
43
|
-
const finalAnimation =
|
|
43
|
+
const finalAnimation = getAnimationOptions(this.context.options, animation);
|
|
44
44
|
if (!finalAnimation) return false;
|
|
45
45
|
return pick({ ...finalAnimation }, ['easing', 'duration']) as Exclude<ViewportAnimationEffectTiming, boolean>;
|
|
46
46
|
}
|
package/src/spec/data.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { ID, State } from '../types';
|
|
|
2
2
|
import type { ComboStyle } from './element/combo';
|
|
3
3
|
import type { EdgeStyle } from './element/edge';
|
|
4
4
|
import type { NodeStyle } from './element/node';
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* <zh/> 图数据
|
|
8
7
|
*
|
|
@@ -180,6 +179,20 @@ export interface EdgeData {
|
|
|
180
179
|
* <en/> Target node ID
|
|
181
180
|
*/
|
|
182
181
|
target: ID;
|
|
182
|
+
/**
|
|
183
|
+
* <zh/> 边的起点 shape
|
|
184
|
+
*
|
|
185
|
+
* <en/> The source shape. Represents the start of the edge
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
sourceNode?: ID;
|
|
189
|
+
/**
|
|
190
|
+
* <zh/> 边的终点 shape
|
|
191
|
+
*
|
|
192
|
+
* <en/> The source shape. Represents the start of the edge
|
|
193
|
+
* @internal
|
|
194
|
+
*/
|
|
195
|
+
targetNode?: ID;
|
|
183
196
|
/**
|
|
184
197
|
* <zh/> 边类型
|
|
185
198
|
*
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import type { Animation } from '../../animations/types';
|
|
2
|
-
|
|
3
|
-
export type AnimationOptions =
|
|
4
|
-
| false
|
|
5
|
-
| ({
|
|
6
|
-
[STAGE in AnimationStage]?: Animation;
|
|
7
|
-
} & {
|
|
8
|
-
[key: string]: Animation;
|
|
9
|
-
});
|
|
10
|
-
|
|
11
1
|
/**
|
|
12
|
-
* <zh/>
|
|
2
|
+
* <zh/> 元素动画执行阶段
|
|
13
3
|
*
|
|
14
|
-
* <en/>
|
|
4
|
+
* <en/> Stage of element animation execution
|
|
15
5
|
*/
|
|
16
|
-
export type AnimationStage = 'enter' | 'update' | 'exit' | '
|
|
6
|
+
export type AnimationStage = 'enter' | 'update' | 'exit' | 'show' | 'hide' | 'collapse' | 'expand' | string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { AnimationOptions } from '../../animations/types';
|
|
1
2
|
import type { BaseComboStyleProps } from '../../elements/combos';
|
|
2
3
|
import type { CallableObject } from '../../types';
|
|
3
4
|
import type { ComboData } from '../data';
|
|
4
|
-
import type {
|
|
5
|
+
import type { AnimationStage } from './animation';
|
|
5
6
|
import type { PaletteOptions } from './palette';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -33,7 +34,7 @@ export interface ComboOptions {
|
|
|
33
34
|
*
|
|
34
35
|
* <en/> Combo animation
|
|
35
36
|
*/
|
|
36
|
-
animation?: AnimationOptions
|
|
37
|
+
animation?: false | Record<AnimationStage, false | string | AnimationOptions[]>;
|
|
37
38
|
/**
|
|
38
39
|
* <zh/> 色板
|
|
39
40
|
*
|
|
@@ -45,7 +46,7 @@ export interface ComboOptions {
|
|
|
45
46
|
export interface StaticComboOptions {
|
|
46
47
|
style?: ComboStyle;
|
|
47
48
|
state?: Record<string, ComboStyle>;
|
|
48
|
-
animation?: AnimationOptions
|
|
49
|
+
animation?: false | Record<AnimationStage, false | string | AnimationOptions[]>;
|
|
49
50
|
palette?: PaletteOptions;
|
|
50
51
|
}
|
|
51
52
|
|
package/src/spec/element/edge.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { AnimationOptions } from '../../animations/types';
|
|
1
2
|
import type { BaseEdgeStyleProps } from '../../elements/edges';
|
|
2
3
|
import type { CallableObject } from '../../types';
|
|
3
4
|
import type { EdgeData } from '../data';
|
|
4
|
-
import type {
|
|
5
|
+
import type { AnimationStage } from './animation';
|
|
5
6
|
import type { PaletteOptions } from './palette';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -33,7 +34,7 @@ export interface EdgeOptions {
|
|
|
33
34
|
*
|
|
34
35
|
* <en/> Edge animation
|
|
35
36
|
*/
|
|
36
|
-
animation?: AnimationOptions
|
|
37
|
+
animation?: false | Record<AnimationStage, false | string | AnimationOptions[]>;
|
|
37
38
|
/**
|
|
38
39
|
* <zh/> 色板
|
|
39
40
|
*
|
|
@@ -45,7 +46,7 @@ export interface EdgeOptions {
|
|
|
45
46
|
export interface StaticEdgeOptions {
|
|
46
47
|
style?: EdgeStyle;
|
|
47
48
|
state?: Record<string, EdgeStyle>;
|
|
48
|
-
animation?: AnimationOptions
|
|
49
|
+
animation?: false | Record<AnimationStage, false | string | AnimationOptions[]>;
|
|
49
50
|
palette?: PaletteOptions;
|
|
50
51
|
}
|
|
51
52
|
|
package/src/spec/element/node.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { AnimationOptions } from '../../animations/types';
|
|
1
2
|
import type { BaseNodeStyleProps } from '../../elements/nodes';
|
|
2
3
|
import type { CallableObject } from '../../types';
|
|
3
4
|
import type { NodeData } from '../data';
|
|
4
|
-
import type {
|
|
5
|
+
import type { AnimationStage } from './animation';
|
|
5
6
|
import type { PaletteOptions } from './palette';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -33,7 +34,7 @@ export interface NodeOptions {
|
|
|
33
34
|
*
|
|
34
35
|
* <en/> Node animation
|
|
35
36
|
*/
|
|
36
|
-
animation?: AnimationOptions
|
|
37
|
+
animation?: false | Record<AnimationStage, false | string | AnimationOptions[]>;
|
|
37
38
|
/**
|
|
38
39
|
* <zh/> 色板
|
|
39
40
|
*
|
|
@@ -45,7 +46,7 @@ export interface NodeOptions {
|
|
|
45
46
|
export interface StaticNodeOptions {
|
|
46
47
|
style?: NodeStyle;
|
|
47
48
|
state?: Record<string, NodeStyle>;
|
|
48
|
-
animation?: AnimationOptions
|
|
49
|
+
animation?: false | Record<AnimationStage, false | string | AnimationOptions[]>;
|
|
49
50
|
palette?: PaletteOptions;
|
|
50
51
|
}
|
|
51
52
|
|
package/src/themes/base.ts
CHANGED
|
@@ -136,7 +136,10 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
136
136
|
animation: {
|
|
137
137
|
enter: 'fade',
|
|
138
138
|
exit: 'fade',
|
|
139
|
-
|
|
139
|
+
show: 'fade',
|
|
140
|
+
hide: 'fade',
|
|
141
|
+
expand: 'node-expand',
|
|
142
|
+
collapse: 'node-collapse',
|
|
140
143
|
update: [{ fields: ['x', 'y', 'fill', 'stroke'] }],
|
|
141
144
|
},
|
|
142
145
|
},
|
|
@@ -190,11 +193,11 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
190
193
|
animation: {
|
|
191
194
|
enter: 'fade',
|
|
192
195
|
exit: 'fade',
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
],
|
|
196
|
+
expand: 'path-in',
|
|
197
|
+
collapse: 'path-out',
|
|
198
|
+
show: 'fade',
|
|
199
|
+
hide: 'fade',
|
|
200
|
+
update: [{ fields: ['sourceNode', 'targetNode'] }, { fields: ['stroke'], shape: 'key' }],
|
|
198
201
|
},
|
|
199
202
|
},
|
|
200
203
|
combo: {
|
|
@@ -253,10 +256,11 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
253
256
|
animation: {
|
|
254
257
|
enter: 'fade',
|
|
255
258
|
exit: 'fade',
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
259
|
+
show: 'fade',
|
|
260
|
+
hide: 'fade',
|
|
261
|
+
expand: 'combo-expand',
|
|
262
|
+
collapse: 'combo-collapse',
|
|
263
|
+
update: [{ fields: ['x', 'y'] }, { fields: ['fill', 'stroke', 'lineWidth'], shape: 'key' }],
|
|
260
264
|
},
|
|
261
265
|
},
|
|
262
266
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BaseExtension } from '../registry/extension';
|
|
2
|
+
import type { DrawContext } from '../runtime/element';
|
|
2
3
|
import type { CustomBehaviorOption } from '../spec/behavior';
|
|
3
4
|
import type { DrawData } from './types';
|
|
4
5
|
|
|
5
6
|
export type BaseTransformOptions = CustomBehaviorOption;
|
|
6
7
|
|
|
7
8
|
export abstract class BaseTransform<T extends BaseTransformOptions = BaseTransformOptions> extends BaseExtension<T> {
|
|
8
|
-
public beforeDraw(data: DrawData): DrawData {
|
|
9
|
+
public beforeDraw(data: DrawData, context: DrawContext): DrawData {
|
|
9
10
|
return data;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
@@ -1,42 +1,22 @@
|
|
|
1
|
+
import type { DrawContext } from '../runtime/element';
|
|
1
2
|
import type { ComboData } from '../spec';
|
|
2
|
-
import
|
|
3
|
+
import { isCollapsed } from '../utils/collapsibility';
|
|
3
4
|
import { getSubgraphRelatedEdges } from '../utils/edge';
|
|
4
5
|
import { idOf } from '../utils/id';
|
|
6
|
+
// import { reassignTo } from '../utils/transform';
|
|
5
7
|
import { BaseTransform } from './base-transform';
|
|
6
|
-
import type { DrawData
|
|
8
|
+
import type { DrawData } from './types';
|
|
9
|
+
import { reassignTo } from './utils';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
|
-
* <zh/>
|
|
12
|
+
* <zh/> 处理组合的收起和展开
|
|
10
13
|
*
|
|
11
|
-
* <en/>
|
|
12
|
-
* @param input - <zh>绘制数据 | <en>DrawData
|
|
13
|
-
* @param type - <zh>类型 | <en>type
|
|
14
|
-
* @param elementType - <zh>元素类型 | <en>element type
|
|
15
|
-
* @param datum - <zh>数据 | <en>data
|
|
16
|
-
*/
|
|
17
|
-
const reassignTo = (
|
|
18
|
-
input: DrawData,
|
|
19
|
-
type: 'add' | 'update' | 'remove',
|
|
20
|
-
elementType: ElementType,
|
|
21
|
-
datum: ElementDatum,
|
|
22
|
-
) => {
|
|
23
|
-
const id = idOf(datum);
|
|
24
|
-
const typeName = `${elementType}s` as keyof ProcedureData;
|
|
25
|
-
const exitsDatum: any =
|
|
26
|
-
input.add[typeName].get(id) || input.update[typeName].get(id) || input.remove[typeName].get(id) || datum;
|
|
27
|
-
Object.entries(input).forEach(([_type, value]) => {
|
|
28
|
-
if (type === _type) value[typeName].set(id, exitsDatum);
|
|
29
|
-
else value[typeName].delete(id);
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* <zh/> 处理元素的收起和展开
|
|
35
|
-
*
|
|
36
|
-
* <en/> Process the collapse and expand of elements
|
|
14
|
+
* <en/> Process the collapse and expand of combos
|
|
37
15
|
*/
|
|
38
16
|
export class CollapseExpandCombo extends BaseTransform {
|
|
39
|
-
public beforeDraw(input: DrawData): DrawData {
|
|
17
|
+
public beforeDraw(input: DrawData, context: DrawContext): DrawData {
|
|
18
|
+
if (context.stage === 'visibility') return input;
|
|
19
|
+
|
|
40
20
|
const { model } = this.context;
|
|
41
21
|
const { add, update } = input;
|
|
42
22
|
// combo 添加和更新的顺序为先子后父,因此采用倒序遍历
|
|
@@ -45,8 +25,7 @@ export class CollapseExpandCombo extends BaseTransform {
|
|
|
45
25
|
while (combos.length) {
|
|
46
26
|
const [id, combo] = combos.pop()!;
|
|
47
27
|
|
|
48
|
-
|
|
49
|
-
if (isCollapsed) {
|
|
28
|
+
if (isCollapsed(combo)) {
|
|
50
29
|
const descendants = model.getDescendantsData(id);
|
|
51
30
|
const descendantIds = descendants.map(idOf);
|
|
52
31
|
const { internal, external } = getSubgraphRelatedEdges(descendantIds, (id) => model.getRelatedEdgesData(id));
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { TREE_KEY } from '../constants';
|
|
2
|
+
import type { NodeData } from '../spec';
|
|
3
|
+
import type { ElementDatum, ElementType, ID } from '../types';
|
|
4
|
+
import { isCollapsed } from '../utils/collapsibility';
|
|
5
|
+
import { idOf } from '../utils/id';
|
|
6
|
+
import { BaseTransform } from './base-transform';
|
|
7
|
+
import type { DrawData, ProcedureData } from './types';
|
|
8
|
+
import { reassignTo } from './utils';
|
|
9
|
+
|
|
10
|
+
// 如果在任务列表中不存在,则添加到任务列表
|
|
11
|
+
// If it does not exist in the task list, add it to the task list
|
|
12
|
+
const weakAssignTo = (input: DrawData, type: 'add' | 'update', elementType: ElementType, datum: ElementDatum) => {
|
|
13
|
+
const typeName = `${elementType}s` as keyof ProcedureData;
|
|
14
|
+
const id = idOf(datum);
|
|
15
|
+
if (!input.add[typeName].has(id) && !input.update[typeName].has(id)) {
|
|
16
|
+
input[type][typeName].set(idOf(datum), datum as any);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* <zh/> 处理(树图)节点的收起和展开
|
|
22
|
+
*
|
|
23
|
+
* <en/> Process the collapse and expand of (tree)nodes
|
|
24
|
+
*/
|
|
25
|
+
export class CollapseExpandNode extends BaseTransform {
|
|
26
|
+
private getElement(id: ID) {
|
|
27
|
+
return this.context.element!.getElement(id);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private handleExpand(node: NodeData, input: DrawData) {
|
|
31
|
+
weakAssignTo(input, 'add', 'node', node);
|
|
32
|
+
if (isCollapsed(node)) return;
|
|
33
|
+
|
|
34
|
+
const id = idOf(node);
|
|
35
|
+
weakAssignTo(input, 'add', 'node', node);
|
|
36
|
+
|
|
37
|
+
const relatedEdges = this.context.model.getRelatedEdgesData(id, 'out');
|
|
38
|
+
relatedEdges.forEach((edge) => {
|
|
39
|
+
reassignTo(input, 'add', 'edge', edge);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const children = this.context.model.getChildrenData(id);
|
|
43
|
+
children.forEach((child) => {
|
|
44
|
+
this.handleExpand(child, input);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public beforeDraw(input: DrawData): DrawData {
|
|
49
|
+
const {
|
|
50
|
+
add: { nodes: nodesToAdd },
|
|
51
|
+
update: { nodes: nodesToUpdate },
|
|
52
|
+
} = input;
|
|
53
|
+
const nodesToCollapse = new Map<ID, NodeData>();
|
|
54
|
+
const nodesToExpand = new Map<ID, NodeData>();
|
|
55
|
+
|
|
56
|
+
nodesToAdd.forEach((node, id) => {
|
|
57
|
+
if (isCollapsed(node)) nodesToCollapse.set(id, node);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
nodesToUpdate.forEach((node, id) => {
|
|
61
|
+
const nodeElement = this.getElement(id);
|
|
62
|
+
if (!nodeElement) return;
|
|
63
|
+
|
|
64
|
+
const isCurrentCollapsed = nodeElement.attributes.collapsed;
|
|
65
|
+
if (isCollapsed(node)) {
|
|
66
|
+
if (!isCurrentCollapsed) nodesToCollapse.set(id, node);
|
|
67
|
+
} else {
|
|
68
|
+
if (isCurrentCollapsed) nodesToExpand.set(id, node);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const handledNodes = new Set<ID>();
|
|
73
|
+
|
|
74
|
+
nodesToCollapse.forEach((node, id) => {
|
|
75
|
+
// 将子节点添加到待删除列表,并删除关联的边
|
|
76
|
+
// Add child nodes to the list to be deleted,and delete the associated edges
|
|
77
|
+
const descendants = this.context.model!.getDescendantsData(id);
|
|
78
|
+
descendants.forEach((descendant) => {
|
|
79
|
+
const id = idOf(descendant);
|
|
80
|
+
if (handledNodes.has(id)) return;
|
|
81
|
+
|
|
82
|
+
reassignTo(input, 'remove', 'node', descendant);
|
|
83
|
+
const relatedEdges = this.context.model.getRelatedEdgesData(id);
|
|
84
|
+
relatedEdges.forEach((edge) => {
|
|
85
|
+
reassignTo(input, 'remove', 'edge', edge);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
handledNodes.add(id);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
nodesToExpand.forEach((node, id) => {
|
|
93
|
+
const ancestors = this.context.model.getAncestorsData(id, TREE_KEY);
|
|
94
|
+
|
|
95
|
+
// 如果祖先节点是收起的,添加到移除列表
|
|
96
|
+
// If the ancestor node is collapsed, add it to the removal list
|
|
97
|
+
if (ancestors.some(isCollapsed)) {
|
|
98
|
+
reassignTo(input, 'remove', 'node', node);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
this.handleExpand(node, input);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return input;
|
|
106
|
+
}
|
|
107
|
+
}
|