UNPKG

@progress/kendo-react-grid

Version:

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

68 lines (67 loc) 2.36 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 i from "react"; import { useUnstyled as b, uGrid as C, classNames as T, useDroppable as k } from "@progress/kendo-react-common"; import { GRID_ROW_INDEX_ATTRIBUTE as v } from "../constants/index.mjs"; import { GridContext as H } from "../utils/GridContext.mjs"; const N = (e) => { var u; const a = i.useContext(H), { reorderRowDropTargetRef: w, reorderRowDragTargetRef: r, activeDragRowDataItemRef: R } = a, { rowType: o, isAltRow: g, isInEdit: m, isSelected: h, isHighlighted: D } = e, n = b(), f = n && n.uGrid ? n.uGrid : C, I = T( f.tr({ selected: h, highlighted: D, isHeader: o === "groupHeader", isFooter: o === "groupFooter", isMaster: o !== "groupHeader" && o !== "groupFooter", isAltRow: g, isInEdit: m }) ), l = i.useRef(null); k(l, { 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) => a.rowClick(t, e.dataItem), onDoubleClick: (t) => a.rowDblClick(t, e.dataItem) }, c = { ref: l, 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, [v]: e.rowType === "data" ? e.dataIndex : void 0 }, s = e.rowType || "data", d = e.rows; if (d && d[s]) { const t = d[s]; return /* @__PURE__ */ i.createElement(t, { key: e.absoluteRowIndex, ...e, trProps: c }, e.children); } return /* @__PURE__ */ i.createElement("tr", { key: e.absoluteRowIndex, ...c }, e.children); }; export { N as GridRow };