@next-bricks/diagram 0.28.0 → 0.29.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/dist/bricks.json +3 -3
- package/dist/chunks/1728.1dbc9d53.js +2 -0
- package/dist/chunks/1728.1dbc9d53.js.map +1 -0
- package/dist/chunks/1860.4fd60630.js +2 -0
- package/dist/chunks/1860.4fd60630.js.map +1 -0
- package/dist/chunks/{1972.8418a5c0.js → 1972.d6fea46c.js} +2 -2
- package/dist/chunks/{1972.8418a5c0.js.map → 1972.d6fea46c.js.map} +1 -1
- package/dist/chunks/2311.1877f3a0.js +2 -0
- package/dist/chunks/2311.1877f3a0.js.map +1 -0
- package/dist/chunks/5481.d6977dfc.js +3 -0
- package/dist/chunks/5481.d6977dfc.js.map +1 -0
- package/dist/chunks/7034.286dd8ae.js +3 -0
- package/dist/chunks/7034.286dd8ae.js.map +1 -0
- package/dist/chunks/{9591.d3a952ac.js → 9591.c5101110.js} +2 -2
- package/dist/chunks/{9591.d3a952ac.js.map → 9591.c5101110.js.map} +1 -1
- package/dist/chunks/{eo-diagram.40f64d0f.js → eo-diagram.5f32fd41.js} +2 -2
- package/dist/chunks/eo-diagram.5f32fd41.js.map +1 -0
- package/dist/chunks/eo-display-canvas.577f0b51.js +2 -0
- package/dist/chunks/eo-display-canvas.577f0b51.js.map +1 -0
- package/dist/chunks/eo-draw-canvas.cdb7565f.js +2 -0
- package/dist/chunks/eo-draw-canvas.cdb7565f.js.map +1 -0
- package/dist/chunks/main.08edb90f.js +2 -0
- package/dist/chunks/main.08edb90f.js.map +1 -0
- package/dist/examples.json +4 -4
- package/dist/index.6f17b5d2.js +2 -0
- package/dist/index.6f17b5d2.js.map +1 -0
- package/dist/manifest.json +90 -72
- package/dist/types.json +3228 -2624
- package/dist-types/display-canvas/index.d.ts +5 -1
- package/dist-types/draw-canvas/CellComponent.d.ts +3 -2
- package/dist-types/draw-canvas/constants.d.ts +1 -0
- package/dist-types/draw-canvas/index.d.ts +7 -1
- package/dist-types/draw-canvas/interfaces.d.ts +30 -2
- package/dist-types/draw-canvas/processors/asserts.d.ts +1 -0
- package/dist-types/draw-canvas/processors/handleMouseDown.d.ts +3 -2
- package/dist-types/draw-canvas/processors/updateCells.d.ts +6 -3
- package/dist-types/shared/canvas/useAutoCenter.d.ts +2 -1
- package/dist-types/shared/canvas/useLayout.d.ts +19 -0
- package/dist-types/shared/canvas/useReady.d.ts +7 -0
- package/docs/eo-display-canvas.md +276 -0
- package/docs/eo-draw-canvas.md +770 -0
- package/package.json +2 -2
- package/dist/chunks/1728.5cff5747.js +0 -2
- package/dist/chunks/1728.5cff5747.js.map +0 -1
- package/dist/chunks/4054.a7e7e379.js +0 -2
- package/dist/chunks/4054.a7e7e379.js.map +0 -1
- package/dist/chunks/4456.3fd8ee7c.js +0 -2
- package/dist/chunks/4456.3fd8ee7c.js.map +0 -1
- package/dist/chunks/5816.f6e1a89e.js +0 -3
- package/dist/chunks/5816.f6e1a89e.js.map +0 -1
- package/dist/chunks/730.3f786ebf.js +0 -3
- package/dist/chunks/730.3f786ebf.js.map +0 -1
- package/dist/chunks/9061.cbb65689.js +0 -2
- package/dist/chunks/9061.cbb65689.js.map +0 -1
- package/dist/chunks/eo-diagram.40f64d0f.js.map +0 -1
- package/dist/chunks/eo-display-canvas.d8b6ac59.js +0 -2
- package/dist/chunks/eo-display-canvas.d8b6ac59.js.map +0 -1
- package/dist/chunks/eo-draw-canvas.4963b54f.js +0 -2
- package/dist/chunks/eo-draw-canvas.4963b54f.js.map +0 -1
- package/dist/chunks/main.2025fb50.js +0 -2
- package/dist/chunks/main.2025fb50.js.map +0 -1
- package/dist/index.0e3710fb.js +0 -2
- package/dist/index.0e3710fb.js.map +0 -1
- /package/dist/chunks/{5816.f6e1a89e.js.LICENSE.txt → 5481.d6977dfc.js.LICENSE.txt} +0 -0
- /package/dist/chunks/{730.3f786ebf.js.LICENSE.txt → 7034.286dd8ae.js.LICENSE.txt} +0 -0
|
@@ -2,9 +2,11 @@ import React from "react";
|
|
|
2
2
|
import { ReactNextElement } from "@next-core/react-element";
|
|
3
3
|
import "@next-core/theme";
|
|
4
4
|
import type { RangeTuple, SizeTuple } from "../diagram/interfaces";
|
|
5
|
-
import type { ActiveTarget, InitialCell, NodeBrickConf, CellContextMenuDetail, EdgeLineConf } from "../draw-canvas/interfaces";
|
|
5
|
+
import type { ActiveTarget, InitialCell, NodeBrickConf, CellContextMenuDetail, EdgeLineConf, LayoutType, LayoutOptions } from "../draw-canvas/interfaces";
|
|
6
6
|
export interface EoDisplayCanvasProps {
|
|
7
7
|
cells: InitialCell[] | undefined;
|
|
8
|
+
layout: LayoutType;
|
|
9
|
+
layoutOptions?: LayoutOptions;
|
|
8
10
|
defaultNodeSize: SizeTuple;
|
|
9
11
|
defaultNodeBricks?: NodeBrickConf[];
|
|
10
12
|
defaultEdgeLines?: EdgeLineConf[];
|
|
@@ -24,6 +26,8 @@ export declare class EoDisplayCanvas extends ReactNextElement implements EoDispl
|
|
|
24
26
|
* 仅当初始化时使用,渲染后重新设置 `cells` 将无效。
|
|
25
27
|
*/
|
|
26
28
|
accessor cells: InitialCell[] | undefined;
|
|
29
|
+
accessor layout: LayoutType;
|
|
30
|
+
accessor layoutOptions: LayoutOptions | undefined;
|
|
27
31
|
accessor defaultNodeSize: SizeTuple;
|
|
28
32
|
accessor defaultNodeBricks: NodeBrickConf[] | undefined;
|
|
29
33
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { ActiveTarget, Cell, CellContextMenuDetail, DecoratorTextChangeDetail, EdgeLineConf, NodeBrickConf } from "./interfaces";
|
|
2
|
+
import type { ActiveTarget, Cell, CellContextMenuDetail, DecoratorTextChangeDetail, EdgeLineConf, LayoutType, NodeBrickConf } from "./interfaces";
|
|
3
3
|
import type { MoveCellPayload, ResizeCellPayload } from "./reducers/interfaces";
|
|
4
4
|
import type { SizeTuple, TransformLiteral } from "../diagram/interfaces";
|
|
5
5
|
export interface CellComponentProps {
|
|
6
|
+
layout: LayoutType;
|
|
6
7
|
cell: Cell;
|
|
7
8
|
cells: Cell[];
|
|
8
9
|
defaultNodeBricks?: NodeBrickConf[];
|
|
@@ -27,4 +28,4 @@ export interface CellComponentProps {
|
|
|
27
28
|
onCellMouseEnter?(cell: Cell): void;
|
|
28
29
|
onCellMouseLeave?(cell: Cell): void;
|
|
29
30
|
}
|
|
30
|
-
export declare function CellComponent({ cell, cells, defaultNodeBricks, defaultEdgeLines, markerEnd, active, readOnly, transform, unrelatedCells, onCellMoving, onCellMoved, onCellResizing, onCellResized, onSwitchActiveTarget, onCellContextMenu, onDecoratorTextEditing, onDecoratorTextChange, onNodeBrickResize, onCellMouseEnter, onCellMouseLeave, }: CellComponentProps): JSX.Element | null;
|
|
31
|
+
export declare function CellComponent({ layout, cell, cells, defaultNodeBricks, defaultEdgeLines, markerEnd, active, readOnly, transform, unrelatedCells, onCellMoving, onCellMoved, onCellResizing, onCellResized, onSwitchActiveTarget, onCellContextMenu, onDecoratorTextEditing, onDecoratorTextChange, onNodeBrickResize, onCellMouseEnter, onCellMouseLeave, }: CellComponentProps): JSX.Element | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const SYMBOL_FOR_SIZE_INITIALIZED: unique symbol;
|
|
2
|
+
export declare const SYMBOL_FOR_LAYOUT_INITIALIZED: unique symbol;
|
|
2
3
|
export declare const DEFAULT_NODE_SIZE = 20;
|
|
3
4
|
export declare const DEFAULT_NODE_GAP = 36;
|
|
4
5
|
export declare const DEFAULT_AREA_WIDTH = 100;
|
|
@@ -3,10 +3,12 @@ import { ReactNextElement } from "@next-core/react-element";
|
|
|
3
3
|
import type { UseSingleBrickConf } from "@next-core/react-runtime";
|
|
4
4
|
import "@next-core/theme";
|
|
5
5
|
import type { PositionTuple, RangeTuple, SizeTuple, TransformLiteral } from "../diagram/interfaces";
|
|
6
|
-
import type { ActiveTarget, Cell, EdgeCell, InitialCell, NodeBrickConf, NodeCell, NodeId, DecoratorCell, DecoratorType, CellContextMenuDetail, ConnectNodesDetail, EdgeLineConf, DecoratorTextChangeDetail } from "./interfaces";
|
|
6
|
+
import type { ActiveTarget, Cell, EdgeCell, InitialCell, NodeBrickConf, NodeCell, NodeId, DecoratorCell, DecoratorType, CellContextMenuDetail, ConnectNodesDetail, EdgeLineConf, DecoratorTextChangeDetail, LayoutType, LayoutOptions } from "./interfaces";
|
|
7
7
|
import type { MoveCellPayload, ResizeCellPayload } from "./reducers/interfaces";
|
|
8
8
|
export interface EoDrawCanvasProps {
|
|
9
9
|
cells: InitialCell[] | undefined;
|
|
10
|
+
layout: LayoutType;
|
|
11
|
+
layoutOptions?: LayoutOptions;
|
|
10
12
|
defaultNodeSize: SizeTuple;
|
|
11
13
|
defaultNodeBricks?: NodeBrickConf[];
|
|
12
14
|
defaultEdgeLines?: EdgeLineConf[];
|
|
@@ -44,6 +46,7 @@ export interface UpdateCellsContext {
|
|
|
44
46
|
}
|
|
45
47
|
export interface AddNodesContext {
|
|
46
48
|
defaultNodeSize: SizeTuple;
|
|
49
|
+
canvasWidth: number;
|
|
47
50
|
canvasHeight: number;
|
|
48
51
|
}
|
|
49
52
|
export declare const EoDrawCanvasComponent: React.ForwardRefExoticComponent<EoDrawCanvasComponentProps & React.RefAttributes<DrawCanvasRef>>;
|
|
@@ -58,6 +61,8 @@ export declare class EoDrawCanvas extends ReactNextElement implements EoDrawCanv
|
|
|
58
61
|
* 仅当初始化时使用,渲染后重新设置 `cells` 将无效。
|
|
59
62
|
*/
|
|
60
63
|
accessor cells: InitialCell[] | undefined;
|
|
64
|
+
accessor layout: LayoutType;
|
|
65
|
+
accessor layoutOptions: LayoutOptions | undefined;
|
|
61
66
|
accessor defaultNodeSize: SizeTuple;
|
|
62
67
|
accessor defaultNodeBricks: NodeBrickConf[] | undefined;
|
|
63
68
|
/**
|
|
@@ -109,6 +114,7 @@ export interface DrawCanvasRef {
|
|
|
109
114
|
manuallyConnectNodes(source: NodeId): Promise<ConnectNodesDetail>;
|
|
110
115
|
updateCells(cells: InitialCell[], ctx: Partial<UpdateCellsContext> & {
|
|
111
116
|
defaultNodeSize: SizeTuple;
|
|
117
|
+
canvasWidth: number;
|
|
112
118
|
canvasHeight: number;
|
|
113
119
|
}): {
|
|
114
120
|
cells: Cell[];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { UseSingleBrickConf } from "@next-core/react-runtime";
|
|
2
|
+
import type { SimulationLinkDatum, SimulationNodeDatum } from "d3-force";
|
|
2
3
|
import type { ResizeCellPayload } from "./reducers/interfaces";
|
|
3
|
-
import type { PositionTuple, TransformLiteral } from "../diagram/interfaces";
|
|
4
|
-
import { SYMBOL_FOR_SIZE_INITIALIZED } from "./constants";
|
|
4
|
+
import type { PartialRectTuple, PositionTuple, TransformLiteral } from "../diagram/interfaces";
|
|
5
|
+
import { SYMBOL_FOR_SIZE_INITIALIZED, type SYMBOL_FOR_LAYOUT_INITIALIZED } from "./constants";
|
|
5
6
|
export type Cell = NodeCell | EdgeCell | DecoratorCell;
|
|
6
7
|
export type BrickCell = NodeBrickCell;
|
|
7
8
|
export type NodeCell = NodeBrickCell;
|
|
@@ -17,6 +18,7 @@ export interface BaseNodeCell extends BaseCell {
|
|
|
17
18
|
id: NodeId;
|
|
18
19
|
view: NodeView;
|
|
19
20
|
[SYMBOL_FOR_SIZE_INITIALIZED]?: boolean;
|
|
21
|
+
[SYMBOL_FOR_LAYOUT_INITIALIZED]?: boolean;
|
|
20
22
|
}
|
|
21
23
|
export interface BaseEdgeCell extends BaseCell {
|
|
22
24
|
type: "edge";
|
|
@@ -108,3 +110,29 @@ export interface DecoratorTextChangeDetail {
|
|
|
108
110
|
id: string;
|
|
109
111
|
view: DecoratorView;
|
|
110
112
|
}
|
|
113
|
+
export type LayoutType = "manual" | "force" | "dagre" | undefined;
|
|
114
|
+
export type LayoutOptions = LayoutOptionsDagre | LayoutOptionsForce;
|
|
115
|
+
export interface LayoutOptionsDagre extends BaseLayoutOptions {
|
|
116
|
+
rankdir?: "TB" | "BT" | "LR" | "RL";
|
|
117
|
+
ranksep?: number;
|
|
118
|
+
edgesep?: number;
|
|
119
|
+
nodesep?: number;
|
|
120
|
+
align?: "UL" | "UR" | "DL" | "DR";
|
|
121
|
+
}
|
|
122
|
+
export interface LayoutOptionsForce extends BaseLayoutOptions {
|
|
123
|
+
collide?: boolean | ForceCollideOptions;
|
|
124
|
+
}
|
|
125
|
+
export interface ForceCollideOptions {
|
|
126
|
+
radiusDiff?: number;
|
|
127
|
+
strength?: number;
|
|
128
|
+
iterations?: number;
|
|
129
|
+
}
|
|
130
|
+
export interface BaseLayoutOptions {
|
|
131
|
+
nodePadding?: PartialRectTuple;
|
|
132
|
+
}
|
|
133
|
+
export interface ForceNode extends SimulationNodeDatum {
|
|
134
|
+
id: NodeId;
|
|
135
|
+
width: number;
|
|
136
|
+
height: number;
|
|
137
|
+
}
|
|
138
|
+
export type ForceLink = SimulationLinkDatum<ForceNode>;
|
|
@@ -3,3 +3,4 @@ export declare function isNodeCell(cell: Cell): cell is NodeCell;
|
|
|
3
3
|
export declare function isDecoratorCell(cell: Cell): cell is DecoratorCell;
|
|
4
4
|
export declare function isInitialNodeCell(cell: InitialCell): cell is InitialNodeCell;
|
|
5
5
|
export declare function isEdgeCell(cell: Cell): cell is EdgeCell;
|
|
6
|
+
export declare function isNodeOrEdgeCell(cell: Cell): cell is NodeCell | EdgeCell;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ActiveTarget, Cell } from "../interfaces";
|
|
1
|
+
import type { ActiveTarget, Cell, LayoutType } from "../interfaces";
|
|
2
2
|
import type { MoveCellPayload, ResizeCellPayload } from "../reducers/interfaces";
|
|
3
|
-
export declare function handleMouseDown(event: MouseEvent, { action, cell, scale, onCellMoving, onCellMoved, onCellResizing, onCellResized, onSwitchActiveTarget, }: {
|
|
3
|
+
export declare function handleMouseDown(event: MouseEvent, { action, cell, scale, layout, onCellMoving, onCellMoved, onCellResizing, onCellResized, onSwitchActiveTarget, }: {
|
|
4
4
|
action: "move" | "resize";
|
|
5
5
|
cell: Cell;
|
|
6
6
|
scale: number;
|
|
7
|
+
layout?: LayoutType;
|
|
7
8
|
onCellMoving?(info: MoveCellPayload): void;
|
|
8
9
|
onCellMoved?(info: MoveCellPayload): void;
|
|
9
10
|
onCellResizing?(info: ResizeCellPayload): void;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { SizeTuple, TransformLiteral } from "../../diagram/interfaces";
|
|
2
|
-
import type { Cell, InitialCell, NodeId } from "../interfaces";
|
|
3
|
-
export declare function updateCells({ cells, previousCells, defaultNodeSize, canvasHeight, transform, reason, parent, }: {
|
|
1
|
+
import type { RangeTuple, SizeTuple, TransformLiteral } from "../../diagram/interfaces";
|
|
2
|
+
import type { Cell, InitialCell, LayoutType, NodeId } from "../interfaces";
|
|
3
|
+
export declare function updateCells({ cells, layout, previousCells, defaultNodeSize, canvasWidth, canvasHeight, scaleRange, transform, reason, parent, }: {
|
|
4
4
|
cells: InitialCell[];
|
|
5
|
+
layout?: LayoutType;
|
|
5
6
|
previousCells: Cell[];
|
|
6
7
|
defaultNodeSize: SizeTuple;
|
|
8
|
+
canvasWidth: number;
|
|
7
9
|
canvasHeight: number;
|
|
10
|
+
scaleRange: RangeTuple;
|
|
8
11
|
transform: TransformLiteral;
|
|
9
12
|
reason?: "add-related-nodes";
|
|
10
13
|
parent?: NodeId;
|
|
@@ -5,6 +5,7 @@ import type { Cell } from "../../draw-canvas/interfaces";
|
|
|
5
5
|
export interface UseAutoCenterOptions {
|
|
6
6
|
rootRef: React.RefObject<SVGSVGElement>;
|
|
7
7
|
cells: Cell[];
|
|
8
|
+
layoutInitialized: boolean;
|
|
8
9
|
zoomable?: boolean;
|
|
9
10
|
zoomer: ZoomBehavior<SVGSVGElement, unknown>;
|
|
10
11
|
scaleRange: RangeTuple;
|
|
@@ -13,4 +14,4 @@ export type UseAutoCenterResult = [
|
|
|
13
14
|
centered: boolean,
|
|
14
15
|
setCentered: React.Dispatch<React.SetStateAction<boolean>>
|
|
15
16
|
];
|
|
16
|
-
export declare function useAutoCenter({ rootRef, cells, zoomable, zoomer, scaleRange, }: UseAutoCenterOptions): UseAutoCenterResult;
|
|
17
|
+
export declare function useAutoCenter({ rootRef, cells, layoutInitialized, zoomable, zoomer, scaleRange, }: UseAutoCenterOptions): UseAutoCenterResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ZoomBehavior } from "d3-zoom";
|
|
3
|
+
import type { Cell, LayoutOptions, LayoutType } from "../../draw-canvas/interfaces";
|
|
4
|
+
import type { RangeTuple } from "../../diagram/interfaces";
|
|
5
|
+
import type { DrawCanvasAction } from "../../draw-canvas/reducers/interfaces";
|
|
6
|
+
export interface UseLayoutOptions {
|
|
7
|
+
layout: LayoutType;
|
|
8
|
+
layoutOptions?: LayoutOptions;
|
|
9
|
+
rootRef: React.RefObject<SVGSVGElement>;
|
|
10
|
+
cells: Cell[];
|
|
11
|
+
zoomable?: boolean;
|
|
12
|
+
zoomer: ZoomBehavior<SVGSVGElement, unknown>;
|
|
13
|
+
scaleRange: RangeTuple;
|
|
14
|
+
dispatch: (value: DrawCanvasAction) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function useLayout({ layout, layoutOptions, rootRef, cells, zoomable, zoomer, scaleRange, dispatch, }: UseLayoutOptions): {
|
|
17
|
+
centered: boolean;
|
|
18
|
+
setCentered: React.Dispatch<React.SetStateAction<boolean>>;
|
|
19
|
+
};
|
|
@@ -146,3 +146,279 @@
|
|
|
146
146
|
]
|
|
147
147
|
%>
|
|
148
148
|
```
|
|
149
|
+
|
|
150
|
+
### Force layout
|
|
151
|
+
|
|
152
|
+
```yaml preview minHeight="600px"
|
|
153
|
+
- brick: div
|
|
154
|
+
properties:
|
|
155
|
+
style:
|
|
156
|
+
display: flex
|
|
157
|
+
height: 600px
|
|
158
|
+
gap: 1em
|
|
159
|
+
context:
|
|
160
|
+
- name: initialCells
|
|
161
|
+
value: |
|
|
162
|
+
<%
|
|
163
|
+
[
|
|
164
|
+
{
|
|
165
|
+
type: "decorator",
|
|
166
|
+
id: "area-1",
|
|
167
|
+
decorator: "area",
|
|
168
|
+
view: {
|
|
169
|
+
x: 10,
|
|
170
|
+
y: 20,
|
|
171
|
+
width: 400,
|
|
172
|
+
height: 300,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: "edge",
|
|
177
|
+
source: "X",
|
|
178
|
+
target: "Y",
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
type: "edge",
|
|
182
|
+
source: "X",
|
|
183
|
+
target: "Z",
|
|
184
|
+
data: {
|
|
185
|
+
virtual: true,
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
].concat(
|
|
189
|
+
["X", "Y", "Z", "W"].map((id) => ({
|
|
190
|
+
type: "node",
|
|
191
|
+
id,
|
|
192
|
+
data: {
|
|
193
|
+
name: `Node ${id}`,
|
|
194
|
+
},
|
|
195
|
+
view: {
|
|
196
|
+
width: 60,
|
|
197
|
+
height: 60,
|
|
198
|
+
}
|
|
199
|
+
}))
|
|
200
|
+
).concat([
|
|
201
|
+
{
|
|
202
|
+
type: "decorator",
|
|
203
|
+
id: "text-1",
|
|
204
|
+
decorator: "text",
|
|
205
|
+
view: {
|
|
206
|
+
x: 100,
|
|
207
|
+
y: 120,
|
|
208
|
+
width: 100,
|
|
209
|
+
height: 20,
|
|
210
|
+
text: "Hello!"
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
])
|
|
214
|
+
%>
|
|
215
|
+
- name: activeTarget
|
|
216
|
+
- name: targetCell
|
|
217
|
+
children:
|
|
218
|
+
- brick: div
|
|
219
|
+
properties:
|
|
220
|
+
style:
|
|
221
|
+
flex: 1
|
|
222
|
+
minWidth: 0
|
|
223
|
+
children:
|
|
224
|
+
- brick: eo-display-canvas
|
|
225
|
+
properties:
|
|
226
|
+
style:
|
|
227
|
+
width: 100%
|
|
228
|
+
height: 100%
|
|
229
|
+
activeTarget: <%= CTX.activeTarget %>
|
|
230
|
+
fadeUnrelatedCells: true
|
|
231
|
+
layout: force
|
|
232
|
+
# Initial nodes only
|
|
233
|
+
defaultNodeSize: [60, 60]
|
|
234
|
+
defaultNodeBricks:
|
|
235
|
+
- useBrick:
|
|
236
|
+
brick: diagram.experimental-node
|
|
237
|
+
properties:
|
|
238
|
+
textContent: <% `Node ${DATA.node.id}` %>
|
|
239
|
+
status: |
|
|
240
|
+
<%=
|
|
241
|
+
CTX.activeTarget?.type === "node" && CTX.activeTarget.id === DATA.node.id
|
|
242
|
+
? "highlighted"
|
|
243
|
+
// : CTX.unrelated.some(n =>
|
|
244
|
+
// n.type === "node" && n.id === DATA.node.id
|
|
245
|
+
// )
|
|
246
|
+
// ? "faded"
|
|
247
|
+
: "default"
|
|
248
|
+
%>
|
|
249
|
+
defaultEdgeLines:
|
|
250
|
+
- if: <% DATA.edge.data?.virtual %>
|
|
251
|
+
dashed: true
|
|
252
|
+
cells: <% CTX.initialCells %>
|
|
253
|
+
events:
|
|
254
|
+
activeTarget.change:
|
|
255
|
+
action: context.replace
|
|
256
|
+
args:
|
|
257
|
+
- activeTarget
|
|
258
|
+
- <% EVENT.detail %>
|
|
259
|
+
cell.contextmenu:
|
|
260
|
+
- target: eo-context-menu
|
|
261
|
+
method: open
|
|
262
|
+
args:
|
|
263
|
+
- position:
|
|
264
|
+
- <% EVENT.detail.clientX %>
|
|
265
|
+
- <% EVENT.detail.clientY %>
|
|
266
|
+
- action: context.replace
|
|
267
|
+
args:
|
|
268
|
+
- targetCell
|
|
269
|
+
- <% EVENT.detail.cell %>
|
|
270
|
+
scale.change:
|
|
271
|
+
action: context.replace
|
|
272
|
+
args:
|
|
273
|
+
- scale
|
|
274
|
+
- <% EVENT.detail %>
|
|
275
|
+
- brick: eo-context-menu
|
|
276
|
+
properties:
|
|
277
|
+
actions: |
|
|
278
|
+
<%=
|
|
279
|
+
[
|
|
280
|
+
{
|
|
281
|
+
text: `Test ${CTX.targetCell?.type}`,
|
|
282
|
+
event: `test-${CTX.targetCell?.type}`,
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
%>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Dagre layout
|
|
289
|
+
|
|
290
|
+
```yaml preview minHeight="600px"
|
|
291
|
+
- brick: div
|
|
292
|
+
properties:
|
|
293
|
+
style:
|
|
294
|
+
display: flex
|
|
295
|
+
height: 600px
|
|
296
|
+
gap: 1em
|
|
297
|
+
context:
|
|
298
|
+
- name: initialCells
|
|
299
|
+
value: |
|
|
300
|
+
<%
|
|
301
|
+
[
|
|
302
|
+
{
|
|
303
|
+
type: "decorator",
|
|
304
|
+
id: "area-1",
|
|
305
|
+
decorator: "area",
|
|
306
|
+
view: {
|
|
307
|
+
x: 10,
|
|
308
|
+
y: 20,
|
|
309
|
+
width: 400,
|
|
310
|
+
height: 300,
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
type: "edge",
|
|
315
|
+
source: "X",
|
|
316
|
+
target: "Y",
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
type: "edge",
|
|
320
|
+
source: "X",
|
|
321
|
+
target: "Z",
|
|
322
|
+
data: {
|
|
323
|
+
virtual: true,
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
].concat(
|
|
327
|
+
["X", "Y", "Z", "W"].map((id) => ({
|
|
328
|
+
type: "node",
|
|
329
|
+
id,
|
|
330
|
+
data: {
|
|
331
|
+
name: `Node ${id}`,
|
|
332
|
+
},
|
|
333
|
+
view: {
|
|
334
|
+
width: 60,
|
|
335
|
+
height: 60,
|
|
336
|
+
}
|
|
337
|
+
}))
|
|
338
|
+
).concat([
|
|
339
|
+
{
|
|
340
|
+
type: "decorator",
|
|
341
|
+
id: "text-1",
|
|
342
|
+
decorator: "text",
|
|
343
|
+
view: {
|
|
344
|
+
x: 100,
|
|
345
|
+
y: 120,
|
|
346
|
+
width: 100,
|
|
347
|
+
height: 20,
|
|
348
|
+
text: "Hello!"
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
])
|
|
352
|
+
%>
|
|
353
|
+
- name: activeTarget
|
|
354
|
+
- name: targetCell
|
|
355
|
+
children:
|
|
356
|
+
- brick: div
|
|
357
|
+
properties:
|
|
358
|
+
style:
|
|
359
|
+
flex: 1
|
|
360
|
+
minWidth: 0
|
|
361
|
+
children:
|
|
362
|
+
- brick: eo-display-canvas
|
|
363
|
+
properties:
|
|
364
|
+
style:
|
|
365
|
+
width: 100%
|
|
366
|
+
height: 100%
|
|
367
|
+
activeTarget: <%= CTX.activeTarget %>
|
|
368
|
+
fadeUnrelatedCells: true
|
|
369
|
+
layout: dagre
|
|
370
|
+
# Initial nodes only
|
|
371
|
+
defaultNodeSize: [60, 60]
|
|
372
|
+
defaultNodeBricks:
|
|
373
|
+
- useBrick:
|
|
374
|
+
brick: diagram.experimental-node
|
|
375
|
+
properties:
|
|
376
|
+
textContent: <% `Node ${DATA.node.id}` %>
|
|
377
|
+
status: |
|
|
378
|
+
<%=
|
|
379
|
+
CTX.activeTarget?.type === "node" && CTX.activeTarget.id === DATA.node.id
|
|
380
|
+
? "highlighted"
|
|
381
|
+
// : CTX.unrelated.some(n =>
|
|
382
|
+
// n.type === "node" && n.id === DATA.node.id
|
|
383
|
+
// )
|
|
384
|
+
// ? "faded"
|
|
385
|
+
: "default"
|
|
386
|
+
%>
|
|
387
|
+
defaultEdgeLines:
|
|
388
|
+
- if: <% DATA.edge.data?.virtual %>
|
|
389
|
+
dashed: true
|
|
390
|
+
cells: <% CTX.initialCells %>
|
|
391
|
+
events:
|
|
392
|
+
activeTarget.change:
|
|
393
|
+
action: context.replace
|
|
394
|
+
args:
|
|
395
|
+
- activeTarget
|
|
396
|
+
- <% EVENT.detail %>
|
|
397
|
+
cell.contextmenu:
|
|
398
|
+
- target: eo-context-menu
|
|
399
|
+
method: open
|
|
400
|
+
args:
|
|
401
|
+
- position:
|
|
402
|
+
- <% EVENT.detail.clientX %>
|
|
403
|
+
- <% EVENT.detail.clientY %>
|
|
404
|
+
- action: context.replace
|
|
405
|
+
args:
|
|
406
|
+
- targetCell
|
|
407
|
+
- <% EVENT.detail.cell %>
|
|
408
|
+
scale.change:
|
|
409
|
+
action: context.replace
|
|
410
|
+
args:
|
|
411
|
+
- scale
|
|
412
|
+
- <% EVENT.detail %>
|
|
413
|
+
- brick: eo-context-menu
|
|
414
|
+
properties:
|
|
415
|
+
actions: |
|
|
416
|
+
<%=
|
|
417
|
+
[
|
|
418
|
+
{
|
|
419
|
+
text: `Test ${CTX.targetCell?.type}`,
|
|
420
|
+
event: `test-${CTX.targetCell?.type}`,
|
|
421
|
+
}
|
|
422
|
+
]
|
|
423
|
+
%>
|
|
424
|
+
```
|