@antv/g6 5.0.44 → 5.0.45

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 (170) hide show
  1. package/dist/g6.min.js +11 -11
  2. package/dist/lib/plugins/edge-filter-lens/index.d.ts +2 -2
  3. package/dist/lib/plugins/grid-line.d.ts +19 -1
  4. package/dist/lib/plugins/hull/hull/format.d.ts +9 -0
  5. package/dist/lib/plugins/hull/hull/grid_handle.d.ts +15 -0
  6. package/dist/lib/plugins/hull/hull/index.d.ts +3 -0
  7. package/dist/lib/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
  8. package/dist/lib/plugins/hull/hull/robust-orientation.d.ts +2 -0
  9. package/dist/lib/plugins/hull/hull/robust-scale.d.ts +1 -0
  10. package/dist/lib/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
  11. package/dist/lib/plugins/hull/hull/robust-subtract.d.ts +1 -0
  12. package/dist/lib/plugins/hull/hull/robust-sum.d.ts +1 -0
  13. package/dist/lib/plugins/hull/hull/two-product.d.ts +1 -0
  14. package/dist/lib/plugins/hull/hull/two-sum.d.ts +1 -0
  15. package/dist/lib/plugins/toolbar/util.d.ts +4 -0
  16. package/dist/lib/transforms/process-parallel-edges.d.ts +14 -2
  17. package/dist/lib/utils/element.d.ts +9 -9
  18. package/dist/lib/version.d.ts +1 -1
  19. package/esm/plugins/edge-filter-lens/index.d.ts +2 -2
  20. package/esm/plugins/edge-filter-lens/index.js +2 -0
  21. package/esm/plugins/edge-filter-lens/index.js.map +1 -1
  22. package/esm/plugins/fisheye/index.js +3 -0
  23. package/esm/plugins/fisheye/index.js.map +1 -1
  24. package/esm/plugins/grid-line.d.ts +19 -1
  25. package/esm/plugins/grid-line.js +42 -5
  26. package/esm/plugins/grid-line.js.map +1 -1
  27. package/esm/plugins/hull/hull/format.d.ts +9 -0
  28. package/esm/plugins/hull/hull/format.js +20 -0
  29. package/esm/plugins/hull/hull/format.js.map +1 -0
  30. package/esm/plugins/hull/hull/grid_handle.d.ts +15 -0
  31. package/esm/plugins/hull/hull/grid_handle.js +66 -0
  32. package/esm/plugins/hull/hull/grid_handle.js.map +1 -0
  33. package/esm/plugins/hull/hull/index.d.ts +3 -0
  34. package/esm/plugins/hull/hull/index.js +150 -0
  35. package/esm/plugins/hull/hull/index.js.map +1 -0
  36. package/esm/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
  37. package/esm/plugins/hull/hull/monotone-convex-hull-2d.js +63 -0
  38. package/esm/plugins/hull/hull/monotone-convex-hull-2d.js.map +1 -0
  39. package/esm/plugins/hull/hull/robust-orientation.d.ts +2 -0
  40. package/esm/plugins/hull/hull/robust-orientation.js +145 -0
  41. package/esm/plugins/hull/hull/robust-orientation.js.map +1 -0
  42. package/esm/plugins/hull/hull/robust-scale.d.ts +1 -0
  43. package/esm/plugins/hull/hull/robust-scale.js +47 -0
  44. package/esm/plugins/hull/hull/robust-scale.js.map +1 -0
  45. package/esm/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
  46. package/esm/plugins/hull/hull/robust-segment-intersect.js +29 -0
  47. package/esm/plugins/hull/hull/robust-segment-intersect.js.map +1 -0
  48. package/esm/plugins/hull/hull/robust-subtract.d.ts +1 -0
  49. package/esm/plugins/hull/hull/robust-subtract.js +161 -0
  50. package/esm/plugins/hull/hull/robust-subtract.js.map +1 -0
  51. package/esm/plugins/hull/hull/robust-sum.d.ts +1 -0
  52. package/esm/plugins/hull/hull/robust-sum.js +155 -0
  53. package/esm/plugins/hull/hull/robust-sum.js.map +1 -0
  54. package/esm/plugins/hull/hull/two-product.d.ts +1 -0
  55. package/esm/plugins/hull/hull/two-product.js +24 -0
  56. package/esm/plugins/hull/hull/two-product.js.map +1 -0
  57. package/esm/plugins/hull/hull/two-sum.d.ts +1 -0
  58. package/esm/plugins/hull/hull/two-sum.js +15 -0
  59. package/esm/plugins/hull/hull/two-sum.js.map +1 -0
  60. package/esm/plugins/hull/index.js +1 -1
  61. package/esm/plugins/hull/index.js.map +1 -1
  62. package/esm/plugins/minimap/index.js +1 -1
  63. package/esm/plugins/minimap/index.js.map +1 -1
  64. package/esm/plugins/toolbar/index.js +6 -3
  65. package/esm/plugins/toolbar/index.js.map +1 -1
  66. package/esm/plugins/toolbar/util.d.ts +4 -0
  67. package/esm/plugins/toolbar/util.js.map +1 -1
  68. package/esm/runtime/graph.js +1 -1
  69. package/esm/runtime/graph.js.map +1 -1
  70. package/esm/runtime/layout.js +4 -4
  71. package/esm/runtime/layout.js.map +1 -1
  72. package/esm/transforms/process-parallel-edges.d.ts +14 -2
  73. package/esm/transforms/process-parallel-edges.js +35 -10
  74. package/esm/transforms/process-parallel-edges.js.map +1 -1
  75. package/esm/utils/edge.js +5 -4
  76. package/esm/utils/edge.js.map +1 -1
  77. package/esm/utils/element.d.ts +9 -9
  78. package/esm/utils/element.js +30 -20
  79. package/esm/utils/element.js.map +1 -1
  80. package/esm/version.d.ts +1 -1
  81. package/esm/version.js +1 -1
  82. package/lib/plugins/edge-filter-lens/index.d.ts +2 -2
  83. package/lib/plugins/edge-filter-lens/index.js +2 -0
  84. package/lib/plugins/edge-filter-lens/index.js.map +1 -1
  85. package/lib/plugins/fisheye/index.js +3 -0
  86. package/lib/plugins/fisheye/index.js.map +1 -1
  87. package/lib/plugins/grid-line.d.ts +19 -1
  88. package/lib/plugins/grid-line.js +41 -4
  89. package/lib/plugins/grid-line.js.map +1 -1
  90. package/lib/plugins/hull/hull/format.d.ts +9 -0
  91. package/lib/plugins/hull/hull/format.js +23 -0
  92. package/lib/plugins/hull/hull/format.js.map +1 -0
  93. package/lib/plugins/hull/hull/grid_handle.d.ts +15 -0
  94. package/lib/plugins/hull/hull/grid_handle.js +71 -0
  95. package/lib/plugins/hull/hull/grid_handle.js.map +1 -0
  96. package/lib/plugins/hull/hull/index.d.ts +3 -0
  97. package/lib/plugins/hull/hull/index.js +153 -0
  98. package/lib/plugins/hull/hull/index.js.map +1 -0
  99. package/lib/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
  100. package/lib/plugins/hull/hull/monotone-convex-hull-2d.js +68 -0
  101. package/lib/plugins/hull/hull/monotone-convex-hull-2d.js.map +1 -0
  102. package/lib/plugins/hull/hull/robust-orientation.d.ts +2 -0
  103. package/lib/plugins/hull/hull/robust-orientation.js +146 -0
  104. package/lib/plugins/hull/hull/robust-orientation.js.map +1 -0
  105. package/lib/plugins/hull/hull/robust-scale.d.ts +1 -0
  106. package/lib/plugins/hull/hull/robust-scale.js +49 -0
  107. package/lib/plugins/hull/hull/robust-scale.js.map +1 -0
  108. package/lib/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
  109. package/lib/plugins/hull/hull/robust-segment-intersect.js +35 -0
  110. package/lib/plugins/hull/hull/robust-segment-intersect.js.map +1 -0
  111. package/lib/plugins/hull/hull/robust-subtract.d.ts +1 -0
  112. package/lib/plugins/hull/hull/robust-subtract.js +163 -0
  113. package/lib/plugins/hull/hull/robust-subtract.js.map +1 -0
  114. package/lib/plugins/hull/hull/robust-sum.d.ts +1 -0
  115. package/lib/plugins/hull/hull/robust-sum.js +157 -0
  116. package/lib/plugins/hull/hull/robust-sum.js.map +1 -0
  117. package/lib/plugins/hull/hull/two-product.d.ts +1 -0
  118. package/lib/plugins/hull/hull/two-product.js +26 -0
  119. package/lib/plugins/hull/hull/two-product.js.map +1 -0
  120. package/lib/plugins/hull/hull/two-sum.d.ts +1 -0
  121. package/lib/plugins/hull/hull/two-sum.js +17 -0
  122. package/lib/plugins/hull/hull/two-sum.js.map +1 -0
  123. package/lib/plugins/hull/index.js +2 -5
  124. package/lib/plugins/hull/index.js.map +1 -1
  125. package/lib/plugins/minimap/index.js +1 -1
  126. package/lib/plugins/minimap/index.js.map +1 -1
  127. package/lib/plugins/toolbar/index.js +6 -3
  128. package/lib/plugins/toolbar/index.js.map +1 -1
  129. package/lib/plugins/toolbar/util.d.ts +4 -0
  130. package/lib/plugins/toolbar/util.js.map +1 -1
  131. package/lib/runtime/graph.js +1 -1
  132. package/lib/runtime/graph.js.map +1 -1
  133. package/lib/runtime/layout.js +4 -4
  134. package/lib/runtime/layout.js.map +1 -1
  135. package/lib/transforms/process-parallel-edges.d.ts +14 -2
  136. package/lib/transforms/process-parallel-edges.js +35 -10
  137. package/lib/transforms/process-parallel-edges.js.map +1 -1
  138. package/lib/utils/edge.js +5 -4
  139. package/lib/utils/edge.js.map +1 -1
  140. package/lib/utils/element.d.ts +9 -9
  141. package/lib/utils/element.js +30 -20
  142. package/lib/utils/element.js.map +1 -1
  143. package/lib/version.d.ts +1 -1
  144. package/lib/version.js +1 -1
  145. package/package.json +3 -4
  146. package/src/plugins/edge-filter-lens/index.ts +4 -4
  147. package/src/plugins/fisheye/index.ts +2 -0
  148. package/src/plugins/grid-line.ts +72 -8
  149. package/src/plugins/hull/hull/README.md +1 -0
  150. package/src/plugins/hull/hull/format.ts +29 -0
  151. package/src/plugins/hull/hull/grid_handle.ts +73 -0
  152. package/src/plugins/hull/hull/index.ts +203 -0
  153. package/src/plugins/hull/hull/monotone-convex-hull-2d.ts +76 -0
  154. package/src/plugins/hull/hull/robust-orientation.ts +443 -0
  155. package/src/plugins/hull/hull/robust-scale.ts +53 -0
  156. package/src/plugins/hull/hull/robust-segment-intersect.ts +29 -0
  157. package/src/plugins/hull/hull/robust-subtract.ts +187 -0
  158. package/src/plugins/hull/hull/robust-sum.ts +175 -0
  159. package/src/plugins/hull/hull/two-product.ts +31 -0
  160. package/src/plugins/hull/hull/two-sum.ts +17 -0
  161. package/src/plugins/hull/index.ts +1 -1
  162. package/src/plugins/minimap/index.ts +4 -8
  163. package/src/plugins/toolbar/index.ts +1 -1
  164. package/src/plugins/toolbar/util.ts +4 -0
  165. package/src/runtime/graph.ts +1 -1
  166. package/src/runtime/layout.ts +4 -4
  167. package/src/transforms/process-parallel-edges.ts +41 -10
  168. package/src/utils/edge.ts +5 -4
  169. package/src/utils/element.ts +33 -22
  170. package/src/version.ts +1 -1
@@ -1,7 +1,7 @@
1
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
+ import type { BaseShape, BaseShapeStyleProps } from '../elements/shapes';
5
5
  import type { Combo, Edge, Element, Node, NodePortStyleProps, Placement, Point, TriangleDirection } from '../types';
6
6
  import type { NodeLabelStyleProps, Port } from '../types/node';
7
7
  import { getBBoxHeight, getBBoxWidth } from './bbox';
@@ -71,6 +71,14 @@ const PORT_MAP: Record<string, Point> = {
71
71
  right: [1, 0.5],
72
72
  bottom: [0.5, 1],
73
73
  left: [0, 0.5],
74
+ 'left-top': [0, 0],
75
+ 'top-left': [0, 0],
76
+ 'left-bottom': [0, 1],
77
+ 'bottom-left': [0, 1],
78
+ 'right-top': [1, 0],
79
+ 'top-right': [1, 0],
80
+ 'right-bottom': [1, 1],
81
+ 'bottom-right': [1, 1],
74
82
  default: [0.5, 0.5],
75
83
  };
76
84
 
@@ -78,18 +86,18 @@ const PORT_MAP: Record<string, Point> = {
78
86
  * Get the Port x, y by `position`.
79
87
  * @param bbox - BBox of element.
80
88
  * @param placement - The position relative with element.
81
- * @param ports - The map of position.
89
+ * @param portMap - The map of position.
82
90
  * @param isRelative - Whether the position in MAP is relative.
83
91
  * @returns [x, y]
84
92
  */
85
93
  export function getPortXYByPlacement(
86
94
  bbox: AABB,
87
95
  placement?: Placement,
88
- ports: Record<string, Point> = PORT_MAP,
96
+ portMap: Record<string, Point> = PORT_MAP,
89
97
  isRelative = true,
90
98
  ): Point {
91
99
  const DEFAULT = [0.5, 0.5];
92
- const p: [number, number] = isString(placement) ? get(ports, placement.toLocaleLowerCase(), DEFAULT) : placement;
100
+ const p: [number, number] = isString(placement) ? get(portMap, placement.toLocaleLowerCase(), DEFAULT) : placement;
93
101
 
94
102
  if (!isRelative && isString(placement)) return p;
95
103
 
@@ -174,7 +182,7 @@ export function findPorts(
174
182
  * 3. If the node has no ports, return undefined.
175
183
  * @param node - <zh/> 节点 | <en/> Node
176
184
  * @param oppositeNode - <zh/> 对端节点 | <en/> Opposite Node
177
- * @param portKey - <zh/> 连接桩的 key | <en/> Port Key
185
+ * @param portKey - <zh/> 连接桩的键值(key) | <en/> Port Key
178
186
  * @param oppositePortKey - <zh/> 对端连接桩的 key | <en/> Opposite Port Key
179
187
  * @returns <zh/> 连接桩 | <en/> Port
180
188
  */
@@ -200,7 +208,7 @@ export function findPort(node: Node, oppositeNode: Node, portKey?: string, oppos
200
208
  * 2. If `portKey` is not specified, return positions of all ports.
201
209
  * 3. If the node has no ports, return the center of the node.
202
210
  * @param node - <zh/> 节点 | <en/> Node
203
- * @param portKey
211
+ * @param portKey - <zh/> 连接桩的键值(key),如不指定则返回所有 | <en/> Port Key, return all if not specified
204
212
  * @returns <zh/> 连接点 | <en/> Connection Point
205
213
  */
206
214
  function findConnectionPoints(node: Node, portKey?: string): Point[] {
@@ -230,7 +238,7 @@ export function getConnectionPoint(node: Port | Node | Combo, opposite: Node | P
230
238
  * <en/> Get the connection point of the port
231
239
  * @param port - <zh/> 连接桩 | <en/> Port
232
240
  * @param opposite - <zh/> 对端的具体点或节点 | <en/> Opposite Point or Node
233
- * @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
241
+ * // @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
234
242
  * @returns <zh/> 连接桩的连接点 | <en/> Port Point
235
243
  */
236
244
  export function getPortConnectionPoint(port: Port, opposite: Node | Port): Point {
@@ -240,8 +248,8 @@ export function getPortConnectionPoint(port: Port, opposite: Node | Port): Point
240
248
  // 1. linkToCenter 为 true,则返回连接桩的中心 | If linkToCenter is true, return the center of the port
241
249
  if (port.attributes.linkToCenter) return port.getPosition();
242
250
 
243
- // 2. 推导对端的具体点:如果是连接桩,则返回连接桩的中心;如果是节点,则返回节点的中心;如果是具体点则直接返回
244
- // 2. Derive the specific point of the opposite: if it is a port, return the center of the port; if it is a node, return the center of the node; if it is a specific point, return directly
251
+ // 2. 推导对端的具体点:如果是连接桩或节点,则返回它的中心;如果是具体点,则直接返回
252
+ // 2. Get a specific opposite point: if it is a port or a node, return its center; if it is a specific point, return directly
245
253
  const oppositePosition = isPoint(opposite)
246
254
  ? opposite
247
255
  : isNode(opposite)
@@ -256,19 +264,19 @@ export function getPortConnectionPoint(port: Port, opposite: Node | Port): Point
256
264
  * <zh/> 获取节点的连接点
257
265
  *
258
266
  * <en/> Get the Node Connection Point
259
- * @param node - <zh/> 节点 | <en/> Node
267
+ * @param nodeLike - <zh/> 节点或组合 | <en/> Node or Combo
260
268
  * @param opposite - <zh/> 对端的具体点或节点 | <en/> Opposite Point or Node
261
- * @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
269
+ * // @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
262
270
  * @returns <zh/> 节点的连接点 | <en/> Node Point
263
271
  */
264
- export function getNodeConnectionPoint(node: Node, opposite: Node | Port): Point {
265
- if (!node || !opposite) return [0, 0, 0];
272
+ export function getNodeConnectionPoint(nodeLike: Node | Combo, opposite: Node | Port): Point {
273
+ if (!nodeLike || !opposite) return [0, 0, 0];
266
274
  const oppositePosition = isPoint(opposite)
267
275
  ? opposite
268
276
  : isNode(opposite)
269
277
  ? opposite.getCenter()
270
278
  : opposite.getPosition();
271
- return node.getIntersectPoint(oppositePosition) || node.getCenter();
279
+ return nodeLike.getIntersectPoint(oppositePosition) || nodeLike.getCenter();
272
280
  }
273
281
 
274
282
  /**
@@ -290,16 +298,19 @@ export function getTextStyleByPlacement(
290
298
  const direction = placement.split('-');
291
299
  const [x, y] = getXYByPlacement(bbox, placement);
292
300
 
293
- const textAlign = direction.includes('left') ? 'right' : direction.includes('right') ? 'left' : 'center';
301
+ const [top, bottom]: TextStyleProps['textBaseline'][] = isReverseBaseline ? ['bottom', 'top'] : ['top', 'bottom'];
294
302
 
295
- let textBaseline: TextStyleProps['textBaseline'] = direction.includes('top')
296
- ? 'bottom'
303
+ const textBaseline: TextStyleProps['textBaseline'] = direction.includes('top')
304
+ ? bottom
297
305
  : direction.includes('bottom')
298
- ? 'top'
306
+ ? top
299
307
  : 'middle';
300
- if (isReverseBaseline) {
301
- textBaseline = textBaseline === 'top' ? 'bottom' : textBaseline === 'bottom' ? 'top' : textBaseline;
302
- }
308
+
309
+ const textAlign: TextStyleProps['textAlign'] = direction.includes('left')
310
+ ? 'right'
311
+ : direction.includes('right')
312
+ ? 'left'
313
+ : 'center';
303
314
 
304
315
  return {
305
316
  transform: [['translate', x + offsetX, y + offsetY]],
@@ -475,7 +486,7 @@ export function isVisible(element: DisplayObject) {
475
486
  * @param element - <zh/> 元素 | <en/> element
476
487
  * @param style - <zh/> 样式 | <en/> style
477
488
  */
478
- export function setAttributes(element: BaseShape<any>, style: Record<string, any>) {
489
+ export function setAttributes(element: BaseShape<any>, style: Partial<BaseShapeStyleProps> & Record<string, any>) {
479
490
  const { zIndex, transform, transformOrigin, visibility, cursor, clipPath, component, ...rest } = style;
480
491
  Object.assign(element.attributes, rest);
481
492
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '5.0.44';
1
+ export const version = '5.0.45';