@progress/kendo-react-grid
Version:
React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package
89 lines (88 loc) • 2.98 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 o from "react";
import { useTableKeyboardNavigation as x, GROUP_EXPAND_ACTION as I } from "@progress/kendo-react-data-tools";
import { GridContext as y } from "../../GridClientWrapper.mjs";
import { Keys as h } from "@progress/kendo-react-common";
import { cloneReactElement as r } from "../../utils/index.mjs";
const G = (e) => {
var u;
const { cellProps: n } = e, t = o.useContext(y), m = x(n.id), s = o.useCallback(
(l) => {
l.isDefaultPrevented() || l.keyCode === h.enter && (t != null && t.itemChange) && (l.preventDefault(), t.itemChange({
dataItem: n.dataItem,
dataIndex: n.dataIndex,
syntheticEvent: l,
field: void 0,
value: !n.expanded
}), t == null || t.dispatchGroupExpand(
{
type: I.TOGGLE,
group: n.group
},
l
));
},
[t, n.dataItem, n.dataIndex, n.expanded, n.group]
), C = e.addKeyDownHandler ? {
onKeyDown: s
} : {}, d = o.useCallback(
(l) => {
t != null && t.onContextMenu && t.onContextMenu.call(void 0, l, n.dataItem, n.field);
},
[t, n.dataItem, n.field]
), P = t.getCellPositionStyle(n.columnPosition), f = {
style: { ...(u = e.tdProps) == null ? void 0 : u.style, ...P }
}, a = {
...m,
...C,
onContextMenu: d,
...f
}, i = {
onContextMenu: t.onContextMenu,
onChange: t.itemChange,
selectionChange: (l) => {
t.selectionChange({
event: l,
dataItem: n.dataItem,
dataIndex: n.rowDataIndex,
columnIndex: n.columnIndex
});
}
};
if (e.isCustom)
return t.isClient || e.isClient ? r(e.children, {
// pass down to tdProps for client templates
tdProps: e.tdProps ? {
...e.tdProps,
...a
} : null,
td2Props: e.td2Props ? {
...e.td2Props,
onContextMenu: d
} : null,
...i
}) : r(e.children, {
...a
});
const c = e.renderSecondCell ? /* @__PURE__ */ o.createElement("td", { ...e.td2Props, onContextMenu: d }) : null;
if (n.render) {
let l = null;
return e.renderFirstCell && (e.renderSecondCell ? l = /* @__PURE__ */ o.createElement(o.Fragment, null, /* @__PURE__ */ o.createElement("td", { ...e.tdProps, ...a }, e.content), e.renderSecondCell && c) : l = /* @__PURE__ */ o.createElement("td", { ...e.tdProps, ...a }, e.content)), n.render.call(void 0, l, {
...n,
...i
});
}
return /* @__PURE__ */ o.createElement(o.Fragment, null, e.children && r(e.children, {
...a
}), c);
};
export {
G as GridGroupCellContainer
};