UNPKG

@progress/kendo-react-grid

Version:
67 lines 2.98 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import * as React from 'react'; /** * @hidden */ var PagerNumericButtons = /** @class */ (function (_super) { __extends(PagerNumericButtons, _super); function PagerNumericButtons() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.click = function (e, page) { e.preventDefault(); _this.props.pageChange(page, e); }; return _this; } Object.defineProperty(PagerNumericButtons.prototype, "end", { get: function () { return Math.min((this.start + this.props.buttonCount) - 1, this.props.totalPages); }, enumerable: true, configurable: true }); Object.defineProperty(PagerNumericButtons.prototype, "start", { get: function () { var page = this.props.currentPage; var buttonCount = this.props.buttonCount; if (page > buttonCount) { var reminder = (page % buttonCount); return (reminder === 0) ? (page - buttonCount) + 1 : (page - reminder) + 1; } return 1; }, enumerable: true, configurable: true }); PagerNumericButtons.prototype.render = function () { var _this = this; var prevDots = this.start > 1 ? (React.createElement("li", null, React.createElement("a", { className: "k-link", onClick: function (e) { return _this.click(e, _this.start - 1); }, href: "#" }, "..."))) : ''; var postDots = this.end < this.props.totalPages ? (React.createElement("li", null, React.createElement("a", { className: "k-link", onClick: function (e) { return _this.click(e, _this.end + 1); }, href: "#" }, "..."))) : ''; var buttons = []; for (var idx = this.start; idx <= this.end; idx++) { buttons.push(idx); } var numerics = buttons.map(function (page) { return (React.createElement("li", { key: page }, React.createElement("a", { href: "#", onClick: function (e) { return _this.click(e, page); }, className: _this.props.currentPage === page ? 'k-link k-state-selected' : 'k-link' }, page))); }); return (React.createElement("ul", { className: "k-pager-numbers k-reset" }, prevDots, numerics, postDots)); }; return PagerNumericButtons; }(React.Component)); export { PagerNumericButtons }; //# sourceMappingURL=PagerNumericButtons.js.map