@flowgram.ai/free-layout-core 0.2.10 → 0.2.12
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 +106 -34
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +99 -33
- package/dist/index.js.map +1 -1
- package/dist/typings/index.d.mts +1 -1
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/workflow-drag.d.mts +1 -1
- package/dist/typings/workflow-drag.d.ts +1 -1
- package/dist/typings/workflow-json.d.mts +1 -1
- package/dist/typings/workflow-json.d.ts +1 -1
- package/dist/typings/workflow-line.d.mts +1 -1
- package/dist/typings/workflow-line.d.ts +1 -1
- package/dist/typings/workflow-node.d.mts +1 -1
- package/dist/typings/workflow-node.d.ts +1 -1
- package/dist/typings/workflow-registry.d.mts +1 -1
- package/dist/typings/workflow-registry.d.ts +1 -1
- package/dist/{workflow-line-entity-BGD6_sdy.d.mts → workflow-line-entity-B34FWw9W.d.mts} +9 -2
- package/dist/{workflow-line-entity-OFVYg40b.d.ts → workflow-line-entity-B4Mfa03B.d.ts} +9 -2
- package/package.json +9 -9
package/dist/esm/index.js
CHANGED
|
@@ -52,7 +52,12 @@ import { useCallback, useEffect as useEffect2, useRef, useState, useContext, use
|
|
|
52
52
|
import { useObserve } from "@flowgram.ai/reactive";
|
|
53
53
|
import { getNodeForm } from "@flowgram.ai/node";
|
|
54
54
|
import { FlowNodeRenderData as FlowNodeRenderData3 } from "@flowgram.ai/document";
|
|
55
|
-
import {
|
|
55
|
+
import {
|
|
56
|
+
MouseTouchEvent as MouseTouchEvent2,
|
|
57
|
+
PlaygroundEntityContext,
|
|
58
|
+
useListenEvents,
|
|
59
|
+
useService
|
|
60
|
+
} from "@flowgram.ai/core";
|
|
56
61
|
|
|
57
62
|
// src/service/workflow-select-service.ts
|
|
58
63
|
import { inject, injectable } from "inversify";
|
|
@@ -1048,7 +1053,9 @@ import { EntityManager } from "@flowgram.ai/core";
|
|
|
1048
1053
|
var WorkflowHoverService = class {
|
|
1049
1054
|
constructor() {
|
|
1050
1055
|
this.onHoveredChangeEmitter = new Emitter2();
|
|
1056
|
+
this.onUpdateHoverPositionEmitter = new Emitter2();
|
|
1051
1057
|
this.onHoveredChange = this.onHoveredChangeEmitter.event;
|
|
1058
|
+
this.onUpdateHoverPosition = this.onUpdateHoverPositionEmitter.event;
|
|
1052
1059
|
// 当前鼠标 hover 位置
|
|
1053
1060
|
this.hoveredPos = { x: 0, y: 0 };
|
|
1054
1061
|
/**
|
|
@@ -1068,6 +1075,13 @@ var WorkflowHoverService = class {
|
|
|
1068
1075
|
this.onHoveredChangeEmitter.fire(hoveredKey);
|
|
1069
1076
|
}
|
|
1070
1077
|
}
|
|
1078
|
+
updateHoverPosition(position, target) {
|
|
1079
|
+
this.hoveredPos = position;
|
|
1080
|
+
this.onUpdateHoverPositionEmitter.fire({
|
|
1081
|
+
position,
|
|
1082
|
+
target
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1071
1085
|
/**
|
|
1072
1086
|
* 清空 hover 内容
|
|
1073
1087
|
*/
|
|
@@ -1117,6 +1131,7 @@ import {
|
|
|
1117
1131
|
import { FlowNodeBaseType as FlowNodeBaseType2 } from "@flowgram.ai/document";
|
|
1118
1132
|
import {
|
|
1119
1133
|
CommandService,
|
|
1134
|
+
MouseTouchEvent,
|
|
1120
1135
|
PlaygroundConfigEntity as PlaygroundConfigEntity5,
|
|
1121
1136
|
PlaygroundDrag,
|
|
1122
1137
|
TransformData as TransformData9
|
|
@@ -2392,7 +2407,8 @@ var WorkflowDragService = class {
|
|
|
2392
2407
|
});
|
|
2393
2408
|
}
|
|
2394
2409
|
});
|
|
2395
|
-
|
|
2410
|
+
const { clientX, clientY } = MouseTouchEvent.getEventCoord(triggerEvent);
|
|
2411
|
+
return dragger.start(clientX, clientY, this.playgroundConfig)?.then(() => dragSuccess);
|
|
2396
2412
|
}
|
|
2397
2413
|
/**
|
|
2398
2414
|
* 通过拖入卡片添加
|
|
@@ -2802,7 +2818,8 @@ var WorkflowDragService = class {
|
|
|
2802
2818
|
}
|
|
2803
2819
|
}
|
|
2804
2820
|
});
|
|
2805
|
-
|
|
2821
|
+
const { clientX, clientY } = MouseTouchEvent.getEventCoord(event);
|
|
2822
|
+
await dragger.start(clientX, clientY, config);
|
|
2806
2823
|
return deferred.promise;
|
|
2807
2824
|
}
|
|
2808
2825
|
/**
|
|
@@ -3028,6 +3045,9 @@ function useNodeRender(nodeFromProps) {
|
|
|
3028
3045
|
const dragService = useService(WorkflowDragService);
|
|
3029
3046
|
const selectionService = useService(WorkflowSelectService);
|
|
3030
3047
|
const isDragging = useRef(false);
|
|
3048
|
+
const [formValueVersion, updateFormValueVersion] = useState(0);
|
|
3049
|
+
const formValueDependRef = useRef(false);
|
|
3050
|
+
formValueDependRef.current = false;
|
|
3031
3051
|
const nodeRef = useRef(null);
|
|
3032
3052
|
const [linkingNodeId, setLinkingNodeId] = useState("");
|
|
3033
3053
|
useEffect2(() => {
|
|
@@ -3044,12 +3064,14 @@ function useNodeRender(nodeFromProps) {
|
|
|
3044
3064
|
}, []);
|
|
3045
3065
|
const startDrag = useCallback(
|
|
3046
3066
|
(e) => {
|
|
3047
|
-
|
|
3067
|
+
MouseTouchEvent2.preventDefault(e);
|
|
3048
3068
|
if (!selectionService.isSelected(node.id)) {
|
|
3049
3069
|
selectNode(e);
|
|
3050
3070
|
}
|
|
3051
|
-
if (!
|
|
3052
|
-
|
|
3071
|
+
if (!MouseTouchEvent2.isTouchEvent(e)) {
|
|
3072
|
+
if (!checkTargetDraggable(e.target) || !checkTargetDraggable(document.activeElement)) {
|
|
3073
|
+
return;
|
|
3074
|
+
}
|
|
3053
3075
|
}
|
|
3054
3076
|
isDragging.current = true;
|
|
3055
3077
|
dragService.startDragSelectedNodes(e)?.finally(
|
|
@@ -3101,36 +3123,86 @@ function useNodeRender(nodeFromProps) {
|
|
|
3101
3123
|
const toggleExpand = useCallback(() => {
|
|
3102
3124
|
renderData.toggleExpand();
|
|
3103
3125
|
}, [renderData]);
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
if (!form) return void 0;
|
|
3123
|
-
return {
|
|
3124
|
-
...form,
|
|
3125
|
-
get values() {
|
|
3126
|
+
const selected = selectionService.isSelected(node.id);
|
|
3127
|
+
const activated = selectionService.isActivated(node.id);
|
|
3128
|
+
const expanded = renderData.expanded;
|
|
3129
|
+
useEffect2(() => {
|
|
3130
|
+
const toDispose = form?.onFormValuesChange(() => {
|
|
3131
|
+
if (formValueDependRef.current) {
|
|
3132
|
+
updateFormValueVersion((v) => v + 1);
|
|
3133
|
+
}
|
|
3134
|
+
});
|
|
3135
|
+
return () => toDispose?.dispose();
|
|
3136
|
+
}, [form]);
|
|
3137
|
+
return useMemo(
|
|
3138
|
+
() => ({
|
|
3139
|
+
id: node.id,
|
|
3140
|
+
type: node.flowNodeType,
|
|
3141
|
+
get data() {
|
|
3142
|
+
if (form) {
|
|
3143
|
+
formValueDependRef.current = true;
|
|
3126
3144
|
return form.values;
|
|
3127
|
-
},
|
|
3128
|
-
get state() {
|
|
3129
|
-
return formState;
|
|
3130
3145
|
}
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3146
|
+
return getExtInfo();
|
|
3147
|
+
},
|
|
3148
|
+
updateData(values) {
|
|
3149
|
+
if (form) {
|
|
3150
|
+
form.updateFormValues(values);
|
|
3151
|
+
} else {
|
|
3152
|
+
updateExtInfo(values);
|
|
3153
|
+
}
|
|
3154
|
+
},
|
|
3155
|
+
node,
|
|
3156
|
+
selected,
|
|
3157
|
+
activated,
|
|
3158
|
+
expanded,
|
|
3159
|
+
startDrag,
|
|
3160
|
+
get ports() {
|
|
3161
|
+
return portsData.allPorts;
|
|
3162
|
+
},
|
|
3163
|
+
deleteNode,
|
|
3164
|
+
selectNode,
|
|
3165
|
+
readonly,
|
|
3166
|
+
linkingNodeId,
|
|
3167
|
+
nodeRef,
|
|
3168
|
+
onFocus,
|
|
3169
|
+
onBlur,
|
|
3170
|
+
getExtInfo,
|
|
3171
|
+
updateExtInfo,
|
|
3172
|
+
toggleExpand,
|
|
3173
|
+
get form() {
|
|
3174
|
+
if (!form) return void 0;
|
|
3175
|
+
return {
|
|
3176
|
+
...form,
|
|
3177
|
+
get values() {
|
|
3178
|
+
formValueDependRef.current = true;
|
|
3179
|
+
return form.values;
|
|
3180
|
+
},
|
|
3181
|
+
get state() {
|
|
3182
|
+
return formState;
|
|
3183
|
+
}
|
|
3184
|
+
};
|
|
3185
|
+
}
|
|
3186
|
+
}),
|
|
3187
|
+
[
|
|
3188
|
+
node,
|
|
3189
|
+
selected,
|
|
3190
|
+
activated,
|
|
3191
|
+
expanded,
|
|
3192
|
+
startDrag,
|
|
3193
|
+
deleteNode,
|
|
3194
|
+
selectNode,
|
|
3195
|
+
readonly,
|
|
3196
|
+
linkingNodeId,
|
|
3197
|
+
nodeRef,
|
|
3198
|
+
onFocus,
|
|
3199
|
+
onBlur,
|
|
3200
|
+
getExtInfo,
|
|
3201
|
+
updateExtInfo,
|
|
3202
|
+
toggleExpand,
|
|
3203
|
+
formValueVersion
|
|
3204
|
+
]
|
|
3205
|
+
);
|
|
3134
3206
|
}
|
|
3135
3207
|
|
|
3136
3208
|
// src/hooks/use-current-dom-node.ts
|