@teambit/react-router 0.0.743 → 0.0.746
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.
- package/LocationHooks.tsx +24 -0
- package/dist/LocationHooks.d.ts +6 -0
- package/dist/LocationHooks.js +45 -0
- package/dist/LocationHooks.js.map +1 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.js +37 -21
- package/dist/index.js.map +1 -1
- package/dist/legacy-routing.d.ts +2 -0
- package/dist/legacy-routing.js +102 -0
- package/dist/legacy-routing.js.map +1 -0
- package/dist/react-router.ui.runtime.d.ts +6 -10
- package/dist/react-router.ui.runtime.js +31 -18
- package/dist/react-router.ui.runtime.js.map +1 -1
- package/dist/route-context.d.ts +2 -3
- package/dist/route-context.js +35 -38
- package/dist/route-context.js.map +1 -1
- package/legacy-routing.tsx +24 -0
- package/package-tar/teambit-react-router-0.0.746.tgz +0 -0
- package/package.json +8 -11
- package/{preview-1653708349111.js → preview-1653881205832.js} +2 -2
- package/react-router.ui.runtime.tsx +21 -18
- package/route-context.tsx +14 -28
- package/dist/react-router-routing/index.d.ts +0 -1
- package/dist/react-router-routing/index.js +0 -23
- package/dist/react-router-routing/index.js.map +0 -1
- package/dist/react-router-routing/react-router-routing.d.ts +0 -11
- package/dist/react-router-routing/react-router-routing.js +0 -55
- package/dist/react-router-routing/react-router-routing.js.map +0 -1
- package/package-tar/teambit-react-router-0.0.743.tgz +0 -0
- package/react-router-routing/index.ts +0 -1
- package/react-router-routing/react-router-routing.tsx +0 -15
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useLocation, useNavigate, NavigateFunction, useNavigationType } from 'react-router-dom';
|
|
3
|
+
import { LocationListener } from './react-router.ui.runtime';
|
|
4
|
+
|
|
5
|
+
export function LocationHooks({
|
|
6
|
+
onLocationChange, onNavigatorChange,
|
|
7
|
+
}: {
|
|
8
|
+
onLocationChange: LocationListener;
|
|
9
|
+
onNavigatorChange: (nav: NavigateFunction) => void;
|
|
10
|
+
}) {
|
|
11
|
+
const location = useLocation();
|
|
12
|
+
const navAction = useNavigationType(); // the action that got react router to this location
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
onLocationChange(location, navAction);
|
|
17
|
+
}, [location, navAction, onLocationChange]);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
onNavigatorChange(navigate);
|
|
21
|
+
}, [navigate, onNavigatorChange]);
|
|
22
|
+
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NavigateFunction } from 'react-router-dom';
|
|
2
|
+
import { LocationListener } from './react-router.ui.runtime';
|
|
3
|
+
export declare function LocationHooks({ onLocationChange, onNavigatorChange, }: {
|
|
4
|
+
onLocationChange: LocationListener;
|
|
5
|
+
onNavigatorChange: (nav: NavigateFunction) => void;
|
|
6
|
+
}): null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LocationHooks = LocationHooks;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = require("react");
|
|
10
|
+
|
|
11
|
+
_react = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _reactRouterDom() {
|
|
19
|
+
const data = require("react-router-dom");
|
|
20
|
+
|
|
21
|
+
_reactRouterDom = function () {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function LocationHooks({
|
|
29
|
+
onLocationChange,
|
|
30
|
+
onNavigatorChange
|
|
31
|
+
}) {
|
|
32
|
+
const location = (0, _reactRouterDom().useLocation)();
|
|
33
|
+
const navAction = (0, _reactRouterDom().useNavigationType)(); // the action that got react router to this location
|
|
34
|
+
|
|
35
|
+
const navigate = (0, _reactRouterDom().useNavigate)();
|
|
36
|
+
(0, _react().useEffect)(() => {
|
|
37
|
+
onLocationChange(location, navAction);
|
|
38
|
+
}, [location, navAction, onLocationChange]);
|
|
39
|
+
(0, _react().useEffect)(() => {
|
|
40
|
+
onNavigatorChange(navigate);
|
|
41
|
+
}, [navigate, onNavigatorChange]);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=LocationHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LocationHooks","onLocationChange","onNavigatorChange","location","useLocation","navAction","useNavigationType","navigate","useNavigate","useEffect"],"sources":["LocationHooks.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation, useNavigate, NavigateFunction, useNavigationType } from 'react-router-dom';\nimport { LocationListener } from './react-router.ui.runtime';\n\nexport function LocationHooks({\n onLocationChange, onNavigatorChange,\n}: {\n onLocationChange: LocationListener;\n onNavigatorChange: (nav: NavigateFunction) => void;\n}) {\n const location = useLocation();\n const navAction = useNavigationType(); // the action that got react router to this location\n const navigate = useNavigate();\n\n useEffect(() => {\n onLocationChange(location, navAction);\n }, [location, navAction, onLocationChange]);\n\n useEffect(() => {\n onNavigatorChange(navigate);\n }, [navigate, onNavigatorChange]);\n\n return null;\n}\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,SAASA,aAAT,CAAuB;EAC5BC,gBAD4B;EACVC;AADU,CAAvB,EAKJ;EACD,MAAMC,QAAQ,GAAG,IAAAC,6BAAA,GAAjB;EACA,MAAMC,SAAS,GAAG,IAAAC,mCAAA,GAAlB,CAFC,CAEsC;;EACvC,MAAMC,QAAQ,GAAG,IAAAC,6BAAA,GAAjB;EAEA,IAAAC,kBAAA,EAAU,MAAM;IACdR,gBAAgB,CAACE,QAAD,EAAWE,SAAX,CAAhB;EACD,CAFD,EAEG,CAACF,QAAD,EAAWE,SAAX,EAAsBJ,gBAAtB,CAFH;EAIA,IAAAQ,kBAAA,EAAU,MAAM;IACdP,iBAAiB,CAACK,QAAD,CAAjB;EACD,CAFD,EAEG,CAACA,QAAD,EAAWL,iBAAX,CAFH;EAIA,OAAO,IAAP;AACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { ReactRouterAspect } from './react-router.aspect';
|
|
2
2
|
export { Routing } from './routing-method';
|
|
3
3
|
export type { ReactRouterUI } from './react-router.ui.runtime';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export { RoutingProvider, useRouting, useLocation } from '@teambit/base-ui.routing.routing-provider';
|
|
7
|
-
export { LinkAnchor, LinkContextProvider, useLinkContext } from '@teambit/ui-foundation.ui.react-router.link-anchor';
|
|
8
|
-
export * as ReactRouter from 'react-router';
|
|
4
|
+
export * as navigation from '@teambit/base-react.navigation.link';
|
|
5
|
+
export * as ReactRouter from 'react-router-dom';
|
|
9
6
|
export { ReactRouterAspect };
|
|
10
7
|
export default ReactRouterAspect;
|
|
8
|
+
export { /** @deprecated */ Link, /** @deprecated */ LinkProps } from '@teambit/base-ui.routing.link';
|
|
9
|
+
export { /** @deprecated */ NavLink, /** @deprecated */ NavLinkProps } from '@teambit/base-ui.routing.nav-link';
|
|
10
|
+
export {
|
|
11
|
+
/** @deprecated */ RoutingProvider,
|
|
12
|
+
/** @deprecated */ useRouting,
|
|
13
|
+
/** @deprecated */ useLocation, } from '@teambit/base-ui.routing.routing-provider';
|
|
14
|
+
export {
|
|
15
|
+
/** @deprecated */ LinkAnchor,
|
|
16
|
+
/** @deprecated */ LinkContextProvider,
|
|
17
|
+
/** @deprecated */ useLinkContext, } from '@teambit/ui-foundation.ui.react-router.link-anchor';
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ Object.defineProperty(exports, "RoutingProvider", {
|
|
|
58
58
|
return _baseUiRouting3().RoutingProvider;
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
exports.default = void 0;
|
|
61
|
+
exports.navigation = exports.default = void 0;
|
|
62
62
|
Object.defineProperty(exports, "useLinkContext", {
|
|
63
63
|
enumerable: true,
|
|
64
64
|
get: function () {
|
|
@@ -98,6 +98,40 @@ function _routingMethod() {
|
|
|
98
98
|
return data;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
function _navigation() {
|
|
102
|
+
const data = _interopRequireWildcard(require("@teambit/base-react.navigation.link"));
|
|
103
|
+
|
|
104
|
+
_navigation = function () {
|
|
105
|
+
return data;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return data;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
Object.defineProperty(exports, "navigation", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get: function () {
|
|
114
|
+
return _navigation();
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
function _ReactRouter() {
|
|
119
|
+
const data = _interopRequireWildcard(require("react-router-dom"));
|
|
120
|
+
|
|
121
|
+
_ReactRouter = function () {
|
|
122
|
+
return data;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
return data;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
Object.defineProperty(exports, "ReactRouter", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function () {
|
|
131
|
+
return _ReactRouter();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
101
135
|
function _baseUiRouting() {
|
|
102
136
|
const data = require("@teambit/base-ui.routing.link");
|
|
103
137
|
|
|
@@ -138,30 +172,12 @@ function _uiFoundationUiReactRouter() {
|
|
|
138
172
|
return data;
|
|
139
173
|
}
|
|
140
174
|
|
|
141
|
-
function _ReactRouter() {
|
|
142
|
-
const data = _interopRequireWildcard(require("react-router"));
|
|
143
|
-
|
|
144
|
-
_ReactRouter = function () {
|
|
145
|
-
return data;
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
return data;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
Object.defineProperty(exports, "ReactRouter", {
|
|
152
|
-
enumerable: true,
|
|
153
|
-
get: function () {
|
|
154
|
-
return _ReactRouter();
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
|
|
158
175
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
159
176
|
|
|
160
177
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
161
178
|
|
|
162
|
-
// TODO -
|
|
163
|
-
|
|
164
|
-
var _default = _reactRouter().ReactRouterAspect;
|
|
179
|
+
var _default = _reactRouter().ReactRouterAspect; // TODO - remove after releasing dependants (symphony)
|
|
180
|
+
|
|
165
181
|
|
|
166
182
|
exports.default = _default;
|
|
167
183
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ReactRouterAspect"],"sources":["index.ts"],"sourcesContent":["import { ReactRouterAspect } from './react-router.aspect';\n\nexport { Routing } from './routing-method';\nexport type { ReactRouterUI } from './react-router.ui.runtime';\n\
|
|
1
|
+
{"version":3,"names":["ReactRouterAspect"],"sources":["index.ts"],"sourcesContent":["import { ReactRouterAspect } from './react-router.aspect';\n\nexport { Routing } from './routing-method';\nexport type { ReactRouterUI } from './react-router.ui.runtime';\n\nexport * as navigation from '@teambit/base-react.navigation.link';\nexport * as ReactRouter from 'react-router-dom';\n\nexport { ReactRouterAspect };\nexport default ReactRouterAspect;\n\n// TODO - remove after releasing dependants (symphony)\nexport { /** @deprecated */ Link, /** @deprecated */ LinkProps } from '@teambit/base-ui.routing.link';\nexport { /** @deprecated */ NavLink, /** @deprecated */ NavLinkProps } from '@teambit/base-ui.routing.nav-link';\nexport {\n /** @deprecated */ RoutingProvider,\n /** @deprecated */ useRouting,\n /** @deprecated */ useLocation,\n} from '@teambit/base-ui.routing.routing-provider';\nexport {\n /** @deprecated */ LinkAnchor,\n /** @deprecated */ LinkContextProvider,\n /** @deprecated */ useLinkContext,\n} from '@teambit/ui-foundation.ui.react-router.link-anchor';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;eAVeA,gC,EAEf"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.LegacyNavProvider = LegacyNavProvider;
|
|
9
|
+
|
|
10
|
+
function _extends2() {
|
|
11
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
+
|
|
13
|
+
_extends2 = function () {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _objectWithoutProperties2() {
|
|
21
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
22
|
+
|
|
23
|
+
_objectWithoutProperties2 = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _react() {
|
|
31
|
+
const data = _interopRequireWildcard(require("react"));
|
|
32
|
+
|
|
33
|
+
_react = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _baseUiRouting() {
|
|
41
|
+
const data = require("@teambit/base-ui.routing.routing-provider");
|
|
42
|
+
|
|
43
|
+
_baseUiRouting = function () {
|
|
44
|
+
return data;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _baseReactNavigation() {
|
|
51
|
+
const data = require("@teambit/base-react.navigation.link");
|
|
52
|
+
|
|
53
|
+
_baseReactNavigation = function () {
|
|
54
|
+
return data;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
61
|
+
|
|
62
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
63
|
+
|
|
64
|
+
function useLegacyRouting() {
|
|
65
|
+
return {
|
|
66
|
+
Link: _baseReactNavigation().Link,
|
|
67
|
+
// eslint-disable-next-line react/prop-types
|
|
68
|
+
NavLink: /*#__PURE__*/(0, _react().forwardRef)(function NavLinkAdapter(_ref, ref) {
|
|
69
|
+
let {
|
|
70
|
+
isActive
|
|
71
|
+
} = _ref,
|
|
72
|
+
props = (0, _objectWithoutProperties2().default)(_ref, ["isActive"]);
|
|
73
|
+
const active = isActive === null || isActive === void 0 ? void 0 : isActive();
|
|
74
|
+
return /*#__PURE__*/_react().default.createElement(_baseReactNavigation().Link, (0, _extends2().default)({}, props, {
|
|
75
|
+
active: active,
|
|
76
|
+
ref: ref
|
|
77
|
+
}));
|
|
78
|
+
}),
|
|
79
|
+
useLocation: () => {
|
|
80
|
+
var _useLocation;
|
|
81
|
+
|
|
82
|
+
return (// @ts-ignore
|
|
83
|
+
(_useLocation = (0, _baseReactNavigation().useLocation)()) !== null && _useLocation !== void 0 ? _useLocation : {
|
|
84
|
+
pathname: '/',
|
|
85
|
+
hash: '',
|
|
86
|
+
search: ''
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function LegacyNavProvider({
|
|
94
|
+
children
|
|
95
|
+
}) {
|
|
96
|
+
const legacyRouting = useLegacyRouting();
|
|
97
|
+
return /*#__PURE__*/_react().default.createElement(_baseUiRouting().RoutingProvider, {
|
|
98
|
+
value: legacyRouting
|
|
99
|
+
}, children);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=legacy-routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useLegacyRouting","Link","NavLink","forwardRef","NavLinkAdapter","ref","isActive","props","active","useLocation","pathname","hash","search","LegacyNavProvider","children","legacyRouting"],"sources":["legacy-routing.tsx"],"sourcesContent":["import React, { PropsWithChildren, forwardRef } from 'react';\nimport { RoutingProvider, Routing } from '@teambit/base-ui.routing.routing-provider';\nimport type { NavLinkProps } from '@teambit/base-ui.routing.native-nav-link';\nimport { Link, useLocation } from '@teambit/base-react.navigation.link';\n\nfunction useLegacyRouting(): Routing {\n return {\n Link,\n // eslint-disable-next-line react/prop-types\n NavLink: forwardRef<HTMLAnchorElement, NavLinkProps>(function NavLinkAdapter({ isActive, ...props }, ref) {\n const active = isActive?.();\n return <Link {...props} active={active} ref={ref} />;\n }),\n useLocation: () =>\n // @ts-ignore\n useLocation() ?? { pathname: '/', hash: '', search: '' },\n };\n}\n\nexport function LegacyNavProvider({ children }: PropsWithChildren<{}>) {\n const legacyRouting = useLegacyRouting();\n\n return <RoutingProvider value={legacyRouting}>{children}</RoutingProvider>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAEA,SAASA,gBAAT,GAAqC;EACnC,OAAO;IACLC,IAAI,EAAJA,2BADK;IAEL;IACAC,OAAO,eAAE,IAAAC,mBAAA,EAA4C,SAASC,cAAT,OAAgDC,GAAhD,EAAqD;MAAA,IAA7B;QAAEC;MAAF,CAA6B;MAAA,IAAdC,KAAc;MACxG,MAAMC,MAAM,GAAGF,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,EAAvB;MACA,oBAAO,+BAAC,2BAAD,+BAAUC,KAAV;QAAiB,MAAM,EAAEC,MAAzB;QAAiC,GAAG,EAAEH;MAAtC,GAAP;IACD,CAHQ,CAHJ;IAOLI,WAAW,EAAE;MAAA;;MAAA,OACX;QADW,gBAEX,IAAAA,kCAAA,GAFW,uDAEM;UAAEC,QAAQ,EAAE,GAAZ;UAAiBC,IAAI,EAAE,EAAvB;UAA2BC,MAAM,EAAE;QAAnC;MAFN;IAAA;EAPR,CAAP;AAWD;;AAEM,SAASC,iBAAT,CAA2B;EAAEC;AAAF,CAA3B,EAAgE;EACrE,MAAMC,aAAa,GAAGf,gBAAgB,EAAtC;EAEA,oBAAO,+BAAC,gCAAD;IAAiB,KAAK,EAAEe;EAAxB,GAAwCD,QAAxC,CAAP;AACD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { RouteProps } from 'react-router-dom';
|
|
3
|
-
import { History, LocationListener, LocationDescriptor, Action } from 'history';
|
|
2
|
+
import type { Location, NavigationType, RouteProps } from 'react-router-dom';
|
|
4
3
|
import { SlotRegistry } from '@teambit/harmony';
|
|
5
4
|
import { RenderPlugins } from '@teambit/ui';
|
|
6
5
|
import { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
7
6
|
import { Routing } from './routing-method';
|
|
7
|
+
export declare type LocationListener = (location: Location, action: NavigationType) => void;
|
|
8
8
|
declare type RouteChangeSlot = SlotRegistry<LocationListener>;
|
|
9
9
|
declare type RenderContext = {
|
|
10
10
|
initialLocation?: string;
|
|
@@ -18,7 +18,6 @@ export declare class ReactRouterUI {
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
private routeChangeListener;
|
|
21
|
-
private routerHistory?;
|
|
22
21
|
private routingMode;
|
|
23
22
|
constructor(
|
|
24
23
|
/**
|
|
@@ -33,9 +32,6 @@ export declare class ReactRouterUI {
|
|
|
33
32
|
* render all slot routes.
|
|
34
33
|
*/
|
|
35
34
|
renderRoutes(routes: RouteProps[]): JSX.Element;
|
|
36
|
-
private unregisterListener?;
|
|
37
|
-
/** (internal method) sets the routing engine for navigation methods */
|
|
38
|
-
setRouter: (routerHistory: History) => void;
|
|
39
35
|
/** decides how navigation is stored and applied.
|
|
40
36
|
* Url - updates the `window.location.pathname`.
|
|
41
37
|
* Hash - updates `window.location.hash`.
|
|
@@ -50,12 +46,12 @@ export declare class ReactRouterUI {
|
|
|
50
46
|
/**
|
|
51
47
|
* change browser location
|
|
52
48
|
*/
|
|
53
|
-
navigateTo: (path:
|
|
49
|
+
navigateTo: (path: Location | string, action?: NavigationType | undefined) => void;
|
|
50
|
+
private navigate?;
|
|
51
|
+
private handleLocationChange;
|
|
54
52
|
private AppRoutingContext;
|
|
55
53
|
renderPlugin: RenderPlugins<RenderContext>;
|
|
56
|
-
static slots: (((registerFn: () => string) => SlotRegistry<RouteProps
|
|
57
|
-
[x: string]: string | undefined;
|
|
58
|
-
}>>) | ((registerFn: () => string) => SlotRegistry<LocationListener<unknown>>))[];
|
|
54
|
+
static slots: (((registerFn: () => string) => SlotRegistry<RouteProps>) | ((registerFn: () => string) => SlotRegistry<LocationListener>))[];
|
|
59
55
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
60
56
|
static provider(deps: any, config: any, [routeSlot, routeChangeSlot]: [RouteSlot, RouteChangeSlot]): Promise<ReactRouterUI>;
|
|
61
57
|
}
|
|
@@ -8,8 +8,6 @@ require("core-js/modules/es.promise.js");
|
|
|
8
8
|
|
|
9
9
|
require("core-js/modules/es.regexp.exec.js");
|
|
10
10
|
|
|
11
|
-
require("core-js/modules/es.string.replace.js");
|
|
12
|
-
|
|
13
11
|
Object.defineProperty(exports, "__esModule", {
|
|
14
12
|
value: true
|
|
15
13
|
});
|
|
@@ -95,6 +93,16 @@ function _routingMethod() {
|
|
|
95
93
|
return data;
|
|
96
94
|
}
|
|
97
95
|
|
|
96
|
+
function _LocationHooks() {
|
|
97
|
+
const data = require("./LocationHooks");
|
|
98
|
+
|
|
99
|
+
_LocationHooks = function () {
|
|
100
|
+
return data;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
|
|
98
106
|
class ReactRouterUI {
|
|
99
107
|
constructor(
|
|
100
108
|
/**
|
|
@@ -107,20 +115,11 @@ class ReactRouterUI {
|
|
|
107
115
|
routeChangeListener) {
|
|
108
116
|
this.routeSlot = routeSlot;
|
|
109
117
|
this.routeChangeListener = routeChangeListener;
|
|
110
|
-
(0, _defineProperty2().default)(this, "routerHistory", void 0);
|
|
111
118
|
(0, _defineProperty2().default)(this, "routingMode", _uiFoundationUi().isBrowser ? _routingMethod().Routing.url : _routingMethod().Routing.static);
|
|
112
|
-
(0, _defineProperty2().default)(this, "unregisterListener", undefined);
|
|
113
|
-
(0, _defineProperty2().default)(this, "setRouter", routerHistory => {
|
|
114
|
-
var _this$unregisterListe;
|
|
115
|
-
|
|
116
|
-
this.routerHistory = routerHistory;
|
|
117
|
-
(_this$unregisterListe = this.unregisterListener) === null || _this$unregisterListe === void 0 ? void 0 : _this$unregisterListe.call(this);
|
|
118
|
-
this.unregisterListener = routerHistory.listen((...args) => {
|
|
119
|
-
this.routeChangeListener.values().forEach(listener => listener(...args));
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
119
|
(0, _defineProperty2().default)(this, "navigateTo", (path, action) => {
|
|
123
|
-
var _this$
|
|
120
|
+
var _this$navigate, _this$navigate2;
|
|
121
|
+
|
|
122
|
+
const state = typeof path !== 'string' ? path.state : undefined;
|
|
124
123
|
|
|
125
124
|
switch (action) {
|
|
126
125
|
case 'POP':
|
|
@@ -128,14 +127,24 @@ class ReactRouterUI {
|
|
|
128
127
|
// TBD;
|
|
129
128
|
|
|
130
129
|
case 'REPLACE':
|
|
131
|
-
(_this$
|
|
130
|
+
(_this$navigate = this.navigate) === null || _this$navigate === void 0 ? void 0 : _this$navigate.call(this, path, {
|
|
131
|
+
replace: true,
|
|
132
|
+
state
|
|
133
|
+
});
|
|
132
134
|
return;
|
|
133
135
|
|
|
134
136
|
case 'PUSH':
|
|
135
137
|
default:
|
|
136
|
-
(_this$
|
|
138
|
+
(_this$navigate2 = this.navigate) === null || _this$navigate2 === void 0 ? void 0 : _this$navigate2.call(this, path, {
|
|
139
|
+
state
|
|
140
|
+
});
|
|
137
141
|
}
|
|
138
142
|
});
|
|
143
|
+
(0, _defineProperty2().default)(this, "navigate", undefined);
|
|
144
|
+
(0, _defineProperty2().default)(this, "handleLocationChange", (location, action) => {
|
|
145
|
+
const listeners = this.routeChangeListener.values();
|
|
146
|
+
listeners.forEach(listener => listener(location, action));
|
|
147
|
+
});
|
|
139
148
|
(0, _defineProperty2().default)(this, "AppRoutingContext", ({
|
|
140
149
|
children,
|
|
141
150
|
renderCtx
|
|
@@ -144,7 +153,10 @@ class ReactRouterUI {
|
|
|
144
153
|
reactRouterUi: this,
|
|
145
154
|
routing: this.routingMode,
|
|
146
155
|
location: renderCtx === null || renderCtx === void 0 ? void 0 : renderCtx.initialLocation
|
|
147
|
-
}, children)
|
|
156
|
+
}, children, /*#__PURE__*/_react().default.createElement(_LocationHooks().LocationHooks, {
|
|
157
|
+
onLocationChange: this.handleLocationChange,
|
|
158
|
+
onNavigatorChange: nav => this.navigate = nav
|
|
159
|
+
}));
|
|
148
160
|
});
|
|
149
161
|
(0, _defineProperty2().default)(this, "renderPlugin", {
|
|
150
162
|
browserInit: () => {
|
|
@@ -175,12 +187,13 @@ class ReactRouterUI {
|
|
|
175
187
|
rootRoutes: routes
|
|
176
188
|
});
|
|
177
189
|
}
|
|
178
|
-
|
|
179
190
|
/** decides how navigation is stored and applied.
|
|
180
191
|
* Url - updates the `window.location.pathname`.
|
|
181
192
|
* Hash - updates `window.location.hash`.
|
|
182
193
|
* InMemory - store state internally and don't update the browser.
|
|
183
194
|
*/
|
|
195
|
+
|
|
196
|
+
|
|
184
197
|
setRoutingMode(routing) {
|
|
185
198
|
this.routingMode = routing;
|
|
186
199
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ReactRouterUI","constructor","routeSlot","routeChangeListener","isBrowser","Routing","url","static","
|
|
1
|
+
{"version":3,"names":["ReactRouterUI","constructor","routeSlot","routeChangeListener","isBrowser","Routing","url","static","path","action","state","undefined","navigate","replace","location","listeners","values","forEach","listener","children","renderCtx","routingMode","initialLocation","handleLocationChange","nav","browserInit","window","pathname","search","hash","serverInit","browser","reactContext","AppRoutingContext","renderRoutes","routes","setRoutingMode","routing","register","route","registerListener","provider","deps","config","routeChangeSlot","Slot","withType","UIRuntime","ReactRouterAspect","addRuntime"],"sources":["react-router.ui.runtime.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { NavigateFunction } from 'react-router-dom';\nimport type { Location, NavigationType, RouteProps } from 'react-router-dom';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { RenderPlugins, UIRuntime } from '@teambit/ui';\nimport { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';\nimport { isBrowser } from '@teambit/ui-foundation.ui.is-browser';\n\nimport { ReactRouterAspect } from './react-router.aspect';\nimport { RouteContext, RootRoute } from './route-context';\nimport { Routing } from './routing-method';\nimport { LocationHooks } from './LocationHooks';\n\nexport type LocationListener = (location: Location, action: NavigationType) => void;\ntype RouteChangeSlot = SlotRegistry<LocationListener>;\ntype RenderContext = { initialLocation?: string };\n\nexport class ReactRouterUI {\n private routingMode = isBrowser ? Routing.url : Routing.static;\n\n constructor(\n /**\n * route slot.\n */\n private routeSlot: RouteSlot,\n /**\n *\n */\n private routeChangeListener: RouteChangeSlot\n ) {}\n\n /**\n * render all slot routes.\n */\n renderRoutes(routes: RouteProps[]) {\n return <RootRoute routeSlot={this.routeSlot} rootRoutes={routes} />;\n }\n\n /** decides how navigation is stored and applied.\n * Url - updates the `window.location.pathname`.\n * Hash - updates `window.location.hash`.\n * InMemory - store state internally and don't update the browser.\n */\n setRoutingMode(routing: Routing) {\n this.routingMode = routing;\n }\n\n /**\n * register a new route.\n */\n register(route: RouteProps) {\n this.routeSlot.register(route);\n return this;\n }\n\n registerListener(listener: LocationListener) {\n this.routeChangeListener.register(listener);\n }\n\n /**\n * change browser location\n */\n navigateTo = (\n /** destination */\n path: Location | string,\n /** history action to execute (pop / push / replace) */\n action?: NavigationType\n ) => {\n const state = typeof path !== 'string' ? path.state : undefined;\n\n switch (action) {\n case 'POP':\n return; // TBD;\n case 'REPLACE':\n this.navigate?.(path, { replace: true, state });\n return;\n case 'PUSH':\n default:\n this.navigate?.(path, { state });\n }\n };\n\n private navigate?: NavigateFunction = undefined;\n\n private handleLocationChange = (location: Location, action: NavigationType) => {\n const listeners = this.routeChangeListener.values();\n listeners.forEach((listener) => listener(location, action));\n };\n\n private AppRoutingContext = ({ children, renderCtx }: { children: ReactNode; renderCtx?: RenderContext }) => {\n return (\n <RouteContext reactRouterUi={this} routing={this.routingMode} location={renderCtx?.initialLocation}>\n {children}\n <LocationHooks\n onLocationChange={this.handleLocationChange}\n onNavigatorChange={(nav) => (this.navigate = nav)}\n />\n </RouteContext>\n );\n };\n\n public renderPlugin: RenderPlugins<RenderContext> = {\n browserInit: () => {\n const initialLocation = `${window.location.pathname}${window.location.search}${window.location.hash}`;\n return { initialLocation };\n },\n serverInit: ({ browser }) => {\n const initialLocation = browser?.location.url;\n return { initialLocation };\n },\n reactContext: this.AppRoutingContext,\n };\n\n static slots = [Slot.withType<RouteProps>(), Slot.withType<LocationListener>()];\n static runtime = UIRuntime;\n\n static async provider(deps, config, [routeSlot, routeChangeSlot]: [RouteSlot, RouteChangeSlot]) {\n return new ReactRouterUI(routeSlot, routeChangeSlot);\n }\n}\n\nReactRouterAspect.addRuntime(ReactRouterUI);\n"],"mappings":"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"}
|
package/dist/route-context.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { RouteProps
|
|
2
|
+
import { RouteProps } from 'react-router-dom';
|
|
3
3
|
import { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
4
4
|
import { ReactRouterUI } from './react-router.ui.runtime';
|
|
5
5
|
import { Routing } from './routing-method';
|
|
6
|
-
export declare type History = ReturnType<typeof useHistory>;
|
|
7
6
|
declare type RouterContextProps = {
|
|
8
7
|
reactRouterUi: ReactRouterUI;
|
|
9
8
|
routing?: Routing;
|
|
@@ -17,6 +16,6 @@ declare type RootRouteProps = {
|
|
|
17
16
|
/**
|
|
18
17
|
* Setup context needed for routing.
|
|
19
18
|
*/
|
|
20
|
-
export declare function RouteContext({
|
|
19
|
+
export declare function RouteContext({ routing, children, location }: RouterContextProps): JSX.Element;
|
|
21
20
|
export declare function RootRoute({ rootRoutes, routeSlot }: RootRouteProps): JSX.Element;
|
|
22
21
|
export {};
|
package/dist/route-context.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -7,7 +9,7 @@ exports.RootRoute = RootRoute;
|
|
|
7
9
|
exports.RouteContext = RouteContext;
|
|
8
10
|
|
|
9
11
|
function _react() {
|
|
10
|
-
const data =
|
|
12
|
+
const data = _interopRequireDefault(require("react"));
|
|
11
13
|
|
|
12
14
|
_react = function () {
|
|
13
15
|
return data;
|
|
@@ -26,10 +28,10 @@ function _reactRouterDom() {
|
|
|
26
28
|
return data;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
function
|
|
30
|
-
const data = require("
|
|
31
|
+
function _server() {
|
|
32
|
+
const data = require("react-router-dom/server");
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
_server = function () {
|
|
33
35
|
return data;
|
|
34
36
|
};
|
|
35
37
|
|
|
@@ -46,10 +48,20 @@ function _uiFoundationUiReactRouter() {
|
|
|
46
48
|
return data;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
function
|
|
50
|
-
const data = require("
|
|
51
|
+
function _baseReactNavigation() {
|
|
52
|
+
const data = require("@teambit/base-react.navigation.link");
|
|
53
|
+
|
|
54
|
+
_baseReactNavigation = function () {
|
|
55
|
+
return data;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _uiFoundationUiNavigation() {
|
|
62
|
+
const data = require("@teambit/ui-foundation.ui.navigation.react-router-adapter");
|
|
51
63
|
|
|
52
|
-
|
|
64
|
+
_uiFoundationUiNavigation = function () {
|
|
53
65
|
return data;
|
|
54
66
|
};
|
|
55
67
|
|
|
@@ -66,31 +78,30 @@ function _routingMethod() {
|
|
|
66
78
|
return data;
|
|
67
79
|
}
|
|
68
80
|
|
|
69
|
-
function
|
|
81
|
+
function _legacyRouting() {
|
|
82
|
+
const data = require("./legacy-routing");
|
|
70
83
|
|
|
71
|
-
|
|
84
|
+
_legacyRouting = function () {
|
|
85
|
+
return data;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return data;
|
|
89
|
+
}
|
|
72
90
|
|
|
73
91
|
/**
|
|
74
92
|
* Setup context needed for routing.
|
|
75
93
|
*/
|
|
76
94
|
function RouteContext({
|
|
77
|
-
reactRouterUi,
|
|
78
95
|
routing = _routingMethod().Routing.url,
|
|
79
96
|
children,
|
|
80
97
|
location
|
|
81
98
|
}) {
|
|
82
|
-
return (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}, /*#__PURE__*/_react().default.createElement(HistoryGetter, {
|
|
89
|
-
onRouterChange: reactRouterUi.setRouter
|
|
90
|
-
}), /*#__PURE__*/_react().default.createElement(_baseUiRouting().RoutingProvider, {
|
|
91
|
-
value: _reactRouterRouting().reactRouterRouting
|
|
92
|
-
}, children))
|
|
93
|
-
);
|
|
99
|
+
return /*#__PURE__*/_react().default.createElement(Router, {
|
|
100
|
+
type: routing,
|
|
101
|
+
location: location
|
|
102
|
+
}, /*#__PURE__*/_react().default.createElement(_baseReactNavigation().NavigationProvider, {
|
|
103
|
+
implementation: _uiFoundationUiNavigation().reactRouterAdapter
|
|
104
|
+
}, /*#__PURE__*/_react().default.createElement(_legacyRouting().LegacyNavProvider, null, children)));
|
|
94
105
|
}
|
|
95
106
|
|
|
96
107
|
function RootRoute({
|
|
@@ -112,8 +123,8 @@ function Router({
|
|
|
112
123
|
}) {
|
|
113
124
|
switch (type) {
|
|
114
125
|
case _routingMethod().Routing.static:
|
|
115
|
-
return /*#__PURE__*/_react().default.createElement(
|
|
116
|
-
location: location
|
|
126
|
+
return /*#__PURE__*/_react().default.createElement(_server().StaticRouter, {
|
|
127
|
+
location: location || '/'
|
|
117
128
|
}, children);
|
|
118
129
|
|
|
119
130
|
case _routingMethod().Routing.inMemory:
|
|
@@ -132,19 +143,5 @@ function Router({
|
|
|
132
143
|
return /*#__PURE__*/_react().default.createElement(_reactRouterDom().BrowserRouter, null, children);
|
|
133
144
|
}
|
|
134
145
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Calls onRouterChange when routing History object changes.
|
|
137
|
-
* Used to inject history back into reactRouterUi
|
|
138
|
-
* (needs to be rendered inside of <BrowserRouter/>)
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
function HistoryGetter({
|
|
143
|
-
onRouterChange
|
|
144
|
-
}) {
|
|
145
|
-
const history = (0, _reactRouterDom().useHistory)();
|
|
146
|
-
(0, _react().useEffect)(() => onRouterChange(history), [history]);
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
146
|
|
|
150
147
|
//# sourceMappingURL=route-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RouteContext","
|
|
1
|
+
{"version":3,"names":["RouteContext","routing","Routing","url","children","location","reactRouterAdapter","RootRoute","rootRoutes","routeSlot","Router","type","static","inMemory","hash"],"sources":["route-context.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { BrowserRouter, MemoryRouter, HashRouter, RouteProps } from 'react-router-dom';\nimport { StaticRouter } from 'react-router-dom/server';\nimport { RouteSlot, SlotRouter } from '@teambit/ui-foundation.ui.react-router.slot-router';\nimport { NavigationProvider } from '@teambit/base-react.navigation.link';\nimport { reactRouterAdapter } from '@teambit/ui-foundation.ui.navigation.react-router-adapter';\nimport { ReactRouterUI } from './react-router.ui.runtime';\nimport { Routing } from './routing-method';\nimport { LegacyNavProvider } from './legacy-routing';\n\ntype RouterContextProps = {\n reactRouterUi: ReactRouterUI;\n routing?: Routing;\n children: ReactNode;\n location?: string;\n};\n\ntype RootRouteProps = {\n rootRoutes: RouteProps[];\n routeSlot: RouteSlot;\n};\n\n/**\n * Setup context needed for routing.\n */\nexport function RouteContext({ routing = Routing.url, children, location }: RouterContextProps) {\n return (\n <Router type={routing} location={location}>\n <NavigationProvider implementation={reactRouterAdapter}>\n <LegacyNavProvider>\n {/* route tree root: */}\n {children}\n </LegacyNavProvider>\n </NavigationProvider>\n </Router>\n );\n}\n\nexport function RootRoute({ rootRoutes, routeSlot }: RootRouteProps) {\n return <SlotRouter slot={routeSlot} rootRoutes={rootRoutes} />;\n}\n\n/** provides the router engine (browser, inMemory, etc) */\nfunction Router({ type, children, location }: { type: Routing; children: ReactNode; location?: string }) {\n switch (type) {\n case Routing.static:\n return <StaticRouter location={location || '/'}>{children}</StaticRouter>;\n case Routing.inMemory:\n return (\n <MemoryRouter initialEntries={[location || '/']} initialIndex={1}>\n {children}\n </MemoryRouter>\n );\n case Routing.hash:\n // @ts-ignore - https://github.com/teambit/bit/issues/5746\n return <HashRouter>{children}</HashRouter>;\n case Routing.url:\n default:\n // @ts-ignore - https://github.com/teambit/bit/issues/5746\n return <BrowserRouter>{children}</BrowserRouter>;\n }\n}\n"],"mappings":";;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAcA;AACA;AACA;AACO,SAASA,YAAT,CAAsB;EAAEC,OAAO,GAAGC,wBAAA,CAAQC,GAApB;EAAyBC,QAAzB;EAAmCC;AAAnC,CAAtB,EAAyF;EAC9F,oBACE,+BAAC,MAAD;IAAQ,IAAI,EAAEJ,OAAd;IAAuB,QAAQ,EAAEI;EAAjC,gBACE,+BAAC,yCAAD;IAAoB,cAAc,EAAEC;EAApC,gBACE,+BAAC,kCAAD,QAEGF,QAFH,CADF,CADF,CADF;AAUD;;AAEM,SAASG,SAAT,CAAmB;EAAEC,UAAF;EAAcC;AAAd,CAAnB,EAA8D;EACnE,oBAAO,+BAAC,uCAAD;IAAY,IAAI,EAAEA,SAAlB;IAA6B,UAAU,EAAED;EAAzC,EAAP;AACD;AAED;;;AACA,SAASE,MAAT,CAAgB;EAAEC,IAAF;EAAQP,QAAR;EAAkBC;AAAlB,CAAhB,EAAyG;EACvG,QAAQM,IAAR;IACE,KAAKT,wBAAA,CAAQU,MAAb;MACE,oBAAO,+BAAC,sBAAD;QAAc,QAAQ,EAAEP,QAAQ,IAAI;MAApC,GAA0CD,QAA1C,CAAP;;IACF,KAAKF,wBAAA,CAAQW,QAAb;MACE,oBACE,+BAAC,8BAAD;QAAc,cAAc,EAAE,CAACR,QAAQ,IAAI,GAAb,CAA9B;QAAiD,YAAY,EAAE;MAA/D,GACGD,QADH,CADF;;IAKF,KAAKF,wBAAA,CAAQY,IAAb;MACE;MACA,oBAAO,+BAAC,4BAAD,QAAaV,QAAb,CAAP;;IACF,KAAKF,wBAAA,CAAQC,GAAb;IACA;MACE;MACA,oBAAO,+BAAC,+BAAD,QAAgBC,QAAhB,CAAP;EAfJ;AAiBD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { PropsWithChildren, forwardRef } from 'react';
|
|
2
|
+
import { RoutingProvider, Routing } from '@teambit/base-ui.routing.routing-provider';
|
|
3
|
+
import type { NavLinkProps } from '@teambit/base-ui.routing.native-nav-link';
|
|
4
|
+
import { Link, useLocation } from '@teambit/base-react.navigation.link';
|
|
5
|
+
|
|
6
|
+
function useLegacyRouting(): Routing {
|
|
7
|
+
return {
|
|
8
|
+
Link,
|
|
9
|
+
// eslint-disable-next-line react/prop-types
|
|
10
|
+
NavLink: forwardRef<HTMLAnchorElement, NavLinkProps>(function NavLinkAdapter({ isActive, ...props }, ref) {
|
|
11
|
+
const active = isActive?.();
|
|
12
|
+
return <Link {...props} active={active} ref={ref} />;
|
|
13
|
+
}),
|
|
14
|
+
useLocation: () =>
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
useLocation() ?? { pathname: '/', hash: '', search: '' },
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function LegacyNavProvider({ children }: PropsWithChildren<{}>) {
|
|
21
|
+
const legacyRouting = useLegacyRouting();
|
|
22
|
+
|
|
23
|
+
return <RoutingProvider value={legacyRouting}>{children}</RoutingProvider>;
|
|
24
|
+
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/react-router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.746",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/ui-foundation/react-router",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.ui-foundation",
|
|
8
8
|
"name": "react-router",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.746"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"react-router": "5.2.0",
|
|
13
|
-
"history": "4.10.1",
|
|
14
|
-
"react-router-dom": "5.2.0",
|
|
15
12
|
"@babel/runtime": "7.12.18",
|
|
16
13
|
"core-js": "^3.0.0",
|
|
14
|
+
"@teambit/base-react.navigation.link": "2.0.27",
|
|
17
15
|
"@teambit/base-ui.routing.link": "1.0.0",
|
|
18
16
|
"@teambit/base-ui.routing.nav-link": "1.0.0",
|
|
19
17
|
"@teambit/base-ui.routing.routing-provider": "1.0.0",
|
|
18
|
+
"@teambit/base-ui.routing.native-nav-link": "1.0.0",
|
|
20
19
|
"@teambit/harmony": "0.3.3",
|
|
20
|
+
"@teambit/ui-foundation.ui.navigation.react-router-adapter": "6.1.1",
|
|
21
21
|
"@teambit/ui-foundation.ui.react-router.link-anchor": "0.0.123",
|
|
22
22
|
"@teambit/ui-foundation.ui.is-browser": "0.0.486",
|
|
23
|
-
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.
|
|
24
|
-
"@teambit/ui": "0.0.
|
|
25
|
-
"@teambit/ui-foundation.ui.react-router.link": "0.0.489",
|
|
26
|
-
"@teambit/ui-foundation.ui.react-router.nav-link": "0.0.489"
|
|
23
|
+
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.490",
|
|
24
|
+
"@teambit/ui": "0.0.746"
|
|
27
25
|
},
|
|
28
26
|
"devDependencies": {
|
|
29
27
|
"@types/react": "^17.0.8",
|
|
30
|
-
"@types/history": "4.7.8",
|
|
31
|
-
"@types/react-router-dom": "5.1.7",
|
|
32
28
|
"@types/mocha": "9.1.0",
|
|
33
29
|
"@types/testing-library__jest-dom": "5.9.5",
|
|
34
30
|
"@types/jest": "^26.0.0",
|
|
@@ -36,6 +32,7 @@
|
|
|
36
32
|
"@types/node": "12.20.4"
|
|
37
33
|
},
|
|
38
34
|
"peerDependencies": {
|
|
35
|
+
"react-router-dom": "^6.0.0",
|
|
39
36
|
"@teambit/legacy": "1.0.273",
|
|
40
37
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
41
38
|
"react": "^16.8.0 || ^17.0.0"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.ui-foundation_react-router@0.0.
|
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.ui-foundation_react-router@0.0.
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.ui-foundation_react-router@0.0.746/dist/react-router.composition.js')]
|
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.ui-foundation_react-router@0.0.746/dist/react-router.docs.mdx')]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { NavigateFunction } from 'react-router-dom';
|
|
3
|
+
import type { Location, NavigationType, RouteProps } from 'react-router-dom';
|
|
4
4
|
import { Slot, SlotRegistry } from '@teambit/harmony';
|
|
5
5
|
import { RenderPlugins, UIRuntime } from '@teambit/ui';
|
|
6
6
|
import { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
@@ -9,12 +9,13 @@ import { isBrowser } from '@teambit/ui-foundation.ui.is-browser';
|
|
|
9
9
|
import { ReactRouterAspect } from './react-router.aspect';
|
|
10
10
|
import { RouteContext, RootRoute } from './route-context';
|
|
11
11
|
import { Routing } from './routing-method';
|
|
12
|
+
import { LocationHooks } from './LocationHooks';
|
|
12
13
|
|
|
14
|
+
export type LocationListener = (location: Location, action: NavigationType) => void;
|
|
13
15
|
type RouteChangeSlot = SlotRegistry<LocationListener>;
|
|
14
16
|
type RenderContext = { initialLocation?: string };
|
|
15
17
|
|
|
16
18
|
export class ReactRouterUI {
|
|
17
|
-
private routerHistory?: History;
|
|
18
19
|
private routingMode = isBrowser ? Routing.url : Routing.static;
|
|
19
20
|
|
|
20
21
|
constructor(
|
|
@@ -35,17 +36,6 @@ export class ReactRouterUI {
|
|
|
35
36
|
return <RootRoute routeSlot={this.routeSlot} rootRoutes={routes} />;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
private unregisterListener?: UnregisterCallback = undefined;
|
|
39
|
-
/** (internal method) sets the routing engine for navigation methods */
|
|
40
|
-
setRouter = (routerHistory: History) => {
|
|
41
|
-
this.routerHistory = routerHistory;
|
|
42
|
-
|
|
43
|
-
this.unregisterListener?.();
|
|
44
|
-
this.unregisterListener = routerHistory.listen((...args) => {
|
|
45
|
-
this.routeChangeListener.values().forEach((listener) => listener(...args));
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
39
|
/** decides how navigation is stored and applied.
|
|
50
40
|
* Url - updates the `window.location.pathname`.
|
|
51
41
|
* Hash - updates `window.location.hash`.
|
|
@@ -72,26 +62,39 @@ export class ReactRouterUI {
|
|
|
72
62
|
*/
|
|
73
63
|
navigateTo = (
|
|
74
64
|
/** destination */
|
|
75
|
-
path:
|
|
65
|
+
path: Location | string,
|
|
76
66
|
/** history action to execute (pop / push / replace) */
|
|
77
|
-
action?:
|
|
67
|
+
action?: NavigationType
|
|
78
68
|
) => {
|
|
69
|
+
const state = typeof path !== 'string' ? path.state : undefined;
|
|
70
|
+
|
|
79
71
|
switch (action) {
|
|
80
72
|
case 'POP':
|
|
81
73
|
return; // TBD;
|
|
82
74
|
case 'REPLACE':
|
|
83
|
-
this.
|
|
75
|
+
this.navigate?.(path, { replace: true, state });
|
|
84
76
|
return;
|
|
85
77
|
case 'PUSH':
|
|
86
78
|
default:
|
|
87
|
-
this.
|
|
79
|
+
this.navigate?.(path, { state });
|
|
88
80
|
}
|
|
89
81
|
};
|
|
90
82
|
|
|
83
|
+
private navigate?: NavigateFunction = undefined;
|
|
84
|
+
|
|
85
|
+
private handleLocationChange = (location: Location, action: NavigationType) => {
|
|
86
|
+
const listeners = this.routeChangeListener.values();
|
|
87
|
+
listeners.forEach((listener) => listener(location, action));
|
|
88
|
+
};
|
|
89
|
+
|
|
91
90
|
private AppRoutingContext = ({ children, renderCtx }: { children: ReactNode; renderCtx?: RenderContext }) => {
|
|
92
91
|
return (
|
|
93
92
|
<RouteContext reactRouterUi={this} routing={this.routingMode} location={renderCtx?.initialLocation}>
|
|
94
93
|
{children}
|
|
94
|
+
<LocationHooks
|
|
95
|
+
onLocationChange={this.handleLocationChange}
|
|
96
|
+
onNavigatorChange={(nav) => (this.navigate = nav)}
|
|
97
|
+
/>
|
|
95
98
|
</RouteContext>
|
|
96
99
|
);
|
|
97
100
|
};
|
package/route-context.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { BrowserRouter,
|
|
3
|
-
import {
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { BrowserRouter, MemoryRouter, HashRouter, RouteProps } from 'react-router-dom';
|
|
3
|
+
import { StaticRouter } from 'react-router-dom/server';
|
|
4
4
|
import { RouteSlot, SlotRouter } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
5
|
+
import { NavigationProvider } from '@teambit/base-react.navigation.link';
|
|
6
|
+
import { reactRouterAdapter } from '@teambit/ui-foundation.ui.navigation.react-router-adapter';
|
|
5
7
|
import { ReactRouterUI } from './react-router.ui.runtime';
|
|
6
|
-
import { reactRouterRouting } from './react-router-routing';
|
|
7
8
|
import { Routing } from './routing-method';
|
|
8
|
-
|
|
9
|
-
export type History = ReturnType<typeof useHistory>;
|
|
9
|
+
import { LegacyNavProvider } from './legacy-routing';
|
|
10
10
|
|
|
11
11
|
type RouterContextProps = {
|
|
12
12
|
reactRouterUi: ReactRouterUI;
|
|
@@ -23,17 +23,15 @@ type RootRouteProps = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Setup context needed for routing.
|
|
25
25
|
*/
|
|
26
|
-
export function RouteContext({
|
|
26
|
+
export function RouteContext({ routing = Routing.url, children, location }: RouterContextProps) {
|
|
27
27
|
return (
|
|
28
|
-
// {/* set up the virtual router (browser, inMemory, etc) */}
|
|
29
28
|
<Router type={routing} location={location}>
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</RoutingProvider>
|
|
29
|
+
<NavigationProvider implementation={reactRouterAdapter}>
|
|
30
|
+
<LegacyNavProvider>
|
|
31
|
+
{/* route tree root: */}
|
|
32
|
+
{children}
|
|
33
|
+
</LegacyNavProvider>
|
|
34
|
+
</NavigationProvider>
|
|
37
35
|
</Router>
|
|
38
36
|
);
|
|
39
37
|
}
|
|
@@ -46,7 +44,7 @@ export function RootRoute({ rootRoutes, routeSlot }: RootRouteProps) {
|
|
|
46
44
|
function Router({ type, children, location }: { type: Routing; children: ReactNode; location?: string }) {
|
|
47
45
|
switch (type) {
|
|
48
46
|
case Routing.static:
|
|
49
|
-
return <StaticRouter location={location}>{children}</StaticRouter>;
|
|
47
|
+
return <StaticRouter location={location || '/'}>{children}</StaticRouter>;
|
|
50
48
|
case Routing.inMemory:
|
|
51
49
|
return (
|
|
52
50
|
<MemoryRouter initialEntries={[location || '/']} initialIndex={1}>
|
|
@@ -62,15 +60,3 @@ function Router({ type, children, location }: { type: Routing; children: ReactNo
|
|
|
62
60
|
return <BrowserRouter>{children}</BrowserRouter>;
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Calls onRouterChange when routing History object changes.
|
|
68
|
-
* Used to inject history back into reactRouterUi
|
|
69
|
-
* (needs to be rendered inside of <BrowserRouter/>)
|
|
70
|
-
*/
|
|
71
|
-
function HistoryGetter({ onRouterChange }: { onRouterChange: (routerHistory: History) => void }) {
|
|
72
|
-
const history = useHistory();
|
|
73
|
-
useEffect(() => onRouterChange(history), [history]);
|
|
74
|
-
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { reactRouterRouting } from './react-router-routing';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "reactRouterRouting", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _reactRouterRouting().reactRouterRouting;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
function _reactRouterRouting() {
|
|
14
|
-
const data = require("./react-router-routing");
|
|
15
|
-
|
|
16
|
-
_reactRouterRouting = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { reactRouterRouting } from './react-router-routing';\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useLocation } from 'react-router-dom';
|
|
2
|
-
import { Link } from '@teambit/ui-foundation.ui.react-router.link';
|
|
3
|
-
import { NavLink } from '@teambit/ui-foundation.ui.react-router.nav-link';
|
|
4
|
-
/**
|
|
5
|
-
* defines react-router's routing components (link, useLocation, etc)
|
|
6
|
-
*/
|
|
7
|
-
export declare const reactRouterRouting: {
|
|
8
|
-
Link: typeof Link;
|
|
9
|
-
NavLink: typeof NavLink;
|
|
10
|
-
useLocation: typeof useLocation;
|
|
11
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.reactRouterRouting = void 0;
|
|
7
|
-
|
|
8
|
-
function _reactRouterDom() {
|
|
9
|
-
const data = require("react-router-dom");
|
|
10
|
-
|
|
11
|
-
_reactRouterDom = function () {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function _uiFoundationUiReactRouter() {
|
|
19
|
-
const data = require("@teambit/ui-foundation.ui.react-router.link");
|
|
20
|
-
|
|
21
|
-
_uiFoundationUiReactRouter = function () {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _uiFoundationUiReactRouter2() {
|
|
29
|
-
const data = require("@teambit/ui-foundation.ui.react-router.nav-link");
|
|
30
|
-
|
|
31
|
-
_uiFoundationUiReactRouter2 = function () {
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line no-restricted-imports
|
|
39
|
-
// eslint-disable-next-line no-restricted-imports
|
|
40
|
-
// React Router Link and NavLink are internal implementations of our isomorphic routing components.
|
|
41
|
-
// do not use them, use @teambit/base-ui.routing.link and @teambit/base-ui.routing.nav-link instead
|
|
42
|
-
//
|
|
43
|
-
// here we define them as the routing components of the application.
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* defines react-router's routing components (link, useLocation, etc)
|
|
47
|
-
*/
|
|
48
|
-
const reactRouterRouting = {
|
|
49
|
-
Link: _uiFoundationUiReactRouter().Link,
|
|
50
|
-
NavLink: _uiFoundationUiReactRouter2().NavLink,
|
|
51
|
-
useLocation: _reactRouterDom().useLocation
|
|
52
|
-
};
|
|
53
|
-
exports.reactRouterRouting = reactRouterRouting;
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=react-router-routing.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["reactRouterRouting","Link","NavLink","useLocation"],"sources":["react-router-routing.tsx"],"sourcesContent":["import { useLocation } from 'react-router-dom';\n// eslint-disable-next-line no-restricted-imports\nimport { Link } from '@teambit/ui-foundation.ui.react-router.link';\n// eslint-disable-next-line no-restricted-imports\nimport { NavLink } from '@teambit/ui-foundation.ui.react-router.nav-link';\n\n// React Router Link and NavLink are internal implementations of our isomorphic routing components.\n// do not use them, use @teambit/base-ui.routing.link and @teambit/base-ui.routing.nav-link instead\n//\n// here we define them as the routing components of the application.\n\n/**\n * defines react-router's routing components (link, useLocation, etc)\n */\nexport const reactRouterRouting = { Link, NavLink, useLocation };\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAHA;AAEA;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAG;EAAEC,IAAI,EAAJA,iCAAF;EAAQC,OAAO,EAAPA,qCAAR;EAAiBC,WAAW,EAAXA;AAAjB,CAA3B"}
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { reactRouterRouting } from './react-router-routing';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useLocation } from 'react-router-dom';
|
|
2
|
-
// eslint-disable-next-line no-restricted-imports
|
|
3
|
-
import { Link } from '@teambit/ui-foundation.ui.react-router.link';
|
|
4
|
-
// eslint-disable-next-line no-restricted-imports
|
|
5
|
-
import { NavLink } from '@teambit/ui-foundation.ui.react-router.nav-link';
|
|
6
|
-
|
|
7
|
-
// React Router Link and NavLink are internal implementations of our isomorphic routing components.
|
|
8
|
-
// do not use them, use @teambit/base-ui.routing.link and @teambit/base-ui.routing.nav-link instead
|
|
9
|
-
//
|
|
10
|
-
// here we define them as the routing components of the application.
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* defines react-router's routing components (link, useLocation, etc)
|
|
14
|
-
*/
|
|
15
|
-
export const reactRouterRouting = { Link, NavLink, useLocation };
|