@umijs/renderer-react 4.0.66 → 4.0.68
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/dist/appContext.js +4 -9
- package/dist/link.js +3 -6
- package/dist/routes.js +10 -22
- package/dist/useFetcher.js +1 -2
- package/dist/withRouter.js +0 -1
- package/package.json +1 -1
package/dist/appContext.js
CHANGED
|
@@ -9,23 +9,18 @@ export function useAppData() {
|
|
|
9
9
|
}
|
|
10
10
|
export function useSelectedRoutes() {
|
|
11
11
|
var location = useLocation();
|
|
12
|
-
|
|
13
12
|
var _useAppData = useAppData(),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
clientRoutes = _useAppData.clientRoutes;
|
|
14
|
+
// use `useLocation` get location without `basename`, not need `basename` param
|
|
17
15
|
var routes = matchRoutes(clientRoutes, location.pathname);
|
|
18
16
|
return routes || [];
|
|
19
17
|
}
|
|
20
18
|
export function useRouteProps() {
|
|
21
19
|
var _currentRoute$;
|
|
22
|
-
|
|
23
20
|
var currentRoute = useSelectedRoutes().slice(-1);
|
|
24
|
-
|
|
25
21
|
var _ref = ((_currentRoute$ = currentRoute[0]) === null || _currentRoute$ === void 0 ? void 0 : _currentRoute$.route) || {},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
_ = _ref.element,
|
|
23
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
24
|
return props;
|
|
30
25
|
}
|
|
31
26
|
export function useServerLoaderData() {
|
package/dist/link.js
CHANGED
|
@@ -6,19 +6,16 @@ import { Link } from 'react-router-dom';
|
|
|
6
6
|
import { useAppData } from "./appContext";
|
|
7
7
|
export function LinkWithPrefetch(props) {
|
|
8
8
|
var _props$to;
|
|
9
|
-
|
|
10
9
|
var prefetch = props.prefetch,
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
linkProps = _objectWithoutProperties(props, _excluded);
|
|
13
11
|
var appData = useAppData();
|
|
14
|
-
var to = typeof props.to === 'string' ? props.to : (_props$to = props.to) === null || _props$to === void 0 ? void 0 : _props$to.pathname;
|
|
12
|
+
var to = typeof props.to === 'string' ? props.to : (_props$to = props.to) === null || _props$to === void 0 ? void 0 : _props$to.pathname;
|
|
13
|
+
// compatible with old code
|
|
15
14
|
// which to might be undefined
|
|
16
|
-
|
|
17
15
|
if (!to) return null;
|
|
18
16
|
return /*#__PURE__*/React.createElement(Link, _extends({
|
|
19
17
|
onMouseEnter: function onMouseEnter() {
|
|
20
18
|
var _appData$preloadRoute;
|
|
21
|
-
|
|
22
19
|
return prefetch && to && ((_appData$preloadRoute = appData.preloadRoute) === null || _appData$preloadRoute === void 0 ? void 0 : _appData$preloadRoute.call(appData, to));
|
|
23
20
|
}
|
|
24
21
|
}, linkProps), props.children);
|
package/dist/routes.js
CHANGED
|
@@ -9,8 +9,8 @@ import { RouteContext, useRouteData } from "./routeContext";
|
|
|
9
9
|
import { useAppData } from "./appContext";
|
|
10
10
|
export function createClientRoutes(opts) {
|
|
11
11
|
var routesById = opts.routesById,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
parentId = opts.parentId,
|
|
13
|
+
routeComponents = opts.routeComponents;
|
|
14
14
|
return Object.keys(routesById).filter(function (id) {
|
|
15
15
|
return routesById[id].parentId === parentId;
|
|
16
16
|
}).map(function (id) {
|
|
@@ -32,36 +32,28 @@ export function createClientRoutes(opts) {
|
|
|
32
32
|
loadingComponent: opts.loadingComponent,
|
|
33
33
|
reactRouter5Compat: opts.reactRouter5Compat
|
|
34
34
|
});
|
|
35
|
-
|
|
36
35
|
if (children.length > 0) {
|
|
37
|
-
route.children = children;
|
|
36
|
+
route.children = children;
|
|
37
|
+
// TODO: remove me
|
|
38
38
|
// compatible with @ant-design/pro-layout
|
|
39
|
-
|
|
40
39
|
route.routes = children;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
41
|
return route;
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
function NavigateWithParams(props) {
|
|
48
45
|
var params = useParams();
|
|
49
|
-
|
|
50
46
|
var propsWithParams = _objectSpread(_objectSpread({}, props), {}, {
|
|
51
47
|
to: generatePath(props.to, params)
|
|
52
48
|
});
|
|
53
|
-
|
|
54
49
|
return /*#__PURE__*/React.createElement(Navigate, _extends({
|
|
55
50
|
replace: true
|
|
56
51
|
}, propsWithParams));
|
|
57
52
|
}
|
|
58
|
-
|
|
59
53
|
function createClientRoute(opts) {
|
|
60
54
|
var route = opts.route;
|
|
61
|
-
|
|
62
55
|
var redirect = route.redirect,
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
props = _objectWithoutProperties(route, _excluded);
|
|
65
57
|
var Remote = opts.reactRouter5Compat ? RemoteComponentReactRouter5 : RemoteComponent;
|
|
66
58
|
return _objectSpread({
|
|
67
59
|
element: redirect ? /*#__PURE__*/React.createElement(NavigateWithParams, {
|
|
@@ -77,27 +69,24 @@ function createClientRoute(opts) {
|
|
|
77
69
|
}))
|
|
78
70
|
}, props);
|
|
79
71
|
}
|
|
80
|
-
|
|
81
72
|
function DefaultLoading() {
|
|
82
73
|
return /*#__PURE__*/React.createElement("div", null);
|
|
83
74
|
}
|
|
84
|
-
|
|
85
75
|
function RemoteComponentReactRouter5(props) {
|
|
86
76
|
var _useRouteData = useRouteData(),
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
route = _useRouteData.route;
|
|
89
78
|
var _useAppData = useAppData(),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
79
|
+
history = _useAppData.history,
|
|
80
|
+
clientRoutes = _useAppData.clientRoutes;
|
|
93
81
|
var params = useParams();
|
|
94
82
|
var match = {
|
|
95
83
|
params: params,
|
|
96
84
|
isExact: true,
|
|
97
85
|
path: route.path,
|
|
98
86
|
url: history.location.pathname
|
|
99
|
-
};
|
|
87
|
+
};
|
|
100
88
|
|
|
89
|
+
// staticContext 没有兼容 好像没看到对应的兼容写法
|
|
101
90
|
var Component = props.loader;
|
|
102
91
|
return /*#__PURE__*/React.createElement(React.Suspense, {
|
|
103
92
|
fallback: /*#__PURE__*/React.createElement(props.loadingComponent, null)
|
|
@@ -110,7 +99,6 @@ function RemoteComponentReactRouter5(props) {
|
|
|
110
99
|
routes: clientRoutes
|
|
111
100
|
}, props.hasChildren && /*#__PURE__*/React.createElement(Outlet, null)));
|
|
112
101
|
}
|
|
113
|
-
|
|
114
102
|
function RemoteComponent(props) {
|
|
115
103
|
var Component = props.loader;
|
|
116
104
|
return /*#__PURE__*/React.createElement(React.Suspense, {
|
package/dist/useFetcher.js
CHANGED
|
@@ -2,8 +2,7 @@ import { useLocation } from 'react-router-dom';
|
|
|
2
2
|
import { useAppData } from "./appContext";
|
|
3
3
|
export function __useFetcher() {
|
|
4
4
|
var _useAppData = useAppData(),
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
preloadRoute = _useAppData.preloadRoute;
|
|
7
6
|
var location = useLocation();
|
|
8
7
|
return {
|
|
9
8
|
load: function load(path) {
|
package/dist/withRouter.js
CHANGED
package/package.json
CHANGED