UNPKG

@progress/kendo-react-gantt

Version:

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

54 lines (53 loc) 2.25 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 a from "react"; import { FieldWrapper as L } from "@progress/kendo-react-form"; import { Label as k, Hint as M, Error as N } from "@progress/kendo-react-labels"; import { findByFieldValue as V, DropDownList as x } from "@progress/kendo-react-dropdowns"; const S = (n) => { const { validationMessage: d, touched: p, label: w, id: o, valid: m, disabled: u, hint: h, idField: l, dataItem: C, ...E } = n, I = { id: null, title: "-None-", parentId: null }, v = [], i = p && d, D = !i && h, f = D ? `${o}_hint` : "", g = i ? `${o}_error` : "", r = a.useCallback( (t) => { if (!t || !t.children) return n.data; for (const e of t.children) v.push(e), e.children && r(e); const c = v.map((e) => e.id); return n.data.filter((e) => !c.includes(e.id)); }, [n.data] ), $ = r(C), s = a.useMemo( () => $.map((t) => { const c = new Date(t.start).toLocaleDateString(), e = new Date(t.end).toLocaleDateString(); return { ...t, title: `${t.title} (${c}-${e})` }; }), [r] ), b = a.useMemo( () => V(s, l, n.value), [s, l, n.value] ), F = (t) => { t.value.id === null ? n.onChange({ value: null }) : n.onChange({ value: t.value[l] }); }; return /* @__PURE__ */ a.createElement(L, { className: "k-col-span-full" }, /* @__PURE__ */ a.createElement(k, { editorId: o, editorValid: m, editorDisabled: u }, w), /* @__PURE__ */ a.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ a.createElement( x, { textField: "title", ariaDescribedBy: `${f} ${g}`, valid: m, id: o, disabled: u, ...E, value: b, data: s, onChange: F, defaultItem: I } ), D && /* @__PURE__ */ a.createElement(M, { id: f }, h), i && /* @__PURE__ */ a.createElement(N, { id: g }, d))); }; export { S as FormDropDownList };