@teambit/react-router 0.0.647 → 0.0.651
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/{__preview-1644549681149.js → __preview-1645365357220.js} +0 -0
- package/dist/react-router.ui.runtime.d.ts +6 -7
- package/dist/react-router.ui.runtime.js +29 -16
- package/dist/react-router.ui.runtime.js.map +1 -1
- package/package-tar/teambit-react-router-0.0.651.tgz +0 -0
- package/package.json +12 -12
- package/react-router.ui.runtime.tsx +25 -30
- package/package-tar/teambit-react-router-0.0.647.tgz +0 -0
|
File without changes
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import { RouteProps } from 'react-router-dom';
|
|
3
3
|
import { History, LocationListener, LocationDescriptor, Action } from 'history';
|
|
4
4
|
import { SlotRegistry } from '@teambit/harmony';
|
|
5
|
+
import { RenderPlugins } from '@teambit/ui';
|
|
5
6
|
import { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
6
7
|
import { Routing } from './routing-method';
|
|
7
8
|
declare type RouteChangeSlot = SlotRegistry<LocationListener>;
|
|
8
|
-
declare type
|
|
9
|
+
declare type RenderContext = {
|
|
9
10
|
initialLocation?: string;
|
|
10
11
|
};
|
|
11
12
|
export declare class ReactRouterUI {
|
|
@@ -31,7 +32,7 @@ export declare class ReactRouterUI {
|
|
|
31
32
|
/**
|
|
32
33
|
* render all slot routes.
|
|
33
34
|
*/
|
|
34
|
-
renderRoutes(routes: RouteProps[]
|
|
35
|
+
renderRoutes(routes: RouteProps[]): JSX.Element;
|
|
35
36
|
private unregisterListener?;
|
|
36
37
|
/** (internal method) sets the routing engine for navigation methods */
|
|
37
38
|
setRouter: (routerHistory: History) => void;
|
|
@@ -49,11 +50,9 @@ export declare class ReactRouterUI {
|
|
|
49
50
|
/**
|
|
50
51
|
* change browser location
|
|
51
52
|
*/
|
|
52
|
-
navigateTo: (path: LocationDescriptor, action?:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*/
|
|
56
|
-
private legacyNavigateTo;
|
|
53
|
+
navigateTo: (path: LocationDescriptor, action?: Action | undefined) => void;
|
|
54
|
+
private AppRoutingContext;
|
|
55
|
+
renderPlugin: RenderPlugins<RenderContext>;
|
|
57
56
|
static slots: (((registerFn: () => string) => SlotRegistry<RouteProps<string, {
|
|
58
57
|
[x: string]: string | undefined;
|
|
59
58
|
}>>) | ((registerFn: () => string) => SlotRegistry<LocationListener<unknown>>))[];
|
|
@@ -122,11 +122,6 @@ class ReactRouterUI {
|
|
|
122
122
|
(0, _defineProperty2().default)(this, "navigateTo", (path, action) => {
|
|
123
123
|
var _this$routerHistory, _this$routerHistory2;
|
|
124
124
|
|
|
125
|
-
if (typeof action !== 'string') {
|
|
126
|
-
this.legacyNavigateTo(path, action);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
125
|
switch (action) {
|
|
131
126
|
case 'POP':
|
|
132
127
|
return;
|
|
@@ -141,10 +136,32 @@ class ReactRouterUI {
|
|
|
141
136
|
(_this$routerHistory2 = this.routerHistory) === null || _this$routerHistory2 === void 0 ? void 0 : _this$routerHistory2.push(path);
|
|
142
137
|
}
|
|
143
138
|
});
|
|
144
|
-
(0, _defineProperty2().default)(this, "
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
(0, _defineProperty2().default)(this, "AppRoutingContext", ({
|
|
140
|
+
children,
|
|
141
|
+
renderCtx
|
|
142
|
+
}) => {
|
|
143
|
+
return /*#__PURE__*/_react().default.createElement(_routeContext().RouteContext, {
|
|
144
|
+
reactRouterUi: this,
|
|
145
|
+
routing: this.routingMode,
|
|
146
|
+
location: renderCtx === null || renderCtx === void 0 ? void 0 : renderCtx.initialLocation
|
|
147
|
+
}, children);
|
|
148
|
+
});
|
|
149
|
+
(0, _defineProperty2().default)(this, "renderPlugin", {
|
|
150
|
+
browserInit: () => {
|
|
151
|
+
const initialLocation = `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
152
|
+
return {
|
|
153
|
+
initialLocation
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
serverInit: ({
|
|
157
|
+
browser
|
|
158
|
+
}) => {
|
|
159
|
+
const initialLocation = browser === null || browser === void 0 ? void 0 : browser.location.url;
|
|
160
|
+
return {
|
|
161
|
+
initialLocation
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
reactContext: this.AppRoutingContext
|
|
148
165
|
});
|
|
149
166
|
}
|
|
150
167
|
/**
|
|
@@ -152,15 +169,11 @@ class ReactRouterUI {
|
|
|
152
169
|
*/
|
|
153
170
|
|
|
154
171
|
|
|
155
|
-
renderRoutes(routes
|
|
156
|
-
return /*#__PURE__*/_react().default.createElement(_routeContext().
|
|
157
|
-
reactRouterUi: this,
|
|
158
|
-
routing: this.routingMode,
|
|
159
|
-
location: options.initialLocation
|
|
160
|
-
}, /*#__PURE__*/_react().default.createElement(_routeContext().RootRoute, {
|
|
172
|
+
renderRoutes(routes) {
|
|
173
|
+
return /*#__PURE__*/_react().default.createElement(_routeContext().RootRoute, {
|
|
161
174
|
routeSlot: this.routeSlot,
|
|
162
175
|
rootRoutes: routes
|
|
163
|
-
})
|
|
176
|
+
});
|
|
164
177
|
}
|
|
165
178
|
|
|
166
179
|
/** decides how navigation is stored and applied.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["react-router.ui.runtime.tsx"],"names":["ReactRouterUI","constructor","routeSlot","routeChangeListener","isBrowser","Routing","url","static","undefined","routerHistory","unregisterListener","listen","args","values","forEach","listener","path","action","
|
|
1
|
+
{"version":3,"sources":["react-router.ui.runtime.tsx"],"names":["ReactRouterUI","constructor","routeSlot","routeChangeListener","isBrowser","Routing","url","static","undefined","routerHistory","unregisterListener","listen","args","values","forEach","listener","path","action","replace","push","children","renderCtx","routingMode","initialLocation","browserInit","window","location","pathname","search","hash","serverInit","browser","reactContext","AppRoutingContext","renderRoutes","routes","setRoutingMode","routing","register","route","registerListener","provider","deps","config","routeChange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AgB,CAACzB,QAAD,EAA6B;AAC3C,SAAKZ,mBAAL,CAAyBmC,QAAzB,CAAkCvB,QAAlC;AACD;AAED;AACF;AACA;;;AA0CuB,eAAR0B,QAAQ,CAACC,IAAD,EAAOC,MAAP,EAAe,CAACzC,SAAD,EAAY0C,eAAZ,CAAf,EAA2E;AAC9F,WAAO,IAAI5C,aAAJ,CAAkBE,SAAlB,EAA6B0C,eAA7B,CAAP;AACD;;AApGwB;;;gCAAd5C,a,WA+FI,CAAC6C,gBAAKC,QAAL,EAAD,EAA8BD,gBAAKC,QAAL,EAA9B,C;gCA/FJ9C,a,aAgGM+C,e;;AAOnBC,iCAAkBC,UAAlB,CAA6BjD,aAA7B","sourcesContent":["import React, { ReactNode } from 'react';\nimport { RouteProps } from 'react-router-dom';\nimport { History, UnregisterCallback, LocationListener, LocationDescriptor, Action } from 'history';\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';\n\ntype RouteChangeSlot = SlotRegistry<LocationListener>;\ntype RenderContext = { initialLocation?: string };\n\nexport class ReactRouterUI {\n private routerHistory?: History;\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 private unregisterListener?: UnregisterCallback = undefined;\n /** (internal method) sets the routing engine for navigation methods */\n setRouter = (routerHistory: History) => {\n this.routerHistory = routerHistory;\n\n this.unregisterListener?.();\n this.unregisterListener = routerHistory.listen((...args) => {\n this.routeChangeListener.values().forEach((listener) => listener(...args));\n });\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: LocationDescriptor,\n /** history action to execute (pop / push / replace) */\n action?: Action\n ) => {\n switch (action) {\n case 'POP':\n return; // TBD;\n case 'REPLACE':\n this.routerHistory?.replace(path);\n return;\n case 'PUSH':\n default:\n this.routerHistory?.push(path);\n }\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 </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"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/react-router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.651",
|
|
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.651"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"react-router": "5.2.0",
|
|
@@ -18,25 +18,25 @@
|
|
|
18
18
|
"@teambit/base-ui.routing.link": "1.0.0",
|
|
19
19
|
"@teambit/base-ui.routing.nav-link": "1.0.0",
|
|
20
20
|
"@teambit/base-ui.routing.routing-provider": "1.0.0",
|
|
21
|
-
"@teambit/ui-foundation.ui.react-router.link-anchor": "0.0.
|
|
22
|
-
"@teambit/ui-foundation.ui.is-browser": "0.0.
|
|
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.
|
|
26
|
-
"@teambit/ui-foundation.ui.react-router.nav-link": "0.0.
|
|
21
|
+
"@teambit/ui-foundation.ui.react-router.link-anchor": "0.0.123",
|
|
22
|
+
"@teambit/ui-foundation.ui.is-browser": "0.0.486",
|
|
23
|
+
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.488",
|
|
24
|
+
"@teambit/ui": "0.0.651",
|
|
25
|
+
"@teambit/ui-foundation.ui.react-router.link": "0.0.489",
|
|
26
|
+
"@teambit/ui-foundation.ui.react-router.nav-link": "0.0.489"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/history": "4.7.8",
|
|
30
30
|
"@types/react-router-dom": "5.1.7",
|
|
31
31
|
"@types/react": "^17.0.8",
|
|
32
|
-
"@types/mocha": "
|
|
32
|
+
"@types/mocha": "9.1.0",
|
|
33
33
|
"@types/testing-library__jest-dom": "5.9.5",
|
|
34
34
|
"@types/jest": "^26.0.0",
|
|
35
35
|
"@types/react-dom": "^17.0.5",
|
|
36
36
|
"@types/node": "12.20.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@teambit/legacy": "1.0.
|
|
39
|
+
"@teambit/legacy": "1.0.223",
|
|
40
40
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
41
41
|
"react": "^16.8.0 || ^17.0.0"
|
|
42
42
|
},
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@teambit/legacy": "-",
|
|
57
|
-
"@types/mocha": "
|
|
57
|
+
"@types/mocha": "9.1.0",
|
|
58
58
|
"@types/testing-library__jest-dom": "5.9.5",
|
|
59
59
|
"@types/jest": "^26.0.0",
|
|
60
60
|
"@types/react-dom": "^17.0.5",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"react": "-"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@teambit/legacy": "1.0.
|
|
67
|
+
"@teambit/legacy": "1.0.223",
|
|
68
68
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
69
69
|
"react": "^16.8.0 || ^17.0.0"
|
|
70
70
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { RouteProps } from 'react-router-dom';
|
|
3
3
|
import { History, UnregisterCallback, LocationListener, LocationDescriptor, Action } from 'history';
|
|
4
4
|
import { Slot, SlotRegistry } from '@teambit/harmony';
|
|
5
|
-
import { UIRuntime } from '@teambit/ui';
|
|
5
|
+
import { RenderPlugins, UIRuntime } from '@teambit/ui';
|
|
6
6
|
import { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
7
7
|
import { isBrowser } from '@teambit/ui-foundation.ui.is-browser';
|
|
8
8
|
|
|
@@ -11,9 +11,7 @@ import { RouteContext, RootRoute } from './route-context';
|
|
|
11
11
|
import { Routing } from './routing-method';
|
|
12
12
|
|
|
13
13
|
type RouteChangeSlot = SlotRegistry<LocationListener>;
|
|
14
|
-
type
|
|
15
|
-
initialLocation?: string;
|
|
16
|
-
};
|
|
14
|
+
type RenderContext = { initialLocation?: string };
|
|
17
15
|
|
|
18
16
|
export class ReactRouterUI {
|
|
19
17
|
private routerHistory?: History;
|
|
@@ -33,12 +31,8 @@ export class ReactRouterUI {
|
|
|
33
31
|
/**
|
|
34
32
|
* render all slot routes.
|
|
35
33
|
*/
|
|
36
|
-
renderRoutes(routes: RouteProps[]
|
|
37
|
-
return
|
|
38
|
-
<RouteContext reactRouterUi={this} routing={this.routingMode} location={options.initialLocation}>
|
|
39
|
-
<RootRoute routeSlot={this.routeSlot} rootRoutes={routes}></RootRoute>
|
|
40
|
-
</RouteContext>
|
|
41
|
-
);
|
|
34
|
+
renderRoutes(routes: RouteProps[]) {
|
|
35
|
+
return <RootRoute routeSlot={this.routeSlot} rootRoutes={routes} />;
|
|
42
36
|
}
|
|
43
37
|
|
|
44
38
|
private unregisterListener?: UnregisterCallback = undefined;
|
|
@@ -79,17 +73,9 @@ export class ReactRouterUI {
|
|
|
79
73
|
navigateTo = (
|
|
80
74
|
/** destination */
|
|
81
75
|
path: LocationDescriptor,
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
* Supports state-object for legacy calls. (this will be removed when supported by symphony)
|
|
85
|
-
*/
|
|
86
|
-
action?: Action | Record<string, any>
|
|
76
|
+
/** history action to execute (pop / push / replace) */
|
|
77
|
+
action?: Action
|
|
87
78
|
) => {
|
|
88
|
-
if (typeof action !== 'string') {
|
|
89
|
-
this.legacyNavigateTo(path as string, action);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
79
|
switch (action) {
|
|
94
80
|
case 'POP':
|
|
95
81
|
return; // TBD;
|
|
@@ -102,15 +88,24 @@ export class ReactRouterUI {
|
|
|
102
88
|
}
|
|
103
89
|
};
|
|
104
90
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
91
|
+
private AppRoutingContext = ({ children, renderCtx }: { children: ReactNode; renderCtx?: RenderContext }) => {
|
|
92
|
+
return (
|
|
93
|
+
<RouteContext reactRouterUi={this} routing={this.routingMode} location={renderCtx?.initialLocation}>
|
|
94
|
+
{children}
|
|
95
|
+
</RouteContext>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
public renderPlugin: RenderPlugins<RenderContext> = {
|
|
100
|
+
browserInit: () => {
|
|
101
|
+
const initialLocation = `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
102
|
+
return { initialLocation };
|
|
103
|
+
},
|
|
104
|
+
serverInit: ({ browser }) => {
|
|
105
|
+
const initialLocation = browser?.location.url;
|
|
106
|
+
return { initialLocation };
|
|
107
|
+
},
|
|
108
|
+
reactContext: this.AppRoutingContext,
|
|
114
109
|
};
|
|
115
110
|
|
|
116
111
|
static slots = [Slot.withType<RouteProps>(), Slot.withType<LocationListener>()];
|
|
Binary file
|