@gpa-gemstone/react-forms 1.1.36 → 1.1.38
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/DatePicker.js +2 -2
- package/lib/DateTimeUI/Clock.js +12 -2
- package/lib/Input.d.ts +1 -0
- package/lib/Input.js +21 -5
- package/package.json +2 -2
package/lib/DatePicker.js
CHANGED
|
@@ -39,8 +39,8 @@ var DateTimePopup_1 = require("./DateTimeUI/DateTimePopup");
|
|
|
39
39
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
40
40
|
function DateTimePicker(props) {
|
|
41
41
|
// Formats that will be used for dateBoxes
|
|
42
|
-
var boxFormat = "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]
|
|
43
|
-
var recordFormat = props.Format !== undefined ? props.Format : "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]
|
|
42
|
+
var boxFormat = "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]HH:mm:ss");
|
|
43
|
+
var recordFormat = props.Format !== undefined ? props.Format : "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]HH:mm:ss.SSS[Z]");
|
|
44
44
|
var parse = function (r) { return moment(props.Record[props.Field], recordFormat); };
|
|
45
45
|
var divRef = React.useRef(null);
|
|
46
46
|
// Adds a buffer between the outside props and what the box is reading to prevent box overwriting every render with a keystroke
|
package/lib/DateTimeUI/Clock.js
CHANGED
|
@@ -46,11 +46,21 @@ function Clock(props) {
|
|
|
46
46
|
}, [hour, minute, second]);
|
|
47
47
|
function increase(type) {
|
|
48
48
|
var d = moment(props.DateTime).add(1, type);
|
|
49
|
-
|
|
49
|
+
if (type === 'h')
|
|
50
|
+
setHour(d.format("HH"));
|
|
51
|
+
if (type === 'm')
|
|
52
|
+
setMinute(d.format("mm"));
|
|
53
|
+
if (type === 's')
|
|
54
|
+
setSecond(d.format("ss"));
|
|
50
55
|
}
|
|
51
56
|
function decrease(type) {
|
|
52
57
|
var d = moment(props.DateTime).subtract(1, type);
|
|
53
|
-
|
|
58
|
+
if (type === 'h')
|
|
59
|
+
setHour(d.format("HH"));
|
|
60
|
+
if (type === 'm')
|
|
61
|
+
setMinute(d.format("mm"));
|
|
62
|
+
if (type === 's')
|
|
63
|
+
setSecond(d.format("ss"));
|
|
54
64
|
}
|
|
55
65
|
return (React.createElement("div", { style: { background: '#f0f0f0', marginTop: 10, opacity: 1 } },
|
|
56
66
|
React.createElement("table", { style: { textAlign: 'center' } },
|
package/lib/Input.d.ts
CHANGED
package/lib/Input.js
CHANGED
|
@@ -52,14 +52,27 @@ function Input(props) {
|
|
|
52
52
|
}
|
|
53
53
|
setInternal(false);
|
|
54
54
|
}, [props.Record[props.Field]]);
|
|
55
|
+
function onBlur() {
|
|
56
|
+
var _a;
|
|
57
|
+
var _b;
|
|
58
|
+
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
59
|
+
if (!allowNull && (props.Type === 'number' || props.Type === 'integer') && heldVal === '') {
|
|
60
|
+
setInternal(false);
|
|
61
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = (_b = props.DefaultValue) !== null && _b !== void 0 ? _b : 0, _a)));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
55
64
|
function valueChange(value) {
|
|
56
65
|
var _a, _b, _c;
|
|
57
66
|
setInternal(true);
|
|
58
67
|
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
59
68
|
if (props.Type === 'number') {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
var v = (value.length > 0 && value[0] === '.' ? ("0" + value) : value);
|
|
70
|
+
if ((0, helper_functions_1.IsNumber)(v) || (v === '' && allowNull)) {
|
|
71
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = v !== '' ? parseFloat(v) : null, _a)));
|
|
72
|
+
setHeldVal(v);
|
|
73
|
+
}
|
|
74
|
+
else if (v === '') {
|
|
75
|
+
setHeldVal(v);
|
|
63
76
|
}
|
|
64
77
|
}
|
|
65
78
|
else if (props.Type === 'integer') {
|
|
@@ -67,6 +80,9 @@ function Input(props) {
|
|
|
67
80
|
props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = value !== '' ? parseFloat(value) : null, _b)));
|
|
68
81
|
setHeldVal(value);
|
|
69
82
|
}
|
|
83
|
+
else if (value === '') {
|
|
84
|
+
setHeldVal(value);
|
|
85
|
+
}
|
|
70
86
|
}
|
|
71
87
|
else {
|
|
72
88
|
props.Setter(__assign(__assign({}, props.Record), (_c = {}, _c[props.Field] = value !== '' ? value : null, _c)));
|
|
@@ -76,7 +92,7 @@ function Input(props) {
|
|
|
76
92
|
var showLabel = props.Label !== "";
|
|
77
93
|
var showHelpIcon = props.Help !== undefined;
|
|
78
94
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
79
|
-
return (React.createElement("div", { className: "form-
|
|
95
|
+
return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.Style },
|
|
80
96
|
showHelpIcon || showLabel ?
|
|
81
97
|
React.createElement("label", null,
|
|
82
98
|
showLabel ? label : '',
|
|
@@ -84,7 +100,7 @@ function Input(props) {
|
|
|
84
100
|
showHelpIcon ?
|
|
85
101
|
React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
|
|
86
102
|
: null,
|
|
87
|
-
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 }),
|
|
103
|
+
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, onBlur: onBlur }),
|
|
88
104
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field + ' is a required field.' : props.Feedback)));
|
|
89
105
|
}
|
|
90
106
|
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.38",
|
|
4
4
|
"description": "React Form modules for gpa webapps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"typescript": "4.4.4"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
45
|
+
"@gpa-gemstone/helper-functions": "0.0.20",
|
|
46
46
|
"@types/react": "^17.0.14",
|
|
47
47
|
"@types/styled-components": "^5.1.11",
|
|
48
48
|
"react": "^18.2.0",
|