@xh/hoist 77.0.0-SNAPSHOT.1759338550975 → 77.0.0-SNAPSHOT.1759414848931

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,5 +1,6 @@
1
1
  import { HoistModel, MenuItemLike, PlainObject, RefreshMode, RenderMode } from '@xh/hoist/core';
2
2
  import '@xh/hoist/desktop/register';
3
+ import { IReactionDisposer } from 'mobx/dist/internal';
3
4
  import { ReactElement } from 'react';
4
5
  import { DashViewSpec } from './DashViewSpec';
5
6
  export type DashViewState = PlainObject;
@@ -23,7 +24,7 @@ export declare class DashViewModel<T extends DashViewSpec = DashViewSpec> extend
23
24
  * constructing these models - no need to specify manually.
24
25
  */
25
26
  containerModel: any;
26
- /** Title with which to initialize the view. */
27
+ /** Title with which to initialize the view. Value is persisted. */
27
28
  title: string;
28
29
  /**
29
30
  * Additional info that will be displayed after the title.
@@ -31,6 +32,8 @@ export declare class DashViewModel<T extends DashViewSpec = DashViewSpec> extend
31
32
  * Value is not persisted.
32
33
  **/
33
34
  titleDetails: string;
35
+ get fullTitle(): string;
36
+ fullTitleReaction: IReactionDisposer;
34
37
  /** Icon with which to initialize the view. */
35
38
  icon: ReactElement;
36
39
  /** State with which to initialize the view. */
@@ -16,6 +16,7 @@ import {
16
16
  import '@xh/hoist/desktop/register';
17
17
  import {makeObservable, bindable} from '@xh/hoist/mobx';
18
18
  import {throwIf} from '@xh/hoist/utils/js';
19
+ import {IReactionDisposer} from 'mobx/dist/internal';
19
20
  import {ReactElement} from 'react';
20
21
  import {DashViewSpec} from './DashViewSpec';
21
22
 
@@ -44,7 +45,7 @@ export class DashViewModel<T extends DashViewSpec = DashViewSpec> extends HoistM
44
45
  */
45
46
  containerModel: any;
46
47
 
47
- /** Title with which to initialize the view. */
48
+ /** Title with which to initialize the view. Value is persisted. */
48
49
  @bindable title: string;
49
50
 
50
51
  /**
@@ -54,6 +55,12 @@ export class DashViewModel<T extends DashViewSpec = DashViewSpec> extends HoistM
54
55
  **/
55
56
  @bindable titleDetails: string;
56
57
 
58
+ get fullTitle(): string {
59
+ return this.title + (this.titleDetails ? ' ' + this.titleDetails : '');
60
+ }
61
+
62
+ fullTitleReaction: IReactionDisposer;
63
+
57
64
  /** Icon with which to initialize the view. */
58
65
  @bindable.ref icon: ReactElement;
59
66
 
@@ -34,13 +34,12 @@ export const dashCanvasView = hoistCmp.factory({
34
34
  model: uses(DashCanvasViewModel, {publishMode: 'limited'}),
35
35
 
36
36
  render({model, className}) {
37
- const {viewSpec, ref, hidePanelHeader, headerItems, autoHeight, titleDetails, title, icon} =
38
- model,
37
+ const {viewSpec, ref, hidePanelHeader, headerItems, autoHeight, fullTitle, icon} = model,
39
38
  headerProps = hidePanelHeader
40
39
  ? {}
41
40
  : {
42
41
  compactHeader: true,
43
- title: title + (titleDetails ? ' ' + titleDetails : ''),
42
+ title: fullTitle,
44
43
  icon,
45
44
  headerItems: [...headerItems, headerMenu({model})]
46
45
  };
@@ -531,7 +531,7 @@ export class DashContainerModel
531
531
  $titleEl = $el.find('.lm_title').first(),
532
532
  iconSelector = 'svg.svg-inline--fa',
533
533
  viewSpec = this.getViewSpec(item.config.component),
534
- {icon, title} = viewModel;
534
+ {icon} = viewModel;
535
535
 
536
536
  $el.off('contextmenu').contextmenu(e => {
537
537
  const index = stack.contentItems.indexOf(item);
@@ -551,22 +551,18 @@ export class DashContainerModel
551
551
  }
552
552
  }
553
553
 
554
- if (title) {
555
- const currentTitle = $titleEl.text();
556
- if (currentTitle !== title) $titleEl.text(title);
557
- }
558
-
559
554
  if (viewSpec.allowRename) {
560
555
  this.insertTitleForm($el, viewModel);
561
556
  $titleEl.off('dblclick').dblclick(() => this.showTitleForm($el, viewModel));
562
557
  }
563
558
 
564
- viewModel.addReaction({
565
- track: () => viewModel.titleDetails,
559
+ viewModel.fullTitleReaction?.();
560
+ viewModel.fullTitleReaction = viewModel.addReaction({
561
+ track: () => viewModel.fullTitle,
566
562
  run: () => {
567
563
  const currentTitle = $titleEl.text(),
568
- {title, titleDetails} = viewModel,
569
- newTitle = title + (titleDetails ? ' ' + titleDetails : '');
564
+ newTitle = viewModel.fullTitle;
565
+
570
566
  if (currentTitle !== newTitle) $titleEl.text(newTitle);
571
567
  }
572
568
  });
@@ -589,7 +585,6 @@ export class DashContainerModel
589
585
  $formEl.submit(() => {
590
586
  const title = $inputEl.val();
591
587
  if (title.length) {
592
- $titleEl.text(title);
593
588
  viewModel.title = title;
594
589
  }
595
590
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "77.0.0-SNAPSHOT.1759338550975",
3
+ "version": "77.0.0-SNAPSHOT.1759414848931",
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",