@xh/hoist 75.0.0-SNAPSHOT.1750963411217 → 75.0.0-SNAPSHOT.1750966316712
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 +9 -4
- package/build/types/desktop/cmp/viewmanager/ViewManager.d.ts +8 -1
- package/build/types/utils/impl/MenuItems.d.ts +13 -0
- package/build/types/utils/impl/index.d.ts +1 -0
- package/desktop/cmp/button/AppMenuButton.ts +3 -46
- package/desktop/cmp/viewmanager/ViewManager.ts +11 -3
- package/desktop/cmp/viewmanager/ViewMenu.ts +9 -2
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/utils/impl/MenuItems.ts +57 -0
- package/utils/impl/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,26 +3,31 @@
|
|
|
3
3
|
## v75.0.0-SNAPSHOT - unreleased
|
|
4
4
|
|
|
5
5
|
### 🎁 New Features
|
|
6
|
+
|
|
6
7
|
* Added props to `ViewManager` to customize icons used for different types of views, and modified
|
|
7
8
|
default icons for Global and Shared views.
|
|
9
|
+
* Added `ViewManager.extraMenuItems` prop to allow insertion of custom, app-specific items into the
|
|
10
|
+
component's standard menu.
|
|
8
11
|
|
|
9
12
|
## v74.0.0 - 2025-06-11
|
|
10
13
|
|
|
11
14
|
### 💥 Breaking Changes (upgrade difficulty: 🟢 LOW - minor changes to ViewManagerModel, ChartModel)
|
|
12
15
|
|
|
13
16
|
* Removed `ViewManagerModel.settleTime`. Now set via individual `PersistOptions.settleTime` instead.
|
|
14
|
-
* ️Removed `ChartModel.showContextMenu`.
|
|
15
|
-
property instead.
|
|
17
|
+
* ️Removed `ChartModel.showContextMenu`. Use a setting of `false` for the new
|
|
18
|
+
`ChartModel.contextMenu` property instead.
|
|
16
19
|
|
|
17
20
|
### 🎁 New Features
|
|
21
|
+
|
|
18
22
|
* Added `ViewManagerModel.preserveUnsavedChanges` flag to opt-out of that behaviour.
|
|
19
23
|
* Added `PersistOptions.settleTime` to configure time to wait for state to settle before persisting.
|
|
20
24
|
* Support for grid column level `onCellClicked` events.
|
|
21
25
|
* General improvements to `MenuItem` api
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
* New `MenuContext` object now sent as 2nd arg to `actionFn` and `prepareFn`.
|
|
27
|
+
* New `ChartModel.contextMenu` property provides a fully customizable context menu for charts.
|
|
24
28
|
|
|
25
29
|
### 🐞 Bug Fixes
|
|
30
|
+
|
|
26
31
|
* Improved `ViewManagerModel.settleTime` by delegating to individual `PersistenceProviders`.
|
|
27
32
|
* Fixed bug where grid column state could become unintentionally dirty when columns were hidden.
|
|
28
33
|
* Improved `WebsocketService` heartbeat detection to auto-reconnect when the socket reports as open
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HoistProps } from '@xh/hoist/core';
|
|
1
|
+
import { HoistProps, MenuItemLike } from '@xh/hoist/core';
|
|
2
2
|
import { ViewManagerModel } from '@xh/hoist/cmp/viewmanager';
|
|
3
3
|
import { ButtonProps } from '@xh/hoist/desktop/cmp/button';
|
|
4
4
|
import { ReactElement } from 'react';
|
|
@@ -21,6 +21,13 @@ export interface ViewManagerProps extends HoistProps<ViewManagerModel> {
|
|
|
21
21
|
showRevertButton?: ViewManagerStateButtonMode;
|
|
22
22
|
/** Side relative to the menu on which save/revert buttons should render. Default 'right'. */
|
|
23
23
|
buttonSide?: 'left' | 'right';
|
|
24
|
+
/**
|
|
25
|
+
* Array of extra menu items. Can contain:
|
|
26
|
+
* + `MenuItems` or configs to create them.
|
|
27
|
+
* + `MenuDividers` or the special string token '-'.
|
|
28
|
+
* + React Elements or strings, which will be interpreted as the `text` property for a MenuItem.
|
|
29
|
+
*/
|
|
30
|
+
extraMenuItems?: MenuItemLike[];
|
|
24
31
|
}
|
|
25
32
|
/**
|
|
26
33
|
* Visibility options for save/revert buttons inlined next to the ViewManager menu:
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MenuItemLike } from '@xh/hoist/core';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Parse MenuItem configs into Blueprint MenuItems.
|
|
5
|
+
*
|
|
6
|
+
* Note this is currently used in a few limited places and is not generally applied to all menu-
|
|
7
|
+
* like components in Hoist. In particular, it is not used by the `menu` component re-exported from
|
|
8
|
+
* Blueprint. See https://github.com/xh/hoist-react/issues/2400 covering TBD work to more fully
|
|
9
|
+
* standardize a Hoist menu component that might then incorporate this processing.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseMenuItems(items: MenuItemLike[]): ReactNode[];
|
|
@@ -4,17 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2025 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import {hoistCmp, isMenuItem, MenuItemLike, XH} from '@xh/hoist/core';
|
|
7
|
+
import {hoistCmp, MenuItemLike, XH} from '@xh/hoist/core';
|
|
9
8
|
import {ButtonProps, button} from '@xh/hoist/desktop/cmp/button';
|
|
10
9
|
import '@xh/hoist/desktop/register';
|
|
11
10
|
import {Icon} from '@xh/hoist/icon';
|
|
12
|
-
import {menu,
|
|
13
|
-
import {
|
|
14
|
-
import {filterConsecutiveMenuSeparators, isOmitted} from '@xh/hoist/utils/impl';
|
|
11
|
+
import {menu, popover} from '@xh/hoist/kit/blueprint';
|
|
12
|
+
import {parseMenuItems} from '@xh/hoist/utils/impl';
|
|
15
13
|
import {withDefault} from '@xh/hoist/utils/js';
|
|
16
|
-
import {clone, isEmpty} from 'lodash';
|
|
17
|
-
import {ReactNode} from 'react';
|
|
18
14
|
|
|
19
15
|
export interface AppMenuButtonProps extends ButtonProps {
|
|
20
16
|
/**
|
|
@@ -176,42 +172,3 @@ function buildMenuItems(props: AppMenuButtonProps) {
|
|
|
176
172
|
|
|
177
173
|
return parseMenuItems([...extraItems, '-', ...defaultItems]);
|
|
178
174
|
}
|
|
179
|
-
|
|
180
|
-
function parseMenuItems(items: MenuItemLike[]): ReactNode[] {
|
|
181
|
-
items = items.map(item => {
|
|
182
|
-
if (!isMenuItem(item)) return item;
|
|
183
|
-
|
|
184
|
-
item = clone(item);
|
|
185
|
-
item.items = clone(item.items);
|
|
186
|
-
item.prepareFn?.(item);
|
|
187
|
-
return item;
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
return items
|
|
191
|
-
.filter(it => !isMenuItem(it) || (!it.hidden && !isOmitted(it)))
|
|
192
|
-
.filter(filterConsecutiveMenuSeparators())
|
|
193
|
-
.map(item => {
|
|
194
|
-
if (item === '-') return menuDivider();
|
|
195
|
-
if (!isMenuItem(item)) return item;
|
|
196
|
-
|
|
197
|
-
const {actionFn} = item;
|
|
198
|
-
|
|
199
|
-
// Create menuItem from config
|
|
200
|
-
const cfg: MenuItemProps = {
|
|
201
|
-
text: item.text,
|
|
202
|
-
icon: item.icon,
|
|
203
|
-
intent: item.intent,
|
|
204
|
-
className: item.className,
|
|
205
|
-
onClick: actionFn ? e => wait().then(() => actionFn(e)) : null, // do async to allow menu to close
|
|
206
|
-
disabled: item.disabled
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
// Recursively parse any submenus
|
|
210
|
-
if (!isEmpty(item.items)) {
|
|
211
|
-
cfg.children = parseMenuItems(item.items);
|
|
212
|
-
cfg.popoverProps = {openOnTargetFocus: false};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return menuItem(cfg);
|
|
216
|
-
});
|
|
217
|
-
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import {box, fragment, hbox} from '@xh/hoist/cmp/layout';
|
|
9
9
|
import {spinner} from '@xh/hoist/cmp/spinner';
|
|
10
|
-
import {hoistCmp, HoistProps, useLocalModel, uses} from '@xh/hoist/core';
|
|
10
|
+
import {hoistCmp, HoistProps, MenuItemLike, useLocalModel, uses} from '@xh/hoist/core';
|
|
11
11
|
import {ViewManagerModel} from '@xh/hoist/cmp/viewmanager';
|
|
12
12
|
import {button, ButtonProps} from '@xh/hoist/desktop/cmp/button';
|
|
13
13
|
import {Icon} from '@xh/hoist/icon';
|
|
@@ -42,6 +42,13 @@ export interface ViewManagerProps extends HoistProps<ViewManagerModel> {
|
|
|
42
42
|
showRevertButton?: ViewManagerStateButtonMode;
|
|
43
43
|
/** Side relative to the menu on which save/revert buttons should render. Default 'right'. */
|
|
44
44
|
buttonSide?: 'left' | 'right';
|
|
45
|
+
/**
|
|
46
|
+
* Array of extra menu items. Can contain:
|
|
47
|
+
* + `MenuItems` or configs to create them.
|
|
48
|
+
* + `MenuDividers` or the special string token '-'.
|
|
49
|
+
* + React Elements or strings, which will be interpreted as the `text` property for a MenuItem.
|
|
50
|
+
*/
|
|
51
|
+
extraMenuItems?: MenuItemLike[];
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
/**
|
|
@@ -76,7 +83,8 @@ export const [ViewManager, viewManager] = hoistCmp.withFactory<ViewManagerProps>
|
|
|
76
83
|
globalViewIcon = Icon.globe(),
|
|
77
84
|
showSaveButton = 'whenDirty',
|
|
78
85
|
showRevertButton = 'never',
|
|
79
|
-
buttonSide = 'right'
|
|
86
|
+
buttonSide = 'right',
|
|
87
|
+
extraMenuItems = []
|
|
80
88
|
}: ViewManagerProps) {
|
|
81
89
|
const {loadModel} = model,
|
|
82
90
|
locModel = useLocalModel(() => new ViewManagerLocalModel(model)),
|
|
@@ -103,7 +111,7 @@ export const [ViewManager, viewManager] = hoistCmp.withFactory<ViewManagerProps>
|
|
|
103
111
|
height: 30,
|
|
104
112
|
width: 30
|
|
105
113
|
})
|
|
106
|
-
: viewMenu({model: locModel}),
|
|
114
|
+
: viewMenu({model: locModel, extraMenuItems}),
|
|
107
115
|
onOpening: () => model.refreshAsync(),
|
|
108
116
|
placement: 'bottom',
|
|
109
117
|
popoverClassName: 'xh-view-manager__popover'
|
|
@@ -11,6 +11,7 @@ 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
13
|
import {pluralize} from '@xh/hoist/utils/js';
|
|
14
|
+
import {filterConsecutiveMenuSeparators, parseMenuItems} from '@xh/hoist/utils/impl';
|
|
14
15
|
import {Dictionary} from 'express-serve-static-core';
|
|
15
16
|
import {each, filter, groupBy, isEmpty, isFunction, orderBy, some, startCase} from 'lodash';
|
|
16
17
|
import {ReactNode} from 'react';
|
|
@@ -20,10 +21,16 @@ import {ViewManagerLocalModel} from './ViewManagerLocalModel';
|
|
|
20
21
|
* Default Menu used by ViewManager.
|
|
21
22
|
*/
|
|
22
23
|
export const viewMenu = hoistCmp.factory<ViewManagerLocalModel>({
|
|
23
|
-
render({model}) {
|
|
24
|
+
render({model, extraMenuItems}) {
|
|
24
25
|
return menu({
|
|
25
26
|
className: 'xh-view-manager__menu',
|
|
26
|
-
items: [
|
|
27
|
+
items: [
|
|
28
|
+
...getNavMenuItems(model.parent),
|
|
29
|
+
menuDivider(),
|
|
30
|
+
...parseMenuItems(extraMenuItems),
|
|
31
|
+
menuDivider(),
|
|
32
|
+
...getOtherMenuItems(model)
|
|
33
|
+
].filter(filterConsecutiveMenuSeparators())
|
|
27
34
|
});
|
|
28
35
|
}
|
|
29
36
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "75.0.0-SNAPSHOT.
|
|
3
|
+
"version": "75.0.0-SNAPSHOT.1750966316712",
|
|
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",
|