@steroidsjs/core 2.2.73 → 2.2.74
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/package.json +1 -1
- package/ui/form/DateField/useDateInputState.d.ts +9 -1
- package/ui/form/DateField/useDateInputState.js +3 -3
- package/ui/form/DateField/useDateTime.d.ts +1 -1
- package/ui/form/DateField/useDateTime.js +12 -4
- package/ui/form/DateTimeField/DateTimeField.js +6 -4
- package/ui/form/TimeField/TimeField.js +4 -2
package/package.json
CHANGED
|
@@ -36,9 +36,17 @@ export interface IDateInputStateInput extends IFieldWrapperInputProps {
|
|
|
36
36
|
*/
|
|
37
37
|
valueFormat?: string;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Приводить значение даты к часовому поясу UTC
|
|
40
|
+
* (пример: с бэкенда приходит дата в какой-либо временной зоне (не UTC), но нужно отбразить ее
|
|
41
|
+
* в часовом поясе UTC. В этом случае dateInUTC = false, а useUTC = true)
|
|
40
42
|
*/
|
|
41
43
|
useUTC?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Задано ли значение даты в часовом поясе UTC
|
|
46
|
+
* (пример: с бэкенда приходит дата в UTC, но нужно отбразить ее в локальном времени.
|
|
47
|
+
* В этом случае dateInUTC = true, а useUTC = false)
|
|
48
|
+
*/
|
|
49
|
+
dateInUTC?: boolean;
|
|
42
50
|
}
|
|
43
51
|
export interface IDateInputStateOutput {
|
|
44
52
|
/**
|
|
@@ -23,7 +23,7 @@ function useDateInputState(props) {
|
|
|
23
23
|
var propsDisplayValue = react_1.useMemo(function () { return calendar_1.convertDate(props.input.value, [
|
|
24
24
|
props.valueFormat,
|
|
25
25
|
props.displayFormat,
|
|
26
|
-
], props.displayFormat,
|
|
26
|
+
], props.displayFormat, props.useUTC, props.dateInUTC) || ''; }, [props.displayFormat, props.input.value, props.valueFormat]);
|
|
27
27
|
// Display value state
|
|
28
28
|
var _a = react_1.useState(propsDisplayValue), displayValue = _a[0], setDisplayValue = _a[1];
|
|
29
29
|
// Update display value on update props input value
|
|
@@ -41,7 +41,7 @@ function useDateInputState(props) {
|
|
|
41
41
|
var onDisplayValueChange = react_1.useCallback(function (value) {
|
|
42
42
|
value = value.replace(/[^0-9:. ]/g, '');
|
|
43
43
|
setDisplayValue(value);
|
|
44
|
-
var parsedValue = calendar_1.convertDate(value, props.displayFormat, props.valueFormat, props.useUTC);
|
|
44
|
+
var parsedValue = calendar_1.convertDate(value, props.displayFormat, props.valueFormat, props.useUTC, props.dateInUTC);
|
|
45
45
|
var newValue = parsedValue || !value ? parsedValue || null : false;
|
|
46
46
|
if (newValue && newValue !== props.input.value) {
|
|
47
47
|
props.input.onChange.call(null, newValue);
|
|
@@ -49,7 +49,7 @@ function useDateInputState(props) {
|
|
|
49
49
|
props.onChange.call(null, value);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
}, [props.displayFormat, props.input.onChange, props.input.value, props.onChange, props.valueFormat, props.useUTC]);
|
|
52
|
+
}, [props.displayFormat, props.input.onChange, props.input.value, props.onChange, props.valueFormat, props.useUTC, props.dateInUTC]);
|
|
53
53
|
// Dropdown opened state
|
|
54
54
|
var _b = react_1.useState(false), isOpened = _b[0], setIsOpened = _b[1];
|
|
55
55
|
// Focus/blur handlers
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDateInputStateInput } from '../../form/DateField/useDateInputState';
|
|
2
|
-
interface IUseDateTimeProps extends Pick<IDateInputStateInput, 'displayFormat' | 'valueFormat' | 'input' | 'useUTC'> {
|
|
2
|
+
interface IUseDateTimeProps extends Pick<IDateInputStateInput, 'displayFormat' | 'valueFormat' | 'input' | 'useUTC' | 'dateInUTC'> {
|
|
3
3
|
dateTimeSeparator: string;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
@@ -13,16 +13,24 @@ var calendar_1 = require("../../../utils/calendar");
|
|
|
13
13
|
*/
|
|
14
14
|
function useDateTime(props) {
|
|
15
15
|
var _a = props.valueFormat.split(props.dateTimeSeparator), dateValueFormat = _a[0], timeValueFormat = _a[1];
|
|
16
|
-
var dateValue = react_1.useMemo(function () { return calendar_1.convertDate(props.input.value, [props.valueFormat, props.displayFormat], dateValueFormat,
|
|
17
|
-
var timeValue = react_1.useMemo(function () { return calendar_1.convertDate(props.input.value, [props.displayFormat, props.valueFormat], timeValueFormat,
|
|
16
|
+
var dateValue = react_1.useMemo(function () { return calendar_1.convertDate(props.input.value, [props.valueFormat, props.displayFormat], dateValueFormat, props.useUTC, props.dateInUTC); }, [dateValueFormat, props.displayFormat, props.input.value, props.valueFormat]);
|
|
17
|
+
var timeValue = react_1.useMemo(function () { return calendar_1.convertDate(props.input.value, [props.displayFormat, props.valueFormat], timeValueFormat, props.useUTC, props.dateInUTC); }, [props.displayFormat, props.input.value, props.valueFormat, timeValueFormat]);
|
|
18
18
|
// Handler for calendar and time picker changes
|
|
19
19
|
var onDateSelect = react_1.useCallback(function (date) {
|
|
20
20
|
var result = date + props.dateTimeSeparator + (timeValue || '00:00');
|
|
21
|
-
props.input.onChange.call(null, calendar_1.convertDate(result, [props.valueFormat, 'YYYY-MM-DD HH:mm'], props.valueFormat,
|
|
21
|
+
props.input.onChange.call(null, calendar_1.convertDate(result, [props.valueFormat, 'YYYY-MM-DD HH:mm'], props.valueFormat,
|
|
22
|
+
// converting to UTC here depends on whether the date is stored in UTC
|
|
23
|
+
props.dateInUTC,
|
|
24
|
+
// whether the date provided from onSelect is in UTC or not depends on this flag
|
|
25
|
+
props.useUTC));
|
|
22
26
|
}, [props.dateTimeSeparator, props.input.onChange, props.valueFormat, timeValue]);
|
|
23
27
|
var onTimeSelect = react_1.useCallback(function (time) {
|
|
24
28
|
var result = (dateValue || moment_1["default"]().format(dateValueFormat)) + props.dateTimeSeparator + time;
|
|
25
|
-
props.input.onChange.call(null, calendar_1.convertDate(result, [props.valueFormat, 'YYYY-MM-DD HH:mm'], props.valueFormat,
|
|
29
|
+
props.input.onChange.call(null, calendar_1.convertDate(result, [props.valueFormat, 'YYYY-MM-DD HH:mm'], props.valueFormat,
|
|
30
|
+
// converting to UTC here depends on whether the date is stored in UTC
|
|
31
|
+
props.dateInUTC,
|
|
32
|
+
// whether the date provided from onSelect is in UTC or not depends on this flag
|
|
33
|
+
props.useUTC));
|
|
26
34
|
}, [dateValue, dateValueFormat, props.dateTimeSeparator, props.input.onChange, props.valueFormat]);
|
|
27
35
|
return {
|
|
28
36
|
dateValue: dateValue,
|
|
@@ -35,15 +35,16 @@ function DateTimeField(props) {
|
|
|
35
35
|
placeholder: props.placeholder,
|
|
36
36
|
valueFormat: props.valueFormat,
|
|
37
37
|
displayFormat: props.displayFormat,
|
|
38
|
-
useUTC: props.useUTC
|
|
38
|
+
useUTC: props.useUTC,
|
|
39
|
+
dateInUTC: props.dateInUTC
|
|
39
40
|
}), onClear = _a.onClear, onClose = _a.onClose, isOpened = _a.isOpened, inputProps = _a.inputProps;
|
|
40
|
-
console.log("DATETIME INPUT", inputProps);
|
|
41
41
|
var _b = useDateTime_1["default"]({
|
|
42
42
|
displayFormat: props.displayFormat,
|
|
43
43
|
dateTimeSeparator: DATE_TIME_SEPARATOR,
|
|
44
44
|
input: props.input,
|
|
45
45
|
valueFormat: props.valueFormat,
|
|
46
|
-
useUTC: props.useUTC
|
|
46
|
+
useUTC: props.useUTC,
|
|
47
|
+
dateInUTC: props.dateInUTC
|
|
47
48
|
}), dateValueFormat = _b.dateValueFormat, dateValue = _b.dateValue, timeValue = _b.timeValue, onDateSelect = _b.onDateSelect, onTimeSelect = _b.onTimeSelect;
|
|
48
49
|
// Calendar props
|
|
49
50
|
var calendarProps = react_1.useMemo(function () { return ({
|
|
@@ -72,6 +73,7 @@ DateTimeField.defaultProps = {
|
|
|
72
73
|
className: '',
|
|
73
74
|
displayFormat: 'DD.MM.YYYY' + DATE_TIME_SEPARATOR + 'HH:mm',
|
|
74
75
|
valueFormat: 'YYYY-MM-DD' + DATE_TIME_SEPARATOR + 'HH:mm',
|
|
75
|
-
useUTC: true
|
|
76
|
+
useUTC: true,
|
|
77
|
+
dateInUTC: false
|
|
76
78
|
};
|
|
77
79
|
exports["default"] = fieldWrapper_1["default"]('DateTimeField', DateTimeField);
|
|
@@ -29,7 +29,8 @@ function TimeField(props) {
|
|
|
29
29
|
placeholder: props.placeholder,
|
|
30
30
|
valueFormat: props.valueFormat,
|
|
31
31
|
displayFormat: props.displayFormat,
|
|
32
|
-
useUTC: props.useUTC
|
|
32
|
+
useUTC: props.useUTC,
|
|
33
|
+
dateInUTC: props.dateInUTC
|
|
33
34
|
}), onNow = _a.onNow, onClear = _a.onClear, onClose = _a.onClose, isOpened = _a.isOpened, inputProps = _a.inputProps;
|
|
34
35
|
var timePanelViewProps = react_1.useMemo(function () { return (__assign({ onNow: onNow,
|
|
35
36
|
onClose: onClose, value: inputProps.value, onSelect: inputProps.onChange }, props.timePanelViewProps)); }, [inputProps.onChange, inputProps.value, onClose, onNow, props.timePanelViewProps]);
|
|
@@ -49,6 +50,7 @@ TimeField.defaultProps = {
|
|
|
49
50
|
showRemove: true,
|
|
50
51
|
type: 'text',
|
|
51
52
|
valueFormat: 'HH:mm',
|
|
52
|
-
useUTC: true
|
|
53
|
+
useUTC: true,
|
|
54
|
+
dateInUTC: false
|
|
53
55
|
};
|
|
54
56
|
exports["default"] = fieldWrapper_1["default"]('TimeField', TimeField);
|