import { useRef } from 'react'; import { isNil } from 'ramda'; import DatePicker, { ReactDatePickerProps } from 'react-datepicker'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCalendarAlt as calendarIcon } from '@fortawesome/free-regular-svg-icons'; import classNames from 'classnames'; import './DateInput.scss'; export type DateInputProps = ReactDatePickerProps; const DateInput = (props: DateInputProps) => { const { className, isClearable, selected } = props; const showCalendarIcon = !isClearable || isNil(selected); const ref = useRef<{ input: HTMLInputElement }>(); return (
{showCalendarIcon && ( ref.current?.input.focus()} /> )}
); }; export default DateInput;