@yh-ui/flow 1.0.51 → 1.0.52

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.
@@ -14,6 +14,7 @@ exports.getCustomEdge = getCustomEdge;
14
14
  exports.getCustomNode = getCustomNode;
15
15
  exports.getCustomNodeTemplate = getCustomNodeTemplate;
16
16
  exports.getEdgeTemplate = getEdgeTemplate;
17
+ exports.getNodeAbsolutePosition = getNodeAbsolutePosition;
17
18
  exports.getNodeChildren = getNodeChildren;
18
19
  exports.getNodeParent = getNodeParent;
19
20
  exports.hasCustomEdge = hasCustomEdge;
@@ -100,6 +101,26 @@ function getNodeParent(node, allNodes) {
100
101
  if (!node.parentId) return void 0;
101
102
  return allNodes.find(n => n.id === node.parentId);
102
103
  }
104
+ function getNodeAbsolutePosition(node, allNodes) {
105
+ let x = node.position.x;
106
+ let y = node.position.y;
107
+ let current = node;
108
+ let depth = 0;
109
+ const maxDepth = 100;
110
+ const nodeMap = allNodes instanceof Map ? allNodes : new Map(allNodes.map(n => [n.id, n]));
111
+ while (current.parentId && depth < maxDepth) {
112
+ const parent = nodeMap.get(current.parentId);
113
+ if (!parent) break;
114
+ x += parent.position.x;
115
+ y += parent.position.y;
116
+ current = parent;
117
+ depth++;
118
+ }
119
+ return {
120
+ x,
121
+ y
122
+ };
123
+ }
103
124
  const edgeTemplates = /* @__PURE__ */new Map();
104
125
  function registerEdgeTemplate(template) {
105
126
  edgeTemplates.set(template.type, template);
@@ -44,6 +44,31 @@ export interface NestedNodeConfig {
44
44
  export declare function isNestedNode(node: Node): boolean;
45
45
  export declare function getNodeChildren(node: Node, allNodes: Node[]): Node[];
46
46
  export declare function getNodeParent(node: Node, allNodes: Node[]): Node | undefined;
47
+ export declare function getNodeAbsolutePosition(node: {
48
+ id: string;
49
+ position: {
50
+ x: number;
51
+ y: number;
52
+ };
53
+ parentId?: string;
54
+ }, allNodes: {
55
+ id: string;
56
+ position: {
57
+ x: number;
58
+ y: number;
59
+ };
60
+ parentId?: string;
61
+ }[] | Map<string, {
62
+ id: string;
63
+ position: {
64
+ x: number;
65
+ y: number;
66
+ };
67
+ parentId?: string;
68
+ }>): {
69
+ x: number;
70
+ y: number;
71
+ };
47
72
  export interface EdgeTemplate {
48
73
  type: EdgeType;
49
74
  component?: Component;
@@ -70,6 +70,23 @@ export function getNodeParent(node, allNodes) {
70
70
  if (!node.parentId) return void 0;
71
71
  return allNodes.find((n) => n.id === node.parentId);
72
72
  }
73
+ export function getNodeAbsolutePosition(node, allNodes) {
74
+ let x = node.position.x;
75
+ let y = node.position.y;
76
+ let current = node;
77
+ let depth = 0;
78
+ const maxDepth = 100;
79
+ const nodeMap = allNodes instanceof Map ? allNodes : new Map(allNodes.map((n) => [n.id, n]));
80
+ while (current.parentId && depth < maxDepth) {
81
+ const parent = nodeMap.get(current.parentId);
82
+ if (!parent) break;
83
+ x += parent.position.x;
84
+ y += parent.position.y;
85
+ current = parent;
86
+ depth++;
87
+ }
88
+ return { x, y };
89
+ }
73
90
  const edgeTemplates = /* @__PURE__ */ new Map();
74
91
  export function registerEdgeTemplate(template) {
75
92
  edgeTemplates.set(template.type, template);
@@ -39,8 +39,8 @@ function getDir(pos) {
39
39
  function getHandlePosition(node, handlePosition = "right", _handleId) {
40
40
  const x = node.position.x;
41
41
  const y = node.position.y;
42
- let width = node.width;
43
- let height = node.height;
42
+ let width = node.measured?.width ?? node.width;
43
+ let height = node.measured?.height ?? node.height;
44
44
  if (width === void 0 && node.style?.width) {
45
45
  const val = parseInt(String(node.style.width));
46
46
  if (!isNaN(val)) width = val;
@@ -20,6 +20,10 @@ export declare function getHandlePosition(node: {
20
20
  width?: number;
21
21
  height?: number;
22
22
  style?: NodeStyle;
23
+ measured?: {
24
+ width: number;
25
+ height: number;
26
+ };
23
27
  }, handlePosition?: Position, _handleId?: string | null): {
24
28
  x: number;
25
29
  y: number;
@@ -13,8 +13,8 @@ function getDir(pos) {
13
13
  export function getHandlePosition(node, handlePosition = "right", _handleId) {
14
14
  const x = node.position.x;
15
15
  const y = node.position.y;
16
- let width = node.width;
17
- let height = node.height;
16
+ let width = node.measured?.width ?? node.width;
17
+ let height = node.measured?.height ?? node.height;
18
18
  if (width === void 0 && node.style?.width) {
19
19
  const val = parseInt(String(node.style.width));
20
20
  if (!isNaN(val)) width = val;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yh-ui/flow",
3
- "version": "1.0.51",
3
+ "version": "1.0.52",
4
4
  "description": "YH-UI High-performance Flow Chart Component",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -32,8 +32,8 @@
32
32
  "lint": "eslint ."
33
33
  },
34
34
  "dependencies": {
35
- "@yh-ui/utils": "^1.0.51",
36
- "@yh-ui/hooks": "^1.0.51"
35
+ "@yh-ui/utils": "^1.0.52",
36
+ "@yh-ui/hooks": "^1.0.52"
37
37
  },
38
38
  "devDependencies": {
39
39
  "vue": "^3.5.35",
@@ -41,7 +41,21 @@
41
41
  "vue-sfc-transformer": "^0.1.17"
42
42
  },
43
43
  "peerDependencies": {
44
- "vue": "^3.5.35"
44
+ "vue": "^3.5.35",
45
+ "dagre": ">=0.8.5",
46
+ "elkjs": ">=0.9.0",
47
+ "d3-force": ">=3.0.0"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "dagre": {
51
+ "optional": true
52
+ },
53
+ "elkjs": {
54
+ "optional": true
55
+ },
56
+ "d3-force": {
57
+ "optional": true
58
+ }
45
59
  },
46
60
  "publishConfig": {
47
61
  "access": "public"