"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.default = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")); var _react = _interopRequireDefault(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _classnames = _interopRequireDefault(require("classnames")); var _utils = require("./utils"); var propTypes = { 'aria-label': _propTypes.default.string, children: _propTypes.default.node, className: _propTypes.default.string, cssModule: _propTypes.default.object, next: _propTypes.default.bool, previous: _propTypes.default.bool, first: _propTypes.default.bool, last: _propTypes.default.bool, tag: _utils.tagPropType }; var defaultProps = { tag: 'a' }; var PaginationLink = function PaginationLink(props) { var className = props.className, cssModule = props.cssModule, next = props.next, previous = props.previous, first = props.first, last = props.last, Tag = props.tag, attributes = (0, _objectWithoutPropertiesLoose2.default)(props, ["className", "cssModule", "next", "previous", "first", "last", "tag"]); var classes = (0, _utils.mapToCssModules)((0, _classnames.default)(className, 'page-link'), cssModule); var defaultAriaLabel; if (previous) { defaultAriaLabel = 'Previous'; } else if (next) { defaultAriaLabel = 'Next'; } else if (first) { defaultAriaLabel = 'First'; } else if (last) { defaultAriaLabel = 'Last'; } var ariaLabel = props['aria-label'] || defaultAriaLabel; var defaultCaret; if (previous) { defaultCaret = "\u2039"; } else if (next) { defaultCaret = "\u203A"; } else if (first) { defaultCaret = "\xAB"; } else if (last) { defaultCaret = "\xBB"; } var children = props.children; if (children && Array.isArray(children) && children.length === 0) { children = null; } if (!attributes.href && Tag === 'a') { Tag = 'button'; } if (previous || next || first || last) { children = [/*#__PURE__*/_react.default.createElement("span", { "aria-hidden": "true", key: "caret" }, children || defaultCaret), /*#__PURE__*/_react.default.createElement("span", { className: "sr-only", key: "sr" }, ariaLabel)]; } return /*#__PURE__*/_react.default.createElement(Tag, (0, _extends2.default)({}, attributes, { className: classes, "aria-label": ariaLabel }), children); }; PaginationLink.propTypes = propTypes; PaginationLink.defaultProps = defaultProps; var _default = PaginationLink; exports.default = _default;