@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/diagram",
3
- "version": "1.39.4",
3
+ "version": "1.40.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -69,6 +69,7 @@
69
69
  "dependencies": {
70
70
  "@dagrejs/dagre": "1.1.5",
71
71
  "@floating-ui/dom": "^1.7.4",
72
+ "@lume/kiwi": "^0.4.4",
72
73
  "@mantine/core": "8.2.8",
73
74
  "@mantine/hooks": "8.2.8",
74
75
  "@nanostores/react": "1.0.0",
@@ -88,11 +89,11 @@
88
89
  "remeda": "^2.30.0",
89
90
  "type-fest": "^4.41.0",
90
91
  "xstate": "^5.20.2",
91
- "@likec4/core": "1.39.4",
92
- "@likec4/styles": "1.39.4"
92
+ "@likec4/core": "1.40.0",
93
+ "@likec4/styles": "1.40.0"
93
94
  },
94
95
  "peerDependencies": {
95
- "@pandacss/dev": "^1.1.0",
96
+ "@pandacss/dev": "^1.3.0",
96
97
  "react": "^18.x || ^19.x",
97
98
  "react-dom": "^18.x || ^19.x"
98
99
  },
@@ -102,7 +103,7 @@
102
103
  }
103
104
  },
104
105
  "devDependencies": {
105
- "@pandacss/dev": "^1.1.0",
106
+ "@pandacss/dev": "^1.3.0",
106
107
  "@statelyai/inspect": "^0.4.0",
107
108
  "@tabler/icons-react": "3.34.1",
108
109
  "@types/bezier-js": "^4.1.3",
@@ -115,11 +116,11 @@
115
116
  "react": "19.1.1",
116
117
  "react-dom": "19.1.1",
117
118
  "typescript": "5.9.2",
118
- "vite": "^6.3.5",
119
+ "vite": "^6.3.6",
119
120
  "vite-plugin-dts": "^4.5.4",
120
121
  "vitest": "3.2.4",
121
122
  "wireit": "0.14.12",
122
- "@likec4/tsconfig": "1.39.4"
123
+ "@likec4/tsconfig": "1.40.0"
123
124
  },
124
125
  "scripts": {
125
126
  "typecheck": "tsc --build --verbose",
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": "1.1.0",
2
+ "schemaVersion": "1.3.0",
3
3
  "styles": {
4
4
  "atomic": [
5
5
  "background]___[value:dots",
@@ -240,6 +240,7 @@
240
240
  "position]___[value:bottom-end",
241
241
  "boxShadow]___[value:xl",
242
242
  "display]___[value:flex]___[cond:@/xs",
243
+ "paddingBlock]___[value:1",
243
244
  "alignItems]___[value:baseline",
244
245
  "stroke]___[value:1.8",
245
246
  "marginTop]___[value:1",
@@ -313,10 +314,14 @@
313
314
  "borderColor]___[value:mantine.colors.gray[5]",
314
315
  "borderRadius]___[value:3",
315
316
  "transform]___[value:translate(-50%, -50%)",
316
- "flexShrink]___[value:0",
317
- "marginRight]___[value:sm",
318
317
  "borderColor]___[value:mantine.colors.orange[6]",
319
318
  "borderWidth]___[value:4]___[cond:md",
319
+ "marginRight]___[value:sm",
320
+ "flexShrink]___[value:0",
321
+ "display]___[value:[inherit]]___[cond:@/md",
322
+ "marginInlineStart]___[value:0",
323
+ "marginInlineStart]___[value:2]___[cond:@/md",
324
+ "height]___[value:26",
320
325
  "top]___[value:[1px]",
321
326
  "right]___[value:[1px]",
322
327
  "zIndex]___[value:9",
@@ -668,11 +673,8 @@
668
673
  "transitionDelay]___[value:0.2s",
669
674
  "transitionDelay]___[value:0s]___[cond:_hover",
670
675
  "lineClamp]___[value:5",
671
- "fill]___[value:[none]",
672
- "strokeOpacity]___[value:0",
676
+ "fill]___[value:none",
673
677
  "transition]___[value:none]___[cond:_reduceGraphics",
674
- "display]___[value:none]___[cond:_reduceGraphicsOnPan",
675
- "display]___[value:none]___[cond:_smallZoom",
676
678
  "strokeWidth]___[value:calc(var(--xy-edge-stroke-width) + 2)",
677
679
  "strokeOpacity]___[value:0.08",
678
680
  "transitionProperty]___[value:stroke-width, stroke-opacity]___[cond:_noReduceGraphics",
@@ -686,8 +688,7 @@
686
688
  "strokeOpacity]___[value:0.4]___[cond:_whenSelected<___>_whenHovered",
687
689
  "fill]___[value:[var(--xy-edge-stroke)]",
688
690
  "stroke]___[value:[var(--xy-edge-stroke)]",
689
- "fill]___[value:[none!]",
690
- "strokeDashoffset]___[value:10",
691
+ "strokeDashoffset]___[value:0",
691
692
  "animationStyle]___[value:xyedgeAnimated]___[cond:_noReduceGraphics",
692
693
  "animationPlayState]___[value:paused]___[cond:_noReduceGraphics",
693
694
  "transition]___[value:stroke 130ms ease-out,stroke-width 130ms ease-out]___[cond:_noReduceGraphics",
@@ -703,6 +704,7 @@
703
704
  "top]___[value:[calc(100% - 30px)]",
704
705
  "width]___[value:auto",
705
706
  "minHeight]___[value:30px",
707
+ "display]___[value:none]___[cond:_smallZoom",
706
708
  "top]___[value:0.5",
707
709
  "right]___[value:[5px]]___[cond:_shapeBrowser",
708
710
  "top]___[value:[14px]]___[cond:_shapeCylinder",
@@ -759,6 +761,25 @@
759
761
  "cursor]___[value:grabbing",
760
762
  "cursor]___[value:grabbing !important]___[cond:& *",
761
763
  "cursor]___[value:grabbing !important]___[cond:& .react-flow__edge-interaction",
764
+ "border]___[value:default",
765
+ "borderWidth]___[value:1",
766
+ "--_color]___[value:var(--likec4-palette-stroke)",
767
+ "--_color]___[value:[color-mix(in srgb, var(--likec4-palette-hiContrast) 40%, var(--likec4-palette-fill))]]___[cond:_dark",
768
+ "borderColor]___[value:[var(--_color)/30]",
769
+ "backgroundColor]___[value:var(--likec4-palette-fill)/15",
770
+ "paddingLeft]___[value:2",
771
+ "paddingTop]___[value:0.5",
772
+ "fontWeight]___[value:bold",
773
+ "letterSpacing]___[value:.75px",
774
+ "color]___[value:[var(--_color)/75]",
775
+ "backgroundColor]___[value:var(--likec4-palette-fill)",
776
+ "borderRadius]___[value:xs",
777
+ "width]___[value:5px",
778
+ "width]___[value:7px]___[cond:_whenHovered",
779
+ "width]___[value:7px]___[cond:_whenSelected",
780
+ "translateX]___[value:-1/2",
781
+ "translateY]___[value:-1/2",
782
+ "top]___[value:1",
762
783
  "position]___[value:top-end",
763
784
  "minWidth]___[value:200",
764
785
  "maxWidth]___[value:calc(100vw - 16px)",
@@ -1,5 +1,12 @@
1
1
  import type * as t from '@likec4/core/types'
2
- import type { DiagramEdge, DiagramNode, LayoutedView, ViewChange, WhereOperator } from '@likec4/core/types'
2
+ import type {
3
+ DiagramEdge,
4
+ DiagramNode,
5
+ DynamicViewDisplayVariant,
6
+ LayoutedView,
7
+ ViewChange,
8
+ WhereOperator,
9
+ } from '@likec4/core/types'
3
10
  import type { ReactFlowProps as XYFlowProps } from '@xyflow/react'
4
11
  import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react'
5
12
  import type { SetRequired } from 'type-fest'
@@ -250,6 +257,12 @@ export interface LikeC4DiagramProperties<A extends Any = Any> {
250
257
  */
251
258
  enableDynamicViewWalkthrough?: boolean | undefined
252
259
 
260
+ /**
261
+ * Default dynamic view display variant
262
+ * @default 'diagram'
263
+ */
264
+ dynamicViewVariant?: DynamicViewDisplayVariant | undefined
265
+
253
266
  /**
254
267
  * Display element tags in the bottom left corner
255
268
  * @default false
@@ -1,6 +1,7 @@
1
1
  import type { Any } from '@likec4/core/types'
2
2
  import { ReactFlowProvider as XYFlowProvider } from '@xyflow/react'
3
3
  import { type PropsWithChildren, useRef } from 'react'
4
+ import { FitViewPaddings } from './base'
4
5
  import {
5
6
  DiagramEventHandlers,
6
7
  DiagramFeatures,
@@ -37,9 +38,10 @@ export function LikeC4Diagram<A extends Any = Any>({
37
38
  onBurgerMenuClick,
38
39
  view,
39
40
  className,
40
- fitView = true,
41
- fitViewPadding = '8px',
42
41
  readonly = true,
42
+ controls = !readonly,
43
+ fitView = true,
44
+ fitViewPadding = controls === 'next' ? FitViewPaddings.withControls : FitViewPaddings.default,
43
45
  pannable = true,
44
46
  zoomable = true,
45
47
  background = 'dots',
@@ -50,11 +52,11 @@ export function LikeC4Diagram<A extends Any = Any>({
50
52
  enableRelationshipBrowser = enableRelationshipDetails,
51
53
  nodesDraggable = !readonly,
52
54
  nodesSelectable = !readonly || enableFocusMode || !!onNavigateTo || !!onNodeClick,
53
- controls = !readonly,
54
55
  showDiagramTitle = true,
55
56
  showNotations = true,
56
57
  showNavigationButtons = !!onNavigateTo,
57
58
  enableDynamicViewWalkthrough = false,
59
+ dynamicViewVariant,
58
60
  enableSearch = true,
59
61
  initialWidth,
60
62
  initialHeight,
@@ -63,7 +65,7 @@ export function LikeC4Diagram<A extends Any = Any>({
63
65
  renderIcon,
64
66
  renderControls,
65
67
  where,
66
- reactFlowProps = {},
68
+ reactFlowProps,
67
69
  renderNodes,
68
70
  children,
69
71
  }: LikeC4DiagramProps<A>) {
@@ -144,6 +146,7 @@ export function LikeC4Diagram<A extends Any = Any>({
144
146
  fitViewPadding={fitViewPadding}
145
147
  nodesSelectable={nodesSelectable}
146
148
  where={where ?? null}
149
+ dynamicViewVariant={dynamicViewVariant}
147
150
  >
148
151
  <ControlsCustomLayoutProvider value={renderControls ?? null}>
149
152
  <LikeC4DiagramXYFlow
package/src/base/const.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { ViewPadding } from '../LikeC4Diagram.props'
2
+
1
3
  export const ZIndexes = {
2
4
  Compound: 1,
3
5
  // XYFlow increments zIndexes of compounds
@@ -8,3 +10,13 @@ export const ZIndexes = {
8
10
 
9
11
  export const MinZoom = 0.05
10
12
  export const MaxZoom = 3
13
+
14
+ export const FitViewPaddings = {
15
+ default: '16px',
16
+ withControls: {
17
+ top: '50px',
18
+ left: '16px',
19
+ right: '16px',
20
+ bottom: '16px',
21
+ },
22
+ } satisfies Record<string, ViewPadding>
package/src/base/index.ts CHANGED
@@ -8,3 +8,5 @@ export {
8
8
  type ReactFlowEdge,
9
9
  type ReactFlowNode,
10
10
  } from './types'
11
+
12
+ export * from './const'
@@ -50,6 +50,8 @@ export const EdgeLabel = forwardRef<HTMLDivElement, EdgeLabelProps>((
50
50
  cursor: selectable || stepNum !== null ? 'pointer' : 'default',
51
51
  })
52
52
 
53
+ const hasLabel = isTruthy(label) || isTruthy(technology)
54
+
53
55
  return (
54
56
  <m.div
55
57
  ref={ref}
@@ -65,25 +67,27 @@ export const EdgeLabel = forwardRef<HTMLDivElement, EdgeLabelProps>((
65
67
  {stepNum}
66
68
  </Box>
67
69
  )}
68
- <Box className={classes.labelContents}>
69
- {isTruthy(label) && (
70
- <Box
71
- className={cx(
72
- classes.labelText,
73
- css({
74
- lineClamp: 5,
75
- }),
76
- )}>
77
- {label}
78
- </Box>
79
- )}
80
- {isTruthy(technology) && (
81
- <Box className={classes.labelTechnology}>
82
- {'[ ' + technology + ' ]'}
83
- </Box>
84
- )}
85
- {children}
86
- </Box>
70
+ {hasLabel && (
71
+ <Box className={classes.labelContents}>
72
+ {isTruthy(label) && (
73
+ <Box
74
+ className={cx(
75
+ classes.labelText,
76
+ css({
77
+ lineClamp: 5,
78
+ }),
79
+ )}>
80
+ {label}
81
+ </Box>
82
+ )}
83
+ {isTruthy(technology) && (
84
+ <Box className={classes.labelTechnology}>
85
+ {'[ ' + technology + ' ]'}
86
+ </Box>
87
+ )}
88
+ {children}
89
+ </Box>
90
+ )}
87
91
  </m.div>
88
92
  )
89
93
  })
@@ -1,9 +1,10 @@
1
1
  import type { DiagramEdge } from '@likec4/core/types'
2
- import { css, cx } from '@likec4/styles/css'
2
+ import { cx } from '@likec4/styles/css'
3
3
  import { EdgeLabelRenderer } from '@xyflow/react'
4
- import { type HTMLAttributes } from 'react'
4
+ import { type HTMLAttributes, useCallback } from 'react'
5
5
  import { isNumber } from 'remeda'
6
6
  import type { UndefinedOnPartialDeep } from 'type-fest'
7
+ import { useXYStore } from '../../../hooks'
7
8
  import { ZIndexes } from '../../const'
8
9
  import type { EdgeProps } from '../../types'
9
10
 
@@ -50,10 +51,14 @@ export function EdgeLabelContainer({
50
51
  children,
51
52
  ...rest
52
53
  }: EdgeLabelContainerProps) {
53
- let zIndex = ZIndexes.Edge
54
+ let zIndex = useXYStore(
55
+ useCallback((state) => {
56
+ return state.edgeLookup.get(id)?.zIndex ?? ZIndexes.Edge
57
+ }, [id]),
58
+ )
59
+ // Move above the elements
54
60
  if (isHovered || isActive) {
55
- // Move above the elements
56
- zIndex = ZIndexes.Element + 1
61
+ zIndex += 100
57
62
  }
58
63
 
59
64
  let labelX = labelXY?.x ?? labelBBox?.x,
@@ -65,9 +70,10 @@ export function EdgeLabelContainer({
65
70
  const translate = labelXY?.translate
66
71
 
67
72
  return (
68
- <EdgeLabelRenderer key={id}>
73
+ <EdgeLabelRenderer>
69
74
  <div
70
75
  key={id}
76
+ {...rest}
71
77
  className={cx(
72
78
  'nodrag nopan',
73
79
  'likec4-edge-label-container',
@@ -88,7 +94,6 @@ export function EdgeLabelContainer({
88
94
  ...style,
89
95
  transform: `translate(${toCssVarValue(labelX)}, ${toCssVarValue(labelY)}) ${translate || ''}`,
90
96
  }}
91
- {...rest}
92
97
  >
93
98
  {children}
94
99
  </div>
@@ -3,7 +3,7 @@ import { css, cx } from '@likec4/styles/css'
3
3
  import { type PointerEventHandler, forwardRef } from 'react'
4
4
  import type { UndefinedOnPartialDeep } from 'type-fest'
5
5
  import type { EdgeProps } from '../../types'
6
- import { cssEdgePath, edgePathBg, hideOnReducedGraphics, markerContext } from './edge.css'
6
+ import { cssEdgePath, edgePathBg, markerContext } from './edge.css'
7
7
  import { arrowTypeToMarker, EdgeMarkers } from './EdgeMarkers'
8
8
 
9
9
  type Data = UndefinedOnPartialDeep<
@@ -32,6 +32,7 @@ export const EdgePath = forwardRef<SVGPathElement, EdgePathProps>(({
32
32
  tail,
33
33
  head,
34
34
  },
35
+ selectable = true,
35
36
  style,
36
37
  interactionWidth,
37
38
  },
@@ -71,25 +72,34 @@ export const EdgePath = forwardRef<SVGPathElement, EdgePathProps>(({
71
72
 
72
73
  return (
73
74
  <>
74
- <path
75
- className={cx(
76
- 'react-flow__edge-interaction',
77
- hideOnReducedGraphics,
78
- css({
79
- fill: '[none]',
75
+ {selectable && (
76
+ <path
77
+ className={cx(
78
+ 'react-flow__edge-interaction',
79
+ 'hide-on-reduced-graphics',
80
+ css({
81
+ fill: 'none',
82
+ }),
83
+ )}
84
+ d={svgPath}
85
+ style={{
86
+ strokeWidth: interactionWidth ?? 10,
87
+ stroke: 'currentcolor',
80
88
  strokeOpacity: 0,
81
- }),
82
- )}
83
- d={svgPath}
84
- strokeWidth={interactionWidth ?? 10}
85
- />
89
+ }}
90
+ />
91
+ )}
86
92
  <g className={markerContext} onPointerDown={onEdgePointerDown}>
87
93
  <defs>
88
94
  {MarkerStart && <MarkerStart id={'start' + id} />}
89
95
  {MarkerEnd && <MarkerEnd id={'end' + id} />}
90
96
  </defs>
91
97
  <path
92
- className={cx('react-flow__edge-path', edgePathBg)}
98
+ className={cx(
99
+ 'react-flow__edge-path',
100
+ 'hide-on-reduced-graphics',
101
+ edgePathBg,
102
+ )}
93
103
  d={svgPath}
94
104
  style={style}
95
105
  strokeLinecap={'round'}
@@ -98,7 +108,7 @@ export const EdgePath = forwardRef<SVGPathElement, EdgePathProps>(({
98
108
  ref={svgPathRef}
99
109
  className={cx(
100
110
  'react-flow__edge-path',
101
- 'react-flow__edge-interaction',
111
+ selectable && 'react-flow__edge-interaction',
102
112
  cssEdgePath,
103
113
  )}
104
114
  d={svgPath}
@@ -113,3 +123,4 @@ export const EdgePath = forwardRef<SVGPathElement, EdgePathProps>(({
113
123
  </>
114
124
  )
115
125
  })
126
+ EdgePath.displayName = 'EdgePath'
@@ -8,18 +8,9 @@ export const edgeContainer = css({
8
8
  },
9
9
  })
10
10
 
11
- const _hideOnReducedGraphics = css.raw({
12
- _reduceGraphicsOnPan: {
13
- display: 'none',
14
- },
15
- _smallZoom: {
16
- display: 'none',
17
- },
18
- })
19
- export const hideOnReducedGraphics = css(_hideOnReducedGraphics)
20
-
21
- export const edgePathBg = css(_hideOnReducedGraphics, {
22
- fill: '[none]',
11
+ export const edgePathBg = css({
12
+ pointerEvents: 'none',
13
+ fill: 'none',
23
14
  strokeWidth: 'calc(var(--xy-edge-stroke-width) + 2)',
24
15
  strokeOpacity: 0.08,
25
16
  _noReduceGraphics: {
@@ -48,8 +39,8 @@ export const markerContext = css({
48
39
  })
49
40
 
50
41
  export const cssEdgePath = css({
51
- fill: '[none!]',
52
- strokeDashoffset: 10,
42
+ fill: 'none',
43
+ strokeDashoffset: 0,
53
44
  _noReduceGraphics: {
54
45
  animationStyle: 'xyedgeAnimated',
55
46
  animationPlayState: 'paused',
@@ -4,7 +4,6 @@ import { actionBtn } from '@likec4/styles/recipes'
4
4
  import { ActionIcon } from '@mantine/core'
5
5
  import { useId } from '@mantine/hooks'
6
6
  import * as m from 'motion/react-m'
7
- import { useIsZoomTooSmall } from '../../../hooks/useXYFlow'
8
7
  import { stopPropagation } from '../../../utils/xyflow'
9
8
  import type { NodeProps } from '../../types'
10
9
 
@@ -43,8 +42,7 @@ export function ElementActionButtons({
43
42
  buttons,
44
43
  }: ElementActionButtonsProps) {
45
44
  const id = useId()
46
- const zoomTooSmall = useIsZoomTooSmall()
47
- if (!buttons.length || zoomTooSmall) {
45
+ if (!buttons.length) {
48
46
  return null
49
47
  }
50
48
  return (
@@ -2,11 +2,9 @@ import {
2
2
  type Color,
3
3
  type ElementShape,
4
4
  type ElementStyle,
5
- DefaultPaddingSize,
6
- DefaultShapeSize,
7
- DefaultTextSize,
5
+ ensureSizes,
8
6
  } from '@likec4/core/types'
9
- import { css, cx } from '@likec4/styles/css'
7
+ import { cx } from '@likec4/styles/css'
10
8
  import type { MotionNodeLayoutOptions } from 'motion/react'
11
9
  import * as m from 'motion/react-m'
12
10
  import { type CSSProperties, type ReactNode, forwardRef } from 'react'
@@ -28,31 +26,6 @@ export type ElementNodeContainerProps =
28
26
  [key: `data-${string}`]: string | undefined
29
27
  }
30
28
  & MotionNodeLayoutOptions
31
-
32
- export function nodeSizes({
33
- size,
34
- padding,
35
- textSize,
36
- }: ElementStyle) {
37
- if (!size && !!textSize) {
38
- size = textSize
39
- }
40
- if (!textSize && !!size) {
41
- textSize = size
42
- }
43
- if (!padding && !!size) {
44
- padding = size
45
- }
46
- size ??= DefaultShapeSize
47
- textSize ??= DefaultTextSize
48
- padding ??= DefaultPaddingSize
49
- return {
50
- size,
51
- padding,
52
- textSize,
53
- }
54
- }
55
-
56
29
  /**
57
30
  * Top-level primitive to compose leaf nodes renderers.
58
31
  * This container provides the state via data-* attributes
@@ -86,7 +59,7 @@ export const ElementNodeContainer = forwardRef<HTMLDivElement, ElementNodeContai
86
59
  size,
87
60
  padding,
88
61
  textSize,
89
- } = nodeSizes(data.style ?? {})
62
+ } = ensureSizes(data.style ?? {})
90
63
 
91
64
  return (
92
65
  <m.div
@@ -1,4 +1,4 @@
1
- import type { DiagramNode, RichTextOrEmpty } from '@likec4/core/types'
1
+ import { type DiagramNode, type RichTextOrEmpty, ensureSizes } from '@likec4/core/types'
2
2
  import { cx } from '@likec4/styles/css'
3
3
  import { Box } from '@likec4/styles/jsx'
4
4
  import { elementNodeData, elementNodeIcon as elementIconRecipe } from '@likec4/styles/recipes'
@@ -8,7 +8,6 @@ import type { Simplify } from 'type-fest'
8
8
  import { IconRenderer } from '../../../context/IconRenderer'
9
9
  import type { NodeProps, NonOptional } from '../../types'
10
10
  import { MarkdownBlock } from '../MarkdownBlock'
11
- import { nodeSizes } from './ElementNodeContainer'
12
11
 
13
12
  type Data = Simplify<
14
13
  & NonOptional<
@@ -44,7 +43,7 @@ export function ElementTitle({ id, data, iconSize }: ElementTitleProps) {
44
43
  hasDescription: !!data.description?.nonEmpty,
45
44
  hasTechnology: !isEmpty(data.technology ?? ''),
46
45
  })
47
- const size = nodeSizes(data.style).size
46
+ const { size } = ensureSizes(data.style)
48
47
  const isSm = size === 'sm'
49
48
  const isSmOrXs = isSm || size === 'xs'
50
49
  return (
package/src/base/types.ts CHANGED
@@ -15,11 +15,11 @@ type RFEdge<
15
15
  type ReactFlowNodeProps<
16
16
  NodeData extends Record<string, unknown> = Record<string, unknown>,
17
17
  NodeType extends string | undefined = string | undefined,
18
- > = RF.NodeProps<RFNode<NodeData, NodeType>>
18
+ > = RF.NodeProps<RF.Node<NodeData, NodeType>>
19
19
  type ReactFlowEdgeProps<
20
20
  EdgeData extends Record<string, unknown> = Record<string, unknown>,
21
21
  EdgeType extends string | undefined = string | undefined,
22
- > = RF.EdgeProps<RFEdge<EdgeData, EdgeType>>
22
+ > = RF.EdgeProps<RF.Edge<EdgeData, EdgeType>>
23
23
 
24
24
  export namespace Base {
25
25
  // 'immediate' means that the node is dimmed without delay
@@ -156,9 +156,11 @@ export type NodeProps<T extends Record<string, unknown> = {}, NodeType extends s
156
156
  /**
157
157
  * ReactFlow Custom Edge properties with BaseEdgeData at least
158
158
  */
159
- export type EdgeProps<T extends Record<string, unknown> = {}, EdgeType extends string = string> = SetRequired<
160
- Simplify<ReactFlowEdgeProps<Base.EdgeData & T, EdgeType>>,
161
- 'data'
159
+ export type EdgeProps<T extends Record<string, unknown> = {}, EdgeType extends string = string> = Simplify<
160
+ SetRequired<
161
+ ReactFlowEdgeProps<Base.EdgeData & T, EdgeType>,
162
+ 'data'
163
+ >
162
164
  >
163
165
 
164
166
  export type ReactFlowNode<Data extends Record<string, unknown>, NodeType extends string> = SetRequired<
@@ -1,5 +1,4 @@
1
1
  import type * as t from '@likec4/core/types'
2
- import type { WhereOperator } from '@likec4/core/types'
3
2
  import type { CSSProperties } from 'react'
4
3
  import type {
5
4
  CustomNodes,
@@ -109,10 +108,16 @@ export interface LikeC4ViewProps<A extends t.aux.Any = t.aux.UnknownLayouted> {
109
108
 
110
109
  /**
111
110
  * If Walkthrough for dynamic views should be enabled
112
- * @default enableFocusMode
111
+ * @default false
113
112
  */
114
113
  enableDynamicViewWalkthrough?: boolean | undefined
115
114
 
115
+ /**
116
+ * Default dynamic view display variant
117
+ * @default 'diagram'
118
+ */
119
+ dynamicViewVariant?: t.DynamicViewDisplayVariant | undefined
120
+
116
121
  /**
117
122
  * Enable popup with element details
118
123
  * @default false
@@ -145,7 +150,7 @@ export interface LikeC4ViewProps<A extends t.aux.Any = t.aux.UnknownLayouted> {
145
150
  */
146
151
  reduceGraphics?: 'auto' | boolean | undefined
147
152
 
148
- where?: WhereOperator<A> | undefined
153
+ where?: t.WhereOperator<A> | undefined
149
154
 
150
155
  /**
151
156
  * Override some react flow props
@@ -228,6 +233,12 @@ export interface LikeC4BrowserProps {
228
233
  */
229
234
  enableDynamicViewWalkthrough?: boolean | undefined
230
235
 
236
+ /**
237
+ * Default dynamic view display variant
238
+ * @default 'diagram'
239
+ */
240
+ dynamicViewVariant?: t.DynamicViewDisplayVariant | undefined
241
+
231
242
  /**
232
243
  * Enable popup with element details
233
244
  * @default true