@likec4/diagram 1.0.0-next.2 → 1.0.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 (124) hide show
  1. package/dist/LikeC4Diagram.css.d.ts +0 -1
  2. package/dist/LikeC4Diagram.d.ts +1 -2
  3. package/dist/LikeC4Diagram.props.d.ts +24 -25
  4. package/dist/StaticLikeC4Diagram.d.ts +1 -2
  5. package/dist/globals.css.d.ts +1 -0
  6. package/dist/hooks/index.d.ts +2 -3
  7. package/dist/hooks/useSetState.d.ts +3 -0
  8. package/dist/hooks/useUpdateEffect.d.ts +4 -0
  9. package/dist/icons/Clipboard.d.ts +0 -1
  10. package/dist/icons/Link.d.ts +0 -1
  11. package/dist/icons/ZoomIn.d.ts +0 -1
  12. package/dist/icons/index.d.ts +0 -1
  13. package/dist/index.d.ts +1 -4
  14. package/dist/index.mjs +9388 -0
  15. package/dist/mantine/EnsureMantine.d.ts +2 -4
  16. package/dist/mantine/theme.d.ts +3 -0
  17. package/dist/mantine.css.d.ts +1 -0
  18. package/dist/state/DiagramContext.d.ts +386 -0
  19. package/dist/state/WhenInitialized.d.ts +3 -0
  20. package/dist/state/diagramStore.d.ts +428 -0
  21. package/dist/state/index.d.ts +4 -2
  22. package/dist/state/useDiagramStore.d.ts +387 -0
  23. package/dist/style.css +1212 -1
  24. package/dist/theme.css.d.ts +16 -2
  25. package/dist/ui/Camera.d.ts +0 -1
  26. package/dist/ui/KeepAspectRatio.css.d.ts +0 -1
  27. package/dist/ui/KeepAspectRatio.d.ts +0 -1
  28. package/dist/ui/OptionsPanel.css.d.ts +0 -1
  29. package/dist/ui/OptionsPanel.d.ts +0 -1
  30. package/dist/ui/index.d.ts +0 -1
  31. package/dist/ui/options/NodeOptions.d.ts +0 -1
  32. package/dist/xyflow/FitviewOnDiagramChange.d.ts +1 -5
  33. package/dist/xyflow/SyncWithDiagram.d.ts +5 -0
  34. package/dist/xyflow/XYFlowBackground.d.ts +0 -1
  35. package/dist/xyflow/XYFlowEvents.d.ts +5 -15
  36. package/dist/xyflow/XYFlowWrapper.d.ts +4 -5
  37. package/dist/xyflow/const.d.ts +1 -2
  38. package/dist/xyflow/diagram-to-xyflow.d.ts +4 -2
  39. package/dist/xyflow/edges/RelationshipEdge.d.ts +7 -7
  40. package/dist/xyflow/edges/edges.css.d.ts +2 -1
  41. package/dist/xyflow/edges/utils.d.ts +3 -4
  42. package/dist/xyflow/hooks/index.d.ts +2 -37
  43. package/dist/xyflow/hooks/{use-layout-/321/201onstraints.d.ts → useLayoutConstraints.d.ts} +2 -4
  44. package/dist/xyflow/hooks/useXYFlow.d.ts +266 -0
  45. package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +0 -1
  46. package/dist/xyflow/nodes/compound/CompoundNode.d.ts +0 -1
  47. package/dist/xyflow/nodes/compound/index.d.ts +0 -1
  48. package/dist/xyflow/nodes/element/ElementIcon.d.ts +1 -2
  49. package/dist/xyflow/nodes/element/ElementLink.css.d.ts +0 -1
  50. package/dist/xyflow/nodes/element/ElementLink.d.ts +1 -2
  51. package/dist/xyflow/nodes/element/ElementNode.d.ts +1 -3
  52. package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +2 -3
  53. package/dist/xyflow/nodes/element/element.css.d.ts +0 -1
  54. package/dist/xyflow/nodes/element/index.d.ts +1 -2
  55. package/dist/xyflow/nodes/shared/NavigateToBtn.d.ts +0 -1
  56. package/dist/xyflow/types.d.ts +20 -8
  57. package/dist/xyflow/utils.d.ts +0 -1
  58. package/package.json +36 -34
  59. package/src/LikeC4Diagram.css.ts +31 -0
  60. package/src/LikeC4Diagram.props.ts +154 -0
  61. package/src/LikeC4Diagram.tsx +119 -0
  62. package/src/StaticLikeC4Diagram.tsx +39 -0
  63. package/src/globals.css.ts +128 -0
  64. package/src/hooks/index.ts +2 -0
  65. package/src/hooks/useSetState.ts +19 -0
  66. package/src/hooks/useUpdateEffect.ts +28 -0
  67. package/src/icons/Clipboard.tsx +24 -0
  68. package/src/icons/Link.tsx +23 -0
  69. package/src/icons/ZoomIn.tsx +25 -0
  70. package/src/icons/index.ts +3 -0
  71. package/src/index.ts +11 -0
  72. package/src/mantine/EnsureMantine.tsx +14 -0
  73. package/src/mantine/theme.ts +19 -0
  74. package/src/mantine.css.ts +4 -0
  75. package/src/reset.d.ts +2 -0
  76. package/src/state/DiagramContext.tsx +42 -0
  77. package/src/state/WhenInitialized.tsx +24 -0
  78. package/src/state/diagramStore.ts +358 -0
  79. package/src/state/index.ts +4 -0
  80. package/src/state/useDiagramStore.ts +39 -0
  81. package/src/theme.css.ts +64 -0
  82. package/src/ui/Camera.tsx +174 -0
  83. package/src/ui/KeepAspectRatio.css.ts +7 -0
  84. package/src/ui/KeepAspectRatio.tsx +35 -0
  85. package/src/ui/OptionsPanel.css.ts +10 -0
  86. package/src/ui/OptionsPanel.tsx +65 -0
  87. package/src/ui/index.ts +3 -0
  88. package/src/ui/options/NodeOptions.tsx +253 -0
  89. package/src/xyflow/FitviewOnDiagramChange.tsx +93 -0
  90. package/src/xyflow/SyncWithDiagram.tsx +113 -0
  91. package/src/xyflow/XYFlowBackground.tsx +33 -0
  92. package/src/xyflow/XYFlowEvents.tsx +100 -0
  93. package/src/xyflow/XYFlowWrapper.tsx +166 -0
  94. package/src/xyflow/const.ts +7 -0
  95. package/src/xyflow/diagram-to-xyflow.ts +197 -0
  96. package/src/xyflow/edges/RelationshipEdge.tsx +288 -0
  97. package/src/xyflow/edges/edges.css.ts +124 -0
  98. package/src/xyflow/edges/utils.ts +110 -0
  99. package/src/xyflow/hooks/index.ts +2 -0
  100. package/src/xyflow/hooks/useLayoutConstraints.ts +289 -0
  101. package/src/xyflow/hooks/useXYFlow.ts +20 -0
  102. package/src/xyflow/nodes/compound/CompoundNode.css.ts +191 -0
  103. package/src/xyflow/nodes/compound/CompoundNode.tsx +105 -0
  104. package/src/xyflow/nodes/compound/index.ts +1 -0
  105. package/src/xyflow/nodes/element/ElementIcon.tsx +44 -0
  106. package/src/xyflow/nodes/element/ElementLink.css.ts +67 -0
  107. package/src/xyflow/nodes/element/ElementLink.tsx +94 -0
  108. package/src/xyflow/nodes/element/ElementNode.tsx +225 -0
  109. package/src/xyflow/nodes/element/ElementShapeSvg.tsx +181 -0
  110. package/src/xyflow/nodes/element/element.css.ts +261 -0
  111. package/src/xyflow/nodes/element/index.ts +1 -0
  112. package/src/xyflow/nodes/shared/NavigateToBtn.tsx +25 -0
  113. package/src/xyflow/types.ts +100 -0
  114. package/src/xyflow/utils.ts +12 -0
  115. package/dist/EmbeddedLikeC4Diagram.css.d.ts +0 -6
  116. package/dist/EmbeddedLikeC4Diagram.d.ts +0 -18
  117. package/dist/bundle.d.ts +0 -3
  118. package/dist/hooks/use-set-state.d.ts +0 -2
  119. package/dist/hooks/use-update-effect.d.ts +0 -4
  120. package/dist/index.css.d.ts +0 -2
  121. package/dist/index.js +0 -13043
  122. package/dist/mantine/index.d.ts +0 -3
  123. package/dist/state/DiagramState.d.ts +0 -162
  124. package/dist/xyflow/UpdateOnDiagramChange.d.ts +0 -10
@@ -2,4 +2,3 @@ export declare const cssReactFlow: string;
2
2
  export declare const cssDisablePan: string;
3
3
  export declare const cssTransparentBg: string;
4
4
  export declare const cssNoControls: string;
5
- //# sourceMappingURL=LikeC4Diagram.css.d.ts.map
@@ -1,5 +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, colorMode, readonly, pannable, zoomable, nodesSelectable, nodesDraggable, background, controls, disableHovercards, initialWidth, initialHeight, keepAspectRatio, ...eventHandlers }: LikeC4DiagramProps): JSX.Element;
5
- //# sourceMappingURL=LikeC4Diagram.d.ts.map
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;
@@ -1,28 +1,27 @@
1
1
  import { XYBackgroundProps } from './xyflow/XYFlowBackground';
2
2
  import { XYFlowEdge, XYFlowNode } from './xyflow/types';
3
3
  import { SetRequired, Simplify } from 'type-fest';
4
- import { DiagramEdge, DiagramNode, DiagramView, ElementShape, Fqn, NonEmptyArray, ThemeColor } from '@likec4/core';
4
+ import { MouseEvent as ReactMouseEvent } from 'react';
5
+ import { DiagramEdge, DiagramNode, DiagramView, ElementShape, Fqn, NonEmptyArray, ThemeColor, ViewID } from '@likec4/core';
5
6
 
6
7
  export type DiagramNodeWithNavigate = Simplify<SetRequired<DiagramNode, 'navigateTo'>>;
7
- export type OnNavigateTo = (event: {
8
- element: DiagramNodeWithNavigate;
9
- xynode: XYFlowNode;
10
- event: React.MouseEvent;
11
- }) => void;
8
+ export type OnNavigateTo = {
9
+ (to: ViewID, event: ReactMouseEvent, element: DiagramNodeWithNavigate, xynode: XYFlowNode): void;
10
+ };
12
11
  export type OnNodeClick = (event: {
13
12
  element: DiagramNode;
14
13
  xynode: XYFlowNode;
15
- event: React.MouseEvent;
14
+ event: ReactMouseEvent;
16
15
  }) => void;
17
16
  export type OnEdgeClick = (event: {
18
17
  relation: DiagramEdge;
19
18
  xyedge: XYFlowEdge;
20
- event: React.MouseEvent;
19
+ event: ReactMouseEvent;
21
20
  }) => void;
22
21
  /**
23
22
  * On pane/canvas click (not on any node or edge)
24
23
  */
25
- export type OnCanvasClick = (event: React.MouseEvent) => void;
24
+ export type OnCanvasClick = (event: ReactMouseEvent) => void;
26
25
  export declare namespace Changes {
27
26
  interface ChangeColor {
28
27
  op: 'change-color';
@@ -39,8 +38,10 @@ export type Change = Changes.ChangeColor | Changes.ChangeShape;
39
38
  export type ChangeEvent = {
40
39
  changes: NonEmptyArray<Change>;
41
40
  };
42
- export type OnChange = (event: ChangeEvent) => void;
43
- export type LikeC4ColorMode = 'light' | 'dark';
41
+ export type OnChange = {
42
+ (event: ChangeEvent): void;
43
+ };
44
+ export type LikeC4ColorScheme = 'light' | 'dark';
44
45
  export interface LikeC4DiagramProperties {
45
46
  view: DiagramView;
46
47
  className?: string | undefined;
@@ -50,7 +51,6 @@ export interface LikeC4DiagramProperties {
50
51
  *
51
52
  * @example 'light' | 'dark'
52
53
  */
53
- colorMode?: LikeC4ColorMode | undefined;
54
54
  /**
55
55
  * Show/hide controls menu
56
56
  * @default false
@@ -99,20 +99,19 @@ export interface LikeC4DiagramProperties {
99
99
  */
100
100
  background?: 'transparent' | 'solid' | XYBackgroundProps | undefined;
101
101
  /**
102
- * Disable element hovercards, such as links and properties
103
- * @default false
102
+ * Display hovercards with element links
103
+ * @default true
104
104
  */
105
- disableHovercards?: boolean | undefined;
105
+ showElementLinks?: boolean | undefined;
106
106
  }
107
107
  export interface LikeC4DiagramEventHandlers {
108
- onChange?: OnChange | undefined;
109
- onNavigateTo?: OnNavigateTo | undefined;
110
- onNodeClick?: OnNodeClick | undefined;
111
- onNodeContextMenu?: OnNodeClick | undefined;
112
- onCanvasContextMenu?: OnCanvasClick | undefined;
113
- onEdgeClick?: OnEdgeClick | undefined;
114
- onEdgeContextMenu?: OnEdgeClick | undefined;
115
- onCanvasClick?: OnCanvasClick | undefined;
116
- onCanvasDblClick?: OnCanvasClick | undefined;
108
+ onChange?: OnChange | null | undefined;
109
+ onNavigateTo?: OnNavigateTo | null | undefined;
110
+ onNodeClick?: OnNodeClick | null | undefined;
111
+ onNodeContextMenu?: OnNodeClick | null | undefined;
112
+ onCanvasContextMenu?: OnCanvasClick | null | undefined;
113
+ onEdgeClick?: OnEdgeClick | null | undefined;
114
+ onEdgeContextMenu?: OnEdgeClick | null | undefined;
115
+ onCanvasClick?: OnCanvasClick | null | undefined;
116
+ onCanvasDblClick?: OnCanvasClick | null | undefined;
117
117
  }
118
- //# sourceMappingURL=LikeC4Diagram.props.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { LikeC4DiagramProperties } from './LikeC4Diagram.props';
2
2
 
3
- export type StaticLikeC4DiagramProps = Pick<LikeC4DiagramProperties, 'view' | 'keepAspectRatio' | 'className' | 'colorMode' | 'fitView' | 'fitViewPadding' | 'background' | 'initialWidth' | 'initialHeight'>;
3
+ export type StaticLikeC4DiagramProps = Pick<LikeC4DiagramProperties, 'view' | 'keepAspectRatio' | 'className' | 'fitView' | 'fitViewPadding' | 'background' | 'initialWidth' | 'initialHeight'>;
4
4
  export declare function StaticLikeC4Diagram({ view, fitView, fitViewPadding, background, ...rest }: StaticLikeC4DiagramProps): JSX.Element;
5
- //# sourceMappingURL=StaticLikeC4Diagram.d.ts.map
@@ -0,0 +1 @@
1
+ export declare const rootClassName = "likec4-diagram-root";
@@ -1,3 +1,2 @@
1
- export * from './use-set-state';
2
- export * from './use-update-effect';
3
- //# sourceMappingURL=index.d.ts.map
1
+ export * from './useSetState';
2
+ export * from './useUpdateEffect';
@@ -0,0 +1,3 @@
1
+ import { NonEmptyObject } from 'type-fest';
2
+
3
+ export declare function useSetState<T extends object>(initialState: T | (() => T)): readonly [T, (statePartial: NonEmptyObject<Partial<T>> | ((current: T) => NonEmptyObject<Partial<T>>)) => void];
@@ -0,0 +1,4 @@
1
+ import { DependencyList, EffectCallback } from 'react';
2
+ import { DependenciesComparator, EffectHook } from '@react-hookz/web';
3
+
4
+ export declare function useUpdateEffect<Callback extends EffectCallback = EffectCallback, Deps extends DependencyList = DependencyList>(callback: Callback, deps: Deps, equalityFn?: DependenciesComparator<Deps>, effectHook?: EffectHook<Callback, Deps>): void;
@@ -1,4 +1,3 @@
1
1
  import { SVGProps } from 'react';
2
2
 
3
3
  export declare const ClipboardCopy: import('react').ForwardRefExoticComponent<Omit<SVGProps<SVGSVGElement>, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
4
- //# sourceMappingURL=Clipboard.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import { SVGProps } from 'react';
2
2
 
3
3
  export declare const Link: import('react').ForwardRefExoticComponent<Omit<SVGProps<SVGSVGElement>, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
4
- //# sourceMappingURL=Link.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import { SVGProps } from 'react';
2
2
 
3
3
  export declare const ZoomIn: import('react').ForwardRefExoticComponent<Omit<SVGProps<SVGSVGElement>, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
4
- //# sourceMappingURL=ZoomIn.d.ts.map
@@ -1,4 +1,3 @@
1
1
  export * from './Clipboard';
2
2
  export * from './Link';
3
3
  export * from './ZoomIn';
4
- //# sourceMappingURL=index.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,11 +1,8 @@
1
1
 
2
- export { EmbeddedLikeC4Diagram } from './EmbeddedLikeC4Diagram';
3
2
  export { LikeC4Diagram } from './LikeC4Diagram';
4
3
  export { StaticLikeC4Diagram } from './StaticLikeC4Diagram';
5
- export type * from './EmbeddedLikeC4Diagram';
4
+ export * from './hooks';
6
5
  export type * from './LikeC4Diagram';
7
6
  export type * from './LikeC4Diagram.props';
8
7
  export type * from './StaticLikeC4Diagram';
9
8
  export type * from './xyflow/types';
10
- export * from './bundle';
11
- //# sourceMappingURL=index.d.ts.map