2024-07-01 18:58:51 +08:00
|
|
|
import { Flex } from 'antd';
|
2024-06-27 14:57:40 +08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
|
import { Handle, NodeProps, Position } from 'reactflow';
|
2024-07-01 18:58:51 +08:00
|
|
|
import { Operator, operatorMap } from '../../constant';
|
2024-06-27 14:57:40 +08:00
|
|
|
import { NodeData } from '../../interface';
|
|
|
|
|
|
|
|
|
|
import styles from './index.less';
|
|
|
|
|
|
|
|
|
|
// TODO: do not allow other nodes to connect to this node
|
|
|
|
|
export function BeginNode({ id, data, selected }: NodeProps<NodeData>) {
|
|
|
|
|
return (
|
|
|
|
|
<section
|
|
|
|
|
className={classNames(styles.ragNode, {
|
|
|
|
|
[styles.selectedNode]: selected,
|
|
|
|
|
})}
|
2024-07-01 18:58:51 +08:00
|
|
|
style={{
|
|
|
|
|
backgroundColor: operatorMap[data.label as Operator].backgroundColor,
|
|
|
|
|
color: 'white',
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 50,
|
|
|
|
|
}}
|
2024-06-27 14:57:40 +08:00
|
|
|
>
|
|
|
|
|
<Handle
|
|
|
|
|
type="source"
|
|
|
|
|
position={Position.Right}
|
|
|
|
|
isConnectable
|
|
|
|
|
className={styles.handle}
|
|
|
|
|
></Handle>
|
2024-07-01 18:58:51 +08:00
|
|
|
<Flex vertical align="center" justify="center" gap={6}>
|
|
|
|
|
<span className={styles.type}>{data.label}</span>
|
2024-06-27 14:57:40 +08:00
|
|
|
</Flex>
|
|
|
|
|
<section className={styles.bottomBox}>
|
2024-07-01 17:12:04 +08:00
|
|
|
<div className={styles.nodeName}>{data.name}</div>
|
2024-06-27 14:57:40 +08:00
|
|
|
</section>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|