@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,74 +1,74 @@
1
- import { __awaiter, __decorate, __generator, __metadata, __param } from "tslib";
2
- import { Routing, ModalUtils, Misc, AppServices } from '@singularsystems/neo-core';
3
- import ViewBase from '../Views/ViewBase';
4
- import { inject, injectable } from 'inversify';
5
- import { NeoReactTypes } from '../Modules/Types';
6
- import { RoutingState } from './RoutingState';
7
- var PageLeaveHandler = /** @class */ (function () {
8
- function PageLeaveHandler(routingState) {
9
- this.routingState = routingState;
10
- }
11
- /**
12
- * Handler for react-routers BrowserRouter.getUserConfirmation
13
- */
14
- PageLeaveHandler.showNavigationConfirmation = function (prompt, callback) {
15
- return __awaiter(this, void 0, void 0, function () {
16
- var result;
17
- return __generator(this, function (_a) {
18
- switch (_a.label) {
19
- case 0: return [4 /*yield*/, Misc.Globals.appService.get(AppServices.NeoTypes.Routing.PageLeaveHandler).onLeavePage(ViewBase.currentView, prompt, Routing.NavigateLocation.Internal)];
20
- case 1:
21
- result = _a.sent();
22
- callback(result);
23
- return [2 /*return*/];
24
- }
25
- });
26
- });
27
- };
28
- PageLeaveHandler.prototype.onWindowUnload = function (view, e) {
29
- if (view) {
30
- var routeView = Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState).currentRouteView;
31
- var prompt_1 = routeView.beforeLocationChanged(undefined, "PUSH", true);
32
- if (prompt_1 || prompt_1 === false || prompt_1 === "") {
33
- e.preventDefault();
34
- e.returnValue = !prompt_1 ? "Are you sure you want to continue?" : prompt_1;
35
- }
36
- }
37
- };
38
- PageLeaveHandler.prototype.onLeavePage = function (view, prompt, location) {
39
- if (this.routingState.leavePromise) {
40
- var promise_1 = this.routingState.leavePromise;
41
- this.routingState.leavePromise = undefined;
42
- return new Promise(function (resolve) {
43
- promise_1.then(function (result) {
44
- if (result) {
45
- resolve(result === true || result === Misc.ModalResult.Yes);
46
- }
47
- else {
48
- resolve(false);
49
- }
50
- });
51
- });
52
- }
53
- else {
54
- return this.showDefaultConfirmation(view, prompt, location);
55
- }
56
- };
57
- PageLeaveHandler.prototype.showDefaultConfirmation = function (view, prompt, location) {
58
- var title = view ? view.viewName : "Un-saved Changes";
59
- return new Promise(function (resolve) {
60
- ModalUtils.showModal(title, prompt, {
61
- onClose: function () { return resolve(false); },
62
- acceptButton: { text: "Leave", onClick: function () { return resolve(true); } },
63
- closeButton: { text: "Stay", onClick: function () { return resolve(false); } }
64
- });
65
- });
66
- };
67
- PageLeaveHandler = __decorate([
68
- injectable(),
69
- __param(0, inject(NeoReactTypes.Routing.GlobalRoutingState.symbol)),
70
- __metadata("design:paramtypes", [RoutingState])
71
- ], PageLeaveHandler);
72
- return PageLeaveHandler;
73
- }());
74
- export { PageLeaveHandler };
1
+ import { __awaiter, __decorate, __generator, __metadata, __param } from "tslib";
2
+ import { Routing, ModalUtils, Misc, AppServices } from '@singularsystems/neo-core';
3
+ import { inject, injectable } from 'inversify';
4
+ import { NeoReactTypes } from '../Modules/Types';
5
+ import { RoutingState } from './RoutingState';
6
+ export var PageLeaveHandler = /** @class */ (function () {
7
+ function PageLeaveHandler(routingState) {
8
+ this.routingState = routingState;
9
+ }
10
+ /**
11
+ * Handler for react-routers BrowserRouter.getUserConfirmation
12
+ */
13
+ PageLeaveHandler.showNavigationConfirmation = function (prompt, callback) {
14
+ return __awaiter(this, void 0, void 0, function () {
15
+ var pageLeaveHandler, routingState, result;
16
+ return __generator(this, function (_a) {
17
+ switch (_a.label) {
18
+ case 0:
19
+ pageLeaveHandler = Misc.Globals.appService.get(AppServices.NeoTypes.Routing.PageLeaveHandler), routingState = Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState);
20
+ return [4 /*yield*/, pageLeaveHandler.onLeavePage(routingState.currentView, prompt, Routing.NavigateLocation.Internal)];
21
+ case 1:
22
+ result = _a.sent();
23
+ callback(result);
24
+ return [2 /*return*/];
25
+ }
26
+ });
27
+ });
28
+ };
29
+ PageLeaveHandler.prototype.onWindowUnload = function (view, e) {
30
+ if (view) {
31
+ var routeView = Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState).currentRouteView;
32
+ var prompt_1 = routeView.beforeLocationChanged(undefined, "PUSH", true);
33
+ if (prompt_1 || prompt_1 === false || prompt_1 === "") {
34
+ e.preventDefault();
35
+ e.returnValue = !prompt_1 ? "Are you sure you want to continue?" : prompt_1;
36
+ }
37
+ }
38
+ };
39
+ PageLeaveHandler.prototype.onLeavePage = function (view, prompt, location) {
40
+ if (this.routingState.leavePromise) {
41
+ var promise_1 = this.routingState.leavePromise;
42
+ this.routingState.leavePromise = undefined;
43
+ return new Promise(function (resolve) {
44
+ promise_1.then(function (result) {
45
+ if (result) {
46
+ resolve(result === true || result === Misc.ModalResult.Yes);
47
+ }
48
+ else {
49
+ resolve(false);
50
+ }
51
+ });
52
+ });
53
+ }
54
+ else {
55
+ return this.showDefaultConfirmation(view, prompt, location);
56
+ }
57
+ };
58
+ PageLeaveHandler.prototype.showDefaultConfirmation = function (view, prompt, location) {
59
+ var title = view ? view.viewName : "Un-saved Changes";
60
+ return new Promise(function (resolve) {
61
+ ModalUtils.showModal(title, prompt, {
62
+ onClose: function () { return resolve(false); },
63
+ acceptButton: { text: "Leave", onClick: function () { return resolve(true); } },
64
+ closeButton: { text: "Stay", onClick: function () { return resolve(false); } }
65
+ });
66
+ });
67
+ };
68
+ PageLeaveHandler = __decorate([
69
+ injectable(),
70
+ __param(0, inject(NeoReactTypes.Routing.GlobalRoutingState.symbol)),
71
+ __metadata("design:paramtypes", [RoutingState])
72
+ ], PageLeaveHandler);
73
+ return PageLeaveHandler;
74
+ }());
@@ -1,31 +1,31 @@
1
- import { Routing } from '@singularsystems/neo-core';
2
- import React from 'react';
3
- export interface IProcessedRoute extends Routing.IRoute {
4
- key: number;
5
- /** Path including parameters */
6
- routePath: string;
7
- }
8
- export default class RouteProvider {
9
- menuRoutes: Routing.IMenuRoute[];
10
- pureRoutes?: Routing.IRoute[] | undefined;
11
- notFoundRoute?: React.ComponentType<{}> | undefined;
12
- private key;
13
- private routeIndex;
14
- private paramRoutes;
15
- flattenedRoutes: IProcessedRoute[];
16
- /**
17
- * Creates a route provider which provides a list of flattened routes.
18
- * @param menuRoutes Routes which appear on the main menu.
19
- * @param pureRoutes Routes which don't have a menu item.
20
- * @param notFoundRoute Route to render when the url doesn't match any of the above routes.
21
- */
22
- constructor(menuRoutes: Routing.IMenuRoute[], pureRoutes?: Routing.IRoute[] | undefined, notFoundRoute?: React.ComponentType<{}> | undefined);
23
- /** Gets the path the component is bound to. If the component is bound to multiple paths, the first path is returned. */
24
- getPathForComponent(component: any): string | undefined;
25
- private flatten;
26
- /**
27
- * Create a copy of the route info, and process it.
28
- * Adds a unique key, and adds route parameters extracted from the component static params object.
29
- */
30
- private processRoute;
31
- }
1
+ import { Routing } from '@singularsystems/neo-core';
2
+ import React from 'react';
3
+ export interface IProcessedRoute extends Routing.IRoute {
4
+ key: number;
5
+ /** Path including parameters */
6
+ routePath: string;
7
+ }
8
+ export default class RouteProvider {
9
+ menuRoutes: Routing.IMenuRoute[];
10
+ pureRoutes?: Routing.IRoute[] | undefined;
11
+ notFoundRoute?: React.ComponentType<{}> | undefined;
12
+ private key;
13
+ private routeIndex;
14
+ private paramRoutes;
15
+ flattenedRoutes: IProcessedRoute[];
16
+ /**
17
+ * Creates a route provider which provides a list of flattened routes.
18
+ * @param menuRoutes Routes which appear on the main menu.
19
+ * @param pureRoutes Routes which don't have a menu item.
20
+ * @param notFoundRoute Route to render when the url doesn't match any of the above routes.
21
+ */
22
+ constructor(menuRoutes: Routing.IMenuRoute[], pureRoutes?: Routing.IRoute[] | undefined, notFoundRoute?: React.ComponentType<{}> | undefined);
23
+ /** Gets the path the component is bound to. If the component is bound to multiple paths, the first path is returned. */
24
+ getPathForComponent(component: any): string | undefined;
25
+ private flatten;
26
+ /**
27
+ * Create a copy of the route info, and process it.
28
+ * Adds a unique key, and adds route parameters extracted from the component static params object.
29
+ */
30
+ private processRoute;
31
+ }
@@ -1,92 +1,92 @@
1
- import { __assign, __spreadArray } from "tslib";
2
- import { MenuRoute } from './MenuRoute';
3
- var RouteProvider = /** @class */ (function () {
4
- /**
5
- * Creates a route provider which provides a list of flattened routes.
6
- * @param menuRoutes Routes which appear on the main menu.
7
- * @param pureRoutes Routes which don't have a menu item.
8
- * @param notFoundRoute Route to render when the url doesn't match any of the above routes.
9
- */
10
- function RouteProvider(menuRoutes, pureRoutes, notFoundRoute) {
11
- var _a;
12
- this.menuRoutes = menuRoutes;
13
- this.pureRoutes = pureRoutes;
14
- this.notFoundRoute = notFoundRoute;
15
- this.key = 1;
16
- this.routeIndex = {};
17
- this.paramRoutes = [];
18
- this.flattenedRoutes = [];
19
- this.flatten(menuRoutes);
20
- if (pureRoutes)
21
- this.flatten(pureRoutes);
22
- /*
23
- Routes with template parameters must be added last so concrete routes resolve first.
24
- E.g.
25
- /clients/subview - SubViewComponent
26
- /clients/:param - ClientsComponent
27
-
28
- If the above was swapped around, ClientsComponent would match instead of SubViewComponent for /clients/subview.
29
- */
30
- (_a = this.flattenedRoutes).push.apply(_a, this.paramRoutes.sortBy("order", "desc").map(function (c) { return c.route; }));
31
- if (notFoundRoute) {
32
- this.flattenedRoutes.push({ component: notFoundRoute, key: -1, allowAnonymous: true, routePath: "" });
33
- }
34
- }
35
- /** Gets the path the component is bound to. If the component is bound to multiple paths, the first path is returned. */
36
- RouteProvider.prototype.getPathForComponent = function (component) {
37
- var _a;
38
- return (_a = this.flattenedRoutes.find(function (c) { return c.component === component; })) === null || _a === void 0 ? void 0 : _a.path;
39
- };
40
- RouteProvider.prototype.flatten = function (routes, parent) {
41
- var _a, _b;
42
- for (var _i = 0, routes_1 = routes; _i < routes_1.length; _i++) {
43
- var route = routes_1[_i];
44
- var hasComponent = route.path && route.component;
45
- if (hasComponent) {
46
- if (parent && !route.breadCrumbParent) {
47
- route.breadCrumbParent = parent;
48
- }
49
- this.processRoute(route);
50
- }
51
- var menuRoute = route;
52
- var children = __spreadArray(__spreadArray([], ((_a = route.routeChildren) !== null && _a !== void 0 ? _a : []), true), ((_b = menuRoute.children) !== null && _b !== void 0 ? _b : []), true);
53
- this.flatten(children, (hasComponent && menuRoute.showInBreadCrumb !== false) ? menuRoute : undefined);
54
- }
55
- };
56
- /**
57
- * Create a copy of the route info, and process it.
58
- * Adds a unique key, and adds route parameters extracted from the component static params object.
59
- */
60
- RouteProvider.prototype.processRoute = function (route) {
61
- var processed = __assign(__assign({}, route), { routePath: route.path, key: this.key++ });
62
- var isParamRoute = false;
63
- if (route instanceof MenuRoute) {
64
- processed.routePath = route.basePath;
65
- }
66
- var viewBaseComponent = route.component;
67
- if (viewBaseComponent.params) {
68
- if (processed.routePath.endsWith("/")) {
69
- processed.routePath = processed.routePath.substring(0, processed.routePath.length - 1);
70
- }
71
- for (var param in viewBaseComponent.params) {
72
- var routeParam = viewBaseComponent.params[param];
73
- if (!routeParam.isQuery) {
74
- isParamRoute = true;
75
- processed.routePath += "/:" + param + (routeParam.required ? "" : "?");
76
- }
77
- }
78
- }
79
- if (!this.routeIndex[processed.routePath]) {
80
- this.routeIndex[processed.routePath] = true;
81
- if (isParamRoute) {
82
- // Must be ordered later by the number of slashes in the path. Root path is a special case.
83
- this.paramRoutes.push({ route: processed, order: route.path === "/" ? 0 : (route.path.match(/\//g) || []).length });
84
- }
85
- else {
86
- this.flattenedRoutes.push(processed);
87
- }
88
- }
89
- };
90
- return RouteProvider;
91
- }());
92
- export default RouteProvider;
1
+ import { __assign, __spreadArray } from "tslib";
2
+ import { MenuRoute } from './MenuRoute';
3
+ var RouteProvider = /** @class */ (function () {
4
+ /**
5
+ * Creates a route provider which provides a list of flattened routes.
6
+ * @param menuRoutes Routes which appear on the main menu.
7
+ * @param pureRoutes Routes which don't have a menu item.
8
+ * @param notFoundRoute Route to render when the url doesn't match any of the above routes.
9
+ */
10
+ function RouteProvider(menuRoutes, pureRoutes, notFoundRoute) {
11
+ var _a;
12
+ this.menuRoutes = menuRoutes;
13
+ this.pureRoutes = pureRoutes;
14
+ this.notFoundRoute = notFoundRoute;
15
+ this.key = 1;
16
+ this.routeIndex = {};
17
+ this.paramRoutes = [];
18
+ this.flattenedRoutes = [];
19
+ this.flatten(menuRoutes);
20
+ if (pureRoutes)
21
+ this.flatten(pureRoutes);
22
+ /*
23
+ Routes with template parameters must be added last so concrete routes resolve first.
24
+ E.g.
25
+ /clients/subview - SubViewComponent
26
+ /clients/:param - ClientsComponent
27
+
28
+ If the above was swapped around, ClientsComponent would match instead of SubViewComponent for /clients/subview.
29
+ */
30
+ (_a = this.flattenedRoutes).push.apply(_a, this.paramRoutes.sortBy("order", "desc").map(function (c) { return c.route; }));
31
+ if (notFoundRoute) {
32
+ this.flattenedRoutes.push({ component: notFoundRoute, key: -1, allowAnonymous: true, routePath: "" });
33
+ }
34
+ }
35
+ /** Gets the path the component is bound to. If the component is bound to multiple paths, the first path is returned. */
36
+ RouteProvider.prototype.getPathForComponent = function (component) {
37
+ var _a;
38
+ return (_a = this.flattenedRoutes.find(function (c) { return c.component === component; })) === null || _a === void 0 ? void 0 : _a.path;
39
+ };
40
+ RouteProvider.prototype.flatten = function (routes, parent) {
41
+ var _a, _b;
42
+ for (var _i = 0, routes_1 = routes; _i < routes_1.length; _i++) {
43
+ var route = routes_1[_i];
44
+ var hasComponent = route.path && route.component;
45
+ if (hasComponent) {
46
+ if (parent && !route.breadCrumbParent) {
47
+ route.breadCrumbParent = parent;
48
+ }
49
+ this.processRoute(route);
50
+ }
51
+ var menuRoute = route;
52
+ var children = __spreadArray(__spreadArray([], ((_a = route.routeChildren) !== null && _a !== void 0 ? _a : []), true), ((_b = menuRoute.children) !== null && _b !== void 0 ? _b : []), true);
53
+ this.flatten(children, (hasComponent && menuRoute.showInBreadCrumb !== false) ? menuRoute : undefined);
54
+ }
55
+ };
56
+ /**
57
+ * Create a copy of the route info, and process it.
58
+ * Adds a unique key, and adds route parameters extracted from the component static params object.
59
+ */
60
+ RouteProvider.prototype.processRoute = function (route) {
61
+ var processed = __assign(__assign({}, route), { routePath: route.path, key: this.key++ });
62
+ var isParamRoute = false;
63
+ if (route instanceof MenuRoute) {
64
+ processed.routePath = route.basePath;
65
+ }
66
+ var viewBaseComponent = route.component;
67
+ if (viewBaseComponent.params) {
68
+ if (processed.routePath.endsWith("/")) {
69
+ processed.routePath = processed.routePath.substring(0, processed.routePath.length - 1);
70
+ }
71
+ for (var param in viewBaseComponent.params) {
72
+ var routeParam = viewBaseComponent.params[param];
73
+ if (!routeParam.isQuery) {
74
+ isParamRoute = true;
75
+ processed.routePath += "/:" + param + (routeParam.required ? "" : "?");
76
+ }
77
+ }
78
+ }
79
+ if (!this.routeIndex[processed.routePath]) {
80
+ this.routeIndex[processed.routePath] = true;
81
+ if (isParamRoute) {
82
+ // Must be ordered later by the number of slashes in the path. Root path is a special case.
83
+ this.paramRoutes.push({ route: processed, order: route.path === "/" ? 0 : (route.path.match(/\//g) || []).length });
84
+ }
85
+ else {
86
+ this.flattenedRoutes.push(processed);
87
+ }
88
+ }
89
+ };
90
+ return RouteProvider;
91
+ }());
92
+ export default RouteProvider;
@@ -1,50 +1,50 @@
1
- import * as React from 'react';
2
- import { RouteComponentProps, Switch, Route } from 'react-router';
3
- import { Location, Action } from 'history';
4
- import { Routing } from '@singularsystems/neo-core';
5
- import RouteProvider from './RouteProvider';
6
- import { IRouteChangedProps } from './IRouteChangedProps';
7
- export interface IRouteViewInternal {
8
- beforeLocationChanged(location: Location | undefined, action: Action, isUnload?: boolean): string | false | void;
9
- }
10
- export default abstract class RouteView extends React.Component<RouteComponentProps> {
11
- private historyListenDisposer?;
12
- private historyBlockDisposer?;
13
- protected switchComponent: typeof Switch;
14
- protected routeComponent: typeof Route;
15
- protected _routes: RouteProvider;
16
- protected getForbiddenComponent: (route: Routing.IRoute) => JSX.Element;
17
- protected getSigningInComponent: (route: Routing.IRoute) => JSX.Element;
18
- protected securityService: import("@singularsystems/neo-core/dist/Security/ISecurityService").default;
19
- protected routeSecurityService: Routing.IRouteSecurityService;
20
- protected routingState: import("./RoutingState").RoutingState;
21
- constructor(props: RouteComponentProps);
22
- get routes(): RouteProvider;
23
- set routes(value: RouteProvider);
24
- componentDidMount(): void;
25
- componentDidUpdate(): void;
26
- componentWillUnmount(): void;
27
- private beforeLocationChanged;
28
- /**
29
- * Called when the url changes, before the router renders the new view.
30
- * Return a string to block navigation.
31
- * @param isNewView True if the view is changing. False if a view parameter value is changing.
32
- * @param currentView The current view before change.
33
- */
34
- protected beforeRouteChanged(props: IRouteChangedProps): void;
35
- private getMatch;
36
- static isExact(route: Routing.IRoute): boolean;
37
- render(): React.CElement<import("react-router").SwitchProps, Switch>;
38
- private getRouteComponent;
39
- /**
40
- * Creates the routes component after authentication and authorisation checks have been done.
41
- * This can be used to override all routes to display pages like terms and conditions.
42
- * To redirect to a route, return a react router <Redirect to= /> component.
43
- */
44
- protected getAuthorisedComponent(route: Routing.IRoute, path: string): JSX.Element;
45
- /**
46
- * Checks if the user is authorised to access this route.
47
- * Component from getForbiddenComponent() is returned if not.
48
- */
49
- protected isAuthorised(route: Routing.IRoute): boolean;
50
- }
1
+ import * as React from 'react';
2
+ import { RouteComponentProps, Switch, Route } from 'react-router';
3
+ import { Location, Action } from 'history';
4
+ import { Routing } from '@singularsystems/neo-core';
5
+ import RouteProvider from './RouteProvider';
6
+ import { IRouteChangedProps } from './IRouteChangedProps';
7
+ export interface IRouteViewInternal {
8
+ beforeLocationChanged(location: Location | undefined, action: Action, isUnload?: boolean): string | false | void;
9
+ }
10
+ export default abstract class RouteView extends React.Component<RouteComponentProps> {
11
+ private historyListenDisposer?;
12
+ private historyBlockDisposer?;
13
+ protected switchComponent: typeof Switch;
14
+ protected routeComponent: typeof Route;
15
+ protected _routes: RouteProvider;
16
+ protected getForbiddenComponent: (route: Routing.IRoute) => JSX.Element;
17
+ protected getSigningInComponent: (route: Routing.IRoute) => JSX.Element;
18
+ protected securityService: import("@singularsystems/neo-core/dist/Security/ISecurityService").default;
19
+ protected routeSecurityService: Routing.IRouteSecurityService;
20
+ protected routingState: import("./RoutingState").RoutingState;
21
+ constructor(props: RouteComponentProps);
22
+ get routes(): RouteProvider;
23
+ set routes(value: RouteProvider);
24
+ componentDidMount(): void;
25
+ componentDidUpdate(): void;
26
+ componentWillUnmount(): void;
27
+ private beforeLocationChanged;
28
+ /**
29
+ * Called when the url changes, before the router renders the new view.
30
+ * Return a string to block navigation.
31
+ * @param isNewView True if the view is changing. False if a view parameter value is changing.
32
+ * @param currentView The current view before change.
33
+ */
34
+ protected beforeRouteChanged(props: IRouteChangedProps): void;
35
+ private getMatch;
36
+ static isExact(route: Routing.IRoute): boolean;
37
+ render(): React.CElement<import("react-router").SwitchProps, Switch>;
38
+ private getRouteComponent;
39
+ /**
40
+ * Creates the routes component after authentication and authorisation checks have been done.
41
+ * This can be used to override all routes to display pages like terms and conditions.
42
+ * To redirect to a route, return a react router <Redirect to= /> component.
43
+ */
44
+ protected getAuthorisedComponent(route: Routing.IRoute, path: string): JSX.Element;
45
+ /**
46
+ * Checks if the user is authorised to access this route.
47
+ * Component from getForbiddenComponent() is returned if not.
48
+ */
49
+ protected isAuthorised(route: Routing.IRoute): boolean;
50
+ }