rectangle.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { CompoundedComponent } from "@/types";
  2. import { register } from "@antv/x6-react-shape";
  3. import { Node } from "@antv/x6";
  4. import { ports } from "../data";
  5. import CustomInput from "../CustomInput";
  6. const component = ({ node }: { node: Node }) => {
  7. const { label, styles } = node.getData();
  8. return (
  9. <>
  10. <div className="relative text-0 w-full h-full">
  11. <CustomInput value={label} styles={styles} node={node}/>
  12. <svg
  13. className="w-full h-full"
  14. viewBox="0 0 96 54"
  15. xmlns="http://www.w3.org/2000/svg"
  16. >
  17. <rect
  18. x="2"
  19. y="2"
  20. width="92"
  21. height="50"
  22. fill="white"
  23. stroke="#323232"
  24. strokeWidth="2"
  25. />
  26. </svg>
  27. </div>
  28. </>
  29. );
  30. };
  31. register({
  32. shape: "custom-react-rectangle",
  33. width: 96,
  34. height: 54,
  35. effect: ["data"],
  36. component: component,
  37. });
  38. const Rectangle: CompoundedComponent = {
  39. name: "矩形",
  40. icon: require("./image/rectangle.png"),
  41. node: {
  42. shape: "custom-react-rectangle",
  43. data: {
  44. label: "矩形",
  45. },
  46. ports,
  47. },
  48. };
  49. export default Rectangle;