UNPKG

pouncejs

Version:

A collection of UI components from Panther labs

62 lines (56 loc) 1.84 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; import React from 'react'; import Box from '../Box'; import { useTable } from './Table'; var TableRow = /*#__PURE__*/React.forwardRef(function TableRow(_ref, ref) { var _ref$selected = _ref.selected, selected = _ref$selected === void 0 ? false : _ref$selected, rest = _objectWithoutPropertiesLoose(_ref, ["selected"]); var tableProps = useTable(); var rowStyles = React.useMemo(function () { var styles = {}; if (tableProps.rowSeparationStrategy === 'background') { styles = _extends({}, styles, { 'tbody > &:nth-of-type(odd)': { backgroundColor: !selected ? tableProps.backgroundColorOddRows : undefined }, 'tbody > &:nth-of-type(even)': { backgroundColor: !selected ? tableProps.backgroundColor : undefined } }); } if (tableProps.rowSeparationStrategy === 'border') { styles = _extends({}, styles, { borderBottom: '1px solid', borderColor: 'navyblue-300' }); } if (tableProps.hoverable) { styles = _extends({}, styles, { transition: 'all 0.05s linear', _hover: { backgroundColor: 'navyblue-500' } }); } if (selected) { styles = _extends({}, styles, { backgroundColor: 'navyblue-600', borderColor: 'navyblue-600', _hover: { backgroundColor: 'navyblue-600', borderColor: 'navyblue-600' } }); } return styles; }, [tableProps, selected]); return /*#__PURE__*/React.createElement(Box, _extends({ as: "tr", role: "row", ref: ref, sx: rowStyles }, rest)); }); export default /*#__PURE__*/React.memo(TableRow);