order |
---|
1 |
- v2 版本不再强依赖 antd 组件库。
- 增加
DrawerComponent
属性,代替 v1 版本 sdk 内部使用 antdDrawer
的地方 - 增加
PopoverComponent
属性,代替 v1 版本 sdk 内部使用 antdPopover
的地方 - 增加
PopconfirmComponent
属性,代替 v1 版本 sdk 内部使用 antdPopconfirm
的地方 - 增加
createUuid
属性,自定义节点的 uuid div.flow-builder-node__content
元素外层增加div.flow-builder-node__content-wrap
元素,修复Popconfirm
内容区域的 click 误触发节点的点击事件
.flow-builder {
display: flex;
align-items: center;
- .ant-popover-inner-content {
- white-space: nowrap;
- }
}
.flow-builder-addable-nodes {
- .ant-popover-inner-content {
- padding: 8px 0;
- }
}
若遇到 Popover
内容区域样式错乱,可以尝试添加 white-space: nowrap; 样式。
直接将 antd 的 Drawer, Popover 和 Popconfirm 组件分别传给 DrawerComponent, PopoverComponent 和 PopconfirmComponent 属性。
import FlowBuilder from 'react-flow-builder';
+ import { Drawer, Popover, Popconfirm } from 'antd';
export default () => (
<FlowBuilder
+ DrawerComponent={Drawer}
+ PopoverComponent={Popover}
+ PopconfirmComponent={Popconfirm}
/>
);
由于 antd v5 版本 api 的差异,react-flow-builder v1 版本中内置的 antd 组件用法不能兼容,需要进行少量的属性调整。
import FlowBuilder from 'react-flow-builder';
+ import { Drawer, Popover, Popconfirm } from 'antd';
+ const DrawerComponent = (props) => {
+ const { visible, children, ...restProps } = props;
+ return (
+ <Drawer
+ open={visible}
+ {...restProps}
+ >
+ {children}
+ </Drawer>
+ );
+ };
+ const PopoverComponent = (props) => {
+ const { visible, onVisibleChange, children, ...restProps } = props;
+ return (
+ <Popover
+ open={visible}
+ onOpenChange={onVisibleChange}
+ {...restProps}
+ >
+ {children}
+ </Popover>
+ );
+ };
+ const PopconfirmComponent = (props) => {
+ const { children, ...restProps } = props;
+ return (
+ <Popconfirm
+ {...restProps}
+ >
+ {children}
+ </Popconfirm>
+ );
+ };
export default () => (
<FlowBuilder
+ DrawerComponent={DrawerComponent}
+ PopoverComponent={PopoverComponent}
+ PopconfirmComponent={PopconfirmComponent}
/>
);
import FlowBuilder from 'react-flow-builder';
+ import { Drawer, Popover, Popconfirm } from '@arco-design/web-react';
+ const DrawerComponent = (props) => {
+ const { destroyOnClose, onClose, children, ...restProps } = props;
+ return (
+ <Drawer
+ onCancel={onClose}
+ footer={null}
+ {...restProps}
+ >
+ {children}
+ </Drawer>
+ );
+ };
+ const PopoverComponent = (props) => {
+ const { visible, children, overlayClassName, placement, getPopupContainer, ...restProps } = props;
+ return (
+ <Popover
+ popupVisible={visible}
+ position='rt'
+ className={overlayClassName}
+ {...restProps}
+ >
+ {children}
+ </Popover>
+ );
+ };
+ const PopconfirmComponent = (props) => {
+ const { onConfirm, children, ...restProps } = props;
+ return (
+ <Popconfirm
+ onOk={onConfirm}
+ {...restProps}
+ >
+ {children}
+ </Popconfirm>
+ );
+ };
export default () => (
<FlowBuilder
+ DrawerComponent={DrawerComponent}
+ PopoverComponent={PopoverComponent}
+ PopconfirmComponent={PopconfirmComponent}
/>
);