@xh/hoist 73.0.0-SNAPSHOT.1744142528681 → 73.0.0-SNAPSHOT.1744145292985

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
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## v73.0.0-SNAPSHOT - unreleased
4
4
 
5
+ ### 🎁 New Features
6
+
7
+ `ViewManagerConfig` takes new key `customViewMenuItem` to allow ViewManagers implementations to customize
8
+ the menu items for views in the view manager menu.
9
+
5
10
  ## v72.3.0 - 2025-04-08
6
11
 
7
12
  ### 🎁 New Features
@@ -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 {
@@ -85,6 +86,12 @@ export interface ViewManagerConfig {
85
86
  * Optional user-facing display name for describing global views. Defaults to 'global'
86
87
  */
87
88
  globalDisplayName?: string;
89
+ /**
90
+ * Optional key used as route param for view tokens. Specify if you have customized your
91
+ * ViewManager implementation to be routable, and you want users to be able to Ctrl+Click or
92
+ * ContextMenu Click to open views from the view menu in new tabs or windows.
93
+ */
94
+ customViewMenuItem?: (view: ViewInfo) => ReactNode;
88
95
  }
89
96
  /**
90
97
  * ViewManagerModel coordinates the loading, saving, and management of user-defined bundles of
@@ -121,6 +128,7 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
121
128
  readonly instance: string;
122
129
  readonly typeDisplayName: string;
123
130
  readonly globalDisplayName: string;
131
+ readonly customViewMenuItem: (view: ViewInfo) => ReactNode;
124
132
  readonly enableAutoSave: boolean;
125
133
  readonly enableDefault: boolean;
126
134
  readonly enableGlobal: boolean;
@@ -123,6 +123,13 @@ export interface ViewManagerConfig {
123
123
  * Optional user-facing display name for describing global views. Defaults to 'global'
124
124
  */
125
125
  globalDisplayName?: string;
126
+
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.
131
+ */
132
+ customViewMenuItem?: (view: ViewInfo) => ReactNode;
126
133
  }
127
134
 
128
135
  /**
@@ -165,6 +172,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
165
172
  readonly instance: string;
166
173
  readonly typeDisplayName: string;
167
174
  readonly globalDisplayName: string;
175
+ readonly customViewMenuItem: (view: ViewInfo) => ReactNode;
168
176
  readonly enableAutoSave: boolean;
169
177
  readonly enableDefault: boolean;
170
178
  readonly enableGlobal: boolean;
@@ -283,6 +291,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
283
291
  instance = 'default',
284
292
  typeDisplayName,
285
293
  globalDisplayName = 'global',
294
+ customViewMenuItem,
286
295
  manageGlobal = false,
287
296
  enableAutoSave = true,
288
297
  enableDefault = true,
@@ -296,13 +305,14 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
296
305
 
297
306
  throwIf(
298
307
  !enableDefault && !initialViewSpec,
299
- "ViewManagerModel requires 'initialViewSpec' if `enableDefault` is false."
308
+ "ViewManagerModel requires 'initialViewSpec' if 'enableDefault' is false."
300
309
  );
301
310
 
302
311
  this.type = type;
303
312
  this.instance = instance;
304
313
  this.typeDisplayName = lowerCase(typeDisplayName ?? genDisplayName(type));
305
314
  this.globalDisplayName = globalDisplayName;
315
+ this.customViewMenuItem = customViewMenuItem;
306
316
  this.manageGlobal = executeIfFunction(manageGlobal) ?? false;
307
317
  this.enableDefault = enableDefault;
308
318
  this.enableGlobal = enableGlobal;
@@ -162,12 +162,14 @@ function viewMenuItem(view: ViewInfo, model: ViewManagerModel): ReactNode {
162
162
  if (!view.isOwned && view.owner) title.push(view.owner);
163
163
  if (view.description) title.push(view.description);
164
164
 
165
- return menuItem({
166
- className: 'xh-view-manager__menu-item',
167
- key: view.token,
168
- text: view.name,
169
- title: title.join(' | '),
170
- icon,
171
- onClick: () => model.selectViewAsync(view).catchDefault()
172
- });
165
+ return model.customViewMenuItem
166
+ ? model.customViewMenuItem(view)
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
+ });
173
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "73.0.0-SNAPSHOT.1744142528681",
3
+ "version": "73.0.0-SNAPSHOT.1744145292985",
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",