@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,14 +1,14 @@
1
- import React from 'react';
2
- import { Components } from '@singularsystems/neo-core';
3
- import { FileContext } from './FileContext';
4
- export interface IFileUploadProps {
5
- fileManager?: Components.IFileManager;
6
- type?: "striped" | "animated";
7
- variant?: Components.variant;
8
- }
9
- export default class FileUploadProgress extends React.Component<IFileUploadProps & React.HTMLProps<HTMLDivElement>> {
10
- static contextType: React.Context<import("./FileContext").IFileContextProps>;
11
- context: React.ContextType<typeof FileContext>;
12
- private fileManager;
13
- render(): false | JSX.Element;
14
- }
1
+ import React from 'react';
2
+ import { Components } from '@singularsystems/neo-core';
3
+ import { FileContext } from './FileContext';
4
+ export interface IFileUploadProps {
5
+ fileManager?: Components.IFileManager;
6
+ type?: "striped" | "animated";
7
+ variant?: Components.variant;
8
+ }
9
+ export default class FileUploadProgress extends React.Component<IFileUploadProps & React.HTMLProps<HTMLDivElement>> {
10
+ static contextType: React.Context<import("./FileContext").IFileContextProps>;
11
+ context: React.ContextType<typeof FileContext>;
12
+ private fileManager;
13
+ render(): false | JSX.Element;
14
+ }
@@ -1,35 +1,35 @@
1
- import { __assign, __decorate, __extends, __rest } from "tslib";
2
- import React from 'react';
3
- import { observer } from 'mobx-react';
4
- import { Utils } from '@singularsystems/neo-core';
5
- import { FileContext } from './FileContext';
6
- import ProgressBar from '../ProgressBar';
7
- var FileUploadProgress = /** @class */ (function (_super) {
8
- __extends(FileUploadProgress, _super);
9
- function FileUploadProgress() {
10
- return _super !== null && _super.apply(this, arguments) || this;
11
- }
12
- FileUploadProgress.prototype.render = function () {
13
- var _a = this.props, fileManager = _a.fileManager, type = _a.type, variant = _a.variant, domProps = __rest(_a, ["fileManager", "type", "variant"]);
14
- if (this.context.fileManager) {
15
- this.fileManager = this.context.fileManager;
16
- }
17
- else {
18
- if (!fileManager) {
19
- throw Error("FileUploadProgress must be in a FileContext, or have fileManager specified.");
20
- }
21
- this.fileManager = fileManager;
22
- }
23
- domProps.className = Utils.joinWithSpaces(domProps.className, "neo-file-progress-container");
24
- return (this.fileManager.isUploading &&
25
- React.createElement("div", __assign({}, domProps), this.fileManager.currentUploads.map(function (upload) { return (React.createElement("div", { key: upload.key, className: "neo-file-progress" },
26
- React.createElement("span", null, upload.toString()),
27
- React.createElement(ProgressBar, { progress: upload.uploadPercent, type: type, variant: variant }))); })));
28
- };
29
- FileUploadProgress.contextType = FileContext;
30
- FileUploadProgress = __decorate([
31
- observer
32
- ], FileUploadProgress);
33
- return FileUploadProgress;
34
- }(React.Component));
35
- export default FileUploadProgress;
1
+ import { __assign, __decorate, __extends, __rest } from "tslib";
2
+ import React from 'react';
3
+ import { observer } from 'mobx-react';
4
+ import { Utils } from '@singularsystems/neo-core';
5
+ import { FileContext } from './FileContext';
6
+ import ProgressBar from '../ProgressBar';
7
+ var FileUploadProgress = /** @class */ (function (_super) {
8
+ __extends(FileUploadProgress, _super);
9
+ function FileUploadProgress() {
10
+ return _super !== null && _super.apply(this, arguments) || this;
11
+ }
12
+ FileUploadProgress.prototype.render = function () {
13
+ var _a = this.props, fileManager = _a.fileManager, type = _a.type, variant = _a.variant, domProps = __rest(_a, ["fileManager", "type", "variant"]);
14
+ if (this.context.fileManager) {
15
+ this.fileManager = this.context.fileManager;
16
+ }
17
+ else {
18
+ if (!fileManager) {
19
+ throw Error("FileUploadProgress must be in a FileContext, or have fileManager specified.");
20
+ }
21
+ this.fileManager = fileManager;
22
+ }
23
+ domProps.className = Utils.joinWithSpaces(domProps.className, "neo-file-progress-container");
24
+ return (this.fileManager.isUploading &&
25
+ React.createElement("div", __assign({}, domProps), this.fileManager.currentUploads.map(function (upload) { return (React.createElement("div", { key: upload.key, className: "neo-file-progress" },
26
+ React.createElement("span", null, upload.toString()),
27
+ React.createElement(ProgressBar, { progress: upload.uploadPercent, type: type, variant: variant }))); })));
28
+ };
29
+ FileUploadProgress.contextType = FileContext;
30
+ FileUploadProgress = __decorate([
31
+ observer
32
+ ], FileUploadProgress);
33
+ return FileUploadProgress;
34
+ }(React.Component));
35
+ export default FileUploadProgress;
@@ -1,18 +1,19 @@
1
- import * as React from 'react';
2
- import { Components, Model } from '@singularsystems/neo-core';
3
- export interface IFormProps<T extends Model.IModelBase> extends React.FormHTMLAttributes<HTMLElement>, Components.IFormOptions<T> {
4
- /**
5
- * Called when the form is submitted, but the model is not valid.
6
- * The justValidated parameter will be true if the validationDisplayMode is 'AfterSubmit', and this is the first submit attempt.
7
- */
8
- onInvalid?: (e: React.FormEvent, justValidated?: boolean) => void;
9
- children: React.ReactNode;
10
- }
11
- export default class Form<T extends Model.IModelBase> extends React.Component<IFormProps<T>> {
12
- private reactionDisposer?;
13
- private firstSubmit;
14
- private onSubmit;
15
- private disposeReaction;
16
- componentWillUnmount(): void;
17
- render(): JSX.Element;
18
- }
1
+ import * as React from 'react';
2
+ import { Components, Model } from '@singularsystems/neo-core';
3
+ interface IFormProps<T extends Model.IModelBase> extends Omit<React.FormHTMLAttributes<HTMLElement>, "children">, Components.IFormOptions<T> {
4
+ /**
5
+ * Called when the form is submitted, but the model is not valid.
6
+ * The justValidated parameter will be true if the validationDisplayMode is 'AfterSubmit', and this is the first submit attempt.
7
+ */
8
+ onInvalid?: (e: React.FormEvent, justValidated?: boolean) => void;
9
+ children: React.ReactNode | ((item: T, meta: Model.TransformMetaType<T>) => React.ReactNode);
10
+ }
11
+ export default class Form<T extends Model.IModelBase> extends React.Component<IFormProps<T>> {
12
+ private reactionDisposer?;
13
+ private firstSubmit;
14
+ private onSubmit;
15
+ private disposeReaction;
16
+ componentWillUnmount(): void;
17
+ render(): JSX.Element;
18
+ }
19
+ export {};
@@ -1,90 +1,90 @@
1
- import { __assign, __decorate, __extends, __rest } from "tslib";
2
- import * as React from 'react';
3
- import { observer, Observer } from 'mobx-react';
4
- import { Validation, Model, ModalUtils, Misc } from '@singularsystems/neo-core';
5
- import ValidationSummary from './ValidationSummary';
6
- import { reaction } from 'mobx';
7
- import { FormContextProvider } from './FormContext';
8
- var Form = /** @class */ (function (_super) {
9
- __extends(Form, _super);
10
- function Form() {
11
- var _this = _super !== null && _super.apply(this, arguments) || this;
12
- _this.firstSubmit = true;
13
- return _this;
14
- }
15
- Form.prototype.onSubmit = function (e, model) {
16
- var _this = this;
17
- e.preventDefault();
18
- e.stopPropagation();
19
- this.disposeReaction();
20
- var canSubmit = true;
21
- // TODO: if the model and none of its children have blurred, justValidated should be true
22
- var justValidated = this.props.validationDisplayMode === Validation.DisplayMode.AfterSubmit && this.firstSubmit;
23
- this.firstSubmit = false;
24
- if (model) {
25
- if (!model.isValid) {
26
- canSubmit = false;
27
- var container = void 0;
28
- if (model instanceof Array) {
29
- container = model;
30
- }
31
- else {
32
- container = [model];
33
- }
34
- Model.GraphTraverser.traverseItems(container, new Model.GraphTraverser.RecursionState(), function (item, state) {
35
- item.validator.forceShowErrors = true;
36
- });
37
- if (this.props.onInvalid)
38
- this.props.onInvalid(e, justValidated);
39
- if (this.props.showSummaryModal || this.props.invalidSummaryText || this.props.invalidSummaryTitle) {
40
- var onClose = this.disposeReaction.bind(this);
41
- var codeModal_1 = ModalUtils.showModal(this.props.invalidSummaryTitle || "Invalid data", React.createElement(Observer, null, function () {
42
- return React.createElement("div", null,
43
- _this.props.invalidSummaryText || "Cannot continue due to the following errors:",
44
- React.createElement(ValidationSummary, { graph: Validation.getValidationSummary(model), hideTopLevelTitle: !(model instanceof Array) }));
45
- }), { onClose: onClose, closeButton: { text: "Ok", onClick: onClose } });
46
- // Listen for when isValid changes to true, in case there is an async rule running.
47
- this.reactionDisposer = reaction(function () { return model.isValid; }, function () {
48
- _this.disposeReaction();
49
- codeModal_1.close();
50
- if (model.isValid && _this.props.onSubmit)
51
- _this.props.onSubmit(e);
52
- });
53
- }
54
- }
55
- }
56
- if (canSubmit && this.props.onSubmit) {
57
- this.props.onSubmit(e);
58
- }
59
- };
60
- Form.prototype.disposeReaction = function () {
61
- if (this.reactionDisposer) {
62
- this.reactionDisposer();
63
- this.reactionDisposer = undefined;
64
- }
65
- };
66
- Form.prototype.componentWillUnmount = function () {
67
- this.disposeReaction();
68
- };
69
- Form.prototype.render = function () {
70
- var _this = this;
71
- var _a = this.props, validationDisplayMode = _a.validationDisplayMode, allReadOnly = _a.allReadOnly, allDisabled = _a.allDisabled, model = _a.model, showSummaryModal = _a.showSummaryModal, invalidSummaryTitle = _a.invalidSummaryTitle, invalidSummaryText = _a.invalidSummaryText, native = __rest(_a, ["validationDisplayMode", "allReadOnly", "allDisabled", "model", "showSummaryModal", "invalidSummaryTitle", "invalidSummaryText"]);
72
- var formModel;
73
- if (model) {
74
- // Allow binding to ObservableProperty
75
- if (model.attachedTo && !(model instanceof Array)) {
76
- formModel = model.attachedTo;
77
- }
78
- else {
79
- formModel = model;
80
- }
81
- }
82
- return (React.createElement("form", __assign({}, native, { onSubmit: function (e) { return _this.onSubmit(e, formModel); } }),
83
- React.createElement(FormContextProvider, { validationDisplayMode: validationDisplayMode !== null && validationDisplayMode !== void 0 ? validationDisplayMode : Misc.Settings.form.validationDisplayMode, allReadOnly: allReadOnly, allDisabled: allDisabled }, (this.props.children instanceof Function) ? this.props.children(model, model.meta) : this.props.children)));
84
- };
85
- Form = __decorate([
86
- observer
87
- ], Form);
88
- return Form;
89
- }(React.Component));
90
- export default Form;
1
+ import { __assign, __decorate, __extends, __rest } from "tslib";
2
+ import * as React from 'react';
3
+ import { observer, Observer } from 'mobx-react';
4
+ import { Validation, Model, ModalUtils, Misc } from '@singularsystems/neo-core';
5
+ import ValidationSummary from './ValidationSummary';
6
+ import { reaction } from 'mobx';
7
+ import { FormContextProvider } from './FormContext';
8
+ var Form = /** @class */ (function (_super) {
9
+ __extends(Form, _super);
10
+ function Form() {
11
+ var _this = _super !== null && _super.apply(this, arguments) || this;
12
+ _this.firstSubmit = true;
13
+ return _this;
14
+ }
15
+ Form.prototype.onSubmit = function (e, model) {
16
+ var _this = this;
17
+ e.preventDefault();
18
+ e.stopPropagation();
19
+ this.disposeReaction();
20
+ var canSubmit = true;
21
+ // TODO: if the model and none of its children have blurred, justValidated should be true
22
+ var justValidated = this.props.validationDisplayMode === Validation.DisplayMode.AfterSubmit && this.firstSubmit;
23
+ this.firstSubmit = false;
24
+ if (model) {
25
+ if (!model.isValid) {
26
+ canSubmit = false;
27
+ var container = void 0;
28
+ if (model instanceof Array) {
29
+ container = model;
30
+ }
31
+ else {
32
+ container = [model];
33
+ }
34
+ Model.GraphTraverser.traverseItems(container, new Model.GraphTraverser.RecursionState(), function (item, state) {
35
+ item.validator.forceShowErrors = true;
36
+ });
37
+ if (this.props.onInvalid)
38
+ this.props.onInvalid(e, justValidated);
39
+ if (this.props.showSummaryModal || this.props.invalidSummaryText || this.props.invalidSummaryTitle) {
40
+ var onClose = this.disposeReaction.bind(this);
41
+ var codeModal_1 = ModalUtils.showModal(this.props.invalidSummaryTitle || "Invalid data", React.createElement(Observer, null, function () {
42
+ return React.createElement("div", null,
43
+ _this.props.invalidSummaryText || "Cannot continue due to the following issues:",
44
+ React.createElement(ValidationSummary, { graph: Validation.getValidationSummary(model), hideTopLevelTitle: !(model instanceof Array) }));
45
+ }), { onClose: onClose, closeButton: { text: "Ok", onClick: onClose } });
46
+ // Listen for when isValid changes to true, in case there is an async rule running.
47
+ this.reactionDisposer = reaction(function () { return model.isValid; }, function () {
48
+ _this.disposeReaction();
49
+ codeModal_1.close();
50
+ if (model.isValid && _this.props.onSubmit)
51
+ _this.props.onSubmit(e);
52
+ });
53
+ }
54
+ }
55
+ }
56
+ if (canSubmit && this.props.onSubmit) {
57
+ this.props.onSubmit(e);
58
+ }
59
+ };
60
+ Form.prototype.disposeReaction = function () {
61
+ if (this.reactionDisposer) {
62
+ this.reactionDisposer();
63
+ this.reactionDisposer = undefined;
64
+ }
65
+ };
66
+ Form.prototype.componentWillUnmount = function () {
67
+ this.disposeReaction();
68
+ };
69
+ Form.prototype.render = function () {
70
+ var _this = this;
71
+ var _a = this.props, validationDisplayMode = _a.validationDisplayMode, allReadOnly = _a.allReadOnly, allDisabled = _a.allDisabled, model = _a.model, showSummaryModal = _a.showSummaryModal, invalidSummaryTitle = _a.invalidSummaryTitle, invalidSummaryText = _a.invalidSummaryText, native = __rest(_a, ["validationDisplayMode", "allReadOnly", "allDisabled", "model", "showSummaryModal", "invalidSummaryTitle", "invalidSummaryText"]);
72
+ var formModel;
73
+ if (model) {
74
+ // Allow binding to ObservableProperty
75
+ if (model.attachedTo && !(model instanceof Array)) {
76
+ formModel = model.attachedTo;
77
+ }
78
+ else {
79
+ formModel = model;
80
+ }
81
+ }
82
+ return (React.createElement("form", __assign({}, native, { onSubmit: function (e) { return _this.onSubmit(e, formModel); } }),
83
+ React.createElement(FormContextProvider, { validationDisplayMode: validationDisplayMode !== null && validationDisplayMode !== void 0 ? validationDisplayMode : Misc.Settings.form.validationDisplayMode, allReadOnly: allReadOnly, allDisabled: allDisabled }, (this.props.children instanceof Function) ? this.props.children(model, model.meta) : this.props.children)));
84
+ };
85
+ Form = __decorate([
86
+ observer
87
+ ], Form);
88
+ return Form;
89
+ }(React.Component));
90
+ export default Form;
@@ -1,31 +1,33 @@
1
- import React from 'react';
2
- import { Components, Model, Validation } from '@singularsystems/neo-core';
3
- export declare enum EditorParentType {
4
- FormGroup = 1,
5
- Column = 2
6
- }
7
- export declare class FormContextParams implements Components.IFormContextOptions {
8
- /** The validation display mode to apply to all controls. */
9
- validationDisplayMode: Validation.DisplayMode;
10
- /** True if all controls in this section should be readonly. */
11
- allReadOnly: boolean;
12
- /** True if all controls in this section should be disabled. */
13
- allDisabled: boolean;
14
- /** True if all labels should be hidden. */
15
- suppressLabels?: boolean;
16
- /**
17
- * The property the form group is bound to.
18
- */
19
- bindProperty: Model.IPropertyInstance;
20
- parentType: EditorParentType;
21
- uniqueId?: string;
22
- }
23
- export declare const FormContext: React.Context<FormContextParams>;
24
- /**
25
- * Allows the attributes of multiple child form controls to be set at a parent level.
26
- */
27
- export declare class FormContextProvider extends React.Component<Components.IFormContextOptions> {
28
- static contextType: React.Context<FormContextParams>;
29
- context: React.ContextType<typeof FormContext>;
30
- render(): JSX.Element;
31
- }
1
+ import React from 'react';
2
+ import { Components, Model, Validation } from '@singularsystems/neo-core';
3
+ export declare enum EditorParentType {
4
+ FormGroup = 1,
5
+ Column = 2
6
+ }
7
+ export declare class FormContextParams implements Components.IFormContextOptions {
8
+ /** The validation display mode to apply to all controls. */
9
+ validationDisplayMode: Validation.DisplayMode;
10
+ /** True if all controls in this section should be readonly. */
11
+ allReadOnly: boolean;
12
+ /** True if all controls in this section should be disabled. */
13
+ allDisabled: boolean;
14
+ /** True if all labels should be hidden. */
15
+ suppressLabels?: boolean;
16
+ /**
17
+ * The property the form group is bound to.
18
+ */
19
+ bindProperty: Model.IPropertyInstance;
20
+ parentType: EditorParentType;
21
+ uniqueId?: string;
22
+ }
23
+ export declare const FormContext: React.Context<FormContextParams>;
24
+ /**
25
+ * Allows the attributes of multiple child form controls to be set at a parent level.
26
+ */
27
+ export declare class FormContextProvider extends React.Component<Components.IFormContextOptions & {
28
+ children: React.ReactNode;
29
+ }> {
30
+ static contextType: React.Context<FormContextParams>;
31
+ context: React.ContextType<typeof FormContext>;
32
+ render(): JSX.Element;
33
+ }
@@ -1,40 +1,39 @@
1
- import { __assign, __extends, __rest } from "tslib";
2
- import React from 'react';
3
- import { Validation } from '@singularsystems/neo-core';
4
- export var EditorParentType;
5
- (function (EditorParentType) {
6
- EditorParentType[EditorParentType["FormGroup"] = 1] = "FormGroup";
7
- EditorParentType[EditorParentType["Column"] = 2] = "Column";
8
- })(EditorParentType || (EditorParentType = {}));
9
- var FormContextParams = /** @class */ (function () {
10
- function FormContextParams() {
11
- /** The validation display mode to apply to all controls. */
12
- this.validationDisplayMode = Validation.DisplayMode.AfterBlur;
13
- /** True if all controls in this section should be readonly. */
14
- this.allReadOnly = false;
15
- /** True if all controls in this section should be disabled. */
16
- this.allDisabled = false;
17
- /** True if all labels should be hidden. */
18
- this.suppressLabels = undefined;
19
- }
20
- return FormContextParams;
21
- }());
22
- export { FormContextParams };
23
- export var FormContext = React.createContext(new FormContextParams());
24
- /**
25
- * Allows the attributes of multiple child form controls to be set at a parent level.
26
- */
27
- var FormContextProvider = /** @class */ (function (_super) {
28
- __extends(FormContextProvider, _super);
29
- function FormContextProvider() {
30
- return _super !== null && _super.apply(this, arguments) || this;
31
- }
32
- FormContextProvider.prototype.render = function () {
33
- var _a = this.props, children = _a.children, newContextParams = __rest(_a, ["children"]);
34
- var newContext = __assign(__assign({}, this.context), newContextParams);
35
- return (React.createElement(FormContext.Provider, { value: newContext }, children));
36
- };
37
- FormContextProvider.contextType = FormContext;
38
- return FormContextProvider;
39
- }(React.Component));
40
- export { FormContextProvider };
1
+ import { __assign, __extends, __rest } from "tslib";
2
+ import React from 'react';
3
+ import { Validation } from '@singularsystems/neo-core';
4
+ export var EditorParentType;
5
+ (function (EditorParentType) {
6
+ EditorParentType[EditorParentType["FormGroup"] = 1] = "FormGroup";
7
+ EditorParentType[EditorParentType["Column"] = 2] = "Column";
8
+ })(EditorParentType || (EditorParentType = {}));
9
+ var FormContextParams = /** @class */ (function () {
10
+ function FormContextParams() {
11
+ /** The validation display mode to apply to all controls. */
12
+ this.validationDisplayMode = Validation.DisplayMode.AfterBlur;
13
+ /** True if all controls in this section should be readonly. */
14
+ this.allReadOnly = false;
15
+ /** True if all controls in this section should be disabled. */
16
+ this.allDisabled = false;
17
+ /** True if all labels should be hidden. */
18
+ this.suppressLabels = undefined;
19
+ }
20
+ return FormContextParams;
21
+ }());
22
+ export { FormContextParams };
23
+ export var FormContext = React.createContext(new FormContextParams());
24
+ /**
25
+ * Allows the attributes of multiple child form controls to be set at a parent level.
26
+ */
27
+ export var FormContextProvider = /** @class */ (function (_super) {
28
+ __extends(FormContextProvider, _super);
29
+ function FormContextProvider() {
30
+ return _super !== null && _super.apply(this, arguments) || this;
31
+ }
32
+ FormContextProvider.prototype.render = function () {
33
+ var _a = this.props, children = _a.children, newContextParams = __rest(_a, ["children"]);
34
+ var newContext = __assign(__assign({}, this.context), newContextParams);
35
+ return (React.createElement(FormContext.Provider, { value: newContext }, children));
36
+ };
37
+ FormContextProvider.contextType = FormContext;
38
+ return FormContextProvider;
39
+ }(React.Component));
@@ -1,37 +1,37 @@
1
- import * as React from 'react';
2
- import { IEditorContainerProps } from '../PropTypes';
3
- import ComponentBase from '../ComponentBase';
4
- import { FormContext } from '../FormContext';
5
- export interface IFormGroupProps<TData> extends IEditorContainerProps<HTMLDivElement, TData> {
6
- /**
7
- * Properties to apply to the label.
8
- */
9
- labelProps?: React.HTMLProps<HTMLLabelElement>;
10
- /**
11
- * Hides the label.
12
- */
13
- suppressLabel?: boolean;
14
- /**
15
- * Text to show beneath the editor. This will be hidden when validation text is shown.
16
- */
17
- footerText?: string | JSX.Element;
18
- /**
19
- * Text / element to show to the right of the label.
20
- */
21
- rightLabel?: string | JSX.Element;
22
- }
23
- export interface IFormGroupClasses {
24
- container: string;
25
- containerDom: React.HTMLProps<HTMLDivElement>;
26
- label: string;
27
- editor: string;
28
- }
29
- export declare class FormGroupBase<T extends IFormGroupProps<TData>, TData> extends ComponentBase<T> {
30
- static contextType: React.Context<import("../FormContext").FormContextParams>;
31
- context: React.ContextType<typeof FormContext>;
32
- protected getFormGroupClasses(domProps: React.HTMLProps<HTMLDivElement>, isCheckBox: boolean): IFormGroupClasses;
33
- protected hideLabelForCheckboxes(): boolean;
34
- render(): JSX.Element;
35
- }
36
- export default class FormGroup<TData> extends FormGroupBase<IFormGroupProps<TData>, TData> {
37
- }
1
+ import * as React from 'react';
2
+ import { IEditorContainerProps } from '../PropTypes';
3
+ import ComponentBase from '../ComponentBase';
4
+ import { FormContext } from '../FormContext';
5
+ export interface IFormGroupProps<TData> extends IEditorContainerProps<HTMLDivElement, TData> {
6
+ /**
7
+ * Properties to apply to the label.
8
+ */
9
+ labelProps?: React.HTMLProps<HTMLLabelElement>;
10
+ /**
11
+ * Hides the label.
12
+ */
13
+ suppressLabel?: boolean;
14
+ /**
15
+ * Text to show beneath the editor. This will be hidden when validation text is shown.
16
+ */
17
+ footerText?: string | JSX.Element;
18
+ /**
19
+ * Text / element to show to the right of the label.
20
+ */
21
+ rightLabel?: string | JSX.Element;
22
+ }
23
+ export interface IFormGroupClasses {
24
+ container: string;
25
+ containerDom: React.HTMLProps<HTMLDivElement>;
26
+ label: string;
27
+ editor: string;
28
+ }
29
+ export declare class FormGroupBase<T extends IFormGroupProps<TData>, TData> extends ComponentBase<T> {
30
+ static contextType: React.Context<import("../FormContext").FormContextParams>;
31
+ context: React.ContextType<typeof FormContext>;
32
+ protected getFormGroupClasses(domProps: React.HTMLProps<HTMLDivElement>, isCheckBox: boolean): IFormGroupClasses;
33
+ protected hideLabelForCheckboxes(): boolean;
34
+ render(): JSX.Element;
35
+ }
36
+ export default class FormGroup<TData> extends FormGroupBase<IFormGroupProps<TData>, TData> {
37
+ }