@nu-art/thunderstorm-frontend 0.400.10 → 0.400.13
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/component-modules/mouse-interactivity/types.d.ts +1 -0
- package/components/TS_MouseInteractivity/TS_PopUp/TS_PopUp.js +1 -0
- package/components/TS_Radio/TS_Radio.js +3 -4
- package/components/TS_V2_TextArea/TS_TextAreaV2.d.ts +1 -1
- package/components/TS_V2_TextArea/TS_TextAreaV2.js +4 -4
- package/modules/ModuleFE_BrowserHistory.d.ts +199 -5
- package/modules/ModuleFE_BrowserHistory.js +242 -4
- package/modules/ModuleFE_LocalStorage.js +9 -9
- package/modules/ModuleFE_Thunderstorm.d.ts +2 -0
- package/modules/ModuleFE_Thunderstorm.js +15 -2
- package/modules/component-loader/entry-component-loading-module.js +2 -2
- package/modules/routing/ModuleFE_Routing.d.ts +154 -0
- package/modules/routing/ModuleFE_Routing.js +157 -3
- package/modules/routing/ModuleFE_RoutingV2.d.ts +91 -1
- package/modules/routing/ModuleFE_RoutingV2.js +193 -1
- package/modules/routing/index.d.ts +0 -1
- package/modules/routing/index.js +0 -1
- package/package.json +6 -6
- package/utils/EditableItem.js +1 -1
- package/utils/tools.d.ts +5 -0
- package/utils/tools.js +4 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Module, TypedMap } from '@nu-art/ts-common';
|
|
2
|
+
import { GenericUpdate } from '@nu-art/thunderstorm-shared';
|
|
2
3
|
type Config = {
|
|
3
4
|
appName: string;
|
|
4
5
|
themeColor: string;
|
|
@@ -26,6 +27,7 @@ declare class ModuleFE_Thunderstorm_Class extends Module<Config> {
|
|
|
26
27
|
params?: TypedMap<(() => string) | string | undefined>;
|
|
27
28
|
}, target?: UrlTarget): void;
|
|
28
29
|
downloadFile(props: FileDownloadProps): void;
|
|
30
|
+
performGenericUpdate: (updateData: GenericUpdate[]) => Promise<void>;
|
|
29
31
|
}
|
|
30
32
|
export declare const ModuleFE_Thunderstorm: ModuleFE_Thunderstorm_Class;
|
|
31
33
|
export {};
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* See the License for the specific language governing permissions and
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
|
-
import { _keys, BadImplementationException, Module } from '@nu-art/ts-common';
|
|
21
|
+
import { _keys, BadImplementationException, Module, MUSTNeverHappenException, Promise_all_sequentially, RuntimeModules } from '@nu-art/ts-common';
|
|
22
22
|
import { ModuleFE_Toaster } from '../component-modules/ModuleFE_Toaster.js';
|
|
23
|
-
import { composeURL } from './
|
|
23
|
+
import { composeURL } from './routing/ModuleFE_RoutingV2.js';
|
|
24
24
|
import { HttpMethod } from '@nu-art/thunderstorm-shared';
|
|
25
25
|
import { base64ToBlob } from '../utils/tools.js';
|
|
26
26
|
import { ModuleFE_XHR } from './http/ModuleFE_XHR.js';
|
|
@@ -118,5 +118,18 @@ class ModuleFE_Thunderstorm_Class extends Module {
|
|
|
118
118
|
element.setAttribute('download', `${props.fileName}`);
|
|
119
119
|
element.click();
|
|
120
120
|
}
|
|
121
|
+
performGenericUpdate = async (updateData) => {
|
|
122
|
+
const promises = [];
|
|
123
|
+
updateData.forEach(update => {
|
|
124
|
+
const module = RuntimeModules().find(module => module.dbDef?.dbKey === update.dbKey);
|
|
125
|
+
if (!module)
|
|
126
|
+
throw new MUSTNeverHappenException(`Trying to perform a generic update without an existing module for dbKey ${update.dbKey}`);
|
|
127
|
+
if (update.data.toUpdate?.length)
|
|
128
|
+
promises.push(() => module.onEntriesUpdated(update.data.toUpdate));
|
|
129
|
+
if (update.data.toDelete?.length)
|
|
130
|
+
promises.push(() => module.onEntriesDeleted(update.data.toDelete));
|
|
131
|
+
});
|
|
132
|
+
await Promise_all_sequentially(promises);
|
|
133
|
+
};
|
|
121
134
|
}
|
|
122
135
|
export const ModuleFE_Thunderstorm = new ModuleFE_Thunderstorm_Class();
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
import { Module } from '@nu-art/ts-common';
|
|
22
22
|
// noinspection TypeScriptPreferShortImport
|
|
23
23
|
import { ModuleFE_XHR } from '../http/ModuleFE_XHR.js';
|
|
24
|
-
import {
|
|
24
|
+
import { ModuleFE_RoutingV2 } from '../routing/ModuleFE_RoutingV2.js';
|
|
25
25
|
import { HttpMethod } from '@nu-art/thunderstorm-shared';
|
|
26
26
|
export class PageLoadingModule_Class extends Module {
|
|
27
27
|
injected = {};
|
|
28
28
|
loadScript(src, progressListener) {
|
|
29
29
|
const apiDef = {
|
|
30
30
|
method: HttpMethod.GET,
|
|
31
|
-
baseUrl:
|
|
31
|
+
baseUrl: ModuleFE_RoutingV2.getOrigin(),
|
|
32
32
|
path: src
|
|
33
33
|
};
|
|
34
34
|
ModuleFE_XHR
|
|
@@ -1,7 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated This module is deprecated. Use ModuleFE_RoutingV2 instead.
|
|
3
|
+
*
|
|
4
|
+
* Migration Guide:
|
|
5
|
+
*
|
|
6
|
+
* ModuleFE_Routing uses an imperative API (addRoute, clearRoutes) while ModuleFE_RoutingV2 uses a declarative
|
|
7
|
+
* route object API (TS_Route). Migration requires refactoring route definitions.
|
|
8
|
+
*
|
|
9
|
+
* Key Differences:
|
|
10
|
+
* - Old: ModuleFE_Routing.addRoute(key, path, component)
|
|
11
|
+
* - New: Define TS_Route objects with key, path, Component properties
|
|
12
|
+
*
|
|
13
|
+
* - Old: ModuleFE_Routing.goToRoute(key, params)
|
|
14
|
+
* - New: ModuleFE_RoutingV2.goToRoute(routeObject, params)
|
|
15
|
+
*
|
|
16
|
+
* - Old: ModuleFE_Routing.getRoutesMap()
|
|
17
|
+
* - New: ModuleFE_RoutingV2.generateRoutes(rootRoute) - returns JSX
|
|
18
|
+
*
|
|
19
|
+
* See ModuleFE_RoutingV2 and TS_Route type for the new API.
|
|
20
|
+
*
|
|
21
|
+
* This module will be removed in a future version. Please migrate to ModuleFE_RoutingV2.
|
|
22
|
+
*/
|
|
1
23
|
import { Module, RouteParams } from '@nu-art/ts-common';
|
|
2
24
|
import * as React from 'react';
|
|
3
25
|
import { RoutePath } from './route.js';
|
|
4
26
|
import { QueryParams } from '@nu-art/thunderstorm-shared';
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use ModuleFE_RoutingV2 instead. This class will be removed in a future version.
|
|
29
|
+
*
|
|
30
|
+
* All functionality has been migrated to ModuleFE_RoutingV2. See file-level deprecation notice for migration guide.
|
|
31
|
+
*/
|
|
5
32
|
declare class ModuleFE_Routing_Class extends Module<{}> {
|
|
6
33
|
private readonly routes;
|
|
7
34
|
private readonly ordinalRoutes;
|
|
@@ -10,21 +37,148 @@ declare class ModuleFE_Routing_Class extends Module<{}> {
|
|
|
10
37
|
private readonly createLinkNode;
|
|
11
38
|
constructor();
|
|
12
39
|
init(): void;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use ModuleFE_RoutingV2 with TS_Route objects instead
|
|
42
|
+
*
|
|
43
|
+
* Migration: Define routes as TS_Route objects and pass to ModuleFE_RoutingV2.generateRoutes()
|
|
44
|
+
*/
|
|
13
45
|
clearRoutes(): void;
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use ModuleFE_RoutingV2 with TS_Route objects instead
|
|
48
|
+
*
|
|
49
|
+
* Migration:
|
|
50
|
+
* // Old:
|
|
51
|
+
* ModuleFE_Routing.addRoute('home', '/', HomeComponent);
|
|
52
|
+
*
|
|
53
|
+
* // New:
|
|
54
|
+
* const route: TS_Route = { key: 'home', path: '/', Component: HomeComponent };
|
|
55
|
+
* // Then use ModuleFE_RoutingV2.generateRoutes(rootRoute) where rootRoute contains this route
|
|
56
|
+
*/
|
|
14
57
|
addRoute(key: string, route: string, component: React.ComponentClass<any, any> | string): RoutePath;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Use ModuleFE_RoutingV2.getRouteByKey() instead
|
|
60
|
+
*
|
|
61
|
+
* Migration:
|
|
62
|
+
* // Old:
|
|
63
|
+
* const route = ModuleFE_Routing.getRoute(key);
|
|
64
|
+
*
|
|
65
|
+
* // New:
|
|
66
|
+
* const route = ModuleFE_RoutingV2.getRouteByKey(key);
|
|
67
|
+
*/
|
|
15
68
|
getRoute(key: string): RoutePath;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use ModuleFE_RoutingV2.getFullPath() instead
|
|
71
|
+
*
|
|
72
|
+
* Migration:
|
|
73
|
+
* // Old:
|
|
74
|
+
* const path = ModuleFE_Routing.getPath(key);
|
|
75
|
+
*
|
|
76
|
+
* // New:
|
|
77
|
+
* const path = ModuleFE_RoutingV2.getFullPath(key);
|
|
78
|
+
*/
|
|
16
79
|
getPath(key: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated Use ModuleFE_RoutingV2.goToRoute() instead
|
|
82
|
+
*
|
|
83
|
+
* Migration:
|
|
84
|
+
* // Old:
|
|
85
|
+
* ModuleFE_Routing.goToRoute(key, params);
|
|
86
|
+
*
|
|
87
|
+
* // New:
|
|
88
|
+
* const route = ModuleFE_RoutingV2.getRouteByKey(key);
|
|
89
|
+
* if (route) ModuleFE_RoutingV2.goToRoute(route, params);
|
|
90
|
+
*/
|
|
17
91
|
goToRoute(key: string, params?: RouteParams): void;
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated Use ModuleFE_RoutingV2.redirect() instead
|
|
94
|
+
*
|
|
95
|
+
* Migration:
|
|
96
|
+
* // Old:
|
|
97
|
+
* return ModuleFE_Routing.redirect(key);
|
|
98
|
+
*
|
|
99
|
+
* // New:
|
|
100
|
+
* const route = ModuleFE_RoutingV2.getRouteByKey(key);
|
|
101
|
+
* if (route) return ModuleFE_RoutingV2.redirect(route);
|
|
102
|
+
*/
|
|
18
103
|
redirect(key: string): import("react/jsx-runtime").JSX.Element;
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrentRouteKey() instead
|
|
106
|
+
*
|
|
107
|
+
* Migration:
|
|
108
|
+
* // Old:
|
|
109
|
+
* const key = ModuleFE_Routing.getMyRouteKey();
|
|
110
|
+
*
|
|
111
|
+
* // New:
|
|
112
|
+
* const route = ModuleFE_RoutingV2.getCurrentRouteKey();
|
|
113
|
+
* const key = route?.key;
|
|
114
|
+
*/
|
|
19
115
|
getMyRouteKey: () => string | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated Use ModuleFE_RoutingV2 with TS_NavLink component instead
|
|
118
|
+
*
|
|
119
|
+
* Migration: Use TS_NavLink component from ModuleFE_RoutingV2 with route objects
|
|
120
|
+
*/
|
|
20
121
|
getNavLinks(keys: string[]): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated Use TS_NavLink from ModuleFE_RoutingV2 instead
|
|
124
|
+
*
|
|
125
|
+
* Migration: Use <TS_NavLink route={routeObject}> component
|
|
126
|
+
*/
|
|
21
127
|
getNavLink(key: string): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated Use standard React Router Link or TS_NavLink from ModuleFE_RoutingV2
|
|
130
|
+
*/
|
|
22
131
|
getLink(key: string): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
132
|
+
/**
|
|
133
|
+
* @deprecated Use ModuleFE_RoutingV2.generateRoutes() instead
|
|
134
|
+
*
|
|
135
|
+
* Migration:
|
|
136
|
+
* // Old:
|
|
137
|
+
* {ModuleFE_Routing.getRoutesMap()}
|
|
138
|
+
*
|
|
139
|
+
* // New:
|
|
140
|
+
* {ModuleFE_RoutingV2.generateRoutes(rootRoute)}
|
|
141
|
+
*/
|
|
23
142
|
getRoutesMap(keys?: string[]): import("react/jsx-runtime").JSX.Element;
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrentUrl() instead
|
|
145
|
+
*
|
|
146
|
+
* Migration:
|
|
147
|
+
* // Old:
|
|
148
|
+
* const url = ModuleFE_Routing.getCurrentUrl();
|
|
149
|
+
*
|
|
150
|
+
* // New:
|
|
151
|
+
* const url = ModuleFE_RoutingV2.getCurrentUrl();
|
|
152
|
+
*/
|
|
24
153
|
getCurrentUrl: () => string;
|
|
25
154
|
private getEncodedQueryParams;
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParams() instead
|
|
157
|
+
*
|
|
158
|
+
* Migration:
|
|
159
|
+
* // Old:
|
|
160
|
+
* const params = ModuleFE_Routing.getSearch();
|
|
161
|
+
*
|
|
162
|
+
* // New:
|
|
163
|
+
* const params = ModuleFE_RoutingV2.getQueryParams();
|
|
164
|
+
*/
|
|
26
165
|
getSearch(): QueryParams;
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Use ModuleFE_RoutingV2.push() or ModuleFE_RoutingV2.goToRoute() instead
|
|
168
|
+
*
|
|
169
|
+
* Migration:
|
|
170
|
+
* // Old:
|
|
171
|
+
* ModuleFE_Routing.goToUrl('/path');
|
|
172
|
+
*
|
|
173
|
+
* // New:
|
|
174
|
+
* ModuleFE_RoutingV2.push({pathname: '/path'});
|
|
175
|
+
*/
|
|
27
176
|
goToUrl: (url: string) => string;
|
|
28
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* @deprecated Use ModuleFE_RoutingV2 instead. This export will be removed in a future version.
|
|
180
|
+
*
|
|
181
|
+
* See file-level deprecation notice for migration guide.
|
|
182
|
+
*/
|
|
29
183
|
export declare const ModuleFE_Routing: ModuleFE_Routing_Class;
|
|
30
184
|
export {};
|
|
@@ -19,10 +19,37 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated This module is deprecated. Use ModuleFE_RoutingV2 instead.
|
|
24
|
+
*
|
|
25
|
+
* Migration Guide:
|
|
26
|
+
*
|
|
27
|
+
* ModuleFE_Routing uses an imperative API (addRoute, clearRoutes) while ModuleFE_RoutingV2 uses a declarative
|
|
28
|
+
* route object API (TS_Route). Migration requires refactoring route definitions.
|
|
29
|
+
*
|
|
30
|
+
* Key Differences:
|
|
31
|
+
* - Old: ModuleFE_Routing.addRoute(key, path, component)
|
|
32
|
+
* - New: Define TS_Route objects with key, path, Component properties
|
|
33
|
+
*
|
|
34
|
+
* - Old: ModuleFE_Routing.goToRoute(key, params)
|
|
35
|
+
* - New: ModuleFE_RoutingV2.goToRoute(routeObject, params)
|
|
36
|
+
*
|
|
37
|
+
* - Old: ModuleFE_Routing.getRoutesMap()
|
|
38
|
+
* - New: ModuleFE_RoutingV2.generateRoutes(rootRoute) - returns JSX
|
|
39
|
+
*
|
|
40
|
+
* See ModuleFE_RoutingV2 and TS_Route type for the new API.
|
|
41
|
+
*
|
|
42
|
+
* This module will be removed in a future version. Please migrate to ModuleFE_RoutingV2.
|
|
43
|
+
*/
|
|
22
44
|
import { _keys, addItemToArray, BadImplementationException, composeQueryParams, Module } from '@nu-art/ts-common';
|
|
23
45
|
import { defaultLinkNode, defaultNavLinkNode, defaultRouteNode, RoutePath } from './route.js';
|
|
24
|
-
import {
|
|
46
|
+
import { ModuleFE_RoutingV2 } from './ModuleFE_RoutingV2.js';
|
|
25
47
|
import { Navigate, Routes } from 'react-router-dom';
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Use ModuleFE_RoutingV2 instead. This class will be removed in a future version.
|
|
50
|
+
*
|
|
51
|
+
* All functionality has been migrated to ModuleFE_RoutingV2. See file-level deprecation notice for migration guide.
|
|
52
|
+
*/
|
|
26
53
|
class ModuleFE_Routing_Class extends Module {
|
|
27
54
|
routes = {};
|
|
28
55
|
ordinalRoutes = [];
|
|
@@ -37,12 +64,28 @@ class ModuleFE_Routing_Class extends Module {
|
|
|
37
64
|
}
|
|
38
65
|
init() {
|
|
39
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated Use ModuleFE_RoutingV2 with TS_Route objects instead
|
|
69
|
+
*
|
|
70
|
+
* Migration: Define routes as TS_Route objects and pass to ModuleFE_RoutingV2.generateRoutes()
|
|
71
|
+
*/
|
|
40
72
|
clearRoutes() {
|
|
41
73
|
for (const item of this.ordinalRoutes) {
|
|
42
74
|
delete this.routes[item];
|
|
43
75
|
}
|
|
44
76
|
this.ordinalRoutes.splice(0);
|
|
45
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated Use ModuleFE_RoutingV2 with TS_Route objects instead
|
|
80
|
+
*
|
|
81
|
+
* Migration:
|
|
82
|
+
* // Old:
|
|
83
|
+
* ModuleFE_Routing.addRoute('home', '/', HomeComponent);
|
|
84
|
+
*
|
|
85
|
+
* // New:
|
|
86
|
+
* const route: TS_Route = { key: 'home', path: '/', Component: HomeComponent };
|
|
87
|
+
* // Then use ModuleFE_RoutingV2.generateRoutes(rootRoute) where rootRoute contains this route
|
|
88
|
+
*/
|
|
46
89
|
addRoute(key, route, component) {
|
|
47
90
|
const previousRoute = this.routes[key];
|
|
48
91
|
if (previousRoute)
|
|
@@ -50,37 +93,123 @@ class ModuleFE_Routing_Class extends Module {
|
|
|
50
93
|
addItemToArray(this.ordinalRoutes, key);
|
|
51
94
|
return this.routes[key] = new RoutePath(key, route, component);
|
|
52
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated Use ModuleFE_RoutingV2.getRouteByKey() instead
|
|
98
|
+
*
|
|
99
|
+
* Migration:
|
|
100
|
+
* // Old:
|
|
101
|
+
* const route = ModuleFE_Routing.getRoute(key);
|
|
102
|
+
*
|
|
103
|
+
* // New:
|
|
104
|
+
* const route = ModuleFE_RoutingV2.getRouteByKey(key);
|
|
105
|
+
*/
|
|
53
106
|
getRoute(key) {
|
|
54
107
|
const route = this.routes[key];
|
|
55
108
|
if (!route)
|
|
56
109
|
throw new BadImplementationException(`No Route for key '${key}'... Did you forget to add it??`);
|
|
57
110
|
return route;
|
|
58
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated Use ModuleFE_RoutingV2.getFullPath() instead
|
|
114
|
+
*
|
|
115
|
+
* Migration:
|
|
116
|
+
* // Old:
|
|
117
|
+
* const path = ModuleFE_Routing.getPath(key);
|
|
118
|
+
*
|
|
119
|
+
* // New:
|
|
120
|
+
* const path = ModuleFE_RoutingV2.getFullPath(key);
|
|
121
|
+
*/
|
|
59
122
|
getPath(key) {
|
|
60
123
|
return this.getRoute(key).path;
|
|
61
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated Use ModuleFE_RoutingV2.goToRoute() instead
|
|
127
|
+
*
|
|
128
|
+
* Migration:
|
|
129
|
+
* // Old:
|
|
130
|
+
* ModuleFE_Routing.goToRoute(key, params);
|
|
131
|
+
*
|
|
132
|
+
* // New:
|
|
133
|
+
* const route = ModuleFE_RoutingV2.getRouteByKey(key);
|
|
134
|
+
* if (route) ModuleFE_RoutingV2.goToRoute(route, params);
|
|
135
|
+
*/
|
|
62
136
|
goToRoute(key, params) {
|
|
63
137
|
const pathname = this.getPath(key);
|
|
64
138
|
const search = composeQueryParams(params);
|
|
65
|
-
|
|
139
|
+
ModuleFE_RoutingV2.push({ pathname, search: search ? `?${search}` : '' });
|
|
66
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated Use ModuleFE_RoutingV2.redirect() instead
|
|
143
|
+
*
|
|
144
|
+
* Migration:
|
|
145
|
+
* // Old:
|
|
146
|
+
* return ModuleFE_Routing.redirect(key);
|
|
147
|
+
*
|
|
148
|
+
* // New:
|
|
149
|
+
* const route = ModuleFE_RoutingV2.getRouteByKey(key);
|
|
150
|
+
* if (route) return ModuleFE_RoutingV2.redirect(route);
|
|
151
|
+
*/
|
|
67
152
|
redirect(key) {
|
|
68
153
|
return _jsx(Navigate, { to: ModuleFE_Routing.getPath(key) });
|
|
69
154
|
}
|
|
70
|
-
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrentRouteKey() instead
|
|
157
|
+
*
|
|
158
|
+
* Migration:
|
|
159
|
+
* // Old:
|
|
160
|
+
* const key = ModuleFE_Routing.getMyRouteKey();
|
|
161
|
+
*
|
|
162
|
+
* // New:
|
|
163
|
+
* const route = ModuleFE_RoutingV2.getCurrentRouteKey();
|
|
164
|
+
* const key = route?.key;
|
|
165
|
+
*/
|
|
166
|
+
getMyRouteKey = () => Object.keys(this.routes).find(key => this.routes[key].path === ModuleFE_RoutingV2.getCurrent().pathname);
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated Use ModuleFE_RoutingV2 with TS_NavLink component instead
|
|
169
|
+
*
|
|
170
|
+
* Migration: Use TS_NavLink component from ModuleFE_RoutingV2 with route objects
|
|
171
|
+
*/
|
|
71
172
|
// need to figure out how to create parameterized urls from this call !!
|
|
72
173
|
getNavLinks(keys) {
|
|
73
174
|
return keys.map(key => this.getRoute(key)).filter(route => route.visible && route.visible()).map(route => this.createNavLinkNode(route));
|
|
74
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* @deprecated Use TS_NavLink from ModuleFE_RoutingV2 instead
|
|
178
|
+
*
|
|
179
|
+
* Migration: Use <TS_NavLink route={routeObject}> component
|
|
180
|
+
*/
|
|
75
181
|
getNavLink(key) {
|
|
76
182
|
return this.createNavLinkNode(this.getRoute(key));
|
|
77
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* @deprecated Use standard React Router Link or TS_NavLink from ModuleFE_RoutingV2
|
|
186
|
+
*/
|
|
78
187
|
getLink(key) {
|
|
79
188
|
return this.createLinkNode(this.getRoute(key));
|
|
80
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* @deprecated Use ModuleFE_RoutingV2.generateRoutes() instead
|
|
192
|
+
*
|
|
193
|
+
* Migration:
|
|
194
|
+
* // Old:
|
|
195
|
+
* {ModuleFE_Routing.getRoutesMap()}
|
|
196
|
+
*
|
|
197
|
+
* // New:
|
|
198
|
+
* {ModuleFE_RoutingV2.generateRoutes(rootRoute)}
|
|
199
|
+
*/
|
|
81
200
|
getRoutesMap(keys) {
|
|
82
201
|
return _jsx(Routes, { children: (keys || this.ordinalRoutes).map(key => this.createRouteNode(this.getRoute(key))) });
|
|
83
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrentUrl() instead
|
|
205
|
+
*
|
|
206
|
+
* Migration:
|
|
207
|
+
* // Old:
|
|
208
|
+
* const url = ModuleFE_Routing.getCurrentUrl();
|
|
209
|
+
*
|
|
210
|
+
* // New:
|
|
211
|
+
* const url = ModuleFE_RoutingV2.getCurrentUrl();
|
|
212
|
+
*/
|
|
84
213
|
getCurrentUrl = () => window.location.href;
|
|
85
214
|
getEncodedQueryParams = () => {
|
|
86
215
|
const queryParams = {};
|
|
@@ -105,6 +234,16 @@ class ModuleFE_Routing_Class extends Module {
|
|
|
105
234
|
return toRet;
|
|
106
235
|
}, queryParams);
|
|
107
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParams() instead
|
|
239
|
+
*
|
|
240
|
+
* Migration:
|
|
241
|
+
* // Old:
|
|
242
|
+
* const params = ModuleFE_Routing.getSearch();
|
|
243
|
+
*
|
|
244
|
+
* // New:
|
|
245
|
+
* const params = ModuleFE_RoutingV2.getQueryParams();
|
|
246
|
+
*/
|
|
108
247
|
getSearch() {
|
|
109
248
|
const params = this.getEncodedQueryParams();
|
|
110
249
|
_keys(params).forEach(key => {
|
|
@@ -117,6 +256,21 @@ class ModuleFE_Routing_Class extends Module {
|
|
|
117
256
|
});
|
|
118
257
|
return params;
|
|
119
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* @deprecated Use ModuleFE_RoutingV2.push() or ModuleFE_RoutingV2.goToRoute() instead
|
|
261
|
+
*
|
|
262
|
+
* Migration:
|
|
263
|
+
* // Old:
|
|
264
|
+
* ModuleFE_Routing.goToUrl('/path');
|
|
265
|
+
*
|
|
266
|
+
* // New:
|
|
267
|
+
* ModuleFE_RoutingV2.push({pathname: '/path'});
|
|
268
|
+
*/
|
|
120
269
|
goToUrl = (url) => window.location.href = url;
|
|
121
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* @deprecated Use ModuleFE_RoutingV2 instead. This export will be removed in a future version.
|
|
273
|
+
*
|
|
274
|
+
* See file-level deprecation notice for migration guide.
|
|
275
|
+
*/
|
|
122
276
|
export const ModuleFE_Routing = new ModuleFE_Routing_Class();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NavigateFunction, NavLinkProps } from 'react-router-dom';
|
|
2
2
|
import { TS_Route } from './types.js';
|
|
3
3
|
import { Module } from '@nu-art/ts-common';
|
|
4
|
-
import { QueryParams } from '@nu-art/thunderstorm-shared';
|
|
4
|
+
import { QueryParams, UrlQueryParams } from '@nu-art/thunderstorm-shared';
|
|
5
5
|
declare class ModuleFE_RoutingV2_Class extends Module<{}> {
|
|
6
6
|
private routesMapByKey;
|
|
7
7
|
private routesMapByPath;
|
|
@@ -16,10 +16,100 @@ declare class ModuleFE_RoutingV2_Class extends Module<{}> {
|
|
|
16
16
|
getFullPath(routeKey: string): string;
|
|
17
17
|
getCurrentRouteKey(): TS_Route;
|
|
18
18
|
setNavigate(navigate: NavigateFunction): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get all query parameters from the current URL (decoded)
|
|
21
|
+
*/
|
|
22
|
+
getQueryParams(): UrlQueryParams;
|
|
23
|
+
/**
|
|
24
|
+
* Get a single query parameter from the current URL
|
|
25
|
+
* @param key - The query parameter key
|
|
26
|
+
* @returns The decoded value, null if key exists but value is empty, or undefined if key doesn't exist
|
|
27
|
+
*/
|
|
28
|
+
getQueryParameter(key: string): string | null | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Replace all query parameters on the current route
|
|
31
|
+
* @param queryParams - The query parameters to set
|
|
32
|
+
*/
|
|
33
|
+
setQuery(queryParams: UrlQueryParams): void;
|
|
34
|
+
/**
|
|
35
|
+
* Add or update a single query parameter on the current route
|
|
36
|
+
* @param key - The query parameter key
|
|
37
|
+
* @param value - The query parameter value
|
|
38
|
+
*/
|
|
39
|
+
addQueryParam(key: string, value: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Remove a single query parameter from the current route
|
|
42
|
+
* @param key - The query parameter key to remove
|
|
43
|
+
*/
|
|
44
|
+
removeQueryParam(key: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Get the current location object (compatible with BrowserHistory.getCurrent())
|
|
47
|
+
* @returns Object with pathname and search properties
|
|
48
|
+
*/
|
|
49
|
+
getCurrent(): {
|
|
50
|
+
pathname: string;
|
|
51
|
+
search: string;
|
|
52
|
+
hash?: string;
|
|
53
|
+
state?: any;
|
|
54
|
+
key?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Get the current URL pathname
|
|
58
|
+
* @returns The current pathname
|
|
59
|
+
*/
|
|
60
|
+
getCurrentUrl(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Get the window origin
|
|
63
|
+
* @returns The origin (protocol + hostname + port)
|
|
64
|
+
*/
|
|
65
|
+
getOrigin(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Navigate to a pathname with optional query params (adds to history)
|
|
68
|
+
* @param location - Location descriptor with pathname and optional search
|
|
69
|
+
*/
|
|
70
|
+
push(location: {
|
|
71
|
+
pathname: string;
|
|
72
|
+
search?: string;
|
|
73
|
+
hash?: string;
|
|
74
|
+
}): void;
|
|
75
|
+
/**
|
|
76
|
+
* Replace current history entry with new pathname and optional query params
|
|
77
|
+
* @param location - Location descriptor with pathname and optional search
|
|
78
|
+
*/
|
|
79
|
+
replace(location: {
|
|
80
|
+
pathname: string;
|
|
81
|
+
search?: string;
|
|
82
|
+
hash?: string;
|
|
83
|
+
}): void;
|
|
84
|
+
private getEncodedQueryParams;
|
|
85
|
+
private composeQuery;
|
|
86
|
+
private encodeUrlParams;
|
|
87
|
+
private createLocationDataFromQueryParams;
|
|
88
|
+
private updateQueryParams;
|
|
89
|
+
private composeLocationUrl;
|
|
19
90
|
}
|
|
20
91
|
export declare const TS_NavLink: (props: {
|
|
21
92
|
route: TS_Route;
|
|
22
93
|
ignoreClickOnSameRoute?: boolean;
|
|
23
94
|
} & Partial<NavLinkProps>) => import("react/jsx-runtime").JSX.Element;
|
|
24
95
|
export declare const ModuleFE_RoutingV2: ModuleFE_RoutingV2_Class;
|
|
96
|
+
/**
|
|
97
|
+
* Encode URL query parameters
|
|
98
|
+
* @param queryParams - Query parameters to encode
|
|
99
|
+
* @returns Encoded query parameters
|
|
100
|
+
*/
|
|
101
|
+
export declare function encodeUrlParams(queryParams?: UrlQueryParams): UrlQueryParams;
|
|
102
|
+
/**
|
|
103
|
+
* Compose a query string from query parameters
|
|
104
|
+
* @param queryParams - Query parameters to compose
|
|
105
|
+
* @returns Query string (without leading ?)
|
|
106
|
+
*/
|
|
107
|
+
export declare function composeQuery(queryParams?: UrlQueryParams): string;
|
|
108
|
+
/**
|
|
109
|
+
* Compose a full URL with query parameters
|
|
110
|
+
* @param url - Base URL
|
|
111
|
+
* @param queryParams - Optional query parameters
|
|
112
|
+
* @returns Full URL with query string
|
|
113
|
+
*/
|
|
114
|
+
export declare function composeURL(url: string, queryParams?: UrlQueryParams): string;
|
|
25
115
|
export {};
|