swico 0.9.0-beta → 0.9.0-beta1
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/package.json
CHANGED
|
@@ -87,12 +87,13 @@ var getPathNameList = function (routes) {
|
|
|
87
87
|
};
|
|
88
88
|
exports.pathNameList = getPathNameList(routes_1.default);
|
|
89
89
|
var getLocation = function (originalHistory) {
|
|
90
|
-
var _a = originalHistory.location, pathname = _a.pathname, hash = _a.hash, search = _a.search;
|
|
90
|
+
var _a = originalHistory.location, pathname = _a.pathname, hash = _a.hash, search = _a.search, _b = _a.state, state = _b === void 0 ? {} : _b;
|
|
91
91
|
var routerBaseLength = formatRouterBase.length;
|
|
92
92
|
var path = pathname.slice(routerBaseLength);
|
|
93
93
|
var matchPathNameItem = exports.pathNameList.find(function (item) { return item.path === path || (0, exports.compareURLPatterns)(path, item.path); });
|
|
94
94
|
var params = interpolatePathParams(matchPathNameItem === null || matchPathNameItem === void 0 ? void 0 : matchPathNameItem.path, path);
|
|
95
95
|
return {
|
|
96
|
+
state: state,
|
|
96
97
|
hash: hash,
|
|
97
98
|
search: search,
|
|
98
99
|
pathname: pathname,
|
|
@@ -11,7 +11,7 @@ var useLocation = function () {
|
|
|
11
11
|
var _a, _b;
|
|
12
12
|
var location = (0, react_router_dom_1.useLocation)();
|
|
13
13
|
var params = (0, react_router_dom_1.useParams)();
|
|
14
|
-
var search = location.search, hash = location.hash, pathname = location.pathname;
|
|
14
|
+
var search = location.search, hash = location.hash, pathname = location.pathname, _c = location.state, state = _c === void 0 ? {} : _c;
|
|
15
15
|
var name = (_a = history_1.pathNameList.find(function (item) {
|
|
16
16
|
return (Object.keys(params).length > 0 && (0, history_1.compareURLPatterns)(pathname, item.path)) ||
|
|
17
17
|
item.path === pathname;
|
|
@@ -19,6 +19,7 @@ var useLocation = function () {
|
|
|
19
19
|
var query = search ? qs_1.default.parse(search.startsWith('?') ? search.slice(1) : search) : {};
|
|
20
20
|
return {
|
|
21
21
|
name: name,
|
|
22
|
+
state: state,
|
|
22
23
|
path: pathname,
|
|
23
24
|
pathname: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.pathname,
|
|
24
25
|
search: '',
|
|
@@ -36,9 +36,10 @@ var getRouter = function () {
|
|
|
36
36
|
back: router.back,
|
|
37
37
|
forward: router.forward,
|
|
38
38
|
get location() {
|
|
39
|
+
var _a;
|
|
39
40
|
var lastIndexBase = config_1.routerBase[config_1.routerBase.length - 1];
|
|
40
41
|
var formatRouterBase = lastIndexBase === '/' ? config_1.routerBase.slice(0, config_1.routerBase.length - 1) : config_1.routerBase;
|
|
41
|
-
var
|
|
42
|
+
var _b = router.currentRoute.value, path = _b.path, params = _b.params, query = _b.query, name = _b.name, hash = _b.hash, fullPath = _b.fullPath;
|
|
42
43
|
return {
|
|
43
44
|
path: path,
|
|
44
45
|
pathname: formatRouterBase + path,
|
|
@@ -46,6 +47,7 @@ var getRouter = function () {
|
|
|
46
47
|
query: query,
|
|
47
48
|
name: name,
|
|
48
49
|
hash: hash,
|
|
50
|
+
state: (_a = window.history.state) !== null && _a !== void 0 ? _a : {},
|
|
49
51
|
search: query ? qs_1.default.stringify(query) : ''
|
|
50
52
|
};
|
|
51
53
|
}
|
|
@@ -19,6 +19,7 @@ var useLocation = function () {
|
|
|
19
19
|
name: '',
|
|
20
20
|
path: '',
|
|
21
21
|
search: '',
|
|
22
|
+
state: {},
|
|
22
23
|
hash: '',
|
|
23
24
|
pathname: '',
|
|
24
25
|
params: {},
|
|
@@ -34,6 +35,7 @@ var useLocation = function () {
|
|
|
34
35
|
location.query = query;
|
|
35
36
|
location.hash = hash;
|
|
36
37
|
location.params = params;
|
|
38
|
+
location.state = window.history.state || {};
|
|
37
39
|
});
|
|
38
40
|
return location;
|
|
39
41
|
};
|