1 |
- {"version":3,"file":"react-router-dom.min.js","sources":["../modules/BrowserRouter.js","../modules/HashRouter.js","../modules/utils/locationUtils.js","../modules/Link.js","../modules/NavLink.js"],"sourcesContent":["import React from \"react\";\nimport { Router } from \"react-router\";\nimport { createBrowserHistory as createHistory } from \"history\";\nimport PropTypes from \"prop-types\";\nimport warning from \"tiny-warning\";\n\n/**\n * The public API for a <Router> that uses HTML5 history.\n */\nclass BrowserRouter extends React.Component {\n history = createHistory(this.props);\n\n render() {\n return <Router history={this.history} children={this.props.children} />;\n }\n}\n\nif (__DEV__) {\n BrowserRouter.propTypes = {\n basename: PropTypes.string,\n children: PropTypes.node,\n forceRefresh: PropTypes.bool,\n getUserConfirmation: PropTypes.func,\n keyLength: PropTypes.number\n };\n\n BrowserRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<BrowserRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { BrowserRouter as Router }`.\"\n );\n };\n}\n\nexport default BrowserRouter;\n","import React from \"react\";\nimport { Router } from \"react-router\";\nimport { createHashHistory as createHistory } from \"history\";\nimport PropTypes from \"prop-types\";\nimport warning from \"tiny-warning\";\n\n/**\n * The public API for a <Router> that uses window.location.hash.\n */\nclass HashRouter extends React.Component {\n history = createHistory(this.props);\n\n render() {\n return <Router history={this.history} children={this.props.children} />;\n }\n}\n\nif (__DEV__) {\n HashRouter.propTypes = {\n basename: PropTypes.string,\n children: PropTypes.node,\n getUserConfirmation: PropTypes.func,\n hashType: PropTypes.oneOf([\"hashbang\", \"noslash\", \"slash\"])\n };\n\n HashRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<HashRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { HashRouter as Router }`.\"\n );\n };\n}\n\nexport default HashRouter;\n","import { createLocation } from \"history\";\n\nexport const resolveToLocation = (to, currentLocation) =>\n typeof to === \"function\" ? to(currentLocation) : to;\n\nexport const normalizeToLocation = (to, currentLocation) => {\n return typeof to === \"string\"\n ? createLocation(to, null, null, currentLocation)\n : to;\n};\n","import React from \"react\";\nimport { __RouterContext as RouterContext } from \"react-router\";\nimport { createPath } from 'history';\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport {\n resolveToLocation,\n normalizeToLocation\n} from \"./utils/locationUtils.js\";\n\n// React 15 compat\nconst forwardRefShim = C => C;\nlet { forwardRef } = React;\nif (typeof forwardRef === \"undefined\") {\n forwardRef = forwardRefShim;\n}\n\nfunction isModifiedEvent(event) {\n return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);\n}\n\nconst LinkAnchor = forwardRef(\n (\n {\n innerRef, // TODO: deprecate\n navigate,\n onClick,\n ...rest\n },\n forwardedRef\n ) => {\n const { target } = rest;\n\n let props = {\n ...rest,\n onClick: event => {\n try {\n if (onClick) onClick(event);\n } catch (ex) {\n event.preventDefault();\n throw ex;\n }\n\n if (\n !event.defaultPrevented && // onClick prevented default\n event.button === 0 && // ignore everything but left clicks\n (!target || target === \"_self\") && // let browser handle \"target=_blank\" etc.\n !isModifiedEvent(event) // ignore clicks with modifier keys\n ) {\n event.preventDefault();\n navigate();\n }\n }\n };\n\n // React 15 compat\n if (forwardRefShim !== forwardRef) {\n props.ref = forwardedRef || innerRef;\n } else {\n props.ref = innerRef;\n }\n\n /* eslint-disable-next-line jsx-a11y/anchor-has-content */\n return <a {...props} />;\n }\n);\n\nif (__DEV__) {\n LinkAnchor.displayName = \"LinkAnchor\";\n}\n\n/**\n * The public API for rendering a history-aware <a>.\n */\nconst Link = forwardRef(\n (\n {\n component = LinkAnchor,\n replace,\n to,\n innerRef, // TODO: deprecate\n ...rest\n },\n forwardedRef\n ) => {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Link> outside a <Router>\");\n\n const { history } = context;\n\n const location = normalizeToLocation(\n resolveToLocation(to, context.location),\n context.location\n );\n\n const href = location ? history.createHref(location) : \"\";\n const props = {\n ...rest,\n href,\n navigate() {\n const location = resolveToLocation(to, context.location);\n const isDuplicateNavigation = createPath(context.location) === createPath(normalizeToLocation(location));\n const method = (replace || isDuplicateNavigation) ? history.replace : history.push;\n\n method(location);\n }\n };\n\n // React 15 compat\n if (forwardRefShim !== forwardRef) {\n props.ref = forwardedRef || innerRef;\n } else {\n props.innerRef = innerRef;\n }\n\n return React.createElement(component, props);\n }}\n </RouterContext.Consumer>\n );\n }\n);\n\nif (__DEV__) {\n const toType = PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.object,\n PropTypes.func\n ]);\n const refType = PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.any })\n ]);\n\n Link.displayName = \"Link\";\n\n Link.propTypes = {\n innerRef: refType,\n onClick: PropTypes.func,\n replace: PropTypes.bool,\n target: PropTypes.string,\n to: toType.isRequired\n };\n}\n\nexport default Link;\n","import React from \"react\";\nimport { __RouterContext as RouterContext, matchPath } from \"react-router\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport Link from \"./Link.js\";\nimport {\n resolveToLocation,\n normalizeToLocation\n} from \"./utils/locationUtils.js\";\n\n// React 15 compat\nconst forwardRefShim = C => C;\nlet { forwardRef } = React;\nif (typeof forwardRef === \"undefined\") {\n forwardRef = forwardRefShim;\n}\n\nfunction joinClassnames(...classnames) {\n return classnames.filter(i => i).join(\" \");\n}\n\n/**\n * A <Link> wrapper that knows if it's \"active\" or not.\n */\nconst NavLink = forwardRef(\n (\n {\n \"aria-current\": ariaCurrent = \"page\",\n activeClassName = \"active\", // TODO: deprecate\n activeStyle, // TODO: deprecate\n className: classNameProp,\n exact,\n isActive: isActiveProp,\n location: locationProp,\n sensitive,\n strict,\n style: styleProp,\n to,\n innerRef, // TODO: deprecate\n ...rest\n },\n forwardedRef\n ) => {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <NavLink> outside a <Router>\");\n\n const currentLocation = locationProp || context.location;\n const toLocation = normalizeToLocation(\n resolveToLocation(to, currentLocation),\n currentLocation\n );\n const { pathname: path } = toLocation;\n // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202\n const escapedPath =\n path && path.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, \"\\\\$1\");\n\n const match = escapedPath\n ? matchPath(currentLocation.pathname, {\n path: escapedPath,\n exact,\n sensitive,\n strict\n })\n : null;\n const isActive = !!(isActiveProp\n ? isActiveProp(match, currentLocation)\n : match);\n\n let className =\n typeof classNameProp === \"function\"\n ? classNameProp(isActive)\n : classNameProp;\n\n let style =\n typeof styleProp === \"function\" ? styleProp(isActive) : styleProp;\n\n if (isActive) {\n className = joinClassnames(className, activeClassName);\n style = { ...style, ...activeStyle };\n }\n\n const props = {\n \"aria-current\": (isActive && ariaCurrent) || null,\n className,\n style,\n to: toLocation,\n ...rest\n };\n\n // React 15 compat\n if (forwardRefShim !== forwardRef) {\n props.ref = forwardedRef || innerRef;\n } else {\n props.innerRef = innerRef;\n }\n\n return <Link {...props} />;\n }}\n </RouterContext.Consumer>\n );\n }\n);\n\nif (__DEV__) {\n NavLink.displayName = \"NavLink\";\n\n const ariaCurrentType = PropTypes.oneOf([\n \"page\",\n \"step\",\n \"location\",\n \"date\",\n \"time\",\n \"true\",\n \"false\"\n ]);\n\n NavLink.propTypes = {\n ...Link.propTypes,\n \"aria-current\": ariaCurrentType,\n activeClassName: PropTypes.string,\n activeStyle: PropTypes.object,\n className: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),\n exact: PropTypes.bool,\n isActive: PropTypes.func,\n location: PropTypes.object,\n sensitive: PropTypes.bool,\n strict: PropTypes.bool,\n style: PropTypes.oneOfType([PropTypes.object, PropTypes.func])\n };\n}\n\nexport default NavLink;\n"],"names":["BrowserRouter","history","createHistory","_this","props","render","React","Router","this","children","Component","HashRouter","resolveToLocation","to","currentLocation","normalizeToLocation","createLocation","forwardRefShim","C","forwardRef","isModifiedEvent","event","metaKey","altKey","ctrlKey","shiftKey","LinkAnchor","forwardedRef","innerRef","navigate","onClick","rest","target","ex","preventDefault","defaultPrevented","button","ref","Link","component","replace","RouterContext","Consumer","context","invariant","location","href","createHref","isDuplicateNavigation","createPath","push","createElement","joinClassnames","classnames","filter","i","join","NavLink","ariaCurrent","activeClassName","activeStyle","classNameProp","className","exact","isActiveProp","isActive","locationProp","sensitive","strict","styleProp","style","toLocation","path","pathname","escapedPath","match","matchPath"],"mappings":"s9BASMA,kKACJC,QAAUC,6BAAcC,EAAKC,gDAE7BC,OAAA,kBACSC,oBAACC,oBAAON,QAASO,KAAKP,QAASQ,SAAUD,KAAKJ,MAAMK,eAJnCH,MAAMI,WCA5BC,+JACJV,QAAUC,0BAAcC,EAAKC,gDAE7BC,OAAA,kBACSC,oBAACC,oBAAON,QAASO,KAAKP,QAASQ,SAAUD,KAAKJ,MAAMK,eAJtCH,MAAMI,WCPlBE,kBAAoB,SAACC,EAAIC,SACtB,mBAAPD,EAAoBA,EAAGC,GAAmBD,GAEtCE,oBAAsB,SAACF,EAAIC,SACjB,iBAAPD,EACVG,uBAAeH,EAAI,KAAM,KAAMC,GAC/BD,GCGAI,eAAiB,SAAAC,UAAKA,GACtBC,WAAeb,MAAfa,WAKN,SAASC,gBAAgBC,YACbA,EAAMC,SAAWD,EAAME,QAAUF,EAAMG,SAAWH,EAAMI,eAL1C,IAAfN,aACTA,WAAaF,gBAOf,IAAMS,WAAaP,WACjB,WAOEQ,OALEC,IAAAA,SACAC,IAAAA,SACAC,IAAAA,QACGC,qEAIGC,EAAWD,EAAXC,OAEJ5B,cACC2B,GACHD,QAAS,SAAAT,OAEDS,GAASA,EAAQT,GACrB,MAAOY,SACPZ,EAAMa,iBACAD,EAILZ,EAAMc,kBACU,IAAjBd,EAAMe,QACJJ,GAAqB,UAAXA,GACXZ,gBAAgBC,KAEjBA,EAAMa,iBACNL,eAOJzB,EAAMiC,IADJpB,iBAAmBE,YACTQ,GAEAC,EAIPtB,wBAAOF,KAWZkC,KAAOnB,WAC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