@antv/g6 5.0.37 → 5.0.39

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/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.0.37";
1
+ export declare const version = "5.0.39";
package/lib/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = '5.0.37';
4
+ exports.version = '5.0.39';
5
5
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g6",
3
- "version": "5.0.37",
3
+ "version": "5.0.39",
4
4
  "description": "A Graph Visualization Framework in JavaScript",
5
5
  "keywords": [
6
6
  "antv",
@@ -268,7 +268,7 @@ export class HTML extends BaseNode<HTMLStyleProps> {
268
268
  let x: number;
269
269
  let y: number;
270
270
  const { offsetX, offsetY, clientX, clientY } = nativeEvent;
271
- if (this.context.canvas.context.config.supportsCSSTransform && !isNil(offsetX) && !isNil(offsetY)) {
271
+ if (!isNil(offsetX) && !isNil(offsetY)) {
272
272
  x = offsetX;
273
273
  y = offsetY;
274
274
  } else {
@@ -31,7 +31,7 @@ export interface TooltipOptions
31
31
  *
32
32
  * <en/> Function for getting tooltip content
33
33
  */
34
- getContent?: (event: IElementEvent, items: ElementDatum[]) => HTMLElement | string;
34
+ getContent?: (event: IElementEvent, items: ElementDatum[]) => Promise<HTMLElement | string>;
35
35
  /**
36
36
  * <zh/> 是否启用
37
37
  *
@@ -215,11 +215,11 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
215
215
  * <en/> Show tooltip of target element
216
216
  * @param id - <zh/> 元素 ID | <en/> element ID
217
217
  */
218
- public showById = (id: ID) => {
218
+ public showById = async (id: ID) => {
219
219
  const event = {
220
220
  target: { id },
221
221
  } as IElementEvent;
222
- this.show(event);
222
+ await this.show(event);
223
223
  };
224
224
 
225
225
  private getElementData = (id: ID, targetType: ElementType) => {
@@ -243,7 +243,7 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
243
243
  * @param event - <zh/> 目标元素 | <en/> target element
244
244
  * @internal
245
245
  */
246
- public show = (event: IElementEvent) => {
246
+ public show = async (event: IElementEvent) => {
247
247
  const {
248
248
  client,
249
249
  target: { id },
@@ -258,7 +258,7 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
258
258
 
259
259
  let tooltipContent: { [key: string]: unknown } = {};
260
260
  if (getContent) {
261
- tooltipContent.content = getContent(event, items);
261
+ tooltipContent.content = await getContent(event, items);
262
262
  if (!tooltipContent.content) return;
263
263
  } else {
264
264
  const style = this.context.graph.getElementRenderStyle(id);
@@ -1,6 +1,7 @@
1
- import type { AABB, BaseStyleProps, DisplayObject, TextStyleProps } from '@antv/g';
1
+ import type { AABB, DisplayObject, TextStyleProps } from '@antv/g';
2
2
  import { get, isNumber, isString, set } from '@antv/util';
3
3
  import { BaseCombo, BaseEdge, BaseNode } from '../elements';
4
+ import type { BaseShape } from '../elements/shapes';
4
5
  import type { Combo, Edge, Element, Node, NodePortStyleProps, Placement, Point, TriangleDirection } from '../types';
5
6
  import type { NodeLabelStyleProps, Port } from '../types/node';
6
7
  import { getBBoxHeight, getBBoxWidth } from './bbox';
@@ -474,8 +475,8 @@ export function isVisible(element: DisplayObject) {
474
475
  * @param element - <zh/> 元素 | <en/> element
475
476
  * @param style - <zh/> 样式 | <en/> style
476
477
  */
477
- export function setAttributes(element: DisplayObject, style: BaseStyleProps) {
478
- const { zIndex, transform, transformOrigin, visibility, cursor, clipPath, ...rest } = style;
478
+ export function setAttributes(element: BaseShape<any>, style: Record<string, any>) {
479
+ const { zIndex, transform, transformOrigin, visibility, cursor, clipPath, component, ...rest } = style;
479
480
  Object.assign(element.attributes, rest);
480
481
 
481
482
  if (transform) element.setAttribute('transform', transform);
@@ -484,6 +485,7 @@ export function setAttributes(element: DisplayObject, style: BaseStyleProps) {
484
485
  if (visibility) element.setAttribute('visibility', visibility);
485
486
  if (cursor) element.setAttribute('cursor', cursor);
486
487
  if (clipPath) element.setAttribute('clipPath', clipPath);
488
+ if (component) element.setAttribute('component', component);
487
489
  }
488
490
 
489
491
  /**
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '5.0.37';
1
+ export const version = '5.0.39';