likec4 1.16.0 → 1.17.1

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.
@@ -78,13 +78,13 @@ const LikeC4ViewMemo = /* @__PURE__ */ memo<LikeC4ViewProps>(function LikeC4View
78
78
  background = 'transparent',
79
79
  browserBackground = 'dots',
80
80
  where,
81
- showElementLinks = true,
82
81
  showDiagramTitle = false,
83
82
  showNavigationButtons = false,
84
83
  showNotations = false,
85
84
  enableFocusMode = false,
86
- showRelationshipDetails = false,
87
- enableRelationshipsBrowser = false,
85
+ enableElementDetails = false,
86
+ enableRelationshipDetails = false,
87
+ enableRelationshipBrowser = enableRelationshipDetails,
88
88
  browserClassName,
89
89
  browserStyle,
90
90
  mantineTheme,
@@ -124,12 +124,13 @@ const LikeC4ViewMemo = /* @__PURE__ */ memo<LikeC4ViewProps>(function LikeC4View
124
124
  onNavigateTo={interactive ? onNavigateTo : undefined}
125
125
  background={background}
126
126
  renderIcon={RenderIcon}
127
- showElementLinks={showElementLinks}
128
127
  showDiagramTitle={showDiagramTitle}
129
128
  showNavigationButtons={showNavigationButtons}
130
129
  showNotations={showNotations}
131
130
  enableFocusMode={enableFocusMode}
132
- showRelationshipDetails={showRelationshipDetails}
131
+ enableElementDetails={enableElementDetails}
132
+ enableRelationshipBrowser={enableRelationshipBrowser}
133
+ enableRelationshipDetails={enableRelationshipDetails}
133
134
  where={where}
134
135
  mantineTheme={mantineTheme}
135
136
  styleNonce={styleNonce}
@@ -149,7 +150,9 @@ const LikeC4ViewMemo = /* @__PURE__ */ memo<LikeC4ViewProps>(function LikeC4View
149
150
  style={browserStyle}
150
151
  mantineTheme={mantineTheme}
151
152
  styleNonce={styleNonce}
152
- enableRelationshipsBrowser={enableRelationshipsBrowser}
153
+ enableElementDetails
154
+ enableRelationshipBrowser
155
+ enableRelationshipDetails
153
156
  />
154
157
  )}
155
158
  </LikeC4ModelProvider>
@@ -1,19 +1,11 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useOverviewGraph } from "virtual:likec4/overview-graph";
3
- import { u, c as createReactComponent, I as IconFolderFilled, e, a as useUpdateEffect, n as nonexhaustive } from "./main-DejpCNPJ.js";
4
- import { u as useRouter } from "./tanstack-router-CfO1HFS2.js";
5
- import { B as BaseEdge, H as Handle, P as Position, u as useNodesState, a as useEdgesState, i as index, b as Background, c as BackgroundVariant } from "./likec4-zEZHE7gJ.js";
3
+ import { c as createReactComponent, I as IconFolderFilled, n, u as useUpdateEffect, i, a as nonexhaustive } from "./main-E2hyQKFO.js";
4
+ import { u as useRouter } from "./tanstack-router-CF1kJvtP.js";
5
+ import { B as BaseEdge, H as Handle, P as Position, u as useNodesState, a as useEdgesState, i as index, b as Background, c as BackgroundVariant } from "./likec4-DF_Jsv_p.js";
6
6
  import { memo, useRef, useMemo } from "react";
7
- import { P as Paper, c as clsx, G as Group, T as ThemeIcon, a as Text, C as Card, b as CardSection, d as Center, I as Image, B as Box, u as useMantineColorScheme } from "./mantine-Dx0sIYv1.js";
7
+ import { P as Paper, c as clsx, G as Group, T as ThemeIcon, a as Text, C as Card, b as CardSection, d as Center, I as Image, B as Box, u as useMantineColorScheme } from "./mantine-BzD51ZKm.js";
8
8
  import { usePreviewUrl } from "virtual:likec4/previews";
9
- function i(...e2) {
10
- return u(y, e2);
11
- }
12
- function y(e2, r) {
13
- let o = {};
14
- for (let n of r) n in e2 && (o[n] = e2[n]);
15
- return o;
16
- }
17
9
  /**
18
10
  * @license @tabler/icons-react v3.17.0 - MIT
19
11
  *
@@ -29,7 +21,7 @@ var IconLoader = createReactComponent("outline", "loader", "IconLoader", [["path
29
21
  */
30
22
  var IconFileFilled = createReactComponent("filled", "file-filled", "IconFileFilled", [["path", { d: "M12 2l.117 .007a1 1 0 0 1 .876 .876l.007 .117v4l.005 .15a2 2 0 0 0 1.838 1.844l.157 .006h4l.117 .007a1 1 0 0 1 .876 .876l.007 .117v9a3 3 0 0 1 -2.824 2.995l-.176 .005h-10a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-14a3 3 0 0 1 2.824 -2.995l.176 -.005h5z", key: "svg-0" }], ["path", { d: "M19 7h-4l-.001 -4.001z", key: "svg-1" }]]), root = "mxt2a80";
31
23
  function edgePath(points) {
32
- return points.reduce((acc, [x, y2], i2) => acc + `${i2 === 0 ? "M" : " L"} ${x},${y2}`, "");
24
+ return points.reduce((acc, [x, y], i2) => acc + `${i2 === 0 ? "M" : " L"} ${x},${y}`, "");
33
25
  }
34
26
  function LinkEdge({
35
27
  id,
@@ -54,7 +46,7 @@ const FolderNode = /* @__PURE__ */ memo(function({
54
46
  parentId,
55
47
  id
56
48
  }) {
57
- const isTopLevel = e(parentId);
49
+ const isTopLevel = n(parentId);
58
50
  return /* @__PURE__ */ jsxs(Fragment, { children: [
59
51
  /* @__PURE__ */ jsx(Handle, { type: "target", position: Position.Top, className: handleCenter }),
60
52
  /* @__PURE__ */ jsx(
@@ -83,7 +75,7 @@ const FolderNode = /* @__PURE__ */ memo(function({
83
75
  parentId,
84
76
  id
85
77
  }) {
86
- const isTopLevel = e(parentId);
78
+ const isTopLevel = n(parentId);
87
79
  return /* @__PURE__ */ jsxs(Fragment, { children: [
88
80
  /* @__PURE__ */ jsx(Handle, { type: "target", position: Position.Top, className: handleCenter }),
89
81
  /* @__PURE__ */ jsx(
@@ -150,7 +142,7 @@ const FolderNode = /* @__PURE__ */ memo(function({
150
142
  link: LinkEdge
151
143
  }, overviewGraphToXYFlowData = (graph) => ({
152
144
  nodes: graph.nodes.map(({ id, parentId, position, width, height, ...node }) => {
153
- const parent = parentId ? graph.nodes.find((n) => n.id === parentId) : null, rect = {
145
+ const parent = parentId ? graph.nodes.find((n2) => n2.id === parentId) : null, rect = {
154
146
  ...position,
155
147
  width,
156
148
  height
@@ -222,9 +214,9 @@ function OverviewDiagrams({
222
214
  const router = useRouter(), xyflowRef = useRef(), { colorScheme } = useMantineColorScheme(), xyflowdata = useMemo(() => overviewGraphToXYFlowData(graph), [graph]), [nodes, setNodes, onNodesChange] = useNodesState(xyflowdata.nodes), [edges, setEdges, onEdgeChanges] = useEdgesState(xyflowdata.edges);
223
215
  useUpdateEffect(() => {
224
216
  setNodes(
225
- (nodes2) => xyflowdata.nodes.map((n) => {
226
- const current = nodes2.find((node) => node.id === n.id);
227
- return current ? { ...i(current, ["selected", "hidden"]), ...n } : n;
217
+ (nodes2) => xyflowdata.nodes.map((n2) => {
218
+ const current = nodes2.find((node) => node.id === n2.id);
219
+ return current ? { ...i(current, ["selected", "hidden"]), ...n2 } : n2;
228
220
  })
229
221
  ), setEdges(xyflowdata.edges);
230
222
  }, [xyflowdata.nodes, xyflowdata.edges]);
@@ -284,7 +276,7 @@ function OverviewDiagrams({
284
276
  onInit: (instance) => xyflowRef.current = instance,
285
277
  onNodeClick: (event, node) => {
286
278
  if (node.type === "view") {
287
- event.stopPropagation(), setNodes((nodes2) => nodes2.map(({ data, ...n }) => ({ ...n, data: { ...data, dimmed: n.id !== node.id } }))), xyflowRef.current?.fitView({
279
+ event.stopPropagation(), setNodes((nodes2) => nodes2.map(({ data, ...n2 }) => ({ ...n2, data: { ...data, dimmed: n2.id !== node.id } }))), xyflowRef.current?.fitView({
288
280
  maxZoom: 10,
289
281
  padding: 0,
290
282
  nodes: [node],
@@ -302,7 +294,7 @@ function OverviewDiagrams({
302
294
  }, 800);
303
295
  return;
304
296
  }
305
- node.selected && (event.stopPropagation(), setNodes((nodes2) => nodes2.map((n) => n.id === node.id ? { ...n, selected: !1 } : n)));
297
+ node.selected && (event.stopPropagation(), setNodes((nodes2) => nodes2.map((n2) => n2.id === node.id ? { ...n2, selected: !1 } : n2)));
306
298
  },
307
299
  children: /* @__PURE__ */ jsx(Background, { variant: BackgroundVariant.Dots, size: 4, gap: 50 })
308
300
  }
@@ -2486,19 +2486,15 @@ function nodeHasDimensions(node) {
2486
2486
  return (node.measured?.width ?? node.width ?? node.initialWidth) !== void 0 && (node.measured?.height ?? node.height ?? node.initialHeight) !== void 0;
2487
2487
  }
2488
2488
  function evaluateAbsolutePosition(position, dimensions = { width: 0, height: 0 }, parentId, nodeLookup, nodeOrigin) {
2489
- let nextParentId = parentId;
2490
- const positionAbsolute = { ...position };
2491
- for (; nextParentId; ) {
2492
- const parent = nodeLookup.get(nextParentId);
2493
- if (nextParentId = parent?.parentId, parent) {
2494
- const origin = parent.origin || nodeOrigin;
2495
- positionAbsolute.x += parent.internals.positionAbsolute.x - (dimensions.width ?? 0) * origin[0], positionAbsolute.y += parent.internals.positionAbsolute.y - (dimensions.height ?? 0) * origin[1];
2496
- }
2489
+ const positionAbsolute = { ...position }, parent = nodeLookup.get(parentId);
2490
+ if (parent) {
2491
+ const origin = parent.origin || nodeOrigin;
2492
+ positionAbsolute.x += parent.internals.positionAbsolute.x - (dimensions.width ?? 0) * origin[0], positionAbsolute.y += parent.internals.positionAbsolute.y - (dimensions.height ?? 0) * origin[1];
2497
2493
  }
2498
2494
  return positionAbsolute;
2499
2495
  }
2500
- function getPointerPosition(event, { snapGrid = [0, 0], snapToGrid = !1, transform: transform2 }) {
2501
- const { x, y } = getEventPosition(event), pointerPos = pointToRendererPoint({ x, y }, transform2), { x: xSnapped, y: ySnapped } = snapToGrid ? snapPosition(pointerPos, snapGrid) : pointerPos;
2496
+ function getPointerPosition(event, { snapGrid = [0, 0], snapToGrid = !1, transform: transform2, containerBounds }) {
2497
+ const { x, y } = getEventPosition(event), pointerPos = pointToRendererPoint({ x: x - (containerBounds?.left ?? 0), y: y - (containerBounds?.top ?? 0) }, transform2), { x: xSnapped, y: ySnapped } = snapToGrid ? snapPosition(pointerPos, snapGrid) : pointerPos;
2502
2498
  return {
2503
2499
  xSnapped,
2504
2500
  ySnapped,
@@ -3054,13 +3050,13 @@ function getEventHandlerParams({ nodeId, dragItems, nodeLookup, dragging = !0 })
3054
3050
  }
3055
3051
  if (!nodeId)
3056
3052
  return [nodesFromDragItems[0], nodesFromDragItems];
3057
- const node = nodeLookup.get(nodeId).internals.userNode;
3053
+ const node = nodeLookup.get(nodeId)?.internals.userNode;
3058
3054
  return [
3059
- {
3055
+ node ? {
3060
3056
  ...node,
3061
3057
  position: dragItems.get(nodeId)?.position || node.position,
3062
3058
  dragging
3063
- },
3059
+ } : nodesFromDragItems[0],
3064
3060
  nodesFromDragItems
3065
3061
  ];
3066
3062
  }
@@ -3120,7 +3116,7 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
3120
3116
  function startDrag(event) {
3121
3117
  const { nodeLookup, multiSelectionActive, nodesDraggable, transform: transform2, snapGrid, snapToGrid, selectNodesOnDrag, onNodeDragStart, onSelectionDragStart, unselectNodesAndEdges } = getStoreItems();
3122
3118
  dragStarted = !0, (!selectNodesOnDrag || !isSelectable) && !multiSelectionActive && nodeId && (nodeLookup.get(nodeId)?.selected || unselectNodesAndEdges()), isSelectable && selectNodesOnDrag && nodeId && onNodeMouseDown?.(nodeId);
3123
- const pointerPos = getPointerPosition(event.sourceEvent, { transform: transform2, snapGrid, snapToGrid });
3119
+ const pointerPos = getPointerPosition(event.sourceEvent, { transform: transform2, snapGrid, snapToGrid, containerBounds });
3124
3120
  if (lastPos = pointerPos, dragItems = getDragItems(nodeLookup, nodesDraggable, pointerPos, nodeId), dragItems.size > 0 && (onDragStart || onNodeDragStart || !nodeId && onSelectionDragStart)) {
3125
3121
  const [currentNode, currentNodes] = getEventHandlerParams({
3126
3122
  nodeId,
@@ -3132,9 +3128,9 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
3132
3128
  }
3133
3129
  const d3DragInstance = drag().clickDistance(nodeClickDistance).on("start", (event) => {
3134
3130
  const { domNode: domNode2, nodeDragThreshold, transform: transform2, snapGrid, snapToGrid } = getStoreItems();
3135
- abortDrag = !1, nodeDragThreshold === 0 && startDrag(event), lastPos = getPointerPosition(event.sourceEvent, { transform: transform2, snapGrid, snapToGrid }), containerBounds = domNode2?.getBoundingClientRect() || null, mousePosition = getEventPosition(event.sourceEvent, containerBounds);
3131
+ containerBounds = domNode2?.getBoundingClientRect() || null, abortDrag = !1, nodeDragThreshold === 0 && startDrag(event), lastPos = getPointerPosition(event.sourceEvent, { transform: transform2, snapGrid, snapToGrid, containerBounds }), mousePosition = getEventPosition(event.sourceEvent, containerBounds);
3136
3132
  }).on("drag", (event) => {
3137
- const { autoPanOnNodeDrag, transform: transform2, snapGrid, snapToGrid, nodeDragThreshold, nodeLookup } = getStoreItems(), pointerPos = getPointerPosition(event.sourceEvent, { transform: transform2, snapGrid, snapToGrid });
3133
+ const { autoPanOnNodeDrag, transform: transform2, snapGrid, snapToGrid, nodeDragThreshold, nodeLookup } = getStoreItems(), pointerPos = getPointerPosition(event.sourceEvent, { transform: transform2, snapGrid, snapToGrid, containerBounds });
3138
3134
  if ((event.sourceEvent.type === "touchmove" && event.sourceEvent.touches.length > 1 || // if user deletes a node while dragging, we need to abort the drag to prevent errors
3139
3135
  nodeId && !nodeLookup.has(nodeId)) && (abortDrag = !0), !abortDrag) {
3140
3136
  if (!autoPanStarted && autoPanOnNodeDrag && dragStarted && (autoPanStarted = !0, autoPan()), !dragStarted) {
@@ -3694,12 +3690,18 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
3694
3690
  function update({ controlPosition, boundaries, keepAspectRatio, onResizeStart, onResize, onResizeEnd, shouldResize }) {
3695
3691
  let prevValues = { ...initPrevValues$1 }, startValues = { ...initStartValues };
3696
3692
  const controlDirection = getControlDirection(controlPosition);
3697
- let node, childNodes = [], parentNode, parentExtent, childExtent;
3693
+ let node, containerBounds = null, childNodes = [], parentNode, parentExtent, childExtent;
3698
3694
  const dragHandler = drag().on("start", (event) => {
3699
- const { nodeLookup, transform: transform2, snapGrid, snapToGrid, nodeOrigin } = getStoreItems();
3695
+ const { nodeLookup, transform: transform2, snapGrid, snapToGrid, nodeOrigin, paneDomNode } = getStoreItems();
3700
3696
  if (node = nodeLookup.get(nodeId), !node)
3701
3697
  return;
3702
- const { xSnapped, ySnapped } = getPointerPosition(event.sourceEvent, { transform: transform2, snapGrid, snapToGrid });
3698
+ containerBounds = paneDomNode?.getBoundingClientRect() ?? null;
3699
+ const { xSnapped, ySnapped } = getPointerPosition(event.sourceEvent, {
3700
+ transform: transform2,
3701
+ snapGrid,
3702
+ snapToGrid,
3703
+ containerBounds
3704
+ });
3703
3705
  prevValues = {
3704
3706
  width: node.measured.width ?? 0,
3705
3707
  height: node.measured.height ?? 0,
@@ -3725,7 +3727,12 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
3725
3727
  }
3726
3728
  onResizeStart?.(event, { ...prevValues });
3727
3729
  }).on("drag", (event) => {
3728
- const { transform: transform2, snapGrid, snapToGrid, nodeOrigin: storeNodeOrigin } = getStoreItems(), pointerPosition = getPointerPosition(event.sourceEvent, { transform: transform2, snapGrid, snapToGrid }), childChanges = [];
3730
+ const { transform: transform2, snapGrid, snapToGrid, nodeOrigin: storeNodeOrigin } = getStoreItems(), pointerPosition = getPointerPosition(event.sourceEvent, {
3731
+ transform: transform2,
3732
+ snapGrid,
3733
+ snapToGrid,
3734
+ containerBounds
3735
+ }), childChanges = [];
3729
3736
  if (!node)
3730
3737
  return;
3731
3738
  const { x: prevX, y: prevY, width: prevWidth, height: prevHeight } = prevValues, change = {}, nodeOrigin = node.origin ?? storeNodeOrigin, { width, height, x, y } = getDimensionsAfterResize(startValues, controlDirection, pointerPosition, boundaries, keepAspectRatio, nodeOrigin, parentExtent, childExtent), isWidthChange = width !== prevWidth, isHeightChange = height !== prevHeight, isXPosChange = x !== prevX && isWidthChange, isYPosChange = y !== prevY && isHeightChange;
@@ -4006,7 +4013,12 @@ const defaultDoc = typeof document < "u" ? document : null;
4006
4013
  function useKeyPress(keyCode = null, options = { target: defaultDoc, actInsideInputWithModifier: !0 }) {
4007
4014
  const [keyPressed, setKeyPressed] = useState(!1), modifierPressed = useRef(!1), pressedKeys = useRef(/* @__PURE__ */ new Set([])), [keyCodes, keysToWatch] = useMemo(() => {
4008
4015
  if (keyCode !== null) {
4009
- const keys = (Array.isArray(keyCode) ? keyCode : [keyCode]).filter((kc) => typeof kc == "string").map((kc) => kc.split("+")), keysFlat = keys.reduce((res, item) => res.concat(...item), []);
4016
+ const keys = (Array.isArray(keyCode) ? keyCode : [keyCode]).filter((kc) => typeof kc == "string").map((kc) => kc.replace("+", `
4017
+ `).replace(`
4018
+
4019
+ `, `
4020
+ +`).split(`
4021
+ `)), keysFlat = keys.reduce((res, item) => res.concat(...item), []);
4010
4022
  return [keys, keysFlat];
4011
4023
  }
4012
4024
  return [[], []];
@@ -4207,15 +4219,11 @@ function fixedForwardRef(render) {
4207
4219
  }
4208
4220
  const useIsomorphicLayoutEffect = typeof window < "u" ? useLayoutEffect : useEffect;
4209
4221
  function useQueue(runQueue) {
4210
- const [shouldFlush, setShouldFlush] = useState(!1), [queue] = useState(() => createQueue(() => setShouldFlush(!0)));
4222
+ const [serial, setSerial] = useState(BigInt(0)), [queue] = useState(() => createQueue(() => setSerial((n2) => n2 + BigInt(1))));
4211
4223
  return useIsomorphicLayoutEffect(() => {
4212
- if (!shouldFlush) {
4213
- queue.reset();
4214
- return;
4215
- }
4216
4224
  const queueItems = queue.get();
4217
- queueItems.length && (runQueue(queueItems), queue.reset()), setShouldFlush(!1);
4218
- }, [shouldFlush]), queue;
4225
+ queueItems.length && (runQueue(queueItems), queue.reset());
4226
+ }, [serial]), queue;
4219
4227
  }
4220
4228
  function createQueue(cb) {
4221
4229
  let queue = [];
@@ -5710,6 +5718,9 @@ function useNodesData(nodeIds) {
5710
5718
  return isArrayOfIds ? data : data[0] ?? null;
5711
5719
  }, [nodeIds]), shallowNodeData);
5712
5720
  }
5721
+ function useInternalNode(id2) {
5722
+ return useStore(useCallback((s) => s.nodeLookup.get(id2), [id2]), shallow$1);
5723
+ }
5713
5724
  function LinePattern({ dimensions, lineWidth, variant, className }) {
5714
5725
  return jsx("path", { strokeWidth: lineWidth, d: `M${dimensions[0] / 2} 0 V${dimensions[1]} M0 ${dimensions[1] / 2} H${dimensions[0]}`, className: cc(["react-flow__background-pattern", variant, className]) });
5715
5726
  }
@@ -5932,13 +5943,14 @@ function ResizeControl({ nodeId, position, variant = ResizeControlVariant.Handle
5932
5943
  domNode: resizeControlRef.current,
5933
5944
  nodeId: id2,
5934
5945
  getStoreItems: () => {
5935
- const { nodeLookup, transform: transform2, snapGrid, snapToGrid, nodeOrigin } = store.getState();
5946
+ const { nodeLookup, transform: transform2, snapGrid, snapToGrid, nodeOrigin, domNode } = store.getState();
5936
5947
  return {
5937
5948
  nodeLookup,
5938
5949
  transform: transform2,
5939
5950
  snapGrid,
5940
5951
  snapToGrid,
5941
- nodeOrigin
5952
+ nodeOrigin,
5953
+ paneDomNode: domNode
5942
5954
  };
5943
5955
  },
5944
5956
  onChange: (change, childChanges) => {
@@ -6092,5 +6104,6 @@ export {
6092
6104
  Panel as t,
6093
6105
  useNodesState as u,
6094
6106
  useOnViewportChange as v,
6095
- withSelectorExports as w
6107
+ withSelectorExports as w,
6108
+ useInternalNode as x
6096
6109
  };