UNPKG

@gssfed/vital-ui-kit-react

Version:
82 lines (72 loc) 3.06 kB
var _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; }; var _templateObject = _taggedTemplateLiteral(['\n color: #456296;\n border-bottom: 1px solid #D8e3f6;\n\n :hover {\n background-color: #eef2fc;\n }\n\n div[role=\'gridcell\'] {\n padding-left: 20px;\n }\n\n ', ';\n'], ['\n color: #456296;\n border-bottom: 1px solid #D8e3f6;\n\n :hover {\n background-color: #eef2fc;\n }\n\n div[role=\'gridcell\'] {\n padding-left: 20px;\n }\n\n ', ';\n']), _templateObject2 = _taggedTemplateLiteral(['\n background-color: #f7f9fd;\n '], ['\n background-color: #f7f9fd;\n ']); function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } import * as React from 'react'; import styled, { css } from 'styled-components'; var Row = styled.div(_templateObject, function (_ref) { var isOdd = _ref.isOdd; return isOdd && css(_templateObject2); }); /** * Default row renderer for Table. */ export default function defaultRowRenderer(_ref2) { var className = _ref2.className, columns = _ref2.columns, index = _ref2.index, key = _ref2.key, onRowClick = _ref2.onRowClick, onRowDoubleClick = _ref2.onRowDoubleClick, onRowMouseOut = _ref2.onRowMouseOut, onRowMouseOver = _ref2.onRowMouseOver, onRowRightClick = _ref2.onRowRightClick, rowData = _ref2.rowData, style = _ref2.style; var a11yProps = {}; var rowStyle = function rowStyle() { if (index < 0) { return { isHeader: true }; } return index % 2 === 0 ? { isEven: true } : { isOdd: true }; }; if (onRowClick || onRowDoubleClick || onRowMouseOut || onRowMouseOver || onRowRightClick) { a11yProps['aria-label'] = 'row'; a11yProps.tabIndex = 0; if (onRowClick) { a11yProps.onClick = function (event) { return onRowClick({ event: event, index: index, rowData: rowData }); }; } if (onRowDoubleClick) { a11yProps.onDoubleClick = function (event) { return onRowDoubleClick({ event: event, index: index, rowData: rowData }); }; } if (onRowMouseOut) { a11yProps.onMouseOut = function (event) { return onRowMouseOut({ event: event, index: index, rowData: rowData }); }; } if (onRowMouseOver) { a11yProps.onMouseOver = function (event) { return onRowMouseOver({ event: event, index: index, rowData: rowData }); }; } if (onRowRightClick) { a11yProps.onContextMenu = function (event) { return onRowRightClick({ event: event, index: index, rowData: rowData }); }; } } return React.createElement( Row, _extends({}, rowStyle(), a11yProps, { className: className, key: key, role: 'row', style: style }), columns ); }