@xh/hoist 73.0.0-SNAPSHOT.1744144713361 → 73.0.0-SNAPSHOT.1744145524716

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/CHANGELOG.md CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  ### 🎁 New Features
6
6
 
7
- `ViewManagerConfig` takes new key `viewRouteParam` to allow ViewManagers implemented with routing to
8
- have the view buttons on their menu items be right clickable/Ctrl+ Click to open views in new tabs or windows.
7
+ `ViewManagerConfig` takes new optional key `customViewMenuItem` to allow ViewManagers implementations to customize
8
+ the menu items for views in the view manager menu.
9
9
 
10
10
  ## v72.3.0 - 2025-04-08
11
11
 
@@ -1,5 +1,6 @@
1
1
  import { HoistModel, LoadSpec, PlainObject, TaskObserver, Thunkable } from '@xh/hoist/core';
2
2
  import type { ViewManagerProvider } from '@xh/hoist/core';
3
+ import { ReactNode } from 'react';
3
4
  import { ViewInfo } from './ViewInfo';
4
5
  import { View } from './View';
5
6
  export interface ViewCreateSpec {
@@ -86,11 +87,10 @@ export interface ViewManagerConfig {
86
87
  */
87
88
  globalDisplayName?: string;
88
89
  /**
89
- * Optional key used as route param for view tokens. Specify if you have customized your
90
- * ViewManager implementation to be routable, and you want users to be able to Ctrl+Click or
91
- * ContextMenu Click to open views from the view menu in new tabs or windows.
90
+ * Optional key to pass a method that returns customized BlueprintJS `menuItem` for listing
91
+ * views in the ViewManager menu.
92
92
  */
93
- viewRouteParam?: string;
93
+ customViewMenuItem?: (view: ViewInfo, model: ViewManagerModel) => ReactNode;
94
94
  }
95
95
  /**
96
96
  * ViewManagerModel coordinates the loading, saving, and management of user-defined bundles of
@@ -127,7 +127,7 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
127
127
  readonly instance: string;
128
128
  readonly typeDisplayName: string;
129
129
  readonly globalDisplayName: string;
130
- readonly viewRouteParam: string;
130
+ readonly customViewMenuItem: (view: ViewInfo, model: ViewManagerModel) => ReactNode;
131
131
  readonly enableAutoSave: boolean;
132
132
  readonly enableDefault: boolean;
133
133
  readonly enableGlobal: boolean;
@@ -125,11 +125,10 @@ export interface ViewManagerConfig {
125
125
  globalDisplayName?: string;
126
126
 
127
127
  /**
128
- * Optional key used as route param for view tokens. Specify if you have customized your
129
- * ViewManager implementation to be routable, and you want users to be able to Ctrl+Click or
130
- * ContextMenu Click to open views from the view menu in new tabs or windows.
128
+ * Optional key to pass a method that returns customized BlueprintJS `menuItem` for listing
129
+ * views in the ViewManager menu.
131
130
  */
132
- viewRouteParam?: string;
131
+ customViewMenuItem?: (view: ViewInfo, model: ViewManagerModel) => ReactNode;
133
132
  }
134
133
 
135
134
  /**
@@ -172,7 +171,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
172
171
  readonly instance: string;
173
172
  readonly typeDisplayName: string;
174
173
  readonly globalDisplayName: string;
175
- readonly viewRouteParam: string;
174
+ readonly customViewMenuItem: (view: ViewInfo, model: ViewManagerModel) => ReactNode;
176
175
  readonly enableAutoSave: boolean;
177
176
  readonly enableDefault: boolean;
178
177
  readonly enableGlobal: boolean;
@@ -291,7 +290,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
291
290
  instance = 'default',
292
291
  typeDisplayName,
293
292
  globalDisplayName = 'global',
294
- viewRouteParam,
293
+ customViewMenuItem,
295
294
  manageGlobal = false,
296
295
  enableAutoSave = true,
297
296
  enableDefault = true,
@@ -308,16 +307,11 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
308
307
  "ViewManagerModel requires 'initialViewSpec' if 'enableDefault' is false."
309
308
  );
310
309
 
311
- throwIf(
312
- viewRouteParam && isNil(XH.routerState),
313
- "Cannot use 'viewRouteParam' if your app does not define a router."
314
- );
315
-
316
310
  this.type = type;
317
311
  this.instance = instance;
318
312
  this.typeDisplayName = lowerCase(typeDisplayName ?? genDisplayName(type));
319
313
  this.globalDisplayName = globalDisplayName;
320
- this.viewRouteParam = viewRouteParam;
314
+ this.customViewMenuItem = customViewMenuItem;
321
315
  this.manageGlobal = executeIfFunction(manageGlobal) ?? false;
322
316
  this.enableDefault = enableDefault;
323
317
  this.enableGlobal = enableGlobal;
@@ -5,12 +5,12 @@
5
5
  * Copyright © 2025 Extremely Heavy Industries Inc.
6
6
  */
7
7
 
8
- import {hoistCmp, XH} from '@xh/hoist/core';
8
+ import {hoistCmp} from '@xh/hoist/core';
9
9
  import {ViewManagerModel, ViewInfo} from '@xh/hoist/cmp/viewmanager';
10
10
  import {switchInput} from '@xh/hoist/desktop/cmp/input';
11
11
  import {Icon} from '@xh/hoist/icon';
12
12
  import {menu, menuDivider, menuItem} from '@xh/hoist/kit/blueprint';
13
- import {consumeEvent, pluralize} from '@xh/hoist/utils/js';
13
+ import {pluralize} from '@xh/hoist/utils/js';
14
14
  import {Dictionary} from 'express-serve-static-core';
15
15
  import {each, filter, groupBy, isEmpty, orderBy, some, startCase} from 'lodash';
16
16
  import {ReactNode} from 'react';
@@ -157,34 +157,19 @@ function getGroupedMenuItems(
157
157
 
158
158
  function viewMenuItem(view: ViewInfo, model: ViewManagerModel): ReactNode {
159
159
  const icon = view.isCurrentView ? Icon.check() : Icon.placeholder(),
160
- title = [],
161
- usingRouting = !!(XH.routerState && model.viewRouteParam);
160
+ title = [];
162
161
 
163
162
  if (!view.isOwned && view.owner) title.push(view.owner);
164
163
  if (view.description) title.push(view.description);
165
164
 
166
- const href = usingRouting
167
- ? XH.router.buildUrl(XH.routerState.name, {
168
- ...XH.routerState.params,
169
- [model.viewRouteParam]: view.token
170
- })
171
- : undefined;
172
-
173
- return menuItem({
174
- className: 'xh-view-manager__menu-item',
175
- key: view.token,
176
- text: view.name,
177
- title: title.join(' | '),
178
- icon,
179
- href,
180
- onClick: e => {
181
- if (!usingRouting || (e.button === 0 && !e.ctrlKey && !e.metaKey)) {
182
- consumeEvent(e);
183
- model.selectViewAsync(view).catchDefault();
184
- return false;
185
- }
186
-
187
- return true;
188
- }
189
- });
165
+ return model.customViewMenuItem
166
+ ? model.customViewMenuItem(view, model)
167
+ : menuItem({
168
+ className: 'xh-view-manager__menu-item',
169
+ key: view.token,
170
+ text: view.name,
171
+ title: title.join(' | '),
172
+ icon,
173
+ onClick: () => model.selectViewAsync(view).catchDefault()
174
+ });
190
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "73.0.0-SNAPSHOT.1744144713361",
3
+ "version": "73.0.0-SNAPSHOT.1744145524716",
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",