swico 0.5.0-beta13 → 0.5.0-beta15
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
|
@@ -10,4 +10,12 @@ export declare const getHistory: (routerBase: ConfigRouterType['base'], routerTy
|
|
|
10
10
|
history: SwicoHistoryType;
|
|
11
11
|
originalHistory: import("history").HashHistory;
|
|
12
12
|
};
|
|
13
|
-
export declare const useLocation:
|
|
13
|
+
export declare const useLocation: () => {
|
|
14
|
+
name: string;
|
|
15
|
+
path: string;
|
|
16
|
+
pathname: string;
|
|
17
|
+
search: string;
|
|
18
|
+
query: {};
|
|
19
|
+
hash: string;
|
|
20
|
+
params: {};
|
|
21
|
+
};
|
|
@@ -11,6 +11,7 @@ var react_router_dom_2 = require("react-router-dom");
|
|
|
11
11
|
var routes_1 = require("./routes");
|
|
12
12
|
var react_router_dom_3 = require("react-router-dom");
|
|
13
13
|
Object.defineProperty(exports, "HistoryRouter", { enumerable: true, get: function () { return react_router_dom_3.unstable_HistoryRouter; } });
|
|
14
|
+
console.log('routes', routes_1.routes);
|
|
14
15
|
var interpolatePath = function (pathTemplate, params) {
|
|
15
16
|
var pathParts = pathTemplate.split('/');
|
|
16
17
|
var interpolatedParts = pathParts.map(function (part) {
|
|
@@ -146,25 +147,19 @@ var compareURLPatterns = function (urlPatternWithValues, urlPatternWithParams) {
|
|
|
146
147
|
return true;
|
|
147
148
|
};
|
|
148
149
|
var useLocation = function () {
|
|
149
|
-
var _a
|
|
150
|
+
var _a;
|
|
150
151
|
var location = (0, react_router_dom_1.useLocation)();
|
|
151
152
|
var params = (0, react_router_dom_2.useParams)();
|
|
152
153
|
var search = location.search, hash = location.hash, pathname = location.pathname;
|
|
153
154
|
console.log('routes2', routes_1.routes);
|
|
154
|
-
var pathNameList = (0, exports.getPathNameList)(routes_1.routes);
|
|
155
|
-
var name = (_a = pathNameList.find(function (item) {
|
|
156
|
-
return (Object.keys(params).length > 0 && compareURLPatterns(pathname, item.path)) ||
|
|
157
|
-
item.path === pathname;
|
|
158
|
-
})) === null || _a === void 0 ? void 0 : _a.name;
|
|
159
|
-
var query = search ? qs_1.default.parse(search.startsWith('?') ? search.slice(1) : search) : {};
|
|
160
155
|
return {
|
|
161
|
-
name:
|
|
162
|
-
path:
|
|
163
|
-
pathname: (
|
|
164
|
-
search:
|
|
165
|
-
query:
|
|
166
|
-
hash:
|
|
167
|
-
params:
|
|
156
|
+
name: '',
|
|
157
|
+
path: '',
|
|
158
|
+
pathname: (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.pathname,
|
|
159
|
+
search: '',
|
|
160
|
+
query: {},
|
|
161
|
+
hash: '',
|
|
162
|
+
params: {}
|
|
168
163
|
};
|
|
169
164
|
};
|
|
170
165
|
exports.useLocation = useLocation;
|