@singularsystems/neo-react 1.0.0-beta.2 → 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/React/AutoRunner.js +12 -1
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +2 -1
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +17 -6
- package/dist/ReactComponents/DropDown/DropDown.d.ts +3 -0
- package/dist/ReactComponents/DropDown/DropDown.js +11 -6
- package/dist/ReactComponents/Grid/Grid.d.ts +1 -0
- package/dist/ReactComponents/Grid/Grid.js +3 -3
- package/dist/ReactComponents/Grid/Row.d.ts +4 -0
- package/dist/ReactComponents/Grid/Row.js +2 -1
- package/dist/ReactComponents/PropTypes.d.ts +1 -1
- package/dist/ReactComponents/Tabs/Tab.d.ts +1 -1
- 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 +3 -3
- package/CHANGELOG.md +0 -98
package/dist/React/AutoRunner.js
CHANGED
|
@@ -22,8 +22,19 @@ var AutoRunner = /** @class */ (function () {
|
|
|
22
22
|
this.disposerDelayed = reaction(function () { return _this.accessAllValues(model, true, new Map(), ""); }, function () { var _a; return _this.runCallback(model, callback, (_a = _this.options.delayMs) !== null && _a !== void 0 ? _a : 500); });
|
|
23
23
|
this.disposerImmediate = reaction(function () { return _this.accessAllValues(model, false, new Map(), ""); }, function () { return _this.runCallback(model, callback, 0); });
|
|
24
24
|
}
|
|
25
|
+
Object.defineProperty(AutoRunner.prototype, "hasPending", {
|
|
26
|
+
get: function () {
|
|
27
|
+
return DebounceHelper.hasPending(this);
|
|
28
|
+
},
|
|
29
|
+
enumerable: false,
|
|
30
|
+
configurable: true
|
|
31
|
+
});
|
|
25
32
|
AutoRunner.prototype.cancelPending = function () {
|
|
26
|
-
DebounceHelper.
|
|
33
|
+
if (DebounceHelper.hasPending(this)) {
|
|
34
|
+
DebounceHelper.cancelPending(this);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
27
38
|
};
|
|
28
39
|
AutoRunner.prototype.fireImmediate = function () {
|
|
29
40
|
DebounceHelper.executeImmediate(this);
|
|
@@ -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";
|
|
@@ -26,6 +26,8 @@ export interface IDropDownSpecificProps<T> {
|
|
|
26
26
|
nullText?: string;
|
|
27
27
|
/** Text to display as the first item in the drop down list when the user is allowed to select a blank item. */
|
|
28
28
|
deSelectText?: string;
|
|
29
|
+
/** Set to true if the property should be sorted by value instead of display text. */
|
|
30
|
+
sortByValue?: boolean;
|
|
29
31
|
}
|
|
30
32
|
export interface IDropDownProps<T> extends IBindableEditorProps<HTMLSelectElement> {
|
|
31
33
|
select: IDropDownSpecificProps<T>;
|
|
@@ -34,6 +36,7 @@ export default class DropDown<T> extends DropDownBase<T, IDropDownProps<T>> {
|
|
|
34
36
|
static contextType: React.Context<import("../FormContext").FormContextParams>;
|
|
35
37
|
context: React.ContextType<typeof FormContext>;
|
|
36
38
|
private selectedItem;
|
|
39
|
+
private sortByValue?;
|
|
37
40
|
private listIndexSymbol;
|
|
38
41
|
constructor(props: IDropDownProps<T>);
|
|
39
42
|
private get items();
|
|
@@ -41,7 +41,9 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
41
41
|
list.forEach(function (item) { return index[item[_this.valueMember]] = item; });
|
|
42
42
|
};
|
|
43
43
|
DropDown.prototype.getSelectedOption = function (value) {
|
|
44
|
-
this.
|
|
44
|
+
if (!this.sortByValue) {
|
|
45
|
+
this.props.bind.propertyInfo.hasSortValue = true;
|
|
46
|
+
}
|
|
45
47
|
if (!this.selectedItem || this.selectedItem[this.valueMember] != value) {
|
|
46
48
|
var list = this.items;
|
|
47
49
|
var indexJustCreated = false;
|
|
@@ -61,7 +63,9 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
61
63
|
this.selectedItem[this.displayMember] = "";
|
|
62
64
|
this.selectedItem[this.valueMember] = null;
|
|
63
65
|
}
|
|
64
|
-
|
|
66
|
+
var displayValue = this.selectedItem[this.displayMember];
|
|
67
|
+
this.setFieldInfo(this.props.bind, displayValue);
|
|
68
|
+
this.props.bind.sortValue = this.sortByValue ? value : displayValue;
|
|
65
69
|
}
|
|
66
70
|
return this.selectedItem;
|
|
67
71
|
};
|
|
@@ -81,10 +85,11 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
81
85
|
};
|
|
82
86
|
DropDown.prototype.render = function () {
|
|
83
87
|
var _this = this;
|
|
84
|
-
var _a, _b, _c, _d, _e, _f;
|
|
88
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
85
89
|
var splitProps = BindPropsHelper.normaliseEditorProps(this, this.props);
|
|
86
90
|
var domProps = BindPropsHelper.autoSetDomProperties(splitProps, this.context);
|
|
87
91
|
domProps.className = Utils.joinWithSpaces(domProps.className, splitProps.isBootstrap ? "form-control" : "neo-forms-editor");
|
|
92
|
+
this.sortByValue = (_a = splitProps.select) === null || _a === void 0 ? void 0 : _a.sortByValue;
|
|
88
93
|
if (splitProps.select) {
|
|
89
94
|
if (splitProps.select.valueMember)
|
|
90
95
|
this.valueMember = splitProps.select.valueMember;
|
|
@@ -96,7 +101,7 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
96
101
|
var items = this.items;
|
|
97
102
|
var selectedItem = this.getSelectedOption(this.props.bind.value); // This sets the sort value to allow sorting of drop downs in grids.
|
|
98
103
|
var value = this.props.bind.value;
|
|
99
|
-
var addBlankItem = ((
|
|
104
|
+
var addBlankItem = ((_c = (_b = splitProps.select) === null || _b === void 0 ? void 0 : _b.allowNulls) !== null && _c !== void 0 ? _c : this.props.bind.propertyInfo.allowNulls) || !value;
|
|
100
105
|
if (addBlankItem && items.find(function (item) { return item[_this.valueMember] === null || item[_this.valueMember] === ""; })) {
|
|
101
106
|
// If there is an item with a null value, don't add a blank drop down item.
|
|
102
107
|
addBlankItem = false;
|
|
@@ -106,7 +111,7 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
106
111
|
control = React.createElement("div", { className: "form-control form-control-loading" },
|
|
107
112
|
React.createElement("div", { className: "spinner-border" }));
|
|
108
113
|
}
|
|
109
|
-
else if ((
|
|
114
|
+
else if ((_d = splitProps.select) === null || _d === void 0 ? void 0 : _d.renderAsText) {
|
|
110
115
|
control = React.createElement("span", null, selectedItem ? selectedItem[this.displayMember] : "");
|
|
111
116
|
}
|
|
112
117
|
else if (splitProps.editor.isReadOnly) {
|
|
@@ -117,7 +122,7 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
117
122
|
domProps.disabled = true;
|
|
118
123
|
}
|
|
119
124
|
var valueIsBlank = value === undefined || value === null;
|
|
120
|
-
var nullText = (valueIsBlank || ((
|
|
125
|
+
var nullText = (valueIsBlank || ((_e = splitProps.select) === null || _e === void 0 ? void 0 : _e.deSelectText) === undefined) ? (_f = splitProps.select) === null || _f === void 0 ? void 0 : _f.nullText : (_g = splitProps.select) === null || _g === void 0 ? void 0 : _g.deSelectText;
|
|
121
126
|
if (valueIsBlank) {
|
|
122
127
|
domProps.className = Utils.joinWithSpaces(domProps.className, "select-no-value");
|
|
123
128
|
}
|
|
@@ -11,6 +11,7 @@ export declare class GridContextParams<T> {
|
|
|
11
11
|
inFirstRowInGroup: boolean;
|
|
12
12
|
columnCount: number;
|
|
13
13
|
expandProperty?: Model.IPropertyInstance<boolean | null>;
|
|
14
|
+
hideExpandButton?: boolean;
|
|
14
15
|
expandAll?: boolean;
|
|
15
16
|
hasSummaries: boolean;
|
|
16
17
|
dataView: Data.DataViewBase<T>;
|
|
@@ -101,12 +101,12 @@ var Grid = /** @class */ (function (_super) {
|
|
|
101
101
|
}
|
|
102
102
|
return (React.createElement("table", __assign({}, domProps, { className: className, ref: this.domRef }),
|
|
103
103
|
React.createElement(GridContext.Provider, { value: this.gridContext },
|
|
104
|
-
React.createElement(TableSection, { type: "header" }, this.headerItem && this.props.children(this.headerItem, this.headerItem.meta)),
|
|
104
|
+
React.createElement(TableSection, { type: "header" }, this.headerItem && this.props.children(this.headerItem, this.headerItem.meta, true)),
|
|
105
105
|
React.createElement(TableSection, { type: "body" }, this.gridContext.dataView.getItems().map(function (item) { return (React.createElement(ItemGroup, { item: item, key: keyProperty ? item[keyProperty] : item.entityIdentifier, template: _this.props.children })); })),
|
|
106
106
|
React.createElement(Observer, null, function () {
|
|
107
107
|
return React.createElement(React.Fragment, null, (showAddButton || addButton || footerButtons || _this.gridContext.hasSummaries || footerContent !== undefined) &&
|
|
108
108
|
React.createElement(TableSection, { type: "footer" },
|
|
109
|
-
_this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta),
|
|
109
|
+
_this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta, true),
|
|
110
110
|
footerContent !== undefined && footerContent(_this.gridContext.dataView.getItems()),
|
|
111
111
|
(showAddButton || addButton || footerButtons) &&
|
|
112
112
|
React.createElement(AddButtonRow, { addButton: addButton, showAddButton: showAddButton, additionalContent: footerButtons })));
|
|
@@ -208,7 +208,7 @@ var ItemGroup = /** @class */ (function (_super) {
|
|
|
208
208
|
ItemGroup.prototype.render = function () {
|
|
209
209
|
this.context.currentItem = this.props.item;
|
|
210
210
|
//this.context.inFirstRowInGroup = true;
|
|
211
|
-
return (this.props.template(this.props.item, this.props.item.meta));
|
|
211
|
+
return (this.props.template(this.props.item, this.props.item.meta, false));
|
|
212
212
|
};
|
|
213
213
|
ItemGroup.contextType = GridContext;
|
|
214
214
|
ItemGroup = __decorate([
|
|
@@ -71,6 +71,10 @@ interface INeoRowGroupProps {
|
|
|
71
71
|
* To hide the expand button, return null.
|
|
72
72
|
*/
|
|
73
73
|
expandProperty?: Model.IPropertyInstance<boolean | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Hides the expansion button on this row.
|
|
76
|
+
*/
|
|
77
|
+
hideExpandButton?: boolean;
|
|
74
78
|
children: React.ReactNode;
|
|
75
79
|
}
|
|
76
80
|
export declare class RowGroup extends React.Component<INeoRowGroupProps> {
|
|
@@ -76,7 +76,7 @@ var Row = /** @class */ (function (_super) {
|
|
|
76
76
|
var output = ((this.props.showInHeader || inBody) &&
|
|
77
77
|
React.createElement("tr", __assign({}, domProps),
|
|
78
78
|
this.expandProperty && this.context.expandAll === undefined &&
|
|
79
|
-
React.createElement(Column, { className: "neo-grid-expand-column" }, this.firstRowInGroup && inBody && this.expandProperty.value !== null &&
|
|
79
|
+
React.createElement(Column, { className: "neo-grid-expand-column" }, this.firstRowInGroup && inBody && this.context.hideExpandButton !== true && this.expandProperty.value !== null &&
|
|
80
80
|
React.createElement(NeoButton, __assign({}, expandButtonOptions))),
|
|
81
81
|
this.props.children));
|
|
82
82
|
this.setGridContext();
|
|
@@ -193,6 +193,7 @@ export var RowGroup = /** @class */ (function (_super) {
|
|
|
193
193
|
RowGroup.prototype.render = function () {
|
|
194
194
|
this.context.expandProperty = this.props.expandProperty;
|
|
195
195
|
this.context.inFirstRowInGroup = true;
|
|
196
|
+
this.context.hideExpandButton = this.props.hideExpandButton;
|
|
196
197
|
return this.props.children;
|
|
197
198
|
};
|
|
198
199
|
RowGroup.contextType = GridContext;
|
|
@@ -11,7 +11,7 @@ import PropertyInfo from '@singularsystems/neo-core/dist/Model/PropertyInfo';
|
|
|
11
11
|
import { IComponentBase } from './ComponentBase';
|
|
12
12
|
import FileInput, { IFileEditorProps } from './FileManager/FileInput';
|
|
13
13
|
import { FormContextParams } from './FormContext';
|
|
14
|
-
export type ItemCallback<T> = (item: T, meta: TransformMetaType<T
|
|
14
|
+
export type ItemCallback<T> = (item: T, meta: TransformMetaType<T>, isHeader: boolean) => React.ReactNode;
|
|
15
15
|
export declare enum ControlType {
|
|
16
16
|
Date = 0,
|
|
17
17
|
Number = 1,
|
|
@@ -9,7 +9,7 @@ interface ITabProps {
|
|
|
9
9
|
/** Name used for binding to selected tab. (Same as id property) */
|
|
10
10
|
name?: string;
|
|
11
11
|
/** Icon to display in tab header. */
|
|
12
|
-
icon?:
|
|
12
|
+
icon?: any;
|
|
13
13
|
/** True if the tab is disabled and not allowed to be clicked on. */
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
/**
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"typescript": "5.0.4"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@singularsystems/neo-core": "1.0.0-beta.
|
|
32
|
+
"@singularsystems/neo-core": "1.0.0-beta.5",
|
|
33
33
|
"@types/rc-slider": "^8.6.5",
|
|
34
34
|
"@types/react-color": "^3.0.1",
|
|
35
35
|
"axios": "1.4.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"tslib": "2.5.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@singularsystems/neo-core": ">=1.0.0-beta.
|
|
51
|
+
"@singularsystems/neo-core": ">=1.0.0-beta.5",
|
|
52
52
|
"axios": "1.4.0",
|
|
53
53
|
"inversify": ">=5.0.1",
|
|
54
54
|
"mobx": ">=6.9.0",
|
package/CHANGELOG.md
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# Version 1.x
|
|
2
|
-
|
|
3
|
-
Version 1 of neo-react upgrades react to version 18, and mobX to version 6. Both of these are major updates and will require you to make code changes to your project.
|
|
4
|
-
|
|
5
|
-
## Testing
|
|
6
|
-
|
|
7
|
-
In addition to requiring code / syntax changes, both React 18, and Mobx 6 behave differently enough to their previous versions that runtime bugs may be introduced into your project. You should only update to this version when you and the client have enough time to test the project thoroughly. If you find any issues, please report them so this document can be updated.
|
|
8
|
-
|
|
9
|
-
The project changes required are detailed below:
|
|
10
|
-
|
|
11
|
-
## Package changes:
|
|
12
|
-
|
|
13
|
-
* Update all neo packages to the latest 1.x version.
|
|
14
|
-
* Update the following packages to the latest version (these were the latest at time of writing):
|
|
15
|
-
* dependencies
|
|
16
|
-
* `"axios": "1.4.0"`,
|
|
17
|
-
* `"mobx": "6.9.0"`,
|
|
18
|
-
* `"mobx-react": "7.6.0"`,
|
|
19
|
-
* `"react": "18.2.0"`,
|
|
20
|
-
* `"react-dom": "18.2.0"`,
|
|
21
|
-
* `"react-router": "5.2.1"`, - Must be version 5.x
|
|
22
|
-
* `"react-router-dom": "5.3.0"`, - Must be version 5.x
|
|
23
|
-
* `"react-select": "5.7.3"`,
|
|
24
|
-
|
|
25
|
-
* devDependencies
|
|
26
|
-
* `"@types/react": "18.2.4"`,
|
|
27
|
-
* `"@types/react-dom": "18.2.3"`,
|
|
28
|
-
* `"@types/react-router": "5.1.17"`, - Must be version 5.x
|
|
29
|
-
* `"@types/react-router-dom": "5.3.3"`, - Must be version 5.x
|
|
30
|
-
* resolutions
|
|
31
|
-
* remove all entries
|
|
32
|
-
* delete yarn.lock, and run `yarn install`
|
|
33
|
-
|
|
34
|
-
## Fix errors
|
|
35
|
-
|
|
36
|
-
If any of your components allow children, React 18 requires to you have an explicit `children` prop. Add this to the props definition of the component:
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
interface MyProps {
|
|
40
|
-
...
|
|
41
|
-
children: React.ReactNode;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// or if the component has no other props:
|
|
45
|
-
|
|
46
|
-
MyComponent extends React.Component<{ children: React.ReactNode }> {
|
|
47
|
-
...
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
The React root api has also changed in version 18. Make the following changes to your `index.tsx` file:
|
|
52
|
-
|
|
53
|
-
Your existing code will look something like this:
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
import ReactDOM from 'react-dom';
|
|
57
|
-
...
|
|
58
|
-
// React init
|
|
59
|
-
ReactDOM.render(
|
|
60
|
-
renderComponent,
|
|
61
|
-
document.getElementById('root') as HTMLElement
|
|
62
|
-
);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Change the `ReactDOM` import, and the react init code:
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
import ReactDOM from 'react-dom/client';
|
|
69
|
-
...
|
|
70
|
-
// React init
|
|
71
|
-
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
|
72
|
-
root.render(renderComponent);
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Mobx
|
|
76
|
-
|
|
77
|
-
Before mobx 6, you could mark a property as being observable by adding an `@observable` decorator to the property. In mobx 6 this no longer works ([read more](https://mobx.js.org/migrating-from-4-or-5.html)).
|
|
78
|
-
|
|
79
|
-
For any class that extends `ModelBase`, `ValueObject`, `ViewModelBase` etc, this change is handled by neo, and you will not need to change any code.
|
|
80
|
-
|
|
81
|
-
For other classes, you will need to add initialisation code to the constructor.
|
|
82
|
-
|
|
83
|
-
* Search for `@observable` in your project. (In most projects this will be in the Sidebar and AppLayout components)
|
|
84
|
-
* In the constructor of the class that contains the property, add:
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
makeObservable(this);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Decorators on neo models
|
|
91
|
-
|
|
92
|
-
If you try use mobx decorators on any models that extend `ModelBase`, `ValueObject` or `ViewModelBase`, you will receive this error:
|
|
93
|
-
|
|
94
|
-
> [MobX] makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.
|
|
95
|
-
|
|
96
|
-
This is most likely because you have used an `@action` decorator on a method. Neo now marks all methods as actions, so you can remove the `@action` decorator.
|
|
97
|
-
|
|
98
|
-
* Search for `@action` in your project. Remove the decorator **only** if the class extends `ModelBase` (and its decendents e.g. `ValueObject`) or `ViewModelBase`.
|