Skip to content

Commit a7d30ef

Browse files
committed
chore(Connection): move multipoint connections
1 parent dcf4d7e commit a7d30ef

7 files changed

Lines changed: 25 additions & 27 deletions

File tree

src/react-components/elk/components/BezierMultipointConnection.ts renamed to src/components/canvas/connections/BezierMultipointConnection.ts

File renamed without changes.

src/react-components/elk/components/MultipointConnection.ts renamed to src/components/canvas/connections/MultipointConnection.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import intersects from "intersects";
22

3-
import { Path2DRenderStyleResult } from "../../../components/canvas/connections/BatchPath2D";
4-
import { BlockConnection } from "../../../components/canvas/connections/BlockConnection";
5-
import { isPointInStroke } from "../../../components/canvas/connections/bezierHelpers";
63
import { HitBoxData } from "../../../services/HitTest";
4+
import { TMultipointConnection } from "../../../store/connection/ConnectionState";
75
import { curvePolyline } from "../../../utils/shapes/curvePolyline";
86
import { trangleArrowForVector } from "../../../utils/shapes/triangle";
9-
import { TMultipointConnection } from "../types";
7+
8+
import { Path2DRenderStyleResult } from "./BatchPath2D";
9+
import { BlockConnection } from "./BlockConnection";
10+
import { isPointInStroke } from "./bezierHelpers";
1011

1112
const DEFAULT_FONT_SIZE = 14;
1213

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export * from "./BaseConnection";
22
export * from "./BlockConnection";
3+
export * from "./MultipointConnection";
4+
export * from "./BezierMultipointConnection";
35
export * from "./Arrow";
46
export * from "./BatchPath2D";

src/react-components/elk/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
export { MultipointConnection } from "./components/MultipointConnection";
2-
export {
3-
BezierMultipointConnection,
4-
generateBezierParams,
5-
bezierCurveLine,
6-
} from "./components/BezierMultipointConnection";
71
export { useElk } from "./hooks/useElk";

src/react-components/elk/types/index.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
1-
import { TConnection, TConnectionId } from "../../../store/connection/ConnectionState";
1+
import { TConnectionId, TMultipointConnection } from "../../../store/connection/ConnectionState";
22
import { TPoint } from "../../../utils/types/shapes";
33

4-
export type TLabel = {
5-
height?: number;
6-
width?: number;
7-
x?: number;
8-
y?: number;
9-
text?: string;
10-
};
11-
12-
export type TMultipointConnection = TConnection & {
13-
points?: TPoint[];
14-
labels?: TLabel[];
15-
};
16-
174
export type ConverterResult = {
185
edges: Record<TConnectionId, Pick<TMultipointConnection, "points" | "labels">>;
196
blocks: Record<TConnectionId, TPoint>;

src/store/connection/ConnectionState.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { BaseConnection, TBaseConnectionProps, TBaseConnectionState } from "../.
66
import { TGraphLayerContext } from "../../components/canvas/layers/graphLayer/GraphLayer";
77
import { TConnectionColors } from "../../graphConfig";
88
import { ESelectionStrategy, ISelectionBucket } from "../../services/selection/types";
9+
import { TPoint } from "../../utils/types/shapes";
910
import { TBlockId } from "../block/Block";
1011

1112
import { ConnectionsStore } from "./ConnectionList";
@@ -38,6 +39,19 @@ export type TConnection = {
3839
selected?: boolean;
3940
} & (TConnectionBlockPoint | TConnectionPortPoint);
4041

42+
export type TLabel = {
43+
height?: number;
44+
width?: number;
45+
x?: number;
46+
y?: number;
47+
text?: string;
48+
};
49+
50+
export type TMultipointConnection = TConnection & {
51+
points?: TPoint[];
52+
labels?: TLabel[];
53+
};
54+
4155
export class ConnectionState<T extends TConnection = TConnection> {
4256
public $state = signal<T>(undefined);
4357

src/stories/plugins/elk/elk.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { Description, Meta as StorybookMeta, Title } from "@storybook/addon-docs
55
import type { Meta, StoryFn } from "@storybook/react-webpack5";
66
import ELK, { ElkNode } from "elkjs";
77

8-
import { Graph, GraphState, TBlock, TConnection, TGraphConfig } from "../../../index";
9-
import { GraphCanvas, MultipointConnection, useElk, useGraph, useGraphEvent } from "../../../react-components";
10-
import { TMultipointConnection } from "../../../react-components/elk/types";
8+
import { Graph, GraphState, MultipointConnection, TBlock, TConnection, TGraphConfig } from "../../../index";
9+
import { GraphCanvas, useElk, useGraph, useGraphEvent } from "../../../react-components";
1110
import { useFn } from "../../../react-components/utils/hooks/useFn";
11+
import { TMultipointConnection } from "../../../store/connection/ConnectionState";
1212
import { BlockStory } from "../../main/Block";
1313

1414
import { getExampleConfig } from "./getExampleConfig";

0 commit comments

Comments
 (0)