Sankey.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import React from 'react'
  2. import { Row, Col, Select, Checkbox, InputNumber } from 'antd'
  3. const Option = Select.Option
  4. import { onSectionChange } from './util'
  5. import { ISpecConfig } from '../types'
  6. import styles from '../../../Workbench.less'
  7. interface ISpecSectionSankeyProps {
  8. spec: ISpecConfig
  9. title: string
  10. onChange: (value: string | number, propPath: string | string[]) => void
  11. }
  12. function SpecSectionSankey (props: ISpecSectionSankeyProps) {
  13. const { spec, title, onChange } = props
  14. const { draggable, nodeWidth, nodeGap, orient } = spec
  15. return (
  16. <div className={styles.paneBlock}>
  17. <h4>{title}</h4>
  18. <div className={styles.blockBody}>
  19. <Row gutter={8} type="flex" align="middle" className={styles.blockRow}>
  20. <Col span={18}>
  21. <Checkbox
  22. checked={draggable}
  23. onChange={onSectionChange(onChange, 'draggable')}
  24. >
  25. 允许拖动
  26. </Checkbox>
  27. </Col>
  28. </Row>
  29. <Row gutter={8} type="flex" align="middle" className={styles.blockRow}>
  30. <Col span={10}>节点布局方向</Col>
  31. <Col span={14}>
  32. <Select
  33. placeholder="排列"
  34. className={styles.blockElm}
  35. value={orient}
  36. onChange={onSectionChange(onChange, 'orient')}
  37. >
  38. <Option key="horizontal" value="horizontal">水平排列</Option>
  39. <Option key="vertical" value="vertical">垂直排列</Option>
  40. </Select>
  41. </Col>
  42. </Row>
  43. <Row gutter={8} type="flex" align="middle" className={styles.blockRow}>
  44. <Col span={6}>节点宽度</Col>
  45. <Col span={6}>
  46. <InputNumber
  47. placeholder="节点宽度"
  48. className={styles.blockElm}
  49. value={nodeWidth}
  50. min={0}
  51. onChange={onSectionChange(onChange, 'nodeWidth')}
  52. />
  53. </Col>
  54. <Col span={6}>节点间隔</Col>
  55. <Col span={6}>
  56. <InputNumber
  57. placeholder="节点间隔"
  58. className={styles.blockElm}
  59. value={nodeGap}
  60. min={0}
  61. onChange={onSectionChange(onChange, 'nodeGap')}
  62. />
  63. </Col>
  64. </Row>
  65. </div>
  66. </div>
  67. )
  68. }
  69. export default SpecSectionSankey