UNPKG

@progress/kendo-react-grid

Version:

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

93 lines (92 loc) 2.9 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 r from "react"; import { useRtl as g, useUnstyled as N, uGrid as E, classNames as c } from "@progress/kendo-react-common"; import { tableKeyboardNavigationHeaderAttributes as m } from "@progress/kendo-react-data-tools"; import { GridContext as v } from "../utils/GridContext.mjs"; const y = (e) => { const l = r.useRef(null), s = r.useRef(null), o = r.useRef(!1), t = r.useContext(v), R = g(t.headerElementRef); t.columnResizeRef.current && t.columnResizeRef.current.setIsRtl(R === "rtl"), r.useImperativeHandle(t.headerRef, () => ({ setScrollLeft: (a) => { l.current && l.current.scrollLeft !== a && (o.current = !0, l.current.scrollLeft = a); }, setWidth: (a) => { s.current && (s.current.style.width = a ? a + "px" : ""); }, table: () => s.current })); const h = (a) => { var f; if (o.current) { o.current = !1; return; } if (!l.current) return; const d = l.current.scrollLeft, i = ((f = t.vsRef.current) == null ? void 0 : f.container) || null; i && i.scrollLeft !== d && (i.scrollLeft = d); }, u = N(), n = u && u.uGrid ? u.uGrid : E, { size: b = "md" } = e; return e.staticHeaders ? /* @__PURE__ */ r.createElement( "div", { ref: t.headerElementRef, className: c(n.header({ draggable: e.draggable }), e.className), role: "presentation" }, /* @__PURE__ */ r.createElement( "div", { ref: l, className: c(n.headerWrap({})), onScroll: h, role: "presentation" }, /* @__PURE__ */ r.createElement( "table", { ref: s, className: c(n.headerTable({ size: b }), e.className), role: "presentation" }, /* @__PURE__ */ r.createElement( "colgroup", { ref: (a) => { t.columnResizeRef.current && (t.columnResizeRef.current.colGroupHeader = a); } }, e.cols ), /* @__PURE__ */ r.createElement( "thead", { className: c(n.tableThead({})), role: "rowgroup", ...m }, e.headerRow, e.filterRow ) ) ) ) : /* @__PURE__ */ r.createElement( "thead", { role: "presentation", className: c(n.thead({ draggable: e.draggable }), e.className), ...m }, e.headerRow, e.filterRow ); }; y.displayName = "KendoReactHeader"; export { y as Header };