FPSMS-frontend
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

59 righe
1.3 KiB

  1. "use client";
  2. import { BaseEdge, getSmoothStepPath, type EdgeProps } from "@xyflow/react";
  3. import { buildTraceFlowCorridorPath } from "./traceFlowEdgeLayout";
  4. export type TraceFlowEdgeData = {
  5. offset?: number;
  6. pathMode?: "smooth" | "corridor";
  7. corridorY?: number;
  8. corridorEntryOffset?: number;
  9. corridorExitOffset?: number;
  10. corridorBranchOffset?: number;
  11. };
  12. export const TraceFlowEdge = ({
  13. id,
  14. sourceX,
  15. sourceY,
  16. targetX,
  17. targetY,
  18. sourcePosition,
  19. targetPosition,
  20. style,
  21. markerEnd,
  22. data,
  23. }: EdgeProps) => {
  24. const edgeData = data as TraceFlowEdgeData | undefined;
  25. const offset = edgeData?.offset ?? 0;
  26. const path =
  27. edgeData?.pathMode === "corridor" && edgeData.corridorY != null
  28. ? buildTraceFlowCorridorPath(
  29. sourceX,
  30. sourceY,
  31. targetX,
  32. targetY,
  33. edgeData.corridorY,
  34. edgeData.corridorEntryOffset,
  35. edgeData.corridorExitOffset,
  36. edgeData.corridorBranchOffset,
  37. )
  38. : getSmoothStepPath({
  39. sourceX,
  40. sourceY,
  41. sourcePosition,
  42. targetX,
  43. targetY,
  44. targetPosition,
  45. borderRadius: 8,
  46. offset,
  47. })[0];
  48. return <BaseEdge id={id} path={path} style={style} markerEnd={markerEnd} />;
  49. };
  50. export const traceFlowEdgeTypes = {
  51. traceFlow: TraceFlowEdge,
  52. };