@likec4/diagram 1.20.1 → 1.20.2
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/dist/LikeC4Diagram.css.d.ts +1 -0
- package/dist/LikeC4Diagram.css.js +3 -1
- package/dist/base/BaseXYFlow.js +15 -14
- package/dist/base/Link.css.d.ts +3 -0
- package/dist/base/Link.css.js +9 -0
- package/dist/base/Link.d.ts +5 -0
- package/dist/base/Link.js +58 -0
- package/dist/base/const.d.ts +1 -0
- package/dist/base/const.js +2 -1
- package/dist/base/example/custom.d.ts +1 -1
- package/dist/base/index.d.ts +1 -0
- package/dist/base/primitives/compound/CompoundActionButton.js +2 -1
- package/dist/base/primitives/compound/CompoundDetailsButton.js +2 -1
- package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +0 -1
- package/dist/base/primitives/compound/CompoundNodeContainer.css.js +4 -6
- package/dist/base/primitives/compound/CompoundNodeContainer.js +2 -2
- package/dist/base/primitives/customEdge.d.ts +1 -1
- package/dist/base/primitives/customEdge.js +1 -1
- package/dist/base/primitives/customNode.js +1 -1
- package/dist/base/primitives/edge/EdgeLabel.js +3 -1
- package/dist/base/primitives/edge/EdgePath.d.ts +2 -1
- package/dist/base/primitives/edge/EdgePath.js +2 -0
- package/dist/base/primitives/element/ElementActionButtons.js +2 -1
- package/dist/base/primitives/element/ElementDetailsButton.js +2 -1
- package/dist/base/primitives/element/ElementNodeContainer.css.d.ts +0 -1
- package/dist/base/primitives/element/ElementNodeContainer.css.js +1 -3
- package/dist/base/primitives/element/ElementNodeContainer.js +2 -3
- package/dist/base/primitives/element/ElementShape.js +4 -2
- package/dist/base/primitives/element/ElementTitle.js +2 -1
- package/dist/base/updateEdges.js +3 -3
- package/dist/base/updateNodes.js +2 -2
- package/dist/context/FramerMotionConfig.js +1 -1
- package/dist/hooks/useDiagram.d.ts +313 -90
- package/dist/hooks/useDiagramActor.d.ts +2 -2
- package/dist/hooks/useDiagramContext.d.ts +1 -1
- package/dist/hooks/useXYFlow.d.ts +2 -1
- package/dist/hooks/useXYFlow.js +5 -0
- package/dist/likec4diagram/XYFlow.js +12 -10
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +2 -2
- package/dist/likec4diagram/custom/index.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/nodeTypes.js +2 -2
- package/dist/likec4diagram/state/actorContext.d.ts +1438 -364
- package/dist/likec4diagram/state/assign.js +2 -2
- package/dist/likec4diagram/state/machine.d.ts +321 -93
- package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +1 -1
- package/dist/likec4diagram/types.d.ts +1 -0
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +4 -3
- package/dist/likec4diagram/useViewToNodesEdges.js +3 -1
- package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +0 -1
- package/dist/overlays/element-details/ElementDetailsCard.css.js +1 -3
- package/dist/overlays/element-details/ElementDetailsCard.js +5 -30
- package/dist/overlays/relationship-details/RelationshipDetails.js +4 -4
- package/dist/overlays/relationship-details/custom/ElementActions.js +1 -3
- package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +1 -1
- package/dist/overlays/relationship-details/hooks.d.ts +2 -2
- package/dist/overlays/relationship-details/hooks.js +7 -7
- package/dist/overlays/relationship-details/useLayoutedDetails.js +7 -10
- package/dist/overlays/relationships-browser/-useRelationshipsView.d.ts +4 -1
- package/dist/overlays/relationships-browser/-useRelationshipsView.js +12 -11
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +81 -66
- package/dist/overlays/relationships-browser/_types.d.ts +2 -1
- package/dist/overlays/relationships-browser/actor.d.ts +15 -2
- package/dist/overlays/relationships-browser/actor.js +262 -65
- package/dist/overlays/relationships-browser/const.d.ts +1 -0
- package/dist/overlays/relationships-browser/const.js +4 -0
- package/dist/overlays/relationships-browser/custom/ElementActions.js +1 -1
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +3 -2
- package/dist/overlays/relationships-browser/custom/edgeTypes.js +24 -6
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +3 -2
- package/dist/overlays/relationships-browser/hooks.d.ts +6 -3
- package/dist/overlays/relationships-browser/hooks.js +4 -2
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +7 -2
- package/dist/style.css +1 -1
- package/dist/utils/xyflow.js +9 -1
- package/package.json +8 -8
- package/src/LikeC4Diagram.css.ts +8 -0
- package/src/base/BaseXYFlow.tsx +23 -14
- package/src/base/Link.css.ts +49 -0
- package/src/base/Link.tsx +66 -0
- package/src/base/const.ts +1 -0
- package/src/base/index.ts +2 -0
- package/src/base/primitives/compound/CompoundActionButton.tsx +2 -1
- package/src/base/primitives/compound/CompoundDetailsButton.tsx +2 -1
- package/src/base/primitives/compound/CompoundNodeContainer.css.ts +16 -10
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +1 -1
- package/src/base/primitives/customEdge.ts +2 -0
- package/src/base/primitives/customNode.ts +3 -0
- package/src/base/primitives/edge/EdgeLabel.tsx +3 -1
- package/src/base/primitives/edge/EdgePath.tsx +3 -0
- package/src/base/primitives/element/ElementActionButtons.tsx +2 -1
- package/src/base/primitives/element/ElementDetailsButton.tsx +2 -1
- package/src/base/primitives/element/ElementNodeContainer.css.ts +9 -4
- package/src/base/primitives/element/ElementNodeContainer.tsx +1 -2
- package/src/base/primitives/element/ElementShape.tsx +4 -3
- package/src/base/primitives/element/ElementTitle.tsx +2 -1
- package/src/base/updateEdges.ts +3 -2
- package/src/base/updateNodes.ts +3 -2
- package/src/context/DiagramFeatures.tsx +1 -0
- package/src/context/FramerMotionConfig.tsx +1 -1
- package/src/hooks/useDiagramActor.ts +7 -5
- package/src/hooks/useDiagramContext.ts +4 -1
- package/src/hooks/useXYFlow.ts +6 -1
- package/src/likec4diagram/XYFlow.tsx +20 -9
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +2 -2
- package/src/likec4diagram/custom/nodes/nodeTypes.tsx +2 -2
- package/src/likec4diagram/types.ts +1 -0
- package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +4 -3
- package/src/likec4diagram/useViewToNodesEdges.ts +1 -0
- package/src/overlays/element-details/ElementDetailsCard.css.ts +0 -28
- package/src/overlays/element-details/ElementDetailsCard.tsx +2 -50
- package/src/overlays/relationship-details/RelationshipDetails.tsx +4 -4
- package/src/overlays/relationship-details/custom/ElementActions.tsx +1 -2
- package/src/overlays/relationship-details/custom/edgeTypes.tsx +0 -5
- package/src/overlays/relationship-details/hooks.ts +6 -6
- package/src/overlays/relationship-details/useLayoutedDetails.ts +7 -10
- package/src/overlays/relationships-browser/-useRelationshipsView.ts +16 -12
- package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +105 -68
- package/src/overlays/relationships-browser/_types.ts +2 -1
- package/src/overlays/relationships-browser/actor.ts +321 -62
- package/src/overlays/relationships-browser/const.ts +1 -0
- package/src/overlays/relationships-browser/custom/ElementActions.tsx +1 -1
- package/src/overlays/relationships-browser/custom/edgeTypes.tsx +25 -6
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +3 -2
- package/src/overlays/relationships-browser/hooks.ts +3 -1
- package/src/overlays/relationships-browser/useViewToNodesEdges.ts +8 -2
- package/dist/likec4diagram/ui/diagram-title/Link.js +0 -36
- package/dist/ui/Link.d.ts +0 -4
- package/src/ui/Link.tsx +0 -40
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LikeC4ViewActorRef, MachineSnapshot } from '../likec4diagram/state/machine';
|
|
2
2
|
import { SyncLayoutActorSnapshot } from '../likec4diagram/state/syncManualLayoutActor';
|
|
3
3
|
export declare function useDiagramActor(): LikeC4ViewActorRef;
|
|
4
|
-
export declare function useDiagramActorState<T>(selector: (state: MachineSnapshot) => T, compare?:
|
|
5
|
-
export declare function useDiagramSyncLayoutState<T>(selector: (state: SyncLayoutActorSnapshot) => T, compare?:
|
|
4
|
+
export declare function useDiagramActorState<T = unknown>(selector: (state: MachineSnapshot) => T, compare?: (a: NoInfer<T>, b: NoInfer<T>) => boolean): T;
|
|
5
|
+
export declare function useDiagramSyncLayoutState<T = unknown>(selector: (state: SyncLayoutActorSnapshot) => T, compare?: (a: NoInfer<T>, b: NoInfer<T>) => boolean): T;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DiagramContext } from '../likec4diagram/state/machine';
|
|
2
|
-
export declare function useDiagramContext<T>(selector: (state: DiagramContext) => T, compare?:
|
|
2
|
+
export declare function useDiagramContext<T = unknown>(selector: (state: DiagramContext) => T, compare?: (a: NoInfer<T>, b: NoInfer<T>) => boolean): T;
|
|
3
3
|
export { DiagramContext } from '../likec4diagram/state/machine';
|
|
@@ -50,7 +50,7 @@ export declare const useXYFlow: () => ReactFlowInstance<Types.Node, {
|
|
|
50
50
|
dimmed?: import("../base").Base.Dimmed;
|
|
51
51
|
};
|
|
52
52
|
}>;
|
|
53
|
-
export declare function useXYStore<StateSlice = unknown>(selector: (state: ReactFlowState<Types.Node, Types.Edge>) => StateSlice, equalityFn?: (a: StateSlice
|
|
53
|
+
export declare function useXYStore<StateSlice = unknown>(selector: (state: ReactFlowState<Types.Node, Types.Edge>) => StateSlice, equalityFn?: (a: NoInfer<StateSlice>, b: NoInfer<StateSlice>) => boolean): StateSlice;
|
|
54
54
|
export declare const useXYStoreApi: () => {
|
|
55
55
|
getState: () => ReactFlowState<Types.Node, {
|
|
56
56
|
id: string;
|
|
@@ -426,3 +426,4 @@ export declare const useXYStoreApi: () => {
|
|
|
426
426
|
};
|
|
427
427
|
export type XYStoreApi = ReturnType<typeof useXYStoreApi>;
|
|
428
428
|
export declare const useXYInternalNode: (id: string) => InternalNode<Types.Node> | undefined;
|
|
429
|
+
export declare function useIsZoomTooSmall(): boolean;
|
package/dist/hooks/useXYFlow.js
CHANGED
|
@@ -10,7 +10,12 @@ function useXYStore(selector, equalityFn) {
|
|
|
10
10
|
}
|
|
11
11
|
const useXYStoreApi = useStoreApi;
|
|
12
12
|
const useXYInternalNode = useInternalNode;
|
|
13
|
+
const selectZoom = (state) => state.transform[2] < 0.2;
|
|
14
|
+
function useIsZoomTooSmall() {
|
|
15
|
+
return useStore(selectZoom);
|
|
16
|
+
}
|
|
13
17
|
export {
|
|
18
|
+
useIsZoomTooSmall,
|
|
14
19
|
useXYFlow,
|
|
15
20
|
useXYInternalNode,
|
|
16
21
|
useXYStore,
|
|
@@ -2,12 +2,12 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { nonNullable } from "@likec4/core";
|
|
3
3
|
import { useCallbackRef } from "@mantine/hooks";
|
|
4
4
|
import clsx from "clsx";
|
|
5
|
+
import { shallowEqual } from "fast-equals";
|
|
5
6
|
import { useDiagram } from "../hooks/useDiagram.js";
|
|
6
7
|
import { useDiagramContext } from "../hooks/useDiagramContext.js";
|
|
7
8
|
import { edgeTypes } from "./custom/index.js";
|
|
8
9
|
import { useLayoutConstraints } from "./useLayoutConstraints.js";
|
|
9
10
|
import { useDiagramEventHandlers } from "../context/DiagramEventHandlers.js";
|
|
10
|
-
import { useEnabledFeature } from "../context/DiagramFeatures.js";
|
|
11
11
|
import { BaseXYFlow } from "../base/BaseXYFlow.js";
|
|
12
12
|
import { nodeTypes } from "./custom/nodes/nodeTypes.js";
|
|
13
13
|
const selectXYProps = (ctx) => ({
|
|
@@ -16,16 +16,21 @@ const selectXYProps = (ctx) => ({
|
|
|
16
16
|
edges: ctx.xyedges,
|
|
17
17
|
pannable: ctx.pannable,
|
|
18
18
|
zoomable: ctx.zoomable,
|
|
19
|
-
fitViewPadding: ctx.fitViewPadding
|
|
19
|
+
fitViewPadding: ctx.fitViewPadding,
|
|
20
|
+
enableFitView: ctx.features.enableFitView,
|
|
21
|
+
enableReadOnly: ctx.features.enableReadOnly
|
|
20
22
|
});
|
|
23
|
+
const equalsXYProps = (a, b) => a.initialized === b.initialized && a.pannable === b.pannable && a.zoomable === b.zoomable && a.fitViewPadding === b.fitViewPadding && a.enableFitView === b.enableFitView && a.enableReadOnly === b.enableReadOnly && shallowEqual(a.nodes, b.nodes) && shallowEqual(a.edges, b.edges);
|
|
21
24
|
const LikeC4DiagramXYFlow = ({ background, ...rest }) => {
|
|
22
25
|
const diagram = useDiagram();
|
|
23
26
|
const {
|
|
24
27
|
initialized,
|
|
25
28
|
nodes,
|
|
26
29
|
edges,
|
|
30
|
+
enableReadOnly,
|
|
31
|
+
enableFitView,
|
|
27
32
|
...props
|
|
28
|
-
} = useDiagramContext(selectXYProps);
|
|
33
|
+
} = useDiagramContext(selectXYProps, equalsXYProps);
|
|
29
34
|
const {
|
|
30
35
|
onNodeContextMenu,
|
|
31
36
|
onCanvasContextMenu,
|
|
@@ -35,12 +40,11 @@ const LikeC4DiagramXYFlow = ({ background, ...rest }) => {
|
|
|
35
40
|
onCanvasClick,
|
|
36
41
|
onCanvasDblClick
|
|
37
42
|
} = useDiagramEventHandlers();
|
|
38
|
-
const {
|
|
39
|
-
enableFitView,
|
|
40
|
-
enableReadOnly
|
|
41
|
-
} = useEnabledFeature("ReadOnly", "FitView");
|
|
42
43
|
const notReadOnly = !enableReadOnly;
|
|
43
44
|
const layoutConstraints = useLayoutConstraints();
|
|
45
|
+
const onViewportResize = useCallbackRef(() => {
|
|
46
|
+
diagram.send({ type: "xyflow.resized" });
|
|
47
|
+
});
|
|
44
48
|
return /* @__PURE__ */ jsx(
|
|
45
49
|
BaseXYFlow,
|
|
46
50
|
{
|
|
@@ -107,9 +111,7 @@ const LikeC4DiagramXYFlow = ({ background, ...rest }) => {
|
|
|
107
111
|
})
|
|
108
112
|
},
|
|
109
113
|
...enableFitView && {
|
|
110
|
-
onViewportResize
|
|
111
|
-
diagram.send({ type: "xyflow.resized" });
|
|
112
|
-
}
|
|
114
|
+
onViewportResize
|
|
113
115
|
},
|
|
114
116
|
...notReadOnly && rest.nodesDraggable && layoutConstraints,
|
|
115
117
|
...props,
|
|
@@ -7,9 +7,9 @@ export declare const RelationshipEdge: NamedExoticComponent<{
|
|
|
7
7
|
target: string;
|
|
8
8
|
style?: CSSProperties;
|
|
9
9
|
id: string;
|
|
10
|
-
selected?: boolean;
|
|
11
10
|
selectable?: boolean;
|
|
12
11
|
deletable?: boolean;
|
|
12
|
+
selected?: boolean;
|
|
13
13
|
animated?: boolean;
|
|
14
14
|
sourceX: number;
|
|
15
15
|
sourceY: number;
|
|
@@ -7,13 +7,13 @@ import { useCallback, forwardRef, Fragment as Fragment$1 } from "react";
|
|
|
7
7
|
import { pipe, map, filter, isTruthy, partition } from "remeda";
|
|
8
8
|
import { useDiagram } from "../../../hooks/useDiagram.js";
|
|
9
9
|
import { useDiagramContext } from "../../../hooks/useDiagramContext.js";
|
|
10
|
-
import { Link } from "../../ui/diagram-title/Link.js";
|
|
11
10
|
import { menuDropdown, menuItemRelationship, endpoint, title } from "./RelationshipsDropdownMenu.css.js";
|
|
12
11
|
import { DiagramContext } from "../../state/machine.js";
|
|
13
12
|
import { useLikeC4Model } from "../../../likec4model/useLikeC4Model.js";
|
|
14
13
|
import { useMantinePortalProps } from "../../../hooks/useMantinePortalProps.js";
|
|
15
14
|
import { useEnabledFeature, IfEnabled } from "../../../context/DiagramFeatures.js";
|
|
16
15
|
import { useDiagramEventHandlers } from "../../../context/DiagramEventHandlers.js";
|
|
16
|
+
import { Link } from "../../../base/Link.js";
|
|
17
17
|
const stopPropagation = (e) => e.stopPropagation();
|
|
18
18
|
const Tooltip = Tooltip$1.withProps({
|
|
19
19
|
color: "gray",
|
|
@@ -194,7 +194,7 @@ const Relationship = forwardRef(({
|
|
|
194
194
|
gap: 3,
|
|
195
195
|
justify: "stretch",
|
|
196
196
|
align: "stretch",
|
|
197
|
-
children: links.map((link) => /* @__PURE__ */ jsx(Link, { link }, link.url))
|
|
197
|
+
children: links.map((link) => /* @__PURE__ */ jsx(Link, { size: "sm", value: link }, link.url))
|
|
198
198
|
}
|
|
199
199
|
)
|
|
200
200
|
] });
|
|
@@ -32,7 +32,7 @@ const ElementDetailsButtonWithHandler = ({ fqn, ...props }) => {
|
|
|
32
32
|
};
|
|
33
33
|
const nodeTypes = {
|
|
34
34
|
element: customNode((props) => /* @__PURE__ */ jsxs(ElementNodeContainer, { nodeProps: props, children: [
|
|
35
|
-
/* @__PURE__ */ jsx(ElementShape, { ...props }),
|
|
35
|
+
/* @__PURE__ */ jsx(ElementShape, { ...props, isMultiple: props.data.isMultiple }),
|
|
36
36
|
/* @__PURE__ */ jsx(ElementTitle, { ...props }),
|
|
37
37
|
/* @__PURE__ */ jsx(ElementActions, { ...props }),
|
|
38
38
|
/* @__PURE__ */ jsx(
|
|
@@ -46,7 +46,7 @@ const nodeTypes = {
|
|
|
46
46
|
/* @__PURE__ */ jsx(DefaultHandles, {})
|
|
47
47
|
] })),
|
|
48
48
|
deployment: customNode((props) => /* @__PURE__ */ jsxs(ElementNodeContainer, { nodeProps: props, children: [
|
|
49
|
-
/* @__PURE__ */ jsx(ElementShape, { ...props }),
|
|
49
|
+
/* @__PURE__ */ jsx(ElementShape, { ...props, isMultiple: props.data.isMultiple }),
|
|
50
50
|
/* @__PURE__ */ jsx(ElementTitle, { ...props }),
|
|
51
51
|
/* @__PURE__ */ jsx(DeploymentElementActions, { ...props }),
|
|
52
52
|
!!props.data.modelFqn && /* @__PURE__ */ jsx(
|