@flowgram.ai/free-layout-core 0.1.8 → 0.1.10

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.
@@ -1,4 +1,4 @@
1
- export { t as LineColor, u as LineColors, k as LinePosition, L as LineRenderType, s as LineType, q as WorkflowContentChangeEvent, p as WorkflowContentChangeType, o as WorkflowJSON, j as WorkflowLineRenderContribution, v as WorkflowLineRenderContributionFactory, d as WorkflowNodeJSON, r as WorkflowNodeMeta } from '../workflow-line-entity-DZGrnBuq.mjs';
1
+ export { q as LineColor, r as LineColors, g as LinePosition, L as LineRenderType, p as LineType, m as WorkflowContentChangeEvent, l as WorkflowContentChangeType, k as WorkflowJSON, f as WorkflowLineRenderContribution, s as WorkflowLineRenderContributionFactory, o as WorkflowNodeJSON, n as WorkflowNodeMeta } from '../workflow-line-entity-BJQBRDgJ.mjs';
2
2
  export { WorkflowEdgeJSON } from './workflow-edge.mjs';
3
3
  export { WorkflowNodeFormMeta, WorkflowNodeRegistry, WorkflowNodeRenderProps } from './workflow-registry.mjs';
4
4
  export { a as WorkflowSubCanvas } from '../workflow-sub-canvas-DOVla1mw.mjs';
@@ -6,6 +6,7 @@ import '@flowgram.ai/utils';
6
6
  import '@flowgram.ai/core';
7
7
  import '@flowgram.ai/document';
8
8
  import '@flowgram.ai/form-core';
9
+ import 'react';
9
10
  import '@flowgram.ai/node';
10
11
 
11
12
  declare const URLParams: unique symbol;
@@ -1,4 +1,4 @@
1
- export { t as LineColor, u as LineColors, k as LinePosition, L as LineRenderType, s as LineType, q as WorkflowContentChangeEvent, p as WorkflowContentChangeType, o as WorkflowJSON, j as WorkflowLineRenderContribution, v as WorkflowLineRenderContributionFactory, d as WorkflowNodeJSON, r as WorkflowNodeMeta } from '../workflow-line-entity-BcXJ4GjA.js';
1
+ export { q as LineColor, r as LineColors, g as LinePosition, L as LineRenderType, p as LineType, m as WorkflowContentChangeEvent, l as WorkflowContentChangeType, k as WorkflowJSON, f as WorkflowLineRenderContribution, s as WorkflowLineRenderContributionFactory, o as WorkflowNodeJSON, n as WorkflowNodeMeta } from '../workflow-line-entity-CEitdjhk.js';
2
2
  export { WorkflowEdgeJSON } from './workflow-edge.js';
3
3
  export { WorkflowNodeFormMeta, WorkflowNodeRegistry, WorkflowNodeRenderProps } from './workflow-registry.js';
4
4
  export { a as WorkflowSubCanvas } from '../workflow-sub-canvas-DOVla1mw.js';
@@ -6,6 +6,7 @@ import '@flowgram.ai/utils';
6
6
  import '@flowgram.ai/core';
7
7
  import '@flowgram.ai/document';
8
8
  import '@flowgram.ai/form-core';
9
+ import 'react';
9
10
  import '@flowgram.ai/node';
10
11
 
11
12
  declare const URLParams: unique symbol;
@@ -1,7 +1,8 @@
1
1
  import '../workflow-sub-canvas-DOVla1mw.mjs';
2
- export { q as WorkflowContentChangeEvent, p as WorkflowContentChangeType, o as WorkflowJSON } from '../workflow-line-entity-DZGrnBuq.mjs';
2
+ export { m as WorkflowContentChangeEvent, l as WorkflowContentChangeType, k as WorkflowJSON } from '../workflow-line-entity-BJQBRDgJ.mjs';
3
3
  import './workflow-edge.mjs';
4
4
  import '@flowgram.ai/document';
5
5
  import '@flowgram.ai/utils';
6
6
  import '@flowgram.ai/core';
7
7
  import '@flowgram.ai/form-core';
8
+ import 'react';
@@ -1,7 +1,8 @@
1
1
  import '../workflow-sub-canvas-DOVla1mw.js';
2
- export { q as WorkflowContentChangeEvent, p as WorkflowContentChangeType, o as WorkflowJSON } from '../workflow-line-entity-BcXJ4GjA.js';
2
+ export { m as WorkflowContentChangeEvent, l as WorkflowContentChangeType, k as WorkflowJSON } from '../workflow-line-entity-CEitdjhk.js';
3
3
  import './workflow-edge.js';
4
4
  import '@flowgram.ai/document';
5
5
  import '@flowgram.ai/utils';
6
6
  import '@flowgram.ai/core';
7
7
  import '@flowgram.ai/form-core';
8
+ import 'react';
@@ -1,7 +1,8 @@
1
1
  import '@flowgram.ai/utils';
2
- export { t as LineColor, u as LineColors, k as LinePosition, L as LineRenderType, s as LineType, j as WorkflowLineRenderContribution, v as WorkflowLineRenderContributionFactory } from '../workflow-line-entity-DZGrnBuq.mjs';
2
+ export { q as LineColor, r as LineColors, g as LinePosition, L as LineRenderType, p as LineType, f as WorkflowLineRenderContribution, s as WorkflowLineRenderContributionFactory } from '../workflow-line-entity-BJQBRDgJ.mjs';
3
3
  import '@flowgram.ai/core';
4
4
  import '@flowgram.ai/document';
5
5
  import '../workflow-sub-canvas-DOVla1mw.mjs';
6
6
  import '@flowgram.ai/form-core';
7
7
  import './workflow-edge.mjs';
8
+ import 'react';
@@ -1,7 +1,8 @@
1
1
  import '@flowgram.ai/utils';
2
- export { t as LineColor, u as LineColors, k as LinePosition, L as LineRenderType, s as LineType, j as WorkflowLineRenderContribution, v as WorkflowLineRenderContributionFactory } from '../workflow-line-entity-BcXJ4GjA.js';
2
+ export { q as LineColor, r as LineColors, g as LinePosition, L as LineRenderType, p as LineType, f as WorkflowLineRenderContribution, s as WorkflowLineRenderContributionFactory } from '../workflow-line-entity-CEitdjhk.js';
3
3
  import '@flowgram.ai/core';
4
4
  import '@flowgram.ai/document';
5
5
  import '../workflow-sub-canvas-DOVla1mw.js';
6
6
  import '@flowgram.ai/form-core';
7
7
  import './workflow-edge.js';
8
+ import 'react';
@@ -1,7 +1,8 @@
1
1
  import '@flowgram.ai/utils';
2
2
  import '@flowgram.ai/document';
3
3
  import '../workflow-sub-canvas-DOVla1mw.mjs';
4
- export { d as WorkflowNodeJSON, r as WorkflowNodeMeta } from '../workflow-line-entity-DZGrnBuq.mjs';
4
+ export { o as WorkflowNodeJSON, n as WorkflowNodeMeta } from '../workflow-line-entity-BJQBRDgJ.mjs';
5
5
  import './workflow-edge.mjs';
6
6
  import '@flowgram.ai/core';
7
7
  import '@flowgram.ai/form-core';
8
+ import 'react';
@@ -1,7 +1,8 @@
1
1
  import '@flowgram.ai/utils';
2
2
  import '@flowgram.ai/document';
3
3
  import '../workflow-sub-canvas-DOVla1mw.js';
4
- export { d as WorkflowNodeJSON, r as WorkflowNodeMeta } from '../workflow-line-entity-BcXJ4GjA.js';
4
+ export { o as WorkflowNodeJSON, n as WorkflowNodeMeta } from '../workflow-line-entity-CEitdjhk.js';
5
5
  import './workflow-edge.js';
6
6
  import '@flowgram.ai/core';
7
7
  import '@flowgram.ai/form-core';
8
+ import 'react';
@@ -2,10 +2,11 @@ import { FormMeta } from '@flowgram.ai/node';
2
2
  import { FormMetaOrFormMetaGenerator } from '@flowgram.ai/form-core';
3
3
  import { FlowNodeRegistry } from '@flowgram.ai/document';
4
4
  import { W as WorkflowNodeEntity } from '../workflow-sub-canvas-DOVla1mw.mjs';
5
- import { r as WorkflowNodeMeta } from '../workflow-line-entity-DZGrnBuq.mjs';
5
+ import { n as WorkflowNodeMeta } from '../workflow-line-entity-BJQBRDgJ.mjs';
6
6
  import '@flowgram.ai/utils';
7
7
  import '@flowgram.ai/core';
8
8
  import './workflow-edge.mjs';
9
+ import 'react';
9
10
 
10
11
  /**
11
12
  * 节点表单引擎配置
@@ -2,10 +2,11 @@ import { FormMeta } from '@flowgram.ai/node';
2
2
  import { FormMetaOrFormMetaGenerator } from '@flowgram.ai/form-core';
3
3
  import { FlowNodeRegistry } from '@flowgram.ai/document';
4
4
  import { W as WorkflowNodeEntity } from '../workflow-sub-canvas-DOVla1mw.js';
5
- import { r as WorkflowNodeMeta } from '../workflow-line-entity-BcXJ4GjA.js';
5
+ import { n as WorkflowNodeMeta } from '../workflow-line-entity-CEitdjhk.js';
6
6
  import '@flowgram.ai/utils';
7
7
  import '@flowgram.ai/core';
8
8
  import './workflow-edge.js';
9
+ import 'react';
9
10
 
10
11
  /**
11
12
  * 节点表单引擎配置
@@ -1,10 +1,11 @@
1
1
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
2
- import { IPoint, Rectangle, Emitter, Event, DisposableCollection } from '@flowgram.ai/utils';
3
- import { EntityManager, SelectionService, Playground, Entity, PlaygroundConfigEntity, PlaygroundContext, EntityOpts } from '@flowgram.ai/core';
4
- import { FlowNodeMeta, FlowNodeJSON, FlowDocumentOptions, FlowDocument } from '@flowgram.ai/document';
2
+ import { IPoint, Rectangle, Emitter, Event, PositionSchema, DisposableCollection, Disposable } from '@flowgram.ai/utils';
3
+ import { EntityManager, SelectionService, Playground, Entity, PlaygroundConfigEntity, PlaygroundContext, PlaygroundDragEvent, CommandService, EntityOpts } from '@flowgram.ai/core';
4
+ import { FlowNodeMeta, FlowNodeJSON, FlowDocument, FlowOperationBaseService, FlowNodeEntity, FlowDocumentOptions } from '@flowgram.ai/document';
5
5
  import { W as WorkflowNodeEntity, a as WorkflowSubCanvas } from './workflow-sub-canvas-DOVla1mw.mjs';
6
6
  import { NodeEngineContext } from '@flowgram.ai/form-core';
7
7
  import { WorkflowEdgeJSON } from './typings/workflow-edge.mjs';
8
+ import React from 'react';
8
9
 
9
10
  /**
10
11
  * 节点 meta 信息
@@ -125,53 +126,6 @@ type WorkflowLineRenderContributionFactory = (new (entity: WorkflowLineEntity) =
125
126
  type: LineRenderType;
126
127
  };
127
128
 
128
- declare const WorkflowDocumentOptions: unique symbol;
129
- /**
130
- * 线条配置
131
- */
132
- interface WorkflowDocumentOptions extends FlowDocumentOptions {
133
- cursors?: {
134
- grab?: string;
135
- grabbing?: string;
136
- };
137
- /** 线条颜色 */
138
- lineColor?: Partial<LineColor>;
139
- /** 是否显示错误线条 */
140
- isErrorLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
141
- /** 是否错误端口 */
142
- isErrorPort?: (port: WorkflowPortEntity) => boolean;
143
- /** 是否禁用端口 */
144
- isDisabledPort?: (port: WorkflowPortEntity) => boolean;
145
- /** 是否反转线条箭头 */
146
- isReverseLine?: (line: WorkflowLineEntity) => boolean;
147
- /** 是否隐藏线条箭头 */
148
- isHideArrowLine?: (line: WorkflowLineEntity) => boolean;
149
- /** 是否流动线条 */
150
- isFlowingLine?: (line: WorkflowLineEntity) => boolean;
151
- /** 是否禁用线条 */
152
- isDisabledLine?: (line: WorkflowLineEntity) => boolean;
153
- /** 是否竖向线条 */
154
- isVerticalLine?: (line: WorkflowLineEntity) => boolean;
155
- /** 获取线条渲染器 */
156
- setLineRenderType?: (line: WorkflowLineEntity) => LineRenderType | undefined;
157
- /** 设置线条样式 */
158
- setLineClassName?: (line: WorkflowLineEntity) => string | undefined;
159
- /** 能否添加线条 */
160
- canAddLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity, lines: WorkflowLinesManager, silent?: boolean) => boolean;
161
- /** 能否删除节点 */
162
- canDeleteNode?: (node: WorkflowNodeEntity, silent?: boolean) => boolean;
163
- /** 能否删除线条 */
164
- canDeleteLine?: (line: WorkflowLineEntity, newLineInfo?: Required<WorkflowLinePortInfo>, silent?: boolean) => boolean;
165
- /**
166
- * @param fromPort - 开始点
167
- * @param oldToPort - 旧的连接点
168
- * @param newToPort - 新的连接点
169
- * @param lines - 线条管理器
170
- */
171
- canResetLine?: (fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity, lines: WorkflowLinesManager) => boolean;
172
- }
173
- declare const WorkflowDocumentOptionsDefault: WorkflowDocumentOptions;
174
-
175
129
  /**
176
130
  * 可 Hover 的节点 类型
177
131
  */
@@ -347,6 +301,172 @@ declare class WorkflowDocument extends FlowDocument {
347
301
  private createWorkflowLine;
348
302
  }
349
303
 
304
+ interface LineEventProps {
305
+ type: 'onDrag' | 'onDragEnd';
306
+ onDragNodeId?: string;
307
+ event?: MouseEvent;
308
+ }
309
+ interface INodesDragEvent {
310
+ type: string;
311
+ nodes: FlowNodeEntity[];
312
+ startPositions: IPoint[];
313
+ altKey: boolean;
314
+ }
315
+ interface NodesDragEndEvent extends INodesDragEvent {
316
+ type: 'onDragEnd';
317
+ }
318
+ type NodesDragEvent = NodesDragEndEvent;
319
+ type onDragLineEndParams = {
320
+ fromPort: WorkflowPortEntity;
321
+ toPort?: WorkflowPortEntity;
322
+ mousePos: PositionSchema;
323
+ line?: WorkflowLineEntity;
324
+ originLine?: WorkflowLineEntity;
325
+ event: PlaygroundDragEvent;
326
+ };
327
+ type OnDragLineEnd = (params: onDragLineEndParams) => Promise<void>;
328
+ declare class WorkflowDragService {
329
+ protected playgroundConfig: PlaygroundConfigEntity;
330
+ protected hoverService: WorkflowHoverService;
331
+ protected document: WorkflowDocument;
332
+ protected linesManager: WorkflowLinesManager;
333
+ protected commandService: CommandService;
334
+ protected selectService: WorkflowSelectService;
335
+ protected operationService: FlowOperationBaseService;
336
+ readonly options: WorkflowDocumentOptions;
337
+ private _onDragLineEventEmitter;
338
+ readonly onDragLineEventChange: _flowgram_ai_utils.Event<LineEventProps>;
339
+ isDragging: boolean;
340
+ private _nodesDragEmitter;
341
+ readonly onNodesDrag: _flowgram_ai_utils.Event<NodesDragEndEvent>;
342
+ protected _toDispose: DisposableCollection;
343
+ private _droppableTransforms;
344
+ private _dropNode?;
345
+ private posAdjusters;
346
+ private _onDragLineEndCallbacks;
347
+ init(): void;
348
+ dispose(): void;
349
+ /**
350
+ * 拖拽选中节点
351
+ * @param event
352
+ */
353
+ startDragSelectedNodes(event: MouseEvent | React.MouseEvent): Promise<boolean>;
354
+ /**
355
+ * 通过拖入卡片添加
356
+ * @param type
357
+ * @param event
358
+ * @param data 节点数据
359
+ */
360
+ dropCard(type: string, event: {
361
+ clientX: number;
362
+ clientY: number;
363
+ }, data?: Partial<WorkflowNodeJSON>, parent?: WorkflowNodeEntity): Promise<WorkflowNodeEntity | undefined>;
364
+ /**
365
+ * 拖拽卡片到画布
366
+ * 返回创建结果
367
+ * @param type
368
+ * @param event
369
+ */
370
+ startDragCard(type: string, event: React.MouseEvent, data: Partial<WorkflowNodeJSON>, cloneNode?: (e: PlaygroundDragEvent) => HTMLDivElement): Promise<WorkflowNodeEntity | undefined>;
371
+ /**
372
+ * 如果存在容器节点,且传入鼠标坐标,需要用容器的坐标减去传入的鼠标坐标
373
+ */
374
+ adjustSubNodePosition(subNodeType?: string, containerNode?: WorkflowNodeEntity, mousePos?: IPoint, resetEmptyPos?: boolean): IPoint;
375
+ /**
376
+ * 注册位置调整
377
+ */
378
+ registerPosAdjuster(adjuster: (params: {
379
+ selectedNodes: WorkflowNodeEntity[];
380
+ position: IPoint;
381
+ }) => IPoint): {
382
+ dispose: () => boolean;
383
+ };
384
+ /**
385
+ * 获取拖拽偏移
386
+ */
387
+ private getDragPosOffset;
388
+ private updateDroppableTransforms;
389
+ /**
390
+ * 获取节点整体位置
391
+ */
392
+ private getNodesPosition;
393
+ private nodeSelectable;
394
+ private updateDropNode;
395
+ private clearDrop;
396
+ private setLineColor;
397
+ private handleDragOnNode;
398
+ private childrenOfContainer;
399
+ /**
400
+ * 绘制线条
401
+ * @param opts
402
+ * @param event
403
+ */
404
+ startDrawingLine(fromPort: WorkflowPortEntity, event: {
405
+ clientX: number;
406
+ clientY: number;
407
+ }, originLine?: WorkflowLineEntity): Promise<{
408
+ dragSuccess?: boolean;
409
+ newLine?: WorkflowLineEntity;
410
+ }>;
411
+ /**
412
+ * 重新连接线条
413
+ * @param line
414
+ * @param e
415
+ */
416
+ resetLine(line: WorkflowLineEntity, e: MouseEvent): Promise<void>;
417
+ /** 线条拖拽结束 */
418
+ onDragLineEnd(callback: OnDragLineEnd): Disposable;
419
+ }
420
+
421
+ declare const WorkflowDocumentOptions: unique symbol;
422
+ /**
423
+ * 线条配置
424
+ */
425
+ interface WorkflowDocumentOptions extends FlowDocumentOptions {
426
+ cursors?: {
427
+ grab?: string;
428
+ grabbing?: string;
429
+ };
430
+ /** 线条颜色 */
431
+ lineColor?: Partial<LineColor>;
432
+ /** 是否显示错误线条 */
433
+ isErrorLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
434
+ /** 是否错误端口 */
435
+ isErrorPort?: (port: WorkflowPortEntity) => boolean;
436
+ /** 是否禁用端口 */
437
+ isDisabledPort?: (port: WorkflowPortEntity) => boolean;
438
+ /** 是否反转线条箭头 */
439
+ isReverseLine?: (line: WorkflowLineEntity) => boolean;
440
+ /** 是否隐藏线条箭头 */
441
+ isHideArrowLine?: (line: WorkflowLineEntity) => boolean;
442
+ /** 是否流动线条 */
443
+ isFlowingLine?: (line: WorkflowLineEntity) => boolean;
444
+ /** 是否禁用线条 */
445
+ isDisabledLine?: (line: WorkflowLineEntity) => boolean;
446
+ /** 是否竖向线条 */
447
+ isVerticalLine?: (line: WorkflowLineEntity) => boolean;
448
+ /** 拖拽线条结束 */
449
+ onDragLineEnd?: (params: onDragLineEndParams) => Promise<void>;
450
+ /** 获取线条渲染器 */
451
+ setLineRenderType?: (line: WorkflowLineEntity) => LineRenderType | undefined;
452
+ /** 设置线条样式 */
453
+ setLineClassName?: (line: WorkflowLineEntity) => string | undefined;
454
+ /** 能否添加线条 */
455
+ canAddLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity, lines: WorkflowLinesManager, silent?: boolean) => boolean;
456
+ /** 能否删除节点 */
457
+ canDeleteNode?: (node: WorkflowNodeEntity, silent?: boolean) => boolean;
458
+ /** 能否删除线条 */
459
+ canDeleteLine?: (line: WorkflowLineEntity, newLineInfo?: Required<WorkflowLinePortInfo>, silent?: boolean) => boolean;
460
+ /**
461
+ * @param fromPort - 开始点
462
+ * @param oldToPort - 旧的连接点
463
+ * @param newToPort - 新的连接点
464
+ * @param lines - 线条管理器
465
+ */
466
+ canResetLine?: (fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity, lines: WorkflowLinesManager) => boolean;
467
+ }
468
+ declare const WorkflowDocumentOptionsDefault: WorkflowDocumentOptions;
469
+
350
470
  /**
351
471
  * 线条管理
352
472
  */
@@ -624,4 +744,4 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
624
744
  fireRender(): void;
625
745
  }
626
746
 
627
- export { PORT_SIZE as A, type WorkflowPortEntityOpts as B, type WorkfloEntityHoverable as C, WorkflowDocumentProvider as D, WorkflowDocumentOptions as E, WorkflowDocumentOptionsDefault as F, type LineRenderType as L, POINT_RADIUS as P, WorkflowHoverService as W, WorkflowDocument as a, WorkflowLinesManager as b, WorkflowSelectService as c, type WorkflowNodeJSON as d, WorkflowPortEntity as e, WorkflowLineEntity as f, type WorkflowPorts as g, type WorkflowPortType as h, type WorkflowPort as i, type WorkflowLineRenderContribution as j, type LinePosition as k, getPortEntityId as l, WORKFLOW_LINE_ENTITY as m, domReactToBounds as n, type WorkflowJSON as o, WorkflowContentChangeType as p, type WorkflowContentChangeEvent as q, type WorkflowNodeMeta as r, LineType as s, type LineColor as t, LineColors as u, type WorkflowLineRenderContributionFactory as v, LINE_HOVER_DISTANCE as w, type WorkflowLinePortInfo as x, type WorkflowLineEntityOpts as y, type WorkflowLineInfo as z };
747
+ export { type WorkfloEntityHoverable as A, WorkflowHoverService as B, type NodesDragEvent as C, type onDragLineEndParams as D, WorkflowDragService as E, WorkflowDocumentProvider as F, WorkflowLinesManager as G, WorkflowDocumentOptions as H, WorkflowDocumentOptionsDefault as I, type LineRenderType as L, type NodesDragEndEvent as N, type OnDragLineEnd as O, POINT_RADIUS as P, WorkflowPortEntity as W, WorkflowDocument as a, type WorkflowPorts as b, type WorkflowPortType as c, type WorkflowPort as d, WorkflowLineEntity as e, type WorkflowLineRenderContribution as f, type LinePosition as g, getPortEntityId as h, WORKFLOW_LINE_ENTITY as i, domReactToBounds as j, type WorkflowJSON as k, WorkflowContentChangeType as l, type WorkflowContentChangeEvent as m, type WorkflowNodeMeta as n, type WorkflowNodeJSON as o, LineType as p, type LineColor as q, LineColors as r, type WorkflowLineRenderContributionFactory as s, LINE_HOVER_DISTANCE as t, type WorkflowLinePortInfo as u, type WorkflowLineEntityOpts as v, type WorkflowLineInfo as w, PORT_SIZE as x, type WorkflowPortEntityOpts as y, WorkflowSelectService as z };
@@ -1,10 +1,11 @@
1
1
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
2
- import { IPoint, Rectangle, Emitter, Event, DisposableCollection } from '@flowgram.ai/utils';
3
- import { EntityManager, SelectionService, Playground, Entity, PlaygroundConfigEntity, PlaygroundContext, EntityOpts } from '@flowgram.ai/core';
4
- import { FlowNodeMeta, FlowNodeJSON, FlowDocumentOptions, FlowDocument } from '@flowgram.ai/document';
2
+ import { IPoint, Rectangle, Emitter, Event, PositionSchema, DisposableCollection, Disposable } from '@flowgram.ai/utils';
3
+ import { EntityManager, SelectionService, Playground, Entity, PlaygroundConfigEntity, PlaygroundContext, PlaygroundDragEvent, CommandService, EntityOpts } from '@flowgram.ai/core';
4
+ import { FlowNodeMeta, FlowNodeJSON, FlowDocument, FlowOperationBaseService, FlowNodeEntity, FlowDocumentOptions } from '@flowgram.ai/document';
5
5
  import { W as WorkflowNodeEntity, a as WorkflowSubCanvas } from './workflow-sub-canvas-DOVla1mw.js';
6
6
  import { NodeEngineContext } from '@flowgram.ai/form-core';
7
7
  import { WorkflowEdgeJSON } from './typings/workflow-edge.js';
8
+ import React from 'react';
8
9
 
9
10
  /**
10
11
  * 节点 meta 信息
@@ -125,53 +126,6 @@ type WorkflowLineRenderContributionFactory = (new (entity: WorkflowLineEntity) =
125
126
  type: LineRenderType;
126
127
  };
127
128
 
128
- declare const WorkflowDocumentOptions: unique symbol;
129
- /**
130
- * 线条配置
131
- */
132
- interface WorkflowDocumentOptions extends FlowDocumentOptions {
133
- cursors?: {
134
- grab?: string;
135
- grabbing?: string;
136
- };
137
- /** 线条颜色 */
138
- lineColor?: Partial<LineColor>;
139
- /** 是否显示错误线条 */
140
- isErrorLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
141
- /** 是否错误端口 */
142
- isErrorPort?: (port: WorkflowPortEntity) => boolean;
143
- /** 是否禁用端口 */
144
- isDisabledPort?: (port: WorkflowPortEntity) => boolean;
145
- /** 是否反转线条箭头 */
146
- isReverseLine?: (line: WorkflowLineEntity) => boolean;
147
- /** 是否隐藏线条箭头 */
148
- isHideArrowLine?: (line: WorkflowLineEntity) => boolean;
149
- /** 是否流动线条 */
150
- isFlowingLine?: (line: WorkflowLineEntity) => boolean;
151
- /** 是否禁用线条 */
152
- isDisabledLine?: (line: WorkflowLineEntity) => boolean;
153
- /** 是否竖向线条 */
154
- isVerticalLine?: (line: WorkflowLineEntity) => boolean;
155
- /** 获取线条渲染器 */
156
- setLineRenderType?: (line: WorkflowLineEntity) => LineRenderType | undefined;
157
- /** 设置线条样式 */
158
- setLineClassName?: (line: WorkflowLineEntity) => string | undefined;
159
- /** 能否添加线条 */
160
- canAddLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity, lines: WorkflowLinesManager, silent?: boolean) => boolean;
161
- /** 能否删除节点 */
162
- canDeleteNode?: (node: WorkflowNodeEntity, silent?: boolean) => boolean;
163
- /** 能否删除线条 */
164
- canDeleteLine?: (line: WorkflowLineEntity, newLineInfo?: Required<WorkflowLinePortInfo>, silent?: boolean) => boolean;
165
- /**
166
- * @param fromPort - 开始点
167
- * @param oldToPort - 旧的连接点
168
- * @param newToPort - 新的连接点
169
- * @param lines - 线条管理器
170
- */
171
- canResetLine?: (fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity, lines: WorkflowLinesManager) => boolean;
172
- }
173
- declare const WorkflowDocumentOptionsDefault: WorkflowDocumentOptions;
174
-
175
129
  /**
176
130
  * 可 Hover 的节点 类型
177
131
  */
@@ -347,6 +301,172 @@ declare class WorkflowDocument extends FlowDocument {
347
301
  private createWorkflowLine;
348
302
  }
349
303
 
304
+ interface LineEventProps {
305
+ type: 'onDrag' | 'onDragEnd';
306
+ onDragNodeId?: string;
307
+ event?: MouseEvent;
308
+ }
309
+ interface INodesDragEvent {
310
+ type: string;
311
+ nodes: FlowNodeEntity[];
312
+ startPositions: IPoint[];
313
+ altKey: boolean;
314
+ }
315
+ interface NodesDragEndEvent extends INodesDragEvent {
316
+ type: 'onDragEnd';
317
+ }
318
+ type NodesDragEvent = NodesDragEndEvent;
319
+ type onDragLineEndParams = {
320
+ fromPort: WorkflowPortEntity;
321
+ toPort?: WorkflowPortEntity;
322
+ mousePos: PositionSchema;
323
+ line?: WorkflowLineEntity;
324
+ originLine?: WorkflowLineEntity;
325
+ event: PlaygroundDragEvent;
326
+ };
327
+ type OnDragLineEnd = (params: onDragLineEndParams) => Promise<void>;
328
+ declare class WorkflowDragService {
329
+ protected playgroundConfig: PlaygroundConfigEntity;
330
+ protected hoverService: WorkflowHoverService;
331
+ protected document: WorkflowDocument;
332
+ protected linesManager: WorkflowLinesManager;
333
+ protected commandService: CommandService;
334
+ protected selectService: WorkflowSelectService;
335
+ protected operationService: FlowOperationBaseService;
336
+ readonly options: WorkflowDocumentOptions;
337
+ private _onDragLineEventEmitter;
338
+ readonly onDragLineEventChange: _flowgram_ai_utils.Event<LineEventProps>;
339
+ isDragging: boolean;
340
+ private _nodesDragEmitter;
341
+ readonly onNodesDrag: _flowgram_ai_utils.Event<NodesDragEndEvent>;
342
+ protected _toDispose: DisposableCollection;
343
+ private _droppableTransforms;
344
+ private _dropNode?;
345
+ private posAdjusters;
346
+ private _onDragLineEndCallbacks;
347
+ init(): void;
348
+ dispose(): void;
349
+ /**
350
+ * 拖拽选中节点
351
+ * @param event
352
+ */
353
+ startDragSelectedNodes(event: MouseEvent | React.MouseEvent): Promise<boolean>;
354
+ /**
355
+ * 通过拖入卡片添加
356
+ * @param type
357
+ * @param event
358
+ * @param data 节点数据
359
+ */
360
+ dropCard(type: string, event: {
361
+ clientX: number;
362
+ clientY: number;
363
+ }, data?: Partial<WorkflowNodeJSON>, parent?: WorkflowNodeEntity): Promise<WorkflowNodeEntity | undefined>;
364
+ /**
365
+ * 拖拽卡片到画布
366
+ * 返回创建结果
367
+ * @param type
368
+ * @param event
369
+ */
370
+ startDragCard(type: string, event: React.MouseEvent, data: Partial<WorkflowNodeJSON>, cloneNode?: (e: PlaygroundDragEvent) => HTMLDivElement): Promise<WorkflowNodeEntity | undefined>;
371
+ /**
372
+ * 如果存在容器节点,且传入鼠标坐标,需要用容器的坐标减去传入的鼠标坐标
373
+ */
374
+ adjustSubNodePosition(subNodeType?: string, containerNode?: WorkflowNodeEntity, mousePos?: IPoint, resetEmptyPos?: boolean): IPoint;
375
+ /**
376
+ * 注册位置调整
377
+ */
378
+ registerPosAdjuster(adjuster: (params: {
379
+ selectedNodes: WorkflowNodeEntity[];
380
+ position: IPoint;
381
+ }) => IPoint): {
382
+ dispose: () => boolean;
383
+ };
384
+ /**
385
+ * 获取拖拽偏移
386
+ */
387
+ private getDragPosOffset;
388
+ private updateDroppableTransforms;
389
+ /**
390
+ * 获取节点整体位置
391
+ */
392
+ private getNodesPosition;
393
+ private nodeSelectable;
394
+ private updateDropNode;
395
+ private clearDrop;
396
+ private setLineColor;
397
+ private handleDragOnNode;
398
+ private childrenOfContainer;
399
+ /**
400
+ * 绘制线条
401
+ * @param opts
402
+ * @param event
403
+ */
404
+ startDrawingLine(fromPort: WorkflowPortEntity, event: {
405
+ clientX: number;
406
+ clientY: number;
407
+ }, originLine?: WorkflowLineEntity): Promise<{
408
+ dragSuccess?: boolean;
409
+ newLine?: WorkflowLineEntity;
410
+ }>;
411
+ /**
412
+ * 重新连接线条
413
+ * @param line
414
+ * @param e
415
+ */
416
+ resetLine(line: WorkflowLineEntity, e: MouseEvent): Promise<void>;
417
+ /** 线条拖拽结束 */
418
+ onDragLineEnd(callback: OnDragLineEnd): Disposable;
419
+ }
420
+
421
+ declare const WorkflowDocumentOptions: unique symbol;
422
+ /**
423
+ * 线条配置
424
+ */
425
+ interface WorkflowDocumentOptions extends FlowDocumentOptions {
426
+ cursors?: {
427
+ grab?: string;
428
+ grabbing?: string;
429
+ };
430
+ /** 线条颜色 */
431
+ lineColor?: Partial<LineColor>;
432
+ /** 是否显示错误线条 */
433
+ isErrorLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
434
+ /** 是否错误端口 */
435
+ isErrorPort?: (port: WorkflowPortEntity) => boolean;
436
+ /** 是否禁用端口 */
437
+ isDisabledPort?: (port: WorkflowPortEntity) => boolean;
438
+ /** 是否反转线条箭头 */
439
+ isReverseLine?: (line: WorkflowLineEntity) => boolean;
440
+ /** 是否隐藏线条箭头 */
441
+ isHideArrowLine?: (line: WorkflowLineEntity) => boolean;
442
+ /** 是否流动线条 */
443
+ isFlowingLine?: (line: WorkflowLineEntity) => boolean;
444
+ /** 是否禁用线条 */
445
+ isDisabledLine?: (line: WorkflowLineEntity) => boolean;
446
+ /** 是否竖向线条 */
447
+ isVerticalLine?: (line: WorkflowLineEntity) => boolean;
448
+ /** 拖拽线条结束 */
449
+ onDragLineEnd?: (params: onDragLineEndParams) => Promise<void>;
450
+ /** 获取线条渲染器 */
451
+ setLineRenderType?: (line: WorkflowLineEntity) => LineRenderType | undefined;
452
+ /** 设置线条样式 */
453
+ setLineClassName?: (line: WorkflowLineEntity) => string | undefined;
454
+ /** 能否添加线条 */
455
+ canAddLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity, lines: WorkflowLinesManager, silent?: boolean) => boolean;
456
+ /** 能否删除节点 */
457
+ canDeleteNode?: (node: WorkflowNodeEntity, silent?: boolean) => boolean;
458
+ /** 能否删除线条 */
459
+ canDeleteLine?: (line: WorkflowLineEntity, newLineInfo?: Required<WorkflowLinePortInfo>, silent?: boolean) => boolean;
460
+ /**
461
+ * @param fromPort - 开始点
462
+ * @param oldToPort - 旧的连接点
463
+ * @param newToPort - 新的连接点
464
+ * @param lines - 线条管理器
465
+ */
466
+ canResetLine?: (fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity, lines: WorkflowLinesManager) => boolean;
467
+ }
468
+ declare const WorkflowDocumentOptionsDefault: WorkflowDocumentOptions;
469
+
350
470
  /**
351
471
  * 线条管理
352
472
  */
@@ -624,4 +744,4 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
624
744
  fireRender(): void;
625
745
  }
626
746
 
627
- export { PORT_SIZE as A, type WorkflowPortEntityOpts as B, type WorkfloEntityHoverable as C, WorkflowDocumentProvider as D, WorkflowDocumentOptions as E, WorkflowDocumentOptionsDefault as F, type LineRenderType as L, POINT_RADIUS as P, WorkflowHoverService as W, WorkflowDocument as a, WorkflowLinesManager as b, WorkflowSelectService as c, type WorkflowNodeJSON as d, WorkflowPortEntity as e, WorkflowLineEntity as f, type WorkflowPorts as g, type WorkflowPortType as h, type WorkflowPort as i, type WorkflowLineRenderContribution as j, type LinePosition as k, getPortEntityId as l, WORKFLOW_LINE_ENTITY as m, domReactToBounds as n, type WorkflowJSON as o, WorkflowContentChangeType as p, type WorkflowContentChangeEvent as q, type WorkflowNodeMeta as r, LineType as s, type LineColor as t, LineColors as u, type WorkflowLineRenderContributionFactory as v, LINE_HOVER_DISTANCE as w, type WorkflowLinePortInfo as x, type WorkflowLineEntityOpts as y, type WorkflowLineInfo as z };
747
+ export { type WorkfloEntityHoverable as A, WorkflowHoverService as B, type NodesDragEvent as C, type onDragLineEndParams as D, WorkflowDragService as E, WorkflowDocumentProvider as F, WorkflowLinesManager as G, WorkflowDocumentOptions as H, WorkflowDocumentOptionsDefault as I, type LineRenderType as L, type NodesDragEndEvent as N, type OnDragLineEnd as O, POINT_RADIUS as P, WorkflowPortEntity as W, WorkflowDocument as a, type WorkflowPorts as b, type WorkflowPortType as c, type WorkflowPort as d, WorkflowLineEntity as e, type WorkflowLineRenderContribution as f, type LinePosition as g, getPortEntityId as h, WORKFLOW_LINE_ENTITY as i, domReactToBounds as j, type WorkflowJSON as k, WorkflowContentChangeType as l, type WorkflowContentChangeEvent as m, type WorkflowNodeMeta as n, type WorkflowNodeJSON as o, LineType as p, type LineColor as q, LineColors as r, type WorkflowLineRenderContributionFactory as s, LINE_HOVER_DISTANCE as t, type WorkflowLinePortInfo as u, type WorkflowLineEntityOpts as v, type WorkflowLineInfo as w, PORT_SIZE as x, type WorkflowPortEntityOpts as y, WorkflowSelectService as z };