redux-date-range-picker-utils
Builders for redux actions, action-types and reducers for date-range-picker. All developer need – is to create a component
Installation
npm install --save redux-date-range-picker-utils
Examples
Action-types
;const DATE_PICKER = ;// =>// {// DATE_PICKER_TOGGLE_DROPDOWN: 'MY_DATE_PICKER_DATE_PICKER_TOGGLE_DROPDOWN',// DATE_PICKER_OPEN_DROPDOWN: 'MY_DATE_PICKER_DATE_PICKER_OPEN_DROPDOWN',// DATE_PICKER_CLOSE_DROPDOWN: 'MY_DATE_PICKER_DATE_PICKER_CLOSE_DROPDOWN',// DATE_PICKER_SHIFT_CURRENT_MONTH: 'MY_DATE_PICKER_DATE_PICKER_SHIFT_CURRENT_MONTH',// DATE_PICKER_SELECT_DATE: 'MY_DATE_PICKER_DATE_PICKER_SELECT_DATE',// };
Actions
;;const actions = ;// =>//{// myCustomPrefixToggleDropdown, or toggleDropdown// myCustomPrefixOpenDropdown, or openDropdown// myCustomPrefixCloseDropdown, or closeDropdown// myCustomPrefixShiftCurrentMonth, or shiftCurrentMonth// myCustomPrefixSelectDate or selectDate//};
Reducer
;;const reducer = ;;
State methods
; // Get prop => prop value; // BatchUpdate props with object => current chainable interface; // Toggle dropdown => current chainable interface; // Open dropdown => current chainable interface; // Close dropdown => current chainable interface; // Shift current month by +-shiftSize (year will change also) => current chainable interface; // Date, moment or string. Select a date => current chainable interface
State props
{
// Actual selected date
from: 'YYYY-MM-DD', // or null
to: 'YYYY-MM-DD', // or null
// Clicked, but not selected yet
selectedFrom: 'YYYY-MM-DD', // or null
selectedTo: 'YYYY-MM-DD', // or null
isDropdownOpen: Boolean,
currentMonth: +'M', // Index of current month
currentYear: +'YYYY' // Current year
}
Component
;;// ... Somewhere in high level component that connects to store .render() method <Component ...actions ...statepathtostate />
;; { return <InputBlock onClick= props/> <Calendar isVisible=props currentMonth=props onDateClick= props /> ;};