@xh/hoist 73.0.0-SNAPSHOT.1746050507413 → 73.0.0-SNAPSHOT.1746195895077

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/admin/AppModel.ts CHANGED
@@ -170,7 +170,8 @@ export class AppModel extends HoistAppModel {
170
170
  async initViewManagerModelsAsync() {
171
171
  this.viewManagerModels.activityTracking = await ViewManagerModel.createAsync({
172
172
  type: 'xhAdminActivityTrackingView',
173
- typeDisplayName: 'View'
173
+ typeDisplayName: 'View',
174
+ manageGlobal: XH.getUser().isHoistAdmin
174
175
  });
175
176
  }
176
177
  }
@@ -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
- this.logWarn('TabContainer routing is not supported for mobile applications.');
149
- return;
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,
@@ -356,8 +356,11 @@ export class TabContainerModel extends HoistModel implements Persistable<{active
356
356
  {router} = XH,
357
357
  state = router.getState();
358
358
 
359
+ console.log('syncWithRouter', state, router.isActive(route));
360
+
359
361
  if (state && router.isActive(route)) {
360
362
  const tab = tabs.find(t => router.isActive(route + '.' + t.id, state.params));
363
+ console.log('activating', tab);
361
364
  if (tab && !tab.isActive && !tab.disabled) {
362
365
  this.setActiveTabIdInternal(tab.id);
363
366
  }
@@ -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,10 @@ 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
+ console.log(this.route, this.routePrefix);
116
+
104
117
  this.pages = pages;
105
118
  this.track = track;
106
119
  this.pullDownToRefresh = pullDownToRefresh;
@@ -199,19 +212,22 @@ export class NavigatorModel extends HoistModel {
199
212
  swiper.allowTouchMove = false;
200
213
  });
201
214
 
215
+ console.log('swiper change');
202
216
  this.onRouteChange(true);
203
217
  }
204
218
 
205
219
  /** @internal */
206
220
  @action
207
221
  onPageChange = () => {
222
+ console.log('onPageChange');
208
223
  // 1) Clear any pages after the active page. These can be left over from a back swipe.
209
224
  this.stack = this.stack.slice(0, this._swiper.activeIndex + 1);
210
225
 
211
226
  // 2) Sync route to match the current page stack
212
- const newRouteName = this.stack.map(it => it.id).join('.'),
227
+ const newRouteName = this.routePrefix + this.stack.map(it => it.id).join('.'),
213
228
  newRouteParams = mergeDeep({}, ...this.stack.map(it => it.props));
214
229
 
230
+ console.log('newRouteName', newRouteName);
215
231
  XH.navigate(newRouteName, newRouteParams);
216
232
 
217
233
  // 3) Update state according to the active page and trigger optional callback
@@ -226,16 +242,18 @@ export class NavigatorModel extends HoistModel {
226
242
  };
227
243
 
228
244
  private onRouteChange(init: boolean = false) {
229
- if (!this._swiper || !XH.routerState) return;
245
+ const {route: myRoute, routePrefix: myRoutePrefix, _swiper} = this;
246
+ console.log('onRouteChange', XH.router.isActive(myRoute));
247
+ if (!XH.routerState || (myRoute && !XH.router.isActive(myRoute)) || !_swiper) return;
230
248
 
231
- // Break the current route name into parts, and collect any params for each part.
232
- // Use meta.params to determine which params are associated with each route part.
233
- // Save these params to use as props for the page.
249
+ // Break the current route name into parts, only looking at our part of it (myRoute and below).
250
+ // Collect any params for each part. Use meta.params to determine which params are associated
251
+ // with each route part. Save these params to use as props for the page.
234
252
  const {meta, name, params} = XH.routerState,
235
- parts = name.split('.');
253
+ parts = name.replace(myRoutePrefix, '').split('.');
236
254
 
237
255
  const routeParts = parts.map((id, idx) => {
238
- const metaKey = parts.slice(0, idx + 1).join('.'),
256
+ const metaKey = myRoutePrefix + parts.slice(0, idx + 1).join('.'),
239
257
  props = {};
240
258
 
241
259
  // Extract props for this part
@@ -245,6 +263,7 @@ export class NavigatorModel extends HoistModel {
245
263
 
246
264
  return {id, props};
247
265
  });
266
+ console.log(myRoutePrefix, XH.routerState, parts, routeParts);
248
267
 
249
268
  // Loop through the route parts, rebuilding the page stack to match.
250
269
  const stack = [];
@@ -262,7 +281,7 @@ export class NavigatorModel extends HoistModel {
262
281
  // we drop the rest of the route and redirect to the route so far
263
282
  if (init && pageModelCfg.disableDirectLink) {
264
283
  const completedRouteParts = routeParts.slice(0, i),
265
- newRouteName = completedRouteParts.map(it => it.id).join('.'),
284
+ newRouteName = myRoutePrefix + completedRouteParts.map(it => it.id).join('.'),
266
285
  newRouteParams = mergeDeep({}, ...completedRouteParts.map(it => it.props));
267
286
 
268
287
  XH.navigate(newRouteName, newRouteParams, {replace: true});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "73.0.0-SNAPSHOT.1746050507413",
3
+ "version": "73.0.0-SNAPSHOT.1746195895077",
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",