@razorpay/blade
Version:
The Design System that powers Razorpay
188 lines (185 loc) • 11.2 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { tableRow } from '../tokens.js';
import { getTableActionsHoverStyles } from '../utils.js';
import getIn from '../../../utils/lodashButBetter/get.js';
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var getRowWrapperSelector = function getRowWrapperSelector(_ref) {
var isVirtualized = _ref.isVirtualized;
return isVirtualized ? 'tbody div' : '&';
};
var addTableRowSelectorIFVirtualized = function addTableRowSelectorIFVirtualized(_ref2) {
var isVirtualized = _ref2.isVirtualized;
return isVirtualized ? 'tr' : '';
};
var getTableBodyStyles = function getTableBodyStyles(_ref3) {
var _ref6;
var isVirtualized = _ref3.isVirtualized,
addCommonStyles = _ref3.addCommonStyles,
theme = _ref3.theme,
height = _ref3.height,
width = _ref3.width,
isSelectable = _ref3.isSelectable,
showStripedRows = _ref3.showStripedRows;
var shouldAddCommonStyle = isVirtualized !== null && isVirtualized !== void 0 ? isVirtualized : addCommonStyles;
return _objectSpread(_objectSpread({}, isVirtualized && {
'& > div ': {
overflow: 'auto !important',
height: "".concat(height, " !important"),
width: "".concat(width, " !important")
},
// and remove scroll from the main table element
'&': {
overflow: 'hidden !important'
},
// for virtualized table, we need to apply some styles to tbody
'tbody > div': {
display: 'block !important'
},
'tbody div tr': {
display: 'grid',
gridTemplateColumns: 'var(--data-table-library_grid-template-columns)',
columnGap: '0'
},
'tbody div tr:last-child .cell-wrapper': {
borderBottom: 'none'
},
'tbody div td': {
padding: '0'
}
}), shouldAddCommonStyle && _objectSpread(_objectSpread(_objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " .row-select-single-selected .cell-wrapper-base, .row-select-selected .cell-wrapper-base"), {
backgroundColor: getIn(theme.colors, tableRow.nonStripe.backgroundColorSelected)
}), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " .row-select-single-selected:hover:not(.disabled-row) .cell-wrapper-base, .row-select-selected:hover:not(.disabled-row) .cell-wrapper-base"), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.nonStripe.backgroundColorSelectedHover)
}, getTableActionsHoverStyles({
hoverColor: tableRow.nonStripe.backgroundColorSelectedHover,
backgroundGradientColor: tableRow.nonStripeWrapper.backgroundColorSelectedHover,
theme: theme
}))), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " .row-select-single-selected:focus:not(.disabled-row) .cell-wrapper-base, .row-select-selected:focus:not(.disabled-row) .cell-wrapper-base"), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.nonStripe.backgroundColorSelectedFocus)
}, getTableActionsHoverStyles({
hoverColor: tableRow.nonStripe.backgroundColorSelectedFocus,
backgroundGradientColor: tableRow.nonStripeWrapper.backgroundColorSelectedFocus,
theme: theme
}))), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " .row-select-single-selected:active:not(.disabled-row) .cell-wrapper-base, .row-select-selected:active:not(.disabled-row) .cell-wrapper-base"), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.nonStripe.backgroundColorSelectedActive)
}, getTableActionsHoverStyles({
hoverColor: tableRow.nonStripe.backgroundColorSelectedActive,
backgroundGradientColor: tableRow.nonStripe.backgroundColorHover,
theme: theme
}))), isSelectable && _defineProperty({}, "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " tr:active:not(.disabled-row) .cell-wrapper"), {
backgroundColor: getIn(theme.colors, tableRow.nonStripeWrapper.backgroundColorActive)
})), showStripedRows && _defineProperty(_defineProperty({}, "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " tr:nth-child(even) .cell-wrapper"), {
backgroundColor: getIn(theme.colors, tableRow.stripeWrapper.backgroundColor)
}), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " tr:nth-child(even) .cell-wrapper-base"), {
backgroundColor: tableRow.stripe.backgroundColor
})), showStripedRows && isSelectable && (_ref6 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref6, "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " tr:nth-child(even):hover:not(.disabled-row) .cell-wrapper"), {
backgroundColor: getIn(theme.colors, tableRow.stripeWrapper.backgroundColorHover)
}), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " tr:nth-child(even):focus:not(.disabled-row) .cell-wrapper"), {
backgroundColor: getIn(theme.colors, tableRow.stripeWrapper.backgroundColorFocus)
}), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " tr:nth-child(even):active:not(.disabled-row) .cell-wrapper"), {
backgroundColor: getIn(theme.colors, tableRow.stripeWrapper.backgroundColorActive)
}), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " .row-select-single-selected:nth-child(even) .cell-wrapper, .row-select-selected:nth-child(even) .cell-wrapper"), {
backgroundColor: getIn(theme.colors, tableRow.stripeWrapper.backgroundColorSelected)
}), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " .row-select-single-selected:nth-child(even):hover:not(.disabled-row) .cell-wrapper, .row-select-selected:nth-child(even):hover:not(.disabled-row) .cell-wrapper"), {
backgroundColor: getIn(theme.colors, tableRow.stripeWrapper.backgroundColorSelectedHover)
}), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " .row-select-single-selected:nth-child(even):focus:not(.disabled-row) .cell-wrapper, .row-select-selected:nth-child(even):focus:not(.disabled-row) .cell-wrapper"), {
backgroundColor: getIn(theme.colors, tableRow.stripeWrapper.backgroundColorSelectedFocus)
}), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " .row-select-single-selected:nth-child(even):active:not(.disabled-row) .cell-wrapper, .row-select-selected:nth-child(even):active:not(.disabled-row) .cell-wrapper"), {
backgroundColor: getIn(theme.colors, tableRow.stripeWrapper.backgroundColorSelectedActive)
}), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " tr:nth-child(even):hover:not(.disabled-row) .cell-wrapper-base"), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.stripe.backgroundColorHover)
}, getTableActionsHoverStyles({
hoverColor: tableRow.stripe.backgroundColorHover,
theme: theme,
backgroundGradientColor: tableRow.stripeWrapper.backgroundColorHover
}))), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " tr:nth-child(even):focus:not(.disabled-row) .cell-wrapper-base"), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.stripe.backgroundColorFocus)
}, getTableActionsHoverStyles({
hoverColor: tableRow.stripe.backgroundColorFocus,
theme: theme,
backgroundGradientColor: tableRow.stripeWrapper.backgroundColorFocus
}))), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " tr:nth-child(even):active:not(.disabled-row) .cell-wrapper-base"), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.stripe.backgroundColorActive)
}, getTableActionsHoverStyles({
hoverColor: tableRow.stripe.backgroundColorActive,
backgroundGradientColor: tableRow.stripe.backgroundColorHover,
theme: theme
}))), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref6, "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " ").concat(addTableRowSelectorIFVirtualized({
isVirtualized: isVirtualized
}), ".row-select-single-selected:nth-child(even) .cell-wrapper-base, .row-select-selected:nth-child(even) .cell-wrapper-base "), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.stripe.backgroundColorSelected)
}, getTableActionsHoverStyles({
hoverColor: tableRow.stripe.backgroundColorSelected,
theme: theme,
backgroundGradientColor: tableRow.stripeWrapper.backgroundColorSelected
}))), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " ").concat(addTableRowSelectorIFVirtualized({
isVirtualized: isVirtualized
}), " .row-select-single-selected:nth-child(even):hover:not(.disabled-row) .cell-wrapper-base, .row-select-selected:nth-child(even):hover:not(.disabled-row) .cell-wrapper-base "), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.stripe.backgroundColorSelectedHover)
}, getTableActionsHoverStyles({
hoverColor: tableRow.stripe.backgroundColorSelectedHover,
theme: theme,
backgroundGradientColor: tableRow.stripeWrapper.backgroundColorSelectedHover
}))), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " ").concat(addTableRowSelectorIFVirtualized({
isVirtualized: isVirtualized
}), " .row-select-single-selected:nth-child(even):focus:not(.disabled-row) .cell-wrapper-base, .row-select-selected:nth-child(even):focus:not(.disabled-row) .cell-wrapper-base "), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.stripe.backgroundColorSelectedFocus)
}, getTableActionsHoverStyles({
hoverColor: tableRow.stripe.backgroundColorSelectedFocus,
theme: theme,
backgroundGradientColor: tableRow.stripeWrapper.backgroundColorSelectedFocus
}))), "".concat(getRowWrapperSelector({
isVirtualized: isVirtualized
}), " ").concat(addTableRowSelectorIFVirtualized({
isVirtualized: isVirtualized
}), ".row-select-single-selected:nth-child(even):active:not(.disabled-row) .cell-wrapper-base, .row-select-selected:nth-child(even):active:not(.disabled-row) .cell-wrapper-base "), _objectSpread({
backgroundColor: getIn(theme.colors, tableRow.stripe.backgroundColorSelectedActive)
}, getTableActionsHoverStyles({
hoverColor: tableRow.stripe.backgroundColorSelectedActive,
theme: theme,
backgroundGradientColor: tableRow.stripe.backgroundColorHover
}))))));
};
export { getTableBodyStyles };
//# sourceMappingURL=tableBodyStyles.js.map