react-day-picker
Advanced tools
Comparing version 0.4.0 to 0.5.0
"use strict"; | ||
var _interopRequire = function (obj) { | ||
return obj && (obj["default"] || obj); | ||
}; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
@@ -13,7 +11,5 @@ var React = _interopRequire(require("react")); | ||
var DayPicker = React.createClass({ | ||
displayName: "DayPicker", | ||
propTypes: { | ||
@@ -41,7 +37,10 @@ | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
this.setState({ month: nextProps.initialMonth }); | ||
if (!this.state.monthDidChange) this.setState({ month: nextProps.initialMonth }); | ||
}, | ||
getInitialState: function getInitialState() { | ||
return { month: this.props.initialMonth.clone() }; | ||
return { | ||
month: this.props.initialMonth.clone(), | ||
monthDidChange: false | ||
}; | ||
}, | ||
@@ -67,5 +66,7 @@ | ||
var _this = this; | ||
var month = this.state.month; | ||
var nextMonth = month.clone().add(1, "month"); | ||
this.setState({ month: nextMonth }, function () { | ||
this.setState({ month: nextMonth, monthDidChange: true }, function () { | ||
_this.props.onNextMonthClick && _this.props.onNextMonthClick(_this.state.month); | ||
@@ -76,7 +77,9 @@ }); | ||
handlePrevMonthClick: function handlePrevMonthClick(e) { | ||
var _this2 = this; | ||
var _this = this; | ||
var month = this.state.month; | ||
var prevMonth = month.clone().subtract(1, "month"); | ||
this.setState({ month: prevMonth }, function () { | ||
_this2.props.onPrevMonthClick && _this2.props.onPrevMonthClick(_this2.state.month); | ||
this.setState({ month: prevMonth, monthDidChange: true }, function () { | ||
_this.props.onPrevMonthClick && _this.props.onPrevMonthClick(_this.state.month); | ||
}); | ||
@@ -87,2 +90,3 @@ }, | ||
var modifiers = this.props.modifiers; | ||
var dayModifiers = []; | ||
@@ -98,2 +102,3 @@ if (modifiers) for (var modifier in modifiers) { | ||
var month = this.state.month; | ||
return React.createElement( | ||
@@ -131,3 +136,4 @@ "table", | ||
renderWeeks: function renderWeeks() { | ||
var _this3 = this; | ||
var _this = this; | ||
return weeks(this.state.month).map(function (week, i) { | ||
@@ -137,3 +143,3 @@ return React.createElement( | ||
{ key: i, className: "daypicker__week" }, | ||
_this3.renderDays(week) | ||
_this.renderDays(week) | ||
); | ||
@@ -156,3 +162,4 @@ }); | ||
renderDays: function renderDays(week) { | ||
var _this4 = this; | ||
var _this = this; | ||
var firstDay = week[0]; | ||
@@ -162,3 +169,3 @@ var lastDay = week[week.length - 1]; | ||
var days = week.map(function (day) { | ||
return _this4.renderDay(day); | ||
return _this.renderDay(day); | ||
}); | ||
@@ -173,4 +180,3 @@ | ||
// days belonging to the next month | ||
for (var j = lastDay.weekday() + 1, | ||
count = 1; j < 7; j++, count++) { | ||
for (var j = lastDay.weekday() + 1, count = 1; j < 7; j++, count++) { | ||
var nextDay = lastDay.clone().add(count, "day"); | ||
@@ -177,0 +183,0 @@ days.push(this.renderDay(nextDay, true)); |
"use strict"; | ||
// return an array of the weeks (array of days) in a month | ||
exports.weeks = weeks; | ||
// return an array of the weeks (array of days) in a month | ||
function weeks(m) { | ||
var firstOfMonth = m.clone().startOf("month"); | ||
@@ -22,2 +23,5 @@ var lastOfMonth = m.clone().endOf("month"); | ||
return weeksInMonth; | ||
} | ||
} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); |
@@ -14,3 +14,3 @@ module.exports = { | ||
loaders: [ | ||
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['6to5-loader'] }, | ||
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel-loader'] }, | ||
{ test: /\.scss?$/, loaders: ['style', 'css', 'autoprefixer-loader?browsers=last 2 version', 'sass-loader'] }, | ||
@@ -17,0 +17,0 @@ { test: /\.svg$/, loader: "url-loader?limit=100000&mimetype=image/svg+xml" } |
{ | ||
"name": "react-day-picker", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Minimalistic date picker component for React and momentjs.", | ||
@@ -9,3 +9,3 @@ "main": "./dist/DayPicker.js", | ||
"build": "cd example && webpack --hot=false --devtool=false --optimize-minimize", | ||
"prepublish": "6to5 ./src -d ./dist" | ||
"prepublish": "babel ./src -d ./dist" | ||
}, | ||
@@ -35,17 +35,17 @@ "repository": { | ||
"devDependencies": { | ||
"6to5": "^2.12.6", | ||
"6to5-jest": "^1.0.0", | ||
"6to5-loader": "^2.0.0", | ||
"autoprefixer-loader": "^1.0.0", | ||
"babel": "^4.4.5", | ||
"babel-jest": "^4.0.0", | ||
"babel-loader": "^4.0.0", | ||
"autoprefixer-loader": "^1.1.0", | ||
"css-loader": "^0.9.1", | ||
"jest-cli": "^0.2.1", | ||
"react-tap-event-plugin": "^0.1.3", | ||
"sass-loader": "^0.3.1", | ||
"jest-cli": "^0.4.0", | ||
"react-tap-event-plugin": "^0.1.4", | ||
"sass-loader": "^0.4.0-beta", | ||
"style-loader": "^0.8.3", | ||
"url-loader": "^0.5.5", | ||
"webpack": "^1.4.15", | ||
"webpack": "^1.5.3", | ||
"webpack-dev-server": "^1.7.0" | ||
}, | ||
"jest": { | ||
"scriptPreprocessor": "./node_modules/6to5-jest", | ||
"scriptPreprocessor": "./node_modules/babel-jest", | ||
"testFileExtensions": [ | ||
@@ -52,0 +52,0 @@ "js" |
@@ -9,2 +9,3 @@ # react-day-picker | ||
```bash | ||
@@ -14,2 +15,4 @@ npm install react-day-picker --save | ||
[![npm version](https://badge.fury.io/js/react-day-picker.svg)](http://badge.fury.io/js/react-day-picker) | ||
### Use of modifiers | ||
@@ -16,0 +19,0 @@ |
@@ -29,7 +29,11 @@ import React from 'react'; | ||
componentWillReceiveProps(nextProps) { | ||
this.setState({ month: nextProps.initialMonth }); | ||
if (!this.state.monthDidChange) | ||
this.setState({ month: nextProps.initialMonth }); | ||
}, | ||
getInitialState() { | ||
return { month: this.props.initialMonth.clone() }; | ||
return { | ||
month: this.props.initialMonth.clone(), | ||
monthDidChange: false | ||
}; | ||
}, | ||
@@ -56,3 +60,3 @@ | ||
const nextMonth = month.clone().add(1, 'month'); | ||
this.setState({ month: nextMonth }, () => { | ||
this.setState({ month: nextMonth, monthDidChange: true }, () => { | ||
this.props.onNextMonthClick | ||
@@ -66,3 +70,3 @@ && this.props.onNextMonthClick(this.state.month); | ||
const prevMonth = month.clone().subtract(1, 'month'); | ||
this.setState({ month: prevMonth }, () => { | ||
this.setState({ month: prevMonth, monthDidChange: true }, () => { | ||
this.props.onPrevMonthClick | ||
@@ -69,0 +73,0 @@ && this.props.onPrevMonthClick(this.state.month); |
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
410139
1767
130