Skip to content

Commit 1b05519

Browse files
author
昔梦
committed
feat:1.新增hideTitleTips配置属性2.hideEdgeAddBtn转移配置位置
1 parent 523afed commit 1b05519

File tree

10 files changed

+45
-26
lines changed

10 files changed

+45
-26
lines changed

docs/xflow/api.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ title: API
1515
| settings | 节点配置,定义页面中可拖动的节点配置 | ( [TNodeGroup](#tnodegroup) \| [TNodeItem](#tnodeitem) )[ ] | |
1616
| nodeSelector | 节点选择器配置,可控制节点的可搜索性 | `TNodeSelector` |
1717
| iconFontUrl | iconfont url,用于配置图标渲染 | `String` | |
18-
| globalConfig | 全局的面板和节点配置 | {nodePanel:[TNodePanel](#tnodepanel),nodeView:[TNodeView](#tnodeview)} | |
18+
| globalConfig | 全局的面板和节点配置 | {nodePanel:[TNodePanel](#tnodepanel),nodeView:[TNodeView](#tnodeview),edge:[TEdge](#tedge)} | |
1919

2020
## TNodePanel
2121

@@ -34,8 +34,15 @@ title: API
3434

3535
| 属性 | 描述 | 类型 | 默认值 |
3636
| ----- | ------------ | ------------- | ------ |
37-
| hideEdgeAddBtn | 是否隐藏两个节点之间,连线上的增加节点按钮 | `boolean` | false |
37+
| hideTitleTips | 是否隐藏节点标题的tooltip描述信息提示 | `boolean` | false |
38+
39+
## TEdge
40+
41+
边的全局配置
3842

43+
| 属性 | 描述 | 类型 | 默认值 |
44+
| ----- | ------------ | ------------- | ------ |
45+
| hideEdgeAddBtn | 是否隐藏两个节点之间,连线上的增加节点按钮 | `boolean` | false |
3946

4047
## TNodeGroup
4148

docs/xflow/demo/nodeSetting/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ export const Flow = () => {
2727
width: '400px',
2828
hideDesc:true
2929
},
30-
nodeView: {
30+
edge: {
3131
hideEdgeAddBtn:true,
32-
}
32+
},
33+
nodeView: {
34+
hideTitleTips: true
35+
},
3336
}}
3437
/>
3538
</>

packages/x-flow/src/components/CustomEdge/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default memo((edge: any) => {
2828
});
2929

3030
const { globalConfig } = useContext(ConfigContext);
31-
const hideEdgeAddBtn = globalConfig?.nodeView?.hideEdgeAddBtn ?? false;
31+
const hideEdgeAddBtn = globalConfig?.edge?.hideEdgeAddBtn ?? false;
3232

3333
const {
3434
nodes,

packages/x-flow/src/components/NodeContainer/index.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ export default memo((props: any) => {
1919
NodeWidget,
2020
iconFontUrl,
2121
iconSvg,
22+
hideTitleTips,
2223
} = props;
2324
const IconBox = useMemo(() => createIconFont(iconFontUrl), [iconFontUrl]);
25+
2426
return (
2527
<div
2628
className={classNames('custom-node-container', {
@@ -29,30 +31,24 @@ export default memo((props: any) => {
2931
onClick={onClick}
3032
>
3133
<div className="node-title">
32-
<Popover
33-
content={<MenuTooltip {...props} />}
34-
placement="bottomLeft"
35-
trigger="hover"
36-
getPopupContainer={() =>
37-
document.getElementById('xflow-container') as HTMLElement
38-
}
39-
>
40-
{/* <Tooltip
41-
title='点击图标查看节点信息'
42-
arrow={false}
43-
placement='topLeft'
44-
color='#fff'
45-
overlayInnerStyle={{
46-
color: '#354052',
47-
fontSize: '12px',
48-
}}
49-
getPopupContainer={() => document.getElementById('xflow-container') as HTMLElement}
50-
> */}
34+
{!hideTitleTips ? (
35+
<Popover
36+
content={<MenuTooltip {...props} />}
37+
placement="bottomLeft"
38+
trigger="hover"
39+
getPopupContainer={() =>
40+
document.getElementById('xflow-container') as HTMLElement
41+
}
42+
>
43+
<span className="icon-box" style={{ background: icon?.bgColor }}>
44+
{iconSvg ? iconSvg : <IconBox {...icon} />}
45+
</span>
46+
</Popover>
47+
) : (
5148
<span className="icon-box" style={{ background: icon?.bgColor }}>
5249
{iconSvg ? iconSvg : <IconBox {...icon} />}
5350
</span>
54-
{/* </Tooltip> */}
55-
</Popover>
51+
)}
5652
<Text
5753
style={{ width: 188, marginLeft: '8px' }}
5854
ellipsis={{

packages/x-flow/src/nodes/node-common/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default memo((props: any) => {
1010
const nodeDescription = nodeSetting?.description || '';
1111

1212
const hideDesc = nodeSetting?.nodePanel?.hideDesc ?? globalConfig?.nodePanel?.hideDesc ?? false;
13+
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
1314

1415
return (
1516
<NodeContainer
@@ -27,6 +28,7 @@ export default memo((props: any) => {
2728
iconFontUrl={iconFontUrl}
2829
description={nodeDescription} // 不允许用户更改的节点描述
2930
iconSvg={nodeSetting?.iconSvg}
31+
hideTitleTips={hideTitleTips}
3032
/>
3133
);
3234
});

packages/x-flow/src/nodes/node-end/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default memo((props: any) => {
99
const NodeWidget = widgets[nodeSetting?.nodeWidget] || undefined;
1010
const nodeDescription = nodeSetting?.description || '';
1111
const hideDesc = nodeSetting?.nodePanel?.hideDesc ?? globalConfig?.nodePanel?.hideDesc ?? false;
12+
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
1213

1314

1415
return (
@@ -27,6 +28,7 @@ export default memo((props: any) => {
2728
iconFontUrl={iconFontUrl}
2829
description={nodeDescription} // 不允许用户更改的节点描述
2930
iconSvg={nodeSetting?.iconSvg}
31+
hideTitleTips={hideTitleTips}
3032
/>
3133
);
3234
});

packages/x-flow/src/nodes/node-parallel/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default memo((props: any) => {
1919
const NodeWidget = widgets[nodeSetting?.nodeWidget] || undefined;
2020
const nodeDescription = nodeSetting?.description || '';
2121
const hideDesc = nodeSetting?.nodePanel?.hideDesc ?? globalConfig?.nodePanel?.hideDesc ?? false;
22+
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
2223

2324
return (
2425
<NodeContainer
@@ -46,6 +47,7 @@ export default memo((props: any) => {
4647
}
4748
description={nodeDescription} // 不允许用户更改的节点描述
4849
iconSvg={nodeSetting?.iconSvg}
50+
hideTitleTips={hideTitleTips}
4951
/>
5052
);
5153
});

packages/x-flow/src/nodes/node-start/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default memo((props: any) => {
99
const NodeWidget = widgets[nodeSetting?.nodeWidget] || undefined;
1010
const nodeDescription = nodeSetting?.description || '';
1111
const hideDesc = nodeSetting?.nodePanel?.hideDesc ?? globalConfig?.nodePanel?.hideDesc ?? false;
12+
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
1213

1314
return (
1415
<NodeContainer
@@ -26,6 +27,7 @@ export default memo((props: any) => {
2627
iconFontUrl={iconFontUrl}
2728
description={nodeDescription} // 不允许用户更改的节点描述
2829
iconSvg={nodeSetting?.iconSvg}
30+
hideTitleTips={hideTitleTips}
2931
/>
3032
);
3133
});

packages/x-flow/src/nodes/node-switch/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default memo((props: any) => {
1919
const NodeWidget = widgets[nodeSetting?.nodeWidget] || undefined;
2020
const nodeDescription = nodeSetting?.description || '';
2121
const hideDesc = nodeSetting?.nodePanel?.hideDesc ?? globalConfig?.nodePanel?.hideDesc ?? false;
22+
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
2223

2324
return (
2425
<NodeContainer
@@ -46,6 +47,7 @@ export default memo((props: any) => {
4647
}
4748
description={nodeDescription} // 不允许用户更改的节点描述
4849
iconSvg={nodeSetting?.iconSvg}
50+
hideTitleTips={hideTitleTips}
4951
/>
5052
);
5153
});

packages/x-flow/src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export interface FlowProps {
5858
hideDesc?: boolean; // 配置面板描述
5959
},
6060
nodeView?: {
61+
hideTitleTips: boolean;
62+
},
63+
edge: {
6164
hideEdgeAddBtn: boolean;// 是否隐藏两个节点之间,连线上的增加节点按钮
6265
}
6366
}

0 commit comments

Comments
 (0)