@xh/hoist 75.0.0-SNAPSHOT.1749666833237 → 75.0.0-SNAPSHOT.1750963411217

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,10 @@
2
2
 
3
3
  ## v75.0.0-SNAPSHOT - unreleased
4
4
 
5
+ ### 🎁 New Features
6
+ * Added props to `ViewManager` to customize icons used for different types of views, and modified
7
+ default icons for Global and Shared views.
8
+
5
9
  ## v74.0.0 - 2025-06-11
6
10
 
7
11
  ### 💥 Breaking Changes (upgrade difficulty: 🟢 LOW - minor changes to ViewManagerModel, ChartModel)
@@ -15,15 +15,19 @@ export declare class ViewInfo {
15
15
  readonly description: string;
16
16
  /** User owning this view. Null if the view is global.*/
17
17
  readonly owner: string;
18
- /** Is the owner making this view accessible to others? Always true for global views. */
18
+ /**
19
+ * True if the owner (which can be the current user) has made this view accessible to all other
20
+ * users. Note always `false` for global views, to better distinguish the two sharing models.
21
+ */
19
22
  readonly isShared: boolean;
20
23
  /** True if this view is global and visible to all users. */
21
24
  readonly isGlobal: boolean;
22
25
  /** Optional group name used for bucketing this view in display. */
23
26
  readonly group: string;
24
27
  /**
25
- * Should this view be pinned by users by default?
26
- * This value is intended to be used for global views only.
28
+ * True if this view should be pinned by default to all users' menus, where it will appear
29
+ * unless the user has explicitly unpinned it. Only applicable for global views, can be enabled
30
+ * by view managers to promote especially important global views and ensure users see them.
27
31
  */
28
32
  readonly isDefaultPinned: boolean;
29
33
  /**
@@ -1,26 +1,35 @@
1
1
  import { HoistProps } from '@xh/hoist/core';
2
2
  import { ViewManagerModel } from '@xh/hoist/cmp/viewmanager';
3
3
  import { ButtonProps } from '@xh/hoist/desktop/cmp/button';
4
+ import { ReactElement } from 'react';
4
5
  import './ViewManager.scss';
5
- /**
6
- * Visibility options for save/revert button.
7
- *
8
- * 'never' to hide button.
9
- * 'whenDirty' to only show when persistence state is dirty and button is therefore enabled.
10
- * 'always' will always show button.
11
- */
12
- export type ViewManagerStateButtonMode = 'whenDirty' | 'always' | 'never';
13
6
  export interface ViewManagerProps extends HoistProps<ViewManagerModel> {
14
7
  menuButtonProps?: Partial<ButtonProps>;
15
8
  saveButtonProps?: Partial<ButtonProps>;
16
9
  revertButtonProps?: Partial<ButtonProps>;
10
+ /** Button icon when on the default (in-code state) view. Default `Icon.bookmark`. */
11
+ defaultViewIcon?: ReactElement;
12
+ /** Button icon when the selected view is owned by the current user. Default `Icon.bookmark`. */
13
+ ownedViewIcon?: ReactElement;
14
+ /** Button icon when the selected view is shared by another user. Default `Icon.users`. */
15
+ sharedViewIcon?: ReactElement;
16
+ /** Button icon when the selected view is globally shared. Default `Icon.globe`. */
17
+ globalViewIcon?: ReactElement;
17
18
  /** Default 'whenDirty' */
18
19
  showSaveButton?: ViewManagerStateButtonMode;
19
20
  /** Default 'never' */
20
21
  showRevertButton?: ViewManagerStateButtonMode;
21
- /** Side the save and revert buttons should appear on (default 'right') */
22
+ /** Side relative to the menu on which save/revert buttons should render. Default 'right'. */
22
23
  buttonSide?: 'left' | 'right';
23
24
  }
25
+ /**
26
+ * Visibility options for save/revert buttons inlined next to the ViewManager menu:
27
+ * 'never' to always hide - user must save/revert via menu.
28
+ * 'whenDirty' (default) to show only when view state is dirty and the button is enabled.
29
+ * 'always' to always show, including when view not dirty and the button is disabled.
30
+ * Useful to avoid jumpiness in toolbar layouts.
31
+ */
32
+ export type ViewManagerStateButtonMode = 'whenDirty' | 'always' | 'never';
24
33
  /**
25
34
  * Desktop ViewManager component - a button-based menu for saving and swapping between named
26
35
  * bundles of persisted component state (e.g. grid views, dashboards, and similar).
@@ -29,7 +29,10 @@ export class ViewInfo {
29
29
  /** User owning this view. Null if the view is global.*/
30
30
  readonly owner: string;
31
31
 
32
- /** Is the owner making this view accessible to others? Always true for global views. */
32
+ /**
33
+ * True if the owner (which can be the current user) has made this view accessible to all other
34
+ * users. Note always `false` for global views, to better distinguish the two sharing models.
35
+ */
33
36
  readonly isShared: boolean;
34
37
 
35
38
  /** True if this view is global and visible to all users. */
@@ -39,8 +42,9 @@ export class ViewInfo {
39
42
  readonly group: string;
40
43
 
41
44
  /**
42
- * Should this view be pinned by users by default?
43
- * This value is intended to be used for global views only.
45
+ * True if this view should be pinned by default to all users' menus, where it will appear
46
+ * unless the user has explicitly unpinned it. Only applicable for global views, can be enabled
47
+ * by view managers to promote especially important global views and ensure users see them.
44
48
  */
45
49
  readonly isDefaultPinned: boolean;
46
50
 
@@ -14,6 +14,7 @@ import {Icon} from '@xh/hoist/icon';
14
14
  import {popover} from '@xh/hoist/kit/blueprint';
15
15
  import {useOnVisibleChange} from '@xh/hoist/utils/react';
16
16
  import {startCase} from 'lodash';
17
+ import {ReactElement} from 'react';
17
18
  import {viewMenu} from './ViewMenu';
18
19
  import {ViewManagerLocalModel} from './ViewManagerLocalModel';
19
20
  import {manageDialog} from './dialog/ManageDialog';
@@ -21,28 +22,37 @@ import {saveAsDialog} from './dialog/SaveAsDialog';
21
22
 
22
23
  import './ViewManager.scss';
23
24
 
24
- /**
25
- * Visibility options for save/revert button.
26
- *
27
- * 'never' to hide button.
28
- * 'whenDirty' to only show when persistence state is dirty and button is therefore enabled.
29
- * 'always' will always show button.
30
- */
31
- export type ViewManagerStateButtonMode = 'whenDirty' | 'always' | 'never';
32
-
33
25
  export interface ViewManagerProps extends HoistProps<ViewManagerModel> {
34
26
  menuButtonProps?: Partial<ButtonProps>;
35
27
  saveButtonProps?: Partial<ButtonProps>;
36
28
  revertButtonProps?: Partial<ButtonProps>;
37
29
 
30
+ /** Button icon when on the default (in-code state) view. Default `Icon.bookmark`. */
31
+ defaultViewIcon?: ReactElement;
32
+ /** Button icon when the selected view is owned by the current user. Default `Icon.bookmark`. */
33
+ ownedViewIcon?: ReactElement;
34
+ /** Button icon when the selected view is shared by another user. Default `Icon.users`. */
35
+ sharedViewIcon?: ReactElement;
36
+ /** Button icon when the selected view is globally shared. Default `Icon.globe`. */
37
+ globalViewIcon?: ReactElement;
38
+
38
39
  /** Default 'whenDirty' */
39
40
  showSaveButton?: ViewManagerStateButtonMode;
40
41
  /** Default 'never' */
41
42
  showRevertButton?: ViewManagerStateButtonMode;
42
- /** Side the save and revert buttons should appear on (default 'right') */
43
+ /** Side relative to the menu on which save/revert buttons should render. Default 'right'. */
43
44
  buttonSide?: 'left' | 'right';
44
45
  }
45
46
 
47
+ /**
48
+ * Visibility options for save/revert buttons inlined next to the ViewManager menu:
49
+ * 'never' to always hide - user must save/revert via menu.
50
+ * 'whenDirty' (default) to show only when view state is dirty and the button is enabled.
51
+ * 'always' to always show, including when view not dirty and the button is disabled.
52
+ * Useful to avoid jumpiness in toolbar layouts.
53
+ */
54
+ export type ViewManagerStateButtonMode = 'whenDirty' | 'always' | 'never';
55
+
46
56
  /**
47
57
  * Desktop ViewManager component - a button-based menu for saving and swapping between named
48
58
  * bundles of persisted component state (e.g. grid views, dashboards, and similar).
@@ -60,6 +70,10 @@ export const [ViewManager, viewManager] = hoistCmp.withFactory<ViewManagerProps>
60
70
  menuButtonProps,
61
71
  saveButtonProps,
62
72
  revertButtonProps,
73
+ defaultViewIcon = Icon.bookmark(),
74
+ ownedViewIcon = Icon.bookmark(),
75
+ sharedViewIcon = Icon.users(),
76
+ globalViewIcon = Icon.globe(),
63
77
  showSaveButton = 'whenDirty',
64
78
  showRevertButton = 'never',
65
79
  buttonSide = 'right'
@@ -70,7 +84,17 @@ export const [ViewManager, viewManager] = hoistCmp.withFactory<ViewManagerProps>
70
84
  revert = revertButton({model: locModel, mode: showRevertButton, ...revertButtonProps}),
71
85
  menu = popover({
72
86
  disabled: !locModel.isVisible, // Prevent orphaned popover menu
73
- item: menuButton({model: locModel, ...menuButtonProps}),
87
+ item: menuButton({
88
+ model: locModel,
89
+ icon: buttonIcon({
90
+ model: locModel,
91
+ defaultViewIcon,
92
+ ownedViewIcon,
93
+ sharedViewIcon,
94
+ globalViewIcon
95
+ }),
96
+ ...menuButtonProps
97
+ }),
74
98
  content: loadModel.isPending
75
99
  ? box({
76
100
  item: spinner({compact: true}),
@@ -97,13 +121,13 @@ export const [ViewManager, viewManager] = hoistCmp.withFactory<ViewManagerProps>
97
121
  });
98
122
 
99
123
  const menuButton = hoistCmp.factory<ViewManagerLocalModel>({
100
- render({model, ...rest}) {
124
+ render({model, icon, ...rest}) {
101
125
  const {view, typeDisplayName, isLoading} = model.parent;
102
126
  return button({
103
127
  className: 'xh-view-manager__menu-button',
104
128
  text: view.isDefault ? `Default ${startCase(typeDisplayName)}` : view.name,
105
129
  icon: !isLoading
106
- ? Icon.bookmark()
130
+ ? icon
107
131
  : box({
108
132
  item: spinner({width: 13, height: 13, style: {margin: 'auto'}}),
109
133
  width: 16.25
@@ -115,6 +139,16 @@ const menuButton = hoistCmp.factory<ViewManagerLocalModel>({
115
139
  }
116
140
  });
117
141
 
142
+ const buttonIcon = hoistCmp.factory<ViewManagerLocalModel>({
143
+ render({model, ownedViewIcon, sharedViewIcon, globalViewIcon, defaultViewIcon}) {
144
+ const {view} = model.parent;
145
+ if (view.isOwned) return ownedViewIcon;
146
+ if (view.isShared) return sharedViewIcon;
147
+ if (view.isGlobal) return globalViewIcon;
148
+ return defaultViewIcon;
149
+ }
150
+ });
151
+
118
152
  const saveButton = hoistCmp.factory<ViewManagerLocalModel>({
119
153
  render({model, mode, ...rest}) {
120
154
  if (hideStateButton(model, mode)) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "75.0.0-SNAPSHOT.1749666833237",
3
+ "version": "75.0.0-SNAPSHOT.1750963411217",
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",