@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.39 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
*-------------------------------------------------------------------------------------------
*/
"use client";
import * as n from "react";
import { useUnstyled as h, uGrid as v, 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 E } from "../GridClientWrapper.mjs";
const N = (e) => {
var R;
const a = n.useContext(E), {
reorderRowDropTargetRef: g,
reorderRowDragTargetRef: r,
activeDragRowDataItemRef: m
} = a, { rowType: o, isAltRow: D, isInEdit: f, isSelected: I } = e, i = h(), x = i && i.uGrid ? i.uGrid : v, y = C(
x.tr({
selected: I,
isHeader: o === "groupHeader",
isFooter: o === "groupFooter",
isMaster: o !== "groupHeader" && o !== "groupFooter",
isAltRow: D,
isInEdit: f
})
), l = n.useRef(null);
T(l, {
onDragOver: (t) => {
if (e.isRowReorderable && m.current) {
const b = t.originalEvent.target;
g.current = b.closest(".k-table-row");
}
},
onDrop: () => {
r.current && e.isRowReorderable && (r.current.style.userSelect = "");
}
});
const c = {
onClick: (t) => a.rowClick(t, e.dataItem),
onDoubleClick: (t) => a.rowDblClick(t, e.dataItem)
}, s = {
ref: l,
id: e.id,
...c,
className: y,
style: {
height: e.rowHeight ? e.rowHeight + "px" : "",
visibility: e.isHidden ? "hidden" : "",
userSelect: (R = r == null ? void 0 : r.current) == null ? void 0 : R.style.userSelect
},
role: "row",
"aria-rowindex": e.ariaRowIndex,
"absolute-row-index": e.absoluteRowIndex,
[k]: e.rowType === "data" ? e.dataIndex : void 0
}, u = e.rowType || "data", d = e.rows;
if (d && d[u]) {
const t = d[u];
return /* @__PURE__ */ n.createElement(t, { key: e.absoluteRowIndex, ...e, trProps: s }, e.children);
}
const w = /* @__PURE__ */ n.createElement("tr", { key: e.absoluteRowIndex, ...s }, e.children);
return e.render ? e.render.call(void 0, w, { ...e, ...c }) : w;
};
export {
N as GridRow
};