@activecollab/components
Version:
ActiveCollab Components
34 lines • 1.1 kB
JavaScript
import React, { useCallback } from "react";
import { addMonths } from "date-fns";
import { NavBarElement } from "../Pickers/NavBarElement";
export const CustomNavBarElement = _ref => {
let {
month,
showMonthPicker = false,
onChangeDirection,
onMonthChange
} = _ref;
const nextMonth = showMonthPicker ? addMonths(month, 12) : addMonths(month, 1);
const previousMonth = showMonthPicker ? addMonths(month, -12) : addMonths(month, -1);
const onNextClick = useCallback(() => {
if (onChangeDirection) {
onChangeDirection(true);
}
if (onMonthChange) {
onMonthChange(nextMonth);
}
}, [nextMonth, onChangeDirection, onMonthChange]);
const onPreviousClick = useCallback(() => {
if (onChangeDirection) {
onChangeDirection(false);
}
if (onMonthChange) {
onMonthChange(previousMonth);
}
}, [onChangeDirection, onMonthChange, previousMonth]);
return /*#__PURE__*/React.createElement(NavBarElement, {
onNextClick: onNextClick,
onPreviousClick: onPreviousClick
});
};
//# sourceMappingURL=CustomNavBarElement.js.map