@singularsystems/neo-react 0.10.53 → 0.10.54
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/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +2 -0
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +7 -3
- package/dist/ReactComponents/Input.d.ts +1 -1
- package/dist/ReactComponents/NumberInput.d.ts +4 -1
- package/dist/ReactComponents/NumberInput.js +14 -12
- package/dist/ReactComponents/PropTypes.js +24 -8
- package/dist/Views/ViewComponentBase.d.ts +7 -1
- package/dist/Views/ViewComponentBase.js +8 -5
- package/dist/Views/ViewModelBase.d.ts +1 -0
- package/package.json +11 -2
|
@@ -8,6 +8,7 @@ import { FormContext } from '../FormContext';
|
|
|
8
8
|
interface IOption {
|
|
9
9
|
value: string | number;
|
|
10
10
|
label: string;
|
|
11
|
+
item?: any;
|
|
11
12
|
}
|
|
12
13
|
interface IAutoCompleteCommonProps<T> extends ICommonEditorProps, Props<IOption, true> {
|
|
13
14
|
/**
|
|
@@ -74,6 +75,7 @@ export default class AutoCompleteDropDown<T> extends DropDownBase<T, IAutoComple
|
|
|
74
75
|
private asyncSelectImplementation;
|
|
75
76
|
private selectImplementation;
|
|
76
77
|
constructor(props: IAutoCompleteProps<T> | IAutoCompleteMultiSelectProps<T>);
|
|
78
|
+
static getBindProp<T>(props: IAutoCompleteProps<T> | IAutoCompleteMultiSelectProps<T>): any;
|
|
77
79
|
private onKeyPress;
|
|
78
80
|
private mapTArrayToOptions;
|
|
79
81
|
private onItemSelected;
|
|
@@ -18,6 +18,10 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
18
18
|
_this.onItemSelected = _this.onItemSelected.bind(_this);
|
|
19
19
|
return _this;
|
|
20
20
|
}
|
|
21
|
+
AutoCompleteDropDown.getBindProp = function (props) {
|
|
22
|
+
var _a;
|
|
23
|
+
return _a = props.bind, (_a !== null && _a !== void 0 ? _a : props.bindItems);
|
|
24
|
+
};
|
|
21
25
|
AutoCompleteDropDown.prototype.onKeyPress = function (searchValue, dataReceived) {
|
|
22
26
|
var _this = this;
|
|
23
27
|
var _a, _b;
|
|
@@ -45,7 +49,7 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
45
49
|
if (items.length) {
|
|
46
50
|
this.findMembers(items[0]);
|
|
47
51
|
}
|
|
48
|
-
return items.map(function (item) { return (__assign(__assign({}, item), { value: item[_this.valueMember], label: item[_this.displayMember] })); });
|
|
52
|
+
return items.map(function (item) { return (__assign(__assign({}, item), { item: item, value: item[_this.valueMember], label: item[_this.displayMember] })); });
|
|
49
53
|
};
|
|
50
54
|
AutoCompleteDropDown.prototype.onItemSelected = function (args, action) {
|
|
51
55
|
var onItemSelected = this.props.onItemSelected;
|
|
@@ -60,7 +64,7 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
60
64
|
bindIdsList.push(action.option.value);
|
|
61
65
|
}
|
|
62
66
|
if (onItemSelected) {
|
|
63
|
-
onItemSelected(action.option);
|
|
67
|
+
onItemSelected(action.option.item);
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
else if (action.action === "remove-value") {
|
|
@@ -93,7 +97,7 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
93
97
|
this.props.bindDisplay.value = args ? args.label : "";
|
|
94
98
|
}
|
|
95
99
|
if (onItemSelected) {
|
|
96
|
-
onItemSelected(
|
|
100
|
+
onItemSelected(action.option.item);
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
};
|
|
@@ -3,7 +3,7 @@ import { IBindableEditorProps } from './PropTypes';
|
|
|
3
3
|
import { Components } from '@singularsystems/neo-core';
|
|
4
4
|
import ComponentBase from './ComponentBase';
|
|
5
5
|
import { FormContext } from './FormContext';
|
|
6
|
-
declare type InputType = "text" | "password" | "checkbox" | "switch";
|
|
6
|
+
declare type InputType = "text" | "password" | "checkbox" | "switch" | "tel" | "email";
|
|
7
7
|
export interface IInputSpecificProps {
|
|
8
8
|
/** Type of input to use */
|
|
9
9
|
type?: InputType;
|
|
@@ -15,6 +15,8 @@ export interface INumberInputSpecificProps {
|
|
|
15
15
|
autoRound?: boolean;
|
|
16
16
|
/** Text to display if the value is zero or null. E.g. '-' */
|
|
17
17
|
zeroText?: string;
|
|
18
|
+
/** Set to true to use the browsers native numeric input control. Note: only decimal place formatting is supported in this mode. */
|
|
19
|
+
native?: boolean;
|
|
18
20
|
}
|
|
19
21
|
export interface INumberInputProps extends IBindableEditorProps<HTMLInputElement> {
|
|
20
22
|
numProps?: INumberInputSpecificProps;
|
|
@@ -24,7 +26,8 @@ export declare class FormatState {
|
|
|
24
26
|
hasExternalPercentSymbol: boolean;
|
|
25
27
|
formatString: string;
|
|
26
28
|
zeroText?: string | undefined;
|
|
27
|
-
|
|
29
|
+
useNative?: boolean | undefined;
|
|
30
|
+
constructor(isPercent: boolean, hasExternalPercentSymbol: boolean, formatString: string, zeroText?: string | undefined, useNative?: boolean | undefined);
|
|
28
31
|
static create(numericType: Misc.DataType, numProps?: INumberInputSpecificProps, appendText?: string): FormatState;
|
|
29
32
|
getFormattedValue(value?: number | Decimal | null): string;
|
|
30
33
|
}
|
|
@@ -9,14 +9,15 @@ import { observer } from 'mobx-react';
|
|
|
9
9
|
import memoize from 'memoize-one';
|
|
10
10
|
import ComponentBase from './ComponentBase';
|
|
11
11
|
var FormatState = /** @class */ (function () {
|
|
12
|
-
function FormatState(isPercent, hasExternalPercentSymbol, formatString, zeroText) {
|
|
12
|
+
function FormatState(isPercent, hasExternalPercentSymbol, formatString, zeroText, useNative) {
|
|
13
13
|
this.isPercent = isPercent;
|
|
14
14
|
this.hasExternalPercentSymbol = hasExternalPercentSymbol;
|
|
15
15
|
this.formatString = formatString;
|
|
16
16
|
this.zeroText = zeroText;
|
|
17
|
+
this.useNative = useNative;
|
|
17
18
|
}
|
|
18
19
|
FormatState.create = function (numericType, numProps, appendText) {
|
|
19
|
-
var _a, _b, _c;
|
|
20
|
+
var _a, _b, _c, _d;
|
|
20
21
|
var isPercent = false;
|
|
21
22
|
var hasExternalPercentSymbol = false;
|
|
22
23
|
var formatString = numProps ? numProps.formatString : "";
|
|
@@ -38,7 +39,7 @@ var FormatState = /** @class */ (function () {
|
|
|
38
39
|
if (formatString.indexOf("%") >= 0 || appendText === "%") {
|
|
39
40
|
isPercent = true;
|
|
40
41
|
}
|
|
41
|
-
return new FormatState(isPercent, hasExternalPercentSymbol, formatString, (_c = numProps) === null || _c === void 0 ? void 0 : _c.zeroText);
|
|
42
|
+
return new FormatState(isPercent, hasExternalPercentSymbol, formatString, (_c = numProps) === null || _c === void 0 ? void 0 : _c.zeroText, (_d = numProps) === null || _d === void 0 ? void 0 : _d.native);
|
|
42
43
|
};
|
|
43
44
|
FormatState.prototype.getFormattedValue = function (value) {
|
|
44
45
|
if (!value && this.zeroText !== undefined) {
|
|
@@ -52,7 +53,7 @@ var FormatState = /** @class */ (function () {
|
|
|
52
53
|
if (this.hasExternalPercentSymbol) {
|
|
53
54
|
value *= 100;
|
|
54
55
|
}
|
|
55
|
-
return NumberUtils.format(value, this.formatString);
|
|
56
|
+
return this.useNative ? NumberUtils.formatRaw(value, this.formatString, false) : NumberUtils.format(value, this.formatString);
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
59
|
return value;
|
|
@@ -141,13 +142,8 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
141
142
|
this.hasFocus = true;
|
|
142
143
|
var numberValue = this.getBindValueAsNumber();
|
|
143
144
|
var stringValue;
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
stringValue = "0";
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
stringValue = "";
|
|
150
|
-
}
|
|
145
|
+
if (numberValue === null || numberValue === undefined) {
|
|
146
|
+
stringValue = "";
|
|
151
147
|
}
|
|
152
148
|
else {
|
|
153
149
|
if (element.readOnly || !this.props.numProps || this.props.numProps.autoRound !== false) {
|
|
@@ -218,10 +214,12 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
218
214
|
}
|
|
219
215
|
};
|
|
220
216
|
NumberInput.prototype.render = function () {
|
|
217
|
+
var _a;
|
|
221
218
|
var splitProps = BindPropsHelper.normaliseEditorProps(this, this.props);
|
|
222
219
|
var domProps = BindPropsHelper.autoSetDomProperties(splitProps, this.context, this.onBlur, this.onFocus);
|
|
223
220
|
domProps.className = Utils.joinWithSpaces(domProps.className, splitProps.isBootstrap ? "form-control" : "neo-forms-editor", "numeric-input");
|
|
224
221
|
var editorProps = splitProps.editor;
|
|
222
|
+
var useNative = (_a = splitProps.numProps) === null || _a === void 0 ? void 0 : _a.native;
|
|
225
223
|
var displayInfo = this.props.bind.validator.getDisplayState(this.context.validationDisplayMode);
|
|
226
224
|
displayInfo.applyToDom(domProps, !splitProps.inGroup);
|
|
227
225
|
this.formatState = this.recalcFormatState(this.numericType, splitProps.numProps, editorProps.appendText);
|
|
@@ -235,7 +233,11 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
235
233
|
this.inputElement.current.value = this.formatState.getFormattedValue(editorProps.bind.value);
|
|
236
234
|
}
|
|
237
235
|
}
|
|
238
|
-
|
|
236
|
+
if (useNative && !domProps.step) {
|
|
237
|
+
var decimals = NumberUtils.getDecimalPlaces(this.formatState.formatString);
|
|
238
|
+
domProps.step = decimals === 0 ? "1" : "0." + "0".repeat(decimals - 1) + "1";
|
|
239
|
+
}
|
|
240
|
+
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));
|
|
239
241
|
};
|
|
240
242
|
NumberInput.contextType = FormContext;
|
|
241
243
|
NumberInput = __decorate([
|
|
@@ -113,18 +113,34 @@ var BindPropsHelper = /** @class */ (function () {
|
|
|
113
113
|
BindPropsHelper.normaliseContainerProps = function (component, props, inGroup, isBootstrap) {
|
|
114
114
|
// Split flattened props into components.
|
|
115
115
|
if (isBootstrap === void 0) { isBootstrap = true; }
|
|
116
|
-
var _a, _b;
|
|
116
|
+
var _a, _b, _c, _d, _e;
|
|
117
117
|
var splitProps = this.splitCommonEditorProps(props);
|
|
118
|
-
var
|
|
118
|
+
var _f = splitProps.rest,
|
|
119
119
|
// Bindable editor props
|
|
120
|
-
bind =
|
|
120
|
+
bind = _f.bind, display = _f.display, placeholder = _f.placeholder,
|
|
121
121
|
// Editor selector props
|
|
122
|
-
select =
|
|
122
|
+
select = _f.select, input = _f.input, dateProps = _f.dateProps, numProps = _f.numProps, fileProps = _f.fileProps, radioList = _f.radioList,
|
|
123
123
|
// Common container props
|
|
124
|
-
label =
|
|
124
|
+
label = _f.label, editorProps = _f.editorProps, editorTooltip = _f.editorTooltip, editorClassName = _f.editorClassName, editorStyle = _f.editorStyle, suppressDefaultContent = _f.suppressDefaultContent, bindContext = _f.bindContext,
|
|
125
125
|
// Container dom
|
|
126
|
-
containerDom = __rest(
|
|
126
|
+
containerDom = __rest(_f, ["bind", "display", "placeholder", "select", "input", "dateProps", "numProps", "fileProps", "radioList", "label", "editorProps", "editorTooltip", "editorClassName", "editorStyle", "suppressDefaultContent", "bindContext"]);
|
|
127
127
|
var bindOrDisplay = BindPropsHelper.getBindProperty(props);
|
|
128
|
+
if (!bindOrDisplay) {
|
|
129
|
+
var child = containerDom.children;
|
|
130
|
+
var childBind = void 0;
|
|
131
|
+
if (child) {
|
|
132
|
+
if ((_a = child.type) === null || _a === void 0 ? void 0 : _a.getBindProp) {
|
|
133
|
+
childBind = (_b = child.type) === null || _b === void 0 ? void 0 : _b.getBindProp(child.props);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
childBind = (_c = child.props) === null || _c === void 0 ? void 0 : _c.bind;
|
|
137
|
+
}
|
|
138
|
+
if (childBind) {
|
|
139
|
+
bindOrDisplay = childBind;
|
|
140
|
+
bindContext = bindOrDisplay;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
128
144
|
if (bindOrDisplay && bindOrDisplay.propertyInfo.isReadOnly)
|
|
129
145
|
splitProps.editor.isReadOnly = true;
|
|
130
146
|
if (!props.bind && props.display)
|
|
@@ -145,7 +161,7 @@ var BindPropsHelper = /** @class */ (function () {
|
|
|
145
161
|
}
|
|
146
162
|
return {
|
|
147
163
|
bind: bindOrDisplay,
|
|
148
|
-
editor: __assign({ bind: bindOrDisplay, placeholder: this.getPlaceholderText(placeholder, (
|
|
164
|
+
editor: __assign({ bind: bindOrDisplay, placeholder: this.getPlaceholderText(placeholder, (_d = bindOrDisplay) === null || _d === void 0 ? void 0 : _d.propertyInfo) }, splitProps.editor),
|
|
149
165
|
editorDom: editorProps,
|
|
150
166
|
container: { label: label, editorTooltip: editorTooltip, editorClassName: editorClassName, editorStyle: editorStyle, bindContext: bindContext, suppressDefaultContent: suppressDefaultContent },
|
|
151
167
|
select: select,
|
|
@@ -155,7 +171,7 @@ var BindPropsHelper = /** @class */ (function () {
|
|
|
155
171
|
fileProps: fileProps,
|
|
156
172
|
radioList: radioList,
|
|
157
173
|
inGroup: inGroup,
|
|
158
|
-
uniqueID: ((
|
|
174
|
+
uniqueID: ((_e = bindOrDisplay) === null || _e === void 0 ? void 0 : _e.uniqueID) + "!" + component.uniqueId,
|
|
159
175
|
containerDom: containerDom,
|
|
160
176
|
isBootstrap: isBootstrap
|
|
161
177
|
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ITaskRunner } from '@singularsystems/neo-core';
|
|
3
3
|
import { IViewModel } from './IViewModel';
|
|
4
|
+
import { valueOrLazy } from './ViewModelBase';
|
|
4
5
|
interface IComponentProps {
|
|
5
6
|
taskRunner?: ITaskRunner;
|
|
6
7
|
}
|
|
7
8
|
export default class ViewComponentBase<TProps extends IComponentProps, TViewModel extends IViewModel> extends React.Component<TProps> {
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Creates a view component.
|
|
11
|
+
* @param props Component props.
|
|
12
|
+
* @param viewModel Instance of view model, or view model type, or callback which returns a view model. Taskrunner will be set only if passing in VM type.
|
|
13
|
+
*/
|
|
14
|
+
constructor(props: TProps, viewModel: valueOrLazy<TViewModel>);
|
|
9
15
|
viewModel: TViewModel;
|
|
10
16
|
componentDidMount(): void;
|
|
11
17
|
componentWillUnmount(): void;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import ViewModelBase from './ViewModelBase';
|
|
3
4
|
var ViewComponentBase = /** @class */ (function (_super) {
|
|
4
5
|
__extends(ViewComponentBase, _super);
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Creates a view component.
|
|
8
|
+
* @param props Component props.
|
|
9
|
+
* @param viewModel Instance of view model, or view model type, or callback which returns a view model. Taskrunner will be set only if passing in VM type.
|
|
10
|
+
*/
|
|
11
|
+
function ViewComponentBase(props, viewModel) {
|
|
6
12
|
var _this = _super.call(this, props) || this;
|
|
7
|
-
_this.viewModel =
|
|
8
|
-
if (props.taskRunner) {
|
|
9
|
-
_this.viewModel.taskRunner = props.taskRunner;
|
|
10
|
-
}
|
|
13
|
+
_this.viewModel = ViewModelBase.create(viewModel, props.taskRunner);
|
|
11
14
|
return _this;
|
|
12
15
|
}
|
|
13
16
|
ViewComponentBase.prototype.componentDidMount = function () {
|
|
@@ -27,6 +27,7 @@ export default abstract class ViewModelBase extends ModelBase implements IViewMo
|
|
|
27
27
|
}): TViewModel;
|
|
28
28
|
/**
|
|
29
29
|
* Registers a child view model that will be disposed when this view model is disposed.
|
|
30
|
+
* You must manually pass the current VMs task runner to the new viewmodel instance.
|
|
30
31
|
*/
|
|
31
32
|
registerViewModel<TViewModel extends IViewModel>(viewModel: TViewModel): TViewModel;
|
|
32
33
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.54",
|
|
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.58",
|
|
37
37
|
"axios": "^0.21.1",
|
|
38
38
|
"decimal.js-light": "2.5.1",
|
|
39
39
|
"history": "4.10.1",
|
|
@@ -45,5 +45,14 @@
|
|
|
45
45
|
"react-custom-scrollbars": "^4.2.1",
|
|
46
46
|
"react-dom": "^16.13.1",
|
|
47
47
|
"react-router-dom": "5.1.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@singularsystems/neo-core": ">=0.10.58",
|
|
51
|
+
"axios": ">=0.21.1",
|
|
52
|
+
"inversify": ">=5.0.1",
|
|
53
|
+
"react": ">=16.13.1",
|
|
54
|
+
"react-dom": ">=16.13.1",
|
|
55
|
+
"react-router": "^5.0.0",
|
|
56
|
+
"react-router-dom": "^5.0.0"
|
|
48
57
|
}
|
|
49
58
|
}
|