Socket
Socket
Sign inDemoInstall

react-day-picker

Package Overview
Dependencies
Maintainers
1
Versions
247
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-day-picker - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

8

lib/addons/index.js

@@ -1,2 +0,1 @@

// Deprecated: remove from the next major version!
"use strict";

@@ -7,5 +6,4 @@

});
exports.LocaleUtils = undefined;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _LocaleUtils2 = require("./LocaleUtils");

@@ -15,3 +13,5 @@

exports.LocaleUtils = _LocaleUtils3["default"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.LocaleUtils = _LocaleUtils3.default; // Deprecated: remove from the next major version!
//# sourceMappingURL=index.js.map

@@ -1,2 +0,1 @@

// Deprecated: remove from the next major version
"use strict";

@@ -7,5 +6,4 @@

});
exports.default = undefined;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _MomentLocaleUtils = require("./MomentLocaleUtils");

@@ -15,4 +13,5 @@

exports["default"] = _MomentLocaleUtils2["default"];
module.exports = exports["default"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _MomentLocaleUtils2.default; // Deprecated: remove from the next major version
//# sourceMappingURL=LocaleUtils.js.map

@@ -6,5 +6,8 @@ "use strict";

});
exports.formatMonthTitle = formatMonthTitle;
exports.formatWeekdayShort = formatWeekdayShort;
exports.formatWeekdayLong = formatWeekdayLong;
exports.getFirstDayOfWeek = getFirstDayOfWeek;
exports.getMonths = getMonths;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _moment = require("moment");

@@ -14,42 +17,47 @@

exports["default"] = {
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
formatMonthTitle: function formatMonthTitle(date) {
var locale = arguments.length <= 1 || arguments[1] === undefined ? "en" : arguments[1];
function formatMonthTitle(date) {
var locale = arguments.length <= 1 || arguments[1] === undefined ? "en" : arguments[1];
return (0, _moment2["default"])(date).locale(locale).format("MMMM YYYY");
},
return (0, _moment2.default)(date).locale(locale).format("MMMM YYYY");
}
formatWeekdayShort: function formatWeekdayShort(day) {
var locale = arguments.length <= 1 || arguments[1] === undefined ? "en" : arguments[1];
function formatWeekdayShort(day) {
var locale = arguments.length <= 1 || arguments[1] === undefined ? "en" : arguments[1];
return (0, _moment2["default"])().locale(locale).weekday(day).format("dd");
},
return (0, _moment2.default)().locale(locale).weekday(day).format("dd");
}
formatWeekdayLong: function formatWeekdayLong(day) {
var locale = arguments.length <= 1 || arguments[1] === undefined ? "en" : arguments[1];
function formatWeekdayLong(day) {
var locale = arguments.length <= 1 || arguments[1] === undefined ? "en" : arguments[1];
return (0, _moment2["default"])().locale(locale).weekday(day).format("dddd");
},
return (0, _moment2.default)().locale(locale).weekday(day).format("dddd");
}
getFirstDayOfWeek: function getFirstDayOfWeek() {
var locale = arguments.length <= 0 || arguments[0] === undefined ? "en" : arguments[0];
function getFirstDayOfWeek() {
var locale = arguments.length <= 0 || arguments[0] === undefined ? "en" : arguments[0];
var localeData = _moment2["default"].localeData(locale);
return localeData.firstDayOfWeek();
},
var localeData = _moment2.default.localeData(locale);
return localeData.firstDayOfWeek();
}
getMonths: function getMonths() {
var locale = arguments.length <= 0 || arguments[0] === undefined ? "en" : arguments[0];
function getMonths() {
var locale = arguments.length <= 0 || arguments[0] === undefined ? "en" : arguments[0];
var months = [];
var i = 0;
while (i < 12) {
months.push((0, _moment2["default"])().locale(locale).month(i++).format("MMMM"));
}
return months;
var months = [];
var i = 0;
while (i < 12) {
months.push((0, _moment2.default)().locale(locale).month(i++).format("MMMM"));
}
return months;
}
exports.default = {
formatMonthTitle: formatMonthTitle,
formatWeekdayShort: formatWeekdayShort,
formatWeekdayLong: formatWeekdayLong,
getFirstDayOfWeek: getFirstDayOfWeek,
getMonths: getMonths
};
module.exports = exports["default"];
//# sourceMappingURL=MomentLocaleUtils.js.map

@@ -6,124 +6,134 @@ "use strict";

});
var DateUtils = {
exports.addMonths = addMonths;
exports.clone = clone;
exports.isSameDay = isSameDay;
exports.isPastDay = isPastDay;
exports.isDayBetween = isDayBetween;
exports.addDayToRange = addDayToRange;
exports.isDayInRange = isDayInRange;
/**
* Return `d` as a new date with `n` months added.
* @param {[type]} d
* @param {[type]} n
*/
function addMonths(d, n) {
var newDate = clone(d);
newDate.setMonth(d.getMonth() + n);
return newDate;
}
/**
* Return `d` as a new date with `n` months added.
* @param {[type]} d
* @param {[type]} n
*/
addMonths: function addMonths(d, n) {
var newDate = DateUtils.clone(d);
newDate.setMonth(d.getMonth() + n);
return newDate;
},
/**
* Clone a date object.
*
* @param {Date} d The date to clone
* @return {Date} The cloned date
*/
function clone(d) {
return new Date(d.getTime());
}
/**
* Clone a date object.
*
* @param {Date} d The date to clone
* @return {Date} The cloned date
*/
clone: function clone(d) {
return new Date(d.getTime());
},
/**
* Return `true` if two dates are the same day, ignoring the time.
*
* @param {Date} d1
* @param {Date} d2
* @return {Boolean}
*/
function isSameDay(d1, d2) {
if (!d1 || !d2) {
return false;
}
return d1.getDate() === d2.getDate() && d1.getMonth() === d2.getMonth() && d1.getFullYear() === d2.getFullYear();
}
/**
* Return `true` if two dates are the same day, ignoring the time.
*
* @param {Date} d1
* @param {Date} d2
* @return {Boolean}
*/
isSameDay: function isSameDay(d1, d2) {
if (!d1 || !d2) {
return false;
}
return d1.getDate() === d2.getDate() && d1.getMonth() === d2.getMonth() && d1.getFullYear() === d2.getFullYear();
},
/**
* Return `true` if a day is in the past, e.g. yesterday or any day
* before yesterday.
*
* @param {Date} d
* @return {Boolean}
*/
function isPastDay(d) {
var today = new Date();
today.setHours(0, 0, 0, 0);
return d < today;
}
/**
* Return `true` if a day is in the past, e.g. yesterday or any day
* before yesterday.
*
* @param {Date} d
* @return {Boolean}
*/
isPastDay: function isPastDay(d) {
var today = new Date();
today.setHours(0, 0, 0, 0);
return d < today;
},
/**
* Return `true` if day `d` is between days `d1` and `d2`,
* without including them.
*
* @param {Date} d
* @param {Date} d1
* @param {Date} d2
* @return {Boolean}
*/
function isDayBetween(d, d1, d2) {
d = clone(d);
d1 = clone(d1);
d2 = clone(d2);
/**
* Return `true` if day `d` is between days `d1` and `d2`,
* without including them.
*
* @param {Date} d
* @param {Date} d1
* @param {Date} d2
* @return {Boolean}
*/
isDayBetween: function isDayBetween(d, d1, d2) {
d = DateUtils.clone(d);
d1 = DateUtils.clone(d1);
d2 = DateUtils.clone(d2);
d.setHours(0, 0, 0, 0);
d1.setHours(0, 0, 0, 0);
d2.setHours(0, 0, 0, 0);
return d1 < d && d < d2 || d2 < d && d < d1;
}
d.setHours(0, 0, 0, 0);
d1.setHours(0, 0, 0, 0);
d2.setHours(0, 0, 0, 0);
return d1 < d && d < d2 || d2 < d && d < d1;
},
/**
* Add a day to a range and return a new range. A range is an object with
* `from` and `to` days.
*
* @param {Date} day
* @param {Object} range
* @return {Object} Returns a new range object
*/
function addDayToRange(day) {
var range = arguments.length <= 1 || arguments[1] === undefined ? { from: null, to: null } : arguments[1];
var from = range.from;
var to = range.to;
/**
* Add a day to a range and return a new range. A range is an object with
* `from` and `to` days.
*
* @param {Date} day
* @param {Object} range
* @return {Object} Returns a new range object
*/
addDayToRange: function addDayToRange(day) {
var range = arguments.length <= 1 || arguments[1] === undefined ? { from: null, to: null } : arguments[1];
var from = range.from;
var to = range.to;
if (!from) {
if (!from) {
from = day;
} else if (from && to && isSameDay(from, to) && isSameDay(day, from)) {
from = null;
to = null;
} else if (to && day < from) {
from = day;
} else if (to && isSameDay(day, to)) {
from = day;
to = day;
} else {
to = day;
if (to < from) {
to = from;
from = day;
} else if (from && to && DateUtils.isSameDay(from, to) && DateUtils.isSameDay(day, from)) {
from = null;
to = null;
} else if (to && day < from) {
from = day;
} else if (to && DateUtils.isSameDay(day, to)) {
from = day;
to = day;
} else {
to = day;
if (to < from) {
to = from;
from = day;
}
}
}
return { from: from, to: to };
},
return { from: from, to: to };
}
/**
* Return `true` if a day is included in a range of days.
*
* @param {Date} day
* @param {Object} range
* @return {Boolean}
*/
isDayInRange: function isDayInRange(day, range) {
var from = range.from;
var to = range.to;
/**
* Return `true` if a day is included in a range of days.
*
* @param {Date} day
* @param {Object} range
* @return {Boolean}
*/
function isDayInRange(day, range) {
var from = range.from;
var to = range.to;
return from && DateUtils.isSameDay(day, from) || to && DateUtils.isSameDay(day, to) || from && to && DateUtils.isDayBetween(day, from, to);
}
return from && isSameDay(day, from) || to && isSameDay(day, to) || from && to && isDayBetween(day, from, to);
}
exports.default = {
addDayToRange: addDayToRange,
addMonths: addMonths,
clone: clone,
isSameDay: isSameDay,
isDayInRange: isDayInRange,
isDayBetween: isDayBetween,
isPastDay: isPastDay
};
exports["default"] = DateUtils;
module.exports = exports["default"];
//# sourceMappingURL=DateUtils.js.map

@@ -7,14 +7,6 @@ "use strict";

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _react = require("react");

@@ -26,12 +18,26 @@

var _Helpers2 = _interopRequireDefault(_Helpers);
var Helpers = _interopRequireWildcard(_Helpers);
var _DateUtils = require("./DateUtils");
var _DateUtils2 = _interopRequireDefault(_DateUtils);
var DateUtils = _interopRequireWildcard(_DateUtils);
var _LocaleUtils = require("./LocaleUtils");
var _LocaleUtils2 = _interopRequireDefault(_LocaleUtils);
var LocaleUtils = _interopRequireWildcard(_LocaleUtils);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var keys = {

@@ -44,3 +50,3 @@ LEFT: 37,

var Caption = (function (_Component) {
var Caption = function (_Component) {
_inherits(Caption, _Component);

@@ -51,3 +57,3 @@

_get(Object.getPrototypeOf(Caption.prototype), "constructor", this).apply(this, arguments);
return _possibleConstructorReturn(this, Object.getPrototypeOf(Caption).apply(this, arguments));
}

@@ -64,3 +70,3 @@

return _react2["default"].createElement(
return _react2.default.createElement(
"div",

@@ -74,71 +80,16 @@ { className: "DayPicker-Caption", onClick: onClick },

return Caption;
})(_react.Component);
}(_react.Component);
var DayPicker = (function (_Component2) {
var DayPicker = function (_Component2) {
_inherits(DayPicker, _Component2);
_createClass(DayPicker, null, [{
key: "propTypes",
value: {
className: _react.PropTypes.string,
style: _react.PropTypes.object,
tabIndex: _react.PropTypes.number,
initialMonth: _react.PropTypes.instanceOf(Date),
numberOfMonths: _react.PropTypes.number,
modifiers: _react.PropTypes.object,
locale: _react.PropTypes.string,
localeUtils: _react.PropTypes.shape({
formatMonthTitle: _react.PropTypes.func,
formatWeekdayShort: _react.PropTypes.func,
formatWeekdayLong: _react.PropTypes.func,
getFirstDayOfWeek: _react.PropTypes.func
}),
enableOutsideDays: _react.PropTypes.bool,
canChangeMonth: _react.PropTypes.bool,
fromMonth: _react.PropTypes.instanceOf(Date),
toMonth: _react.PropTypes.instanceOf(Date),
onDayClick: _react.PropTypes.func,
onDayTouchTap: _react.PropTypes.func,
onDayMouseEnter: _react.PropTypes.func,
onDayMouseLeave: _react.PropTypes.func,
onMonthChange: _react.PropTypes.func,
onCaptionClick: _react.PropTypes.func,
renderDay: _react.PropTypes.func,
captionElement: _react.PropTypes.element
},
enumerable: true
}, {
key: "defaultProps",
value: {
tabIndex: 0,
initialMonth: new Date(),
numberOfMonths: 1,
locale: "en",
localeUtils: _LocaleUtils2["default"],
enableOutsideDays: false,
canChangeMonth: true,
renderDay: function renderDay(day) {
return day.getDate();
},
captionElement: _react2["default"].createElement(Caption, null)
},
enumerable: true
}]);
function DayPicker(props) {
_classCallCheck(this, DayPicker);
_get(Object.getPrototypeOf(DayPicker.prototype), "constructor", this).call(this, props);
this.state = {
currentMonth: _Helpers2["default"].startOfMonth(props.initialMonth)
var _this2 = _possibleConstructorReturn(this, Object.getPrototypeOf(DayPicker).call(this, props));
_this2.state = {
currentMonth: Helpers.startOfMonth(props.initialMonth)
};
return _this2;
}

@@ -151,3 +102,3 @@

this.setState({
currentMonth: _Helpers2["default"].startOfMonth(nextProps.initialMonth)
currentMonth: Helpers.startOfMonth(nextProps.initialMonth)
});

@@ -166,3 +117,3 @@ }

return _Helpers2["default"].getMonthsDiff(currentMonth, fromMonth) < 0;
return Helpers.getMonthsDiff(currentMonth, fromMonth) < 0;
}

@@ -181,3 +132,3 @@ }, {

return _Helpers2["default"].getMonthsDiff(currentMonth, toMonth) >= numberOfMonths;
return Helpers.getMonthsDiff(currentMonth, toMonth) >= numberOfMonths;
}

@@ -191,3 +142,3 @@ }, {

if (fromMonth && _Helpers2["default"].getMonthsDiff(fromMonth, d) < 0 || toMonth && _Helpers2["default"].getMonthsDiff(toMonth, d) > 0) {
if (fromMonth && Helpers.getMonthsDiff(fromMonth, d) < 0 || toMonth && Helpers.getMonthsDiff(toMonth, d) > 0) {
return false;

@@ -204,3 +155,3 @@ }

this.setState({
currentMonth: _Helpers2["default"].startOfMonth(d)
currentMonth: Helpers.startOfMonth(d)
});

@@ -211,3 +162,3 @@ }

value: function showNextMonth(callback) {
var _this = this;
var _this3 = this;

@@ -219,3 +170,3 @@ if (!this.allowNextMonth()) {

var nextMonth = _DateUtils2["default"].addMonths(currentMonth, 1);
var nextMonth = DateUtils.addMonths(currentMonth, 1);
this.setState({

@@ -227,4 +178,4 @@ currentMonth: nextMonth

}
if (_this.props.onMonthChange) {
_this.props.onMonthChange(_this.state.currentMonth);
if (_this3.props.onMonthChange) {
_this3.props.onMonthChange(_this3.state.currentMonth);
}

@@ -236,3 +187,3 @@ });

value: function showPreviousMonth(callback) {
var _this2 = this;
var _this4 = this;

@@ -244,3 +195,3 @@ if (!this.allowPreviousMonth()) {

var prevMonth = _DateUtils2["default"].addMonths(currentMonth, -1);
var prevMonth = DateUtils.addMonths(currentMonth, -1);
this.setState({

@@ -252,4 +203,4 @@ currentMonth: prevMonth

}
if (_this2.props.onMonthChange) {
_this2.props.onMonthChange(_this2.state.currentMonth);
if (_this4.props.onMonthChange) {
_this4.props.onMonthChange(_this4.state.currentMonth);
}

@@ -274,3 +225,3 @@ });

var prevMonth = _DateUtils2["default"].addMonths(currentMonth, -numberOfMonths);
var prevMonth = DateUtils.addMonths(currentMonth, -numberOfMonths);
this.setState({

@@ -303,3 +254,3 @@ currentMonth: prevMonth

var nextMonth = _DateUtils2["default"].addMonths(currentMonth, numberOfMonths);
var nextMonth = DateUtils.addMonths(currentMonth, numberOfMonths);
this.setState({

@@ -321,10 +272,25 @@ currentMonth: nextMonth

value: function handleKeyDown(e) {
switch (e.keyCode) {
case keys.LEFT:
this.showPreviousMonth();
break;
case keys.RIGHT:
this.showNextMonth();
break;
var _this5 = this;
e.persist();
if (!this.props.canChangeMonth && this.props.onKeyDown) {
this.props.onKeyDown(e);
return;
}
if (this.props.canChangeMonth) {
var callback = this.props.onKeyDown ? function () {
return _this5.props.onKeyDown(e);
} : null;
switch (e.keyCode) {
case keys.LEFT:
this.showPreviousMonth(callback);
break;
case keys.RIGHT:
this.showNextMonth(callback);
break;
}
}
}

@@ -412,3 +378,3 @@ }, {

var diffInMonths = _Helpers2["default"].getMonthsDiff(currentMonth, day);
var diffInMonths = Helpers.getMonthsDiff(currentMonth, day);
if (diffInMonths > 0 && diffInMonths >= numberOfMonths) {

@@ -424,13 +390,19 @@ this.showNextMonth();

var baseClass = "DayPicker-NavButton DayPicker-NavButton";
return _react2["default"].createElement(
var isRTL = this.props.dir === "rtl";
var leftButton = isRTL ? this.allowNextMonth() : this.allowPreviousMonth();
var rightButton = isRTL ? this.allowPreviousMonth() : this.allowNextMonth();
return _react2.default.createElement(
"div",
{ className: "DayPicker-NavBar" },
this.allowPreviousMonth() && _react2["default"].createElement("span", {
key: "prev",
leftButton && _react2.default.createElement("span", {
key: "left",
className: baseClass + "--prev",
onClick: this.handlePrevMonthClick.bind(this) }),
this.allowNextMonth() && _react2["default"].createElement("span", {
key: "next",
onClick: isRTL ? this.handleNextMonthClick.bind(this) : this.handlePrevMonthClick.bind(this)
}),
rightButton && _react2.default.createElement("span", {
key: "right",
className: baseClass + "--next",
onClick: this.handleNextMonthClick.bind(this) })
onClick: isRTL ? this.handlePrevMonthClick.bind(this) : this.handleNextMonthClick.bind(this)
})
);

@@ -441,3 +413,3 @@ }

value: function renderMonth(date, i) {
var _this3 = this;
var _this6 = this;

@@ -450,10 +422,11 @@ var _props4 = this.props;

var caption = _react2["default"].cloneElement(captionElement, {
var caption = _react2.default.cloneElement(captionElement, {
date: date, localeUtils: localeUtils, locale: locale,
onClick: onCaptionClick ? function (e) {
return _this3.handleCaptionClick(e, date);
return _this6.handleCaptionClick(e, date);
} : null
});
return _react2["default"].createElement(
return _react2.default.createElement(
"div",

@@ -464,6 +437,6 @@ {

caption,
_react2["default"].createElement(
_react2.default.createElement(
"div",
{ className: "DayPicker-Weekdays" },
_react2["default"].createElement(
_react2.default.createElement(
"div",

@@ -474,3 +447,3 @@ { className: "DayPicker-WeekdaysRow" },

),
_react2["default"].createElement(
_react2.default.createElement(
"div",

@@ -491,6 +464,6 @@ { className: "DayPicker-Body" },

for (var i = 0; i < 7; i++) {
days.push(_react2["default"].createElement(
days.push(_react2.default.createElement(
"div",
{ key: i, className: "DayPicker-Weekday" },
_react2["default"].createElement(
_react2.default.createElement(
"abbr",

@@ -507,3 +480,3 @@ { title: localeUtils.formatWeekdayLong(i, locale) },

value: function renderWeeksInMonth(month) {
var _this4 = this;
var _this7 = this;

@@ -515,8 +488,8 @@ var _props6 = this.props;

var firstDayOfWeek = localeUtils.getFirstDayOfWeek(locale);
return _Helpers2["default"].getWeekArray(month, firstDayOfWeek).map(function (week, i) {
return _react2["default"].createElement(
return Helpers.getWeekArray(month, firstDayOfWeek).map(function (week, i) {
return _react2.default.createElement(
"div",
{ key: i, className: "DayPicker-Week", role: "row" },
week.map(function (day) {
return _this4.renderDay(month, day);
return _this7.renderDay(month, day);
})

@@ -529,5 +502,4 @@ );

value: function renderDay(month, day) {
var _this5 = this;
var _this8 = this;
var renderDay = this.props.renderDay;
var _props7 = this.props;

@@ -537,2 +509,3 @@ var enableOutsideDays = _props7.enableOutsideDays;

var className = "DayPicker-Day";

@@ -542,3 +515,3 @@ var modifiers = [];

var isToday = _DateUtils2["default"].isSameDay(day, new Date());
var isToday = DateUtils.isSameDay(day, new Date());
if (isToday) {

@@ -554,3 +527,3 @@ modifiers.push("today");

if (modifierFunctions) {
var customModifiers = _Helpers2["default"].getModifiersForDay(day, modifierFunctions);
var customModifiers = Helpers.getModifiersForDay(day, modifierFunctions);
modifiers = [].concat(_toConsumableArray(modifiers), _toConsumableArray(customModifiers));

@@ -564,3 +537,3 @@ }

if (isOutside && !enableOutsideDays) {
return _react2["default"].createElement("div", { key: "outside-" + key, className: className });
return _react2.default.createElement("div", { key: "outside-" + key, className: className });
}

@@ -582,3 +555,3 @@

}
return _react2["default"].createElement(
return _react2.default.createElement(
"div",

@@ -588,19 +561,19 @@ { key: key, className: className,

role: "gridcell",
onKeyDown: function (e) {
return _this5.handleDayKeyDown(e, day, modifiers);
onKeyDown: function onKeyDown(e) {
return _this8.handleDayKeyDown(e, day, modifiers);
},
onMouseEnter: onDayMouseEnter ? function (e) {
return _this5.handleDayMouseEnter(e, day, modifiers);
return _this8.handleDayMouseEnter(e, day, modifiers);
} : null,
onMouseLeave: onDayMouseLeave ? function (e) {
return _this5.handleDayMouseLeave(e, day, modifiers);
return _this8.handleDayMouseLeave(e, day, modifiers);
} : null,
onClick: onDayClick ? function (e) {
return _this5.handleDayClick(e, day, modifiers);
return _this8.handleDayClick(e, day, modifiers);
} : null,
onTouchTap: onDayTouchTap ? function (e) {
return _this5.handleDayTouchTap(e, day, modifiers);
return _this8.handleDayTouchTap(e, day, modifiers);
} : null
},
renderDay(day)
this.props.renderDay(day)
);

@@ -611,8 +584,11 @@ }

value: function render() {
var _this9 = this;
var _props9 = this.props;
var numberOfMonths = _props9.numberOfMonths;
var locale = _props9.locale;
var style = _props9.style;
var tabIndex = _props9.tabIndex;
var canChangeMonth = _props9.canChangeMonth;
var attributes = _objectWithoutProperties(_props9, ["numberOfMonths", "locale", "canChangeMonth"]);
var currentMonth = this.state.currentMonth;

@@ -625,4 +601,4 @@

}
if (this.props.className) {
className = className + " " + this.props.className;
if (attributes.className) {
className = className + " " + attributes.className;
}

@@ -633,13 +609,15 @@

for (var i = 0; i < numberOfMonths; i++) {
month = _DateUtils2["default"].addMonths(currentMonth, i);
month = DateUtils.addMonths(currentMonth, i);
months.push(this.renderMonth(month, i));
}
return _react2["default"].createElement(
return _react2.default.createElement(
"div",
{ className: className,
style: style,
_extends({ className: className,
role: "widget",
tabIndex: canChangeMonth && tabIndex,
onKeyDown: canChangeMonth && this.handleKeyDown.bind(this) },
tabIndex: canChangeMonth && attributes.tabIndex,
onKeyDown: function onKeyDown(e) {
return _this9.handleKeyDown(e);
}
}, attributes),
canChangeMonth && this.renderNavBar(),

@@ -652,6 +630,50 @@ months

return DayPicker;
})(_react.Component);
}(_react.Component);
exports["default"] = DayPicker;
module.exports = exports["default"];
DayPicker.propTypes = {
initialMonth: _react.PropTypes.instanceOf(Date),
numberOfMonths: _react.PropTypes.number,
modifiers: _react.PropTypes.object,
locale: _react.PropTypes.string,
localeUtils: _react.PropTypes.shape({
formatMonthTitle: _react.PropTypes.func,
formatWeekdayShort: _react.PropTypes.func,
formatWeekdayLong: _react.PropTypes.func,
getFirstDayOfWeek: _react.PropTypes.func
}),
enableOutsideDays: _react.PropTypes.bool,
canChangeMonth: _react.PropTypes.bool,
fromMonth: _react.PropTypes.instanceOf(Date),
toMonth: _react.PropTypes.instanceOf(Date),
onDayClick: _react.PropTypes.func,
onDayTouchTap: _react.PropTypes.func,
onDayMouseEnter: _react.PropTypes.func,
onDayMouseLeave: _react.PropTypes.func,
onMonthChange: _react.PropTypes.func,
onCaptionClick: _react.PropTypes.func,
renderDay: _react.PropTypes.func,
captionElement: _react.PropTypes.element
};
DayPicker.defaultProps = {
tabIndex: 0,
initialMonth: new Date(),
numberOfMonths: 1,
locale: "en",
localeUtils: LocaleUtils,
enableOutsideDays: false,
canChangeMonth: true,
renderDay: function renderDay(day) {
return day.getDate();
},
captionElement: _react2.default.createElement(Caption, null)
};
exports.default = DayPicker;
//# sourceMappingURL=DayPicker.js.map

@@ -6,97 +6,92 @@ "use strict";

});
exports.startOfMonth = startOfMonth;
exports.getFirstDayOfMonth = getFirstDayOfMonth;
exports.getDaysInMonth = getDaysInMonth;
exports.getWeekArray = getWeekArray;
exports.getModifiersForDay = getModifiersForDay;
exports.getMonthsDiff = getMonthsDiff;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _DateUtils = require("./DateUtils");
var _DateUtils2 = _interopRequireDefault(_DateUtils);
var _LocaleUtils = require("./LocaleUtils");
var _LocaleUtils2 = _interopRequireDefault(_LocaleUtils);
function startOfMonth(d) {
var newDate = (0, _DateUtils.clone)(d);
newDate.setDate(1);
newDate.setHours(12, 0, 0, 0); // always set noon to avoid time zone issues
return newDate;
}
exports["default"] = {
function getFirstDayOfMonth(d) {
return new Date(d.getFullYear(), d.getMonth(), 1, 12);
}
startOfMonth: function startOfMonth(d) {
var newDate = _DateUtils2["default"].clone(d);
newDate.setDate(1);
newDate.setHours(12, 0, 0, 0); // always set noon to avoid time zone issues
return newDate;
},
function getDaysInMonth(d) {
var resultDate = getFirstDayOfMonth(d);
getFirstDayOfMonth: function getFirstDayOfMonth(d) {
return new Date(d.getFullYear(), d.getMonth(), 1, 12);
},
resultDate.setMonth(resultDate.getMonth() + 1);
resultDate.setDate(resultDate.getDate() - 1);
getDaysInMonth: function getDaysInMonth(d) {
var resultDate = this.getFirstDayOfMonth(d);
return resultDate.getDate();
}
resultDate.setMonth(resultDate.getMonth() + 1);
resultDate.setDate(resultDate.getDate() - 1);
function getWeekArray(d) {
var firstDayOfWeek = arguments.length <= 1 || arguments[1] === undefined ? (0, _LocaleUtils.getFirstDayOfWeek)() : arguments[1];
return resultDate.getDate();
},
var daysInMonth = getDaysInMonth(d);
var dayArray = [];
getWeekArray: function getWeekArray(d) {
var firstDayOfWeek = arguments.length <= 1 || arguments[1] === undefined ? _LocaleUtils2["default"].getFirstDayOfWeek() : arguments[1];
var week = [];
var weekArray = [];
var daysInMonth = this.getDaysInMonth(d);
var dayArray = [];
for (var i = 1; i <= daysInMonth; i++) {
dayArray.push(new Date(d.getFullYear(), d.getMonth(), i, 12));
}
var week = [];
var weekArray = [];
for (var i = 1; i <= daysInMonth; i++) {
dayArray.push(new Date(d.getFullYear(), d.getMonth(), i, 12));
dayArray.forEach(function (day) {
if (week.length > 0 && day.getDay() === firstDayOfWeek) {
weekArray.push(week);
week = [];
}
week.push(day);
if (dayArray.indexOf(day) === dayArray.length - 1) {
weekArray.push(week);
}
});
dayArray.forEach(function (day) {
if (week.length > 0 && day.getDay() === firstDayOfWeek) {
weekArray.push(week);
week = [];
}
week.push(day);
if (dayArray.indexOf(day) === dayArray.length - 1) {
weekArray.push(week);
}
});
// unshift days to start the first week
var firstWeek = weekArray[0];
for (var i = 7 - firstWeek.length; i > 0; i--) {
var outsideDate = (0, _DateUtils.clone)(firstWeek[0]);
outsideDate.setDate(firstWeek[0].getDate() - 1);
firstWeek.unshift(outsideDate);
}
// unshift days to start the first week
var firstWeek = weekArray[0];
for (var i = 7 - firstWeek.length; i > 0; i--) {
var outsideDate = _DateUtils2["default"].clone(firstWeek[0]);
outsideDate.setDate(firstWeek[0].getDate() - 1);
firstWeek.unshift(outsideDate);
}
// push days until the end of the last week
var lastWeek = weekArray[weekArray.length - 1];
for (var i = lastWeek.length; i < 7; i++) {
var outsideDate = (0, _DateUtils.clone)(lastWeek[lastWeek.length - 1]);
outsideDate.setDate(lastWeek[lastWeek.length - 1].getDate() + 1);
lastWeek.push(outsideDate);
}
// push days until the end of the last week
var lastWeek = weekArray[weekArray.length - 1];
for (var i = lastWeek.length; i < 7; i++) {
var outsideDate = _DateUtils2["default"].clone(lastWeek[lastWeek.length - 1]);
outsideDate.setDate(lastWeek[lastWeek.length - 1].getDate() + 1);
lastWeek.push(outsideDate);
}
return weekArray;
}
return weekArray;
},
getModifiersForDay: function getModifiersForDay(d, modifierFunctions) {
var modifiers = [];
if (modifierFunctions) {
for (var modifier in modifierFunctions) {
var func = modifierFunctions[modifier];
if (func(d)) {
modifiers.push(modifier);
}
function getModifiersForDay(d, modifierFunctions) {
var modifiers = [];
if (modifierFunctions) {
for (var modifier in modifierFunctions) {
var func = modifierFunctions[modifier];
if (func(d)) {
modifiers.push(modifier);
}
}
return modifiers;
},
getMonthsDiff: function getMonthsDiff(d1, d2) {
return d2.getMonth() - d1.getMonth() + 12 * (d2.getFullYear() - d1.getFullYear());
}
return modifiers;
}
};
module.exports = exports["default"];
function getMonthsDiff(d1, d2) {
return d2.getMonth() - d1.getMonth() + 12 * (d2.getFullYear() - d1.getFullYear());
}
//# sourceMappingURL=Helpers.js.map

@@ -6,2 +6,7 @@ "use strict";

});
exports.formatMonthTitle = formatMonthTitle;
exports.formatWeekdayShort = formatWeekdayShort;
exports.formatWeekdayLong = formatWeekdayLong;
exports.getFirstDayOfWeek = getFirstDayOfWeek;
exports.getMonths = getMonths;
var WEEKDAYS_LONG = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

@@ -13,26 +18,29 @@

exports["default"] = {
function formatMonthTitle(d) {
return MONTHS[d.getMonth()] + " " + d.getFullYear();
}
formatMonthTitle: function formatMonthTitle(d) {
return MONTHS[d.getMonth()] + " " + d.getFullYear();
},
function formatWeekdayShort(i) {
return WEEKDAYS_SHORT[i];
}
formatWeekdayShort: function formatWeekdayShort(i) {
return WEEKDAYS_SHORT[i];
},
function formatWeekdayLong(i) {
return WEEKDAYS_LONG[i];
}
formatWeekdayLong: function formatWeekdayLong(i) {
return WEEKDAYS_LONG[i];
},
function getFirstDayOfWeek() {
return 0;
}
getFirstDayOfWeek: function getFirstDayOfWeek() {
return 0;
},
function getMonths() {
return MONTHS;
}
getMonths: function getMonths() {
return MONTHS;
}
exports.default = {
formatMonthTitle: formatMonthTitle,
formatWeekdayShort: formatWeekdayShort,
formatWeekdayLong: formatWeekdayLong,
getFirstDayOfWeek: getFirstDayOfWeek,
getMonths: getMonths
};
module.exports = exports["default"];
//# sourceMappingURL=LocaleUtils.js.map
{
"name": "react-day-picker",
"version": "1.2.0",
"version": "1.3.0",
"description": "Flexible date picker component for React",

@@ -13,14 +13,10 @@ "main": "DayPicker.js",

"lint": "eslint src test",
"test": "mocha --compilers js:babel/register --recursive --reporter spec",
"test": "mocha --compilers js:babel-core/register --recursive --reporter spec",
"test:watch": "npm test -- --watch",
"cover": "istanbul cover -- _mocha --recursive --compilers js:babel/register --reporter spec",
"cover": "babel-node ./node_modules/istanbul/lib/cli cover -- _mocha --recursive --reporter spec",
"check": "npm run lint && npm run test",
"prerelease": "npm run check && webpack",
"prepublish": "babel ./src -d ./lib --source-maps && postcss --use autoprefixer src/style.css -d lib/",
"examples:clean": "rimraf examples/built",
"examples:build": "npm run examples:clean && cd examples && npm run build && cd ..",
"docs:clean": "rimraf _book",

@@ -30,3 +26,2 @@ "docs:prepare": "gitbook install",

"docs:watch": "npm run docs:prepare && gitbook serve",
"docs:publish": "npm run docs:clean && npm run docs:build && npm run examples:build && rimraf _book/examples && mv examples/built _book/examples && cd _book && git init && git commit --allow-empty -m 'Update docs and examples' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'Update docs and examples' && git push git@github.com:gpbl/react-day-picker gh-pages --force"

@@ -61,5 +56,8 @@ },

"autoprefixer": "^6.0.3",
"babel": "^5.8.21",
"babel-core": "^5.8.22",
"babel-eslint": "^4.0.10",
"babel-cli": "^6.4.5",
"babel-core": "^6.4.5",
"babel-eslint": "^5.0.0-beta6",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"chai": "^3.4.1",

@@ -71,5 +69,5 @@ "classlist-polyfill": "^1.0.1",

"exenv": "^1.2.0",
"fbjs": "^0.4.0",
"fbjs": "0.7.2",
"gitbook-cli": "^1.0.0",
"istanbul": "^0.4.0",
"istanbul": "^1.0.0-alpha",
"jsdom": "^7.0.2",

@@ -76,0 +74,0 @@ "mocha": "^2.2.5",

@@ -1,4 +0,19 @@

react-day-picker
=======
<p align="center">
<img width="359" style="margin: 0 auto" alt="title" src="https://cloud.githubusercontent.com/assets/120693/12210154/46ea65d2-b658-11e5-9328-8abaaa9fbcdd.png">
</p>
<p align="center">
<img width="297" style="margin: 0 auto" alt="screen shot" src="https://cloud.githubusercontent.com/assets/120693/12312069/74c136d6-ba5c-11e5-8eae-680ecd200f95.png">
</p>
react-day-picker is a flexible date picker component for [React](https://facebook.github.io/react/).
* no external dependencies
* select [days](http://www.gpbl.org/react-day-picker/examples/#selectable), [ranges](http://www.gpbl.org/react-day-picker/examples/#range), whatever using CSS modifiers
* ready for i18n, with [moment.js](http://www.gpbl.org/react-day-picker/examples/#localized) or [any other library](http://www.gpbl.org/react-day-picker/examples/#localizedCustom)
* customizable [style](https://github.com/gpbl/react-day-picker/blob/master/src/style.css)
* navigable via keyboard, ARIA support
Look at [some examples](http://gpbl.org/react-day-picker/examples) showing all its features!
[![build status](https://img.shields.io/travis/gpbl/react-day-picker/master.svg?style=flat-square)](https://travis-ci.org/gpbl/react-day-picker)

@@ -10,24 +25,21 @@ [![coveralls](https://img.shields.io/coveralls/gpbl/react-day-picker.svg?style=flat-square)](https://coveralls.io/r/gpbl/react-day-picker?branch=master)

react-day-picker is a flexible date picker component for [React](https://facebook.github.io/react/).
* select days, ranges, whatever using CSS modifiers
* easily change style and add content to days cells
* display multiple months
* ready for i18n, with moment.js or any other library
* navigable via keyboard, ARIA support
* no external dependencies
### Documentation
<p align="center">
<img width="291" style="margin: 0 auto" alt="screen shot 2015-11-11 at 15 51 07" src="https://cloud.githubusercontent.com/assets/120693/11093859/d52e0c26-888c-11e5-917e-aaa9686dcb84.png">
</p>
## Documentation and help
* [Guides and API](http://gpbl.org/react-day-picker)
* [Examples with code](http://gpbl.org/react-day-picker/examples)
* [Github](https://github.com/gpbl/react-day-picker)
* [Documentation](http://gpbl.org/react-day-picker)
* [Getting started](http://gpbl.org/react-day-picker/docs/GettingStarted.html)
* [API](http://www.gpbl.org/react-day-picker/docs/API.html)
* [Styling](http://www.gpbl.org/react-day-picker/docs/Styling.html)
* [Localization](http://www.gpbl.org/react-day-picker/docs/Localization.html)
* [Tips](http://www.gpbl.org/react-day-picker/docs/Tips.html)
* [Utilities](http://www.gpbl.org/react-day-picker/docs/Utilities.html)
* [Changelog](https://github.com/gpbl/react-day-picker/releases)
* [Issues](https://github.com/gpbl/react-day-picker/issues)
* [Gitter room](https://gitter.im/gpbl/react-day-picker)
### Contribute
* [Github](https://github.com/gpbl/react-day-picker) – pull requests are welcome!
* [Issues](https://github.com/gpbl/react-day-picker/issues) – file bugs and suggestions
* [Gitter room](https://gitter.im/gpbl/react-day-picker) – ask questions and chat with other developers
## Quick start

@@ -34,0 +46,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc