UNPKG

opds-web-client

Version:
59 lines (58 loc) 2.3 kB
"use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; var React = require("react"); var react_router_1 = require("react-router"); var CatalogLink = (function (_super) { __extends(CatalogLink, _super); function CatalogLink() { return _super.apply(this, arguments) || this; } // provides full router context expected by but not actually used by Link // see https://github.com/reactjs/react-router/blob/master/docs/API.md#contextrouter // and https://github.com/reactjs/react-router/blob/master/modules/PropTypes.js CatalogLink.prototype.getChildContext = function () { var noop = function () { }; var router = Object.assign({}, this.context.router, { replace: noop, go: noop, goBack: noop, goForward: noop, setRouteLeaveHook: noop, }); return { router: router }; }; ; CatalogLink.prototype.render = function () { var _a = this.props, collectionUrl = _a.collectionUrl, bookUrl = _a.bookUrl; collectionUrl = collectionUrl || null; bookUrl = bookUrl || null; var location = this.context.pathFor(collectionUrl, bookUrl); // remove props that Link won't recognize var props = Object.assign({}, this.props); delete props["collectionUrl"]; delete props["bookUrl"]; return (React.createElement(react_router_1.Link, __assign({ to: location }, props))); }; return CatalogLink; }(React.Component)); CatalogLink.contextTypes = { router: React.PropTypes.object.isRequired, pathFor: React.PropTypes.func.isRequired }; CatalogLink.childContextTypes = { router: React.PropTypes.object.isRequired }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = CatalogLink;