UNPKG

react-mui-table

Version:

A react component that takes data & style parameters, and renders a Material UI table.

117 lines (85 loc) 4.96 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _lodash = require('lodash.isequal'); var _lodash2 = _interopRequireDefault(_lodash); var _IconButton = require('material-ui/IconButton'); var _IconButton2 = _interopRequireDefault(_IconButton); var _keyboardArrowLeft = require('material-ui/svg-icons/hardware/keyboard-arrow-left'); var _keyboardArrowLeft2 = _interopRequireDefault(_keyboardArrowLeft); var _keyboardArrowRight = require('material-ui/svg-icons/hardware/keyboard-arrow-right'); var _keyboardArrowRight2 = _interopRequireDefault(_keyboardArrowRight); var _RowsPerPage = require('./RowsPerPage'); var _RowsPerPage2 = _interopRequireDefault(_RowsPerPage); var _styles = require('./styles'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Pagination = function (_Component) { _inherits(Pagination, _Component); function Pagination() { var _ref; var _temp, _this, _ret; _classCallCheck(this, Pagination); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Pagination.__proto__ || Object.getPrototypeOf(Pagination)).call.apply(_ref, [this].concat(args))), _this), _this.shouldComponentUpdate = function (nextProps) { return !(0, _lodash2.default)(nextProps, _this.props); }, _this.runNextPage = function () { var _this$props = _this.props, hasNextPage = _this$props.hasNextPage, nextPage = _this$props.nextPage; if (!hasNextPage) return; nextPage(); }, _this.runPreviousPage = function () { var _this$props2 = _this.props, hasPreviousPage = _this$props2.hasPreviousPage, previousPage = _this$props2.previousPage; if (!hasPreviousPage) return; previousPage(); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(Pagination, [{ key: 'render', value: function render() { var _props = this.props, hasNextPage = _props.hasNextPage, hasPreviousPage = _props.hasPreviousPage, rows = _props.rows, paginationText = _props.paginationText, changeRowsPerPage = _props.changeRowsPerPage, rowOptions = _props.rowOptions; return _react2.default.createElement( 'div', { style: _styles.paginationStyles.wrapper }, _react2.default.createElement(_RowsPerPage2.default, { paginationText: paginationText, changeRowsPerPage: changeRowsPerPage, rowOptions: rowOptions, rows: rows }), _react2.default.createElement( _IconButton2.default, { iconStyle: { color: hasPreviousPage ? 'rgba(0, 0, 0, .54)' : 'rgba(0, 0, 0, .38)' }, onClick: this.runPreviousPage }, _react2.default.createElement(_keyboardArrowLeft2.default, null) ), _react2.default.createElement( _IconButton2.default, { iconStyle: { color: hasNextPage ? 'rgba(0, 0, 0, .54)' : 'rgba(0, 0, 0, .38)' }, onClick: this.runNextPage }, _react2.default.createElement(_keyboardArrowRight2.default, null) ) ); } }]); return Pagination; }(_react.Component); exports.default = Pagination;