@xh/hoist 73.0.0-SNAPSHOT.1744144713361 → 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
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
### 🎁 New Features
|
|
6
6
|
|
|
7
|
-
`ViewManagerConfig` takes new key `
|
|
8
|
-
|
|
7
|
+
`ViewManagerConfig` takes new 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 {
|
|
@@ -90,7 +91,7 @@ export interface ViewManagerConfig {
|
|
|
90
91
|
* ViewManager implementation to be routable, and you want users to be able to Ctrl+Click or
|
|
91
92
|
* ContextMenu Click to open views from the view menu in new tabs or windows.
|
|
92
93
|
*/
|
|
93
|
-
|
|
94
|
+
customViewMenuItem?: (view: ViewInfo) => ReactNode;
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
96
97
|
* ViewManagerModel coordinates the loading, saving, and management of user-defined bundles of
|
|
@@ -127,7 +128,7 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
127
128
|
readonly instance: string;
|
|
128
129
|
readonly typeDisplayName: string;
|
|
129
130
|
readonly globalDisplayName: string;
|
|
130
|
-
readonly
|
|
131
|
+
readonly customViewMenuItem: (view: ViewInfo) => ReactNode;
|
|
131
132
|
readonly enableAutoSave: boolean;
|
|
132
133
|
readonly enableDefault: boolean;
|
|
133
134
|
readonly enableGlobal: boolean;
|
|
@@ -129,7 +129,7 @@ export interface ViewManagerConfig {
|
|
|
129
129
|
* ViewManager implementation to be routable, and you want users to be able to Ctrl+Click or
|
|
130
130
|
* ContextMenu Click to open views from the view menu in new tabs or windows.
|
|
131
131
|
*/
|
|
132
|
-
|
|
132
|
+
customViewMenuItem?: (view: ViewInfo) => ReactNode;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
@@ -172,7 +172,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
172
172
|
readonly instance: string;
|
|
173
173
|
readonly typeDisplayName: string;
|
|
174
174
|
readonly globalDisplayName: string;
|
|
175
|
-
readonly
|
|
175
|
+
readonly customViewMenuItem: (view: ViewInfo) => ReactNode;
|
|
176
176
|
readonly enableAutoSave: boolean;
|
|
177
177
|
readonly enableDefault: boolean;
|
|
178
178
|
readonly enableGlobal: boolean;
|
|
@@ -291,7 +291,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
291
291
|
instance = 'default',
|
|
292
292
|
typeDisplayName,
|
|
293
293
|
globalDisplayName = 'global',
|
|
294
|
-
|
|
294
|
+
customViewMenuItem,
|
|
295
295
|
manageGlobal = false,
|
|
296
296
|
enableAutoSave = true,
|
|
297
297
|
enableDefault = true,
|
|
@@ -308,16 +308,11 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
308
308
|
"ViewManagerModel requires 'initialViewSpec' if 'enableDefault' is false."
|
|
309
309
|
);
|
|
310
310
|
|
|
311
|
-
throwIf(
|
|
312
|
-
viewRouteParam && isNil(XH.routerState),
|
|
313
|
-
"Cannot use 'viewRouteParam' if your app does not define a router."
|
|
314
|
-
);
|
|
315
|
-
|
|
316
311
|
this.type = type;
|
|
317
312
|
this.instance = instance;
|
|
318
313
|
this.typeDisplayName = lowerCase(typeDisplayName ?? genDisplayName(type));
|
|
319
314
|
this.globalDisplayName = globalDisplayName;
|
|
320
|
-
this.
|
|
315
|
+
this.customViewMenuItem = customViewMenuItem;
|
|
321
316
|
this.manageGlobal = executeIfFunction(manageGlobal) ?? false;
|
|
322
317
|
this.enableDefault = enableDefault;
|
|
323
318
|
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)
|
|
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.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",
|