@likec4/diagram 1.0.2 → 1.1.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 (50) hide show
  1. package/dist/KeepAspectRatioContainer.d.ts +9 -0
  2. package/dist/LikeC4Diagram.css.d.ts +1 -0
  3. package/dist/LikeC4Diagram.d.ts +1 -1
  4. package/dist/LikeC4Diagram.props.d.ts +16 -11
  5. package/dist/index.mjs +639 -762
  6. package/dist/state/DiagramContext.d.ts +54 -18
  7. package/dist/state/diagramStore.d.ts +61 -21
  8. package/dist/state/useDiagramStore.d.ts +54 -18
  9. package/dist/style.css +690 -79
  10. package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
  11. package/dist/ui/DiagramTitlePanel.d.ts +2 -0
  12. package/dist/ui/OptionsPanel.d.ts +1 -2
  13. package/dist/ui/index.d.ts +0 -1
  14. package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
  15. package/dist/xyflow/{XYFlowWrapper.d.ts → XYFlow.d.ts} +2 -2
  16. package/dist/xyflow/XYFlowEvents.d.ts +133 -13
  17. package/dist/xyflow/edges/RelationshipEdge.d.ts +2 -2
  18. package/dist/xyflow/edges/edges.css.d.ts +1 -0
  19. package/dist/xyflow/hooks/useXYFlow.d.ts +20 -20
  20. package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +7 -5
  21. package/dist/xyflow/types.d.ts +2 -2
  22. package/package.json +5 -3
  23. package/src/{ui/KeepAspectRatio.tsx → KeepAspectRatioContainer.tsx} +7 -6
  24. package/src/LikeC4Diagram.css.ts +8 -1
  25. package/src/LikeC4Diagram.props.ts +17 -12
  26. package/src/LikeC4Diagram.tsx +9 -6
  27. package/src/StaticLikeC4Diagram.tsx +1 -0
  28. package/src/globals.css.ts +48 -38
  29. package/src/state/diagramStore.ts +125 -68
  30. package/src/ui/DiagramTitlePanel.css.ts +32 -0
  31. package/src/ui/DiagramTitlePanel.tsx +139 -0
  32. package/src/ui/OptionsPanel.tsx +4 -23
  33. package/src/ui/index.ts +0 -1
  34. package/src/ui/options/NodeOptions.tsx +107 -30
  35. package/src/xyflow/FitviewOnDiagramChange.tsx +26 -20
  36. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +57 -0
  37. package/src/xyflow/SyncWithDiagram.tsx +35 -26
  38. package/src/xyflow/{XYFlowWrapper.tsx → XYFlow.tsx} +24 -27
  39. package/src/xyflow/XYFlowEvents.tsx +175 -81
  40. package/src/xyflow/diagram-to-xyflow.ts +4 -4
  41. package/src/xyflow/edges/RelationshipEdge.tsx +43 -47
  42. package/src/xyflow/edges/edges.css.ts +77 -36
  43. package/src/xyflow/nodes/compound/CompoundNode.css.ts +94 -44
  44. package/src/xyflow/nodes/compound/CompoundNode.tsx +29 -31
  45. package/src/xyflow/nodes/element/ElementNode.tsx +2 -2
  46. package/src/xyflow/nodes/element/element.css.ts +1 -0
  47. package/src/xyflow/nodes/shared/NavigateToBtn.tsx +2 -1
  48. package/dist/ui/KeepAspectRatio.css.d.ts +0 -1
  49. package/dist/ui/KeepAspectRatio.d.ts +0 -9
  50. package/src/ui/KeepAspectRatio.css.ts +0 -7
@@ -0,0 +1,9 @@
1
+ import { HTMLAttributes } from 'react';
2
+
3
+ type KeepAspectRatioContainerProps = HTMLAttributes<HTMLDivElement> & {
4
+ enabled: boolean;
5
+ width: number;
6
+ height: number;
7
+ };
8
+ export declare function KeepAspectRatioContainer({ children, width, height, enabled, className, style, ...rest }: KeepAspectRatioContainerProps): JSX.Element;
9
+ export {};
@@ -1,3 +1,4 @@
1
+ export declare const keepAspectRatioContainer: string;
1
2
  export declare const cssReactFlow: string;
2
3
  export declare const cssDisablePan: string;
3
4
  export declare const cssTransparentBg: string;
@@ -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, initialWidth, initialHeight, keepAspectRatio, onCanvasClick, onCanvasContextMenu, onCanvasDblClick, onEdgeClick, onChange, onEdgeContextMenu, onNavigateTo, onNodeClick, onNodeContextMenu }: LikeC4DiagramProps): JSX.Element;
4
+ export declare function LikeC4Diagram({ view, className, fitView, fitViewPadding, readonly, pannable, zoomable, nodesSelectable, nodesDraggable, background, controls, showElementLinks, showDiagramTitle, initialWidth, initialHeight, keepAspectRatio, onCanvasClick, onCanvasContextMenu, onCanvasDblClick, onEdgeClick, onChange, onEdgeContextMenu, onNavigateTo, onNodeClick, onNodeContextMenu }: LikeC4DiagramProps): JSX.Element;
@@ -1,8 +1,8 @@
1
- import { XYBackgroundProps } from './xyflow/XYFlowBackground';
2
1
  import { XYFlowEdge, XYFlowNode } from './xyflow/types';
2
+ import { XYBackgroundProps } from './xyflow/XYFlowBackground';
3
3
  import { SetRequired, Simplify } from 'type-fest';
4
4
  import { MouseEvent as ReactMouseEvent } from 'react';
5
- import { DiagramEdge, DiagramNode, DiagramView, ElementShape, Fqn, NonEmptyArray, ThemeColor, ViewID } from '@likec4/core';
5
+ import { BorderStyle, DiagramEdge, DiagramNode, DiagramView, ElementShape, Fqn, NonEmptyArray, ThemeColor, ViewID } from '@likec4/core';
6
6
 
7
7
  export type DiagramNodeWithNavigate = Simplify<SetRequired<DiagramNode, 'navigateTo'>>;
8
8
  export type OnNavigateTo = {
@@ -23,18 +23,18 @@ export type OnEdgeClick = (event: {
23
23
  */
24
24
  export type OnCanvasClick = (event: ReactMouseEvent) => void;
25
25
  export declare namespace Changes {
26
- interface ChangeColor {
27
- op: 'change-color';
28
- color: ThemeColor;
29
- targets: NonEmptyArray<Fqn>;
30
- }
31
- interface ChangeShape {
32
- op: 'change-shape';
33
- shape: ElementShape;
26
+ interface ChangeElementStyle {
27
+ op: 'change-element-style';
28
+ style: {
29
+ border?: BorderStyle;
30
+ opacity?: number;
31
+ shape?: ElementShape;
32
+ color?: ThemeColor;
33
+ };
34
34
  targets: NonEmptyArray<Fqn>;
35
35
  }
36
36
  }
37
- export type Change = Changes.ChangeColor | Changes.ChangeShape;
37
+ export type Change = Changes.ChangeElementStyle;
38
38
  export type ChangeEvent = {
39
39
  changes: NonEmptyArray<Change>;
40
40
  };
@@ -103,6 +103,11 @@ export interface LikeC4DiagramProperties {
103
103
  * @default true
104
104
  */
105
105
  showElementLinks?: boolean | undefined;
106
+ /**
107
+ * Display panel with diagram title / description
108
+ * @default true
109
+ */
110
+ showDiagramTitle?: boolean | undefined;
106
111
  }
107
112
  export interface LikeC4DiagramEventHandlers {
108
113
  onChange?: OnChange | null | undefined;