@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.
Files changed (196) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +4 -0
  3. package/dist/Modules/NeoReactModule.d.ts +4 -4
  4. package/dist/Modules/NeoReactModule.js +28 -26
  5. package/dist/Modules/ReactSetup.d.ts +2 -2
  6. package/dist/Modules/ReactSetup.js +17 -17
  7. package/dist/Modules/Types.d.ts +63 -61
  8. package/dist/Modules/Types.js +13 -12
  9. package/dist/React/AutoRunner.d.ts +5 -5
  10. package/dist/React/AutoRunner.js +94 -92
  11. package/dist/React/DataView.d.ts +6 -6
  12. package/dist/React/DataView.js +11 -11
  13. package/dist/React/ReactModelCreator.d.ts +11 -11
  14. package/dist/React/ReactModelCreator.js +165 -162
  15. package/dist/ReactComponents/Button.d.ts +24 -23
  16. package/dist/ReactComponents/Button.js +131 -123
  17. package/dist/ReactComponents/Card.d.ts +24 -23
  18. package/dist/ReactComponents/Card.js +56 -54
  19. package/dist/ReactComponents/Collapsable.d.ts +23 -23
  20. package/dist/ReactComponents/Collapsable.js +38 -38
  21. package/dist/ReactComponents/CollapsableBase.d.ts +13 -13
  22. package/dist/ReactComponents/CollapsableBase.js +42 -42
  23. package/dist/ReactComponents/ColorPicker.d.ts +26 -26
  24. package/dist/ReactComponents/ColorPicker.js +67 -67
  25. package/dist/ReactComponents/ComponentBase.d.ts +17 -17
  26. package/dist/ReactComponents/ComponentBase.js +33 -33
  27. package/dist/ReactComponents/ContextMenu/ContextMenu.d.ts +25 -24
  28. package/dist/ReactComponents/ContextMenu/ContextMenu.js +91 -88
  29. package/dist/ReactComponents/ContextMenu/ContextMenuContainer.d.ts +14 -14
  30. package/dist/ReactComponents/ContextMenu/ContextMenuContainer.js +48 -48
  31. package/dist/ReactComponents/ContextMenu/ContextMenuState.d.ts +8 -7
  32. package/dist/ReactComponents/ContextMenu/ContextMenuState.js +23 -23
  33. package/dist/ReactComponents/DatePicker.d.ts +19 -19
  34. package/dist/ReactComponents/DatePicker.js +53 -53
  35. package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +93 -83
  36. package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +222 -188
  37. package/dist/ReactComponents/DropDown/DropDown.d.ts +44 -44
  38. package/dist/ReactComponents/DropDown/DropDown.js +138 -134
  39. package/dist/ReactComponents/DropDown/DropDownBase.d.ts +16 -15
  40. package/dist/ReactComponents/DropDown/DropDownBase.js +86 -108
  41. package/dist/ReactComponents/DropDown/LookupHelper.d.ts +13 -0
  42. package/dist/ReactComponents/DropDown/LookupHelper.js +45 -0
  43. package/dist/ReactComponents/ErrorHandler.d.ts +9 -8
  44. package/dist/ReactComponents/ErrorHandler.js +92 -91
  45. package/dist/ReactComponents/FileManager/FileBasicInput.d.ts +20 -20
  46. package/dist/ReactComponents/FileManager/FileBasicInput.js +70 -70
  47. package/dist/ReactComponents/FileManager/FileContext.d.ts +16 -16
  48. package/dist/ReactComponents/FileManager/FileContext.js +24 -24
  49. package/dist/ReactComponents/FileManager/FileDropArea.d.ts +19 -18
  50. package/dist/ReactComponents/FileManager/FileDropArea.js +66 -64
  51. package/dist/ReactComponents/FileManager/FileInput.d.ts +44 -42
  52. package/dist/ReactComponents/FileManager/FileInput.js +191 -189
  53. package/dist/ReactComponents/FileManager/FileUploadButton.d.ts +17 -17
  54. package/dist/ReactComponents/FileManager/FileUploadButton.js +49 -49
  55. package/dist/ReactComponents/FileManager/FileUploadProgress.d.ts +14 -14
  56. package/dist/ReactComponents/FileManager/FileUploadProgress.js +35 -35
  57. package/dist/ReactComponents/Form.d.ts +19 -18
  58. package/dist/ReactComponents/Form.js +90 -90
  59. package/dist/ReactComponents/FormContext.d.ts +33 -31
  60. package/dist/ReactComponents/FormContext.js +39 -40
  61. package/dist/ReactComponents/FormGroup/FormGroup.d.ts +37 -37
  62. package/dist/ReactComponents/FormGroup/FormGroup.js +83 -84
  63. package/dist/ReactComponents/FormGroup/FormGroupFloating.d.ts +19 -19
  64. package/dist/ReactComponents/FormGroup/FormGroupFloating.js +97 -97
  65. package/dist/ReactComponents/FormGroup/FormGroupInline.d.ts +11 -11
  66. package/dist/ReactComponents/FormGroup/FormGroupInline.js +43 -43
  67. package/dist/ReactComponents/Grid/ButtonColumn.d.ts +47 -47
  68. package/dist/ReactComponents/Grid/ButtonColumn.js +81 -82
  69. package/dist/ReactComponents/Grid/Column.d.ts +47 -47
  70. package/dist/ReactComponents/Grid/Column.js +205 -205
  71. package/dist/ReactComponents/Grid/ColumnHelper.d.ts +12 -12
  72. package/dist/ReactComponents/Grid/ColumnHelper.js +19 -19
  73. package/dist/ReactComponents/Grid/Grid.d.ts +87 -90
  74. package/dist/ReactComponents/Grid/Grid.js +203 -203
  75. package/dist/ReactComponents/Grid/Row.d.ts +81 -81
  76. package/dist/ReactComponents/Grid/Row.js +200 -201
  77. package/dist/ReactComponents/Grid/_Exports.d.ts +5 -5
  78. package/dist/ReactComponents/Grid/_Exports.js +5 -5
  79. package/dist/ReactComponents/GridLayout.d.ts +20 -20
  80. package/dist/ReactComponents/GridLayout.js +38 -38
  81. package/dist/ReactComponents/Icons/FontAwesomeIconFactory.d.ts +23 -0
  82. package/dist/ReactComponents/Icons/FontAwesomeIconFactory.js +43 -0
  83. package/dist/ReactComponents/Icons/IIconFactory.d.ts +21 -0
  84. package/dist/ReactComponents/Icons/IIconFactory.js +1 -0
  85. package/dist/ReactComponents/Icons/IconFactory.d.ts +9 -0
  86. package/dist/ReactComponents/Icons/IconFactory.js +45 -0
  87. package/dist/ReactComponents/Icons/index.d.ts +3 -0
  88. package/dist/ReactComponents/Icons/index.js +2 -0
  89. package/dist/ReactComponents/Input.d.ts +45 -45
  90. package/dist/ReactComponents/Input.js +153 -152
  91. package/dist/ReactComponents/InputHelpers.d.ts +6 -5
  92. package/dist/ReactComponents/InputHelpers.js +29 -33
  93. package/dist/ReactComponents/Link.d.ts +13 -13
  94. package/dist/ReactComponents/Link.js +28 -28
  95. package/dist/ReactComponents/Loader.d.ts +18 -18
  96. package/dist/ReactComponents/Loader.js +57 -57
  97. package/dist/ReactComponents/Misc.d.ts +15 -15
  98. package/dist/ReactComponents/Misc.js +28 -28
  99. package/dist/ReactComponents/Modal/Modal.d.ts +11 -11
  100. package/dist/ReactComponents/Modal/Modal.js +129 -129
  101. package/dist/ReactComponents/Modal/ModalContainer.d.ts +17 -17
  102. package/dist/ReactComponents/Modal/ModalContainer.js +37 -37
  103. package/dist/ReactComponents/Modal/ModalPortal.d.ts +16 -15
  104. package/dist/ReactComponents/Modal/ModalPortal.js +27 -27
  105. package/dist/ReactComponents/Notifications/Alert.d.ts +7 -6
  106. package/dist/ReactComponents/Notifications/Alert.js +38 -35
  107. package/dist/ReactComponents/Notifications/Toast.d.ts +9 -8
  108. package/dist/ReactComponents/Notifications/Toast.js +47 -45
  109. package/dist/ReactComponents/Notifications/ToastContainer.d.ts +8 -8
  110. package/dist/ReactComponents/Notifications/ToastContainer.js +18 -18
  111. package/dist/ReactComponents/NumberInput.d.ts +57 -50
  112. package/dist/ReactComponents/NumberInput.js +260 -246
  113. package/dist/ReactComponents/Paging/BasicPagerControls.d.ts +26 -25
  114. package/dist/ReactComponents/Paging/BasicPagerControls.js +57 -55
  115. package/dist/ReactComponents/Paging/PageSizeControl.d.ts +11 -11
  116. package/dist/ReactComponents/Paging/PageSizeControl.js +21 -21
  117. package/dist/ReactComponents/Paging/Pager.d.ts +24 -24
  118. package/dist/ReactComponents/Paging/Pager.js +41 -41
  119. package/dist/ReactComponents/ProgressBar.d.ts +19 -19
  120. package/dist/ReactComponents/ProgressBar.js +52 -52
  121. package/dist/ReactComponents/PropTypes.d.ts +161 -161
  122. package/dist/ReactComponents/PropTypes.js +253 -236
  123. package/dist/ReactComponents/RadioList.d.ts +29 -29
  124. package/dist/ReactComponents/RadioList.js +59 -77
  125. package/dist/ReactComponents/Slider.d.ts +28 -28
  126. package/dist/ReactComponents/Slider.js +76 -76
  127. package/dist/ReactComponents/StateObserver.d.ts +15 -15
  128. package/dist/ReactComponents/StateObserver.js +35 -35
  129. package/dist/ReactComponents/Tabs/Tab.d.ts +42 -41
  130. package/dist/ReactComponents/Tabs/Tab.js +71 -72
  131. package/dist/ReactComponents/Tabs/TabContainer.d.ts +44 -44
  132. package/dist/ReactComponents/Tabs/TabContainer.js +98 -98
  133. package/dist/ReactComponents/Tabs/TabManager.d.ts +62 -62
  134. package/dist/ReactComponents/Tabs/TabManager.js +154 -154
  135. package/dist/ReactComponents/Tooltip.d.ts +20 -19
  136. package/dist/ReactComponents/Tooltip.js +51 -51
  137. package/dist/ReactComponents/TooltipHelper.d.ts +8 -8
  138. package/dist/ReactComponents/TooltipHelper.js +84 -84
  139. package/dist/ReactComponents/TooltipProvider.d.ts +30 -30
  140. package/dist/ReactComponents/TooltipProvider.js +111 -111
  141. package/dist/ReactComponents/ValidationSummary.d.ts +23 -22
  142. package/dist/ReactComponents/ValidationSummary.js +46 -43
  143. package/dist/ReactComponents/_Exports.d.ts +41 -41
  144. package/dist/ReactComponents/_Exports.js +41 -41
  145. package/dist/ReactComponents/_Managers.d.ts +4 -4
  146. package/dist/ReactComponents/_Managers.js +4 -4
  147. package/dist/Routing/BreadCrumbItem.d.ts +14 -14
  148. package/dist/Routing/BreadCrumbItem.js +12 -12
  149. package/dist/Routing/IRouteChangedProps.d.ts +31 -31
  150. package/dist/Routing/IRouteChangedProps.js +1 -1
  151. package/dist/Routing/IRouteParameter.d.ts +22 -22
  152. package/dist/Routing/IRouteParameter.js +9 -9
  153. package/dist/Routing/MenuRoute.d.ts +25 -24
  154. package/dist/Routing/MenuRoute.js +24 -24
  155. package/dist/Routing/NavigationHelper.d.ts +41 -40
  156. package/dist/Routing/NavigationHelper.js +61 -61
  157. package/dist/Routing/PageLeaveHandler.d.ts +13 -13
  158. package/dist/Routing/PageLeaveHandler.js +74 -74
  159. package/dist/Routing/RouteProvider.d.ts +31 -31
  160. package/dist/Routing/RouteProvider.js +92 -92
  161. package/dist/Routing/RouteView.d.ts +50 -50
  162. package/dist/Routing/RouteView.js +143 -144
  163. package/dist/Routing/RoutingState.d.ts +18 -15
  164. package/dist/Routing/RoutingState.js +45 -40
  165. package/dist/Routing/ViewParameter.d.ts +80 -58
  166. package/dist/Routing/ViewParameter.js +116 -95
  167. package/dist/Routing/ViewParameterList.d.ts +53 -53
  168. package/dist/Routing/ViewParameterList.js +163 -145
  169. package/dist/Routing/index.d.ts +9 -9
  170. package/dist/Routing/index.js +6 -6
  171. package/dist/Services/DisposeHelper.d.ts +15 -15
  172. package/dist/Services/DisposeHelper.js +40 -41
  173. package/dist/Services/IDisposeHelper.d.ts +12 -12
  174. package/dist/Services/IDisposeHelper.js +1 -1
  175. package/dist/Views/EmptyViewModel.d.ts +5 -5
  176. package/dist/Views/EmptyViewModel.js +14 -14
  177. package/dist/Views/IViewModel.d.ts +16 -16
  178. package/dist/Views/IViewModel.js +1 -1
  179. package/dist/Views/PersistentViewBase.d.ts +10 -10
  180. package/dist/Views/PersistentViewBase.js +21 -21
  181. package/dist/Views/ViewBase.d.ts +70 -71
  182. package/dist/Views/ViewBase.js +166 -153
  183. package/dist/Views/ViewComponentBase.d.ts +19 -13
  184. package/dist/Views/ViewComponentBase.js +24 -21
  185. package/dist/Views/ViewModelBase.d.ts +57 -56
  186. package/dist/Views/ViewModelBase.js +122 -118
  187. package/dist/Views/ViewState.d.ts +13 -13
  188. package/dist/Views/ViewState.js +9 -9
  189. package/dist/Views/index.d.ts +5 -5
  190. package/dist/Views/index.js +5 -5
  191. package/dist/index.d.ts +11 -10
  192. package/dist/index.js +10 -9
  193. package/package.json +26 -26
  194. package/styles/DatePicker.scss +2 -2
  195. package/styles/Forms.scss +5 -0
  196. package/styles/Validation.scss +0 -9
@@ -1,144 +1,143 @@
1
- import { __extends } from "tslib";
2
- import * as React from 'react';
3
- import { matchPath } from 'react-router';
4
- import { AppServices, Misc } from '@singularsystems/neo-core';
5
- import ViewBase from '../Views/ViewBase';
6
- import { NeoReactTypes } from '../Modules/Types';
7
- import { Observer } from 'mobx-react';
8
- var RouteView = /** @class */ (function (_super) {
9
- __extends(RouteView, _super);
10
- function RouteView(props) {
11
- var _this = _super.call(this, props) || this;
12
- _this.securityService = Misc.Globals.appService.get(AppServices.NeoTypes.Security.SecurityService);
13
- _this.routeSecurityService = Misc.Globals.appService.get(AppServices.NeoTypes.Routing.RouteSecurityService);
14
- _this.routingState = Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState);
15
- _this.state = {};
16
- _this.routingState.currentRouteView = _this;
17
- return _this;
18
- }
19
- Object.defineProperty(RouteView.prototype, "routes", {
20
- get: function () {
21
- return this._routes;
22
- },
23
- set: function (value) {
24
- this._routes = value;
25
- this.routingState.appRouteProvider = value;
26
- },
27
- enumerable: false,
28
- configurable: true
29
- });
30
- RouteView.prototype.componentDidMount = function () {
31
- this.historyBlockDisposer = this.props.history.block(this.beforeLocationChanged.bind(this));
32
- this.routingState.onRouteChanged();
33
- };
34
- RouteView.prototype.componentDidUpdate = function () {
35
- this.routingState.onRouteChanged();
36
- };
37
- RouteView.prototype.componentWillUnmount = function () {
38
- if (this.historyListenDisposer) {
39
- this.historyListenDisposer();
40
- }
41
- if (this.historyBlockDisposer) {
42
- this.historyBlockDisposer();
43
- }
44
- };
45
- RouteView.prototype.beforeLocationChanged = function (location, action, isUnload) {
46
- var _a;
47
- var currentRoute = this.routingState.currentRoute;
48
- var match = location ? this.getMatch(location) : undefined;
49
- var changeProps = {
50
- isNewView: !currentRoute || !match || match.route !== currentRoute,
51
- isUnload: isUnload !== null && isUnload !== void 0 ? isUnload : false,
52
- currentView: (_a = ViewBase.currentView) !== null && _a !== void 0 ? _a : undefined,
53
- newRoute: match === null || match === void 0 ? void 0 : match.route,
54
- match: match === null || match === void 0 ? void 0 : match.match
55
- };
56
- if (ViewBase.currentView) {
57
- ViewBase.currentView.beforeRouteChanged(changeProps);
58
- if (changeProps.leavePrompt === undefined && (changeProps.isNewView || changeProps.isUnload)) {
59
- changeProps.leavePrompt = ViewBase.currentView.onLeave();
60
- }
61
- }
62
- this.beforeRouteChanged(changeProps);
63
- if (changeProps.leavePrompt === undefined) {
64
- return undefined;
65
- }
66
- else if (typeof changeProps.leavePrompt === "string") {
67
- return changeProps.leavePrompt;
68
- }
69
- else if (changeProps.leavePrompt === false) {
70
- return false;
71
- }
72
- else {
73
- this.routingState.leavePromise = changeProps.leavePrompt;
74
- return "";
75
- }
76
- };
77
- /**
78
- * Called when the url changes, before the router renders the new view.
79
- * Return a string to block navigation.
80
- * @param isNewView True if the view is changing. False if a view parameter value is changing.
81
- * @param currentView The current view before change.
82
- */
83
- RouteView.prototype.beforeRouteChanged = function (props) {
84
- };
85
- RouteView.prototype.getMatch = function (location) {
86
- for (var _i = 0, _a = this._routes.flattenedRoutes; _i < _a.length; _i++) {
87
- var route = _a[_i];
88
- var match = matchPath(location.pathname, { path: route.routePath, exact: RouteView.isExact(route) });
89
- if (match) {
90
- return { match: match, route: route };
91
- }
92
- }
93
- return null;
94
- };
95
- RouteView.isExact = function (route) {
96
- if (route.exact === undefined) {
97
- return route.path === "/" || (route.path !== undefined && route.children !== undefined);
98
- }
99
- else {
100
- return route.exact;
101
- }
102
- };
103
- RouteView.prototype.render = function () {
104
- var _this = this;
105
- return React.createElement(this.switchComponent, {}, [this.routes.flattenedRoutes.map(function (route) { return (React.createElement(_this.routeComponent, { key: route.key, path: route.routePath, exact: RouteView.isExact(route),
106
- render: function (props) {
107
- _this.routingState.setCurrentRoute(props, route);
108
- return React.createElement(Observer, null, function () { return _this.getRouteComponent(route, props.location.pathname + props.location.search); });
109
- } })); })]);
110
- };
111
- RouteView.prototype.getRouteComponent = function (route, path) {
112
- if (!route.allowAnonymous) {
113
- if (this.securityService.isAuthenticated) {
114
- if (!this.isAuthorised(route)) {
115
- //Render forbidden
116
- return this.getForbiddenComponent(route);
117
- }
118
- }
119
- else {
120
- //Redirect
121
- void this.securityService.authentication.beginSignIn(path);
122
- return this.getSigningInComponent(route);
123
- }
124
- }
125
- return this.getAuthorisedComponent(route, path);
126
- };
127
- /**
128
- * Creates the routes component after authentication and authorisation checks have been done.
129
- * This can be used to override all routes to display pages like terms and conditions.
130
- * To redirect to a route, return a react router <Redirect to= /> component.
131
- */
132
- RouteView.prototype.getAuthorisedComponent = function (route, path) {
133
- return React.createElement(route.component, null);
134
- };
135
- /**
136
- * Checks if the user is authorised to access this route.
137
- * Component from getForbiddenComponent() is returned if not.
138
- */
139
- RouteView.prototype.isAuthorised = function (route) {
140
- return this.routeSecurityService.routeAllowed(route);
141
- };
142
- return RouteView;
143
- }(React.Component));
144
- export default RouteView;
1
+ import { __extends } from "tslib";
2
+ import * as React from 'react';
3
+ import { matchPath } from 'react-router';
4
+ import { AppServices, Misc } from '@singularsystems/neo-core';
5
+ import { NeoReactTypes } from '../Modules/Types';
6
+ import { Observer } from 'mobx-react';
7
+ var RouteView = /** @class */ (function (_super) {
8
+ __extends(RouteView, _super);
9
+ function RouteView(props) {
10
+ var _this = _super.call(this, props) || this;
11
+ _this.securityService = Misc.Globals.appService.get(AppServices.NeoTypes.Security.SecurityService);
12
+ _this.routeSecurityService = Misc.Globals.appService.get(AppServices.NeoTypes.Routing.RouteSecurityService);
13
+ _this.routingState = Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState);
14
+ _this.state = {};
15
+ _this.routingState.currentRouteView = _this;
16
+ return _this;
17
+ }
18
+ Object.defineProperty(RouteView.prototype, "routes", {
19
+ get: function () {
20
+ return this._routes;
21
+ },
22
+ set: function (value) {
23
+ this._routes = value;
24
+ this.routingState.appRouteProvider = value;
25
+ },
26
+ enumerable: false,
27
+ configurable: true
28
+ });
29
+ RouteView.prototype.componentDidMount = function () {
30
+ this.historyBlockDisposer = this.props.history.block(this.beforeLocationChanged.bind(this));
31
+ this.routingState.onRouteChanged();
32
+ };
33
+ RouteView.prototype.componentDidUpdate = function () {
34
+ this.routingState.onRouteChanged();
35
+ };
36
+ RouteView.prototype.componentWillUnmount = function () {
37
+ if (this.historyListenDisposer) {
38
+ this.historyListenDisposer();
39
+ }
40
+ if (this.historyBlockDisposer) {
41
+ this.historyBlockDisposer();
42
+ }
43
+ };
44
+ RouteView.prototype.beforeLocationChanged = function (location, action, isUnload) {
45
+ var _a;
46
+ var currentRoute = this.routingState.currentRoute;
47
+ var match = location ? this.getMatch(location) : undefined;
48
+ var changeProps = {
49
+ isNewView: !currentRoute || !match || match.route !== currentRoute,
50
+ isUnload: isUnload !== null && isUnload !== void 0 ? isUnload : false,
51
+ currentView: (_a = this.routingState.currentView) !== null && _a !== void 0 ? _a : undefined,
52
+ newRoute: match === null || match === void 0 ? void 0 : match.route,
53
+ match: match === null || match === void 0 ? void 0 : match.match
54
+ };
55
+ if (this.routingState.currentView) {
56
+ this.routingState.currentView.beforeRouteChanged(changeProps);
57
+ if (changeProps.leavePrompt === undefined && (changeProps.isNewView || changeProps.isUnload)) {
58
+ changeProps.leavePrompt = this.routingState.currentView.onLeave();
59
+ }
60
+ }
61
+ this.beforeRouteChanged(changeProps);
62
+ if (changeProps.leavePrompt === undefined) {
63
+ return undefined;
64
+ }
65
+ else if (typeof changeProps.leavePrompt === "string") {
66
+ return changeProps.leavePrompt;
67
+ }
68
+ else if (changeProps.leavePrompt === false) {
69
+ return false;
70
+ }
71
+ else {
72
+ this.routingState.leavePromise = changeProps.leavePrompt;
73
+ return "";
74
+ }
75
+ };
76
+ /**
77
+ * Called when the url changes, before the router renders the new view.
78
+ * Return a string to block navigation.
79
+ * @param isNewView True if the view is changing. False if a view parameter value is changing.
80
+ * @param currentView The current view before change.
81
+ */
82
+ RouteView.prototype.beforeRouteChanged = function (props) {
83
+ };
84
+ RouteView.prototype.getMatch = function (location) {
85
+ for (var _i = 0, _a = this._routes.flattenedRoutes; _i < _a.length; _i++) {
86
+ var route = _a[_i];
87
+ var match = matchPath(location.pathname, { path: route.routePath, exact: RouteView.isExact(route) });
88
+ if (match) {
89
+ return { match: match, route: route };
90
+ }
91
+ }
92
+ return null;
93
+ };
94
+ RouteView.isExact = function (route) {
95
+ if (route.exact === undefined) {
96
+ return route.path === "/" || (route.path !== undefined && route.children !== undefined);
97
+ }
98
+ else {
99
+ return route.exact;
100
+ }
101
+ };
102
+ RouteView.prototype.render = function () {
103
+ var _this = this;
104
+ return React.createElement(this.switchComponent, {}, [this.routes.flattenedRoutes.map(function (route) { return (React.createElement(_this.routeComponent, { key: route.key, path: route.routePath, exact: RouteView.isExact(route),
105
+ render: function (props) {
106
+ _this.routingState.setCurrentRoute(props, route);
107
+ return React.createElement(Observer, null, function () { return _this.getRouteComponent(route, props.location.pathname + props.location.search); });
108
+ } })); })]);
109
+ };
110
+ RouteView.prototype.getRouteComponent = function (route, path) {
111
+ if (!route.allowAnonymous) {
112
+ if (this.securityService.isAuthenticated) {
113
+ if (!this.isAuthorised(route)) {
114
+ //Render forbidden
115
+ return this.getForbiddenComponent(route);
116
+ }
117
+ }
118
+ else {
119
+ //Redirect
120
+ void this.securityService.authentication.beginSignIn(path);
121
+ return this.getSigningInComponent(route);
122
+ }
123
+ }
124
+ return this.getAuthorisedComponent(route, path);
125
+ };
126
+ /**
127
+ * Creates the routes component after authentication and authorisation checks have been done.
128
+ * This can be used to override all routes to display pages like terms and conditions.
129
+ * To redirect to a route, return a react router <Redirect to= /> component.
130
+ */
131
+ RouteView.prototype.getAuthorisedComponent = function (route, path) {
132
+ return React.createElement(route.component, null);
133
+ };
134
+ /**
135
+ * Checks if the user is authorised to access this route.
136
+ * Component from getForbiddenComponent() is returned if not.
137
+ */
138
+ RouteView.prototype.isAuthorised = function (route) {
139
+ return this.routeSecurityService.routeAllowed(route);
140
+ };
141
+ return RouteView;
142
+ }(React.Component));
143
+ export default RouteView;
@@ -1,15 +1,18 @@
1
- import { Misc } from '@singularsystems/neo-core';
2
- import { RouteComponentProps } from 'react-router-dom';
3
- import RouteProvider, { IProcessedRoute } from './RouteProvider';
4
- import RouteView from './RouteView';
5
- export declare class RoutingState {
6
- appRouteProvider: RouteProvider;
7
- currentRouteProps: RouteComponentProps;
8
- currentRoute?: IProcessedRoute;
9
- currentRouteView?: RouteView;
10
- leavePromise?: Promise<boolean> | Promise<Misc.ModalResult> | Promise<void>;
11
- observableRoute: IProcessedRoute | null;
12
- setCurrentRoute(routeProps: RouteComponentProps, route: IProcessedRoute): void;
13
- private previousRoute?;
14
- onRouteChanged(): void;
15
- }
1
+ import { Misc } from '@singularsystems/neo-core';
2
+ import { RouteComponentProps } from 'react-router-dom';
3
+ import { IViewBase } from '../Views/ViewBase';
4
+ import RouteProvider, { IProcessedRoute } from './RouteProvider';
5
+ import RouteView from './RouteView';
6
+ export declare class RoutingState {
7
+ appRouteProvider: RouteProvider;
8
+ currentRouteProps: RouteComponentProps;
9
+ currentRoute?: IProcessedRoute;
10
+ currentRouteView?: RouteView;
11
+ leavePromise?: Promise<boolean> | Promise<Misc.ModalResult> | Promise<void>;
12
+ observableRoute: IProcessedRoute | null;
13
+ currentView: IViewBase | null;
14
+ constructor();
15
+ setCurrentRoute(routeProps: RouteComponentProps, route: IProcessedRoute): void;
16
+ private previousRoute?;
17
+ onRouteChanged(): void;
18
+ }
@@ -1,40 +1,45 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { injectable } from 'inversify';
3
- import { observable } from 'mobx';
4
- import { ViewBase } from '../Views';
5
- var RoutingState = /** @class */ (function () {
6
- function RoutingState() {
7
- this.observableRoute = null;
8
- }
9
- RoutingState.prototype.setCurrentRoute = function (routeProps, route) {
10
- this.currentRouteProps = routeProps;
11
- this.currentRoute = route;
12
- };
13
- RoutingState.prototype.onRouteChanged = function () {
14
- var _a, _b;
15
- if (this.previousRoute !== this.currentRoute) {
16
- this.previousRoute = this.currentRoute;
17
- this.observableRoute = (_a = this.currentRoute) !== null && _a !== void 0 ? _a : null;
18
- if (((_b = ViewBase.currentView) === null || _b === void 0 ? void 0 : _b.constructor) !== this.currentRoute.component) {
19
- ViewBase.currentView = null;
20
- }
21
- // Scroll back to top as if the browser had actually loaded a new page.
22
- window.scrollTo(0, 0);
23
- }
24
- else {
25
- // Same route, but parameters must have changed.
26
- if (ViewBase.currentView) {
27
- ViewBase.currentView.updateViewParams(this.currentRouteProps.match);
28
- }
29
- }
30
- };
31
- __decorate([
32
- observable.ref,
33
- __metadata("design:type", Object)
34
- ], RoutingState.prototype, "observableRoute", void 0);
35
- RoutingState = __decorate([
36
- injectable()
37
- ], RoutingState);
38
- return RoutingState;
39
- }());
40
- export { RoutingState };
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { injectable } from 'inversify';
3
+ import { makeObservable, observable } from 'mobx';
4
+ export var RoutingState = /** @class */ (function () {
5
+ function RoutingState() {
6
+ this.observableRoute = null;
7
+ this.currentView = null;
8
+ makeObservable(this);
9
+ }
10
+ RoutingState.prototype.setCurrentRoute = function (routeProps, route) {
11
+ this.currentRouteProps = routeProps;
12
+ this.currentRoute = route;
13
+ };
14
+ RoutingState.prototype.onRouteChanged = function () {
15
+ var _a, _b;
16
+ if (this.previousRoute !== this.currentRoute) {
17
+ this.previousRoute = this.currentRoute;
18
+ this.observableRoute = (_a = this.currentRoute) !== null && _a !== void 0 ? _a : null;
19
+ if (((_b = this.currentView) === null || _b === void 0 ? void 0 : _b.constructor) !== this.currentRoute.component) {
20
+ this.currentView = null;
21
+ }
22
+ // Scroll back to top as if the browser had actually loaded a new page.
23
+ window.scrollTo(0, 0);
24
+ }
25
+ else {
26
+ // Same route, but parameters must have changed.
27
+ if (this.currentView) {
28
+ this.currentView.updateViewParams(this.currentRouteProps.match);
29
+ }
30
+ }
31
+ };
32
+ __decorate([
33
+ observable.ref,
34
+ __metadata("design:type", Object)
35
+ ], RoutingState.prototype, "observableRoute", void 0);
36
+ __decorate([
37
+ observable.ref,
38
+ __metadata("design:type", Object)
39
+ ], RoutingState.prototype, "currentView", void 0);
40
+ RoutingState = __decorate([
41
+ injectable(),
42
+ __metadata("design:paramtypes", [])
43
+ ], RoutingState);
44
+ return RoutingState;
45
+ }());
@@ -1,58 +1,80 @@
1
- import { IRouteParameter } from './IRouteParameter';
2
- import { IViewParameterListInternal } from './ViewParameterList';
3
- import { Model } from '@singularsystems/neo-core';
4
- export interface IViewParameter {
5
- /**
6
- * Gets or sets the current parameter value.
7
- */
8
- value: number | string | null;
9
- /**
10
- * Clears the value, replacing the url instead of adding to the history.
11
- * This prevents the back button returning the params to the current state.
12
- */
13
- reset(): void;
14
- /**
15
- * Gets or sets the description which corresponds with the value.
16
- * Used by the breadcrumb.
17
- */
18
- description: string;
19
- /**
20
- * Returns value as a nullable int.
21
- */
22
- asNullableInt(): number | null;
23
- /**
24
- * Returns the value as a string. String will be empty if the underlying value is null.
25
- */
26
- asString(): string;
27
- /**
28
- * Allows this view parameter to automatically update when the provided properties value changes.
29
- * This is one way, you will still need to set the property value in viewParamsUpdated()
30
- */
31
- bindTo(property: Model.IPropertyInstance): void;
32
- /**
33
- * Allows this view parameter to automatically update when the value returned in the provided callback changes.
34
- */
35
- bindTo(callback: () => (string | number | null | undefined)): void;
36
- }
37
- export declare class ViewParameter implements IViewParameter {
38
- private parent;
39
- name: string;
40
- routeParameter: IRouteParameter;
41
- private hasPendingValue;
42
- private pendingValue;
43
- private _value;
44
- constructor(parent: IViewParameterListInternal, name: string, routeParameter: IRouteParameter);
45
- bindTo(propertyOrCallback: Model.IPropertyInstance | (() => (string | number | null | undefined))): void;
46
- get value(): number | string | null;
47
- set value(value: number | string | null);
48
- reset(): void;
49
- description: string;
50
- asNullableInt(): number | null;
51
- asString(): string;
52
- /** Sets the initial value, and returns true if the value changed. */
53
- setInitial(value: string | null): boolean;
54
- getParamString(state: {
55
- hasQuery: boolean;
56
- }): string;
57
- get latestValue(): string | null;
58
- }
1
+ /// <reference types="react" />
2
+ import { IRouteParameter } from './IRouteParameter';
3
+ import { IViewParameterListInternal } from './ViewParameterList';
4
+ import { Model } from '@singularsystems/neo-core';
5
+ export interface IViewParameter {
6
+ /**
7
+ * Gets or sets the current parameter value.
8
+ */
9
+ value: number | string | null;
10
+ /**
11
+ * Clears the value, replacing the url instead of adding to the history.
12
+ * This prevents the back button returning the params to the current state.
13
+ */
14
+ reset(): void;
15
+ /**
16
+ * Gets or sets the description which corresponds with the value.
17
+ * Used by the breadcrumb.
18
+ */
19
+ description: string;
20
+ /**
21
+ * Sets the description, and an optional list of prefixes.
22
+ * @param description Description of the current value.
23
+ * @param prefixes Function that returns prefixes for this breadcrumb item. The previous prefixes are passed into the function.
24
+ */
25
+ setDescription(description: string, getPrefixes?: (currentPrefixes: IViewParameterPrefix[]) => IViewParameterPrefix[]): void;
26
+ /**
27
+ * Returns value as a nullable int.
28
+ */
29
+ asNullableInt(): number | null;
30
+ /**
31
+ * Returns the value as a string. String will be empty if the underlying value is null.
32
+ */
33
+ asString(): string;
34
+ /**
35
+ * Allows this view parameter to automatically update when the provided properties value changes.
36
+ * This is one way, you will still need to set the property value in viewParamsUpdated()
37
+ */
38
+ bindTo(property: Model.IPropertyInstance): void;
39
+ /**
40
+ * Allows this view parameter to automatically update when the value returned in the provided callback changes.
41
+ */
42
+ bindTo(callback: () => (string | number | null | undefined)): void;
43
+ }
44
+ export declare class ViewParameter implements IViewParameter {
45
+ private parent;
46
+ name: string;
47
+ routeParameter: IRouteParameter;
48
+ private hasPendingValue;
49
+ private pendingValue;
50
+ private _value;
51
+ prefixes: IViewParameterPrefix[];
52
+ constructor(parent: IViewParameterListInternal, name: string, routeParameter: IRouteParameter);
53
+ bindTo(propertyOrCallback: Model.IPropertyInstance | (() => (string | number | null | undefined))): void;
54
+ get value(): number | string | null;
55
+ set value(value: number | string | null);
56
+ reset(): void;
57
+ _description: string;
58
+ get description(): string;
59
+ set description(value: string);
60
+ setDescription(description: string, getPrefixes?: (currentPrefixes: IViewParameterPrefix[]) => IViewParameterPrefix[]): void;
61
+ asNullableInt(): number | null;
62
+ asString(): string;
63
+ /** Updates the current value, and returns true if the value changed. */
64
+ update(value: string | null): boolean;
65
+ getParamString(state: {
66
+ hasQuery: boolean;
67
+ }): string;
68
+ get latestValue(): string | null;
69
+ }
70
+ interface IViewParameterPrefix {
71
+ /** Label to show on breadcrumb. */
72
+ label: string;
73
+ /** Value to use in the breadcrumb link. Clicking on the link will set the view parameter to this value. */
74
+ value?: number | string | null;
75
+ /** Custom link to use in the breadcrumb. */
76
+ link?: string;
77
+ /** Click event for the breadcrumb. */
78
+ onClick?: (e: React.MouseEvent) => void;
79
+ }
80
+ export {};