@veracity/vui
Version:
Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.
45 lines (43 loc) • 1.29 kB
JavaScript
import { cs } from "../utils/styles.js";
import { useStyleConfig } from "../core/theme.js";
import styled from "../core/styled.js";
import vui from "../core/vui.js";
import { useTableContext } from "./context.js";
import { Tr } from "./tr.js";
import { Th } from "./th.js";
import { jsx } from "react/jsx-runtime";
//#region src/table/thead.tsx
const TheadBase = styled.theadBox`
tr th,
tr td {
border-bottom: 1px solid sandstone.main;
}
`;
/** Displays Table head with support for columns and sticky. */
const Thead = vui((props, ref) => {
const { children, className, ...rest } = props;
const { columns, stickyHeader } = useTableContext() ?? {};
const styles = useStyleConfig("Table", useTableContext());
const stickyProps = stickyHeader ? {
bg: "white",
position: "sticky",
top: 0,
zIndex: 3
} : {};
return /* @__PURE__ */ jsx(TheadBase, {
className: cs("vui-thead", className),
ref,
...stickyProps,
...styles.thead,
...rest,
children: children ?? /* @__PURE__ */ jsx(Tr, { children: columns?.map((column) => /* @__PURE__ */ jsx(Th, {
role: "columnheader",
...column
}, column.field)) })
});
});
Thead.displayName = "Thead";
//#endregion
export { Thead, Thead as default };
globalThis.__vuiVersion__ = "5.3.1"
//# sourceMappingURL=thead.js.map