Skip to content

Commit

Permalink
Merge pull request #1607 from alibaba/xflow
Browse files Browse the repository at this point in the history
Xflow
  • Loading branch information
lhbxs authored Jan 8, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents ff7055c + 57ed161 commit c7ef029
Showing 5 changed files with 14 additions and 13 deletions.
5 changes: 4 additions & 1 deletion packages/x-flow/package.json
Original file line number Diff line number Diff line change
@@ -57,7 +57,10 @@
"use-context-selector": "^1.4.1",
"zundo": "^2.1.0",
"zustand": "^4.5.4",
"@monaco-editor/react": "^4.4.6"
"@monaco-editor/react": "^4.6.0",
"monaco-editor-webpack-plugin": "^4.1.1",
"react-monaco-editor": "^0.44.0",
"react-simple-code-editor": "^0.11.0"
},
"devDependencies": {
"deep-equal": "^2.0.3",
11 changes: 7 additions & 4 deletions packages/x-flow/src/XFlow.tsx
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
import '@xyflow/react/dist/style.css';
import { useEventListener, useMemoizedFn } from 'ahooks';
import produce, { setAutoFreeze } from 'immer';
import { debounce } from 'lodash';
import { debounce, isFunction } from 'lodash';
import type { FC } from 'react';
import React, {
memo,
@@ -86,7 +86,7 @@ const XFlow: FC<FlowProps> = memo(props => {
const { settingMap, globalConfig,readOnly } = useContext(ConfigContext);
const [openPanel, setOpenPanel] = useState<boolean>(true);
const [openLogPanel, setOpenLogPanel] = useState<boolean>(true);
const { onNodeClick,panel = {} as any } = props;
const { onNodeClick } = props;

useEffect(() => {
zoomTo(0.8);
@@ -147,8 +147,8 @@ const XFlow: FC<FlowProps> = memo(props => {
id: uuid(),
type: 'custom',
data: {
...data,
title: `${title}_${uuid4()}`,
...data,
},
position: {
x: 0,
@@ -268,6 +268,7 @@ const XFlow: FC<FlowProps> = memo(props => {
}, [activeNode?.id]);

const deletable = globalConfig?.edge?.deletable ?? true;
const panelonClose = globalConfig?.nodePanel?.onClose

return (
<div id="xflow-container" ref={workflowContainerRef}>
@@ -341,7 +342,9 @@ const XFlow: FC<FlowProps> = memo(props => {
if (!activeNode?._status || !openLogPanel) {
setActiveNode(null);
}
panel.onClose && panel.onClose(activeNode?.id)
if(isFunction(panelonClose)){
panelonClose(activeNode?.id)
}
}}
node={activeNode}
data={activeNode?.values}
2 changes: 1 addition & 1 deletion packages/x-flow/src/components/CustomEdge/index.tsx
Original file line number Diff line number Diff line change
@@ -77,8 +77,8 @@ export default memo((edge: any) => {
id: targetId,
type: 'custom',
data: {
...data,
title: `${title}_${uuid4()}`,
...data,
},
position: { x, y },
});
2 changes: 1 addition & 1 deletion packages/x-flow/src/components/CustomNode/index.tsx
Original file line number Diff line number Diff line change
@@ -57,8 +57,8 @@ export default memo((props: any) => {
id: targetId,
type: 'custom',
data: {
...data,
title: `${title}_${uuid4()}`,
...data,
},
position: { x, y },
};
7 changes: 1 addition & 6 deletions packages/x-flow/src/types.ts
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ export interface TNodePanel {
// 配置面板属性设置
width?: string | number; // 配置面板宽度
hideDesc?: boolean; // 配置面板描述
onClose?:(activeNodeId:string)=>void
}

export interface TNodeSelector {
@@ -99,11 +100,6 @@ export interface THandle{
// isConnectableEnd?:boolean
isValidConnection?:HandleProps['isValidConnection']
}

export interface TPanel{
onClose:(activeNodeId:string)=>void
}

export interface FlowProps {
initialValues?: {
nodes: any[];
@@ -130,7 +126,6 @@ export interface FlowProps {
};
logPanel?: TLogPanel; // 日志面板配置
readOnly?:boolean//只读模式
panel?:TPanel //表单配置面板
onNodeClick?: NodeMouseHandler;
onMenuItemClick?: (itemInfo: ItemInfo, defaultAction: () => void) => void;
clickAddNode?:(type:string,nodeItem:TNodeItem,addNode:(initData?:Record<string,any>)=>void)=>void

0 comments on commit c7ef029

Please sign in to comment.