@pushwoosh/dumb-components 1.1.53 → 1.1.54
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { Color } from '@pushwoosh/kit-constants';
|
|
4
4
|
import { Horizontal, useClickAway, Vertical } from '@pushwoosh/kit-helpers';
|
|
@@ -21,8 +21,14 @@ export const CalendarDropdown = props => {
|
|
|
21
21
|
const [isShaking, setIsShaking] = useState(false);
|
|
22
22
|
const [popoverPosition, setPopoverPosition] = useState(null);
|
|
23
23
|
const [value, setValue] = useState(props.value ?? (isRangePicker ? [] : undefined));
|
|
24
|
-
const initialTimezone =
|
|
24
|
+
const initialTimezone = calendarProps.timezone || 'UTC';
|
|
25
25
|
const [timezone, setTimezone] = useState(initialTimezone);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setValue(props.value ?? (isRangePicker ? [] : undefined));
|
|
28
|
+
}, [props.value, isRangePicker]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setTimezone(calendarProps.timezone || 'UTC');
|
|
31
|
+
}, [calendarProps.timezone]);
|
|
26
32
|
const closePopover = () => {
|
|
27
33
|
setPopoverPosition(null);
|
|
28
34
|
setValue(props.value ?? (isRangePicker ? [] : undefined));
|
|
@@ -44,7 +50,7 @@ export const CalendarDropdown = props => {
|
|
|
44
50
|
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, val);
|
|
45
51
|
};
|
|
46
52
|
const presets = 'presets' in props ? props.presets : undefined;
|
|
47
|
-
const noValue = isRangePicker ? (value === null || value === void 0 ? void 0 : value.length) === 0 : !value;
|
|
53
|
+
const noValue = isRangePicker ? ((value === null || value === void 0 ? void 0 : value.length) ?? 0) === 0 : !value;
|
|
48
54
|
let buttonText;
|
|
49
55
|
if (noValue) {
|
|
50
56
|
buttonText = isRangePicker ? 'Select period' : 'Select date';
|