ObjectNode.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React from "react";
  2. import { ConditionalWrapper, CustomNodeProps } from "src/components/CustomNode";
  3. import useConfig from "src/hooks/store/useConfig";
  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 performanceMode = useConfig((state) => state.performanceMode);
  13. return (
  14. <Styled.StyledForeignObject width={width} height={height} x={0} y={0}>
  15. <ConditionalWrapper condition={performanceMode}>
  16. <Styled.StyledText width={width} height={height}>
  17. {value.map((val, idx) => (
  18. <Styled.StyledRow
  19. data-key={JSON.stringify(val[1])}
  20. data-x={x}
  21. data-y={y}
  22. key={idx}
  23. width={width}
  24. value={JSON.stringify(val[1])}
  25. >
  26. <Styled.StyledKey objectKey>
  27. {JSON.stringify(val[0]).replaceAll('"', "")}:{" "}
  28. </Styled.StyledKey>
  29. <Styled.StyledLinkItUrl>
  30. {JSON.stringify(val[1])}
  31. </Styled.StyledLinkItUrl>
  32. </Styled.StyledRow>
  33. ))}
  34. </Styled.StyledText>
  35. </ConditionalWrapper>
  36. </Styled.StyledForeignObject>
  37. );
  38. };
  39. export default ObjectNode;