@gpa-gemstone/react-forms 1.1.73 → 1.1.75
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 +12 -8
- package/package.json +3 -3
package/lib/DatePicker.js
CHANGED
|
@@ -59,6 +59,7 @@ function DateTimePicker(props) {
|
|
|
59
59
|
var _f = React.useState(false), showOverlay = _f[0], setShowOverlay = _f[1];
|
|
60
60
|
var _g = React.useState(0), top = _g[0], setTop = _g[1];
|
|
61
61
|
var _h = React.useState(0), left = _h[0], setLeft = _h[1];
|
|
62
|
+
var allowNull = React.useMemo(function () { var _a; return (_a = props.AllowEmpty) !== null && _a !== void 0 ? _a : false; }, [props.AllowEmpty]);
|
|
62
63
|
React.useEffect(function () {
|
|
63
64
|
setGuid((0, helper_functions_1.CreateGuid)());
|
|
64
65
|
}, []);
|
|
@@ -90,12 +91,11 @@ function DateTimePicker(props) {
|
|
|
90
91
|
}, [props.Record, props.Field, boxFormat, showOverlay]);
|
|
91
92
|
function setPickerAndRecord(arg) {
|
|
92
93
|
var _a, _b;
|
|
93
|
-
var _c;
|
|
94
94
|
setPickerRecord(arg);
|
|
95
|
-
if (
|
|
95
|
+
if (allowNull && arg === undefined && props.Record[props.Field] !== null)
|
|
96
96
|
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = null, _a)));
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
else if ((arg != undefined && validateDate(arg)) &&
|
|
98
|
+
props.Record[props.Field].toString() !== arg.format(recordFormat))
|
|
99
99
|
props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = arg.format(recordFormat), _b)));
|
|
100
100
|
}
|
|
101
101
|
// Handle clicks outside the component.
|
|
@@ -154,7 +154,11 @@ function DateTimePicker(props) {
|
|
|
154
154
|
}
|
|
155
155
|
function validateDate(date) {
|
|
156
156
|
var minStartDate = props.MinDate != null ? props.MinDate.startOf('day') : moment("1753-01-01", "YYYY-MM-DD").startOf('day');
|
|
157
|
-
if (
|
|
157
|
+
if (allowNull && date == null) {
|
|
158
|
+
setFeedbackMessage("");
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
else if (date == null || !date.isValid()) {
|
|
158
162
|
setFeedbackMessage("Please enter a valid date.");
|
|
159
163
|
return false;
|
|
160
164
|
}
|
|
@@ -179,13 +183,13 @@ function DateTimePicker(props) {
|
|
|
179
183
|
};
|
|
180
184
|
function valueChange(value) {
|
|
181
185
|
var _a, _b;
|
|
182
|
-
var
|
|
183
|
-
var
|
|
186
|
+
var date = (value === '') ? undefined : moment(value, boxFormat);
|
|
187
|
+
var validDate = validateDate(date);
|
|
184
188
|
if (allowNull && value === '') {
|
|
185
189
|
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = null, _a)));
|
|
186
190
|
setPickerAndRecord(undefined);
|
|
187
191
|
}
|
|
188
|
-
else if (
|
|
192
|
+
else if (validDate) {
|
|
189
193
|
props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = moment(value, boxFormat).format(recordFormat), _b)));
|
|
190
194
|
setPickerAndRecord(moment(value, boxFormat));
|
|
191
195
|
}
|
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.75",
|
|
4
4
|
"description": "React Form modules for gpa webapps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typescript": "5.5.3"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@gpa-gemstone/application-typings": "0.0.
|
|
49
|
-
"@gpa-gemstone/gpa-symbols": "0.0.
|
|
48
|
+
"@gpa-gemstone/application-typings": "0.0.78",
|
|
49
|
+
"@gpa-gemstone/gpa-symbols": "0.0.43",
|
|
50
50
|
"@gpa-gemstone/helper-functions": "0.0.35",
|
|
51
51
|
"@types/react": "^17.0.14",
|
|
52
52
|
"@types/styled-components": "^5.1.11",
|