useDateRangeInput
useDateRangeInput is a hook which will provide the props required to compose together a Calendar with a pair ofinput components of your choice.
Like with useDateInput you can use an HTML input, or an Input or Formfield from your favourite UI framework, or even your own component.
A simple example of use is
const {Calendar,CalendarProvider,getCalendarProviderProps,getStartDateProps,getEndDateProps,getPopperProps,} = useDateRangeInput();
Calendaris the calendar component.CalendarProvideris the context which wires all the UI components together, you can use it in your own components to manage stategetCalendarProviderPropsis a callback which provides the props forCalendarProvidergetStartDatePropsis a callback which provides the props for your start date, Input UI Element.getEndDatePropsis a callback which provides the props for your end date, Input UI Element.getPopperPropsis an callback which provides the props for any Popper UI Element.
Popper's are a portal which are only needed if you are open the Calendar from another component.
ie. an Input when clicked display the Calendar in a portal, which overlays the rest of the page.
When your input components and Calendar are composed together by useDateRangeInput it should look like this
Example
Actions
useDateRangeInput provides an imperative API for the controlled state, use-case.
Pass a ref to useDateRangeInput and it will be assigned an impertive API of state and helpers.
const {Calendar,CalendarProvider,getCalendarProviderProps,getInputProps,getPopperProps,} = useDateInput({actions});
The imperative API takes the form.
actions.current = {createDate,dispatch,mouseClickOutside,navigateNext,navigatePrevious,selectDate,setAnimating,setEnableKeyboardNavigation,setKeyboardCursor,setMouseCursor,setEndDate,setStartDate,setOpen,setKeyPress,setVisibleFromDate}