ObjectNode.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from "react";
  2. import { useConfig } from "src/hocs/config";
  3. import { ConditionalWrapper, CustomNodeProps } from "src/components/CustomNode";
  4. import * as Styled from "./styles";
  5. const ObjectNode: React.FC<CustomNodeProps<[string, string][]>> = ({
  6. width,
  7. height,
  8. value,
  9. x,
  10. y,
  11. }) => {
  12. const { settings } = useConfig();
  13. return (
  14. <Styled.StyledForeignObject width={width} height={height} x={0} y={0}>
  15. <ConditionalWrapper condition={settings.performance}>
  16. <Styled.StyledText width={width} height={height}>
  17. {value.map(
  18. (val, idx) =>
  19. val[1] && (
  20. <Styled.StyledRow
  21. data-key={val[1]}
  22. data-x={x}
  23. data-y={y}
  24. key={idx}
  25. width={width}
  26. >
  27. <Styled.StyledKey objectKey>{val[0]}: </Styled.StyledKey>
  28. {val[1]}
  29. </Styled.StyledRow>
  30. )
  31. )}
  32. </Styled.StyledText>
  33. </ConditionalWrapper>
  34. </Styled.StyledForeignObject>
  35. );
  36. };
  37. export default ObjectNode;