UNPKG

@progress/kendo-react-gantt

Version:

React Gantt enables the display of self-referencing tabular data with many features. KendoReact Gantt package

58 lines (57 loc) 1.87 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import * as n from "react"; import { useGanttDependencyModelFieldsContext as w, useGanttRowHeightContext as x } from "../context/GanttContext.mjs"; import { dependencyCoordinates as D } from "../utils/index.mjs"; import { getter as i } from "@progress/kendo-react-common"; import { useGanttViewTasksContext as E } from "../context/GanttViewContext.mjs"; const H = (u) => { const { dependency: s } = u, [f] = E(), r = n.useRef(null), a = w(), y = x(), [d, o] = n.useState(!1), h = () => { if (r.current === null || f.current === null) { o(!1); return; } const l = f.current[i(a.fromId)(s)], p = f.current[i(a.toId)(s)]; if (!l || !p) { o(!1); return; } const e = l.element, t = p.element; if (!e || !t) { o(!1); return; } if (d === !1) { o(!0); return; } const C = { top: e.offsetTop + e.offsetHeight / 2, start: e.offsetLeft, end: e.offsetLeft + e.offsetWidth }, g = { top: t.offsetTop + t.offsetHeight / 2, start: t.offsetLeft, end: t.offsetLeft + t.offsetWidth }, G = i(a.type)(s), c = D(C, g, y, G); c && c.length && r.current.setAttribute("points", c.map((m) => `${m.left},${m.top}`).join(" ")); }; return n.useEffect(h), /* @__PURE__ */ n.createElement( "polyline", { ref: r, style: { display: d ? void 0 : "none" } } ); }; H.displayName = "KendoReactGanttDependency"; export { H as GanttDependency };