UNPKG

@intility/bifrost-react

Version:

React library for Intility's design system, Bifrost.

32 lines (31 loc) 1.37 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { forwardRef } from "react"; import classNames from "classnames"; import { faSortUp } from "@fortawesome/free-solid-svg-icons/faSortUp"; import { faSortDown } from "@fortawesome/free-solid-svg-icons/faSortDown"; import { faSort } from "@fortawesome/free-solid-svg-icons/faSort"; import Icon from "../Icon/Icon.js"; import accessibleOnClick from "../../utils/accessibleOnClick.js"; /** * Table.HeaderCell component (th element) * @visibleName Table.HeaderCell */ const TableHeaderCell = /*#__PURE__*/ forwardRef(({ className, onClick, sorting, children, ...props }, ref)=>/*#__PURE__*/ _jsxs("th", { className: classNames(className, { "bf-table-cell-clickable": onClick }), ref: ref, ...props, ...accessibleOnClick(props, onClick), children: [ children, sorting && (sorting === "none" ? /*#__PURE__*/ _jsx(Icon, { className: "bf-table-header-cell-sort bf-table-header-cell-sort-none", icon: faSort }) : /*#__PURE__*/ _jsx(Icon, { className: "bf-table-header-cell-sort", icon: sorting === "asc" ? faSortUp : faSortDown })) ] })); TableHeaderCell.displayName = "Table.HeaderCell"; export default TableHeaderCell;