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

react-datepicker

Package Overview
Dependencies
Maintainers
2
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-datepicker - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

2

bower.json
{
"name": "react-date-picker",
"version": "0.9.0",
"version": "0.10.0",
"authors": [

@@ -5,0 +5,0 @@ "Remon Oldenbeuving <remon@hackerone.com>",

@@ -182,3 +182,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

placeholderText: this.props.placeholderText,
disabled: this.props.disabled }),
disabled: this.props.disabled,
className: this.props.className }),
this.props.disabled ? null : this.calendar()

@@ -571,3 +572,7 @@ );

moveElement: false // always moves to <body> anyway!
}
},
constraints: [{
to: 'window',
attachment: 'together'
}]
};

@@ -623,3 +628,4 @@ },

return {
dateFormat: 'YYYY-MM-DD'
dateFormat: 'YYYY-MM-DD',
className: 'datepicker__input'
};

@@ -697,3 +703,3 @@ },

onChange: this.handleChange,
className: 'datepicker__input',
className: this.props.className,
placeholder: this.props.placeholderText,

@@ -700,0 +706,0 @@ disabled: this.props.disabled });

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("moment"),require("lodash"),require("react-onclickoutside"),require("tether")):"function"==typeof define&&define.amd?define(["react","moment","lodash","react-onclickoutside","tether"],t):"object"==typeof exports?exports.DatePicker=t(require("react"),require("moment"),require("lodash"),require("react-onclickoutside"),require("tether")):e.DatePicker=t(e.React,e.moment,e._,e.OnClickOutside,e.Tether)}(this,function(e,t,n,a,s){return function(e){function t(a){if(n[a])return n[a].exports;var s=n[a]={exports:{},id:a,loaded:!1};return e[a].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";var a=n(2),s=n(8),o=(n(5),n(1)),r=n(10),i=n(4),c=a.createClass({displayName:"DatePicker",propTypes:{weekdays:a.PropTypes.arrayOf(a.PropTypes.string),locale:a.PropTypes.string,dateFormatCalendar:a.PropTypes.string,onChange:a.PropTypes.func.isRequired},getDefaultProps:function(){return{weekdays:["Su","Mo","Tu","We","Th","Fr","Sa"],locale:"en",dateFormatCalendar:"MMMM YYYY",moment:i,onChange:function(){},disabled:!1}},getInitialState:function(){return{focus:!1,selected:this.props.selected}},getValue:function(){return this.state.selected},handleFocus:function(){this.setState({focus:!0})},hideCalendar:function(){setTimeout(function(){this.setState({focus:!1})}.bind(this),0)},handleSelect:function(e){this.setSelected(e),setTimeout(function(){this.hideCalendar()}.bind(this),200)},setSelected:function(e){var t=e.moment();this.props.onChange(t),this.setState({selected:t})},clearSelected:function(){this.props.onChange(null),this.setState({selected:null})},onInputClick:function(){this.setState({focus:!0})},calendar:function(){return this.state.focus?a.createElement(s,null,a.createElement(o,{weekdays:this.props.weekdays,locale:this.props.locale,moment:this.props.moment,dateFormat:this.props.dateFormatCalendar,selected:this.state.selected,onSelect:this.handleSelect,hideCalendar:this.hideCalendar,minDate:this.props.minDate,maxDate:this.props.maxDate,excludeDates:this.props.excludeDates,weekStart:this.props.weekStart})):void 0},render:function(){return a.createElement("div",null,a.createElement(r,{name:this.props.name,date:this.state.selected,dateFormat:this.props.dateFormat,focus:this.state.focus,onFocus:this.handleFocus,handleClick:this.onInputClick,handleEnter:this.hideCalendar,setSelected:this.setSelected,clearSelected:this.clearSelected,hideCalendar:this.hideCalendar,placeholderText:this.props.placeholderText,disabled:this.props.disabled}),this.props.disabled?null:this.calendar())}});e.exports=c},function(e,t,n){"use strict";var a=n(2),s=n(3),o=n(5),r=n(6),i=a.createClass({displayName:"Calendar",mixins:[n(7)],handleClickOutside:function(){this.props.hideCalendar()},getInitialState:function(){return{date:new o(this.props.selected).safeClone(this.props.moment())}},getDefaultProps:function(){return{weekStart:1}},componentWillMount:function(){this.initializeMomentLocale()},componentWillReceiveProps:function(e){null!==e.selected&&e.selected!==this.props.selected&&this.setState({date:new o(e.selected).clone()})},initializeMomentLocale:function(){var e=this.props.weekdays.slice(0);e=e.concat(e.splice(0,this.props.weekStart)),this.props.moment.locale(this.props.locale,{week:{dow:this.props.weekStart},weekdaysMin:e})},increaseMonth:function(){this.setState({date:this.state.date.addMonth()})},decreaseMonth:function(){this.setState({date:this.state.date.subtractMonth()})},weeks:function(){return this.state.date.mapWeeksInMonth(this.renderWeek)},handleDayClick:function(e){this.props.onSelect(e)},renderWeek:function(e,t){return e.weekInMonth(this.state.date)?a.createElement("div",{key:t},this.days(e)):void 0},renderDay:function(e,t){var n,i,c=new o(this.props.minDate).safeClone(),p=new o(this.props.maxDate).safeClone();return this.props.excludeDates&&Array.isArray(this.props.excludeDates)&&(n=r(this.props.excludeDates).map(function(e){return new o(e).safeClone()})),i=e.isBefore(c)||e.isAfter(p)||r(n).some(function(t){return e.sameDay(t)}),a.createElement(s,{key:t,day:e,date:this.state.date,onClick:this.handleDayClick.bind(this,e),selected:new o(this.props.selected),disabled:i})},days:function(e){return e.mapDaysInWeek(this.renderDay)},header:function(){return this.props.moment.weekdaysMin().map(function(e,t){return a.createElement("div",{className:"datepicker__day",key:t},e)})},render:function(){return a.createElement("div",{className:"datepicker"},a.createElement("div",{className:"datepicker__triangle"}),a.createElement("div",{className:"datepicker__header"},a.createElement("a",{className:"datepicker__navigation datepicker__navigation--previous",onClick:this.decreaseMonth}),a.createElement("span",{className:"datepicker__current-month"},this.state.date.localeFormat(this.props.locale,this.props.dateFormat)),a.createElement("a",{className:"datepicker__navigation datepicker__navigation--next",onClick:this.increaseMonth}),a.createElement("div",null,this.header())),a.createElement("div",{className:"datepicker__month"},this.weeks()))}});e.exports=i},function(t,n,a){t.exports=e},function(e,t,n){"use strict";var a=n(2),s=n(4),o=a.createClass({displayName:"Day",handleClick:function(e){this.props.disabled||this.props.onClick(e)},isWeekend:function(){var e=this.props.day.moment().weekday();return 5===e||6===e},render:function(){var e=["datepicker__day"];return this.props.disabled&&e.push("datepicker__day--disabled"),this.props.day.sameDay(this.props.selected)&&e.push("datepicker__day--selected"),this.props.day.sameDay(s())&&e.push("datepicker__day--today"),this.isWeekend()&&e.push("datepicker__day--weekend"),a.createElement("div",{className:e.join(" "),onClick:this.handleClick},this.props.day.day())}});e.exports=o},function(e,n,a){e.exports=t},function(e,t,n){"use strict";function a(e){this._date=e}a.prototype.isBefore=function(e){return this._date.isBefore(e._date,"day")},a.prototype.isAfter=function(e){return this._date.isAfter(e._date,"day")},a.prototype.sameDay=function(e){return this._date.isSame(e._date,"day")},a.prototype.sameMonth=function(e){return this._date.isSame(e._date,"month")},a.prototype.day=function(){return this._date.date()},a.prototype.mapDaysInWeek=function(e){for(var t=[],n=this._date.clone(),s=0;7>s;s++){var o=new a(n.clone().add(s,"days"));t[s]=e(o,s)}return t},a.prototype.mapWeeksInMonth=function(e){for(var t=[],n=this._date.clone().startOf("month").startOf("week"),s=0;6>s;s++){var o=new a(n.clone().add(s,"weeks"));t[s]=e(o,s)}return t},a.prototype.weekInMonth=function(e){var t=this._date.clone(),n=this._date.clone().weekday(7);return t.isSame(e._date,"month")||n.isSame(e._date,"month")},a.prototype.format=function(){return this._date.format.apply(this._date,arguments)},a.prototype.localeFormat=function(){var e=Array.prototype.slice.call(arguments),t=e.shift();return this._date.locale(t).format.apply(this._date,e)},a.prototype.addMonth=function(){return new a(this._date.clone().add(1,"month"))},a.prototype.subtractMonth=function(){return new a(this._date.clone().subtract(1,"month"))},a.prototype.clone=function(){return new a(this._date.clone())},a.prototype.safeClone=function(e){return this._date?this.clone():(void 0===e&&(e=null),new a(e))},a.prototype.moment=function(){return this._date},e.exports=a},function(e,t,a){e.exports=n},function(e,t,n){e.exports=a},function(e,t,n){"use strict";var a=n(2),s=a.createClass({displayName:"Popover",componentWillMount:function(){var e=document.createElement("span");e.className="datepicker__container",this._popoverElement=e,document.querySelector("body").appendChild(this._popoverElement)},componentDidMount:function(){this._renderPopover()},componentDidUpdate:function(){this._renderPopover()},_popoverComponent:function(){var e=this.props.className;return a.createElement("div",{className:e},this.props.children)},_tetherOptions:function(){return{element:this._popoverElement,target:this.getDOMNode().parentElement,attachment:"top left",targetAttachment:"bottom left",targetOffset:"10px 0",optimizations:{moveElement:!1}}},_renderPopover:function(){if(a.render(this._popoverComponent(),this._popoverElement),null!=this._tether)this._tether.setOptions(this._tetherOptions());else if(window&&document){var e=n(9);this._tether=new e(this._tetherOptions())}},componentWillUnmount:function(){this._tether.destroy(),a.unmountComponentAtNode(this._popoverElement),this._popoverElement.parentNode&&this._popoverElement.parentNode.removeChild(this._popoverElement)},render:function(){return a.createElement("span",null)}});e.exports=s},function(e,t,n){e.exports=s},function(e,t,n){"use strict";var a=n(2),s=n(5),o=n(4),r=a.createClass({displayName:"DateInput",getDefaultProps:function(){return{dateFormat:"YYYY-MM-DD"}},getInitialState:function(){return{value:this.safeDateFormat(this.props.date)}},componentDidMount:function(){this.toggleFocus(this.props.focus)},componentWillReceiveProps:function(e){this.toggleFocus(e.focus),this.setState({value:this.safeDateFormat(e.date)})},toggleFocus:function(e){e?a.findDOMNode(this.refs.input).focus():a.findDOMNode(this.refs.input).blur()},handleChange:function(e){var t=o(e.target.value,this.props.dateFormat,!0);this.setState({value:e.target.value}),t.isValid()?this.props.setSelected(new s(t)):""===e.target.value&&this.props.clearSelected()},safeDateFormat:function(e){return e?e.format(this.props.dateFormat):null},handleKeyDown:function(e){switch(e.key){case"Enter":e.preventDefault(),this.props.handleEnter()}},handleClick:function(e){this.props.disabled||this.props.handleClick(e)},render:function(){return a.createElement("input",{ref:"input",type:"text",name:this.props.name,value:this.state.value,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onFocus:this.props.onFocus,onChange:this.handleChange,className:"datepicker__input",placeholder:this.props.placeholderText,disabled:this.props.disabled})}});e.exports=r}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("moment"),require("lodash"),require("react-onclickoutside"),require("tether")):"function"==typeof define&&define.amd?define(["react","moment","lodash","react-onclickoutside","tether"],t):"object"==typeof exports?exports.DatePicker=t(require("react"),require("moment"),require("lodash"),require("react-onclickoutside"),require("tether")):e.DatePicker=t(e.React,e.moment,e._,e.OnClickOutside,e.Tether)}(this,function(e,t,n,s,a){return function(e){function t(s){if(n[s])return n[s].exports;var a=n[s]={exports:{},id:s,loaded:!1};return e[s].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";var s=n(2),a=n(8),o=(n(5),n(1)),r=n(10),i=n(4),c=s.createClass({displayName:"DatePicker",propTypes:{weekdays:s.PropTypes.arrayOf(s.PropTypes.string),locale:s.PropTypes.string,dateFormatCalendar:s.PropTypes.string,onChange:s.PropTypes.func.isRequired},getDefaultProps:function(){return{weekdays:["Su","Mo","Tu","We","Th","Fr","Sa"],locale:"en",dateFormatCalendar:"MMMM YYYY",moment:i,onChange:function(){},disabled:!1}},getInitialState:function(){return{focus:!1,selected:this.props.selected}},getValue:function(){return this.state.selected},handleFocus:function(){this.setState({focus:!0})},hideCalendar:function(){setTimeout(function(){this.setState({focus:!1})}.bind(this),0)},handleSelect:function(e){this.setSelected(e),setTimeout(function(){this.hideCalendar()}.bind(this),200)},setSelected:function(e){var t=e.moment();this.props.onChange(t),this.setState({selected:t})},clearSelected:function(){this.props.onChange(null),this.setState({selected:null})},onInputClick:function(){this.setState({focus:!0})},calendar:function(){return this.state.focus?s.createElement(a,null,s.createElement(o,{weekdays:this.props.weekdays,locale:this.props.locale,moment:this.props.moment,dateFormat:this.props.dateFormatCalendar,selected:this.state.selected,onSelect:this.handleSelect,hideCalendar:this.hideCalendar,minDate:this.props.minDate,maxDate:this.props.maxDate,excludeDates:this.props.excludeDates,weekStart:this.props.weekStart})):void 0},render:function(){return s.createElement("div",null,s.createElement(r,{name:this.props.name,date:this.state.selected,dateFormat:this.props.dateFormat,focus:this.state.focus,onFocus:this.handleFocus,handleClick:this.onInputClick,handleEnter:this.hideCalendar,setSelected:this.setSelected,clearSelected:this.clearSelected,hideCalendar:this.hideCalendar,placeholderText:this.props.placeholderText,disabled:this.props.disabled,className:this.props.className}),this.props.disabled?null:this.calendar())}});e.exports=c},function(e,t,n){"use strict";var s=n(2),a=n(3),o=n(5),r=n(6),i=s.createClass({displayName:"Calendar",mixins:[n(7)],handleClickOutside:function(){this.props.hideCalendar()},getInitialState:function(){return{date:new o(this.props.selected).safeClone(this.props.moment())}},getDefaultProps:function(){return{weekStart:1}},componentWillMount:function(){this.initializeMomentLocale()},componentWillReceiveProps:function(e){null!==e.selected&&e.selected!==this.props.selected&&this.setState({date:new o(e.selected).clone()})},initializeMomentLocale:function(){var e=this.props.weekdays.slice(0);e=e.concat(e.splice(0,this.props.weekStart)),this.props.moment.locale(this.props.locale,{week:{dow:this.props.weekStart},weekdaysMin:e})},increaseMonth:function(){this.setState({date:this.state.date.addMonth()})},decreaseMonth:function(){this.setState({date:this.state.date.subtractMonth()})},weeks:function(){return this.state.date.mapWeeksInMonth(this.renderWeek)},handleDayClick:function(e){this.props.onSelect(e)},renderWeek:function(e,t){return e.weekInMonth(this.state.date)?s.createElement("div",{key:t},this.days(e)):void 0},renderDay:function(e,t){var n,i,c=new o(this.props.minDate).safeClone(),p=new o(this.props.maxDate).safeClone();return this.props.excludeDates&&Array.isArray(this.props.excludeDates)&&(n=r(this.props.excludeDates).map(function(e){return new o(e).safeClone()})),i=e.isBefore(c)||e.isAfter(p)||r(n).some(function(t){return e.sameDay(t)}),s.createElement(a,{key:t,day:e,date:this.state.date,onClick:this.handleDayClick.bind(this,e),selected:new o(this.props.selected),disabled:i})},days:function(e){return e.mapDaysInWeek(this.renderDay)},header:function(){return this.props.moment.weekdaysMin().map(function(e,t){return s.createElement("div",{className:"datepicker__day",key:t},e)})},render:function(){return s.createElement("div",{className:"datepicker"},s.createElement("div",{className:"datepicker__triangle"}),s.createElement("div",{className:"datepicker__header"},s.createElement("a",{className:"datepicker__navigation datepicker__navigation--previous",onClick:this.decreaseMonth}),s.createElement("span",{className:"datepicker__current-month"},this.state.date.localeFormat(this.props.locale,this.props.dateFormat)),s.createElement("a",{className:"datepicker__navigation datepicker__navigation--next",onClick:this.increaseMonth}),s.createElement("div",null,this.header())),s.createElement("div",{className:"datepicker__month"},this.weeks()))}});e.exports=i},function(t,n,s){t.exports=e},function(e,t,n){"use strict";var s=n(2),a=n(4),o=s.createClass({displayName:"Day",handleClick:function(e){this.props.disabled||this.props.onClick(e)},isWeekend:function(){var e=this.props.day.moment().weekday();return 5===e||6===e},render:function(){var e=["datepicker__day"];return this.props.disabled&&e.push("datepicker__day--disabled"),this.props.day.sameDay(this.props.selected)&&e.push("datepicker__day--selected"),this.props.day.sameDay(a())&&e.push("datepicker__day--today"),this.isWeekend()&&e.push("datepicker__day--weekend"),s.createElement("div",{className:e.join(" "),onClick:this.handleClick},this.props.day.day())}});e.exports=o},function(e,n,s){e.exports=t},function(e,t,n){"use strict";function s(e){this._date=e}s.prototype.isBefore=function(e){return this._date.isBefore(e._date,"day")},s.prototype.isAfter=function(e){return this._date.isAfter(e._date,"day")},s.prototype.sameDay=function(e){return this._date.isSame(e._date,"day")},s.prototype.sameMonth=function(e){return this._date.isSame(e._date,"month")},s.prototype.day=function(){return this._date.date()},s.prototype.mapDaysInWeek=function(e){for(var t=[],n=this._date.clone(),a=0;7>a;a++){var o=new s(n.clone().add(a,"days"));t[a]=e(o,a)}return t},s.prototype.mapWeeksInMonth=function(e){for(var t=[],n=this._date.clone().startOf("month").startOf("week"),a=0;6>a;a++){var o=new s(n.clone().add(a,"weeks"));t[a]=e(o,a)}return t},s.prototype.weekInMonth=function(e){var t=this._date.clone(),n=this._date.clone().weekday(7);return t.isSame(e._date,"month")||n.isSame(e._date,"month")},s.prototype.format=function(){return this._date.format.apply(this._date,arguments)},s.prototype.localeFormat=function(){var e=Array.prototype.slice.call(arguments),t=e.shift();return this._date.locale(t).format.apply(this._date,e)},s.prototype.addMonth=function(){return new s(this._date.clone().add(1,"month"))},s.prototype.subtractMonth=function(){return new s(this._date.clone().subtract(1,"month"))},s.prototype.clone=function(){return new s(this._date.clone())},s.prototype.safeClone=function(e){return this._date?this.clone():(void 0===e&&(e=null),new s(e))},s.prototype.moment=function(){return this._date},e.exports=s},function(e,t,s){e.exports=n},function(e,t,n){e.exports=s},function(e,t,n){"use strict";var s=n(2),a=s.createClass({displayName:"Popover",componentWillMount:function(){var e=document.createElement("span");e.className="datepicker__container",this._popoverElement=e,document.querySelector("body").appendChild(this._popoverElement)},componentDidMount:function(){this._renderPopover()},componentDidUpdate:function(){this._renderPopover()},_popoverComponent:function(){var e=this.props.className;return s.createElement("div",{className:e},this.props.children)},_tetherOptions:function(){return{element:this._popoverElement,target:this.getDOMNode().parentElement,attachment:"top left",targetAttachment:"bottom left",targetOffset:"10px 0",optimizations:{moveElement:!1},constraints:[{to:"window",attachment:"together"}]}},_renderPopover:function(){if(s.render(this._popoverComponent(),this._popoverElement),null!=this._tether)this._tether.setOptions(this._tetherOptions());else if(window&&document){var e=n(9);this._tether=new e(this._tetherOptions())}},componentWillUnmount:function(){this._tether.destroy(),s.unmountComponentAtNode(this._popoverElement),this._popoverElement.parentNode&&this._popoverElement.parentNode.removeChild(this._popoverElement)},render:function(){return s.createElement("span",null)}});e.exports=a},function(e,t,n){e.exports=a},function(e,t,n){"use strict";var s=n(2),a=n(5),o=n(4),r=s.createClass({displayName:"DateInput",getDefaultProps:function(){return{dateFormat:"YYYY-MM-DD",className:"datepicker__input"}},getInitialState:function(){return{value:this.safeDateFormat(this.props.date)}},componentDidMount:function(){this.toggleFocus(this.props.focus)},componentWillReceiveProps:function(e){this.toggleFocus(e.focus),this.setState({value:this.safeDateFormat(e.date)})},toggleFocus:function(e){e?s.findDOMNode(this.refs.input).focus():s.findDOMNode(this.refs.input).blur()},handleChange:function(e){var t=o(e.target.value,this.props.dateFormat,!0);this.setState({value:e.target.value}),t.isValid()?this.props.setSelected(new a(t)):""===e.target.value&&this.props.clearSelected()},safeDateFormat:function(e){return e?e.format(this.props.dateFormat):null},handleKeyDown:function(e){switch(e.key){case"Enter":e.preventDefault(),this.props.handleEnter()}},handleClick:function(e){this.props.disabled||this.props.handleClick(e)},render:function(){return s.createElement("input",{ref:"input",type:"text",name:this.props.name,value:this.state.value,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onFocus:this.props.onFocus,onChange:this.handleChange,className:this.props.className,placeholder:this.props.placeholderText,disabled:this.props.disabled})}});e.exports=r}])});

@@ -5,3 +5,3 @@ {

"description": "A simple and reusable datepicker component for React",
"version": "0.9.0",
"version": "0.10.0",
"license": "MIT",

@@ -8,0 +8,0 @@ "homepage": "https://github.com/Hacker0x01/react-datepicker",

@@ -9,3 +9,4 @@ var React = require('react');

return {
dateFormat: 'YYYY-MM-DD'
dateFormat: 'YYYY-MM-DD',
className: 'datepicker__input'
};

@@ -83,3 +84,3 @@ },

onChange={this.handleChange}
className="datepicker__input"
className={this.props.className}
placeholder={this.props.placeholderText}

@@ -86,0 +87,0 @@ disabled={this.props.disabled} />;

@@ -121,3 +121,4 @@ var React = require('react');

placeholderText={this.props.placeholderText}
disabled={this.props.disabled} />
disabled={this.props.disabled}
className={this.props.className} />
{this.props.disabled ? null : this.calendar()}

@@ -124,0 +125,0 @@ </div>

@@ -41,3 +41,9 @@ var React = require('react');

moveElement: false // always moves to <body> anyway!
}
},
constraints: [
{
to: 'window',
attachment: 'together'
}
]
};

@@ -44,0 +50,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 too big to display

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