Skip to content

Commit

Permalink
Merge pull request #276 from arqex/master
Browse files Browse the repository at this point in the history
Update react-onclickoutside dependency and create the CalendarContainer
  • Loading branch information
arqex authored Feb 27, 2017
2 parents 9eae924 + bad3cdf commit 8b74e5a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 120 deletions.
19 changes: 3 additions & 16 deletions DateTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,11 @@
var assign = require('object-assign'),
moment = require('moment'),
React = require('react'),
DaysView = require('./src/DaysView'),
MonthsView = require('./src/MonthsView'),
YearsView = require('./src/YearsView'),
TimeView = require('./src/TimeView')
CalendarContainer = require('./src/CalendarContainer')
;

var TYPES = React.PropTypes;
var Datetime = React.createClass({
mixins: [
require('./src/onClickOutside')
],
viewComponents: {
days: DaysView,
months: MonthsView,
years: YearsView,
time: TimeView
},
propTypes: {
// value: TYPES.object | TYPES.string,
// defaultValue: TYPES.object | TYPES.string,
Expand Down Expand Up @@ -411,8 +399,7 @@ var Datetime = React.createClass({
},

render: function() {
var Component = this.viewComponents[ this.state.currentView ],
DOM = React.DOM,
var DOM = React.DOM,
className = 'rdt' + (this.props.className ?
( Array.isArray( this.props.className ) ?
' ' + this.props.className.join( ' ' ) : ' ' + this.props.className) : ''),
Expand All @@ -439,7 +426,7 @@ var Datetime = React.createClass({
return DOM.div({className: className}, children.concat(
DOM.div(
{ key: 'dt', className: 'rdtPicker' },
React.createElement( Component, this.getComponentProps())
React.createElement( CalendarContainer, {view: this.state.currentView, viewProps: this.getComponentProps(), onClickOutside: this.handleClickOutside })
)
));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
"dependencies": {
"object-assign": "^3.0.0",
"react-onclickoutside": "^4.1.0"
"react-onclickoutside": "^5.9.0"
},
"pre-commit": [
"lint",
Expand Down
26 changes: 26 additions & 0 deletions src/CalendarContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var React = require('react'),
DaysView = require('./DaysView'),
MonthsView = require('./MonthsView'),
YearsView = require('./YearsView'),
TimeView = require('./TimeView'),
onClickOutside = require('react-onclickoutside')
;

var CalendarContainer = onClickOutside( React.createClass({
viewComponents: {
days: DaysView,
months: MonthsView,
years: YearsView,
time: TimeView
},

render: function() {
return React.createElement( this.viewComponents[ this.props.view ], this.props.viewProps );
},

handleClickOutside: function() {
this.props.onClickOutside();
}
}));

module.exports = CalendarContainer;
103 changes: 0 additions & 103 deletions src/onClickOutside.js

This file was deleted.

0 comments on commit 8b74e5a

Please sign in to comment.