UNPKG

@progress/kendo-react-gantt

Version:

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

126 lines (125 loc) 4.21 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 t from "react"; import * as B from "react-dom"; import { canUseDOM as F } from "@progress/kendo-react-common"; import { Form as O } from "@progress/kendo-react-form"; import { Window as R, WindowActionsBar as W } from "@progress/kendo-react-dialogs"; import { Button as r } from "@progress/kendo-react-buttons"; import { GanttEditor as G } from "./GanttEditor.mjs"; import { useLocalization as L } from "@progress/kendo-react-intl"; import { messages as T, editorSave as V, editorCancel as x, editorDelete as A, editorTitle as N } from "../messages/index.mjs"; import { saveIcon as U, cancelIcon as j, trashIcon as q } from "@progress/kendo-svg-icons"; import { findByFieldValue as v } from "@progress/kendo-react-dropdowns"; const P = (a) => { const { onCancel: l, onDelete: c, onClose: d, onSubmit: m, ...D } = a, I = t.useRef(a.dataItem), [n, f] = t.useState({}), C = L(), i = (e) => C.toLanguageString(e, T[e]), g = i(V), h = i(x), b = i(A), E = i(N), k = t.useCallback( (e) => { if (l) { const o = { syntheticEvent: e, nativeEvent: e.nativeEvent, dataItem: a.dataItem }; l.call(void 0, o); } }, [l, a.dataItem] ), S = t.useCallback( (e) => { if (c) { const o = { syntheticEvent: e, nativeEvent: e.nativeEvent, dataItem: a.dataItem }; c.call(void 0, o); } }, [c, a.dataItem] ), M = t.useCallback( ({ syntheticEvent: e }) => { if (d) { const o = { syntheticEvent: e, nativeEvent: e.nativeEvent, dataItem: a.dataItem }; d.call(void 0, o); } }, [d, a.dataItem] ), s = t.useCallback( (e, o) => { if (m) { const z = { dataItem: e, initialDataItem: I.current, syntheticEvent: o, nativeEvent: o && o.nativeEvent, dependencies: n }; m.call(void 0, z); } }, [m, n] ), u = t.useMemo(() => v(n.createdDependencies, "fromId", null) || v(n.createdDependencies, "toId", null), [n]), p = t.useMemo(() => n.createdDependencies && n.createdDependencies.length && u === void 0 || n.updatedDependencies && n.updatedDependencies.length || n.deletedDependencies && n.deletedDependencies.length, [n, u]), y = t.useCallback((e) => { f(e); }, []), w = /* @__PURE__ */ t.createElement( O, { initialValues: a.dataItem, onSubmit: s, render: (e) => /* @__PURE__ */ t.createElement( R, { title: E, minWidth: 90, width: 554, modal: !0, height: 0, onClose: M }, /* @__PURE__ */ t.createElement( G, { taskData: a.taskData, dependencyData: a.dependencyData, dataItem: a.dataItem, onDependencyCreate: y } ), /* @__PURE__ */ t.createElement(W, { layout: "start" }, /* @__PURE__ */ t.createElement( r, { disabled: !e.allowSubmit && !p, onClick: e.allowSubmit ? e.onSubmit : (o) => s(a.dataItem, o), icon: "save", svgIcon: U, themeColor: "primary" }, g ), /* @__PURE__ */ t.createElement(r, { onClick: k, type: "button", icon: "cancel", svgIcon: j }, h), /* @__PURE__ */ t.createElement("div", { className: "k-spacer" }), c && /* @__PURE__ */ t.createElement( r, { onClick: S, icon: "trash", svgIcon: q, fillMode: "flat", themeColor: "primary" }, b )) ), ...D } ); return F ? B.createPortal(w, document && document.body) : null; }; export { P as GanttForm };