@singularsystems/neo-react 1.0.0-alpha.2 → 1.0.0-beta.0
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/CHANGELOG.md +98 -0
- package/README.md +4 -0
- package/dist/Modules/NeoReactModule.d.ts +4 -4
- package/dist/Modules/NeoReactModule.js +28 -26
- package/dist/Modules/ReactSetup.d.ts +2 -2
- package/dist/Modules/ReactSetup.js +17 -17
- package/dist/Modules/Types.d.ts +63 -61
- package/dist/Modules/Types.js +13 -12
- package/dist/React/AutoRunner.d.ts +5 -5
- package/dist/React/AutoRunner.js +94 -92
- package/dist/React/DataView.d.ts +6 -6
- package/dist/React/DataView.js +11 -11
- package/dist/React/ReactModelCreator.d.ts +11 -11
- package/dist/React/ReactModelCreator.js +165 -162
- package/dist/ReactComponents/Button.d.ts +24 -23
- package/dist/ReactComponents/Button.js +131 -123
- package/dist/ReactComponents/Card.d.ts +24 -23
- package/dist/ReactComponents/Card.js +56 -54
- package/dist/ReactComponents/Collapsable.d.ts +23 -23
- package/dist/ReactComponents/Collapsable.js +38 -38
- package/dist/ReactComponents/CollapsableBase.d.ts +13 -13
- package/dist/ReactComponents/CollapsableBase.js +42 -42
- package/dist/ReactComponents/ColorPicker.d.ts +26 -26
- package/dist/ReactComponents/ColorPicker.js +67 -67
- package/dist/ReactComponents/ComponentBase.d.ts +17 -17
- package/dist/ReactComponents/ComponentBase.js +33 -33
- package/dist/ReactComponents/ContextMenu/ContextMenu.d.ts +25 -24
- package/dist/ReactComponents/ContextMenu/ContextMenu.js +91 -88
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.d.ts +14 -14
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.js +48 -48
- package/dist/ReactComponents/ContextMenu/ContextMenuState.d.ts +8 -7
- package/dist/ReactComponents/ContextMenu/ContextMenuState.js +23 -23
- package/dist/ReactComponents/DatePicker.d.ts +19 -19
- package/dist/ReactComponents/DatePicker.js +53 -53
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +93 -83
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +222 -188
- package/dist/ReactComponents/DropDown/DropDown.d.ts +44 -44
- package/dist/ReactComponents/DropDown/DropDown.js +138 -134
- package/dist/ReactComponents/DropDown/DropDownBase.d.ts +16 -15
- package/dist/ReactComponents/DropDown/DropDownBase.js +86 -108
- package/dist/ReactComponents/DropDown/LookupHelper.d.ts +13 -0
- package/dist/ReactComponents/DropDown/LookupHelper.js +45 -0
- package/dist/ReactComponents/ErrorHandler.d.ts +9 -8
- package/dist/ReactComponents/ErrorHandler.js +92 -91
- package/dist/ReactComponents/FileManager/FileBasicInput.d.ts +20 -20
- package/dist/ReactComponents/FileManager/FileBasicInput.js +70 -70
- package/dist/ReactComponents/FileManager/FileContext.d.ts +16 -16
- package/dist/ReactComponents/FileManager/FileContext.js +24 -24
- package/dist/ReactComponents/FileManager/FileDropArea.d.ts +19 -18
- package/dist/ReactComponents/FileManager/FileDropArea.js +66 -64
- package/dist/ReactComponents/FileManager/FileInput.d.ts +44 -42
- package/dist/ReactComponents/FileManager/FileInput.js +191 -189
- package/dist/ReactComponents/FileManager/FileUploadButton.d.ts +17 -17
- package/dist/ReactComponents/FileManager/FileUploadButton.js +49 -49
- package/dist/ReactComponents/FileManager/FileUploadProgress.d.ts +14 -14
- package/dist/ReactComponents/FileManager/FileUploadProgress.js +35 -35
- package/dist/ReactComponents/Form.d.ts +19 -18
- package/dist/ReactComponents/Form.js +90 -90
- package/dist/ReactComponents/FormContext.d.ts +33 -31
- package/dist/ReactComponents/FormContext.js +39 -40
- package/dist/ReactComponents/FormGroup/FormGroup.d.ts +37 -37
- package/dist/ReactComponents/FormGroup/FormGroup.js +83 -84
- package/dist/ReactComponents/FormGroup/FormGroupFloating.d.ts +19 -19
- package/dist/ReactComponents/FormGroup/FormGroupFloating.js +97 -97
- package/dist/ReactComponents/FormGroup/FormGroupInline.d.ts +11 -11
- package/dist/ReactComponents/FormGroup/FormGroupInline.js +43 -43
- package/dist/ReactComponents/Grid/ButtonColumn.d.ts +47 -47
- package/dist/ReactComponents/Grid/ButtonColumn.js +81 -82
- package/dist/ReactComponents/Grid/Column.d.ts +47 -47
- package/dist/ReactComponents/Grid/Column.js +205 -205
- package/dist/ReactComponents/Grid/ColumnHelper.d.ts +12 -12
- package/dist/ReactComponents/Grid/ColumnHelper.js +19 -19
- package/dist/ReactComponents/Grid/Grid.d.ts +87 -90
- package/dist/ReactComponents/Grid/Grid.js +203 -203
- package/dist/ReactComponents/Grid/Row.d.ts +81 -81
- package/dist/ReactComponents/Grid/Row.js +200 -201
- package/dist/ReactComponents/Grid/_Exports.d.ts +5 -5
- package/dist/ReactComponents/Grid/_Exports.js +5 -5
- package/dist/ReactComponents/GridLayout.d.ts +20 -20
- package/dist/ReactComponents/GridLayout.js +38 -38
- package/dist/ReactComponents/Icons/FontAwesomeIconFactory.d.ts +23 -0
- package/dist/ReactComponents/Icons/FontAwesomeIconFactory.js +43 -0
- package/dist/ReactComponents/Icons/IIconFactory.d.ts +21 -0
- package/dist/ReactComponents/Icons/IIconFactory.js +1 -0
- package/dist/ReactComponents/Icons/IconFactory.d.ts +9 -0
- package/dist/ReactComponents/Icons/IconFactory.js +45 -0
- package/dist/ReactComponents/Icons/index.d.ts +3 -0
- package/dist/ReactComponents/Icons/index.js +2 -0
- package/dist/ReactComponents/Input.d.ts +45 -45
- package/dist/ReactComponents/Input.js +153 -152
- package/dist/ReactComponents/InputHelpers.d.ts +6 -5
- package/dist/ReactComponents/InputHelpers.js +29 -33
- package/dist/ReactComponents/Link.d.ts +13 -13
- package/dist/ReactComponents/Link.js +28 -28
- package/dist/ReactComponents/Loader.d.ts +18 -18
- package/dist/ReactComponents/Loader.js +57 -57
- package/dist/ReactComponents/Misc.d.ts +15 -15
- package/dist/ReactComponents/Misc.js +28 -28
- package/dist/ReactComponents/Modal/Modal.d.ts +11 -11
- package/dist/ReactComponents/Modal/Modal.js +129 -129
- package/dist/ReactComponents/Modal/ModalContainer.d.ts +17 -17
- package/dist/ReactComponents/Modal/ModalContainer.js +37 -37
- package/dist/ReactComponents/Modal/ModalPortal.d.ts +16 -15
- package/dist/ReactComponents/Modal/ModalPortal.js +27 -27
- package/dist/ReactComponents/Notifications/Alert.d.ts +7 -6
- package/dist/ReactComponents/Notifications/Alert.js +38 -35
- package/dist/ReactComponents/Notifications/Toast.d.ts +9 -8
- package/dist/ReactComponents/Notifications/Toast.js +47 -45
- package/dist/ReactComponents/Notifications/ToastContainer.d.ts +8 -8
- package/dist/ReactComponents/Notifications/ToastContainer.js +18 -18
- package/dist/ReactComponents/NumberInput.d.ts +57 -50
- package/dist/ReactComponents/NumberInput.js +260 -246
- package/dist/ReactComponents/Paging/BasicPagerControls.d.ts +26 -25
- package/dist/ReactComponents/Paging/BasicPagerControls.js +57 -55
- package/dist/ReactComponents/Paging/PageSizeControl.d.ts +11 -11
- package/dist/ReactComponents/Paging/PageSizeControl.js +21 -21
- package/dist/ReactComponents/Paging/Pager.d.ts +24 -24
- package/dist/ReactComponents/Paging/Pager.js +41 -41
- package/dist/ReactComponents/ProgressBar.d.ts +19 -19
- package/dist/ReactComponents/ProgressBar.js +52 -52
- package/dist/ReactComponents/PropTypes.d.ts +161 -161
- package/dist/ReactComponents/PropTypes.js +253 -236
- package/dist/ReactComponents/RadioList.d.ts +29 -29
- package/dist/ReactComponents/RadioList.js +59 -77
- package/dist/ReactComponents/Slider.d.ts +28 -28
- package/dist/ReactComponents/Slider.js +76 -76
- package/dist/ReactComponents/StateObserver.d.ts +15 -15
- package/dist/ReactComponents/StateObserver.js +35 -35
- package/dist/ReactComponents/Tabs/Tab.d.ts +42 -41
- package/dist/ReactComponents/Tabs/Tab.js +71 -72
- package/dist/ReactComponents/Tabs/TabContainer.d.ts +44 -44
- package/dist/ReactComponents/Tabs/TabContainer.js +98 -98
- package/dist/ReactComponents/Tabs/TabManager.d.ts +62 -62
- package/dist/ReactComponents/Tabs/TabManager.js +154 -154
- package/dist/ReactComponents/Tooltip.d.ts +20 -19
- package/dist/ReactComponents/Tooltip.js +51 -51
- package/dist/ReactComponents/TooltipHelper.d.ts +8 -8
- package/dist/ReactComponents/TooltipHelper.js +84 -84
- package/dist/ReactComponents/TooltipProvider.d.ts +30 -30
- package/dist/ReactComponents/TooltipProvider.js +111 -111
- package/dist/ReactComponents/ValidationSummary.d.ts +23 -22
- package/dist/ReactComponents/ValidationSummary.js +46 -43
- package/dist/ReactComponents/_Exports.d.ts +41 -41
- package/dist/ReactComponents/_Exports.js +41 -41
- package/dist/ReactComponents/_Managers.d.ts +4 -4
- package/dist/ReactComponents/_Managers.js +4 -4
- package/dist/Routing/BreadCrumbItem.d.ts +14 -14
- package/dist/Routing/BreadCrumbItem.js +12 -12
- package/dist/Routing/IRouteChangedProps.d.ts +31 -31
- package/dist/Routing/IRouteChangedProps.js +1 -1
- package/dist/Routing/IRouteParameter.d.ts +22 -22
- package/dist/Routing/IRouteParameter.js +9 -9
- package/dist/Routing/MenuRoute.d.ts +25 -24
- package/dist/Routing/MenuRoute.js +24 -24
- package/dist/Routing/NavigationHelper.d.ts +41 -40
- package/dist/Routing/NavigationHelper.js +61 -61
- package/dist/Routing/PageLeaveHandler.d.ts +13 -13
- package/dist/Routing/PageLeaveHandler.js +74 -74
- package/dist/Routing/RouteProvider.d.ts +31 -31
- package/dist/Routing/RouteProvider.js +92 -92
- package/dist/Routing/RouteView.d.ts +50 -50
- package/dist/Routing/RouteView.js +143 -144
- package/dist/Routing/RoutingState.d.ts +18 -15
- package/dist/Routing/RoutingState.js +45 -40
- package/dist/Routing/ViewParameter.d.ts +80 -58
- package/dist/Routing/ViewParameter.js +116 -95
- package/dist/Routing/ViewParameterList.d.ts +53 -53
- package/dist/Routing/ViewParameterList.js +163 -145
- package/dist/Routing/index.d.ts +9 -9
- package/dist/Routing/index.js +6 -6
- package/dist/Services/DisposeHelper.d.ts +15 -15
- package/dist/Services/DisposeHelper.js +40 -41
- package/dist/Services/IDisposeHelper.d.ts +12 -12
- package/dist/Services/IDisposeHelper.js +1 -1
- package/dist/Views/EmptyViewModel.d.ts +5 -5
- package/dist/Views/EmptyViewModel.js +14 -14
- package/dist/Views/IViewModel.d.ts +16 -16
- package/dist/Views/IViewModel.js +1 -1
- package/dist/Views/PersistentViewBase.d.ts +10 -10
- package/dist/Views/PersistentViewBase.js +21 -21
- package/dist/Views/ViewBase.d.ts +70 -71
- package/dist/Views/ViewBase.js +166 -153
- package/dist/Views/ViewComponentBase.d.ts +19 -13
- package/dist/Views/ViewComponentBase.js +24 -21
- package/dist/Views/ViewModelBase.d.ts +57 -56
- package/dist/Views/ViewModelBase.js +122 -118
- package/dist/Views/ViewState.d.ts +13 -13
- package/dist/Views/ViewState.js +9 -9
- package/dist/Views/index.d.ts +5 -5
- package/dist/Views/index.js +5 -5
- package/dist/index.d.ts +11 -10
- package/dist/index.js +10 -9
- package/package.json +26 -26
- package/styles/DatePicker.scss +2 -2
- package/styles/Forms.scss +5 -0
- package/styles/Validation.scss +0 -9
package/dist/Views/ViewBase.js
CHANGED
|
@@ -1,153 +1,166 @@
|
|
|
1
|
-
import { __decorate, __extends, __metadata } from "tslib";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { observable } from 'mobx';
|
|
4
|
-
import { Misc } from '@singularsystems/neo-core';
|
|
5
|
-
import { ViewParameterList } from '../Routing/ViewParameterList';
|
|
6
|
-
import { ViewState } from './ViewState';
|
|
7
|
-
import { BreadCrumbItem } from '../Routing/BreadCrumbItem';
|
|
8
|
-
import { NeoReactTypes } from '../Modules/Types';
|
|
9
|
-
import ViewModelBase from './ViewModelBase';
|
|
10
|
-
var ViewBase = /** @class */ (function (_super) {
|
|
11
|
-
__extends(ViewBase, _super);
|
|
12
|
-
/**
|
|
13
|
-
* Creates a view
|
|
14
|
-
* @param props React props.
|
|
15
|
-
* @param viewName Name of the view.
|
|
16
|
-
* @param viewModel Instance of view model, or view model type, or callback which returns a view model.
|
|
17
|
-
*/
|
|
18
|
-
function ViewBase(viewName, viewModel, props) {
|
|
19
|
-
var _this = _super.call(this, props) || this;
|
|
20
|
-
_this.viewName = "";
|
|
21
|
-
_this.routingState = Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState);
|
|
22
|
-
_this.navigation = Misc.Globals.appService.get(NeoReactTypes.Routing.NavigationHelper);
|
|
23
|
-
if (typeof viewName !== "string") {
|
|
24
|
-
throw "Error: When inheriting ViewBase, you must pass the view name into the base constructor.";
|
|
25
|
-
}
|
|
26
|
-
_this.viewName = viewName;
|
|
27
|
-
_this.viewState = _this.getStoredViewState(viewModel);
|
|
28
|
-
|
|
29
|
-
return _this;
|
|
30
|
-
}
|
|
31
|
-
Object.defineProperty(ViewBase
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
ViewBase.prototype.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*/
|
|
131
|
-
ViewBase.prototype.
|
|
132
|
-
return
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
1
|
+
import { __awaiter, __decorate, __extends, __generator, __metadata } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { observable, runInAction } from 'mobx';
|
|
4
|
+
import { Misc } from '@singularsystems/neo-core';
|
|
5
|
+
import { ViewParameterList } from '../Routing/ViewParameterList';
|
|
6
|
+
import { ViewState } from './ViewState';
|
|
7
|
+
import { BreadCrumbItem } from '../Routing/BreadCrumbItem';
|
|
8
|
+
import { NeoReactTypes } from '../Modules/Types';
|
|
9
|
+
import ViewModelBase from './ViewModelBase';
|
|
10
|
+
var ViewBase = /** @class */ (function (_super) {
|
|
11
|
+
__extends(ViewBase, _super);
|
|
12
|
+
/**
|
|
13
|
+
* Creates a view
|
|
14
|
+
* @param props React props.
|
|
15
|
+
* @param viewName Name of the view.
|
|
16
|
+
* @param viewModel Instance of view model, or view model type, or callback which returns a view model.
|
|
17
|
+
*/
|
|
18
|
+
function ViewBase(viewName, viewModel, props) {
|
|
19
|
+
var _this = _super.call(this, props) || this;
|
|
20
|
+
_this.viewName = "";
|
|
21
|
+
_this.routingState = Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState);
|
|
22
|
+
_this.navigation = Misc.Globals.appService.get(NeoReactTypes.Routing.NavigationHelper);
|
|
23
|
+
if (typeof viewName !== "string") {
|
|
24
|
+
throw "Error: When inheriting ViewBase, you must pass the view name into the base constructor.";
|
|
25
|
+
}
|
|
26
|
+
_this.viewName = viewName;
|
|
27
|
+
_this.viewState = _this.getStoredViewState(viewModel);
|
|
28
|
+
_this.routingState.currentView = _this;
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(ViewBase, "currentView", {
|
|
32
|
+
// For backwards compatibility
|
|
33
|
+
get: function () {
|
|
34
|
+
return Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState).currentView;
|
|
35
|
+
},
|
|
36
|
+
enumerable: false,
|
|
37
|
+
configurable: true
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(ViewBase.prototype, "viewModel", {
|
|
40
|
+
get: function () {
|
|
41
|
+
return this.viewState.viewModel;
|
|
42
|
+
},
|
|
43
|
+
enumerable: false,
|
|
44
|
+
configurable: true
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(ViewBase.prototype, "taskRunner", {
|
|
47
|
+
get: function () {
|
|
48
|
+
return this.viewModel.taskRunner;
|
|
49
|
+
},
|
|
50
|
+
enumerable: false,
|
|
51
|
+
configurable: true
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(ViewBase.prototype, "viewParams", {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.viewState.viewParams;
|
|
56
|
+
},
|
|
57
|
+
enumerable: false,
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
ViewBase.prototype.getStoredViewState = function (viewModel) {
|
|
61
|
+
return this.createViewState(viewModel);
|
|
62
|
+
};
|
|
63
|
+
ViewBase.prototype.createViewState = function (viewModel) {
|
|
64
|
+
var params = this.constructor.params;
|
|
65
|
+
var paramsList = new ViewParameterList(params, this);
|
|
66
|
+
var viewModelInstance = ViewModelBase.create(viewModel);
|
|
67
|
+
return new ViewState(paramsList, viewModelInstance);
|
|
68
|
+
};
|
|
69
|
+
ViewBase.prototype.componentDidMount = function () {
|
|
70
|
+
var _this = this;
|
|
71
|
+
var paramsUpdated = this.navigation.currentRouteProps ? this.viewState.viewParams.update(this.navigation.currentRouteProps.match) : false;
|
|
72
|
+
var initPromise;
|
|
73
|
+
if (!this.viewState.hasSetup) {
|
|
74
|
+
this.viewState.hasSetup = true;
|
|
75
|
+
initPromise = this.initialise();
|
|
76
|
+
}
|
|
77
|
+
if (paramsUpdated) {
|
|
78
|
+
if (initPromise) {
|
|
79
|
+
initPromise.then(function () { return _this.viewParamsUpdated(); });
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.viewParamsUpdated();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
ViewBase.prototype.componentWillUnmount = function () {
|
|
87
|
+
this.disposeViewModel();
|
|
88
|
+
};
|
|
89
|
+
ViewBase.prototype.updateViewParams = function (match) {
|
|
90
|
+
var _this = this;
|
|
91
|
+
runInAction(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
if (!this.viewState.viewParams.update(match)) return [3 /*break*/, 2];
|
|
96
|
+
return [4 /*yield*/, Promise.resolve(this.viewParamsUpdated())];
|
|
97
|
+
case 1:
|
|
98
|
+
_a.sent();
|
|
99
|
+
_a.label = 2;
|
|
100
|
+
case 2: return [2 /*return*/];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}); });
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* viewParamsUpdated() is called when the component is mounted, and whenever a route parameter or query parameter gets a changed value.
|
|
107
|
+
*/
|
|
108
|
+
ViewBase.prototype.viewParamsUpdated = function () {
|
|
109
|
+
};
|
|
110
|
+
/** Gets the parent breadcrumbs, and the breadcrumb for this view. */
|
|
111
|
+
ViewBase.prototype.getBreadCrumbStart = function () {
|
|
112
|
+
var _this = this;
|
|
113
|
+
var items = [];
|
|
114
|
+
// Get parent items
|
|
115
|
+
var menuRoute = this.routingState.currentRoute;
|
|
116
|
+
var parent = menuRoute.breadCrumbParent;
|
|
117
|
+
while (parent) {
|
|
118
|
+
items.splice(0, 0, new BreadCrumbItem(parent.name, parent.path));
|
|
119
|
+
parent = parent.breadCrumbParent;
|
|
120
|
+
}
|
|
121
|
+
// Add view name
|
|
122
|
+
var firstParam = this.viewState.viewParams.params[0];
|
|
123
|
+
items.push(new BreadCrumbItem(function () { return _this.viewName; }, (firstParam === null || firstParam === void 0 ? void 0 : firstParam.routeParameter.required) ? "" : this.navigation.getCurrentViewPath()));
|
|
124
|
+
return items;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Initialise is called from componentDidMount().
|
|
128
|
+
* Will only be called once per persistent view for the lifetime of the app.
|
|
129
|
+
* If overridden, you must call super.initialise() to initialise the ViewModel.
|
|
130
|
+
*/
|
|
131
|
+
ViewBase.prototype.initialise = function () {
|
|
132
|
+
return this.viewModel.initialise();
|
|
133
|
+
};
|
|
134
|
+
ViewBase.prototype.disposeViewModel = function () {
|
|
135
|
+
this.viewModel.dispose();
|
|
136
|
+
};
|
|
137
|
+
ViewBase.prototype.getBreadCrumbList = function () {
|
|
138
|
+
var breadCrumbList = [];
|
|
139
|
+
if (!this.breadCrumbStartItems) {
|
|
140
|
+
this.breadCrumbStartItems = this.getBreadCrumbStart();
|
|
141
|
+
}
|
|
142
|
+
breadCrumbList.push.apply(breadCrumbList, this.breadCrumbStartItems);
|
|
143
|
+
breadCrumbList.push.apply(breadCrumbList, this.viewParams.getBreadCrumbList());
|
|
144
|
+
return breadCrumbList;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Called when the user navigates to a new view, or when exiting the site.
|
|
148
|
+
* Return a string to show to the user in a dialog.
|
|
149
|
+
*/
|
|
150
|
+
ViewBase.prototype.onLeave = function () {
|
|
151
|
+
return undefined;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Called whenever the route changes. Including navigating to a new view, leaving the site, or changing a route parameter in this view.
|
|
155
|
+
* Note: if props.leavePrompt is set, onLeave() will not be called.
|
|
156
|
+
* @param props
|
|
157
|
+
*/
|
|
158
|
+
ViewBase.prototype.beforeRouteChanged = function (props) {
|
|
159
|
+
};
|
|
160
|
+
__decorate([
|
|
161
|
+
observable.ref,
|
|
162
|
+
__metadata("design:type", String)
|
|
163
|
+
], ViewBase.prototype, "viewName", void 0);
|
|
164
|
+
return ViewBase;
|
|
165
|
+
}(React.Component));
|
|
166
|
+
export default ViewBase;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ITaskRunner } from '@singularsystems/neo-core';
|
|
3
|
-
import { IViewModel } from './IViewModel';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ITaskRunner } from '@singularsystems/neo-core';
|
|
3
|
+
import { IViewModel } from './IViewModel';
|
|
4
|
+
import { valueOrLazy } from './ViewModelBase';
|
|
5
|
+
interface IComponentProps {
|
|
6
|
+
taskRunner?: ITaskRunner;
|
|
7
|
+
}
|
|
8
|
+
export default class ViewComponentBase<TProps extends IComponentProps, TViewModel extends IViewModel> extends React.Component<TProps> {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a view component.
|
|
11
|
+
* @param props Component props.
|
|
12
|
+
* @param viewModel Instance of view model, or view model type, or callback which returns a view model. Taskrunner will be set only if passing in VM type.
|
|
13
|
+
*/
|
|
14
|
+
constructor(props: TProps, viewModel: valueOrLazy<TViewModel>);
|
|
15
|
+
viewModel: TViewModel;
|
|
16
|
+
componentDidMount(): void;
|
|
17
|
+
componentWillUnmount(): void;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
ViewComponentBase.prototype.
|
|
17
|
-
this.viewModel.
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ViewModelBase from './ViewModelBase';
|
|
4
|
+
var ViewComponentBase = /** @class */ (function (_super) {
|
|
5
|
+
__extends(ViewComponentBase, _super);
|
|
6
|
+
/**
|
|
7
|
+
* Creates a view component.
|
|
8
|
+
* @param props Component props.
|
|
9
|
+
* @param viewModel Instance of view model, or view model type, or callback which returns a view model. Taskrunner will be set only if passing in VM type.
|
|
10
|
+
*/
|
|
11
|
+
function ViewComponentBase(props, viewModel) {
|
|
12
|
+
var _this = _super.call(this, props) || this;
|
|
13
|
+
_this.viewModel = ViewModelBase.create(viewModel, props.taskRunner);
|
|
14
|
+
return _this;
|
|
15
|
+
}
|
|
16
|
+
ViewComponentBase.prototype.componentDidMount = function () {
|
|
17
|
+
this.viewModel.initialise();
|
|
18
|
+
};
|
|
19
|
+
ViewComponentBase.prototype.componentWillUnmount = function () {
|
|
20
|
+
this.viewModel.dispose();
|
|
21
|
+
};
|
|
22
|
+
return ViewComponentBase;
|
|
23
|
+
}(React.Component));
|
|
24
|
+
export default ViewComponentBase;
|
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
import { ModelBase, Misc, Model, ITaskRunner } from '@singularsystems/neo-core';
|
|
2
|
-
import { IViewModel } from './IViewModel';
|
|
3
|
-
import { IReactionDisposer } from 'mobx';
|
|
4
|
-
import { BindableBase } from '@singularsystems/neo-core/dist/Model/BindableBase';
|
|
5
|
-
import { AxiosPromise } from 'axios';
|
|
6
|
-
import { WaitForTaskRunnerOptions } from '@singularsystems/neo-core/dist/Components/TaskRunner/TaskRunner';
|
|
7
|
-
export
|
|
8
|
-
export default abstract class ViewModelBase extends ModelBase implements IViewModel {
|
|
9
|
-
taskRunner: ITaskRunner;
|
|
10
|
-
private disposeHelper;
|
|
11
|
-
private trackedViewModels;
|
|
12
|
-
constructor(taskRunner?: ITaskRunner, disposeHelper?: import("../Services/IDisposeHelper").IDisposeHelper);
|
|
13
|
-
initialise(): void;
|
|
14
|
-
/**
|
|
15
|
-
* Registers a mobx reaction, which will be disposed in the dispose() method when the view is unmounted.
|
|
16
|
-
* @param expression Expression to react to.
|
|
17
|
-
* @param effect Callback to run when the result of the expression changes.
|
|
18
|
-
*/
|
|
19
|
-
registerReaction<T>(expression: () => T, effect: (value: T) => void): IReactionDisposer;
|
|
20
|
-
/**
|
|
21
|
-
* Instantiates, and registers a child view model that will be disposed when this view model is disposed.
|
|
22
|
-
* The task runner will be passed to the new vm from this one.
|
|
23
|
-
* @param viewModel View model type.
|
|
24
|
-
*/
|
|
25
|
-
registerViewModel<TViewModel extends IViewModel>(viewModel: new () => TViewModel, options?: {
|
|
26
|
-
initialise: boolean;
|
|
27
|
-
}): TViewModel;
|
|
28
|
-
/**
|
|
29
|
-
* Registers a child view model that will be disposed when this view model is disposed.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
* @param
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
import { ModelBase, Misc, Model, ITaskRunner } from '@singularsystems/neo-core';
|
|
2
|
+
import { IViewModel } from './IViewModel';
|
|
3
|
+
import { IReactionDisposer } from 'mobx';
|
|
4
|
+
import { BindableBase } from '@singularsystems/neo-core/dist/Model/BindableBase';
|
|
5
|
+
import { AxiosPromise } from 'axios';
|
|
6
|
+
import { WaitForTaskRunnerOptions } from '@singularsystems/neo-core/dist/Components/TaskRunner/TaskRunner';
|
|
7
|
+
export type valueOrLazy<T> = T | (() => T) | (new () => T);
|
|
8
|
+
export default abstract class ViewModelBase extends ModelBase implements IViewModel {
|
|
9
|
+
taskRunner: ITaskRunner;
|
|
10
|
+
private disposeHelper;
|
|
11
|
+
private trackedViewModels;
|
|
12
|
+
constructor(taskRunner?: ITaskRunner, disposeHelper?: import("../Services/IDisposeHelper").IDisposeHelper);
|
|
13
|
+
initialise(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Registers a mobx reaction, which will be disposed in the dispose() method when the view is unmounted.
|
|
16
|
+
* @param expression Expression to react to.
|
|
17
|
+
* @param effect Callback to run when the result of the expression changes.
|
|
18
|
+
*/
|
|
19
|
+
registerReaction<T>(expression: () => T, effect: (value: T) => void): IReactionDisposer;
|
|
20
|
+
/**
|
|
21
|
+
* Instantiates, and registers a child view model that will be disposed when this view model is disposed.
|
|
22
|
+
* The task runner will be passed to the new vm from this one.
|
|
23
|
+
* @param viewModel View model type.
|
|
24
|
+
*/
|
|
25
|
+
registerViewModel<TViewModel extends IViewModel>(viewModel: new () => TViewModel, options?: {
|
|
26
|
+
initialise: boolean;
|
|
27
|
+
}): TViewModel;
|
|
28
|
+
/**
|
|
29
|
+
* Registers a child view model that will be disposed when this view model is disposed.
|
|
30
|
+
* You must manually pass the current VMs task runner to the new viewmodel instance.
|
|
31
|
+
*/
|
|
32
|
+
registerViewModel<TViewModel extends IViewModel>(viewModel: TViewModel): TViewModel;
|
|
33
|
+
/**
|
|
34
|
+
* Disposes a child view model and sets the property value to null.
|
|
35
|
+
* Note: you will need to pass in the VM property like this: (this as MyVM).meta.vmProperty
|
|
36
|
+
*/
|
|
37
|
+
protected disposeViewModel(vmProperty: Model.IPropertyInstance<IViewModel | null>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Uses the task runner to call an api endpoint. The returned data is deserialised into an instance of the provided model type.
|
|
40
|
+
*/
|
|
41
|
+
waitForModel<T extends BindableBase>(modelType: typeof BindableBase, task: AxiosPromise<Model.PlainTrackedObject<T>>, options?: Partial<WaitForTaskRunnerOptions<Model.PlainTrackedObject<T>>>): Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Registers the object for disposal when this viewmodel is disposed.
|
|
44
|
+
*/
|
|
45
|
+
autoDispose<T extends Misc.IDisposable>(disposable: T): T;
|
|
46
|
+
/**
|
|
47
|
+
* Binds a list of functions to the viewmodel instance.
|
|
48
|
+
*/
|
|
49
|
+
protected bindMethods(...fns: Function[]): void;
|
|
50
|
+
dispose(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a view model instance.
|
|
53
|
+
* @param viewModel ViewModel instance, callback which returns a ViewModel or ViewModel constructor.
|
|
54
|
+
* @param taskRunner TaskRunner to set if a constructor is passed in.
|
|
55
|
+
*/
|
|
56
|
+
static create<TViewModel extends IViewModel>(viewModel: valueOrLazy<TViewModel>, taskRunner?: ITaskRunner): TViewModel;
|
|
57
|
+
}
|