UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

50 lines (49 loc) • 1.94 kB
"use client"; import Icon from "../../Icon/Icon.mjs"; import { styles } from "./style.mjs"; import { jsx, jsxs } from "react/jsx-runtime"; import { cx } from "antd-style"; import { ChevronDown, ChevronUp } from "lucide-react"; //#region src/base-ui/Table/TableHead.tsx const ariaSortOf = (sorted) => sorted === "asc" ? "ascending" : sorted === "desc" ? "descending" : "none"; const TableHead = ({ classNames, columnIds, columns, fixedOffsets, getColumn, renderFilter, styles: customStyles }) => /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((column, index) => { const id = columnIds[index]; const tableColumn = getColumn(id); const sorted = column.sorter ? tableColumn?.getIsSorted() ?? false : false; return /* @__PURE__ */ jsx("th", { "aria-sort": column.sorter ? ariaSortOf(sorted) : void 0, scope: "col", className: cx(styles.header, column.fixed && styles.fixed, column.className, classNames?.header), style: { textAlign: column.align, width: column.width, ...fixedOffsets[index], ...customStyles?.header, ...column.fixed ? { zIndex: 3 } : void 0 }, children: /* @__PURE__ */ jsxs("span", { className: styles.headerInner, children: [column.sorter ? /* @__PURE__ */ jsxs("button", { className: styles.sortButton, type: "button", onClick: tableColumn?.getToggleSortingHandler(), children: [column.title, /* @__PURE__ */ jsxs("span", { "aria-hidden": "true", className: styles.sortCaret, children: [/* @__PURE__ */ jsx(Icon, { "data-active": sorted === "asc", icon: ChevronUp, size: 10 }), /* @__PURE__ */ jsx(Icon, { "data-active": sorted === "desc", icon: ChevronDown, size: 10 })] })] }) : column.title, column.filters?.length ? renderFilter?.(column, id) : null] }) }, id); }) }) }); //#endregion export { TableHead as default }; //# sourceMappingURL=TableHead.mjs.map