Skip to content

Commit

Permalink
Merge pull request #43 from onefinestay/proptypes-and-linting
Browse files Browse the repository at this point in the history
general changes
  • Loading branch information
AndrewIngram committed Jun 16, 2015
2 parents 5b40a55 + 08c5dac commit d4cd13c
Show file tree
Hide file tree
Showing 34 changed files with 250 additions and 314 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"block-scoped-var": 0,
"brace-style": [0, "1tbs"],
"camelcase": 2,
"comma-dangle": [2, always-multiline],
"comma-spacing": 2,
"comma-style": 0,
"complexity": [0, 11],
Expand Down
62 changes: 21 additions & 41 deletions dist/DateRangePicker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';

Object.defineProperty(exports, '__esModule', {
value: true
});
Expand Down Expand Up @@ -87,8 +88,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 @@ -110,16 +110,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 @@ -128,8 +125,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 @@ -168,8 +164,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 Down Expand Up @@ -199,17 +194,15 @@ var DateRangePicker = _reactAddons2['default'].createClass({
if (!dateCursor.isSame(start)) {
actualStates.push({
state: defaultState,
range: (0, _momentRange2['default'])().range(dateCursor, start)
});
range: (0, _momentRange2['default'])().range(dateCursor, start) });
}
actualStates.push(s);
dateCursor = end;
});

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

// sanitize date states
return _immutable2['default'].List(actualStates).map(function (s) {
Expand All @@ -218,8 +211,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 @@ -286,17 +278,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 @@ -349,8 +339,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 Down Expand Up @@ -380,8 +369,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
if (highlightedDate) {
this.setState({
hideSelection: false,
highlightedDate: null
});
highlightedDate: null });
this.props.onSelect(highlightedDate, this.statesForDate(highlightedDate));
}
},
Expand All @@ -394,16 +382,14 @@ var DateRangePicker = _reactAddons2['default'].createClass({
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 @@ -428,8 +414,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
monthDate.subtract(1, 'months');
this.setState({
year: monthDate.year(),
month: monthDate.month()
});
month: monthDate.month() });
}
},

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

Expand All @@ -480,14 +464,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 Down Expand Up @@ -558,8 +540,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 All @@ -582,8 +563,7 @@ var DateRangePicker = _reactAddons2['default'].createClass({
_reactAddons2['default'].createElement(PaginationArrowComponent, { direction: 'next', onMouseEnter: this.moveForwardIfSelecting, onClick: this.moveForward, disabled: !this.canMoveForward() }),
showLegend ? _reactAddons2['default'].createElement(_Legend2['default'], { stateDefinitions: stateDefinitions, selectedLabel: selectedLabel }) : null
);
}
});
} });

exports['default'] = DateRangePicker;
module.exports = exports['default'];
10 changes: 4 additions & 6 deletions dist/Legend.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';

Object.defineProperty(exports, '__esModule', {
value: true
});
Expand All @@ -22,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 @@ -39,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 @@ -69,8 +68,7 @@ var Legend = _reactAddons2['default'].createClass({
),
items
);
}
});
} });

exports['default'] = Legend;
module.exports = exports['default'];
16 changes: 6 additions & 10 deletions dist/PaginationArrow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';

Object.defineProperty(exports, '__esModule', {
value: true
});
Expand Down Expand Up @@ -28,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 @@ -49,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'];
31 changes: 10 additions & 21 deletions dist/calendar/CalendarDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,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 @@ -102,17 +98,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 @@ -125,8 +119,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 @@ -212,12 +205,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 @@ -255,9 +246,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 d4cd13c

Please sign in to comment.