UNPKG

@eccenca/gui-elements

Version:

GUI elements based on other libraries, usable in React application, written in Typescript.

43 lines 2.8 kB
"use strict"; 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.TableExpandRow = TableExpandRow; const react_1 = __importDefault(require("react")); // import { TableExpandRowProps as CarbonTableExpandRowProps } from "@carbon/react/es/components/DataTable/TableExpandRow"; // TODO: check later again, currently interface is not exported const react_2 = require("@carbon/react"); const constants_1 = require("../../configuration/constants"); const IconButton_1 = __importDefault(require("./../Icon/IconButton")); const index_1 = require("./index"); /** * Table row that is suffixed by a cell containing a button to expand/collapse this row. */ function TableExpandRow(_a) { var { togglerText, isExpanded, isSelected, useZebraStyle, onExpand, className, children } = _a, otherCarbonTableExpandRowProps = __rest(_a, ["togglerText", "isExpanded", "isSelected", "useZebraStyle", "onExpand", "className", "children"]); const carbonClassPrefix = (0, react_2.usePrefix)(); const toggleButton = isExpanded ? react_1.default.cloneElement(react_1.default.createElement(IconButton_1.default, { name: "toggler-showless", text: togglerText }), { onClick: onExpand }) : react_1.default.cloneElement(react_1.default.createElement(IconButton_1.default, { name: "toggler-showmore", text: togglerText }), { onClick: onExpand }); return (react_1.default.createElement("tr", Object.assign({ className: `${constants_1.CLASSPREFIX}-simpletable__row` + ` ${carbonClassPrefix}--parent-row` + (isExpanded ? ` ${carbonClassPrefix}--expandable-row` : "") + (isSelected ? ` ${carbonClassPrefix}--data-table--selected` : "") + (useZebraStyle ? ` ${constants_1.CLASSPREFIX}-simpletable__row--zebra` : "") + (className ? ` ${className}` : ""), "data-parent-row": true }, otherCarbonTableExpandRowProps), react_1.default.createElement(index_1.TableCell, { className: `${constants_1.CLASSPREFIX}-simpletable__rowexpander` + ` ${carbonClassPrefix}--table-expand` }, toggleButton), children)); } exports.default = TableExpandRow; //# sourceMappingURL=TableExpandRow.js.map