@antv/g6 5.0.0-beta.4 → 5.0.0-beta.6

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.
Files changed (246) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/index.d.ts +15 -1
  3. package/esm/index.js +1 -1
  4. package/esm/item/combo.d.ts +1 -1
  5. package/esm/item/combo.js +16 -9
  6. package/esm/item/combo.js.map +1 -1
  7. package/esm/item/edge.d.ts +2 -1
  8. package/esm/item/edge.js +18 -8
  9. package/esm/item/edge.js.map +1 -1
  10. package/esm/item/item.d.ts +3 -2
  11. package/esm/item/item.js +12 -6
  12. package/esm/item/item.js.map +1 -1
  13. package/esm/item/node.d.ts +2 -1
  14. package/esm/item/node.js +19 -10
  15. package/esm/item/node.js.map +1 -1
  16. package/esm/runtime/controller/item.d.ts +1 -0
  17. package/esm/runtime/controller/item.js +271 -151
  18. package/esm/runtime/controller/item.js.map +1 -1
  19. package/esm/runtime/graph.d.ts +98 -18
  20. package/esm/runtime/graph.js +427 -75
  21. package/esm/runtime/graph.js.map +1 -1
  22. package/esm/stdlib/behavior/activate-relations.js +2 -2
  23. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  24. package/esm/stdlib/behavior/brush-select.js +1 -2
  25. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  26. package/esm/stdlib/behavior/click-select.js +1 -1
  27. package/esm/stdlib/behavior/click-select.js.map +1 -1
  28. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  29. package/esm/stdlib/behavior/create-edge.js +206 -0
  30. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  31. package/esm/stdlib/behavior/drag-canvas.d.ts +1 -1
  32. package/esm/stdlib/behavior/drag-canvas.js +51 -28
  33. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  34. package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
  35. package/esm/stdlib/behavior/drag-combo.js +43 -32
  36. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  37. package/esm/stdlib/behavior/drag-node.d.ts +3 -3
  38. package/esm/stdlib/behavior/drag-node.js +76 -63
  39. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  40. package/esm/stdlib/behavior/index.d.ts +2 -0
  41. package/esm/stdlib/behavior/index.js +2 -0
  42. package/esm/stdlib/behavior/index.js.map +1 -1
  43. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  44. package/esm/stdlib/behavior/lasso-select.js +1 -2
  45. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  46. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  47. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  48. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  49. package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -1
  50. package/esm/stdlib/behavior/zoom-canvas.js +47 -24
  51. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  52. package/esm/stdlib/index.d.ts +6 -0
  53. package/esm/stdlib/index.js +15 -9
  54. package/esm/stdlib/index.js.map +1 -1
  55. package/esm/stdlib/item/edge/base.d.ts +1 -1
  56. package/esm/stdlib/item/edge/base.js +13 -4
  57. package/esm/stdlib/item/edge/base.js.map +1 -1
  58. package/esm/stdlib/item/node/base.d.ts +1 -1
  59. package/esm/stdlib/item/node/base.js +11 -12
  60. package/esm/stdlib/item/node/base.js.map +1 -1
  61. package/esm/stdlib/item/node/image.d.ts +1 -1
  62. package/esm/stdlib/item/node/image.js +1 -1
  63. package/esm/stdlib/item/node/image.js.map +1 -1
  64. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  65. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  66. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  67. package/esm/stdlib/plugin/history/index.js +14 -14
  68. package/esm/stdlib/plugin/history/index.js.map +1 -1
  69. package/esm/stdlib/plugin/history/item-data-command.js +4 -4
  70. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  71. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  72. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  73. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  74. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  75. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  76. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  77. package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  78. package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
  79. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  80. package/esm/stdlib/plugin/index.d.ts +1 -0
  81. package/esm/stdlib/plugin/index.js +1 -0
  82. package/esm/stdlib/plugin/index.js.map +1 -1
  83. package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
  84. package/esm/stdlib/plugin/minimap/index.js +109 -8
  85. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  86. package/esm/stdlib/plugin/snapline/index.d.ts +163 -0
  87. package/esm/stdlib/plugin/snapline/index.js +1052 -0
  88. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  89. package/esm/stdlib/plugin/types.d.ts +1 -0
  90. package/esm/types/graph.d.ts +45 -19
  91. package/esm/types/hook.d.ts +22 -2
  92. package/esm/types/spec.d.ts +19 -3
  93. package/esm/util/bbox.d.ts +16 -1
  94. package/esm/util/bbox.js +29 -0
  95. package/esm/util/bbox.js.map +1 -1
  96. package/esm/util/item.d.ts +16 -1
  97. package/esm/util/item.js +31 -8
  98. package/esm/util/item.js.map +1 -1
  99. package/esm/util/shape.js +2 -2
  100. package/esm/util/shape.js.map +1 -1
  101. package/esm/util/warn.d.ts +14 -0
  102. package/esm/util/warn.js +4 -0
  103. package/esm/util/warn.js.map +1 -0
  104. package/lib/index.d.ts +15 -1
  105. package/lib/index.js +1 -1
  106. package/lib/item/combo.d.ts +1 -1
  107. package/lib/item/combo.js +16 -9
  108. package/lib/item/combo.js.map +1 -1
  109. package/lib/item/edge.d.ts +2 -1
  110. package/lib/item/edge.js +18 -8
  111. package/lib/item/edge.js.map +1 -1
  112. package/lib/item/item.d.ts +3 -2
  113. package/lib/item/item.js +12 -6
  114. package/lib/item/item.js.map +1 -1
  115. package/lib/item/node.d.ts +2 -1
  116. package/lib/item/node.js +19 -10
  117. package/lib/item/node.js.map +1 -1
  118. package/lib/runtime/controller/item.d.ts +1 -0
  119. package/lib/runtime/controller/item.js +270 -150
  120. package/lib/runtime/controller/item.js.map +1 -1
  121. package/lib/runtime/graph.d.ts +98 -18
  122. package/lib/runtime/graph.js +427 -75
  123. package/lib/runtime/graph.js.map +1 -1
  124. package/lib/stdlib/behavior/activate-relations.js +2 -2
  125. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  126. package/lib/stdlib/behavior/brush-select.js +1 -2
  127. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  128. package/lib/stdlib/behavior/click-select.js +1 -1
  129. package/lib/stdlib/behavior/click-select.js.map +1 -1
  130. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  131. package/lib/stdlib/behavior/create-edge.js +210 -0
  132. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  133. package/lib/stdlib/behavior/drag-canvas.d.ts +1 -1
  134. package/lib/stdlib/behavior/drag-canvas.js +51 -28
  135. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  136. package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
  137. package/lib/stdlib/behavior/drag-combo.js +43 -32
  138. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  139. package/lib/stdlib/behavior/drag-node.d.ts +3 -3
  140. package/lib/stdlib/behavior/drag-node.js +76 -63
  141. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  142. package/lib/stdlib/behavior/index.d.ts +2 -0
  143. package/lib/stdlib/behavior/index.js +2 -0
  144. package/lib/stdlib/behavior/index.js.map +1 -1
  145. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  146. package/lib/stdlib/behavior/lasso-select.js +1 -2
  147. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  148. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  149. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  150. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  151. package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -1
  152. package/lib/stdlib/behavior/zoom-canvas.js +47 -24
  153. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  154. package/lib/stdlib/index.d.ts +6 -0
  155. package/lib/stdlib/index.js +15 -9
  156. package/lib/stdlib/index.js.map +1 -1
  157. package/lib/stdlib/item/edge/base.d.ts +1 -1
  158. package/lib/stdlib/item/edge/base.js +13 -4
  159. package/lib/stdlib/item/edge/base.js.map +1 -1
  160. package/lib/stdlib/item/node/base.d.ts +1 -1
  161. package/lib/stdlib/item/node/base.js +11 -12
  162. package/lib/stdlib/item/node/base.js.map +1 -1
  163. package/lib/stdlib/item/node/image.d.ts +1 -1
  164. package/lib/stdlib/item/node/image.js +1 -1
  165. package/lib/stdlib/item/node/image.js.map +1 -1
  166. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  167. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  168. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  169. package/lib/stdlib/plugin/history/index.js +14 -14
  170. package/lib/stdlib/plugin/history/index.js.map +1 -1
  171. package/lib/stdlib/plugin/history/item-data-command.js +4 -4
  172. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  173. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  174. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  175. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  176. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  177. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  178. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  179. package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  180. package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
  181. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  182. package/lib/stdlib/plugin/index.d.ts +1 -0
  183. package/lib/stdlib/plugin/index.js +1 -0
  184. package/lib/stdlib/plugin/index.js.map +1 -1
  185. package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
  186. package/lib/stdlib/plugin/minimap/index.js +109 -8
  187. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  188. package/lib/stdlib/plugin/snapline/index.d.ts +163 -0
  189. package/lib/stdlib/plugin/snapline/index.js +1056 -0
  190. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  191. package/lib/stdlib/plugin/types.d.ts +1 -0
  192. package/lib/types/graph.d.ts +45 -19
  193. package/lib/types/hook.d.ts +22 -2
  194. package/lib/types/spec.d.ts +19 -3
  195. package/lib/util/bbox.d.ts +16 -1
  196. package/lib/util/bbox.js +32 -1
  197. package/lib/util/bbox.js.map +1 -1
  198. package/lib/util/item.d.ts +16 -1
  199. package/lib/util/item.js +33 -9
  200. package/lib/util/item.js.map +1 -1
  201. package/lib/util/shape.js +2 -2
  202. package/lib/util/shape.js.map +1 -1
  203. package/lib/util/warn.d.ts +14 -0
  204. package/lib/util/warn.js +8 -0
  205. package/lib/util/warn.js.map +1 -0
  206. package/package.json +2 -2
  207. package/src/index.ts +1 -1
  208. package/src/item/combo.ts +14 -9
  209. package/src/item/edge.ts +17 -8
  210. package/src/item/item.ts +11 -6
  211. package/src/item/node.ts +24 -16
  212. package/src/runtime/controller/item.ts +240 -72
  213. package/src/runtime/graph.ts +536 -80
  214. package/src/stdlib/behavior/activate-relations.ts +2 -2
  215. package/src/stdlib/behavior/brush-select.ts +4 -2
  216. package/src/stdlib/behavior/click-select.ts +1 -1
  217. package/src/stdlib/behavior/create-edge.ts +295 -0
  218. package/src/stdlib/behavior/drag-canvas.ts +67 -29
  219. package/src/stdlib/behavior/drag-combo.ts +10 -10
  220. package/src/stdlib/behavior/drag-node.ts +18 -18
  221. package/src/stdlib/behavior/index.ts +2 -0
  222. package/src/stdlib/behavior/lasso-select.ts +5 -3
  223. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  224. package/src/stdlib/behavior/zoom-canvas.ts +61 -25
  225. package/src/stdlib/index.ts +16 -7
  226. package/src/stdlib/item/edge/base.ts +13 -5
  227. package/src/stdlib/item/node/base.ts +15 -14
  228. package/src/stdlib/item/node/image.ts +1 -1
  229. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  230. package/src/stdlib/plugin/history/index.ts +14 -14
  231. package/src/stdlib/plugin/history/item-data-command.ts +4 -4
  232. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  233. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  234. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  235. package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
  236. package/src/stdlib/plugin/index.ts +1 -0
  237. package/src/stdlib/plugin/minimap/index.ts +113 -9
  238. package/src/stdlib/plugin/snapline/index.ts +1277 -0
  239. package/src/stdlib/plugin/types.ts +1 -0
  240. package/src/types/graph.ts +53 -22
  241. package/src/types/hook.ts +22 -2
  242. package/src/types/spec.ts +22 -3
  243. package/src/util/bbox.ts +38 -1
  244. package/src/util/item.ts +65 -28
  245. package/src/util/shape.ts +2 -2
  246. package/src/util/warn.ts +20 -0
@@ -804,7 +804,11 @@ export abstract class BaseNode {
804
804
  * @param shapeMap The shape map that contains all of the elements to show on the node.
805
805
  * @param zoom The zoom level of the graph.
806
806
  */
807
- public onZoom = (shapeMap: NodeShapeMap | ComboShapeMap, zoom: number) => {
807
+ public onZoom = (
808
+ shapeMap: NodeShapeMap | ComboShapeMap,
809
+ zoom: number,
810
+ cacheHiddenShape = {},
811
+ ) => {
808
812
  // zoomLevel changed
809
813
  if (this.lodStrategy) {
810
814
  const { levels } = this.lodStrategy;
@@ -825,7 +829,7 @@ export abstract class BaseNode {
825
829
  // zoomLevel changed, from higher to lower, hide something
826
830
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
827
831
  levelShapes[String(i)]?.forEach((id) => {
828
- if (!shapeMap[id]) return;
832
+ if (!shapeMap[id] || cacheHiddenShape[id]) return;
829
833
  shapeMap[id].hide();
830
834
  hiddenShape[id] = true;
831
835
  });
@@ -874,8 +878,7 @@ export abstract class BaseNode {
874
878
  const balanceRatio = 1 / zoom || 1;
875
879
  this.zoomCache.balanceRatio = balanceRatio;
876
880
  if (!labelShape || !labelShape.isVisible()) return;
877
- const { labelShape: labelStyle } = this.mergedStyles;
878
- const { position = 'bottom' } = labelStyle;
881
+ const { position = 'bottom' } = this.mergedStyles.labelShape;
879
882
 
880
883
  const keyShapeLocal = keyShape.getLocalBounds();
881
884
  if (zoom < 1) {
@@ -917,21 +920,20 @@ export abstract class BaseNode {
917
920
  const scaleTransform = `scale(${balanceRatio}, ${balanceRatio})`;
918
921
  labelShape.style.transform = `${oriTransform} ${scaleTransform}`;
919
922
  this.scaleTransformCache = scaleTransform;
920
- const wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
921
- labelShape.style.wordWrapWidth = wordWrapWidth;
923
+ labelShape.style.wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
922
924
 
923
925
  if (!labelBackgroundShape || !labelBackgroundShape.isVisible()) return;
924
926
 
925
- const { padding } = this.mergedStyles.labelBackgroundShape;
927
+ const [paddingTop, paddingRight, paddingBottom, paddingLeft] = this
928
+ .mergedStyles.labelBackgroundShape.padding as number[];
929
+ const sidePadding = paddingRight + paddingLeft;
926
930
  const { width, height, x, y } = labelBackgroundShape.attributes;
927
- const [paddingTop, paddingRight, paddingBottom, paddingLeft] =
928
- padding as number[];
929
931
 
930
932
  switch (position) {
931
933
  case 'top':
932
934
  // if it is zoom-out, do not scale the gap between keyShape and labelShape, differentiate from zoom-in by adjusting transformOrigin
933
935
  labelBackgroundShape.style.transformOrigin = `${
934
- paddingLeft + (width - paddingLeft - paddingRight) / 2
936
+ paddingLeft + (width - sidePadding) / 2
935
937
  } ${zoom < 1 ? height - paddingBottom : keyShapeLocal.min[1] - y}`;
936
938
  break;
937
939
  case 'left':
@@ -946,7 +948,7 @@ export abstract class BaseNode {
946
948
  break;
947
949
  case 'bottom':
948
950
  labelBackgroundShape.style.transformOrigin = `${
949
- paddingLeft + (width - paddingLeft - paddingRight) / 2
951
+ paddingLeft + (width - sidePadding) / 2
950
952
  } ${
951
953
  zoom < 1
952
954
  ? paddingTop + (height - paddingTop - paddingBottom) / 2
@@ -956,14 +958,13 @@ export abstract class BaseNode {
956
958
  default:
957
959
  // center
958
960
  labelBackgroundShape.style.transformOrigin = `${
959
- paddingLeft + (width - paddingLeft - paddingRight) / 2
961
+ paddingLeft + (width - sidePadding) / 2
960
962
  } ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
961
963
  }
962
964
 
963
965
  const { labelShapeGeometry: labelBBox } = this.boundsCache;
964
966
  const labelWidth = labelBBox.max[0] - labelBBox.min[0];
965
- const xAxistRatio =
966
- (labelWidth * balanceRatio + paddingLeft + paddingRight) / width;
967
+ const xAxistRatio = (labelWidth * balanceRatio + sidePadding) / width;
967
968
 
968
969
  labelBackgroundShape.style.transform = `scale(${xAxistRatio}, ${balanceRatio})`;
969
970
  }
@@ -7,9 +7,9 @@ import {
7
7
  NodeShapeStyles,
8
8
  } from '../../../types/node';
9
9
  import { convertToNumber } from '../../../util/type';
10
- import { BaseNode } from './base';
11
10
  import { ComboModelData, ComboShapeMap } from '../../../types/combo';
12
11
  import { ShapeTagMap } from '../../../util/shape';
12
+ import { BaseNode } from './base';
13
13
 
14
14
  export class ImageNode extends BaseNode {
15
15
  override defaultStyles = {
@@ -11,7 +11,7 @@ export class ComboCommand implements Command {
11
11
  }
12
12
 
13
13
  undo(graph: IGraph) {
14
- graph.executeWithoutStacking(() => {
14
+ graph.executeWithNoStack(() => {
15
15
  this.action === 'expandCombo'
16
16
  ? graph.collapseCombo(this.ids)
17
17
  : graph.expandCombo(this.ids);
@@ -19,7 +19,7 @@ export class ComboCommand implements Command {
19
19
  }
20
20
 
21
21
  redo(graph: IGraph) {
22
- graph.executeWithoutStacking(() => {
22
+ graph.executeWithNoStack(() => {
23
23
  this.action === 'collapseCombo'
24
24
  ? graph.collapseCombo(this.ids)
25
25
  : graph.expandCombo(this.ids);
@@ -200,7 +200,7 @@ export class History extends Base {
200
200
  /**
201
201
  * Pause stacking operations.
202
202
  */
203
- pauseStacking(): void {
203
+ pauseStack(): void {
204
204
  this.withoutStackingCounter++;
205
205
 
206
206
  if (this.withoutStackingCounter === 1) {
@@ -212,7 +212,7 @@ export class History extends Base {
212
212
  /**
213
213
  * Resume stacking operations.
214
214
  */
215
- resumeStacking(): void {
215
+ resumeStack(): void {
216
216
  if (this.withoutStackingCounter > 0) {
217
217
  this.withoutStackingCounter--;
218
218
  }
@@ -260,14 +260,14 @@ export class History extends Base {
260
260
  }
261
261
 
262
262
  /**
263
- * Begin a batch operation.
264
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
263
+ * Begin a historyBatch operation.
264
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
265
265
  * treated as a single operation when undoing or redoing.
266
266
  */
267
- public startBatch() {
267
+ public startHistoryBatch() {
268
268
  if (this.isBatching) {
269
269
  throw new Error(
270
- 'Ensure that batch processing is stopped before starting.',
270
+ 'Ensure that historyBatch processing is stopped before starting.',
271
271
  );
272
272
  }
273
273
  this.initBatchCommands();
@@ -275,14 +275,14 @@ export class History extends Base {
275
275
  }
276
276
 
277
277
  /**
278
- * End a batch operation.
279
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
278
+ * End a historyBatch operation.
279
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
280
280
  * treated as a single operation when undoing or redoing.
281
281
  */
282
- public stopBatch() {
282
+ public stopHistoryBatch() {
283
283
  if (!this.isBatching) {
284
284
  throw new Error(
285
- 'Ensure that batch processing is started before stopping.',
285
+ 'Ensure that historyBatch processing is started before stopping.',
286
286
  );
287
287
  }
288
288
  this.push(this.batchCommands);
@@ -290,13 +290,13 @@ export class History extends Base {
290
290
  }
291
291
 
292
292
  /**
293
- * Execute the provided function in a batch mode
293
+ * Execute the provided function in a historyBatch mode
294
294
  * @param callback
295
295
  */
296
- public batch(callback) {
297
- this.startBatch();
296
+ public historyBatch(callback) {
297
+ this.startHistoryBatch();
298
298
  callback();
299
- this.stopBatch();
299
+ this.stopHistoryBatch();
300
300
  }
301
301
 
302
302
  public getEvents() {
@@ -26,14 +26,14 @@ export class ItemDataCommand implements Command {
26
26
 
27
27
  private removeChangedData(graph) {
28
28
  const ids = this.changes.map((data) => data.value?.id).filter(Boolean);
29
- graph.executeWithoutStacking(() => {
29
+ graph.executeWithNoStack(() => {
30
30
  graph.removeData(this.type, ids);
31
31
  });
32
32
  }
33
33
 
34
34
  private addChangedData(graph) {
35
35
  const models = this.changes.map((data) => data.value).filter(Boolean);
36
- graph.executeWithoutStacking(() => {
36
+ graph.executeWithNoStack(() => {
37
37
  graph.addData(this.type, models);
38
38
  });
39
39
  }
@@ -61,13 +61,13 @@ export class ItemDataCommand implements Command {
61
61
  });
62
62
  }
63
63
 
64
- graph.pauseStacking();
64
+ graph.pauseStack();
65
65
  if (onlyMove) {
66
66
  graph.updatePosition(this.type, models, this.upsertAncestors);
67
67
  } else {
68
68
  graph.updateData(this.type, models);
69
69
  }
70
- graph.resumeStacking();
70
+ graph.resumeStack();
71
71
  }
72
72
 
73
73
  undo(graph: IGraph) {
@@ -11,7 +11,7 @@ export class LayerUpdatedCommand implements Command {
11
11
  }
12
12
 
13
13
  undo(graph: IGraph) {
14
- graph.executeWithoutStacking(() => {
14
+ graph.executeWithNoStack(() => {
15
15
  this.action === 'front'
16
16
  ? graph.backItem(this.ids)
17
17
  : graph.frontItem(this.ids);
@@ -19,7 +19,7 @@ export class LayerUpdatedCommand implements Command {
19
19
  }
20
20
 
21
21
  redo(graph: IGraph) {
22
- graph.executeWithoutStacking(() => {
22
+ graph.executeWithNoStack(() => {
23
23
  this.action === 'front'
24
24
  ? graph.frontItem(this.ids)
25
25
  : graph.backItem(this.ids);
@@ -20,7 +20,7 @@ export class StateUpdatedCommand implements Command {
20
20
  private updateItemsStates(graph, stateOptions) {
21
21
  stateOptions?.map((option) => {
22
22
  const { ids, states, value } = option;
23
- graph.executeWithoutStacking(() => {
23
+ graph.executeWithNoStack(() => {
24
24
  graph.setItemState(ids, states, value);
25
25
  });
26
26
  });
@@ -20,13 +20,13 @@ export class VisibilityUpdatedCommand implements Command {
20
20
  }
21
21
 
22
22
  private toggleItemsVisible(graph: IGraph, values) {
23
- graph.pauseStacking();
23
+ graph.pauseStack();
24
24
  each(values, (value) =>
25
25
  value.visible
26
26
  ? graph.showItem(value.ids, this.disableAnimate)
27
27
  : graph.hideItem(value.ids, this.disableAnimate),
28
28
  );
29
- graph.resumeStacking();
29
+ graph.resumeStack();
30
30
  }
31
31
 
32
32
  undo(graph: IGraph) {
@@ -51,7 +51,8 @@ interface HullComponentFullOptions extends HullComponentOptions {
51
51
  export default class Hull {
52
52
  graph: IGraph;
53
53
 
54
- path: any[][];
54
+ // TODO: PathArray is not exported by @antv/util 2.x but by 3.x. Correct the type String | PathArray after upgrading @antv/util
55
+ path: any;
55
56
 
56
57
  members: (NodeModel | ComboModel)[];
57
58
 
@@ -172,9 +173,9 @@ export default class Hull {
172
173
  const shape = this.graph.drawTransient('path', this.options.id, {
173
174
  style: {
174
175
  path: this.path,
176
+ pointerEvents: 'none',
175
177
  ...this.options.style,
176
178
  },
177
- capture: false,
178
179
  });
179
180
  const { labelShape } = this.options;
180
181
  if (labelShape?.text) {
@@ -183,10 +184,10 @@ export default class Hull {
183
184
  const formattedLabelStyle = this.getLabelStyle(labelShape, shapeBounds);
184
185
  this.graph.drawTransient('text', `${this.options.id}-label`, {
185
186
  style: {
187
+ pointerEvents: 'none',
186
188
  ...labelShapeStyle,
187
189
  ...formattedLabelStyle,
188
190
  },
189
- capture: false,
190
191
  });
191
192
  }
192
193
  shape.toBack();
@@ -426,8 +427,10 @@ export default class Hull {
426
427
 
427
428
  public updateStyle(style: ShapeStyle) {
428
429
  this.graph.drawTransient('path', this.options.id, {
429
- style,
430
- capture: false,
430
+ style: {
431
+ ...style,
432
+ pointerEvents: 'none',
433
+ },
431
434
  });
432
435
  }
433
436
 
@@ -7,3 +7,4 @@ export * from './minimap';
7
7
  export * from './toolbar';
8
8
  export * from './tooltip';
9
9
  export * from './timebar';
10
+ export * from './snapline';
@@ -54,6 +54,8 @@ export class Minimap extends Base {
54
54
  private dx: number;
55
55
  /** Distance from left of minimap graph to the left of minimap container. */
56
56
  private dy: number;
57
+ /** Cache the visibility while items' visibility changed. And apply them onto the minimap with debounce. */
58
+ private visibleCache: { [id: string]: boolean } = {};
57
59
 
58
60
  constructor(options?: MiniMapConfig) {
59
61
  super(options);
@@ -80,11 +82,11 @@ export class Minimap extends Base {
80
82
 
81
83
  public getEvents() {
82
84
  return {
83
- afterupdateitem: this.handleUpdateCanvas,
84
85
  afteritemstatechange: this.handleUpdateCanvas,
85
86
  afterlayout: this.handleUpdateCanvas,
86
87
  viewportchange: this.handleUpdateCanvas,
87
88
  afteritemchange: this.handleUpdateCanvas,
89
+ afteritemvisibilitychange: this.handleVisibilityChange,
88
90
  };
89
91
  }
90
92
 
@@ -115,12 +117,12 @@ export class Minimap extends Base {
115
117
  style='position:absolute;
116
118
  left:0;
117
119
  top:0;
118
- box-sizing:border-box;
119
120
  border: 2px solid #1980ff;
121
+ box-sizing:border-box;
120
122
  background: rgba(0, 0, 255, 0.1);
121
123
  cursor:move'
122
124
  draggable=${isSafari || isFireFox ? false : true}
123
- </div>`);
125
+ />`);
124
126
 
125
127
  // Last mouse x position
126
128
  let x = 0;
@@ -128,11 +130,25 @@ export class Minimap extends Base {
128
130
  let y = 0;
129
131
  // Whether in dragging status
130
132
  let dragging = false;
133
+ let resizing = false;
131
134
 
132
135
  const dragstartevent = isSafari || isFireFox ? 'mousedown' : 'dragstart';
136
+ this.container.addEventListener('mousemove', (e) => {
137
+ const moveAtBorder = getMoveAtBorder(viewport, e);
138
+ if (moveAtBorder) {
139
+ this.container.style.cursor = cursorMap[moveAtBorder];
140
+ viewport.style.cursor = cursorMap[moveAtBorder];
141
+ } else {
142
+ this.container.style.cursor = 'unset';
143
+ viewport.style.cursor = 'move';
144
+ }
145
+ });
133
146
  viewport.addEventListener(
134
147
  dragstartevent,
135
148
  ((e: IG6GraphEvent) => {
149
+ resizing = getMoveAtBorder(viewport, e);
150
+ if (resizing) return;
151
+
136
152
  if ((e as any).dataTransfer) {
137
153
  const img = new Image();
138
154
  img.src =
@@ -159,6 +175,30 @@ export class Minimap extends Base {
159
175
  );
160
176
 
161
177
  const dragListener = (e: IG6GraphEvent) => {
178
+ const { style } = viewport;
179
+ const left = parseInt(style.left, 10);
180
+ const top = parseInt(style.top, 10);
181
+ const width = parseInt(style.width, 10);
182
+ const height = parseInt(style.height, 10);
183
+
184
+ if (resizing) {
185
+ const { clientX, clientY } = e;
186
+ const afterResize = { left, top, width, height };
187
+ if (resizing.includes('left')) {
188
+ afterResize.left = `${clientX}px`;
189
+ afterResize.width = `${left + width - clientX}px`;
190
+ } else if (resizing.includes('right')) {
191
+ afterResize.width = `${clientX - left}px`;
192
+ }
193
+ if (resizing.includes('top')) {
194
+ afterResize.top = `${clientY}`;
195
+ afterResize.height = `${top + height - clientY}`;
196
+ } else if (resizing.includes('bottom')) {
197
+ afterResize.height = `${clientY - top}`;
198
+ }
199
+ modifyCSS(viewport, afterResize);
200
+ return;
201
+ }
162
202
  if (!dragging || isNil(e.clientX) || isNil(e.clientY)) {
163
203
  return;
164
204
  }
@@ -168,12 +208,6 @@ export class Minimap extends Base {
168
208
  let dx = x - e.clientX;
169
209
  let dy = y - e.clientY;
170
210
 
171
- const { style } = viewport;
172
- const left = parseInt(style.left, 10);
173
- const top = parseInt(style.top, 10);
174
- const width = parseInt(style.width, 10);
175
- const height = parseInt(style.height, 10);
176
-
177
211
  // If the viewport is already on the left or right, stop moving x.
178
212
  if (left - dx < 0 || left - dx + width >= size[0]) {
179
213
  dx = 0;
@@ -201,6 +235,7 @@ export class Minimap extends Base {
201
235
 
202
236
  const dragendListener = () => {
203
237
  dragging = false;
238
+ resizing = false;
204
239
  this.options.refresh = true;
205
240
  };
206
241
  const dragendevent = isSafari || isFireFox ? 'mouseup' : 'dragend';
@@ -549,6 +584,34 @@ export class Minimap extends Base {
549
584
  false,
550
585
  );
551
586
 
587
+ private handleVisibilityChange = (params) => {
588
+ const { ids, value } = params;
589
+ ids.forEach((id) => {
590
+ this.visibleCache[id] = value;
591
+ });
592
+ this.debounceCloneVisibility();
593
+ };
594
+
595
+ private debounceCloneVisibility = debounce(
596
+ () => {
597
+ const nodeGroup = this.canvas.getRoot().getElementById('node-group');
598
+ const edgeGroup = this.canvas.getRoot().getElementById('edge-group');
599
+ nodeGroup.childNodes.concat(edgeGroup.childNodes).forEach((child) => {
600
+ const id = child.getAttribute?.('data-item-id');
601
+ if (this.visibleCache.hasOwnProperty(id)) {
602
+ if (this.visibleCache[id]) {
603
+ child.childNodes.forEach((shape) => shape.show());
604
+ } else if (this.visibleCache[id] === false) {
605
+ child.childNodes.forEach((shape) => shape.hide());
606
+ }
607
+ }
608
+ });
609
+ this.visibleCache = {};
610
+ },
611
+ 50,
612
+ false,
613
+ );
614
+
552
615
  public init(graph: IGraph) {
553
616
  super.init(graph);
554
617
  const promise = this.initContainer();
@@ -696,3 +759,44 @@ export class Minimap extends Base {
696
759
  if (container?.parentNode) container.parentNode.removeChild(container);
697
760
  }
698
761
  }
762
+
763
+ const getMoveAtBorder = (dom, evt) => {
764
+ const bounds = dom.getBoundingClientRect();
765
+ const { clientX, clientY } = evt;
766
+ if (Math.abs(clientX - bounds.x) < 4 && Math.abs(clientY - bounds.y) < 4) {
767
+ return 'left-top';
768
+ } else if (
769
+ Math.abs(clientX - bounds.x) < 4 &&
770
+ Math.abs(clientY - bounds.y - bounds.height) < 4
771
+ ) {
772
+ return 'left-bottom';
773
+ } else if (
774
+ Math.abs(clientX - bounds.x - bounds.width) < 4 &&
775
+ Math.abs(clientY - bounds.y) < 4
776
+ ) {
777
+ return 'right-top';
778
+ } else if (
779
+ Math.abs(clientX - bounds.x - bounds.width) < 4 &&
780
+ Math.abs(clientY - bounds.y - bounds.height) < 4
781
+ ) {
782
+ return 'right-bottom';
783
+ } else if (Math.abs(clientX - bounds.x) < 4) {
784
+ return 'left';
785
+ } else if (Math.abs(clientY - bounds.y) < 4) {
786
+ return 'top';
787
+ } else if (Math.abs(clientY - bounds.y - bounds.height) < 4) {
788
+ return 'bottom';
789
+ }
790
+ return false;
791
+ };
792
+
793
+ const cursorMap = {
794
+ 'left-top': 'nwse-resize',
795
+ 'right-bottom': 'nwse-resize',
796
+ 'right-top': 'nesw-resize',
797
+ 'left-bottom': 'nesw-resize',
798
+ left: 'ew-resize',
799
+ right: 'ew-resize',
800
+ top: 'ns-resize',
801
+ bottom: 'ns-resize',
802
+ };