@xh/hoist 70.0.0-SNAPSHOT.1731695078472 → 70.0.0-SNAPSHOT.1731700937079

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.
@@ -1,9 +1,9 @@
1
- import { HoistModel, LoadSpec, Persistable, PersistableState, PersistOptions, PlainObject, Thunkable, ViewManagerProvider } from '@xh/hoist/core';
1
+ import { HoistModel, LoadSpec, Persistable, PersistableState, PersistOptions, PlainObject, TaskObserver, Thunkable, ViewManagerProvider } from '@xh/hoist/core';
2
2
  import { SaveDialogModel } from './impl/SaveDialogModel';
3
3
  import { View, ViewTree } from './Types';
4
4
  export interface ViewManagerConfig {
5
5
  /**
6
- * True (default) to allow user to opt-in to automatically saving changes to their private
6
+ * True (default) to allow user to opt in to automatically saving changes to their private
7
7
  * views - requires `persistWith`.
8
8
  */
9
9
  enableAutoSave?: boolean;
@@ -84,6 +84,11 @@ export declare class ViewManagerModel<T extends PlainObject = PlainObject> exten
84
84
  * generally available as per `enableAutoSave`).
85
85
  */
86
86
  autoSaveActive: boolean;
87
+ /**
88
+ * TaskObserver linked to {@link selectViewAsync}. If a change to the active view is likely to
89
+ * require intensive layout/grid work, consider masking affected components with this observer.
90
+ */
91
+ viewSelectionObserver: TaskObserver;
87
92
  manageDialogOpen: boolean;
88
93
  readonly saveDialogModel: SaveDialogModel;
89
94
  private readonly _enableSharing;
@@ -7,6 +7,7 @@ import {
7
7
  PersistenceProvider,
8
8
  PersistOptions,
9
9
  PlainObject,
10
+ TaskObserver,
10
11
  Thunkable,
11
12
  ViewManagerProvider,
12
13
  XH
@@ -22,7 +23,7 @@ import {View, ViewTree} from './Types';
22
23
 
23
24
  export interface ViewManagerConfig {
24
25
  /**
25
- * True (default) to allow user to opt-in to automatically saving changes to their private
26
+ * True (default) to allow user to opt in to automatically saving changes to their private
26
27
  * views - requires `persistWith`.
27
28
  */
28
29
  enableAutoSave?: boolean;
@@ -114,6 +115,12 @@ export class ViewManagerModel<T extends PlainObject = PlainObject>
114
115
  */
115
116
  @bindable autoSaveActive = false;
116
117
 
118
+ /**
119
+ * TaskObserver linked to {@link selectViewAsync}. If a change to the active view is likely to
120
+ * require intensive layout/grid work, consider masking affected components with this observer.
121
+ */
122
+ viewSelectionObserver: TaskObserver;
123
+
117
124
  @observable manageDialogOpen = false;
118
125
  @managed readonly saveDialogModel: SaveDialogModel;
119
126
 
@@ -234,6 +241,10 @@ export class ViewManagerModel<T extends PlainObject = PlainObject>
234
241
  this.enableFavorites = enableFavorites && !!persistWith;
235
242
  this.saveDialogModel = new SaveDialogModel(this);
236
243
 
244
+ this.viewSelectionObserver = TaskObserver.trackLast({
245
+ message: `Updating ${this.displayName}...`
246
+ });
247
+
237
248
  if (persistWith) {
238
249
  PersistenceProvider.create({
239
250
  persistOptions: {
@@ -278,18 +289,19 @@ export class ViewManagerModel<T extends PlainObject = PlainObject>
278
289
  }
279
290
 
280
291
  async selectViewAsync(token: string) {
281
- // TODO - review if we benefit from async + masking - eg during intensive
282
- // component rebuild within setValue?
283
- await wait();
284
-
285
- this.selectedToken = token;
286
-
287
- // Allow this model to restore its own persisted state in its ctor and note the desired
288
- // selected token before views have been loaded. Once views are loaded, this method will
289
- // be called again with the desired token and will proceed to set the value.
290
- if (isEmpty(this.views)) return;
291
-
292
- this.setValue(this.selectedView?.value ?? ({} as T));
292
+ // Introduce minimal wait and link to viewSelectionObserver to allow apps to mask.
293
+ await wait(100)
294
+ .then(() => {
295
+ this.selectedToken = token;
296
+
297
+ // Allow this model to restore its own persisted state in its ctor and note the desired
298
+ // selected token before views have been loaded. Once views are loaded, this method will
299
+ // be called again with the desired token and will proceed to set the value.
300
+ if (isEmpty(this.views)) return;
301
+
302
+ this.setValue(this.selectedView?.value ?? ({} as T));
303
+ })
304
+ .linkTo(this.viewSelectionObserver);
293
305
  }
294
306
 
295
307
  async saveAsync(skipToast: boolean = false) {
@@ -188,7 +188,7 @@ const viewMenu = hoistCmp.factory<ViewManagerProps>({
188
188
  }),
189
189
  menuItem({
190
190
  icon: Icon.copy(),
191
- text: 'Save as...',
191
+ text: 'Save As...',
192
192
  onClick: () => model.saveAsAsync()
193
193
  }),
194
194
  menuItem({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "70.0.0-SNAPSHOT.1731695078472",
3
+ "version": "70.0.0-SNAPSHOT.1731700937079",
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",