@xh/hoist 74.0.0-SNAPSHOT.1747440631981 → 74.0.0-SNAPSHOT.1747519346365
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.
|
@@ -27,6 +27,10 @@ export interface NavigatorConfig {
|
|
|
27
27
|
* See enum for description of supported modes.
|
|
28
28
|
*/
|
|
29
29
|
refreshMode?: RefreshMode;
|
|
30
|
+
/**
|
|
31
|
+
* Base route name for this navigator, with the route for each page being "[route]/[page.id]".
|
|
32
|
+
*/
|
|
33
|
+
route?: string;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* Model for handling stack-based navigation between pages.
|
|
@@ -34,6 +38,8 @@ export interface NavigatorConfig {
|
|
|
34
38
|
*/
|
|
35
39
|
export declare class NavigatorModel extends HoistModel {
|
|
36
40
|
disableAppRefreshButton: boolean;
|
|
41
|
+
readonly route: string;
|
|
42
|
+
readonly routePrefix: string;
|
|
37
43
|
stack: PageModel[];
|
|
38
44
|
pages: PageConfig[];
|
|
39
45
|
track: boolean;
|
|
@@ -49,7 +55,7 @@ export declare class NavigatorModel extends HoistModel {
|
|
|
49
55
|
get activePageIdx(): number;
|
|
50
56
|
get allowSlideNext(): boolean;
|
|
51
57
|
get allowSlidePrev(): boolean;
|
|
52
|
-
constructor({ pages, track, pullDownToRefresh, transitionMs, renderMode, refreshMode }: NavigatorConfig);
|
|
58
|
+
constructor({ pages, route, track, pullDownToRefresh, transitionMs, renderMode, refreshMode }: NavigatorConfig);
|
|
53
59
|
/**
|
|
54
60
|
* @param callback - function to execute (once) after the next page transition.
|
|
55
61
|
*/
|
|
@@ -144,10 +144,10 @@ export class TabContainerModel extends HoistModel implements Persistable<{active
|
|
|
144
144
|
this.refreshContextModel.xhImpl = xhImpl;
|
|
145
145
|
|
|
146
146
|
if (route) {
|
|
147
|
-
if (XH.isMobileApp) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
147
|
+
// if (XH.isMobileApp) {
|
|
148
|
+
// this.logWarn('TabContainer routing is not supported for mobile applications.');
|
|
149
|
+
// return;
|
|
150
|
+
// }
|
|
151
151
|
|
|
152
152
|
this.addReaction({
|
|
153
153
|
track: () => XH.routerState,
|
|
@@ -44,6 +44,11 @@ export interface NavigatorConfig {
|
|
|
44
44
|
* See enum for description of supported modes.
|
|
45
45
|
*/
|
|
46
46
|
refreshMode?: RefreshMode;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Base route name for this navigator, with the route for each page being "[route]/[page.id]".
|
|
50
|
+
*/
|
|
51
|
+
route?: string;
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
/**
|
|
@@ -53,6 +58,9 @@ export interface NavigatorConfig {
|
|
|
53
58
|
export class NavigatorModel extends HoistModel {
|
|
54
59
|
@bindable disableAppRefreshButton: boolean;
|
|
55
60
|
|
|
61
|
+
readonly route: string;
|
|
62
|
+
readonly routePrefix: string;
|
|
63
|
+
|
|
56
64
|
@bindable.ref
|
|
57
65
|
stack: PageModel[] = [];
|
|
58
66
|
|
|
@@ -89,6 +97,7 @@ export class NavigatorModel extends HoistModel {
|
|
|
89
97
|
|
|
90
98
|
constructor({
|
|
91
99
|
pages,
|
|
100
|
+
route,
|
|
92
101
|
track = false,
|
|
93
102
|
pullDownToRefresh = true,
|
|
94
103
|
transitionMs = 500,
|
|
@@ -101,6 +110,9 @@ export class NavigatorModel extends HoistModel {
|
|
|
101
110
|
ensureNotEmpty(pages, 'NavigatorModel needs at least one page.');
|
|
102
111
|
ensureUniqueBy(pages, 'id', 'Multiple NavigatorModel PageModels have the same id.');
|
|
103
112
|
|
|
113
|
+
this.route = route ?? '';
|
|
114
|
+
this.routePrefix = route ? route.substring(0, route.lastIndexOf('.') + 1) : '';
|
|
115
|
+
|
|
104
116
|
this.pages = pages;
|
|
105
117
|
this.track = track;
|
|
106
118
|
this.pullDownToRefresh = pullDownToRefresh;
|
|
@@ -209,7 +221,7 @@ export class NavigatorModel extends HoistModel {
|
|
|
209
221
|
this.stack = this.stack.slice(0, this._swiper.activeIndex + 1);
|
|
210
222
|
|
|
211
223
|
// 2) Sync route to match the current page stack
|
|
212
|
-
const newRouteName = this.stack.map(it => it.id).join('.'),
|
|
224
|
+
const newRouteName = this.routePrefix + this.stack.map(it => it.id).join('.'),
|
|
213
225
|
newRouteParams = mergeDeep({}, ...this.stack.map(it => it.props));
|
|
214
226
|
|
|
215
227
|
XH.navigate(newRouteName, newRouteParams);
|
|
@@ -226,16 +238,17 @@ export class NavigatorModel extends HoistModel {
|
|
|
226
238
|
};
|
|
227
239
|
|
|
228
240
|
private onRouteChange(init: boolean = false) {
|
|
229
|
-
|
|
241
|
+
const {route: myRoute, routePrefix: myRoutePrefix, _swiper} = this;
|
|
242
|
+
if (!XH.routerState || (myRoute && !XH.router.isActive(myRoute)) || !_swiper) return;
|
|
230
243
|
|
|
231
|
-
// Break the current route name into parts,
|
|
232
|
-
// Use meta.params to determine which params are associated
|
|
233
|
-
// Save these params to use as props for the page.
|
|
244
|
+
// Break the current route name into parts, only looking at our part of it (myRoute and below).
|
|
245
|
+
// Collect any params for each part. Use meta.params to determine which params are associated
|
|
246
|
+
// with each route part. Save these params to use as props for the page.
|
|
234
247
|
const {meta, name, params} = XH.routerState,
|
|
235
|
-
parts = name.split('.');
|
|
248
|
+
parts = name.replace(myRoutePrefix, '').split('.');
|
|
236
249
|
|
|
237
250
|
const routeParts = parts.map((id, idx) => {
|
|
238
|
-
const metaKey = parts.slice(0, idx + 1).join('.'),
|
|
251
|
+
const metaKey = myRoutePrefix + parts.slice(0, idx + 1).join('.'),
|
|
239
252
|
props = {};
|
|
240
253
|
|
|
241
254
|
// Extract props for this part
|
|
@@ -262,7 +275,7 @@ export class NavigatorModel extends HoistModel {
|
|
|
262
275
|
// we drop the rest of the route and redirect to the route so far
|
|
263
276
|
if (init && pageModelCfg.disableDirectLink) {
|
|
264
277
|
const completedRouteParts = routeParts.slice(0, i),
|
|
265
|
-
newRouteName = completedRouteParts.map(it => it.id).join('.'),
|
|
278
|
+
newRouteName = myRoutePrefix + completedRouteParts.map(it => it.id).join('.'),
|
|
266
279
|
newRouteParams = mergeDeep({}, ...completedRouteParts.map(it => it.props));
|
|
267
280
|
|
|
268
281
|
XH.navigate(newRouteName, newRouteParams, {replace: true});
|
package/mobx/overrides.ts
CHANGED
|
@@ -81,7 +81,7 @@ export function checkMakeObservable(target: any) {
|
|
|
81
81
|
if (!isEmpty(missing)) {
|
|
82
82
|
logError(
|
|
83
83
|
`Observable properties [${missing.join(', ')}] not initialized properly. ` +
|
|
84
|
-
'Ensure you call makeObservable() in your constructor',
|
|
84
|
+
'Ensure you call makeObservable(this) in your constructor',
|
|
85
85
|
target
|
|
86
86
|
);
|
|
87
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "74.0.0-SNAPSHOT.
|
|
3
|
+
"version": "74.0.0-SNAPSHOT.1747519346365",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|