@gpa-gemstone/react-forms 1.1.27 → 1.1.28
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/lib/Input.js +17 -10
- package/package.json +2 -2
package/lib/Input.js
CHANGED
|
@@ -41,23 +41,30 @@ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
|
41
41
|
function Input(props) {
|
|
42
42
|
var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
|
|
43
43
|
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
44
|
-
var _c = React.useState(
|
|
44
|
+
var _c = React.useState(false), internal = _c[0], setInternal = _c[1];
|
|
45
|
+
var _d = React.useState(''), heldVal = _d[0], setHeldVal = _d[1]; // Need to buffer tha value because parseFloat will throw away trailing decimals or zeros
|
|
45
46
|
React.useEffect(function () {
|
|
46
47
|
setGuid((0, helper_functions_1.CreateGuid)());
|
|
47
48
|
}, []);
|
|
48
49
|
React.useEffect(function () {
|
|
49
|
-
|
|
50
|
+
if (!internal) {
|
|
51
|
+
setHeldVal(props.Record[props.Field] == null ? '' : props.Record[props.Field].toString());
|
|
52
|
+
}
|
|
53
|
+
setInternal(false);
|
|
50
54
|
}, [props.Record[props.Field]]);
|
|
51
|
-
function valueChange(
|
|
55
|
+
function valueChange(value) {
|
|
52
56
|
var _a, _b;
|
|
57
|
+
setInternal(true);
|
|
53
58
|
if (props.Type === 'number') {
|
|
54
|
-
if (
|
|
55
|
-
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] =
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
if ((0, helper_functions_1.IsNumber)(value)) {
|
|
60
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = value !== '' ? parseFloat(value) : null, _a)));
|
|
61
|
+
setHeldVal(value);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = value !== '' ? value : null, _b)));
|
|
66
|
+
setHeldVal(value);
|
|
58
67
|
}
|
|
59
|
-
else
|
|
60
|
-
props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = evt.target.value !== '' ? evt.target.value : null, _b)));
|
|
61
68
|
}
|
|
62
69
|
return (React.createElement("div", { className: "form-group" },
|
|
63
70
|
(props.Label !== "") ?
|
|
@@ -67,7 +74,7 @@ function Input(props) {
|
|
|
67
74
|
props.Help !== undefined ?
|
|
68
75
|
React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
|
|
69
76
|
: null,
|
|
70
|
-
React.createElement("input", { "data-help": guid, type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) { return valueChange(evt); }, value: heldVal, disabled: props.Disabled == null ? false : props.Disabled }),
|
|
77
|
+
React.createElement("input", { "data-help": guid, type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) { return valueChange(evt.target.value); }, value: heldVal, disabled: props.Disabled == null ? false : props.Disabled }),
|
|
71
78
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field + ' is a required field.' : props.Feedback)));
|
|
72
79
|
}
|
|
73
80
|
exports.default = Input;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpa-gemstone/react-forms",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.28",
|
|
4
4
|
"description": "React Form modules for gpa webapps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"typescript": "4.4.4"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
48
|
+
"@gpa-gemstone/helper-functions": "0.0.17",
|
|
49
49
|
"@types/react": "^17.0.14",
|
|
50
50
|
"@types/styled-components": "^5.1.11",
|
|
51
51
|
"react": "^18.2.0",
|