@likec4/diagram 1.5.0 → 1.6.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 (36) hide show
  1. package/LICENSE +1 -1
  2. package/dist/LikeC4Diagram.d.ts +1 -1
  3. package/dist/LikeC4Diagram.props.d.ts +18 -3
  4. package/dist/StaticLikeC4Diagram.d.ts +1 -1
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.mjs +490 -8409
  7. package/dist/state/DiagramContext.d.ts +18 -9
  8. package/dist/state/diagramStore.d.ts +12 -2
  9. package/dist/style.css +149 -85
  10. package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +5 -0
  11. package/dist/xyflow/nodes/element/element.css.d.ts +4 -2
  12. package/package.json +17 -17
  13. package/src/LikeC4Diagram.props.ts +21 -3
  14. package/src/LikeC4Diagram.tsx +9 -11
  15. package/src/StaticLikeC4Diagram.tsx +1 -0
  16. package/src/index.ts +2 -0
  17. package/src/state/DiagramContext.tsx +5 -5
  18. package/src/state/diagramStore.ts +8 -1
  19. package/src/ui/BackwardForwardPanel.tsx +1 -1
  20. package/src/xyflow/FitviewOnDiagramChange.tsx +1 -1
  21. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +1 -1
  22. package/src/xyflow/SyncWithDiagram.tsx +1 -1
  23. package/src/xyflow/XYFlow.tsx +2 -4
  24. package/src/xyflow/XYFlowEvents.tsx +1 -1
  25. package/src/xyflow/XYFlowInner.tsx +2 -1
  26. package/src/xyflow/edges/RelationshipEdge.tsx +3 -3
  27. package/src/xyflow/edges/edges.css.ts +6 -6
  28. package/src/xyflow/hooks/useLayoutConstraints.ts +1 -1
  29. package/src/xyflow/nodes/compound/CompoundNode.tsx +1 -1
  30. package/src/xyflow/nodes/element/ElementLink.tsx +2 -1
  31. package/src/xyflow/nodes/element/ElementNode.tsx +73 -24
  32. package/src/xyflow/nodes/element/ElementShapeSvg.tsx +2 -2
  33. package/src/xyflow/nodes/element/element.css.ts +126 -54
  34. package/src/xyflow/nodes/shared/NavigateToBtn.tsx +1 -1
  35. package/dist/xyflow/nodes/element/ElementIcon.d.ts +0 -7
  36. package/src/xyflow/nodes/element/ElementIcon.tsx +0 -33
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Denis Davydkov
3
+ Copyright (c) 2023-2024 Denis Davydkov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -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 }: 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, initialWidth, initialHeight, keepAspectRatio, experimentalEdgeEditing, onCanvasClick, onCanvasContextMenu, onCanvasDblClick, onEdgeClick, onChange, onEdgeContextMenu, onNavigateTo, onNodeClick, onNodeContextMenu, renderIcon }: LikeC4DiagramProps): import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,20 @@
1
1
  import { BorderStyle, DiagramEdge, DiagramNode, DiagramView, EdgeId, ElementShape, Fqn, NonEmptyArray, ThemeColor, ViewID } from '@likec4/core';
2
2
  import { XYPosition } from '@xyflow/system';
3
- import { MouseEvent as ReactMouseEvent } from 'react';
4
- import { SetRequired, Simplify } from 'type-fest';
3
+ import { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
5
4
  import { XYFlowEdge, XYFlowNode } from './xyflow/types';
6
5
  import { XYBackground } from './xyflow/XYFlowBackground';
7
6
 
8
- export type DiagramNodeWithNavigate = Simplify<SetRequired<DiagramNode, 'navigateTo'>>;
7
+ export type DiagramNodeWithNavigate = Omit<DiagramNode, 'navigateTo'> & {
8
+ navigateTo: ViewID;
9
+ };
10
+ type ElementIconNodeProps = {
11
+ id: string;
12
+ title: string;
13
+ icon?: string | undefined;
14
+ };
15
+ export type ElementIconRenderer = (props: {
16
+ node: ElementIconNodeProps;
17
+ }) => ReactNode;
9
18
  export type OnNavigateTo = {
10
19
  (to: ViewID, event?: ReactMouseEvent, element?: DiagramNodeWithNavigate, xynode?: XYFlowNode): void;
11
20
  };
@@ -136,6 +145,11 @@ export interface LikeC4DiagramProperties {
136
145
  * @default false
137
146
  */
138
147
  experimentalEdgeEditing?: boolean | undefined;
148
+ /**
149
+ * Render custom icon for a node
150
+ * By default, if icon is http:// or https://, it will be rendered as an image
151
+ */
152
+ renderIcon?: ElementIconRenderer | undefined;
139
153
  }
140
154
  export interface LikeC4DiagramEventHandlers {
141
155
  onChange?: OnChange | null | undefined;
@@ -148,3 +162,4 @@ export interface LikeC4DiagramEventHandlers {
148
162
  onCanvasClick?: OnCanvasClick | null | undefined;
149
163
  onCanvasDblClick?: OnCanvasClick | null | undefined;
150
164
  }
165
+ export {};
@@ -1,4 +1,4 @@
1
1
  import { LikeC4DiagramProperties } from './LikeC4Diagram.props';
2
2
 
3
- export type StaticLikeC4DiagramProps = Pick<LikeC4DiagramProperties, 'view' | 'keepAspectRatio' | 'className' | 'fitView' | 'fitViewPadding' | 'background' | 'initialWidth' | 'initialHeight'>;
3
+ export type StaticLikeC4DiagramProps = Pick<LikeC4DiagramProperties, 'view' | 'keepAspectRatio' | 'className' | 'fitView' | 'fitViewPadding' | 'background' | 'initialWidth' | 'initialHeight' | 'renderIcon'>;
4
4
  export declare function StaticLikeC4Diagram({ view, fitView, fitViewPadding, background, ...rest }: StaticLikeC4DiagramProps): import("react/jsx-runtime").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  export { LikeC4Diagram } from './LikeC4Diagram';
2
3
  export { StaticLikeC4Diagram } from './StaticLikeC4Diagram';
3
4
  export { useSetState, useUpdateEffect } from './hooks';