@likec4/diagram 1.24.0 → 1.24.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 (116) hide show
  1. package/dist/LikeC4Diagram.css.d.ts +5 -0
  2. package/dist/LikeC4Diagram.css.js +1 -0
  3. package/dist/LikeC4Diagram.d.ts +1 -1
  4. package/dist/LikeC4Diagram.js +6 -2
  5. package/dist/LikeC4Diagram.props.d.ts +6 -0
  6. package/dist/base/BaseXYFlow.d.ts +1 -1
  7. package/dist/base/BaseXYFlow.js +12 -3
  8. package/dist/base/const.d.ts +1 -1
  9. package/dist/base/const.js +1 -1
  10. package/dist/base/primitives/compound/CompoundActionButton.css.js +2 -0
  11. package/dist/base/primitives/compound/CompoundDetailsButton.css.js +2 -0
  12. package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +0 -1
  13. package/dist/base/primitives/compound/CompoundNodeContainer.css.js +4 -4
  14. package/dist/base/primitives/compound/CompoundNodeContainer.js +35 -22
  15. package/dist/base/primitives/compound/CompoundTitle.css.js +3 -1
  16. package/dist/base/primitives/customNode.js +1 -1
  17. package/dist/base/primitives/edge/EdgeContainer.js +5 -4
  18. package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -1
  19. package/dist/base/primitives/edge/EdgeLabel.css.js +2 -5
  20. package/dist/base/primitives/edge/EdgeLabel.js +5 -5
  21. package/dist/base/primitives/edge/edge.css.d.ts +1 -1
  22. package/dist/base/primitives/edge/edge.css.js +4 -5
  23. package/dist/base/primitives/element/ElementActionButtons.css.js +2 -0
  24. package/dist/base/primitives/element/ElementActionButtons.js +4 -3
  25. package/dist/base/primitives/element/ElementDetailsButton.css.js +2 -0
  26. package/dist/base/primitives/element/ElementNodeContainer.css.js +2 -0
  27. package/dist/base/primitives/element/ElementNodeContainer.js +3 -1
  28. package/dist/base/primitives/element/ElementShape.css.js +4 -2
  29. package/dist/base/primitives/element/ElementShape.js +2 -3
  30. package/dist/base/primitives/element/ElementTitle.css.js +2 -0
  31. package/dist/base/primitives/element/styles.css.js +2 -0
  32. package/dist/components/SearchControl.css.js +2 -0
  33. package/dist/context/FramerMotionConfig.d.ts +9 -1
  34. package/dist/context/FramerMotionConfig.js +5 -2
  35. package/dist/context/RootContainer.js +13 -1
  36. package/dist/diagram.css +1 -1
  37. package/dist/globals.css.d.ts +2 -0
  38. package/dist/hooks/safeContext.js +1 -0
  39. package/dist/hooks/useDiagram.d.ts +554 -864
  40. package/dist/hooks/useDiagram.js +1 -0
  41. package/dist/hooks/useIsReducedGraphics.d.ts +4 -0
  42. package/dist/hooks/useIsReducedGraphics.js +8 -0
  43. package/dist/hooks/useXYFlow.js +1 -1
  44. package/dist/likec4diagram/DiagramUI.d.ts +2 -1
  45. package/dist/likec4diagram/DiagramUI.js +5 -3
  46. package/dist/likec4diagram/custom/nodes/nodeTypes.js +2 -2
  47. package/dist/likec4diagram/ui/controls/styles.css.js +2 -0
  48. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.css.js +2 -0
  49. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +3 -4
  50. package/dist/likec4diagram/ui/search/LikeC4Search.css.js +2 -0
  51. package/dist/overlays/element-details/ElementDetailsCard.js +12 -8
  52. package/dist/overlays/element-details/actor.d.ts +9084 -2569
  53. package/dist/overlays/overlay/Overlay.js +6 -3
  54. package/dist/overlays/relationship-details/RelationshipDetails.js +31 -17
  55. package/dist/overlays/relationship-details/actor.d.ts +228 -3
  56. package/dist/overlays/relationship-details/actor.js +86 -14
  57. package/dist/overlays/relationship-details/hooks.d.ts +3 -0
  58. package/dist/overlays/relationship-details/hooks.js +6 -2
  59. package/dist/overlays/relationships-browser/-useRelationshipsView.js +12 -3
  60. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +12 -3
  61. package/dist/overlays/relationships-browser/actor.d.ts +271 -54
  62. package/dist/overlays/relationships-browser/actor.js +86 -23
  63. package/dist/state/DiagramActorProvider.js +12 -2
  64. package/dist/state/diagram-machine.d.ts +563 -867
  65. package/dist/state/diagram-machine.js +82 -81
  66. package/dist/state/persistence.d.ts +5 -0
  67. package/dist/state/persistence.js +23 -0
  68. package/package.json +9 -9
  69. package/src/LikeC4Diagram.css.ts +13 -5
  70. package/src/LikeC4Diagram.props.ts +7 -0
  71. package/src/LikeC4Diagram.tsx +33 -24
  72. package/src/base/BaseXYFlow.tsx +14 -9
  73. package/src/base/const.ts +1 -1
  74. package/src/base/primitives/compound/CompoundActionButton.css.ts +6 -0
  75. package/src/base/primitives/compound/CompoundDetailsButton.css.ts +4 -0
  76. package/src/base/primitives/compound/CompoundNodeContainer.css.ts +41 -59
  77. package/src/base/primitives/compound/CompoundNodeContainer.tsx +42 -22
  78. package/src/base/primitives/compound/CompoundTitle.css.ts +14 -13
  79. package/src/base/primitives/customNode.ts +3 -2
  80. package/src/base/primitives/edge/EdgeContainer.tsx +4 -3
  81. package/src/base/primitives/edge/EdgeLabel.css.ts +17 -11
  82. package/src/base/primitives/edge/EdgeLabel.tsx +4 -4
  83. package/src/base/primitives/edge/edge.css.ts +47 -27
  84. package/src/base/primitives/element/ElementActionButtons.css.ts +4 -0
  85. package/src/base/primitives/element/ElementActionButtons.tsx +4 -2
  86. package/src/base/primitives/element/ElementDetailsButton.css.ts +6 -8
  87. package/src/base/primitives/element/ElementNodeContainer.css.ts +18 -21
  88. package/src/base/primitives/element/ElementNodeContainer.tsx +3 -1
  89. package/src/base/primitives/element/ElementShape.css.ts +10 -6
  90. package/src/base/primitives/element/ElementShape.tsx +2 -2
  91. package/src/components/SearchControl.css.ts +11 -4
  92. package/src/context/FramerMotionConfig.tsx +13 -2
  93. package/src/context/RootContainer.tsx +9 -2
  94. package/src/globals.css.ts +3 -0
  95. package/src/hooks/safeContext.tsx +2 -1
  96. package/src/hooks/useDiagram.ts +1 -0
  97. package/src/hooks/useIsReducedGraphics.ts +5 -0
  98. package/src/hooks/useXYFlow.ts +1 -1
  99. package/src/likec4diagram/DiagramUI.tsx +5 -3
  100. package/src/likec4diagram/custom/nodes/nodeTypes.tsx +2 -2
  101. package/src/likec4diagram/ui/controls/styles.css.ts +11 -1
  102. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.css.ts +10 -3
  103. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +6 -3
  104. package/src/likec4diagram/ui/search/LikeC4Search.css.ts +1 -0
  105. package/src/overlays/element-details/ElementDetailsCard.tsx +238 -231
  106. package/src/overlays/overlay/Overlay.css.ts +1 -9
  107. package/src/overlays/overlay/Overlay.tsx +6 -3
  108. package/src/overlays/relationship-details/RelationshipDetails.tsx +83 -66
  109. package/src/overlays/relationship-details/actor.ts +106 -13
  110. package/src/overlays/relationship-details/hooks.ts +6 -2
  111. package/src/overlays/relationships-browser/-useRelationshipsView.ts +10 -0
  112. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +16 -8
  113. package/src/overlays/relationships-browser/actor.ts +92 -22
  114. package/src/state/DiagramActorProvider.tsx +13 -2
  115. package/src/state/diagram-machine.ts +80 -79
  116. package/src/state/persistence.ts +22 -0
@@ -9,6 +9,7 @@ function useDiagram() {
9
9
  const actor = useDiagramActorRef();
10
10
  const [, startTransition] = useTransition();
11
11
  return useMemo(() => ({
12
+ actor,
12
13
  send: actor.send,
13
14
  navigateTo: (viewId, fromNode) => {
14
15
  startTransition(() => {
@@ -0,0 +1,4 @@
1
+ export declare const ReducedGraphicsContext: ({ children, value }: {
2
+ value: boolean;
3
+ children: React.ReactNode;
4
+ }) => import("react/jsx-runtime").JSX.Element, useIsReducedGraphics: () => boolean;
@@ -0,0 +1,8 @@
1
+ import { createSafeContext } from "@mantine/core";
2
+ const [ReducedGraphicsContext, useIsReducedGraphics] = createSafeContext(
3
+ "ReducedGraphicsContext is not provided"
4
+ );
5
+ export {
6
+ ReducedGraphicsContext,
7
+ useIsReducedGraphics
8
+ };
@@ -10,7 +10,7 @@ function useXYStore(selector, equalityFn) {
10
10
  }
11
11
  const useXYStoreApi = useStoreApi;
12
12
  const useXYInternalNode = useInternalNode;
13
- const selectZoom = (state) => state.transform[2] < 0.2;
13
+ const selectZoom = (state) => state.transform[2] < 0.25;
14
14
  function useIsZoomTooSmall() {
15
15
  return useStore(selectZoom);
16
16
  }
@@ -1 +1,2 @@
1
- export declare function DiagramUI(): import("react/jsx-runtime").JSX.Element;
1
+ import { MemoExoticComponent } from 'react';
2
+ export declare const DiagramUI: MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
@@ -1,4 +1,5 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { memo } from "react";
2
3
  import { useDiagramActorSnapshot } from "../hooks/useDiagram.js";
3
4
  import { Overlays } from "../overlays/Overlays.js";
4
5
  import { useEnabledFeatures } from "../context/DiagramFeatures.js";
@@ -6,13 +7,13 @@ import { Controls } from "./ui/controls/Controls.js";
6
7
  import { DiagramTitlePanel } from "./ui/diagram-title/DiagramTitlePanel.js";
7
8
  import { NotationPanel } from "./ui/notation/NotationPanel.js";
8
9
  import { DynamicViewWalkthrough } from "./ui/walkthrough/DynamicViewWalkthrough.js";
9
- function DiagramUI() {
10
+ const DiagramUI = memo(() => {
10
11
  const {
11
12
  enableViewTitle,
12
13
  enableNotations,
13
14
  enableDynamicViewWalkthrough
14
15
  } = useEnabledFeatures();
15
- const overlaysActorRef = useDiagramActorSnapshot((s) => s.children.overlays);
16
+ const overlaysActorRef = useDiagramActorSnapshot((s) => s.children.overlays, Object.is);
16
17
  return /* @__PURE__ */ jsxs(Fragment, { children: [
17
18
  /* @__PURE__ */ jsx(Controls, {}),
18
19
  overlaysActorRef && /* @__PURE__ */ jsx(Overlays, { overlaysActorRef }),
@@ -20,7 +21,8 @@ function DiagramUI() {
20
21
  enableNotations && /* @__PURE__ */ jsx(NotationPanel, {}),
21
22
  enableDynamicViewWalkthrough && /* @__PURE__ */ jsx(DynamicViewWalkthrough, {})
22
23
  ] });
23
- }
24
+ });
25
+ DiagramUI.displayName = "DiagramUI";
24
26
  export {
25
27
  DiagramUI
26
28
  };
@@ -32,7 +32,7 @@ const ElementDetailsButtonWithHandler = ({ fqn, ...props }) => {
32
32
  };
33
33
  const nodeTypes = {
34
34
  element: customNode((props) => /* @__PURE__ */ jsxs(ElementNodeContainer, { nodeProps: props, children: [
35
- /* @__PURE__ */ jsx(ElementShape, { ...props, isMultiple: props.data.isMultiple }),
35
+ /* @__PURE__ */ jsx(ElementShape, { ...props, isMultiple: props.data.isMultiple, withSelectedIndicator: props.selected }),
36
36
  /* @__PURE__ */ jsx(ElementTitle, { ...props }),
37
37
  /* @__PURE__ */ jsx(ElementActions, { ...props }),
38
38
  /* @__PURE__ */ jsx(
@@ -46,7 +46,7 @@ const nodeTypes = {
46
46
  /* @__PURE__ */ jsx(DefaultHandles, {})
47
47
  ] })),
48
48
  deployment: customNode((props) => /* @__PURE__ */ jsxs(ElementNodeContainer, { nodeProps: props, children: [
49
- /* @__PURE__ */ jsx(ElementShape, { ...props, isMultiple: props.data.isMultiple }),
49
+ /* @__PURE__ */ jsx(ElementShape, { ...props, isMultiple: props.data.isMultiple, withSelectedIndicator: props.selected }),
50
50
  /* @__PURE__ */ jsx(ElementTitle, { ...props }),
51
51
  /* @__PURE__ */ jsx(DeploymentElementActions, { ...props }),
52
52
  !!props.data.modelFqn && /* @__PURE__ */ jsx(
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  var navigationButtons = "o1xx0f0";
3
5
  var panel = "o1xx0f1";
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  var container = "_1wkb4qe0";
3
5
  var card = "_1wkb4qe1";
@@ -115,8 +115,8 @@ function DiagramTitlePanel() {
115
115
  Spoiler,
116
116
  {
117
117
  maxHeight: 42,
118
- showLabel: /* @__PURE__ */ jsx(Button, { color: "gray", variant: "light", fz: "10", size: "compact-xs", tabIndex: -1, children: "show more" }),
119
- hideLabel: /* @__PURE__ */ jsx(Button, { color: "gray", variant: "light", fz: "10", size: "compact-xs", tabIndex: -1, children: "hide" }),
118
+ showLabel: /* @__PURE__ */ jsx(Button, { component: "div", color: "gray", variant: "light", fz: "10", size: "compact-xs", tabIndex: -1, children: "show more" }),
119
+ hideLabel: /* @__PURE__ */ jsx(Button, { component: "div", color: "gray", variant: "light", fz: "10", size: "compact-xs", tabIndex: -1, children: "hide" }),
120
120
  children: /* @__PURE__ */ jsx(
121
121
  Text,
122
122
  {
@@ -151,8 +151,7 @@ function DiagramTitlePanel() {
151
151
  ]
152
152
  }
153
153
  )
154
- },
155
- id
154
+ }
156
155
  ) });
157
156
  }
158
157
  export {
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  /* empty css */
3
5
  var focusable = "_1cfw8gr4";
@@ -1,21 +1,23 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { isScopedElementView, isDeploymentView } from "@likec4/core";
3
- import { Card, Box, Group, Text, CloseButton, Badge, Flex, ActionIconGroup, ActionIcon, Tooltip as Tooltip$1, Tabs, TabsList, TabsTab, TabsPanel, ScrollArea, Stack, Divider as Divider$1, Code, UnstyledButton, ThemeIcon } from "@mantine/core";
3
+ import { RemoveScroll, Card, Box, Group, Text, CloseButton, Badge, Flex, ActionIconGroup, ActionIcon, Tooltip as Tooltip$1, Tabs, TabsList, TabsTab, TabsPanel, ScrollArea, Stack, Divider as Divider$1, Code, UnstyledButton, ThemeIcon } from "@mantine/core";
4
4
  import { useViewportSize, useSessionStorage } from "@mantine/hooks";
5
5
  import { useSyncedRef, useDebouncedCallback, useTimeoutEffect } from "@react-hookz/web";
6
6
  import { IconExternalLink, IconFileSymlink, IconZoomScan, IconStack2 } from "@tabler/icons-react";
7
+ import clsx from "clsx";
7
8
  import { useDragControls, useMotionValue, m } from "framer-motion";
8
9
  import { useState, useCallback, useRef } from "react";
9
10
  import { pipe, map, partition, only, clamp, isNullish } from "remeda";
10
11
  import { Link } from "../../components/Link.js";
11
12
  import { useDiagram } from "../../hooks/useDiagram.js";
12
- import { dialog, card, cardHeader, title, tabsPanel, tabsTab, tabsList, tabsRoot, propertiesGrid, resizeHandle, elementIcon, propertyLabel, viewButton, viewButtonTitle } from "./ElementDetailsCard.css.js";
13
+ import { card, cardHeader, title, tabsPanel, tabsTab, tabsList, tabsRoot, propertiesGrid, resizeHandle, dialog, elementIcon, propertyLabel, viewButton, viewButtonTitle } from "./ElementDetailsCard.css.js";
13
14
  import { TabPanelDeployments } from "./TabPanelDeployments.js";
14
15
  import { TabPanelRelationships } from "./TabPanelRelationships.js";
15
16
  import { TabPanelStructure } from "./TabPanelStructure.js";
16
17
  import { useLikeC4Model } from "../../likec4model/useLikeC4Model.js";
17
18
  import { useUpdateEffect } from "../../hooks/useUpdateEffect.js";
18
19
  import { IconRenderer } from "../../context/IconRenderer.js";
20
+ import { stopPropagation } from "../../utils/xyflow.js";
19
21
  import { IfEnabled, DiagramFeatures } from "../../context/DiagramFeatures.js";
20
22
  const Divider = Divider$1.withProps({
21
23
  mb: 8,
@@ -144,15 +146,15 @@ function ElementDetailsCard({
144
146
  if (!((_a2 = ref.current) == null ? void 0 : _a2.open)) {
145
147
  (_b2 = ref.current) == null ? void 0 : _b2.showModal();
146
148
  }
147
- }, 30);
149
+ }, 20);
148
150
  useTimeoutEffect(() => {
149
151
  setOpened(true);
150
- }, 120);
152
+ }, 150);
151
153
  return /* @__PURE__ */ jsx(
152
154
  m.dialog,
153
155
  {
154
156
  ref,
155
- className: dialog,
157
+ className: clsx(dialog, RemoveScroll.classNames.fullWidth),
156
158
  layout: true,
157
159
  layoutRoot: true,
158
160
  initial: {
@@ -172,16 +174,18 @@ function ElementDetailsCard({
172
174
  },
173
175
  onClick: (e) => {
174
176
  var _a2, _b2, _c2;
177
+ e.stopPropagation();
175
178
  if (((_b2 = (_a2 = e.target) == null ? void 0 : _a2.nodeName) == null ? void 0 : _b2.toUpperCase()) === "DIALOG") {
176
- e.stopPropagation();
177
179
  (_c2 = ref.current) == null ? void 0 : _c2.close();
178
180
  }
179
181
  },
182
+ onDoubleClick: stopPropagation,
183
+ onPointerDown: stopPropagation,
180
184
  onClose: (e) => {
181
185
  e.stopPropagation();
182
186
  close();
183
187
  },
184
- children: /* @__PURE__ */ jsxs(
188
+ children: /* @__PURE__ */ jsx(RemoveScroll, { forwardProps: true, removeScrollBar: false, children: /* @__PURE__ */ jsxs(
185
189
  Card,
186
190
  {
187
191
  drag: true,
@@ -401,7 +405,7 @@ function ElementDetailsCard({
401
405
  )
402
406
  ]
403
407
  }
404
- )
408
+ ) })
405
409
  }
406
410
  );
407
411
  }