@likec4/diagram 1.6.0 → 1.7.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 (49) hide show
  1. package/dist/LikeC4Diagram.d.ts +1 -1
  2. package/dist/LikeC4Diagram.props.d.ts +10 -11
  3. package/dist/hooks/useUpdateEffect.d.ts +1 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.mjs +769 -8587
  6. package/dist/state/DiagramContext.d.ts +746 -181
  7. package/dist/state/diagram-to-xyflow.d.ts +10 -0
  8. package/dist/state/diagramStore.d.ts +782 -202
  9. package/dist/style.css +273 -275
  10. package/dist/types.d.ts +20 -0
  11. package/dist/xyflow/EdgeMarkers.d.ts +1 -0
  12. package/dist/xyflow/FitviewOnDiagramChange.d.ts +1 -1
  13. package/dist/xyflow/XYFlow.d.ts +1 -4
  14. package/dist/xyflow/XYFlowEvents.d.ts +41 -12
  15. package/dist/xyflow/XYFlowInner.d.ts +0 -1
  16. package/dist/xyflow/edges/RelationshipEdge.d.ts +3 -3
  17. package/dist/xyflow/hooks/index.d.ts +0 -1
  18. package/dist/xyflow/hooks/useXYFlow.d.ts +27 -27
  19. package/dist/xyflow/types.d.ts +11 -19
  20. package/dist/xyflow/utils.d.ts +1 -0
  21. package/package.json +11 -11
  22. package/src/LikeC4Diagram.props.ts +17 -13
  23. package/src/LikeC4Diagram.tsx +67 -106
  24. package/src/globals.css.ts +10 -6
  25. package/src/hooks/useUpdateEffect.ts +16 -1
  26. package/src/index.ts +3 -0
  27. package/src/state/DiagramContext.tsx +19 -27
  28. package/src/{xyflow → state}/diagram-to-xyflow.ts +19 -18
  29. package/src/state/diagramStore.ts +404 -192
  30. package/src/types.ts +22 -0
  31. package/src/ui/BackwardForwardPanel.tsx +24 -7
  32. package/src/xyflow/EdgeMarkers.tsx +2 -0
  33. package/src/xyflow/FitviewOnDiagramChange.tsx +42 -75
  34. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +1 -1
  35. package/src/xyflow/XYFlow.tsx +57 -35
  36. package/src/xyflow/XYFlowEvents.tsx +58 -10
  37. package/src/xyflow/XYFlowInner.tsx +9 -8
  38. package/src/xyflow/edges/RelationshipEdge.tsx +43 -29
  39. package/src/xyflow/edges/edges.css.ts +3 -3
  40. package/src/xyflow/edges/utils.ts +0 -1
  41. package/src/xyflow/hooks/index.ts +0 -1
  42. package/src/xyflow/hooks/useLayoutConstraints.ts +42 -65
  43. package/src/xyflow/nodes/element/ElementNode.tsx +8 -11
  44. package/src/xyflow/nodes/element/element.css.ts +8 -6
  45. package/src/xyflow/types.ts +14 -32
  46. package/src/xyflow/utils.ts +4 -0
  47. package/dist/xyflow/SyncWithDiagram.d.ts +0 -4
  48. package/dist/xyflow/diagram-to-xyflow.d.ts +0 -7
  49. package/src/xyflow/SyncWithDiagram.tsx +0 -85
@@ -1,4 +1,4 @@
1
1
  import { LikeC4DiagramEventHandlers, LikeC4DiagramProperties } from './LikeC4Diagram.props';
2
2
 
3
3
  export type LikeC4DiagramProps = LikeC4DiagramProperties & LikeC4DiagramEventHandlers;
4
- export declare function LikeC4Diagram({ view, className, fitView, fitViewPadding, readonly, pannable, zoomable, nodesSelectable, nodesDraggable, background, controls, showElementLinks, showDiagramTitle, showNavigationButtons, enableDynamicViewWalkthrough, initialWidth, initialHeight, keepAspectRatio, experimentalEdgeEditing, onCanvasClick, onCanvasContextMenu, onCanvasDblClick, onEdgeClick, onChange, onEdgeContextMenu, onNavigateTo, onNodeClick, onNodeContextMenu, renderIcon }: LikeC4DiagramProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare function LikeC4Diagram({ view, className, fitView, fitViewPadding, readonly, pannable, zoomable, nodesSelectable, nodesDraggable, background, controls, showElementLinks, showDiagramTitle, showNavigationButtons, enableDynamicViewWalkthrough, enableFocusMode, initialWidth, initialHeight, keepAspectRatio, experimentalEdgeEditing, onCanvasClick, onCanvasContextMenu, onCanvasDblClick, onEdgeClick, onChange, onEdgeContextMenu, onNavigateTo, onNodeClick, onNodeContextMenu, onEditorCommand, renderIcon }: LikeC4DiagramProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
- import { BorderStyle, DiagramEdge, DiagramNode, DiagramView, EdgeId, ElementShape, Fqn, NonEmptyArray, ThemeColor, ViewID } from '@likec4/core';
2
- import { XYPosition } from '@xyflow/system';
1
+ import { BorderStyle, DiagramEdge, DiagramNode, DiagramView, ElementShape, Fqn, NonEmptyArray, ThemeColor, ViewID, ViewManualLayout } from '@likec4/core';
3
2
  import { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
3
+ import { DiagramEditorCommand } from './types';
4
4
  import { XYFlowEdge, XYFlowNode } from './xyflow/types';
5
5
  import { XYBackground } from './xyflow/XYFlowBackground';
6
6
 
@@ -28,6 +28,7 @@ export type OnEdgeClick = (event: {
28
28
  xyedge: XYFlowEdge;
29
29
  event: ReactMouseEvent;
30
30
  }) => void;
31
+ export type OnEditorCommand = (cmd: DiagramEditorCommand) => void;
31
32
  /**
32
33
  * On pane/canvas click (not on any node or edge)
33
34
  */
@@ -45,15 +46,7 @@ export declare namespace Changes {
45
46
  }
46
47
  interface SaveManualLayout {
47
48
  op: 'save-manual-layout';
48
- nodes: Record<Fqn, {
49
- x: number;
50
- y: number;
51
- width: number;
52
- height: number;
53
- }>;
54
- edges: Record<EdgeId, {
55
- controlPoints: XYPosition[];
56
- }>;
49
+ layout: ViewManualLayout;
57
50
  }
58
51
  }
59
52
  export type Change = Changes.ChangeElementStyle | Changes.SaveManualLayout;
@@ -135,6 +128,11 @@ export interface LikeC4DiagramProperties {
135
128
  * @default false
136
129
  */
137
130
  showNavigationButtons?: undefined | boolean;
131
+ /**
132
+ * If double click on a node should enable focus mode, i.e. highlight incoming/outgoing edges
133
+ * @default true
134
+ */
135
+ enableFocusMode?: boolean | undefined;
138
136
  /**
139
137
  * If Walkthrough for dynamic views should be enabled
140
138
  * @default false
@@ -161,5 +159,6 @@ export interface LikeC4DiagramEventHandlers {
161
159
  onEdgeContextMenu?: OnEdgeClick | null | undefined;
162
160
  onCanvasClick?: OnCanvasClick | null | undefined;
163
161
  onCanvasDblClick?: OnCanvasClick | null | undefined;
162
+ onEditorCommand?: OnEditorCommand | null | undefined;
164
163
  }
165
164
  export {};
@@ -1,4 +1,5 @@
1
1
  import { DependenciesComparator, EffectHook } from '@react-hookz/web';
2
2
  import { DependencyList, EffectCallback } from 'react';
3
3
 
4
+ export declare const depsShallowEqual: DependenciesComparator;
4
5
  export declare function useUpdateEffect<Callback extends EffectCallback = EffectCallback, Deps extends DependencyList = DependencyList>(callback: Callback, deps: Deps, equalityFn?: DependenciesComparator<Deps>, effectHook?: EffectHook<Callback, Deps>): void;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
+
1
2
  export { LikeC4Diagram } from './LikeC4Diagram';
2
3
  export { StaticLikeC4Diagram } from './StaticLikeC4Diagram';
3
4
  export { useSetState, useUpdateEffect } from './hooks';
4
5
  export type * from './LikeC4Diagram';
5
6
  export type * from './LikeC4Diagram.props';
6
7
  export type * from './StaticLikeC4Diagram';
8
+ export type * from './types';
7
9
  export type * from './xyflow/types';