@flowgram-vue/free-lines-plugin 0.2.0 → 0.2.1
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/index.cjs +10 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -269
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/components/workflow-port-render/index.ts +6 -0
- package/dist/index.css +0 -120
- package/dist/index.css.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,269 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { PropType, CSSProperties, Component, VNodeChild, VNode } from 'vue';
|
|
3
|
-
import { WorkflowPortEntity, WorkflowLineEntity, LineRenderType, WorkflowLineRenderContributionFactory, WorkflowLineUIState, WorkflowHoverService, WorkflowSelectService, WorkflowDocument, LinePointLocation, LineCenterPoint, WorkflowLineRenderContribution, LineType, LinePoint } from '@flowgram-vue/free-layout-core';
|
|
4
|
-
import * as _flowgram_vue_core from '@flowgram-vue/core';
|
|
5
|
-
import { Layer, PlaygroundContainerFactory, TransformData } from '@flowgram-vue/core';
|
|
6
|
-
import { FlowRendererRegistry } from '@flowgram-vue/renderer';
|
|
7
|
-
import { StackingContextManager } from '@flowgram-vue/free-stack-plugin';
|
|
8
|
-
import { IPoint, Rectangle } from '@flowgram-vue/utils';
|
|
9
|
-
import { Bezier } from 'bezier-js';
|
|
10
|
-
|
|
11
|
-
interface WorkflowPortRenderProps {
|
|
12
|
-
entity: WorkflowPortEntity;
|
|
13
|
-
className?: string;
|
|
14
|
-
style?: CSSProperties;
|
|
15
|
-
onClick?: (e: MouseEvent, port: WorkflowPortEntity) => void;
|
|
16
|
-
/** 激活状态颜色 (linked/hovered) */
|
|
17
|
-
primaryColor?: string;
|
|
18
|
-
/** 默认状态颜色 */
|
|
19
|
-
secondaryColor?: string;
|
|
20
|
-
/** 错误状态颜色 */
|
|
21
|
-
errorColor?: string;
|
|
22
|
-
/** 背景颜色 */
|
|
23
|
-
backgroundColor?: string;
|
|
24
|
-
}
|
|
25
|
-
declare const WorkflowPortRender: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
26
|
-
entity: {
|
|
27
|
-
type: PropType<WorkflowPortEntity>;
|
|
28
|
-
required: true;
|
|
29
|
-
};
|
|
30
|
-
className: {
|
|
31
|
-
type: StringConstructor;
|
|
32
|
-
default: string;
|
|
33
|
-
};
|
|
34
|
-
style: {
|
|
35
|
-
type: PropType<CSSProperties>;
|
|
36
|
-
};
|
|
37
|
-
onClick: {
|
|
38
|
-
type: PropType<(e: MouseEvent, port: WorkflowPortEntity) => void>;
|
|
39
|
-
};
|
|
40
|
-
primaryColor: {
|
|
41
|
-
type: StringConstructor;
|
|
42
|
-
};
|
|
43
|
-
secondaryColor: {
|
|
44
|
-
type: StringConstructor;
|
|
45
|
-
};
|
|
46
|
-
errorColor: {
|
|
47
|
-
type: StringConstructor;
|
|
48
|
-
};
|
|
49
|
-
backgroundColor: {
|
|
50
|
-
type: StringConstructor;
|
|
51
|
-
};
|
|
52
|
-
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
53
|
-
[key: string]: any;
|
|
54
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
55
|
-
entity: {
|
|
56
|
-
type: PropType<WorkflowPortEntity>;
|
|
57
|
-
required: true;
|
|
58
|
-
};
|
|
59
|
-
className: {
|
|
60
|
-
type: StringConstructor;
|
|
61
|
-
default: string;
|
|
62
|
-
};
|
|
63
|
-
style: {
|
|
64
|
-
type: PropType<CSSProperties>;
|
|
65
|
-
};
|
|
66
|
-
onClick: {
|
|
67
|
-
type: PropType<(e: MouseEvent, port: WorkflowPortEntity) => void>;
|
|
68
|
-
};
|
|
69
|
-
primaryColor: {
|
|
70
|
-
type: StringConstructor;
|
|
71
|
-
};
|
|
72
|
-
secondaryColor: {
|
|
73
|
-
type: StringConstructor;
|
|
74
|
-
};
|
|
75
|
-
errorColor: {
|
|
76
|
-
type: StringConstructor;
|
|
77
|
-
};
|
|
78
|
-
backgroundColor: {
|
|
79
|
-
type: StringConstructor;
|
|
80
|
-
};
|
|
81
|
-
}>> & Readonly<{}>, {
|
|
82
|
-
className: string;
|
|
83
|
-
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
87
|
-
* SPDX-License-Identifier: MIT
|
|
88
|
-
*/
|
|
89
|
-
declare const LINE_OFFSET = 6;
|
|
90
|
-
declare const LINE_PADDING = 12;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
94
|
-
* SPDX-License-Identifier: MIT
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
interface LineRenderProps {
|
|
98
|
-
key: string;
|
|
99
|
-
color?: string;
|
|
100
|
-
selected?: boolean;
|
|
101
|
-
hovered?: boolean;
|
|
102
|
-
line: WorkflowLineEntity;
|
|
103
|
-
lineType: LineRenderType;
|
|
104
|
-
version: string;
|
|
105
|
-
strokePrefix?: string;
|
|
106
|
-
children?: VNodeChild;
|
|
107
|
-
rendererRegistry?: FlowRendererRegistry;
|
|
108
|
-
[key: string]: any;
|
|
109
|
-
}
|
|
110
|
-
interface LinesLayerOptions {
|
|
111
|
-
renderInsideLine?: Component;
|
|
112
|
-
renderLine?: Component;
|
|
113
|
-
customLineProps?: (line: WorkflowLineEntity, oldProps: LineRenderProps) => LineRenderProps;
|
|
114
|
-
}
|
|
115
|
-
interface FreeLinesPluginOptions extends LinesLayerOptions {
|
|
116
|
-
contributions?: WorkflowLineRenderContributionFactory[];
|
|
117
|
-
defaultLineUIState?: Partial<WorkflowLineUIState>;
|
|
118
|
-
defaultLineType?: LineRenderType;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
declare const createFreeLinesPlugin: _flowgram_vue_core.PluginCreator<FreeLinesPluginOptions>;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
125
|
-
* SPDX-License-Identifier: MIT
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
|
-
declare class WorkflowLinesLayer extends Layer<LinesLayerOptions> {
|
|
129
|
-
static type: string;
|
|
130
|
-
hoverService: WorkflowHoverService;
|
|
131
|
-
selectService: WorkflowSelectService;
|
|
132
|
-
stackContext: StackingContextManager;
|
|
133
|
-
rendererRegistry: FlowRendererRegistry;
|
|
134
|
-
playgroundContainer: PlaygroundContainerFactory;
|
|
135
|
-
readonly lines: WorkflowLineEntity[];
|
|
136
|
-
readonly ports: WorkflowPortEntity[];
|
|
137
|
-
readonly trans: TransformData[];
|
|
138
|
-
protected workflowDocument: WorkflowDocument;
|
|
139
|
-
private layerID;
|
|
140
|
-
private mountedLines;
|
|
141
|
-
private _version;
|
|
142
|
-
private rafId?;
|
|
143
|
-
/**
|
|
144
|
-
* 节点线条
|
|
145
|
-
*/
|
|
146
|
-
node: HTMLDivElement;
|
|
147
|
-
onZoom(scale: number): void;
|
|
148
|
-
onReady(): void;
|
|
149
|
-
dispose(): void;
|
|
150
|
-
render(): VNode;
|
|
151
|
-
private scheduleLineRenderUpdate;
|
|
152
|
-
private bumpVersion;
|
|
153
|
-
private lineProps;
|
|
154
|
-
private lineVersion;
|
|
155
|
-
private lineComponent;
|
|
156
|
-
private renderLine;
|
|
157
|
-
private get renderElement();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
162
|
-
* SPDX-License-Identifier: MIT
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* 箭头渲染器属性接口
|
|
167
|
-
*/
|
|
168
|
-
interface ArrowRendererProps {
|
|
169
|
-
/** 用于渐变的唯一ID */
|
|
170
|
-
id: string;
|
|
171
|
-
/** 箭头位置 */
|
|
172
|
-
pos: IPoint;
|
|
173
|
-
location: LinePointLocation;
|
|
174
|
-
/** 描边宽度 */
|
|
175
|
-
strokeWidth: number;
|
|
176
|
-
/** 是否隐藏箭头 */
|
|
177
|
-
hide?: boolean;
|
|
178
|
-
/** 线条实体,提供更多上下文信息 */
|
|
179
|
-
line: WorkflowLineEntity;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* 箭头渲染器组件类型
|
|
183
|
-
*/
|
|
184
|
-
type ArrowRendererComponent = Component;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
188
|
-
* SPDX-License-Identifier: MIT
|
|
189
|
-
*/
|
|
190
|
-
|
|
191
|
-
interface BezierData {
|
|
192
|
-
fromPos: IPoint;
|
|
193
|
-
toPos: IPoint;
|
|
194
|
-
bbox: Rectangle;
|
|
195
|
-
controls: IPoint[];
|
|
196
|
-
bezier: Bezier;
|
|
197
|
-
path: string;
|
|
198
|
-
center: LineCenterPoint;
|
|
199
|
-
}
|
|
200
|
-
declare class WorkflowBezierLineContribution implements WorkflowLineRenderContribution {
|
|
201
|
-
static type: LineType;
|
|
202
|
-
entity: WorkflowLineEntity;
|
|
203
|
-
constructor(entity: WorkflowLineEntity);
|
|
204
|
-
private data?;
|
|
205
|
-
get path(): string;
|
|
206
|
-
calcDistance(pos: IPoint): number;
|
|
207
|
-
get bounds(): Rectangle;
|
|
208
|
-
get center(): LineCenterPoint | undefined;
|
|
209
|
-
update(params: {
|
|
210
|
-
fromPos: LinePoint;
|
|
211
|
-
toPos: LinePoint;
|
|
212
|
-
}): void;
|
|
213
|
-
private calcBezier;
|
|
214
|
-
private getPath;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
219
|
-
* SPDX-License-Identifier: MIT
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
|
-
interface FoldData {
|
|
223
|
-
points: IPoint[];
|
|
224
|
-
path: string;
|
|
225
|
-
bbox: Rectangle;
|
|
226
|
-
center: LineCenterPoint;
|
|
227
|
-
}
|
|
228
|
-
declare class WorkflowFoldLineContribution implements WorkflowLineRenderContribution {
|
|
229
|
-
static type: LineType;
|
|
230
|
-
entity: WorkflowLineEntity;
|
|
231
|
-
constructor(entity: WorkflowLineEntity);
|
|
232
|
-
private data?;
|
|
233
|
-
get path(): string;
|
|
234
|
-
calcDistance(pos: IPoint): number;
|
|
235
|
-
get bounds(): Rectangle;
|
|
236
|
-
get center(): LineCenterPoint | undefined;
|
|
237
|
-
update(params: {
|
|
238
|
-
fromPos: LinePoint;
|
|
239
|
-
toPos: LinePoint;
|
|
240
|
-
}): void;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
245
|
-
* SPDX-License-Identifier: MIT
|
|
246
|
-
*/
|
|
247
|
-
|
|
248
|
-
interface StraightData {
|
|
249
|
-
points: IPoint[];
|
|
250
|
-
path: string;
|
|
251
|
-
bbox: Rectangle;
|
|
252
|
-
center: LineCenterPoint;
|
|
253
|
-
}
|
|
254
|
-
declare class WorkflowStraightLineContribution implements WorkflowLineRenderContribution {
|
|
255
|
-
static type: LineType;
|
|
256
|
-
entity: WorkflowLineEntity;
|
|
257
|
-
constructor(entity: WorkflowLineEntity);
|
|
258
|
-
private data?;
|
|
259
|
-
get path(): string;
|
|
260
|
-
calcDistance(pos: IPoint): number;
|
|
261
|
-
get bounds(): Rectangle;
|
|
262
|
-
get center(): LineCenterPoint | undefined;
|
|
263
|
-
update(params: {
|
|
264
|
-
fromPos: LinePoint;
|
|
265
|
-
toPos: LinePoint;
|
|
266
|
-
}): void;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
export { type ArrowRendererComponent, type ArrowRendererProps, type BezierData, type FoldData, type FreeLinesPluginOptions, LINE_OFFSET, LINE_PADDING, type LineRenderProps, WorkflowLinesLayer as LinesLayer, type LinesLayerOptions, type StraightData, WorkflowBezierLineContribution, WorkflowFoldLineContribution, WorkflowLinesLayer, WorkflowPortRender, type WorkflowPortRenderProps, WorkflowStraightLineContribution, createFreeLinesPlugin };
|
|
1
|
+
export * from '../src/index';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { defineComponent, h, shallowRef, watch, onBeforeUnmount, Teleport, provide, Fragment } from 'vue';
|
|
2
2
|
import classNames from 'clsx';
|
|
3
|
+
import { FlowNodeTransformData } from '@flowgram-vue/document';
|
|
3
4
|
import { WorkflowHoverService, WorkflowLinesManager, usePlaygroundReadonlyState, WorkflowLineRenderData, WorkflowSelectService, WorkflowLineEntity, WorkflowPortEntity, WorkflowNodeEntity, WorkflowDocument, LineType, nanoid, getLineCenter } from '@flowgram-vue/free-layout-core';
|
|
4
5
|
import { useService, MouseTouchEvent, PlaygroundVueContainerKey, PlaygroundVueRefKey, Playground, PlaygroundContainerFactory, observeEntities, observeEntityDatas, TransformData, definePluginCreator, Layer } from '@flowgram-vue/core';
|
|
6
|
+
import styleInject from '#style-inject';
|
|
5
7
|
import { inject, injectable } from 'inversify';
|
|
6
8
|
import { Point, domUtils, Rectangle } from '@flowgram-vue/utils';
|
|
7
9
|
import { FlowRendererKey, FlowRendererRegistry } from '@flowgram-vue/renderer';
|
|
@@ -30,6 +32,7 @@ var CrossHair = defineComponent({
|
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
34
|
var cross_hair_default = CrossHair;
|
|
35
|
+
styleInject('.workflow-port-render {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n margin-top: -10px;\n margin-left: -10px;\n left: 50%;\n top: 50%;\n position: absolute;\n border: none;\n}\n.workflow-port-render > .symbol {\n opacity: 0;\n}\n.workflow-port-render .bg-circle {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n border-radius: 50%;\n width: 20px;\n height: 20px;\n background-color: var(--g-workflow-port-color-background, #fff);\n transform: scale(0.5);\n transition: all 0.2s linear 0s;\n}\n.workflow-port-render .bg {\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n background: var(--g-workflow-port-color-secondary, #9197f1);\n transform: scale(0.4, 0.4);\n transition: all 0.2s linear 0s;\n}\n.workflow-port-render .bg.hasError {\n background: var(--g-workflow-port-color-error, red);\n}\n.workflow-port-render .bg .symbol {\n position: absolute;\n width: 14px;\n height: 14px;\n opacity: 0;\n pointer-events: none;\n color: var(--g-workflow-port-color-background, #fff);\n transition: opacity 0.2s linear 0s;\n}\n.workflow-port-render .bg .symbol > svg {\n width: 14px;\n height: 14px;\n}\n.workflow-port-render .focus-circle {\n position: absolute;\n display: flex;\n justify-content: center;\n align-items: center;\n width: 8px;\n height: 8px;\n opacity: 0;\n background: var(--g-workflow-port-color-secondary, #9197f1);\n border-radius: 50%;\n transition: opacity 0.2s linear 0s;\n}\n.workflow-port-render.linked .bg:not(.hasError) {\n background: var(--g-workflow-port-color-primary, #4d53e8);\n}\n.workflow-port-render.hovered .bg:not(.hasError) {\n border: none;\n cursor: crosshair;\n transform: scale(1, 1);\n background: var(--g-workflow-port-color-primary, #4d53e8);\n}\n.workflow-port-render.hovered .bg:not(.hasError) > .symbol {\n opacity: 1;\n}\n.workflow-port-render .cross-hair {\n position: relative;\n left: 2px;\n top: 2px;\n}\n.workflow-port-render .cross-hair::after,\n.workflow-port-render .cross-hair::before {\n content: "";\n background: var(--g-workflow-port-color-background, #fff);\n border-radius: 2px;\n position: absolute;\n}\n.workflow-port-render .cross-hair::after {\n left: 4px;\n width: 2px;\n height: 6px;\n box-shadow: 0 4px var(--g-workflow-port-color-background, #fff);\n}\n.workflow-port-render .cross-hair::before {\n top: 4px;\n width: 6px;\n height: 2px;\n box-shadow: 4px 0 var(--g-workflow-port-color-background, #fff);\n}\n');
|
|
33
36
|
|
|
34
37
|
// src/components/workflow-port-render/index.ts
|
|
35
38
|
var WorkflowPortRender = defineComponent({
|
|
@@ -75,6 +78,11 @@ var WorkflowPortRender = defineComponent({
|
|
|
75
78
|
posX.value = Math.round(newPos.x);
|
|
76
79
|
posY.value = Math.round(newPos.y);
|
|
77
80
|
}),
|
|
81
|
+
entity.node.getData(FlowNodeTransformData).onDataChange(() => {
|
|
82
|
+
const newPos = entity.relativePosition;
|
|
83
|
+
posX.value = Math.round(newPos.x);
|
|
84
|
+
posY.value = Math.round(newPos.y);
|
|
85
|
+
}),
|
|
78
86
|
hoverService.onHoveredChange(() => {
|
|
79
87
|
hovered.value = hoverService.isHovered(entity.id);
|
|
80
88
|
}),
|
|
@@ -252,6 +260,7 @@ var ArrowRenderer = defineComponent({
|
|
|
252
260
|
};
|
|
253
261
|
}
|
|
254
262
|
});
|
|
263
|
+
styleInject(".gedit-flow-activity-edge {\n position: absolute;\n}\n@keyframes flowingDash {\n to {\n stroke-dashoffset: -13;\n }\n}\n.gedit-flow-activity-edge .dashed-line {\n stroke-dasharray: 8, 5;\n}\n.gedit-flow-activity-edge .flowing-line {\n animation: flowingDash 0.5s linear infinite;\n}\n");
|
|
255
264
|
|
|
256
265
|
// src/components/workflow-line-render/line-svg.ts
|
|
257
266
|
var PADDING = 12;
|