@singularsystems/neo-react 0.10.61 → 0.10.62
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/DatePicker.d.ts +1 -0
- package/dist/ReactComponents/DatePicker.js +6 -2
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +4 -0
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +3 -0
- package/dist/ReactComponents/Grid/ButtonColumn.js +1 -1
- package/dist/ReactComponents/Input.js +1 -1
- package/dist/ReactComponents/InputHelpers.d.ts +2 -2
- package/dist/ReactComponents/InputHelpers.js +3 -3
- package/dist/ReactComponents/NumberInput.js +14 -7
- package/package.json +2 -2
- package/styles/DatePicker.scss +11 -0
|
@@ -12,6 +12,7 @@ export default class DatePicker extends ComponentBase<INeoDatePickerProps> {
|
|
|
12
12
|
private container;
|
|
13
13
|
private datePicker?;
|
|
14
14
|
private isReadOnly;
|
|
15
|
+
private inputRef;
|
|
15
16
|
constructor(props: INeoDatePickerProps);
|
|
16
17
|
componentDidMount(): void;
|
|
17
18
|
componentWillUnmount(): void;
|
|
@@ -11,6 +11,7 @@ var DatePicker = /** @class */ (function (_super) {
|
|
|
11
11
|
function DatePicker(props) {
|
|
12
12
|
var _this = _super.call(this, props) || this;
|
|
13
13
|
_this.isReadOnly = false;
|
|
14
|
+
_this.inputRef = React.createRef();
|
|
14
15
|
_this.container = React.createRef();
|
|
15
16
|
return _this;
|
|
16
17
|
}
|
|
@@ -33,6 +34,9 @@ var DatePicker = /** @class */ (function (_super) {
|
|
|
33
34
|
this.isReadOnly = !!domProps.readOnly;
|
|
34
35
|
var displayInfo = this.props.bind.validator.getDisplayState(this.context.validationDisplayMode);
|
|
35
36
|
displayInfo.applyToDom(domProps, !splitProps.inGroup);
|
|
37
|
+
if (splitProps.editor.inputElement) {
|
|
38
|
+
this.inputRef = splitProps.editor.inputElement;
|
|
39
|
+
}
|
|
36
40
|
if (this.datePicker) {
|
|
37
41
|
this.datePicker.update(splitProps.dateProps, this.props.bind, this.isReadOnly);
|
|
38
42
|
}
|
|
@@ -40,8 +44,8 @@ var DatePicker = /** @class */ (function (_super) {
|
|
|
40
44
|
// Create dependency on bound value on initial render.
|
|
41
45
|
void this.props.bind.value;
|
|
42
46
|
}
|
|
43
|
-
return (React.createElement("div", { className: "neo-datepicker-container", ref: this.container },
|
|
44
|
-
InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({ type: "text" }, domProps, { ref:
|
|
47
|
+
return (React.createElement("div", { className: "neo-datepicker-container", ref: this.container }, Components.DatePicker.mustShowInput(splitProps.dateProps) &&
|
|
48
|
+
InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({ type: "text" }, domProps, { ref: this.inputRef })), splitProps.editor, this.inputRef)));
|
|
45
49
|
};
|
|
46
50
|
DatePicker.contextType = FormContext;
|
|
47
51
|
DatePicker = __decorate([
|
|
@@ -21,6 +21,10 @@ interface IAutoCompleteCommonProps<T> extends ICommonEditorProps, Props<IOption,
|
|
|
21
21
|
items?: ItemSource<T>;
|
|
22
22
|
valueMember?: keyof T;
|
|
23
23
|
displayMember?: keyof T;
|
|
24
|
+
/**
|
|
25
|
+
* Function used to filter items out of the datasource.
|
|
26
|
+
* **Note:** this will only apply to the `items` prop. */
|
|
27
|
+
filterPredicate?: (item: T) => boolean;
|
|
24
28
|
/**
|
|
25
29
|
* Property of an item to use as the description.
|
|
26
30
|
*
|
|
@@ -134,6 +134,9 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
134
134
|
var defaultItems = undefined;
|
|
135
135
|
if (this.props.items) {
|
|
136
136
|
var items_1 = this.getItems(this.props.items);
|
|
137
|
+
if (this.props.filterPredicate !== undefined) {
|
|
138
|
+
items_1 = items_1.filter(this.props.filterPredicate);
|
|
139
|
+
}
|
|
137
140
|
defaultItems = this.mapTArrayToOptions(items_1);
|
|
138
141
|
if (descriptionMember === undefined && items_1.length > 0) {
|
|
139
142
|
if (EnumHelper.isEnumItem(items_1[0])) {
|
|
@@ -72,7 +72,7 @@ var ButtonColumn = /** @class */ (function (_super) {
|
|
|
72
72
|
React.createElement("th", __assign({}, domProps), this.section === "header" && label) :
|
|
73
73
|
React.createElement("td", __assign({}, domProps),
|
|
74
74
|
childAlignment === "right" ? buttons : undefined,
|
|
75
|
-
this.props.children,
|
|
75
|
+
this.props.children instanceof Function ? this.props.children() : this.props.children,
|
|
76
76
|
childAlignment !== "right" ? buttons : undefined));
|
|
77
77
|
};
|
|
78
78
|
ButtonColumn.isColumnComponent = true;
|
|
@@ -106,7 +106,7 @@ var Input = /** @class */ (function (_super) {
|
|
|
106
106
|
splitProps.editor.append = this.props.bind.value ?
|
|
107
107
|
React.createElement(Button, __assign({ size: "sm" }, buttonOptions, { icon: !this.showPassword ? "far-eye fa-fw" : "far-eye-slash fa-fw", onClick: function () { return _this.showPassword = !_this.showPassword; } })) : null;
|
|
108
108
|
}
|
|
109
|
-
return (InputHelpers.surroundWithInputGroup(inputElement, splitProps.editor));
|
|
109
|
+
return (InputHelpers.surroundWithInputGroup(inputElement, splitProps.editor, this.domRef));
|
|
110
110
|
};
|
|
111
111
|
Input.contextType = FormContext;
|
|
112
112
|
__decorate([
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { ICommonEditorProps } from './PropTypes';
|
|
3
3
|
export declare class InputHelpers {
|
|
4
4
|
private static iconFactory?;
|
|
5
|
-
static surroundWithInputGroup<T>(element: T, props: ICommonEditorProps): JSX.Element | T;
|
|
5
|
+
static surroundWithInputGroup<T>(element: T, props: ICommonEditorProps, inputRef?: React.RefObject<HTMLElement>): JSX.Element | T;
|
|
6
6
|
}
|
|
@@ -4,7 +4,7 @@ import { NeoReactTypes } from '../Modules/Types';
|
|
|
4
4
|
var InputHelpers = /** @class */ (function () {
|
|
5
5
|
function InputHelpers() {
|
|
6
6
|
}
|
|
7
|
-
InputHelpers.surroundWithInputGroup = function (element, props) {
|
|
7
|
+
InputHelpers.surroundWithInputGroup = function (element, props, inputRef) {
|
|
8
8
|
if (!this.iconFactory) {
|
|
9
9
|
this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
|
|
10
10
|
}
|
|
@@ -13,12 +13,12 @@ var InputHelpers = /** @class */ (function () {
|
|
|
13
13
|
(props.prependText || props.prepend) &&
|
|
14
14
|
React.createElement("div", { className: "input-group-prepend" },
|
|
15
15
|
props.prepend && (props.prepend instanceof Function ? props.prepend() : props.prepend),
|
|
16
|
-
props.prependText && React.createElement("span", { className: "input-group-text" }, this.iconFactory.textOrIcon(props.prependText))),
|
|
16
|
+
props.prependText && React.createElement("span", { className: "input-group-text", onClick: function () { var _a, _b; return (_b = (_a = inputRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.focus(); } }, this.iconFactory.textOrIcon(props.prependText))),
|
|
17
17
|
element,
|
|
18
18
|
(props.appendText || props.append) &&
|
|
19
19
|
React.createElement("div", { className: "input-group-append" },
|
|
20
20
|
props.append && (props.append instanceof Function ? props.append() : props.append),
|
|
21
|
-
props.appendText && React.createElement("span", { className: "input-group-text" }, this.iconFactory.textOrIcon(props.appendText)))));
|
|
21
|
+
props.appendText && React.createElement("span", { className: "input-group-text", onClick: function () { var _a, _b; return (_b = (_a = inputRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.focus(); } }, this.iconFactory.textOrIcon(props.appendText)))));
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
return element;
|
|
@@ -97,8 +97,15 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
97
97
|
}
|
|
98
98
|
NumberInput.prototype.onChanged = function (e) {
|
|
99
99
|
var newValue;
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
var stringValue = e.target.value;
|
|
101
|
+
if (stringValue !== "") {
|
|
102
|
+
if (NumberUtils.allowAsDecimalSeparator) {
|
|
103
|
+
var firstIndex = stringValue.indexOf(NumberUtils.allowAsDecimalSeparator), lastIndex = stringValue.lastIndexOf(NumberUtils.allowAsDecimalSeparator);
|
|
104
|
+
if (firstIndex >= 0 && firstIndex === lastIndex) {
|
|
105
|
+
stringValue = stringValue.replace(NumberUtils.allowAsDecimalSeparator, ".");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var testValue = stringValue;
|
|
102
109
|
if (testValue[0] === "-") {
|
|
103
110
|
testValue = testValue.substring(1);
|
|
104
111
|
}
|
|
@@ -106,18 +113,18 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
106
113
|
return;
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
|
-
if (
|
|
116
|
+
if (stringValue == "") {
|
|
110
117
|
newValue = this.props.bind.propertyInfo.allowNulls ? null : new Decimal(0);
|
|
111
118
|
}
|
|
112
119
|
else if (this.formatState.isPercent && NumberUtils.transformPercent) {
|
|
113
|
-
newValue = new Decimal(
|
|
120
|
+
newValue = new Decimal(stringValue).dividedBy(100);
|
|
114
121
|
}
|
|
115
122
|
else if (this.numericType === Misc.DataType.Float || this.numericType === Misc.DataType.Decimal) {
|
|
116
|
-
newValue = new Decimal(
|
|
123
|
+
newValue = new Decimal(stringValue);
|
|
117
124
|
}
|
|
118
125
|
else {
|
|
119
126
|
// Rounds to zero.
|
|
120
|
-
newValue = new Decimal(
|
|
127
|
+
newValue = new Decimal(stringValue).toDecimalPlaces(0, Decimal.ROUND_DOWN);
|
|
121
128
|
}
|
|
122
129
|
if (newValue === null) {
|
|
123
130
|
this.props.bind.value = newValue;
|
|
@@ -249,7 +256,7 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
249
256
|
var decimals = NumberUtils.getDecimalPlaces(this.formatState.formatString);
|
|
250
257
|
domProps.step = decimals === 0 ? "1" : "0." + "0".repeat(decimals - 1) + "1";
|
|
251
258
|
}
|
|
252
|
-
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));
|
|
259
|
+
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, this.inputElement));
|
|
253
260
|
};
|
|
254
261
|
NumberInput.contextType = FormContext;
|
|
255
262
|
NumberInput = __decorate([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.62",
|
|
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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-router-dom": "5.1.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@singularsystems/neo-core": ">=0.10.
|
|
50
|
+
"@singularsystems/neo-core": ">=0.10.72",
|
|
51
51
|
"axios": ">=0.21.1",
|
|
52
52
|
"inversify": ">=5.0.1",
|
|
53
53
|
"react": ">=16.13.1",
|
package/styles/DatePicker.scss
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
position: relative;
|
|
4
4
|
width: 100%;
|
|
5
5
|
color: initial;
|
|
6
|
+
|
|
7
|
+
&.neo-datepicker-always-show {
|
|
8
|
+
width: max-content;
|
|
9
|
+
|
|
10
|
+
input {
|
|
11
|
+
text-align: center;
|
|
12
|
+
padding: 0.125rem 0;
|
|
13
|
+
height: auto;
|
|
14
|
+
margin-bottom: 0.25rem;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
6
17
|
}
|
|
7
18
|
|
|
8
19
|
.neo-datepicker-popup {
|