@likec4/diagram 1.1.1 → 1.2.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 (80) hide show
  1. package/dist/KeepAspectRatioContainer.d.ts +1 -1
  2. package/dist/LikeC4Diagram.d.ts +1 -1
  3. package/dist/LikeC4Diagram.props.d.ts +10 -5
  4. package/dist/StaticLikeC4Diagram.d.ts +1 -1
  5. package/dist/hooks/useUpdateEffect.d.ts +1 -1
  6. package/dist/icons/Clipboard.d.ts +1 -1
  7. package/dist/icons/Link.d.ts +1 -1
  8. package/dist/icons/ZoomIn.d.ts +1 -1
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.mjs +2604 -1502
  11. package/dist/mantine/EnsureMantine.d.ts +1 -1
  12. package/dist/state/DiagramContext.d.ts +2307 -192
  13. package/dist/state/WhenInitialized.d.ts +1 -1
  14. package/dist/state/diagramStore.d.ts +2220 -97
  15. package/dist/state/useDiagramStore.d.ts +2124 -9
  16. package/dist/style.css +210 -136
  17. package/dist/theme.css.d.ts +1 -0
  18. package/dist/ui/DiagramTitlePanel.d.ts +1 -2
  19. package/dist/ui/DynamicViewWalkthrough.css.d.ts +3 -0
  20. package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
  21. package/dist/ui/OptionsPanel.d.ts +1 -2
  22. package/dist/ui/index.d.ts +1 -0
  23. package/dist/ui/options/NodeOptions.d.ts +1 -2
  24. package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -2
  25. package/dist/xyflow/SyncWithDiagram.d.ts +1 -2
  26. package/dist/xyflow/XYFlow.d.ts +5 -8
  27. package/dist/xyflow/XYFlowBackground.d.ts +6 -5
  28. package/dist/xyflow/XYFlowEvents.d.ts +60 -66
  29. package/dist/xyflow/XYFlowInner.d.ts +11 -0
  30. package/dist/xyflow/diagram-to-xyflow.d.ts +2 -2
  31. package/dist/xyflow/edges/RelationshipEdge.d.ts +17 -17
  32. package/dist/xyflow/edges/edges.css.d.ts +4 -2
  33. package/dist/xyflow/edges/utils.d.ts +3 -1
  34. package/dist/xyflow/hooks/useLayoutConstraints.d.ts +1 -1
  35. package/dist/xyflow/hooks/useXYFlow.d.ts +162 -162
  36. package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +1 -0
  37. package/dist/xyflow/nodes/compound/CompoundNode.d.ts +1 -1
  38. package/dist/xyflow/nodes/element/ElementIcon.d.ts +1 -1
  39. package/dist/xyflow/nodes/element/ElementLink.d.ts +1 -1
  40. package/dist/xyflow/nodes/element/ElementNode.d.ts +2 -2
  41. package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +2 -2
  42. package/dist/xyflow/nodes/element/element.css.d.ts +2 -1
  43. package/dist/xyflow/nodes/shared/NavigateToBtn.d.ts +1 -2
  44. package/dist/xyflow/types.d.ts +23 -23
  45. package/package.json +23 -21
  46. package/src/KeepAspectRatioContainer.tsx +1 -1
  47. package/src/LikeC4Diagram.css.ts +2 -0
  48. package/src/LikeC4Diagram.props.ts +9 -4
  49. package/src/LikeC4Diagram.tsx +17 -11
  50. package/src/StaticLikeC4Diagram.tsx +1 -0
  51. package/src/globals.css.ts +1 -0
  52. package/src/index.ts +0 -3
  53. package/src/state/DiagramContext.tsx +21 -12
  54. package/src/state/diagramStore.ts +177 -38
  55. package/src/theme.css.ts +1 -0
  56. package/src/ui/DiagramTitlePanel.css.ts +2 -1
  57. package/src/ui/DiagramTitlePanel.tsx +3 -4
  58. package/src/ui/DynamicViewWalkthrough.css.ts +46 -0
  59. package/src/ui/DynamicViewWalkthrough.tsx +86 -0
  60. package/src/ui/OptionsPanel.tsx +5 -3
  61. package/src/ui/index.ts +1 -0
  62. package/src/ui/options/NodeOptions.tsx +23 -24
  63. package/src/xyflow/FitviewOnDiagramChange.tsx +89 -69
  64. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +57 -39
  65. package/src/xyflow/SyncWithDiagram.tsx +55 -107
  66. package/src/xyflow/XYFlow.tsx +51 -35
  67. package/src/xyflow/XYFlowBackground.tsx +7 -5
  68. package/src/xyflow/XYFlowEvents.tsx +100 -95
  69. package/src/xyflow/XYFlowInner.tsx +50 -0
  70. package/src/xyflow/diagram-to-xyflow.ts +16 -21
  71. package/src/xyflow/edges/RelationshipEdge.tsx +70 -34
  72. package/src/xyflow/edges/edges.css.ts +68 -34
  73. package/src/xyflow/edges/utils.ts +31 -0
  74. package/src/xyflow/nodes/compound/CompoundNode.css.ts +6 -2
  75. package/src/xyflow/nodes/compound/CompoundNode.tsx +6 -3
  76. package/src/xyflow/nodes/element/ElementLink.tsx +13 -3
  77. package/src/xyflow/nodes/element/ElementNode.tsx +24 -19
  78. package/src/xyflow/nodes/element/element.css.ts +9 -2
  79. package/src/xyflow/nodes/shared/NavigateToBtn.tsx +1 -0
  80. package/src/xyflow/types.ts +7 -8
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const themedColors: ({
3
2
  key: "primary";
4
3
  value: "#3b82f6";
@@ -17,4 +16,4 @@ export type ThemeColorKey = typeof themedColors[0]['key'];
17
16
  export type ColorKey = typeof colors[0]['key'];
18
17
  export declare function NodeOptions({ selectedNodeIds }: {
19
18
  selectedNodeIds: string[];
20
- }): JSX.Element | null;
19
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -1,2 +1,4 @@
1
- /// <reference types="react" />
2
- export declare const FitViewOnDiagramChange: import('react').MemoExoticComponent<() => JSX.Element | null>;
1
+ /**
2
+ * Fits the view when the view changes and nodes are initialized
3
+ */
4
+ export declare function FitViewOnDiagramChange(): import("react/jsx-runtime").JSX.Element | null;
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
1
  /**
3
2
  * Syncs the diagram state with the XYFlow instance
4
3
  */
5
- export declare const SyncWithDiagram: import('react').MemoExoticComponent<() => null>;
4
+ export declare function SyncWithDiagram(): null;
@@ -1,14 +1,11 @@
1
- import { XYFlowEdge, XYFlowNode } from './types';
2
- import { LikeC4DiagramProperties } from '../LikeC4Diagram.props';
3
- import { SetNonNullable, Simplify } from 'type-fest';
4
1
  import { CSSProperties, PropsWithChildren } from 'react';
2
+ import { XYFlowEdge, XYFlowNode } from './types';
5
3
 
6
- type OnlyExpectedProps = Required<Pick<LikeC4DiagramProperties, 'className' | 'controls' | 'background'>>;
7
- type XYFlowWrapperProps = Simplify<PropsWithChildren<SetNonNullable<OnlyExpectedProps> & {
4
+ type XYFlowWrapperProps = PropsWithChildren<{
5
+ className?: string | undefined;
8
6
  defaultNodes: XYFlowNode[];
9
7
  defaultEdges: XYFlowEdge[];
10
8
  style?: CSSProperties | undefined;
11
- }>>;
12
- declare function XYFlowWrapper({ className, children, defaultNodes, defaultEdges, controls, background, style }: XYFlowWrapperProps): JSX.Element;
13
- export declare const XYFlow: typeof XYFlowWrapper;
9
+ }>;
10
+ export declare function XYFlow({ className, children, defaultNodes, defaultEdges, style }: XYFlowWrapperProps): import("react/jsx-runtime").JSX.Element;
14
11
  export {};
@@ -1,10 +1,11 @@
1
- import { OverrideProperties } from 'type-fest';
2
1
  import { BackgroundProps } from '@xyflow/react';
2
+ import { OverrideProperties } from 'type-fest';
3
3
 
4
4
  export type XYBackgroundVariant = 'dots' | 'lines' | 'cross';
5
- export type XYBackgroundProps = XYBackgroundVariant | OverrideProperties<BackgroundProps, {
5
+ export type XYBackground = XYBackgroundVariant | OverrideProperties<BackgroundProps, {
6
6
  variant: XYBackgroundVariant;
7
7
  }>;
8
- export declare const XYFlowBackground: import('react').NamedExoticComponent<{
9
- background: XYBackgroundProps;
10
- }>;
8
+ export type XYBackgroundProps = {
9
+ background: XYBackground;
10
+ };
11
+ export declare function XYFlowBackground({ background }: XYBackgroundProps): import("react/jsx-runtime").JSX.Element;
@@ -8,128 +8,122 @@ export declare function useXYFlowEvents(): {
8
8
  onEdgeContextMenu: (event: import('react').MouseEvent<Element, MouseEvent>, xyedge: {
9
9
  source: string;
10
10
  target: string;
11
- style?: import('react').CSSProperties;
12
- id: string;
13
- zIndex?: number;
14
- markerEnd?: import('@xyflow/react').EdgeMarkerType;
15
- markerStart?: import('@xyflow/react').EdgeMarkerType;
16
- hidden?: boolean;
17
- className?: string;
18
- label?: import('react').ReactNode;
19
- selected?: boolean;
20
- selectable?: boolean;
21
- deletable?: boolean;
22
- ariaLabel?: string;
23
- focusable?: boolean;
24
11
  sourceHandle?: string | null;
25
12
  targetHandle?: string | null;
26
13
  animated?: boolean;
14
+ hidden?: boolean;
15
+ deletable?: boolean;
16
+ selectable?: boolean;
17
+ selected?: boolean;
18
+ markerStart?: import('@xyflow/react').EdgeMarkerType;
19
+ markerEnd?: import('@xyflow/react').EdgeMarkerType;
20
+ zIndex?: number;
21
+ ariaLabel?: string;
27
22
  interactionWidth?: number;
23
+ label?: import('react').ReactNode;
28
24
  labelStyle?: import('react').CSSProperties;
29
25
  labelShowBg?: boolean;
30
26
  labelBgStyle?: import('react').CSSProperties;
31
27
  labelBgPadding?: [number, number];
32
28
  labelBgBorderRadius?: number;
29
+ style?: import('react').CSSProperties;
30
+ className?: string;
33
31
  updatable?: import('@xyflow/react').EdgeUpdatable;
32
+ focusable?: boolean;
34
33
  data: import('./types').RelationshipData;
35
- type: "relationship";
34
+ readonly id: string;
35
+ readonly type: "relationship";
36
36
  }) => void;
37
37
  onNodeClick: (event: import('react').MouseEvent<Element, MouseEvent>, xynode: XYFlowNode) => void;
38
38
  onNodeDoubleClick: (event: import('react').MouseEvent<Element, MouseEvent>, xynode: XYFlowNode) => void;
39
39
  onEdgeClick: (event: import('react').MouseEvent<Element, MouseEvent>, xyedge: {
40
40
  source: string;
41
41
  target: string;
42
- style?: import('react').CSSProperties;
43
- id: string;
44
- zIndex?: number;
45
- markerEnd?: import('@xyflow/react').EdgeMarkerType;
46
- markerStart?: import('@xyflow/react').EdgeMarkerType;
47
- hidden?: boolean;
48
- className?: string;
49
- label?: import('react').ReactNode;
50
- selected?: boolean;
51
- selectable?: boolean;
52
- deletable?: boolean;
53
- ariaLabel?: string;
54
- focusable?: boolean;
55
42
  sourceHandle?: string | null;
56
43
  targetHandle?: string | null;
57
44
  animated?: boolean;
45
+ hidden?: boolean;
46
+ deletable?: boolean;
47
+ selectable?: boolean;
48
+ selected?: boolean;
49
+ markerStart?: import('@xyflow/react').EdgeMarkerType;
50
+ markerEnd?: import('@xyflow/react').EdgeMarkerType;
51
+ zIndex?: number;
52
+ ariaLabel?: string;
58
53
  interactionWidth?: number;
54
+ label?: import('react').ReactNode;
59
55
  labelStyle?: import('react').CSSProperties;
60
56
  labelShowBg?: boolean;
61
57
  labelBgStyle?: import('react').CSSProperties;
62
58
  labelBgPadding?: [number, number];
63
59
  labelBgBorderRadius?: number;
60
+ style?: import('react').CSSProperties;
61
+ className?: string;
64
62
  updatable?: import('@xyflow/react').EdgeUpdatable;
63
+ focusable?: boolean;
65
64
  data: import('./types').RelationshipData;
66
- type: "relationship";
65
+ readonly id: string;
66
+ readonly type: "relationship";
67
67
  }) => void;
68
68
  onMoveEnd: (event: MouseEvent | TouchEvent | null, _viewport: import('@xyflow/react').Viewport) => void;
69
- onNodeMouseEnter: (event: import('react').MouseEvent<Element, MouseEvent>, xynode: XYFlowNode) => void;
70
- onNodeMouseLeave: (event: import('react').MouseEvent<Element, MouseEvent>, xynode: XYFlowNode) => void;
71
- onEdgeMouseEnter: (event: import('react').MouseEvent<Element, MouseEvent>, xyedge: {
69
+ onNodeMouseEnter: (_event: import('react').MouseEvent<Element, MouseEvent>, xynode: XYFlowNode) => void;
70
+ onNodeMouseLeave: (_event: import('react').MouseEvent<Element, MouseEvent>, xynode: XYFlowNode) => void;
71
+ onEdgeMouseEnter: (_event: import('react').MouseEvent<Element, MouseEvent>, { id, source, target }: {
72
72
  source: string;
73
73
  target: string;
74
- style?: import('react').CSSProperties;
75
- id: string;
76
- zIndex?: number;
77
- markerEnd?: import('@xyflow/react').EdgeMarkerType;
78
- markerStart?: import('@xyflow/react').EdgeMarkerType;
79
- hidden?: boolean;
80
- className?: string;
81
- label?: import('react').ReactNode;
82
- selected?: boolean;
83
- selectable?: boolean;
84
- deletable?: boolean;
85
- ariaLabel?: string;
86
- focusable?: boolean;
87
74
  sourceHandle?: string | null;
88
75
  targetHandle?: string | null;
89
76
  animated?: boolean;
77
+ hidden?: boolean;
78
+ deletable?: boolean;
79
+ selectable?: boolean;
80
+ selected?: boolean;
81
+ markerStart?: import('@xyflow/react').EdgeMarkerType;
82
+ markerEnd?: import('@xyflow/react').EdgeMarkerType;
83
+ zIndex?: number;
84
+ ariaLabel?: string;
90
85
  interactionWidth?: number;
86
+ label?: import('react').ReactNode;
91
87
  labelStyle?: import('react').CSSProperties;
92
88
  labelShowBg?: boolean;
93
89
  labelBgStyle?: import('react').CSSProperties;
94
90
  labelBgPadding?: [number, number];
95
91
  labelBgBorderRadius?: number;
92
+ style?: import('react').CSSProperties;
93
+ className?: string;
96
94
  updatable?: import('@xyflow/react').EdgeUpdatable;
95
+ focusable?: boolean;
97
96
  data: import('./types').RelationshipData;
98
- type: "relationship";
97
+ readonly id: string;
98
+ readonly type: "relationship";
99
99
  }) => void;
100
- onEdgeMouseLeave: (event: import('react').MouseEvent<Element, MouseEvent>, xyedge: {
100
+ onEdgeMouseLeave: (_event: import('react').MouseEvent<Element, MouseEvent>, xyedge: {
101
101
  source: string;
102
102
  target: string;
103
- style?: import('react').CSSProperties;
104
- id: string;
105
- zIndex?: number;
106
- markerEnd?: import('@xyflow/react').EdgeMarkerType;
107
- markerStart?: import('@xyflow/react').EdgeMarkerType;
108
- hidden?: boolean;
109
- className?: string;
110
- label?: import('react').ReactNode;
111
- selected?: boolean;
112
- selectable?: boolean;
113
- deletable?: boolean;
114
- ariaLabel?: string;
115
- focusable?: boolean;
116
103
  sourceHandle?: string | null;
117
104
  targetHandle?: string | null;
118
105
  animated?: boolean;
106
+ hidden?: boolean;
107
+ deletable?: boolean;
108
+ selectable?: boolean;
109
+ selected?: boolean;
110
+ markerStart?: import('@xyflow/react').EdgeMarkerType;
111
+ markerEnd?: import('@xyflow/react').EdgeMarkerType;
112
+ zIndex?: number;
113
+ ariaLabel?: string;
119
114
  interactionWidth?: number;
115
+ label?: import('react').ReactNode;
120
116
  labelStyle?: import('react').CSSProperties;
121
117
  labelShowBg?: boolean;
122
118
  labelBgStyle?: import('react').CSSProperties;
123
119
  labelBgPadding?: [number, number];
124
120
  labelBgBorderRadius?: number;
121
+ style?: import('react').CSSProperties;
122
+ className?: string;
125
123
  updatable?: import('@xyflow/react').EdgeUpdatable;
124
+ focusable?: boolean;
126
125
  data: import('./types').RelationshipData;
127
- type: "relationship";
126
+ readonly id: string;
127
+ readonly type: "relationship";
128
128
  }) => void;
129
- /**
130
- * WOKAROUND:
131
- * Viewport transform is not rounded to integers which results in blurry nodes on some resolution
132
- * https://github.com/xyflow/xyflow/issues/3282
133
- */
134
- onViewportChange: ({ x, y, zoom }: import('@xyflow/react').Viewport) => void;
135
129
  };
@@ -0,0 +1,11 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { LikeC4DiagramProperties } from '../LikeC4Diagram.props';
3
+
4
+ type XYFlowInnerProps = PropsWithChildren<{
5
+ background: NonNullable<LikeC4DiagramProperties['background']>;
6
+ controls: boolean;
7
+ showDiagramTitle: boolean;
8
+ enableDynamicViewWalkthrough: boolean;
9
+ }>;
10
+ export declare function XYFlowInner({ children, background, controls, showDiagramTitle, enableDynamicViewWalkthrough }: XYFlowInnerProps): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -1,7 +1,7 @@
1
- import { XYFlowData } from '../xyflow/types';
2
1
  import { DiagramView } from '@likec4/core';
2
+ import { XYFlowData } from '../xyflow/types';
3
3
 
4
- export declare function diagramViewToXYFlowData(view: Pick<DiagramView, 'nodes' | 'edges'>, opts: {
4
+ export declare function diagramViewToXYFlowData(view: Pick<DiagramView, 'nodes' | 'edges' | '__'>, opts: {
5
5
  draggable: boolean;
6
6
  selectable: boolean;
7
7
  }): XYFlowData;
@@ -1,32 +1,32 @@
1
- import { CSSProperties } from 'react';
2
1
  import { EdgeProps } from '@xyflow/react';
2
+ import { CSSProperties } from 'react';
3
3
 
4
4
  export declare const RelationshipEdge: import('react').NamedExoticComponent<EdgeProps<{
5
5
  source: string;
6
6
  target: string;
7
- style?: CSSProperties;
8
- id: string;
9
- zIndex?: number;
10
- markerEnd?: import("@xyflow/react").EdgeMarkerType;
11
- markerStart?: import("@xyflow/react").EdgeMarkerType;
12
- hidden?: boolean;
13
- className?: string;
14
- label?: import("react").ReactNode;
15
- selected?: boolean;
16
- selectable?: boolean;
17
- deletable?: boolean;
18
- ariaLabel?: string;
19
- focusable?: boolean;
20
7
  sourceHandle?: string | null;
21
8
  targetHandle?: string | null;
22
9
  animated?: boolean;
10
+ hidden?: boolean;
11
+ deletable?: boolean;
12
+ selectable?: boolean;
13
+ selected?: boolean;
14
+ markerStart?: import('@xyflow/react').EdgeMarkerType;
15
+ markerEnd?: import('@xyflow/react').EdgeMarkerType;
16
+ zIndex?: number;
17
+ ariaLabel?: string;
23
18
  interactionWidth?: number;
19
+ label?: import('react').ReactNode;
24
20
  labelStyle?: CSSProperties;
25
21
  labelShowBg?: boolean;
26
22
  labelBgStyle?: CSSProperties;
27
23
  labelBgPadding?: [number, number];
28
24
  labelBgBorderRadius?: number;
29
- updatable?: import("@xyflow/react").EdgeUpdatable;
30
- data: import("../types").RelationshipData;
31
- type: "relationship";
25
+ style?: CSSProperties;
26
+ className?: string;
27
+ updatable?: import('@xyflow/react').EdgeUpdatable;
28
+ focusable?: boolean;
29
+ data: import('../types').RelationshipData;
30
+ readonly id: string;
31
+ readonly type: "relationship";
32
32
  }>>;
@@ -1,9 +1,11 @@
1
1
  export declare const container: string;
2
+ export declare const dimmed: string;
2
3
  export declare const edgePathBg: string;
3
- export declare const fillStrokeCtx: string;
4
+ export declare const markerContext: string;
4
5
  export declare const controlPoint: string;
5
6
  export declare const cssEdgePath: string;
6
7
  export declare const varLabelX: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
7
8
  export declare const varLabelY: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
8
9
  export declare const edgeLabel: string;
9
- export declare const edgeLabelBody: string;
10
+ export declare const stepEdgeNumber: string;
11
+ export declare const edgeLabelText: string;
@@ -1,6 +1,8 @@
1
- import { InternalXYFlowNode } from '../types';
1
+ import { Point } from '@likec4/core';
2
2
  import { Position, XYPosition } from '@xyflow/react';
3
+ import { InternalXYFlowNode } from '../types';
3
4
 
5
+ export declare function getNodeIntersectionFromCenterToPoint(intersectionNode: InternalXYFlowNode, [x1, y1]: Point): readonly [number, number];
4
6
  export declare function getPointPosition(node: InternalXYFlowNode, intersectionPoint: XYPosition): readonly [number, number, Position];
5
7
  export declare function getEdgeParams(source: InternalXYFlowNode, target: InternalXYFlowNode): {
6
8
  sx: number;
@@ -1,5 +1,5 @@
1
- import { XYFlowNode } from '../types';
2
1
  import { ReactFlowProps } from '@xyflow/react';
2
+ import { XYFlowNode } from '../types';
3
3
 
4
4
  type LayoutConstraints = Required<Pick<ReactFlowProps<XYFlowNode>, 'onNodeDragStart' | 'onNodeDrag' | 'onNodeDragStop'>>;
5
5
  /**