@singularsystems/neo-react 0.10.66 → 0.10.67

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.
@@ -46,8 +46,9 @@ interface IAutoCompleteCommonProps<T> extends ICommonEditorProps, Props<IOption,
46
46
  /**
47
47
  * Callback which fires when an item is selected.
48
48
  * The removedItem parameter will be provided when removing an item from a multi select drop down.
49
+ * The addedItem parameter will be provided when an item is selected in a multi select drop down. This is the item stored in the bindItems list.
49
50
  */
50
- onItemSelected?: (item?: T, removedItem?: Model.ISelectedItem) => void;
51
+ onItemSelected?: (item?: T, removedItem?: Model.ISelectedItem, addedItem?: Model.ISelectedItem) => void;
51
52
  /**
52
53
  * Millisecond delay from the last typed character, to when the itemSource function is called.
53
54
  * Default is 500ms.
@@ -75,12 +75,13 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
75
75
  // Multi select
76
76
  var itemList = itemsProperty.value;
77
77
  if (action.action === "select-option") {
78
- itemList.push({ id: action.option.value, display: action.option.label });
78
+ var newItem = { id: action.option.value, display: action.option.label };
79
+ itemList.push(newItem);
79
80
  if (this.bindIdsList) {
80
81
  this.bindIdsList.push(action.option.value);
81
82
  }
82
83
  if (onItemSelected) {
83
- onItemSelected((_a = action.option) === null || _a === void 0 ? void 0 : _a.item);
84
+ onItemSelected((_a = action.option) === null || _a === void 0 ? void 0 : _a.item, undefined, newItem);
84
85
  }
85
86
  }
86
87
  else if (action.action === "remove-value") {
@@ -129,15 +130,25 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
129
130
  var bindDisplayProperty = bindDisplay;
130
131
  var displayInfo = this.bindProperty.validator.getDisplayState(this.context.validationDisplayMode);
131
132
  displayInfo.applyToDom(nativeProps, this.context.parentType !== EditorParentType.FormGroup);
132
- this.displayMember = (_a = this.props.displayMember) !== null && _a !== void 0 ? _a : "";
133
- this.valueMember = (_b = this.props.valueMember) !== null && _b !== void 0 ? _b : "";
133
+ if (!this.displayMember) {
134
+ this.displayMember = (_a = this.props.displayMember) !== null && _a !== void 0 ? _a : "";
135
+ }
136
+ if (!this.valueMember) {
137
+ this.valueMember = (_b = this.props.valueMember) !== null && _b !== void 0 ? _b : "";
138
+ }
134
139
  var defaultItems = undefined;
135
140
  if (this.props.items) {
136
141
  var items_1 = this.getItems(this.props.items);
142
+ defaultItems = this.mapTArrayToOptions(items_1);
137
143
  if (this.props.filterPredicate !== undefined) {
138
- items_1 = items_1.filter(this.props.filterPredicate);
144
+ if (bindValue) {
145
+ // Dont filter out the current selected item even if excluded by the filter.
146
+ defaultItems = defaultItems.filter(function (option) { return bindValue.value === option.value || _this.props.filterPredicate(option.item); });
147
+ }
148
+ else {
149
+ defaultItems = defaultItems.filter(function (option) { return _this.props.filterPredicate(option.item); });
150
+ }
139
151
  }
140
- defaultItems = this.mapTArrayToOptions(items_1);
141
152
  if (descriptionMember === undefined && items_1.length > 0) {
142
153
  if (EnumHelper.isEnumItem(items_1[0])) {
143
154
  descriptionMember = "description";
@@ -1,7 +1,6 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
2
  import React from "react";
3
3
  import { Components, Utils } from "@singularsystems/neo-core";
4
- import { ObservableValue } from "@singularsystems/neo-core/dist/Model/ObservableValue";
5
4
  import { TabManager } from './TabManager';
6
5
  var TabContextParams = /** @class */ (function () {
7
6
  function TabContextParams() {
@@ -18,7 +17,6 @@ export var TabContext = React.createContext(new TabContextParams());
18
17
  var TabContainer = /** @class */ (function (_super) {
19
18
  __extends(TabContainer, _super);
20
19
  function TabContainer(props) {
21
- var _a;
22
20
  var _this = _super.call(this, props) || this;
23
21
  _this.tabContext = new TabContextParams();
24
22
  var tabManager;
@@ -27,8 +25,7 @@ var TabContainer = /** @class */ (function (_super) {
27
25
  _this.tabContext.isUserTabManager = true;
28
26
  }
29
27
  else {
30
- tabManager = new TabManager("", true);
31
- tabManager.observable = (_a = _this.props.selectedTab) !== null && _a !== void 0 ? _a : new ObservableValue("");
28
+ tabManager = new TabManager("", true, _this.props.selectedTab);
32
29
  }
33
30
  _this.tabManager = tabManager;
34
31
  _this.tabContext.tabManager = _this.tabManager;
@@ -22,13 +22,14 @@ export interface ITabManagerInternal extends ITabManager {
22
22
  */
23
23
  export declare class TabManager<T extends string = string> {
24
24
  private autoSelectFirstTab;
25
- observable: Model.ObservableValue<T>;
25
+ private reactionDisposer;
26
+ observable: Model.IObservableValue<T>;
26
27
  /**
27
28
  * Creates a tab manager used to bind to a tab container.
28
29
  * @param selectedTab Initially selected tab.
29
30
  * @param autoSelectFirstTab Set to true if the first child tab should become selected.
30
31
  */
31
- constructor(selectedTab?: T, autoSelectFirstTab?: boolean);
32
+ constructor(selectedTab?: T, autoSelectFirstTab?: boolean, observable?: Model.IObservableValue<T>);
32
33
  /** Called by tab container. */
33
34
  private initialise;
34
35
  /** Called by tab container. */
@@ -43,6 +44,7 @@ export declare class TabManager<T extends string = string> {
43
44
  * Registers a callback to run whenever the tab with this tab key is displayed.
44
45
  */
45
46
  onTabDisplayed(tabKey: T, callback: () => void): this;
47
+ /** Called by tab container. */
46
48
  private tabMounted;
47
49
  private getTab;
48
50
  /**
@@ -1,4 +1,5 @@
1
1
  import { Model } from '@singularsystems/neo-core';
2
+ import { reaction } from "mobx";
2
3
  import { CancellableEvent } from '../Misc';
3
4
  /**
4
5
  * Tab manager used to manage a tab component.
@@ -10,14 +11,20 @@ var TabManager = /** @class */ (function () {
10
11
  * @param selectedTab Initially selected tab.
11
12
  * @param autoSelectFirstTab Set to true if the first child tab should become selected.
12
13
  */
13
- function TabManager(selectedTab, autoSelectFirstTab) {
14
+ function TabManager(selectedTab, autoSelectFirstTab, observable) {
15
+ var _this = this;
14
16
  if (selectedTab === void 0) { selectedTab = ""; }
15
17
  if (autoSelectFirstTab === void 0) { autoSelectFirstTab = false; }
16
18
  this.autoSelectFirstTab = autoSelectFirstTab;
17
- this.observable = new Model.ObservableValue("");
18
19
  this.tabs = {};
19
- this.observable.value = selectedTab;
20
+ if (observable) {
21
+ this.observable = observable;
22
+ }
23
+ else {
24
+ this.observable = new Model.ObservableValue(selectedTab);
25
+ }
20
26
  this.onTabChanged = this.onTabChanged.bind(this);
27
+ this.reactionDisposer = reaction(function () { return _this.observable.value; }, function () { return _this.onTabChanged(); });
21
28
  }
22
29
  /** Called by tab container. */
23
30
  TabManager.prototype.initialise = function () {
@@ -27,6 +34,7 @@ var TabManager = /** @class */ (function () {
27
34
  };
28
35
  /** Called by tab container. */
29
36
  TabManager.prototype.destroy = function () {
37
+ this.reactionDisposer();
30
38
  };
31
39
  Object.defineProperty(TabManager.prototype, "selectedTab", {
32
40
  get: function () {
@@ -50,7 +58,6 @@ var TabManager = /** @class */ (function () {
50
58
  }
51
59
  cancellableEvent.tryRunAction(function () {
52
60
  _this.observable.value = value;
53
- _this.onTabChanged();
54
61
  });
55
62
  }
56
63
  },
@@ -73,6 +80,7 @@ var TabManager = /** @class */ (function () {
73
80
  tab.onDisplayed = callback;
74
81
  return this;
75
82
  };
83
+ /** Called by tab container. */
76
84
  TabManager.prototype.tabMounted = function (tabKey, onLeave) {
77
85
  var tab = this.getTab(tabKey, true);
78
86
  tab.onLeave = onLeave;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-react",
3
- "version": "0.10.66",
3
+ "version": "0.10.67",
4
4
  "description": "React application logic and components for the Neo client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",