@razorpay/blade
Version:
The Design System that powers Razorpay
151 lines (148 loc) • 6.69 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import 'react';
import { Footer, FooterRow, FooterCell } from '@table-library/react-table-library/table';
import styled from 'styled-components';
import { tableFooter, tableRow } from './tokens.js';
import { ComponentIds } from './componentIds.js';
import { useTableContext } from './TableContext.js';
import '../Typography/index.js';
import '../../utils/index.js';
import '../../utils/metaAttribute/index.js';
import '../../utils/assignWithoutSideEffects/index.js';
import getIn from '../../utils/lodashButBetter/get.js';
import '../../tokens/global/index.js';
import '../../utils/makeAnalyticsAttribute/index.js';
import { jsx } from 'react/jsx-runtime';
import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
import { makeSpace } from '../../utils/makeSpace/makeSpace.js';
import { makeSize } from '../../utils/makeSize/makeSize.js';
import { size } from '../../tokens/global/size.js';
import { Text } from '../Typography/Text/Text.js';
var _excluded = ["children"],
_excluded2 = ["children"],
_excluded3 = ["children", "textAlign"];
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 StyledFooter = /*#__PURE__*/styled(Footer).withConfig({
displayName: "TableFooterweb__StyledFooter",
componentId: "sc-1dkm291-0"
})(function (_ref) {
var theme = _ref.theme;
return {
'&&&': {
backgroundColor: getIn(theme.colors, tableFooter.backgroundColor),
'& tr:last-child th': {
borderBottom: 'none'
}
}
};
});
var _TableFooter = function _TableFooter(_ref2) {
var children = _ref2.children,
rest = _objectWithoutProperties(_ref2, _excluded);
return /*#__PURE__*/jsx(StyledFooter, _objectSpread(_objectSpread(_objectSpread({
isFooter: true
}, metaAttribute({
name: MetaConstants.TableFooter
})), makeAnalyticsAttribute(rest)), {}, {
children: children
}));
};
var TableFooter = /*#__PURE__*/assignWithoutSideEffects(_TableFooter, {
componentId: ComponentIds.TableFooter
});
var StyledFooterRow = /*#__PURE__*/styled(FooterRow).withConfig({
displayName: "TableFooterweb__StyledFooterRow",
componentId: "sc-1dkm291-1"
})(function (_ref3) {
var theme = _ref3.theme,
$showBorderedCells = _ref3.$showBorderedCells;
return {
'& th': $showBorderedCells ? {
borderRightWidth: makeSpace(getIn(theme.border.width, tableRow.borderBottomWidth)),
borderRightColor: getIn(theme.colors, tableRow.borderColor),
borderRightStyle: 'solid'
} : undefined,
'& th:last-child ': {
borderRight: 'none'
}
};
});
var _TableFooterRow = function _TableFooterRow(_ref4) {
var children = _ref4.children,
rest = _objectWithoutProperties(_ref4, _excluded2);
var _useTableContext = useTableContext(),
showBorderedCells = _useTableContext.showBorderedCells;
return /*#__PURE__*/jsx(StyledFooterRow, _objectSpread(_objectSpread(_objectSpread({}, metaAttribute({
name: MetaConstants.TableFooterRow
})), makeAnalyticsAttribute(rest)), {}, {
$showBorderedCells: showBorderedCells,
children: children
}));
};
var TableFooterRow = /*#__PURE__*/assignWithoutSideEffects(_TableFooterRow, {
componentId: ComponentIds.TableFooterRow
});
var StyledFooterCell = /*#__PURE__*/styled(FooterCell).withConfig({
displayName: "TableFooterweb__StyledFooterCell",
componentId: "sc-1dkm291-2"
})(function (_ref5) {
var theme = _ref5.theme,
$backgroundColor = _ref5.$backgroundColor,
$rowDensity = _ref5.$rowDensity,
$textAlign = _ref5.$textAlign;
return {
'&&&': {
height: '100%',
backgroundColor: getIn(theme.colors, $backgroundColor),
borderBottomWidth: makeSpace(getIn(theme.border.width, tableFooter.borderBottomAndTopWidth)),
borderTopWidth: makeSpace(getIn(theme.border.width, tableFooter.borderBottomAndTopWidth)),
borderBottomColor: getIn(theme.colors, tableFooter.borderBottomAndTopColor),
borderTopColor: getIn(theme.colors, tableFooter.borderBottomAndTopColor),
borderBottomStyle: 'solid',
borderTopStyle: 'solid',
'> div': {
backgroundColor: getIn(theme.colors, tableFooter.backgroundColor),
display: 'flex',
flexDirection: 'row',
height: '100%',
paddingLeft: makeSpace(getIn(theme, tableRow.paddingLeft[$rowDensity])),
paddingRight: makeSpace(getIn(theme, tableRow.paddingRight[$rowDensity])),
minHeight: makeSize(getIn(size, tableRow.minHeight[$rowDensity])),
alignItems: 'center',
justifyContent: $textAlign ? $textAlign : 'left'
}
}
};
});
var _TableFooterCell = function _TableFooterCell(_ref6) {
var children = _ref6.children,
textAlign = _ref6.textAlign,
rest = _objectWithoutProperties(_ref6, _excluded3);
var isChildrenString = typeof children === 'string';
var _useTableContext2 = useTableContext(),
backgroundColor = _useTableContext2.backgroundColor,
rowDensity = _useTableContext2.rowDensity;
return /*#__PURE__*/jsx(StyledFooterCell, _objectSpread(_objectSpread(_objectSpread({
$backgroundColor: backgroundColor,
$rowDensity: rowDensity,
$textAlign: textAlign
}, metaAttribute({
name: MetaConstants.TableFooterCell
})), makeAnalyticsAttribute(rest)), {}, {
children: isChildrenString ? /*#__PURE__*/jsx(Text, {
size: "medium",
weight: "medium",
children: children
}) : children
}));
};
var TableFooterCell = /*#__PURE__*/assignWithoutSideEffects(_TableFooterCell, {
componentId: ComponentIds.TableFooterCell
});
export { TableFooter, TableFooterCell, TableFooterRow };
//# sourceMappingURL=TableFooter.web.js.map