@terraware/web-components 2.14.1-rc.0 → 2.14.1-rc.1
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.
@@ -23,16 +23,16 @@ var _date = require("../../utils/date");
|
|
23
23
|
* export type DatePickerDateType = Exclude<DateType, Date> | null;
|
24
24
|
*/
|
25
25
|
|
26
|
-
var initializeDate = function initializeDate(value) {
|
26
|
+
var initializeDate = function initializeDate(value, timeZoneId) {
|
27
27
|
if (!value) {
|
28
28
|
return null;
|
29
29
|
}
|
30
|
-
var date = (0, _date.getDate)(value);
|
30
|
+
var date = (0, _date.getDate)(value, timeZoneId);
|
31
31
|
return date !== null && date !== void 0 && date.isValid ? date : null;
|
32
32
|
};
|
33
33
|
function DatePicker(props) {
|
34
34
|
var _props$locale;
|
35
|
-
var _useState = (0, _react.useState)(initializeDate(props.value)),
|
35
|
+
var _useState = (0, _react.useState)(initializeDate(props.value, props.defaultTimeZone)),
|
36
36
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
37
37
|
temporalValue = _useState2[0],
|
38
38
|
setTemporalValue = _useState2[1];
|
@@ -40,13 +40,13 @@ function DatePicker(props) {
|
|
40
40
|
_luxon.Settings.defaultZone = (0, _date.tz)(props.defaultTimeZone);
|
41
41
|
_react.default.useEffect(function () {
|
42
42
|
setTemporalValue(function (prev) {
|
43
|
-
if (props.value !== prev
|
44
|
-
return initializeDate(props.value);
|
43
|
+
if (props.value !== prev) {
|
44
|
+
return initializeDate(props.value, props.defaultTimeZone);
|
45
45
|
} else {
|
46
46
|
return prev;
|
47
47
|
}
|
48
48
|
});
|
49
|
-
}, [props.value]);
|
49
|
+
}, [props.defaultTimeZone, props.value]);
|
50
50
|
|
51
51
|
/**
|
52
52
|
* Note: the inputProps override for placeholder is needed
|
@@ -86,8 +86,8 @@ function DatePicker(props) {
|
|
86
86
|
}, props.label), /*#__PURE__*/_react.default.createElement(_xDatePickers.DesktopDatePicker, {
|
87
87
|
disabled: props.disabled,
|
88
88
|
inputFormat: "yyyy-MM-dd",
|
89
|
-
minDate: initializeDate(props.minDate) || undefined,
|
90
|
-
maxDate: initializeDate(props.maxDate) || undefined,
|
89
|
+
minDate: initializeDate(props.minDate, props.defaultTimeZone) || undefined,
|
90
|
+
maxDate: initializeDate(props.maxDate, props.defaultTimeZone) || undefined,
|
91
91
|
onChange: function onChange(newValue) {
|
92
92
|
setTemporalValue(newValue);
|
93
93
|
// TODO: remove onChange and make onDateChange required
|
@@ -98,6 +98,6 @@ function DatePicker(props) {
|
|
98
98
|
},
|
99
99
|
onError: props.onError,
|
100
100
|
renderInput: renderInput,
|
101
|
-
value: temporalValue
|
101
|
+
value: temporalValue
|
102
102
|
})));
|
103
103
|
}
|