Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.props.timeZone
);
return {
suggestedItems,
highlightedIndex: suggestedItems.length > 0 ? 0 : null,
};
}
if (changes.hasOwnProperty('isOpen')) {
return {
inputValue: changes.inputValue || prevState.inputValue,
startDate: changes.isOpen ? prevState.startDate : null,
// set time input value to time from value when menu is opened
timeString:
changes.isOpen && this.props.value !== ''
? formatTime(
this.props.value,
this.props.intl.locale,
this.props.timeZone
)
: '',
// ensure calendar always opens on selected item, or on
// current month when there is no selected item
calendarDate:
this.props.value === '' ? getToday() : this.props.value,
};
}
if (changes.hasOwnProperty('highlightedIndex')) {
return { highlightedIndex: changes.highlightedIndex };
}
return null;
this.setState(() => {
if (!parsedTime) return { timeString: '' };
let date = getToday(this.props.timeZone);
if (parsedTime) {
date = changeTime(
date,
this.props.timeZone,
parsedTime
);
}
return {
timeString: formatTime(
date,
this.props.intl.locale,
this.props.timeZone
),
};
});
},
prevState => {
if (activationTypes.includes(changes.type)) {
return {
startDate: changes.isOpen ? prevState.startDate : null,
inputValue: changes.inputValue || prevState.inputValue,
timeString: changes.selectedItem
? formatTime(
changes.selectedItem,
this.props.intl.locale,
this.props.timeZone
)
: prevState.timeString,
};
}
if (changes.hasOwnProperty('inputValue')) {
const suggestedItems = createSuggestedItems(
changes.inputValue,
this.props.timeZone
);
return {
suggestedItems,
highlightedIndex: suggestedItems.length > 0 ? 0 : null,