File size: 1,926 Bytes
64b1da0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Flex } from 'antd';
import classNames from 'classnames';
import pick from 'lodash/pick';
import { Handle, NodeProps, Position } from 'reactflow';
import { Operator, operatorMap } from '../../constant';
import { NodeData } from '../../interface';
import OperatorIcon from '../../operator-icon';
import NodeDropdown from './dropdown';

import CategorizeHandle from './categorize-handle';
import styles from './index.less';

export function RelevantNode({ id, data, selected }: NodeProps<NodeData>) {
  const style = operatorMap[data.label as Operator];

  return (
    <section
      className={classNames(styles.ragNode, {
        [styles.selectedNode]: selected,
      })}
      style={pick(style, ['backgroundColor', 'width', 'height', 'color'])}
    >
      <Handle
        type="target"
        position={Position.Left}
        isConnectable
        className={styles.handle}
        id={'a'}
      ></Handle>
      <Handle
        type="target"
        position={Position.Top}
        isConnectable
        className={styles.handle}
        id={'b'}
      ></Handle>
      <Handle
        type="target"
        position={Position.Bottom}
        isConnectable
        className={styles.handle}
        id={'c'}
      ></Handle>
      <CategorizeHandle top={20} right={6} text={'yes'}></CategorizeHandle>
      <CategorizeHandle top={80} right={6} text={'no'}></CategorizeHandle>
      <Flex vertical align="center" justify="center">
        <OperatorIcon
          name={data.label as Operator}
          fontSize={style.iconFontSize}
        ></OperatorIcon>
        <span
          className={styles.type}
          style={{ fontSize: style.fontSize ?? 14 }}
        >
          {data.label}
        </span>
        <NodeDropdown id={id}></NodeDropdown>
      </Flex>
      <section className={styles.bottomBox}>
        <div className={styles.nodeName}>{data.name}</div>
      </section>
    </section>
  );
}