@likec4/diagram 1.59.2 → 1.59.3

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 (73) hide show
  1. package/README.md +53 -0
  2. package/dist/LikeC4Styles.js +2 -1
  3. package/dist/base/BaseXYFlow.js +8 -1
  4. package/dist/base-primitives/compound/CompoundNodeContainer.js +2 -3
  5. package/dist/base-primitives/compound/CompoundTitle.js +5 -4
  6. package/dist/base-primitives/element/ElementData.js +6 -1
  7. package/dist/base-primitives/element/ElementShape.js +9 -10
  8. package/dist/context/CurrentViewModelProvider.js +2 -1
  9. package/dist/context/DiagramEventHandlers.js +2 -1
  10. package/dist/context/IconRenderer.js +42 -26
  11. package/dist/context/TagStylesContext.d.ts +2 -1
  12. package/dist/context/TagStylesContext.js +32 -20
  13. package/dist/custom/index.js +1 -1
  14. package/dist/editor/LikeC4EditorCallbacks.d.ts +20 -1
  15. package/dist/editor/LikeC4EditorCallbacks.js +4 -1
  16. package/dist/editor/actor/setup.d.ts +1 -0
  17. package/dist/editor/actor/setup.js +17 -12
  18. package/dist/editor/actor/state.sync-queue.js +1 -0
  19. package/dist/editor/applyChangesToManualLayout.js +1 -1
  20. package/dist/editor/index.d.ts +1 -1
  21. package/dist/editor/useEditorActorLogic.js +10 -3
  22. package/dist/hooks/useDiagram.js +4 -2
  23. package/dist/hooks/useDiagramCompareLayout.d.ts +13 -3
  24. package/dist/hooks/useDiagramCompareLayout.js +6 -1
  25. package/dist/hooks/useUpdateEffect.js +2 -1
  26. package/dist/index.d.ts +2 -1
  27. package/dist/index.js +3 -2
  28. package/dist/likec4diagram/DiagramUI.js +4 -3
  29. package/dist/likec4diagram/DiagramXYFlow.d.ts +1 -0
  30. package/dist/likec4diagram/DiagramXYFlow.js +14 -7
  31. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -3
  32. package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +1 -3
  33. package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +3 -2
  34. package/dist/likec4diagram/custom/nodes/nodes.js +6 -3
  35. package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +4 -3
  36. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +1 -2
  37. package/dist/likec4diagram/state/assign.js +1 -1
  38. package/dist/likec4diagram/state/createViewChange.js +1 -6
  39. package/dist/likec4diagram/state/machine.actions.js +6 -2
  40. package/dist/likec4diagram/state/machine.setup.js +9 -8
  41. package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +1 -1
  42. package/dist/likec4diagram/state/utils.js +7 -3
  43. package/dist/likec4diagram/ui/FloatingSequenceActors.js +2 -1
  44. package/dist/likec4diagram/ui/sequence-outline/SequenceOutlinePanel.js +4 -2
  45. package/dist/likec4diagram/useLayoutConstraints.js +19 -4
  46. package/dist/likec4diagram/xyflow-sequence/layouter.js +8 -10
  47. package/dist/navigationpanel/NavigationPanelDropdown.js +2 -1
  48. package/dist/navigationpanel/controls/DetailsControls.js +2 -1
  49. package/dist/navigationpanel/editorpanel/ApplySemanticLayout.js +2 -1
  50. package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.js +2 -1
  51. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +2 -0
  52. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +11 -3
  53. package/dist/navigationpanel/walkthrough/DynamicViewControls.js +1 -3
  54. package/dist/overlays/element-details/ElementDetailsCard.js +2 -2
  55. package/dist/overlays/overlaysActor.js +16 -17
  56. package/dist/overlays/relationship-details/RelationshipDetails.js +2 -1
  57. package/dist/overlays/relationship-details/hooks.js +2 -1
  58. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +4 -2
  59. package/dist/overlays/relationships-browser/actor.js +2 -1
  60. package/dist/overlays/relationships-browser/custom/ElementActions.js +39 -38
  61. package/dist/overlays/relationships-browser/hooks.js +2 -1
  62. package/dist/projects-overview/ProjectsOverview.js +8 -7
  63. package/dist/projects-overview/hooks.js +2 -1
  64. package/dist/search/components/ViewsColum.js +10 -8
  65. package/dist/search/hooks.js +2 -1
  66. package/dist/shadowroot/ShadowRoot.js +4 -2
  67. package/dist/styles2.js +1 -1
  68. package/dist/utils/index.js +2 -2
  69. package/package.json +26 -26
  70. package/panda.buildinfo.json +2 -1
  71. package/styles-min.css +1 -1
  72. package/styles-xyflow.css +1 -1
  73. package/styles.css +1 -1
@@ -30,9 +30,7 @@ function StartWalkthroughButton() {
30
30
  const actor = useNavigationActor();
31
31
  let tooltipLabel = "Start Dynamic View Walkthrough";
32
32
  switch (true) {
33
- case enableCompareWithLatest:
34
- tooltipLabel = "Walkthrough not available when Compare is active";
35
- break;
33
+ case enableCompareWithLatest: tooltipLabel = "Walkthrough not available when Compare is active";
36
34
  }
37
35
  return /* @__PURE__ */ jsx(Tooltip$1, {
38
36
  label: tooltipLabel,
@@ -79,8 +79,8 @@ function ElementDetailsCard({ viewId, fromNode, rectFromNode, fqn, onClose }) {
79
79
  const defaultLink = only(elementModel.links);
80
80
  const controls = useDragControls();
81
81
  const isCompound = (nodeModel?.$node.children?.length ?? 0) > 0;
82
- const _width = Math.min(700, windowWidth - MIN_PADDING * 2);
83
- const _height = Math.min(650, windowHeight - MIN_PADDING * 2);
82
+ const _width = Math.min(700, windowWidth - 48);
83
+ const _height = Math.min(650, windowHeight - 48);
84
84
  const fromPosition = rectFromNode ? {
85
85
  x: rectFromNode.x + (isCompound ? rectFromNode.width - _width / 2 : rectFromNode.width / 2),
86
86
  y: rectFromNode.y + (isCompound ? 0 : rectFromNode.height / 2)
@@ -6,6 +6,20 @@ import { isString, last, reverse } from "remeda";
6
6
  import { getHotkeyHandler } from "@mantine/hooks";
7
7
  import { assertEvent, fromCallback, setup } from "xstate";
8
8
  //#region src/overlays/overlaysActor.ts
9
+ var hotkeyLogic = fromCallback(({ sendBack }) => {
10
+ const handler = getHotkeyHandler([[
11
+ "Escape",
12
+ (event) => {
13
+ event.stopPropagation();
14
+ sendBack({ type: "close" });
15
+ },
16
+ { preventDefault: true }
17
+ ]]);
18
+ document.body.addEventListener("keydown", handler, { capture: true });
19
+ return () => {
20
+ document.body.removeEventListener("keydown", handler, { capture: true });
21
+ };
22
+ });
9
23
  var machine = setup({
10
24
  types: {
11
25
  context: {},
@@ -17,20 +31,7 @@ var machine = setup({
17
31
  relationshipDetails: relationshipDetailsLogic,
18
32
  elementDetails: elementDetailsLogic,
19
33
  relationshipsBrowser: relationshipsBrowserLogic,
20
- hotkey: fromCallback(({ sendBack }) => {
21
- const handler = getHotkeyHandler([[
22
- "Escape",
23
- (event) => {
24
- event.stopPropagation();
25
- sendBack({ type: "close" });
26
- },
27
- { preventDefault: true }
28
- ]]);
29
- document.body.addEventListener("keydown", handler, { capture: true });
30
- return () => {
31
- document.body.removeEventListener("keydown", handler, { capture: true });
32
- };
33
- })
34
+ hotkey: hotkeyLogic
34
35
  },
35
36
  guards: {
36
37
  "has overlays?": ({ context }) => context.overlays.length > 0,
@@ -167,9 +168,7 @@ var openOverlay = () => machine.enqueueActions(({ enqueue, event }) => {
167
168
  case "open.relationshipDetails":
168
169
  enqueue(openRelationshipDetails());
169
170
  break;
170
- case "open.relationshipsBrowser":
171
- enqueue(openRelationshipsBrowser());
172
- break;
171
+ case "open.relationshipsBrowser": enqueue(openRelationshipsBrowser());
173
172
  }
174
173
  });
175
174
  var listenToEsc = () => machine.spawnChild("hotkey", { id: "hotkey" });
@@ -56,7 +56,8 @@ var SyncRelationshipDetailsXYFlow = memo(() => {
56
56
  let data;
57
57
  if ("edgeId" in subject && isTruthy(subject.edgeId)) {
58
58
  invariant(view, `view ${subject.viewId} not found`);
59
- data = computeEdgeDetailsViewData([nonNullable(view.findEdge(subject.edgeId), `edge ${subject.edgeId} not found in ${subject.viewId}`).id], view);
59
+ const edge = nonNullable(view.findEdge(subject.edgeId), `edge ${subject.edgeId} not found in ${subject.viewId}`);
60
+ data = computeEdgeDetailsViewData([edge.id], view);
60
61
  } else if (!!subject.source && !!subject.target) data = computeRelationshipDetailsViewData({
61
62
  source: likec4model.element(subject.source),
62
63
  target: likec4model.element(subject.target)
@@ -11,7 +11,8 @@ function useRelationshipDetailsActor() {
11
11
  }
12
12
  function useRelationshipDetailsState(selector, compare = shallowEqual) {
13
13
  const select = useCallbackRef(selector);
14
- return useSelector(useRelationshipDetailsActor(), select, compare);
14
+ const actor = useRelationshipDetailsActor();
15
+ return useSelector(actor, select, compare);
15
16
  }
16
17
  function useRelationshipDetails() {
17
18
  const actor = useRelationshipDetailsActor();
@@ -152,9 +152,11 @@ var RelationshipsBrowserInner = memo(() => {
152
152
  useEffect(() => {
153
153
  browser.updateView(layouted);
154
154
  }, [layouted, browser]);
155
+ const hasStepBack = current > 0;
156
+ const hasStepForward = current + 1 < history.length;
155
157
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(TopLeftPanel, {
156
- hasStepBack: current > 0,
157
- hasStepForward: current + 1 < history.length,
158
+ hasStepBack,
159
+ hasStepForward,
158
160
  onStepBack: () => historyOps.back(),
159
161
  onStepForward: () => historyOps.forward()
160
162
  }), closeable && /* @__PURE__ */ jsx(Panel, {
@@ -43,7 +43,8 @@ var layouter = fromPromise(async ({ input, self, signal }) => {
43
43
  x: nextSubjectNode.position.x + (nextSubjectNode.initialWidth ?? 0) / 2,
44
44
  y: nextSubjectNode.position.y + (nextSubjectNode.initialHeight ?? 0) / 2
45
45
  };
46
- const currentSubjectCenter = getNodeCenter(xyflow.getInternalNode(currentSubjectNode.id));
46
+ const currentSubjectInternalNode = xyflow.getInternalNode(currentSubjectNode.id);
47
+ const currentSubjectCenter = getNodeCenter(currentSubjectInternalNode);
47
48
  const nested = /* @__PURE__ */ new Set();
48
49
  currentNodes.forEach((n) => {
49
50
  if (n.id === existingNode.id) return;
@@ -16,45 +16,46 @@ var ElementActions = (props) => {
16
16
  const browser = useRelationshipsBrowser();
17
17
  const subject = useRelationshipsBrowserState(selectSubject);
18
18
  const { navigateTo, fqn } = props.data;
19
+ const buttons = useMemo(() => {
20
+ const buttons = [];
21
+ if (navigateTo && enableNavigateTo && currentViewId !== navigateTo) buttons.push({
22
+ key: "navigate",
23
+ icon: /* @__PURE__ */ jsx(IconZoomScan, {}),
24
+ onClick: (e) => {
25
+ e.stopPropagation();
26
+ diagram.navigateTo(navigateTo);
27
+ }
28
+ });
29
+ if (fqn !== subject) buttons.push({
30
+ key: "relationships",
31
+ icon: /* @__PURE__ */ jsx(IconTransform, {}),
32
+ onClick: (e) => {
33
+ e.stopPropagation();
34
+ browser.navigateTo(fqn, props.id);
35
+ }
36
+ });
37
+ if (enableVscode) buttons.push({
38
+ key: "goToSource",
39
+ icon: /* @__PURE__ */ jsx(IconFileSymlink, {}),
40
+ onClick: (e) => {
41
+ e.stopPropagation();
42
+ diagram.openSource({ element: fqn });
43
+ }
44
+ });
45
+ return buttons;
46
+ }, [
47
+ navigateTo,
48
+ enableNavigateTo,
49
+ currentViewId,
50
+ fqn,
51
+ subject,
52
+ enableVscode,
53
+ diagram,
54
+ browser,
55
+ props.id
56
+ ]);
19
57
  return /* @__PURE__ */ jsx(ElementActionButtons, {
20
- buttons: useMemo(() => {
21
- const buttons = [];
22
- if (navigateTo && enableNavigateTo && currentViewId !== navigateTo) buttons.push({
23
- key: "navigate",
24
- icon: /* @__PURE__ */ jsx(IconZoomScan, {}),
25
- onClick: (e) => {
26
- e.stopPropagation();
27
- diagram.navigateTo(navigateTo);
28
- }
29
- });
30
- if (fqn !== subject) buttons.push({
31
- key: "relationships",
32
- icon: /* @__PURE__ */ jsx(IconTransform, {}),
33
- onClick: (e) => {
34
- e.stopPropagation();
35
- browser.navigateTo(fqn, props.id);
36
- }
37
- });
38
- if (enableVscode) buttons.push({
39
- key: "goToSource",
40
- icon: /* @__PURE__ */ jsx(IconFileSymlink, {}),
41
- onClick: (e) => {
42
- e.stopPropagation();
43
- diagram.openSource({ element: fqn });
44
- }
45
- });
46
- return buttons;
47
- }, [
48
- navigateTo,
49
- enableNavigateTo,
50
- currentViewId,
51
- fqn,
52
- subject,
53
- enableVscode,
54
- diagram,
55
- browser,
56
- props.id
57
- ]),
58
+ buttons,
58
59
  ...props
59
60
  });
60
61
  };
@@ -9,7 +9,8 @@ function useRelationshipsBrowserActor() {
9
9
  return nonNullable(useContext(RelationshipsBrowserActorContext), "No RelationshipsBrowserActorContext");
10
10
  }
11
11
  function useRelationshipsBrowserState(selector, compare = shallowEqual) {
12
- return useSelector(useRelationshipsBrowserActor(), selector, compare);
12
+ const actor = useRelationshipsBrowserActor();
13
+ return useSelector(actor, selector, compare);
13
14
  }
14
15
  function useRelationshipsBrowser() {
15
16
  const actor = useRelationshipsBrowserActor();
@@ -36,16 +36,17 @@ function ProjectsOverview({ view, onNavigateToProject, fitViewPadding = {
36
36
  };
37
37
  }, [actorRef]);
38
38
  const bounds = view.bounds;
39
+ const initialRef = useRef({
40
+ initialNodes: [],
41
+ initialEdges: [],
42
+ initialWidth: bounds.width,
43
+ initialHeight: bounds.height,
44
+ fitView: false
45
+ });
39
46
  return /* @__PURE__ */ jsx(ProjectsOverviewActorContextProvider, {
40
47
  value: actorRef,
41
48
  children: /* @__PURE__ */ jsxs(ReactFlowProvider, {
42
- ...useRef({
43
- initialNodes: [],
44
- initialEdges: [],
45
- initialWidth: bounds.width,
46
- initialHeight: bounds.height,
47
- fitView: false
48
- }).current,
49
+ ...initialRef.current,
49
50
  children: [/* @__PURE__ */ jsx(LayoutGroup, {
50
51
  id: actorRef.sessionId,
51
52
  inherit: false,
@@ -5,7 +5,8 @@ import { shallowEqual } from "fast-equals";
5
5
  import { useSelector } from "@xstate/react";
6
6
  //#region src/projects-overview/hooks.ts
7
7
  function useProjectsOverviewState(selector, compare = shallowEqual) {
8
- return useSelector(useProjectsOverviewActor(), selector, compare);
8
+ const actor = useProjectsOverviewActor();
9
+ return useSelector(actor, selector, compare);
9
10
  }
10
11
  function useProjectsOverviewXYStoreApi() {
11
12
  return useStoreApi();
@@ -25,14 +25,16 @@ var useFoundViews = () => {
25
25
  const search = useNormalizedSearch();
26
26
  return useMemo(() => {
27
27
  let views = [...likec4model.views()];
28
- if (search) if (search.startsWith("kind:")) views = [];
29
- else {
30
- const searchTag = search.startsWith("#") ? search.slice(1) : null;
31
- views = views.filter((view) => {
32
- if (searchTag) return view.tags.some((tag) => tag.toLocaleLowerCase().includes(searchTag));
33
- const desc = preferSummary(view.$view)?.md || " ";
34
- return `${view.id} ${view.title} ${desc}`.toLocaleLowerCase().includes(search);
35
- });
28
+ if (search) {
29
+ if (search.startsWith("kind:")) views = [];
30
+ else {
31
+ const searchTag = search.startsWith("#") ? search.slice(1) : null;
32
+ views = views.filter((view) => {
33
+ if (searchTag) return view.tags.some((tag) => tag.toLocaleLowerCase().includes(searchTag));
34
+ const desc = preferSummary(view.$view)?.md || " ";
35
+ return `${view.id} ${view.title} ${desc}`.toLocaleLowerCase().includes(search);
36
+ });
37
+ }
36
38
  }
37
39
  return [
38
40
  views,
@@ -3,7 +3,8 @@ import { useSearchContext } from "./SearchContext.js";
3
3
  import { useCallback, useDeferredValue } from "react";
4
4
  //#region src/search/hooks.ts
5
5
  function useNormalizedSearch() {
6
- return useDeferredValue(useSearchContext().normalizedSearch);
6
+ const ctx = useSearchContext();
7
+ return useDeferredValue(ctx.normalizedSearch);
7
8
  }
8
9
  function useUpdateSearch() {
9
10
  const { setSearchValue } = useSearchContext();
@@ -78,8 +78,9 @@ function ShadowRoot({ children, theme, injectFontCss = true, styleNonce, colorSc
78
78
  }
79
79
  return "";
80
80
  });
81
+ const nonce = getStyleNonce();
81
82
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(MemoizedStyle, {
82
- nonce: getStyleNonce(),
83
+ nonce,
83
84
  cssstyle
84
85
  }), /* @__PURE__ */ jsx(ShadowRootHost, {
85
86
  ...props,
@@ -175,7 +176,8 @@ function createShadowRootStylesheets(csstext) {
175
176
  }
176
177
  var getComputedColorScheme = () => {
177
178
  try {
178
- const colorScheme = first((window.getComputedStyle(document.documentElement).colorScheme ?? "").split(" "));
179
+ const htmlScheme = window.getComputedStyle(document.documentElement).colorScheme ?? "";
180
+ const colorScheme = first(htmlScheme.split(" "));
179
181
  if (colorScheme === "light" || colorScheme === "dark") return colorScheme;
180
182
  } catch {}
181
183
  return null;