123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import { CompoundedComponent } from "@/types";
- import { register } from "@antv/x6-react-shape";
- import { Node } from "@antv/x6";
- import { ports, defaultData } from "../data";
- import CustomInput from "../CustomInput";
- import { useSizeHook, useShapeProps } from "@/hooks";
- const component = ({ node }: { node: Node }) => {
- const { label, text, fill, stroke, opacity } = node.getData();
- const { size, ref } = useSizeHook();
- const {
- fillContent,
- defsContent,
- strokeColor,
- strokeWidth,
- strokeDasharray,
- } = useShapeProps(fill, size, stroke);
- const { width: w, height: h } = size;
- return (
- <>
- <div
- className="relative text-0 w-full h-full"
- ref={ref}
- style={{ opacity: opacity / 100 }}
- >
- <CustomInput value={label} styles={text} node={node} />
- <svg
- className="w-full h-full"
- viewBox={`0 0 ${size?.width} ${size?.height}`}
- xmlns="http://www.w3.org/2000/svg"
- >
- <defs>{defsContent}</defs>
- <path
- d={`
- M ${w*0.67},${strokeWidth}
- L ${w*0.67},${h-Math.min(w*0.5,h*0.45)}
- L ${w-strokeWidth},${h-Math.min(w*0.5,h*0.45)}
- L ${w/2},${h-strokeWidth}
- L ${strokeWidth},${h-Math.min(w*0.5,h*0.45)}
- L ${w*0.33},${h-Math.min(w*0.5,h*0.45)}
- L ${w*0.33},${strokeWidth}
- Z
- `}
- fill={fillContent}
- stroke={strokeColor}
- strokeDasharray={strokeDasharray}
- strokeWidth={strokeWidth}
- />
- </svg>
- </div>
- </>
- );
- };
- register({
- shape: "custom-react-singleDownArrow",
- width: 60,
- height: 90,
- effect: ["data"],
- component: component,
- });
- const singleDownArrow: CompoundedComponent = {
- name: "下箭头",
- icon: require("./image/singleDownArrow.png"),
- node: {
- shape: "custom-react-singleDownArrow",
- data: {
- label: "",
- ...defaultData,
- },
- ports,
- },
- };
- export default singleDownArrow;
|