- {format(date, 'MMM', {locale})}
+ {format(date, 'MMM', {locale})}
);
})}
@@ -103,7 +136,7 @@ export default class Years extends Component {
const {height, selected, showMonths, theme, today, width} = this.props;
const currentYear = today.getFullYear();
const years = this.props.years.slice(0, this.props.years.length);
- const selectedYearIndex = years.indexOf(selected.getFullYear());
+ const selectedYearIndex = this.selectedYearIndex;
const rowHeight = showMonths ? 110 : 50;
const heights = years.map((val, index) => index === 0 || index === years.length - 1
? rowHeight + SPACING
@@ -142,8 +175,8 @@ export default class Years extends Component {
[styles.first]: index === 0,
[styles.last]: index === years.length - 1,
})}
- onClick={() => this.handleClick(new Date(selected).setYear(year))}
- title={`Set year to ${year}`}
+ onClick={() => !isRange(selected) && this.handleClick(new Date(selected).setYear(year))}
+ title={isRange(selected) ? '' : `Set year to ${year}`}
data-year={year}
style={Object.assign({}, style, {
color: (
diff --git a/src/index.js b/src/index.js
index b8fac0de..31ae48d4 100644
--- a/src/index.js
+++ b/src/index.js
@@ -6,8 +6,9 @@ export {default as Calendar} from './Calendar';
export {withDateSelection} from './Calendar/withDateSelection';
export {withKeyboardSupport} from './Calendar/withKeyboardSupport';
export {withMultipleDates, defaultMultipleDateInterpolation} from './Calendar/withMultipleDates';
-export {withRange, EVENT_TYPE} from './Calendar/withRange';
-
+export {withRange} from './Calendar/withRange';
+export {EVENT_TYPE} from './Calendar/Range';
+export {withMonthRange} from './Calendar/withMonthRange';
/*
* By default, Calendar is a controlled component.
* Export a sensible default for minimal setup
diff --git a/src/utils/index.js b/src/utils/index.js
index f7c3211f..80c88c08 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -6,6 +6,7 @@ import isBefore from 'date-fns/is_before';
import isSameDay from 'date-fns/is_same_day';
import endOfDay from 'date-fns/end_of_day';
import startOfDay from 'date-fns/start_of_day';
+import parse from 'date-fns/parse';
import {withPropsOnChange} from 'recompose';
export const keyCodes = {
@@ -186,4 +187,18 @@ export function range(start, stop, step = 1) {
return range;
};
+export function isRange(date) {
+ if (!date) {
+ return false;
+ }
+ const {start, end} = date;
+ return start !== undefined && end !== undefined;
+}
+
+export function getSortedDate(start, end) {
+ return isBefore(start, end)
+ ? {start, end}
+ : {start: end, end: start};
+}
+
export {default as animate} from './animate';