@react-md/table
Version:
Create responsive data tables and accessible fixed tables
57 lines • 2.98 kB
JavaScript
;
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableCellContent = void 0;
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var classnames_1 = __importDefault(require("classnames"));
var button_1 = require("@react-md/button");
var icon_1 = require("@react-md/icon");
var utils_1 = require("@react-md/utils");
var block = (0, utils_1.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.
*/
exports.TableCellContent = (0, react_1.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 (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
}
var icon = null;
if (sortOrder !== "none") {
var rotated = propRotated !== null && propRotated !== void 0 ? propRotated : sortOrder === "descending";
icon = (0, jsx_runtime_1.jsx)(icon_1.IconRotator, __assign({ rotated: rotated }, { children: propIcon }));
}
return ((0, jsx_runtime_1.jsx)(button_1.UnstyledButton, __assign({ id: id, ref: ref, style: style, className: (0, classnames_1.default)(block("child", (_b = {},
_b[hAlign] = hAlign !== "left",
_b)), className) }, { children: (0, jsx_runtime_1.jsx)(icon_1.TextIconSpacing, __assign({}, props, { icon: icon }, { children: children })) })));
});
//# sourceMappingURL=TableCellContent.js.map