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

react-date-picker

Package Overview
Dependencies
Maintainers
1
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-date-picker - npm Package Compare versions

Comparing version 2.0.7 to 2.0.8

25

dist/react-date-picker.js

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

view: this.props.defaultView,
viewDate: this.props.defaultViewDate
viewDate: this.props.defaultViewDate,
defaultDate: this.props.defaultDate
}

@@ -178,3 +179,3 @@ },

date = date || this.viewMoment || this.props.date || new Date()
date = date || this.viewMoment || this.getDate() || new Date()

@@ -193,2 +194,14 @@ if (moment.isMoment(date)){

getDate: function() {
var date
if (this.props.date != null){
date = this.props.date
} else {
date = this.state.defaultDate
}
return date? this.toMoment(date): null
},
render: function() {

@@ -204,2 +217,4 @@

props.date = this.getDate()
props.viewDate = this.viewMoment = this.getViewDate()

@@ -471,2 +486,8 @@ props.locale = this.props.locale

if (this.props.date == null){
this.setState({
defaultDate: text
})
}
;(this.props.onChange || emptyFn)(text, date, event)

@@ -473,0 +494,0 @@ },

89

dist/react-date-picker.nomoment.js

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

view: this.props.defaultView,
viewDate: this.props.defaultViewDate
viewDate: this.props.defaultViewDate,
defaultDate: this.props.defaultDate
}

@@ -178,3 +179,3 @@ },

date = date || this.viewMoment || this.props.date || new Date()
date = date || this.viewMoment || this.getDate() || new Date()

@@ -193,2 +194,14 @@ if (moment.isMoment(date)){

getDate: function() {
var date
if (this.props.date != null){
date = this.props.date
} else {
date = this.state.defaultDate
}
return date? this.toMoment(date): null
},
render: function() {

@@ -204,2 +217,4 @@

props.date = this.getDate()
props.viewDate = this.viewMoment = this.getViewDate()

@@ -471,2 +486,8 @@ props.locale = this.props.locale

if (this.props.date == null){
this.setState({
defaultDate: text
})
}
;(this.props.onChange || emptyFn)(text, date, event)

@@ -523,3 +544,3 @@ },

var FORMAT = __webpack_require__(11)
var FORMAT = __webpack_require__(10)
var asConfig = __webpack_require__(8)

@@ -781,3 +802,3 @@ var toMoment = __webpack_require__(7)

var FORMAT = __webpack_require__(11)
var FORMAT = __webpack_require__(10)
var asConfig = __webpack_require__(8)

@@ -907,3 +928,3 @@ var toMoment = __webpack_require__(7)

var FORMAT = __webpack_require__(11)
var FORMAT = __webpack_require__(10)
var asConfig = __webpack_require__(8)

@@ -1100,3 +1121,3 @@ var toMoment = __webpack_require__(7)

var moment = __webpack_require__(2)
var CONFIG = __webpack_require__(10)
var CONFIG = __webpack_require__(11)

@@ -1137,3 +1158,3 @@ /**

var CONFIG = __webpack_require__(10)
var CONFIG = __webpack_require__(11)
var KEYS = Object.keys(CONFIG)

@@ -1217,2 +1238,29 @@

var CONFIG = __webpack_require__(11)
var toMoment = __webpack_require__(7)
function f(mom, format){
return toMoment(mom).format(format)
}
module.exports = {
day: function(mom, format) {
return f(mom, format || CONFIG.dayFormat)
},
month: function(mom, format) {
return f(mom, format || CONFIG.monthFormat)
},
year: function(mom, format) {
return f(mom, format || CONFIG.yearFormat)
}
}
/***/ },
/* 11 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
var getWeekDayNames = __webpack_require__(12)

@@ -1267,29 +1315,2 @@

/***/ },
/* 11 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
var CONFIG = __webpack_require__(10)
var toMoment = __webpack_require__(7)
function f(mom, format){
return toMoment(mom).format(format)
}
module.exports = {
day: function(mom, format) {
return f(mom, format || CONFIG.dayFormat)
},
month: function(mom, format) {
return f(mom, format || CONFIG.monthFormat)
},
year: function(mom, format) {
return f(mom, format || CONFIG.yearFormat)
}
}
/***/ },
/* 12 */

@@ -1296,0 +1317,0 @@ /***/ function(module, exports, __webpack_require__) {

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("moment"),require("React")):"function"==typeof define&&define.amd?define(["moment","React"],t):"object"==typeof exports?exports.DatePicker=t(require("moment"),require("React")):e.DatePicker=t(e.moment,e.React)}(this,function(e,t){return function(e){function t(n){if(a[n])return a[n].exports;var r=a[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var a={};return t.m=e,t.c=a,t.p="",t(0)}([function(e,t,a){"use strict";function n(){}var r=a(4),o=a(2),i=a(5),s=a(1),c=a(11),l=a(12),d=a(9),h=a(10),u=a(3),p=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m={month:c,year:l,decade:d},f=r.createClass({displayName:"DatePicker",propTypes:{todayText:r.PropTypes.string,gotoSelectedText:r.PropTypes.string,renderFooter:r.PropTypes.func,onChange:r.PropTypes.func,date:r.PropTypes.any,viewDate:r.PropTypes.any},getViewOrder:function(){return["month","year","decade"]},getDefaultProps:function(){var e=s({},i(),{navOnDateClick:!0,defaultStyle:{boxSizing:"border-box"}});return delete e.viewDate,delete e.date,e},getInitialState:function(){return{view:this.props.defaultView,viewDate:this.props.defaultViewDate}},getViewName:function(){var e=null!=this.props.view?this.props.view:this.state.view;return e||"month"},addViewIndex:function(e){var t=this.getViewName(),a=this.getViewOrder(),n=a.indexOf(t);return n+=e,n%a.length},getNextViewName:function(){return this.getViewOrder()[this.addViewIndex(1)]},getPrevViewName:function(){return this.getViewOrder()[this.addViewIndex(-1)]},getView:function(){return m[this.getViewName()]||m.month},getViewFactory:function(){var e=this.getView();return r.createFactory&&(e.__factory=e.__factory||r.createFactory(e),e=e.__factory),e},getViewDate:function(){var e=p(this.props,"viewDate")?this.props.viewDate:this.state.viewDate;return e=e||this.viewMoment||this.props.date||new Date,o.isMoment(e)&&(e=+e),e=this.toMoment(e)},render:function(){var e=s({},this.props);this.toMoment=function(t,a){return u(t,a||e.dateFormat,{locale:e.locale})};var t=this.getViewFactory();e.viewDate=this.viewMoment=this.getViewDate(),e.locale=this.props.locale,e.localeData=o.localeData(e.locale),e.renderDay=this.props.renderDay,e.onRenderDay=this.props.onRenderDay;var a=(this.props.className||"")+" date-picker";e.style=this.prepareStyle(e);var n=e,n=i(e);return n.localeData=e.localeData,n.onSelect=this.handleSelect,n.onChange=this.handleChange,r.createElement("div",r.__spread({className:a,style:e.style},this.props),r.createElement("div",{className:"dp-inner",style:{width:"100%",height:"100%",display:"flex",flexFlow:"column"}},this.renderHeader(t,e),r.createElement("div",{className:"dp-body",style:{flex:1}},r.createElement("div",{className:"dp-anim-target"},t(n))),this.renderFooter(e)))},prepareStyle:function(e){var t=s({},e.defaultStyle,e.style);return t},renderFooter:function(e){if(!this.props.hideFooter){this.props.today&&console.warn('Please use "todayText" prop instead of "today"!'),this.props.gotoSelected&&console.warn('Please use "gotoSelectedText" prop instead of "gotoSelected"!');var t,a=this.props.todayText||"Today",n=this.props.gotoSelectedText||"Go to selected",o={todayText:a,gotoSelectedText:n,onTodayClick:this.gotoNow,onGotoSelectedClick:this.gotoSelected,date:e.date,viewDate:e.viewDate};return"function"==typeof this.props.renderFooter&&(t=this.props.renderFooter(o)),void 0!==t?t:r.createElement("div",{className:"dp-footer"},r.createElement("div",{className:"dp-footer-today",onClick:this.gotoNow},a),r.createElement("div",{className:"dp-footer-selected",onClick:this.gotoSelected},n))}},gotoNow:function(){this.gotoDate(+new Date)},gotoSelected:function(){this.gotoDate(this.props.date||+new Date)},gotoDate:function(e){this.setView("month"),this.setViewDate(e)},getViewColspan:function(){var e={month:5,year:2,decade:2};return e[this.getViewName()]},renderHeader:function(e,t){t=t||this.props;var a=this.getViewDate(),n=this.getView().getHeaderText(a,t),o=this.getViewColspan(),i=this.props.navPrev,s=this.props.navNext;return r.createElement(h,{prevText:i,nextText:s,colspan:o,onPrev:this.handleNavPrev,onNext:this.handleNavNext,onChange:this.handleViewChange},n)},handleRenderDay:function(e){return(this.props.renderDay||n)(e)||[]},handleViewChange:function(){this.setView(this.getNextViewName())},setView:function(e){"function"==typeof this.props.onViewChange&&this.props.onViewChange(e),null==this.props.view&&this.setState({view:e})},setViewDate:function(e){e=this.toMoment(e);var t=this.props.onViewDateChange;if("function"==typeof t){var a=e.format(this.props.dateFormat),n=this.getViewName();t(a,e,n)}p(this.props,"viewDate")||this.setState({viewDate:e})},getNext:function(){var e=this.getViewDate(),t=this.toMoment;return{month:function(){return t(e).add(1,"month")},year:function(){return t(e).add(1,"year")},decade:function(){return t(e).add(10,"year")}}[this.getViewName()]()},getPrev:function(){var e=this.getViewDate(),t=this.toMoment;return{month:function(){return t(e).add(-1,"month")},year:function(){return t(e).add(-1,"year")},decade:function(){return t(e).add(-10,"year")}}[this.getViewName()]()},handleNavigation:function(e,t){var a=-1==e?this.getPrev():this.getNext();if(this.setViewDate(a),"function"==typeof this.props.onNav){var n=a.format(this.props.dateFormat),r=this.getViewName();this.props.onNav(n,a,r,e,t)}},handleNavPrev:function(e){this.handleNavigation(-1,e)},handleNavNext:function(e){this.handleNavigation(1,e)},handleChange:function(e,t){if(e=this.toMoment(e),this.props.navOnDateClick){var a=this.toMoment(this.getViewDate()),r=a.format("YYYY-MM"),o=e.format("YYYY-MM");o>r?this.handleNavNext(t):r>o&&this.handleNavPrev(t)}var i=e.format(this.props.dateFormat);(this.props.onChange||n)(i,e,t)},handleSelect:function(e,t){var a=this.getViewName(),n={decade:"year",year:"month"}[a],r=e.get(n),o=this.toMoment(this.getViewDate()).set(n,r),i=this.getPrevViewName();if(this.setViewDate(o),this.setView(i),"function"==typeof this.props.onSelect){var s=o.format(this.props.dateFormat);this.props.onSelect(s,o,i,t)}}});e.exports=f},function(e){"use strict";function t(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=Object.assign||function(e){for(var a,n,r=t(e),o=1;o<arguments.length;o++){a=arguments[o],n=Object.keys(Object(a));for(var i=0;i<n.length;i++)r[n[i]]=a[n[i]]}return r}},function(t){t.exports=e},function(e,t,a){"use strict";var n=a(2),r=a(6);e.exports=function(e,t,a){var o=!(!a||!a.strict),i=a&&a.locale;return t=t||r.dateFormat,"string"==typeof e?n(e,t,i,o):n(null==e?new Date:e,void 0,i,o)}},function(e){e.exports=t},function(e,t,a){"use strict";function n(e,t,a){return e&&a.forEach(function(a){t[a]=e[a]}),t}var r=a(1),o=a(6),i=Object.keys(o);e.exports=function(e,t){var a=i;return t&&(a=Object.keys(t)),t=t||o,e?n(e,r({},t),a):r({},t)}},function(e,t,a){"use strict";var n=a(8);e.exports={weekDayNames:n,weekStartDay:null,locale:null,dayFormat:"D",monthFormat:"MMMM",yearFormat:"YYYY",navPrev:"‹",navNext:"›",view:null,date:null,minDate:null,maxDate:null,viewDate:null,dateFormat:"YYYY-MM-DD"}},function(e,t,a){"use strict";function n(e,t){return o(e).format(t)}var r=a(6),o=a(3);e.exports={day:function(e,t){return n(e,t||r.dayFormat)},month:function(e,t){return n(e,t||r.monthFormat)},year:function(e,t){return n(e,t||r.yearFormat)}}},function(e,t,a){"use strict";var n=a(2),r=1*n().startOf("week").format("d");e.exports=function(e,t){var a;if(t){var o=n.localeData(t);a=o&&o._weekdaysShort?o._weekdaysShort:a}a=(a||n.weekdaysShort()).concat();for(var i=a,s=null==e?r:e;s>0;)i.push(i.shift()),s--;return i}},function(e,t,a){"use strict";function n(){}var r,o=a(4),i=a(2),s=a(1),c=a(7),l=a(5),s=(a(3),a(1)),d=o.createClass({displayName:"DecadeView",getDefaultProps:function(){return l()},getYearsInDecade:function(e){var t=i(e).get("year"),a=t%10;t=t-a-1;for(var n=[],r=0,o=i(t,"YYYY").startOf("year");12>r;r++)n.push(i(o)),o.add(1,"year");return n},render:function(){r=+i().startOf("day");var e=s({},this.props),t=e.viewMoment=i(this.props.viewDate);e.date&&(e.moment=i(e.date).startOf("year"));var a=this.getYearsInDecade(t);return o.createElement("table",{className:"dp-table dp-decade-view"},o.createElement("tbody",null,this.renderYears(e,a)))},renderYears:function(e,t){for(var a=t.map(function(t,a,n){return this.renderYear(e,t,a,n)},this),n=t.length,r=[],i=Math.ceil(n/4),s=0;i>s;s++)r.push(a.slice(4*s,4*(s+1)));return r.map(function(e,t){return o.createElement("tr",{key:"row"+t},e)})},renderYear:function(e,t,a,n){var r=c.year(t,e.yearFormat),i=["dp-cell dp-year"],s=+t;return s==e.moment&&i.push("dp-value"),a||i.push("dp-prev"),a==n.length-1&&i.push("dp-next"),o.createElement("td",{key:r,className:i.join(" "),onClick:this.handleClick.bind(this,e,t)},r)},handleClick:function(e,t,a){a.target.value=t,(e.onSelect||n)(t,a)}});d.getHeaderText=function(e){var t=i(e).get("year"),a=t%10;return t=t-a-1,t+" - "+(t+11)},e.exports=d},function(e,t,a){"use strict";var n=a(4),r=n.PropTypes;e.exports=n.createClass({displayName:"DatePickerHeader",propTypes:{onChange:r.func,onPrev:r.func,onNext:r.func,colspan:r.number,children:r.node},render:function(){var e=this.props;return n.createElement("div",{className:"dp-header"},n.createElement("table",{className:"dp-nav-table"},n.createElement("tbody",null,n.createElement("tr",{className:"dp-row"},n.createElement("td",{className:"dp-prev-nav dp-nav-cell dp-cell",onClick:e.onPrev},e.prevText),n.createElement("td",{className:"dp-nav-view dp-cell",colSpan:e.colspan,onClick:e.onChange},e.children),n.createElement("td",{className:"dp-next-nav dp-nav-cell dp-cell",onClick:e.onNext},e.nextText)))))}})},function(e,t,a){"use strict";function n(){}var r,o=a(4),i=(a(2),a(1)),s=a(7),c=a(5),l=a(3),d=o.createClass({displayName:"MonthView",formatAsDay:function(e,t){return e.format(t||"D")},getDefaultProps:function(){return c()},getWeekStartMoment:function(e){var t=this.weekStartDay,a=this.toMoment(e).day(t);return a},getDaysInMonth:function(e){var t=this.toMoment(e).startOf("month"),a=this.getWeekStartMoment(t),n=[],r=0;for(t.add(-1,"days").isBefore(a)&&a.add(-1,"weeks");42>r;r++)n.push(this.toMoment(a)),a.add(1,"days");return n},render:function(){var e=i({},this.props);this.toMoment=function(t,a){return l(t,a||e.dateFormat,{locale:e.locale})},r=+this.toMoment().startOf("day");var t=e.dateFormat,a=e.viewMoment=this.toMoment(e.viewDate,t),n=e.weekStartDay;null==n&&(n=e.localeData._week?e.localeData._week.dow:null),this.weekStartDay=e.weekStartDay=n,e.minDate&&(e.minDate=+this.toMoment(e.minDate,t)),e.maxDate&&(e.maxDate=+this.toMoment(e.maxDate,t)),this.monthFirst=this.toMoment(a).startOf("month"),this.monthLast=this.toMoment(a).endOf("month"),e.date&&(e.moment=this.toMoment(e.date).startOf("day"));var s=this.getDaysInMonth(a);return o.createElement("table",{className:"dp-table dp-month-view"},o.createElement("tbody",null,this.renderWeekDayNames(),this.renderDays(e,s)))},renderDays:function(e,t){for(var a=t.map(function(t){return this.renderDay(e,t)},this),n=t.length,r=[],i=Math.ceil(n/7),s=0;i>s;s++)r.push(a.slice(7*s,7*(s+1)));return r.map(function(e,t){return o.createElement("tr",{key:"row"+t,className:"dp-week dp-row"},e)})},renderDay:function(e,t){var a=s.day(t,e.dayFormat),n=["dp-cell dp-day"],i=+t;i==r?n.push("dp-current"):i<this.monthFirst?n.push("dp-prev"):i>this.monthLast&&n.push("dp-next"),e.minDate&&t<e.minDate&&n.push("dp-disabled dp-before-min"),e.maxDate&&t>e.maxDate&&n.push("dp-disabled dp-after-max"),i==e.moment&&n.push("dp-value");var c={key:a,text:a,date:t,className:n.join(" "),style:{},onClick:this.handleClick.bind(this,e,t,i),children:a};"function"==typeof e.onRenderDay&&(c=e.onRenderDay(c));var l=o.DOM.td,d=e.renderDay||l,h=d(c);return void 0===h&&(h=l(c)),h},getWeekDayNames:function(e){e=e||this.props;var t=e.weekDayNames,a=this.weekStartDay;if("function"==typeof t)t=t(a,e.locale);else if(Array.isArray(t)){t=[].concat(t);for(var n=a;n>0;)t.push(t.shift()),n--}return t},renderWeekDayNames:function(){var e=this.getWeekDayNames();return o.createElement("tr",{className:"dp-row dp-week-day-names"},e.map(function(e){return o.createElement("td",{key:e,className:"dp-cell dp-week-day-name"},e)}))},handleClick:function(e,t,a,r){e.minDate&&a<e.minDate||e.maxDate&&a>e.maxDate||(r.target.value=t,(e.onChange||n)(t,r))}});d.getHeaderText=function(e,t){return l(e,null,{locale:t.locale}).format("MMMM YYYY")},e.exports=d},function(e,t,a){"use strict";function n(){}var r,o=a(4),i=a(2),s=a(7),c=a(5),l=a(3),d=a(1),h=o.createClass({displayName:"YearView",getDefaultProps:function(){return c()},getMonthsInYear:function(e){for(var t=i(e).startOf("year"),a=[],n=0;12>n;n++)a.push(i(t)),t.add(1,"month");return a},render:function(){r=+i().startOf("day");var e=d({},this.props),t=e.viewMoment=i(this.props.viewDate);e.date&&(e.moment=i(e.date).startOf("month"));var a=this.getMonthsInYear(t);return o.createElement("table",{className:"dp-table dp-year-view"},o.createElement("tbody",null,this.renderMonths(e,a)))},renderMonths:function(e,t){for(var a=t.map(function(t){return this.renderMonth(e,t)},this),n=t.length,r=[],i=Math.ceil(n/4),s=0;i>s;s++)r.push(a.slice(4*s,4*(s+1)));return r.map(function(e,t){return o.createElement("tr",{key:"row"+t},e)})},renderMonth:function(e,t){var a=s.month(t,e.monthFormat),n=["dp-cell dp-month"],r=+t;return r==e.moment&&n.push("dp-value"),o.createElement("td",{key:a,className:n.join(" "),onClick:this.handleClick.bind(this,e,t)},a)},handleClick:function(e,t,a){a.target.value=t,(e.onSelect||n)(t,a)}});h.getHeaderText=function(e,t){return l(e,null,{locale:t.locale}).format("YYYY")},e.exports=h}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("moment"),require("React")):"function"==typeof define&&define.amd?define(["moment","React"],t):"object"==typeof exports?exports.DatePicker=t(require("moment"),require("React")):e.DatePicker=t(e.moment,e.React)}(this,function(e,t){return function(e){function t(n){if(a[n])return a[n].exports;var r=a[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var a={};return t.m=e,t.c=a,t.p="",t(0)}([function(e,t,a){"use strict";function n(){}var r=a(4),o=a(2),i=a(5),s=a(1),c=a(11),l=a(12),d=a(9),h=a(10),u=a(3),p=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m={month:c,year:l,decade:d},f=r.createClass({displayName:"DatePicker",propTypes:{todayText:r.PropTypes.string,gotoSelectedText:r.PropTypes.string,renderFooter:r.PropTypes.func,onChange:r.PropTypes.func,date:r.PropTypes.any,viewDate:r.PropTypes.any},getViewOrder:function(){return["month","year","decade"]},getDefaultProps:function(){var e=s({},i(),{navOnDateClick:!0,defaultStyle:{boxSizing:"border-box"}});return delete e.viewDate,delete e.date,e},getInitialState:function(){return{view:this.props.defaultView,viewDate:this.props.defaultViewDate,defaultDate:this.props.defaultDate}},getViewName:function(){var e=null!=this.props.view?this.props.view:this.state.view;return e||"month"},addViewIndex:function(e){var t=this.getViewName(),a=this.getViewOrder(),n=a.indexOf(t);return n+=e,n%a.length},getNextViewName:function(){return this.getViewOrder()[this.addViewIndex(1)]},getPrevViewName:function(){return this.getViewOrder()[this.addViewIndex(-1)]},getView:function(){return m[this.getViewName()]||m.month},getViewFactory:function(){var e=this.getView();return r.createFactory&&(e.__factory=e.__factory||r.createFactory(e),e=e.__factory),e},getViewDate:function(){var e=p(this.props,"viewDate")?this.props.viewDate:this.state.viewDate;return e=e||this.viewMoment||this.getDate()||new Date,o.isMoment(e)&&(e=+e),e=this.toMoment(e)},getDate:function(){var e;return e=null!=this.props.date?this.props.date:this.state.defaultDate,e?this.toMoment(e):null},render:function(){var e=s({},this.props);this.toMoment=function(t,a){return u(t,a||e.dateFormat,{locale:e.locale})};var t=this.getViewFactory();e.date=this.getDate(),e.viewDate=this.viewMoment=this.getViewDate(),e.locale=this.props.locale,e.localeData=o.localeData(e.locale),e.renderDay=this.props.renderDay,e.onRenderDay=this.props.onRenderDay;var a=(this.props.className||"")+" date-picker";e.style=this.prepareStyle(e);var n=e,n=i(e);return n.localeData=e.localeData,n.onSelect=this.handleSelect,n.onChange=this.handleChange,r.createElement("div",r.__spread({className:a,style:e.style},this.props),r.createElement("div",{className:"dp-inner",style:{width:"100%",height:"100%",display:"flex",flexFlow:"column"}},this.renderHeader(t,e),r.createElement("div",{className:"dp-body",style:{flex:1}},r.createElement("div",{className:"dp-anim-target"},t(n))),this.renderFooter(e)))},prepareStyle:function(e){var t=s({},e.defaultStyle,e.style);return t},renderFooter:function(e){if(!this.props.hideFooter){this.props.today&&console.warn('Please use "todayText" prop instead of "today"!'),this.props.gotoSelected&&console.warn('Please use "gotoSelectedText" prop instead of "gotoSelected"!');var t,a=this.props.todayText||"Today",n=this.props.gotoSelectedText||"Go to selected",o={todayText:a,gotoSelectedText:n,onTodayClick:this.gotoNow,onGotoSelectedClick:this.gotoSelected,date:e.date,viewDate:e.viewDate};return"function"==typeof this.props.renderFooter&&(t=this.props.renderFooter(o)),void 0!==t?t:r.createElement("div",{className:"dp-footer"},r.createElement("div",{className:"dp-footer-today",onClick:this.gotoNow},a),r.createElement("div",{className:"dp-footer-selected",onClick:this.gotoSelected},n))}},gotoNow:function(){this.gotoDate(+new Date)},gotoSelected:function(){this.gotoDate(this.props.date||+new Date)},gotoDate:function(e){this.setView("month"),this.setViewDate(e)},getViewColspan:function(){var e={month:5,year:2,decade:2};return e[this.getViewName()]},renderHeader:function(e,t){t=t||this.props;var a=this.getViewDate(),n=this.getView().getHeaderText(a,t),o=this.getViewColspan(),i=this.props.navPrev,s=this.props.navNext;return r.createElement(h,{prevText:i,nextText:s,colspan:o,onPrev:this.handleNavPrev,onNext:this.handleNavNext,onChange:this.handleViewChange},n)},handleRenderDay:function(e){return(this.props.renderDay||n)(e)||[]},handleViewChange:function(){this.setView(this.getNextViewName())},setView:function(e){"function"==typeof this.props.onViewChange&&this.props.onViewChange(e),null==this.props.view&&this.setState({view:e})},setViewDate:function(e){e=this.toMoment(e);var t=this.props.onViewDateChange;if("function"==typeof t){var a=e.format(this.props.dateFormat),n=this.getViewName();t(a,e,n)}p(this.props,"viewDate")||this.setState({viewDate:e})},getNext:function(){var e=this.getViewDate(),t=this.toMoment;return{month:function(){return t(e).add(1,"month")},year:function(){return t(e).add(1,"year")},decade:function(){return t(e).add(10,"year")}}[this.getViewName()]()},getPrev:function(){var e=this.getViewDate(),t=this.toMoment;return{month:function(){return t(e).add(-1,"month")},year:function(){return t(e).add(-1,"year")},decade:function(){return t(e).add(-10,"year")}}[this.getViewName()]()},handleNavigation:function(e,t){var a=-1==e?this.getPrev():this.getNext();if(this.setViewDate(a),"function"==typeof this.props.onNav){var n=a.format(this.props.dateFormat),r=this.getViewName();this.props.onNav(n,a,r,e,t)}},handleNavPrev:function(e){this.handleNavigation(-1,e)},handleNavNext:function(e){this.handleNavigation(1,e)},handleChange:function(e,t){if(e=this.toMoment(e),this.props.navOnDateClick){var a=this.toMoment(this.getViewDate()),r=a.format("YYYY-MM"),o=e.format("YYYY-MM");o>r?this.handleNavNext(t):r>o&&this.handleNavPrev(t)}var i=e.format(this.props.dateFormat);null==this.props.date&&this.setState({defaultDate:i}),(this.props.onChange||n)(i,e,t)},handleSelect:function(e,t){var a=this.getViewName(),n={decade:"year",year:"month"}[a],r=e.get(n),o=this.toMoment(this.getViewDate()).set(n,r),i=this.getPrevViewName();if(this.setViewDate(o),this.setView(i),"function"==typeof this.props.onSelect){var s=o.format(this.props.dateFormat);this.props.onSelect(s,o,i,t)}}});e.exports=f},function(e){"use strict";function t(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=Object.assign||function(e){for(var a,n,r=t(e),o=1;o<arguments.length;o++){a=arguments[o],n=Object.keys(Object(a));for(var i=0;i<n.length;i++)r[n[i]]=a[n[i]]}return r}},function(t){t.exports=e},function(e,t,a){"use strict";var n=a(2),r=a(6);e.exports=function(e,t,a){var o=!(!a||!a.strict),i=a&&a.locale;return t=t||r.dateFormat,"string"==typeof e?n(e,t,i,o):n(null==e?new Date:e,void 0,i,o)}},function(e){e.exports=t},function(e,t,a){"use strict";function n(e,t,a){return e&&a.forEach(function(a){t[a]=e[a]}),t}var r=a(1),o=a(6),i=Object.keys(o);e.exports=function(e,t){var a=i;return t&&(a=Object.keys(t)),t=t||o,e?n(e,r({},t),a):r({},t)}},function(e,t,a){"use strict";var n=a(8);e.exports={weekDayNames:n,weekStartDay:null,locale:null,dayFormat:"D",monthFormat:"MMMM",yearFormat:"YYYY",navPrev:"‹",navNext:"›",view:null,date:null,minDate:null,maxDate:null,viewDate:null,dateFormat:"YYYY-MM-DD"}},function(e,t,a){"use strict";function n(e,t){return o(e).format(t)}var r=a(6),o=a(3);e.exports={day:function(e,t){return n(e,t||r.dayFormat)},month:function(e,t){return n(e,t||r.monthFormat)},year:function(e,t){return n(e,t||r.yearFormat)}}},function(e,t,a){"use strict";var n=a(2),r=1*n().startOf("week").format("d");e.exports=function(e,t){var a;if(t){var o=n.localeData(t);a=o&&o._weekdaysShort?o._weekdaysShort:a}a=(a||n.weekdaysShort()).concat();for(var i=a,s=null==e?r:e;s>0;)i.push(i.shift()),s--;return i}},function(e,t,a){"use strict";function n(){}var r,o=a(4),i=a(2),s=a(1),c=a(7),l=a(5),s=(a(3),a(1)),d=o.createClass({displayName:"DecadeView",getDefaultProps:function(){return l()},getYearsInDecade:function(e){var t=i(e).get("year"),a=t%10;t=t-a-1;for(var n=[],r=0,o=i(t,"YYYY").startOf("year");12>r;r++)n.push(i(o)),o.add(1,"year");return n},render:function(){r=+i().startOf("day");var e=s({},this.props),t=e.viewMoment=i(this.props.viewDate);e.date&&(e.moment=i(e.date).startOf("year"));var a=this.getYearsInDecade(t);return o.createElement("table",{className:"dp-table dp-decade-view"},o.createElement("tbody",null,this.renderYears(e,a)))},renderYears:function(e,t){for(var a=t.map(function(t,a,n){return this.renderYear(e,t,a,n)},this),n=t.length,r=[],i=Math.ceil(n/4),s=0;i>s;s++)r.push(a.slice(4*s,4*(s+1)));return r.map(function(e,t){return o.createElement("tr",{key:"row"+t},e)})},renderYear:function(e,t,a,n){var r=c.year(t,e.yearFormat),i=["dp-cell dp-year"],s=+t;return s==e.moment&&i.push("dp-value"),a||i.push("dp-prev"),a==n.length-1&&i.push("dp-next"),o.createElement("td",{key:r,className:i.join(" "),onClick:this.handleClick.bind(this,e,t)},r)},handleClick:function(e,t,a){a.target.value=t,(e.onSelect||n)(t,a)}});d.getHeaderText=function(e){var t=i(e).get("year"),a=t%10;return t=t-a-1,t+" - "+(t+11)},e.exports=d},function(e,t,a){"use strict";var n=a(4),r=n.PropTypes;e.exports=n.createClass({displayName:"DatePickerHeader",propTypes:{onChange:r.func,onPrev:r.func,onNext:r.func,colspan:r.number,children:r.node},render:function(){var e=this.props;return n.createElement("div",{className:"dp-header"},n.createElement("table",{className:"dp-nav-table"},n.createElement("tbody",null,n.createElement("tr",{className:"dp-row"},n.createElement("td",{className:"dp-prev-nav dp-nav-cell dp-cell",onClick:e.onPrev},e.prevText),n.createElement("td",{className:"dp-nav-view dp-cell",colSpan:e.colspan,onClick:e.onChange},e.children),n.createElement("td",{className:"dp-next-nav dp-nav-cell dp-cell",onClick:e.onNext},e.nextText)))))}})},function(e,t,a){"use strict";function n(){}var r,o=a(4),i=(a(2),a(1)),s=a(7),c=a(5),l=a(3),d=o.createClass({displayName:"MonthView",formatAsDay:function(e,t){return e.format(t||"D")},getDefaultProps:function(){return c()},getWeekStartMoment:function(e){var t=this.weekStartDay,a=this.toMoment(e).day(t);return a},getDaysInMonth:function(e){var t=this.toMoment(e).startOf("month"),a=this.getWeekStartMoment(t),n=[],r=0;for(t.add(-1,"days").isBefore(a)&&a.add(-1,"weeks");42>r;r++)n.push(this.toMoment(a)),a.add(1,"days");return n},render:function(){var e=i({},this.props);this.toMoment=function(t,a){return l(t,a||e.dateFormat,{locale:e.locale})},r=+this.toMoment().startOf("day");var t=e.dateFormat,a=e.viewMoment=this.toMoment(e.viewDate,t),n=e.weekStartDay;null==n&&(n=e.localeData._week?e.localeData._week.dow:null),this.weekStartDay=e.weekStartDay=n,e.minDate&&(e.minDate=+this.toMoment(e.minDate,t)),e.maxDate&&(e.maxDate=+this.toMoment(e.maxDate,t)),this.monthFirst=this.toMoment(a).startOf("month"),this.monthLast=this.toMoment(a).endOf("month"),e.date&&(e.moment=this.toMoment(e.date).startOf("day"));var s=this.getDaysInMonth(a);return o.createElement("table",{className:"dp-table dp-month-view"},o.createElement("tbody",null,this.renderWeekDayNames(),this.renderDays(e,s)))},renderDays:function(e,t){for(var a=t.map(function(t){return this.renderDay(e,t)},this),n=t.length,r=[],i=Math.ceil(n/7),s=0;i>s;s++)r.push(a.slice(7*s,7*(s+1)));return r.map(function(e,t){return o.createElement("tr",{key:"row"+t,className:"dp-week dp-row"},e)})},renderDay:function(e,t){var a=s.day(t,e.dayFormat),n=["dp-cell dp-day"],i=+t;i==r?n.push("dp-current"):i<this.monthFirst?n.push("dp-prev"):i>this.monthLast&&n.push("dp-next"),e.minDate&&t<e.minDate&&n.push("dp-disabled dp-before-min"),e.maxDate&&t>e.maxDate&&n.push("dp-disabled dp-after-max"),i==e.moment&&n.push("dp-value");var c={key:a,text:a,date:t,className:n.join(" "),style:{},onClick:this.handleClick.bind(this,e,t,i),children:a};"function"==typeof e.onRenderDay&&(c=e.onRenderDay(c));var l=o.DOM.td,d=e.renderDay||l,h=d(c);return void 0===h&&(h=l(c)),h},getWeekDayNames:function(e){e=e||this.props;var t=e.weekDayNames,a=this.weekStartDay;if("function"==typeof t)t=t(a,e.locale);else if(Array.isArray(t)){t=[].concat(t);for(var n=a;n>0;)t.push(t.shift()),n--}return t},renderWeekDayNames:function(){var e=this.getWeekDayNames();return o.createElement("tr",{className:"dp-row dp-week-day-names"},e.map(function(e){return o.createElement("td",{key:e,className:"dp-cell dp-week-day-name"},e)}))},handleClick:function(e,t,a,r){e.minDate&&a<e.minDate||e.maxDate&&a>e.maxDate||(r.target.value=t,(e.onChange||n)(t,r))}});d.getHeaderText=function(e,t){return l(e,null,{locale:t.locale}).format("MMMM YYYY")},e.exports=d},function(e,t,a){"use strict";function n(){}var r,o=a(4),i=a(2),s=a(7),c=a(5),l=a(3),d=a(1),h=o.createClass({displayName:"YearView",getDefaultProps:function(){return c()},getMonthsInYear:function(e){for(var t=i(e).startOf("year"),a=[],n=0;12>n;n++)a.push(i(t)),t.add(1,"month");return a},render:function(){r=+i().startOf("day");var e=d({},this.props),t=e.viewMoment=i(this.props.viewDate);e.date&&(e.moment=i(e.date).startOf("month"));var a=this.getMonthsInYear(t);return o.createElement("table",{className:"dp-table dp-year-view"},o.createElement("tbody",null,this.renderMonths(e,a)))},renderMonths:function(e,t){for(var a=t.map(function(t){return this.renderMonth(e,t)},this),n=t.length,r=[],i=Math.ceil(n/4),s=0;i>s;s++)r.push(a.slice(4*s,4*(s+1)));return r.map(function(e,t){return o.createElement("tr",{key:"row"+t},e)})},renderMonth:function(e,t){var a=s.month(t,e.monthFormat),n=["dp-cell dp-month"],r=+t;return r==e.moment&&n.push("dp-value"),o.createElement("td",{key:a,className:n.join(" "),onClick:this.handleClick.bind(this,e,t)},a)},handleClick:function(e,t,a){a.target.value=t,(e.onSelect||n)(t,a)}});h.getHeaderText=function(e,t){return l(e,null,{locale:t.locale}).format("YYYY")},e.exports=h}])});

@@ -87,3 +87,3 @@ 'use strict'

<select value={LOCALE} onChange={this.onLocaleChange}>
<option value="en">English</option>
<option value="en">English (US)</option>
<option value="fr">French</option>

@@ -101,3 +101,3 @@ <option value="de">German</option>

xonViewChange={onViewChange}
xonViewDateChange={onViewDateChange}
onViewDateChange={onViewDateChange}
onRenderDay={renderDay}

@@ -107,3 +107,6 @@ weekStartDay={0}

todayText={today}
minDate='2013-04-04' maxDate='2015-10-10' date={v} onChange={this.onChange}/>
minDate='2013-04-04' maxDate='2015-10-10'
date={v}
defaultDate={v + 400000000}
xonChange={this.onChange}/>

@@ -110,0 +113,0 @@ <button onClick={clear}>clear</button>

@@ -70,3 +70,4 @@ 'use strict'

view: this.props.defaultView,
viewDate: this.props.defaultViewDate
viewDate: this.props.defaultViewDate,
defaultDate: this.props.defaultDate
}

@@ -122,3 +123,3 @@ },

date = date || this.viewMoment || this.props.date || new Date()
date = date || this.viewMoment || this.getDate() || new Date()

@@ -137,2 +138,14 @@ if (moment.isMoment(date)){

getDate: function() {
var date
if (this.props.date != null){
date = this.props.date
} else {
date = this.state.defaultDate
}
return date? this.toMoment(date): null
},
render: function() {

@@ -148,2 +161,4 @@

props.date = this.getDate()
props.viewDate = this.viewMoment = this.getViewDate()

@@ -415,2 +430,8 @@ props.locale = this.props.locale

if (this.props.date == null){
this.setState({
defaultDate: text
})
}
;(this.props.onChange || emptyFn)(text, date, event)

@@ -417,0 +438,0 @@ },

{
"name": "react-date-picker",
"version": "2.0.7",
"version": "2.0.8",
"description": "React Date Picker",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -87,3 +87,4 @@ react-date-picker

* hideFooter: Boolean - by default footer is shown, so specify this to true if you don't want the footer
* date : Date / String / Moment / Number
* date : Date / String / Moment / Number - for controlled behavior. Make sure you also specify an `onChange` prop
* defaultDate: Date / String / Moment / Number - for uncontrolled behavior
* `minDate` : Date / String / Moment / Number

@@ -90,0 +91,0 @@ * `maxDate` : Date / String / Moment / Number

@@ -70,3 +70,4 @@ 'use strict'

view: this.props.defaultView,
viewDate: this.props.defaultViewDate
viewDate: this.props.defaultViewDate,
defaultDate: this.props.defaultDate
}

@@ -122,3 +123,3 @@ },

date = date || this.viewMoment || this.props.date || new Date()
date = date || this.viewMoment || this.getDate() || new Date()

@@ -137,2 +138,14 @@ if (moment.isMoment(date)){

getDate: function() {
var date
if (this.props.date != null){
date = this.props.date
} else {
date = this.state.defaultDate
}
return date? this.toMoment(date): null
},
render: function() {

@@ -148,2 +161,4 @@

props.date = this.getDate()
props.viewDate = this.viewMoment = this.getViewDate()

@@ -415,2 +430,8 @@ props.locale = this.props.locale

if (this.props.date == null){
this.setState({
defaultDate: text
})
}
;(this.props.onChange || emptyFn)(text, date, event)

@@ -417,0 +438,0 @@ },

Sorry, the diff of this file is too big to display

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