Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-daypicker

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-daypicker - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0-beta

277

lib/DayPicker.js

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

'use strict';
"use strict";

@@ -6,42 +6,51 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
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 _react = _interopRequireWildcard(require("react"));
var _react = require('react');
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react2 = _interopRequireDefault(_react);
var _moment = _interopRequireDefault(require("moment"));
var _propTypes = require('prop-types');
var _reactMomentProptypes = _interopRequireDefault(require("react-moment-proptypes"));
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = _interopRequireDefault(require("classnames"));
var _moment = require('moment');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _moment2 = _interopRequireDefault(_moment);
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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
var _reactMomentProptypes = require('react-moment-proptypes');
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _reactMomentProptypes2 = _interopRequireDefault(_reactMomentProptypes);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _classnames = require('classnames');
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); } }
var _classnames2 = _interopRequireDefault(_classnames);
function _createClass(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 _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
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; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var DayPicker = function (_Component) {
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var DayPicker =
/*#__PURE__*/
function (_Component) {
_inherits(DayPicker, _Component);
function DayPicker(props) {
var _this;
_classCallCheck(this, DayPicker);
var _this = _possibleConstructorReturn(this, (DayPicker.__proto__ || Object.getPrototypeOf(DayPicker)).call(this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(DayPicker).call(this, props));
_this.previousMonth = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "previousMonth", function () {
var month = _this.month.subtract(1, 'month');

@@ -53,5 +62,5 @@

});
};
});
_this.nextMonth = function () {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "nextMonth", function () {
var month = _this.month.add(1, 'month');

@@ -63,52 +72,38 @@

});
};
});
_this.onDayClick = function (event) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onDayClick", function (event) {
var dayOfMonth = event.nativeEvent.target.innerText;
var day = _this.month.date(dayOfMonth);
_this.props.onDayClick(day);
};
});
_this.renderDay = function (day, index) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderDay", function (day, index) {
var keyPrefix = _this.state.keyPrefix;
var active = _this.props.active;
var today = (0, _moment2.default)();
var today = (0, _moment.default)();
var currentMonth = _this.month;
var isToday = day && currentMonth.year() == today.year() && currentMonth.month() == today.month() && day == today.date();
var isActive = day && active && currentMonth.year() == active.year() && currentMonth.month() == active.month() && day == active.date();
return _react.default.createElement("td", {
className: (0, _classnames.default)('day', {
active: isActive,
empty: !day,
today: isToday
}),
key: "".concat(keyPrefix, ".day.").concat(index),
onClick: _this.onDayClick
}, day || '');
});
return _react2.default.createElement(
'td',
{
className: (0, _classnames2.default)('day', {
active: isActive,
empty: !day,
today: isToday
}),
key: keyPrefix + '.day.' + index,
onClick: _this.onDayClick
},
day || ''
);
};
_this.renderWeek = function (days, index) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderWeek", function (days, index) {
var keyPrefix = _this.state.keyPrefix;
return _react.default.createElement("tr", {
key: "".concat(keyPrefix, ".week.").concat(index)
}, days.map(_this.renderDay));
});
return _react2.default.createElement(
'tr',
{
key: keyPrefix + '.week.' + index
},
days.map(_this.renderDay)
);
};
var date = (0, _moment2.default)();
var date = (0, _moment.default)();
_this.state = {

@@ -122,110 +117,48 @@ month: date,

_createClass(DayPicker, [{
key: 'render',
key: "render",
value: function render() {
return _react2.default.createElement(
'div',
{ className: 'react-daypicker-root' },
_react2.default.createElement(
'div',
{ className: 'header' },
_react2.default.createElement(
'div',
{ className: 'previous-month', onClick: this.previousMonth },
'\u25C0'
),
_react2.default.createElement(
'div',
{ className: 'month-year' },
this.month.format('MMMM YYYY')
),
_react2.default.createElement(
'div',
{ className: 'next-month', onClick: this.nextMonth },
'\u25B6'
)
),
_react2.default.createElement(
'table',
null,
_react2.default.createElement(
'thead',
null,
_react2.default.createElement(
'tr',
null,
_react2.default.createElement(
'th',
{ scope: 'col' },
_react2.default.createElement(
'abbr',
{ title: 'Sunday' },
'Sun'
)
),
_react2.default.createElement(
'th',
{ scope: 'col' },
_react2.default.createElement(
'abbr',
{ title: 'Monday' },
'Mon'
)
),
_react2.default.createElement(
'th',
{ scope: 'col' },
_react2.default.createElement(
'abbr',
{ title: 'Tuesday' },
'Tue'
)
),
_react2.default.createElement(
'th',
{ scope: 'col' },
_react2.default.createElement(
'abbr',
{ title: 'Wednesday' },
'Wed'
)
),
_react2.default.createElement(
'th',
{ scope: 'col' },
_react2.default.createElement(
'abbr',
{ title: 'Thursday' },
'Thu'
)
),
_react2.default.createElement(
'th',
{ scope: 'col' },
_react2.default.createElement(
'abbr',
{ title: 'Friday' },
'Fri'
)
),
_react2.default.createElement(
'th',
{ scope: 'col' },
_react2.default.createElement(
'abbr',
{ title: 'Saturday' },
'Sat'
)
)
)
),
_react2.default.createElement(
'tbody',
null,
this.weeks.map(this.renderWeek)
)
)
);
return _react.default.createElement("div", {
className: "react-daypicker-root"
}, _react.default.createElement("div", {
className: "header"
}, _react.default.createElement("div", {
className: "previous-month",
onClick: this.previousMonth
}, "\u25C0"), _react.default.createElement("div", {
className: "month-year"
}, this.month.format('MMMM YYYY')), _react.default.createElement("div", {
className: "next-month",
onClick: this.nextMonth
}, "\u25B6")), _react.default.createElement("table", null, _react.default.createElement("thead", null, _react.default.createElement("tr", null, _react.default.createElement("th", {
scope: "col"
}, _react.default.createElement("abbr", {
title: "Sunday"
}, "Sun")), _react.default.createElement("th", {
scope: "col"
}, _react.default.createElement("abbr", {
title: "Monday"
}, "Mon")), _react.default.createElement("th", {
scope: "col"
}, _react.default.createElement("abbr", {
title: "Tuesday"
}, "Tue")), _react.default.createElement("th", {
scope: "col"
}, _react.default.createElement("abbr", {
title: "Wednesday"
}, "Wed")), _react.default.createElement("th", {
scope: "col"
}, _react.default.createElement("abbr", {
title: "Thursday"
}, "Thu")), _react.default.createElement("th", {
scope: "col"
}, _react.default.createElement("abbr", {
title: "Friday"
}, "Fri")), _react.default.createElement("th", {
scope: "col"
}, _react.default.createElement("abbr", {
title: "Saturday"
}, "Sat")))), _react.default.createElement("tbody", null, this.weeks.map(this.renderWeek))));
}
}, {
key: 'days',
key: "days",
get: function get() {

@@ -235,2 +168,3 @@ var days = [];

var offset = this.month.date(0).day() + 1;
if (offset < 7) {

@@ -241,9 +175,11 @@ for (var i = 0; i < offset; i++) {

}
for (var _i = 1; _i <= daysInMonth; _i++) {
days.push(_i);
}
return days;
}
}, {
key: 'weeks',
key: "weeks",
get: function get() {

@@ -253,9 +189,11 @@ var days = this.days;

var weekCount = Math.ceil(days.length / 7);
for (var i = 0; i < weekCount; i++) {
weeks.push(days.slice(i * 7, (i + 1) * 7));
}
return weeks;
}
}, {
key: 'month',
key: "month",
get: function get() {

@@ -269,6 +207,7 @@ return this.state.month.clone();

DayPicker.propTypes = {
active: _reactMomentProptypes2.default.momentObj,
onDayClick: _propTypes2.default.func.isRequired
};
exports.default = DayPicker;
exports.default = DayPicker;
_defineProperty(DayPicker, "propTypes", {
active: _reactMomentProptypes.default.momentObj,
onDayClick: _propTypes.default.func.isRequired
});
{
"name": "react-daypicker",
"version": "1.1.0",
"version": "2.0.0-beta",
"description": "A simple datepicker inspired by Pikaday.",

@@ -22,7 +22,8 @@ "main": "lib/DayPicker.js",

"devDependencies": {
"babel-cli": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.18.0",
"babel-plugin-transform-react-jsx": "^6.8.0",
"babel-preset-es2015": "^6.18.0",
"node-sass": "^3.10.1"
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"node-sass": "^4.11.0"
},

@@ -42,4 +43,4 @@ "repository": {

"dependencies": {
"react-moment-proptypes": "^1.2.0"
"react-moment-proptypes": "^1.6.0"
}
}

@@ -5,2 +5,4 @@ # react-daypicker

[![Downloads][downloads-image]][downloads-url]
![minified size](https://badgen.net/bundlephobia/min/react-daypicker)
![minzipped size](https://badgen.net/bundlephobia/minzip/react-daypicker)

@@ -72,2 +74,3 @@ [![npm badge][npm-badge-png]][package-url]

* classnames
* prop-types

@@ -74,0 +77,0 @@ ## Developing

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