@progress/kendo-react-grid
Version:
React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package
70 lines (69 loc) • 2.22 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 a from "react";
import { useTableKeyboardNavigation as y } from "@progress/kendo-react-data-tools";
import { GridContext as I } from "../../GridClientWrapper.mjs";
import { cloneReactElement as i } from "../../utils/index.mjs";
const p = (n) => {
var d;
const { cellProps: e } = n, t = a.useContext(I), s = y(e.id), u = a.useCallback(
(o) => {
var l;
(l = t == null ? void 0 : t.cellClick) == null || l.call(t, o, e.dataItem, e.field);
},
[t, e.dataItem, e.field]
), m = a.useCallback(
(o) => {
var l;
(l = t == null ? void 0 : t.onContextMenu) == null || l.call(void 0, o, e.dataItem, e.field);
},
[t, e.dataItem, e.field]
), C = e.rowType === "groupFooter" || e.rowType !== "groupHeader" ? {
onContextMenu: m
} : {}, f = t.getCellPositionStyle(e.columnPosition), P = e.rowType !== "groupFooter" && e.rowType !== "groupHeader" ? {
style: { ...(d = n.tdProps) == null ? void 0 : d.style, ...f }
} : {}, r = {
...s,
...C,
...P,
onClick: u
}, c = {
onContextMenu: t.onContextMenu,
onChange: t.itemChange,
selectionChange: (o) => {
t.selectionChange({
event: o,
dataItem: e.dataItem,
dataIndex: e.rowDataIndex,
columnIndex: e.columnIndex
});
}
};
if (n.isCustom)
return t.isClient || n.isClient ? i(n.children, {
// pass down to tdProps for client templates
tdProps: { ...n.tdProps, ...r },
...c
}) : i(n.children, {
...r
});
if (e.render) {
const o = e.rowType !== "groupHeader" ? /* @__PURE__ */ a.createElement("td", { ...n.tdProps, ...r }, n.content) : null;
return e.render.call(void 0, o, {
...e,
...c
});
}
return n.children && i(n.children, {
...r
});
};
export {
p as GridCellContainer
};