diff --git a/components/ui/datepicker/component.js b/components/ui/datepicker/component.js index 17ab3f6111..da8bb07e8c 100644 --- a/components/ui/datepicker/component.js +++ b/components/ui/datepicker/component.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { Portal } from 'react-portal'; import OutsideClickHandler from 'react-outside-click-handler'; import moment from 'moment'; +import Spinner from 'components/spinner'; import ReactDatePicker, { registerLocale, @@ -23,7 +24,14 @@ registerLocale('zh', zh); registerLocale('pt_BR', ptBR); registerLocale('id', id); -const Datepicker = ({ lang, selected, minDate, maxDate, ...props }) => { +const Datepicker = ({ + lang, + loading = false, + selected, + minDate, + maxDate, + ...props +}) => { const [open, setOpen] = useState(false); const inputEl = useRef(); @@ -37,6 +45,17 @@ const Datepicker = ({ lang, selected, minDate, maxDate, ...props }) => { )); + const LoadingInput = () => ( + + ); + const CalendarWrapper = ({ className, children }) => ( setOpen(false)}> {children} @@ -78,27 +97,31 @@ const Datepicker = ({ lang, selected, minDate, maxDate, ...props }) => { return (
- setOpen(false)} - customInput={} - calendarClassName="datepicker-calendar" - renderCustomHeader={(headerProps) => ( - - )} - popperContainer={PortalContainer} - locale={lang || 'en'} - calendarContainer={CalendarWrapper} - {...props} - selected={selectedUTC} - minDate={minDateUTC} - maxDate={maxDateUTC} - /> + {loading ? ( + + ) : ( + setOpen(false)} + customInput={} + calendarClassName="datepicker-calendar" + renderCustomHeader={(headerProps) => ( + + )} + popperContainer={PortalContainer} + locale={lang || 'en'} + calendarContainer={CalendarWrapper} + {...props} + selected={selectedUTC} + minDate={minDateUTC} + maxDate={maxDateUTC} + /> + )}
); }; @@ -112,6 +135,7 @@ Datepicker.propTypes = { selected: PropTypes.object, minDate: PropTypes.object, maxDate: PropTypes.object, + loading: PropTypes.bool, }; export default Datepicker; diff --git a/components/ui/datepicker/datepicker-header/styles.scss b/components/ui/datepicker/datepicker-header/styles.scss index 98378ead63..f37aeaaa8e 100644 --- a/components/ui/datepicker/datepicker-header/styles.scss +++ b/components/ui/datepicker/datepicker-header/styles.scss @@ -39,3 +39,12 @@ } } } + +.c-datepicker { + .datepicker-input { + &.loading { + width: 86px; + height: 1.3rem; + } + } +} diff --git a/components/widget/components/widget-header/components/widget-settings/component.jsx b/components/widget/components/widget-header/components/widget-settings/component.jsx index 58960b55a2..e08d77bffd 100644 --- a/components/widget/components/widget-header/components/widget-settings/component.jsx +++ b/components/widget/components/widget-header/components/widget-settings/component.jsx @@ -116,18 +116,21 @@ class WidgetSettings extends PureComponent { /> ); - case 'datepicker': + case 'datepicker': { + const loadingDatepicker = !startValue || !minDate || !maxDate; + return ( -
+
From propagateChange({ - [startKey]: moment(change).format('YYYY-MM-DD'), + [startKey]: moment(change).format("YYYY-MM-DD"), })} minDate={new Date(minDate)} maxDate={new Date(maxDate)} @@ -139,10 +142,11 @@ class WidgetSettings extends PureComponent { To propagateChange({ - [endKey]: moment(change).format('YYYY-MM-DD'), + [endKey]: moment(change).format("YYYY-MM-DD"), })} minDate={new Date(minDate)} maxDate={new Date(maxDate)} @@ -153,6 +157,7 @@ class WidgetSettings extends PureComponent {
); + } default: return ( options &&