react-router-dom 5.2.0 → 6.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +345 -0
  2. package/{LICENSE → LICENSE.md} +3 -1
  3. package/README.md +4 -36
  4. package/dist/dom.d.ts +76 -0
  5. package/dist/index.d.ts +246 -0
  6. package/dist/index.js +1058 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/main.js +19 -0
  9. package/dist/react-router-dom.development.js +1005 -0
  10. package/dist/react-router-dom.development.js.map +1 -0
  11. package/dist/react-router-dom.production.min.js +12 -0
  12. package/dist/react-router-dom.production.min.js.map +1 -0
  13. package/dist/server.d.ts +28 -0
  14. package/dist/server.js +319 -0
  15. package/dist/server.mjs +291 -0
  16. package/dist/umd/react-router-dom.development.js +1306 -0
  17. package/dist/umd/react-router-dom.development.js.map +1 -0
  18. package/dist/umd/react-router-dom.production.min.js +12 -0
  19. package/dist/umd/react-router-dom.production.min.js.map +1 -0
  20. package/package.json +38 -54
  21. package/server.d.ts +28 -0
  22. package/server.js +319 -0
  23. package/server.mjs +291 -0
  24. package/BrowserRouter.js +0 -3
  25. package/HashRouter.js +0 -3
  26. package/Link.js +0 -3
  27. package/MemoryRouter.js +0 -3
  28. package/NavLink.js +0 -3
  29. package/Prompt.js +0 -3
  30. package/Redirect.js +0 -3
  31. package/Route.js +0 -3
  32. package/Router.js +0 -3
  33. package/StaticRouter.js +0 -3
  34. package/Switch.js +0 -3
  35. package/cjs/react-router-dom.js +0 -443
  36. package/cjs/react-router-dom.js.map +0 -1
  37. package/cjs/react-router-dom.min.js +0 -2
  38. package/cjs/react-router-dom.min.js.map +0 -1
  39. package/es/BrowserRouter.js +0 -5
  40. package/es/HashRouter.js +0 -5
  41. package/es/Link.js +0 -5
  42. package/es/MemoryRouter.js +0 -5
  43. package/es/NavLink.js +0 -5
  44. package/es/Prompt.js +0 -5
  45. package/es/Redirect.js +0 -5
  46. package/es/Route.js +0 -5
  47. package/es/Router.js +0 -5
  48. package/es/StaticRouter.js +0 -5
  49. package/es/Switch.js +0 -5
  50. package/es/generatePath.js +0 -5
  51. package/es/matchPath.js +0 -5
  52. package/es/warnAboutDeprecatedESMImport.js +0 -34
  53. package/es/withRouter.js +0 -5
  54. package/esm/react-router-dom.js +0 -317
  55. package/esm/react-router-dom.js.map +0 -1
  56. package/generatePath.js +0 -3
  57. package/index.js +0 -7
  58. package/matchPath.js +0 -3
  59. package/modules/BrowserRouter.js +0 -36
  60. package/modules/HashRouter.js +0 -35
  61. package/modules/Link.js +0 -146
  62. package/modules/NavLink.js +0 -125
  63. package/modules/index.js +0 -21
  64. package/modules/utils/locationUtils.js +0 -10
  65. package/umd/react-router-dom.js +0 -3969
  66. package/umd/react-router-dom.js.map +0 -1
  67. package/umd/react-router-dom.min.js +0 -2
  68. package/umd/react-router-dom.min.js.map +0 -1
  69. package/warnAboutDeprecatedCJSRequire.js +0 -36
  70. package/withRouter.js +0 -3
@@ -1,125 +0,0 @@
1
- import React from "react";
2
- import { __RouterContext as RouterContext, matchPath } from "react-router";
3
- import PropTypes from "prop-types";
4
- import invariant from "tiny-invariant";
5
- import Link from "./Link.js";
6
- import {
7
- resolveToLocation,
8
- normalizeToLocation
9
- } from "./utils/locationUtils.js";
10
-
11
- // React 15 compat
12
- const forwardRefShim = C => C;
13
- let { forwardRef } = React;
14
- if (typeof forwardRef === "undefined") {
15
- forwardRef = forwardRefShim;
16
- }
17
-
18
- function joinClassnames(...classnames) {
19
- return classnames.filter(i => i).join(" ");
20
- }
21
-
22
- /**
23
- * A <Link> wrapper that knows if it's "active" or not.
24
- */
25
- const NavLink = forwardRef(
26
- (
27
- {
28
- "aria-current": ariaCurrent = "page",
29
- activeClassName = "active",
30
- activeStyle,
31
- className: classNameProp,
32
- exact,
33
- isActive: isActiveProp,
34
- location: locationProp,
35
- sensitive,
36
- strict,
37
- style: styleProp,
38
- to,
39
- innerRef, // TODO: deprecate
40
- ...rest
41
- },
42
- forwardedRef
43
- ) => {
44
- return (
45
- <RouterContext.Consumer>
46
- {context => {
47
- invariant(context, "You should not use <NavLink> outside a <Router>");
48
-
49
- const currentLocation = locationProp || context.location;
50
- const toLocation = normalizeToLocation(
51
- resolveToLocation(to, currentLocation),
52
- currentLocation
53
- );
54
- const { pathname: path } = toLocation;
55
- // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
56
- const escapedPath =
57
- path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
58
-
59
- const match = escapedPath
60
- ? matchPath(currentLocation.pathname, {
61
- path: escapedPath,
62
- exact,
63
- sensitive,
64
- strict
65
- })
66
- : null;
67
- const isActive = !!(isActiveProp
68
- ? isActiveProp(match, currentLocation)
69
- : match);
70
-
71
- const className = isActive
72
- ? joinClassnames(classNameProp, activeClassName)
73
- : classNameProp;
74
- const style = isActive ? { ...styleProp, ...activeStyle } : styleProp;
75
-
76
- const props = {
77
- "aria-current": (isActive && ariaCurrent) || null,
78
- className,
79
- style,
80
- to: toLocation,
81
- ...rest
82
- };
83
-
84
- // React 15 compat
85
- if (forwardRefShim !== forwardRef) {
86
- props.ref = forwardedRef || innerRef;
87
- } else {
88
- props.innerRef = innerRef;
89
- }
90
-
91
- return <Link {...props} />;
92
- }}
93
- </RouterContext.Consumer>
94
- );
95
- }
96
- );
97
-
98
- if (__DEV__) {
99
- NavLink.displayName = "NavLink";
100
-
101
- const ariaCurrentType = PropTypes.oneOf([
102
- "page",
103
- "step",
104
- "location",
105
- "date",
106
- "time",
107
- "true"
108
- ]);
109
-
110
- NavLink.propTypes = {
111
- ...Link.propTypes,
112
- "aria-current": ariaCurrentType,
113
- activeClassName: PropTypes.string,
114
- activeStyle: PropTypes.object,
115
- className: PropTypes.string,
116
- exact: PropTypes.bool,
117
- isActive: PropTypes.func,
118
- location: PropTypes.object,
119
- sensitive: PropTypes.bool,
120
- strict: PropTypes.bool,
121
- style: PropTypes.object
122
- };
123
- }
124
-
125
- export default NavLink;
package/modules/index.js DELETED
@@ -1,21 +0,0 @@
1
- export {
2
- MemoryRouter,
3
- Prompt,
4
- Redirect,
5
- Route,
6
- Router,
7
- StaticRouter,
8
- Switch,
9
- generatePath,
10
- matchPath,
11
- withRouter,
12
- useHistory,
13
- useLocation,
14
- useParams,
15
- useRouteMatch
16
- } from "react-router";
17
-
18
- export { default as BrowserRouter } from "./BrowserRouter.js";
19
- export { default as HashRouter } from "./HashRouter.js";
20
- export { default as Link } from "./Link.js";
21
- export { default as NavLink } from "./NavLink.js";
@@ -1,10 +0,0 @@
1
- import { createLocation } from "history";
2
-
3
- export const resolveToLocation = (to, currentLocation) =>
4
- typeof to === "function" ? to(currentLocation) : to;
5
-
6
- export const normalizeToLocation = (to, currentLocation) => {
7
- return typeof to === "string"
8
- ? createLocation(to, null, null, currentLocation)
9
- : to;
10
- };