@next-bricks/diagram 0.55.0 → 0.56.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/5903.ee85cf0c.js +2 -0
- package/dist/chunks/5903.ee85cf0c.js.map +1 -0
- package/dist/chunks/9711.a67e7f03.js +2 -0
- package/dist/chunks/9711.a67e7f03.js.map +1 -0
- package/dist/chunks/{eo-display-canvas.c4f21ed5.js → eo-display-canvas.28d0385d.js} +2 -2
- package/dist/chunks/{eo-display-canvas.c4f21ed5.js.map → eo-display-canvas.28d0385d.js.map} +1 -1
- package/dist/chunks/eo-draw-canvas.4b11d12e.js +2 -0
- package/dist/chunks/eo-draw-canvas.4b11d12e.js.map +1 -0
- package/dist/chunks/{main.3da92bd7.js → main.3238fda4.js} +2 -2
- package/dist/chunks/{main.3da92bd7.js.map → main.3238fda4.js.map} +1 -1
- package/dist/examples.json +4 -4
- package/dist/{index.415b685f.js → index.9e7c2eca.js} +2 -2
- package/dist/{index.415b685f.js.map → index.9e7c2eca.js.map} +1 -1
- package/dist/manifest.json +130 -124
- package/dist/types.json +4521 -4273
- package/dist-types/draw-canvas/CellComponent.d.ts +6 -6
- package/dist-types/draw-canvas/EdgeComponent.d.ts +3 -3
- package/dist-types/draw-canvas/EditingLineComponent.d.ts +4 -4
- package/dist-types/draw-canvas/HoverStateContext.d.ts +7 -3
- package/dist-types/draw-canvas/LineConnectorComponent.d.ts +4 -4
- package/dist-types/draw-canvas/LineEditorComponent.d.ts +5 -5
- package/dist-types/draw-canvas/constants.d.ts +1 -0
- package/dist-types/draw-canvas/decorators/DecoratorLine.d.ts +3 -0
- package/dist-types/draw-canvas/decorators/DecoratorLine.spec.d.ts +1 -0
- package/dist-types/draw-canvas/decorators/DecoratorRect.d.ts +3 -0
- package/dist-types/draw-canvas/decorators/DecoratorRect.spec.d.ts +1 -0
- package/dist-types/draw-canvas/decorators/index.d.ts +1 -1
- package/dist-types/draw-canvas/index.d.ts +17 -4
- package/dist-types/draw-canvas/interfaces.d.ts +32 -7
- package/dist-types/draw-canvas/processors/asserts.d.ts +4 -1
- package/dist-types/draw-canvas/processors/handleMouseDown.d.ts +3 -3
- package/dist-types/draw-canvas/reducers/interfaces.d.ts +14 -3
- package/dist-types/shared/canvas/processors/getEditingLinePoints.d.ts +3 -3
- package/dist-types/shared/canvas/processors/getSmartLinePoints.d.ts +4 -2
- package/dist-types/shared/canvas/useEditableLineMap.d.ts +3 -3
- package/dist-types/shared/canvas/useLineMarkers.d.ts +2 -2
- package/docs/eo-draw-canvas.md +70 -31
- package/package.json +2 -2
- package/dist/chunks/8552.b1182b74.js +0 -2
- package/dist/chunks/8552.b1182b74.js.map +0 -1
- package/dist/chunks/9711.6546e794.js +0 -2
- package/dist/chunks/9711.6546e794.js.map +0 -1
- package/dist/chunks/eo-draw-canvas.8d6f455b.js +0 -2
- package/dist/chunks/eo-draw-canvas.8d6f455b.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActiveTarget, Cell, CellContextMenuDetail, ComputedEdgeLineConf, DecoratorTextChangeDetail,
|
|
1
|
+
import type { ActiveTarget, Cell, CellContextMenuDetail, ComputedEdgeLineConf, DecoratorTextChangeDetail, LayoutOptions, LayoutType, NodeBrickConf, EditableLine, EditableLineCell } from "./interfaces";
|
|
2
2
|
import type { MoveCellPayload, ResizeCellPayload } from "./reducers/interfaces";
|
|
3
3
|
import type { SizeTuple, TransformLiteral } from "../diagram/interfaces";
|
|
4
4
|
export interface CellComponentProps {
|
|
@@ -10,16 +10,16 @@ export interface CellComponentProps {
|
|
|
10
10
|
degradedNodeLabel?: string;
|
|
11
11
|
defaultNodeBricks?: NodeBrickConf[];
|
|
12
12
|
transform: TransformLiteral;
|
|
13
|
-
lineConfMap: WeakMap<
|
|
14
|
-
editableLineMap: WeakMap<
|
|
13
|
+
lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;
|
|
14
|
+
editableLineMap: WeakMap<EditableLineCell, EditableLine>;
|
|
15
15
|
activeTarget: ActiveTarget | null | undefined;
|
|
16
16
|
readOnly?: boolean;
|
|
17
17
|
hoverCell?: Cell | null | undefined;
|
|
18
18
|
unrelatedCells: Cell[];
|
|
19
19
|
dragNodeToContainerActive?: boolean;
|
|
20
20
|
allowEdgeToArea?: boolean;
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
curActiveEditableLine?: EditableLineCell | null;
|
|
22
|
+
updateCurActiveEditableLine?: (activeEditableLine: EditableLineCell | null) => void;
|
|
23
23
|
onCellsMoving?(info: MoveCellPayload[]): void;
|
|
24
24
|
onCellsMoved?(info: MoveCellPayload[]): void;
|
|
25
25
|
onCellResizing?(info: ResizeCellPayload): void;
|
|
@@ -36,4 +36,4 @@ export interface CellComponentProps {
|
|
|
36
36
|
onCellMouseEnter?(cell: Cell): void;
|
|
37
37
|
onCellMouseLeave?(cell: Cell): void;
|
|
38
38
|
}
|
|
39
|
-
export declare function CellComponent({ layout, layoutOptions, cell, cells, degraded, degradedNodeLabel, defaultNodeBricks, lineConfMap, editableLineMap, activeTarget, dragNodeToContainerActive, readOnly, transform, hoverCell, unrelatedCells, allowEdgeToArea,
|
|
39
|
+
export declare function CellComponent({ layout, layoutOptions, cell, cells, degraded, degradedNodeLabel, defaultNodeBricks, lineConfMap, editableLineMap, activeTarget, dragNodeToContainerActive, readOnly, transform, hoverCell, unrelatedCells, allowEdgeToArea, curActiveEditableLine, updateCurActiveEditableLine, onCellsMoving, onCellsMoved, onCellResizing, onCellResized, onSwitchActiveTarget, onCellContextMenu, onCellClick, onDecoratorTextEditing, onDecoratorTextChange, onNodeBrickResize, onCellMouseEnter, onCellMouseLeave, }: CellComponentProps): JSX.Element | null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ActiveTarget, ComputedEdgeLineConf, EdgeCell, EditableLine } from "./interfaces";
|
|
1
|
+
import type { ActiveTarget, ComputedEdgeLineConf, EdgeCell, EditableLine, EditableLineCell } from "./interfaces";
|
|
2
2
|
export interface EdgeComponentProps {
|
|
3
3
|
edge: EdgeCell;
|
|
4
|
-
lineConfMap: WeakMap<
|
|
5
|
-
editableLineMap: WeakMap<
|
|
4
|
+
lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;
|
|
5
|
+
editableLineMap: WeakMap<EditableLineCell, EditableLine>;
|
|
6
6
|
readOnly?: boolean;
|
|
7
7
|
active?: boolean;
|
|
8
8
|
activeRelated?: boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Cell, ComputedLineConnecterConf,
|
|
1
|
+
import type { Cell, ComputedLineConnecterConf, EditableLine, EditableLineCell } from "./interfaces";
|
|
2
2
|
import type { TransformLiteral } from "../diagram/interfaces";
|
|
3
3
|
export interface EditingLineComponentProps {
|
|
4
4
|
cells: Cell[];
|
|
5
|
-
editableLineMap: WeakMap<
|
|
5
|
+
editableLineMap: WeakMap<EditableLineCell, EditableLine>;
|
|
6
6
|
transform: TransformLiteral;
|
|
7
7
|
options: ComputedLineConnecterConf;
|
|
8
|
-
|
|
8
|
+
activeEditableLine: EditableLineCell | null;
|
|
9
9
|
}
|
|
10
|
-
export declare function EditingLineComponent({ cells, editableLineMap, transform, options,
|
|
10
|
+
export declare function EditingLineComponent({ cells, editableLineMap, transform, options, activeEditableLine, }: EditingLineComponentProps): JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { DecoratorCell,
|
|
2
|
+
import type { DecoratorCell, DecoratorLineView, DecoratorView, EdgeView, EditableLineCell, LineEditorState, NodeCell, SmartConnectLineState } from "./interfaces";
|
|
3
3
|
import type { NodePosition } from "../diagram/interfaces";
|
|
4
4
|
export interface HoverState {
|
|
5
5
|
cell: NodeCell | DecoratorCell;
|
|
@@ -12,24 +12,28 @@ export declare const HoverStateContext: React.Context<{
|
|
|
12
12
|
smartConnectLineState: SmartConnectLineState | null;
|
|
13
13
|
unsetHoverStateTimeoutRef: React.MutableRefObject<number | null>;
|
|
14
14
|
hoverState: HoverState | null;
|
|
15
|
-
|
|
15
|
+
activeEditableLines: EditableLineCell[];
|
|
16
16
|
lineEditorState: LineEditorState | null;
|
|
17
|
+
movingCells?: boolean;
|
|
17
18
|
setLineEditorState: React.Dispatch<React.SetStateAction<LineEditorState | null>>;
|
|
18
19
|
setHoverState: React.Dispatch<React.SetStateAction<HoverState | null>>;
|
|
19
20
|
setSmartConnectLineState: React.Dispatch<React.SetStateAction<SmartConnectLineState | null>>;
|
|
20
21
|
onConnect?: (source: NodeCell | DecoratorCell, target: NodeCell | DecoratorCell, exitPosition: NodePosition, entryPosition: NodePosition | undefined) => void;
|
|
21
22
|
onChangeEdgeView?: (source: NodeCell | DecoratorCell, target: NodeCell | DecoratorCell, view: EdgeView) => void;
|
|
23
|
+
onChangeDecoratorView?: (cell: DecoratorCell, view: DecoratorView | DecoratorLineView) => void;
|
|
22
24
|
}>;
|
|
23
25
|
export declare function useHoverStateContext(): {
|
|
24
26
|
rootRef: React.RefObject<SVGSVGElement>;
|
|
25
27
|
smartConnectLineState: SmartConnectLineState | null;
|
|
26
28
|
unsetHoverStateTimeoutRef: React.MutableRefObject<number | null>;
|
|
27
29
|
hoverState: HoverState | null;
|
|
28
|
-
|
|
30
|
+
activeEditableLines: EditableLineCell[];
|
|
29
31
|
lineEditorState: LineEditorState | null;
|
|
32
|
+
movingCells?: boolean;
|
|
30
33
|
setLineEditorState: React.Dispatch<React.SetStateAction<LineEditorState | null>>;
|
|
31
34
|
setHoverState: React.Dispatch<React.SetStateAction<HoverState | null>>;
|
|
32
35
|
setSmartConnectLineState: React.Dispatch<React.SetStateAction<SmartConnectLineState | null>>;
|
|
33
36
|
onConnect?: (source: NodeCell | DecoratorCell, target: NodeCell | DecoratorCell, exitPosition: NodePosition, entryPosition: NodePosition | undefined) => void;
|
|
34
37
|
onChangeEdgeView?: (source: NodeCell | DecoratorCell, target: NodeCell | DecoratorCell, view: EdgeView) => void;
|
|
38
|
+
onChangeDecoratorView?: (cell: DecoratorCell, view: DecoratorView | DecoratorLineView) => void;
|
|
35
39
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ActiveTarget,
|
|
1
|
+
import type { ActiveTarget, EditableLine, EditableLineCell } from "./interfaces";
|
|
2
2
|
export interface LineConnectorComponentProps {
|
|
3
3
|
activeTarget: ActiveTarget | null;
|
|
4
|
-
editableLineMap: WeakMap<
|
|
4
|
+
editableLineMap: WeakMap<EditableLineCell, EditableLine>;
|
|
5
5
|
scale: number;
|
|
6
|
-
|
|
6
|
+
activeEditableLine: EditableLineCell | null;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export declare function LineConnectorComponent({ activeTarget, editableLineMap, scale,
|
|
9
|
+
export declare function LineConnectorComponent({ activeTarget, editableLineMap, scale, activeEditableLine, disabled, }: LineConnectorComponentProps): JSX.Element | null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EditableLine, EditableLineCell } from "./interfaces";
|
|
2
2
|
export interface LineEditorComponentProps {
|
|
3
3
|
scale: number;
|
|
4
|
-
editableLineMap: WeakMap<
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
editableLineMap: WeakMap<EditableLineCell, EditableLine>;
|
|
5
|
+
activeEditableLine: EditableLineCell;
|
|
6
|
+
updateCurActiveEditableLine?: (activeEditableLine: EditableLineCell | null) => void;
|
|
7
7
|
}
|
|
8
|
-
export declare function LineEditorComponent({ scale, editableLineMap,
|
|
8
|
+
export declare function LineEditorComponent({ scale, editableLineMap, activeEditableLine, updateCurActiveEditableLine, }: LineEditorComponentProps): JSX.Element | null;
|
|
@@ -9,6 +9,7 @@ export declare const DEFAULT_SCALE_RANGE_MIN = 0.5;
|
|
|
9
9
|
export declare const DEFAULT_SCALE_RANGE_MAX = 2;
|
|
10
10
|
export declare const DEFAULT_LINE_STROKE_COLOR = "gray";
|
|
11
11
|
export declare const DEFAULT_LINE_STROKE_WIDTH = 1;
|
|
12
|
+
export declare const DEFAULT_DECORATOR_LINE_STROKE_COLOR = "rgba(73, 126, 255, 0.7)";
|
|
12
13
|
export declare const DEFAULT_LINE_INTERACT_STROKE_WIDTH = 15;
|
|
13
14
|
export declare const DEFAULT_LINE_INTERACT_SHOW_START_ARROW = false;
|
|
14
15
|
export declare const DEFAULT_LINE_INTERACT_SHOW_END_ARROW = true;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BasicDecoratorProps } from "../interfaces";
|
|
2
|
+
export type DecoratorLineProps = Pick<BasicDecoratorProps, "cell" | "active" | "lineConfMap" | "editableLineMap">;
|
|
3
|
+
export declare function DecoratorLine({ cell, active, lineConfMap, editableLineMap, }: DecoratorLineProps): JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BasicDecoratorProps } from "../interfaces";
|
|
2
|
+
export type DecoratorRectProps = Omit<BasicDecoratorProps, "lineConfMap" | "editableLineMap">;
|
|
3
|
+
export declare function DecoratorRect({ cell, transform, readOnly, layout, view, activeTarget, cells, onCellResizing, onCellResized, onSwitchActiveTarget, }: DecoratorRectProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { BasicDecoratorProps } from "../interfaces";
|
|
2
|
-
export declare function DecoratorComponent({ cell, view, transform, readOnly, layout, layoutOptions, activeTarget, cells, onCellResizing, onCellResized, onSwitchActiveTarget, onDecoratorTextEditing, onDecoratorTextChange, }: BasicDecoratorProps): JSX.Element | null;
|
|
2
|
+
export declare function DecoratorComponent({ cell, view, transform, readOnly, layout, layoutOptions, active, activeTarget, cells, lineConfMap, editableLineMap, onCellResizing, onCellResized, onSwitchActiveTarget, onDecoratorTextEditing, onDecoratorTextChange, }: BasicDecoratorProps): JSX.Element | null;
|
|
@@ -2,9 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { ReactNextElement } from "@next-core/react-element";
|
|
3
3
|
import type { UseSingleBrickConf } from "@next-core/react-runtime";
|
|
4
4
|
import "@next-core/theme";
|
|
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, LayoutType, LayoutOptions, LineConnecterConf, Direction, LineSettings } from "./interfaces";
|
|
7
|
-
import type { EdgeViewChangePayload, MoveCellPayload, ResizeCellPayload } from "./reducers/interfaces";
|
|
5
|
+
import type { NodePosition, PositionTuple, RangeTuple, SizeTuple, TransformLiteral } from "../diagram/interfaces";
|
|
6
|
+
import type { ActiveTarget, Cell, EdgeCell, InitialCell, NodeBrickConf, NodeCell, NodeId, DecoratorCell, DecoratorType, CellContextMenuDetail, ConnectNodesDetail, EdgeLineConf, DecoratorTextChangeDetail, LayoutType, LayoutOptions, LineConnecterConf, Direction, LineSettings, DecoratorView, DecoratorLineView } from "./interfaces";
|
|
7
|
+
import type { DecoratorViewChangePayload, EdgeViewChangePayload, MoveCellPayload, ResizeCellPayload } from "./reducers/interfaces";
|
|
8
8
|
export interface EoDrawCanvasProps {
|
|
9
9
|
cells: InitialCell[] | undefined;
|
|
10
10
|
layout: LayoutType;
|
|
@@ -40,6 +40,18 @@ export interface DropDecoratorInfo {
|
|
|
40
40
|
position: PositionTuple;
|
|
41
41
|
text?: string;
|
|
42
42
|
direction?: Direction;
|
|
43
|
+
/**
|
|
44
|
+
* Line decorator only: setting initial source position related to (0, 0)
|
|
45
|
+
* @default {x:-30,y:30}
|
|
46
|
+
*/
|
|
47
|
+
source?: NodePosition;
|
|
48
|
+
/**
|
|
49
|
+
* Line decorator only: setting initial source position related to (0, 0)
|
|
50
|
+
* @default {x:30,y:-30}
|
|
51
|
+
*/
|
|
52
|
+
target?: NodePosition;
|
|
53
|
+
/** Override decorator view settings */
|
|
54
|
+
view?: DecoratorView & DecoratorLineView;
|
|
43
55
|
}
|
|
44
56
|
export interface AddNodeInfo {
|
|
45
57
|
id: NodeId;
|
|
@@ -140,7 +152,7 @@ export declare class EoDrawCanvas extends ReactNextElement implements EoDrawCanv
|
|
|
140
152
|
*/
|
|
141
153
|
accessor doNotResetActiveTargetOutsideCanvas: boolean | undefined;
|
|
142
154
|
dropNode({ id, position, size, data, useBrick, }: DropNodeInfo): Promise<NodeCell | null>;
|
|
143
|
-
dropDecorator({ position, decorator, text, direction, }: DropDecoratorInfo): Promise<DecoratorCell | null>;
|
|
155
|
+
dropDecorator({ position, decorator, text, direction, source, target, view, }: DropDecoratorInfo): Promise<DecoratorCell | null>;
|
|
144
156
|
addNodes(nodes: AddNodeInfo[]): Promise<NodeCell[]>;
|
|
145
157
|
addEdge({ source, target, data }: AddEdgeInfo): Promise<EdgeCell>;
|
|
146
158
|
manuallyConnectNodes(source: NodeId): Promise<ConnectNodesDetail>;
|
|
@@ -164,6 +176,7 @@ export interface EoDrawCanvasComponentProps extends EoDrawCanvasProps {
|
|
|
164
176
|
onEdgeAdd(detail: ConnectNodesDetail): void;
|
|
165
177
|
onEdgeViewChange(detail: EdgeViewChangePayload): void;
|
|
166
178
|
onDecoratorTextChange(detail: DecoratorTextChangeDetail): void;
|
|
179
|
+
onDecoratorViewChange(detail: DecoratorViewChangePayload): void;
|
|
167
180
|
onContainerContainerChange(detail: MoveCellPayload[]): void;
|
|
168
181
|
onScaleChange(scale: number): void;
|
|
169
182
|
}
|
|
@@ -6,7 +6,6 @@ import type { SYMBOL_FOR_SIZE_INITIALIZED, SYMBOL_FOR_LAYOUT_INITIALIZED } from
|
|
|
6
6
|
export type Cell = NodeCell | EdgeCell | DecoratorCell;
|
|
7
7
|
export type BrickCell = NodeBrickCell;
|
|
8
8
|
export type NodeCell = NodeBrickCell;
|
|
9
|
-
export type EdgeCell = BaseEdgeCell;
|
|
10
9
|
export type NodeBrickCell = BaseBrickCell & BaseNodeCell;
|
|
11
10
|
export type NodeId = string;
|
|
12
11
|
export interface BaseBrickCell extends BaseCell {
|
|
@@ -21,13 +20,13 @@ export interface BaseNodeCell extends BaseCell {
|
|
|
21
20
|
[SYMBOL_FOR_SIZE_INITIALIZED]?: boolean;
|
|
22
21
|
[SYMBOL_FOR_LAYOUT_INITIALIZED]?: boolean;
|
|
23
22
|
}
|
|
24
|
-
export interface
|
|
23
|
+
export interface EdgeCell extends BaseCell {
|
|
25
24
|
type: "edge";
|
|
26
25
|
source: NodeId;
|
|
27
26
|
target: NodeId;
|
|
28
27
|
view?: EdgeView;
|
|
29
28
|
}
|
|
30
|
-
export type DecoratorType = "text" | "area" | "container";
|
|
29
|
+
export type DecoratorType = "text" | "area" | "container" | "rect" | "line";
|
|
31
30
|
export type Direction = "top" | "right" | "bottom" | "left";
|
|
32
31
|
export interface DecoratorCell extends BaseCell {
|
|
33
32
|
type: "decorator";
|
|
@@ -35,6 +34,10 @@ export interface DecoratorCell extends BaseCell {
|
|
|
35
34
|
id: NodeId;
|
|
36
35
|
view: DecoratorView;
|
|
37
36
|
}
|
|
37
|
+
export interface LineDecoratorCell extends Omit<DecoratorCell, "view"> {
|
|
38
|
+
decorator: "line";
|
|
39
|
+
view: DecoratorLineView;
|
|
40
|
+
}
|
|
38
41
|
export interface BaseCell {
|
|
39
42
|
type: "node" | "edge" | "decorator";
|
|
40
43
|
data?: unknown;
|
|
@@ -44,9 +47,21 @@ export interface NodeView extends InitialNodeView {
|
|
|
44
47
|
height: number;
|
|
45
48
|
}
|
|
46
49
|
export interface DecoratorView extends NodeView {
|
|
50
|
+
/** 用于文本装饰器和容器装饰器 */
|
|
47
51
|
text?: string;
|
|
52
|
+
/** 设置容器装饰器的文本位置 */
|
|
48
53
|
direction?: Direction;
|
|
54
|
+
vertices?: NodePosition[] | null;
|
|
55
|
+
}
|
|
56
|
+
export interface DecoratorLineView extends NodeView, BaseEdgeLineConf {
|
|
57
|
+
source: NodePosition;
|
|
58
|
+
target: NodePosition;
|
|
59
|
+
vertices?: NodePosition[] | null;
|
|
60
|
+
exitPosition?: undefined;
|
|
61
|
+
entryPosition?: undefined;
|
|
49
62
|
}
|
|
63
|
+
export type EditableLineCell = EdgeCell | DecoratorCell;
|
|
64
|
+
export type EditableLineView = EdgeView | DecoratorLineView;
|
|
50
65
|
export interface InitialNodeView {
|
|
51
66
|
x: number;
|
|
52
67
|
y: number;
|
|
@@ -170,8 +185,11 @@ export interface BasicDecoratorProps {
|
|
|
170
185
|
layout?: LayoutType;
|
|
171
186
|
view: DecoratorView;
|
|
172
187
|
layoutOptions?: LayoutOptions;
|
|
188
|
+
active?: boolean;
|
|
173
189
|
activeTarget: ActiveTarget | null | undefined;
|
|
174
190
|
cells: Cell[];
|
|
191
|
+
lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;
|
|
192
|
+
editableLineMap: WeakMap<EditableLineCell, EditableLine>;
|
|
175
193
|
onCellResizing?(info: ResizeCellPayload): void;
|
|
176
194
|
onCellResized?(info: ResizeCellPayload): void;
|
|
177
195
|
onSwitchActiveTarget?(activeTarget: ActiveTarget | null): void;
|
|
@@ -208,7 +226,7 @@ export interface ConnectNodesDetail {
|
|
|
208
226
|
}
|
|
209
227
|
export interface DecoratorTextChangeDetail {
|
|
210
228
|
id: string;
|
|
211
|
-
view: DecoratorView;
|
|
229
|
+
view: DecoratorView | DecoratorLineView;
|
|
212
230
|
}
|
|
213
231
|
export type LayoutType = "manual" | "force" | "dagre" | undefined;
|
|
214
232
|
export type LayoutOptions = LayoutOptionsManual | LayoutOptionsDagre | LayoutOptionsForce;
|
|
@@ -296,7 +314,7 @@ export interface LineEditorStateOfEndPoint {
|
|
|
296
314
|
from: PositionTuple;
|
|
297
315
|
}
|
|
298
316
|
export interface LineEditorStateOfControl {
|
|
299
|
-
type: "control";
|
|
317
|
+
type: "control" | "corner" | "break";
|
|
300
318
|
offset: PositionTuple;
|
|
301
319
|
from: PositionTuple;
|
|
302
320
|
control: ControlPoint;
|
|
@@ -318,16 +336,23 @@ export type BiDirection = "ns" | "ew";
|
|
|
318
336
|
* ```
|
|
319
337
|
*/
|
|
320
338
|
export interface ControlPoint extends NodePosition {
|
|
321
|
-
|
|
339
|
+
type: "control" | "corner" | "break";
|
|
340
|
+
direction?: BiDirection;
|
|
322
341
|
index: number;
|
|
323
342
|
}
|
|
324
|
-
export
|
|
343
|
+
export type EditableLine = EditableEdgeLine | EditableDecoratorLine;
|
|
344
|
+
export interface EditableEdgeLine {
|
|
325
345
|
edge: EdgeCell;
|
|
326
346
|
points: NodePosition[];
|
|
327
347
|
source: NodeBrickCell | DecoratorCell;
|
|
328
348
|
target: NodeBrickCell | DecoratorCell;
|
|
329
349
|
parallelGap: number;
|
|
330
350
|
}
|
|
351
|
+
export interface EditableDecoratorLine {
|
|
352
|
+
decorator: DecoratorCell;
|
|
353
|
+
points: NodePosition[];
|
|
354
|
+
parallelGap: number;
|
|
355
|
+
}
|
|
331
356
|
export type PositionAndAngle = [
|
|
332
357
|
x: number,
|
|
333
358
|
y: number,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Cell, DecoratorCell, EdgeCell, InitialCell, InitialNodeCell, LayoutType, LineType, NodeCell } from "../interfaces";
|
|
1
|
+
import type { Cell, DecoratorCell, EdgeCell, EditableEdgeLine, EditableLine, InitialCell, InitialNodeCell, LayoutType, LineDecoratorCell, LineType, NodeCell } from "../interfaces";
|
|
2
2
|
import { MoveCellPayload } from "../reducers/interfaces";
|
|
3
3
|
export declare function isNodeCell(cell: Cell | MoveCellPayload): cell is NodeCell;
|
|
4
4
|
export declare function isDecoratorCell(cell: Cell): cell is DecoratorCell;
|
|
@@ -10,5 +10,8 @@ export declare function isEdgeSide(cell: Cell, allowEdgeToArea: boolean | undefi
|
|
|
10
10
|
export declare function isNodeOrTextDecoratorCell(cell: Cell | MoveCellPayload): cell is NodeCell | DecoratorCell;
|
|
11
11
|
export declare function isTextDecoratorCell(cell: Cell): cell is DecoratorCell;
|
|
12
12
|
export declare function isContainerDecoratorCell(cell: Cell | MoveCellPayload): cell is DecoratorCell;
|
|
13
|
+
export declare function isRectDecoratorCell(cell: Cell | MoveCellPayload): cell is DecoratorCell;
|
|
14
|
+
export declare function isLineDecoratorCell(cell: Cell | LineDecoratorCell | MoveCellPayload): cell is LineDecoratorCell;
|
|
13
15
|
export declare function isNoManualLayout(layout: LayoutType): boolean;
|
|
14
16
|
export declare function isStraightType(type: LineType | undefined): type is "straight" | undefined;
|
|
17
|
+
export declare function isEditableEdgeLine(line: EditableLine): line is EditableEdgeLine;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ActiveTarget, Cell, LayoutOptions, LayoutType,
|
|
1
|
+
import type { ActiveTarget, Cell, LayoutOptions, LayoutType, EditableLineCell } from "../interfaces";
|
|
2
2
|
import type { MoveCellPayload, ResizeCellPayload } from "../reducers/interfaces";
|
|
3
|
-
export declare function handleMouseDown(event: MouseEvent, { action, cell, scale, layout, layoutOptions, activeTarget, cells, onCellsMoving, onCellsMoved, onCellResizing, onCellResized, onSwitchActiveTarget,
|
|
3
|
+
export declare function handleMouseDown(event: MouseEvent, { action, cell, scale, layout, layoutOptions, activeTarget, cells, onCellsMoving, onCellsMoved, onCellResizing, onCellResized, onSwitchActiveTarget, updateCurActiveEditableLine, }: {
|
|
4
4
|
action: "move" | "resize";
|
|
5
5
|
cell: Cell;
|
|
6
6
|
scale: number;
|
|
@@ -13,5 +13,5 @@ export declare function handleMouseDown(event: MouseEvent, { action, cell, scale
|
|
|
13
13
|
onCellResizing?(info: ResizeCellPayload): void;
|
|
14
14
|
onCellResized?(info: ResizeCellPayload): void;
|
|
15
15
|
onSwitchActiveTarget?(activeTarget: ActiveTarget | null): void;
|
|
16
|
-
|
|
16
|
+
updateCurActiveEditableLine?: (activeEditableLine: EditableLineCell | null) => void;
|
|
17
17
|
}): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { PositionTuple, SizeTuple } from "../../diagram/interfaces";
|
|
2
|
-
import type { Cell, DecoratorCell, DecoratorType, EdgeCell, NodeCell, NodeId } from "../interfaces";
|
|
1
|
+
import type { NodePosition, PositionTuple, SizeTuple } from "../../diagram/interfaces";
|
|
2
|
+
import type { Cell, DecoratorCell, DecoratorLineView, DecoratorType, DecoratorView, EdgeCell, NodeCell, NodeId } from "../interfaces";
|
|
3
3
|
export interface DrawCanvasState {
|
|
4
4
|
cells: Cell[];
|
|
5
5
|
layoutKey: number;
|
|
6
6
|
}
|
|
7
|
-
export type DrawCanvasAction = DropNodeAction | DropDecoratorAction | AddNodeAction | AddEdgeAction | ChangeEdgeViewAction | MoveCellsAction | ResizeCellAction | UpdateCellsAction | UpdateNodeSizeAction;
|
|
7
|
+
export type DrawCanvasAction = DropNodeAction | DropDecoratorAction | AddNodeAction | AddEdgeAction | ChangeEdgeViewAction | ChangeDecoratorViewAction | MoveCellsAction | ResizeCellAction | UpdateCellsAction | UpdateNodeSizeAction;
|
|
8
8
|
export interface DropNodeAction {
|
|
9
9
|
type: "drop-node";
|
|
10
10
|
payload: NodeCell;
|
|
@@ -25,6 +25,10 @@ export interface ChangeEdgeViewAction {
|
|
|
25
25
|
type: "change-edge-view";
|
|
26
26
|
payload: EdgeViewChangePayload;
|
|
27
27
|
}
|
|
28
|
+
export interface ChangeDecoratorViewAction {
|
|
29
|
+
type: "change-decorator-view";
|
|
30
|
+
payload: DecoratorViewChangePayload;
|
|
31
|
+
}
|
|
28
32
|
export interface MoveCellsAction {
|
|
29
33
|
type: "move-cells";
|
|
30
34
|
payload: MoveCellPayload[];
|
|
@@ -56,6 +60,9 @@ export interface MoveCellPayload {
|
|
|
56
60
|
decorator?: DecoratorType;
|
|
57
61
|
containerCell?: DecoratorCell;
|
|
58
62
|
guideLines?: LineTuple[];
|
|
63
|
+
source?: NodePosition;
|
|
64
|
+
target?: NodePosition;
|
|
65
|
+
vertices?: NodePosition[];
|
|
59
66
|
}
|
|
60
67
|
export interface ResizeCellPayload {
|
|
61
68
|
type: "node" | "decorator";
|
|
@@ -69,3 +76,7 @@ export interface MoveNodePayload {
|
|
|
69
76
|
y: number;
|
|
70
77
|
}
|
|
71
78
|
export type EdgeViewChangePayload = Pick<EdgeCell, "source" | "target" | "view">;
|
|
79
|
+
export type DecoratorViewChangePayload = {
|
|
80
|
+
id: NodeId;
|
|
81
|
+
view: DecoratorView | DecoratorLineView;
|
|
82
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodePosition, PositionTuple } from "../../../diagram/interfaces";
|
|
2
2
|
import type { HoverState } from "../../../draw-canvas/HoverStateContext";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function getEditingLinePoints(
|
|
5
|
-
export declare function getNewLineVertices(
|
|
3
|
+
import type { LineEditorState, LineEditorStateOfControl, EditableLine, EditableLineCell } from "../../../draw-canvas/interfaces";
|
|
4
|
+
export declare function getEditingLinePoints(activeEditableLine: EditableLineCell | null, lineEditorState: LineEditorState | null, editableLineMap: WeakMap<EditableLineCell, EditableLine>, connectLineTo: PositionTuple | null, hoverState: HoverState | null): NodePosition[] | null;
|
|
5
|
+
export declare function getNewLineVertices(activeEditableLine: EditableLineCell, lineEditorState: LineEditorStateOfControl, editableLineMap: WeakMap<EditableLineCell, EditableLine>, connectLineTo: PositionTuple): NodePosition[];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { NodePosition } from "../../../diagram/interfaces";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function getSmartLinePoints(sourceView: NodeView, targetView: NodeView,
|
|
2
|
+
import type { EditableLineView, NodeView } from "../../../draw-canvas/interfaces";
|
|
3
|
+
export declare function getSmartLinePoints(sourceView: NodeView, targetView: NodeView, lineView: EditableLineView | undefined, parallelGap?: number,
|
|
4
|
+
/** @default "edge" */
|
|
5
|
+
cellType?: "edge" | "decorator"): NodePosition[] | null;
|
|
4
6
|
export declare function simplifyVertices(exitPoint: NodePosition, vertices: NodePosition[], entryPoint: NodePosition): NodePosition[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Cell, ComputedEdgeLineConf, EdgeCell, EditableLine } from "../../draw-canvas/interfaces";
|
|
1
|
+
import type { Cell, ComputedEdgeLineConf, DecoratorCell, EdgeCell, EditableLine } from "../../draw-canvas/interfaces";
|
|
2
2
|
export declare function useEditableLineMap({ cells, lineConfMap, }: {
|
|
3
3
|
cells: Cell[];
|
|
4
|
-
lineConfMap: WeakMap<EdgeCell, ComputedEdgeLineConf>;
|
|
5
|
-
}): WeakMap<
|
|
4
|
+
lineConfMap: WeakMap<EdgeCell | DecoratorCell, ComputedEdgeLineConf>;
|
|
5
|
+
}): WeakMap<EdgeCell | DecoratorCell, EditableLine>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Cell, ComputedEdgeLineConf, ComputedLineConnecterConf,
|
|
1
|
+
import type { Cell, ComputedEdgeLineConf, ComputedLineConnecterConf, EdgeLineConf, EditableLineCell, LineConnecterConf, LineMarker } from "../../draw-canvas/interfaces";
|
|
2
2
|
import { LineMarkerConf } from "../../diagram/interfaces";
|
|
3
3
|
export interface UseLineMarkersOptions {
|
|
4
4
|
cells: Cell[];
|
|
@@ -7,7 +7,7 @@ export interface UseLineMarkersOptions {
|
|
|
7
7
|
lineConnector?: LineConnecterConf | boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare function useLineMarkers({ cells, defaultEdgeLines, markerPrefix, lineConnector, }: UseLineMarkersOptions): {
|
|
10
|
-
lineConfMap: WeakMap<
|
|
10
|
+
lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;
|
|
11
11
|
lineConnectorConf: ComputedLineConnecterConf | null;
|
|
12
12
|
markers: LineMarker[];
|
|
13
13
|
};
|
package/docs/eo-draw-canvas.md
CHANGED
|
@@ -29,6 +29,17 @@
|
|
|
29
29
|
height: 300,
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
type: "decorator",
|
|
34
|
+
id: "rect-1",
|
|
35
|
+
decorator: "rect",
|
|
36
|
+
view: {
|
|
37
|
+
x: 10,
|
|
38
|
+
y: 20,
|
|
39
|
+
width: 400,
|
|
40
|
+
height: 300,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
32
43
|
{
|
|
33
44
|
type: "decorator",
|
|
34
45
|
id: "container-1",
|
|
@@ -256,6 +267,8 @@
|
|
|
256
267
|
dataSource:
|
|
257
268
|
- area
|
|
258
269
|
- text
|
|
270
|
+
- line
|
|
271
|
+
- rect
|
|
259
272
|
- container.top
|
|
260
273
|
- container.right
|
|
261
274
|
- container.bottom
|
|
@@ -280,21 +293,26 @@
|
|
|
280
293
|
- target: eo-draw-canvas
|
|
281
294
|
method: dropDecorator
|
|
282
295
|
args:
|
|
283
|
-
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
296
|
+
- |
|
|
297
|
+
<%
|
|
298
|
+
ITEM === "line"
|
|
299
|
+
? {
|
|
300
|
+
position: EVENT.detail,
|
|
301
|
+
decorator: ITEM.split(".")[0],
|
|
302
|
+
}
|
|
303
|
+
: {
|
|
304
|
+
position: EVENT.detail,
|
|
305
|
+
decorator: ITEM.split(".")[0],
|
|
306
|
+
text: _.upperFirst(ITEM),
|
|
307
|
+
direction: ITEM.split(".").pop(),
|
|
308
|
+
}
|
|
309
|
+
%>
|
|
287
310
|
callback:
|
|
288
311
|
success:
|
|
289
|
-
if: <% EVENT.detail %>
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
# - <% JSON.stringify(EVENT.detail) %>
|
|
294
|
-
else:
|
|
295
|
-
action: message.warn
|
|
296
|
-
args:
|
|
297
|
-
- Unexpected drop position
|
|
312
|
+
if: <% !EVENT.detail %>
|
|
313
|
+
action: message.warn
|
|
314
|
+
args:
|
|
315
|
+
- Unexpected drop position
|
|
298
316
|
- brick: div
|
|
299
317
|
properties:
|
|
300
318
|
style:
|
|
@@ -389,6 +407,11 @@
|
|
|
389
407
|
args:
|
|
390
408
|
- |
|
|
391
409
|
<% `Edge view changed: ${JSON.stringify(EVENT.detail)}` %>
|
|
410
|
+
decorator.view.change:
|
|
411
|
+
action: message.info
|
|
412
|
+
args:
|
|
413
|
+
- |
|
|
414
|
+
<% `Decorator view changed: ${JSON.stringify(EVENT.detail)}` %>
|
|
392
415
|
decorator.text.change:
|
|
393
416
|
action: message.info
|
|
394
417
|
args:
|
|
@@ -638,6 +661,32 @@
|
|
|
638
661
|
value: |
|
|
639
662
|
<%
|
|
640
663
|
[
|
|
664
|
+
{
|
|
665
|
+
type: "decorator",
|
|
666
|
+
decorator: "line",
|
|
667
|
+
id: "line-1",
|
|
668
|
+
view: {
|
|
669
|
+
source: {
|
|
670
|
+
x: 200,
|
|
671
|
+
y: 200,
|
|
672
|
+
},
|
|
673
|
+
target: {
|
|
674
|
+
x: 250,
|
|
675
|
+
y: 150,
|
|
676
|
+
},
|
|
677
|
+
// type: "polyline",
|
|
678
|
+
vertices: [
|
|
679
|
+
{
|
|
680
|
+
x: 180,
|
|
681
|
+
y: 125,
|
|
682
|
+
},
|
|
683
|
+
],
|
|
684
|
+
markers: [{
|
|
685
|
+
placement: "end",
|
|
686
|
+
type: "arrow",
|
|
687
|
+
}],
|
|
688
|
+
},
|
|
689
|
+
},
|
|
641
690
|
{
|
|
642
691
|
type: "edge",
|
|
643
692
|
source: "X",
|
|
@@ -1096,15 +1145,10 @@
|
|
|
1096
1145
|
text: '<% ITEM === "text" ? "Text" : undefined %>'
|
|
1097
1146
|
callback:
|
|
1098
1147
|
success:
|
|
1099
|
-
if: <% EVENT.detail %>
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
# - <% JSON.stringify(EVENT.detail) %>
|
|
1104
|
-
else:
|
|
1105
|
-
action: message.warn
|
|
1106
|
-
args:
|
|
1107
|
-
- Unexpected drop position
|
|
1148
|
+
if: <% !EVENT.detail %>
|
|
1149
|
+
action: message.warn
|
|
1150
|
+
args:
|
|
1151
|
+
- Unexpected drop position
|
|
1108
1152
|
- brick: div
|
|
1109
1153
|
properties:
|
|
1110
1154
|
style:
|
|
@@ -1487,15 +1531,10 @@
|
|
|
1487
1531
|
text: '<% ITEM === "text" ? "Text" : undefined %>'
|
|
1488
1532
|
callback:
|
|
1489
1533
|
success:
|
|
1490
|
-
if: <% EVENT.detail %>
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
# - <% JSON.stringify(EVENT.detail) %>
|
|
1495
|
-
else:
|
|
1496
|
-
action: message.warn
|
|
1497
|
-
args:
|
|
1498
|
-
- Unexpected drop position
|
|
1534
|
+
if: <% !EVENT.detail %>
|
|
1535
|
+
action: message.warn
|
|
1536
|
+
args:
|
|
1537
|
+
- Unexpected drop position
|
|
1499
1538
|
- brick: div
|
|
1500
1539
|
properties:
|
|
1501
1540
|
style:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-bricks/diagram",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"homepage": "https://github.com/easyops-cn/next-advanced-bricks/tree/master/bricks/diagram",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@next-bricks/basic": "*"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "4bf3a21b3ba8b2ad8a79e373d967afc5aa26c227"
|
|
45
45
|
}
|