@likec4/diagram 1.27.2 → 1.28.0

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 (75) hide show
  1. package/bundle/index.js +715 -616
  2. package/dist/base/primitives/customEdge.d.ts +1 -1
  3. package/dist/base/primitives/edge/EdgeActionButton.d.ts +1 -2
  4. package/dist/base/primitives/edge/EdgeLabelContainer.js +3 -2
  5. package/dist/base/primitives/edge/EdgePath.d.ts +1 -1
  6. package/dist/base/primitives/element/ElementActionButtons.d.ts +1 -1
  7. package/dist/base/primitives/element/ElementActionButtons.js +11 -7
  8. package/dist/base/primitives/element/ElementDetailsButton.js +5 -1
  9. package/dist/bundle/styles.css.js +2 -2
  10. package/dist/hooks/useDiagram.d.ts +2 -2
  11. package/dist/hooks/useDiagram.js +9 -20
  12. package/dist/hooks/useXYFlow.d.ts +2 -2
  13. package/dist/likec4diagram/DiagramXYFlow.js +6 -6
  14. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +2 -2
  15. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +11 -1
  16. package/dist/likec4diagram/custom/index.d.ts +2 -1
  17. package/dist/likec4diagram/ui/notation/NotationPanel.js +0 -1
  18. package/dist/overlays/Overlays.js +2 -2
  19. package/dist/overlays/element-details/actor.d.ts +303 -303
  20. package/dist/overlays/overlay/Overlay.css.d.ts +2 -25
  21. package/dist/overlays/overlay/Overlay.css.js +3 -43
  22. package/dist/overlays/overlay/Overlay.d.ts +1 -1
  23. package/dist/overlays/overlay/Overlay.js +97 -90
  24. package/dist/overlays/overlaysActor.js +4 -1
  25. package/dist/overlays/relationship-details/RelationshipDetails.d.ts +1 -1
  26. package/dist/overlays/relationship-details/actor.d.ts +16 -7
  27. package/dist/overlays/relationship-details/actor.js +1 -6
  28. package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +1 -1
  29. package/dist/overlays/relationship-details/custom/nodeTypes.js +1 -1
  30. package/dist/overlays/relationship-details/hooks.d.ts +2 -3
  31. package/dist/overlays/relationship-details/hooks.js +2 -5
  32. package/dist/overlays/relationship-details/layout-to-xyflow.js +0 -4
  33. package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +1 -1
  34. package/dist/overlays/relationships-browser/actor.d.ts +2 -3
  35. package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +1 -1
  36. package/dist/overlays/relationships-browser/custom/nodeTypes.js +1 -1
  37. package/dist/overlays/relationships-browser/hooks.d.ts +2 -3
  38. package/dist/overlays/relationships-browser/hooks.js +5 -8
  39. package/dist/overlays/relationships-browser/layout.d.ts +1 -1
  40. package/dist/overlays/relationships-browser/layout.js +2 -6
  41. package/dist/state/diagram-machine.d.ts +2 -2
  42. package/dist/state/hotkeyActor.js +12 -3
  43. package/dist/styles.css.js +1 -1
  44. package/dist/utils/index.d.ts +0 -1
  45. package/package.json +10 -10
  46. package/src/base/primitives/compound/CompoundNodeContainer.css.ts +0 -3
  47. package/src/base/primitives/edge/EdgeActionButton.tsx +1 -2
  48. package/src/base/primitives/edge/EdgeLabelContainer.tsx +7 -5
  49. package/src/base/primitives/element/ElementActionButtons.tsx +11 -9
  50. package/src/base/primitives/element/ElementDetailsButton.tsx +4 -0
  51. package/src/base/primitives/element/ElementNodeContainer.css.ts +0 -18
  52. package/src/bundle/styles.css.ts +7 -2
  53. package/src/components/SearchControl.css.ts +4 -8
  54. package/src/hooks/useDiagram.ts +9 -20
  55. package/src/likec4diagram/DiagramXYFlow.tsx +6 -6
  56. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +7 -1
  57. package/src/likec4diagram/custom/edges/edges.css.ts +0 -2
  58. package/src/likec4diagram/ui/notation/NotationPanel.css.ts +0 -4
  59. package/src/likec4diagram/ui/notation/NotationPanel.tsx +0 -1
  60. package/src/likec4diagram/ui/search/ViewsColumn.css.ts +0 -4
  61. package/src/overlays/Overlays.tsx +3 -3
  62. package/src/overlays/overlay/Overlay.css.ts +3 -43
  63. package/src/overlays/overlay/Overlay.tsx +108 -101
  64. package/src/overlays/overlaysActor.ts +5 -1
  65. package/src/overlays/relationship-details/actor.ts +1 -6
  66. package/src/overlays/relationship-details/custom/nodeTypes.tsx +1 -1
  67. package/src/overlays/relationship-details/hooks.ts +2 -5
  68. package/src/overlays/relationship-details/layout-to-xyflow.ts +2 -25
  69. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +1 -1
  70. package/src/overlays/relationships-browser/hooks.ts +5 -8
  71. package/src/overlays/relationships-browser/layout.ts +3 -20
  72. package/src/state/hotkeyActor.ts +13 -3
  73. package/src/utils/index.ts +0 -1
  74. package/dist/utils/types.d.ts +0 -8
  75. package/src/utils/types.ts +0 -6
@@ -1,6 +1,6 @@
1
1
  import { FunctionComponent, NamedExoticComponent, CSSProperties, ReactNode } from 'react';
2
2
  import { Base, EdgeProps } from '../types';
3
- import { Position } from '@xyflow/system';
3
+ import { Position } from '@xyflow/react';
4
4
  export declare const edgePropsEqual: <P extends Record<string, unknown> = Base.EdgeData>(prev: EdgeProps<P>, next: EdgeProps<P>) => boolean;
5
5
  export declare function customEdge<P extends Record<string, unknown> = Base.NodeData>(Edge: FunctionComponent<EdgeProps<P>>): NamedExoticComponent<{
6
6
  id: string;
@@ -1,5 +1,4 @@
1
- import { EdgeProps } from '../../types';
2
- type EdgeActionBtnProps = EdgeProps & {
1
+ type EdgeActionBtnProps = {
3
2
  icon?: React.ReactNode;
4
3
  onClick: (e: React.MouseEvent) => void;
5
4
  };
@@ -74,9 +74,10 @@ function EdgeLabelContainer({
74
74
  children: /* @__PURE__ */ jsx(
75
75
  "div",
76
76
  {
77
- className: css({
77
+ style: {
78
78
  display: "contents"
79
- }),
79
+ },
80
+ // Work around to keep same global selector data-likec4-dimmed
80
81
  ...isDimmed !== false && {
81
82
  "data-likec4-dimmed": isDimmed
82
83
  },
@@ -1,5 +1,5 @@
1
1
  import { PointerEventHandler, ForwardRefExoticComponent, CSSProperties, ReactNode, RefAttributes } from 'react';
2
- import { Position } from '@xyflow/system';
2
+ import { Position } from '@xyflow/react';
3
3
  import { RelationshipLineType, RelationshipArrowType } from '@likec4/core';
4
4
  export declare const EdgePath: ForwardRefExoticComponent<{
5
5
  id: string;
@@ -2,7 +2,7 @@ import { NodeProps } from '../../types';
2
2
  type ElementActionButtonsProps = NodeProps & {
3
3
  buttons: ElementActionButtons.Item[];
4
4
  };
5
- export declare function ElementActionButtons({ id, selected, data: { hovered: isHovered, }, buttons, }: ElementActionButtonsProps): import("react/jsx-runtime").JSX.Element | null;
5
+ export declare function ElementActionButtons({ selected, data: { hovered: isHovered, }, buttons, }: ElementActionButtonsProps): import("react/jsx-runtime").JSX.Element | null;
6
6
  export declare namespace ElementActionButtons {
7
7
  type Item = {
8
8
  key?: string;
@@ -2,6 +2,7 @@ import { jsx } from 'react/jsx-runtime';
2
2
  import { css, cx } from '@likec4/styles/css';
3
3
  import { actionBtn } from '@likec4/styles/recipes';
4
4
  import { Box, ActionIcon } from '@mantine/core';
5
+ import { useId } from '@mantine/hooks';
5
6
  import { m } from 'framer-motion';
6
7
  import { useIsZoomTooSmall } from '../../../hooks/useXYFlow.js';
7
8
  import { stopPropagation } from '../../../utils/xyflow.js';
@@ -27,13 +28,13 @@ const actionButtons = css({
27
28
  alignItems: "center"
28
29
  });
29
30
  function ElementActionButtons({
30
- id,
31
31
  selected = false,
32
32
  data: {
33
33
  hovered: isHovered = false
34
34
  },
35
35
  buttons
36
36
  }) {
37
+ const id = useId();
37
38
  const zoomTooSmall = useIsZoomTooSmall();
38
39
  if (!buttons.length || zoomTooSmall) {
39
40
  return null;
@@ -56,21 +57,24 @@ function ElementActionButtons({
56
57
  "data-likec4-hovered": isHovered,
57
58
  className: cx("nodrag nopan", actionButtons),
58
59
  children: buttons.map((button, index) => /* @__PURE__ */ jsx(
59
- m.div,
60
+ ActionIcon,
60
61
  {
62
+ component: m.button,
63
+ layout: true,
64
+ className: actionBtn({}),
61
65
  initial: false,
62
66
  whileTap: { scale: 1 },
63
67
  whileHover: {
64
68
  scale: 1.3
65
69
  },
66
- onTap: (e) => button.onClick(e),
67
- onClick: stopPropagation,
70
+ onClick: button.onClick,
68
71
  onDoubleClick: stopPropagation,
69
- children: /* @__PURE__ */ jsx(ActionIcon, { className: actionBtn({}), children: button.icon })
72
+ children: button.icon
70
73
  },
71
- `action-button-${id}-${button.key ?? index}`
74
+ `${id}-${button.key ?? index}`
72
75
  ))
73
- }
76
+ },
77
+ `${id}-action-buttons`
74
78
  ) });
75
79
  }
76
80
 
@@ -2,6 +2,7 @@ import { jsx } from 'react/jsx-runtime';
2
2
  import { cx, css } from '@likec4/styles/css';
3
3
  import { actionBtn } from '@likec4/styles/recipes';
4
4
  import { Box, ActionIcon } from '@mantine/core';
5
+ import { useId } from '@mantine/hooks';
5
6
  import { IconId } from '@tabler/icons-react';
6
7
  import { m } from 'framer-motion';
7
8
  import { stopPropagation } from '../../../utils/xyflow.js';
@@ -35,11 +36,13 @@ function ElementDetailsButton({
35
36
  icon,
36
37
  onClick
37
38
  }) {
39
+ const id = useId();
38
40
  return /* @__PURE__ */ jsx(Box, { className: cx(container, "details-button"), children: /* @__PURE__ */ jsx(
39
41
  ActionIcon,
40
42
  {
41
43
  className: cx("nodrag nopan", actionBtn({ variant: "transparent" })),
42
44
  component: m.button,
45
+ layout: true,
43
46
  initial: false,
44
47
  style: {
45
48
  originX: 0.45,
@@ -60,7 +63,8 @@ function ElementDetailsButton({
60
63
  onClick,
61
64
  onDoubleClick: stopPropagation,
62
65
  children: icon ?? /* @__PURE__ */ jsx(IconId, { stroke: 1.8, style: { width: "75%" } })
63
- }
66
+ },
67
+ id
64
68
  ) });
65
69
  }
66
70
 
@@ -1,8 +1,8 @@
1
1
  import { css } from '@likec4/styles/css';
2
2
  import { createTheme, Portal } from '@mantine/core';
3
- import { useColorScheme as useColorScheme$1, useMutationObserver, useDebouncedCallback } from '@mantine/hooks';
3
+ import { useColorScheme as useColorScheme$1, useMutationObserver, useDebouncedCallback, useId } from '@mantine/hooks';
4
4
  import { useIsomorphicLayoutEffect } from '@react-hookz/web';
5
- import { useState, useId } from 'react';
5
+ import { useState } from 'react';
6
6
  import { first, isString, isFunction } from 'remeda';
7
7
  import inlinedStyles from '../styles.css.js';
8
8
  import fontsCss from './font.css.js';
@@ -13,9 +13,9 @@ import { HotKeyEvent } from '../state/hotkeyActor';
13
13
  import { OverlaysContext, OverlayActorEvent, OverlayActorEmitedEvent } from '../overlays/overlaysActor';
14
14
  import { ElementDetailsLogic } from '../overlays/element-details/actor';
15
15
  import { EnabledFeatures } from '../context';
16
- import { ReactFlowState, ReactFlowInstance } from '@xyflow/react';
17
- import { EdgeMarkerType, HandleType, XYPosition, Viewport, NodeChange, EdgeChange } from '@xyflow/system';
16
+ import { ReactFlowState, EdgeMarkerType, HandleType, ReactFlowInstance } from '@xyflow/react';
18
17
  import { ReactNode, CSSProperties } from 'react';
18
+ import { XYPosition, Viewport, NodeChange, EdgeChange } from '@xyflow/system';
19
19
  export { useDiagramActorRef };
20
20
  export declare function useDiagram(): {
21
21
  actor: DiagramActorRef;
@@ -2,44 +2,33 @@ import '@likec4/core';
2
2
  import { useCallbackRef } from '@mantine/hooks';
3
3
  import { useSelector } from '@xstate/react';
4
4
  import { shallowEqual } from 'fast-equals';
5
- import { useTransition, useMemo } from 'react';
5
+ import { useMemo } from 'react';
6
6
  import { findDiagramEdge, findDiagramNode } from '../state/utils.js';
7
7
  import { useDiagramActorRef } from './safeContext.js';
8
8
 
9
9
  function useDiagram() {
10
10
  const actor = useDiagramActorRef();
11
- const [, startTransition] = useTransition();
12
11
  return useMemo(() => ({
13
12
  actor,
14
13
  send: actor.send,
15
14
  navigateTo: (viewId, fromNode) => {
16
- startTransition(() => {
17
- actor.send({
18
- type: "navigate.to",
19
- viewId,
20
- ...fromNode && { fromNode }
21
- });
15
+ actor.send({
16
+ type: "navigate.to",
17
+ viewId,
18
+ ...fromNode && { fromNode }
22
19
  });
23
20
  },
24
21
  navigate: (direction) => {
25
- startTransition(() => {
26
- actor.send({ type: `navigate.${direction}` });
27
- });
22
+ actor.send({ type: `navigate.${direction}` });
28
23
  },
29
24
  fitDiagram: (duration = 350) => {
30
- startTransition(() => {
31
- actor.send({ type: "fitDiagram", duration });
32
- });
25
+ actor.send({ type: "fitDiagram", duration });
33
26
  },
34
27
  openRelationshipsBrowser: (fqn) => {
35
- startTransition(() => {
36
- actor.send({ type: "open.relationshipsBrowser", fqn });
37
- });
28
+ actor.send({ type: "open.relationshipsBrowser", fqn });
38
29
  },
39
30
  openSource: (params) => {
40
- startTransition(() => {
41
- actor.send({ type: "open.source", ...params });
42
- });
31
+ actor.send({ type: "open.source", ...params });
43
32
  },
44
33
  openElementDetails: (fqn, fromNode) => {
45
34
  actor.send({ type: "open.elementDetails", fqn, fromNode });
@@ -1,8 +1,8 @@
1
- import { ReactFlowState, ReactFlowInstance, InternalNode } from '@xyflow/react';
1
+ import { ReactFlowState, ReactFlowInstance, EdgeMarkerType, HandleType, InternalNode } from '@xyflow/react';
2
2
  import { Types } from '../likec4diagram/types';
3
- import { EdgeMarkerType, HandleType, XYPosition } from '@xyflow/system';
4
3
  import { ReactNode, CSSProperties } from 'react';
5
4
  import { EdgeId, NonEmptyArray, Point, Color, BBox, RelationshipLineType, RelationshipArrowType, ViewId } from '@likec4/core';
5
+ import { XYPosition } from '@xyflow/system';
6
6
  export declare const useXYFlow: () => ReactFlowInstance<Types.Node, {
7
7
  id: string;
8
8
  source: string;
@@ -57,15 +57,13 @@ const LikeC4DiagramXYFlow = memo(({
57
57
  onCanvasDblClick
58
58
  } = useDiagramEventHandlers();
59
59
  const notReadOnly = !enableReadOnly, isReducedGraphics = useIsReducedGraphics(), layoutConstraints = useLayoutConstraints(), $isPanning = usePanningAtom(), isPanning = useTimeout(() => {
60
- if (!$isPanning.get()) {
61
- $isPanning.set(true);
62
- }
63
- }, isReducedGraphics ? 150 : 350), notPanning = useDebouncedCallback(() => {
60
+ $isPanning.set(true);
61
+ }, isReducedGraphics ? 100 : 200), notPanning = useDebouncedCallback(() => {
64
62
  isPanning.clear();
65
63
  if ($isPanning.get()) {
66
64
  $isPanning.set(false);
67
65
  }
68
- }, 120), onMove = useCallbackRef((event) => {
66
+ }, 200), onMove = useCallbackRef((event) => {
69
67
  if (!event) {
70
68
  return;
71
69
  }
@@ -74,7 +72,9 @@ const LikeC4DiagramXYFlow = memo(({
74
72
  }
75
73
  notPanning();
76
74
  }), onMoveEnd = useCallbackRef((event, viewport) => {
77
- notPanning.flush();
75
+ if (!!event) {
76
+ notPanning.flush();
77
+ }
78
78
  diagram.send({ type: "xyflow.viewportMoved", viewport, manually: !!event });
79
79
  }), onViewportResize = useCallbackRef(() => {
80
80
  diagram.send({ type: "xyflow.resized" });
@@ -1,7 +1,7 @@
1
1
  import { EdgeId, NonEmptyArray, Point, Color, BBox, RelationshipLineType, RelationshipArrowType, ViewId } from '@likec4/core';
2
- import { XYPosition } from '@xyflow/react';
3
2
  import { NamedExoticComponent, CSSProperties, ReactNode } from 'react';
4
- import { Position } from '@xyflow/system';
3
+ import { Position } from '@xyflow/react';
4
+ import { XYPosition } from '@xyflow/system';
5
5
  export declare const RelationshipEdge: NamedExoticComponent<{
6
6
  id: string;
7
7
  selected?: boolean;
@@ -265,7 +265,17 @@ const RelationshipEdge = customEdge((props) => {
265
265
  }
266
266
  return /* @__PURE__ */ jsxs(Fragment, { children: [
267
267
  /* @__PURE__ */ jsxs(EdgeContainer, { ...props, className: clsx(isControlPointDragging && controlDragging), children: [
268
- /* @__PURE__ */ jsx(EdgePath, { ...props, svgPath: edgePath, ref: svgPathRef, onEdgePointerDown }),
268
+ /* @__PURE__ */ jsx(
269
+ EdgePath,
270
+ {
271
+ ...props,
272
+ svgPath: edgePath,
273
+ ref: svgPathRef,
274
+ ...enableEdgeEditing && {
275
+ onEdgePointerDown
276
+ }
277
+ }
278
+ ),
269
279
  /* @__PURE__ */ jsx(
270
280
  EdgeLabelContainer,
271
281
  {
@@ -1,8 +1,9 @@
1
1
  import { Types } from '../types';
2
2
  import { NamedExoticComponent, CSSProperties, ReactNode } from 'react';
3
3
  import { NodeProps } from '../../base';
4
- import { Position, XYPosition } from '@xyflow/system';
4
+ import { Position } from '@xyflow/react';
5
5
  import { EdgeId, NonEmptyArray, Point, Color, BBox, RelationshipLineType, RelationshipArrowType, ViewId } from '@likec4/core';
6
+ import { XYPosition } from '@xyflow/system';
6
7
  export declare const nodeTypes: {
7
8
  element: NamedExoticComponent<NodeProps<Types.ElementNodeData>>;
8
9
  deployment: NamedExoticComponent<NodeProps<Types.DeploymentElementNodeData>>;
@@ -1,7 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import '@likec4/core';
3
3
  import { cx, css } from '@likec4/styles/css';
4
- import '@likec4/styles/tokens';
5
4
  import { Tooltip, ThemeIcon, ActionIcon, Paper, Tabs, TabsList, TabsTab, TabsPanel, ScrollAreaAutosize, Stack, Card, Group, Box, Badge, Text } from '@mantine/core';
6
5
  import { useLocalStorage } from '@mantine/hooks';
7
6
  import { IconAlertTriangle, IconHelpCircle, IconArrowDownRight } from '@tabler/icons-react';
@@ -92,7 +92,7 @@ const Overlays = memo(({ overlaysActorRef }) => {
92
92
  return /* @__PURE__ */ jsx(
93
93
  Overlay,
94
94
  {
95
- overlayLevel: Math.min(index, 3),
95
+ overlayLevel: index,
96
96
  onClose: () => close(overlay.actorRef),
97
97
  children: /* @__PURE__ */ jsx(RelationshipsBrowser, { actorRef: overlay.actorRef })
98
98
  },
@@ -102,7 +102,7 @@ const Overlays = memo(({ overlaysActorRef }) => {
102
102
  return /* @__PURE__ */ jsx(
103
103
  Overlay,
104
104
  {
105
- overlayLevel: Math.min(index, 3),
105
+ overlayLevel: index,
106
106
  onClose: () => close(overlay.actorRef),
107
107
  children: /* @__PURE__ */ jsx(RelationshipDetails, { actorRef: overlay.actorRef })
108
108
  },