@xh/hoist 74.0.0 → 74.1.0
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 +22 -4
- package/build/types/cmp/grouping/GroupingChooserModel.d.ts +7 -4
- package/build/types/cmp/viewmanager/ViewInfo.d.ts +7 -3
- package/build/types/desktop/cmp/grouping/GroupingChooser.d.ts +4 -4
- package/build/types/desktop/cmp/viewmanager/ViewManager.d.ts +26 -10
- package/build/types/mobile/cmp/grouping/GroupingChooser.d.ts +2 -6
- package/build/types/utils/impl/MenuItems.d.ts +13 -0
- package/build/types/utils/impl/index.d.ts +1 -0
- package/cmp/grouping/GroupingChooserModel.ts +20 -12
- package/cmp/viewmanager/ViewInfo.ts +7 -3
- package/core/HoistAppModel.ts +1 -0
- package/desktop/cmp/button/AppMenuButton.ts +3 -46
- package/desktop/cmp/grouping/GroupingChooser.scss +28 -39
- package/desktop/cmp/grouping/GroupingChooser.ts +72 -82
- package/desktop/cmp/viewmanager/ViewManager.ts +58 -16
- package/desktop/cmp/viewmanager/ViewMenu.ts +9 -2
- package/mobile/appcontainer/FeedbackDialog.ts +4 -0
- package/mobile/appcontainer/OptionsDialog.ts +3 -1
- package/mobile/cmp/grid/impl/ColChooser.ts +3 -2
- package/mobile/cmp/grouping/GroupingChooser.scss +41 -20
- package/mobile/cmp/grouping/GroupingChooser.ts +60 -89
- package/mobile/cmp/panel/DialogPanel.scss +5 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/utils/impl/MenuItems.ts +57 -0
- package/utils/impl/index.ts +1 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {isMenuItem, MenuItemLike} from '@xh/hoist/core';
|
|
2
|
+
import {menuDivider, menuItem} from '@xh/hoist/kit/blueprint';
|
|
3
|
+
import {MenuItemProps} from '@blueprintjs/core';
|
|
4
|
+
import {wait} from '@xh/hoist/promise';
|
|
5
|
+
import {isOmitted} from '@xh/hoist/utils/impl/IsOmitted';
|
|
6
|
+
import {filterConsecutiveMenuSeparators} from '@xh/hoist/utils/impl/Separators';
|
|
7
|
+
import {clone, isEmpty} from 'lodash';
|
|
8
|
+
import {ReactNode} from 'react';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Parse MenuItem configs into Blueprint MenuItems.
|
|
12
|
+
*
|
|
13
|
+
* Note this is currently used in a few limited places and is not generally applied to all menu-
|
|
14
|
+
* like components in Hoist. In particular, it is not used by the `menu` component re-exported from
|
|
15
|
+
* Blueprint. See https://github.com/xh/hoist-react/issues/2400 covering TBD work to more fully
|
|
16
|
+
* standardize a Hoist menu component that might then incorporate this processing.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export function parseMenuItems(items: MenuItemLike[]): ReactNode[] {
|
|
21
|
+
items = items.map(item => {
|
|
22
|
+
if (!isMenuItem(item)) return item;
|
|
23
|
+
|
|
24
|
+
item = clone(item);
|
|
25
|
+
item.items = clone(item.items);
|
|
26
|
+
item.prepareFn?.(item);
|
|
27
|
+
return item;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return items
|
|
31
|
+
.filter(it => !isMenuItem(it) || (!it.hidden && !isOmitted(it)))
|
|
32
|
+
.filter(filterConsecutiveMenuSeparators())
|
|
33
|
+
.map(item => {
|
|
34
|
+
if (item === '-') return menuDivider();
|
|
35
|
+
if (!isMenuItem(item)) return item;
|
|
36
|
+
|
|
37
|
+
const {actionFn} = item;
|
|
38
|
+
|
|
39
|
+
// Create menuItem from config
|
|
40
|
+
const cfg: MenuItemProps = {
|
|
41
|
+
text: item.text,
|
|
42
|
+
icon: item.icon,
|
|
43
|
+
intent: item.intent,
|
|
44
|
+
className: item.className,
|
|
45
|
+
onClick: actionFn ? e => wait().then(() => actionFn(e)) : null, // do async to allow menu to close
|
|
46
|
+
disabled: item.disabled
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Recursively parse any submenus
|
|
50
|
+
if (!isEmpty(item.items)) {
|
|
51
|
+
cfg.children = parseMenuItems(item.items);
|
|
52
|
+
cfg.popoverProps = {openOnTargetFocus: false};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return menuItem(cfg);
|
|
56
|
+
});
|
|
57
|
+
}
|
package/utils/impl/index.ts
CHANGED