@payfit/unity-components
Version:
40 lines (39 loc) • 1.42 kB
JavaScript
import e, { forwardRef as t, memo as n, useMemo as r } from "react";
import { uyTv as i } from "@payfit/unity-themes";
import { jsx as a } from "react/jsx-runtime";
//#region src/components/table/parts/TableHeader.tsx
var o = i({ base: [
"uy:h-500 uy:bg-surface-neutral-low uy:rounded-tl-100 uy:rounded-tr-100 uy:overflow-hidden",
"uy:sticky uy:top-0 uy:z-[1]",
"uy:[&_th]:relative uy:[&_th]:after:absolute uy:[&_th]:after:inset-x-0 uy:[&_th]:after:bottom-0",
"uy:[&_th]:after:h-px uy:[&_th]:after:bg-border-neutral-enabled uy:[&_th]:after:content-[''] uy:[&_th]:after:pointer-events-none"
] }), s = n(t(({ children: t, ...n }, i) => {
let s = r(() => {
let n = (t, n) => {
let r = 0;
return e.Children.map(t, (t) => {
if (!e.isValidElement(t)) return t;
let i = t, a = r;
return r += i.props.colSpan ?? 1, e.cloneElement(i, {
rowIndex: n,
colIndex: a,
...i.props
});
});
}, r = e.Children.toArray(t);
return r.length > 0 && r.every((t) => e.isValidElement(t) && t.type === "tr") ? r.map((t, r) => {
let i = t;
return e.cloneElement(i, { children: n(i.props.children, r) });
}) : /* @__PURE__ */ a("tr", { children: n(t, 0) });
}, [t]);
return /* @__PURE__ */ a("thead", {
ref: i,
className: o(),
"data-dd-privacy": "allow",
...n,
children: s
});
}));
s.displayName = "TableHeader";
//#endregion
export { s as TableHeader, o as tableHeader };