@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 `
|
|
8
|
-
|
|
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
|
|
90
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
|
129
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
|
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
|
|
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 {
|
|
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
|
-
|
|
167
|
-
?
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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.
|
|
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",
|