UNPKG

shineout

Version:

Shein 前端组件库

88 lines (74 loc) 2.64 kB
import _extends from "@babel/runtime/helpers/extends"; import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectSpread from "@babel/runtime/helpers/objectSpread"; import React, { PureComponent } from 'react'; import classnames from 'classnames'; import { defaultProps } from '../utils/defaultProps'; import { paginationClass } from './styles'; import Links from './Links'; import Jumper from './Jumper'; import Simple from './Simple'; import PageSizeList from './PageSizeList'; import { isRTL } from '../config'; import getDataset from '../utils/dom/getDataset'; import { getDirectionClass } from '../utils/classname'; var DefaultValue = _objectSpread({}, defaultProps, { layout: ['links'], span: 5, text: {} }); var Pagination = /*#__PURE__*/ function (_PureComponent) { _inheritsLoose(Pagination, _PureComponent); function Pagination() { return _PureComponent.apply(this, arguments) || this; } var _proto = Pagination.prototype; _proto.render = function render() { var _this = this; var _this$props = this.props, align = _this$props.align, layout = _this$props.layout, size = _this$props.size, style = _this$props.style; var rtl = isRTL(); var className = classnames(paginationClass('_', size, align, rtl && 'rtl'), this.props.className); var sectionClassName = paginationClass(getDirectionClass('section')); return React.createElement("div", _extends({ className: className, style: style }, getDataset(this.props)), layout.map(function (section, i) { switch (section) { case 'links': return React.createElement(Links, _extends({ key: section }, _this.props)); case 'list': return React.createElement(PageSizeList, _extends({ key: section }, _this.props)); case 'jumper': return React.createElement(Jumper, _extends({ key: section }, _this.props)); case 'simple': return React.createElement(Simple, _extends({ key: section }, _this.props)); default: if (typeof section === 'function') { return React.createElement("div", { key: i, className: sectionClassName }, React.createElement("span", null, section(_this.props))); } return null; } })); }; return Pagination; }(PureComponent); _defineProperty(Pagination, "defaultProps", DefaultValue); export default Pagination;