@likec4/diagram 1.17.1 → 1.19.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.
- package/LICENSE +1 -1
- package/dist/LikeC4CustomColors.d.ts +7 -0
- package/dist/LikeC4CustomColors.js +30 -0
- package/dist/LikeC4Diagram.css.d.ts +5 -0
- package/dist/LikeC4Diagram.css.js +13 -0
- package/dist/LikeC4Diagram.d.ts +6 -0
- package/dist/LikeC4Diagram.js +194 -0
- package/dist/LikeC4Diagram.props.d.ts +166 -0
- package/dist/LikeC4ModelProvider.d.ts +9 -0
- package/dist/LikeC4ModelProvider.js +12 -0
- package/dist/LikeC4Search.css.d.ts +1 -0
- package/dist/LikeC4Search.css.js +5 -0
- package/dist/LikeC4Search.d.ts +2 -0
- package/dist/LikeC4Search.js +96 -0
- package/dist/StaticLikeC4Diagram.d.ts +3 -0
- package/dist/StaticLikeC4Diagram.js +41 -0
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/controls/Text.d.ts +2 -0
- package/dist/controls/Text.js +7 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +1 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.js +5 -0
- package/dist/controls/action-button-bar/ActionButtonBar.d.ts +9 -0
- package/dist/controls/action-button-bar/ActionButtonBar.js +100 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +10 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.js +9 -0
- package/dist/controls/action-buttons/ActionButton.css.d.ts +1 -0
- package/dist/controls/action-buttons/ActionButton.css.js +5 -0
- package/dist/controls/action-buttons/ActionButton.d.ts +9 -0
- package/dist/controls/action-buttons/ActionButton.js +66 -0
- package/dist/controls/action-buttons/ActionButtons.d.ts +12 -0
- package/dist/controls/action-buttons/ActionButtons.js +99 -0
- package/dist/globals.css.d.ts +1 -0
- package/dist/globals.css.js +92 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useDiagramState.d.ts +6 -0
- package/dist/hooks/useDiagramState.js +27 -0
- package/dist/hooks/useMantinePortalProps.d.ts +9 -0
- package/dist/hooks/useMantinePortalProps.js +9 -0
- package/dist/hooks/useSetState.d.ts +2 -0
- package/dist/hooks/useSetState.js +19 -0
- package/dist/hooks/useUpdateEffect.d.ts +4 -0
- package/dist/hooks/useUpdateEffect.js +32 -0
- package/dist/hooks/useXYFlow.d.ts +270 -0
- package/dist/hooks/useXYFlow.js +20 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +25 -0
- package/dist/likec4model/LikeC4ModelContext.d.ts +3 -0
- package/dist/likec4model/LikeC4ModelContext.js +5 -0
- package/dist/likec4model/index.d.ts +2 -0
- package/dist/likec4model/useLikeC4ElementsTree.d.ts +12 -0
- package/dist/likec4model/useLikeC4ElementsTree.js +25 -0
- package/dist/likec4model/useLikeC4Model.d.ts +20 -0
- package/dist/likec4model/useLikeC4Model.js +55 -0
- package/dist/overlays/OverlayContext.d.ts +10 -0
- package/dist/overlays/OverlayContext.js +9 -0
- package/dist/overlays/Overlays.css.d.ts +3 -0
- package/dist/overlays/Overlays.css.js +7 -0
- package/dist/overlays/Overlays.d.ts +2 -0
- package/dist/overlays/Overlays.js +137 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +5 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +185 -0
- package/dist/overlays/edge-details/SelectEdge.css.d.ts +7 -0
- package/dist/overlays/edge-details/SelectEdge.css.js +17 -0
- package/dist/overlays/edge-details/SelectEdge.d.ts +5 -0
- package/dist/overlays/edge-details/SelectEdge.js +129 -0
- package/dist/overlays/edge-details/_types.d.ts +14 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.d.ts +21 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.js +270 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.js +76 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.js +159 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +84 -0
- package/dist/overlays/edge-details/xyflow/styles.css.d.ts +9 -0
- package/dist/overlays/edge-details/xyflow/styles.css.js +21 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +16 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.js +33 -0
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -0
- package/dist/overlays/element-details/ElementDetailsCard.js +484 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.d.ts +4 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.js +11 -0
- package/dist/overlays/element-details/TabPanelDeployments.d.ts +7 -0
- package/dist/overlays/element-details/TabPanelDeployments.js +173 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.d.ts +5 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -0
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +8 -0
- package/dist/overlays/element-details/TabPanelRelationships.js +157 -0
- package/dist/overlays/element-details/TabPanelStructure.css.d.ts +2 -0
- package/dist/overlays/element-details/TabPanelStructure.css.js +7 -0
- package/dist/overlays/element-details/TabPanelStructure.d.ts +25 -0
- package/dist/overlays/element-details/TabPanelStructure.js +91 -0
- package/dist/overlays/index.d.ts +1 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +5 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.js +193 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +19 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.js +290 -0
- package/dist/overlays/relationships-of/SelectElement.css.d.ts +2 -0
- package/dist/overlays/relationships-of/SelectElement.css.js +7 -0
- package/dist/overlays/relationships-of/SelectElement.d.ts +7 -0
- package/dist/overlays/relationships-of/SelectElement.js +126 -0
- package/dist/overlays/relationships-of/_types.d.ts +28 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +22 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.js +496 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.js +120 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.js +194 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +5 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.js +18 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +123 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +14 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.js +24 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +4 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +12 -0
- package/dist/overlays/shared/xyflow/_types.d.ts +77 -0
- package/dist/state/DiagramContext.d.ts +1609 -0
- package/dist/state/DiagramContext.js +101 -0
- package/dist/state/aligners.d.ts +42 -0
- package/dist/state/aligners.js +349 -0
- package/dist/state/diagram-to-xyflow.d.ts +11 -0
- package/dist/state/diagram-to-xyflow.js +113 -0
- package/dist/state/diagramStore.d.ts +1705 -0
- package/dist/state/diagramStore.js +808 -0
- package/dist/state/diagramStore.layout.d.ts +4 -0
- package/dist/state/diagramStore.layout.js +56 -0
- package/dist/style.css +1 -0
- package/dist/theme-vars.css.d.ts +72 -0
- package/dist/theme-vars.css.js +6 -0
- package/dist/theme-vars.css.ts.vanilla.css.js +1 -0
- package/dist/theme-vars.d.ts +3 -0
- package/dist/theme-vars.js +5 -0
- package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
- package/dist/ui/DiagramTitlePanel.css.js +11 -0
- package/dist/ui/DiagramTitlePanel.d.ts +1 -0
- package/dist/ui/DiagramTitlePanel.js +159 -0
- package/dist/ui/DynamicViewWalkthrough.css.d.ts +4 -0
- package/dist/ui/DynamicViewWalkthrough.css.js +11 -0
- package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
- package/dist/ui/DynamicViewWalkthrough.js +156 -0
- package/dist/ui/EnsureMantine.d.ts +7 -0
- package/dist/ui/EnsureMantine.js +14 -0
- package/dist/ui/FramerMotionConfig.d.ts +2 -0
- package/dist/ui/FramerMotionConfig.js +14 -0
- package/dist/ui/Link.d.ts +4 -0
- package/dist/ui/Link.js +36 -0
- package/dist/ui/notation/NotationPanel.css.d.ts +6 -0
- package/dist/ui/notation/NotationPanel.css.js +16 -0
- package/dist/ui/notation/NotationPanel.d.ts +1 -0
- package/dist/ui/notation/NotationPanel.js +250 -0
- package/dist/ui/notation/index.d.ts +1 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +2 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.js +159 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.d.ts +2 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.js +137 -0
- package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
- package/dist/ui/top-left/TopLeftPanel.js +211 -0
- package/dist/ui/top-left/_shared.d.ts +7 -0
- package/dist/ui/top-left/_shared.js +22 -0
- package/dist/ui/top-left/styles.css.d.ts +8 -0
- package/dist/ui/top-left/styles.css.js +17 -0
- package/dist/utils/types.d.ts +8 -0
- package/dist/utils/vector.d.ts +24 -0
- package/dist/utils/vector.js +55 -0
- package/dist/xyflow/EdgeMarkers.d.ts +12 -0
- package/dist/xyflow/EdgeMarkers.js +192 -0
- package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -0
- package/dist/xyflow/FitviewOnDiagramChange.js +72 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.js +96 -0
- package/dist/xyflow/XYFlow.d.ts +8 -0
- package/dist/xyflow/XYFlow.js +145 -0
- package/dist/xyflow/XYFlowBackground.d.ts +10 -0
- package/dist/xyflow/XYFlowBackground.js +25 -0
- package/dist/xyflow/XYFlowInner.d.ts +8 -0
- package/dist/xyflow/XYFlowInner.js +41 -0
- package/dist/xyflow/const.d.ts +7 -0
- package/dist/xyflow/const.js +12 -0
- package/dist/xyflow/edges/EdgeLabel.d.ts +7 -0
- package/dist/xyflow/edges/EdgeLabel.js +160 -0
- package/dist/xyflow/edges/RelationshipEdge.d.ts +6 -0
- package/dist/xyflow/edges/RelationshipEdge.js +443 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.d.ts +4 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.js +11 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.d.ts +13 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.js +211 -0
- package/dist/xyflow/edges/edges.css.d.ts +17 -0
- package/dist/xyflow/edges/edges.css.js +37 -0
- package/dist/xyflow/edges/utils.d.ts +16 -0
- package/dist/xyflow/edges/utils.js +24 -0
- package/dist/xyflow/nodes/AnimateVariants.d.ts +1313 -0
- package/dist/xyflow/nodes/AnimateVariants.js +123 -0
- package/dist/xyflow/nodes/Node.css.d.ts +3 -0
- package/dist/xyflow/nodes/Node.css.js +9 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +14 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.js +27 -0
- package/dist/xyflow/nodes/compound/CompoundNode.d.ts +6 -0
- package/dist/xyflow/nodes/compound/CompoundNode.js +216 -0
- package/dist/xyflow/nodes/compound/index.d.ts +1 -0
- package/dist/xyflow/nodes/element/ElementLink.css.d.ts +3 -0
- package/dist/xyflow/nodes/element/ElementLink.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.js +190 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +17 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.js +175 -0
- package/dist/xyflow/nodes/element/element.css.d.ts +18 -0
- package/dist/xyflow/nodes/element/element.css.js +31 -0
- package/dist/xyflow/nodes/element/index.d.ts +1 -0
- package/dist/xyflow/nodes/shared/ElementIcon.d.ts +8 -0
- package/dist/xyflow/nodes/shared/ElementIcon.js +38 -0
- package/dist/xyflow/nodes/shared/Toolbar.d.ts +9 -0
- package/dist/xyflow/nodes/shared/Toolbar.js +436 -0
- package/dist/xyflow/types.d.ts +36 -0
- package/dist/xyflow/useLayoutConstraints.d.ts +42 -0
- package/dist/xyflow/useLayoutConstraints.js +226 -0
- package/dist/xyflow/useXYFlowEvents.d.ts +160 -0
- package/dist/xyflow/useXYFlowEvents.js +275 -0
- package/dist/xyflow/utils.d.ts +22 -0
- package/dist/xyflow/utils.js +72 -0
- package/package.json +40 -31
- package/src/LikeC4Diagram.props.ts +21 -12
- package/src/LikeC4Diagram.tsx +8 -10
- package/src/LikeC4Search.css.ts +12 -0
- package/src/LikeC4Search.tsx +45 -93
- package/src/controls/Text.ts +5 -0
- package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
- package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
- package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
- package/src/controls/action-buttons/ActionButton.css.ts +29 -0
- package/src/controls/action-buttons/ActionButton.tsx +66 -0
- package/src/controls/action-buttons/ActionButtons.tsx +138 -0
- package/src/hooks/useDiagramState.ts +8 -3
- package/src/hooks/useXYFlow.ts +9 -8
- package/src/index.ts +12 -6
- package/src/likec4model/index.ts +12 -2
- package/src/likec4model/useLikeC4ElementsTree.ts +6 -13
- package/src/likec4model/useLikeC4Model.ts +21 -11
- package/src/overlays/Overlays.tsx +96 -63
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -10
- package/src/overlays/edge-details/_types.ts +13 -33
- package/src/overlays/edge-details/use-layouted-edge-details.ts +35 -26
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +8 -13
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +7 -7
- package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
- package/src/overlays/element-details/ElementDetailsCard.tsx +91 -78
- package/src/overlays/element-details/TabPanelDeployments.css.ts +69 -0
- package/src/overlays/element-details/TabPanelDeployments.tsx +217 -0
- package/src/overlays/element-details/TabPanelRelationships.tsx +8 -9
- package/src/overlays/element-details/TabPanelStructure.tsx +10 -10
- package/src/overlays/relationships-of/RelationshipsOverlay.tsx +1 -1
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +26 -34
- package/src/overlays/relationships-of/SelectElement.tsx +2 -2
- package/src/overlays/relationships-of/_types.ts +20 -58
- package/src/overlays/relationships-of/use-layouted-relationships.ts +54 -59
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +10 -16
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +24 -21
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -15
- package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
- package/src/overlays/shared/xyflow/_types.ts +87 -0
- package/src/state/diagram-to-xyflow.ts +6 -7
- package/src/state/diagramStore.layout.ts +3 -4
- package/src/state/diagramStore.ts +63 -48
- package/src/theme-vars.css.ts +81 -0
- package/src/theme-vars.ts +8 -81
- package/src/ui/DiagramTitlePanel.tsx +7 -34
- package/src/ui/Link.tsx +40 -0
- package/src/ui/notation/NotationPanel.tsx +4 -2
- package/src/ui/top-left/ChangeAutoLayoutButton.tsx +2 -2
- package/src/ui/top-left/TopLeftPanel.tsx +5 -5
- package/src/utils/types.ts +6 -0
- package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
- package/src/xyflow/XYFlow.tsx +2 -2
- package/src/xyflow/edges/EdgeLabel.tsx +26 -19
- package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
- package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +23 -10
- package/src/xyflow/edges/edges.css.ts +68 -74
- package/src/xyflow/edges/utils.ts +6 -6
- package/src/xyflow/nodes/AnimateVariants.ts +143 -0
- package/src/xyflow/nodes/Node.css.ts +44 -0
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +27 -75
- package/src/xyflow/nodes/compound/CompoundNode.tsx +82 -163
- package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +73 -252
- package/src/xyflow/nodes/element/element.css.ts +40 -64
- package/src/xyflow/nodes/shared/ElementIcon.tsx +1 -1
- package/src/xyflow/nodes/shared/Toolbar.tsx +51 -35
- package/src/xyflow/types.ts +48 -51
- package/src/xyflow/useLayoutConstraints.ts +10 -10
- package/src/xyflow/useXYFlowEvents.ts +31 -35
- package/src/xyflow/utils.ts +2 -2
- package/src/ui/OptionsPanel.css.ts +0 -9
- package/src/ui/OptionsPanel.tsx +0 -70
- package/src/ui/options/EdgeOptions.tsx +0 -142
- package/src/ui/options/NodeOptions.tsx +0 -362
- package/src/xyflow/nodes/element/ElementDetails.css.ts +0 -101
- package/src/xyflow/nodes/element/ElementDetails.tsx +0 -393
- package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { DiagramFlowTypes } from '../xyflow/types';
|
|
2
|
+
import { ReactFlowInstance, InternalNode, ReactFlowState } from '@xyflow/react';
|
|
3
|
+
import { EdgeMarkerType, HandleType } from '@xyflow/system';
|
|
4
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
5
|
+
export declare const useXYFlow: () => ReactFlowInstance<DiagramFlowTypes.Node, {
|
|
6
|
+
id: string;
|
|
7
|
+
type: "relationship";
|
|
8
|
+
source: string;
|
|
9
|
+
target: string;
|
|
10
|
+
sourceHandle?: string | null;
|
|
11
|
+
targetHandle?: string | null;
|
|
12
|
+
animated?: boolean;
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
deletable?: boolean;
|
|
15
|
+
selectable?: boolean;
|
|
16
|
+
data: DiagramFlowTypes.DiagramEdgeData;
|
|
17
|
+
selected?: boolean;
|
|
18
|
+
markerStart?: EdgeMarkerType;
|
|
19
|
+
markerEnd?: EdgeMarkerType;
|
|
20
|
+
zIndex?: number;
|
|
21
|
+
ariaLabel?: string;
|
|
22
|
+
interactionWidth?: number;
|
|
23
|
+
label?: ReactNode;
|
|
24
|
+
labelStyle?: CSSProperties;
|
|
25
|
+
labelShowBg?: boolean;
|
|
26
|
+
labelBgStyle?: CSSProperties;
|
|
27
|
+
labelBgPadding?: [number, number];
|
|
28
|
+
labelBgBorderRadius?: number;
|
|
29
|
+
style?: CSSProperties;
|
|
30
|
+
className?: string;
|
|
31
|
+
reconnectable?: boolean | HandleType;
|
|
32
|
+
focusable?: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const useXYNodesData: {
|
|
35
|
+
(nodeId: string): Pick<DiagramFlowTypes.Node, "id" | "type" | "data"> | null;
|
|
36
|
+
(nodeIds: string[]): Pick<DiagramFlowTypes.Node, "id" | "type" | "data">[];
|
|
37
|
+
};
|
|
38
|
+
export declare const useXYInternalNode: (id: string) => InternalNode<DiagramFlowTypes.Node> | undefined;
|
|
39
|
+
export declare function useXYStore<StateSlice = unknown>(selector: (state: DiagramFlowTypes.XYFlowState) => StateSlice, equalityFn?: (a: StateSlice, b: StateSlice) => boolean): StateSlice;
|
|
40
|
+
export declare const useXYStoreApi: () => {
|
|
41
|
+
getState: () => ReactFlowState<DiagramFlowTypes.Node, {
|
|
42
|
+
id: string;
|
|
43
|
+
type: "relationship";
|
|
44
|
+
source: string;
|
|
45
|
+
target: string;
|
|
46
|
+
sourceHandle?: string | null;
|
|
47
|
+
targetHandle?: string | null;
|
|
48
|
+
animated?: boolean;
|
|
49
|
+
hidden?: boolean;
|
|
50
|
+
deletable?: boolean;
|
|
51
|
+
selectable?: boolean;
|
|
52
|
+
data: DiagramFlowTypes.DiagramEdgeData;
|
|
53
|
+
selected?: boolean;
|
|
54
|
+
markerStart?: EdgeMarkerType;
|
|
55
|
+
markerEnd?: EdgeMarkerType;
|
|
56
|
+
zIndex?: number;
|
|
57
|
+
ariaLabel?: string;
|
|
58
|
+
interactionWidth?: number;
|
|
59
|
+
label?: ReactNode;
|
|
60
|
+
labelStyle?: CSSProperties;
|
|
61
|
+
labelShowBg?: boolean;
|
|
62
|
+
labelBgStyle?: CSSProperties;
|
|
63
|
+
labelBgPadding?: [number, number];
|
|
64
|
+
labelBgBorderRadius?: number;
|
|
65
|
+
style?: CSSProperties;
|
|
66
|
+
className?: string;
|
|
67
|
+
reconnectable?: boolean | HandleType;
|
|
68
|
+
focusable?: boolean;
|
|
69
|
+
}>;
|
|
70
|
+
setState: (partial: ReactFlowState<DiagramFlowTypes.Node, {
|
|
71
|
+
id: string;
|
|
72
|
+
type: "relationship";
|
|
73
|
+
source: string;
|
|
74
|
+
target: string;
|
|
75
|
+
sourceHandle?: string | null;
|
|
76
|
+
targetHandle?: string | null;
|
|
77
|
+
animated?: boolean;
|
|
78
|
+
hidden?: boolean;
|
|
79
|
+
deletable?: boolean;
|
|
80
|
+
selectable?: boolean;
|
|
81
|
+
data: DiagramFlowTypes.DiagramEdgeData;
|
|
82
|
+
selected?: boolean;
|
|
83
|
+
markerStart?: EdgeMarkerType;
|
|
84
|
+
markerEnd?: EdgeMarkerType;
|
|
85
|
+
zIndex?: number;
|
|
86
|
+
ariaLabel?: string;
|
|
87
|
+
interactionWidth?: number;
|
|
88
|
+
label?: ReactNode;
|
|
89
|
+
labelStyle?: CSSProperties;
|
|
90
|
+
labelShowBg?: boolean;
|
|
91
|
+
labelBgStyle?: CSSProperties;
|
|
92
|
+
labelBgPadding?: [number, number];
|
|
93
|
+
labelBgBorderRadius?: number;
|
|
94
|
+
style?: CSSProperties;
|
|
95
|
+
className?: string;
|
|
96
|
+
reconnectable?: boolean | HandleType;
|
|
97
|
+
focusable?: boolean;
|
|
98
|
+
}> | Partial< ReactFlowState<DiagramFlowTypes.Node, {
|
|
99
|
+
id: string;
|
|
100
|
+
type: "relationship";
|
|
101
|
+
source: string;
|
|
102
|
+
target: string;
|
|
103
|
+
sourceHandle?: string | null;
|
|
104
|
+
targetHandle?: string | null;
|
|
105
|
+
animated?: boolean;
|
|
106
|
+
hidden?: boolean;
|
|
107
|
+
deletable?: boolean;
|
|
108
|
+
selectable?: boolean;
|
|
109
|
+
data: DiagramFlowTypes.DiagramEdgeData;
|
|
110
|
+
selected?: boolean;
|
|
111
|
+
markerStart?: EdgeMarkerType;
|
|
112
|
+
markerEnd?: EdgeMarkerType;
|
|
113
|
+
zIndex?: number;
|
|
114
|
+
ariaLabel?: string;
|
|
115
|
+
interactionWidth?: number;
|
|
116
|
+
label?: ReactNode;
|
|
117
|
+
labelStyle?: CSSProperties;
|
|
118
|
+
labelShowBg?: boolean;
|
|
119
|
+
labelBgStyle?: CSSProperties;
|
|
120
|
+
labelBgPadding?: [number, number];
|
|
121
|
+
labelBgBorderRadius?: number;
|
|
122
|
+
style?: CSSProperties;
|
|
123
|
+
className?: string;
|
|
124
|
+
reconnectable?: boolean | HandleType;
|
|
125
|
+
focusable?: boolean;
|
|
126
|
+
}>> | ((state: ReactFlowState<DiagramFlowTypes.Node, {
|
|
127
|
+
id: string;
|
|
128
|
+
type: "relationship";
|
|
129
|
+
source: string;
|
|
130
|
+
target: string;
|
|
131
|
+
sourceHandle?: string | null;
|
|
132
|
+
targetHandle?: string | null;
|
|
133
|
+
animated?: boolean;
|
|
134
|
+
hidden?: boolean;
|
|
135
|
+
deletable?: boolean;
|
|
136
|
+
selectable?: boolean;
|
|
137
|
+
data: DiagramFlowTypes.DiagramEdgeData;
|
|
138
|
+
selected?: boolean;
|
|
139
|
+
markerStart?: EdgeMarkerType;
|
|
140
|
+
markerEnd?: EdgeMarkerType;
|
|
141
|
+
zIndex?: number;
|
|
142
|
+
ariaLabel?: string;
|
|
143
|
+
interactionWidth?: number;
|
|
144
|
+
label?: ReactNode;
|
|
145
|
+
labelStyle?: CSSProperties;
|
|
146
|
+
labelShowBg?: boolean;
|
|
147
|
+
labelBgStyle?: CSSProperties;
|
|
148
|
+
labelBgPadding?: [number, number];
|
|
149
|
+
labelBgBorderRadius?: number;
|
|
150
|
+
style?: CSSProperties;
|
|
151
|
+
className?: string;
|
|
152
|
+
reconnectable?: boolean | HandleType;
|
|
153
|
+
focusable?: boolean;
|
|
154
|
+
}>) => ReactFlowState<DiagramFlowTypes.Node, {
|
|
155
|
+
id: string;
|
|
156
|
+
type: "relationship";
|
|
157
|
+
source: string;
|
|
158
|
+
target: string;
|
|
159
|
+
sourceHandle?: string | null;
|
|
160
|
+
targetHandle?: string | null;
|
|
161
|
+
animated?: boolean;
|
|
162
|
+
hidden?: boolean;
|
|
163
|
+
deletable?: boolean;
|
|
164
|
+
selectable?: boolean;
|
|
165
|
+
data: DiagramFlowTypes.DiagramEdgeData;
|
|
166
|
+
selected?: boolean;
|
|
167
|
+
markerStart?: EdgeMarkerType;
|
|
168
|
+
markerEnd?: EdgeMarkerType;
|
|
169
|
+
zIndex?: number;
|
|
170
|
+
ariaLabel?: string;
|
|
171
|
+
interactionWidth?: number;
|
|
172
|
+
label?: ReactNode;
|
|
173
|
+
labelStyle?: CSSProperties;
|
|
174
|
+
labelShowBg?: boolean;
|
|
175
|
+
labelBgStyle?: CSSProperties;
|
|
176
|
+
labelBgPadding?: [number, number];
|
|
177
|
+
labelBgBorderRadius?: number;
|
|
178
|
+
style?: CSSProperties;
|
|
179
|
+
className?: string;
|
|
180
|
+
reconnectable?: boolean | HandleType;
|
|
181
|
+
focusable?: boolean;
|
|
182
|
+
}> | Partial< ReactFlowState<DiagramFlowTypes.Node, {
|
|
183
|
+
id: string;
|
|
184
|
+
type: "relationship";
|
|
185
|
+
source: string;
|
|
186
|
+
target: string;
|
|
187
|
+
sourceHandle?: string | null;
|
|
188
|
+
targetHandle?: string | null;
|
|
189
|
+
animated?: boolean;
|
|
190
|
+
hidden?: boolean;
|
|
191
|
+
deletable?: boolean;
|
|
192
|
+
selectable?: boolean;
|
|
193
|
+
data: DiagramFlowTypes.DiagramEdgeData;
|
|
194
|
+
selected?: boolean;
|
|
195
|
+
markerStart?: EdgeMarkerType;
|
|
196
|
+
markerEnd?: EdgeMarkerType;
|
|
197
|
+
zIndex?: number;
|
|
198
|
+
ariaLabel?: string;
|
|
199
|
+
interactionWidth?: number;
|
|
200
|
+
label?: ReactNode;
|
|
201
|
+
labelStyle?: CSSProperties;
|
|
202
|
+
labelShowBg?: boolean;
|
|
203
|
+
labelBgStyle?: CSSProperties;
|
|
204
|
+
labelBgPadding?: [number, number];
|
|
205
|
+
labelBgBorderRadius?: number;
|
|
206
|
+
style?: CSSProperties;
|
|
207
|
+
className?: string;
|
|
208
|
+
reconnectable?: boolean | HandleType;
|
|
209
|
+
focusable?: boolean;
|
|
210
|
+
}>>), replace?: boolean | undefined) => void;
|
|
211
|
+
subscribe: (listener: (state: ReactFlowState<DiagramFlowTypes.Node, {
|
|
212
|
+
id: string;
|
|
213
|
+
type: "relationship";
|
|
214
|
+
source: string;
|
|
215
|
+
target: string;
|
|
216
|
+
sourceHandle?: string | null;
|
|
217
|
+
targetHandle?: string | null;
|
|
218
|
+
animated?: boolean;
|
|
219
|
+
hidden?: boolean;
|
|
220
|
+
deletable?: boolean;
|
|
221
|
+
selectable?: boolean;
|
|
222
|
+
data: DiagramFlowTypes.DiagramEdgeData;
|
|
223
|
+
selected?: boolean;
|
|
224
|
+
markerStart?: EdgeMarkerType;
|
|
225
|
+
markerEnd?: EdgeMarkerType;
|
|
226
|
+
zIndex?: number;
|
|
227
|
+
ariaLabel?: string;
|
|
228
|
+
interactionWidth?: number;
|
|
229
|
+
label?: ReactNode;
|
|
230
|
+
labelStyle?: CSSProperties;
|
|
231
|
+
labelShowBg?: boolean;
|
|
232
|
+
labelBgStyle?: CSSProperties;
|
|
233
|
+
labelBgPadding?: [number, number];
|
|
234
|
+
labelBgBorderRadius?: number;
|
|
235
|
+
style?: CSSProperties;
|
|
236
|
+
className?: string;
|
|
237
|
+
reconnectable?: boolean | HandleType;
|
|
238
|
+
focusable?: boolean;
|
|
239
|
+
}>, prevState: ReactFlowState<DiagramFlowTypes.Node, {
|
|
240
|
+
id: string;
|
|
241
|
+
type: "relationship";
|
|
242
|
+
source: string;
|
|
243
|
+
target: string;
|
|
244
|
+
sourceHandle?: string | null;
|
|
245
|
+
targetHandle?: string | null;
|
|
246
|
+
animated?: boolean;
|
|
247
|
+
hidden?: boolean;
|
|
248
|
+
deletable?: boolean;
|
|
249
|
+
selectable?: boolean;
|
|
250
|
+
data: DiagramFlowTypes.DiagramEdgeData;
|
|
251
|
+
selected?: boolean;
|
|
252
|
+
markerStart?: EdgeMarkerType;
|
|
253
|
+
markerEnd?: EdgeMarkerType;
|
|
254
|
+
zIndex?: number;
|
|
255
|
+
ariaLabel?: string;
|
|
256
|
+
interactionWidth?: number;
|
|
257
|
+
label?: ReactNode;
|
|
258
|
+
labelStyle?: CSSProperties;
|
|
259
|
+
labelShowBg?: boolean;
|
|
260
|
+
labelBgStyle?: CSSProperties;
|
|
261
|
+
labelBgPadding?: [number, number];
|
|
262
|
+
labelBgBorderRadius?: number;
|
|
263
|
+
style?: CSSProperties;
|
|
264
|
+
className?: string;
|
|
265
|
+
reconnectable?: boolean | HandleType;
|
|
266
|
+
focusable?: boolean;
|
|
267
|
+
}>) => void) => () => void;
|
|
268
|
+
};
|
|
269
|
+
export type XYStoreApi = ReturnType<typeof useXYStoreApi>;
|
|
270
|
+
export declare function useXYEdgesData(edgeIds: string[]): Pick<DiagramFlowTypes.Edge, 'id' | 'data'>[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useReactFlow, useStoreApi, useInternalNode, useStore, useNodesData } from "@xyflow/react";
|
|
2
|
+
import { shallowEqual } from "fast-equals";
|
|
3
|
+
import "react";
|
|
4
|
+
const useXYFlow = useReactFlow;
|
|
5
|
+
const useXYNodesData = useNodesData;
|
|
6
|
+
const useXYInternalNode = useInternalNode;
|
|
7
|
+
function useXYStore(selector, equalityFn) {
|
|
8
|
+
return useStore(
|
|
9
|
+
selector,
|
|
10
|
+
shallowEqual
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
const useXYStoreApi = useStoreApi;
|
|
14
|
+
export {
|
|
15
|
+
useXYFlow,
|
|
16
|
+
useXYInternalNode,
|
|
17
|
+
useXYNodesData,
|
|
18
|
+
useXYStore,
|
|
19
|
+
useXYStoreApi
|
|
20
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { LikeC4Diagram } from './LikeC4Diagram';
|
|
2
|
+
export type { LikeC4DiagramProps } from './LikeC4Diagram';
|
|
3
|
+
export { useLikeC4DiagramView, useLikeC4ElementModel, useLikeC4ElementsTree, useLikeC4Model, useLikeC4View, useLikeC4ViewModel, useLikeC4Views, } from './likec4model';
|
|
4
|
+
export { LikeC4ModelProvider } from './LikeC4ModelProvider';
|
|
5
|
+
export { useSetState } from './hooks/useSetState';
|
|
6
|
+
export { useUpdateEffect } from './hooks/useUpdateEffect';
|
|
7
|
+
export { vars, xyvars } from './theme-vars';
|
|
8
|
+
export type * from './LikeC4Diagram.props';
|
|
9
|
+
export type * from './xyflow/types';
|
|
10
|
+
export { StaticLikeC4Diagram } from './StaticLikeC4Diagram';
|
|
11
|
+
export type { StaticLikeC4DiagramProps } from './StaticLikeC4Diagram';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { LikeC4Diagram } from "./LikeC4Diagram.js";
|
|
3
|
+
import { LikeC4ModelProvider } from "./LikeC4ModelProvider.js";
|
|
4
|
+
import { useSetState } from "./hooks/useSetState.js";
|
|
5
|
+
import { useUpdateEffect } from "./hooks/useUpdateEffect.js";
|
|
6
|
+
import { StaticLikeC4Diagram } from "./StaticLikeC4Diagram.js";
|
|
7
|
+
import { useLikeC4DiagramView, useLikeC4ElementModel, useLikeC4Model, useLikeC4View, useLikeC4ViewModel, useLikeC4Views } from "./likec4model/useLikeC4Model.js";
|
|
8
|
+
import { useLikeC4ElementsTree } from "./likec4model/useLikeC4ElementsTree.js";
|
|
9
|
+
import { vars, xyvars } from "./theme-vars.css.js";
|
|
10
|
+
export {
|
|
11
|
+
LikeC4Diagram,
|
|
12
|
+
LikeC4ModelProvider,
|
|
13
|
+
StaticLikeC4Diagram,
|
|
14
|
+
useLikeC4DiagramView,
|
|
15
|
+
useLikeC4ElementModel,
|
|
16
|
+
useLikeC4ElementsTree,
|
|
17
|
+
useLikeC4Model,
|
|
18
|
+
useLikeC4View,
|
|
19
|
+
useLikeC4ViewModel,
|
|
20
|
+
useLikeC4Views,
|
|
21
|
+
useSetState,
|
|
22
|
+
useUpdateEffect,
|
|
23
|
+
vars,
|
|
24
|
+
xyvars
|
|
25
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fqn, ViewId } from '@likec4/core';
|
|
2
|
+
interface LikeC4ModelTreeNodeData {
|
|
3
|
+
label: string;
|
|
4
|
+
value: Fqn;
|
|
5
|
+
children: LikeC4ModelTreeNodeData[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns a tree of elements in the model.
|
|
9
|
+
* If `viewId` is provided, returns the tree of elements in the view.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useLikeC4ElementsTree(viewId?: ViewId): LikeC4ModelTreeNodeData[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { compareNatural } from "@likec4/core";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { useLikeC4Model } from "./useLikeC4Model.js";
|
|
4
|
+
const sortByLabel = (a, b) => compareNatural(a.label, b.label);
|
|
5
|
+
function buildNode(element) {
|
|
6
|
+
return {
|
|
7
|
+
label: element.title,
|
|
8
|
+
value: element.id,
|
|
9
|
+
children: [...element.children()].map(buildNode).sort(sortByLabel)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function useLikeC4ElementsTree(viewId) {
|
|
13
|
+
const model = useLikeC4Model(true);
|
|
14
|
+
return useMemo(() => {
|
|
15
|
+
if (viewId) {
|
|
16
|
+
const view = model.view(viewId);
|
|
17
|
+
return [...view.roots()].map(buildNode).sort(sortByLabel);
|
|
18
|
+
} else {
|
|
19
|
+
return [...model.roots()].map(buildNode).sort(sortByLabel);
|
|
20
|
+
}
|
|
21
|
+
}, [model, viewId ?? null]);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
useLikeC4ElementsTree
|
|
25
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComputedView, DiagramView, Fqn, LikeC4Model, ViewId } from '@likec4/core';
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
export declare function useLikeC4Model(): LikeC4Model | null;
|
|
4
|
+
export declare function useLikeC4Model(strict: true): LikeC4Model;
|
|
5
|
+
export declare function useLikeC4Model(strict: boolean): LikeC4Model | null;
|
|
6
|
+
export declare function useLikeC4Model(strict: true, type: 'layouted'): LikeC4Model.Layouted;
|
|
7
|
+
export declare function useLikeC4Model(strict: true, type: 'computed'): LikeC4Model.Computed;
|
|
8
|
+
export declare function useLikeC4Model(strict: true, type: 'layouted' | 'computed' | undefined): LikeC4Model;
|
|
9
|
+
export declare function useLikeC4Model(strict: boolean, type: 'layouted'): LikeC4Model.Layouted | null;
|
|
10
|
+
export declare function useLikeC4Model(strict: boolean, type: 'computed'): LikeC4Model.Computed | null;
|
|
11
|
+
export declare function useLikeC4Model(strict: boolean, type: 'layouted' | 'computed' | undefined): LikeC4Model | null;
|
|
12
|
+
export declare function useLikeC4Views(): Record<ViewId, ComputedView | DiagramView>;
|
|
13
|
+
export declare function useLikeC4ViewModel(viewId: LiteralUnion<ViewId, string>): LikeC4Model.View;
|
|
14
|
+
export declare function useLikeC4CurrentViewModel(): LikeC4Model.View;
|
|
15
|
+
/**
|
|
16
|
+
* Parsed view, computed or layouted
|
|
17
|
+
*/
|
|
18
|
+
export declare function useLikeC4View(viewId: LiteralUnion<ViewId, string>): ComputedView | DiagramView | null;
|
|
19
|
+
export declare function useLikeC4DiagramView(viewId: LiteralUnion<ViewId, string>): DiagramView | null;
|
|
20
|
+
export declare function useLikeC4ElementModel(fqn: LiteralUnion<Fqn, string>): LikeC4Model.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import "@likec4/core";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { isString, isNonNullish, isDefined } from "remeda";
|
|
4
|
+
import { LikeC4ModelContext } from "./LikeC4ModelContext.js";
|
|
5
|
+
import { useCurrentViewId } from "../hooks/useDiagramState.js";
|
|
6
|
+
function useLikeC4Model(strict, type) {
|
|
7
|
+
const model = useContext(LikeC4ModelContext);
|
|
8
|
+
if (isString(type) && isNonNullish(model) && model.type !== type) {
|
|
9
|
+
throw new Error(`Invalid LikeC4ModelContext, expected "${type}" but got "${model.type}" in context`);
|
|
10
|
+
}
|
|
11
|
+
if (isDefined(strict) && strict === true && !model) {
|
|
12
|
+
throw new Error("No LikeC4Model found in context");
|
|
13
|
+
}
|
|
14
|
+
return model;
|
|
15
|
+
}
|
|
16
|
+
function useLikeC4Views() {
|
|
17
|
+
return useLikeC4Model(true).$model.views;
|
|
18
|
+
}
|
|
19
|
+
function useLikeC4ViewModel(viewId) {
|
|
20
|
+
return useLikeC4Model(true).view(viewId);
|
|
21
|
+
}
|
|
22
|
+
function useLikeC4CurrentViewModel() {
|
|
23
|
+
const viewId = useCurrentViewId();
|
|
24
|
+
return useLikeC4Model(true).view(viewId);
|
|
25
|
+
}
|
|
26
|
+
function useLikeC4View(viewId) {
|
|
27
|
+
const model = useLikeC4Model(true);
|
|
28
|
+
try {
|
|
29
|
+
return model.view(viewId).$view;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.warn(error);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function useLikeC4DiagramView(viewId) {
|
|
36
|
+
const model = useLikeC4Model(true, "layouted");
|
|
37
|
+
try {
|
|
38
|
+
return model.view(viewId).$view;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.warn(error);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function useLikeC4ElementModel(fqn) {
|
|
45
|
+
return useLikeC4Model(true).element(fqn);
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
useLikeC4CurrentViewModel,
|
|
49
|
+
useLikeC4DiagramView,
|
|
50
|
+
useLikeC4ElementModel,
|
|
51
|
+
useLikeC4Model,
|
|
52
|
+
useLikeC4View,
|
|
53
|
+
useLikeC4ViewModel,
|
|
54
|
+
useLikeC4Views
|
|
55
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DiagramState } from '../hooks';
|
|
2
|
+
import { Context } from 'react';
|
|
3
|
+
export declare const OverlayContext: Context<{
|
|
4
|
+
openOverlay: DiagramState["openOverlay"];
|
|
5
|
+
close: (onClosed?: () => void) => void;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function useOverlayDialog(): {
|
|
8
|
+
openOverlay: DiagramState["openOverlay"];
|
|
9
|
+
close: (onClosed?: () => void) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RemoveScroll, Box, FocusTrap, ActionIcon, Notification, Text, Group, Button } from "@mantine/core";
|
|
3
|
+
import { useHotkeys } from "@mantine/hooks";
|
|
4
|
+
import { IconX } from "@tabler/icons-react";
|
|
5
|
+
import { ReactFlowProvider } from "@xyflow/react";
|
|
6
|
+
import { AnimatePresence, m } from "framer-motion";
|
|
7
|
+
import { memo, useRef, useMemo } from "react";
|
|
8
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
9
|
+
import { isNullish } from "remeda";
|
|
10
|
+
import { useDiagramStoreApi, useDiagramState } from "../hooks/useDiagramState.js";
|
|
11
|
+
import { EdgeDetailsXYFlow } from "./edge-details/EdgeDetailsXYFlow.js";
|
|
12
|
+
import { ElementDetailsCard } from "./element-details/ElementDetailsCard.js";
|
|
13
|
+
import { OverlayContext } from "./OverlayContext.js";
|
|
14
|
+
import { container } from "./Overlays.css.js";
|
|
15
|
+
import { RelationshipsOverlay } from "./relationships-of/RelationshipsOverlay.js";
|
|
16
|
+
function Fallback({ error, resetErrorBoundary }) {
|
|
17
|
+
const errorString = error instanceof Error ? error.message : "Unknown error";
|
|
18
|
+
return /* @__PURE__ */ jsx(Box, { className: container, p: "lg", children: /* @__PURE__ */ jsxs(
|
|
19
|
+
Notification,
|
|
20
|
+
{
|
|
21
|
+
icon: /* @__PURE__ */ jsx(IconX, { style: { width: 16, height: 16 } }),
|
|
22
|
+
styles: {
|
|
23
|
+
icon: {
|
|
24
|
+
alignSelf: "flex-start"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
color: "red",
|
|
28
|
+
title: "Oops, something went wrong",
|
|
29
|
+
py: "lg",
|
|
30
|
+
withCloseButton: false,
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
Text,
|
|
34
|
+
{
|
|
35
|
+
style: {
|
|
36
|
+
whiteSpace: "preserve-breaks"
|
|
37
|
+
},
|
|
38
|
+
children: errorString
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ jsx(Group, { gap: "xs", mt: "sm", children: /* @__PURE__ */ jsx(Button, { color: "gray", size: "xs", variant: "light", onClick: () => resetErrorBoundary(), children: "Reset" }) })
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
) });
|
|
45
|
+
}
|
|
46
|
+
const Overlays = memo(() => {
|
|
47
|
+
const diagramStore = useDiagramStoreApi();
|
|
48
|
+
const {
|
|
49
|
+
activeOverlay,
|
|
50
|
+
viewId
|
|
51
|
+
} = useDiagramState((s) => ({
|
|
52
|
+
activeOverlay: s.activeOverlay,
|
|
53
|
+
viewId: s.view.id
|
|
54
|
+
}));
|
|
55
|
+
const onCloseCbRef = useRef();
|
|
56
|
+
const ctxValue = useMemo(() => ({
|
|
57
|
+
openOverlay: (overlay) => {
|
|
58
|
+
diagramStore.getState().openOverlay(overlay);
|
|
59
|
+
},
|
|
60
|
+
close: (cb) => {
|
|
61
|
+
onCloseCbRef.current = cb;
|
|
62
|
+
diagramStore.getState().closeOverlay();
|
|
63
|
+
}
|
|
64
|
+
}), [diagramStore]);
|
|
65
|
+
const onExitComplete = () => {
|
|
66
|
+
var _a;
|
|
67
|
+
(_a = onCloseCbRef.current) == null ? void 0 : _a.call(onCloseCbRef);
|
|
68
|
+
onCloseCbRef.current = void 0;
|
|
69
|
+
};
|
|
70
|
+
const isActive = !!activeOverlay;
|
|
71
|
+
useHotkeys(
|
|
72
|
+
isActive ? [
|
|
73
|
+
["Escape", (e) => {
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
ctxValue.close();
|
|
76
|
+
}, { preventDefault: true }]
|
|
77
|
+
] : []
|
|
78
|
+
);
|
|
79
|
+
return /* @__PURE__ */ jsx(OverlayContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsxs(ErrorBoundary, { FallbackComponent: Fallback, onReset: () => ctxValue.close(), children: [
|
|
80
|
+
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, onExitComplete, children: (activeOverlay == null ? void 0 : activeOverlay.elementDetails) && /* @__PURE__ */ jsx(ElementDetailsCard, { fqn: activeOverlay.elementDetails }, "details card") }, viewId),
|
|
81
|
+
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, onExitComplete, children: activeOverlay && isNullish(activeOverlay.elementDetails) && /* @__PURE__ */ jsx(RemoveScroll, { forwardProps: true, children: /* @__PURE__ */ jsx(
|
|
82
|
+
Box,
|
|
83
|
+
{
|
|
84
|
+
component: m.div,
|
|
85
|
+
className: container,
|
|
86
|
+
"data-likec4-color": "gray",
|
|
87
|
+
initial: {
|
|
88
|
+
"--backdrop-blur": "0px",
|
|
89
|
+
"--backdrop-opacity": "0%",
|
|
90
|
+
opacity: 0,
|
|
91
|
+
translateY: -15
|
|
92
|
+
},
|
|
93
|
+
animate: {
|
|
94
|
+
"--backdrop-blur": "10px",
|
|
95
|
+
"--backdrop-opacity": "70%",
|
|
96
|
+
opacity: 1,
|
|
97
|
+
translateY: 0
|
|
98
|
+
},
|
|
99
|
+
exit: {
|
|
100
|
+
"--backdrop-blur": "1px",
|
|
101
|
+
"--backdrop-opacity": "0%",
|
|
102
|
+
translateY: -5,
|
|
103
|
+
opacity: 0,
|
|
104
|
+
transition: {
|
|
105
|
+
duration: 0.2
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
children: /* @__PURE__ */ jsxs(FocusTrap, { children: [
|
|
109
|
+
activeOverlay.relationshipsOf && /* @__PURE__ */ jsx(RelationshipsOverlay, { subjectId: activeOverlay.relationshipsOf }),
|
|
110
|
+
activeOverlay.edgeDetails && /* @__PURE__ */ jsx(
|
|
111
|
+
ReactFlowProvider,
|
|
112
|
+
{
|
|
113
|
+
defaultNodes: [],
|
|
114
|
+
defaultEdges: [],
|
|
115
|
+
children: /* @__PURE__ */ jsx(EdgeDetailsXYFlow, { edgeId: activeOverlay.edgeDetails })
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsx(Box, { pos: "absolute", top: "1rem", right: "1rem", children: /* @__PURE__ */ jsx(
|
|
119
|
+
ActionIcon,
|
|
120
|
+
{
|
|
121
|
+
variant: "default",
|
|
122
|
+
size: "lg",
|
|
123
|
+
onClick: (e) => {
|
|
124
|
+
e.stopPropagation();
|
|
125
|
+
ctxValue.close();
|
|
126
|
+
},
|
|
127
|
+
children: /* @__PURE__ */ jsx(IconX, {})
|
|
128
|
+
}
|
|
129
|
+
) })
|
|
130
|
+
] })
|
|
131
|
+
}
|
|
132
|
+
) }) })
|
|
133
|
+
] }) });
|
|
134
|
+
});
|
|
135
|
+
export {
|
|
136
|
+
Overlays
|
|
137
|
+
};
|