UNPKG

@progress/kendo-react-grid

Version:

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

36 lines (35 loc) 1.71 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 n from "react"; import { GridContext as w } from "../../utils/GridContext.mjs"; import { Keys as i } from "@progress/kendo-react-common"; const k = n.createContext(void 0), K = (r) => { const o = n.useContext(w), l = n.useRef(null), [d, s] = n.useState(), c = (e, t) => { r.sortable && t.sortable && (e.preventDefault(), o.sortChange && o.headerCellClick(e, t)); }, f = (e, t) => { if (e.isDefaultPrevented()) return; const { keyCode: a, metaKey: b, ctrlKey: m, altKey: h } = e, x = r.sortable && t.sortable, u = e.target; if (x && e.keyCode === i.enter && u.className.indexOf("k-table-th") !== -1 && c(e, t), r.navigatable) { if (r.groupable && (b && a === i.enter || m && a === i.space)) { e.preventDefault(); const g = r.columns.findIndex((y) => y.field === t.field); o.columnGroupChange && o.columnGroupChange(g, e); } h && a === i.down && (e.preventDefault(), s(t.field), l.current = u); } }, C = () => { s(void 0), l.current && l.current.getAttribute("tabindex") !== "-1" && l.current.focus(); }; return /* @__PURE__ */ n.createElement(k.Provider, { value: { cellClick: c, cellKeyDown: f, handleCloseMenu: C, showColumnMenuField: d } }, r.children); }; export { K as GridHeaderRowContainer, k as GridHeaderRowContext };