UNPKG

@progress/kendo-react-grid

Version:

React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package

67 lines (66 loc) 2.32 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use client"; import * as a from "react"; import { useUnstyled as b, uGrid as h, classNames as C, useDroppable as T } from "@progress/kendo-react-common"; import { GRID_ROW_INDEX_ATTRIBUTE as k } from "../constants/index.mjs"; import { GridContext as v } from "../utils/GridContext.mjs"; const F = (e) => { var u; const n = a.useContext(v), { reorderRowDropTargetRef: w, reorderRowDragTargetRef: r, activeDragRowDataItemRef: R } = n, { rowType: o, isAltRow: g, isInEdit: m, isSelected: D } = e, i = b(), f = i && i.uGrid ? i.uGrid : h, I = C( f.tr({ selected: D, isHeader: o === "groupHeader", isFooter: o === "groupFooter", isMaster: o !== "groupHeader" && o !== "groupFooter", isAltRow: g, isInEdit: m }) ), c = a.useRef(null); T(c, { onDragOver: (t) => { if (e.isRowReorderable && R.current) { const y = t.originalEvent.target; w.current = y.closest(".k-table-row"); } }, onDrop: () => { r.current && e.isRowReorderable && (r.current.style.userSelect = ""); } }); const x = { onClick: (t) => n.rowClick(t, e.dataItem), onDoubleClick: (t) => n.rowDblClick(t, e.dataItem) }, l = { ref: c, id: e.id, ...x, className: I, style: { height: e.rowHeight ? e.rowHeight + "px" : "", visibility: e.isHidden ? "hidden" : "", userSelect: (u = r == null ? void 0 : r.current) == null ? void 0 : u.style.userSelect }, role: "row", "aria-rowindex": e.ariaRowIndex, "absolute-row-index": e.absoluteRowIndex, [k]: e.rowType === "data" ? e.dataIndex : void 0 }, s = e.rowType || "data", d = e.rows; if (d && d[s]) { const t = d[s]; return /* @__PURE__ */ a.createElement(t, { key: e.absoluteRowIndex, ...e, trProps: l }, e.children); } return /* @__PURE__ */ a.createElement("tr", { key: e.absoluteRowIndex, ...l }, e.children); }; export { F as GridRow };