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