@flowgram.ai/renderer 0.5.2 → 0.5.3
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/esm/index.js +39 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +39 -31
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -26,7 +26,6 @@ interface CollisionRetType {
|
|
|
26
26
|
declare class FlowDragEntity extends ConfigEntity<FlowDragEntityConfig> {
|
|
27
27
|
private playgroundConfigEntity;
|
|
28
28
|
static type: string;
|
|
29
|
-
private containerDom;
|
|
30
29
|
private containerX;
|
|
31
30
|
private containerY;
|
|
32
31
|
private _scrollXInterval;
|
|
@@ -41,8 +40,7 @@ declare class FlowDragEntity extends ConfigEntity<FlowDragEntityConfig> {
|
|
|
41
40
|
private _startScrollY;
|
|
42
41
|
private _stopScrollY;
|
|
43
42
|
stopAllScroll(): void;
|
|
44
|
-
|
|
45
|
-
scrollDirection(e: MouseEvent, containerDom: HTMLDivElement, x: number, y: number): ScrollDirection | undefined;
|
|
43
|
+
scrollDirection(e: MouseEvent, x: number, y: number): ScrollDirection | undefined;
|
|
46
44
|
dispose(): void;
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -494,7 +492,10 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
494
492
|
private disableDragScroll;
|
|
495
493
|
private dragJSON?;
|
|
496
494
|
private onCreateNode?;
|
|
497
|
-
|
|
495
|
+
dragOffset: {
|
|
496
|
+
x: number;
|
|
497
|
+
y: number;
|
|
498
|
+
};
|
|
498
499
|
get transitions(): FlowNodeTransitionData[];
|
|
499
500
|
readonly rendererRegistry: FlowRendererRegistry;
|
|
500
501
|
get dragStartEntity(): FlowNodeEntity | undefined;
|
|
@@ -517,13 +518,14 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
517
518
|
startDrag(e: {
|
|
518
519
|
clientX: number;
|
|
519
520
|
clientY: number;
|
|
520
|
-
}, { dragStartEntity: startEntityFromProps, dragEntities, dragJSON, onCreateNode }: StartDragProps, options?: {
|
|
521
|
+
}, { dragStartEntity: startEntityFromProps, dragEntities, dragJSON, isBranch, onCreateNode, }: StartDragProps, options?: {
|
|
521
522
|
dragOffsetX?: number;
|
|
522
523
|
dragOffsetY?: number;
|
|
523
524
|
disableDragScroll?: boolean;
|
|
524
525
|
}): Promise<void>;
|
|
525
526
|
onReady(): void;
|
|
526
|
-
|
|
527
|
+
dispose(): void;
|
|
528
|
+
render(): React.ReactPortal;
|
|
527
529
|
}
|
|
528
530
|
|
|
529
531
|
interface FlowSelectorBoxOptions extends LayerOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ interface CollisionRetType {
|
|
|
26
26
|
declare class FlowDragEntity extends ConfigEntity<FlowDragEntityConfig> {
|
|
27
27
|
private playgroundConfigEntity;
|
|
28
28
|
static type: string;
|
|
29
|
-
private containerDom;
|
|
30
29
|
private containerX;
|
|
31
30
|
private containerY;
|
|
32
31
|
private _scrollXInterval;
|
|
@@ -41,8 +40,7 @@ declare class FlowDragEntity extends ConfigEntity<FlowDragEntityConfig> {
|
|
|
41
40
|
private _startScrollY;
|
|
42
41
|
private _stopScrollY;
|
|
43
42
|
stopAllScroll(): void;
|
|
44
|
-
|
|
45
|
-
scrollDirection(e: MouseEvent, containerDom: HTMLDivElement, x: number, y: number): ScrollDirection | undefined;
|
|
43
|
+
scrollDirection(e: MouseEvent, x: number, y: number): ScrollDirection | undefined;
|
|
46
44
|
dispose(): void;
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -494,7 +492,10 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
494
492
|
private disableDragScroll;
|
|
495
493
|
private dragJSON?;
|
|
496
494
|
private onCreateNode?;
|
|
497
|
-
|
|
495
|
+
dragOffset: {
|
|
496
|
+
x: number;
|
|
497
|
+
y: number;
|
|
498
|
+
};
|
|
498
499
|
get transitions(): FlowNodeTransitionData[];
|
|
499
500
|
readonly rendererRegistry: FlowRendererRegistry;
|
|
500
501
|
get dragStartEntity(): FlowNodeEntity | undefined;
|
|
@@ -517,13 +518,14 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
517
518
|
startDrag(e: {
|
|
518
519
|
clientX: number;
|
|
519
520
|
clientY: number;
|
|
520
|
-
}, { dragStartEntity: startEntityFromProps, dragEntities, dragJSON, onCreateNode }: StartDragProps, options?: {
|
|
521
|
+
}, { dragStartEntity: startEntityFromProps, dragEntities, dragJSON, isBranch, onCreateNode, }: StartDragProps, options?: {
|
|
521
522
|
dragOffsetX?: number;
|
|
522
523
|
dragOffsetY?: number;
|
|
523
524
|
disableDragScroll?: boolean;
|
|
524
525
|
}): Promise<void>;
|
|
525
526
|
onReady(): void;
|
|
526
|
-
|
|
527
|
+
dispose(): void;
|
|
528
|
+
render(): React.ReactPortal;
|
|
527
529
|
}
|
|
528
530
|
|
|
529
531
|
interface FlowSelectorBoxOptions extends LayerOptions {
|
package/dist/index.js
CHANGED
|
@@ -389,7 +389,6 @@ var FlowDragEntity = class extends import_core2.ConfigEntity {
|
|
|
389
389
|
} else {
|
|
390
390
|
this.containerX -= SCROLL_DELTA;
|
|
391
391
|
}
|
|
392
|
-
this.setDomStyle();
|
|
393
392
|
}
|
|
394
393
|
}, SCROLL_INTERVAL);
|
|
395
394
|
this._scrollXInterval = { interval, origin };
|
|
@@ -418,7 +417,6 @@ var FlowDragEntity = class extends import_core2.ConfigEntity {
|
|
|
418
417
|
} else {
|
|
419
418
|
this.containerY -= SCROLL_DELTA;
|
|
420
419
|
}
|
|
421
|
-
this.setDomStyle();
|
|
422
420
|
}
|
|
423
421
|
}, SCROLL_INTERVAL);
|
|
424
422
|
this._scrollYInterval = { interval, origin };
|
|
@@ -433,15 +431,10 @@ var FlowDragEntity = class extends import_core2.ConfigEntity {
|
|
|
433
431
|
this._stopScrollX();
|
|
434
432
|
this._stopScrollY();
|
|
435
433
|
}
|
|
436
|
-
|
|
437
|
-
this.containerDom.style.left = `${this.containerX}px`;
|
|
438
|
-
this.containerDom.style.top = `${this.containerY}px`;
|
|
439
|
-
}
|
|
440
|
-
scrollDirection(e, containerDom, x, y) {
|
|
434
|
+
scrollDirection(e, x, y) {
|
|
441
435
|
const playgroundConfig = this.playgroundConfigEntity.config;
|
|
442
436
|
const currentScrollX = playgroundConfig.scrollX;
|
|
443
437
|
const currentScrollY = playgroundConfig.scrollY;
|
|
444
|
-
this.containerDom = containerDom;
|
|
445
438
|
this.containerX = x;
|
|
446
439
|
this.containerY = y;
|
|
447
440
|
const clientRect = this.playgroundConfigEntity.playgroundDomNode.getBoundingClientRect();
|
|
@@ -2325,6 +2318,7 @@ FlowScrollBarLayer = __decorateClass([
|
|
|
2325
2318
|
], FlowScrollBarLayer);
|
|
2326
2319
|
|
|
2327
2320
|
// src/layers/flow-drag-layer.tsx
|
|
2321
|
+
var import_react_dom2 = __toESM(require("react-dom"));
|
|
2328
2322
|
var import_react15 = __toESM(require("react"));
|
|
2329
2323
|
var import_inversify9 = require("inversify");
|
|
2330
2324
|
var import_utils22 = require("@flowgram.ai/utils");
|
|
@@ -2431,17 +2425,12 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2431
2425
|
this.flowRenderStateEntity.setDragLabelSide(side);
|
|
2432
2426
|
this.containerRef.current.style.visibility = "visible";
|
|
2433
2427
|
this.pipelineNode.parentElement.appendChild(this.draggingNodeMask);
|
|
2434
|
-
this.containerRef.current.style.left = `${dragBlockX}px`;
|
|
2435
|
-
this.containerRef.current.style.top = `${dragBlockY}px`;
|
|
2428
|
+
this.containerRef.current.style.left = `${dragBlockX + this.pipelineNode.offsetLeft + clientBounds.x + window.scrollX}px`;
|
|
2429
|
+
this.containerRef.current.style.top = `${dragBlockY + this.pipelineNode.offsetTop + clientBounds.y + window.scrollY}px`;
|
|
2436
2430
|
this.containerRef.current.style.transformOrigin = "top left";
|
|
2437
2431
|
this.containerRef.current.style.transform = `scale(${scale})`;
|
|
2438
2432
|
if (!this.disableDragScroll) {
|
|
2439
|
-
this.flowDragConfigEntity.scrollDirection(
|
|
2440
|
-
event,
|
|
2441
|
-
this.containerRef.current,
|
|
2442
|
-
dragBlockX,
|
|
2443
|
-
dragBlockY
|
|
2444
|
-
);
|
|
2433
|
+
this.flowDragConfigEntity.scrollDirection(event, dragBlockX, dragBlockY);
|
|
2445
2434
|
}
|
|
2446
2435
|
}
|
|
2447
2436
|
}
|
|
@@ -2452,7 +2441,11 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2452
2441
|
const activatedNodeId = this.flowDragService.dropNodeId;
|
|
2453
2442
|
if (activatedNodeId) {
|
|
2454
2443
|
if (this.flowDragService.isDragBranch) {
|
|
2455
|
-
this.
|
|
2444
|
+
if (this.dragJSON) {
|
|
2445
|
+
await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
|
|
2446
|
+
} else {
|
|
2447
|
+
this.flowDragService.dropBranch();
|
|
2448
|
+
}
|
|
2456
2449
|
} else {
|
|
2457
2450
|
if (this.dragJSON) {
|
|
2458
2451
|
await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
|
|
@@ -2464,6 +2457,7 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2464
2457
|
}
|
|
2465
2458
|
this.flowRenderStateEntity.setNodeDroppingId("");
|
|
2466
2459
|
this.flowRenderStateEntity.setDragLabelSide();
|
|
2460
|
+
this.flowRenderStateEntity.setIsBranch(false);
|
|
2467
2461
|
this.dragStartEntity = void 0;
|
|
2468
2462
|
this.dragEntities = [];
|
|
2469
2463
|
this.flowDragConfigEntity.stopAllScroll();
|
|
@@ -2481,13 +2475,20 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2481
2475
|
* 开始拖拽事件
|
|
2482
2476
|
* @param e
|
|
2483
2477
|
*/
|
|
2484
|
-
async startDrag(e, {
|
|
2478
|
+
async startDrag(e, {
|
|
2479
|
+
dragStartEntity: startEntityFromProps,
|
|
2480
|
+
dragEntities,
|
|
2481
|
+
dragJSON,
|
|
2482
|
+
isBranch,
|
|
2483
|
+
onCreateNode
|
|
2484
|
+
}, options) {
|
|
2485
2485
|
if (this.isGrab() || this.config.disabled || this.config.readonly) {
|
|
2486
2486
|
return;
|
|
2487
2487
|
}
|
|
2488
2488
|
this.disableDragScroll = Boolean(options?.disableDragScroll);
|
|
2489
2489
|
this.dragJSON = dragJSON;
|
|
2490
2490
|
this.onCreateNode = onCreateNode;
|
|
2491
|
+
this.flowRenderStateEntity.setIsBranch(Boolean(isBranch));
|
|
2491
2492
|
this.dragOffset.x = options?.dragOffsetX || DEFAULT_DRAG_OFFSET_X;
|
|
2492
2493
|
this.dragOffset.y = options?.dragOffsetY || DEFAULT_DRAG_OFFSET_Y;
|
|
2493
2494
|
const type = startEntityFromProps?.flowNodeType || dragJSON?.type;
|
|
@@ -2517,23 +2518,30 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2517
2518
|
this.toDispose.push(this.flowDragService.onDrop(this.options.onDrop));
|
|
2518
2519
|
}
|
|
2519
2520
|
}
|
|
2521
|
+
dispose() {
|
|
2522
|
+
this._dragger.dispose();
|
|
2523
|
+
super.dispose();
|
|
2524
|
+
}
|
|
2520
2525
|
render() {
|
|
2521
2526
|
const DragComp = this.dragNodeComp.renderer;
|
|
2522
|
-
return
|
|
2523
|
-
"div",
|
|
2524
|
-
{
|
|
2525
|
-
ref: this.containerRef,
|
|
2526
|
-
style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
|
|
2527
|
-
onMouseEnter: (e) => e.stopPropagation()
|
|
2528
|
-
},
|
|
2527
|
+
return import_react_dom2.default.createPortal(
|
|
2529
2528
|
/* @__PURE__ */ import_react15.default.createElement(
|
|
2530
|
-
|
|
2529
|
+
"div",
|
|
2531
2530
|
{
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
}
|
|
2536
|
-
|
|
2531
|
+
ref: this.containerRef,
|
|
2532
|
+
style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
|
|
2533
|
+
onMouseEnter: (e) => e.stopPropagation()
|
|
2534
|
+
},
|
|
2535
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
2536
|
+
DragComp,
|
|
2537
|
+
{
|
|
2538
|
+
dragJSON: this.dragJSON,
|
|
2539
|
+
dragStart: this.dragStartEntity,
|
|
2540
|
+
dragNodes: this.dragEntities
|
|
2541
|
+
}
|
|
2542
|
+
)
|
|
2543
|
+
),
|
|
2544
|
+
document.body
|
|
2537
2545
|
);
|
|
2538
2546
|
}
|
|
2539
2547
|
};
|