Socket
Socket
Sign inDemoInstall

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.9 to 2.0.10

13

dist/react-date-picker.js

@@ -216,2 +216,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

var dateString = props.date.format(this.props.dateFormat)
props.viewDate = this.viewMoment = this.getViewDate()

@@ -234,2 +236,3 @@ props.locale = this.props.locale

viewProps.dateString = dateString
viewProps.localeData = props.localeData

@@ -710,6 +713,9 @@ viewProps.onSelect = this.handleSelect

var mom = this.toMoment(date)
var renderDayProps = {
key : dayText,
text : dayText,
date : date,
date : mom,
moment : mom,
className: classes.join(' '),

@@ -1303,3 +1309,6 @@ style : {},

//if the date property is given as string, it will be parsed using this format
dateFormat: 'YYYY-MM-DD'
dateFormat: 'YYYY-MM-DD',
onRenderDay: null,
renderDay: null,
}

@@ -1306,0 +1315,0 @@

@@ -216,2 +216,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

var dateString = props.date.format(this.props.dateFormat)
props.viewDate = this.viewMoment = this.getViewDate()

@@ -234,2 +236,3 @@ props.locale = this.props.locale

viewProps.dateString = dateString
viewProps.localeData = props.localeData

@@ -710,6 +713,9 @@ viewProps.onSelect = this.handleSelect

var mom = this.toMoment(date)
var renderDayProps = {
key : dayText,
text : dayText,
date : date,
date : mom,
moment : mom,
className: classes.join(' '),

@@ -1303,3 +1309,6 @@ style : {},

//if the date property is given as string, it will be parsed using this format
dateFormat: 'YYYY-MM-DD'
dateFormat: 'YYYY-MM-DD',
onRenderDay: null,
renderDay: null,
}

@@ -1306,0 +1315,0 @@

2

dist/react-date-picker.nomoment.min.js

@@ -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,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.bind(this,e)},n))}},gotoNow:function(){this.gotoDate(+new Date)},gotoSelected:function(e){this.gotoDate(e.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}])});
!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();var a=e.date.format(this.props.dateFormat);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 n=(this.props.className||"")+" date-picker";e.style=this.prepareStyle(e);var c=e,c=i(e);return c.dateString=a,c.localeData=e.localeData,c.onSelect=this.handleSelect,c.onChange=this.handleChange,r.createElement("div",r.__spread({className:n,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(c))),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.bind(this,e)},n))}},gotoNow:function(){this.gotoDate(+new Date)},gotoSelected:function(e){this.gotoDate(e.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",onRenderDay:null,renderDay:null}},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=this.toMoment(t),l={key:a,text:a,date:c,moment:c,className:n.join(" "),style:{},onClick:this.handleClick.bind(this,e,t,i),children:a};"function"==typeof e.onRenderDay&&(l=e.onRenderDay(l));var d=o.DOM.td,h=e.renderDay||d,u=h(l);return void 0===u&&(u=d(l)),u},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}])});

@@ -59,4 +59,5 @@ 'use strict'

props.className += ' aaa '
props.style = props.style || {}
props.style.color = 'red'
return props

@@ -63,0 +64,0 @@ }

@@ -48,3 +48,6 @@ 'use strict'

//if the date property is given as string, it will be parsed using this format
dateFormat: 'YYYY-MM-DD'
dateFormat: 'YYYY-MM-DD',
onRenderDay: null,
renderDay: null,
}

@@ -160,2 +160,4 @@ 'use strict'

var dateString = props.date.format(this.props.dateFormat)
props.viewDate = this.viewMoment = this.getViewDate()

@@ -178,2 +180,3 @@ props.locale = this.props.locale

viewProps.dateString = dateString
viewProps.localeData = props.localeData

@@ -180,0 +183,0 @@ viewProps.onSelect = this.handleSelect

@@ -176,6 +176,9 @@ 'use strict'

var mom = this.toMoment(date)
var renderDayProps = {
key : dayText,
text : dayText,
date : date,
date : mom,
moment : mom,
className: classes.join(' '),

@@ -182,0 +185,0 @@ style : {},

{
"name": "react-date-picker",
"version": "2.0.9",
"version": "2.0.10",
"description": "React Date Picker",

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

@@ -48,3 +48,6 @@ 'use strict'

//if the date property is given as string, it will be parsed using this format
dateFormat: 'YYYY-MM-DD'
dateFormat: 'YYYY-MM-DD',
onRenderDay: null,
renderDay: null,
}

@@ -160,2 +160,4 @@ 'use strict'

var dateString = props.date.format(this.props.dateFormat)
props.viewDate = this.viewMoment = this.getViewDate()

@@ -178,2 +180,3 @@ props.locale = this.props.locale

viewProps.dateString = dateString
viewProps.localeData = props.localeData

@@ -180,0 +183,0 @@ viewProps.onSelect = this.handleSelect

@@ -176,6 +176,9 @@ 'use strict'

var mom = this.toMoment(date)
var renderDayProps = {
key : dayText,
text : dayText,
date : date,
date : mom,
moment : mom,
className: classes.join(' '),

@@ -182,0 +185,0 @@ style : {},

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