UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

147 lines (120 loc) 4.25 kB
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; function _createSuper(Derived) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } return function () { var Super = _getPrototypeOf(Derived), result; if (isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'mini-store'; var FOOTER_ROW_KEY = "rc_table_footer_key_".concat(Date.now()); function getColumnFooter(col) { if (typeof col.footer === 'function') return col.footer; return function () { return col.footer; }; } var TableFooterRow = /*#__PURE__*/ function (_Component) { _inherits(TableFooterRow, _Component); var _super = _createSuper(TableFooterRow); function TableFooterRow() { var _this; _classCallCheck(this, TableFooterRow); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function () { var onHover = _this.props.onHover; if (onHover) { onHover(true, FOOTER_ROW_KEY); } }); _defineProperty(_assertThisInitialized(_this), "handleMouseLeave", function () { var onHover = _this.props.onHover; if (onHover) { onHover(false, FOOTER_ROW_KEY); } }); return _this; } _createClass(TableFooterRow, [{ key: "render", value: function render() { var _this$props = this.props, columns = _this$props.columns, data = _this$props.data, components = _this$props.components, prefixCls = _this$props.prefixCls, hovered = _this$props.hovered, height = _this$props.height; var FooterRow = components.footer.row; var FooterCell = components.footer.cell; var className = "".concat(prefixCls, "-footer-row"); if (hovered) { className += " ".concat(prefixCls, "-row-hover"); } return React.createElement(FooterRow, { onMouseEnter: this.handleMouseEnter, onMouseLeave: this.handleMouseLeave, className: className, style: { height: height } }, columns.map(function (col) { return React.createElement(FooterCell, { key: col.key || col.dataIndex }, col.footer ? getColumnFooter(col)(data) : null); })); } }]); return TableFooterRow; }(Component); _defineProperty(TableFooterRow, "propTypes", { columns: PropTypes.array, data: PropTypes.array, components: PropTypes.any, prefixCls: PropTypes.string, onHover: PropTypes.func, hovered: PropTypes.bool, height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) }); function getRowHeight(state, props) { var fixedColumnsFootRowsHeight = state.fixedColumnsFootRowsHeight; var fixed = props.fixed; return fixed ? fixedColumnsFootRowsHeight[0] : null; } export default connect(function (state, props) { return { hovered: state.currentHoverKey === FOOTER_ROW_KEY, height: getRowHeight(state, props) }; })(TableFooterRow); //# sourceMappingURL=TableFooterRow.js.map