@likec4/diagram 1.39.4 → 1.40.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 (123) hide show
  1. package/bundle/{chunk-CW_KClZe.js → chunk-CDr-4Ymp.js} +936 -903
  2. package/bundle/custom.js +61 -60
  3. package/bundle/index.js +2667 -539
  4. package/dist/LikeC4Diagram.d.ts +1 -1
  5. package/dist/LikeC4Diagram.js +7 -4
  6. package/dist/LikeC4Diagram.props.d.ts +6 -1
  7. package/dist/base/const.d.ts +9 -0
  8. package/dist/base/const.js +10 -1
  9. package/dist/base/index.d.ts +1 -0
  10. package/dist/base/primitives/edge/EdgeLabel.js +2 -1
  11. package/dist/base/primitives/edge/EdgeLabelContainer.js +10 -4
  12. package/dist/base/primitives/edge/EdgePath.js +17 -8
  13. package/dist/base/primitives/edge/edge.css.d.ts +0 -1
  14. package/dist/base/primitives/edge/edge.css.js +6 -14
  15. package/dist/base/primitives/element/ElementActionButtons.js +1 -3
  16. package/dist/base/primitives/element/ElementNodeContainer.d.ts +0 -6
  17. package/dist/base/primitives/element/ElementNodeContainer.js +3 -26
  18. package/dist/base/primitives/element/ElementTitle.js +2 -2
  19. package/dist/base/types.d.ts +3 -3
  20. package/dist/bundle/LikeC4View.js +4 -12
  21. package/dist/bundle/LikeC4View.props.d.ts +12 -3
  22. package/dist/bundle/custom.js +1 -1
  23. package/dist/custom/customNodes.d.ts +6 -0
  24. package/dist/custom/customNodes.js +2 -1
  25. package/dist/custom/index.js +1 -1
  26. package/dist/hooks/useDiagram.d.ts +5 -1
  27. package/dist/hooks/useDiagram.js +3 -0
  28. package/dist/hooks/useXYFlow.d.ts +4 -439
  29. package/dist/likec4diagram/DiagramUI.js +1 -1
  30. package/dist/likec4diagram/DiagramXYFlow.js +8 -4
  31. package/dist/likec4diagram/convert-to-xyflow.d.ts +14 -0
  32. package/dist/likec4diagram/convert-to-xyflow.js +29 -0
  33. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +3 -3
  34. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +0 -1
  35. package/dist/likec4diagram/custom/edges/SequenceStepEdge.d.ts +3 -0
  36. package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +71 -0
  37. package/dist/likec4diagram/custom/index.js +7 -2
  38. package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -1
  39. package/dist/likec4diagram/custom/nodes/SequenceActorNode.d.ts +4 -0
  40. package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +157 -0
  41. package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
  42. package/dist/likec4diagram/custom/nodes/nodes.d.ts +1 -2
  43. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +31 -27
  44. package/dist/likec4diagram/types.d.ts +41 -7
  45. package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +11 -0
  46. package/dist/likec4diagram/{useViewToNodesEdges.js → xyflow-diagram/diagram-view.js} +4 -13
  47. package/dist/likec4diagram/xyflow-sequence/_types.d.ts +41 -0
  48. package/dist/likec4diagram/xyflow-sequence/const.d.ts +17 -0
  49. package/dist/likec4diagram/xyflow-sequence/const.js +16 -0
  50. package/dist/likec4diagram/xyflow-sequence/layouter.d.ts +46 -0
  51. package/dist/likec4diagram/xyflow-sequence/layouter.js +408 -0
  52. package/dist/likec4diagram/xyflow-sequence/sequence-view.d.ts +7 -0
  53. package/dist/likec4diagram/xyflow-sequence/sequence-view.js +273 -0
  54. package/dist/likec4diagram/xyflow-sequence/utils.d.ts +14 -0
  55. package/dist/likec4diagram/xyflow-sequence/utils.js +92 -0
  56. package/dist/navigationpanel/NavigationPanelControls.js +2 -2
  57. package/dist/navigationpanel/controls/ViewDetailsCard.js +5 -2
  58. package/dist/navigationpanel/dropdown/ProjectsMenu.js +53 -44
  59. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.d.ts +1 -2
  60. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +10 -41
  61. package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +292 -0
  62. package/dist/navigationpanel/walkthrough/DynamicViewControls.js +119 -0
  63. package/dist/navigationpanel/walkthrough/index.d.ts +2 -1
  64. package/dist/overlays/relationship-details/RelationshipDetails.js +4 -1
  65. package/dist/state/DiagramActorProvider.d.ts +3 -2
  66. package/dist/state/DiagramActorProvider.js +19 -11
  67. package/dist/state/assign.js +11 -4
  68. package/dist/state/diagram-machine.d.ts +224 -194
  69. package/dist/state/diagram-machine.js +170 -63
  70. package/dist/state/utils.d.ts +7 -1
  71. package/dist/state/utils.js +67 -7
  72. package/dist/styles-min.css +1 -1
  73. package/dist/styles.css +1 -1
  74. package/dist/styles.css2.js +1 -1
  75. package/package.json +8 -7
  76. package/panda.buildinfo.json +30 -9
  77. package/src/LikeC4Diagram.props.ts +14 -1
  78. package/src/LikeC4Diagram.tsx +7 -4
  79. package/src/base/const.ts +12 -0
  80. package/src/base/index.ts +2 -0
  81. package/src/base/primitives/edge/EdgeLabel.tsx +23 -19
  82. package/src/base/primitives/edge/EdgeLabelContainer.tsx +12 -7
  83. package/src/base/primitives/edge/EdgePath.tsx +25 -14
  84. package/src/base/primitives/edge/edge.css.ts +5 -14
  85. package/src/base/primitives/element/ElementActionButtons.tsx +1 -3
  86. package/src/base/primitives/element/ElementNodeContainer.tsx +3 -30
  87. package/src/base/primitives/element/ElementTitle.tsx +2 -3
  88. package/src/base/types.ts +7 -5
  89. package/src/bundle/LikeC4View.props.ts +14 -3
  90. package/src/bundle/LikeC4View.tsx +4 -14
  91. package/src/bundle/ReactLikeC4.tsx +1 -2
  92. package/src/custom/customNodes.ts +7 -0
  93. package/src/hooks/useDiagram.ts +10 -0
  94. package/src/likec4diagram/DiagramUI.tsx +1 -1
  95. package/src/likec4diagram/DiagramXYFlow.tsx +10 -5
  96. package/src/likec4diagram/convert-to-xyflow.ts +45 -0
  97. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +0 -1
  98. package/src/likec4diagram/custom/edges/SequenceStepEdge.tsx +65 -0
  99. package/src/likec4diagram/custom/index.ts +7 -1
  100. package/src/likec4diagram/custom/nodes/ElementActions.tsx +4 -2
  101. package/src/likec4diagram/custom/nodes/SequenceActorNode.tsx +175 -0
  102. package/src/likec4diagram/custom/nodes/index.ts +1 -0
  103. package/src/likec4diagram/custom/nodes/nodes.tsx +1 -1
  104. package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +36 -30
  105. package/src/likec4diagram/types.ts +96 -13
  106. package/src/likec4diagram/{useViewToNodesEdges.ts → xyflow-diagram/diagram-view.ts} +7 -28
  107. package/src/likec4diagram/xyflow-sequence/_types.ts +45 -0
  108. package/src/likec4diagram/xyflow-sequence/const.ts +37 -0
  109. package/src/likec4diagram/xyflow-sequence/layouter.ts +567 -0
  110. package/src/likec4diagram/xyflow-sequence/sequence-view.ts +337 -0
  111. package/src/likec4diagram/xyflow-sequence/utils.ts +112 -0
  112. package/src/navigationpanel/NavigationPanelControls.tsx +2 -2
  113. package/src/navigationpanel/controls/ViewDetailsCard.tsx +5 -2
  114. package/src/navigationpanel/dropdown/ProjectsMenu.tsx +5 -1
  115. package/src/navigationpanel/walkthrough/ActiveWalkthroughControls.tsx +5 -40
  116. package/src/navigationpanel/walkthrough/DynamicViewControls.tsx +125 -0
  117. package/src/navigationpanel/walkthrough/index.tsx +2 -1
  118. package/src/overlays/relationship-details/RelationshipDetails.tsx +5 -2
  119. package/src/state/DiagramActorProvider.tsx +21 -10
  120. package/src/state/assign.ts +18 -5
  121. package/src/state/diagram-machine.ts +207 -75
  122. package/src/state/utils.ts +81 -7
  123. package/dist/likec4diagram/useViewToNodesEdges.d.ts +0 -12
@@ -2,4 +2,4 @@ import { Any } from '@likec4/core/types';
2
2
  import { PropsWithChildren } from 'react';
3
3
  import { LikeC4DiagramEventHandlers, LikeC4DiagramProperties } from './LikeC4Diagram.props';
4
4
  export type LikeC4DiagramProps<A extends Any = Any> = PropsWithChildren<LikeC4DiagramProperties<A> & LikeC4DiagramEventHandlers<A>>;
5
- export declare function LikeC4Diagram<A extends Any = Any>({ onCanvasClick, onCanvasContextMenu, onCanvasDblClick, onEdgeClick, onChange, onEdgeContextMenu, onNavigateTo, onNodeClick, onNodeContextMenu, onOpenSource, onBurgerMenuClick, view, className, fitView, fitViewPadding, readonly, pannable, zoomable, background, enableElementTags, enableFocusMode, enableElementDetails, enableRelationshipDetails, enableRelationshipBrowser, nodesDraggable, nodesSelectable, controls, showDiagramTitle, showNotations, showNavigationButtons, enableDynamicViewWalkthrough, enableSearch, initialWidth, initialHeight, experimentalEdgeEditing, reduceGraphics, renderIcon, renderControls, where, reactFlowProps, renderNodes, children, }: LikeC4DiagramProps<A>): import("react/jsx-runtime").JSX.Element;
5
+ export declare function LikeC4Diagram<A extends Any = Any>({ onCanvasClick, onCanvasContextMenu, onCanvasDblClick, onEdgeClick, onChange, onEdgeContextMenu, onNavigateTo, onNodeClick, onNodeContextMenu, onOpenSource, onBurgerMenuClick, view, className, readonly, controls, fitView, fitViewPadding, pannable, zoomable, background, enableElementTags, enableFocusMode, enableElementDetails, enableRelationshipDetails, enableRelationshipBrowser, nodesDraggable, nodesSelectable, showDiagramTitle, showNotations, showNavigationButtons, enableDynamicViewWalkthrough, dynamicViewVariant, enableSearch, initialWidth, initialHeight, experimentalEdgeEditing, reduceGraphics, renderIcon, renderControls, where, reactFlowProps, renderNodes, children, }: LikeC4DiagramProps<A>): import("react/jsx-runtime").JSX.Element;
@@ -13,6 +13,7 @@ import { IconRendererProvider } from './context/IconRenderer.js';
13
13
  import { DiagramFeatures } from './context/DiagramFeatures.js';
14
14
  import { DiagramEventHandlers } from './context/DiagramEventHandlers.js';
15
15
  import { RootContainer } from './context/RootContainer.js';
16
+ import { FitViewPaddings } from './base/const.js';
16
17
 
17
18
  function LikeC4Diagram({
18
19
  onCanvasClick,
@@ -28,9 +29,10 @@ function LikeC4Diagram({
28
29
  onBurgerMenuClick,
29
30
  view,
30
31
  className,
31
- fitView = true,
32
- fitViewPadding = "8px",
33
32
  readonly = true,
33
+ controls = !readonly,
34
+ fitView = true,
35
+ fitViewPadding = controls === "next" ? FitViewPaddings.withControls : FitViewPaddings.default,
34
36
  pannable = true,
35
37
  zoomable = true,
36
38
  background = "dots",
@@ -41,11 +43,11 @@ function LikeC4Diagram({
41
43
  enableRelationshipBrowser = enableRelationshipDetails,
42
44
  nodesDraggable = !readonly,
43
45
  nodesSelectable = !readonly || enableFocusMode || !!onNavigateTo || !!onNodeClick,
44
- controls = !readonly,
45
46
  showDiagramTitle = true,
46
47
  showNotations = true,
47
48
  showNavigationButtons = !!onNavigateTo,
48
49
  enableDynamicViewWalkthrough = false,
50
+ dynamicViewVariant,
49
51
  enableSearch = true,
50
52
  initialWidth,
51
53
  initialHeight,
@@ -54,7 +56,7 @@ function LikeC4Diagram({
54
56
  renderIcon,
55
57
  renderControls,
56
58
  where,
57
- reactFlowProps = {},
59
+ reactFlowProps,
58
60
  renderNodes,
59
61
  children
60
62
  }) {
@@ -126,6 +128,7 @@ function LikeC4Diagram({
126
128
  fitViewPadding,
127
129
  nodesSelectable,
128
130
  where: where ?? null,
131
+ dynamicViewVariant,
129
132
  children: /* @__PURE__ */ jsx(ControlsCustomLayoutProvider, { value: renderControls ?? null, children: /* @__PURE__ */ jsx(
130
133
  LikeC4DiagramXYFlow,
131
134
  {
@@ -1,4 +1,4 @@
1
- import { DiagramEdge, DiagramNode, LayoutedView, ViewChange, WhereOperator } from '@likec4/core/types';
1
+ import { DiagramEdge, DiagramNode, DynamicViewDisplayVariant, LayoutedView, ViewChange, WhereOperator } from '@likec4/core/types';
2
2
  import { ReactFlowProps as XYFlowProps } from '@xyflow/react';
3
3
  import { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
4
4
  import { SetRequired } from 'type-fest';
@@ -183,6 +183,11 @@ export interface LikeC4DiagramProperties<A extends Any = Any> {
183
183
  * @default false
184
184
  */
185
185
  enableDynamicViewWalkthrough?: boolean | undefined;
186
+ /**
187
+ * Default dynamic view display variant
188
+ * @default 'diagram'
189
+ */
190
+ dynamicViewVariant?: DynamicViewDisplayVariant | undefined;
186
191
  /**
187
192
  * Display element tags in the bottom left corner
188
193
  * @default false
@@ -6,3 +6,12 @@ export declare const ZIndexes: {
6
6
  };
7
7
  export declare const MinZoom = 0.05;
8
8
  export declare const MaxZoom = 3;
9
+ export declare const FitViewPaddings: {
10
+ default: "16px";
11
+ withControls: {
12
+ top: "50px";
13
+ left: "16px";
14
+ right: "16px";
15
+ bottom: "16px";
16
+ };
17
+ };
@@ -7,5 +7,14 @@ const ZIndexes = {
7
7
  };
8
8
  const MinZoom = 0.05;
9
9
  const MaxZoom = 3;
10
+ const FitViewPaddings = {
11
+ default: "16px",
12
+ withControls: {
13
+ top: "50px",
14
+ left: "16px",
15
+ right: "16px",
16
+ bottom: "16px"
17
+ }
18
+ };
10
19
 
11
- export { MaxZoom, MinZoom, ZIndexes };
20
+ export { FitViewPaddings, MaxZoom, MinZoom, ZIndexes };
@@ -1,2 +1,3 @@
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 * from './const';
@@ -28,6 +28,7 @@ const EdgeLabel = forwardRef(({
28
28
  isStepEdge: stepNum !== null,
29
29
  cursor: selectable || stepNum !== null ? "pointer" : "default"
30
30
  });
31
+ const hasLabel = isTruthy(label) || isTruthy(technology);
31
32
  return /* @__PURE__ */ jsxs(
32
33
  m.div,
33
34
  {
@@ -40,7 +41,7 @@ const EdgeLabel = forwardRef(({
40
41
  ...rest,
41
42
  children: [
42
43
  stepNum !== null && /* @__PURE__ */ jsx(Box, { className: classes.stepNumber, children: stepNum }),
43
- /* @__PURE__ */ jsxs(Box, { className: classes.labelContents, children: [
44
+ hasLabel && /* @__PURE__ */ jsxs(Box, { className: classes.labelContents, children: [
44
45
  isTruthy(label) && /* @__PURE__ */ jsx(
45
46
  Box,
46
47
  {
@@ -1,8 +1,10 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { cx } from '@likec4/styles/css';
3
3
  import { EdgeLabelRenderer } from '@xyflow/react';
4
+ import { useCallback } from 'react';
4
5
  import { isNumber } from 'remeda';
5
6
  import { ZIndexes } from '../../const.js';
7
+ import { useXYStore } from '../../../hooks/useXYFlow.js';
6
8
 
7
9
  const toCssVarValue = (value) => {
8
10
  if (value === void 0) return void 0;
@@ -25,9 +27,13 @@ function EdgeLabelContainer({
25
27
  children,
26
28
  ...rest
27
29
  }) {
28
- let zIndex = ZIndexes.Edge;
30
+ let zIndex = useXYStore(
31
+ useCallback((state) => {
32
+ return state.edgeLookup.get(id)?.zIndex ?? ZIndexes.Edge;
33
+ }, [id])
34
+ );
29
35
  if (isHovered || isActive) {
30
- zIndex = ZIndexes.Element + 1;
36
+ zIndex += 100;
31
37
  }
32
38
  let labelX = labelXY?.x ?? labelBBox?.x, labelY = labelXY?.y ?? labelBBox?.y;
33
39
  if (labelX === void 0 || labelY === void 0) {
@@ -37,6 +43,7 @@ function EdgeLabelContainer({
37
43
  return /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsx(
38
44
  "div",
39
45
  {
46
+ ...rest,
40
47
  className: cx(
41
48
  "nodrag nopan",
42
49
  "likec4-edge-label-container",
@@ -57,11 +64,10 @@ function EdgeLabelContainer({
57
64
  ...style,
58
65
  transform: `translate(${toCssVarValue(labelX)}, ${toCssVarValue(labelY)}) ${translate || ""}`
59
66
  },
60
- ...rest,
61
67
  children
62
68
  },
63
69
  id
64
- ) }, id);
70
+ ) });
65
71
  }
66
72
 
67
73
  export { EdgeLabelContainer };
@@ -1,7 +1,7 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
2
  import { cx, css } from '@likec4/styles/css';
3
3
  import { forwardRef } from 'react';
4
- import { hideOnReducedGraphics, markerContext, edgePathBg, cssEdgePath } from './edge.css.js';
4
+ import { markerContext, edgePathBg, cssEdgePath } from './edge.css.js';
5
5
  import { arrowTypeToMarker, EdgeMarkers } from './EdgeMarkers.js';
6
6
 
7
7
  const EdgePath = forwardRef(({
@@ -13,6 +13,7 @@ const EdgePath = forwardRef(({
13
13
  tail,
14
14
  head
15
15
  },
16
+ selectable = true,
16
17
  style,
17
18
  interactionWidth
18
19
  },
@@ -36,19 +37,22 @@ const EdgePath = forwardRef(({
36
37
  strokeDasharray = "8,10";
37
38
  }
38
39
  return /* @__PURE__ */ jsxs(Fragment, { children: [
39
- /* @__PURE__ */ jsx(
40
+ selectable && /* @__PURE__ */ jsx(
40
41
  "path",
41
42
  {
42
43
  className: cx(
43
44
  "react-flow__edge-interaction",
44
- hideOnReducedGraphics,
45
+ "hide-on-reduced-graphics",
45
46
  css({
46
- fill: "[none]",
47
- strokeOpacity: 0
47
+ fill: "none"
48
48
  })
49
49
  ),
50
50
  d: svgPath,
51
- strokeWidth: interactionWidth ?? 10
51
+ style: {
52
+ strokeWidth: interactionWidth ?? 10,
53
+ stroke: "currentcolor",
54
+ strokeOpacity: 0
55
+ }
52
56
  }
53
57
  ),
54
58
  /* @__PURE__ */ jsxs("g", { className: markerContext, onPointerDown: onEdgePointerDown, children: [
@@ -59,7 +63,11 @@ const EdgePath = forwardRef(({
59
63
  /* @__PURE__ */ jsx(
60
64
  "path",
61
65
  {
62
- className: cx("react-flow__edge-path", edgePathBg),
66
+ className: cx(
67
+ "react-flow__edge-path",
68
+ "hide-on-reduced-graphics",
69
+ edgePathBg
70
+ ),
63
71
  d: svgPath,
64
72
  style,
65
73
  strokeLinecap: "round"
@@ -71,7 +79,7 @@ const EdgePath = forwardRef(({
71
79
  ref: svgPathRef,
72
80
  className: cx(
73
81
  "react-flow__edge-path",
74
- "react-flow__edge-interaction",
82
+ selectable && "react-flow__edge-interaction",
75
83
  cssEdgePath
76
84
  ),
77
85
  d: svgPath,
@@ -86,5 +94,6 @@ const EdgePath = forwardRef(({
86
94
  ] })
87
95
  ] });
88
96
  });
97
+ EdgePath.displayName = "EdgePath";
89
98
 
90
99
  export { EdgePath };
@@ -1,5 +1,4 @@
1
1
  export declare const edgeContainer: string;
2
- export declare const hideOnReducedGraphics: string;
3
2
  export declare const edgePathBg: string;
4
3
  export declare const markerContext: string;
5
4
  export declare const cssEdgePath: string;
@@ -6,17 +6,9 @@ const edgeContainer = css({
6
6
  transition: "none"
7
7
  }
8
8
  });
9
- const _hideOnReducedGraphics = css.raw({
10
- _reduceGraphicsOnPan: {
11
- display: "none"
12
- },
13
- _smallZoom: {
14
- display: "none"
15
- }
16
- });
17
- const hideOnReducedGraphics = css(_hideOnReducedGraphics);
18
- const edgePathBg = css(_hideOnReducedGraphics, {
19
- fill: "[none]",
9
+ const edgePathBg = css({
10
+ pointerEvents: "none",
11
+ fill: "none",
20
12
  strokeWidth: "calc(var(--xy-edge-stroke-width) + 2)",
21
13
  strokeOpacity: 0.08,
22
14
  _noReduceGraphics: {
@@ -42,8 +34,8 @@ const markerContext = css({
42
34
  stroke: "[var(--xy-edge-stroke)]"
43
35
  });
44
36
  const cssEdgePath = css({
45
- fill: "[none!]",
46
- strokeDashoffset: 10,
37
+ fill: "none",
38
+ strokeDashoffset: 0,
47
39
  _noReduceGraphics: {
48
40
  animationStyle: "xyedgeAnimated",
49
41
  animationPlayState: "paused",
@@ -76,4 +68,4 @@ const cssEdgePath = css({
76
68
  }
77
69
  });
78
70
 
79
- export { cssEdgePath, edgeContainer, edgePathBg, hideOnReducedGraphics, markerContext };
71
+ export { cssEdgePath, edgeContainer, edgePathBg, markerContext };
@@ -5,7 +5,6 @@ import { actionBtn } from '@likec4/styles/recipes';
5
5
  import { ActionIcon } from '@mantine/core';
6
6
  import { useId } from '@mantine/hooks';
7
7
  import * as m from 'motion/react-m';
8
- import { useIsZoomTooSmall } from '../../../hooks/useXYFlow.js';
9
8
  import { stopPropagation } from '../../../utils/xyflow.js';
10
9
 
11
10
  const container = css({
@@ -37,8 +36,7 @@ function ElementActionButtons({
37
36
  buttons
38
37
  }) {
39
38
  const id = useId();
40
- const zoomTooSmall = useIsZoomTooSmall();
41
- if (!buttons.length || zoomTooSmall) {
39
+ if (!buttons.length) {
42
40
  return null;
43
41
  }
44
42
  return /* @__PURE__ */ jsx(Box, { className: container, children: /* @__PURE__ */ jsx(
@@ -2,7 +2,6 @@ import { Color, ElementShape, ElementStyle } from '@likec4/core/types';
2
2
  import { MotionNodeLayoutOptions } from 'motion/react';
3
3
  import { CSSProperties, ReactNode, ForwardRefExoticComponent, RefAttributes } from 'react';
4
4
  import { NodeProps } from '../../types';
5
- import { ShapeSize, SpacingSize, TextSize } from '@likec4/core';
6
5
  export type RequiredData = {
7
6
  color: Color;
8
7
  shape: ElementShape;
@@ -15,11 +14,6 @@ export type ElementNodeContainerProps = {
15
14
  style?: CSSProperties | undefined;
16
15
  [key: `data-${string}`]: string | undefined;
17
16
  } & MotionNodeLayoutOptions;
18
- export declare function nodeSizes({ size, padding, textSize, }: ElementStyle): {
19
- size: ShapeSize;
20
- padding: SpacingSize;
21
- textSize: TextSize;
22
- };
23
17
  /**
24
18
  * Top-level primitive to compose leaf nodes renderers.
25
19
  * This container provides the state via data-* attributes
@@ -1,33 +1,10 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { DefaultShapeSize, DefaultTextSize, DefaultPaddingSize } from '@likec4/core/types';
2
+ import { ensureSizes } from '@likec4/core/types';
3
3
  import { cx } from '@likec4/styles/css';
4
4
  import * as m from 'motion/react-m';
5
5
  import { forwardRef } from 'react';
6
6
  import { container } from './ElementNodeContainer.css.js';
7
7
 
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 ??= DefaultShapeSize;
23
- textSize ??= DefaultTextSize;
24
- padding ??= DefaultPaddingSize;
25
- return {
26
- size,
27
- padding,
28
- textSize
29
- };
30
- }
31
8
  const ElementNodeContainer = forwardRef(({
32
9
  nodeProps: {
33
10
  selected = false,
@@ -56,7 +33,7 @@ const ElementNodeContainer = forwardRef(({
56
33
  size,
57
34
  padding,
58
35
  textSize
59
- } = nodeSizes(data.style ?? {});
36
+ } = ensureSizes(data.style ?? {});
60
37
  return /* @__PURE__ */ jsx(
61
38
  m.div,
62
39
  {
@@ -93,4 +70,4 @@ const ElementNodeContainer = forwardRef(({
93
70
  });
94
71
  ElementNodeContainer.displayName = "ElementNodeContainer";
95
72
 
96
- export { ElementNodeContainer, nodeSizes };
73
+ export { ElementNodeContainer };
@@ -1,4 +1,5 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { ensureSizes } from '@likec4/core/types';
2
3
  import { cx } from '@likec4/styles/css';
3
4
  import { Box } from '@likec4/styles/jsx';
4
5
  import { elementNodeIcon, elementNodeData } from '@likec4/styles/recipes';
@@ -6,7 +7,6 @@ import { Text } from '@mantine/core';
6
7
  import { isTruthy, isEmpty, isNumber } from 'remeda';
7
8
  import { IconRenderer } from '../../../context/IconRenderer.js';
8
9
  import { MarkdownBlock } from '../MarkdownBlock.js';
9
- import { nodeSizes } from './ElementNodeContainer.js';
10
10
 
11
11
  function ElementTitle({ id, data, iconSize }) {
12
12
  const elementIcon = IconRenderer({
@@ -22,7 +22,7 @@ function ElementTitle({ id, data, iconSize }) {
22
22
  hasDescription: !!data.description?.nonEmpty,
23
23
  hasTechnology: !isEmpty(data.technology ?? "")
24
24
  });
25
- const size = nodeSizes(data.style).size;
25
+ const { size } = ensureSizes(data.style);
26
26
  const isSm = size === "sm";
27
27
  const isSmOrXs = isSm || size === "xs";
28
28
  return /* @__PURE__ */ jsxs(
@@ -2,8 +2,8 @@ import { OptionalKeysOf, SetRequired, Simplify } from 'type-fest';
2
2
  import type * as RF from '@xyflow/react';
3
3
  type RFNode<NodeData extends Record<string, unknown> = Record<string, unknown>, NodeType extends string | undefined = string | undefined> = RF.Node<NodeData, NodeType>;
4
4
  type RFEdge<EdgeData extends Record<string, unknown> = Record<string, unknown>, EdgeType extends string | undefined = string | undefined> = RF.Edge<EdgeData, EdgeType>;
5
- type ReactFlowNodeProps<NodeData extends Record<string, unknown> = Record<string, unknown>, NodeType extends string | undefined = string | undefined> = RF.NodeProps<RFNode<NodeData, NodeType>>;
6
- type ReactFlowEdgeProps<EdgeData extends Record<string, unknown> = Record<string, unknown>, EdgeType extends string | undefined = string | undefined> = RF.EdgeProps<RFEdge<EdgeData, EdgeType>>;
5
+ type ReactFlowNodeProps<NodeData extends Record<string, unknown> = Record<string, unknown>, NodeType extends string | undefined = string | undefined> = RF.NodeProps<RF.Node<NodeData, NodeType>>;
6
+ type ReactFlowEdgeProps<EdgeData extends Record<string, unknown> = Record<string, unknown>, EdgeType extends string | undefined = string | undefined> = RF.EdgeProps<RF.Edge<EdgeData, EdgeType>>;
7
7
  export declare namespace Base {
8
8
  export type Dimmed = 'immediate' | boolean;
9
9
  export type NodeData = {
@@ -87,7 +87,7 @@ export type NodeProps<T extends Record<string, unknown> = {}, NodeType extends s
87
87
  /**
88
88
  * ReactFlow Custom Edge properties with BaseEdgeData at least
89
89
  */
90
- export type EdgeProps<T extends Record<string, unknown> = {}, EdgeType extends string = string> = SetRequired<Simplify<ReactFlowEdgeProps<Base.EdgeData & T, EdgeType>>, 'data'>;
90
+ export type EdgeProps<T extends Record<string, unknown> = {}, EdgeType extends string = string> = Simplify<SetRequired<ReactFlowEdgeProps<Base.EdgeData & T, EdgeType>, 'data'>>;
91
91
  export type ReactFlowNode<Data extends Record<string, unknown>, NodeType extends string> = SetRequired<RFNode<Data, NodeType>, 'type' | 'initialWidth' | 'initialHeight'>;
92
92
  export type ReactFlowEdge<Data extends Record<string, unknown>, EdgeType extends string> = SetRequired<RFEdge<Data, EdgeType>, 'type' | 'data'>;
93
93
  export {};
@@ -4,6 +4,7 @@ import { Box, ActionIcon } from '@mantine/core';
4
4
  import { useCallbackRef, shallowEqual } from '@mantine/hooks';
5
5
  import { memo, useState } from 'react';
6
6
  import { isBoolean } from 'remeda';
7
+ import { FitViewPaddings } from '../base/const.js';
7
8
  import { FramerMotionConfig } from '../context/FramerMotionConfig.js';
8
9
  import { LikeC4Diagram } from '../LikeC4Diagram.js';
9
10
  import { useLikeC4Model } from '../likec4model/useLikeC4Model.js';
@@ -31,12 +32,6 @@ function LikeC4View({
31
32
  }
32
33
  return /* @__PURE__ */ jsx(LikeC4ViewInner, { view: view.$view, ...props });
33
34
  }
34
- const DEFAULT_BROWSER_PADDING = {
35
- top: "50px",
36
- bottom: "16px",
37
- left: "16px",
38
- right: "16px"
39
- };
40
35
  const LikeC4ViewInner = memo(({
41
36
  view,
42
37
  className,
@@ -46,8 +41,6 @@ const LikeC4ViewInner = memo(({
46
41
  colorScheme: explicitColorScheme,
47
42
  injectFontCss = true,
48
43
  controls = false,
49
- fitView = true,
50
- fitViewPadding = "16px",
51
44
  background = "transparent",
52
45
  browser = true,
53
46
  showDiagramTitle = false,
@@ -117,8 +110,8 @@ const LikeC4ViewInner = memo(({
117
110
  pannable,
118
111
  zoomable,
119
112
  background,
120
- fitView,
121
- fitViewPadding,
113
+ fitView: true,
114
+ fitViewPadding: FitViewPaddings.default,
122
115
  showDiagramTitle,
123
116
  showNotations: showNotations && hasNotations,
124
117
  enableDynamicViewWalkthrough,
@@ -138,7 +131,6 @@ const LikeC4ViewInner = memo(({
138
131
  ),
139
132
  enableSearch: false,
140
133
  ...isBrowserEnabled && {
141
- onNavigateTo,
142
134
  onCanvasClick: onNavigateToThisView,
143
135
  onNodeClick: onNavigateToThisView
144
136
  },
@@ -164,8 +156,8 @@ const LikeC4ViewInner = memo(({
164
156
  controls: "next",
165
157
  readonly: true,
166
158
  fitView: true,
167
- fitViewPadding: DEFAULT_BROWSER_PADDING,
168
159
  ...props,
160
+ fitViewPadding: FitViewPaddings.withControls,
169
161
  ...browserProps,
170
162
  showNotations: (browserProps.showNotations ?? true) && (browserView.notation?.nodes.length ?? 0) > 0,
171
163
  renderNodes
@@ -1,4 +1,3 @@
1
- import { WhereOperator } from '@likec4/core/types';
2
1
  import { CSSProperties } from 'react';
3
2
  import { CustomNodes, ElementIconRenderer, OverrideReactFlowProps, PaddingWithUnit, ViewPadding } from '../LikeC4Diagram.props';
4
3
  import type * as t from '@likec4/core/types';
@@ -87,9 +86,14 @@ export interface LikeC4ViewProps<A extends t.aux.Any = t.aux.UnknownLayouted> {
87
86
  enableFocusMode?: boolean | undefined;
88
87
  /**
89
88
  * If Walkthrough for dynamic views should be enabled
90
- * @default enableFocusMode
89
+ * @default false
91
90
  */
92
91
  enableDynamicViewWalkthrough?: boolean | undefined;
92
+ /**
93
+ * Default dynamic view display variant
94
+ * @default 'diagram'
95
+ */
96
+ dynamicViewVariant?: t.DynamicViewDisplayVariant | undefined;
93
97
  /**
94
98
  * Enable popup with element details
95
99
  * @default false
@@ -117,7 +121,7 @@ export interface LikeC4ViewProps<A extends t.aux.Any = t.aux.UnknownLayouted> {
117
121
  * @default 'auto' - will be set to true if view is pannable and has more than 3000 * 2000 pixels
118
122
  */
119
123
  reduceGraphics?: 'auto' | boolean | undefined;
120
- where?: WhereOperator<A> | undefined;
124
+ where?: t.WhereOperator<A> | undefined;
121
125
  /**
122
126
  * Override some react flow props
123
127
  */
@@ -185,6 +189,11 @@ export interface LikeC4BrowserProps {
185
189
  * @default true
186
190
  */
187
191
  enableDynamicViewWalkthrough?: boolean | undefined;
192
+ /**
193
+ * Default dynamic view display variant
194
+ * @default 'diagram'
195
+ */
196
+ dynamicViewVariant?: t.DynamicViewDisplayVariant | undefined;
188
197
  /**
189
198
  * Enable popup with element details
190
199
  * @default true
@@ -1,4 +1,4 @@
1
- export { compoundDeploymentNode, compoundElementNode, deploymentNode, elementNode, viewGroupNode } from '../custom/customNodes.js';
1
+ export { compoundDeploymentNode, compoundElementNode, deploymentNode, elementNode, sequenceActorNode, viewGroupNode } from '../custom/customNodes.js';
2
2
  export { CompoundActionButton } from '../base/primitives/compound/CompoundActionButton.js';
3
3
  export { CompoundDetailsButton } from '../base/primitives/compound/CompoundDetailsButton.js';
4
4
  export { CompoundNodeContainer } from '../base/primitives/compound/CompoundNodeContainer.js';
@@ -230,11 +230,17 @@ export type CustomViewGroupNodeProps = {
230
230
  nodeProps: NodeProps<Types.ViewGroupNodeData, 'view-group'>;
231
231
  nodeModel: NodeModel.IsGroup<Any>;
232
232
  };
233
+ export declare const sequenceActorNode: CustomNodeComponent<CustomSequenceActorNodeProps>;
234
+ export type CustomSequenceActorNodeProps = {
235
+ nodeProps: NodeProps<Types.SequenceActorNodeData, 'seq-actor'>;
236
+ nodeModel: NodeModel.WithElement<Any>;
237
+ };
233
238
  export interface CustomNodes {
234
239
  element?: FunctionComponent<NodeProps<Types.ElementNodeData, 'element'>>;
235
240
  deployment?: FunctionComponent<NodeProps<Types.DeploymentElementNodeData, 'deployment'>>;
236
241
  compoundElement?: FunctionComponent<NodeProps<Types.CompoundElementNodeData, 'compound-element'>>;
237
242
  compoundDeployment?: FunctionComponent<NodeProps<Types.CompoundDeploymentNodeData, 'compound-deployment'>>;
238
243
  viewGroup?: FunctionComponent<NodeProps<Types.ViewGroupNodeData, 'view-group'>>;
244
+ sequenceActor?: FunctionComponent<NodeProps<Types.SequenceActorNodeData, 'seq-actor'>>;
239
245
  }
240
246
  export {};
@@ -26,5 +26,6 @@ const deploymentNode = customDiagramNode;
26
26
  const compoundElementNode = customDiagramNode;
27
27
  const compoundDeploymentNode = customDiagramNode;
28
28
  const viewGroupNode = customDiagramNode;
29
+ const sequenceActorNode = customDiagramNode;
29
30
 
30
- export { compoundDeploymentNode, compoundElementNode, deploymentNode, elementNode, viewGroupNode };
31
+ export { compoundDeploymentNode, compoundElementNode, deploymentNode, elementNode, sequenceActorNode, viewGroupNode };
@@ -1,4 +1,4 @@
1
- export { compoundDeploymentNode, compoundElementNode, deploymentNode, elementNode, viewGroupNode } from './customNodes.js';
1
+ export { compoundDeploymentNode, compoundElementNode, deploymentNode, elementNode, sequenceActorNode, viewGroupNode } from './customNodes.js';
2
2
  export { CompoundActionButton } from '../base/primitives/compound/CompoundActionButton.js';
3
3
  export { CompoundDetailsButton } from '../base/primitives/compound/CompoundDetailsButton.js';
4
4
  export { CompoundNodeContainer } from '../base/primitives/compound/CompoundNodeContainer.js';
@@ -1,4 +1,4 @@
1
- import { aux, DiagramEdge, DiagramNode, DiagramView, NodeId, NodeNotation as ElementNotation, scalar } from '@likec4/core/types';
1
+ import { aux, DiagramEdge, DiagramNode, DiagramView, DynamicViewDisplayVariant, NodeId, NodeNotation as ElementNotation, scalar } from '@likec4/core/types';
2
2
  import { DependencyList } from 'react';
3
3
  import { PartialDeep } from 'type-fest';
4
4
  import { FeatureName } from '../context/DiagramFeatures';
@@ -92,6 +92,10 @@ export interface DiagramApi {
92
92
  highlightNotation(notation: ElementNotation, kind?: string): void;
93
93
  unhighlightNotation(): void;
94
94
  openSearch(searchValue?: string): void;
95
+ /**
96
+ * Switch dynamic view display variant
97
+ */
98
+ switchDynamicViewVariant(variant: DynamicViewDisplayVariant): void;
95
99
  }
96
100
  /**
97
101
  * Diagram API
@@ -118,6 +118,9 @@ function useDiagram() {
118
118
  },
119
119
  openSearch: (searchValue) => {
120
120
  actor.send({ type: "open.search", ...searchValue && { search: searchValue } });
121
+ },
122
+ switchDynamicViewVariant: (variant) => {
123
+ actor.send({ type: "switch.dynamicViewVariant", variant });
121
124
  }
122
125
  }), [actor]);
123
126
  }