@eccenca/gui-elements
Version:
GUI elements based on other libraries, usable in React application, written in Typescript.
44 lines • 2.42 kB
JavaScript
;
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.tableRowHeightSizes = void 0;
exports.Table = Table;
const react_1 = __importDefault(require("react"));
const react_2 = require("@carbon/react");
// import { TableProps as CarbonTableProps } from "@carbon/react/es/components/DataTable/Table"; // TODO: check later again, currently interface is not exported
const constants_1 = require("../../configuration/constants");
exports.tableRowHeightSizes = {
// current values
small: "xs",
medium: "sm",
large: "md",
};
function Table(_a) {
var { className = "", size = "medium", hasDivider = true, columnWidths, colorless, children } = _a, otherCarbonTableProps = __rest(_a, ["className", "size", "hasDivider", "columnWidths", "colorless", "children"]);
let colLayout = false;
if (!!columnWidths && columnWidths.length > 0) {
colLayout = (react_1.default.createElement("colgroup", { className: `${constants_1.CLASSPREFIX}-simpletable__layout` }, columnWidths.map((width, i) => (react_1.default.createElement("col", { key: i, style: { width } })))));
}
return (react_1.default.createElement(react_2.Table, Object.assign({ className: `${constants_1.CLASSPREFIX}-simpletable ${constants_1.CLASSPREFIX}-simpletable--${size}` +
(hasDivider ? ` ${constants_1.CLASSPREFIX}-simpletable--rowdivider` : "") +
(colLayout ? ` ${constants_1.CLASSPREFIX}-simpletable--haslayout` : "") +
(colorless ? ` ${constants_1.CLASSPREFIX}-simpletable--colorless` : "") +
(className ? ` ${className}` : "") }, otherCarbonTableProps, { size: exports.tableRowHeightSizes[size] }),
!!colLayout && colLayout,
children));
}
exports.default = Table;
//# sourceMappingURL=Table.js.map