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