@singularsystems/neo-react 1.0.0-alpha.2 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -0
- package/README.md +4 -0
- package/dist/Modules/NeoReactModule.d.ts +4 -4
- package/dist/Modules/NeoReactModule.js +28 -26
- package/dist/Modules/ReactSetup.d.ts +2 -2
- package/dist/Modules/ReactSetup.js +17 -17
- package/dist/Modules/Types.d.ts +63 -61
- package/dist/Modules/Types.js +13 -12
- package/dist/React/AutoRunner.d.ts +5 -5
- package/dist/React/AutoRunner.js +94 -92
- package/dist/React/DataView.d.ts +6 -6
- package/dist/React/DataView.js +11 -11
- package/dist/React/ReactModelCreator.d.ts +11 -11
- package/dist/React/ReactModelCreator.js +165 -162
- package/dist/ReactComponents/Button.d.ts +24 -23
- package/dist/ReactComponents/Button.js +131 -123
- package/dist/ReactComponents/Card.d.ts +24 -23
- package/dist/ReactComponents/Card.js +56 -54
- package/dist/ReactComponents/Collapsable.d.ts +23 -23
- package/dist/ReactComponents/Collapsable.js +38 -38
- package/dist/ReactComponents/CollapsableBase.d.ts +13 -13
- package/dist/ReactComponents/CollapsableBase.js +42 -42
- package/dist/ReactComponents/ColorPicker.d.ts +26 -26
- package/dist/ReactComponents/ColorPicker.js +67 -67
- package/dist/ReactComponents/ComponentBase.d.ts +17 -17
- package/dist/ReactComponents/ComponentBase.js +33 -33
- package/dist/ReactComponents/ContextMenu/ContextMenu.d.ts +25 -24
- package/dist/ReactComponents/ContextMenu/ContextMenu.js +91 -88
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.d.ts +14 -14
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.js +48 -48
- package/dist/ReactComponents/ContextMenu/ContextMenuState.d.ts +8 -7
- package/dist/ReactComponents/ContextMenu/ContextMenuState.js +23 -23
- package/dist/ReactComponents/DatePicker.d.ts +19 -19
- package/dist/ReactComponents/DatePicker.js +53 -53
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +93 -83
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +222 -188
- package/dist/ReactComponents/DropDown/DropDown.d.ts +44 -44
- package/dist/ReactComponents/DropDown/DropDown.js +138 -134
- package/dist/ReactComponents/DropDown/DropDownBase.d.ts +16 -15
- package/dist/ReactComponents/DropDown/DropDownBase.js +86 -108
- package/dist/ReactComponents/DropDown/LookupHelper.d.ts +13 -0
- package/dist/ReactComponents/DropDown/LookupHelper.js +45 -0
- package/dist/ReactComponents/ErrorHandler.d.ts +9 -8
- package/dist/ReactComponents/ErrorHandler.js +92 -91
- package/dist/ReactComponents/FileManager/FileBasicInput.d.ts +20 -20
- package/dist/ReactComponents/FileManager/FileBasicInput.js +70 -70
- package/dist/ReactComponents/FileManager/FileContext.d.ts +16 -16
- package/dist/ReactComponents/FileManager/FileContext.js +24 -24
- package/dist/ReactComponents/FileManager/FileDropArea.d.ts +19 -18
- package/dist/ReactComponents/FileManager/FileDropArea.js +66 -64
- package/dist/ReactComponents/FileManager/FileInput.d.ts +44 -42
- package/dist/ReactComponents/FileManager/FileInput.js +191 -189
- package/dist/ReactComponents/FileManager/FileUploadButton.d.ts +17 -17
- package/dist/ReactComponents/FileManager/FileUploadButton.js +49 -49
- package/dist/ReactComponents/FileManager/FileUploadProgress.d.ts +14 -14
- package/dist/ReactComponents/FileManager/FileUploadProgress.js +35 -35
- package/dist/ReactComponents/Form.d.ts +19 -18
- package/dist/ReactComponents/Form.js +90 -90
- package/dist/ReactComponents/FormContext.d.ts +33 -31
- package/dist/ReactComponents/FormContext.js +39 -40
- package/dist/ReactComponents/FormGroup/FormGroup.d.ts +37 -37
- package/dist/ReactComponents/FormGroup/FormGroup.js +83 -84
- package/dist/ReactComponents/FormGroup/FormGroupFloating.d.ts +19 -19
- package/dist/ReactComponents/FormGroup/FormGroupFloating.js +97 -97
- package/dist/ReactComponents/FormGroup/FormGroupInline.d.ts +11 -11
- package/dist/ReactComponents/FormGroup/FormGroupInline.js +43 -43
- package/dist/ReactComponents/Grid/ButtonColumn.d.ts +47 -47
- package/dist/ReactComponents/Grid/ButtonColumn.js +81 -82
- package/dist/ReactComponents/Grid/Column.d.ts +47 -47
- package/dist/ReactComponents/Grid/Column.js +205 -205
- package/dist/ReactComponents/Grid/ColumnHelper.d.ts +12 -12
- package/dist/ReactComponents/Grid/ColumnHelper.js +19 -19
- package/dist/ReactComponents/Grid/Grid.d.ts +87 -90
- package/dist/ReactComponents/Grid/Grid.js +203 -203
- package/dist/ReactComponents/Grid/Row.d.ts +81 -81
- package/dist/ReactComponents/Grid/Row.js +200 -201
- package/dist/ReactComponents/Grid/_Exports.d.ts +5 -5
- package/dist/ReactComponents/Grid/_Exports.js +5 -5
- package/dist/ReactComponents/GridLayout.d.ts +20 -20
- package/dist/ReactComponents/GridLayout.js +38 -38
- package/dist/ReactComponents/Icons/FontAwesomeIconFactory.d.ts +23 -0
- package/dist/ReactComponents/Icons/FontAwesomeIconFactory.js +43 -0
- package/dist/ReactComponents/Icons/IIconFactory.d.ts +21 -0
- package/dist/ReactComponents/Icons/IIconFactory.js +1 -0
- package/dist/ReactComponents/Icons/IconFactory.d.ts +9 -0
- package/dist/ReactComponents/Icons/IconFactory.js +45 -0
- package/dist/ReactComponents/Icons/index.d.ts +3 -0
- package/dist/ReactComponents/Icons/index.js +2 -0
- package/dist/ReactComponents/Input.d.ts +45 -45
- package/dist/ReactComponents/Input.js +153 -152
- package/dist/ReactComponents/InputHelpers.d.ts +6 -5
- package/dist/ReactComponents/InputHelpers.js +29 -33
- package/dist/ReactComponents/Link.d.ts +13 -13
- package/dist/ReactComponents/Link.js +28 -28
- package/dist/ReactComponents/Loader.d.ts +18 -18
- package/dist/ReactComponents/Loader.js +57 -57
- package/dist/ReactComponents/Misc.d.ts +15 -15
- package/dist/ReactComponents/Misc.js +28 -28
- package/dist/ReactComponents/Modal/Modal.d.ts +11 -11
- package/dist/ReactComponents/Modal/Modal.js +129 -129
- package/dist/ReactComponents/Modal/ModalContainer.d.ts +17 -17
- package/dist/ReactComponents/Modal/ModalContainer.js +37 -37
- package/dist/ReactComponents/Modal/ModalPortal.d.ts +16 -15
- package/dist/ReactComponents/Modal/ModalPortal.js +27 -27
- package/dist/ReactComponents/Notifications/Alert.d.ts +7 -6
- package/dist/ReactComponents/Notifications/Alert.js +38 -35
- package/dist/ReactComponents/Notifications/Toast.d.ts +9 -8
- package/dist/ReactComponents/Notifications/Toast.js +47 -45
- package/dist/ReactComponents/Notifications/ToastContainer.d.ts +8 -8
- package/dist/ReactComponents/Notifications/ToastContainer.js +18 -18
- package/dist/ReactComponents/NumberInput.d.ts +57 -50
- package/dist/ReactComponents/NumberInput.js +260 -246
- package/dist/ReactComponents/Paging/BasicPagerControls.d.ts +26 -25
- package/dist/ReactComponents/Paging/BasicPagerControls.js +57 -55
- package/dist/ReactComponents/Paging/PageSizeControl.d.ts +11 -11
- package/dist/ReactComponents/Paging/PageSizeControl.js +21 -21
- package/dist/ReactComponents/Paging/Pager.d.ts +24 -24
- package/dist/ReactComponents/Paging/Pager.js +41 -41
- package/dist/ReactComponents/ProgressBar.d.ts +19 -19
- package/dist/ReactComponents/ProgressBar.js +52 -52
- package/dist/ReactComponents/PropTypes.d.ts +161 -161
- package/dist/ReactComponents/PropTypes.js +253 -236
- package/dist/ReactComponents/RadioList.d.ts +29 -29
- package/dist/ReactComponents/RadioList.js +59 -77
- package/dist/ReactComponents/Slider.d.ts +28 -28
- package/dist/ReactComponents/Slider.js +76 -76
- package/dist/ReactComponents/StateObserver.d.ts +15 -15
- package/dist/ReactComponents/StateObserver.js +35 -35
- package/dist/ReactComponents/Tabs/Tab.d.ts +42 -41
- package/dist/ReactComponents/Tabs/Tab.js +71 -72
- package/dist/ReactComponents/Tabs/TabContainer.d.ts +44 -44
- package/dist/ReactComponents/Tabs/TabContainer.js +98 -98
- package/dist/ReactComponents/Tabs/TabManager.d.ts +62 -62
- package/dist/ReactComponents/Tabs/TabManager.js +154 -154
- package/dist/ReactComponents/Tooltip.d.ts +20 -19
- package/dist/ReactComponents/Tooltip.js +51 -51
- package/dist/ReactComponents/TooltipHelper.d.ts +8 -8
- package/dist/ReactComponents/TooltipHelper.js +84 -84
- package/dist/ReactComponents/TooltipProvider.d.ts +30 -30
- package/dist/ReactComponents/TooltipProvider.js +111 -111
- package/dist/ReactComponents/ValidationSummary.d.ts +23 -22
- package/dist/ReactComponents/ValidationSummary.js +46 -43
- package/dist/ReactComponents/_Exports.d.ts +41 -41
- package/dist/ReactComponents/_Exports.js +41 -41
- package/dist/ReactComponents/_Managers.d.ts +4 -4
- package/dist/ReactComponents/_Managers.js +4 -4
- package/dist/Routing/BreadCrumbItem.d.ts +14 -14
- package/dist/Routing/BreadCrumbItem.js +12 -12
- package/dist/Routing/IRouteChangedProps.d.ts +31 -31
- package/dist/Routing/IRouteChangedProps.js +1 -1
- package/dist/Routing/IRouteParameter.d.ts +22 -22
- package/dist/Routing/IRouteParameter.js +9 -9
- package/dist/Routing/MenuRoute.d.ts +25 -24
- package/dist/Routing/MenuRoute.js +24 -24
- package/dist/Routing/NavigationHelper.d.ts +41 -40
- package/dist/Routing/NavigationHelper.js +61 -61
- package/dist/Routing/PageLeaveHandler.d.ts +13 -13
- package/dist/Routing/PageLeaveHandler.js +74 -74
- package/dist/Routing/RouteProvider.d.ts +31 -31
- package/dist/Routing/RouteProvider.js +92 -92
- package/dist/Routing/RouteView.d.ts +50 -50
- package/dist/Routing/RouteView.js +143 -144
- package/dist/Routing/RoutingState.d.ts +18 -15
- package/dist/Routing/RoutingState.js +45 -40
- package/dist/Routing/ViewParameter.d.ts +80 -58
- package/dist/Routing/ViewParameter.js +116 -95
- package/dist/Routing/ViewParameterList.d.ts +53 -53
- package/dist/Routing/ViewParameterList.js +163 -145
- package/dist/Routing/index.d.ts +9 -9
- package/dist/Routing/index.js +6 -6
- package/dist/Services/DisposeHelper.d.ts +15 -15
- package/dist/Services/DisposeHelper.js +40 -41
- package/dist/Services/IDisposeHelper.d.ts +12 -12
- package/dist/Services/IDisposeHelper.js +1 -1
- package/dist/Views/EmptyViewModel.d.ts +5 -5
- package/dist/Views/EmptyViewModel.js +14 -14
- package/dist/Views/IViewModel.d.ts +16 -16
- package/dist/Views/IViewModel.js +1 -1
- package/dist/Views/PersistentViewBase.d.ts +10 -10
- package/dist/Views/PersistentViewBase.js +21 -21
- package/dist/Views/ViewBase.d.ts +70 -71
- package/dist/Views/ViewBase.js +166 -153
- package/dist/Views/ViewComponentBase.d.ts +19 -13
- package/dist/Views/ViewComponentBase.js +24 -21
- package/dist/Views/ViewModelBase.d.ts +57 -56
- package/dist/Views/ViewModelBase.js +122 -118
- package/dist/Views/ViewState.d.ts +13 -13
- package/dist/Views/ViewState.js +9 -9
- package/dist/Views/index.d.ts +5 -5
- package/dist/Views/index.js +5 -5
- package/dist/index.d.ts +11 -10
- package/dist/index.js +10 -9
- package/package.json +26 -26
- package/styles/DatePicker.scss +2 -2
- package/styles/Forms.scss +5 -0
- package/styles/Validation.scss +0 -9
|
@@ -1,246 +1,260 @@
|
|
|
1
|
-
import { __assign, __decorate, __extends, __metadata } from "tslib";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { BindPropsHelper } from './PropTypes';
|
|
4
|
-
import { FormContext } from './FormContext';
|
|
5
|
-
import { Misc, NumberUtils, Utils } from '@singularsystems/neo-core';
|
|
6
|
-
import Decimal from 'decimal.js-light';
|
|
7
|
-
import { InputHelpers } from './InputHelpers';
|
|
8
|
-
import { observer } from 'mobx-react';
|
|
9
|
-
import memoize from 'memoize-one';
|
|
10
|
-
import ComponentBase from './ComponentBase';
|
|
11
|
-
var FormatState = /** @class */ (function () {
|
|
12
|
-
function FormatState(isPercent, hasExternalPercentSymbol, formatString,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
if (
|
|
109
|
-
this.props.bind.
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
1
|
+
import { __assign, __decorate, __extends, __metadata } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { BindPropsHelper } from './PropTypes';
|
|
4
|
+
import { FormContext } from './FormContext';
|
|
5
|
+
import { Misc, NumberUtils, Utils } from '@singularsystems/neo-core';
|
|
6
|
+
import Decimal from 'decimal.js-light';
|
|
7
|
+
import { InputHelpers } from './InputHelpers';
|
|
8
|
+
import { observer } from 'mobx-react';
|
|
9
|
+
import memoize from 'memoize-one';
|
|
10
|
+
import ComponentBase from './ComponentBase';
|
|
11
|
+
var FormatState = /** @class */ (function () {
|
|
12
|
+
function FormatState(isPercent, hasExternalPercentSymbol, formatString,
|
|
13
|
+
/** How many decimals the value is allowed. */
|
|
14
|
+
allowedDecimals, zeroText, useNative) {
|
|
15
|
+
this.isPercent = isPercent;
|
|
16
|
+
this.hasExternalPercentSymbol = hasExternalPercentSymbol;
|
|
17
|
+
this.formatString = formatString;
|
|
18
|
+
this.allowedDecimals = allowedDecimals;
|
|
19
|
+
this.zeroText = zeroText;
|
|
20
|
+
this.useNative = useNative;
|
|
21
|
+
}
|
|
22
|
+
FormatState.create = function (propertyInfo, numericType, numProps, appendText) {
|
|
23
|
+
var isPercent = false;
|
|
24
|
+
var hasExternalPercentSymbol = false;
|
|
25
|
+
var formatString = numProps ? numProps.formatString : "";
|
|
26
|
+
var displayDecimals = 2;
|
|
27
|
+
if ((formatString && formatString.indexOf("%") >= 0)
|
|
28
|
+
|| appendText === "%"
|
|
29
|
+
|| (numProps === null || numProps === void 0 ? void 0 : numProps.format) === Misc.NumberFormat.PercentDecimals || (numProps === null || numProps === void 0 ? void 0 : numProps.format) === Misc.NumberFormat.PercentNoDecimals) {
|
|
30
|
+
isPercent = true;
|
|
31
|
+
}
|
|
32
|
+
if (propertyInfo.allowedDecimals !== undefined) {
|
|
33
|
+
displayDecimals = propertyInfo.allowedDecimals - (isPercent ? 2 : 0);
|
|
34
|
+
}
|
|
35
|
+
else if (numProps === null || numProps === void 0 ? void 0 : numProps.formatString) {
|
|
36
|
+
displayDecimals = NumberUtils.getDecimalPlaces(numProps.formatString);
|
|
37
|
+
}
|
|
38
|
+
if (!formatString) {
|
|
39
|
+
if (numProps && numProps.format) {
|
|
40
|
+
formatString = NumberUtils.getFormatString(numProps.format, numProps.currencySymbol, displayDecimals);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
var hasDecimals = numericType === Misc.DataType.Float || numericType === Misc.DataType.Decimal;
|
|
44
|
+
var format = (numProps === null || numProps === void 0 ? void 0 : numProps.currencySymbol) ?
|
|
45
|
+
(hasDecimals ? Misc.NumberFormat.CurrencyDecimals : Misc.NumberFormat.CurrencyNoDecimals) :
|
|
46
|
+
(hasDecimals ? Misc.NumberFormat.Decimals : Misc.NumberFormat.NoDecimals);
|
|
47
|
+
formatString = NumberUtils.getFormatString(format, numProps === null || numProps === void 0 ? void 0 : numProps.currencySymbol, displayDecimals);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (formatString.indexOf("%") < 0 && appendText === "%") {
|
|
51
|
+
hasExternalPercentSymbol = true;
|
|
52
|
+
}
|
|
53
|
+
return new FormatState(isPercent, hasExternalPercentSymbol, formatString, displayDecimals + (isPercent ? 2 : 0), numProps === null || numProps === void 0 ? void 0 : numProps.zeroText, numProps === null || numProps === void 0 ? void 0 : numProps.native);
|
|
54
|
+
};
|
|
55
|
+
FormatState.prototype.getFormattedValue = function (value) {
|
|
56
|
+
if (!value && this.zeroText !== undefined) {
|
|
57
|
+
return this.zeroText;
|
|
58
|
+
}
|
|
59
|
+
if (value !== undefined && value !== null) {
|
|
60
|
+
if (value instanceof Misc.Globals.decimalType) {
|
|
61
|
+
value = value.toNumber();
|
|
62
|
+
}
|
|
63
|
+
if (typeof value === "number") {
|
|
64
|
+
if (this.hasExternalPercentSymbol) {
|
|
65
|
+
value *= 100;
|
|
66
|
+
}
|
|
67
|
+
return this.useNative ? NumberUtils.formatRaw(value, this.formatString, false) : NumberUtils.format(value, this.formatString);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
return FormatState;
|
|
78
|
+
}());
|
|
79
|
+
export { FormatState };
|
|
80
|
+
// Taken from https://github.com/MikeMcl/decimal.js-light/blob/master/decimal.js since it is not exported.
|
|
81
|
+
var validDecimalRegex = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
82
|
+
var NumberInput = /** @class */ (function (_super) {
|
|
83
|
+
__extends(NumberInput, _super);
|
|
84
|
+
function NumberInput(props) {
|
|
85
|
+
var _this = _super.call(this, props) || this;
|
|
86
|
+
_this.hasFocus = false;
|
|
87
|
+
_this.isReadOnly = false;
|
|
88
|
+
_this.recalcFormatState = memoize(FormatState.create);
|
|
89
|
+
_this.numericType = _this.props.bind.propertyInfo.propertyType;
|
|
90
|
+
_this.inputElement = React.createRef();
|
|
91
|
+
_this.onChanged = _this.onChanged.bind(_this);
|
|
92
|
+
_this.onFocus = _this.onFocus.bind(_this);
|
|
93
|
+
_this.onBlur = _this.onBlur.bind(_this);
|
|
94
|
+
_this.onKeyDown = _this.onKeyDown.bind(_this);
|
|
95
|
+
return _this;
|
|
96
|
+
}
|
|
97
|
+
NumberInput.prototype.onChanged = function (e) {
|
|
98
|
+
var newValue;
|
|
99
|
+
if (e.target.value !== "") {
|
|
100
|
+
var testValue = e.target.value;
|
|
101
|
+
if (testValue[0] === "-") {
|
|
102
|
+
testValue = testValue.substring(1);
|
|
103
|
+
}
|
|
104
|
+
if (isNaN(parseFloat(testValue)) || !validDecimalRegex.test(testValue)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (e.target.value == "") {
|
|
109
|
+
newValue = this.props.bind.propertyInfo.allowNulls ? null : new Decimal(0);
|
|
110
|
+
}
|
|
111
|
+
else if (this.formatState.isPercent && NumberUtils.transformPercent) {
|
|
112
|
+
newValue = new Decimal(e.target.value).dividedBy(100);
|
|
113
|
+
}
|
|
114
|
+
else if (this.numericType === Misc.DataType.Float || this.numericType === Misc.DataType.Decimal) {
|
|
115
|
+
newValue = new Decimal(e.target.value);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Rounds to zero.
|
|
119
|
+
newValue = new Decimal(e.target.value).toDecimalPlaces(0, Decimal.ROUND_DOWN);
|
|
120
|
+
}
|
|
121
|
+
if (newValue === null) {
|
|
122
|
+
this.props.bind.value = newValue;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
if (!this.props.numProps || this.props.numProps.autoRound !== false) {
|
|
126
|
+
newValue = NumberUtils.round(newValue, this.formatState.allowedDecimals);
|
|
127
|
+
}
|
|
128
|
+
if (this.numericType === Misc.DataType.Decimal) {
|
|
129
|
+
this.props.bind.value = newValue;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
this.props.bind.value = newValue.toNumber();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
NumberInput.prototype.onFocus = function () {
|
|
137
|
+
var element = this.inputElement.current;
|
|
138
|
+
if (element && !element.disabled) {
|
|
139
|
+
this.setFocusedText(element);
|
|
140
|
+
element.select();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
NumberInput.prototype.getBindValueAsNumber = function () {
|
|
144
|
+
var propertyValue = this.props.bind.value;
|
|
145
|
+
if (propertyValue instanceof Misc.Globals.decimalType) {
|
|
146
|
+
return propertyValue.toNumber();
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
return propertyValue;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
NumberInput.prototype.setFocusedText = function (element) {
|
|
153
|
+
this.hasFocus = true;
|
|
154
|
+
var numberValue = this.getBindValueAsNumber();
|
|
155
|
+
var stringValue;
|
|
156
|
+
if (numberValue === null || numberValue === undefined) {
|
|
157
|
+
stringValue = "";
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
if (element.readOnly || !this.props.numProps || this.props.numProps.autoRound !== false) {
|
|
161
|
+
stringValue = NumberUtils.formatRaw(numberValue, this.formatState.formatString, this.formatState.hasExternalPercentSymbol, this.formatState.allowedDecimals);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
if (this.formatState.isPercent && NumberUtils.transformPercent) {
|
|
165
|
+
numberValue *= 100;
|
|
166
|
+
}
|
|
167
|
+
stringValue = numberValue.toString();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
element.value = stringValue;
|
|
171
|
+
};
|
|
172
|
+
NumberInput.prototype.onBlur = function (e) {
|
|
173
|
+
this.hasFocus = false;
|
|
174
|
+
if (this.inputElement.current) {
|
|
175
|
+
this.inputElement.current.value = this.formatState.getFormattedValue(this.props.bind.value);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
NumberInput.prototype.onKeyDown = function (e) {
|
|
179
|
+
var element = this.inputElement.current;
|
|
180
|
+
if (!this.isReadOnly && element && (e.keyCode === 38 || e.keyCode === 40)) {
|
|
181
|
+
var value = this.getBindValueAsNumber();
|
|
182
|
+
if (value !== null) {
|
|
183
|
+
var selectionIndex = element.selectionEnd;
|
|
184
|
+
var deltaValue = 1;
|
|
185
|
+
var decimalIndex = element.value.indexOf(".");
|
|
186
|
+
if (decimalIndex < 0) {
|
|
187
|
+
decimalIndex = element.value.indexOf(",");
|
|
188
|
+
}
|
|
189
|
+
if (decimalIndex > 0 && selectionIndex && selectionIndex > decimalIndex) {
|
|
190
|
+
deltaValue = 0.01;
|
|
191
|
+
}
|
|
192
|
+
if (this.formatState.isPercent && NumberUtils.transformPercent) {
|
|
193
|
+
deltaValue /= 100;
|
|
194
|
+
}
|
|
195
|
+
if (e.keyCode === 38) {
|
|
196
|
+
// Up
|
|
197
|
+
value += deltaValue;
|
|
198
|
+
}
|
|
199
|
+
else if (e.keyCode === 40) {
|
|
200
|
+
// Down
|
|
201
|
+
value -= deltaValue;
|
|
202
|
+
}
|
|
203
|
+
if (this.numericType === Misc.DataType.Decimal) {
|
|
204
|
+
this.props.bind.value = new Decimal(value);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
this.props.bind.value = value;
|
|
208
|
+
}
|
|
209
|
+
this.setFocusedText(element);
|
|
210
|
+
if (selectionIndex !== null) {
|
|
211
|
+
element.selectionStart = element.selectionEnd = selectionIndex;
|
|
212
|
+
}
|
|
213
|
+
e.preventDefault();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
NumberInput.prototype.componentDidMount = function () {
|
|
218
|
+
if (this.inputElement.current) {
|
|
219
|
+
this.inputElement.current.addEventListener("keydown", this.onKeyDown);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
NumberInput.prototype.componentWillUnmount = function () {
|
|
223
|
+
if (this.inputElement.current) {
|
|
224
|
+
this.inputElement.current.removeEventListener("keydown", this.onKeyDown);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
NumberInput.prototype.render = function () {
|
|
228
|
+
var _a;
|
|
229
|
+
var splitProps = BindPropsHelper.normaliseEditorProps(this, this.props);
|
|
230
|
+
var domProps = BindPropsHelper.autoSetDomProperties(splitProps, this.context, this.onBlur, this.onFocus);
|
|
231
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, splitProps.isBootstrap ? "form-control" : "neo-forms-editor", "numeric-input");
|
|
232
|
+
var editorProps = splitProps.editor;
|
|
233
|
+
var useNative = (_a = splitProps.numProps) === null || _a === void 0 ? void 0 : _a.native;
|
|
234
|
+
var displayInfo = this.props.bind.validator.getDisplayState(this.context.validationDisplayMode);
|
|
235
|
+
displayInfo.applyToDom(domProps, !splitProps.inGroup);
|
|
236
|
+
this.formatState = this.recalcFormatState(this.props.bind.propertyInfo, this.numericType, splitProps.numProps, editorProps.appendText);
|
|
237
|
+
this.isReadOnly = domProps.readOnly === true;
|
|
238
|
+
if (editorProps.inputElement) {
|
|
239
|
+
this.inputElement = editorProps.inputElement;
|
|
240
|
+
}
|
|
241
|
+
// Don't update the elements value if it is focused
|
|
242
|
+
if (!this.hasFocus) {
|
|
243
|
+
if (this.inputElement.current) {
|
|
244
|
+
this.inputElement.current.value = this.formatState.getFormattedValue(editorProps.bind.value);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (useNative && !domProps.step) {
|
|
248
|
+
var decimals = NumberUtils.getDecimalPlaces(this.formatState.formatString);
|
|
249
|
+
domProps.step = decimals === 0 ? "1" : "0.".concat("0".repeat(decimals - 1), "1");
|
|
250
|
+
}
|
|
251
|
+
return (InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({}, domProps, { defaultValue: this.formatState.getFormattedValue(editorProps.bind.value), type: useNative ? "number" : "text", onChange: this.onChanged, ref: this.inputElement })), editorProps));
|
|
252
|
+
};
|
|
253
|
+
NumberInput.contextType = FormContext;
|
|
254
|
+
NumberInput = __decorate([
|
|
255
|
+
observer,
|
|
256
|
+
__metadata("design:paramtypes", [Object])
|
|
257
|
+
], NumberInput);
|
|
258
|
+
return NumberInput;
|
|
259
|
+
}(ComponentBase));
|
|
260
|
+
export default NumberInput;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Data } from "@singularsystems/neo-core";
|
|
3
|
-
export interface IPagerControlsProps extends React.HTMLProps<HTMLUListElement> {
|
|
4
|
-
/** Page manager to control. */
|
|
5
|
-
pageManager: Data.IPageManager;
|
|
6
|
-
/** No of buttons to show */
|
|
7
|
-
noOfButtons?: number;
|
|
8
|
-
/** Alignment of buttons. End (right) by default. */
|
|
9
|
-
alignment?: "start" | "center" | "end" | "";
|
|
10
|
-
/** Text of the first button. */
|
|
11
|
-
firstText?: string;
|
|
12
|
-
/** Text of the prev button. */
|
|
13
|
-
prevText?: string;
|
|
14
|
-
/** Text of the next button. */
|
|
15
|
-
nextText?: string;
|
|
16
|
-
/** Text of the last button. */
|
|
17
|
-
lastText?: string;
|
|
18
|
-
/** Hides the pager if there is only one page. True by default. */
|
|
19
|
-
autoHide?: boolean;
|
|
20
|
-
/** Causes the page size control to show, with this label. */
|
|
21
|
-
pageSizeLabel?: string | JSX.Element;
|
|
22
|
-
}
|
|
23
|
-
export default class SimplePagerControls extends React.Component<IPagerControlsProps> {
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Data } from "@singularsystems/neo-core";
|
|
3
|
+
export interface IPagerControlsProps extends React.HTMLProps<HTMLUListElement> {
|
|
4
|
+
/** Page manager to control. */
|
|
5
|
+
pageManager: Data.IPageManager;
|
|
6
|
+
/** No of buttons to show */
|
|
7
|
+
noOfButtons?: number;
|
|
8
|
+
/** Alignment of buttons. End (right) by default. */
|
|
9
|
+
alignment?: "start" | "center" | "end" | "";
|
|
10
|
+
/** Text of the first button. */
|
|
11
|
+
firstText?: string;
|
|
12
|
+
/** Text of the prev button. */
|
|
13
|
+
prevText?: string;
|
|
14
|
+
/** Text of the next button. */
|
|
15
|
+
nextText?: string;
|
|
16
|
+
/** Text of the last button. */
|
|
17
|
+
lastText?: string;
|
|
18
|
+
/** Hides the pager if there is only one page. True by default. */
|
|
19
|
+
autoHide?: boolean;
|
|
20
|
+
/** Causes the page size control to show, with this label. */
|
|
21
|
+
pageSizeLabel?: string | JSX.Element;
|
|
22
|
+
}
|
|
23
|
+
export default class SimplePagerControls extends React.Component<IPagerControlsProps> {
|
|
24
|
+
private iconFactory;
|
|
25
|
+
render(): false | JSX.Element;
|
|
26
|
+
}
|