@antv/g6 5.0.50 → 5.0.51

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 (116) hide show
  1. package/README.md +1 -0
  2. package/README.zh-CN.md +1 -0
  3. package/dist/g6.min.js +38 -59
  4. package/dist/lib/behaviors/brush-select.d.ts +1 -2
  5. package/dist/lib/behaviors/click-select.d.ts +2 -2
  6. package/dist/lib/behaviors/drag-element.d.ts +18 -0
  7. package/dist/lib/behaviors/focus-element.d.ts +18 -0
  8. package/dist/lib/plugins/bubble-sets.d.ts +1 -1
  9. package/dist/lib/plugins/legend.d.ts +10 -2
  10. package/dist/lib/runtime/element.d.ts +8 -0
  11. package/dist/lib/runtime/layout.d.ts +2 -1
  12. package/dist/lib/utils/data.d.ts +9 -0
  13. package/dist/lib/version.d.ts +1 -1
  14. package/esm/behaviors/brush-select.d.ts +1 -2
  15. package/esm/behaviors/brush-select.js +2 -2
  16. package/esm/behaviors/brush-select.js.map +1 -1
  17. package/esm/behaviors/click-select.d.ts +2 -2
  18. package/esm/behaviors/click-select.js.map +1 -1
  19. package/esm/behaviors/create-edge.js +5 -1
  20. package/esm/behaviors/create-edge.js.map +1 -1
  21. package/esm/behaviors/drag-element.d.ts +18 -0
  22. package/esm/behaviors/drag-element.js +18 -1
  23. package/esm/behaviors/drag-element.js.map +1 -1
  24. package/esm/behaviors/focus-element.d.ts +18 -0
  25. package/esm/behaviors/focus-element.js +18 -1
  26. package/esm/behaviors/focus-element.js.map +1 -1
  27. package/esm/elements/combos/base-combo.js.map +1 -1
  28. package/esm/elements/edges/base-edge.js.map +1 -1
  29. package/esm/elements/nodes/base-node.js.map +1 -1
  30. package/esm/plugins/bubble-sets.d.ts +1 -1
  31. package/esm/plugins/bubble-sets.js +30 -7
  32. package/esm/plugins/bubble-sets.js.map +1 -1
  33. package/esm/plugins/legend.d.ts +10 -2
  34. package/esm/plugins/legend.js.map +1 -1
  35. package/esm/plugins/tooltip.js +6 -1
  36. package/esm/plugins/tooltip.js.map +1 -1
  37. package/esm/registry/build-in.js +3 -3
  38. package/esm/registry/build-in.js.map +1 -1
  39. package/esm/runtime/canvas.js.map +1 -1
  40. package/esm/runtime/element.d.ts +8 -0
  41. package/esm/runtime/element.js +53 -8
  42. package/esm/runtime/element.js.map +1 -1
  43. package/esm/runtime/graph.js +2 -2
  44. package/esm/runtime/graph.js.map +1 -1
  45. package/esm/runtime/layout.d.ts +2 -1
  46. package/esm/runtime/layout.js +4 -3
  47. package/esm/runtime/layout.js.map +1 -1
  48. package/esm/utils/data.d.ts +9 -0
  49. package/esm/utils/data.js +11 -0
  50. package/esm/utils/data.js.map +1 -1
  51. package/esm/utils/shortcut.js +1 -1
  52. package/esm/utils/shortcut.js.map +1 -1
  53. package/esm/version.d.ts +1 -1
  54. package/esm/version.js +1 -1
  55. package/lib/behaviors/brush-select.d.ts +1 -2
  56. package/lib/behaviors/brush-select.js +2 -2
  57. package/lib/behaviors/brush-select.js.map +1 -1
  58. package/lib/behaviors/click-select.d.ts +2 -2
  59. package/lib/behaviors/click-select.js.map +1 -1
  60. package/lib/behaviors/create-edge.js +5 -1
  61. package/lib/behaviors/create-edge.js.map +1 -1
  62. package/lib/behaviors/drag-element.d.ts +18 -0
  63. package/lib/behaviors/drag-element.js +18 -1
  64. package/lib/behaviors/drag-element.js.map +1 -1
  65. package/lib/behaviors/focus-element.d.ts +18 -0
  66. package/lib/behaviors/focus-element.js +18 -1
  67. package/lib/behaviors/focus-element.js.map +1 -1
  68. package/lib/elements/combos/base-combo.js.map +1 -1
  69. package/lib/elements/edges/base-edge.js.map +1 -1
  70. package/lib/elements/nodes/base-node.js.map +1 -1
  71. package/lib/plugins/bubble-sets.d.ts +1 -1
  72. package/lib/plugins/bubble-sets.js +30 -7
  73. package/lib/plugins/bubble-sets.js.map +1 -1
  74. package/lib/plugins/legend.d.ts +10 -2
  75. package/lib/plugins/legend.js.map +1 -1
  76. package/lib/plugins/tooltip.js +6 -1
  77. package/lib/plugins/tooltip.js.map +1 -1
  78. package/lib/registry/build-in.js.map +1 -1
  79. package/lib/runtime/canvas.js.map +1 -1
  80. package/lib/runtime/element.d.ts +8 -0
  81. package/lib/runtime/element.js +53 -8
  82. package/lib/runtime/element.js.map +1 -1
  83. package/lib/runtime/graph.js +2 -2
  84. package/lib/runtime/graph.js.map +1 -1
  85. package/lib/runtime/layout.d.ts +2 -1
  86. package/lib/runtime/layout.js +4 -3
  87. package/lib/runtime/layout.js.map +1 -1
  88. package/lib/utils/data.d.ts +9 -0
  89. package/lib/utils/data.js +13 -0
  90. package/lib/utils/data.js.map +1 -1
  91. package/lib/utils/shortcut.js +1 -1
  92. package/lib/utils/shortcut.js.map +1 -1
  93. package/lib/version.d.ts +1 -1
  94. package/lib/version.js +1 -1
  95. package/package.json +4 -4
  96. package/src/behaviors/brush-select.ts +3 -4
  97. package/src/behaviors/click-select.ts +1 -1
  98. package/src/behaviors/create-edge.ts +5 -3
  99. package/src/behaviors/drag-element.ts +29 -1
  100. package/src/behaviors/focus-element.ts +28 -1
  101. package/src/elements/combos/base-combo.ts +2 -1
  102. package/src/elements/edges/base-edge.ts +2 -1
  103. package/src/elements/nodes/base-node.ts +2 -1
  104. package/src/plugins/bubble-sets.ts +37 -9
  105. package/src/plugins/legend.ts +1 -1
  106. package/src/plugins/tooltip.ts +8 -2
  107. package/src/registry/build-in.ts +4 -4
  108. package/src/runtime/canvas.ts +4 -2
  109. package/src/runtime/element.ts +54 -9
  110. package/src/runtime/graph.ts +2 -2
  111. package/src/runtime/layout.ts +4 -3
  112. package/src/types/edge.ts +1 -3
  113. package/src/utils/data.ts +12 -0
  114. package/src/utils/shortcut.ts +1 -1
  115. package/src/version.ts +1 -1
  116. package/src/layouts/hierarchy.d.ts +0 -10
@@ -36,7 +36,8 @@ import { connectImage, dispatchPositionChange } from '../shapes/image';
36
36
  * <en/> Base node style props
37
37
  */
38
38
  export interface BaseNodeStyleProps
39
- extends BaseShapeStyleProps,
39
+ extends
40
+ BaseShapeStyleProps,
40
41
  Prefix<'label', NodeLabelStyleProps>,
41
42
  Prefix<'halo', BaseStyleProps>,
42
43
  Prefix<'icon', IconStyleProps>,
@@ -51,11 +51,11 @@ export interface BubbleSetsOptions extends BasePluginOptions, IBubbleSetOptions,
51
51
  * <en/> The principle is to represent sets by creating a shape similar to a bubble. Each set is represented by a unique "bubble", and the elements in the set are contained within this bubble. If two sets have an intersection, then the two bubbles will have an overlapping part, which represents the intersection of the two sets.
52
52
  */
53
53
  export class BubbleSets extends BasePlugin<BubbleSetsOptions> {
54
- private shape!: Contour;
54
+ private shape?: Contour;
55
55
 
56
56
  private bubbleSets!: BubbleSetsJS;
57
57
 
58
- private path!: PathArray;
58
+ private path: PathArray | null = null;
59
59
 
60
60
  private members: Map<ID, IRectangle | ILine> = new Map();
61
61
 
@@ -90,8 +90,9 @@ export class BubbleSets extends BasePlugin<BubbleSetsOptions> {
90
90
 
91
91
  private init() {
92
92
  this.bubbleSets = new BubbleSetsJS(this.options);
93
- this.members = new Map();
94
- this.avoidMembers = new Map();
93
+ this.members.clear();
94
+ this.avoidMembers.clear();
95
+ this.path = null;
95
96
  }
96
97
 
97
98
  private parseOptions() {
@@ -139,8 +140,21 @@ export class BubbleSets extends BasePlugin<BubbleSetsOptions> {
139
140
  const currAvoidMembers = this.options.avoidMembers;
140
141
  const prevAvoidMembers = [...this.avoidMembers.keys()];
141
142
 
142
- if (!forceUpdateId && isEqual(currMembers, prevMembers) && isEqual(currAvoidMembers, prevAvoidMembers))
143
+ if (currMembers.length === 0 && currAvoidMembers.length === 0) {
144
+ this.members.clear();
145
+ this.avoidMembers.clear();
146
+ this.path = [] as unknown as PathArray;
143
147
  return this.path;
148
+ }
149
+
150
+ if (
151
+ !forceUpdateId &&
152
+ this.path &&
153
+ isEqual(currMembers, prevMembers) &&
154
+ isEqual(currAvoidMembers, prevAvoidMembers)
155
+ ) {
156
+ return this.path;
157
+ }
144
158
 
145
159
  const { enter: membersToEnter = [], exit: membersToExit = [] } = arrayDiff(prevMembers, currMembers, (d) => d);
146
160
  const { enter: avoidMembersToEnter = [], exit: avoidMembersToExit = [] } = arrayDiff(
@@ -150,8 +164,17 @@ export class BubbleSets extends BasePlugin<BubbleSetsOptions> {
150
164
  );
151
165
 
152
166
  if (forceUpdateId) {
153
- membersToExit.push(forceUpdateId);
154
- membersToEnter.push(forceUpdateId);
167
+ const isMemberNow = currMembers.includes(forceUpdateId);
168
+ const isAvoidNow = currAvoidMembers.includes(forceUpdateId);
169
+
170
+ if (isMemberNow) {
171
+ membersToExit.push(forceUpdateId);
172
+ membersToEnter.push(forceUpdateId);
173
+ }
174
+ if (isAvoidNow) {
175
+ avoidMembersToExit.push(forceUpdateId);
176
+ avoidMembersToEnter.push(forceUpdateId);
177
+ }
155
178
  }
156
179
 
157
180
  const updateBubbleSets = (ids: ID[], isEntering: boolean, isMember: boolean) => {
@@ -247,7 +270,7 @@ export class BubbleSets extends BasePlugin<BubbleSetsOptions> {
247
270
  */
248
271
  public addAvoidMember(avoidMembers: ID | ID[]) {
249
272
  const avoidMembersToAdd = Array.isArray(avoidMembers) ? avoidMembers : [avoidMembers];
250
- if (avoidMembersToAdd.some((AvoidMember) => this.options.members.includes(AvoidMember))) {
273
+ if (avoidMembersToAdd.some((avoidMember) => this.options.members.includes(avoidMember))) {
251
274
  this.options.members = this.options.members.filter((id) => !avoidMembersToAdd.includes(id));
252
275
  }
253
276
  this.options.avoidMembers = [...new Set([...this.options.avoidMembers, ...avoidMembersToAdd])];
@@ -294,7 +317,12 @@ export class BubbleSets extends BasePlugin<BubbleSetsOptions> {
294
317
  public destroy(): void {
295
318
  this.context.graph.off(GraphEvent.AFTER_RENDER, this.drawBubbleSets);
296
319
  this.context.graph.off(GraphEvent.AFTER_ELEMENT_UPDATE, this.updateBubbleSetsPath);
297
- this.shape.destroy();
320
+
321
+ if (this.shape) {
322
+ this.shape.destroy();
323
+ this.shape = undefined;
324
+ }
325
+
298
326
  super.destroy();
299
327
  }
300
328
  }
@@ -248,7 +248,7 @@ export class Legend extends BasePlugin<LegendOptions> {
248
248
  };
249
249
  };
250
250
 
251
- private getMarkerData = (field: string | ((item: ElementDatum) => string), elementType: ElementType) => {
251
+ protected getMarkerData = (field: string | ((item: ElementDatum) => string), elementType: ElementType) => {
252
252
  if (!field) return [];
253
253
  const { model, element } = this.context;
254
254
  const { nodes, edges, combos } = model.getData();
@@ -13,7 +13,8 @@ import { BasePlugin } from './base-plugin';
13
13
  * <en/> Tooltip plugin options
14
14
  */
15
15
  export interface TooltipOptions
16
- extends BasePluginOptions,
16
+ extends
17
+ BasePluginOptions,
17
18
  Pick<TooltipStyleProps, 'position' | 'offset' | 'enterable' | 'style' | 'container' | 'title'> {
18
19
  /**
19
20
  * <zh/> 触发行为,可选 hover | click
@@ -254,7 +255,12 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
254
255
  const { getContent, title } = this.options;
255
256
  const items: ElementDatum[] = this.getElementData(id, targetType as ElementType);
256
257
 
257
- if (!this.tooltipElement || !this.isEnable(event, items)) return;
258
+ if (!this.tooltipElement) return;
259
+ // if shown, when is not enable, hide
260
+ if (!this.isEnable(event, items)) {
261
+ this.hide(event);
262
+ return;
263
+ }
258
264
 
259
265
  let tooltipContent: { [key: string]: unknown } = {};
260
266
  if (getContent) {
@@ -153,20 +153,20 @@ const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
153
153
  layout: {
154
154
  'antv-dagre': AntVDagreLayout,
155
155
  'combo-combined': ComboCombinedLayout,
156
- 'compact-box': compactBox,
156
+ 'compact-box': compactBox as any,
157
157
  'd3-force': D3ForceLayout,
158
158
  'force-atlas2': ForceAtlas2Layout,
159
159
  circular: CircularLayout,
160
160
  concentric: ConcentricLayout,
161
161
  dagre: DagreLayout,
162
- dendrogram,
162
+ dendrogram: dendrogram as any,
163
163
  fishbone: FishboneLayout,
164
164
  force: ForceLayout,
165
165
  fruchterman: FruchtermanLayout,
166
166
  grid: GridLayout,
167
- indented,
167
+ indented: indented as any,
168
168
  mds: MDSLayout,
169
- mindmap,
169
+ mindmap: mindmap as any,
170
170
  radial: RadialLayout,
171
171
  random: RandomLayout,
172
172
  snake: SnakeLayout,
@@ -8,8 +8,10 @@ import type { CanvasLayer, Point } from '../types';
8
8
  import { getBBoxSize, getCombinedBBox } from '../utils/bbox';
9
9
  import { parsePoint, toPointObject } from '../utils/point';
10
10
 
11
- export interface CanvasConfig
12
- extends Pick<GCanvasConfig, 'container' | 'devicePixelRatio' | 'width' | 'height' | 'cursor' | 'background'> {
11
+ export interface CanvasConfig extends Pick<
12
+ GCanvasConfig,
13
+ 'container' | 'devicePixelRatio' | 'width' | 'height' | 'cursor' | 'background'
14
+ > {
13
15
  /**
14
16
  * <zh/> 渲染器
15
17
  *
@@ -6,7 +6,7 @@ import { groupBy } from '@antv/util';
6
6
  import { AnimationType, COMBO_KEY, ChangeType, GraphEvent } from '../constants';
7
7
  import { ELEMENT_TYPES } from '../constants/element';
8
8
  import { getExtension } from '../registry/get';
9
- import type { ComboData, EdgeData, GraphData, NodeData } from '../spec';
9
+ import type { ComboData, EdgeData, GraphData, LayoutOptions, NodeData } from '../spec';
10
10
  import type { AnimationStage } from '../spec/element/animation';
11
11
  import type { DrawData, ProcedureData } from '../transforms/types';
12
12
  import type {
@@ -26,6 +26,7 @@ import type {
26
26
  import { cacheStyle, hasCachedStyle } from '../utils/cache';
27
27
  import { reduceDataChanges } from '../utils/change';
28
28
  import { isCollapsed } from '../utils/collapsibility';
29
+ import { isOverridable } from '../utils/data';
29
30
  import { markToBeDestroyed, updateStyle } from '../utils/element';
30
31
  import type { BaseEvent } from '../utils/event';
31
32
  import { AnimateEvent, ElementLifeCycleEvent, GraphLifeCycleEvent, emit } from '../utils/event';
@@ -77,7 +78,7 @@ export class ElementController {
77
78
 
78
79
  public getElementType(elementType: ElementType, datum: ElementDatum) {
79
80
  const { options, graph } = this.context;
80
- const userDefinedType = options[elementType]?.type || datum.type;
81
+ const userDefinedType = isOverridable(datum) ? options[elementType]?.type || datum.type : datum.type;
81
82
 
82
83
  if (!userDefinedType) {
83
84
  if (elementType === 'edge') return 'line';
@@ -255,7 +256,9 @@ export class ElementController {
255
256
  const themeStateStyle = this.getThemeStateStyle(elementType, this.getElementState(id));
256
257
  const stateStyle = this.getStateStyle(id);
257
258
 
258
- const style = Object.assign({}, themeStyle, paletteStyle, dataStyle, defaultStyle, themeStateStyle, stateStyle);
259
+ const style = isOverridable(datum)
260
+ ? Object.assign({}, themeStyle, paletteStyle, dataStyle, defaultStyle, themeStateStyle, stateStyle)
261
+ : Object.assign({}, dataStyle);
259
262
 
260
263
  if (elementType === 'combo') {
261
264
  const childrenData = this.context.model.getChildrenData(id);
@@ -380,6 +383,23 @@ export class ElementController {
380
383
  ComboRemoved = [],
381
384
  } = groupBy(tasks, (change) => change.type) as unknown as Record<`${ChangeType}`, DataChange[]>;
382
385
 
386
+ const moveToAddedIfUnrendered = (updated: DataChange[], added: DataChange[]) => {
387
+ const keptUpdates: DataChange[] = [];
388
+ updated.forEach((change) => {
389
+ const id = idOf(change.value);
390
+ if (!this.getElement(id)) {
391
+ added.push(change);
392
+ } else {
393
+ keptUpdates.push(change);
394
+ }
395
+ });
396
+ return keptUpdates;
397
+ };
398
+
399
+ const finalNodeUpdated = moveToAddedIfUnrendered(NodeUpdated, NodeAdded);
400
+ const finalEdgeUpdated = moveToAddedIfUnrendered(EdgeUpdated, EdgeAdded);
401
+ const finalComboUpdated = moveToAddedIfUnrendered(ComboUpdated, ComboAdded);
402
+
383
403
  const dataOf = <T extends DataChange['value']>(data: DataChange[]) =>
384
404
  new Map(
385
405
  data.map((datum) => {
@@ -395,9 +415,9 @@ export class ElementController {
395
415
  combos: dataOf<ComboData>(ComboAdded),
396
416
  },
397
417
  update: {
398
- nodes: dataOf<NodeData>(NodeUpdated),
399
- edges: dataOf<EdgeData>(EdgeUpdated),
400
- combos: dataOf<ComboData>(ComboUpdated),
418
+ nodes: dataOf<NodeData>(finalNodeUpdated),
419
+ edges: dataOf<EdgeData>(finalEdgeUpdated),
420
+ combos: dataOf<ComboData>(finalComboUpdated),
401
421
  },
402
422
  remove: {
403
423
  nodes: dataOf<NodeData>(NodeRemoved),
@@ -655,6 +675,29 @@ export class ElementController {
655
675
  }
656
676
  }
657
677
 
678
+ /**
679
+ * <zh/> 同步布局结果
680
+ *
681
+ * <en/> Sync layout result
682
+ * @param id - <zh/> 元素 ID | <en/> element ID
683
+ * @param align - <zh/> 是否对齐 | <en/> whether to align
684
+ */
685
+ private async syncLayoutResult(id: ID, align?: boolean) {
686
+ const { layout, model } = this.context;
687
+ if (!layout) return;
688
+
689
+ const layoutOptions = this.context.options.layout;
690
+ const forcePreLayout = (opts: LayoutOptions): LayoutOptions => {
691
+ if (Array.isArray(opts)) {
692
+ return opts.map((o) => ({ ...o, preLayout: true }));
693
+ }
694
+ return { ...opts, preLayout: true };
695
+ };
696
+ const layoutResult = await layout.simulate(layoutOptions ? forcePreLayout(layoutOptions) : undefined);
697
+ if (align) this.alignLayoutResultToElement(layoutResult, id);
698
+ model.updateData(layoutResult);
699
+ }
700
+
658
701
  /**
659
702
  * <zh/> 收起节点
660
703
  *
@@ -663,8 +706,8 @@ export class ElementController {
663
706
  * @param options - <zh/> 选项 | <en/> options
664
707
  */
665
708
  public async collapseNode(id: ID, options: CollapseExpandNodeOptions): Promise<void> {
666
- const { animation } = options;
667
- const { model } = this.context;
709
+ const { animation, align } = options;
710
+ await this.syncLayoutResult(id, align);
668
711
 
669
712
  // 重新计算数据 / Recalculate data
670
713
  const data = this.computeChangesAndDrawData({ stage: 'collapse', animation });
@@ -704,10 +747,12 @@ export class ElementController {
704
747
  * @param animation - <zh/> 是否使用动画,默认为 true | <en/> Whether to use animation, default is true
705
748
  */
706
749
  public async expandNode(id: ID, options: CollapseExpandNodeOptions): Promise<void> {
707
- const { model, layout } = this.context;
750
+ const { model } = this.context;
708
751
  const { animation, align } = options;
709
752
  const position = positionOf(model.getNodeData([id])[0]);
710
753
 
754
+ await this.syncLayoutResult(id, align);
755
+
711
756
  // 重新计算数据 / Recalculate data
712
757
  const data = this.computeChangesAndDrawData({ stage: 'expand', animation });
713
758
  this.createElements(data!.drawData.add, { animation: false, stage: 'expand', target: id });
@@ -1873,7 +1873,7 @@ export class Graph extends EventEmitter {
1873
1873
  if (isCollapsed(model.getNodeLikeData([id])[0])) return;
1874
1874
  if (this.isCollapsingExpanding) return;
1875
1875
 
1876
- if (typeof options === 'boolean') options = { animation: options, align: true };
1876
+ if (typeof options === 'boolean') options = { animation: options, align: false };
1877
1877
 
1878
1878
  const elementType = model.getElementType(id);
1879
1879
 
@@ -1911,7 +1911,7 @@ export class Graph extends EventEmitter {
1911
1911
  if (!isCollapsed(model.getNodeLikeData([id])[0])) return;
1912
1912
  if (this.isCollapsingExpanding) return;
1913
1913
 
1914
- if (typeof options === 'boolean') options = { animation: options, align: true };
1914
+ if (typeof options === 'boolean') options = { animation: options, align: false };
1915
1915
 
1916
1916
  const elementType = model.getElementType(id);
1917
1917
 
@@ -127,11 +127,12 @@ export class LayoutController {
127
127
  * <zh/> 模拟布局
128
128
  *
129
129
  * <en/> Simulate layout
130
+ * @param options - <zh/> 布局配置项 | <en/> Layout options
130
131
  * @returns <zh/> 模拟布局结果 | <en/> Simulated layout result
131
132
  */
132
- public async simulate(): Promise<GraphData> {
133
- if (!this.options) return {};
134
- const pipeline = Array.isArray(this.options) ? this.options : [this.options];
133
+ public async simulate(options: LayoutOptions | undefined = this.options): Promise<GraphData> {
134
+ if (!options) return {};
135
+ const pipeline = Array.isArray(options) ? options : [options];
135
136
 
136
137
  let simulation: GraphData = {};
137
138
 
package/src/types/edge.ts CHANGED
@@ -102,9 +102,7 @@ export interface EdgeBadgeStyleProps extends BadgeStyleProps {
102
102
  * <en/> Edge arrow style properties
103
103
  */
104
104
  export interface EdgeArrowStyleProps
105
- extends PathStyleProps,
106
- Omit<ImageStyleProps, 'width' | 'height'>,
107
- Record<string, unknown> {
105
+ extends PathStyleProps, Omit<ImageStyleProps, 'width' | 'height'>, Record<string, unknown> {
108
106
  /**
109
107
  * <zh/> 箭头大小
110
108
  *
package/src/utils/data.ts CHANGED
@@ -111,3 +111,15 @@ export function isElementDataEqual(original: Partial<ElementDatum> = {}, modifie
111
111
 
112
112
  return true;
113
113
  }
114
+
115
+ export const OVERRIDE_KEY = '__internal_override__';
116
+ /**
117
+ * <zh/> 判断元素数据是否允许被覆盖
118
+ *
119
+ * <en/> Determine whether the element data can be overridden
120
+ * @param datum - <zh/> 元素数据 | <en/> element data
121
+ * @returns <zh/> 是否允许被覆盖 | <en/> is overridable
122
+ */
123
+ export function isOverridable(datum: ElementDatum): boolean {
124
+ return datum[OVERRIDE_KEY] !== false;
125
+ }
@@ -130,6 +130,6 @@ export class Shortcut {
130
130
  this.emitter.off(CommonEvent.WHEEL, this.onWheel);
131
131
  this.emitter.off(CommonEvent.DRAG, this.onDrag);
132
132
  this.pinchHandler?.off('pinchmove', this.boundHandlePinch);
133
- globalThis.removeEventListener?.('blur', this.onFocus);
133
+ globalThis.removeEventListener?.('focus', this.onFocus);
134
134
  }
135
135
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '5.0.50';
1
+ export const version = '5.0.51';
@@ -1,10 +0,0 @@
1
- // TODO need @antv/hierarchy to implement the types
2
- declare module '@antv/hierarchy' {
3
- const _: {
4
- compactBox: any;
5
- dendrogram: any;
6
- indented: any;
7
- mindmap: any;
8
- };
9
- export = _;
10
- }