react-day-picker
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -66,6 +66,3 @@ "use strict"; | ||
handleDayFocus: function (day, modifiers, e) { | ||
var _this = this; | ||
this.setState({ focus: day.dayOfYear() }, function () { | ||
_this.props.onDayFocus && _this.props.onDayFocus(e); | ||
}); | ||
this.setState({ focus: day.dayOfYear() }); | ||
}, | ||
@@ -78,18 +75,17 @@ | ||
handleNextTouchTap: function (e) { | ||
var nextMonth = this.state.month.add(1, "month"); | ||
this.setState({ month: nextMonth }); | ||
this.setState({ month: this.state.month.add(1, "month") }); | ||
}, | ||
handlePrevTouchTap: function (e) { | ||
var prevMonth = this.state.month.subtract(1, "month"); | ||
this.setState({ month: prevMonth }); | ||
this.setState({ month: this.state.month.subtract(1, "month") }); | ||
}, | ||
getDayModifiers: function (day) { | ||
getModifiersForDay: function (day) { | ||
var dayModifiers = []; | ||
if (!this.props.modifiers) return dayModifiers; | ||
var modifiers = this.props.modifiers; | ||
for (var modifier in modifiers) { | ||
var func = modifiers[modifier]; | ||
if (func(day)) dayModifiers.push(modifier); | ||
if (this.props.modifiers) { | ||
var modifiers = this.props.modifiers; | ||
for (var modifier in modifiers) { | ||
var func = modifiers[modifier]; | ||
if (func(day)) dayModifiers.push(modifier); | ||
} | ||
} | ||
@@ -126,3 +122,3 @@ return dayModifiers; | ||
renderWeeks: function () { | ||
var _this2 = this; | ||
var _this = this; | ||
return weeks(this.state.month).map(function (week, i) { | ||
@@ -133,3 +129,3 @@ return React.createElement("div", { | ||
style: rowStyle | ||
}, _this2.renderDays(week)); | ||
}, _this.renderDays(week)); | ||
}); | ||
@@ -154,3 +150,3 @@ }, | ||
renderDays: function (week) { | ||
var _this3 = this; | ||
var _this2 = this; | ||
var firstDay = week[0]; | ||
@@ -160,3 +156,3 @@ var lastDay = week[week.length - 1]; | ||
var days = week.map(function (day) { | ||
return _this3.renderDay(day); | ||
return _this2.renderDay(day); | ||
}); | ||
@@ -180,3 +176,3 @@ | ||
renderDay: function (day, otherMonth) { | ||
var modifiers = this.getDayModifiers(day); | ||
var modifiers = this.getModifiersForDay(day); | ||
@@ -183,0 +179,0 @@ var className = "daypicker__day"; |
{ | ||
"name": "react-day-picker", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "A minimalistic date picker component using moment.js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/DayPicker.js", |
@@ -5,3 +5,3 @@ # react-day-picker | ||
See [demo](http://www.gpbl.org/react-day-picker/). | ||
See a [live version](http://www.gpbl.org/react-day-picker/) of the [example app](example), which makes the component working together with a `<input>` field. | ||
@@ -59,2 +59,8 @@ ```bash | ||
## Styling | ||
A basic inline style is included in the component to create the calendar layout, but you likely need to setup your own CSS. | ||
See [this css example](example/main.css): the daypicker selectors begins with `.daypicker`. | ||
## API | ||
@@ -61,0 +67,0 @@ |
@@ -27,8 +27,7 @@ import React from 'react'; | ||
componentWillReceiveProps(nextProps) { | ||
this.setState({month: nextProps.initialMonth}); | ||
this.setState({ month: nextProps.initialMonth }); | ||
}, | ||
componentDidUpdate(prevProps, prevState) { | ||
if(this.state.focus) | ||
this.refs['d'+this.state.focus].getDOMNode().focus(); | ||
if (this.state.focus) this.refs['d'+this.state.focus].getDOMNode().focus(); | ||
}, | ||
@@ -58,28 +57,25 @@ | ||
handleDayFocus(day, modifiers, e){ | ||
this.setState({focus: day.dayOfYear()}, () => { | ||
this.props.onDayFocus && this.props.onDayFocus(e); | ||
}); | ||
this.setState({ focus: day.dayOfYear() }); | ||
}, | ||
handleDayBlur(day, modifiers, e){ | ||
this.setState({focus: null}); | ||
this.setState({ focus: null }); | ||
}, | ||
handleNextTouchTap(e) { | ||
const nextMonth = this.state.month.add(1, 'month'); | ||
this.setState({month: nextMonth}); | ||
this.setState({ month: this.state.month.add(1, 'month') }); | ||
}, | ||
handlePrevTouchTap(e) { | ||
const prevMonth = this.state.month.subtract(1, 'month'); | ||
this.setState({month: prevMonth}); | ||
this.setState({ month: this.state.month.subtract(1, 'month') }); | ||
}, | ||
getDayModifiers(day) { | ||
getModifiersForDay(day) { | ||
var dayModifiers = []; | ||
if (!this.props.modifiers) return dayModifiers; | ||
const modifiers = this.props.modifiers; | ||
for (let modifier in modifiers) { | ||
var func = modifiers[modifier]; | ||
if (func(day)) dayModifiers.push(modifier); | ||
if (this.props.modifiers) { | ||
const modifiers = this.props.modifiers; | ||
for (let modifier in modifiers) { | ||
var func = modifiers[modifier]; | ||
if (func(day)) dayModifiers.push(modifier); | ||
} | ||
} | ||
@@ -160,3 +156,3 @@ return dayModifiers; | ||
renderDay(day, otherMonth) { | ||
const modifiers = this.getDayModifiers(day); | ||
const modifiers = this.getModifiersForDay(day); | ||
@@ -163,0 +159,0 @@ var className = 'daypicker__day'; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2285982
103
27574