UNPKG

choerodon-ui

Version:

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

173 lines (144 loc) 4.83 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; 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 classNames from 'classnames'; import { Size } from '../_util/enum'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import Select from '../select'; import MiniSelect from './MiniSelect'; import LargeSelect from './LargeSelect'; import RcPagination from '../rc-components/pagination'; import enUS from '../rc-components/pagination/locale/en_US'; import Button from '../button/Button'; import ConfigContext from '../config-provider/ConfigContext'; function getSelect(size) { switch (size) { case Size.small: return MiniSelect; case Size.large: return LargeSelect; default: return Select; } } function getIcon(type) { switch (type) { case 'first': return 'first_page'; case 'last': return 'last_page'; case 'prev': return 'navigate_before'; case 'next': return 'navigate_next'; default: } } function itemRender(page, type, item, disabled, size) { if (page !== undefined) { if (type === 'page' || type === 'jump-prev' || type === 'jump-next') { return React.createElement(Button, { size: size, shape: "circle" }, item); } return React.createElement(Button, { size: size, shape: "circle", icon: getIcon(type), disabled: disabled }); } } var Pagination = /*#__PURE__*/ function (_Component) { _inherits(Pagination, _Component); var _super = _createSuper(Pagination); function Pagination() { var _this; _classCallCheck(this, Pagination); _this = _super.apply(this, arguments); _this.renderPagination = function (locale) { var _this$props = _this.props, className = _this$props.className, size = _this$props.size, customizePrefixCls = _this$props.prefixCls, customizeSelectPrefixCls = _this$props.selectPrefixCls, restProps = _objectWithoutProperties(_this$props, ["className", "size", "prefixCls", "selectPrefixCls"]); var getPrefixCls = _this.context.getPrefixCls; var prefixCls = getPrefixCls('pagination', customizePrefixCls); var selectPrefixCls = getPrefixCls('select', customizeSelectPrefixCls); return React.createElement(RcPagination, _extends({}, restProps, { selectPrefixCls: selectPrefixCls, prefixCls: prefixCls, size: size, className: classNames(className, _defineProperty({}, "".concat(prefixCls, "-").concat(size), size)), selectComponentClass: getSelect(size), locale: locale })); }; return _this; } _createClass(Pagination, [{ key: "render", value: function render() { return React.createElement(LocaleReceiver, { componentName: "Pagination", defaultLocale: enUS }, this.renderPagination); } }], [{ key: "contextType", get: function get() { return ConfigContext; } }]); return Pagination; }(Component); export { Pagination as default }; Pagination.displayName = 'Pagination'; Pagination.defaultProps = { showSizeChanger: true, showSizeChangerLabel: true, tiny: true, pageSizeOptions: ['10', '30', '50', '100', '200'], showTotal: function showTotal(total, range) { return "".concat(range[0], " - ").concat(range[1], " / ").concat(total); }, sizeChangerOptionText: function sizeChangerOptionText(value) { return value; }, itemRender: itemRender }; //# sourceMappingURL=Pagination.js.map