@homecode/ui 4.18.28 → 4.18.30
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/esm/src/components/Router/store.js +5 -4
- package/dist/esm/src/tools/queryParams.js +3 -9
- package/dist/esm/types/src/components/Icon/Icon.example.d.ts +0 -1
- package/dist/esm/types/src/components/Router/Router.types.d.ts +1 -0
- package/dist/esm/types/src/tools/queryParams.d.ts +1 -1
- package/package.json +1 -1
|
@@ -20,11 +20,11 @@ const STORE = createStore('router', {
|
|
|
20
20
|
un(cb) {
|
|
21
21
|
spliceWhere(LISTENERS, cb);
|
|
22
22
|
},
|
|
23
|
-
go(path, query, params = {}) {
|
|
24
|
-
if (path === this.path)
|
|
23
|
+
go(path = this.path, query = {}, params = {}) {
|
|
24
|
+
if (path === this.path && !query)
|
|
25
25
|
return;
|
|
26
26
|
const { replace } = params;
|
|
27
|
-
const pathStr = applyQueryParams(path ?? this.path, query
|
|
27
|
+
const pathStr = applyQueryParams(path ?? this.path, query);
|
|
28
28
|
const action = replace ? 'replaceState' : 'pushState';
|
|
29
29
|
console.log('Router.go', query, pathStr);
|
|
30
30
|
history[action]({}, '', pathStr);
|
|
@@ -54,6 +54,7 @@ function updateRouteState() {
|
|
|
54
54
|
if (isBrowser) {
|
|
55
55
|
window.addEventListener('popstate', updateRouteState);
|
|
56
56
|
window.addEventListener('pushstate', updateRouteState);
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
|
+
// window.routerStore = STORE;
|
|
58
59
|
|
|
59
60
|
export { STORE as default };
|
|
@@ -15,17 +15,11 @@ function stringifyQueryParams(params) {
|
|
|
15
15
|
.map(([key, value]) => `${key}=${value}`)
|
|
16
16
|
.join('&');
|
|
17
17
|
}
|
|
18
|
-
function applyQueryParams(path, queryParams
|
|
18
|
+
function applyQueryParams(path, queryParams) {
|
|
19
19
|
const clearPath = path.replace(/\?.*/, '/');
|
|
20
|
-
if (
|
|
21
|
-
if (Object.keys(currParams).length === 0)
|
|
22
|
-
return path;
|
|
23
|
-
return `${clearPath}?${stringifyQueryParams(currParams)}`;
|
|
24
|
-
}
|
|
25
|
-
if (typeof queryParams === 'string') {
|
|
20
|
+
if (typeof queryParams === 'string')
|
|
26
21
|
return queryParams;
|
|
27
|
-
}
|
|
28
|
-
const query = { ...currParams };
|
|
22
|
+
const query = { ...queryParams };
|
|
29
23
|
Object.entries(queryParams).forEach(([key, value]) => {
|
|
30
24
|
if (value === false)
|
|
31
25
|
delete query[key];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function parseQueryParams(qs?: string): Record<string, string>;
|
|
2
2
|
export declare function stringifyQueryParams(params: Record<string, string>): string;
|
|
3
|
-
export declare function applyQueryParams(path: any, queryParams:
|
|
3
|
+
export declare function applyQueryParams(path: any, queryParams: Record<string, any> | string): string;
|
|
4
4
|
export declare const setSSRQueryParams: (params: any) => void;
|
|
5
5
|
export declare const queryParams: Record<string, string>;
|