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