Skip to content

Commit

Permalink
rebuild and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewIngram committed Jul 8, 2015
1 parent aaf57a2 commit 024d733
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 136 deletions.
69 changes: 24 additions & 45 deletions dist/DateRangePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
singleDateRange: _reactAddons2['default'].PropTypes.bool,
showLegend: _reactAddons2['default'].PropTypes.bool,
stateDefinitions: _reactAddons2['default'].PropTypes.object,
value: _utilsCustomPropTypes2['default'].momentOrMomentRange
},
value: _utilsCustomPropTypes2['default'].momentOrMomentRange },

getDefaultProps: function getDefaultProps() {
var date = new Date();
Expand All @@ -112,16 +111,13 @@ var DateRangePicker = _reactAddons2['default'].createClass({
'__default': {
color: null,
selectable: true,
label: null
}
},
label: null } },
selectedLabel: 'Your selected dates',
defaultState: '__default',
dateStates: [],
showLegend: false,
onSelect: noop,
paginationArrowComponent: _PaginationArrow2['default']
};
paginationArrowComponent: _PaginationArrow2['default'] };
},

componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
Expand All @@ -130,8 +126,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({

this.setState({
dateStates: this.state.dateStates && _immutable2['default'].is(this.state.dateStates, nextDateStates) ? this.state.dateStates : nextDateStates,
enabledRange: this.state.enabledRange && _immutable2['default'].is(this.state.enabledRange, nextEnabledRange) ? this.state.enabledRange : nextEnabledRange
});
enabledRange: this.state.enabledRange && _immutable2['default'].is(this.state.enabledRange, nextEnabledRange) ? this.state.enabledRange : nextEnabledRange });
},

getInitialState: function getInitialState() {
Expand Down Expand Up @@ -170,8 +165,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
highlightRange: null,
hideSelection: false,
enabledRange: this.getEnabledRange(this.props),
dateStates: this.getDateStates(this.props)
};
dateStates: this.getDateStates(this.props) };
},

getEnabledRange: function getEnabledRange(props) {
Expand All @@ -198,20 +192,18 @@ var DateRangePicker = _reactAddons2['default'].createClass({
var start = r.start.startOf('day');
var end = r.end.startOf('day');

if (!dateCursor.isSame(start)) {
if (!dateCursor.isSame(start, 'day')) {
actualStates.push({
state: defaultState,
range: _momentRange2['default'].range(dateCursor, start)
});
range: _momentRange2['default'].range(dateCursor, start) });
}
actualStates.push(s);
dateCursor = end;
});

actualStates.push({
state: defaultState,
range: _momentRange2['default'].range(dateCursor, maxDate)
});
range: _momentRange2['default'].range(dateCursor, maxDate) });

// sanitize date states
return _immutable2['default'].List(actualStates).map(function (s) {
Expand All @@ -220,8 +212,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
range: s.range,
state: s.state,
selectable: def.get('selectable', true),
color: def.get('color')
});
color: def.get('color') });
});
},

Expand Down Expand Up @@ -288,17 +279,15 @@ var DateRangePicker = _reactAddons2['default'].createClass({
highlightRange: function highlightRange(range) {
this.setState({
highlightedRange: range,
highlightedDate: null
});
highlightedDate: null });
if (typeof this.props.onHighlightRange === 'function') {
this.props.onHighlightRange(range, this.statesForRange(range));
}
},

onUnHighlightDate: function onUnHighlightDate() {
this.setState({
highlightedDate: null
});
highlightedDate: null });
},

onSelectDate: function onSelectDate(date) {
Expand Down Expand Up @@ -351,8 +340,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
startRangeSelection: function startRangeSelection(date) {
this.setState({
hideSelection: true,
selectedStartDate: date
});
selectedStartDate: date });
if (typeof this.props.onSelectStart === 'function') {
this.props.onSelectStart((0, _momentRange2['default'])(date));
}
Expand All @@ -367,7 +355,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
},

statesForRange: function statesForRange(range) {
if (range.start.isSame(range.end)) {
if (range.start.isSame(range.end, 'day')) {
return this.statesForDate(range.start);
}
return this.state.dateStates.filter(function (d) {
Expand All @@ -382,30 +370,27 @@ var DateRangePicker = _reactAddons2['default'].createClass({
if (highlightedDate) {
this.setState({
hideSelection: false,
highlightedDate: null
});
highlightedDate: null });
this.props.onSelect(highlightedDate, this.statesForDate(highlightedDate));
}
},

completeRangeSelection: function completeRangeSelection() {
var range = this.state.highlightedRange;

if (range && (!range.start.isSame(range.end) || this.props.singleDateRange)) {
if (range && (!range.start.isSame(range.end, 'day') || this.props.singleDateRange)) {
this.setState({
selectedStartDate: null,
highlightedRange: null,
highlightedDate: null,
hideSelection: false
});
hideSelection: false });
this.props.onSelect(range, this.statesForRange(range));
}
},

highlightDate: function highlightDate(date) {
this.setState({
highlightedDate: date
});
highlightedDate: date });
if (typeof this.props.onHighlightDate === 'function') {
this.props.onHighlightDate(date, this.statesForDate(date));
}
Expand All @@ -430,8 +415,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
monthDate.subtract(1, 'months');
this.setState({
year: monthDate.year(),
month: monthDate.month()
});
month: monthDate.month() });
}
},

Expand All @@ -456,8 +440,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
monthDate.add(1, 'months');
this.setState({
year: monthDate.year(),
month: monthDate.month()
});
month: monthDate.month() });
}
},

Expand All @@ -482,14 +465,12 @@ var DateRangePicker = _reactAddons2['default'].createClass({

this.setState({
year: year,
month: month
});
month: month });
},

changeMonth: function changeMonth(date) {
this.setState({
month: date
});
month: date });
},

renderCalendar: function renderCalendar(index) {
Expand All @@ -510,7 +491,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
var monthDate = this.getMonthDate();
var year = monthDate.year();
var month = monthDate.month();
var key = index + '-' + year + '-' + month;
var key = '' + index + '-' + year + '-' + month;
var props = undefined;

monthDate.add(index, 'months');
Expand Down Expand Up @@ -560,8 +541,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
onHighlightDate: this.onHighlightDate,
onUnHighlightDate: this.onUnHighlightDate,
dateRangesForDate: this.dateRangesForDate,
dateComponent: _calendarCalendarDate2['default']
};
dateComponent: _calendarCalendarDate2['default'] };

return _reactAddons2['default'].createElement(_calendarCalendarMonth2['default'], props);
},
Expand Down Expand Up @@ -590,8 +570,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
) : null,
showLegend ? _reactAddons2['default'].createElement(_Legend2['default'], { stateDefinitions: stateDefinitions, selectedLabel: selectedLabel }) : null
);
}
});
} });

exports['default'] = DateRangePicker;
module.exports = exports['default'];
9 changes: 3 additions & 6 deletions dist/Legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ var Legend = _reactAddons2['default'].createClass({

propTypes: {
selectedLabel: _reactAddons2['default'].PropTypes.string.isRequired,
stateDefinitions: _reactAddons2['default'].PropTypes.object.isRequired
},
stateDefinitions: _reactAddons2['default'].PropTypes.object.isRequired },

render: function render() {
var _props = this.props;
Expand All @@ -40,8 +39,7 @@ var Legend = _reactAddons2['default'].createClass({
def = stateDefinitions[name];
if (def.label && def.color) {
style = {
backgroundColor: def.color
};
backgroundColor: def.color };
items.push(_reactAddons2['default'].createElement(
'li',
{ className: this.cx({ element: 'LegendItem' }), key: name },
Expand Down Expand Up @@ -70,8 +68,7 @@ var Legend = _reactAddons2['default'].createClass({
),
items
);
}
});
} });

exports['default'] = Legend;
module.exports = exports['default'];
15 changes: 5 additions & 10 deletions dist/PaginationArrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ var PaginationArrow = _reactAddons2['default'].createClass({

propTypes: {
disabled: _reactAddons2['default'].PropTypes.bool,
direction: _reactAddons2['default'].PropTypes.oneOf(['next', 'previous'])
},
direction: _reactAddons2['default'].PropTypes.oneOf(['next', 'previous']) },

getDefaultProps: function getDefaultProps() {
return {
disabled: false
};
disabled: false };
},

render: function render() {
Expand All @@ -50,22 +48,19 @@ var PaginationArrow = _reactAddons2['default'].createClass({

var elementOpts = {
modifiers: modifiers,
states: states
};
states: states };

var iconOpts = {
element: 'PaginationArrowIcon',
modifiers: modifiers,
states: states
};
states: states };

return _reactAddons2['default'].createElement(
'div',
_extends({ className: this.cx(elementOpts) }, props),
_reactAddons2['default'].createElement('div', { className: this.cx(iconOpts) })
);
}
});
} });

exports['default'] = PaginationArrow;
module.exports = exports['default'];
30 changes: 10 additions & 20 deletions dist/calendar/CalendarDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,26 @@ var CalendarDate = _reactAddons2['default'].createClass({
dateRangesForDate: _reactAddons2['default'].PropTypes.func,
onHighlightDate: _reactAddons2['default'].PropTypes.func,
onUnHighlightDate: _reactAddons2['default'].PropTypes.func,
onSelectDate: _reactAddons2['default'].PropTypes.func
},
onSelectDate: _reactAddons2['default'].PropTypes.func },

getInitialState: function getInitialState() {
return {
mouseDown: false
};
mouseDown: false };
},

mouseUp: function mouseUp() {
this.props.onSelectDate(this.props.date);

if (this.state.mouseDown) {
this.setState({
mouseDown: false
});
mouseDown: false });
}
document.removeEventListener('mouseup', this.mouseUp);
},

mouseDown: function mouseDown() {
this.setState({
mouseDown: true
});
mouseDown: true });
document.addEventListener('mouseup', this.mouseUp);
},

Expand All @@ -103,17 +99,15 @@ var CalendarDate = _reactAddons2['default'].createClass({

if (this.state.mouseDown) {
this.setState({
mouseDown: false
});
mouseDown: false });
}
document.removeEventListener('touchend', this.touchEnd);
},

touchStart: function touchStart(event) {
event.preventDefault();
this.setState({
mouseDown: true
});
mouseDown: true });
document.addEventListener('touchend', this.touchEnd);
},

Expand All @@ -126,8 +120,7 @@ var CalendarDate = _reactAddons2['default'].createClass({
this.props.onSelectDate(this.props.date);

this.setState({
mouseDown: false
});
mouseDown: false });
}
this.props.onUnHighlightDate(this.props.date);
},
Expand Down Expand Up @@ -214,12 +207,10 @@ var CalendarDate = _reactAddons2['default'].createClass({
if (color) {

style = {
backgroundColor: color
};
backgroundColor: color };
cellStyle = {
borderLeftColor: (0, _utilsLightenDarkenColor2['default'])(color, -10),
borderRightColor: (0, _utilsLightenDarkenColor2['default'])(color, -10)
};
borderRightColor: (0, _utilsLightenDarkenColor2['default'])(color, -10) };
}
} else {
amColor = states.getIn([0, 'color']);
Expand Down Expand Up @@ -257,8 +248,7 @@ var CalendarDate = _reactAddons2['default'].createClass({
selectionModifier ? _reactAddons2['default'].createElement(_CalendarSelection2['default'], { modifier: selectionModifier, pending: pending }) : null,
highlightModifier ? _reactAddons2['default'].createElement(_CalendarHighlight2['default'], { modifier: highlightModifier }) : null
);
}
});
} });

exports['default'] = CalendarDate;
module.exports = exports['default'];
Loading

0 comments on commit 024d733

Please sign in to comment.