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 as default };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=thead.js.map