@likec4/diagram 1.20.2 → 1.20.3

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.
@@ -21,9 +21,10 @@ declare abstract class Rect {
21
21
  };
22
22
  get position(): XYPosition;
23
23
  protected abstract parent: Compound | null;
24
+ constructor(xynode: InternalNode, parent?: Compound | null);
24
25
  }
25
26
  declare class Compound extends Rect {
26
- protected readonly parent: Compound | null;
27
+ readonly parent: Compound | null;
27
28
  readonly children: Rect[];
28
29
  constructor(xynode: InternalNode, parent?: Compound | null);
29
30
  }
@@ -10,12 +10,23 @@ import { useSyncedRef } from "@react-hookz/web";
10
10
  import { useDiagram } from "../hooks/useDiagram.js";
11
11
  import { useXYStoreApi } from "../hooks/useXYFlow.js";
12
12
  class Rect {
13
- constructor() {
13
+ constructor(xynode, parent = null) {
14
14
  __publicField(this, "id");
15
15
  __publicField(this, "minX", Infinity);
16
16
  __publicField(this, "minY", Infinity);
17
17
  __publicField(this, "maxX", -Infinity);
18
18
  __publicField(this, "maxY", -Infinity);
19
+ this.id = xynode.id;
20
+ this.positionAbsolute = !parent ? xynode.position : {
21
+ x: xynode.position.x + parent.minX,
22
+ y: xynode.position.y + parent.minY
23
+ };
24
+ const { width, height } = getNodeDimensions(xynode);
25
+ this.maxX = this.minX + Math.ceil(width);
26
+ this.maxY = this.minY + Math.ceil(height);
27
+ if (parent) {
28
+ parent.children.push(this);
29
+ }
19
30
  }
20
31
  get positionAbsolute() {
21
32
  return {
@@ -56,27 +67,15 @@ __publicField(Rect, "TopPadding", 55);
56
67
  __publicField(Rect, "BottomPadding", 40);
57
68
  class Compound extends Rect {
58
69
  constructor(xynode, parent = null) {
59
- super();
70
+ super(xynode, parent);
60
71
  __publicField(this, "children", []);
61
72
  this.parent = parent;
62
- this.id = xynode.id;
63
- if (parent) {
64
- parent.children.push(this);
65
- }
66
73
  }
67
74
  }
68
75
  class Leaf extends Rect {
69
76
  constructor(xynode, parent = null) {
70
- super();
77
+ super(xynode, parent);
71
78
  this.parent = parent;
72
- this.id = xynode.id;
73
- this.positionAbsolute = xynode.internals.positionAbsolute;
74
- const { width, height } = getNodeDimensions(xynode);
75
- this.maxX = this.minX + Math.ceil(width);
76
- this.maxY = this.minY + Math.ceil(height);
77
- if (parent) {
78
- parent.children.push(this);
79
- }
80
79
  }
81
80
  }
82
81
  function createLayoutConstraints(xyflowApi, editingNodeIds) {
@@ -20,8 +20,8 @@ function TabPanelRelationships({
20
20
  useState("view");
21
21
  const incoming = [...element.incoming()].map((r) => r.id);
22
22
  const outgoing = [...element.outgoing()].map((r) => r.id);
23
- const incomingInView = unique(node.incoming().flatMap((e) => e.$edge.relations).toArray());
24
- const outgoingInView = unique(node.outgoing().flatMap((e) => e.$edge.relations).toArray());
23
+ const incomingInView = unique([...node.incoming()].flatMap((e) => e.$edge.relations));
24
+ const outgoingInView = unique([...node.outgoing()].flatMap((e) => e.$edge.relations));
25
25
  const notIncludedRelations = [
26
26
  ...incoming,
27
27
  ...outgoing
@@ -1,11 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { IconZoomScan, IconTransform } from "@tabler/icons-react";
2
+ import { IconZoomScan, IconTransform, IconFileSymlink } from "@tabler/icons-react";
3
3
  import { useEnabledFeature } from "../../../context/DiagramFeatures.js";
4
4
  import { useDiagram } from "../../../hooks/useDiagram.js";
5
5
  import { useRelationshipsBrowser } from "../hooks.js";
6
6
  import { ElementActionButtons } from "../../../base/primitives/element/ElementActionButtons.js";
7
7
  const ElementActions = (props) => {
8
- const { enableNavigateTo } = useEnabledFeature("NavigateTo");
8
+ const { enableNavigateTo, enableVscode } = useEnabledFeature("NavigateTo", "Vscode");
9
9
  const diagram = useDiagram();
10
10
  const browser = useRelationshipsBrowser();
11
11
  const buttons = [];
@@ -30,6 +30,16 @@ const ElementActions = (props) => {
30
30
  }
31
31
  });
32
32
  }
33
+ if (enableVscode) {
34
+ buttons.push({
35
+ key: "goToSource",
36
+ icon: /* @__PURE__ */ jsx(IconFileSymlink, {}),
37
+ onClick: (e) => {
38
+ e.stopPropagation();
39
+ diagram.openSource({ element: fqn });
40
+ }
41
+ });
42
+ }
33
43
  return /* @__PURE__ */ jsx(
34
44
  ElementActionButtons,
35
45
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/diagram",
3
- "version": "1.20.2",
3
+ "version": "1.20.3",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@dagrejs/dagre": "1.1.4",
42
- "@likec4/core": "1.20.2",
42
+ "@likec4/core": "1.20.3",
43
43
  "@mantine/vanilla-extract": "7.15.2",
44
44
  "@react-hookz/web": "^25.0.1",
45
45
  "@tabler/icons-react": "3.29.0",
@@ -52,7 +52,7 @@
52
52
  "d3-shape": "^3.2.0",
53
53
  "esm-env": "^1.2.2",
54
54
  "fast-equals": "^5.2.2",
55
- "framer-motion": "^11.16.0",
55
+ "framer-motion": "^11.18.2",
56
56
  "khroma": "^2.1.0",
57
57
  "react-error-boundary": "^4.1.2",
58
58
  "remeda": "^2.19.0",
@@ -67,7 +67,7 @@
67
67
  "react-dom": "^18.0.0 || ^19.0.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@likec4/tsconfig": "1.20.2",
70
+ "@likec4/tsconfig": "1.20.3",
71
71
  "@mantine/core": "7.15.2",
72
72
  "@mantine/hooks": "7.15.2",
73
73
  "@mantine/spotlight": "7.15.2",
@@ -76,7 +76,7 @@
76
76
  "@types/d3-shape": "^3.1.7",
77
77
  "@types/react": "~19.0.8",
78
78
  "@types/react-dom": "~19.0.3",
79
- "@vanilla-extract/css": "^1.17.0",
79
+ "@vanilla-extract/css": "^1.17.1",
80
80
  "@vanilla-extract/css-utils": "^0.1.4",
81
81
  "@vanilla-extract/dynamic": "^2.1.2",
82
82
  "react": "~19.0.0",
@@ -60,42 +60,46 @@ abstract class Rect {
60
60
  }
61
61
  }
62
62
  protected abstract parent: Compound | null
63
- }
64
-
65
- class Compound extends Rect {
66
- public readonly children = [] as Rect[]
67
63
 
68
64
  constructor(
69
65
  xynode: InternalNode,
70
- protected readonly parent: Compound | null = null,
66
+ parent: Compound | null = null,
71
67
  ) {
72
- super()
73
68
  this.id = xynode.id
74
69
 
70
+ this.positionAbsolute = !parent ? xynode.position : {
71
+ x: xynode.position.x + parent.minX,
72
+ y: xynode.position.y + parent.minY,
73
+ }
74
+
75
+ const { width, height } = getNodeDimensions(xynode)
76
+
77
+ this.maxX = this.minX + Math.ceil(width)
78
+ this.maxY = this.minY + Math.ceil(height)
79
+
75
80
  if (parent) {
76
81
  parent.children.push(this)
77
82
  }
78
83
  }
79
84
  }
80
85
 
81
- class Leaf extends Rect {
86
+ class Compound extends Rect {
87
+ public readonly children = [] as Rect[]
88
+
82
89
  constructor(
83
90
  xynode: InternalNode,
84
91
  public readonly parent: Compound | null = null,
85
92
  ) {
86
- super()
87
- this.id = xynode.id
88
-
89
- this.positionAbsolute = xynode.internals.positionAbsolute
90
-
91
- const { width, height } = getNodeDimensions(xynode)
92
-
93
- this.maxX = this.minX + Math.ceil(width)
94
- this.maxY = this.minY + Math.ceil(height)
93
+ super(xynode, parent)
94
+ }
95
+ }
95
96
 
96
- if (parent) {
97
- parent.children.push(this)
98
- }
97
+ class Leaf extends Rect {
98
+ constructor(
99
+ xynode: InternalNode,
100
+ public readonly parent: Compound | null = null,
101
+ ) {
102
+ super(xynode, parent)
99
103
  }
100
104
  }
101
105
 
@@ -28,8 +28,8 @@ export function TabPanelRelationships({
28
28
  const incoming = [...element.incoming()].map(r => r.id)
29
29
  const outgoing = [...element.outgoing()].map(r => r.id)
30
30
 
31
- const incomingInView = unique(node.incoming().flatMap(e => e.$edge.relations).toArray())
32
- const outgoingInView = unique(node.outgoing().flatMap(e => e.$edge.relations).toArray())
31
+ const incomingInView = unique([...node.incoming()].flatMap(e => e.$edge.relations))
32
+ const outgoingInView = unique([...node.outgoing()].flatMap(e => e.$edge.relations))
33
33
 
34
34
  const notIncludedRelations = [
35
35
  ...incoming,
@@ -1,4 +1,4 @@
1
- import { IconTransform, IconZoomScan } from '@tabler/icons-react'
1
+ import { IconFileSymlink, IconTransform, IconZoomScan } from '@tabler/icons-react'
2
2
  import { ElementActionButtons } from '../../../base/primitives'
3
3
  import type { NodeProps } from '../../../base/types'
4
4
  import { useEnabledFeature } from '../../../context/DiagramFeatures'
@@ -8,7 +8,7 @@ import { useRelationshipsBrowser } from '../hooks'
8
8
 
9
9
  type ElementActionsProps = NodeProps<Types.ElementNodeData>
10
10
  export const ElementActions = (props: ElementActionsProps) => {
11
- const { enableNavigateTo } = useEnabledFeature('NavigateTo')
11
+ const { enableNavigateTo, enableVscode } = useEnabledFeature('NavigateTo', 'Vscode')
12
12
  const diagram = useDiagram()
13
13
  const browser = useRelationshipsBrowser()
14
14
 
@@ -35,6 +35,16 @@ export const ElementActions = (props: ElementActionsProps) => {
35
35
  },
36
36
  })
37
37
  }
38
+ if (enableVscode) {
39
+ buttons.push({
40
+ key: 'goToSource',
41
+ icon: <IconFileSymlink />,
42
+ onClick: (e) => {
43
+ e.stopPropagation()
44
+ diagram.openSource({ element: fqn })
45
+ },
46
+ })
47
+ }
38
48
  return (
39
49
  <ElementActionButtons
40
50
  buttons={buttons}