@likec4/diagram 1.21.0 → 1.22.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 (129) hide show
  1. package/dist/LikeC4Diagram.js +9 -13
  2. package/dist/base/BaseXYFlow.js +0 -1
  3. package/dist/base/index.d.ts +0 -1
  4. package/dist/base/primitives/compound/CompoundNodeContainer.js +2 -2
  5. package/dist/base/primitives/edge/EdgeLabel.js +2 -2
  6. package/dist/base/primitives/element/ElementNodeContainer.d.ts +6 -1
  7. package/dist/base/primitives/element/ElementNodeContainer.js +31 -13
  8. package/dist/base/primitives/element/ElementTitle.js +7 -3
  9. package/dist/base/primitives/element/styles.css.js +1 -1
  10. package/dist/{base → components}/Link.css.js +3 -3
  11. package/dist/components/SearchControl.css.d.ts +2 -0
  12. package/dist/components/SearchControl.css.js +7 -0
  13. package/dist/components/SearchControl.d.ts +5 -0
  14. package/dist/components/SearchControl.js +17 -0
  15. package/dist/context/IconRenderer.d.ts +10 -0
  16. package/dist/context/IconRenderer.js +34 -0
  17. package/dist/hooks/index.d.ts +0 -1
  18. package/dist/hooks/useDiagram.d.ts +4 -4
  19. package/dist/index.d.ts +1 -1
  20. package/dist/likec4diagram/DiagramUI.js +1 -4
  21. package/dist/likec4diagram/XYFlow.d.ts +6 -1
  22. package/dist/likec4diagram/XYFlow.js +28 -29
  23. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +3 -1
  24. package/dist/likec4diagram/state/actorContext.d.ts +16 -16
  25. package/dist/likec4diagram/state/assign.js +1 -1
  26. package/dist/likec4diagram/state/machine.d.ts +7 -7
  27. package/dist/likec4diagram/state/machine.js +10 -7
  28. package/dist/likec4diagram/ui/controls/Controls.js +63 -48
  29. package/dist/likec4diagram/ui/controls/NavigationButtons.js +44 -69
  30. package/dist/likec4diagram/ui/controls/_shared.js +1 -1
  31. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +5 -4
  32. package/dist/likec4diagram/ui/index.d.ts +2 -0
  33. package/dist/likec4diagram/ui/search/ElementsColumn.css.d.ts +15 -0
  34. package/dist/likec4diagram/ui/search/ElementsColumn.css.js +30 -0
  35. package/dist/likec4diagram/ui/search/ElementsColumn.d.ts +1 -0
  36. package/dist/likec4diagram/ui/search/ElementsColumn.js +243 -0
  37. package/dist/likec4diagram/ui/search/LikeC4Search.css.d.ts +8 -0
  38. package/dist/likec4diagram/ui/search/LikeC4Search.css.js +20 -0
  39. package/dist/likec4diagram/ui/search/LikeC4Search.d.ts +1 -0
  40. package/dist/likec4diagram/ui/search/LikeC4Search.js +265 -0
  41. package/dist/likec4diagram/ui/search/SearchInput.d.ts +1 -0
  42. package/dist/likec4diagram/ui/search/SearchInput.js +196 -0
  43. package/dist/likec4diagram/ui/search/ViewsColum.d.ts +9 -0
  44. package/dist/likec4diagram/ui/search/ViewsColum.js +130 -0
  45. package/dist/likec4diagram/ui/search/ViewsColumn.css.d.ts +5 -0
  46. package/dist/likec4diagram/ui/search/ViewsColumn.css.js +12 -0
  47. package/dist/likec4diagram/ui/search/_shared.css.d.ts +16 -0
  48. package/dist/likec4diagram/ui/search/_shared.css.js +5 -0
  49. package/dist/likec4diagram/ui/search/state.d.ts +19 -0
  50. package/dist/likec4diagram/ui/search/state.js +72 -0
  51. package/dist/likec4diagram/ui/search/utils.d.ts +3 -0
  52. package/dist/likec4diagram/ui/search/utils.js +23 -0
  53. package/dist/likec4diagram/useLayoutConstraints.js +4 -5
  54. package/dist/likec4model/useLikeC4ElementsTree.d.ts +1 -0
  55. package/dist/likec4model/useLikeC4ElementsTree.js +1 -0
  56. package/dist/overlays/Overlays.js +10 -10
  57. package/dist/overlays/element-details/ElementDetailsCard.js +20 -13
  58. package/dist/overlays/element-details/TabPanelDeployments.js +4 -2
  59. package/dist/overlays/overlay/Overlay.d.ts +6 -2
  60. package/dist/overlays/overlay/Overlay.js +18 -29
  61. package/dist/overlays/relationship-details/SelectEdge.js +1 -3
  62. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +6 -5
  63. package/dist/overlays/relationships-browser/SelectElement.js +10 -6
  64. package/dist/overlays/relationships-browser/actor.d.ts +2 -2
  65. package/dist/overlays/relationships-browser/actor.js +8 -8
  66. package/dist/overlays/relationships-browser/custom/nodeTypes.js +2 -2
  67. package/dist/style.css +1 -1
  68. package/package.json +15 -14
  69. package/src/LikeC4Diagram.tsx +0 -1
  70. package/src/base/BaseXYFlow.tsx +0 -1
  71. package/src/base/index.ts +0 -2
  72. package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -7
  73. package/src/base/primitives/element/ElementNodeContainer.tsx +36 -16
  74. package/src/base/primitives/element/ElementTitle.css.ts +12 -9
  75. package/src/base/primitives/element/ElementTitle.tsx +6 -2
  76. package/src/base/primitives/element/styles.css.ts +18 -40
  77. package/src/{base → components}/Link.css.ts +3 -3
  78. package/src/components/SearchControl.css.ts +69 -0
  79. package/src/components/SearchControl.tsx +33 -0
  80. package/src/context/IconRenderer.tsx +54 -1
  81. package/src/hooks/index.ts +0 -1
  82. package/src/index.ts +15 -1
  83. package/src/likec4diagram/DiagramUI.tsx +1 -8
  84. package/src/likec4diagram/XYFlow.tsx +30 -30
  85. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +0 -1
  86. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.ts +1 -0
  87. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +3 -1
  88. package/src/likec4diagram/state/assign.ts +1 -1
  89. package/src/likec4diagram/state/machine.ts +12 -10
  90. package/src/likec4diagram/ui/controls/Controls.tsx +35 -25
  91. package/src/likec4diagram/ui/controls/NavigationButtons.tsx +36 -58
  92. package/src/likec4diagram/ui/controls/styles.css.ts +3 -1
  93. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +111 -108
  94. package/src/likec4diagram/ui/index.ts +2 -0
  95. package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -3
  96. package/src/likec4diagram/ui/search/ElementsColumn.css.ts +119 -0
  97. package/src/likec4diagram/ui/search/ElementsColumn.tsx +291 -0
  98. package/src/likec4diagram/ui/search/LikeC4Search.css.ts +117 -0
  99. package/src/likec4diagram/ui/search/LikeC4Search.tsx +312 -0
  100. package/src/likec4diagram/ui/search/SearchInput.tsx +235 -0
  101. package/src/likec4diagram/ui/search/ViewsColum.tsx +158 -0
  102. package/src/likec4diagram/ui/search/ViewsColumn.css.ts +37 -0
  103. package/src/likec4diagram/ui/search/_shared.css.ts +104 -0
  104. package/src/likec4diagram/ui/search/state.ts +76 -0
  105. package/src/likec4diagram/ui/search/utils.ts +20 -0
  106. package/src/likec4diagram/useLayoutConstraints.ts +4 -5
  107. package/src/likec4model/useLikeC4ElementsTree.ts +4 -4
  108. package/src/overlays/Overlays.tsx +32 -26
  109. package/src/overlays/element-details/ElementDetailsCard.css.ts +4 -4
  110. package/src/overlays/element-details/ElementDetailsCard.tsx +246 -244
  111. package/src/overlays/element-details/TabPanelDeployments.tsx +4 -4
  112. package/src/overlays/overlay/Overlay.css.ts +10 -9
  113. package/src/overlays/overlay/Overlay.tsx +38 -26
  114. package/src/overlays/relationship-details/SelectEdge.css.ts +1 -0
  115. package/src/overlays/relationship-details/SelectEdge.tsx +2 -4
  116. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +10 -5
  117. package/src/overlays/relationships-browser/SelectElement.tsx +88 -82
  118. package/src/overlays/relationships-browser/actor.ts +10 -10
  119. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +2 -2
  120. package/dist/LikeC4Search.css.d.ts +0 -1
  121. package/dist/LikeC4Search.css.js +0 -5
  122. package/dist/LikeC4Search.d.ts +0 -2
  123. package/dist/LikeC4Search.js +0 -88
  124. package/src/LikeC4Search.css.ts +0 -12
  125. package/src/LikeC4Search.tsx +0 -91
  126. /package/dist/{base → components}/Link.css.d.ts +0 -0
  127. /package/dist/{base → components}/Link.d.ts +0 -0
  128. /package/dist/{base → components}/Link.js +0 -0
  129. /package/src/{base → components}/Link.tsx +0 -0
@@ -4,7 +4,6 @@ import { useRef } from "react";
4
4
  import { isEmpty } from "remeda";
5
5
  import { LikeC4CustomColors } from "./LikeC4CustomColors.js";
6
6
  import { DiagramActor } from "./likec4diagram/DiagramActor.js";
7
- import { DiagramUI } from "./likec4diagram/DiagramUI.js";
8
7
  import { useViewToNodesEdges } from "./likec4diagram/useViewToNodesEdges.js";
9
8
  import { LikeC4DiagramXYFlow } from "./likec4diagram/XYFlow.js";
10
9
  import { useLikeC4Model } from "./likec4model/useLikeC4Model.js";
@@ -113,7 +112,7 @@ function LikeC4Diagram({
113
112
  {
114
113
  fitView,
115
114
  ...initialRef.current,
116
- children: /* @__PURE__ */ jsxs(
115
+ children: /* @__PURE__ */ jsx(
117
116
  DiagramActor,
118
117
  {
119
118
  input: {
@@ -123,17 +122,14 @@ function LikeC4Diagram({
123
122
  fitViewPadding,
124
123
  ...xyNodesEdges
125
124
  },
126
- children: [
127
- /* @__PURE__ */ jsx(
128
- LikeC4DiagramXYFlow,
129
- {
130
- nodesDraggable,
131
- nodesSelectable,
132
- background
133
- }
134
- ),
135
- /* @__PURE__ */ jsx(DiagramUI, {})
136
- ]
125
+ children: /* @__PURE__ */ jsx(
126
+ LikeC4DiagramXYFlow,
127
+ {
128
+ nodesDraggable,
129
+ nodesSelectable,
130
+ background
131
+ }
132
+ )
137
133
  }
138
134
  )
139
135
  }
@@ -38,7 +38,6 @@ const BaseXYFlow = ({
38
38
  nodes,
39
39
  edges,
40
40
  className: clsx(
41
- "likec4-diagram",
42
41
  cssReactFlow,
43
42
  pannable !== true && cssDisablePan,
44
43
  background === "transparent" && cssTransparentBg,
@@ -1,3 +1,2 @@
1
1
  export { BaseXYFlow, type BaseXYFlowProps } from './BaseXYFlow';
2
2
  export { Base, type EdgeProps, type NodeProps, type NonOptional, type ReactFlowEdge, type ReactFlowNode, } from './types';
3
- export { Link } from './Link';
@@ -1,11 +1,11 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { createPolymorphicComponent, Box } from "@mantine/core";
3
- import { assignInlineVars } from "../../../node_modules/@vanilla-extract/dynamic/dist/vanilla-extract-dynamic.esm.js";
3
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
4
4
  import clsx from "clsx";
5
5
  import { m } from "framer-motion";
6
6
  import { forwardRef } from "react";
7
7
  import { isNumber, clamp } from "remeda";
8
- import { indicator, compoundBg, compoundBorder, varCompoundOpacity, container, varBorderTransparency } from "./CompoundNodeContainer.css.js";
8
+ import { indicator, compoundBg, compoundBorder, varBorderTransparency, varCompoundOpacity, container } from "./CompoundNodeContainer.css.js";
9
9
  const CompoundNodeContainer = createPolymorphicComponent(
10
10
  forwardRef(({
11
11
  nodeProps: {
@@ -1,14 +1,14 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { isStepEdgeId, extractStep } from "@likec4/core";
3
3
  import { createPolymorphicComponent, Box, Text } from "@mantine/core";
4
- import { assignInlineVars } from "../../../node_modules/@vanilla-extract/dynamic/dist/vanilla-extract-dynamic.esm.js";
4
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
5
5
  import { EdgeLabelRenderer } from "@xyflow/react";
6
6
  import clsx from "clsx";
7
7
  import { forwardRef } from "react";
8
8
  import { isTruthy, isNumber } from "remeda";
9
9
  import { useIsZoomTooSmall } from "../../../hooks/useXYFlow.js";
10
10
  import { ZIndexes } from "../../const.js";
11
- import { edgeLabel, stepEdgeNumber, secondColumn, edgeLabelText, edgeLabelTechnology, edgeVars, edgeLabelContainer, dimmed, varTranslate } from "./EdgeLabel.css.js";
11
+ import { edgeLabel, stepEdgeNumber, secondColumn, edgeLabelText, edgeLabelTechnology, varTranslate, edgeVars, edgeLabelContainer, dimmed } from "./EdgeLabel.css.js";
12
12
  const toCssVarValue = (value) => {
13
13
  if (value === void 0) return void 0;
14
14
  return isNumber(value) ? `${value}px` : value;
@@ -1,4 +1,4 @@
1
- import { DiagramNode } from '@likec4/core';
1
+ import { DiagramNode, ElementStyle, ShapeSize, SpacingSize, TextSize } from '@likec4/core';
2
2
  import { BoxProps, PolymorphicComponentProps } from '@mantine/core';
3
3
  import { PropsWithChildren, FunctionComponent, ReactNode } from 'react';
4
4
  import { NodeProps } from '../../types';
@@ -6,6 +6,11 @@ type RequiredData = Pick<DiagramNode, 'color' | 'shape' | 'style'>;
6
6
  type ElementNodeContainerProps = BoxProps & PropsWithChildren<{
7
7
  nodeProps: NodeProps<RequiredData>;
8
8
  }>;
9
+ export declare function nodeSizes({ size, padding, textSize, }: ElementStyle): {
10
+ size: ShapeSize;
11
+ padding: SpacingSize;
12
+ textSize: TextSize;
13
+ };
9
14
  export declare const ElementNodeContainer: (<C = "div">(props: PolymorphicComponentProps<C, ElementNodeContainerProps>) => React.ReactElement) & Omit< FunctionComponent<(BoxProps & {
10
15
  nodeProps: NodeProps<RequiredData>;
11
16
  } & {
@@ -1,10 +1,33 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { DefaultTextSize, DefaultPaddingSize, DefaultShapeSize } from "@likec4/core";
2
+ import { DefaultShapeSize, DefaultTextSize, DefaultPaddingSize } from "@likec4/core";
3
3
  import { createPolymorphicComponent, Box } from "@mantine/core";
4
4
  import clsx from "clsx";
5
5
  import { m } from "framer-motion";
6
6
  import { forwardRef } from "react";
7
7
  import { container } from "./ElementNodeContainer.css.js";
8
+ function nodeSizes({
9
+ size,
10
+ padding,
11
+ textSize
12
+ }) {
13
+ if (!size && !!textSize) {
14
+ size = textSize;
15
+ }
16
+ if (!textSize && !!size) {
17
+ textSize = size;
18
+ }
19
+ if (!padding && !!size) {
20
+ padding = size;
21
+ }
22
+ size ?? (size = DefaultShapeSize);
23
+ textSize ?? (textSize = DefaultTextSize);
24
+ padding ?? (padding = DefaultPaddingSize);
25
+ return {
26
+ size,
27
+ padding,
28
+ textSize
29
+ };
30
+ }
8
31
  const ElementNodeContainer = createPolymorphicComponent(
9
32
  forwardRef(({
10
33
  nodeProps: {
@@ -28,17 +51,11 @@ const ElementNodeContainer = createPolymorphicComponent(
28
51
  scale = 1.02;
29
52
  break;
30
53
  }
31
- let {
54
+ const {
32
55
  size,
33
56
  padding,
34
57
  textSize
35
- } = data.style;
36
- if (!size && !!textSize) {
37
- size = textSize;
38
- }
39
- if (!textSize && !!size) {
40
- textSize = size;
41
- }
58
+ } = nodeSizes(data.style);
42
59
  return /* @__PURE__ */ jsx(
43
60
  Box,
44
61
  {
@@ -58,9 +75,9 @@ const ElementNodeContainer = createPolymorphicComponent(
58
75
  "data-hovered": isHovered,
59
76
  "data-likec4-color": data.color,
60
77
  "data-likec4-shape": data.shape,
61
- "data-likec4-shape-size": size ?? DefaultShapeSize,
62
- "data-likec4-padding": padding ?? DefaultPaddingSize,
63
- "data-likec4-text-size": textSize ?? DefaultTextSize,
78
+ "data-likec4-shape-size": size,
79
+ "data-likec4-padding": padding,
80
+ "data-likec4-text-size": textSize,
64
81
  "data-likec4-dimmed": isDimmed,
65
82
  ...rest,
66
83
  children
@@ -70,5 +87,6 @@ const ElementNodeContainer = createPolymorphicComponent(
70
87
  );
71
88
  ElementNodeContainer.displayName = "ElementNodeContainer";
72
89
  export {
73
- ElementNodeContainer
90
+ ElementNodeContainer,
91
+ nodeSizes
74
92
  };
@@ -1,11 +1,12 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import "@likec4/core";
3
3
  import { Box, Text } from "@mantine/core";
4
- import { assignInlineVars } from "../../../node_modules/@vanilla-extract/dynamic/dist/vanilla-extract-dynamic.esm.js";
4
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
5
5
  import clsx from "clsx";
6
6
  import { isNumber, isTruthy } from "remeda";
7
7
  import { IconRenderer } from "../../../context/IconRenderer.js";
8
8
  import { hiddenIfZoomTooSmall } from "../../../LikeC4Diagram.css.js";
9
+ import { nodeSizes } from "./ElementNodeContainer.js";
9
10
  import { elementIcon, title, technology, description, elementTextData, elementDataContainer, hasIcon } from "./ElementTitle.css.js";
10
11
  import { iconSize } from "./styles.css.js";
11
12
  function ElementTitle({ id, data, iconSize: iconSize$1 }) {
@@ -17,6 +18,9 @@ function ElementTitle({ id, data, iconSize: iconSize$1 }) {
17
18
  },
18
19
  className: elementIcon
19
20
  });
21
+ const size = nodeSizes(data.style).size;
22
+ const isSm = size === "sm";
23
+ const isSmOrXs = isSm || size === "xs";
20
24
  return /* @__PURE__ */ jsxs(
21
25
  Box,
22
26
  {
@@ -38,7 +42,7 @@ function ElementTitle({ id, data, iconSize: iconSize$1 }) {
38
42
  {
39
43
  component: "h3",
40
44
  className: clsx(title, "likec4-element-title"),
41
- lineClamp: 3,
45
+ lineClamp: isSmOrXs ? 2 : 3,
42
46
  children: data.title
43
47
  }
44
48
  ),
@@ -55,7 +59,7 @@ function ElementTitle({ id, data, iconSize: iconSize$1 }) {
55
59
  {
56
60
  component: "div",
57
61
  className: clsx(description, "likec4-element-description"),
58
- lineClamp: 5,
62
+ lineClamp: isSmOrXs ? 3 : 5,
59
63
  children: data.description
60
64
  }
61
65
  )
@@ -1,6 +1,6 @@
1
1
  /* empty css */
2
2
  /* empty css */
3
- var iconSize = "var(--v7x5jk2)";
3
+ var iconSize = "var(--likec4-icon-size)";
4
4
  export {
5
5
  iconSize
6
6
  };
@@ -1,7 +1,7 @@
1
1
  /* empty css */
2
- var elementLink = "_180738q0";
3
- var linkIcon = "_180738q1";
4
- var linkTitleBox = "_180738q2";
2
+ var elementLink = "_1acgss10";
3
+ var linkIcon = "_1acgss11";
4
+ var linkTitleBox = "_1acgss12";
5
5
  export {
6
6
  elementLink,
7
7
  linkIcon,
@@ -0,0 +1,2 @@
1
+ export declare const root: string;
2
+ export declare const shortcut: string;
@@ -0,0 +1,7 @@
1
+ /* empty css */
2
+ var root = "xmhqho2";
3
+ var shortcut = "xmhqho3";
4
+ export {
5
+ root,
6
+ shortcut
7
+ };
@@ -0,0 +1,5 @@
1
+ import { ElementProps, UnstyledButtonProps } from '@mantine/core';
2
+ interface SearchControlProps extends UnstyledButtonProps, ElementProps<'button'> {
3
+ }
4
+ export declare function SearchControl({ className, ...others }: SearchControlProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { UnstyledButton, Group, rem, Text } from "@mantine/core";
3
+ import { IconSearch } from "@tabler/icons-react";
4
+ import { isMacOs } from "@xyflow/system";
5
+ import clsx from "clsx";
6
+ import { shortcut, root } from "./SearchControl.css.js";
7
+ function SearchControl({ className, ...others }) {
8
+ const isMac = isMacOs();
9
+ return /* @__PURE__ */ jsx(UnstyledButton, { ...others, className: clsx(root, className), children: /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
10
+ /* @__PURE__ */ jsx(IconSearch, { style: { width: rem(15), height: rem(15) }, stroke: 2 }),
11
+ /* @__PURE__ */ jsx(Text, { fz: "sm", fw: "500", pr: 50, children: "Search" }),
12
+ /* @__PURE__ */ jsx(Text, { fw: 700, className: shortcut, children: isMac ? "⌘ + K" : "Ctrl + K" })
13
+ ] }) });
14
+ }
15
+ export {
16
+ SearchControl
17
+ };
@@ -1,3 +1,4 @@
1
+ import { ElementShape } from '@likec4/core';
1
2
  import { ElementIconRenderer } from '../LikeC4Diagram.props';
2
3
  import { Provider } from 'react';
3
4
  export declare const IconRendererProvider: Provider<ElementIconRenderer | null>;
@@ -9,3 +10,12 @@ export declare function IconRenderer({ element, className, }: {
9
10
  };
10
11
  className: string;
11
12
  }): import("react/jsx-runtime").JSX.Element | null;
13
+ export declare function IconOrShapeRenderer({ element, className, }: {
14
+ element: {
15
+ id: string;
16
+ title: string;
17
+ shape: ElementShape;
18
+ icon?: string | null | undefined;
19
+ };
20
+ className: string;
21
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { IconCylinder, IconRectangularPrism, IconReorder, IconUser, IconDeviceMobile, IconBrowser } from "@tabler/icons-react";
2
3
  import clsx from "clsx";
3
4
  import { createContext, useContext } from "react";
4
5
  const IconRendererContext = createContext(null);
@@ -32,7 +33,40 @@ function IconRenderer({
32
33
  }
33
34
  );
34
35
  }
36
+ const ShapeIcons = {
37
+ browser: IconBrowser,
38
+ cylinder: IconCylinder,
39
+ mobile: IconDeviceMobile,
40
+ person: IconUser,
41
+ queue: IconReorder,
42
+ rectangle: IconRectangularPrism,
43
+ storage: IconCylinder
44
+ };
45
+ function IconOrShapeRenderer({
46
+ element,
47
+ className
48
+ }) {
49
+ const icon = IconRenderer({
50
+ element,
51
+ className
52
+ });
53
+ if (icon) {
54
+ return icon;
55
+ }
56
+ const ShapeIcon = ShapeIcons[element.shape];
57
+ return /* @__PURE__ */ jsx(
58
+ "div",
59
+ {
60
+ className: clsx(
61
+ className,
62
+ "likec4-shape-icon"
63
+ ),
64
+ children: /* @__PURE__ */ jsx(ShapeIcon, {})
65
+ }
66
+ );
67
+ }
35
68
  export {
69
+ IconOrShapeRenderer,
36
70
  IconRenderer,
37
71
  IconRendererProvider
38
72
  };
@@ -1,5 +1,4 @@
1
1
  export { useCurrentViewId } from './useCurrentViewId';
2
- export type { DiagramContext } from './useDiagramContext';
3
2
  export { useMantinePortalProps } from './useMantinePortalProps';
4
3
  export { useSetState } from './useSetState';
5
4
  export { useUpdateEffect } from './useUpdateEffect';
@@ -7556,9 +7556,9 @@ export declare function useDiagram(): {
7556
7556
  };
7557
7557
  };
7558
7558
  readonly on: {
7559
- readonly 'xyflow.applyNodeChages': {
7559
+ readonly 'xyflow.applyNodeChanges': {
7560
7560
  readonly actions: ActionFunction<DiagramContext, {
7561
- type: "xyflow.applyNodeChages";
7561
+ type: "xyflow.applyNodeChanges";
7562
7562
  changes: NodeChange<Types.Node>[];
7563
7563
  }, Events, undefined, Values<{
7564
7564
  hotkeyActor: {
@@ -7771,9 +7771,9 @@ export declare function useDiagram(): {
7771
7771
  };
7772
7772
  }>, never, never, never, never>;
7773
7773
  };
7774
- readonly 'xyflow.applyEdgeChages': {
7774
+ readonly 'xyflow.applyEdgeChanges': {
7775
7775
  readonly actions: ActionFunction<DiagramContext, {
7776
- type: "xyflow.applyEdgeChages";
7776
+ type: "xyflow.applyEdgeChanges";
7777
7777
  changes: EdgeChange<Types.Edge>[];
7778
7778
  }, Events, undefined, Values<{
7779
7779
  hotkeyActor: {
package/dist/index.d.ts CHANGED
@@ -7,6 +7,6 @@ export { LikeC4ModelProvider } from './LikeC4ModelProvider';
7
7
  export { useSetState } from './hooks/useSetState';
8
8
  export { useUpdateEffect } from './hooks/useUpdateEffect';
9
9
  export { vars, xyvars } from './theme-vars';
10
- export type * from './LikeC4Diagram.props';
10
+ export type { ChangeEvent, DiagramNodeWithNavigate, ElementIconRenderer, LikeC4ColorScheme, LikeC4DiagramEventHandlers, LikeC4DiagramProperties, OnCanvasClick, OnChange, OnEdgeClick, OnNavigateTo, OnNodeClick, OpenSourceParams, WhereOperator, } from './LikeC4Diagram.props';
11
11
  export { StaticLikeC4Diagram } from './StaticLikeC4Diagram';
12
12
  export type { StaticLikeC4DiagramProps } from './StaticLikeC4Diagram';
@@ -1,17 +1,14 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import "react";
3
- import { LikeC4Search } from "../LikeC4Search.js";
4
2
  import { Overlays } from "../overlays/Overlays.js";
5
- import { DynamicViewWalkthrough } from "./ui/walkthrough/DynamicViewWalkthrough.js";
6
3
  import { Controls } from "./ui/controls/Controls.js";
7
4
  import { IfEnabled } from "../context/DiagramFeatures.js";
8
5
  import { DiagramTitlePanel } from "./ui/diagram-title/DiagramTitlePanel.js";
9
6
  import { NotationPanel } from "./ui/notation/NotationPanel.js";
7
+ import { DynamicViewWalkthrough } from "./ui/walkthrough/DynamicViewWalkthrough.js";
10
8
  function DiagramUI() {
11
9
  return /* @__PURE__ */ jsxs(Fragment, { children: [
12
10
  /* @__PURE__ */ jsx(Controls, {}),
13
11
  /* @__PURE__ */ jsx(Overlays, {}),
14
- /* @__PURE__ */ jsx(IfEnabled, { feature: "Search", children: /* @__PURE__ */ jsx(LikeC4Search, {}) }),
15
12
  /* @__PURE__ */ jsx(IfEnabled, { feature: "ViewTitle", children: /* @__PURE__ */ jsx(DiagramTitlePanel, {}) }),
16
13
  /* @__PURE__ */ jsx(IfEnabled, { feature: "Notations", children: /* @__PURE__ */ jsx(NotationPanel, {}) }),
17
14
  /* @__PURE__ */ jsx(IfEnabled, { feature: "DynamicViewWalkthrough", children: /* @__PURE__ */ jsx(DynamicViewWalkthrough, {}) })
@@ -1,6 +1,11 @@
1
1
  import { EnforceOptional } from 'type-fest/source/enforce-optional';
2
2
  import { LikeC4DiagramProperties } from '../LikeC4Diagram.props';
3
+ import { NamedExoticComponent } from 'react';
3
4
  type Picked = EnforceOptional<Pick<LikeC4DiagramProperties, 'background' | 'nodesDraggable' | 'nodesSelectable'>>;
4
5
  export type LikeC4DiagramXYFlowProps = Required<Picked>;
5
- export declare const LikeC4DiagramXYFlow: ({ background, ...rest }: LikeC4DiagramXYFlowProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const LikeC4DiagramXYFlow: NamedExoticComponent<Required<{
7
+ background?: "solid" | "transparent" | "dots" | "lines" | "cross";
8
+ nodesDraggable?: boolean;
9
+ nodesSelectable?: boolean;
10
+ }>>;
6
11
  export {};
@@ -3,10 +3,12 @@ import { nonNullable } from "@likec4/core";
3
3
  import { useCallbackRef } from "@mantine/hooks";
4
4
  import clsx from "clsx";
5
5
  import { shallowEqual } from "fast-equals";
6
+ import { memo } from "react";
6
7
  import { BaseXYFlow } from "../base/BaseXYFlow.js";
7
8
  import { useDiagram } from "../hooks/useDiagram.js";
8
9
  import { useDiagramContext } from "../hooks/useDiagramContext.js";
9
10
  import { edgeTypes } from "./custom/index.js";
11
+ import { DiagramUI } from "./DiagramUI.js";
10
12
  import { useLayoutConstraints } from "./useLayoutConstraints.js";
11
13
  import { useDiagramEventHandlers } from "../context/DiagramEventHandlers.js";
12
14
  import { nodeTypes } from "./custom/nodes/nodeTypes.js";
@@ -21,7 +23,7 @@ const selectXYProps = (ctx) => ({
21
23
  enableReadOnly: ctx.features.enableReadOnly
22
24
  });
23
25
  const equalsXYProps = (a, b) => a.initialized === b.initialized && a.pannable === b.pannable && a.zoomable === b.zoomable && a.fitViewPadding === b.fitViewPadding && a.enableFitView === b.enableFitView && a.enableReadOnly === b.enableReadOnly && shallowEqual(a.nodes, b.nodes) && shallowEqual(a.edges, b.edges);
24
- const LikeC4DiagramXYFlow = ({ background, ...rest }) => {
26
+ const LikeC4DiagramXYFlow = memo(({ background, nodesDraggable, nodesSelectable }) => {
25
27
  const diagram = useDiagram();
26
28
  const {
27
29
  initialized,
@@ -54,10 +56,10 @@ const LikeC4DiagramXYFlow = ({ background, ...rest }) => {
54
56
  nodeTypes,
55
57
  edgeTypes,
56
58
  onNodesChange: useCallbackRef((changes) => {
57
- diagram.send({ type: "xyflow.applyNodeChages", changes });
59
+ diagram.send({ type: "xyflow.applyNodeChanges", changes });
58
60
  }),
59
61
  onEdgesChange: useCallbackRef((changes) => {
60
- diagram.send({ type: "xyflow.applyEdgeChages", changes });
62
+ diagram.send({ type: "xyflow.applyEdgeChanges", changes });
61
63
  }),
62
64
  background: initialized ? background : "transparent",
63
65
  fitView: false,
@@ -78,6 +80,7 @@ const LikeC4DiagramXYFlow = ({ background, ...rest }) => {
78
80
  }),
79
81
  onDoubleClick: useCallbackRef((e) => {
80
82
  e.stopPropagation();
83
+ e.preventDefault();
81
84
  diagram.send({ type: "xyflow.paneDblClick" });
82
85
  onCanvasDblClick == null ? void 0 : onCanvasDblClick(e);
83
86
  }),
@@ -87,38 +90,34 @@ const LikeC4DiagramXYFlow = ({ background, ...rest }) => {
87
90
  onInit: useCallbackRef((instance) => {
88
91
  diagram.send({ type: "xyflow.init", instance });
89
92
  }),
90
- ...onNodeContextMenu && {
91
- onNodeContextMenu: useCallbackRef((event, node) => {
92
- const diagramNode = nonNullable(
93
- diagram.findDiagramNode(node.id),
94
- `diagramNode ${node.id} not found`
95
- );
96
- onNodeContextMenu(diagramNode, event);
97
- })
98
- },
99
- ...onEdgeContextMenu && {
100
- onEdgeContextMenu: useCallbackRef((event, edge) => {
101
- const diagramEdge = nonNullable(
102
- diagram.findDiagramEdge(edge.id),
103
- `diagramEdge ${edge.id} not found`
104
- );
105
- onEdgeContextMenu(diagramEdge, event);
106
- })
107
- },
108
- ...onCanvasContextMenu && {
109
- onPaneContextMenu: useCallbackRef((event) => {
110
- onCanvasContextMenu(event);
111
- })
112
- },
93
+ onNodeContextMenu: useCallbackRef((event, node) => {
94
+ const diagramNode = nonNullable(
95
+ diagram.findDiagramNode(node.id),
96
+ `diagramNode ${node.id} not found`
97
+ );
98
+ onNodeContextMenu == null ? void 0 : onNodeContextMenu(diagramNode, event);
99
+ }),
100
+ onEdgeContextMenu: useCallbackRef((event, edge) => {
101
+ const diagramEdge = nonNullable(
102
+ diagram.findDiagramEdge(edge.id),
103
+ `diagramEdge ${edge.id} not found`
104
+ );
105
+ onEdgeContextMenu == null ? void 0 : onEdgeContextMenu(diagramEdge, event);
106
+ }),
107
+ onPaneContextMenu: useCallbackRef((event) => {
108
+ onCanvasContextMenu == null ? void 0 : onCanvasContextMenu(event);
109
+ }),
113
110
  ...enableFitView && {
114
111
  onViewportResize
115
112
  },
116
- ...notReadOnly && rest.nodesDraggable && layoutConstraints,
113
+ nodesDraggable,
114
+ nodesSelectable,
115
+ ...notReadOnly && nodesDraggable && layoutConstraints,
117
116
  ...props,
118
- ...rest
117
+ children: /* @__PURE__ */ jsx(DiagramUI, {})
119
118
  }
120
119
  );
121
- };
120
+ }, shallowEqual);
122
121
  export {
123
122
  LikeC4DiagramXYFlow
124
123
  };
@@ -5,7 +5,7 @@ import { IconInfoCircle, IconArrowRight, IconZoomScan, IconFileSymlink } from "@
5
5
  import clsx from "clsx";
6
6
  import { useCallback, Fragment as Fragment$1, forwardRef } from "react";
7
7
  import { pipe, map, filter, isTruthy, partition } from "remeda";
8
- import { Link } from "../../../base/Link.js";
8
+ import { Link } from "../../../components/Link.js";
9
9
  import { useDiagram } from "../../../hooks/useDiagram.js";
10
10
  import { useDiagramContext } from "../../../hooks/useDiagramContext.js";
11
11
  import { DiagramContext } from "../../state/machine.js";
@@ -89,9 +89,11 @@ function RelationshipsDropdownMenu({
89
89
  closeOnClickOutside: true,
90
90
  clickOutsideEvents: ["pointerdown", "mousedown", "click"],
91
91
  closeOnEscape: true,
92
+ keepMounted: false,
92
93
  closeOnItemClick: false,
93
94
  disabled,
94
95
  position: "bottom-start",
96
+ middlewares: { size: { padding: 8 } },
95
97
  ...portalProps,
96
98
  children: [
97
99
  /* @__PURE__ */ jsx(MenuTarget, { children }),
@@ -9055,9 +9055,9 @@ export declare const LikeC4ViewMachineContextProvider: (props: {
9055
9055
  };
9056
9056
  };
9057
9057
  readonly on: {
9058
- readonly 'xyflow.applyNodeChages': {
9058
+ readonly 'xyflow.applyNodeChanges': {
9059
9059
  readonly actions: ActionFunction<DiagramContext, {
9060
- type: "xyflow.applyNodeChages";
9060
+ type: "xyflow.applyNodeChanges";
9061
9061
  changes: NodeChange<import("../types").Types.Node>[];
9062
9062
  }, Events, undefined, Values<{
9063
9063
  hotkeyActor: {
@@ -9307,9 +9307,9 @@ export declare const LikeC4ViewMachineContextProvider: (props: {
9307
9307
  };
9308
9308
  }>, never, never, never, never>;
9309
9309
  };
9310
- readonly 'xyflow.applyEdgeChages': {
9310
+ readonly 'xyflow.applyEdgeChanges': {
9311
9311
  readonly actions: ActionFunction<DiagramContext, {
9312
- type: "xyflow.applyEdgeChages";
9312
+ type: "xyflow.applyEdgeChanges";
9313
9313
  changes: EdgeChange<{
9314
9314
  id: string;
9315
9315
  source: string;
@@ -22116,9 +22116,9 @@ export declare const LikeC4ViewMachineContextProvider: (props: {
22116
22116
  };
22117
22117
  };
22118
22118
  readonly on: {
22119
- readonly 'xyflow.applyNodeChages': {
22119
+ readonly 'xyflow.applyNodeChanges': {
22120
22120
  readonly actions: ActionFunction<DiagramContext, {
22121
- type: "xyflow.applyNodeChages";
22121
+ type: "xyflow.applyNodeChanges";
22122
22122
  changes: NodeChange<import("../types").Types.Node>[];
22123
22123
  }, Events, undefined, Values<{
22124
22124
  hotkeyActor: {
@@ -22368,9 +22368,9 @@ export declare const LikeC4ViewMachineContextProvider: (props: {
22368
22368
  };
22369
22369
  }>, never, never, never, never>;
22370
22370
  };
22371
- readonly 'xyflow.applyEdgeChages': {
22371
+ readonly 'xyflow.applyEdgeChanges': {
22372
22372
  readonly actions: ActionFunction<DiagramContext, {
22373
- type: "xyflow.applyEdgeChages";
22373
+ type: "xyflow.applyEdgeChanges";
22374
22374
  changes: EdgeChange<{
22375
22375
  id: string;
22376
22376
  source: string;
@@ -34842,9 +34842,9 @@ export declare const LikeC4ViewMachineContextProvider: (props: {
34842
34842
  };
34843
34843
  };
34844
34844
  readonly on: {
34845
- readonly 'xyflow.applyNodeChages': {
34845
+ readonly 'xyflow.applyNodeChanges': {
34846
34846
  readonly actions: ActionFunction<DiagramContext, {
34847
- type: "xyflow.applyNodeChages";
34847
+ type: "xyflow.applyNodeChanges";
34848
34848
  changes: NodeChange<import("../types").Types.Node>[];
34849
34849
  }, Events, undefined, Values<{
34850
34850
  hotkeyActor: {
@@ -35094,9 +35094,9 @@ export declare const LikeC4ViewMachineContextProvider: (props: {
35094
35094
  };
35095
35095
  }>, never, never, never, never>;
35096
35096
  };
35097
- readonly 'xyflow.applyEdgeChages': {
35097
+ readonly 'xyflow.applyEdgeChanges': {
35098
35098
  readonly actions: ActionFunction<DiagramContext, {
35099
- type: "xyflow.applyEdgeChages";
35099
+ type: "xyflow.applyEdgeChanges";
35100
35100
  changes: EdgeChange<{
35101
35101
  id: string;
35102
35102
  source: string;
@@ -47901,9 +47901,9 @@ export declare const LikeC4ViewMachineContextProvider: (props: {
47901
47901
  };
47902
47902
  };
47903
47903
  readonly on: {
47904
- readonly 'xyflow.applyNodeChages': {
47904
+ readonly 'xyflow.applyNodeChanges': {
47905
47905
  readonly actions: ActionFunction<DiagramContext, {
47906
- type: "xyflow.applyNodeChages";
47906
+ type: "xyflow.applyNodeChanges";
47907
47907
  changes: NodeChange<import("../types").Types.Node>[];
47908
47908
  }, Events, undefined, Values<{
47909
47909
  hotkeyActor: {
@@ -48153,9 +48153,9 @@ export declare const LikeC4ViewMachineContextProvider: (props: {
48153
48153
  };
48154
48154
  }>, never, never, never, never>;
48155
48155
  };
48156
- readonly 'xyflow.applyEdgeChages': {
48156
+ readonly 'xyflow.applyEdgeChanges': {
48157
48157
  readonly actions: ActionFunction<DiagramContext, {
48158
- type: "xyflow.applyEdgeChages";
48158
+ type: "xyflow.applyEdgeChanges";
48159
48159
  changes: EdgeChange<{
48160
48160
  id: string;
48161
48161
  source: string;