import React from 'react'; import { isNil } from 'ramda'; import DatePicker from 'react-datepicker'; import FontAwesomeIcon from '@fortawesome/react-fontawesome'; import calendarIcon from '@fortawesome/fontawesome-free-regular/faCalendarAlt'; import * as PropTypes from 'prop-types'; import './DateInput.scss'; const propTypes = { className: PropTypes.string, isClearable: PropTypes.bool, selected: PropTypes.oneOfType([ PropTypes.string, PropTypes.object ]), ref: PropTypes.object, }; const DateInput = (props) => { const { className, isClearable, selected, ref = React.createRef() } = props; const showCalendarIcon = !isClearable || isNil(selected); return (
{showCalendarIcon && ( ref.current.input.focus()} /> )}
); }; DateInput.propTypes = propTypes; export default DateInput;