@singularsystems/neo-react 1.0.0-beta.3 → 1.0.0-beta.4
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/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +2 -1
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +17 -6
- package/dist/ReactComponents/Tabs/TabContainer.js +2 -6
- package/dist/ReactComponents/Tabs/TabManager.d.ts +4 -2
- package/dist/ReactComponents/Tabs/TabManager.js +12 -4
- package/package.json +1 -1
|
@@ -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.
|
|
@@ -78,12 +78,13 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
78
78
|
// Multi select
|
|
79
79
|
var itemList = itemsProperty.value;
|
|
80
80
|
if (action.action === "select-option") {
|
|
81
|
-
|
|
81
|
+
var newItem = { id: action.option.value, display: action.option.label };
|
|
82
|
+
itemList.push(newItem);
|
|
82
83
|
if (this.bindIdsList) {
|
|
83
84
|
this.bindIdsList.push(action.option.value);
|
|
84
85
|
}
|
|
85
86
|
if (onItemSelected) {
|
|
86
|
-
onItemSelected((_a = action.option) === null || _a === void 0 ? void 0 : _a.item);
|
|
87
|
+
onItemSelected((_a = action.option) === null || _a === void 0 ? void 0 : _a.item, undefined, newItem);
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
else if (action.action === "remove-value") {
|
|
@@ -132,15 +133,25 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
132
133
|
var bindDisplayProperty = bindDisplay;
|
|
133
134
|
var displayInfo = this.bindProperty.validator.getDisplayState(this.context.validationDisplayMode);
|
|
134
135
|
displayInfo.applyToDom(nativeProps, this.context.parentType !== EditorParentType.FormGroup);
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
if (!this.displayMember) {
|
|
137
|
+
this.displayMember = (_a = this.props.displayMember) !== null && _a !== void 0 ? _a : "";
|
|
138
|
+
}
|
|
139
|
+
if (!this.valueMember) {
|
|
140
|
+
this.valueMember = (_b = this.props.valueMember) !== null && _b !== void 0 ? _b : "";
|
|
141
|
+
}
|
|
137
142
|
var defaultItems = undefined;
|
|
138
143
|
if (this.props.items) {
|
|
139
144
|
var items_1 = this.getItems(this.props.items);
|
|
145
|
+
defaultItems = this.mapTArrayToOptions(items_1);
|
|
140
146
|
if (this.props.filterPredicate !== undefined) {
|
|
141
|
-
|
|
147
|
+
if (bindValue) {
|
|
148
|
+
// Dont filter out the current selected item even if excluded by the filter.
|
|
149
|
+
defaultItems = defaultItems.filter(function (option) { return bindValue.value === option.value || _this.props.filterPredicate(option.item); });
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
defaultItems = defaultItems.filter(function (option) { return _this.props.filterPredicate(option.item); });
|
|
153
|
+
}
|
|
142
154
|
}
|
|
143
|
-
defaultItems = this.mapTArrayToOptions(items_1);
|
|
144
155
|
if (descriptionMember === undefined && items_1.length > 0) {
|
|
145
156
|
if (EnumHelper.isEnumItem(items_1[0])) {
|
|
146
157
|
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,9 +17,7 @@ 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 _this = this;
|
|
22
|
-
var _a;
|
|
23
|
-
_this = _super.call(this, props) || this;
|
|
20
|
+
var _this = _super.call(this, props) || this;
|
|
24
21
|
_this.tabContext = new TabContextParams();
|
|
25
22
|
var tabManager;
|
|
26
23
|
if (_this.props.tabManager) {
|
|
@@ -28,8 +25,7 @@ var TabContainer = /** @class */ (function (_super) {
|
|
|
28
25
|
_this.tabContext.isUserTabManager = true;
|
|
29
26
|
}
|
|
30
27
|
else {
|
|
31
|
-
tabManager = new TabManager("", true);
|
|
32
|
-
tabManager.observable = (_a = _this.props.selectedTab) !== null && _a !== void 0 ? _a : new ObservableValue("");
|
|
28
|
+
tabManager = new TabManager("", true, _this.props.selectedTab);
|
|
33
29
|
}
|
|
34
30
|
_this.tabManager = tabManager;
|
|
35
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
|
-
|
|
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) {
|
|
14
15
|
if (selectedTab === void 0) { selectedTab = ""; }
|
|
15
16
|
if (autoSelectFirstTab === void 0) { autoSelectFirstTab = false; }
|
|
17
|
+
var _this = this;
|
|
16
18
|
this.autoSelectFirstTab = autoSelectFirstTab;
|
|
17
|
-
this.observable = new Model.ObservableValue("");
|
|
18
19
|
this.tabs = {};
|
|
19
|
-
|
|
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