@xh/hoist 70.0.0-SNAPSHOT.1731022145122 → 70.0.0-SNAPSHOT.1731374612473

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/build/types/cmp/filter/FilterChooserModel.d.ts +17 -12
  3. package/build/types/cmp/grid/GridModel.d.ts +5 -9
  4. package/build/types/cmp/grid/Types.d.ts +7 -19
  5. package/build/types/cmp/grid/columns/Column.d.ts +0 -1
  6. package/build/types/cmp/grid/impl/InitPersist.d.ts +7 -0
  7. package/build/types/cmp/grouping/GroupingChooserModel.d.ts +6 -8
  8. package/build/types/cmp/tab/TabContainerModel.d.ts +10 -4
  9. package/build/types/cmp/zoneGrid/Types.d.ts +6 -6
  10. package/build/types/cmp/zoneGrid/ZoneGridModel.d.ts +0 -2
  11. package/build/types/cmp/zoneGrid/impl/InitPersist.d.ts +7 -0
  12. package/build/types/core/HoistBase.d.ts +1 -1
  13. package/build/types/core/persist/CustomProvider.d.ts +5 -6
  14. package/build/types/core/persist/DashViewProvider.d.ts +6 -6
  15. package/build/types/core/persist/LocalStorageProvider.d.ts +4 -5
  16. package/build/types/core/persist/PersistOptions.d.ts +5 -4
  17. package/build/types/core/persist/Persistable.d.ts +14 -0
  18. package/build/types/core/persist/PersistenceProvider.d.ts +47 -34
  19. package/build/types/core/persist/PrefProvider.d.ts +5 -5
  20. package/build/types/core/persist/index.d.ts +2 -0
  21. package/build/types/core/persist/viewmanager/Types.d.ts +46 -0
  22. package/build/types/core/persist/viewmanager/ViewManagerModel.d.ts +149 -0
  23. package/build/types/core/persist/viewmanager/ViewManagerProvider.d.ts +10 -0
  24. package/build/types/core/persist/viewmanager/impl/ManageDialogModel.d.ts +30 -0
  25. package/build/types/core/persist/viewmanager/impl/SaveDialogModel.d.ts +23 -0
  26. package/build/types/core/persist/viewmanager/index.d.ts +2 -0
  27. package/build/types/desktop/cmp/button/ColAutosizeButton.d.ts +1 -1
  28. package/build/types/desktop/cmp/dash/DashConfig.d.ts +3 -1
  29. package/build/types/desktop/cmp/dash/DashModel.d.ts +1 -2
  30. package/build/types/desktop/cmp/dash/DashViewSpec.d.ts +1 -1
  31. package/build/types/desktop/cmp/dash/canvas/DashCanvasModel.d.ts +10 -2
  32. package/build/types/desktop/cmp/dash/container/DashContainerModel.d.ts +26 -10
  33. package/build/types/desktop/cmp/dash/container/impl/DashContainerUtils.d.ts +4 -2
  34. package/build/types/desktop/cmp/panel/PanelModel.d.ts +8 -4
  35. package/build/types/desktop/cmp/viewmanager/ViewManager.d.ts +22 -0
  36. package/build/types/desktop/cmp/viewmanager/cmp/ManageDialog.d.ts +6 -0
  37. package/build/types/desktop/cmp/viewmanager/cmp/SaveDialog.d.ts +2 -0
  38. package/build/types/desktop/cmp/viewmanager/index.d.ts +3 -0
  39. package/build/types/kit/blueprint/Wrappers.d.ts +1 -1
  40. package/build/types/mobile/cmp/button/ColAutosizeButton.d.ts +1 -1
  41. package/build/types/svc/GridAutosizeService.d.ts +2 -5
  42. package/build/types/svc/JsonBlobService.d.ts +45 -24
  43. package/cmp/filter/FilterChooserModel.ts +142 -125
  44. package/cmp/grid/Grid.ts +2 -10
  45. package/cmp/grid/GridModel.ts +18 -31
  46. package/cmp/grid/Types.ts +7 -21
  47. package/cmp/grid/columns/Column.ts +0 -1
  48. package/cmp/grid/impl/InitPersist.ts +71 -0
  49. package/cmp/grouping/GroupingChooserModel.ts +48 -57
  50. package/cmp/tab/TabContainerModel.ts +22 -36
  51. package/cmp/zoneGrid/Types.ts +6 -6
  52. package/cmp/zoneGrid/ZoneGridModel.ts +2 -7
  53. package/cmp/zoneGrid/impl/InitPersist.ts +70 -0
  54. package/core/HoistBase.ts +14 -22
  55. package/core/HoistBaseDecorators.ts +26 -28
  56. package/core/persist/CustomProvider.ts +7 -10
  57. package/core/persist/DashViewProvider.ts +8 -10
  58. package/core/persist/LocalStorageProvider.ts +9 -12
  59. package/core/persist/PersistOptions.ts +6 -4
  60. package/core/persist/Persistable.ts +23 -0
  61. package/core/persist/PersistenceProvider.ts +159 -79
  62. package/core/persist/PrefProvider.ts +9 -12
  63. package/core/persist/index.ts +2 -0
  64. package/core/persist/viewmanager/Types.ts +51 -0
  65. package/core/persist/viewmanager/ViewManagerModel.ts +515 -0
  66. package/core/persist/viewmanager/ViewManagerProvider.ts +51 -0
  67. package/core/persist/viewmanager/impl/ManageDialogModel.ts +274 -0
  68. package/core/persist/viewmanager/impl/SaveDialogModel.ts +112 -0
  69. package/core/persist/viewmanager/index.ts +2 -0
  70. package/desktop/cmp/button/ColAutosizeButton.ts +1 -1
  71. package/desktop/cmp/dash/DashConfig.ts +3 -1
  72. package/desktop/cmp/dash/DashModel.ts +1 -2
  73. package/desktop/cmp/dash/DashViewSpec.ts +1 -1
  74. package/desktop/cmp/dash/canvas/DashCanvasModel.ts +31 -30
  75. package/desktop/cmp/dash/container/DashContainerModel.ts +68 -43
  76. package/desktop/cmp/dash/container/impl/DashContainerUtils.ts +13 -4
  77. package/desktop/cmp/leftrightchooser/LeftRightChooserFilter.ts +1 -1
  78. package/desktop/cmp/panel/PanelModel.ts +33 -53
  79. package/desktop/cmp/store/impl/StoreFilterField.ts +1 -1
  80. package/desktop/cmp/viewmanager/ViewManager.scss +58 -0
  81. package/desktop/cmp/viewmanager/ViewManager.ts +274 -0
  82. package/desktop/cmp/viewmanager/cmp/ManageDialog.ts +197 -0
  83. package/desktop/cmp/viewmanager/cmp/SaveDialog.ts +89 -0
  84. package/desktop/cmp/viewmanager/index.ts +3 -0
  85. package/mobile/cmp/button/ColAutosizeButton.ts +1 -1
  86. package/package.json +1 -1
  87. package/svc/GridAutosizeService.ts +73 -36
  88. package/svc/JsonBlobService.ts +64 -31
  89. package/tsconfig.tsbuildinfo +1 -1
  90. package/build/types/cmp/grid/impl/GridPersistenceModel.d.ts +0 -41
  91. package/build/types/cmp/zoneGrid/impl/ZoneGridPersistenceModel.d.ts +0 -39
  92. package/cmp/grid/impl/GridPersistenceModel.ts +0 -174
  93. package/cmp/zoneGrid/impl/ZoneGridPersistenceModel.ts +0 -149
@@ -0,0 +1,46 @@
1
+ import { PlainObject } from '@xh/hoist/core';
2
+ /**
3
+ * Interface for a bundle of {@link PersistableState} managed by {@link ViewManagerModel}.
4
+ * Views are persisted to / loaded from the server as {@link JsonBlob}s.
5
+ */
6
+ export interface View<T extends PlainObject = PlainObject> {
7
+ /** Either null for private views or special token "*" for globally shared views. */
8
+ acl: '*' | null;
9
+ dateCreated: number;
10
+ description: string;
11
+ /** Calculated display group - either "Shared [entityName]" or "My [entityName]". */
12
+ group: string;
13
+ /**
14
+ * True if user has tagged this view as a favorite. Note that a user's list of favorite views is
15
+ * persisted via `ViewManagerModel.persistWith` and *not* stored in the blob itself.
16
+ */
17
+ isFavorite: boolean;
18
+ /** True if this view has been shared (acl == "*") and is visible to all users. */
19
+ isShared: boolean;
20
+ lastUpdated: number;
21
+ lastUpdatedBy: string;
22
+ /** User-supplied descriptive name. */
23
+ name: string;
24
+ /** Original creator of the view, and the only user with access to it if not shared. */
25
+ owner: string;
26
+ token: string;
27
+ /** App-defined type discriminator, as per {@link ViewManagerConfig.viewType}. */
28
+ type: string;
29
+ value: T;
30
+ }
31
+ /**
32
+ * Abstract representation of ViewManager views available for selection, potentially grouped into
33
+ * hierarchical folders. Lightweight, user-driven organization into "folders" is supported by
34
+ * inserting a "\" in the name of any view.
35
+ */
36
+ export type ViewTree = {
37
+ text: string;
38
+ selected: boolean;
39
+ } & ({
40
+ type: 'folder';
41
+ items: ViewTree[];
42
+ } | {
43
+ type: 'view';
44
+ token: string;
45
+ description: string;
46
+ });
@@ -0,0 +1,149 @@
1
+ import { HoistModel, LoadSpec, Persistable, PersistableState, PersistOptions, PlainObject, Thunkable, ViewManagerProvider } from '@xh/hoist/core';
2
+ import { SaveDialogModel } from './impl/SaveDialogModel';
3
+ import { View, ViewTree } from './Types';
4
+ export interface ViewManagerConfig {
5
+ /**
6
+ * True (default) to allow user to opt-in to automatically saving changes to their private
7
+ * views - requires `persistWith`.
8
+ */
9
+ enableAutoSave?: boolean;
10
+ /**
11
+ * True (default) to allow the user to select a "Default" option that restores all persisted
12
+ * objects to their in-code defaults. If not enabled, at least one saved view should be created
13
+ * in advance, so that there is a clear initial selection for users without any private views.
14
+ */
15
+ enableDefault?: boolean;
16
+ /** True (default) to allow user to mark views as favorites. Requires `persistWith`. */
17
+ enableFavorites?: boolean;
18
+ /**
19
+ * True to allow the user to publish or edit globally shared views. Apps are expected to
20
+ * commonly set this based on user roles - e.g. `XH.getUser().hasRole('MANAGE_GRID_VIEWS')`.
21
+ */
22
+ enableSharing?: Thunkable<boolean>;
23
+ /** Used to persist the user's last selected + favorite views and autoSave preference. */
24
+ persistWith?: PersistOptions;
25
+ /**
26
+ * Required discriminator for the particular class of views to be loaded and managed by this
27
+ * model. Maps onto the `type` field of the persisted `JsonBlob`. Set to something descriptive
28
+ * and specific enough to be identifiable and allow for different viewManagers to be added
29
+ * to your app in the future - e.g. `portfolioGridView` or `tradeBlotterDashboard`.
30
+ */
31
+ viewType: string;
32
+ /**
33
+ * Optional user-facing display name for the view type, displayed in the ViewManager menu
34
+ * and associated management dialogs and prompts. Defaulted from `viewType` if not provided.
35
+ */
36
+ viewTypeDisplayName?: string;
37
+ }
38
+ /**
39
+ * ViewManagerModel coordinates the loading, saving, and management of user-defined bundles of
40
+ * {@link Persistable} component/model state.
41
+ *
42
+ * - Models to be persisted are bound to this model via their `persistWith` config. One or more
43
+ * models can be bound to a single ViewManagerModel, allowing a single view to capture the state
44
+ * of multiple components - e.g. grouping and filtering options along with grid state.
45
+ * - Views are persisted back to the server as JsonBlob objects.
46
+ * - Views can be private to their owner, or optionally enabled for sharing to (all) other users.
47
+ * - Views can be marked as favorites for quick access.
48
+ * - See the desktop {@link ViewManager} component - the initial Hoist UI for this model.
49
+ */
50
+ export declare class ViewManagerModel<T extends PlainObject = PlainObject> extends HoistModel implements Persistable<ViewManagerModelPersistState> {
51
+ /**
52
+ * Factory to create new instances of this model and await its initial load before binding to
53
+ * any persistable component models. This ensures that bound models will have the expected
54
+ * initial persisted state applied within their constructor, before their components have
55
+ * rendered, and avoids thrashing of component state during initial load.
56
+ *
57
+ * To minimize the impact this async requirement has on the design and lifecycle of individual
58
+ * components within an app, consider eagerly constructing any viewManagerModels required within
59
+ * your `AppModel.initAsync` method and saving a reference to them there for component models
60
+ * to then use when they are mounted. The VM model instances will then be "ready to go" and
61
+ * usable within model constructors. (Initializing and referencing from one or more app
62
+ * services would be another, similar option.)
63
+ */
64
+ static createAsync(config: ViewManagerConfig): Promise<ViewManagerModel>;
65
+ /** Immutable configuration for this model. */
66
+ readonly viewType: string;
67
+ readonly displayName: string;
68
+ readonly DisplayName: string;
69
+ readonly enableDefault: boolean;
70
+ readonly enableAutoSave: boolean;
71
+ readonly enableFavorites: boolean;
72
+ /** Last selected, fully-persisted state of the active view. */
73
+ value: T;
74
+ /** Current state of the active view, can include not-yet-persisted changes. */
75
+ pendingValue: T;
76
+ /** Loaded saved view definitions - both private and shared. */
77
+ views: View<T>[];
78
+ /** Token identifier for the currently selected view, or null if in default mode. */
79
+ selectedToken: string;
80
+ /** List of tokens for the user's favorite views. */
81
+ favorites: string[];
82
+ /**
83
+ * True if user has opted-in to automatically saving changes to personal views (if auto-save
84
+ * generally available as per `enableAutoSave`).
85
+ */
86
+ autoSaveActive: boolean;
87
+ manageDialogOpen: boolean;
88
+ readonly saveDialogModel: SaveDialogModel;
89
+ private readonly _enableSharing;
90
+ /**
91
+ * @internal array of {@link ViewManagerProvider} instances bound to this model. Providers will
92
+ * push themselves onto this array when constructed with a reference to this model. Used to
93
+ * proactively push state to the target components when the model's selected `value` changes.
94
+ */
95
+ providers: ViewManagerProvider<any>[];
96
+ get enableSharing(): boolean;
97
+ get selectedView(): View<T>;
98
+ get isSharedViewSelected(): boolean;
99
+ get canSave(): boolean;
100
+ /**
101
+ * True if displaying the save button is appropriate from the model's point of view, even if
102
+ * that button might be disabled due to no changes having been made. Works in concert with the
103
+ * desktop ViewManager component's `showSaveButton` prop.
104
+ */
105
+ get canShowSaveButton(): boolean;
106
+ get enableAutoSaveToggle(): boolean;
107
+ get disabledAutoSaveReason(): string;
108
+ get isDirty(): boolean;
109
+ get isShared(): boolean;
110
+ get favoriteViews(): View<T>[];
111
+ get sharedViews(): View<T>[];
112
+ get privateViews(): View<T>[];
113
+ get sharedViewTree(): ViewTree[];
114
+ get privateViewTree(): ViewTree[];
115
+ /**
116
+ * Use the static {@link createAsync} factory to create an instance of this model and await its
117
+ * initial load before binding to persistable components.
118
+ */
119
+ private constructor();
120
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
121
+ selectViewAsync(token: string): Promise<void>;
122
+ saveAsync(skipToast?: boolean): Promise<void>;
123
+ saveAsAsync(): Promise<void>;
124
+ resetAsync(): Promise<void>;
125
+ setPendingValue(pendingValue: T): void;
126
+ openManageDialog(): void;
127
+ closeManageDialog(): void;
128
+ getHierarchyDisplayName(name: string): string;
129
+ toggleFavorite(token: string): void;
130
+ addFavorite(token: string): void;
131
+ removeFavorite(token: string): void;
132
+ isFavorite(token: string): boolean;
133
+ getPersistableState(): PersistableState<ViewManagerModelPersistState>;
134
+ setPersistableState(state: PersistableState<ViewManagerModelPersistState>): void;
135
+ private processRaw;
136
+ private setValue;
137
+ private cleanValue;
138
+ private confirmSaveForSharedViewAsync;
139
+ private maybeAutoSaveAsync;
140
+ private buildViewTree;
141
+ private getNameHierarchySubstring;
142
+ private isFolderForEntry;
143
+ private onFavoritesChange;
144
+ }
145
+ interface ViewManagerModelPersistState {
146
+ selectedToken: string;
147
+ favorites: string[];
148
+ }
149
+ export {};
@@ -0,0 +1,10 @@
1
+ import { PersistenceProvider, PersistenceProviderConfig } from '../index';
2
+ import type { ViewManagerModel } from './index';
3
+ export declare class ViewManagerProvider<S> extends PersistenceProvider<S> {
4
+ readonly viewManagerModel: ViewManagerModel;
5
+ constructor(cfg: PersistenceProviderConfig<S>);
6
+ pushStateToTarget(): void;
7
+ readRaw(): import("../..").PlainObject;
8
+ writeRaw(data: Record<typeof this.path, S>): void;
9
+ destroy(): void;
10
+ }
@@ -0,0 +1,30 @@
1
+ import { FormModel } from '@xh/hoist/cmp/form';
2
+ import { GridModel } from '@xh/hoist/cmp/grid';
3
+ import { HoistModel, TaskObserver } from '@xh/hoist/core';
4
+ export declare class ManageDialogModel extends HoistModel {
5
+ private viewManagerModel;
6
+ gridModel: GridModel;
7
+ formModel: FormModel;
8
+ readonly saveTask: TaskObserver;
9
+ readonly deleteTask: TaskObserver;
10
+ get selectedId(): string;
11
+ get selectedIds(): string[];
12
+ get hasMultiSelection(): boolean;
13
+ get selIsShared(): boolean;
14
+ get canDelete(): boolean;
15
+ get canEdit(): boolean;
16
+ get enableSharing(): boolean;
17
+ get showSaveButton(): boolean;
18
+ get displayName(): string;
19
+ get enableFavorites(): boolean;
20
+ constructor();
21
+ onLinked(): void;
22
+ doLoadAsync(): Promise<void>;
23
+ saveAsync(): Promise<void>;
24
+ deleteAsync(): Promise<void>;
25
+ private doSaveAsync;
26
+ private doDeleteAsync;
27
+ private ensureGridHasSelection;
28
+ private createGridModel;
29
+ private createFormModel;
30
+ }
@@ -0,0 +1,23 @@
1
+ import { FormModel } from '@xh/hoist/cmp/form';
2
+ import { HoistModel, TaskObserver } from '@xh/hoist/core';
3
+ import { ViewManagerModel } from '@xh/hoist/core/persist/viewmanager';
4
+ import { JsonBlob } from '@xh/hoist/svc';
5
+ import { View } from '../Types';
6
+ export declare class SaveDialogModel extends HoistModel {
7
+ private readonly viewManagerModel;
8
+ readonly formModel: FormModel;
9
+ readonly saveTask: TaskObserver;
10
+ viewStub: Partial<View>;
11
+ isOpen: boolean;
12
+ private resolveOpen;
13
+ private invalidNames;
14
+ get type(): string;
15
+ get DisplayName(): string;
16
+ constructor(viewManagerModel: ViewManagerModel);
17
+ openAsync(viewStub: Partial<View>, invalidNames: string[]): Promise<JsonBlob>;
18
+ cancel(): void;
19
+ saveAsAsync(): Promise<void>;
20
+ private createFormModel;
21
+ private doSaveAsAsync;
22
+ private close;
23
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ViewManagerModel';
2
+ export * from './Types';
@@ -6,7 +6,7 @@ export interface ColAutosizeButtonProps extends ButtonProps {
6
6
  /** GridModel of the grid for which this button should autosize columns. */
7
7
  gridModel?: GridModel;
8
8
  /** Options for the grid autosize. */
9
- autosizeOptions?: GridAutosizeOptions;
9
+ autosizeOptions?: Omit<GridAutosizeOptions, 'mode'>;
10
10
  }
11
11
  /**
12
12
  * A convenience button to autosize visible Grid columns.
@@ -1,8 +1,10 @@
1
1
  import { MenuItemLike, PersistOptions } from '@xh/hoist/core';
2
+ import { DashViewState } from '@xh/hoist/desktop/cmp/dash/DashViewModel';
3
+ import { DashViewSpec } from '@xh/hoist/desktop/cmp/dash/DashViewSpec';
2
4
  /**
3
5
  * Base interface for {@link DashCanvasConfig} and {@link DashContainerConfig}.
4
6
  */
5
- export interface DashConfig<VSPEC, VSTATE> {
7
+ export interface DashConfig<VSPEC extends DashViewSpec, VSTATE extends DashViewState> {
6
8
  /**
7
9
  * A collection of viewSpecs, each describing a type of view that can be displayed in this
8
10
  * container.
@@ -1,4 +1,4 @@
1
- import { HoistModel, PersistenceProvider, RefreshContextModel } from '@xh/hoist/core';
1
+ import { HoistModel, RefreshContextModel } from '@xh/hoist/core';
2
2
  /**
3
3
  * Base Model for {@link DashCanvasModel} and {@link DashContainerModel}.
4
4
  */
@@ -15,6 +15,5 @@ export declare abstract class DashModel<VSPEC, VSTATE, VMODEL> extends HoistMode
15
15
  extraMenuItems: any[];
16
16
  abstract get isEmpty(): boolean;
17
17
  protected restoreState: any;
18
- protected provider: PersistenceProvider;
19
18
  constructor();
20
19
  }
@@ -12,7 +12,7 @@ export interface DashViewSpec {
12
12
  /** Content to be rendered by this DashView. */
13
13
  content: Content;
14
14
  /** Title text added to the tab header. */
15
- title: string;
15
+ title?: string;
16
16
  /** An icon placed at the left-side of the tab header. */
17
17
  icon?: ReactElement;
18
18
  /**
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { Persistable, PersistableState } from '@xh/hoist/core';
2
3
  import { DashCanvasViewModel, DashCanvasViewSpec, DashConfig, DashViewState, DashModel } from '../';
3
4
  import '@xh/hoist/desktop/register';
4
5
  export interface DashCanvasConfig extends DashConfig<DashCanvasViewSpec, DashCanvasItemState> {
@@ -31,7 +32,9 @@ export interface DashCanvasItemLayout {
31
32
  * Model for {@link DashCanvas}, managing all configurable options for the component and publishing
32
33
  * the observable state of its current widgets and their layout.
33
34
  */
34
- export declare class DashCanvasModel extends DashModel<DashCanvasViewSpec, DashCanvasItemState, DashCanvasViewModel> {
35
+ export declare class DashCanvasModel extends DashModel<DashCanvasViewSpec, DashCanvasItemState, DashCanvasViewModel> implements Persistable<{
36
+ state: DashCanvasItemState[];
37
+ }> {
35
38
  columns: number;
36
39
  rowHeight: number;
37
40
  compact: boolean;
@@ -85,13 +88,18 @@ export declare class DashCanvasModel extends DashModel<DashCanvasViewSpec, DashC
85
88
  renameView(id: string): void;
86
89
  /** Scrolls a DashCanvasView into view. */
87
90
  ensureViewVisible(id: string): void;
91
+ getPersistableState(): PersistableState<{
92
+ state: DashCanvasItemState[];
93
+ }>;
94
+ setPersistableState(persistableState: PersistableState<{
95
+ state: DashCanvasItemState[];
96
+ }>): void;
88
97
  private getLayoutFromPosition;
89
98
  private addViewInternal;
90
99
  onVisibleChange(visible: boolean): void;
91
100
  onRglLayoutChange(rglLayout: any): void;
92
101
  private setLayout;
93
102
  private loadState;
94
- private publishState;
95
103
  private buildState;
96
104
  private genViewId;
97
105
  private get viewState();
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { PlainObject, RefreshMode, RenderMode, TaskObserver } from '@xh/hoist/core';
2
+ import { Persistable, PersistableState, PlainObject, RefreshMode, RenderMode, TaskObserver } from '@xh/hoist/core';
3
3
  import { GoldenLayout } from '@xh/hoist/kit/golden-layout';
4
4
  import { DashConfig, DashModel } from '../';
5
5
  import { DashViewModel, DashViewState } from '../DashViewModel';
6
6
  import { DashContainerViewSpec } from './DashContainerViewSpec';
7
- export interface DashContainerConfig extends DashConfig<DashContainerViewSpec, DashViewState> {
7
+ export interface DashContainerConfig extends DashConfig<DashContainerViewSpec, DashContainerViewState> {
8
8
  /** Strategy for rendering DashContainerViews. Can also be set per-view in `viewSpecs`*/
9
9
  renderMode?: RenderMode;
10
10
  /** Strategy for refreshing DashContainerViews. Can also be set per-view in `viewSpecs`*/
@@ -19,6 +19,14 @@ export interface DashContainerConfig extends DashConfig<DashContainerViewSpec, D
19
19
  */
20
20
  goldenLayoutSettings?: PlainObject;
21
21
  }
22
+ export interface DashContainerViewState {
23
+ type: 'row' | 'column' | 'stack' | 'view';
24
+ id?: string;
25
+ content?: DashContainerViewState[];
26
+ title?: string;
27
+ width?: number | string;
28
+ height?: number | string;
29
+ }
22
30
  /**
23
31
  * Model for a DashContainer, representing its contents and layout state.
24
32
  *
@@ -27,7 +35,7 @@ export interface DashContainerConfig extends DashConfig<DashContainerViewSpec, D
27
35
  *
28
36
  * State should be structured as nested arrays of container objects, according to
29
37
  * GoldenLayout's content config. Supported container types are `row`, `column` and `stack`.
30
- * Child containers and views should be provided as an array under the `contents` key.
38
+ * Child containers and views should be provided as an array under the `content` key.
31
39
  *
32
40
  * + `row` lay out its children horizontally.
33
41
  * + `column` lays out its children vertically.
@@ -48,20 +56,20 @@ export interface DashContainerConfig extends DashConfig<DashContainerViewSpec, D
48
56
  * ```
49
57
  * [{
50
58
  * type: 'row',
51
- * contents: [
59
+ * content: [
52
60
  * // The first child of this row has pixel width of '200px'.
53
61
  * // The column will take the remaining width.
54
62
  * {
55
63
  * type: 'stack',
56
64
  * width: '200px',
57
- * contents: [
65
+ * content: [
58
66
  * {type: 'view', id: 'viewId'},
59
67
  * {type: 'view', id: 'viewId'}
60
68
  * ]
61
69
  * },
62
70
  * {
63
71
  * type: 'column',
64
- * contents: [
72
+ * content: [
65
73
  * // Relative height of 40%. The remaining 60% will be split equally by the other views.
66
74
  * {type: 'view', id: 'viewId', height: 40},
67
75
  * {type: 'view', id: 'viewId'},
@@ -75,7 +83,9 @@ export interface DashContainerConfig extends DashConfig<DashContainerViewSpec, D
75
83
  * @see http://golden-layout.com/docs/ItemConfig.html
76
84
  * @see http://golden-layout.com/tutorials/getting-started-react.html
77
85
  */
78
- export declare class DashContainerModel extends DashModel<DashContainerViewSpec, DashViewState, DashViewModel> {
86
+ export declare class DashContainerModel extends DashModel<DashContainerViewSpec, DashViewState, DashViewModel> implements Persistable<{
87
+ state: DashViewState[];
88
+ }> {
79
89
  showMenuButton: boolean;
80
90
  renderMode: RenderMode;
81
91
  refreshMode: RefreshMode;
@@ -98,7 +108,7 @@ export declare class DashContainerModel extends DashModel<DashContainerViewSpec,
98
108
  * Load state into the DashContainer, recreating its layout and contents
99
109
  * @param state - State to load
100
110
  */
101
- loadStateAsync(state: any): Promise<void>;
111
+ loadStateAsync(state: DashViewState[]): Promise<void>;
102
112
  /**
103
113
  * Add a view to the container.
104
114
  *
@@ -118,15 +128,21 @@ export declare class DashContainerModel extends DashModel<DashContainerViewSpec,
118
128
  */
119
129
  renameView(id: string): void;
120
130
  onResize(): void;
131
+ getViewSpec(id: string): DashContainerViewSpec;
132
+ getViewModel(id: string): DashViewModel<DashContainerViewSpec>;
133
+ getPersistableState(): PersistableState<{
134
+ state: DashViewState[];
135
+ }>;
136
+ setPersistableState(persistableState: PersistableState<{
137
+ state: DashViewState[];
138
+ }>): void;
121
139
  private updateState;
122
140
  private publishState;
123
141
  private onItemDestroyed;
124
- private getViewSpec;
125
142
  private getItems;
126
143
  private getItemsBySpecId;
127
144
  private getItemByViewModel;
128
145
  get viewState(): {};
129
- private getViewModel;
130
146
  private addViewModel;
131
147
  private removeViewModel;
132
148
  private onStackCreated;
@@ -1,4 +1,6 @@
1
+ import { DashContainerModel } from '@xh/hoist/desktop/cmp/dash';
1
2
  import { DashContainerViewSpec } from '../DashContainerViewSpec';
3
+ import GoldenLayout from 'golden-layout';
2
4
  /**
3
5
  * Lookup the DashViewModel id of a rendered view
4
6
  */
@@ -6,9 +8,9 @@ export declare function getViewModelId(view: any): any;
6
8
  /**
7
9
  * Convert the output from Golden Layouts into our serializable state
8
10
  */
9
- export declare function convertGLToState(goldenLayout: any, dashContainerModel: any): any[];
11
+ export declare function convertGLToState(goldenLayout: GoldenLayout, dashContainerModel: DashContainerModel): any[];
10
12
  /**
11
13
  * Convert our serializable state into GoldenLayout config
12
14
  */
13
- export declare function convertStateToGL(state: any[], dashContainerModel: any): any;
15
+ export declare function convertStateToGL(state: any[], dashContainerModel: DashContainerModel): any;
14
16
  export declare function goldenLayoutConfig(spec: DashContainerViewSpec): any;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { HoistModel, PersistenceProvider, PersistOptions, RefreshContextModel, RefreshMode, RenderMode, Side } from '@xh/hoist/core';
2
+ import { HoistModel, Persistable, PersistableState, PersistOptions, RefreshContextModel, RefreshMode, RenderMode, Side } from '@xh/hoist/core';
3
3
  import '@xh/hoist/desktop/register';
4
4
  import { ModalSupportConfig, ModalSupportModel } from '../modalsupport/';
5
5
  import { ErrorBoundaryConfig, ErrorBoundaryModel } from '@xh/hoist/cmp/error/ErrorBoundaryModel';
@@ -65,11 +65,15 @@ export interface PanelConfig {
65
65
  /** @internal */
66
66
  xhImpl?: any;
67
67
  }
68
+ export interface PanelPersistState {
69
+ collapsed?: boolean;
70
+ size?: number | string;
71
+ }
68
72
  /**
69
73
  * PanelModel supports configuration and state-management for user-driven Panel resizing and
70
74
  * expand/collapse, along with support for saving this state via a configured PersistenceProvider.
71
75
  */
72
- export declare class PanelModel extends HoistModel {
76
+ export declare class PanelModel extends HoistModel implements Persistable<PanelPersistState> {
73
77
  config: PanelConfig;
74
78
  readonly resizable: boolean;
75
79
  readonly collapsible: boolean;
@@ -87,7 +91,6 @@ export declare class PanelModel extends HoistModel {
87
91
  modalSupportModel: ModalSupportModel;
88
92
  refreshContextModel: RefreshContextModel;
89
93
  errorBoundaryModel: ErrorBoundaryModel;
90
- provider: PersistenceProvider;
91
94
  resizeWhileDragging: boolean;
92
95
  /**
93
96
  * True when collapsed in its "home" location as per this model's state.
@@ -116,10 +119,11 @@ export declare class PanelModel extends HoistModel {
116
119
  * Enable/disable dynamic re-rendering of contents while dragging to resize.
117
120
  */
118
121
  setResizeWhileDragging(v: boolean): void;
122
+ getPersistableState(): PersistableState<PanelPersistState>;
123
+ setPersistableState(state: PersistableState<PanelPersistState>): void;
119
124
  get vertical(): boolean;
120
125
  get contentFirst(): boolean;
121
126
  get isCollapsedToLeftOrRight(): boolean;
122
127
  enforceSizeLimits(): void;
123
- private legacyState;
124
128
  private dispatchResize;
125
129
  }
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { HoistProps } from '@xh/hoist/core';
3
+ import './ViewManager.scss';
4
+ import { ViewManagerModel } from '@xh/hoist/core/persist/viewmanager/ViewManagerModel';
5
+ import { ButtonProps } from '@xh/hoist/desktop/cmp/button';
6
+ export interface ViewManagerProps extends HoistProps<ViewManagerModel> {
7
+ menuButtonProps?: Partial<ButtonProps>;
8
+ saveButtonProps?: Partial<ButtonProps>;
9
+ /** 'whenDirty' to only show saveButton when persistence state is dirty. (Default 'whenDirty') */
10
+ showSaveButton?: 'whenDirty' | 'always' | 'never';
11
+ /** True to render private views in sub-menu (Default false)*/
12
+ showPrivateViewsInSubMenu?: boolean;
13
+ /** True to render shared views in sub-menu (Default false)*/
14
+ showSharedViewsInSubMenu?: boolean;
15
+ }
16
+ /**
17
+ * Desktop ViewManager component - a button-based menu for saving and swapping between named
18
+ * bundles of persisted component state (eg grid views, dashboards, and similar).
19
+ *
20
+ * See {@link ViewManagerModel} for additional details and configuration options.
21
+ */
22
+ export declare const ViewManager: import("react").FC<ViewManagerProps>, viewManager: import("@xh/hoist/core").ElementFactory<ViewManagerProps>;
@@ -0,0 +1,6 @@
1
+ import { HoistProps } from '@xh/hoist/core';
2
+ import { ManageDialogModel } from '@xh/hoist/core/persist/viewmanager/impl/ManageDialogModel';
3
+ export interface ManageDialogProps extends HoistProps<ManageDialogModel> {
4
+ onClose: () => void;
5
+ }
6
+ export declare const manageDialog: import("@xh/hoist/core").ElementFactory<ManageDialogProps>;
@@ -0,0 +1,2 @@
1
+ import { SaveDialogModel } from '@xh/hoist/core/persist/viewmanager/impl/SaveDialogModel';
2
+ export declare const saveDialog: import("@xh/hoist/core").ElementFactory<import("@xh/hoist/core").DefaultHoistProps<SaveDialogModel>>;
@@ -0,0 +1,3 @@
1
+ export * from './ViewManager';
2
+ export * from './cmp/ManageDialog';
3
+ export * from './cmp/SaveDialog';
@@ -2,5 +2,5 @@
2
2
  import { Alert, Button, ButtonGroup, Callout, Card, Checkbox, ControlGroup, Dialog, Drawer, EditableText, FileInput, FormGroup, Hotkey, Hotkeys, InputGroup, Label, Menu, MenuDivider, MenuItem, Navbar, NavbarDivider, NavbarGroup, NavbarHeading, NumericInput, OverflowList, Overlay2 as Overlay, Popover, Radio, RadioGroup, RangeSlider, Slider, Switch, Tab, Tabs, Tag, TagInput, Text, TextArea, Tooltip, Tree } from '@blueprintjs/core';
3
3
  import { DatePicker3 as DatePicker } from '@blueprintjs/datetime2';
4
4
  export { Alert, Button, ButtonGroup, Callout, Card, Checkbox, ControlGroup, DatePicker, Dialog, Drawer, EditableText, FileInput, FormGroup, Hotkeys, Hotkey, InputGroup, Label, Menu, MenuItem, MenuDivider, Navbar, NavbarDivider, NavbarGroup, NavbarHeading, NumericInput, OverflowList, Overlay, Popover, Radio, RadioGroup, RangeSlider, Slider, Switch, Tab, Tabs, Tag, TagInput, TextArea, Text, Tooltip, Tree };
5
- export declare const alert: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").AlertProps>, button: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").ButtonProps>, controlGroup: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").ControlGroupProps>, checkbox: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").CheckboxProps>, dialog: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").DialogProps>, datePicker: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/datetime2").DatePicker3Props>, menuDivider: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").MenuDividerProps>, menuItem: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").MenuItemProps>, navbarDivider: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").NavbarDividerProps>, numericInput: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").HTMLInputProps & import("@blueprintjs/core").NumericInputProps>, overflowList: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").OverflowListProps<any>>, popover: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").PopoverProps<import("@blueprintjs/core").DefaultPopoverTargetHTMLProps>>, radio: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").ControlProps>, rangeSlider: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").RangeSliderProps>, slider: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").SliderProps>, switchControl: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").SwitchProps>, textArea: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TextAreaProps>, tree: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TreeProps<unknown>>, tagInput: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TagInputProps>, fileInput: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").FileInputProps>, overlay: import("@xh/hoist/core").ElementFactory<Pick<import("@blueprintjs/core").Overlay2Props, "lazy" | "className" | "onClose" | "children" | "key" | "autoFocus" | "isOpen" | "transitionDuration" | "canEscapeKeyClose" | "enforceFocus" | "shouldReturnFocusOnClose" | "usePortal" | "portalClassName" | "portalContainer" | "portalStopPropagationEvents" | "transitionName" | "onClosing" | "onClosed" | "onOpening" | "onOpened" | "backdropClassName" | "backdropProps" | "canOutsideClickClose" | "hasBackdrop" | "childRef" | "childRefs"> & import("react").RefAttributes<import("@blueprintjs/core").OverlayInstance>>, tooltip: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TooltipProps<import("@blueprintjs/core").DefaultPopoverTargetHTMLProps>>;
5
+ export declare const alert: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").AlertProps>, button: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").ButtonProps>, controlGroup: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").ControlGroupProps>, checkbox: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").CheckboxProps>, dialog: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").DialogProps>, datePicker: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/datetime2").DatePicker3Props>, menuDivider: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").MenuDividerProps>, menuItem: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").MenuItemProps>, navbarDivider: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").NavbarDividerProps>, numericInput: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").HTMLInputProps & import("@blueprintjs/core").NumericInputProps>, overflowList: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").OverflowListProps<any>>, popover: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").PopoverProps<import("@blueprintjs/core").DefaultPopoverTargetHTMLProps>>, radio: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").ControlProps>, rangeSlider: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").RangeSliderProps>, slider: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").SliderProps>, switchControl: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").SwitchProps>, textArea: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TextAreaProps>, tree: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TreeProps<unknown>>, tagInput: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TagInputProps>, fileInput: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").FileInputProps>, overlay: import("@xh/hoist/core").ElementFactory<Pick<import("@blueprintjs/core").Overlay2Props, "lazy" | "className" | "onClose" | "children" | "key" | "autoFocus" | "transitionDuration" | "canEscapeKeyClose" | "enforceFocus" | "shouldReturnFocusOnClose" | "usePortal" | "portalClassName" | "portalContainer" | "portalStopPropagationEvents" | "isOpen" | "transitionName" | "onClosing" | "onClosed" | "onOpening" | "onOpened" | "backdropClassName" | "backdropProps" | "canOutsideClickClose" | "hasBackdrop" | "childRef" | "childRefs"> & import("react").RefAttributes<import("@blueprintjs/core").OverlayInstance>>, tooltip: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TooltipProps<import("@blueprintjs/core").DefaultPopoverTargetHTMLProps>>;
6
6
  export declare const buttonGroup: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").ButtonGroupProps>, callout: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").CalloutProps>, card: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").CardProps>, drawer: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").DrawerProps>, editableText: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").EditableTextProps>, formGroup: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").FormGroupProps>, hotkey: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").HotkeyProps>, hotkeys: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").HotkeysProps>, inputGroup: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").InputGroupProps>, label: import("@xh/hoist/core").ElementFactory<import("react").AllHTMLAttributes<HTMLLabelElement> & import("react").RefAttributes<HTMLLabelElement>>, menu: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").MenuProps>, navbar: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").NavbarProps>, navbarHeading: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").NavbarHeadingProps>, navbarGroup: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").NavbarGroupProps>, radioGroup: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").RadioGroupProps>, tabs: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TabsProps>, tab: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TabProps>, tag: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TagProps>, text: import("@xh/hoist/core").ElementFactory<import("@blueprintjs/core").TextProps>;
@@ -6,7 +6,7 @@ export interface ColAutosizeButtonProps extends ButtonProps {
6
6
  /** GridModel of the grid for which this button should autosize columns. */
7
7
  gridModel?: GridModel;
8
8
  /** Options for the grid autosize. */
9
- autosizeOptions?: GridAutosizeOptions;
9
+ autosizeOptions?: Omit<GridAutosizeOptions, 'mode'>;
10
10
  }
11
11
  /**
12
12
  * A convenience button to autosize visible Grid columns.
@@ -1,5 +1,5 @@
1
+ import { GridAutosizeOptions, GridModel } from '@xh/hoist/cmp/grid';
1
2
  import { HoistService } from '@xh/hoist/core';
2
- import { GridModel, GridAutosizeOptions } from '@xh/hoist/cmp/grid';
3
3
  /**
4
4
  * Sets appropriate column widths for a grid based on its contents. Generally seeks to make columns
5
5
  * at least as wide as all of their contents, including headers.
@@ -26,13 +26,10 @@ export declare class GridAutosizeService extends HoistService {
26
26
  autosizeAsync(gridModel: GridModel, colIds: string[], options: GridAutosizeOptions): Promise<void>;
27
27
  private calcRequiredWidthsAsync;
28
28
  private gatherRecordsToBeSized;
29
- /**
30
- * Calculate the increased size of columns to fill any remaining space.
31
- */
32
29
  private calcFillWidths;
33
30
  private fillEvenly;
34
31
  private fillSequentially;
35
32
  private getFillState;
36
- private getColumnFillState;
33
+ private getColFillSpec;
37
34
  private getTotalColumnWidth;
38
35
  }