UNPKG

optimizely-oui

Version:

Optimizely's Component Library.

80 lines (64 loc) 3.69 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import React from "react"; import classNames from "classnames"; import PropTypes from "prop-types"; var TR = React.forwardRef(function (_ref, ref) { var _classNames; var backgroundColor = _ref.backgroundColor, borderStyle = _ref.borderStyle, children = _ref.children, className = _ref.className, isActive = _ref.isActive, isHighlighted = _ref.isHighlighted, isLink = _ref.isLink, noBorder = _ref.noBorder, noHover = _ref.noHover, _ref$onRowClick = _ref.onRowClick, onRowClick = _ref$onRowClick === void 0 ? function () { return null; } : _ref$onRowClick, testSection = _ref.testSection, props = _objectWithoutProperties(_ref, ["backgroundColor", "borderStyle", "children", "className", "isActive", "isHighlighted", "isLink", "noBorder", "noHover", "onRowClick", "testSection"]); var classes = classNames((_classNames = { "oui-table-row--active": isActive, "oui-table-row--highlighted": isHighlighted, "oui-table-row--link": isLink, "no-border": noBorder, "hover--disabled": noHover }, _defineProperty(_classNames, "border--".concat(borderStyle), borderStyle), _defineProperty(_classNames, "background--".concat(backgroundColor), backgroundColor), _classNames), className); return React.createElement("tr", _extends({ className: classes, "data-test-section": testSection, onClick: onRowClick, ref: ref }, props), children); }); TR.propTypes = { /** Background color for each row */ backgroundColor: PropTypes.oneOf(["faint", "light"]), /** Border style for each row */ borderStyle: PropTypes.oneOf(["bottom", "top", "sides", "ends", "none"]), /** Expects a `Table.TD` or `Table.TH` component */ children: PropTypes.node, /** CSS class names. */ className: PropTypes.string, /** If true, add active class */ isActive: PropTypes.bool, /** If true, add highlight class */ isHighlighted: PropTypes.bool, /** If true, add link class */ isLink: PropTypes.bool, /** If true, add class to remove border */ noBorder: PropTypes.bool, /** If true, remove hover on inner TDs */ noHover: PropTypes.bool, /** Function to handle row click action */ onRowClick: PropTypes.func, /** Hook for automated JavaScript tests */ testSection: PropTypes.string }; TR.displayName = "TR"; export default TR;