@likec4/diagram 1.27.0 → 1.27.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.
Files changed (57) hide show
  1. package/bundle/index.js +327 -281
  2. package/dist/LikeC4Diagram.js +2 -8
  3. package/dist/base/primitives/compound/CompoundNodeContainer.js +1 -1
  4. package/dist/base/primitives/edge/EdgeLabel.css.js +1 -4
  5. package/dist/base/primitives/edge/EdgeLabelContainer.js +1 -1
  6. package/dist/base/primitives/edge/EdgePath.js +0 -3
  7. package/dist/base/primitives/edge/edge.css.js +2 -0
  8. package/dist/base/primitives/element/ElementNodeContainer.css.js +1 -0
  9. package/dist/base/primitives/element/ElementShape.css.js +1 -12
  10. package/dist/base/primitives/element/ElementTitle.css.js +3 -2
  11. package/dist/base/types.js +2 -2
  12. package/dist/components/Link.js +1 -1
  13. package/dist/hooks/useDiagram.d.ts +320 -490
  14. package/dist/likec4diagram/DiagramXYFlow.js +10 -9
  15. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +30 -41
  16. package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +1 -1
  17. package/dist/likec4diagram/custom/nodes/toolbar/styles.css.js +6 -1
  18. package/dist/likec4diagram/ui/controls/LayoutDriftNotification.js +13 -5
  19. package/dist/likec4diagram/useLayoutConstraints.d.ts +11 -10
  20. package/dist/likec4diagram/useLayoutConstraints.js +64 -61
  21. package/dist/overlays/Overlays.js +2 -2
  22. package/dist/overlays/overlay/Overlay.css.js +31 -12
  23. package/dist/overlays/overlay/Overlay.js +30 -27
  24. package/dist/overlays/relationship-details/useLayoutedDetails.js +1 -1
  25. package/dist/overlays/relationships-browser/SelectElement.js +4 -4
  26. package/dist/state/DiagramActorProvider.d.ts +4 -2
  27. package/dist/state/DiagramActorProvider.js +30 -37
  28. package/dist/state/assign.js +2 -2
  29. package/dist/state/diagram-machine.d.ts +450 -608
  30. package/dist/state/diagram-machine.js +87 -57
  31. package/dist/styles.css.js +1 -1
  32. package/package.json +5 -5
  33. package/src/LikeC4Diagram.tsx +1 -7
  34. package/src/base/primitives/compound/CompoundNodeContainer.tsx +1 -1
  35. package/src/base/primitives/edge/EdgeLabel.css.ts +1 -4
  36. package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -1
  37. package/src/base/primitives/edge/EdgePath.tsx +0 -3
  38. package/src/base/primitives/edge/edge.css.ts +2 -0
  39. package/src/base/primitives/element/ElementNodeContainer.css.ts +1 -0
  40. package/src/base/primitives/element/ElementShape.css.ts +1 -12
  41. package/src/base/primitives/element/ElementTitle.css.ts +3 -2
  42. package/src/base/types.ts +2 -7
  43. package/src/components/Link.tsx +3 -1
  44. package/src/likec4diagram/DiagramXYFlow.tsx +11 -9
  45. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +39 -48
  46. package/src/likec4diagram/custom/nodes/toolbar/Toolbar.tsx +2 -2
  47. package/src/likec4diagram/custom/nodes/toolbar/styles.css.ts +5 -0
  48. package/src/likec4diagram/ui/controls/LayoutDriftNotification.tsx +8 -4
  49. package/src/likec4diagram/useLayoutConstraints.ts +84 -89
  50. package/src/overlays/Overlays.tsx +2 -2
  51. package/src/overlays/overlay/Overlay.css.ts +30 -12
  52. package/src/overlays/overlay/Overlay.tsx +35 -29
  53. package/src/overlays/relationship-details/useLayoutedDetails.ts +1 -1
  54. package/src/overlays/relationships-browser/SelectElement.tsx +5 -5
  55. package/src/state/DiagramActorProvider.tsx +40 -50
  56. package/src/state/assign.ts +2 -2
  57. package/src/state/diagram-machine.ts +100 -69
@@ -6,7 +6,6 @@ import { ControlsCustomLayoutProvider } from './context/ControlsCustomLayout.js'
6
6
  import { ReduceGraphicsContext } from './context/ReduceGraphics.js';
7
7
  import { LikeC4CustomColors } from './LikeC4CustomColors.js';
8
8
  import { LikeC4DiagramXYFlow } from './likec4diagram/DiagramXYFlow.js';
9
- import { useViewToNodesEdges } from './likec4diagram/useViewToNodesEdges.js';
10
9
  import { DiagramActorProvider } from './state/DiagramActorProvider.js';
11
10
  import { useLikeC4Model } from './likec4model/useLikeC4Model.js';
12
11
  import { EnsureMantine } from './context/EnsureMantine.js';
@@ -60,11 +59,6 @@ function LikeC4Diagram({
60
59
  }) {
61
60
  const hasLikec4model = !!useLikeC4Model();
62
61
  const initialRef = useRef(null);
63
- const xyNodesEdges = useViewToNodesEdges({
64
- view,
65
- where,
66
- nodesSelectable
67
- });
68
62
  const isDynamicView = view.__ === "dynamic";
69
63
  if (initialRef.current == null) {
70
64
  initialRef.current = {
@@ -130,8 +124,8 @@ function LikeC4Diagram({
130
124
  view,
131
125
  pannable,
132
126
  zoomable,
133
- fitViewPadding,
134
- ...xyNodesEdges
127
+ nodesSelectable,
128
+ fitViewPadding
135
129
  },
136
130
  children: /* @__PURE__ */ jsx(ControlsCustomLayoutProvider, { value: renderControls ?? null, children: /* @__PURE__ */ jsx(
137
131
  LikeC4DiagramXYFlow,
@@ -60,7 +60,7 @@ function CompoundNodeContainer({
60
60
  "data-compound-title-inverse": opacity < 0.5
61
61
  },
62
62
  ...isDimmed !== false && {
63
- "likec4-dimmed": isDimmed
63
+ "data-likec4-dimmed": isDimmed
64
64
  },
65
65
  style: {
66
66
  ...style,
@@ -42,7 +42,7 @@ const edgeLabelContainer = css({
42
42
  },
43
43
  _noReduceGraphics: {
44
44
  mixBlendMode: {
45
- base: "plus-lighter",
45
+ _dark: "plus-lighter",
46
46
  _light: "screen"
47
47
  }
48
48
  },
@@ -51,9 +51,6 @@ const edgeLabelContainer = css({
51
51
  },
52
52
  _reduceGraphicsOnPan: {
53
53
  display: "none"
54
- },
55
- _whenPanning: {
56
- mixBlendMode: "normal"
57
54
  }
58
55
  });
59
56
  const labelsva = sva({
@@ -10,7 +10,7 @@ import { translate, edgeLabelContainer } from './EdgeLabel.css.js';
10
10
 
11
11
  const toCssVarValue = (value) => {
12
12
  if (value === void 0) return void 0;
13
- return isNumber(value) ? `${value}px` : value;
13
+ return isNumber(value) ? `${Math.round(value)}px` : value;
14
14
  };
15
15
  function EdgeLabelContainer({
16
16
  edgeProps: {
@@ -66,9 +66,6 @@ const EdgePath = forwardRef(({
66
66
  "react-flow__edge-path",
67
67
  "react-flow__edge-interaction",
68
68
  cssEdgePath
69
- // css({
70
- // strokeDasharray: strokeDasharray,
71
- // }),
72
69
  ),
73
70
  d: svgPath,
74
71
  style,
@@ -39,6 +39,7 @@ const _hideOnReducedGraphics = css.raw({
39
39
  });
40
40
  const hideOnReducedGraphics = css(_hideOnReducedGraphics);
41
41
  const edgePathBg = css(_hideOnReducedGraphics, {
42
+ fill: "[none]",
42
43
  strokeWidth: "calc(var(--xy-edge-stroke-width) + 2)",
43
44
  strokeOpacity: 0.08,
44
45
  transitionProperty: "stroke-width, stroke-opacity",
@@ -62,6 +63,7 @@ const markerContext = css({
62
63
  stroke: "[var(--xy-edge-stroke)]"
63
64
  });
64
65
  const cssEdgePath = css({
66
+ fill: "[none]",
65
67
  strokeDashoffset: 10,
66
68
  _noReduceGraphics: {
67
69
  transition: "stroke 130ms ease-out,stroke-width 130ms ease-out"
@@ -9,6 +9,7 @@ const container = css({
9
9
  display: "flex",
10
10
  alignItems: "center",
11
11
  justifyContent: "center",
12
+ pointerEvents: "none",
12
13
  _after: {
13
14
  content: '" "',
14
15
  position: "absolute",
@@ -6,7 +6,7 @@ const indicator = css({
6
6
  },
7
7
  stroke: "likec4.palette.loContrast",
8
8
  fill: "[none]",
9
- strokeWidth: 6,
9
+ strokeWidth: 8,
10
10
  strokeOpacity: 0.8,
11
11
  visibility: "hidden",
12
12
  pointerEvents: "none",
@@ -14,25 +14,14 @@ const indicator = css({
14
14
  stroke: `[color-mix(in srgb, {colors.likec4.palette.fill} 50%,rgb(121, 121, 121))]`
15
15
  },
16
16
  _whenFocused: {
17
- strokeWidth: 12,
18
17
  visibility: "visible"
19
18
  },
20
19
  _groupFocusVisible: {
21
- strokeWidth: 12,
22
20
  visibility: "visible"
23
21
  },
24
22
  _whenSelected: {
25
23
  animationStyle: "indicator",
26
24
  visibility: "visible"
27
- },
28
- _shapeQueue: {
29
- strokeWidth: 8
30
- },
31
- _shapeCylinder: {
32
- strokeWidth: 8
33
- },
34
- _shapeStorage: {
35
- strokeWidth: 8
36
25
  }
37
26
  });
38
27
  const fillElementFill = css({
@@ -18,7 +18,7 @@ const description = css.raw({
18
18
  display: "none"
19
19
  },
20
20
  _smallZoom: {
21
- visibility: "hidden"
21
+ display: "none"
22
22
  }
23
23
  });
24
24
  const technology = css.raw({
@@ -40,7 +40,7 @@ const technology = css.raw({
40
40
  display: "none"
41
41
  },
42
42
  _smallZoom: {
43
- visibility: "hidden"
43
+ display: "none"
44
44
  }
45
45
  });
46
46
  const varIconSize = `var(${iconSize})`;
@@ -92,6 +92,7 @@ const elementTitle = sva({
92
92
  paddingLeft: "calc(var(--likec4-spacing) + 8px)",
93
93
  paddingRight: "calc(var(--likec4-spacing) + 8px)",
94
94
  overflow: "hidden",
95
+ pointerEvents: "none",
95
96
  gap: "12px",
96
97
  _shapeQueue: {
97
98
  paddingLeft: "46px",
@@ -2,7 +2,7 @@ import { hasSubObject } from 'remeda';
2
2
 
3
3
  var Base;
4
4
  ((Base2) => {
5
- const _setDimmed = (v, dimmed) => v.data.dimmed === dimmed ? v : {
5
+ const _setDimmed = (v, dimmed) => (v.data.dimmed ?? false) === dimmed ? v : {
6
6
  ...v,
7
7
  data: {
8
8
  ...v.data,
@@ -16,7 +16,7 @@ var Base;
16
16
  return (v) => _setDimmed(v, arg1);
17
17
  }
18
18
  Base2.setDimmed = setDimmed;
19
- const _setHovered = (v, hovered) => v.data.hovered === hovered ? v : {
19
+ const _setHovered = (v, hovered) => (v.data.hovered ?? false) === hovered ? v : {
20
20
  ...v,
21
21
  data: {
22
22
  ...v.data,
@@ -54,7 +54,7 @@ function Link({
54
54
  size = "md"
55
55
  }) {
56
56
  const isNormalSize = size === "md";
57
- const url = new URL(value.url, window.location.href).toString();
57
+ const url = value.url.includes("://") ? value.url : new window.URL(value.url, window.location.href).toString();
58
58
  return /* @__PURE__ */ jsx(CopyButton, { value: url, children: ({ copied, copy }) => /* @__PURE__ */ jsxs(
59
59
  Anchor,
60
60
  {