@progress/kendo-react-gantt
Version:
React Gantt enables the display of self-referencing tabular data with many features. KendoReact Gantt package
107 lines (106 loc) • 3.72 kB
JavaScript
/**
* @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 { findByFieldValue as s, DropDownList as h } from "@progress/kendo-react-dropdowns";
import { Grid as T, GridToolbar as k, GridColumn as D } from "@progress/kendo-react-grid";
import { Button as S } from "@progress/kendo-react-buttons";
import { plusIcon as p, minusIcon as v } from "@progress/kendo-svg-icons";
import { classNames as E } from "@progress/kendo-react-common";
import { messages as b, editorAdd as M, editorRemove as I, editorDependencyNameLabel as L, editorDependencyTypeLabel as F } from "../messages/index.mjs";
import { useLocalization as N } from "@progress/kendo-react-intl";
import { orderBy as R, filterBy as x } from "@progress/kendo-data-query";
const B = (e, t, l, o) => {
const [d, r] = n.useState(e), c = (i) => {
o(t, "toId", i.target.value.id);
}, m = () => {
if (l && !t.uid)
return l.id === t.id;
if (l && t.id === null)
return l.uid === t.uid;
}, u = n.useMemo(() => s(e, "id", t.toId), [e, t.toId]), y = (i) => {
const a = x(e, i.filter);
r(a);
};
return /* @__PURE__ */ n.createElement("td", { className: E(m() && "k-selected") }, /* @__PURE__ */ n.createElement(
h,
{
textField: "title",
data: d,
value: u,
onChange: c,
filterable: !0,
onFilterChange: y,
required: !0
}
));
}, G = (e, t, l, o) => {
const d = (m) => {
o(t, "type", m.target.value.type);
}, r = () => {
if (l && !t.uid)
return l.id === t.id;
if (l && t.id === null)
return l.uid === t.uid;
}, c = n.useMemo(() => s(e, "type", t.type), [e, t.type]);
return /* @__PURE__ */ n.createElement("td", { className: E(r() && "k-selected") }, /* @__PURE__ */ n.createElement(h, { textField: "name", data: e, value: c, onChange: d }));
}, K = (e) => {
var i;
const [t, l] = n.useState([]), o = N(), d = (a) => o.toLanguageString(a, b[a]), r = d(M), c = d(I), m = d(L), u = d(F), y = n.useMemo(() => {
const a = e.successors.map((f) => {
const g = s(e.flatTasks, "id", f.toId), C = s(e.dependencyTypes, "type", f.type);
return {
...f,
taskTitle: g ? g.title : "",
typeName: C ? C.type : ""
};
});
return R(a, t);
}, [e.successors, e.dependencyTypes, e.flatTasks, t]);
return /* @__PURE__ */ n.createElement(
T,
{
data: y,
sort: t,
sortable: !0,
onRowClick: e.onSelectRow,
onSortChange: (a) => {
l(a.sort);
},
style: { height: "23em" }
},
/* @__PURE__ */ n.createElement(k, null, /* @__PURE__ */ n.createElement(S, { icon: "plus", svgIcon: p, onClick: e.addSuccessorsDependency }, r), /* @__PURE__ */ n.createElement(
S,
{
icon: "minus",
svgIcon: v,
onClick: e.deleteDependency,
disabled: ((i = e.selectedItem) == null ? void 0 : i.id) === void 0
},
c
)),
/* @__PURE__ */ n.createElement(
D,
{
field: "taskTitle",
title: m,
cell: (a) => B(e.flatTasks, a.dataItem, e.selectedItem, e.updateDependency)
}
),
/* @__PURE__ */ n.createElement(
D,
{
field: "type",
title: u,
cell: (a) => G(e.dependencyTypes, a.dataItem, e.selectedItem, e.updateDependency)
}
)
);
};
export {
K as GanttEditorSuccessors
};