UNPKG

@react-md/table

Version:

Create responsive data tables and accessible fixed tables

51 lines 2.59 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import cn from "classnames"; import { UnstyledButton } from "@react-md/button"; import { IconRotator, TextIconSpacing } from "@react-md/icon"; import { bem } from "@react-md/utils"; var block = bem("rmd-table-cell"); /** * This is mostly an internal component since it is automatically used within * the `TableCell` component but this will conditionally wrap the `children` * within an `UnstyledButton` to make a clickable cell. This is really to help * with sort behavior within headers. */ export var TableCellContent = forwardRef(function TableCellContent(_a, ref) { var _b; var id = _a.id, propIcon = _a.icon, style = _a.style, className = _a.className, sortOrder = _a.sortOrder, children = _a.children, propRotated = _a.rotated, _c = _a.hAlign, hAlign = _c === void 0 ? "left" : _c, props = __rest(_a, ["id", "icon", "style", "className", "sortOrder", "children", "rotated", "hAlign"]); if (!sortOrder || propIcon === null) { return _jsx(_Fragment, { children: children }); } var icon = null; if (sortOrder !== "none") { var rotated = propRotated !== null && propRotated !== void 0 ? propRotated : sortOrder === "descending"; icon = _jsx(IconRotator, __assign({ rotated: rotated }, { children: propIcon })); } return (_jsx(UnstyledButton, __assign({ id: id, ref: ref, style: style, className: cn(block("child", (_b = {}, _b[hAlign] = hAlign !== "left", _b)), className) }, { children: _jsx(TextIconSpacing, __assign({}, props, { icon: icon }, { children: children })) }))); }); //# sourceMappingURL=TableCellContent.js.map