@singularsystems/neo-react 0.10.40 → 0.10.41
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/dist/Modules/NeoReactModule.js +2 -0
- package/dist/Modules/Types.d.ts +4 -0
- package/dist/ReactComponents/DropDown/DropDown.js +3 -2
- package/dist/ReactComponents/Modal/Modal.js +4 -1
- package/dist/ReactComponents/NumberInput.js +7 -2
- package/dist/Views/ViewModelBase.d.ts +1 -0
- package/package.json +2 -2
|
@@ -10,9 +10,11 @@ import { AutoRunnerFactory } from '../React/AutoRunner';
|
|
|
10
10
|
import { RoutingState } from '../Routing/RoutingState';
|
|
11
11
|
import { ContextMenuState } from '../ReactComponents/ContextMenu/ContextMenuState';
|
|
12
12
|
import { DisposeHelper } from '../Services/DisposeHelper';
|
|
13
|
+
import Decimal from 'decimal.js-light';
|
|
13
14
|
var neoReactModule = new AppServices.Module("neo-react", function (container) {
|
|
14
15
|
container.bind(AppServices.NeoTypes.Core.AutoRunnerFactory).to(AutoRunnerFactory).inSingletonScope();
|
|
15
16
|
container.bind(AppServices.NeoTypes.Core.ModelCreator).to(ReactModelCreator).inTransientScope();
|
|
17
|
+
container.bind(AppServices.NeoTypes.Misc.DecimalType).toConstantValue(Decimal);
|
|
16
18
|
container.bind(AppServices.NeoTypes.UI.ErrorHandler).to(ErrorHandler).inSingletonScope();
|
|
17
19
|
container.bind(AppServices.NeoTypes.UI.GlobalContextMenuState).toConstantValue(new ContextMenuState());
|
|
18
20
|
container.bind(AppServices.NeoTypes.Routing.PageLeaveHandler).to(PageLeaveHandler).inSingletonScope();
|
package/dist/Modules/Types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import Slider, { Range } from 'rc-slider';
|
|
|
5
5
|
import { SketchPicker } from 'react-color';
|
|
6
6
|
import AsyncSelect from 'react-select/async';
|
|
7
7
|
import { AxiosStatic } from 'axios';
|
|
8
|
+
import Decimal from 'decimal.js-light';
|
|
8
9
|
import Select from 'react-select';
|
|
9
10
|
import { IDisposeHelper } from '../Services/IDisposeHelper';
|
|
10
11
|
declare const NeoReactTypes: {
|
|
@@ -38,6 +39,9 @@ declare const NeoReactTypes: {
|
|
|
38
39
|
Localisation: {
|
|
39
40
|
LocalisationService: AppServices.ServiceIdentifier<import("@singularsystems/neo-core/dist/Localisation").ILocalisationService>;
|
|
40
41
|
};
|
|
42
|
+
Misc: {
|
|
43
|
+
DecimalType: AppServices.ServiceIdentifier<typeof Decimal>;
|
|
44
|
+
};
|
|
41
45
|
Security: {
|
|
42
46
|
AuthenticationService: AppServices.ServiceIdentifier<import("@singularsystems/neo-core/dist/Security").IAuthenticationService>;
|
|
43
47
|
AuthorisationService: AppServices.ServiceIdentifier<import("@singularsystems/neo-core/dist/Security").IAuthorisationService>;
|
|
@@ -80,7 +80,7 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
80
80
|
};
|
|
81
81
|
DropDown.prototype.render = function () {
|
|
82
82
|
var _this = this;
|
|
83
|
-
var _a, _b, _c, _d, _e;
|
|
83
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84
84
|
var splitProps = BindPropsHelper.normaliseEditorProps(this, this.props);
|
|
85
85
|
var domProps = BindPropsHelper.autoSetDomProperties(splitProps, this.context);
|
|
86
86
|
domProps.className = Utils.joinWithSpaces(domProps.className, splitProps.isBootstrap ? "form-control" : "neo-forms-editor");
|
|
@@ -116,9 +116,10 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
116
116
|
domProps.disabled = true;
|
|
117
117
|
}
|
|
118
118
|
var valueIsBlank = value === undefined || value === null;
|
|
119
|
+
var nullText = (valueIsBlank || ((_d = splitProps.select) === null || _d === void 0 ? void 0 : _d.deSelectText) === undefined) ? (_e = splitProps.select) === null || _e === void 0 ? void 0 : _e.nullText : (_f = splitProps.select) === null || _f === void 0 ? void 0 : _f.deSelectText;
|
|
119
120
|
control =
|
|
120
121
|
React.createElement("select", __assign({ value: valueIsBlank ? "" : value, onChange: this.onItemSelected, ref: splitProps.editor.inputElement }, domProps),
|
|
121
|
-
addBlankItem && React.createElement("option", null,
|
|
122
|
+
addBlankItem && React.createElement("option", null, nullText),
|
|
122
123
|
items.map(function (item) { return (React.createElement("option", { value: item[_this.valueMember], key: item[_this.valueMember] }, item[_this.displayMember])); }));
|
|
123
124
|
}
|
|
124
125
|
return (InputHelpers.surroundWithInputGroup(control, splitProps.editor));
|
|
@@ -41,13 +41,16 @@ var Modal = /** @class */ (function (_super) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
show = !!propertyInstance.value;
|
|
44
|
-
onClose = function () {
|
|
44
|
+
onClose = function (event) {
|
|
45
45
|
if (propertyInstance.value === true) {
|
|
46
46
|
propertyInstance.value = false;
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
propertyInstance.value = null;
|
|
50
50
|
}
|
|
51
|
+
if (_this.props.onClose) {
|
|
52
|
+
_this.props.onClose(event);
|
|
53
|
+
}
|
|
51
54
|
};
|
|
52
55
|
}
|
|
53
56
|
else {
|
|
@@ -45,7 +45,7 @@ var FormatState = /** @class */ (function () {
|
|
|
45
45
|
return this.zeroText;
|
|
46
46
|
}
|
|
47
47
|
if (value !== undefined && value !== null) {
|
|
48
|
-
if (value instanceof
|
|
48
|
+
if (value instanceof Misc.Globals.decimalType) {
|
|
49
49
|
value = value.toNumber();
|
|
50
50
|
}
|
|
51
51
|
if (typeof value === "number") {
|
|
@@ -65,6 +65,8 @@ var FormatState = /** @class */ (function () {
|
|
|
65
65
|
return FormatState;
|
|
66
66
|
}());
|
|
67
67
|
export { FormatState };
|
|
68
|
+
// Taken from https://github.com/MikeMcl/decimal.js-light/blob/master/decimal.js since it is not exported.
|
|
69
|
+
var validDecimalRegex = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
68
70
|
var NumberInput = /** @class */ (function (_super) {
|
|
69
71
|
__extends(NumberInput, _super);
|
|
70
72
|
function NumberInput(props) {
|
|
@@ -85,6 +87,9 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
85
87
|
if (e.target.value !== "" && isNaN(parseFloat(e.target.value))) {
|
|
86
88
|
return;
|
|
87
89
|
}
|
|
90
|
+
else if (!validDecimalRegex.test(e.target.value)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
88
93
|
if (e.target.value == "") {
|
|
89
94
|
newValue = this.props.bind.propertyInfo.allowNulls ? null : new Decimal(0);
|
|
90
95
|
}
|
|
@@ -122,7 +127,7 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
122
127
|
};
|
|
123
128
|
NumberInput.prototype.getBindValueAsNumber = function () {
|
|
124
129
|
var propertyValue = this.props.bind.value;
|
|
125
|
-
if (propertyValue instanceof
|
|
130
|
+
if (propertyValue instanceof Misc.Globals.decimalType) {
|
|
126
131
|
return propertyValue.toNumber();
|
|
127
132
|
}
|
|
128
133
|
else {
|
|
@@ -19,6 +19,7 @@ export default abstract class ViewModelBase extends ModelBase implements IViewMo
|
|
|
19
19
|
registerReaction<T>(expression: () => T, effect: (value: T) => void): IReactionDisposer;
|
|
20
20
|
/**
|
|
21
21
|
* Instantiates, and registers a child view model that will be disposed when this view model is disposed.
|
|
22
|
+
* The task runner will be passed to the new vm from this one.
|
|
22
23
|
* @param viewModel View model type.
|
|
23
24
|
*/
|
|
24
25
|
registerViewModel<TViewModel extends IViewModel>(viewModel: new () => TViewModel, options?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.41",
|
|
4
4
|
"description": "React application logic and components for the Neo client library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/rc-slider": "^8.6.5",
|
|
34
34
|
"@types/react-color": "^3.0.1",
|
|
35
35
|
"@types/react-select": "3.1.0",
|
|
36
|
-
"@singularsystems/neo-core": "^0.10.
|
|
36
|
+
"@singularsystems/neo-core": "^0.10.49",
|
|
37
37
|
"axios": "^0.21.1",
|
|
38
38
|
"decimal.js-light": "2.5.1",
|
|
39
39
|
"history": "4.10.1",
|